]> git.lyx.org Git - features.git/commitdiff
Factor common code from TOC updates.
authorRichard Heck <rgheck@lyx.org>
Wed, 27 Mar 2013 21:16:34 +0000 (17:16 -0400)
committerRichard Heck <rgheck@lyx.org>
Wed, 27 Mar 2013 21:16:34 +0000 (17:16 -0400)
src/insets/InsetTOC.cpp
src/insets/InsetTOC.h

index 700680d1a5ea27b351f4e84c9419d063622bbe1c..6ed1fa91e94c534d81b5a730053ffaff84c38f26 100644 (file)
@@ -128,6 +128,35 @@ int InsetTOC::docbook(odocstream & os, OutputParams const &) const
 }
 
 
+void InsetTOC::makeTOCEntry(XHTMLStream & xs, 
+               Paragraph const & par, OutputParams const & op) const
+{
+       string const attr = "href='#" + par.magicLabel() + "' class='tocentry'";
+       xs << html::StartTag("a", attr);
+
+       // First the label, if there is one
+       docstring const & label = par.params().labelString();
+       if (!label.empty())
+               xs << label << " ";
+       // Now the content of the TOC entry, taken from the paragraph itself
+       OutputParams ours = op;
+       ours.for_toc = true;
+       Font const dummy;
+       par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
+
+       xs << html::EndTag("a") << " ";
+
+       // Now a link to the paragraph
+       string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
+       xs << html::StartTag("a", parattr);
+       // FIXME XHTML 
+       // There ought to be a simple way to customize this.
+       // Maybe if we had an InsetLayout for TOC...
+       xs << XHTMLStream::ESCAPE_NONE << "&gt;";
+       xs << html::EndTag("a");                
+}
+
+
 void InsetTOC::makeTOCWithDepth(XHTMLStream xs, 
                Toc toc, OutputParams const & op) const
 {
@@ -179,30 +208,7 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream xs,
                
                // Now output TOC info for this entry
                Paragraph const & par = it->dit().innerParagraph();
-
-               string const attr = "href='#" + par.magicLabel() + "' class='tocentry'";
-               xs << html::StartTag("a", attr);
-
-               // First the label, if there is one
-               docstring const & label = par.params().labelString();
-               if (!label.empty())
-                       xs << label << " ";
-               // Now the content of the TOC entry, taken from the paragraph itself
-               OutputParams ours = op;
-               ours.for_toc = true;
-               Font const dummy;
-               par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
-
-               xs << html::EndTag("a") << " ";
-
-               // Now a link to that paragraph
-               string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
-               xs << html::StartTag("a", parattr);
-               // FIXME XHTML 
-               // There ought to be a simple way to customize this.
-               // Maybe if we had an InsetLayout for TOC...
-               xs << XHTMLStream::ESCAPE_NONE << "&gt;";
-               xs << html::EndTag("a");                
+               makeTOCEntry(xs, par, op);
        }
        for (int i = lastdepth; i > 0; --i) 
                xs << html::EndTag("div") << html::CR();
@@ -223,29 +229,8 @@ void InsetTOC::makeTOCNoDepth(XHTMLStream xs,
                xs << html::StartTag("div", "class='lyxtop-1'") << html::CR();
 
                Paragraph const & par = it->dit().innerParagraph();
-               string const attr = "href='#" + par.magicLabel() + "' class='tocentry'";
-               xs << html::StartTag("a", attr);
-
-               // First the label, if there is one
-               docstring const & label = par.params().labelString();
-               if (!label.empty())
-                       xs << label << " ";
-               // Now the content of the TOC entry, taken from the paragraph itself
-               OutputParams ours = op;
-               ours.for_toc = true;
-               Font const dummy;
-               par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
-
-               xs << html::EndTag("a") << " ";
-
-               // Now a link to that paragraph
-               string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
-               xs << html::StartTag("a", parattr);
-               // FIXME XHTML
-               // There ought to be a simple way to customize this.
-               // Maybe if we had an InsetLayout for TOC...
-               xs << XHTMLStream::ESCAPE_NONE << "&gt;";
-               xs << html::EndTag("a");
+               makeTOCEntry(xs, par, op);
+               
                xs << html::EndTag("div");
        }
 }
index e5127d62c38504a2e437b57ce3d2da4bb51670cf..ead482b2e839870ec93ed3886d12eb528669f517 100644 (file)
@@ -17,6 +17,7 @@
 
 namespace lyx {
 
+class Paragraph;
 class Toc;
 
 /// Used to insert table of contents and similar lists
@@ -66,6 +67,9 @@ private:
        void makeTOCWithDepth(XHTMLStream xs, Toc toc, const OutputParams & op) const;
        ///
        void makeTOCNoDepth(XHTMLStream xs, Toc toc, const OutputParams & op) const;
+       ///
+       void makeTOCEntry(XHTMLStream & xs, Paragraph const & par, OutputParams const & op) const;
+       
        /// \name Private functions inherited from Inset class
        //@{
        ///