]> git.lyx.org Git - lyx.git/commitdiff
Option to auto-insert a paragraph style option, particularly useful for specific...
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 16 Dec 2012 12:37:14 +0000 (13:37 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 16 Dec 2012 12:37:14 +0000 (13:37 +0100)
lib/doc/Customization.lyx
lib/layouts/beamer.layout
src/Layout.cpp
src/Layout.h
src/Text3.cpp

index 6d06e09c12317483ce8d0324aa06163fe88ddaa3..b852ed7a4384927f415da7c237274b59984bd7ea 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.1 created this file. For more info see http://www.lyx.org/
-\lyxformat 452
+\lyxformat 453
 \begin_document
 \begin_header
 \textclass scrbook
@@ -105,6 +105,7 @@ End
 \use_package mathdots 1
 \use_package mathtools 0
 \use_package mhchem 0
+\use_package stmaryrd 0
 \use_package undertilde 0
 \cite_engine basic
 \cite_engine_type numerical
@@ -10907,7 +10908,7 @@ reference "sub:Font-description"
 
 \begin_layout Itemize
 
-\change_inserted -712698321 1353917320
+\change_inserted -712698321 1355661048
 \begin_inset Flex Code
 status collapsed
 
@@ -10969,6 +10970,51 @@ Classic
 \end_inset
 
 .
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1355661160
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1355661057
+AutoInsert
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1355661049
+[int=0]
+\end_layout
+
+\end_inset
+
+ If this is set to 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1355661077
+1
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+, this argument is automatically inserted when the respective style is selected.
+ This option is currently only available for paragraph styles, not for InsetLayo
+uts.
 \change_inserted 155139281 1354198988
 
 \end_layout
index 75e5c9d8c2f4d655bc63c49680d018682f6de985..f65a2ff54f81d4568b5ea143d67c509ae5b5eb7a 100644 (file)
@@ -841,6 +841,7 @@ Style Block
       Color        blue
       Size         large
     EndFont
+    AutoInsert     1
   EndArgument
 End
 
index e53e99171bb848fc11dd09a0759d955d725c6e23..43a6c185ddc36f5a4d51e5ad27c8f8c86b8c39ac 100644 (file)
@@ -881,6 +881,7 @@ void Layout::readArgument(Lexer & lex)
 {
        latexarg arg;
        arg.mandatory = false;
+       arg.autoinsert = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
@@ -906,6 +907,9 @@ void Layout::readArgument(Lexer & lex)
                } else if (tok == "mandatory") {
                        lex.next();
                        arg.mandatory = lex.getBool();
+               } else if (tok == "autoinsert") {
+                       lex.next();
+                       arg.autoinsert = lex.getBool();
                } else if (tok == "leftdelim") {
                        lex.next();
                        arg.ldelim = lex.getDocString();
index a76dca6e89dad3b0c6606102bf84c5af2392d65a..7e5281d5dd87ebeef369750ea7c0338f9cdefbe5 100644 (file)
@@ -100,6 +100,7 @@ public:
                std::string decoration;
                FontInfo font;
                FontInfo labelfont;
+               bool autoinsert;
        };
        ///
        typedef std::map<std::string, latexarg> LaTeXArgMap;
index 421d8f428dc37255400d5a215f568a8a936aacb7..9400526c84d3271d7e10aa5688eb857e002424ab 100644 (file)
@@ -1372,6 +1372,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (change_layout)
                        setLayout(cur, layout);
 
+               Layout::LaTeXArgMap args = tclass[layout].latexargs();
+               Layout::LaTeXArgMap itemargs = tclass[layout].itemargs();
+               if (!itemargs.empty())
+                       args.insert(itemargs.begin(), itemargs.end());
+               Layout::LaTeXArgMap::const_iterator lait = args.begin();
+               Layout::LaTeXArgMap::const_iterator const laend = args.end();
+               for (; lait != laend; ++lait) {
+                       Layout::latexarg arg = (*lait).second;
+                       if (arg.autoinsert) {
+                               FuncRequest cmd(LFUN_ARGUMENT_INSERT, (*lait).first);
+                               lyx::dispatch(cmd);
+                       }
+               }
+
                break;
        }