]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
BufferParams.cpp: fix bug 3568:
[lyx.git] / src / Paragraph.cpp
index 08d0f77b67aa2e4d38fb96514e9caa1a26adb6a3..8f4f196ab352d7e6843b2e84471e2ae91cc87aa8 100644 (file)
@@ -76,7 +76,7 @@ using support::rsplit;
 /////////////////////////////////////////////////////////////////////
 
 class Encoding;
-class LyXLayout;
+class Layout;
 
 
 class Paragraph::Pimpl {
@@ -185,7 +185,7 @@ public:
                             pos_type & i,
                             unsigned int & column,
                             Font const & font,
-                            LyXLayout const & style);
+                            Layout const & style);
        ///
        void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
                                   odocstream &,
@@ -195,13 +195,13 @@ public:
                                   Font const & outerfont,
                                   bool & open_font,
                                   Change::Type & running_change,
-                                  LyXLayout const & style,
+                                  Layout const & style,
                                   pos_type & i,
                                   unsigned int & column, value_type const c);
 
        ///
        void validate(LaTeXFeatures & features,
-                     LyXLayout const & layout) const;
+                     Layout const & layout) const;
 
        ///
        unsigned int id_;
@@ -584,7 +584,7 @@ bool Paragraph::Pimpl::simpleTeXBlanks(Encoding const & encoding,
                                        pos_type & i,
                                       unsigned int & column,
                                       Font const & font,
-                                      LyXLayout const & style)
+                                      Layout const & style)
 {
        if (style.pass_thru)
                return false;
@@ -666,7 +666,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
                                             Font const & outerfont,
                                             bool & open_font,
                                             Change::Type & running_change,
-                                            LyXLayout const & style,
+                                            Layout const & style,
                                             pos_type & i,
                                             unsigned int & column,
                                             value_type const c)
@@ -702,7 +702,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
                        } else {
                                if (open_font) {
                                        column += running_font.latexWriteEndChanges(
-                                               os, basefont, basefont);
+                                               os, bparams, runparams,
+                                               basefont, basefont);
                                        open_font = false;
                                }
 
@@ -757,7 +758,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
                // some insets cannot be inside a font change command
                if (open_font && inset->noFontChange()) {
                        column += running_font.latexWriteEndChanges(
-                                       os, basefont, basefont);
+                                       os, bparams, runparams,
+                                               basefont, basefont);
                        open_font = false;
                        basefont = owner_->getLayoutFont(bparams, outerfont);
                        running_font = basefont;
@@ -942,7 +944,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
 
 
 void Paragraph::Pimpl::validate(LaTeXFeatures & features,
-                               LyXLayout const & layout) const
+                               Layout const & layout) const
 {
        BufferParams const & bparams = features.bufferParams();
 
@@ -991,7 +993,7 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features,
                {
                        features.useLanguage(language);
                        LYXERR(Debug::LATEX) << "Found language "
-                                            << language->babel() << endl;
+                                            << language->lang() << endl;
                }
        }
 
@@ -1326,7 +1328,7 @@ Font const Paragraph::getFirstFontSettings(BufferParams const & bparams) const
 
 
 // Gets the fully instantiated font at a given position in a paragraph
-// This is basically the same function as LyXText::GetFont() in text2.cpp.
+// This is basically the same function as Text::GetFont() in text2.cpp.
 // The difference is that this one is used for generating the LaTeX file,
 // and thus cosmetic "improvements" are disallowed: This has to deliver
 // the true picture of the buffer. (Asger)
