]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaption.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetCaption.cpp
index 9a4af662089ef95a23f3ca2d2a3e1b40bb6bfd5c..9046d054e5ee688b8a5b93fccff5d060afab2f03 100644 (file)
@@ -64,6 +64,14 @@ void InsetCaption::write(ostream & os) const
 }
 
 
+docstring InsetCaption::name() const
+{
+       if (type_.empty())
+               return from_ascii("Caption");
+       return from_utf8("Caption:" + type_);
+}
+
+
 void InsetCaption::read(Lexer & lex)
 {
 #if 0
@@ -167,6 +175,7 @@ Inset * InsetCaption::editXY(Cursor & cur, int x, int y)
 bool InsetCaption::insetAllowed(InsetCode code) const
 {
        switch (code) {
+       // code that is not allowed in a caption
        case FLOAT_CODE:
        case TABULAR_CODE:
        case WRAP_CODE:
@@ -255,9 +264,13 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 {
        if (rp.html_disable_captions)
                return docstring();
-       xs << StartTag("div", "class='float-caption'");
+       string attr = "class='float-caption";
+       if (!type_.empty())
+               attr += " float-caption-" + type_;
+       attr += "'";
+       xs << html::StartTag("div", attr);
        docstring def = getCaptionAsHTML(xs, rp);
-       xs << EndTag("div");
+       xs << html::EndTag("div");
        return def;
 }
 
@@ -294,13 +307,17 @@ docstring InsetCaption::getCaptionAsHTML(XHTMLStream & xs,
 }
 
 
-void InsetCaption::updateLabels(ParIterator const & it, bool out)
+void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype)
 {
        Buffer const & master = *buffer().masterBuffer();
        DocumentClass const & tclass = master.params().documentClass();
        string const & lang = it.paragraph().getParLanguage(master.params())->code();
        Counters & cnts = tclass.counters();
        string const & type = cnts.current_float();
+       if (utype == OutputUpdate) {
+               // counters are local to the caption
+               cnts.saveLastCounter();
+       }
        // Memorize type for addToToc().
        type_ = type;
        if (type.empty())
@@ -320,7 +337,7 @@ void InsetCaption::updateLabels(ParIterator const & it, bool out)
                                       master.B_(tclass.floats().getType(type).name()));
                }
                if (cnts.hasCounter(counter)) {
-                       cnts.step(counter);
+                       cnts.step(counter, utype);
                        full_label_ = bformat(from_ascii("%1$s %2$s:"), 
                                              name,
                                              cnts.theCounter(counter, lang));
@@ -329,7 +346,9 @@ void InsetCaption::updateLabels(ParIterator const & it, bool out)
        }
 
        // Do the real work now.
-       InsetText::updateLabels(it, out);
+       InsetText::updateBuffer(it, utype);
+       if (utype == OutputUpdate)
+               cnts.restoreLastCounter();
 }