From 3382c78af9e19dae30e40023f14623e88ca9b5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 10 Sep 2005 06:51:58 +0000 Subject: [PATCH] implement and use virtual bool neverIndent() (thereby fixing bug 2003) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10436 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/insets/ChangeLog | 10 ++++++++++ src/insets/insetbase.h | 2 ++ src/insets/insetcharstyle.h | 3 +++ src/insets/insetert.h | 2 ++ src/insets/insetoptarg.h | 3 +++ src/insets/insettext.C | 9 +++++++++ src/insets/insettext.h | 2 ++ src/text.C | 6 ++---- 9 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 65e6370a5c..a6dc33087e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2005-08-10 Jürgen Spitzmüller + + * text.C (leftMargin): test for insetbase's new neverIndent() + bool instead of listing each and every inset that does not + wish par indendation. + 2005-09-09 Jean-Marc Lasgouttes * buffer_funcs.C (setCounter): put the code to compute enum label diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 394b58ebcc..289c649678 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2005-08-10 Jürgen Spitzmüller + + * insetbase.[Ch]: new bool neverIndent() which indicates if + an inset does not want paragraph indentation at all. + * insetcharstyle.h: + * insetert.h: + * insetoptarg.h: return true for neverIndent() + * insettext.[Ch]: return true for neverIndent() in case + of tabular cells (based on a crude guess). + 2005-09-09 Georg Baum * insetline.C: Add forgotten include diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 37c0e6cb42..56ba494099 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -338,6 +338,8 @@ public: virtual bool display() const { return false; } /// should we break lines after this inset? virtual bool isLineSeparator() const { return false; } + /// should paragraph indendation be ommitted in any case? + virtual bool neverIndent() const { return false; } /// dumps content to lyxerr virtual void dump() const; /// write inset in .lyx format diff --git a/src/insets/insetcharstyle.h b/src/insets/insetcharstyle.h index 3b2453e4bd..079a5c43c6 100644 --- a/src/insets/insetcharstyle.h +++ b/src/insets/insetcharstyle.h @@ -86,6 +86,9 @@ public: /// InsetCharStyleParams const & params() const { return params_; } + /// should paragraph indendation be ommitted in any case? + bool neverIndent() const { return true; } + protected: InsetCharStyle(InsetCharStyle const &); virtual void doDispatch(LCursor & cur, FuncRequest & cmd); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 0252453d10..7c1b680dae 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -68,6 +68,8 @@ public: void getDrawFont(LyXFont &) const; /// bool forceDefaultParagraphs(InsetBase const *) const { return true; } + /// should paragraph indendation be ommitted in any case? + bool neverIndent() const { return true; } protected: InsetERT(InsetERT const &); /// diff --git a/src/insets/insetoptarg.h b/src/insets/insetoptarg.h index 8030e2dbd5..5521a56f4f 100644 --- a/src/insets/insetoptarg.h +++ b/src/insets/insetoptarg.h @@ -48,6 +48,9 @@ public: OutputParams const &) const; /// Write out tothe .lyx file void write(Buffer const & buf, std::ostream & os) const; + + /// should paragraph indendation be ommitted in any case? + virtual bool neverIndent() const { return true; } protected: InsetOptArg(InsetOptArg const &); private: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 8bc16c1b85..8e894d5d63 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -442,6 +442,15 @@ void InsetText::addPreview(PreviewLoader & loader) const } +//FIXME: instead of this hack, which only works by chance, +// cells should have their own insetcell type, which returns CELL_CODE! +bool InsetText::neverIndent() const +{ + // this is only true for tabular cells + return !text_.isMainText() && lyxCode() == TEXT_CODE; +} + + ParagraphList const & InsetText::paragraphs() const { return text_.paragraphs(); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 0914da33a2..11cd54be75 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -139,6 +139,8 @@ public: bool insetAllowed(Code) const { return true; } /// bool allowSpellCheck() const { return true; } + /// should paragraph indendation be ommitted in any case? + bool neverIndent() const; /// InsetText(InsetText const &); diff --git a/src/text.C b/src/text.C index fa9ab877ad..887bc58e3a 100644 --- a/src/text.C +++ b/src/text.C @@ -591,14 +591,12 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const && !isFirstInSequence(pit, pars_))) && align == LYX_ALIGN_BLOCK && !par.params().noindent() + // in some insets, paragraphs are never indented + && !par.inInset()->neverIndent() // display style insets are always centered, omit indentation && !(!par.empty() && par.isInset(pos) && par.getInset(pos)->display()) - // in charstyles, tabulars and ert paragraphs are never indented! - && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText()) - && par.ownerCode() != InsetBase::ERT_CODE - && par.ownerCode() != InsetBase::CHARSTYLE_CODE) && (par.layout() != tclass.defaultLayout() || bv()->buffer()->params().paragraph_separation == BufferParams::PARSEP_INDENT))