]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaption.cpp
Inset::addToToc(): change signature. Use DocIterator instead of ParConstIterator...
[lyx.git] / src / insets / InsetCaption.cpp
index 5c7a9753b8227ab02fb57a469c186093f5968864..dafaddef13740068d36c337105285c0934db5542 100644 (file)
@@ -47,24 +47,14 @@ using namespace lyx::support;
 namespace lyx {
 
 
-InsetCaption::InsetCaption(InsetCaption const & ic)
-       : InsetText(ic)
+InsetCaption::InsetCaption(Buffer const & buf)
+       : InsetText(buf)
 {
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color_captionframe);
-}
-
-
-InsetCaption::InsetCaption(BufferParams const & bp)
-       : InsetText(bp)
-{
-       setAutoBreakRows(true);
-       setDrawFrame(true);
-       setFrameColor(Color_captionframe);
-       //FIXME Do we need to set all paragraphs here? or will there
-       //always only be one?
-       paragraphs().back().setLayout(bp.documentClass().emptyLayout());
+       // There will always be only one
+       paragraphs().back().setLayout(buf.params().documentClass().emptyLayout());
 }
 
 
@@ -80,11 +70,8 @@ void InsetCaption::read(Lexer & lex)
 #if 0
        // We will enably this check again when the compability
        // code is removed from Buffer::Read (Lgb)
-       string const token = lex.GetString();
-       if (token != "Caption") {
-               lyxerr << "InsetCaption::Read: consistency check failed."
-                      << endl;
-       }
+       lex.setContext("InsetCaption::Read: consistency check");
+       lex >> "Caption";
 #endif
        InsetText::read(lex);
 }
@@ -115,16 +102,16 @@ void InsetCaption::setCustomLabel(docstring const & label)
 }
 
 
-void InsetCaption::addToToc(ParConstIterator const & cpit) const
+void InsetCaption::addToToc(DocIterator const & cpit)
 {
        if (type_.empty())
                return;
 
-       ParConstIterator pit = cpit;
-       pit.push_back(*this);
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc(type_);
-       docstring const str = full_label_ + ". " + pit->asString(false);
+       docstring const str = full_label_ + ". " + text_.getPar(0).asString(false);
        toc.push_back(TocItem(pit, 0, str));
 }
 
@@ -211,6 +198,11 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
                status.enabled(cur.paragraph().insetList().find(OPTARG_CODE) == -1);
                return true;
 
+       case LFUN_INSET_TOGGLE:
+               // pass back to owner
+               cur.undispatched();
+               return false;
+
        default:
                return InsetText::getStatus(cur, cmd, status);
        }
@@ -278,6 +270,14 @@ int InsetCaption::getOptArg(odocstream & os,
 }
 
 
+int InsetCaption::getCaptionText(odocstream & os,
+                       OutputParams const & runparams) const
+{
+       os << full_label_ << ' ';
+       return InsetText::plaintext(os, runparams);
+}
+
+
 void InsetCaption::updateLabels(ParIterator const & it)
 {
        DocumentClass const & tclass = buffer().params().documentClass();
@@ -316,10 +316,4 @@ void InsetCaption::updateLabels(ParIterator const & it)
 }
 
 
-Inset * InsetCaption::clone() const
-{
-       return new InsetCaption(*this);
-}
-
-
 } // namespace lyx