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
This commit is contained in:
Richard Heck 2008-03-19 16:21:33 +00:00
parent 51ac7d895c
commit f2cd36e8ad
10 changed files with 38 additions and 17 deletions

View 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;

View 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());
}

View 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; }

View 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;
}

View 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; }
///

View 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); }

View 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; }
///

View 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;

View 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)
{

View 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;