From f9b81e51e943bcaac885d74edbce41a9d74ad3dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 27 Mar 2008 22:26:24 +0000 Subject: [PATCH] remove remaining MailInsets. please check your favourite insets, I am sure I broke _something_... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24006 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 22 +++--- src/Makefile.am | 2 - src/Text3.cpp | 4 +- src/factory.cpp | 28 ++++---- src/frontends/qt4/GuiBranch.cpp | 4 +- src/frontends/qt4/GuiCitation.cpp | 2 +- src/frontends/qt4/GuiDialog.cpp | 5 +- src/frontends/qt4/GuiExternal.cpp | 6 +- src/frontends/qt4/GuiFloat.cpp | 4 +- src/frontends/qt4/GuiGraphics.cpp | 5 +- src/frontends/qt4/GuiHSpace.cpp | 8 +-- src/frontends/qt4/GuiListings.cpp | 4 +- src/frontends/qt4/GuiNote.cpp | 4 +- src/frontends/qt4/GuiTabular.cpp | 2 +- src/insets/InsetBibitem.cpp | 4 +- src/insets/InsetBibitem.h | 47 +++++++------ src/insets/InsetBibtex.cpp | 2 +- src/insets/InsetBranch.cpp | 52 +++++++------- src/insets/InsetBranch.h | 55 ++++++--------- src/insets/InsetCitation.h | 32 +++++---- src/insets/InsetCommand.cpp | 57 +++++++++------- src/insets/InsetCommand.h | 110 +++++++++++++----------------- src/insets/InsetExternal.cpp | 64 ++++++++--------- src/insets/InsetExternal.h | 62 +++++------------ src/insets/InsetFloat.cpp | 65 ++++++++---------- src/insets/InsetFloat.h | 65 +++++++----------- src/insets/InsetGraphics.cpp | 55 +++++++-------- src/insets/InsetGraphics.h | 90 ++++++++++-------------- src/insets/InsetInclude.cpp | 2 +- src/insets/InsetInclude.h | 10 +-- src/insets/InsetLabel.cpp | 2 +- src/insets/InsetListings.cpp | 36 ++++------ src/insets/InsetListings.h | 51 +++++--------- src/insets/InsetNewline.cpp | 39 ++++------- src/insets/InsetNewline.h | 39 +++-------- src/insets/InsetNewpage.cpp | 41 ++++------- src/insets/InsetNewpage.h | 42 +++--------- src/insets/InsetNote.cpp | 46 ++++++------- src/insets/InsetNote.h | 52 ++++++-------- src/insets/InsetSpace.cpp | 54 ++++++--------- src/insets/InsetSpace.h | 51 +++++--------- src/insets/InsetTabular.cpp | 47 ++++++------- src/insets/InsetTabular.h | 52 +++++--------- src/insets/InsetWrap.cpp | 6 +- src/insets/MailInset.cpp | 57 ---------------- src/insets/MailInset.h | 54 --------------- src/mathed/InsetMathHull.cpp | 4 +- src/mathed/InsetMathRef.cpp | 2 +- src/mathed/MathFactory.cpp | 2 +- 49 files changed, 582 insertions(+), 967 deletions(-) delete mode 100644 src/insets/MailInset.cpp delete mode 100644 src/insets/MailInset.h diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 9aef52f9c4..4804728f98 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1176,7 +1176,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case TOC_CODE: case HYPERLINK_CODE: { InsetCommandParams p(code); - data = InsetCommandMailer::params2string(name, p); + data = InsetCommand::params2string(name, p); break; } case INCLUDE_CODE: { @@ -1186,7 +1186,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // default type is requested data = "include"; InsetCommandParams p(INCLUDE_CODE, data); - data = InsetCommandMailer::params2string("include", p); + data = InsetCommand::params2string("include", p); break; } case BOX_CODE: { @@ -1197,12 +1197,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } case BRANCH_CODE: { InsetBranchParams p; - data = InsetBranchMailer::params2string(p); + data = InsetBranch::params2string(p); break; } case CITE_CODE: { InsetCommandParams p(CITE_CODE); - data = InsetCommandMailer::params2string(name, p); + data = InsetCommand::params2string(name, p); break; } case ERT_CODE: { @@ -1212,33 +1212,33 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case EXTERNAL_CODE: { InsetExternalParams p; Buffer const & buffer = *lyx_view_->buffer(); - data = InsetExternalMailer::params2string(p, buffer); + data = InsetExternal::params2string(p, buffer); break; } case FLOAT_CODE: { InsetFloatParams p; - data = InsetFloatMailer::params2string(p); + data = InsetFloat::params2string(p); break; } case LISTINGS_CODE: { InsetListingsParams p; - data = InsetListingsMailer::params2string(p); + data = InsetListings::params2string(p); break; } case GRAPHICS_CODE: { InsetGraphicsParams p; Buffer const & buffer = *lyx_view_->buffer(); - data = InsetGraphicsMailer::params2string(p, buffer); + data = InsetGraphics::params2string(p, buffer); break; } case NOTE_CODE: { InsetNoteParams p; - data = InsetNoteMailer::params2string(p); + data = InsetNote::params2string(p); break; } case SPACE_CODE: { InsetSpaceParams p; - data = InsetSpaceMailer::params2string(p); + data = InsetSpace::params2string(p); break; } case VSPACE_CODE: { @@ -1279,7 +1279,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) icp["key"] = from_utf8(arg); if (!opt1.empty()) icp["before"] = from_utf8(opt1); - string icstr = InsetCommandMailer::params2string("citation", icp); + string icstr = InsetCommand::params2string("citation", icp); FuncRequest fr(LFUN_INSET_INSERT, icstr); dispatch(fr); } else diff --git a/src/Makefile.am b/src/Makefile.am index 4e95f8a4d3..a8c490deca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -478,7 +478,6 @@ endif noinst_LTLIBRARIES += liblyxinsets.la SOURCEFILESINSETS = \ - insets/MailInset.cpp \ insets/ExternalSupport.cpp \ insets/ExternalTemplate.cpp \ insets/ExternalTransforms.cpp \ @@ -531,7 +530,6 @@ SOURCEFILESINSETS = \ insets/InsetWrap.cpp HEADERFILESINSETS = \ - insets/MailInset.h \ insets/ExternalSupport.h \ insets/ExternalTemplate.h \ insets/ExternalTransforms.h \ diff --git a/src/Text3.cpp b/src/Text3.cpp index 0d839d1ac6..17b8637323 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1287,7 +1287,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } p["target"] = (cmd.argument().empty()) ? content : cmd.argument(); - string const data = InsetCommandMailer::params2string("href", p); + string const data = InsetCommand::params2string("href", p); if (p["target"].empty()) { bv->showDialog("href", data); } else { @@ -1303,7 +1303,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) p["name"] = (cmd.argument().empty()) ? cur.getPossibleLabel() : cmd.argument(); - string const data = InsetCommandMailer::params2string("label", p); + string const data = InsetCommand::params2string("label", p); if (cmd.argument().empty()) { bv->showDialog("label", data); diff --git a/src/factory.cpp b/src/factory.cpp index c070f24a2f..609abcf793 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -158,7 +158,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) string const argument = to_utf8(cmd.argument()); if (params.documentClass().floats().typeExist(argument)) { auto_ptr p(new InsetFloat(buf, argument)); - p->wide(true, params); + p->setWide(true, params); return p.release(); } lyxerr << "Non-existent float type: " << argument << endl; @@ -223,19 +223,19 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case BIBITEM_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetBibitem(icp); } case BIBTEX_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetBibtex(icp); } case CITE_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetCitation(icp); } @@ -247,13 +247,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case LISTINGS_CODE: { InsetListingsParams par; - InsetListingsMailer::string2params(to_utf8(cmd.argument()), par); + InsetListings::string2params(to_utf8(cmd.argument()), par); return new InsetListings(buf, par); } case EXTERNAL_CODE: { InsetExternalParams iep; - InsetExternalMailer::string2params(to_utf8(cmd.argument()), buf, iep); + InsetExternal::string2params(to_utf8(cmd.argument()), buf, iep); auto_ptr inset(new InsetExternal(buf)); inset->setBuffer(buf); inset->setParams(iep); @@ -262,7 +262,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case GRAPHICS_CODE: { InsetGraphicsParams igp; - InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buf, igp); + InsetGraphics::string2params(to_utf8(cmd.argument()), buf, igp); auto_ptr inset(new InsetGraphics(buf)); inset->setParams(igp); return inset.release(); @@ -270,13 +270,13 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case HYPERLINK_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetHyperlink(icp); } case INCLUDE_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetInclude(icp); } @@ -285,31 +285,31 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case NOMENCL_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, lyx::to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, lyx::to_utf8(cmd.argument()), icp); return new InsetNomencl(icp); } case LABEL_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetLabel(icp); } case REF_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetRef(buf, icp); } case SPACE_CODE: { InsetSpaceParams isp; - InsetSpaceMailer::string2params(to_utf8(cmd.argument()), isp); + InsetSpace::string2params(to_utf8(cmd.argument()), isp); return new InsetSpace(isp); } case TOC_CODE: { InsetCommandParams icp(code); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); + InsetCommand::string2params(name, to_utf8(cmd.argument()), icp); return new InsetTOC(icp); } diff --git a/src/frontends/qt4/GuiBranch.cpp b/src/frontends/qt4/GuiBranch.cpp index 0f6793d2d1..10c24e1ec5 100644 --- a/src/frontends/qt4/GuiBranch.cpp +++ b/src/frontends/qt4/GuiBranch.cpp @@ -84,7 +84,7 @@ void GuiBranch::applyView() bool GuiBranch::initialiseParams(string const & data) { - InsetBranchMailer::string2params(data, params_); + InsetBranch::string2params(data, params_); return true; } @@ -97,7 +97,7 @@ void GuiBranch::clearParams() void GuiBranch::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetBranchMailer::params2string(params_))); + dispatch(FuncRequest(getLfun(), InsetBranch::params2string(params_))); } diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index d8041d5cb3..7ba1dcc4d6 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -589,7 +589,7 @@ void GuiCitation::setCitedKeys() bool GuiCitation::initialiseParams(string const & data) { - InsetCommandMailer::string2params(lfun_name_, data, params_); + InsetCommand::string2params(lfun_name_, data, params_); biblio::CiteEngine const engine = buffer().params().citeEngine(); bibkeysInfo_.fillWithBibKeys(&buffer()); citeStyles_ = biblio::getCiteStyles(engine); diff --git a/src/frontends/qt4/GuiDialog.cpp b/src/frontends/qt4/GuiDialog.cpp index d3f9836c08..53a132d5ff 100644 --- a/src/frontends/qt4/GuiDialog.cpp +++ b/src/frontends/qt4/GuiDialog.cpp @@ -132,7 +132,7 @@ bool GuiCommand::initialiseParams(string const & data) { // The name passed with LFUN_INSET_APPLY is also the name // used to identify the mailer. - InsetCommandMailer::string2params(lfun_name_, data, params_); + InsetCommand::string2params(lfun_name_, data, params_); return true; } @@ -142,8 +142,7 @@ void GuiCommand::dispatchParams() if (lfun_name_.empty()) return; - string const lfun = - InsetCommandMailer::params2string(lfun_name_, params_); + string const lfun = InsetCommand::params2string(lfun_name_, params_); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt4/GuiExternal.cpp b/src/frontends/qt4/GuiExternal.cpp index 412f16275c..997928e7ce 100644 --- a/src/frontends/qt4/GuiExternal.cpp +++ b/src/frontends/qt4/GuiExternal.cpp @@ -702,7 +702,7 @@ void GuiExternal::getBB() bool GuiExternal::initialiseParams(string const & data) { - InsetExternalMailer::string2params(data, buffer(), params_); + InsetExternal::string2params(data, buffer(), params_); return true; } @@ -715,7 +715,7 @@ void GuiExternal::clearParams() void GuiExternal::dispatchParams() { - string const lfun = InsetExternalMailer::params2string(params_, buffer()); + string const lfun = InsetExternal::params2string(params_, buffer()); dispatch(FuncRequest(getLfun(), lfun)); } @@ -723,7 +723,7 @@ void GuiExternal::dispatchParams() void GuiExternal::editExternal() { applyView(); - string const lfun = InsetExternalMailer::params2string(params_, buffer()); + string const lfun = InsetExternal::params2string(params_, buffer()); dispatch(FuncRequest(LFUN_EXTERNAL_EDIT, lfun)); } diff --git a/src/frontends/qt4/GuiFloat.cpp b/src/frontends/qt4/GuiFloat.cpp index aae2de3931..9fedf75f88 100644 --- a/src/frontends/qt4/GuiFloat.cpp +++ b/src/frontends/qt4/GuiFloat.cpp @@ -72,7 +72,7 @@ void GuiFloat::applyView() bool GuiFloat::initialiseParams(string const & data) { - InsetFloatMailer::string2params(data, params_); + InsetFloat::string2params(data, params_); return true; } @@ -85,7 +85,7 @@ void GuiFloat::clearParams() void GuiFloat::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetFloatMailer::params2string(params_))); + dispatch(FuncRequest(getLfun(), InsetFloat::params2string(params_))); } diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index 107813006f..cda6c4efa9 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -704,7 +704,7 @@ bool GuiGraphics::isValid() bool GuiGraphics::initialiseParams(string const & data) { - InsetGraphicsMailer::string2params(data, buffer(), params_); + InsetGraphics::string2params(data, buffer(), params_); return true; } @@ -718,8 +718,7 @@ void GuiGraphics::clearParams() void GuiGraphics::dispatchParams() { InsetGraphicsParams tmp_params(params_); - string const lfun = - InsetGraphicsMailer::params2string(tmp_params, buffer()); + string const lfun = InsetGraphics::params2string(tmp_params, buffer()); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt4/GuiHSpace.cpp b/src/frontends/qt4/GuiHSpace.cpp index 43a4e89b6f..29f691f44c 100644 --- a/src/frontends/qt4/GuiHSpace.cpp +++ b/src/frontends/qt4/GuiHSpace.cpp @@ -19,6 +19,7 @@ #include "LyXRC.h" #include "Spacing.h" #include "FuncRequest.h" + #include "insets/InsetSpace.h" #include "support/gettext.h" @@ -248,9 +249,8 @@ void GuiHSpace::updateContents() bool GuiHSpace::initialiseParams(string const & data) { - InsetSpaceMailer::string2params(data, params_); + InsetSpace::string2params(data, params_); setButtonsValid(true); - return true; } @@ -263,13 +263,13 @@ void GuiHSpace::clearParams() void GuiHSpace::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetSpaceMailer::params2string(params_))); + dispatch(FuncRequest(getLfun(), InsetSpace::params2string(params_))); } bool GuiHSpace::isValid() { - return (spacingCO->currentIndex() != 7 || !valueLE->text().isEmpty()); + return spacingCO->currentIndex() != 7 || !valueLE->text().isEmpty(); } diff --git a/src/frontends/qt4/GuiListings.cpp b/src/frontends/qt4/GuiListings.cpp index 614a1c1995..11472e7463 100644 --- a/src/frontends/qt4/GuiListings.cpp +++ b/src/frontends/qt4/GuiListings.cpp @@ -605,7 +605,7 @@ bool GuiListings::isValid() bool GuiListings::initialiseParams(string const & data) { - InsetListingsMailer::string2params(data, params_); + InsetListings::string2params(data, params_); return true; } @@ -618,7 +618,7 @@ void GuiListings::clearParams() void GuiListings::dispatchParams() { - string const lfun = InsetListingsMailer::params2string(params_); + string const lfun = InsetListings::params2string(params_); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt4/GuiNote.cpp b/src/frontends/qt4/GuiNote.cpp index 0768328096..038b053623 100644 --- a/src/frontends/qt4/GuiNote.cpp +++ b/src/frontends/qt4/GuiNote.cpp @@ -75,7 +75,7 @@ void GuiNote::applyView() bool GuiNote::initialiseParams(string const & data) { - InsetNoteMailer::string2params(data, params_); + InsetNote::string2params(data, params_); return true; } @@ -88,7 +88,7 @@ void GuiNote::clearParams() void GuiNote::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_))); + dispatch(FuncRequest(getLfun(), InsetNote::params2string(params_))); } diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 4d5c202b57..54bf939037 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -926,7 +926,7 @@ bool GuiTabular::initialiseParams(string const & data) } InsetTabular tmp(buffer()); - InsetTabularMailer::string2params(data, tmp); + InsetTabular::string2params(data, tmp); tabular_ = Tabular(tmp.tabular); return true; } diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 22bb43d55f..e2195fe596 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -106,7 +106,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBITEM_CODE); - InsetCommandMailer::string2params("bibitem", to_utf8(cmd.argument()), p); + InsetCommand::string2params("bibitem", to_utf8(cmd.argument()), p); if (p.getCmdName().empty()) { cur.noUpdate(); break; @@ -164,7 +164,7 @@ int InsetBibitem::plaintext(odocstream & os, OutputParams const &) const // ale070405 -docstring const bibitemWidest(Buffer const & buffer) +docstring bibitemWidest(Buffer const & buffer) { int w = 0; diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index 44adc6b1ef..5cc1f70c61 100644 --- a/src/insets/InsetBibitem.h +++ b/src/insets/InsetBibitem.h @@ -12,26 +12,37 @@ #ifndef INSET_BIBITEM_H #define INSET_BIBITEM_H - #include "InsetCommand.h" #include "BiblioInfo.h" namespace lyx { -/** Used to insert bibitem's information (key and label) +///////////////////////////////////////////////////////////////////////// +// +// InsetBibItem +// +///////////////////////////////////////////////////////////////////////// + +/// Used to insert bibitem's information (key and label) - Must be automatically inserted as the first object in a - bibliography paragraph. - */ -class InsetBibitem : public InsetCommand { +// Must be automatically inserted as the first object in a +// bibliography paragraph. +class InsetBibitem : public InsetCommand +{ public: /// InsetBibitem(InsetCommandParams const &); + /// + static ParamInfo const & findInfo(std::string const &); + /// + static std::string defaultCommand() { return "bibitem"; } + /// + static bool isCompatibleCommand(std::string const & s) + { return s == "bibitem"; } +private: /// verify label and update references. - /** - * Overloaded from Inset::initView. - **/ + /// Overloaded from Inset::initView. void initView(); /// bool isLabeled() const { return true; } @@ -52,20 +63,13 @@ public: /// Update the counter of this inset virtual void updateLabels(ParIterator const &); /// - static ParamInfo const & findInfo(std::string const &); - /// - static std::string defaultCommand() { return "bibitem"; }; - /// - static bool isCompatibleCommand(std::string const & s) - { return s == "bibitem"; } - /// void updateCommand(docstring const & new_key, bool dummy = false); -protected: /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); -private: + void doDispatch(Cursor & cur, FuncRequest & cmd); /// - virtual Inset * clone() const { return new InsetBibitem(*this); } + Inset * clone() const { return new InsetBibitem(*this); } + + friend docstring bibitemWidest(Buffer const & buffer); /// The label that is set by updateLabels docstring autolabel_; /// @@ -74,8 +78,7 @@ private: /// Return the widest label in the Bibliography. -docstring const bibitemWidest(Buffer const &); - +docstring bibitemWidest(Buffer const &); } // namespace lyx diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index c46176eb8d..e5c0567619 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -91,7 +91,7 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBTEX_CODE); try { - if (!InsetCommandMailer::string2params("bibtex", + if (!InsetCommand::string2params("bibtex", to_utf8(cmd.argument()), p)) { cur.noUpdate(); break; diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index a261897cf8..6770189fa1 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -14,6 +14,7 @@ #include "Buffer.h" #include "BufferParams.h" +#include "BufferView.h" #include "BranchList.h" #include "Color.h" #include "Counters.h" @@ -21,17 +22,21 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "support/gettext.h" #include "Lexer.h" #include "OutputParams.h" #include "TextClass.h" +#include "support/debug.h" +#include "support/gettext.h" + +#include "frontends/Application.h" + #include using namespace std; -namespace lyx { +namespace lyx { InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params) : InsetCollapsable(buf), params_(params) @@ -40,7 +45,7 @@ InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params) InsetBranch::~InsetBranch() { - InsetBranchMailer(*this).hideDialog(); + hideDialogs("branch", this); } @@ -103,7 +108,8 @@ ColorCode InsetBranch::backgroundColor() const bool InsetBranch::showInsetDialog(BufferView * bv) const { - InsetBranchMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("branch", params2string(params()), + const_cast(this)); return true; } @@ -113,7 +119,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetBranchParams params; - InsetBranchMailer::string2params(to_utf8(cmd.argument()), params); + InsetBranch::string2params(to_utf8(cmd.argument()), params); params_.branch = params.branch; setLayout(cur.buffer().params()); break; @@ -127,7 +133,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_INSET_DIALOG_UPDATE: - InsetBranchMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("branch", params2string(params())); break; case LFUN_INSET_TOGGLE: @@ -259,30 +265,16 @@ bool InsetBranch::isMacroScope() const } -string const InsetBranchMailer::name_("branch"); - -InsetBranchMailer::InsetBranchMailer(InsetBranch & inset) - : inset_(inset) -{} - - -string const InsetBranchMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -string const InsetBranchMailer::params2string(InsetBranchParams const & params) +string InsetBranch::params2string(InsetBranchParams const & params) { ostringstream data; - data << name_ << ' '; + data << "branch" << ' '; params.write(data); return data.str(); } -void InsetBranchMailer::string2params(string const & in, - InsetBranchParams & params) +void InsetBranch::string2params(string const & in, InsetBranchParams & params) { params = InsetBranchParams(); if (in.empty()) @@ -294,15 +286,21 @@ void InsetBranchMailer::string2params(string const & in, string name; lex >> name; - if (name != name_) - return print_mailer_error("InsetBranchMailer", in, 1, name_); + if (name != "branch") { + LYXERR0("InsetBranch::string2params(" << in << ")\n" + "Expected arg 1 to be \"branch\"\n"); + return; + } // This is part of the inset proper that is usually swallowed // by Text::readInset string id; lex >> id; - if (!lex || id != "Branch") - return print_mailer_error("InsetBranchMailer", in, 2, "Branch"); + if (!lex || id != "Branch") { + LYXERR0("InsetBranch::string2params(" << in << ")\n" + "Expected arg 2 to be \"Branch\"\n"); + return; + } params.read(lex); } diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 8793602a2e..ca24e99980 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -13,13 +13,13 @@ #define INSETBRANCH_H #include "InsetCollapsable.h" -#include "MailInset.h" namespace lyx { class InsetBranchParams { public: + /// explicit InsetBranchParams(docstring const & b = docstring()) : branch(b) {} /// @@ -31,15 +31,28 @@ public: }; -/** The Branch inset for alternative, conditional output. +///////////////////////////////////////////////////////////////////////// +// +// InsetBranch +// +///////////////////////////////////////////////////////////////////////// + +/// The Branch inset for alternative, conditional output. -*/ -class InsetBranch : public InsetCollapsable { +class InsetBranch : public InsetCollapsable +{ public: /// InsetBranch(Buffer const &, InsetBranchParams const &); /// ~InsetBranch(); + + /// + static std::string params2string(InsetBranchParams const &); + /// + static void string2params(std::string const &, InsetBranchParams &); + +private: /// docstring editMessage() const; /// @@ -51,7 +64,7 @@ public: /// void setButtonLabel(); /// - virtual ColorCode backgroundColor() const; + ColorCode backgroundColor() const; /// bool showInsetDialog(BufferView *) const; /// @@ -76,48 +89,24 @@ public: /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; /// - virtual void updateLabels(ParIterator const &); + void updateLabels(ParIterator const &); /// bool isMacroScope() const; /// docstring toolTip(BufferView const & bv, int x, int y) const; /// - virtual bool useEmptyLayout() const { return false; } -protected: + bool useEmptyLayout() const { return false; } /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// docstring name() const { return from_ascii("Branch"); } -private: - /// - friend class InsetBranchParams; /// Inset * clone() const { return new InsetBranch(*this); } - /// - InsetBranchParams params_; -}; - -class InsetBranchMailer : public MailInset { -public: - /// - InsetBranchMailer(InsetBranch & 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(InsetBranchParams const &); /// - static void string2params(std::string const &, InsetBranchParams &); - -private: - /// - static std::string const name_; + friend class InsetBranchParams; /// - InsetBranch & inset_; + InsetBranchParams params_; }; } // namespace lyx diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index 85f3f0ae22..4d403b66f0 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -10,9 +10,8 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSET_CITE_H -#define INSET_CITE_H - +#ifndef INSET_CITATION_H +#define INSET_CITATION_H #include "InsetCommand.h" #include "InsetCode.h" @@ -22,13 +21,18 @@ namespace lyx { +///////////////////////////////////////////////////////////////////////// +// +// InsetCitation +// +///////////////////////////////////////////////////////////////////////// -/** Used to insert citations - */ -class InsetCitation : public InsetCommand { +/// Used to insert citations +class InsetCitation : public InsetCommand +{ public: /// - InsetCitation(InsetCommandParams const &); + explicit InsetCitation(InsetCommandParams const &); /// bool isLabeled() const { return true; } /// @@ -54,12 +58,11 @@ public: /// static ParamInfo const & findInfo(std::string const &); - //FIXME This is the locus of the design problem we have. - //It really ought to do what default_cite_command() does, - //but to do that it needs to know what CiteEngine we are - //using. - /// - static std::string defaultCommand() { return "cite"; }; + // FIXME This is the locus of the design problem we have. + // It really ought to do what default_cite_command() does, + // but to do that it needs to know what CiteEngine we are + // using. + static std::string defaultCommand() { return "cite"; } /// static bool isCompatibleCommand(std::string const & cmd); private: @@ -89,7 +92,6 @@ private: mutable Cache cache; }; - } // namespace lyx -#endif // INSET_CITE_H +#endif // INSET_CITATION_H diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index aceb05b621..6a3a382e55 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -18,16 +18,20 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "support/gettext.h" #include "Lexer.h" #include "MetricsInfo.h" +#include "support/debug.h" +#include "support/gettext.h" + +#include "frontends/Application.h" + #include using namespace std; -namespace lyx { +namespace lyx { // FIXME Would it now be possible to use the InsetCode in // place of the mailer name and recover that information? @@ -42,7 +46,7 @@ InsetCommand::InsetCommand(InsetCommandParams const & p, InsetCommand::~InsetCommand() { if (!mailer_name_.empty()) - InsetCommandMailer(mailer_name_, *this).hideDialog(); + hideDialogs(mailer_name_, this); } @@ -67,6 +71,18 @@ void InsetCommand::draw(PainterInfo & pi, int x, int y) const } +void InsetCommand::setParam(std::string const & name, docstring const & value) +{ + p_[name] = value; +} + + +docstring const & InsetCommand::getParam(std::string const & name) const +{ + return p_[name]; +} + + void InsetCommand::setParams(InsetCommandParams const & p) { p_ = p; @@ -106,7 +122,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) break; } InsetCommandParams p(p_.code()); - InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p); + InsetCommand::string2params(mailer_name_, to_utf8(cmd.argument()), p); if (p.getCmdName().empty()) cur.noUpdate(); else @@ -116,7 +132,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_DIALOG_UPDATE: { string const name = to_utf8(cmd.argument()); - InsetCommandMailer(name, *this).updateDialog(&cur.bv()); + cur.bv().updateDialog(name, params2string(name, params())); break; } @@ -169,25 +185,13 @@ docstring InsetCommand::contextMenu(BufferView const &, int, int) const void InsetCommand::edit(Cursor & cur, bool, EntryDirection) { if (!mailer_name_.empty()) - InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv()); -} - - -InsetCommandMailer::InsetCommandMailer( - string const & name, InsetCommand & inset) - : name_(name), inset_(inset) -{} - - -string const InsetCommandMailer::inset2string(Buffer const &) const -{ - return params2string(name(), inset_.params()); + cur.bv().showDialog(mailer_name_, params2string(mailer_name_, p_), this); } -//FIXME This could take an InsetCode instead of a string -bool InsetCommandMailer::string2params( - string const & name, string const & in, InsetCommandParams & params) +// FIXME This could take an InsetCode instead of a string +bool InsetCommand::string2params(string const & name, string const & in, + InsetCommandParams & params) { params.clear(); if (in.empty()) @@ -200,7 +204,8 @@ bool InsetCommandMailer::string2params( string n; lex >> n; if (!lex || n != name) { - print_mailer_error("InsetCommandMailer", in, 1, name); + LYXERR0("InsetCommand::string2params(" << in << ")\n" + "Expected arg 1 to be \"" << name << "\"\n"); return false; } @@ -209,7 +214,8 @@ bool InsetCommandMailer::string2params( string id; lex >> id; if (!lex || id != "CommandInset") { - print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand"); + LYXERR0("InsetCommand::string2params(" << in << ")\n" + "Expected arg 2 to be \"CommandInset\"\n"); return false; } @@ -218,9 +224,8 @@ bool InsetCommandMailer::string2params( } -//FIXME This could take an InsetCode instead of a string -string const -InsetCommandMailer::params2string(string const & name, +// FIXME This could take an InsetCode instead of a string +string InsetCommand::params2string(string const & name, InsetCommandParams const & params) { ostringstream data; diff --git a/src/insets/InsetCommand.h b/src/insets/InsetCommand.h index 9e946745ca..503c8124e7 100644 --- a/src/insets/InsetCommand.h +++ b/src/insets/InsetCommand.h @@ -10,41 +10,76 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSET_LATEXCOMMAND_H -#define INSET_LATEXCOMMAND_H +#ifndef INSETCOMMAND_H +#define INSETCOMMAND_H #include "Inset.h" #include "InsetCommandParams.h" #include "RenderButton.h" -#include "MailInset.h" #include "Cursor.h" namespace lyx { +///////////////////////////////////////////////////////////////////////// +// +// InsetCommand +// +///////////////////////////////////////////////////////////////////////// + // Created by Alejandro 970222 -/** Used to insert a LaTeX command automatically. - */ +// Used to insert a LaTeX command automatically. -/// -class InsetCommand : public Inset { +class InsetCommand : public Inset +{ public: /// InsetCommand(InsetCommandParams const &, std::string const & mailer_name); /// ~InsetCommand(); + + /// returns true if params are successfully read + static bool string2params(std::string const &, std::string const & name, + InsetCommandParams &); /// - void metrics(MetricsInfo &, Dimension &) const; + static std::string params2string(std::string const & name, + InsetCommandParams const &); /// - Dimension const dimension(BufferView const &) const { return button_.dimension(); } + InsetCommandParams const & params() const { return p_; } /// - void draw(PainterInfo & pi, int x, int y) const; + void setParams(InsetCommandParams const &); + /// + void setParam(std::string const & name, docstring const & value); + /// + docstring const & getParam(std::string const & name) const; + /// FIXME Remove + docstring const getFirstNonOptParam() const { return p_.getFirstNonOptParam(); } + /// update label and references. + virtual void updateCommand(docstring const &, bool) {} + +protected: /// void write(std::ostream & os) const { p_.write(os); } /// void read(Lexer & lex) { p_.read(lex); } /// + void doDispatch(Cursor & cur, FuncRequest & cmd); + /// + docstring const getCommand() const { return p_.getCommand(); } + /// + std::string const & getCmdName() const { return p_.getCmdName(); } + /// + void setCmdName(std::string const & n) { p_.setCmdName(n); } + +private: + /// + void metrics(MetricsInfo &, Dimension &) const; + /// + Dimension const dimension(BufferView const &) const { return button_.dimension(); } + /// + void draw(PainterInfo & pi, int x, int y) const; + /// int latex(odocstream &, OutputParams const &) const; /// int plaintext(odocstream &, OutputParams const &) const; @@ -53,20 +88,6 @@ public: /// InsetCode lyxCode() const { return NO_CODE; } /// - InsetCommandParams const & params() const { return p_; } - /// FIXME Remove - docstring const getFirstNonOptParam() const { return p_.getFirstNonOptParam(); } - /// - void setParam(std::string const & name, docstring const & value) - { - p_[name] = value; - } - /// - docstring const & getParam(std::string const & name) const - { - return p_[name]; - } - /// void edit(Cursor & cur, bool front, EntryDirection entry_from = ENTRY_DIRECTION_IGNORE); /// @@ -82,24 +103,10 @@ public: /// Whether this is a command this inset can represent. /// Not implemented here. Must be implemented in derived class. static bool isCompatibleCommand(std::string const & cmd); - /// update label and references. - virtual void updateCommand(docstring const &, bool) {}; - /// - virtual docstring contextMenu(BufferView const & bv, int x, int y) const; - -protected: /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); + docstring contextMenu(BufferView const & bv, int x, int y) const; /// bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; - /// - docstring const getCommand() const { return p_.getCommand(); } - /// - std::string const & getCmdName() const { return p_.getCmdName(); } - /// - void setCmdName(std::string const & n) { p_.setCmdName(n); } - /// - void setParams(InsetCommandParams const &); /// This should provide the text for the button virtual docstring screenLabel() const = 0; @@ -115,31 +122,6 @@ private: }; -class InsetCommandMailer : public MailInset { -public: - /// - InsetCommandMailer(std::string const & name, InsetCommand & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// returns true if params are successfully read - static bool string2params(std::string const &, std::string const & name, - InsetCommandParams &); - /// - static std::string const params2string(std::string const & name, - InsetCommandParams const &); -private: - /// - std::string const name_; - /// - InsetCommand & inset_; -}; - - - } // namespace lyx #endif diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index e4129b4789..7b23d9df79 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -18,6 +18,7 @@ #include "insets/RenderPreview.h" #include "Buffer.h" +#include "BufferView.h" #include "Cursor.h" #include "DispatchResult.h" #include "Exporter.h" @@ -31,6 +32,7 @@ #include "OutputParams.h" #include "frontends/alert.h" +#include "frontends/Application.h" #include "graphics/PreviewLoader.h" @@ -422,7 +424,7 @@ InsetExternal::InsetExternal(InsetExternal const & other) InsetExternal::~InsetExternal() { - InsetExternalMailer(*this).hideDialog(); + hideDialogs("external", this); } @@ -456,25 +458,28 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_EXTERNAL_EDIT: { InsetExternalParams p = params(); if (!cmd.argument().empty()) - InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p); + string2params(to_utf8(cmd.argument()), buffer(), p); external::editExternal(p, buffer()); break; } case LFUN_INSET_MODIFY: { InsetExternalParams p; - InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p); + string2params(to_utf8(cmd.argument()), buffer(), p); setParams(p); break; } case LFUN_INSET_DIALOG_UPDATE: - InsetExternalMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("external", + params2string(params(), cur.bv().buffer())); break; case LFUN_MOUSE_RELEASE: if (!cur.selection() && cmd.button() == mouse_button::button1) - InsetExternalMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("external", + params2string(params(), cur.bv().buffer()), + this); break; default: @@ -514,7 +519,9 @@ void InsetExternal::updateEmbeddedFile(EmbeddedFile const & file) void InsetExternal::edit(Cursor & cur, bool, EntryDirection) { - InsetExternalMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("external", + params2string(params(), cur.bv().buffer()), + this); } @@ -854,10 +861,6 @@ void InsetExternal::validate(LaTeXFeatures & features) const } -// -// preview stuff -// - void InsetExternal::addPreview(graphics::PreviewLoader & ploader) const { RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview(); @@ -872,24 +875,8 @@ void InsetExternal::addPreview(graphics::PreviewLoader & ploader) const } -/// Mailer stuff - -string const InsetExternalMailer::name_("external"); - -InsetExternalMailer::InsetExternalMailer(InsetExternal & inset) - : inset_(inset) -{} - - -string const InsetExternalMailer::inset2string(Buffer const & buffer) const -{ - return params2string(inset_.params(), buffer); -} - - -void InsetExternalMailer::string2params(string const & in, - Buffer const & buffer, - InsetExternalParams & params) +void InsetExternal::string2params(string const & in, Buffer const & buffer, + InsetExternalParams & params) { params = InsetExternalParams(); if (in.empty()) @@ -901,26 +888,31 @@ void InsetExternalMailer::string2params(string const & in, string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetExternalMailer", in, 1, name_); + if (!lex || name != "external") { + LYXERR0("InsetExternal::string2params(" << in << ")\n" + "Expected arg 1 to be \"external\"\n"); + return; + } // This is part of the inset proper that is usually swallowed // by Text::readInset string id; lex >> id; - if (!lex || id != "External") - return print_mailer_error("InsetBoxMailer", in, 2, "External"); + if (!lex || id != "External") { + LYXERR0("InsetExternal::string2params(" << in << ")\n" + "Expected arg 2 to be \"External\"\n"); + return; + } params.read(buffer, lex); } -string const -InsetExternalMailer::params2string(InsetExternalParams const & params, - Buffer const & buffer) +string InsetExternal::params2string(InsetExternalParams const & params, + Buffer const & buffer) { ostringstream data; - data << name_ << ' '; + data << "external" << ' '; params.write(buffer, data); data << "\\end_inset\n"; return data.str(); diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 9bcbdf8837..8956c7c38d 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -22,8 +22,6 @@ #include #include -#include "MailInset.h" - /** No two InsetExternalParams variables can have the same temporary file. * This class has copy-semantics but the copy constructor @@ -112,12 +110,27 @@ public: /// ~InsetExternal(); /// + static void string2params(std::string const &, Buffer const &, + InsetExternalParams &); + /// + static std::string params2string(InsetExternalParams const &, + Buffer const &); + /// + InsetExternalParams const & params() const; + /// + void setParams(InsetExternalParams const &); + /// void setBuffer(Buffer & buffer); + /// \returns the number of rows (\n's) of generated code. + int latex(odocstream &, OutputParams const &) const; + +private: + /// + InsetExternal(InsetExternal const &); /// InsetCode lyxCode() const { return EXTERNAL_CODE; } /// EDITABLE editable() const { return IS_EDITABLE; } - /// void metrics(MetricsInfo &, Dimension &) const; /// @@ -126,21 +139,12 @@ public: void write(std::ostream &) const; /// void read(Lexer & lex); - - /// \returns the number of rows (\n's) of generated code. - int latex(odocstream &, OutputParams const &) const; /// int plaintext(odocstream &, OutputParams const &) const; /// int docbook(odocstream &, OutputParams const &) const; - /// Update needed features for this inset. - virtual void validate(LaTeXFeatures & features) const; - - /// - InsetExternalParams const & params() const; - /// - void setParams(InsetExternalParams const &); + void validate(LaTeXFeatures & features) const; /// void addPreview(graphics::PreviewLoader &) const; /// @@ -151,20 +155,14 @@ public: void registerEmbeddedFiles(EmbeddedFileList &) const; /// void updateEmbeddedFile(EmbeddedFile const &); - -protected: - InsetExternal(InsetExternal const &); /// void doDispatch(Cursor & cur, FuncRequest & cmd); -private: /// Inset * clone() const { return new InsetExternal(*this); } - /** This method is connected to the graphics loader, so we are * informed when the image has been loaded. */ void statusChanged() const; - /** Slot receiving a signal that the external file has changed * and the preview should be regenerated. */ @@ -176,30 +174,6 @@ private: boost::scoped_ptr renderer_; }; - -class InsetExternalMailer : public MailInset { -public: - /// - InsetExternalMailer(InsetExternal & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, Buffer const &, - InsetExternalParams &); - /// - static std::string const params2string(InsetExternalParams const &, - Buffer const &); -private: - /// - static std::string const name_; - /// - InsetExternal & inset_; -}; - } // namespace lyx -#endif +#endif // INSET_EXTERNAL_H diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index ffa99288ce..d201a29194 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -32,16 +32,18 @@ #include "ParIterator.h" #include "TextClass.h" +#include "support/convert.h" #include "support/debug.h" #include "support/gettext.h" #include "support/lstrings.h" #include "support/docstream.h" -#include "support/convert.h" + +#include "frontends/Application.h" using namespace std; -namespace lyx { +namespace lyx { // With this inset it will be possible to support the latex package // float.sty, and I am sure that with this and some additional support @@ -121,7 +123,7 @@ InsetFloat::InsetFloat(Buffer const & buf, string const & type) InsetFloat::~InsetFloat() { - InsetFloatMailer(*this).hideDialog(); + hideDialogs("float", this); } @@ -131,18 +133,18 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetFloatParams params; - InsetFloatMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); params_.placement = params.placement; params_.wide = params.wide; params_.sideways = params.sideways; params_.subfloat = params.subfloat; - wide(params_.wide, cur.buffer().params()); - sideways(params_.sideways, cur.buffer().params()); + setWide(params_.wide, cur.buffer().params()); + setSideways(params_.sideways, cur.buffer().params()); break; } case LFUN_INSET_DIALOG_UPDATE: { - InsetFloatMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("float", params2string(params())); break; } @@ -179,7 +181,7 @@ void InsetFloat::updateLabels(ParIterator const & it) // floats can only embed subfloats of their own kind if (subflt) params_.type = saveflt; - subfloat(subflt, buffer().params()); + setSubfloat(subflt, buffer().params()); // Tell to captions what the current float is cnts.current_float(params().type); @@ -253,9 +255,9 @@ void InsetFloat::write(ostream & os) const void InsetFloat::read(Lexer & lex) { params_.read(lex); - wide(params_.wide, buffer().params()); - sideways(params_.sideways, buffer().params()); - subfloat(params_.subfloat, buffer().params()); + setWide(params_.wide, buffer().params()); + setSideways(params_.sideways, buffer().params()); + setSubfloat(params_.subfloat, buffer().params()); InsetCollapsable::read(lex); } @@ -381,12 +383,13 @@ bool InsetFloat::insetAllowed(InsetCode code) const bool InsetFloat::showInsetDialog(BufferView * bv) const { if (!InsetText::showInsetDialog(bv)) - InsetFloatMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("float", params2string(params()), + const_cast(this)); return true; } -void InsetFloat::wide(bool w, BufferParams const & bp) +void InsetFloat::setWide(bool w, BufferParams const & bp) { params_.wide = w; docstring lab = _("float: ") + floatName(params_.type, bp); @@ -396,7 +399,7 @@ void InsetFloat::wide(bool w, BufferParams const & bp) } -void InsetFloat::sideways(bool s, BufferParams const & bp) +void InsetFloat::setSideways(bool s, BufferParams const & bp) { params_.sideways = s; docstring lab = _("float: ") + floatName(params_.type, bp); @@ -406,7 +409,7 @@ void InsetFloat::sideways(bool s, BufferParams const & bp) } -void InsetFloat::subfloat(bool s, BufferParams const & bp) +void InsetFloat::setSubfloat(bool s, BufferParams const & bp) { params_.subfloat = s; docstring lab = _("float: ") + floatName(params_.type, bp); @@ -442,21 +445,7 @@ docstring InsetFloat::getCaption(OutputParams const & runparams) const } -string const InsetFloatMailer::name_("float"); - -InsetFloatMailer::InsetFloatMailer(InsetFloat & inset) - : inset_(inset) -{} - - -string const InsetFloatMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetFloatMailer::string2params(string const & in, - InsetFloatParams & params) +void InsetFloat::string2params(string const & in, InsetFloatParams & params) { params = InsetFloatParams(); if (in.empty()) @@ -468,15 +457,19 @@ void InsetFloatMailer::string2params(string const & in, string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetFloatMailer", in, 1, name_); + if (!lex || name != "float") { + LYXERR0("InsetFloat::string2params(" << in << ")\n" + "Expected arg 1 to be \"float\"\n"); + } // This is part of the inset proper that is usually swallowed // by Text::readInset string id; lex >> id; - if (!lex || id != "Float") - return print_mailer_error("InsetBoxMailer", in, 2, "Float"); + if (!lex || id != "Float") { + LYXERR0("InsetFloat::string2params(" << in << ")\n" + "Expected arg 1 to be \"Float\"\n"); + } // We have to read the type here! lex >> params.type; @@ -484,10 +477,10 @@ void InsetFloatMailer::string2params(string const & in, } -string const InsetFloatMailer::params2string(InsetFloatParams const & params) +string InsetFloat::params2string(InsetFloatParams const & params) { ostringstream data; - data << name_ << ' '; + data << "float" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 1313484f62..e806d9a709 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -10,16 +10,14 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETFLOAT_H -#define INSETFLOAT_H +#ifndef INSET_FLOAT_H +#define INSET_FLOAT_H #include "InsetCollapsable.h" -#include "MailInset.h" namespace lyx { - class InsetFloatParams { public: /// @@ -41,15 +39,35 @@ public: }; -/** The float inset -*/ -class InsetFloat : public InsetCollapsable { +///////////////////////////////////////////////////////////////////////// +// +// InsetFloat +// +///////////////////////////////////////////////////////////////////////// + +/// Used for "floating" objects like tables, figures etc. +class InsetFloat : public InsetCollapsable +{ public: /// InsetFloat(Buffer const &, std::string const &); /// ~InsetFloat(); + + /// + static void string2params(std::string const &, InsetFloatParams &); + /// + static std::string params2string(InsetFloatParams const &); + /// + void setWide(bool w, BufferParams const &); + /// + void setSideways(bool s, BufferParams const &); + /// + void setSubfloat(bool s, BufferParams const &); + /// + InsetFloatParams const & params() const { return params_; } +private: /// docstring name() const { return name_; } /// @@ -75,16 +93,7 @@ public: insets that may contain several paragraphs */ bool noFontChange() const { return true; } /// - void wide(bool w, BufferParams const &); - /// - void sideways(bool s, BufferParams const &); - /// - void subfloat(bool s, BufferParams const &); - /// bool showInsetDialog(BufferView *) const; - /// - InsetFloatParams const & params() const { return params_; } -private: /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; // Update the counters of this inset and of its contents @@ -102,28 +111,6 @@ private: }; -class InsetFloatMailer : public MailInset { -public: - /// - InsetFloatMailer(InsetFloat & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetFloatParams &); - /// - static std::string const params2string(InsetFloatParams const &); -private: - /// - static std::string const name_; - /// - InsetFloat & inset_; -}; - - } // namespace lyx -#endif +#endif // INSET_FLOAT_H diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 0431b51de2..704f57f053 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -70,6 +70,7 @@ TODO #include "TocBackend.h" #include "frontends/alert.h" +#include "frontends/Application.h" #include "support/convert.h" #include "support/debug.h" @@ -177,7 +178,7 @@ Inset * InsetGraphics::clone() const InsetGraphics::~InsetGraphics() { - InsetGraphicsMailer(*this).hideDialog(); + hideDialogs("graphics", this); } @@ -204,14 +205,14 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_GRAPHICS_EDIT: { InsetGraphicsParams p = params(); if (!cmd.argument().empty()) - InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p); + string2params(to_utf8(cmd.argument()), buffer(), p); editGraphics(p, buffer()); break; } case LFUN_INSET_MODIFY: { InsetGraphicsParams p; - InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer(), p); + string2params(to_utf8(cmd.argument()), buffer(), p); if (!p.filename.empty()) setParams(p); else @@ -220,12 +221,14 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - InsetGraphicsMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("graphics", params2string(params(), +cur.bv().buffer())); break; case LFUN_MOUSE_RELEASE: if (!cur.selection() && cmd.button() == mouse_button::button1) - InsetGraphicsMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("graphics", params2string(params(), +cur.bv().buffer()), this); break; default: @@ -266,7 +269,8 @@ void InsetGraphics::updateEmbeddedFile(EmbeddedFile const & file) void InsetGraphics::edit(Cursor & cur, bool, EntryDirection) { - InsetGraphicsMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("graphics", params2string(params(), +cur.bv().buffer()), this); } @@ -309,7 +313,7 @@ void InsetGraphics::read(Lexer & lex) } -string const InsetGraphics::createLatexOptions() const +string InsetGraphics::createLatexOptions() const { // Calculate the options part of the command, we must do it to a string // stream since we might have a trailing comma that we would like to remove @@ -368,7 +372,7 @@ string const InsetGraphics::createLatexOptions() const } -docstring const InsetGraphics::toDocbookLength(Length const & len) const +docstring InsetGraphics::toDocbookLength(Length const & len) const { odocstringstream result; switch (len.unit()) { @@ -425,7 +429,8 @@ docstring const InsetGraphics::toDocbookLength(Length const & len) const return result.str(); } -docstring const InsetGraphics::createDocBookAttributes() const + +docstring InsetGraphics::createDocBookAttributes() const { // Calculate the options part of the command, we must do it to a string // stream since we copied the code from createLatexParams() ;-) @@ -949,22 +954,8 @@ docstring InsetGraphics::contextMenu(BufferView const &, int, int) const } -string const InsetGraphicsMailer::name_("graphics"); - -InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset) - : inset_(inset) -{} - - -string const InsetGraphicsMailer::inset2string(Buffer const & buffer) const -{ - return params2string(inset_.params(), buffer); -} - - -void InsetGraphicsMailer::string2params(string const & in, - Buffer const & buffer, - InsetGraphicsParams & params) +void InsetGraphics::string2params(string const & in, Buffer const & buffer, + InsetGraphicsParams & params) { if (in.empty()) return; @@ -975,20 +966,22 @@ void InsetGraphicsMailer::string2params(string const & in, string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetGraphicsMailer", in, 1, name_); + if (!lex || name != "graphics") { + LYXERR0("InsetGraphics::string2params(" << in << ")\n" + "Expected arg 1 to be \"graphics\"\n"); + return; + } params = InsetGraphicsParams(); readInsetGraphics(lex, buffer.filePath(), params); } -string const -InsetGraphicsMailer::params2string(InsetGraphicsParams const & params, - Buffer const & buffer) +string InsetGraphics::params2string(InsetGraphicsParams const & params, + Buffer const & buffer) { ostringstream data; - data << name_ << ' '; + data << "graphics" << ' '; params.Write(data, buffer); data << "\\end_inset\n"; return data.str(); diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 2630e82b90..5f8f5aea35 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -15,7 +15,6 @@ #include "Inset.h" #include "InsetGraphicsParams.h" -#include "MailInset.h" #include #include @@ -26,13 +25,37 @@ namespace lyx { class RenderGraphic; class LaTeXFeatures; -/// -class InsetGraphics : public Inset, public boost::signals::trackable { +///////////////////////////////////////////////////////////////////////// +// +// InsetGraphics +// +///////////////////////////////////////////////////////////////////////// + +/// Used for images etc. +class InsetGraphics : public Inset, public boost::signals::trackable +{ public: /// InsetGraphics(Buffer & buf); /// ~InsetGraphics(); + + /// + static void string2params(std::string const & data, + Buffer const & buffer, + InsetGraphicsParams &); + /// + static std::string params2string(InsetGraphicsParams const &, + Buffer const &); + /** Set the inset parameters, used by the GUIndependent dialog. + Return true of new params are different from what was so far. + */ + bool setParams(InsetGraphicsParams const & params); + +private: + /// + InsetGraphics(InsetGraphics const &); + /// void setBuffer(Buffer & buffer); /// @@ -44,7 +67,6 @@ public: void write(std::ostream &) const; /// void read(Lexer & lex); - /** returns the number of rows (\n's) of generated tex code. #fragile == true# means, that the inset should take care about fragile commands by adding a #\protect# before. @@ -54,20 +76,12 @@ public: int plaintext(odocstream &, OutputParams const &) const; /// int docbook(odocstream &, OutputParams const &) const; - /** Tell LyX what the latex features you need i.e. what latex packages you need to be included. */ void validate(LaTeXFeatures & features) const; - /// returns LyX code associated with the inset. Used for TOC, ...) InsetCode lyxCode() const { return GRAPHICS_CODE; } - - /** Set the inset parameters, used by the GUIndependent dialog. - Return true of new params are different from what was so far. - */ - bool setParams(InsetGraphicsParams const & params); - /// Get the inset parameters, used by the GUIndependent dialog. InsetGraphicsParams const & params() const; /// @@ -86,65 +100,31 @@ public: void addToToc(ParConstIterator const &) const; /// docstring contextMenu(BufferView const & bv, int x, int y) const; - /// Force inset into LTR environment if surroundings are RTL? - virtual bool forceLTR() const { return true; } -protected: - InsetGraphics(InsetGraphics const &); + bool forceLTR() const { return true; } /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); -private: - friend class InsetGraphicsMailer; - - virtual Inset * clone() const; - + void doDispatch(Cursor & cur, FuncRequest & cmd); + /// + Inset * clone() const; /// Get the status message, depends on the image loading status. - std::string const statusMessage() const; + std::string statusMessage() const; /// Create the options for the latex command. - std::string const createLatexOptions() const; + std::string createLatexOptions() const; /// Create length values for docbook export. - docstring const toDocbookLength(Length const & len) const; + docstring toDocbookLength(Length const & len) const; /// Create the atributes for docbook export. - docstring const createDocBookAttributes() const; + docstring createDocBookAttributes() const; /// Convert the file if needed, and return the location of the file. std::string prepareFile(OutputParams const &) const; /// InsetGraphicsParams params_; - /// holds the entity name that defines the graphics location (SGML). docstring const graphic_label; - /// The thing that actually draws the image on LyX's screen. boost::scoped_ptr const graphic_; }; - -class InsetGraphicsMailer : public MailInset { -public: - /// - InsetGraphicsMailer(InsetGraphics & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const & data, - Buffer const & buffer, - InsetGraphicsParams &); - /// - static std::string const params2string(InsetGraphicsParams const &, - Buffer const &); -private: - /// - static std::string const name_; - /// - InsetGraphics & inset_; -}; - - } // namespace lyx -#endif +#endif // INSET_GRAPHICS_H diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index daa0fbafa2..6002e7f588 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -263,7 +263,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(INCLUDE_CODE); - InsetCommandMailer::string2params("include", to_utf8(cmd.argument()), p); + InsetCommand::string2params("include", to_utf8(cmd.argument()), p); if (!p.getCmdName().empty()) { if (isListings(p)){ InsetListingsParams new_params(to_utf8(p["lstparams"])); diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index 78cfa959a6..957c3dd78e 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -13,12 +13,12 @@ #ifndef INSET_INCLUDE_H #define INSET_INCLUDE_H -#include "BiblioInfo.h" #include "InsetCommand.h" + +#include "BiblioInfo.h" +#include "Counters.h" #include "InsetCommandParams.h" #include "RenderButton.h" -#include "MailInset.h" -#include "Counters.h" #include "EmbeddedFiles.h" #include @@ -93,7 +93,7 @@ public: /// static ParamInfo const & findInfo(std::string const &); /// - static std::string defaultCommand() { return "include"; }; + static std::string defaultCommand() { return "include"; } /// static bool isCompatibleCommand(std::string const & s); protected: @@ -130,4 +130,4 @@ Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params); } // namespace lyx -#endif // INSETINCLUDE_H +#endif // INSET_INCLUDE_H diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 3c577eb2c4..65247a2971 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -137,7 +137,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(LABEL_CODE); // FIXME UNICODE - InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p); + InsetCommand::string2params("label", to_utf8(cmd.argument()), p); if (p.getCmdName().empty()) { cur.noUpdate(); break; diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index e74773d30b..348e620b35 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -12,15 +12,16 @@ #include #include "InsetListings.h" -#include "InsetCaption.h" #include "Buffer.h" +#include "BufferView.h" #include "BufferParams.h" #include "Counters.h" #include "Cursor.h" #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" +#include "InsetCaption.h" #include "InsetList.h" #include "Language.h" #include "MetricsInfo.h" @@ -31,6 +32,8 @@ #include "support/gettext.h" #include "support/lstrings.h" +#include "frontends/Application.h" + #include #include @@ -52,7 +55,7 @@ InsetListings::InsetListings(Buffer const & buf, InsetListingsParams const & par InsetListings::~InsetListings() { - InsetListingsMailer(*this).hideDialog(); + hideDialogs("listings", this); } @@ -154,7 +157,7 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const } } if (isInline) { - char const * delimiter = lstinline_delimiters; + char const * delimiter = lstinline_delimiters; for (; delimiter != '\0'; ++delimiter) if (!contains(code, *delimiter)) break; @@ -209,11 +212,11 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: { - InsetListingsMailer::string2params(to_utf8(cmd.argument()), params()); + InsetListings::string2params(to_utf8(cmd.argument()), params()); break; } case LFUN_INSET_DIALOG_UPDATE: - InsetListingsMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("listings", params2string(params())); break; default: InsetCollapsable::doDispatch(cur, cmd); @@ -258,7 +261,8 @@ void InsetListings::validate(LaTeXFeatures & features) const bool InsetListings::showInsetDialog(BufferView * bv) const { - InsetListingsMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("listings", params2string(params()), + const_cast(this)); return true; } @@ -302,20 +306,7 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const } -string const InsetListingsMailer::name_("listings"); - -InsetListingsMailer::InsetListingsMailer(InsetListings & inset) - : inset_(inset) -{} - - -string const InsetListingsMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetListingsMailer::string2params(string const & in, +void InsetListings::string2params(string const & in, InsetListingsParams & params) { params = InsetListingsParams(); @@ -330,11 +321,10 @@ void InsetListingsMailer::string2params(string const & in, } -string const -InsetListingsMailer::params2string(InsetListingsParams const & params) +string InsetListings::params2string(InsetListingsParams const & params) { ostringstream data; - data << name_ << " "; + data << "listings" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index d21bda8ce6..a1eeeda315 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -9,27 +9,35 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETLISTINGS_H -#define INSETLISTINGS_H +#ifndef INSET_LISTINGS_H +#define INSET_LISTINGS_H #include "LaTeXFeatures.h" #include "InsetERT.h" #include "InsetListingsParams.h" -#include "MailInset.h" namespace lyx { -/** A collapsable text inset for program listings. - */ - +///////////////////////////////////////////////////////////////////////// +// +// InsetListings +// +///////////////////////////////////////////////////////////////////////// -class InsetListings : public InsetCollapsable { +/// A collapsable text inset for program listings. +class InsetListings : public InsetCollapsable +{ public: /// InsetListings(Buffer const &, InsetListingsParams const & par = InsetListingsParams()); /// ~InsetListings(); + /// + static void string2params(std::string const &, InsetListingsParams &); + /// + static std::string params2string(InsetListingsParams const &); +private: /// bool isLabeled() const { return true; } /// @@ -58,8 +66,6 @@ public: InsetListingsParams & params() { return params_; } /// docstring contextMenu(BufferView const & bv, int x, int y) const; - -private: /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// @@ -70,34 +76,11 @@ private: void setButtonLabel(); /// docstring getCaption(OutputParams const &) const; - /// - InsetListingsParams params_; -}; - -class InsetListingsMailer : public MailInset { -public: - /// - InsetListingsMailer(InsetListings & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, - InsetListingsParams &); /// - static std::string const params2string(InsetListingsParams const &); -private: - /// - static std::string const name_; - /// - InsetListings & inset_; + InsetListingsParams params_; }; - } // namespace lyx -#endif +#endif // INSET_LISTINGS_H diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 72faac733b..72f7e13709 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -13,19 +13,20 @@ #include "InsetNewline.h" +#include "Dimension.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "Dimension.h" #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" +#include "frontends/Application.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" #include "support/debug.h" -#include "support/docstring.h" #include "support/docstream.h" +#include "support/docstring.h" using namespace std; @@ -34,6 +35,7 @@ namespace lyx { InsetNewline::InsetNewline() {} + void InsetNewlineParams::write(ostream & os) const { string command; @@ -98,7 +100,7 @@ void InsetNewline::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetNewlineParams params; - InsetNewlineMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); params_.kind = params.kind; break; } @@ -118,10 +120,11 @@ bool InsetNewline::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "newline") { InsetNewlineParams params; - InsetNewlineMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); status.setOnOff(params_.kind == params.kind); - } else + } else { status.enabled(true); + } return true; default: return Inset::getStatus(cur, cmd, status); @@ -259,21 +262,7 @@ docstring InsetNewline::contextMenu(BufferView const &, int, int) const } -string const InsetNewlineMailer::name_ = "newline"; - - -InsetNewlineMailer::InsetNewlineMailer(InsetNewline & inset) - : inset_(inset) -{} - - -string const InsetNewlineMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetNewlineMailer::string2params(string const & in, InsetNewlineParams & params) +void InsetNewline::string2params(string const & in, InsetNewlineParams & params) { params = InsetNewlineParams(); if (in.empty()) @@ -285,17 +274,19 @@ void InsetNewlineMailer::string2params(string const & in, InsetNewlineParams & p string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetNewlineMailer", in, 1, name_); + if (!lex || name != "newline") { + LYXERR0("Expected arg 1 to be \"newlien\" in " << in); + return; + } params.read(lex); } -string const InsetNewlineMailer::params2string(InsetNewlineParams const & params) +string InsetNewline::params2string(InsetNewlineParams const & params) { ostringstream data; - data << name_ << ' '; + data << "newline" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index 50a08face7..fc7684ab73 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -13,15 +13,12 @@ #define INSET_NEWLINE_H #include "Inset.h" -#include "MailInset.h" - -#include "support/docstring.h" -#include "support/gettext.h" namespace lyx { -class InsetNewlineParams { +class InsetNewlineParams +{ public: /// The different kinds of spaces we support enum Kind { @@ -48,6 +45,11 @@ public: InsetNewline(); /// InsetNewline(InsetNewlineParams par) { params_.kind = par.kind; } + /// + static void string2params(std::string const &, InsetNewlineParams &); + /// + static std::string params2string(InsetNewlineParams const &); +private: /// InsetNewlineParams params() const { return params_; } /// @@ -72,39 +74,16 @@ public: /// ColorCode ColorName() const; /// - virtual docstring contextMenu(BufferView const & bv, int x, int y) const; - -private: + docstring contextMenu(BufferView const & bv, int x, int y) const; /// Inset * clone() const { return new InsetNewline(*this); } /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; - /// - InsetNewlineParams params_; -}; - -class InsetNewlineMailer : public MailInset { -public: - /// - InsetNewlineMailer(InsetNewline & inset); - /// - virtual Inset & inset() const { return inset_; } /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetNewlineParams &); - /// - static std::string const params2string(InsetNewlineParams const &); -private: - /// - static std::string const name_; - /// - InsetNewline & inset_; + InsetNewlineParams params_; }; diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index 41bbdea117..e7b9b0523a 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -38,10 +38,10 @@ InsetNewpage::InsetNewpage() {} -InsetNewpage::InsetNewpage(InsetNewpageParams par) -{ - params_.kind = par.kind; -} +InsetNewpage::InsetNewpage(InsetNewpageParams const & params) + : params_(params) +{} + void InsetNewpageParams::write(ostream & os) const { @@ -146,7 +146,7 @@ void InsetNewpage::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetNewpageParams params; - InsetNewpageMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); params_.kind = params.kind; break; } @@ -166,10 +166,11 @@ bool InsetNewpage::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "newpage") { InsetNewpageParams params; - InsetNewpageMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); status.setOnOff(params_.kind == params.kind); - } else + } else { status.enabled(true); + } return true; default: return Inset::getStatus(cur, cmd, status); @@ -264,21 +265,7 @@ docstring InsetNewpage::contextMenu(BufferView const &, int, int) const } -string const InsetNewpageMailer::name_ = "newpage"; - - -InsetNewpageMailer::InsetNewpageMailer(InsetNewpage & inset) - : inset_(inset) -{} - - -string const InsetNewpageMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetNewpageMailer::string2params(string const & in, InsetNewpageParams & params) +void InsetNewpage::string2params(string const & in, InsetNewpageParams & params) { params = InsetNewpageParams(); if (in.empty()) @@ -290,17 +277,19 @@ void InsetNewpageMailer::string2params(string const & in, InsetNewpageParams & p string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetNewpageMailer", in, 1, name_); + if (!lex || name != "newpage") { + LYXERR0("Expected arg 2 to be \"wrap\" in " << in); + return; + } params.read(lex); } -string const InsetNewpageMailer::params2string(InsetNewpageParams const & params) +string InsetNewpage::params2string(InsetNewpageParams const & params) { ostringstream data; - data << name_ << ' '; + data << "newpage" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetNewpage.h b/src/insets/InsetNewpage.h index 96479bbef6..8ee2385411 100644 --- a/src/insets/InsetNewpage.h +++ b/src/insets/InsetNewpage.h @@ -13,15 +13,12 @@ #define INSET_NEWPAGE_H #include "Inset.h" -#include "MailInset.h" - -#include "support/docstring.h" -#include "support/gettext.h" namespace lyx { -class InsetNewpageParams { +class InsetNewpageParams +{ public: /// The different kinds of spaces we support enum Kind { @@ -50,10 +47,13 @@ class InsetNewpage : public Inset public: /// InsetNewpage(); - /// - explicit - InsetNewpage(InsetNewpageParams par); + explicit InsetNewpage(InsetNewpageParams const & par); + /// + static void string2params(std::string const &, InsetNewpageParams &); + /// + static std::string params2string(InsetNewpageParams const &); +private: /// InsetNewpageParams params() const { return params_; } /// @@ -79,38 +79,16 @@ public: /// ColorCode ColorName() const; /// - virtual docstring contextMenu(BufferView const & bv, int x, int y) const; -private: + docstring contextMenu(BufferView const & bv, int x, int y) const; /// Inset * clone() const { return new InsetNewpage(*this); } /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; - /// - InsetNewpageParams params_; -}; - -class InsetNewpageMailer : public MailInset { -public: - /// - InsetNewpageMailer(InsetNewpage & inset); - /// - virtual Inset & inset() const { return inset_; } /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetNewpageParams &); - /// - static std::string const params2string(InsetNewpageParams const &); -private: - /// - static std::string const name_; - /// - InsetNewpage & inset_; + InsetNewpageParams params_; }; } // namespace lyx diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 624ff4ca2a..85aa740bc1 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -37,6 +37,8 @@ #include "support/docstream.h" #include "support/Translator.h" +#include "frontends/Application.h" + #include #include @@ -121,7 +123,7 @@ InsetNote::InsetNote(Buffer const & buf, string const & label) InsetNote::~InsetNote() { - InsetNoteMailer(*this).hideDialog(); + hideDialogs("note", this); } @@ -166,7 +168,8 @@ void InsetNote::setButtonLabel() bool InsetNote::showInsetDialog(BufferView * bv) const { - InsetNoteMailer(const_cast(*this)).showDialog(bv); + bv->showDialog("note", params2string(params()), + const_cast(this)); return true; } @@ -176,14 +179,15 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_INSET_MODIFY: - InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_); + string2params(to_utf8(cmd.argument()), params_); // get a bp from cur: setLayout(cur.buffer().params()); break; case LFUN_INSET_DIALOG_UPDATE: - InsetNoteMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("note", params2string(params())); break; + default: InsetCollapsable::doDispatch(cur, cmd); break; @@ -202,7 +206,7 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd, cmd.getArg(2) == "Note"); if (cmd.getArg(0) == "note") { InsetNoteParams params; - InsetNoteMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); flag.setOnOff(params_.type == params.type); } return true; @@ -347,30 +351,16 @@ docstring InsetNote::contextMenu(BufferView const &, int, int) const } -string const InsetNoteMailer::name_("note"); - -InsetNoteMailer::InsetNoteMailer(InsetNote & inset) - : inset_(inset) -{} - - -string const InsetNoteMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -string const InsetNoteMailer::params2string(InsetNoteParams const & params) +string InsetNote::params2string(InsetNoteParams const & params) { ostringstream data; - data << name_ << ' '; + data << "note" << ' '; params.write(data); return data.str(); } -void InsetNoteMailer::string2params(string const & in, - InsetNoteParams & params) +void InsetNote::string2params(string const & in, InsetNoteParams & params) { params = InsetNoteParams(); @@ -383,15 +373,19 @@ void InsetNoteMailer::string2params(string const & in, string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetNoteMailer", in, 1, name_); + if (!lex || name != "note") { + LYXERR0("Expected arg 1 to be \"note\" in " << in); + return; + } // This is part of the inset proper that is usually swallowed // by Text::readInset string id; lex >> id; - if (!lex || id != "Note") - return print_mailer_error("InsetNoteMailer", in, 2, "Note"); + if (!lex || id != "Note") { + LYXERR0("Expected arg 1 to be \"Note\" in " << in); + return; + } params.read(lex); } diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 7e509a4710..15b416a1f8 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -9,16 +9,16 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETNOTE_H -#define INSETNOTE_H +#ifndef INSET_NOTE_H +#define INSET_NOTE_H #include "InsetCollapsable.h" -#include "MailInset.h" namespace lyx { -class InsetNoteParams { +class InsetNoteParams +{ public: enum Type { Note, @@ -36,16 +36,25 @@ public: }; -/** The PostIt note inset, and other annotations +///////////////////////////////////////////////////////////////////////// +// +// InsetNote +// +///////////////////////////////////////////////////////////////////////// -*/ -class InsetNote : public InsetCollapsable { +/// The PostIt note inset, and other annotations +class InsetNote : public InsetCollapsable +{ public: /// InsetNote(Buffer const &, std::string const &); /// ~InsetNote(); /// + static std::string params2string(InsetNoteParams const &); + /// + static void string2params(std::string const &, InsetNoteParams &); + /// InsetNoteParams const & params() const { return params_; } private: /// @@ -55,7 +64,7 @@ private: /// docstring name() const; /// - virtual DisplayType display() const; + DisplayType display() const; /// bool noFontChange() const { return params_.type != InsetNoteParams::Note; } /// @@ -89,7 +98,7 @@ 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; /// friend class InsetNoteParams; @@ -98,29 +107,6 @@ private: }; -class InsetNoteMailer : public MailInset { -public: - /// - InsetNoteMailer(InsetNote & 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(InsetNoteParams const &); - /// - static void string2params(std::string const &, InsetNoteParams &); - -private: - /// - static std::string const name_; - /// - InsetNote & inset_; -}; - - } // namespace lyx -#endif +#endif // INSET_NOTE_H diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 603998f674..d184ab6397 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -15,6 +15,7 @@ #include "InsetSpace.h" +#include "BufferView.h" #include "Cursor.h" #include "Dimension.h" #include "FuncRequest.h" @@ -24,30 +25,25 @@ #include "MetricsInfo.h" #include "OutputParams.h" -#include "frontends/FontMetrics.h" -#include "frontends/Painter.h" - #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" #include "support/lstrings.h" +#include "frontends/Application.h" +#include "frontends/FontMetrics.h" +#include "frontends/Painter.h" + using namespace std; namespace lyx { -InsetSpace::InsetSpace() +InsetSpace::InsetSpace(InsetSpaceParams const & params) + : params_(params) {} -InsetSpace::InsetSpace(InsetSpaceParams par) -{ - params_.kind = par.kind; - params_.length = par.length; -} - - InsetSpaceParams::Kind InsetSpace::kind() const { return params_.kind; @@ -62,7 +58,7 @@ Length InsetSpace::length() const InsetSpace::~InsetSpace() { - InsetSpaceMailer(*this).hideDialog(); + hideDialogs("space", this); } @@ -125,7 +121,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetSpaceParams params; - InsetSpaceMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); params_.kind = params.kind; params_.length = params.length; break; @@ -133,7 +129,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_MOUSE_RELEASE: if (!cur.selection() && cmd.button() == mouse_button::button1) - InsetSpaceMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("wrap", params2string(params()), this); break; default: @@ -151,7 +147,7 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "space") { InsetSpaceParams params; - InsetSpaceMailer::string2params(to_utf8(cmd.argument()), params); + string2params(to_utf8(cmd.argument()), params); status.setOnOff(params_.kind == params.kind); } else status.enabled(true); @@ -164,7 +160,7 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetSpace::edit(Cursor & cur, bool, EntryDirection) { - InsetSpaceMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("wrap", params2string(params()), this); } @@ -529,21 +525,7 @@ docstring InsetSpace::contextMenu(BufferView const &, int, int) const } -string const InsetSpaceMailer::name_ = "space"; - - -InsetSpaceMailer::InsetSpaceMailer(InsetSpace & inset) - : inset_(inset) -{} - - -string const InsetSpaceMailer::inset2string(Buffer const &) const -{ - return params2string(inset_.params()); -} - - -void InsetSpaceMailer::string2params(string const & in, InsetSpaceParams & params) +void InsetSpace::string2params(string const & in, InsetSpaceParams & params) { params = InsetSpaceParams(); if (in.empty()) @@ -555,17 +537,19 @@ void InsetSpaceMailer::string2params(string const & in, InsetSpaceParams & param string name; lex >> name; - if (!lex || name != name_) - return print_mailer_error("InsetSpaceMailer", in, 1, name_); + if (!lex || name != "space") { + LYXERR0("Expected arg 1 to be \"space\" in " << in); + return; + } params.read(lex); } -string const InsetSpaceMailer::params2string(InsetSpaceParams const & params) +string InsetSpace::params2string(InsetSpaceParams const & params) { ostringstream data; - data << name_ << ' '; + data << "space" << ' '; params.write(data); return data.str(); } diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index 7af58d38e1..c88ba4680b 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -15,10 +15,8 @@ #ifndef INSET_SPACE_H #define INSET_SPACE_H - #include "Inset.h" #include "Length.h" -#include "MailInset.h" namespace lyx { @@ -70,23 +68,30 @@ public: Length length; }; + /// Used to insert different kinds of spaces -class InsetSpace : public Inset { +class InsetSpace : public Inset +{ public: /// - InsetSpace(); - /// - ~InsetSpace(); - + InsetSpace() {} /// - explicit - InsetSpace(InsetSpaceParams par); + explicit InsetSpace(InsetSpaceParams const & par); /// InsetSpaceParams params() const { return params_; } /// InsetSpaceParams::Kind kind() const; /// + ~InsetSpace(); + + /// + static void string2params(std::string const &, InsetSpaceParams &); + /// + static std::string params2string(InsetSpaceParams const &); + /// Length length() const; + +private: /// docstring toolTip(BufferView const & bv, int x, int y) const; /// @@ -123,9 +128,9 @@ public: // a line separator)? bool isSpace() const { return true; } /// - virtual docstring contextMenu(BufferView const & bv, int x, int y) const; -private: - virtual Inset * clone() const { return new InsetSpace(*this); } + docstring contextMenu(BufferView const & bv, int x, int y) const; + /// + Inset * clone() const { return new InsetSpace(*this); } /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// @@ -136,28 +141,6 @@ private: }; -class InsetSpaceMailer : public MailInset { -public: - /// - InsetSpaceMailer(InsetSpace & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetSpaceParams &); - /// - static std::string const params2string(InsetSpaceParams const &); -private: - /// - static std::string const name_; - /// - InsetSpace & inset_; -}; - - } // namespace lyx #endif // INSET_SPACE_H diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 5800432351..dce654ac3e 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -44,12 +44,12 @@ #include "TextClass.h" #include "TextMetrics.h" +#include "frontends/Application.h" #include "frontends/alert.h" #include "frontends/Clipboard.h" #include "frontends/Painter.h" #include "frontends/Selection.h" - #include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" @@ -70,6 +70,7 @@ using namespace lyx::support; using boost::shared_ptr; using boost::dynamic_pointer_cast; + namespace lyx { using cap::dirtyTabularStack; @@ -2768,7 +2769,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab) InsetTabular::~InsetTabular() { - InsetTabularMailer(*this).hideDialog(); + hideDialogs("tabular", this); } @@ -3325,11 +3326,11 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd) // } case LFUN_LAYOUT_TABULAR: - InsetTabularMailer(*this).showDialog(&cur.bv()); + cur.bv().showDialog("tabular", params2string(*this), this); break; case LFUN_INSET_DIALOG_UPDATE: - InsetTabularMailer(*this).updateDialog(&cur.bv()); + cur.bv().updateDialog("tabular", params2string(*this)); break; case LFUN_TABULAR_FEATURE: @@ -4433,14 +4434,16 @@ void InsetTabular::tabularFeatures(Cursor & cur, bool InsetTabular::showInsetDialog(BufferView * bv) const { - InsetTabularMailer(*this).showDialog(bv); + bv->showDialog("tabular", params2string(*this), + const_cast(this)); return true; } void InsetTabular::openLayoutDialog(BufferView * bv) const { - InsetTabularMailer(*this).showDialog(bv); + bv->showDialog("tabular", params2string(*this), + const_cast(this)); } @@ -4810,20 +4813,7 @@ void InsetTabular::completionPosAndDim(Cursor const & cur, int & x, int & y, } -string const InsetTabularMailer::name_("tabular"); - -InsetTabularMailer::InsetTabularMailer(InsetTabular const & inset) - : inset_(const_cast(inset)) -{} - - -string const InsetTabularMailer::inset2string(Buffer const &) const -{ - return params2string(inset_); -} - - -void InsetTabularMailer::string2params(string const & in, InsetTabular & inset) +void InsetTabular::string2params(string const & in, InsetTabular & inset) { istringstream data(in); Lexer lex(0,0); @@ -4834,24 +4824,27 @@ void InsetTabularMailer::string2params(string const & in, InsetTabular & inset) string token; lex >> token; - if (!lex || token != name_) - return print_mailer_error("InsetTabularMailer", in, 1, - name_); + if (!lex || token != "tabular") { + LYXERR0("Expected arg 1 to be \"tabular\" in " << in); + return; + } // This is part of the inset proper that is usually swallowed // by Buffer::readInset lex >> token; - if (!lex || token != "Tabular") - return print_mailer_error("InsetTabularMailer", in, 2, "Tabular"); + if (!lex || token != "Tabular") { + LYXERR0("Expected arg 2 to be \"Tabular\" in " << in); + return; + } inset.read(lex); } -string const InsetTabularMailer::params2string(InsetTabular const & inset) +string InsetTabular::params2string(InsetTabular const & inset) { ostringstream data; - data << name_ << ' '; + data << "tabular" << ' '; inset.write(data); data << "\\end_inset\n"; return data.str(); diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 493c03eeb1..390fc2ab07 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -32,14 +32,13 @@ // Lgb -#ifndef INSETTABULAR_H -#define INSETTABULAR_H +#ifndef INSET_TABULAR_H +#define INSET_TABULAR_H #include "Inset.h" #include "InsetText.h" #include "Layout.h" #include "Length.h" -#include "MailInset.h" #include @@ -652,13 +651,14 @@ private: /// -class InsetTableCell : public InsetText { +class InsetTableCell : public InsetText +{ public: /// - explicit InsetTableCell(Buffer const & buf, + InsetTableCell(Buffer const & buf, Tabular::CellData const * cd, Tabular const * t); /// - virtual InsetCode lyxCode() const { return CELL_CODE; } + InsetCode lyxCode() const { return CELL_CODE; } /// Inset * clone() { return new InsetTableCell(*this); } /// @@ -677,18 +677,20 @@ public: /// void setTabular(Tabular const * t) { table_ = t; } private: - /// - Tabular::CellData const * cell_data_; - /// - Tabular const * table_; /// unimplemented InsetTableCell(); /// unimplemented void operator=(InsetTableCell const &); + + /// + Tabular::CellData const * cell_data_; + /// + Tabular const * table_; }; -class InsetTabular : public Inset { +class InsetTabular : public Inset +{ public: /// InsetTabular(Buffer const &, row_type rows = 1, @@ -696,6 +698,10 @@ public: /// ~InsetTabular(); /// + static void string2params(std::string const &, InsetTabular &); + /// + static std::string params2string(InsetTabular const &); + /// void read(Lexer &); /// void write(std::ostream &) const; @@ -870,30 +876,8 @@ private: bool colselect_; }; - -class InsetTabularMailer : public MailInset { -public: - /// - InsetTabularMailer(InsetTabular const & inset); - /// - virtual Inset & inset() const { return inset_; } - /// - virtual std::string const & name() const { return name_; } - /// - virtual std::string const inset2string(Buffer const &) const; - /// - static void string2params(std::string const &, InsetTabular &); - /// - static std::string const params2string(InsetTabular const &); -private: - /// - static std::string const name_; - /// - InsetTabular & inset_; -}; - std::string const featureAsString(Tabular::Feature feature); } // namespace lyx -#endif +#endif // INSET_TABULAR_H diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index f6cdc4641f..df7596080e 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -273,8 +273,7 @@ void InsetWrap::string2params(string const & in, InsetWrapParams & params) string name; lex >> name; if (!lex || name != "wrap") { - LYXERR0("InsetWrap::string2params(" << in << ")\n" - "Expected arg 1 to be \"wrap\"\n"); + LYXERR0("Expected arg 1 to be \"wrap\" in " << in); return; } @@ -283,8 +282,7 @@ void InsetWrap::string2params(string const & in, InsetWrapParams & params) string id; lex >> id; if (!lex || id != "Wrap") { - LYXERR0("InsetWrap::string2params(" << in << ")\n" - "Expected arg 2 to be \"Wrap\"\n"); + LYXERR0("Expected arg 2 to be \"Wrap\" in " << in); return; } diff --git a/src/insets/MailInset.cpp b/src/insets/MailInset.cpp deleted file mode 100644 index c59949a3ba..0000000000 --- a/src/insets/MailInset.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file MailInset.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "MailInset.h" - -#include "BufferView.h" - -#include "frontends/Application.h" - -#include "support/debug.h" - -#include - -using namespace std; - -namespace lyx { - - -void MailInset::showDialog(BufferView * bv) const -{ - BOOST_ASSERT(bv); - bv->showDialog(name(), inset2string(bv->buffer()), &inset()); -} - - -void MailInset::updateDialog(BufferView * bv) const -{ - BOOST_ASSERT(bv); - bv->updateDialog(name(), inset2string(bv->buffer())); -} - - -void MailInset::hideDialog() const -{ - if (theApp()) - theApp()->hideDialogs(name(), &inset()); -} - - -void print_mailer_error(string const & class_name, - string const & data, int arg_id, string const & arg) -{ - LYXERR0('\n' << class_name << "::string2params(" << data << ")\n" - << "Expected arg " << arg_id << " to be \"" << arg << "\"\n"); -} - - -} // namespace lyx diff --git a/src/insets/MailInset.h b/src/insets/MailInset.h deleted file mode 100644 index 9fca43e8c4..0000000000 --- a/src/insets/MailInset.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- -/** - * \file MailInset.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Angus Leeming - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MAILINSET_H -#define MAILINSET_H - -#include - - -namespace lyx { - - -class Inset; -class Buffer; -class BufferView; - - -class MailInset { -public: - /// - virtual ~MailInset() {}; - /// - void showDialog(BufferView *) const; - /// - void updateDialog(BufferView *) const; - /// - void hideDialog() const; - /// - virtual std::string const inset2string(Buffer const &) const = 0; - -protected: - /// - virtual Inset & inset() const = 0; - /// - virtual std::string const & name() const = 0; -}; - -void print_mailer_error(std::string const & class_name, - std::string const & data, - int arg_id, std::string const & arg); - - - -} // namespace lyx - -#endif // MAILINSET_H diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 366dd01a0d..8b92ddc96f 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1173,7 +1173,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) InsetCommandParams p(LABEL_CODE); p["name"] = cmd.argument().empty() ? old_label : cmd.argument(); - string const data = InsetCommandMailer::params2string("label", p); + string const data = InsetCommand::params2string("label", p); if (cmd.argument().empty()) cur.bv().showDialog("label", data); @@ -1210,7 +1210,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) string const name = cmd.getArg(0); if (name == "label") { InsetCommandParams p(LABEL_CODE); - InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), p); + InsetCommand::string2params(name, to_utf8(cmd.argument()), p); docstring str = p["name"]; cur.recordUndoInset(); row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row(); diff --git a/src/mathed/InsetMathRef.cpp b/src/mathed/InsetMathRef.cpp index f6ca612983..998653b38b 100644 --- a/src/mathed/InsetMathRef.cpp +++ b/src/mathed/InsetMathRef.cpp @@ -177,7 +177,7 @@ string const InsetMathRef::createDialogStr(string const & name) const icp["reference"] = asString(cell(0)); if (!cell(1).empty()) icp["name"] = asString(cell(1)); - return InsetCommandMailer::params2string(name, icp); + return InsetCommand::params2string(name, icp); } diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index fbd9ffabe3..2c67b32dc7 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -414,7 +414,7 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar) InsetCommandParams icp(REF_CODE); // FIXME UNICODE - InsetCommandMailer::string2params("ref", to_utf8(str), icp); + InsetCommand::string2params("ref", to_utf8(str), icp); mathed_parse_cell(ar, icp.getCommand()); if (ar.size() != 1) return false; -- 2.39.5