@@ -1335,7 +1337,7 @@ Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
 {
        BOOST_ASSERT(pos >= 0);
 
-       LyXLayout_ptr const & lout = layout();
+       Layout_ptr const & lout = layout();
 
        pos_type const body_pos = beginOfBody();
 
@@ -1608,10 +1610,10 @@ docstring const Paragraph::translateIfPossible(docstring const & s,
 }
 
 
-docstring Paragraph::expandLabel(LyXLayout_ptr const & layout,
+docstring Paragraph::expandLabel(Layout_ptr const & layout,
                BufferParams const & bparams, bool process_appendix) const
 {
-       LyXTextClass const & tclass = bparams.getLyXTextClass();
+       TextClass const & tclass = bparams.getTextClass();
 
        docstring fmt;
        if (process_appendix && params().appendix())
@@ -1637,7 +1639,7 @@ docstring Paragraph::expandLabel(LyXLayout_ptr const & layout,
 }
 
 
-void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
+void Paragraph::applyLayout(Layout_ptr const & new_layout)
 {
        layout(new_layout);
        params().labelWidthString(docstring());
@@ -1905,7 +1907,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 
        bool return_value = false;
 
-       LyXLayout_ptr style;
+       Layout_ptr style;
 
        // well we have to check if we are in an inset with unlimited
        // length (all in one row) if that is true then we don't allow
@@ -1915,7 +1917,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
        bool asdefault = forceDefaultParagraphs();
 
        if (asdefault) {
-               style = bparams.getLyXTextClass().defaultLayout();
+               style = bparams.getTextClass().defaultLayout();
        } else {
                style = layout();
        }
@@ -1975,7 +1977,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                        if (body_pos > 0) {
                                if (open_font) {
                                        column += running_font.latexWriteEndChanges(
-                                               os, basefont, basefont);
+                                               os, bparams, runparams,
+                                               basefont, basefont);
                                        open_font = false;
                                }
                                basefont = getLayoutFont(bparams, outerfont);
@@ -2027,19 +2030,22 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                     font.language() != running_font.language()))
                {
                        column += running_font.latexWriteEndChanges(
-                                       os, basefont,
+                                       os, bparams, runparams, basefont,
                                        (i == body_pos-1) ? basefont : font);
                        running_font = basefont;
                        open_font = false;
                }
 
                // Switch file encoding if necessary
-               int const count = switchEncoding(os, bparams,
-                               runparams.moving_arg, *(runparams.encoding),
-                               *(font.language()->encoding()));
-               if (count > 0) {
-                       column += count;
-                       runparams.encoding = font.language()->encoding();
+               if (runparams.encoding->package() == Encoding::inputenc &&
+                   font.language()->encoding()->package() == Encoding::inputenc) {
+                       int const count = switchEncoding(os, bparams,
+                                       runparams.moving_arg, *(runparams.encoding),
+                                       *(font.language()->encoding()));
+                       if (count > 0) {
+                               column += count;
+                               runparams.encoding = font.language()->encoding();
+                       }
                }
 
                // Do we need to change font?
@@ -2047,7 +2053,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                     font.language() != running_font.language()) &&
                        i != body_pos - 1)
                {
-                       column += font.latexWriteStartChanges(os, basefont,
+                       column += font.latexWriteStartChanges(os, bparams,
+                                                             runparams, basefont,
                                                              last_font);
                        running_font = font;
                        open_font = true;
@@ -2087,11 +2094,12 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 #ifdef FIXED_LANGUAGE_END_DETECTION
                if (next_) {
                        running_font
-                               .latexWriteEndChanges(os, basefont,
+                               .latexWriteEndChanges(os, bparams, runparams,
+                                       basefont,
                                        next_->getFont(bparams, 0, outerfont));
                } else {
-                       running_font.latexWriteEndChanges(os, basefont,
-                                                         basefont);
+                       running_font.latexWriteEndChanges(os, bparams,
+                                       runparams, basefont, basefont);
                }
 #else
 #ifdef WITH_WARNINGS
@@ -2099,7 +2107,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 //#warning there as we start another \selectlanguage with the next paragraph if
 //#warning we are in need of this. This should be fixed sometime (Jug)
 #endif
-               running_font.latexWriteEndChanges(os, basefont, basefont);
+               running_font.latexWriteEndChanges(os, bparams, runparams,
+                               basefont, basefont);
 #endif
        }
 
@@ -2249,7 +2258,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 {
        bool emph_flag = false;
 
-       LyXLayout_ptr const & style = layout();
+       Layout_ptr const & style = layout();
        Font font_old =
                style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
 
@@ -2457,13 +2466,13 @@ int Paragraph::id() const
 }
 
 
-LyXLayout_ptr const & Paragraph::layout() const
+Layout_ptr const & Paragraph::layout() const
 {
        return layout_;
 }
 
 
-void Paragraph::layout(LyXLayout_ptr const & new_layout)
+void Paragraph::layout(Layout_ptr const & new_layout)
 {
        layout_ = new_layout;
 }