From: Richard Heck Date: Fri, 19 Jun 2009 13:50:19 +0000 (+0000) Subject: Polish some of the recent changes in accord with suggestions X-Git-Tag: 2.0.0~6257 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3b707bc0eddbd11efd0d33ce67a316ff68364b2a;p=features.git Polish some of the recent changes in accord with suggestions of JMarc's. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30186 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index c51efa9976..55224d8abd 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -256,8 +256,8 @@ int InsetCaption::docbook(odocstream & os, } -docstring InsetCaption::xhtml(odocstream & os, - OutputParams const & runparams) const +docstring InsetCaption::xhtml(odocstream &, + OutputParams const &) const { return docstring(); } @@ -276,7 +276,7 @@ int InsetCaption::getOptArg(odocstream & os, } -int InsetCaption::getCaptionText(odocstream & os, +int InsetCaption::getCaptionAsPlaintext(odocstream & os, OutputParams const & runparams) const { os << full_label_ << ' '; @@ -284,7 +284,7 @@ int InsetCaption::getCaptionText(odocstream & os, } -docstring InsetCaption::getCaptionHTML(odocstream & os, +docstring InsetCaption::getCaptionAsHTML(odocstream & os, OutputParams const & runparams) const { os << full_label_ << ' '; diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index 83a3d61e79..a942752126 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -29,9 +29,9 @@ public: /// return the optional argument(s) only int getOptArg(odocstream & os, OutputParams const &) const; /// return the caption text - int getCaptionText(odocstream & os, OutputParams const &) const; + int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const; /// return the caption text as HTML - docstring getCaptionHTML(odocstream & os, OutputParams const &) const; + docstring getCaptionAsHTML(odocstream & os, OutputParams const &) const; private: /// void write(std::ostream & os) const; diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index b12cb7025d..b164d27669 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -23,7 +23,6 @@ #include "FloatList.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "InsetCaption.h" #include "InsetLayout.h" #include "InsetList.h" #include "Language.h" @@ -784,56 +783,6 @@ docstring InsetCollapsable::floatName( } -InsetCaption const * InsetCollapsable::getCaptionInset() const -{ - ParagraphList::const_iterator pit = paragraphs().begin(); - for (; pit != paragraphs().end(); ++pit) { - InsetList::const_iterator it = pit->insetList().begin(); - for (; it != pit->insetList().end(); ++it) { - Inset & inset = *it->inset; - if (inset.lyxCode() == CAPTION_CODE) { - InsetCaption const * ins = - static_cast(it->inset); - return ins; - } - } - } - return 0; -} - - -docstring InsetCollapsable::getCaptionText(OutputParams const & runparams) const -{ - if (paragraphs().empty()) - return docstring(); - - InsetCaption const * ins = getCaptionInset(); - if (ins == 0) - return docstring(); - - odocstringstream ods; - ins->getCaptionText(ods, runparams); - return ods.str(); -} - - -docstring InsetCollapsable::getCaptionHTML(OutputParams const & runparams) const -{ - if (paragraphs().empty()) - return docstring(); - - InsetCaption const * ins = getCaptionInset(); - if (ins == 0) - return docstring(); - - odocstringstream ods; - docstring def = ins->getCaptionHTML(ods, runparams); - if (!def.empty()) - ods << def << '\n'; - return ods.str(); -} - - InsetLayout::InsetDecoration InsetCollapsable::decoration() const { if (!layout_) diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 730e4c6e37..de432aa8fa 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -23,7 +23,6 @@ namespace lyx { class CursorSlice; -class InsetCaption; class InsetLayout; namespace frontend { class Painter; } @@ -181,12 +180,6 @@ protected: /// virtual void resetParagraphsFont(); /// - InsetCaption const * getCaptionInset() const; - /// - docstring getCaptionText(OutputParams const &) const; - /// - docstring getCaptionHTML(OutputParams const &) const; - /// mutable CollapseStatus status_; private: /// cache for the layout_. Make sure it is in sync with the document class! diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index ecf2b08b36..22a95c03cc 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -26,6 +26,7 @@ #include "ErrorList.h" #include "FuncRequest.h" #include "FuncStatus.h" +#include "InsetCaption.h" #include "InsetList.h" #include "Intl.h" #include "Lexer.h" @@ -651,4 +652,48 @@ docstring InsetText::contextMenu(BufferView const &, int, int) const } +InsetCaption const * InsetText::getCaptionInset() const +{ + ParagraphList::const_iterator pit = paragraphs().begin(); + for (; pit != paragraphs().end(); ++pit) { + InsetList::const_iterator it = pit->insetList().begin(); + for (; it != pit->insetList().end(); ++it) { + Inset & inset = *it->inset; + if (inset.lyxCode() == CAPTION_CODE) { + InsetCaption const * ins = + static_cast(it->inset); + return ins; + } + } + } + return 0; +} + + +docstring InsetText::getCaptionText(OutputParams const & runparams) const +{ + InsetCaption const * ins = getCaptionInset(); + if (ins == 0) + return docstring(); + + odocstringstream ods; + ins->getCaptionAsPlaintext(ods, runparams); + return ods.str(); +} + + +docstring InsetText::getCaptionHTML(OutputParams const & runparams) const +{ + InsetCaption const * ins = getCaptionInset(); + if (ins == 0) + return docstring(); + + odocstringstream ods; + docstring def = ins->getCaptionAsHTML(ods, runparams); + if (!def.empty()) + ods << def << '\n'; + return ods.str(); +} + + } // namespace lyx diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 41ac4512a1..ee3e4884b8 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -26,6 +26,7 @@ class CompletionList; class CursorSlice; class Dimension; class ParagraphList; +class InsetCaption; class InsetTabular; /** @@ -176,6 +177,13 @@ public: virtual docstring contextMenu(BufferView const & bv, int x, int y) const; /// void doDispatch(Cursor & cur, FuncRequest & cmd); +protected: + /// + InsetCaption const * getCaptionInset() const; + /// + docstring getCaptionText(OutputParams const &) const; + /// + docstring getCaptionHTML(OutputParams const &) const; private: /// void initParagraphs(UsePlain type); diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 4e8750137f..7d2168675d 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -259,29 +259,6 @@ bool InsetWrap::showInsetDialog(BufferView * bv) const } -docstring InsetWrap::getCaptionText(OutputParams const & runparams) const -{ - if (paragraphs().empty()) - return docstring(); - - ParagraphList::const_iterator pit = paragraphs().begin(); - for (; pit != paragraphs().end(); ++pit) { - InsetList::const_iterator it = pit->insetList().begin(); - for (; it != pit->insetList().end(); ++it) { - Inset & inset = *it->inset; - if (inset.lyxCode() == CAPTION_CODE) { - odocstringstream ods; - InsetCaption * ins = - static_cast(it->inset); - ins->getCaptionText(ods, runparams); - return ods.str(); - } - } - } - return docstring(); -} - - void InsetWrap::string2params(string const & in, InsetWrapParams & params) { params = InsetWrapParams(); diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index aa21ebf4cf..e7c316c42a 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -85,8 +85,6 @@ private: /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// - docstring getCaptionText(OutputParams const &) const; - /// docstring name() const; /// Inset * clone() const { return new InsetWrap(*this); }