The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 53002538fa2f87ae732f9830f24bb819ed402a72
Author: Juergen Spitzmueller <[email protected]>
Date:   Wed Nov 28 19:02:07 2012 +0100

    Pass local font to arguments and assure pass_thru is inherited

diff --git a/src/.Layout.h.kate-swp b/src/.Layout.h.kate-swp
new file mode 100644
index 0000000..2bc3cb2
Binary files /dev/null and b/src/.Layout.h.kate-swp differ
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 6d19c86..5095026 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -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 {
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index fbe664d..b1070d8 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -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?
diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp
index b113878..533c423 100644
--- a/src/insets/InsetArgument.cpp
+++ b/src/insets/InsetArgument.cpp
@@ -13,10 +13,13 @@
 
 #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))
diff --git a/src/insets/InsetArgument.h b/src/insets/InsetArgument.h
index bff6056..1b5050d 100644
--- a/src/insets/InsetArgument.h
+++ b/src/insets/InsetArgument.h
@@ -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
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index 3b5589d..1d7d1f0 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -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();
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 4f5a6b8..7ae505a 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -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
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 4760df5..d1c8000 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -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();
        }
 }
 
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index e211faf..551a249 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -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

-----------------------------------------------------------------------

Summary of changes:
 src/.Layout.h.kate-swp       |  Bin 0 -> 79 bytes
 src/Paragraph.cpp            |   10 ++++++----
 src/insets/Inset.h           |    3 +++
 src/insets/InsetArgument.cpp |   21 +++++++++++++--------
 src/insets/InsetArgument.h   |    4 ++++
 src/insets/InsetLayout.cpp   |    4 ++--
 src/insets/InsetLayout.h     |    4 ++--
 src/insets/InsetText.cpp     |   22 +++++++++++++++-------
 src/output_latex.cpp         |   12 ++++++++----
 9 files changed, 53 insertions(+), 27 deletions(-)
 create mode 100644 src/.Layout.h.kate-swp


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to