From f2cd36e8ad344700f5bdb6457fdb7220b3904176 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 19 Mar 2008 16:21:33 +0000 Subject: [PATCH] Change the signature of forceEmptyLayout(), so that we can pass a cell index with it. We'll need this to get tables right. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23829 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 3 +++ src/Paragraph.cpp | 19 ++++++++++++++----- src/insets/Inset.h | 4 ++-- src/insets/InsetBox.cpp | 2 +- src/insets/InsetBox.h | 7 ++++--- src/insets/InsetCaption.h | 4 ++-- src/insets/InsetERT.h | 4 ++-- src/insets/InsetFlex.h | 2 +- src/insets/InsetTabular.cpp | 6 ++++++ src/insets/InsetTabular.h | 4 +++- 10 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index eca22404b2..4d763e7c31 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -912,6 +912,9 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) break; case LFUN_LAYOUT: + flag.enabled(!cur.inset().forceEmptyLayout(cur.idx())); + break; + case LFUN_LAYOUT_PARAGRAPH: flag.enabled(cur.inset().allowParagraphCustomization(cur.idx())); break; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index c81e472cdc..18b73346b9 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1619,22 +1619,31 @@ void Paragraph::setBeginOfBody() bool Paragraph::forceEmptyLayout() const { Inset const * const inset = inInset(); - return inset && inInset()->forceEmptyLayout(); + if (!inset) + return true; + // FIXME At present, this is wrong for table cells + return inset->forceEmptyLayout(); } bool Paragraph::allowParagraphCustomization() const { - return inInset() && inInset()->allowParagraphCustomization(0); + Inset const * const inset = inInset(); + if (!inset) + return true; + // FIXME At present, this is wrong for table cells + return inset->allowParagraphCustomization(); } namespace { + // FIXME // This is a hack based upon one in InsetText::neverIndent(). // When we have a real InsetTableCell, then we won't need this // method, because InsetTableCell will return the right values, - // viz: InsetTableCell::useEmptyLayout() should return true, but - // InsetTableCell::forceEmptyLayout() should still return false. + // viz: InsetTableCell::useEmptyLayout() should return true, and + // InsetTableCell::forceEmptyLayout() should still return true + // unless the width has been set. // // The #include "insets/InsetText.h" can also be removed then. bool inTableCell(Inset const * inset) @@ -1651,7 +1660,7 @@ bool Paragraph::useEmptyLayout() const { Inset const * const inset = inInset(); return inset && - (inTableCell(inset) || inInset()->useEmptyLayout()); + (inTableCell(inset) || inset->useEmptyLayout()); } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index d489a05091..a5fe6e6b6b 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -350,10 +350,10 @@ public: virtual bool useEmptyLayout() const { return forceEmptyLayout(); } /// if this inset has paragraphs should they be forced to use the /// empty layout? - virtual bool forceEmptyLayout() const { return false; } + virtual bool forceEmptyLayout(idx_type = 0) const { return false; } /// if this inset has paragraphs should the user be allowed to /// customize alignment, etc? - virtual bool allowParagraphCustomization(idx_type) const { return true; } + virtual bool allowParagraphCustomization(idx_type = 0) const { return true; } /// Is the width forced to some value? virtual bool hasFixedWidth() const { return false; } diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index ec99e94b59..3510109515 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -167,7 +167,7 @@ void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const } -bool InsetBox::forceEmptyLayout() const +bool InsetBox::forceEmptyLayout(idx_type) const { return !params_.inner_box; } diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index f9ab46c67d..4f207c28a8 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -94,10 +94,11 @@ private: bool showInsetDialog(BufferView * bv) const; /// DisplayType display() const { return Inline; } - //FIXME Is this the one we want? or is it: - //allowParagraphCustomization(idx_type)? /// - bool forceEmptyLayout() const; + virtual bool allowParagraphCustomization(idx_type = 0) + { return forceEmptyLayout(); } + /// + virtual bool forceEmptyLayout(idx_type = 0) const; /// bool neverIndent() const { return true; } /// diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index 669b979f6f..f158e4a357 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -71,9 +71,9 @@ private: /// void addToToc(ParConstIterator const &) const; /// - bool forceEmptyLayout() const { return true; } + virtual bool forceEmptyLayout(idx_type = 0) const { return true; } /// Captions don't accept alignment, spacing, etc. - bool allowParagraphCustomization(idx_type) const { return false; } + virtual bool allowParagraphCustomization(idx_type = 0) const { return false; } /// Inset * clone() const { return new InsetCaption(*this); } diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index 6004792859..52542beb01 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -60,9 +60,9 @@ private: /// bool showInsetDialog(BufferView *) const; /// - bool forceEmptyLayout() const { return true; } + virtual bool forceEmptyLayout(idx_type = 0) const { return true; } /// - bool allowParagraphCustomization(idx_type) const { return false; } + virtual bool allowParagraphCustomization(idx_type = 0) const { return false; } /// should paragraph indendation be omitted in any case? bool neverIndent() const { return true; } /// diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index eb827f8bd7..5546acf215 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -37,7 +37,7 @@ public: /// void read(Lexer & lex); /// - virtual bool allowParagraphCustomization(idx_type) const { return false; } + virtual bool allowParagraphCustomization(idx_type = 0) const { return false; } /// int plaintext(odocstream &, OutputParams const &) const; diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 3f8f2421f7..6a5ae84361 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -4686,6 +4686,12 @@ bool InsetTabular::allowParagraphCustomization(idx_type cell) const } +bool InsetTabular::forceEmptyLayout(idx_type cell) const +{ + return !tabular.getPWidth(cell).zero(); +} + + bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf, bool usePaste) { diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index cc47402737..777dbed7d9 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -738,7 +738,9 @@ public: /// should all paragraphs be output with "Standard" layout? virtual bool allowParagraphCustomization(idx_type cell = 0) const; /// - virtual bool forceEmptyLayout() { return true; } + virtual bool forceEmptyLayout(idx_type cell = 0) const; + /// + virtual bool useEmptyLayout() { return true; } /// void addPreview(graphics::PreviewLoader &) const; -- 2.39.2