From: Richard Heck Date: Wed, 27 Mar 2013 21:16:34 +0000 (-0400) Subject: Factor common code from TOC updates. X-Git-Tag: 2.1.0beta1~467 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=050142de1bc5fa73242a46dacbb42f9645a95944;p=features.git Factor common code from TOC updates. --- diff --git a/src/insets/InsetTOC.cpp b/src/insets/InsetTOC.cpp index 700680d1a5..6ed1fa91e9 100644 --- a/src/insets/InsetTOC.cpp +++ b/src/insets/InsetTOC.cpp @@ -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 << ">"; + 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 << ">"; - 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 << ">"; - xs << html::EndTag("a"); + makeTOCEntry(xs, par, op); + xs << html::EndTag("div"); } } diff --git a/src/insets/InsetTOC.h b/src/insets/InsetTOC.h index e5127d62c3..ead482b2e8 100644 --- a/src/insets/InsetTOC.h +++ b/src/insets/InsetTOC.h @@ -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 //@{ ///