]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
* BufferParams:
[lyx.git] / src / insets / insetnote.C
index b51078611a16c9c0bf9be4f2ece05abc4a17a4a4..38250c38af6004c44fd9ff7cc6bf8c0430587b8e 100644 (file)
@@ -47,6 +47,7 @@ using std::ostringstream;
 namespace {
 
 typedef Translator<std::string, InsetNoteParams::Type> NoteTranslator;
+typedef Translator<docstring, InsetNoteParams::Type> 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(to_utf8(_("Note")), InsetNoteParams::Note);
-       translator.addPair(to_utf8(_("Comment")), InsetNoteParams::Comment);
-       translator.addPair(to_utf8(_("Greyed out")), InsetNoteParams::Greyedout);
-       translator.addPair(to_utf8(_("Framed")), InsetNoteParams::Framed);
-       translator.addPair(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;
 }
 
@@ -105,14 +105,14 @@ void InsetNoteParams::read(LyXLex & lex)
 {
        string label;
        lex >> label;
-       if (lex)
+       if (lex.isOK())
                type = notetranslator().find(label);
 }
 
 
 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 = from_utf8(notetranslator_loc().find(params_.type));
+       docstring const label = notetranslator_loc().find(params_.type);
        setLabel(label);
 
        LyXFont font(LyXFont::ALL_SANE);
@@ -291,54 +290,54 @@ int InsetNote::latex(Buffer const & buf, odocstream & os,
 
        docstring const str = ss.str();
        os << str;
+       runparams_in.encoding = runparams.encoding;
        // Return how many newlines we issued.
        return int(lyx::count(str.begin(), str.end(), '\n'));
 }
 
 
-int InsetNote::docbook(Buffer const & buf, odocstream & os,
-                      OutputParams const & runparams_in) const
+int InsetNote::plaintext(Buffer const & buf, odocstream & os,
+                         OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
        OutputParams runparams(runparams_in);
        if (params_.type == InsetNoteParams::Comment) {
-               os << "<remark>\n";
                runparams.inComment = true;
                // Ignore files that are exported inside a comment
                runparams.exportdata.reset(new ExportData);
        }
+       os << '[' << _("note") << ":\n";
+       InsetText::plaintext(buf, os, runparams);
+       os << "\n]";
 
-       int const n = InsetText::docbook(buf, os, runparams);
-
-       if (params_.type == InsetNoteParams::Comment)
-               os << "\n</remark>\n";
-
-       // Return how many newlines we issued.
-       //return int(count(str.begin(), str.end(), '\n'));
-        return n + 1 + 2;
+       return PLAINTEXT_NEWLINE + 1; // one char on a separate line
 }
 
 
-int InsetNote::plaintext(Buffer const & buf, odocstream & os,
-                        OutputParams const & runparams_in) const
+int InsetNote::docbook(Buffer const & buf, odocstream & os,
+                       OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
        OutputParams runparams(runparams_in);
        if (params_.type == InsetNoteParams::Comment) {
+               os << "<remark>\n";
                runparams.inComment = true;
                // Ignore files that are exported inside a comment
                runparams.exportdata.reset(new ExportData);
        }
-       os << "[";
-       int const nlines = InsetText::plaintext(buf, os, runparams);
-       os << "]";
+
+       int const n = InsetText::docbook(buf, os, runparams);
+
+       if (params_.type == InsetNoteParams::Comment)
+               os << "\n</remark>\n";
 
        // Return how many newlines we issued.
-       return nlines;
+       //return int(count(str.begin(), str.end(), '\n'));
+        return n + 1 + 2;
 }