X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetnote.C;h=b840955032cdb0b16831769f57f38ed2e1158825;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=decb4785a26186575e79cf5b3ad24e2da30d4a99;hpb=8b67659646c6850377cb9f44a2a0a22c0e80840c;p=lyx.git diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index decb4785a2..b840955032 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -34,8 +34,8 @@ #include -using lyx::docstring; -using lyx::odocstream; + +namespace lyx { using std::string; using std::auto_ptr; @@ -47,6 +47,7 @@ using std::ostringstream; namespace { typedef Translator NoteTranslator; +typedef Translator NoteTranslatorLoc; NoteTranslator const init_notetranslator() { @@ -59,14 +60,13 @@ NoteTranslator const init_notetranslator() } -NoteTranslator const init_notetranslator_loc() +NoteTranslatorLoc const init_notetranslator_loc() { - // FIXME UNICODE - NoteTranslator translator(lyx::to_utf8(_("Note")), InsetNoteParams::Note); - translator.addPair(lyx::to_utf8(_("Comment")), InsetNoteParams::Comment); - translator.addPair(lyx::to_utf8(_("Greyed out")), InsetNoteParams::Greyedout); - translator.addPair(lyx::to_utf8(_("Framed")), InsetNoteParams::Framed); - translator.addPair(lyx::to_utf8(_("Shaded")), InsetNoteParams::Shaded); + NoteTranslatorLoc translator(_("Note"), InsetNoteParams::Note); + translator.addPair(_("Comment"), InsetNoteParams::Comment); + translator.addPair(_("Greyed out"), InsetNoteParams::Greyedout); + translator.addPair(_("Framed"), InsetNoteParams::Framed); + translator.addPair(_("Shaded"), InsetNoteParams::Shaded); return translator; } @@ -78,9 +78,9 @@ NoteTranslator const & notetranslator() } -NoteTranslator const & notetranslator_loc() +NoteTranslatorLoc const & notetranslator_loc() { - static NoteTranslator translator = init_notetranslator_loc(); + static NoteTranslatorLoc translator = init_notetranslator_loc(); return translator; } @@ -112,7 +112,7 @@ void InsetNoteParams::read(LyXLex & lex) void InsetNote::init() { - setInsetName("Note"); + setInsetName(from_ascii("Note")); setButtonLabel(); } @@ -167,8 +167,7 @@ void InsetNote::read(Buffer const & buf, LyXLex & lex) void InsetNote::setButtonLabel() { - // FIXME unicode - docstring const label = lyx::from_utf8(notetranslator_loc().find(params_.type)); + docstring const label = notetranslator_loc().find(params_.type); setLabel(label); LyXFont font(LyXFont::ALL_SANE); @@ -213,7 +212,7 @@ void InsetNote::doDispatch(LCursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: - InsetNoteMailer::string2params(lyx::to_utf8(cmd.argument()), params_); + InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_); setButtonLabel(); break; @@ -271,10 +270,10 @@ int InsetNote::latex(Buffer const & buf, odocstream & os, else if (params_.type == InsetNoteParams::Shaded) type = "shaded"; - lyx::odocstringstream ss; - ss << "%\n\\begin{" << lyx::from_ascii(type) << "}\n"; + odocstringstream ss; + ss << "%\n\\begin{" << from_ascii(type) << "}\n"; InsetText::latex(buf, ss, runparams); - ss << "\n\\end{" << lyx::from_ascii(type) << "}\n"; + ss << "\n\\end{" << from_ascii(type) << "}\n"; // the space after the comment in 'a[comment] b' will be eaten by the // comment environment since the space before b is ignored with the // following latex output: @@ -296,30 +295,28 @@ int InsetNote::latex(Buffer const & buf, odocstream & os, } -int InsetNote::docbook(Buffer const & buf, std::ostream & os, +int InsetNote::docbook(Buffer const & buf, odocstream & os, OutputParams const & runparams_in) const { if (params_.type == InsetNoteParams::Note) return 0; OutputParams runparams(runparams_in); - ostringstream ss; if (params_.type == InsetNoteParams::Comment) { - ss << "\n"; + os << "\n"; runparams.inComment = true; // Ignore files that are exported inside a comment runparams.exportdata.reset(new ExportData); } - InsetText::docbook(buf, ss, runparams); + int const n = InsetText::docbook(buf, os, runparams); if (params_.type == InsetNoteParams::Comment) - ss << "\n\n"; + os << "\n\n"; - string const str = ss.str(); - os << str; // Return how many newlines we issued. - return int(lyx::count(str.begin(), str.end(),'\n')); + //return int(count(str.begin(), str.end(), '\n')); + return n + 1 + 2; } @@ -411,3 +408,6 @@ void InsetNoteMailer::string2params(string const & in, params.read(lex); } + + +} // namespace lyx