From 7a5576c13b6d19df50583ad650d19d89e07c4179 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 11 Mar 2008 15:16:58 +0000 Subject: [PATCH] Try again to fix bug 2178. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23662 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 25 +++++++++++++++++++++++-- src/insets/InsetText.cpp | 9 ++++++++- src/insets/InsetText.h | 2 ++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index e26f70f4bc..d4f5d0dc1a 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -48,6 +48,8 @@ #include "insets/InsetBibitem.h" #include "insets/InsetLabel.h" +// needed only for inTableCell() +#include "insets/InsetText.h" #include "support/convert.h" #include "support/debug.h" @@ -1614,9 +1616,26 @@ void Paragraph::setBeginOfBody() } +namespace { + // 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. + // The #include "insets/InsetText.h" can also be removed then. + bool inTableCell(Inset const * inset) + { + InsetText const * txt = inset->asInsetText(); + if (!txt) + return false; + return txt->isTableCell(); + } +} + + bool Paragraph::forceEmptyLayout() const { - return inInset() && inInset()->forceEmptyLayout(); + Inset * inset = inInset(); + return inset && + (inTableCell(inset) || inInset()->forceEmptyLayout()); } @@ -1628,7 +1647,9 @@ bool Paragraph::allowParagraphCustomization() const bool Paragraph::useEmptyLayout() const { - return inInset() && inInset()->useEmptyLayout(); + Inset * inset = inInset(); + return inset && + (inTableCell(inset) || inInset()->useEmptyLayout()); } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 65f62c675e..ee7b3a299e 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -445,13 +445,20 @@ 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 +bool InsetText::isTableCell() const { // this is only true for tabular cells return !text_.isMainText(buffer()) && lyxCode() == TEXT_CODE; } + +bool InsetText::neverIndent() const +{ + return isTableCell(); +} + + ParagraphList const & InsetText::paragraphs() const { return text_.paragraphs(); diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 5549b24a95..ffd4bad18c 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -128,6 +128,8 @@ public: bool insetAllowed(InsetCode) const { return true; } /// bool allowSpellCheck() const { return true; } + /// + bool isTableCell() const; /// should paragraph indendation be ommitted in any case? bool neverIndent() const; /// -- 2.39.2