remove InsetWrapMailer class

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23991 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-27 00:07:54 +00:00
parent ba348ede83
commit 209b04eaa9
7 changed files with 45 additions and 53 deletions

View File

@ -1248,7 +1248,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
} }
case WRAP_CODE: { case WRAP_CODE: {
InsetWrapParams p; InsetWrapParams p;
data = InsetWrapMailer::params2string(p); data = InsetWrap::params2string(p);
break; break;
} }
default: default:

View File

@ -245,6 +245,7 @@ public:
frontend::Application * theApp(); frontend::Application * theApp();
frontend::Application * createApplication(int & argc, char * argv[]); frontend::Application * createApplication(int & argc, char * argv[]);
void hideDialogs(std::string const & name, Inset * inset);
} // namespace lyx } // namespace lyx

View File

@ -756,8 +756,11 @@ void GuiApplication::onLastWindowClosed()
global_menubar_->grabKeyboard(); global_menubar_->grabKeyboard();
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
//
// X11 specific stuff goes here... // X11 specific stuff goes here...
#ifdef Q_WS_X11 #ifdef Q_WS_X11
bool GuiApplication::x11EventFilter(XEvent * xev) bool GuiApplication::x11EventFilter(XEvent * xev)
{ {
@ -794,6 +797,13 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
} // namespace frontend } // namespace frontend
void hideDialogs(std::string const & name, Inset * inset)
{
if (theApp())
theApp()->hideDialogs(name, inset);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// Font stuff // Font stuff
@ -820,6 +830,12 @@ frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
} }
////////////////////////////////////////////////////////////////////
//
// Misc stuff
//
////////////////////////////////////////////////////////////////////
frontend::Clipboard & theClipboard() frontend::Clipboard & theClipboard()
{ {
BOOST_ASSERT(frontend::guiApp); BOOST_ASSERT(frontend::guiApp);

View File

@ -189,7 +189,7 @@ void GuiWrap::updateContents()
bool GuiWrap::initialiseParams(string const & data) bool GuiWrap::initialiseParams(string const & data)
{ {
InsetWrapMailer::string2params(data, params_); InsetWrap::string2params(data, params_);
return true; return true;
} }
@ -202,7 +202,7 @@ void GuiWrap::clearParams()
void GuiWrap::dispatchParams() void GuiWrap::dispatchParams()
{ {
string const lfun = InsetWrapMailer::params2string(params_); string const lfun = InsetWrap::params2string(params_);
dispatch(FuncRequest(getLfun(), lfun)); dispatch(FuncRequest(getLfun(), lfun));
} }

View File

@ -50,8 +50,7 @@ InsetERT::InsetERT(Buffer const & buf, CollapseStatus status)
InsetERT::~InsetERT() InsetERT::~InsetERT()
{ {
if (theApp()) hideDialogs("ert", this);
theApp()->hideDialogs("ert", this);
} }

View File

@ -34,6 +34,8 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "frontends/Application.h"
using namespace std; using namespace std;
namespace lyx { namespace lyx {
@ -53,7 +55,7 @@ InsetWrap::InsetWrap(Buffer const & buf, string const & type)
InsetWrap::~InsetWrap() InsetWrap::~InsetWrap()
{ {
InsetWrapMailer(*this).hideDialog(); hideDialogs("ert", this);
} }
@ -62,7 +64,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd)
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {
InsetWrapParams params; InsetWrapParams params;
InsetWrapMailer::string2params(to_utf8(cmd.argument()), params); InsetWrap::string2params(to_utf8(cmd.argument()), params);
params_.lines = params.lines; params_.lines = params.lines;
params_.placement = params.placement; params_.placement = params.placement;
params_.overhang = params.overhang; params_.overhang = params.overhang;
@ -71,7 +73,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd)
} }
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:
InsetWrapMailer(*this).updateDialog(&cur.bv()); cur.bv().updateDialog("wrap", params2string(params()));
break; break;
default: default:
@ -252,25 +254,13 @@ bool InsetWrap::insetAllowed(InsetCode code) const
bool InsetWrap::showInsetDialog(BufferView * bv) const bool InsetWrap::showInsetDialog(BufferView * bv) const
{ {
if (!InsetText::showInsetDialog(bv)) if (!InsetText::showInsetDialog(bv))
InsetWrapMailer(const_cast<InsetWrap &>(*this)).showDialog(bv); bv->showDialog("wrap", params2string(params()),
const_cast<InsetWrap *>(this));
return true; return true;
} }
string const InsetWrapMailer::name_("wrap"); void InsetWrap::string2params(string const & in, InsetWrapParams & params)
InsetWrapMailer::InsetWrapMailer(InsetWrap & inset)
: inset_(inset)
{}
string const InsetWrapMailer::inset2string(Buffer const &) const
{
return params2string(inset_.params());
}
void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params)
{ {
params = InsetWrapParams(); params = InsetWrapParams();
if (in.empty()) if (in.empty())
@ -282,15 +272,21 @@ void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params)
string name; string name;
lex >> name; lex >> name;
if (!lex || name != name_) if (!lex || name != "wrap") {
return print_mailer_error("InsetWrapMailer", in, 1, name_); LYXERR0("InsetWrap::string2params(" << in << ")\n"
"Expected arg 1 to be \"wrap\"\n");
return;
}
// This is part of the inset proper that is usually swallowed // This is part of the inset proper that is usually swallowed
// by Text::readInset // by Text::readInset
string id; string id;
lex >> id; lex >> id;
if (!lex || id != "Wrap") if (!lex || id != "Wrap") {
return print_mailer_error("InsetBoxMailer", in, 2, "Wrap"); LYXERR0("InsetWrap::string2params(" << in << ")\n"
"Expected arg 1 to be \"Wrap\"\n");
return;
}
// We have to read the type here! // We have to read the type here!
lex >> params.type; lex >> params.type;
@ -298,10 +294,10 @@ void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params)
} }
string const InsetWrapMailer::params2string(InsetWrapParams const & params) string InsetWrap::params2string(InsetWrapParams const & params)
{ {
ostringstream data; ostringstream data;
data << name_ << ' '; data << "wrap" << ' ';
params.write(data); params.write(data);
return data.str(); return data.str();
} }

View File

@ -14,7 +14,6 @@
#include "InsetCollapsable.h" #include "InsetCollapsable.h"
#include "Length.h" #include "Length.h"
#include "MailInset.h"
namespace lyx { namespace lyx {
@ -50,6 +49,10 @@ public:
~InsetWrap(); ~InsetWrap();
/// ///
InsetWrapParams const & params() const { return params_; } InsetWrapParams const & params() const { return params_; }
///
static void string2params(std::string const &, InsetWrapParams &);
///
static std::string params2string(InsetWrapParams const &);
private: private:
/// ///
void write(std::ostream & os) const; void write(std::ostream & os) const;
@ -88,29 +91,6 @@ private:
docstring name_; docstring name_;
}; };
class InsetWrapMailer : public MailInset {
public:
///
InsetWrapMailer(InsetWrap & 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 &, InsetWrapParams &);
///
static std::string const params2string(InsetWrapParams const &);
private:
///
static std::string const name_;
///
InsetWrap & inset_;
};
} // namespace lyx } // namespace lyx
#endif #endif