]> git.lyx.org Git - features.git/commitdiff
remove InsetBoxMailer.
authorAndré Pönitz <poenitz@gmx.net>
Thu, 27 Mar 2008 07:26:37 +0000 (07:26 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 27 Mar 2008 07:26:37 +0000 (07:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24001 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXFunc.cpp
src/factory.cpp
src/frontends/qt4/GuiBox.cpp
src/frontends/qt4/GuiBox.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetWrap.cpp

index 3cf4c19a7f69545f6dc104491abf66a42300d766..9aef52f9c48beadde77285a3fa30a6f1fc3c2f13 100644 (file)
@@ -1192,7 +1192,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        case BOX_CODE: {
                                // \c data == "Boxed" || "Frameless" etc
                                InsetBoxParams p(data);
-                               data = InsetBoxMailer::params2string(p);
+                               data = InsetBox::params2string(p);
                                break;
                        } 
                        case BRANCH_CODE: {
index dde7c68baf7c6b20b1487c6cfbfa85e2e58adc7a..c070f24a2f5ad7bdfd4aa3b25d35245da4b42aa3 100644 (file)
@@ -400,10 +400,10 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
                }
        }
 
-
        return 0;
 }
 
+
 Inset * createInset(Buffer & buf, FuncRequest const & cmd)
 {
        Inset * inset = createInsetHelper(buf, cmd);
@@ -412,13 +412,12 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
        return inset;
 }
 
