]> git.lyx.org Git - features.git/commitdiff
Manage the initial setting of Default or Plain Layout more simply.
authorRichard Heck <rgheck@comcast.net>
Sat, 4 Apr 2009 19:34:14 +0000 (19:34 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 4 Apr 2009 19:34:14 +0000 (19:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29093 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetBranch.cpp
src/insets/InsetCaption.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetTabular.cpp
src/insets/InsetText.cpp
src/insets/InsetText.h

index 45e4ebe72f9b813efb2f05d9b09d9cc3cf8523b5..fb599edbc5ba446d6a1f767a42251d7d06c61d25 100644 (file)
@@ -40,13 +40,8 @@ using namespace std;
 namespace lyx {
 
 InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params)
-       : InsetCollapsable(buf), params_(params)
-{
-       // override the default for InsetCollapsable, which is to
-       // use the plain layout.
-       DocumentClass const & dc = buf.params().documentClass();
-       paragraphs().back().setDefaultLayout(dc);
-}
+       : InsetCollapsable(buf, InsetText::DefaultLayout), params_(params)
+{}
 
 
 InsetBranch::~InsetBranch()
index e66b728d4ecd4c2bd927fe96f0ec2eee4994db2e..a846fc9159360d9155da2752c1f41f2f9b980dbb 100644 (file)
@@ -48,13 +48,11 @@ namespace lyx {
 
 
 InsetCaption::InsetCaption(Buffer const & buf)
-       : InsetText(buf)
+       : InsetText(buf, InsetText::PlainLayout)
 {
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color_captionframe);
-       // caption insets should use the plain layout
-       paragraphs().back().setPlainLayout(buf.params().documentClass());
 }
 
 
index 24065cd9fcf541d8c4ffa15c05f48176cc20d576..e2fbb3600c66adaaa727b7657a27fc84400f94ac 100644 (file)
@@ -102,16 +102,14 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const
 }
 
 
-InsetCollapsable::InsetCollapsable(Buffer const & buf)
-       : InsetText(buf), status_(Inset::Open),
+InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype)
+       : InsetText(buf, ltype), status_(Inset::Open),
          openinlined_(false), mouse_hover_(false)
 {
-       DocumentClass const & dc = buf.params().documentClass();
-       setLayout(&dc);
+       setLayout(&buf.params().documentClass());
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color_collapsableframe);
-       paragraphs().back().setPlainLayout(dc); 
 }
 
 
index 22c062e69cbb8910cf1845a45e0a32662006c37f..9b4e9b02bfe800c189c2a3ca46ab73ec583d619a 100644 (file)
@@ -32,11 +32,8 @@ namespace frontend { class Painter; }
 */
 class InsetCollapsable : public InsetText {
 public:
-       ///     By default, InsetCollapsable uses the plain layout. If you 
-       /// want to override this in a subclass, you'll need to call 
-       /// Paragraph::setDefaultLayout() in its constructor. See
-       /// InsetBranch for an example.
-       InsetCollapsable(Buffer const &);
+       ///
+       InsetCollapsable(Buffer const &, InsetText::UsePlain = InsetText::PlainLayout);
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
        ///
index 373cd35758efedbd21da31723aa51722ef46e038..427e7020b6171dc42960b9979f771395fb75ebef 100644 (file)
@@ -490,7 +490,6 @@ Tabular::CellData::CellData(Buffer & buf)
          inset(new InsetTableCell(buf))
 {
        inset->setBuffer(const_cast<Buffer &>(buf));
-       inset->paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
 }
 
 
@@ -2841,7 +2840,7 @@ Tabular::BoxType Tabular::useParbox(idx_type cell) const
 /////////////////////////////////////////////////////////////////////
 
 InsetTableCell::InsetTableCell(Buffer & buf)
-       : InsetText(buf), isFixedWidth(false),
+       : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
          contentAlign(LYX_ALIGN_CENTER)
 {}
 
index 1d843502ce4e4f718ba890ae4ae7d1402578060c..0232078b7ef66d0e6f765f9ebc745293528e768f 100644 (file)
@@ -71,11 +71,11 @@ using graphics::PreviewLoader;
 
 /////////////////////////////////////////////////////////////////////
 
-InsetText::InsetText(Buffer const & buf)
+InsetText::InsetText(Buffer const & buf, UsePlain type)
        : drawFrame_(false), frame_color_(Color_insetframe)
 {
        setBuffer(const_cast<Buffer &>(buf));
-       initParagraphs();
+       initParagraphs(type);
 }
 
 
@@ -99,13 +99,17 @@ void InsetText::setBuffer(Buffer & buf)
 }
 
 
-void InsetText::initParagraphs()
+void InsetText::initParagraphs(UsePlain type)
 {
        LASSERT(paragraphs().empty(), /**/);
        paragraphs().push_back(Paragraph());
        Paragraph & ourpar = paragraphs().back();
        ourpar.setInsetOwner(this);
-       ourpar.setDefaultLayout(buffer_->params().documentClass());
+       DocumentClass const & dc = buffer_->params().documentClass();
+       if (type == DefaultLayout)
+               ourpar.setDefaultLayout(dc);
+       else
+               ourpar.setPlainLayout(dc);
 }
 
 
index aabe82ede70fae9630782d28b75b622b44954bc8..90d246719ccc7410788d21e8fe365a44915e4d37 100644 (file)
@@ -34,8 +34,15 @@ class InsetTabular;
  */
 class InsetText : public Inset {
 public:
-       ///
-       explicit InsetText(Buffer const & buffer);
+       enum UsePlain {
+               DefaultLayout,
+               PlainLayout
+       };
+       /// \param buffer
+       /// \param useplain whether to use the plain layout
+       /// This is needed because we cannot call the virtual function
+       /// usePlainLayout() from within the constructor.
+       explicit InsetText(Buffer const & buffer, UsePlain type = DefaultLayout);
        ///
        InsetText(InsetText const &);
        ///
@@ -169,7 +176,7 @@ public:
        void doDispatch(Cursor & cur, FuncRequest & cmd);
 private:
        ///
-       void initParagraphs();
+       void initParagraphs(UsePlain type);
        ///
        void setParagraphOwner();
        ///