]> git.lyx.org Git - lyx.git/blobdiff - src/factory.cpp
Center correctly top labels like Abstract.
[lyx.git] / src / factory.cpp
index c69d37c205ec20c171d3909aa5d57b319a0f2eba..f255ef2540fbd783b94dda492272874c3c8dd59f 100644 (file)
@@ -26,6 +26,7 @@
 #include "insets/InsetBranch.h"
 #include "insets/InsetCaption.h"
 #include "insets/InsetCitation.h"
+#include "insets/InsetCounter.h"
 #include "insets/InsetFlex.h"
 #include "insets/InsetERT.h"
 #include "insets/InsetListings.h"
@@ -155,7 +156,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        string const arg2 = cmd.getArg(1);
                        if (arg1 != "deco") {
                                LYXERR0("LFUN_IPAMACRO_INSERT: wrong argument");
-                               return 0;
+                               return nullptr;
                        }
                        return new InsetIPADeco(buf, arg2);
                }
@@ -176,7 +177,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        string arg = cmd.getArg(0);
                        if (arg.empty()) {
                                LYXERR0("argument-insert needs an argument!");
-                               return 0;
+                               return nullptr;
                        }
                        return new InsetArgument(buf, arg);
                }
@@ -212,7 +213,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        if (argument == "figure" || argument == "table")
                                return new InsetWrap(buf, argument);
                        lyxerr << "Non-existent wrapfig type: " << argument << endl;
-                       return 0;
+                       return nullptr;
                }
 
                case LFUN_INDEX_INSERT: {
@@ -231,7 +232,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
 
                case LFUN_TABULAR_INSERT: {
                        if (cmd.argument().empty())
-                               return 0;
+                               return nullptr;
                        istringstream ss(to_utf8(cmd.argument()));
                        int r = 0, c = 0;
                        ss >> r >> c;
@@ -281,7 +282,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        switch (code) {
                        case NO_CODE:
                                lyxerr << "No such inset '" << name << "'.";
-                               return 0;
+                               return nullptr;
 
                        case BIBITEM_CODE: {
                                InsetCommandParams icp(code);
@@ -301,6 +302,12 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                                return new InsetCitation(buf, icp);
                        }
 
+                       case COUNTER_CODE: {
+                               InsetCommandParams icp(code);
+                               InsetCommand::string2params(to_utf8(cmd.argument()), icp);
+                               return new InsetCounter(buf, icp);
+                       }
+
                        case ERT_CODE: {
                                return new InsetERT(buf,
                                        InsetERT::string2params(to_utf8(cmd.argument())));
@@ -406,7 +413,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        default:
                                lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
                                                << endl;
-                               return 0;
+                               return nullptr;
 
                        }
                } //end LFUN_INSET_INSERT
@@ -478,7 +485,6 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        }
                        return new InsetSpace(isp);
                }
-               break;
 
                default:
                        break;
@@ -491,11 +497,11 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        lyx_exit(1);
                } else if (message.type_ == WarningException) {
                        Alert::warning(message.title_, message.details_);
-                       return 0;
+                       return nullptr;
                }
        }
 
-       return 0;
+       return nullptr;
 }
 
 
@@ -552,6 +558,9 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                        case CITE_CODE:
                                inset.reset(new InsetCitation(buf, inscmd));
                                break;
+                       case COUNTER_CODE:
+                               inset.reset(new InsetCounter(buf, inscmd));
+                               break;
                        case HYPERLINK_CODE:
                                inset.reset(new InsetHyperlink(buf, inscmd));
                                break;
@@ -575,7 +584,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                                break;
                        case REF_CODE:
                                if (inscmd["name"].empty() && inscmd["reference"].empty())
-                                       return 0;
+                                       return nullptr;
                                inset.reset(new InsetRef(buf, inscmd));
                                break;
                        case TOC_CODE:
@@ -587,7 +596,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                                                        << "'" << endl;
                                while (lex.isOK() && lex.getString() != "\\end_inset")
                                        lex.next();
-                               return 0;
+                               return nullptr;
                }
                inset->setBuffer(*buf);
        } else {
@@ -652,8 +661,8 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                        inset.reset(new InsetFloat(buf, string()));
                } else if (tmptok == "Wrap") {
                        lex.next();
-                       string tmptok = lex.getString();
-                       inset.reset(new InsetWrap(buf, tmptok));
+                       string tmptok2 = lex.getString();
+                       inset.reset(new InsetWrap(buf, tmptok2));
                } else if (tmptok == "Caption") {
                        lex.eatLine();
                        string s = lex.getString();
@@ -675,7 +684,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                               << "'" << endl;
                        while (lex.isOK() && lex.getString() != "\\end_inset")
                                lex.next();
-                       return 0;
+                       return nullptr;
                }
 
                // Set the buffer reference for proper parsing of some insets