+
 Inset * readInset(Lexer & lex, Buffer const & buf)
 {
        // consistency check
-       if (lex.getString() != "\\begin_inset") {
-               lyxerr << "Buffer::readInset: Consistency check failed."
-                      << endl;
-       }
+       if (lex.getString() != "\\begin_inset")
+               LYXERR0("Buffer::readInset: Consistency check failed.");
 
        auto_ptr<Inset> inset;
 
@@ -427,13 +426,13 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
 
        // test the different insets
        
-       //FIXME It would be better if we did not have this branch and could
-       //just do one massive switch for all insets. But at present, it's easier 
-       //to do it this way, and we can't do the massive switch until the conversion 
-       //mentioned below. 
-       //Note that if we do want to do a single switch, we need to remove
-       //this "CommandInset" line---or replace it with a single "InsetType" line
-       //that would be used in all insets.
+       // FIXME It would be better if we did not have this branch and could
+       // just do one massive switch for all insets. But at present, it's
+       // easier to do it this way, and we can't do the massive switch until
+       // the conversion mentioned below.  Note that if we do want to do a
+       // single switch, we need to remove this "CommandInset" line---or
+       // replace it with a single "InsetType" line that would be used in all
+       // insets.
        if (tmptok == "CommandInset") {
                lex.next();
                string const insetType = lex.getString();
index 5ba58e0208923f61c5baaad98d5f9dad760956b2..fb8d1618105938b21b70ba436d3ec087eed915b2 100644 (file)
 #include "GuiBox.h"
 
 #include "FuncRequest.h"
-#include "support/gettext.h"
-
 #include "LengthCombo.h"
 #include "Length.h"
-#include "qt_helpers.h"
 #include "LyXRC.h" // to set the default length values
+#include "qt_helpers.h"
 #include "Validator.h"
 
 #include "insets/InsetBox.h"
 
-#include "support/lstrings.h"
+#include "support/gettext.h"
 #include "support/foreach.h"
+#include "support/lstrings.h"
 
 #include <QPushButton>
 #include <QLineEdit>
@@ -450,7 +449,7 @@ void GuiBox::setInnerType(bool frameless, int i)
 
 bool GuiBox::initialiseParams(string const & data)
 {
-       InsetBoxMailer::string2params(data, params_);
+       InsetBox::string2params(data, params_);
        return true;
 
 }
@@ -464,7 +463,7 @@ void GuiBox::clearParams()
 
 void GuiBox::dispatchParams()
 {
-       dispatch(FuncRequest(getLfun(), InsetBoxMailer::params2string(params_)));
+       dispatch(FuncRequest(getLfun(), InsetBox::params2string(params_)));
 }
 
 
index aaca9a4e2deba0765d24b1ec29686ba9901fe2eb..9feb84bc357ee83d37ce07e34f122399682e639a 100644 (file)
@@ -17,8 +17,6 @@
 #include "ui_BoxUi.h"
 #include "insets/InsetBox.h"
 
-#include <vector>
-
 
 namespace lyx {
 namespace frontend {
index 11e6ee0fd4fe0a4a0884e2c1f8804a6cd83969f0..c11dc34d94480afd2b3fd68b934beab36c89b241 100644 (file)
@@ -30,6 +30,8 @@
 #include "support/debug.h"
 #include "support/Translator.h"
 
+#include "frontends/Application.h"
+
 #include <sstream>
 
 using namespace std;
@@ -41,7 +43,7 @@ namespace {
 typedef Translator<string, InsetBox::BoxType> BoxTranslator;
 typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
 
-BoxTranslator const init_boxtranslator()
+BoxTranslator initBoxtranslator()
 {
        BoxTranslator translator("Boxed", InsetBox::Boxed);
        translator.addPair("Frameless", InsetBox::Frameless);
@@ -55,7 +57,7 @@ BoxTranslator const init_boxtranslator()
 }
 
 
-BoxTranslatorLoc const init_boxtranslator_loc()
+BoxTranslatorLoc initBoxtranslatorLoc()
 {
        BoxTranslatorLoc translator(_("simple frame"), InsetBox::Boxed);
        translator.addPair(_("frameless"), InsetBox::Frameless);
@@ -71,19 +73,25 @@ BoxTranslatorLoc const init_boxtranslator_loc()
 
 BoxTranslator const & boxtranslator()
 {
-       static BoxTranslator translator = init_boxtranslator();
+       static BoxTranslator translator = initBoxtranslator();
        return translator;
 }
 
 
 BoxTranslatorLoc const & boxtranslator_loc()
 {
-       static BoxTranslatorLoc translator = init_boxtranslator_loc();
+       static BoxTranslatorLoc translator = initBoxtranslatorLoc();
        return translator;
 }
 
-} // anon
+} // namespace anon
+
 
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetBox
+//
+/////////////////////////////////////////////////////////////////////////
 
 InsetBox::InsetBox(Buffer const & buffer, string const & label)
        : InsetCollapsable(buffer), params_(label)
@@ -95,7 +103,7 @@ InsetBox::InsetBox(Buffer const & buffer, string const & label)
 
 InsetBox::~InsetBox()
 {
-       InsetBoxMailer(*this).hideDialog();
+       hideDialogs("box", this);
 }
 
 
@@ -110,7 +118,7 @@ docstring InsetBox::name() const
        // FIXME: UNICODE
        string name = "Box";
        if (boxtranslator().find(params_.type) == Shaded)
-               name += string(":Shaded");
+               name += ":Shaded";
        return from_ascii(name);
 }
 
@@ -141,8 +149,9 @@ void InsetBox::setButtonLabel()
                        label += _("Parbox");
                else
                        label += _("Minipage");
-       } else
+       } else {
                label += boxtranslator_loc().find(btype);
+       }
        label += ")";
 
        setLabel(label);
@@ -175,7 +184,8 @@ bool InsetBox::forceEmptyLayout(idx_type) const
 
 bool InsetBox::showInsetDialog(BufferView * bv) const
 {
-       InsetBoxMailer(const_cast<InsetBox &>(*this)).showDialog(bv);
+       bv->showDialog("box", params2string(params_), 
+               const_cast<InsetBox *>(this));
        return true;
 }
 
@@ -189,13 +199,13 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (cmd.getArg(0) == "changetype")
                        params_.type = cmd.getArg(1);
                else
-                       InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
+                       string2params(to_utf8(cmd.argument()), params_);
                setLayout(cur.buffer().params());
                break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetBoxMailer(*this).updateDialog(&cur.bv());
+               cur.bv().updateDialog("box", params2string(params_));
                break;
 
        default:
@@ -216,16 +226,16 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
                else
                        flag.enabled(true);
                return true;
+
        case LFUN_INSET_DIALOG_UPDATE:
                flag.enabled(true);
                return true;
+
        case LFUN_BREAK_PARAGRAPH:
                if (params_.inner_box) {
                        return InsetCollapsable::getStatus(cur, cmd, flag);
-               } else {
-                       flag.enabled(false);
-                       return true;
-               }
+               flag.enabled(false);
+               return true;
 
        default:
                return InsetCollapsable::getStatus(cur, cmd, flag);
@@ -349,11 +359,12 @@ int InsetBox::latex(odocstream & os, OutputParams const & runparams) const
                if (params_.use_parbox)
                        os << "{";
                os << "%\n";
-               i += 1;
+               ++i;
        }
-       if (btype == Shaded)
+       if (btype == Shaded) {
                os << "\\begin{shaded}%\n";
-               i += 1;
+               ++i;
+       }
 
        i += InsetText::latex(os, runparams);
 
@@ -496,21 +507,7 @@ docstring InsetBox::contextMenu(BufferView const &, int, int) const
 }
 
 
-InsetBoxMailer::InsetBoxMailer(InsetBox & inset)
-       : inset_(inset)
-{}
-
-
-string const InsetBoxMailer::name_ = "box";
-
-
-string const InsetBoxMailer::inset2string(Buffer const &) const
-{
-       return params2string(inset_.params());
-}
-
-
-string const InsetBoxMailer::params2string(InsetBoxParams const & params)
+string InsetBox::params2string(InsetBoxParams const & params)
 {
        ostringstream data;
        data << "box" << ' ';
@@ -519,8 +516,7 @@ string const InsetBoxMailer::params2string(InsetBoxParams const & params)
 }
 
 
