]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbranch.C
* BufferParams:
[lyx.git] / src / insets / insetbranch.C
index a18bf41d4f8693cc3b5aeefbd99dc70c628cc570..3c28c079c6eef8958169aa9422c62cb036c9163f 100644 (file)
 #include "LColor.h"
 #include "lyxlex.h"
 #include "paragraph.h"
+#include "outputparams.h"
 
 #include <sstream>
 
+
+namespace lyx {
+
 using std::string;
 using std::auto_ptr;
 using std::istringstream;
@@ -35,7 +39,7 @@ using std::ostringstream;
 
 void InsetBranch::init()
 {
-       setInsetName("Branch");
+       setInsetName(from_utf8("Branch"));
        setButtonLabel();
 }
 
@@ -67,7 +71,7 @@ auto_ptr<InsetBase> InsetBranch::doClone() const
 }
 
 
-string const InsetBranch::editMessage() const
+docstring const InsetBranch::editMessage() const
 {
        return _("Opened Branch Inset");
 }
@@ -94,10 +98,11 @@ void InsetBranch::setButtonLabel()
        font.decSize();
        font.decSize();
 
-       string s = _("Branch: ") + params_.branch;
+       docstring s = _("Branch: ") + params_.branch;
        font.setColor(LColor::foreground);
        if (!params_.branch.empty()) {
-               LColor_color c = lcolor.getFromLyXName(params_.branch);
+               // FIXME UNICODE
+               LColor_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
                if (c == LColor::none) {
                        c = LColor::error;
                        s = _("Undef: ") + s;
@@ -122,7 +127,7 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
                InsetBranchParams params;
-               InsetBranchMailer::string2params(cmd.argument, params);
+               InsetBranchMailer::string2params(to_utf8(cmd.argument()), params);
                params_.branch = params.branch;
                setButtonLabel();
                break;
@@ -148,7 +153,7 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
 
 
        case LFUN_INSET_TOGGLE:
-               if (cmd.argument == "assign" || cmd.argument.empty()) {
+               if (cmd.argument() == "assign" || cmd.argument().empty()) {
                        // The branch inset uses "assign".
                        if (isBranchSelected(cur.buffer())) {
                                if (status() != Open)
@@ -183,11 +188,11 @@ bool InsetBranch::getStatus(LCursor & cur, FuncRequest const & cmd,
                break;
 
        case LFUN_INSET_TOGGLE:
-               if (cmd.argument == "open" || cmd.argument == "close" ||
-                   cmd.argument == "toggle")
+               if (cmd.argument() == "open" || cmd.argument() == "close" ||
+                   cmd.argument() == "toggle")
                        flag.enabled(true);
-               else if (cmd.argument == "assign"
-                          || cmd.argument.empty()) {
+               else if (cmd.argument() == "assign"
+                          || cmd.argument().empty()) {
                        if (isBranchSelected(cur.buffer()))
                                flag.enabled(status() != Open);
                        else
@@ -217,35 +222,40 @@ bool InsetBranch::isBranchSelected(Buffer const & buffer) const
 }
 
 
-int InsetBranch::latex(Buffer const & buf, ostream & os,
-                      OutputParams const & runparams) const
+int InsetBranch::latex(Buffer const & buf, odocstream & os,
+                       OutputParams const & runparams) const
 {
        return isBranchSelected(buf) ?
                InsetText::latex(buf, os, runparams) : 0;
 }
 
 
-int InsetBranch::linuxdoc(Buffer const & buf, std::ostream & os,
-                         OutputParams const & runparams) const
+int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
+                           OutputParams const & runparams) const
 {
-       return isBranchSelected(buf) ?
-               InsetText::linuxdoc(buf, os, runparams) : 0;
+       if (!isBranchSelected(buf))
+               return 0;
+
+       os << '[' << _("branch") << ' ' << params_.branch << ":\n";
+       InsetText::plaintext(buf, os, runparams);
+       os << "\n]";
+
+       return PLAINTEXT_NEWLINE + 1; // one char on a separate line
 }
 
 
-int InsetBranch::docbook(Buffer const & buf, std::ostream & os,
-                        OutputParams const & runparams) const
+int InsetBranch::docbook(Buffer const & buf, odocstream & os,
+                         OutputParams const & runparams) const
 {
        return isBranchSelected(buf) ?
                InsetText::docbook(buf, os, runparams) : 0;
 }
 
 
-int InsetBranch::plaintext(Buffer const & buf, std::ostream & os,
-                          OutputParams const & runparams) const
+void InsetBranch::textString(Buffer const & buf, odocstream & os) const
 {
-       return isBranchSelected(buf) ?
-               InsetText::plaintext(buf, os, runparams): 0;
+       if (isBranchSelected(buf))
+               os << paragraphs().begin()->asString(buf, true);
 }
 
 
@@ -307,7 +317,7 @@ void InsetBranchMailer::string2params(string const & in,
 
 void InsetBranchParams::write(ostream & os) const
 {
-       os << "Branch " << branch << '\n';
+       os << "Branch " << to_utf8(branch) << '\n';
 }
 
 
@@ -315,3 +325,5 @@ void InsetBranchParams::read(LyXLex & lex)
 {
        lex >> branch;
 }
+
+} // namespace lyx