]> git.lyx.org Git - features.git/commitdiff
This commit terminates the great InsetCollapsable shrink party
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 21:14:39 +0000 (21:14 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 21:14:39 +0000 (21:14 +0000)
 * 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
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetLayout.h
src/insets/InsetText.cpp
src/insets/InsetText.h

index aa060081efc43a2cbe7e5aaed85f9c99af149459..58be78c951fe5870ce1b338fd556f1e821d13900 100644 (file)
@@ -173,7 +173,7 @@ bool Inset::allowEmpty() const
 
 bool Inset::forceLTR() const
 {
-       return getLayout().isForceLtr();
+       return getLayout().forceLTR();
 }
 
 void Inset::initView()
index 42f2af592d546f32bf37d8853e9a4fa13dd937cb..f171be57bce70d69eb05fb0aaf902358974d5c0e 100644 (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
index f7ed19e6b9dd84a78bb50cd70dda8c91fd42fb03..d692ce91c984684c3ed0c11d9d1275b2da58d8e1 100644 (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;
index b7a109eaf4ed1c8c28c6b9fc840194e56a7e8063..b37a0f97b9163c4c03f5e886b3b1705e437bdf5e 100644 (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:
index a2f75424fcd0d9fca83af8e92ed60526b41d459e..8206bd6f2529fdac86cc7151b707341718cf2d3d 100644 (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,16 +467,32 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
 
 docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
 {
-       xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
-       return docstring();
-}
+       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());
 
-void InsetText::validate(LaTeXFeatures & features) const
-{
-       features.useInsetLayout(getLayout());
-       for_each(paragraphs().begin(), paragraphs().end(),
-                bind(&Paragraph::validate, _1, ref(features)));
+       xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
+
+       if (innertag_opened)
+               html::closeTag(os, il.htmlinnertag());
+       if (opened)
+               html::closeTag(os, il.htmltag());
+       return docstring();
 }
 
 
@@ -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;
index b0897ea394a9af465687b7f6b68cee3a4953151b..399d48db5000c3cdf97f63a48c5094212e395f15 100644 (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 &);
        ///