From 0585f2b2b4be956c8eef2e57dda4d6205d711f8f Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 21:14:39 +0000 Subject: [PATCH] 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 --- src/insets/Inset.cpp | 2 +- src/insets/InsetCollapsable.cpp | 35 --------------------- src/insets/InsetCollapsable.h | 12 ------- src/insets/InsetLayout.h | 2 +- src/insets/InsetText.cpp | 56 +++++++++++++++++++++++++-------- src/insets/InsetText.h | 11 ++++++- 6 files changed, 55 insertions(+), 63 deletions(-) diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index aa060081ef..58be78c951 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -173,7 +173,7 @@ bool Inset::allowEmpty() const bool Inset::forceLTR() const { - return getLayout().isForceLtr(); + return getLayout().forceLTR(); } void Inset::initView() diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 42f2af592d..f171be57bc 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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 diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index f7ed19e6b9..d692ce91c9 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -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; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index b7a109eaf4..b37a0f97b9 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -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: diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index a2f75424fc..8206bd6f25 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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; diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index b0897ea394..399d48db50 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -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 &); ///