Author: rgheck
Date: Sat Jun  5 00:44:58 2010
New Revision: 34596
URL: http://www.lyx.org/trac/changeset/34596

Log:
Rename InsetOptArg as InsetArgument.

Added:
   lyx-devel/trunk/src/insets/InsetArgument.cpp
   lyx-devel/trunk/src/insets/InsetArgument.h
Deleted:
   lyx-devel/trunk/src/insets/InsetOptArg.cpp
   lyx-devel/trunk/src/insets/InsetOptArg.h
Modified:
   lyx-devel/trunk/development/qmake/lyx.pro
   lyx-devel/trunk/development/scons/scons_manifest.py
   lyx-devel/trunk/src/Makefile.am
   lyx-devel/trunk/src/ParagraphMetrics.cpp
   lyx-devel/trunk/src/Text.cpp
   lyx-devel/trunk/src/Text3.cpp
   lyx-devel/trunk/src/TocBackend.cpp
   lyx-devel/trunk/src/factory.cpp
   lyx-devel/trunk/src/insets/Inset.cpp
   lyx-devel/trunk/src/insets/InsetCaption.cpp
   lyx-devel/trunk/src/insets/InsetCode.h
   lyx-devel/trunk/src/insets/InsetText.cpp
   lyx-devel/trunk/src/output_latex.cpp

Modified: lyx-devel/trunk/development/qmake/lyx.pro
==============================================================================
--- lyx-devel/trunk/development/qmake/lyx.pro   Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/development/qmake/lyx.pro   Sat Jun  5 00:44:58 2010        
(r34596)
@@ -152,6 +152,7 @@
 ../../src/insets/ExternalSupport.cpp \
 ../../src/insets/ExternalTemplate.cpp \
 ../../src/insets/ExternalTransforms.cpp \
+../../src/insets/InsetArgument.cpp \
 ../../src/insets/InsetBibitem.cpp \
 ../../src/insets/InsetBibtex.cpp \
 ../../src/insets/InsetBox.cpp \
@@ -185,7 +186,6 @@
 ../../src/insets/InsetNewpage.cpp \
 ../../src/insets/InsetNomencl.cpp \
 ../../src/insets/InsetNote.cpp \
-../../src/insets/InsetOptArg.cpp \
 ../../src/insets/InsetPhantom.cpp \
 ../../src/insets/InsetQuotes.cpp \
 ../../src/insets/InsetRef.cpp \
@@ -494,6 +494,7 @@
 ../../src/insets/ExternalTemplate.h \
 ../../src/insets/ExternalTransforms.h \
 ../../src/insets/Inset.h \
+../../src/insets/InsetArgument.h \
 ../../src/insets/InsetBibitem.h \
 ../../src/insets/InsetBibtex.h \
 ../../src/insets/InsetBox.h \
@@ -527,7 +528,6 @@
 ../../src/insets/InsetNewpage.h \
 ../../src/insets/InsetNomencl.h \
 ../../src/insets/InsetNote.h \
-../../src/insets/InsetOptArg.h \
 ../../src/insets/InsetQuotes.h \
 ../../src/insets/InsetPhantom.h \
 ../../src/insets/InsetRef.h \

Modified: lyx-devel/trunk/development/scons/scons_manifest.py
==============================================================================
--- lyx-devel/trunk/development/scons/scons_manifest.py Sat Jun  5 00:28:21 
2010        (r34595)
+++ lyx-devel/trunk/development/scons/scons_manifest.py Sat Jun  5 00:44:58 
2010        (r34596)
@@ -1003,6 +1003,7 @@
     ExternalTemplate.h
     ExternalTransforms.h
     Inset.h
+    InsetArgument.h
     InsetBibitem.h
     InsetBibtex.h
     InsetBox.h
@@ -1036,7 +1037,6 @@
     InsetNewpage.h
     InsetNomencl.h
     InsetNote.h
-    InsetOptArg.h
     InsetPhantom.h
     InsetPreview.h
     InsetQuotes.h
@@ -1060,6 +1060,7 @@
     ExternalTemplate.cpp
     ExternalTransforms.cpp
     Inset.cpp
+    InsetArgument.cpp
     InsetBibitem.cpp
     InsetBibtex.cpp
     InsetBox.cpp
@@ -1092,7 +1093,6 @@
     InsetNewpage.cpp
     InsetNomencl.cpp
     InsetNote.cpp
-    InsetOptArg.cpp
     InsetPhantom.cpp
     InsetPreview.cpp
     InsetQuotes.cpp

Modified: lyx-devel/trunk/src/Makefile.am
==============================================================================
--- lyx-devel/trunk/src/Makefile.am     Sat Jun  5 00:28:21 2010        (r34595)
+++ lyx-devel/trunk/src/Makefile.am     Sat Jun  5 00:44:58 2010        (r34596)
@@ -514,6 +514,7 @@
        insets/RenderGraphic.cpp \
        insets/RenderPreview.cpp \
        insets/Inset.cpp \
