Abdelrazak Younes wrote:
Jean-Marc Lasgouttes wrote:
"Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

 And if anybody forgot: Now is not the time to make such decisions
or even to discuss them. There are plenty of open bugs and
regressions with 1.5.0 target in bugzilla.

Abdelrazak> OK, let's postpone the discussion to 1.6 then and use the
Abdelrazak> ugly scanning code for now.

Which was exactly the point of my message.

Ah? I thought you wanted to argue... :-)

Anyway, I agree that something like the attached (not tested) should solve the current caption label problem.


Here is a patch that put 1.5 on par with 1.4.

Abdel.

Index: text.C
===================================================================
--- text.C      (revision 17413)
+++ text.C      (working copy)
@@ -56,6 +56,7 @@
 
 #include "insets/insettext.h"
 #include "insets/insetbibitem.h"
+#include "insets/insetcaption.h"
 #include "insets/insethfill.h"
 #include "insets/insetline.h"
 #include "insets/insetnewline.h"
@@ -1744,25 +1745,25 @@
 
        docstring name = from_ascii(layout->latexname());
 
-       // for captions, we want the abbreviation of the float type
-       if (layout->labeltype == LABEL_SENSITIVE) {
-               // Search for the first float or wrap inset in the iterator
-               for (int i = cur.depth(); --i >= 0; ) {
-                       InsetBase * const in = &cur[i].inset();
-                       if (in->lyxCode() == InsetBase::FLOAT_CODE
-                           || in->lyxCode() == InsetBase::WRAP_CODE) {
-                               name = in->getInsetName();
-                               break;
-                       }
-               }
-       }
+       // Inside floats or wraps, we want the abbreviation of the float type
+       InsetBase * float_inset = cur.innerInsetOfType(InsetBase::FLOAT_CODE);
+       if (!float_inset)
+               float_inset = cur.innerInsetOfType(InsetBase::WRAP_CODE);
+       if (float_inset)
+               name = float_inset->getInsetName();
 
+       // for captions, we just take the caption type
+       InsetBase * caption_inset = 
cur.innerInsetOfType(InsetBase::CAPTION_CODE);
+       if (caption_inset)
+               name = from_ascii(static_cast<InsetCaption 
*>(caption_inset)->type());
+
        docstring text = name.substr(0, 3);
        if (name == "theorem")
                text = from_ascii("thm"); // Create a correct prefix for 
prettyref
 
        text += ':';
-       if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
+       if (!float_inset && !caption_inset &&
+               (layout->latextype == LATEX_PARAGRAPH || 
lyxrc.label_init_length < 0))
                text.erase();
 
        docstring par_text = pars_[pit].asString(cur.buffer(), false);

Reply via email to