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