]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaption.cpp
Fix GRAPHICS_EDIT of InsetGraphics
[lyx.git] / src / insets / InsetCaption.cpp
index 1c968b4a01f9a41a1ab8165bc9aa149f5dca2416..4d02187e09f0ccca01c6cffcc3f8b71e12c1ff00 100644 (file)
@@ -47,24 +47,14 @@ using namespace lyx::support;
 namespace lyx {
 
 
-InsetCaption::InsetCaption(InsetCaption const & ic)
-       : InsetText(ic), textclass_(ic.textclass_)
+InsetCaption::InsetCaption(Buffer const & buf)
+       : InsetText(buf)
 {
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color_captionframe);
-}
-
-
-InsetCaption::InsetCaption(BufferParams const & bp)
-       : InsetText(bp), textclass_(bp.documentClass())
-{
-       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());
 }
 
 
@@ -220,6 +210,9 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
 int InsetCaption::latex(odocstream & os,
                        OutputParams const & runparams_in) const
 {
+       if (in_subfloat_)
+               // caption is output as an optional argument
+               return 0;
        // This is a bit too simplistic to take advantage of
        // caption options we must add more later. (Lgb)
        // This code is currently only able to handle the simple
@@ -282,6 +275,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
        string const & type = cnts.current_float();
        // Memorize type for addToToc().
        type_ = type;
+       in_subfloat_ = cnts.isSubfloat();
        if (type.empty())
                full_label_ = buffer().B_("Senseless!!! ");
        else {
@@ -292,11 +286,17 @@ void InsetCaption::updateLabels(ParIterator const & it)
                        name = buffer().B_("Listing");
                else
                        name = buffer().B_(tclass.floats().getType(type).name());
-               if (cnts.hasCounter(from_utf8(type))) {
-                       cnts.step(from_utf8(type));
+               docstring counter = from_utf8(type);
+               if (in_subfloat_) {
+                       counter = "sub-" + from_utf8(type);
+                       name = bformat(_("Sub-%1$s"),
+                                      buffer().B_(tclass.floats().getType(type).name()));
+               }
+               if (cnts.hasCounter(counter)) {
+                       cnts.step(counter);
                        full_label_ = bformat(from_ascii("%1$s %2$s:"), 
-                                             name, 
-                                             cnts.theCounter(from_utf8(type)));
+                                             name,
+                                             cnts.theCounter(counter));
                } else
                        full_label_ = bformat(from_ascii("%1$s #:"), name);     
        }
@@ -306,10 +306,4 @@ void InsetCaption::updateLabels(ParIterator const & it)
 }
 
 
-Inset * InsetCaption::clone() const
-{
-       return new InsetCaption(*this);
-}
-
-
 } // namespace lyx