]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetText.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetText.cpp
index 5c461242e50605db652a460bfac7fdb5c4187341..a396041a30bbb453b7725cf64aa325835495df3e 100644 (file)
@@ -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"
@@ -34,6 +35,7 @@
 #include "MetricsInfo.h"
 #include "output_docbook.h"
 #include "output_latex.h"
+#include "output_xhtml.h"
 #include "OutputParams.h"
 #include "output_plaintext.h"
 #include "paragraph_funcs.h"
@@ -314,15 +316,15 @@ void InsetText::setChange(Change const & change)
 }
 
 
-void InsetText::acceptChanges(BufferParams const & bparams)
+void InsetText::acceptChanges()
 {
-       text_.acceptChanges(bparams);
+       text_.acceptChanges(buffer().params());
 }
 
 
-void InsetText::rejectChanges(BufferParams const & bparams)
+void InsetText::rejectChanges()
 {
-       text_.rejectChanges(bparams);
+       text_.rejectChanges(buffer().params());
 }
 
 
@@ -367,6 +369,13 @@ 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();
+}
+
+
 void InsetText::validate(LaTeXFeatures & features) const
 {
        for_each(paragraphs().begin(), paragraphs().end(),
@@ -539,7 +548,7 @@ void InsetText::addToToc(DocIterator const & cdit)
                                break;
                        }
                }
-               /// now the toc entry for the paragraph
+               // now the toc entry for the paragraph
                int const toclevel = par.layout().toclevel;
                if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
                        dit.pos() = 0;
@@ -643,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<InsetCaption const *>(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