]> git.lyx.org Git - features.git/commitdiff
Pass local font to arguments and assure pass_thru is inherited
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 28 Nov 2012 18:02:07 +0000 (19:02 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 28 Nov 2012 18:02:07 +0000 (19:02 +0100)
src/.Layout.h.kate-swp [new file with mode: 0644]
src/Paragraph.cpp
src/insets/Inset.h
src/insets/InsetArgument.cpp
src/insets/InsetArgument.h
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetText.cpp
src/output_latex.cpp

diff --git a/src/.Layout.h.kate-swp b/src/.Layout.h.kate-swp
new file mode 100644 (file)
index 0000000..2bc3cb2
Binary files /dev/null and b/src/.Layout.h.kate-swp differ
index 6d19c866c25224e3f02260084716c021cfc69c6a..5095026a9241a6fc3e5532d220661e216c2e6130 100644 (file)
@@ -1461,9 +1461,11 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                        // we have to provide all the optional arguments here, even though
                        // the last one is the only one we care about.
                        // Separate handling of optional argument inset.
-                       if (!layout_->latexargs().empty())
-                               latexArgInsets(*owner_, os, features.runparams(),
-                                              layout_->latexargs());
+                       if (!layout_->latexargs().empty()) {
+                               OutputParams rp = features.runparams();
+                               rp.local_font = &owner_->getFirstFontSettings(bp);
+                               latexArgInsets(*owner_, os, rp, layout_->latexargs());
+                       }
                        os << from_ascii(layout_->latexparam());
                }
                docstring::size_type const length = ods.str().length();
