From 83a89711b09d409e2f101c4a407ff6f7e6968ef7 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 19 Jun 2009 18:32:50 +0000 Subject: [PATCH] Fix captions, in accord with observations by Abdel and JMarc. Note that we will sometimes use the "caption trick", still in listings, for example. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30194 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/OutputParams.cpp | 2 +- src/OutputParams.h | 2 ++ src/insets/InsetCaption.cpp | 11 ++++++++--- src/insets/InsetCaption.h | 2 +- src/insets/InsetFloat.cpp | 4 ---- src/insets/InsetListings.cpp | 4 +++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index 4e77c70ee3..c1af29f858 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -26,7 +26,7 @@ OutputParams::OutputParams(Encoding const * enc) inComment(false), inTableCell(NO), inFloat(NONFLOAT), inDeletedInset(0), changeOfDeletedInset(Change::UNCHANGED), par_begin(0), par_end(0), isLastPar(false), - dryrun(false), verbatim(false) + dryrun(false), verbatim(false), disable_captions(false) { // Note: in PreviewLoader::Impl::dumpPreamble // OutputParams runparams(0); diff --git a/src/OutputParams.h b/src/OutputParams.h index 75e6918089..6b25658ee3 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -198,6 +198,8 @@ public: bool dryrun; /// Should we output verbatim or escape LaTeX's special chars? bool verbatim; + /// Should we output captions? (Used in HTML output.) + bool disable_captions; }; diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 55224d8abd..09254d133f 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -256,10 +256,15 @@ int InsetCaption::docbook(odocstream & os, } -docstring InsetCaption::xhtml(odocstream &, - OutputParams const &) const +docstring InsetCaption::xhtml(odocstream & os, + OutputParams const & rp) const { - return docstring(); + if (rp.disable_captions) + return docstring(); + os << "
\n"; + docstring def = getCaptionAsHTML(os, rp); + os << "
\n"; + return def; } int InsetCaption::getArgument(odocstream & os, diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index a942752126..5379b171bc 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -70,7 +70,7 @@ private: int plaintext(odocstream & os, OutputParams const & runparams) const; /// int docbook(odocstream & os, OutputParams const & runparams) const; - /// This does nothing here. Instead, it is handled inside the float. + /// docstring xhtml(odocstream & os, OutputParams const & runparams) const; /// void setCustomLabel(docstring const & label); diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 194e4f769a..39f7870987 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -297,11 +297,7 @@ docstring InsetFloat::xhtml(odocstream & os, OutputParams const & rp) const odocstringstream out; - docstring caption = getCaptionHTML(rp); out << otag; - if (!caption.empty()) - out << "
" << caption << "
\n"; - docstring def = InsetText::xhtml(out, rp); out << ctag; diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index b54b4106fd..c59e92f4d3 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -288,7 +288,9 @@ docstring InsetListings::xhtml(odocstream & os, OutputParams const & rp) const } out << "
\n";
-	docstring def = InsetText::xhtml(out, rp);
+	OutputParams newrp = rp;
+	newrp.disable_captions = true;
+	docstring def = InsetText::xhtml(out, newrp);
 	out << "\n
\n"; if (isInline) {