This commit terminates the great InsetCollapsable shrink party

* rename InsetLayout::isForceLtr to forceLTR
 * move InsetCollapsable::xhtml to InsetText
 * move InsetCollapsable::tocString to InsetText.
 * move forcePlainLayout and allowParagraphCustomization from IC to IT
 * use isPassThru instead of forceLTR in places where it seems to make 
   sense (was introduced in r21285)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30591 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-07-14 21:14:39 +00:00
parent 3dad722072
commit 0585f2b2b4
6 changed files with 55 additions and 63 deletions

View File

@ -173,7 +173,7 @@ bool Inset::allowEmpty() const
bool Inset::forceLTR() const
{
return getLayout().isForceLtr();
return getLayout().forceLTR();
}
void Inset::initView()

View File

@ -616,33 +616,6 @@ InsetLayout::InsetDecoration InsetCollapsable::decoration() const
}
docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
{
InsetLayout const & il = getLayout();
if (undefined())
return InsetText::xhtml(os, runparams);
bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
if (!il.counter().empty()) {
BufferParams const & bp = buffer().masterBuffer()->params();
Counters & cntrs = bp.documentClass().counters();
cntrs.step(il.counter());
// FIXME: translate to paragraph language
if (!il.htmllabel().empty())
os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
}
bool innertag_opened = false;
if (!il.htmlinnertag().empty())
innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
docstring deferred = InsetText::xhtml(os, runparams);
if (innertag_opened)
html::closeTag(os, il.htmlinnertag());
if (opened)
html::closeTag(os, il.htmltag());
return deferred;
}
docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
int y) const
{
@ -659,12 +632,4 @@ docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
return InsetText::contextMenu(bv, x, y);
}
void InsetCollapsable::tocString(odocstream & os) const
{
if (!getLayout().isInToc())
return;
os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
}
} // namespace lyx

View File

@ -125,17 +125,11 @@ public:
ColorCode backgroundColor() const { return getLayout().bgcolor(); }
///
ColorCode labelColor() const { return getLayout().labelfont().color(); }
/// It will rarely be right to call this from subclasses, due
/// to the fact that it steps counters, etc. Instead, call
/// InsetText::xhtml().
docstring xhtml(odocstream &, OutputParams const &) const;
///
InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
///
virtual bool usePlainLayout() const { return true; }
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
protected:
@ -154,12 +148,6 @@ private:
///
Dimension dimensionCollapsed(BufferView const & bv) const;
///
/// should paragraphs be forced to use the empty layout?
virtual bool forcePlainLayout(idx_type = 0) const
{ return getLayout().forcePlainLayout(); }
/// should the user be allowed to customize alignment, etc.?
virtual bool allowParagraphCustomization(idx_type = 0) const
{ return getLayout().allowParagraphCustomization(); }
docstring labelstring_;
///
mutable Box button_dim;

View File

@ -111,7 +111,7 @@ public:
///
bool isKeepEmpty() const { return keepempty_; };
///
bool isForceLtr() const { return forceltr_; };
bool forceLTR() const { return forceltr_; };
///
bool isInToc() const { return intoc_; };
private:

View File

@ -269,9 +269,7 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd)
LYXERR(Debug::ACTION, "InsetText::doDispatch()"
<< " [ cmd.action = " << cmd.action << ']');
// FIXME this use of forceLTR is dubious
// introduced in http://www.lyx.org/trac/changeset/21285
if (forceLTR()) {
if (getLayout().isPassThru()) {
// Force any new text to latex_language FIXME: This
// should only be necessary in constructor, but new
// paragraphs that are created by pressing enter at
@ -334,9 +332,8 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd,
void InsetText::fixParagraphsFont()
{
Font font(inherit_font, buffer().params().language);
if (getLayout().isForceLtr())
font.setLanguage(latex_language);
if (getLayout().isPassThru()) {
font.setLanguage(latex_language);
ParagraphList::iterator par = paragraphs().begin();
ParagraphList::iterator const end = paragraphs().end();
while (par != end) {
@ -370,6 +367,14 @@ void InsetText::rejectChanges()
}
void InsetText::validate(LaTeXFeatures & features) const
{
features.useInsetLayout(getLayout());
for_each(paragraphs().begin(), paragraphs().end(),
bind(&Paragraph::validate, _1, ref(features)));
}
int InsetText::latex(odocstream & os, OutputParams const & runparams) const
{
// This implements the standard way of handling the LaTeX
@ -462,19 +467,35 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
{
InsetLayout const & il = getLayout();
if (undefined()) {
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
return docstring();
}
bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
if (!il.counter().empty()) {
BufferParams const & bp = buffer().masterBuffer()->params();
Counters & cntrs = bp.documentClass().counters();
cntrs.step(il.counter());
// FIXME: translate to paragraph language
if (!il.htmllabel().empty())
os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
}
bool innertag_opened = false;
if (!il.htmlinnertag().empty())
innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
if (innertag_opened)
html::closeTag(os, il.htmlinnertag());
if (opened)
html::closeTag(os, il.htmltag());
return docstring();
}
void InsetText::validate(LaTeXFeatures & features) const
{
features.useInsetLayout(getLayout());
for_each(paragraphs().begin(), paragraphs().end(),
bind(&Paragraph::validate, _1, ref(features)));
}
void InsetText::cursorPos(BufferView const & bv,
CursorSlice const & sl, bool boundary, int & x, int & y) const
{
@ -599,6 +620,15 @@ void InsetText::updateLabels(ParIterator const & it)
}
void InsetText::tocString(odocstream & os) const
{
if (!getLayout().isInToc())
return;
os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
}
void InsetText::addToToc(DocIterator const & cdit)
{
DocIterator dit = cdit;

View File

@ -139,14 +139,23 @@ public:
///
bool insetAllowed(InsetCode) const { return true; }
/// Allow spellchecking, except for insets with latex_language
bool allowSpellCheck() const { return !forceLTR(); }
bool allowSpellCheck() const { return !getLayout().isPassThru(); }
///
virtual bool isMacroScope() const { return false; }
///
virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
///
/// should paragraphs be forced to use the empty layout?
virtual bool forcePlainLayout(idx_type = 0) const
{ return getLayout().forcePlainLayout(); }
/// should the user be allowed to customize alignment, etc.?
virtual bool allowParagraphCustomization(idx_type = 0) const
{ return getLayout().allowParagraphCustomization(); }
/// Update the counters of this inset and of its contents
virtual void updateLabels(ParIterator const &);
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///
void addToToc(DocIterator const &);
///