-void InsetBoxMailer::string2params(string const & in,
-                                  InsetBoxParams & params)
+void InsetBox::string2params(string const & in, InsetBoxParams & params)
 {
        params = InsetBoxParams(string());
        if (in.empty())
@@ -532,20 +528,31 @@ void InsetBoxMailer::string2params(string const & in,
 
        string name;
        lex >> name;
-       if (!lex || name != name_)
-               return print_mailer_error("InsetBoxMailer", in, 1, name_);
+       if (!lex || name != "box") {
+               LYXERR0("InsetBox::string2params(" << in << ")\n"
+                                         "Expected arg 1 to be \"box\"\n");
+               return;
+       }
 
        // This is part of the inset proper that is usually swallowed
        // by Text::readInset
        string id;
        lex >> id;
-       if (!lex || id != "Box")
-               return print_mailer_error("InsetBoxMailer", in, 2, "Box");
+       if (!lex || id != "Box") {
+               LYXERR0("InsetBox::string2params(" << in << ")\n"
+                                         "Expected arg 2 to be \"Box\"\n");
+       }
 
        params.read(lex);
 }
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetBoxParams
+//
+/////////////////////////////////////////////////////////////////////////
+
 InsetBoxParams::InsetBoxParams(string const & label)
        : type(label),
          use_parbox(false),
index 28aa7a4b22b348c523791aa2f2d25e0e855e2f31..94dd37cce871ae1cdc9110c027a455d2877bfac0 100644 (file)
 
 #include "InsetCollapsable.h"
 #include "Length.h"
-#include "MailInset.h"
 
 
 namespace lyx {
 
-class InsetBoxParams {
+class InsetBoxParams
+{
 public:
        ///
        InsetBoxParams(std::string const &);
@@ -28,6 +28,7 @@ public:
        void write(std::ostream & os) const;
        ///
        void read(Lexer & lex);
+
        ///
        std::string type;
        /// Use a parbox (true) or minipage (false)
@@ -52,10 +53,16 @@ public:
 };
 
 
-/** The fbox/fancybox inset
 
-*/
-class InsetBox : public InsetCollapsable {
+///////////////////////////////////////////////////////////////////////
+//
+// The fbox/fancybox inset
+//
+///////////////////////////////////////////////////////////////////////
+
+
+class InsetBox : public InsetCollapsable
+{
 public:
        ///
        enum BoxType {
@@ -72,6 +79,10 @@ public:
        InsetBox(Buffer const &, std::string const &);
        ///
        ~InsetBox();
+       ///
+       static std::string params2string(InsetBoxParams const &);
+       ///
+       static void string2params(std::string const &, InsetBoxParams &);
 private:
        ///
        friend class InsetBoxParams;
@@ -95,10 +106,9 @@ private:
        ///
        DisplayType display() const { return Inline; }
        ///
-       virtual bool allowParagraphCustomization(idx_type = 0)
-               { return forceEmptyLayout(); }
+       bool allowParagraphCustomization(idx_type = 0) { return forceEmptyLayout(); }
        ///
-       virtual bool forceEmptyLayout(idx_type = 0) const;
+       bool forceEmptyLayout(idx_type = 0) const;
        ///
        bool neverIndent() const { return true; }
        ///
@@ -124,36 +134,12 @@ private:
        /// used by the constructors
        void init();
        ///
-       virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
+       docstring contextMenu(BufferView const & bv, int x, int y) const;
 
        ///
        InsetBoxParams params_;
 };
 
-
-class InsetBoxMailer : public MailInset {
-public:
-       ///
-       InsetBoxMailer(InsetBox & inset);
-       ///
-       virtual Inset & inset() const { return inset_; }
-       ///
-       virtual std::string const & name() const { return name_; }
-       ///
-       virtual std::string const inset2string(Buffer const &) const;
-       ///
-       static std::string const params2string(InsetBoxParams const &);
-       ///
-       static void string2params(std::string const &, InsetBoxParams &);
-
-private:
-       ///
-       static std::string const name_;
-       ///
-       InsetBox & inset_;
-};
-
-
 } // namespace lyx
 
-#endif // INSET_BOX_H
+#endif // INSETBOX_H
index 31e58670a485bc4c3e26dd184976c30c855cd2f1..f6cdc4641f57e82ca6b58934d72b5462de455ae2 100644 (file)
@@ -284,7 +284,7 @@ void InsetWrap::string2params(string const & in, InsetWrapParams & params)
        lex >> id;
        if (!lex || id != "Wrap") {
                LYXERR0("InsetWrap::string2params(" << in << ")\n"
-                                         "Expected arg 1 to be \"Wrap\"\n");
+                                         "Expected arg 2 to be \"Wrap\"\n");
                return;
        }