]> git.lyx.org Git - features.git/commitdiff
Support \caption* (bug #3209)
authorGeorg Baum <baum@lyx.org>
Fri, 22 Mar 2013 21:23:38 +0000 (22:23 +0100)
committerGeorg Baum <baum@lyx.org>
Fri, 22 Mar 2013 21:23:38 +0000 (22:23 +0100)
This was a low hanging fruit which would have to wait for a long time because
of a file format change if it was not implemented before 2.1.

27 files changed:
lib/layouts/stdinsets.inc
lib/lyx2lyx/lyx_2_1.py
src/Text3.cpp
src/frontends/qt4/Menus.cpp
src/insets/Inset.h
src/insets/InsetCaption.cpp
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/tex2lyx/TODO.txt
src/tex2lyx/test/CJK.lyx.lyx
src/tex2lyx/test/CJKutf8.lyx.lyx
src/tex2lyx/test/Dummy Document.lyx
src/tex2lyx/test/DummyDocument.lyx
src/tex2lyx/test/Dummy~Document.lyx
src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-insets.tex
src/tex2lyx/test/test-modules.lyx.lyx
src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
src/tex2lyx/test/test-structure.lyx.lyx
src/tex2lyx/test/test.lyx.lyx
src/tex2lyx/test/verbatim.lyx.lyx
src/tex2lyx/text.cpp
src/version.h

index c52381bcafa4c8a8906031af8419e5756cb70eff..40a4917419327f3083fc9eabaebabffbf3299b8b 100644 (file)
@@ -491,6 +491,16 @@ InsetLayout Caption:Standard
 End
 
 
+InsetLayout Caption:LongTableNoNumber
+       CopyStyle            Caption:Standard
+       LatexName            caption*
+       Argument 1
+               LabelString   "Long Table Caption (unnumbered)"
+               Tooltip       "The caption as it appears in the list of tables"
+       EndArgument
+End
+
+
 InsetLayout Preview
        LabelString           Preview
        Decoration            minimalistic
index a7c78f6242ffc2defbcf68cf8885be2f08707173..8b51b2e2030516a2420086fd95d8a6cc600e1c2f 100644 (file)
@@ -3161,7 +3161,6 @@ def convert_captioninsets(document):
           return
       document.body[i] = "\\begin_inset Caption Standard"
       i = i + 1
-        
 
 
 def revert_captioninsets(document):
@@ -3178,7 +3177,7 @@ def revert_captioninsets(document):
 
 def convert_captionlayouts(document):
     " Convert caption layouts to caption insets. "
-    
+
     caption_dict = {
         "Captionabove":  "Above",
         "Captionbelow":  "Below",
@@ -3187,7 +3186,7 @@ def convert_captionlayouts(document):
         "CenteredCaption" : "Centered",
         "Bicaption" : "Bicaption",
         }
-    
+
     i = 0
     while True:
         i = find_token(document.body, "\\begin_layout", i)
@@ -4080,6 +4079,20 @@ def revert_mbox_fbox(document):
         i = i + 1
 
 
+def revert_starred_caption(document):
+    " Reverts unnumbered longtable caption insets "
+    
+    i = 0
+    while True:
+      i = find_token(document.body, "\\begin_inset Caption LongTableNoNumber", i)
+      if i == -1:
+          return
+      # This is not equivalent, but since the caption inset is a full blown
+      # text inset a true conversion to ERT is too difficult.
+      document.body[i] = "\\begin_inset Caption Standard"
+      i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -4140,10 +4153,12 @@ convert = [
            [465, [convert_lyxframes, remove_endframes]],
            [466, []],
            [467, []],
-           [468, []]
+           [468, []],
+           [469, []]
           ]
 
 revert =  [
+           [468, [revert_starred_caption]],
            [467, [revert_mbox_fbox]],
            [466, [revert_iwona_fonts]],
            [465, [revert_powerdot_flexes, revert_powerdot_pause, revert_powerdot_itemargs, revert_powerdot_columns]],
index fad451c7288007d612f4c4bca479e7e5b328a7b8..b87cf2904a2133816e828be1a51b88269bad1283 100644 (file)
@@ -2527,13 +2527,12 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        }
        case LFUN_CAPTION_INSERT: {
                code = CAPTION_CODE;
-               bool varia = true;
+               string arg = cmd.getArg(0);
+               bool varia = arg != "LongTableNoNumber";
                if (cur.depth() > 0) {
-                       if (&cur[cur.depth() - 1].inset()
-                           && !cur[cur.depth() - 1].inset().allowsCaptionVariation())
-                               varia = false;
+                       if (&cur[cur.depth() - 1].inset())
+                               varia = cur[cur.depth() - 1].inset().allowsCaptionVariation(arg);
                }
-               string arg = cmd.getArg(0);
                // not allowed in description items,
                // and in specific insets
                enable = !inDescriptionItem(cur)
index cd7518b481a65e2805d6f711bc23d83b458b12a5..0985a9d2c571830cd72d81595e603b88a0bbf6a2 100644 (file)
@@ -1634,16 +1634,18 @@ void MenuDefinition::expandCaptions(Buffer const * buf, bool switchcap)
                docstring const type = split(*cit, dummy, ':');
                docstring const trtype = translateIfPossible(type);
                docstring const cmitem = bformat(_("Caption (%1$s)"), trtype);
-                       if (switchcap)
-                               addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cmitem),
-                                            FuncRequest(LFUN_INSET_MODIFY,
-                                                        from_ascii("changetype ")
-                                                        + type), QString(), true));
-                       else
-                               captions.addWithStatusCheck(MenuItem(MenuItem::Command,
-                                                                    toqstr(trtype),
-                                                                    FuncRequest(LFUN_CAPTION_INSERT,
-                                                                    type), QString(), true));
+               // make menu item optional, otherwise we would also see
+               // forbidden caption types
+               if (switchcap)
+                       addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cmitem),
+                                    FuncRequest(LFUN_INSET_MODIFY,
+                                                from_ascii("changetype ")
+                                                + type), QString(), true));
+               else
+                       captions.addWithStatusCheck(MenuItem(MenuItem::Command,
+                                                            toqstr(trtype),
+                                                            FuncRequest(LFUN_CAPTION_INSERT,
+                                                            type), QString(), true));
        }
        if (!captions.empty()) {
                MenuItem item(MenuItem::Submenu, qt_("Caption"));
@@ -1796,7 +1798,7 @@ struct Menus::Impl {
        /** The entries with the following kind are expanded to a
            sequence of Command MenuItems: Lastfiles, Documents,
            ViewFormats, ExportFormats, UpdateFormats, Branches,
-           Indices, Arguments, SwitchArguments, Captions, Switchcaptions
+           Indices, Arguments, SwitchArguments, Captions, SwitchCaptions
        */
        void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
                BufferView const *) const;
index 36a0f929d8b38c445e0d7fb5b0ca3dd274c566bc..4b450c10ddcbb6d28c04f973cd3cf6f6e420fd1a 100644 (file)
@@ -351,7 +351,7 @@ public:
        /// can we click at the specified position ?
        virtual bool clickable(int, int) const { return false; }
        /// Move one cell backwards
-       virtual bool allowsCaptionVariation() const { return false; }
+       virtual bool allowsCaptionVariation(std::string const &) const { return false; }
 
        /// does this contain text that can be change track marked in DVI?
        virtual bool canTrackChanges() const { return false; }
index 035a5feda0c5c272f3a447ca64347861cbba4e14..4c7cd74e4e6940fd7461ac929637c893b47fcaa4 100644 (file)
@@ -229,12 +229,11 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
                if (first_arg == "changetype") {
                        string const type = cmd.getArg(1);
                        status.setOnOff(type == type_);
-                       bool varia = true;
+                       bool varia = type != "LongTableNoNumber";
                        // check if the immediate parent inset allows caption variation
                        if (cur.depth() > 1) {
-                               if (&cur[cur.depth() - 2].inset()
-                                   && !cur[cur.depth() - 2].inset().allowsCaptionVariation())
-                                       varia = false;
+                               if (&cur[cur.depth() - 2].inset())
+                                       varia = cur[cur.depth() - 2].inset().allowsCaptionVariation(type);
                        }
                        status.setEnabled(varia
                                          && buffer().params().documentClass().hasInsetLayout(
index bd465fbc3eb8606d2e2fd38f8ef532ebcba8998d..5121d7263f66c42d5e8634d74a22fda8a694563e 100644 (file)
@@ -470,6 +470,12 @@ void InsetFloat::setNewLabel()
 }
 
 
+bool InsetFloat::allowsCaptionVariation(std::string const & newtype) const
+{
+       return !params_.subfloat && newtype != "LongTableNoNumber";
+}
+
+
 docstring InsetFloat::getCaption(OutputParams const & runparams) const
 {
        if (paragraphs().empty())
index f254bc48dbe45a4ebf0a6a2dd7119de36104914e..6cff1089754a15401dff14d5a33d2b169cc815db 100644 (file)
@@ -68,7 +68,7 @@ public:
        ///
        InsetFloatParams const & params() const { return params_; }
        ///
-       bool allowsCaptionVariation() const { return !params_.subfloat; }
+       bool allowsCaptionVariation(std::string const &) const;
 private:
        ///
        docstring layoutName() const;
index 379d29634429aaa23685e7bcb1459fdc33acbffb..2c9967013e482008191c4d9ed26fe90f75f6b883 100644 (file)
@@ -3480,6 +3480,13 @@ bool InsetTabular::insetAllowed(InsetCode code) const
 }
 
 
+bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
+{
+       return tabular.is_long_tabular &&
+               (newtype == "Standard" || newtype == "LongTableNoNumber");
+}
+
+
 void InsetTabular::write(ostream & os) const
 {
        os << "Tabular" << endl;
index e4651a3b8fded091718795daa402de22d03c137c..178060e86aba47d8a8c7d2c4f408913d453c80a7 100644 (file)
@@ -854,6 +854,8 @@ public:
            insets that may contain several paragraphs */
        bool inheritFont() const { return false; }
        ///
+       bool allowsCaptionVariation(std::string const &) const;
+       ///
        DisplayType display() const;
        ///
        void latex(otexstream &, OutputParams const &) const;
index 97b4ae7747fd99d1fb638d66db023f3d9d820024..17979db98529625e3916234f4e0442e165adb9fc 100644 (file)
@@ -88,8 +88,6 @@ Format LaTeX feature                        LyX feature
        \usepackage[scale|scaled=$val]{biolinum-type1}
                                             \font_sans
                                             \font_sf_scale
-463
-465
 466   Powerdot updates:                     
       \pause[]                              layout Pause
       \onslide{}{}                          InsetFlex, InsetArgument
@@ -100,6 +98,7 @@ Format LaTeX feature                        LyX feature
       \begin{enumerate|itemize|...}[]       InsetArgument
 467   support for iwona math font (the other iwona fonts are already supported)
 
+
 General
 
 * Use the language information provided by Language.cpp and the languages file (for babel/lyx/polyglossia name, quote style etc.)
index c288615a0c5225de71d23f27054c61ec982c1c03..0c3968a676cff230e2ab1089f23c567a1877df4a 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 6792280f1ff936b4d50226221ce76dabcda71103..d62a98a9660b9077c1562801a8c1e9930ff88072 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index bbae1d6b6d682305635ed1ea492d463bd3a2ec77..f5f506eb92be96484b7817b4cb368988818b4355 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 63abd7ec05870d878b9d7ae9c624f2add52a2e4b..9cdbd3bfa8a0b0cb030bc1fe17daac0c92a3c066 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 5243c6c9c13e18a4d94f6c5e4b073354f60fb106..22e3d7fb56e3002915e51dcb92ad8aa0acb9f0db 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 5abbf753d98b824aa7b767c3de5de266b4f62e87..5561d4bf9b93061784eaa36505ed7d487e013485 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 081df6b19fdaddfdacfd3e3f95378e813b3ebd9c..720143a253b4f7ce42ed08068089cff3e7c52206 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 468
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 43506536d9f0ac37ac808f654382a6b2ebda4037..6e79b6af5139694e7bf4af7316c9f243fa93c185 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
@@ -1369,7 +1369,7 @@ clearpage}
 \begin_layout Standard
 
 \begin_inset Tabular 
-<lyxtabular version="3" rows="64" columns="2">
+<lyxtabular version="3" rows="66" columns="2">
 <features rotate="0" islongtable="true">
 <column alignment="none" valignment="top" special="@{*}r">
 <column alignment="none" valignment="top" special="|p{1in}@{*}">
@@ -1547,11 +1547,46 @@ Second
 
 \end_layout
 
+\end_inset
+</cell>
+</row>
+<row endfoot="true" caption="true">
+<cell multicolumn="1" alignment="none" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\begin_inset Caption LongTableNoNumber
+
+\begin_layout Standard
+
+\begin_inset Argument 1
+status collapsed
+
+\begin_layout Standard
+An optional table foot caption (used in the list of tables)
+\end_layout
+
+\end_inset
+
+standard foot
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="none" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
 \end_inset
 </cell>
 </row>
 <row endfoot="true">
-<cell alignment="none" valignment="top" topline="true" bottomline="true" usebox="none">
+<cell alignment="none" valignment="top" topline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Standard
@@ -1560,13 +1595,44 @@ This goes at the
 
 \end_inset
 </cell>
-<cell alignment="none" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+<cell alignment="none" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \begin_layout Standard
 bottom.
 \end_layout
 
+\end_inset
+</cell>
+</row>
+<row endlastfoot="true" caption="true">
+<cell multicolumn="1" alignment="none" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\begin_inset Caption LongTableNoNumber
+
+\begin_layout Standard
+
+\begin_inset Argument 1
+status collapsed
+
+\end_inset
+
+(last foot)
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="none" valignment="top" topline="true" usebox="none">
+\begin_inset Text
+
 \end_inset
 </cell>
 </row>
index 0feb452c06cf961b5a3c4e2e2fedd130d61b5325..bb5844a1fa98321512c5217e7f2f0b5020563f4d 100644 (file)
@@ -277,10 +277,14 @@ KILLED & LINE!!!! \kill
 \textbf{First}&\textbf{Second}\\
 \hline\hline
 \endhead
+\caption*
+[An optional table foot caption (used in the list of tables)]
+{standard foot}\\
 \hline
 This goes at the&bottom.\\
 \hline
 \endfoot
+\caption*[]{(last foot)}\\
 \hline
 These lines will&appear\\
 in place of the & usual foot\\
index 749b458713836802c43ab0ad60a73f0b6f0af5f4..40bab9519949ea3f1f27515c786f509a590d3509 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass amsart
index 2e96425a8c68fa74f2073e3d18ce91fb3650381b..c072e31b2347650d6e90069dd893aebf60d8999e 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass book
index 621d9d6486ee8aa66abe7cbbcf845065374e4e17..cbddc698887dfbd2fc544500527f5e02e5fe7707 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 7cffee07e6dee210e59f441e77dace87049a5704..b86ec8fb6900ddb2523ca8a1cc285163455712de 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 7099d8dc13e7af3656cff14cadcf99285e01a463..9e13dccdca11d0f9406df720e918821a0e99298c 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 467
+\lyxformat 469
 \begin_document
 \begin_header
 \textclass article
index 3898fb63a2bd6a24fd7abfa0929793b32331ed6f..2206e003705373857181791318a9a8d9c6ff7fa5 100644 (file)
@@ -2792,10 +2792,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "caption") {
+                       bool starred = false;
+                       if (p.next_token().asInput() == "*") {
+                               p.get_token();
+                               starred = true;
+                       }
                        p.skip_spaces();
                        context.check_layout(os);
                        p.skip_spaces();
-                       begin_inset(os, "Caption Standard\n");
+                       if (starred)
+                               begin_inset(os, "Caption LongTableNoNumber\n");
+                       else
+                               begin_inset(os, "Caption Standard\n");
                        Context newcontext(true, context.textclass, 0, 0, context.font);
                        newcontext.check_layout(os);
                        // FIXME InsetArgument is now properly implemented in InsetLayout
index fcf348a21460f33cd51d252f5171020d402cebce..0aee452a278c6f6a7d197dd466525ed9717c63ee 100644 (file)
@@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 468 // uwestoehr: mbox/fbox support
-#define LYX_FORMAT_TEX2LYX 468 // uwestoehr: mbox/fbox support
+#define LYX_FORMAT_LYX 469 // gb: \caption*{}
+#define LYX_FORMAT_TEX2LYX 469 // gb: \caption*{}
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER