]> git.lyx.org Git - lyx.git/commitdiff
Change the signature of forceEmptyLayout(), so that we can pass a cell index with...
authorRichard Heck <rgheck@comcast.net>
Wed, 19 Mar 2008 16:21:33 +0000 (16:21 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 19 Mar 2008 16:21:33 +0000 (16:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23829 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/Paragraph.cpp
src/insets/Inset.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetCaption.h
src/insets/InsetERT.h
src/insets/InsetFlex.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h

index eca22404b2de20d0b7ea5826e8f03c1ddb483b4e..4d763e7c319f3947d30820b25975f276471f7c99 100644 (file)
@@ -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;
index c81e472cdca7fa7648b027f616105b52f6b1a60f..18b73346b99ec300d158ba9af4b940d90d97a503 100644 (file)
@@ -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());
 }
 
 
index d489a050910f1e47938779e065742d5bb733dc5b..a5fe6e6b6b2aaa964010414e6c1898b997fb00eb 100644 (file)
@@ -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; }
 
index ec99e94b59ab7c24f94bd60513a549c72482d568..3510109515217106e1115f649553ce4cdb9744d5 100644 (file)
@@ -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;
 }
index f9ab46c67deb1bedfceb4889053164e319ab5be3..4f207c28a832dbcb370ab9bc3afb1f932081285c 100644 (file)
@@ -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; }
        ///
index 669b979f6f8e69c978b803bebc090c9de97d0aa7..f158e4a3577cdd435d416c0d0ce4e22e0fd16e31 100644 (file)
@@ -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); }
 
index 6004792859d1489bb87af0e7a5287fceef9a358d..52542beb01ecdfa23964c7fab126f1d412cdeff0 100644 (file)
@@ -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; }
        ///
index eb827f8bd7cb6c0ca89b073345b33f187ce422a3..5546acf215991b64e2d80ca1be69d2502e29adc3 100644 (file)
@@ -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;
index 3f8f2421f7178eea7f25c648b00c9663d94eedc2..6a5ae84361a2a83e7f7cd5ae3df39d78bf3c73d4 100644 (file)
@@ -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)
 {
index cc474027379ef9ac36fccf7873b2c375e760824b..777dbed7d9a91b7856d95455f48f0292b3fbb97f 100644 (file)
@@ -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;