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: {
InsetWrapParams p;
data = InsetWrapMailer::params2string(p);
data = InsetWrap::params2string(p);
break;
}
default:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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