@@ -2168,7 +2170,7 @@ bool Paragraph::usePlainLayout() const
 
 bool Paragraph::isPassThru() const
 {
-       return inInset().getLayout().isPassThru() || d->layout_->pass_thru;
+       return inInset().isPassThru() || d->layout_->pass_thru;
 }
 
 namespace {
index fbe664d5f6c3a43759b132d91d884b6ea7ced297..b1070d8a33d051b960568dbeb03e36f5be75084e 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ColorCode.h"
 #include "InsetCode.h"
+#include "InsetLayout.h"
 #include "LayoutEnums.h"
 #include "OutputEnums.h"
 
@@ -418,6 +419,8 @@ public:
        virtual docstring layoutName() const;
        ///
        virtual InsetLayout const & getLayout() const;
+       ///
+       virtual bool isPassThru() const { return getLayout().isPassThru(); }
        /// Is this inset's layout defined in the document's textclass?
        bool undefined() const;
        /// should this inset be handled like a normal character?
index b113878f062e9c60eee7c65702ac86daa6fedc5b..533c4239956bbb5170ce4603221cb3f0f0f2376d 100644 (file)
 
 #include "InsetArgument.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
 #include "Cursor.h"
 #include "FuncStatus.h"
 #include "FuncRequest.h"
 #include "InsetList.h"
+#include "Language.h"
 #include "Layout.h"
 #include "Lexer.h"
 #include "OutputParams.h"
@@ -35,7 +38,8 @@ namespace lyx {
 
 InsetArgument::InsetArgument(Buffer * buf, string const & name)
     : InsetCollapsable(buf), name_(name), labelstring_(docstring()),
-      font_(inherit_font), labelfont_(inherit_font), decoration_(string())
+      font_(inherit_font), labelfont_(inherit_font), decoration_(string()),
+      pass_thru_(false)
 {}
 
 
@@ -55,16 +59,19 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
 {
        Layout::LaTeXArgMap args;
        bool const insetlayout = &it.inset() && it.paragraph().layout().latexargs().empty();
-       if (insetlayout)
+       if (insetlayout) {
                args = it.inset().getLayout().latexargs();
-       else
+               pass_thru_ = it.inset().getLayout().isPassThru();
+       } else {
                args = it.paragraph().layout().latexargs();
-
+               pass_thru_ = it.paragraph().layout().pass_thru;
+       }
+       
        // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
        if (name_ == "999") {
-               unsigned int const req = insetlayout ? it.inset().getLayout().numRequiredArgs()
+               unsigned int const req = insetlayout ? it.inset().getLayout().requiredArgs()
                                      : it.paragraph().layout().requiredArgs();
-               unsigned int const opts = insetlayout ? it.inset().getLayout().numOptArgs()
+               unsigned int const opts = insetlayout ? it.inset().getLayout().optArgs()
                                      : it.paragraph().layout().optArgs();
                unsigned int nr = 0;
                unsigned int ours = 0;
@@ -251,8 +258,6 @@ void InsetArgument::latexArgument(otexstream & os,
        odocstringstream ss;
        otexstream ots(ss, texrow);
        OutputParams runparams = runparams_in;
-       if (getLayout().isPassThru())
-               runparams.pass_thru = true;
        InsetText::latex(ots, runparams);
        docstring str = ss.str();
        if (ldelim != "{" && support::contains(str, rdelim))
index bff6056934e8ad2d1e23c217539ae0043cb4f5eb..1b5050db95e485ef1f052b69facce60d7e46f58b 100644 (file)
@@ -62,6 +62,8 @@ public:
        bool neverIndent() const { return true; }
        ///
        std::string contextMenuName() const;
+       ///
+       bool isPassThru() const { return pass_thru_; }
        //@}
        /// \name Public functions inherited from InsetCollapsable class
        //@{
@@ -90,6 +92,8 @@ private:
        FontInfo labelfont_;
        ///
        std::string decoration_;
+       ///
+       bool pass_thru_;
 
 protected:
        /// \name Protected functions inherited from Inset class
index 3b5589d8b84c6cb614207d5b3a4d341b68ef0ad0..1d7d1f0ee436ac3f9c41653f1ba557e449d5cb9a 100644 (file)
@@ -544,7 +544,7 @@ void InsetLayout::readArgument(Lexer & lex)
                latexargs_[nr] = arg;
 }
 
-unsigned int InsetLayout::numOptArgs() const
+unsigned int InsetLayout::optArgs() const
 {
        unsigned int nr = 0;
        Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
@@ -556,7 +556,7 @@ unsigned int InsetLayout::numOptArgs() const
 }
 
 
-unsigned int InsetLayout::numRequiredArgs() const
+unsigned int InsetLayout::requiredArgs() const
 {
        unsigned int nr = 0;
        Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
index 4f5a6b89e3f6e27cb21e526fc204868ba631df61..7ae505ae75daf11306bf23ec15cbf3c011386d4b 100644 (file)
@@ -88,9 +88,9 @@ public:
        ///
        Layout::LaTeXArgMap latexargs() const { return latexargs_; }
        ///
-       unsigned int numOptArgs() const;
+       unsigned int optArgs() const;
        ///
-       unsigned int numRequiredArgs() const;
+       unsigned int requiredArgs() const;
        ///
        docstring preamble() const { return preamble_; }
        /// Get language dependent macro definitions needed for this inset
index 4760df5024ac13dd2cfb6be44484d70ad769cf1d..d1c80009bae398ea07629e1a69518b79bc425ddc 100644 (file)
@@ -266,7 +266,7 @@ void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        LYXERR(Debug::ACTION, "InsetText::doDispatch(): cmd: " << cmd);
 
-       if (getLayout().isPassThru()) {
+       if (isPassThru()) {
                // Force any new text to latex_language FIXME: This
                // should only be necessary in constructor, but new
                // paragraphs that are created by pressing enter at
@@ -436,7 +436,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
                        if (runparams.moving_arg)
                                os << "\\protect";
                        os << '\\' << from_utf8(il.latexname());
-                       getOptArg(os, runparams);
+                       if (!il.latexargs().empty())
+                               getOptArg(os, runparams);
                        if (!il.latexparam().empty())
                                os << from_utf8(il.latexparam());
                        os << '{';
@@ -449,13 +450,15 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
                                os.texrow().start(runparams.lastid,
                                                  runparams.lastpos);
                        os << "\\begin{" << from_utf8(il.latexname()) << "}";
-                       getOptArg(os, runparams);
+                       if (!il.latexargs().empty())
+                               getOptArg(os, runparams);
                        if (!il.latexparam().empty())
                                os << from_utf8(il.latexparam());
                        os << '\n';
                }
        } else {
-               getOptArg(os, runparams);
+               if (!il.latexargs().empty())
+                       getOptArg(os, runparams);
                if (!il.latexparam().empty())
                        os << from_utf8(il.latexparam());
        }
@@ -464,7 +467,7 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
                os << il.leftdelim();
 
        OutputParams rp = runparams;
-       if (il.isPassThru())
+       if (isPassThru())
                rp.pass_thru = true;
        if (il.isNeedProtect())
                rp.moving_arg = true;
@@ -605,8 +608,13 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
 }
 
 void InsetText::getOptArg(otexstream & os,
-                       OutputParams const & runparams) const
+                       OutputParams const & runparams_in) const
 {
+       OutputParams runparams = runparams_in;
+       runparams.local_font =
+               &paragraphs()[0].getFirstFontSettings(buffer().masterBuffer()->params());
+       if (isPassThru())
+               runparams.pass_thru = true;
        latexArgInsets(paragraphs()[0], os, runparams, getLayout().latexargs());
 }
 
@@ -728,7 +736,7 @@ bool InsetText::insetAllowed(InsetCode code) const
        case ARG_CODE:
                return true;
        default:
-               return !getLayout().isPassThru();
+               return !isPassThru();
        }
 }
 
index e211fafb6817808cd366f43780b3ed19d469d7b5..551a2496bdb33ede5a23644d2e858477dbb61b3c 100644 (file)
@@ -162,8 +162,11 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
 
        if (style.isEnvironment()) {
                os << "\\begin{" << from_ascii(style.latexname()) << '}';
-               if (!style.latexargs().empty())
-                   latexArgInsets(*pit, os, runparams, style.latexargs());
+               if (!style.latexargs().empty()) {
+                   OutputParams rp = runparams;
+                   rp.local_font = &pit->getFirstFontSettings(bparams);
+                   latexArgInsets(*pit, os, rp, style.latexargs());
+               }
                if (style.latextype == LATEX_LIST_ENVIRONMENT) {
                        os << '{'
                           << pit->params().labelWidthString()
@@ -465,7 +468,7 @@ void TeXOnePar(Buffer const & buf,
                open_encoding_ = none;
        }
 
-       if (text.inset().getLayout().isPassThru()) {
+       if (text.inset().isPassThru()) {
                Font const outerfont = text.outerFont(pit);
 
                // No newline before first paragraph in this lyxtext
@@ -484,6 +487,7 @@ void TeXOnePar(Buffer const & buf,
 
        if (style.pass_thru) {
                Font const outerfont = text.outerFont(pit);
+               runparams.local_font = &par.getFirstFontSettings(bparams);
                parStartCommand(par, os, runparams, style);
 
                par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
@@ -712,8 +716,8 @@ void TeXOnePar(Buffer const & buf,
                }
        }
 
+       runparams.local_font = &par.getFirstFontSettings(bparams);
        parStartCommand(par, os, runparams, style);
-
        Font const outerfont = text.outerFont(pit);
 
        // FIXME UNICODE