From ef2fda75001fdb13689cb3071d3dec2c96063429 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 8 Nov 2006 17:22:44 +0000 Subject: [PATCH] use docstring for textclass preambles git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15808 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LaTeXFeatures.C | 6 +++--- src/LaTeXFeatures.h | 2 +- src/bufferparams.C | 22 +++++++++++----------- src/lyxlayout.C | 2 +- src/lyxlayout.h | 4 ++-- src/lyxtextclass.C | 6 +++--- src/lyxtextclass.h | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 81309285f5..63dd2abfe6 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -481,11 +481,11 @@ string const LaTeXFeatures::getBabelOptions() const } -string const LaTeXFeatures::getTClassPreamble() const +docstring const LaTeXFeatures::getTClassPreamble() const { // the text class specific preamble LyXTextClass const & tclass = params_.getLyXTextClass(); - ostringstream tcpreamble; + odocstringstream tcpreamble; tcpreamble << tclass.preamble(); @@ -539,7 +539,7 @@ void LaTeXFeatures::showStruct() const { lyxerr << "LyX needs the following commands when LaTeXing:" << "\n***** Packages:" << getPackages() << "\n***** Macros:" << getMacros() - << "\n***** Textclass stuff:" << getTClassPreamble() + << "\n***** Textclass stuff:" << to_utf8(getTClassPreamble()) << "\n***** done." << endl; } diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 84e43dbbe2..48524f30a2 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -54,7 +54,7 @@ public: /// std::string const getBabelOptions() const; /// The definitions needed by the document's textclass - std::string const getTClassPreamble() const; + docstring const getTClassPreamble() const; /// The sgml definitions needed by the document (docbook) docstring const getLyXSGMLEntities() const; /// The SGML Required to include the files added with includeFile(); diff --git a/src/bufferparams.C b/src/bufferparams.C index bd7167a3fb..48c17ec5f1 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -1012,13 +1012,13 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // Now insert the LyX specific LaTeX commands... // The optional packages; - string lyxpreamble(features.getPackages()); + docstring lyxpreamble(from_ascii(features.getPackages())); // this might be useful... lyxpreamble += "\n\\makeatletter\n"; // Some macros LyX will need - string tmppreamble(features.getMacros()); + docstring tmppreamble(from_ascii(features.getMacros())); if (!tmppreamble.empty()) { lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " @@ -1036,9 +1036,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, /* the user-defined preamble */ if (!preamble.empty()) { + // FIXME UNICODE lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " "User specified LaTeX commands.\n" - + preamble + '\n'; + + from_utf8(preamble) + '\n'; } // Itemize bullet settings need to be last in case the user @@ -1047,11 +1048,11 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // Actually it has to be done much later than that // since some packages like frenchb make modifications // at \begin{document} time -- JMarc - string bullets_def; + docstring bullets_def; for (int i = 0; i < 4; ++i) { if (user_defined_bullet(i) != ITEMIZE_DEFAULTS[i]) { if (bullets_def.empty()) - bullets_def="\\AtBeginDocument{\n"; + bullets_def += "\\AtBeginDocument{\n"; bullets_def += " \\def\\labelitemi"; switch (i) { // `i' is one less than the item to modify @@ -1067,9 +1068,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, bullets_def += 'v'; break; } - // FIXME UNICODE bullets_def += '{' + - lyx::to_ascii(user_defined_bullet(i).getText()) + user_defined_bullet(i).getText() + "}\n"; } } @@ -1081,8 +1081,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // with other packages. // Jurabib has to be called after babel, though. if (use_babel && !features.isRequired("jurabib")) { - lyxpreamble += babelCall(language_options.str()) + '\n'; - lyxpreamble += features.getBabelOptions(); + // FIXME UNICODE + lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; + lyxpreamble += from_utf8(features.getBabelOptions()); } lyxpreamble += "\\makeatother\n"; @@ -1103,8 +1104,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, texrow.newline(); } - // FIXME UNICODE - os << from_utf8(lyxpreamble); + os << lyxpreamble; return use_babel; } diff --git a/src/lyxlayout.C b/src/lyxlayout.C index 96c6befd73..f54d8145e9 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -360,7 +360,7 @@ bool LyXLayout::read(LyXLex & lexrc, LyXTextClass const & tclass) break; case LT_PREAMBLE: - preamble_ = lexrc.getLongString("EndPreamble"); + preamble_ = from_utf8(lexrc.getLongString("EndPreamble")); break; case LT_LABELTYPE: diff --git a/src/lyxlayout.h b/src/lyxlayout.h index d8d84a1aed..2d12777bf6 100644 --- a/src/lyxlayout.h +++ b/src/lyxlayout.h @@ -63,7 +63,7 @@ public: /// lyx::docstring const & endlabelstring() const { return endlabelstring_; } /// - std::string const & preamble() const { return preamble_; } + docstring const & preamble() const { return preamble_; } /// std::string const & latexparam() const { return latexparam_; } /// @@ -226,7 +226,7 @@ private: /// Internal tag to surround the item text in a list) std::string itemtag_; /// Macro definitions needed for this layout - std::string preamble_; + docstring preamble_; }; diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 8533b698c3..48d602a07e 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -379,7 +379,7 @@ bool LyXTextClass::read(string const & filename, bool merge) break; case TC_PREAMBLE: - preamble_ = lexrc.getLongString("EndPreamble"); + preamble_ = from_utf8(lexrc.getLongString("EndPreamble")); break; case TC_PROVIDESAMSMATH: @@ -681,7 +681,7 @@ void LyXTextClass::readCharStyle(LyXLex & lexrc, string const & name) cs.latexparam = latexparam; cs.font = font; cs.labelfont = labelfont; - cs.preamble = preamble; + cs.preamble = from_utf8(preamble); charstyles().push_back(cs); } @@ -1036,7 +1036,7 @@ string const & LyXTextClass::pagestyle() const } -string const & LyXTextClass::preamble() const +docstring const & LyXTextClass::preamble() const { return preamble_; } diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index e2b05c06bc..45cb28f7e1 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -34,7 +34,7 @@ public: std::string latexparam; LyXFont font; LyXFont labelfont; - std::string preamble; + docstring preamble; }; @@ -122,7 +122,7 @@ public: /// std::string const & pagestyle() const; /// - std::string const & preamble() const; + docstring const & preamble() const; /// Packages that are already loaded by the class enum Provides { @@ -205,7 +205,7 @@ private: /// std::string defaultlayout_; /// preamble text to support layout styles - std::string preamble_; + docstring preamble_; /// latex packages loaded by document class. Provides provides_; /// -- 2.39.5