+       insets/InsetArgument.cpp \
        insets/InsetBibitem.cpp \
        insets/InsetBibtex.cpp \
        insets/InsetBox.cpp \
@@ -546,7 +547,6 @@
        insets/InsetNewpage.cpp \
        insets/InsetNomencl.cpp \
        insets/InsetNote.cpp \
-       insets/InsetOptArg.cpp \
        insets/InsetPhantom.cpp \
        insets/InsetPreview.cpp \
        insets/InsetQuotes.cpp \
@@ -568,6 +568,7 @@
        insets/RenderGraphic.h \
        insets/RenderPreview.h \
        insets/Inset.h \
+       insets/InsetArgument.h \
        insets/InsetBibitem.h \
        insets/InsetBibtex.h \
        insets/InsetBox.h \
@@ -602,7 +603,6 @@
        insets/InsetNewpage.h \
        insets/InsetNomencl.h \
        insets/InsetNote.h \
-       insets/InsetOptArg.h \
        insets/InsetPhantom.h \
        insets/InsetQuotes.h \
        insets/InsetRef.h \

Modified: lyx-devel/trunk/src/ParagraphMetrics.cpp
==============================================================================
--- lyx-devel/trunk/src/ParagraphMetrics.cpp    Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/ParagraphMetrics.cpp    Sat Jun  5 00:44:58 2010        
(r34596)
@@ -39,7 +39,7 @@
 #include "frontends/FontMetrics.h"
 
 #include "insets/InsetBibitem.h"
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 
 #include "support/lassert.h"
 #include "support/debug.h"

Modified: lyx-devel/trunk/src/Text.cpp
==============================================================================
--- lyx-devel/trunk/src/Text.cpp        Sat Jun  5 00:28:21 2010        (r34595)
+++ lyx-devel/trunk/src/Text.cpp        Sat Jun  5 00:44:58 2010        (r34596)
@@ -56,7 +56,7 @@
 #include "insets/InsetLine.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetNewpage.h"
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 #include "insets/InsetSpace.h"
 #include "insets/InsetSpecialChar.h"
 #include "insets/InsetTabular.h"

Modified: lyx-devel/trunk/src/Text3.cpp
==============================================================================
--- lyx-devel/trunk/src/Text3.cpp       Sat Jun  5 00:28:21 2010        (r34595)
+++ lyx-devel/trunk/src/Text3.cpp       Sat Jun  5 00:44:58 2010        (r34596)
@@ -2342,10 +2342,10 @@
                code = INFO_CODE;
                break;
        case LFUN_OPTIONAL_INSERT: {
-               code = OPTARG_CODE;
+               code = ARG_CODE;
                Layout const & lay = cur.paragraph().layout();
                int const numargs = lay.reqargs + lay.optargs;
-               enable = cur.paragraph().insetList().count(OPTARG_CODE) < 
numargs;
+               enable = cur.paragraph().insetList().count(ARG_CODE) < numargs;
                break;
        }
        case LFUN_INDEX_INSERT:

