This is a conservative fix for the layout setting bug discussed in

this thread:
  http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg145547.html
The more dramatic fix suggested there can wait.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27164 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-10-28 14:11:24 +00:00
parent 0b0f0942c0
commit f771d9a994
8 changed files with 33 additions and 12 deletions

View File

@ -2457,12 +2457,24 @@ void Paragraph::setLayout(Layout const & layout)
}
void Paragraph::setDefaultLayout(DocumentClass const & tc)
{
setLayout(tc.defaultLayout());
}
void Paragraph::setPlainLayout(DocumentClass const & tc)
{
setLayout(tc.plainLayout());
}
void Paragraph::setPlainOrDefaultLayout(DocumentClass const & tclass)
{
if (usePlainLayout())
setLayout(tclass.plainLayout());
setPlainLayout(tclass);
else
setLayout(tclass.defaultLayout());
setDefaultLayout(tclass);
}

View File

@ -179,6 +179,10 @@ public:
void setLayout(Layout const & layout);
///
void setPlainOrDefaultLayout(DocumentClass const & tc);
///
void setDefaultLayout(DocumentClass const & tc);
///
void setPlainLayout(DocumentClass const & tc);
/// This is the item depth, only used by enumerate and itemize
signed char itemdepth;

View File

@ -97,10 +97,7 @@ BoxTranslatorLoc const & boxtranslator_loc()
InsetBox::InsetBox(Buffer const & buffer, string const & label)
: InsetCollapsable(buffer), params_(label)
{
if (forcePlainLayout())
paragraphs().back().setLayout(buffer.params().documentClass().plainLayout());
}
{}
InsetBox::~InsetBox()

View File

@ -41,7 +41,12 @@ 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);
}
InsetBranch::~InsetBranch()

View File

@ -53,8 +53,8 @@ InsetCaption::InsetCaption(Buffer const & buf)
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_captionframe);
// There will always be only one
paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
// caption insets should use the plain layout
paragraphs().back().setPlainLayout(buf.params().documentClass());
}

View File

@ -85,7 +85,7 @@ InsetCollapsable::InsetCollapsable(Buffer const & buf)
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
paragraphs().back().setLayout(dc.plainLayout());
paragraphs().back().setPlainLayout(dc);
}

View File

@ -32,7 +32,10 @@ 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(InsetCollapsable const & rhs);

View File

@ -105,7 +105,7 @@ void InsetText::initParagraphs()
paragraphs().push_back(Paragraph());
Paragraph & ourpar = paragraphs().back();
ourpar.setInsetOwner(this);
ourpar.setPlainOrDefaultLayout(buffer_->params().documentClass());
ourpar.setDefaultLayout(buffer_->params().documentClass());
}