X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxtextclass.C;h=48d602a07e3e3feb4cb30d18d692135408c393e6;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=f82a8fd3d2b388d2cba4a120035e793b71b845e0;hpb=2b01ca42d85a4bb019778a50e1b806b76cedd6a4;p=lyx.git diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index f82a8fd3d2..48d602a07e 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -31,13 +31,15 @@ namespace fs = boost::filesystem; #include -using lyx::docstring; -using lyx::support::libFileSearch; -using lyx::support::makeDisplayPath; -using lyx::support::quoteName; -using lyx::support::rtrim; -using lyx::support::subst; -using lyx::support::addName; + +namespace lyx { + +using support::libFileSearch; +using support::makeDisplayPath; +using support::quoteName; +using support::rtrim; +using support::subst; +using support::addName; using std::endl; using std::find_if; @@ -75,15 +77,15 @@ bool layout2layout(string const & filename, string const & tempfile) } std::ostringstream command; - command << lyx::support::os::python() << ' ' << quoteName(script) + command << support::os::python() << ' ' << quoteName(script) << ' ' << quoteName(filename) << ' ' << quoteName(tempfile); string const command_str = command.str(); lyxerr[Debug::TCLASS] << "Running `" << command_str << '\'' << endl; - lyx::support::cmd_ret const ret = - lyx::support::runCommand(command_str); + support::cmd_ret const ret = + support::runCommand(command_str); if (ret.first != 0) { lyxerr << "Could not run layout conversion " "script layout2layout.py." << endl; @@ -173,7 +175,7 @@ enum TextClassTags { // Reads a textclass structure from file. bool LyXTextClass::read(string const & filename, bool merge) { - if (!lyx::support::isFileReadable(filename)) { + if (!support::isFileReadable(filename)) { lyxerr << "Cannot read layout file `" << filename << "'." << endl; return true; @@ -211,11 +213,11 @@ bool LyXTextClass::read(string const & filename, bool merge) if (!merge) lyxerr[Debug::TCLASS] << "Reading textclass " - << lyx::to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename)) << endl; else lyxerr[Debug::TCLASS] << "Reading input file " - << lyx::to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename)) << endl; LyXLex lexrc(textClassTags, @@ -377,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: @@ -442,17 +444,17 @@ bool LyXTextClass::read(string const & filename, bool merge) if (format != FORMAT) { lyxerr[Debug::TCLASS] << "Converting layout file from format " << format << " to " << FORMAT << endl; - string const tempfile = lyx::support::tempName(); + string const tempfile = support::tempName(); error = !layout2layout(filename, tempfile); if (!error) error = read(tempfile, merge); - lyx::support::unlink(tempfile); + support::unlink(tempfile); return error; } if (!merge) { // we are at top level here. lyxerr[Debug::TCLASS] << "Finished reading textclass " - << lyx::to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename)) << endl; if (defaultlayout_.empty()) { lyxerr << "Error: Textclass '" << name_ @@ -482,7 +484,7 @@ bool LyXTextClass::read(string const & filename, bool merge) } else lyxerr[Debug::TCLASS] << "Finished reading input file " - << lyx::to_utf8(makeDisplayPath(filename)) + << to_utf8(makeDisplayPath(filename)) << endl; return error; @@ -679,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); } @@ -804,8 +806,8 @@ void LyXTextClass::readCounter(LyXLex & lexrc) lexrc.pushTable(counterTags, CT_END); - string name; - string within; + docstring name; + docstring within; bool getout = false; while (!getout && lexrc.isOK()) { @@ -819,12 +821,12 @@ void LyXTextClass::readCounter(LyXLex & lexrc) switch (static_cast(le)) { case CT_NAME: lexrc.next(); - name = lexrc.getString(); + name = lyx::from_ascii(lexrc.getString()); break; case CT_WITHIN: lexrc.next(); - within = lexrc.getString(); - if (within == "none") + within = lyx::from_ascii(lexrc.getString()); + if (within == lyx::from_ascii("none")) within.erase(); break; case CT_END: @@ -835,13 +837,10 @@ void LyXTextClass::readCounter(LyXLex & lexrc) // Here if have a full counter if getout == true if (getout) { - // FIXME UNICODE - if (within.empty()) { - ctrs_->newCounter(lyx::from_ascii(name)); - } else { - ctrs_->newCounter(lyx::from_ascii(name), - lyx::from_ascii(within)); - } + if (within.empty()) + ctrs_->newCounter(name); + else + ctrs_->newCounter(name, within); } lexrc.popTable(); @@ -935,7 +934,7 @@ bool LyXTextClass::load(string const & path) const if (!loaded_) { lyxerr << "Error reading `" - << lyx::to_utf8(makeDisplayPath(layout_file)) + << to_utf8(makeDisplayPath(layout_file)) << "'\n(Check `" << name_ << "')\nCheck your installation and " "try Options/Reconfigure..." << endl; @@ -1037,7 +1036,7 @@ string const & LyXTextClass::pagestyle() const } -string const & LyXTextClass::preamble() const +docstring const & LyXTextClass::preamble() const { return preamble_; } @@ -1127,3 +1126,6 @@ ostream & operator<<(ostream & os, LyXTextClass::PageSides p) } return os; } + + +} // namespace lyx