]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetnote.C
hopefully fix tex2lyx linking.
[lyx.git] / src / insets / insetnote.C
index 82ed210bab629622bba48cca6287e864cc095054..d9ef2f787b4f81ada85c06bba74170ac8ff13636 100644 (file)
@@ -34,7 +34,8 @@
 
 #include <sstream>
 
-using lyx::docstring;
+
+namespace lyx {
 
 using std::string;
 using std::auto_ptr;
@@ -61,11 +62,11 @@ NoteTranslator const init_notetranslator()
 NoteTranslator 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);
+       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);
        return translator;
 }
 
@@ -111,7 +112,7 @@ void InsetNoteParams::read(LyXLex & lex)
 
 void InsetNote::init()
 {
-       setInsetName("Note");
+       setInsetName(from_utf8("Note"));
        setButtonLabel();
 }
 
@@ -166,7 +167,8 @@ void InsetNote::read(Buffer const & buf, LyXLex & lex)
 
 void InsetNote::setButtonLabel()
 {
-       string const label = notetranslator_loc().find(params_.type);
+       // FIXME unicode
+       docstring const label = from_utf8(notetranslator_loc().find(params_.type));
        setLabel(label);
 
        LyXFont font(LyXFont::ALL_SANE);
@@ -211,7 +213,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;
 
@@ -249,7 +251,7 @@ bool InsetNote::getStatus(LCursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetNote::latex(Buffer const & buf, ostream & os,
+int InsetNote::latex(Buffer const & buf, odocstream & os,
                     OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
@@ -269,10 +271,10 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
        else if (params_.type == InsetNoteParams::Shaded)
                type = "shaded";
 
-       ostringstream ss;
-       ss << "%\n\\begin{" << type << "}\n";
+       odocstringstream ss;
+       ss << "%\n\\begin{" << from_ascii(type) << "}\n";
        InsetText::latex(buf, ss, runparams);
-       ss << "\n\\end{" << 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:
@@ -287,41 +289,39 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
        if (params_.type == InsetNoteParams::Comment)
                ss << "{}";
 
-       string const str = ss.str();
+       docstring const str = ss.str();
        os << str;
        // Return how many newlines we issued.
-       return int(lyx::count(str.begin(), str.end(),'\n'));
+       return int(lyx::count(str.begin(), str.end(), '\n'));
 }
 
 
-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 << "<remark>\n";
+               os << "<remark>\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</remark>\n";
+               os << "\n</remark>\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;
 }
 
 
-int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
+int InsetNote::plaintext(Buffer const & buf, odocstream & os,
                         OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
@@ -333,15 +333,12 @@ int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
                // Ignore files that are exported inside a comment
                runparams.exportdata.reset(new ExportData);
        }
-       ostringstream ss;
-       ss << "[";
-       InsetText::plaintext(buf, ss, runparams);
-       ss << "]";
+       os << "[";
+       int const nlines = InsetText::plaintext(buf, os, runparams);
+       os << "]";
 
-       string const str = ss.str();
-       os << str;
        // Return how many newlines we issued.
-       return int(lyx::count(str.begin(), str.end(),'\n'));
+       return nlines;
 }
 
 
@@ -412,3 +409,6 @@ void InsetNoteMailer::string2params(string const & in,
 
        params.read(lex);
 }
+
+
+} // namespace lyx