Modified: lyx-devel/trunk/src/TocBackend.cpp
==============================================================================
--- lyx-devel/trunk/src/TocBackend.cpp  Sat Jun  5 00:28:21 2010        (r34595)
+++ lyx-devel/trunk/src/TocBackend.cpp  Sat Jun  5 00:44:58 2010        (r34596)
@@ -25,7 +25,7 @@
 #include "ParIterator.h"
 #include "TextClass.h"
 
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
@@ -142,11 +142,11 @@
        InsetList::const_iterator end = par.insetList().end();
        for (; it != end; ++it) {
                Inset & inset = *it->inset;
-               if (inset.lyxCode() == OPTARG_CODE) {
+               if (inset.lyxCode() == ARG_CODE) {
                        if (!tocstring.empty())
                                break;
                        Paragraph const & inset_par =
-                               
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
+                               
*static_cast<InsetArgument&>(inset).paragraphs().begin();
                        if (!par.labelString().empty())
                                tocstring = par.labelString() + ' ';
                        tocstring += inset_par.asString(AS_STR_INSETS);

Modified: lyx-devel/trunk/src/factory.cpp
==============================================================================
--- lyx-devel/trunk/src/factory.cpp     Sat Jun  5 00:28:21 2010        (r34595)
+++ lyx-devel/trunk/src/factory.cpp     Sat Jun  5 00:44:58 2010        (r34596)
@@ -45,7 +45,7 @@
 #include "insets/InsetNewpage.h"
 #include "insets/InsetNomencl.h"
 #include "insets/InsetNote.h"
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 #include "insets/InsetPhantom.h"
 #include "insets/InsetPreview.h"
 #include "insets/InsetRef.h"
@@ -145,7 +145,7 @@
                        return new InsetMarginal(buf);
 
                case LFUN_OPTIONAL_INSERT:
-                       return new InsetOptArg(buf);
+                       return new InsetArgument(buf);
 
                case LFUN_FLOAT_INSERT:
                        return new InsetFloat(buf, to_utf8(cmd.argument()));
@@ -563,7 +563,7 @@
                } else if (tmptok == "Newline") {
                        inset.reset(new InsetNewline);
                } else if (tmptok == "OptArg") {
-                       inset.reset(new InsetOptArg(buf));
+                       inset.reset(new InsetArgument(buf));
                } else if (tmptok == "Float") {
                        inset.reset(new InsetFloat(buf, string()));
                } else if (tmptok == "Wrap") {

Modified: lyx-devel/trunk/src/insets/Inset.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/Inset.cpp        Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/insets/Inset.cpp        Sat Jun  5 00:44:58 2010        
(r34596)
@@ -102,7 +102,7 @@
        insetnames[FLOAT_LIST_CODE] = InsetName("floatlist");
        insetnames[INDEX_PRINT_CODE] = InsetName("index_print");
        insetnames[NOMENCL_PRINT_CODE] = InsetName("nomencl_print");
-       insetnames[OPTARG_CODE] = InsetName("optarg");
+       insetnames[ARG_CODE] = InsetName("optarg");
        insetnames[NEWLINE_CODE] = InsetName("newline");
        insetnames[LINE_CODE] = InsetName("line");
        insetnames[BRANCH_CODE] = InsetName("branch", _("Branch"));

Added: lyx-devel/trunk/src/insets/InsetArgument.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ lyx-devel/trunk/src/insets/InsetArgument.cpp        Sat Jun  5 00:44:58 
2010        (r34596)
@@ -0,0 +1,73 @@
+/**
+ * \file InsetArgument.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetArgument.h"
+
+#include "support/debug.h"
+#include "support/docstream.h"
+#include "support/gettext.h"
+
+using namespace std;
+
+namespace lyx {
+
+
+InsetArgument::InsetArgument(Buffer * buf)
+       : InsetCollapsable(buf)
+{}
+
+
+void InsetArgument::write(ostream & os) const
+{
+       os << "OptArg" << "\n";
+       InsetCollapsable::write(os);
+}
+
+
+int InsetArgument::latex(odocstream &, OutputParams const &) const
+{
+       return 0;
+}
+
+
+int InsetArgument::plaintext(odocstream &, OutputParams const &) const
+{
+       return 0; // do not output optional arguments
+}
+
+
+int InsetArgument::docbook(odocstream &, OutputParams const &) const
+{
+       return 0;
+}
+
+
+docstring InsetArgument::xhtml(XHTMLStream &, OutputParams const &) const
+{
+       return docstring();
+}
+
+int InsetArgument::latexArgument(odocstream & os,
+               OutputParams const & runparams, bool optional) const
+{
+       odocstringstream ss;
+       int ret = InsetText::latex(ss, runparams);
+       docstring str = ss.str();
+       if (optional && str.find(']') != docstring::npos)
+               str = '{' + str + '}';
+       os << (optional ? '[' : '{') << str
+          << (optional ? ']' : '}');
+       return ret;
+}
+
+
+} // namespace lyx

Added: lyx-devel/trunk/src/insets/InsetArgument.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ lyx-devel/trunk/src/insets/InsetArgument.h  Sat Jun  5 00:44:58 2010        
(r34596)
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+/**
+ * \file InsetArgument.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSETOPTARG_H
+#define INSETOPTARG_H
+
+
+#include "InsetCollapsable.h"
+
+
+namespace lyx {
+
+
+/**
+ * InsetArgument. Used to insert a short version of sectioning header etc.
+ * automatically, or other optional LaTeX arguments
+ */
+class InsetArgument : public InsetCollapsable
+{
+public:
+       ///
+       InsetArgument(Buffer *);
+
+       /// Outputting the parameter of a LaTeX command
+       int latexArgument(odocstream &, OutputParams const &,
+                       bool optional) const;
+       ///
+       bool hasSettings() const { return false; }
+
+private:
+       /// code of the inset
+       InsetCode lyxCode() const { return ARG_CODE; }
+       ///
+       docstring name() const { return from_ascii("OptArg"); }
+       /// Standard LaTeX output -- short-circuited
+       int latex(odocstream &, OutputParams const &) const;
+       /// Standard plain text output -- short-circuited
+       int plaintext(odocstream &, OutputParams const &) const;
+       /// Standard DocBook output -- short-circuited
+       int docbook(odocstream &, OutputParams const &) const;
+       /// Standard XHTML output -- short-circuited
+       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       /// Write out to the .lyx file
+       void write(std::ostream & os) const;
+       /// should paragraph indendation be ommitted in any case?
+       bool neverIndent() const { return true; }
+       ///
+       Inset * clone() const { return new InsetArgument(*this); }
+};
+
+
+} // namespace lyx
+
+#endif // INSETOPTARG_H

Modified: lyx-devel/trunk/src/insets/InsetCaption.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetCaption.cpp Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/insets/InsetCaption.cpp Sat Jun  5 00:44:58 2010        
(r34596)
@@ -199,7 +199,7 @@
                return true;
 
        case LFUN_OPTIONAL_INSERT:
-               status.setEnabled(cur.paragraph().insetList().find(OPTARG_CODE) 
== -1);
+               status.setEnabled(cur.paragraph().insetList().find(ARG_CODE) == 
-1);
                return true;
 
        case LFUN_INSET_TOGGLE:

Modified: lyx-devel/trunk/src/insets/InsetCode.h
==============================================================================
--- lyx-devel/trunk/src/insets/InsetCode.h      Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/insets/InsetCode.h      Sat Jun  5 00:44:58 2010        
(r34596)
@@ -83,7 +83,7 @@
        ///
        INDEX_PRINT_CODE,
        ///
-       OPTARG_CODE,
+       ARG_CODE,
        ///
        CELL_CODE,
        ///

Modified: lyx-devel/trunk/src/insets/InsetText.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetText.cpp    Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/insets/InsetText.cpp    Sat Jun  5 00:44:58 2010        
(r34596)
@@ -12,7 +12,7 @@
 
 #include "InsetText.h"
 
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 
 #include "buffer_funcs.h"
 #include "Buffer.h"
@@ -700,12 +700,12 @@
                        //lyxerr << (void*)&inset << " code: " << 
inset.lyxCode() << std::endl;
                        inset.addToToc(dit);
                        switch (inset.lyxCode()) {
-                       case OPTARG_CODE: {
+                       case ARG_CODE: {
                                if (!tocstring.empty())
                                        break;
                                dit.pos() = 0;
                                Paragraph const & insetpar =
-                                       
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
+                                       
*static_cast<InsetArgument&>(inset).paragraphs().begin();
                                if (!par.labelString().empty())
                                        tocstring = par.labelString() + ' ';
                                tocstring += insetpar.asString(AS_STR_INSETS);

Modified: lyx-devel/trunk/src/output_latex.cpp
==============================================================================
--- lyx-devel/trunk/src/output_latex.cpp        Sat Jun  5 00:28:21 2010        
(r34595)
+++ lyx-devel/trunk/src/output_latex.cpp        Sat Jun  5 00:44:58 2010        
(r34596)
@@ -27,7 +27,7 @@
 #include "VSpace.h"
 
 #include "insets/InsetBibitem.h"
-#include "insets/InsetOptArg.h"
+#include "insets/InsetArgument.h"
 
 #include "support/lassert.h"
 #include "support/debug.h"
@@ -284,18 +284,18 @@
        unsigned int optargs)
 {
        unsigned int totalargs = reqargs + optargs;
-       list<InsetOptArg const *> ilist;
+       list<InsetArgument const *> ilist;
 
        InsetList::const_iterator it = par.insetList().begin();
        InsetList::const_iterator end = par.insetList().end();
        for (; it != end; ++it) {
-               if (it->inset->lyxCode() == OPTARG_CODE) {
+               if (it->inset->lyxCode() == ARG_CODE) {
                        if (ilist.size() >= totalargs) {
                                LYXERR0("WARNING: Found extra argument inset.");
                                continue;
                        }
-                       InsetOptArg const * ins =
-                               static_cast<InsetOptArg const *>(it->inset);
+                       InsetArgument const * ins =
+                               static_cast<InsetArgument const *>(it->inset);
                        ilist.push_back(ins);
                }
        }
@@ -308,7 +308,7 @@
        if (have_optional_args) {
                unsigned int todo = ilist.size() - reqargs;
                for (unsigned int i = 0; i < todo; ++i) {
-                       InsetOptArg const * ins = ilist.front();
+                       InsetArgument const * ins = ilist.front();
                        ilist.pop_front();
                        lines += ins->latexArgument(os, runparams, true);
                }
@@ -325,7 +325,7 @@
                        // a required argument wasn't given, so we output {}
                        os << "{}";
                else {
-                       InsetOptArg const * ins = ilist.front();
+                       InsetArgument const * ins = ilist.front();
                        ilist.pop_front();
                        lines += ins->latexArgument(os, runparams, false);
                }

Reply via email to