mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
Get rid of the InsetInclude::Params::flag variable.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7792 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
482c265462
commit
91d100b25f
@ -1,3 +1,8 @@
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* QInclude.C (apply): No need to set InsetInclude::Params::flag;
|
||||
the variable has been removed. Instead, set the command name directly.
|
||||
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* QLPainter.C:
|
||||
|
@ -56,24 +56,28 @@ void QInclude::update_contents()
|
||||
dialog_->previewCB->setChecked(false);
|
||||
dialog_->previewCB->setEnabled(false);
|
||||
|
||||
switch (params.flag) {
|
||||
case InsetInclude::INPUT:
|
||||
dialog_->typeCO->setCurrentItem(0);
|
||||
dialog_->previewCB->setEnabled(true);
|
||||
dialog_->previewCB->setChecked(params.cparams.preview());
|
||||
break;
|
||||
string cmdname = controller().params().cparams.getCmdName();
|
||||
if (cmdname != "include" &&
|
||||
cmdname != "verbatiminput" &&
|
||||
cmdname != "verbatiminput*")
|
||||
cmdname = "input";
|
||||
|
||||
case InsetInclude::INCLUDE:
|
||||
dialog_->typeCO->setCurrentItem(1);
|
||||
break;
|
||||
if (cmdname == "input") {
|
||||
dialog_->typeCO->setCurrentItem(0);
|
||||
dialog_->previewCB->setEnabled(true);
|
||||
dialog_->previewCB->setChecked(params.cparams.preview());
|
||||
|
||||
} else if (cmdname == "include") {
|
||||
dialog_->typeCO->setCurrentItem(1);
|
||||
|
||||
case InsetInclude::VERBAST:
|
||||
dialog_->visiblespaceCB->setChecked(true);
|
||||
/* fall through */
|
||||
case InsetInclude::VERB:
|
||||
dialog_->typeCO->setCurrentItem(2);
|
||||
dialog_->visiblespaceCB->setEnabled(true);
|
||||
break;
|
||||
} else if (cmdname == "verbatiminput*") {
|
||||
dialog_->typeCO->setCurrentItem(2);
|
||||
dialog_->visiblespaceCB->setEnabled(true);
|
||||
dialog_->visiblespaceCB->setChecked(true);
|
||||
|
||||
} else if (cmdname == "verbatiminput") {
|
||||
dialog_->typeCO->setCurrentItem(2);
|
||||
dialog_->visiblespaceCB->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,14 +91,14 @@ void QInclude::apply()
|
||||
|
||||
int const item = dialog_->typeCO->currentItem();
|
||||
if (item == 0)
|
||||
params.flag = InsetInclude::INPUT;
|
||||
params.cparams.setCmdName("input");
|
||||
else if (item == 1)
|
||||
params.flag = InsetInclude::INCLUDE;
|
||||
params.cparams.setCmdName("include");
|
||||
else {
|
||||
if (dialog_->visiblespaceCB->isChecked())
|
||||
params.flag = InsetInclude::VERBAST;
|
||||
params.cparams.setCmdName("verbatiminput*");
|
||||
else
|
||||
params.flag = InsetInclude::VERB;
|
||||
params.cparams.setCmdName("verbatiminput");
|
||||
}
|
||||
controller().setParams(params);
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* FormInclude.C (apply): No need to set InsetInclude::Params::flag;
|
||||
the variable has been removed. Instead, set the command name directly.
|
||||
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Color.C:
|
||||
|
@ -117,23 +117,18 @@ void FormInclude::apply()
|
||||
InsetInclude::Params params = controller().params();
|
||||
|
||||
params.cparams.preview(fl_get_button(dialog_->check_preview));
|
||||
|
||||
string const file = fl_get_input(dialog_->input_filename);
|
||||
if (controller().fileExists(file))
|
||||
params.cparams.setContents(file);
|
||||
else
|
||||
params.cparams.setContents("");
|
||||
params.cparams.setContents(getString(dialog_->input_filename));
|
||||
|
||||
ControlInclude::Type const type = ControlInclude::Type(type_.get());
|
||||
if (type == ControlInclude::INPUT)
|
||||
params.flag = InsetInclude::INPUT;
|
||||
params.cparams.setCmdName("input");
|
||||
else if (type == ControlInclude::INCLUDE)
|
||||
params.flag = InsetInclude::INCLUDE;
|
||||
params.cparams.setCmdName("include");
|
||||
else if (type == ControlInclude::VERBATIM) {
|
||||
if (fl_get_button(dialog_->check_visiblespace))
|
||||
params.flag = InsetInclude::VERBAST;
|
||||
params.cparams.setCmdName("verbatiminput*");
|
||||
else
|
||||
params.flag = InsetInclude::VERB;
|
||||
params.cparams.setCmdName("verbatiminput");
|
||||
}
|
||||
|
||||
controller().setParams(params);
|
||||
@ -145,7 +140,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
|
||||
ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
|
||||
|
||||
if (ob == dialog_->button_browse) {
|
||||
string const in_name = fl_get_input(dialog_->input_filename);
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
fl_freeze_form(form());
|
||||
ControlInclude::Type const type = ControlInclude::Type(type_.get());
|
||||
string const out_name = controller().Browse(in_name, type);
|
||||
@ -153,7 +148,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
|
||||
fl_unfreeze_form(form());
|
||||
|
||||
} else if (ob == dialog_->button_load) {
|
||||
string const in_name = fl_get_input(dialog_->input_filename);
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
|
||||
dialog().OKButton();
|
||||
controller().load(rtrim(in_name));
|
||||
@ -171,7 +166,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
|
||||
setEnabled(dialog_->button_load, true);
|
||||
|
||||
} else if (ob == dialog_->input_filename) {
|
||||
string const in_name = fl_get_input(dialog_->input_filename);
|
||||
string const in_name = getString(dialog_->input_filename);
|
||||
if (rtrim(in_name).empty())
|
||||
action = ButtonPolicy::SMI_INVALID;
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetinclude.[Ch]: remove Params::operator==, operator!= as they're
|
||||
redundant baggage from yesteryear.
|
||||
Remove Params::flag as it is redundant; the info is present in
|
||||
getCmdName.
|
||||
|
||||
2003-09-18 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetinclude.C (latexString): add a Buffer const & arg.
|
||||
|
@ -177,46 +177,50 @@ InsetInclude::Params const & InsetInclude::params() const
|
||||
}
|
||||
|
||||
|
||||
bool InsetInclude::Params::operator==(Params const & o) const
|
||||
{
|
||||
return cparams == o.cparams && flag == o.flag &&
|
||||
masterFilename_ == o.masterFilename_;
|
||||
}
|
||||
namespace {
|
||||
|
||||
/// the type of inclusion
|
||||
enum Types {
|
||||
INCLUDE = 0,
|
||||
VERB = 1,
|
||||
INPUT = 2,
|
||||
VERBAST = 3
|
||||
};
|
||||
|
||||
|
||||
bool InsetInclude::Params::operator!=(Params const & o) const
|
||||
Types type(InsetInclude::Params const & params)
|
||||
{
|
||||
return !(*this == o);
|
||||
string const command_name = params.cparams.getCmdName();
|
||||
|
||||
if (command_name == "input")
|
||||
return INPUT;
|
||||
if (command_name == "verbatiminput")
|
||||
return VERB;
|
||||
if (command_name == "verbatiminput*")
|
||||
return VERBAST;
|
||||
return INCLUDE;
|
||||
}
|
||||
|
||||
|
||||
bool isVerbatim(InsetInclude::Params const & params)
|
||||
{
|
||||
string const command_name = params.cparams.getCmdName();
|
||||
return command_name == "verbatiminput" ||
|
||||
command_name == "verbatiminput*";
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
void InsetInclude::set(Params const & p)
|
||||
{
|
||||
params_ = p;
|
||||
|
||||
string command;
|
||||
|
||||
switch (params_.flag) {
|
||||
case INCLUDE:
|
||||
command="include";
|
||||
break;
|
||||
case VERB:
|
||||
command="verbatiminput";
|
||||
break;
|
||||
case INPUT:
|
||||
command="input";
|
||||
break;
|
||||
case VERBAST:
|
||||
command="verbatiminput*";
|
||||
break;
|
||||
}
|
||||
|
||||
params_.cparams.setCmdName(command);
|
||||
|
||||
if (preview_->monitoring())
|
||||
preview_->stopMonitoring();
|
||||
|
||||
if (lyx::graphics::PreviewedInset::activated() && params_.flag == INPUT)
|
||||
if (lyx::graphics::PreviewedInset::activated() &&
|
||||
type(params_) == INPUT)
|
||||
preview_->generatePreview();
|
||||
}
|
||||
|
||||
@ -253,17 +257,6 @@ void InsetInclude::read(Buffer const &, LyXLex & lex)
|
||||
void InsetInclude::read(LyXLex & lex)
|
||||
{
|
||||
params_.cparams.read(lex);
|
||||
|
||||
if (params_.cparams.getCmdName() == "include")
|
||||
params_.flag = INCLUDE;
|
||||
else if (params_.cparams.getCmdName() == "input")
|
||||
params_.flag = INPUT;
|
||||
/* FIXME: is this logic necessary now ? */
|
||||
else if (contains(params_.cparams.getCmdName(), "verbatim")) {
|
||||
params_.flag = VERB;
|
||||
if (params_.cparams.getCmdName() == "verbatiminput*")
|
||||
params_.flag = VERBAST;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -271,7 +264,7 @@ string const InsetInclude::getScreenLabel(Buffer const &) const
|
||||
{
|
||||
string temp;
|
||||
|
||||
switch (params_.flag) {
|
||||
switch (type(params_)) {
|
||||
case INPUT: temp += _("Input"); break;
|
||||
case VERB: temp += _("Verbatim Input"); break;
|
||||
case VERBAST: temp += _("Verbatim Input*"); break;
|
||||
@ -304,7 +297,7 @@ string const InsetInclude::getMasterFilename() const
|
||||
|
||||
bool InsetInclude::loadIfNeeded() const
|
||||
{
|
||||
if (isVerbatim())
|
||||
if (isVerbatim(params_))
|
||||
return false;
|
||||
|
||||
if (!IsLyXFilename(getFileName()))
|
||||
@ -367,9 +360,9 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
|
||||
runparams, false);
|
||||
}
|
||||
|
||||
if (isVerbatim()) {
|
||||
if (isVerbatim(params_)) {
|
||||
os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}';
|
||||
} else if (params_.flag == INPUT) {
|
||||
} else if (type(params_) == INPUT) {
|
||||
// \input wants file with extension (default is .tex)
|
||||
if (!IsLyXFilename(getFileName())) {
|
||||
os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}';
|
||||
@ -392,7 +385,7 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
|
||||
|
||||
int InsetInclude::ascii(Buffer const &, ostream & os, int) const
|
||||
{
|
||||
if (isVerbatim())
|
||||
if (isVerbatim(params_))
|
||||
os << GetFileContents(getFileName());
|
||||
return 0;
|
||||
}
|
||||
@ -426,7 +419,7 @@ int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os) const
|
||||
tmp->makeLinuxDocFile(writefile, buffer.niceFile(), true);
|
||||
}
|
||||
|
||||
if (isVerbatim()) {
|
||||
if (isVerbatim(params_)) {
|
||||
os << "<![CDATA["
|
||||
<< GetFileContents(getFileName())
|
||||
<< "]]>";
|
||||
@ -465,7 +458,7 @@ int InsetInclude::docbook(Buffer const & buffer, ostream & os,
|
||||
tmp->makeDocBookFile(writefile, buffer.niceFile(), true);
|
||||
}
|
||||
|
||||
if (isVerbatim()) {
|
||||
if (isVerbatim(params_)) {
|
||||
os << "<inlinegraphic fileref=\""
|
||||
<< '&' << include_label << ';'
|
||||
<< "\" format=\"linespecific\">";
|
||||
@ -478,15 +471,12 @@ int InsetInclude::docbook(Buffer const & buffer, ostream & os,
|
||||
|
||||
void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
|
||||
string incfile(params_.cparams.getContents());
|
||||
string writefile;
|
||||
|
||||
Buffer const * buffer_ptr = bufferlist.getBuffer(getMasterFilename());
|
||||
BOOST_ASSERT(buffer_ptr);
|
||||
Buffer const & b = *buffer_ptr;
|
||||
Buffer const & b = features.buffer();
|
||||
|
||||
if (!b.temppath().empty() && !b.niceFile() && !isVerbatim()) {
|
||||
if (!b.temppath().empty() && !b.niceFile() && !isVerbatim(params_)) {
|
||||
incfile = subst(incfile, '/','@');
|
||||
writefile = AddName(b.temppath(), incfile);
|
||||
} else
|
||||
@ -497,7 +487,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
|
||||
features.includeFile(include_label, writefile);
|
||||
|
||||
if (isVerbatim())
|
||||
if (isVerbatim(params_))
|
||||
features.require("verbatim");
|
||||
|
||||
// Here we must do the fun stuff...
|
||||
@ -550,8 +540,8 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
button_.metrics(mi, dim);
|
||||
}
|
||||
int center_indent = (params_.flag == INPUT ? 0 :
|
||||
(mi.base.textwidth - dim.wid) / 2);
|
||||
int center_indent = type(params_) == INPUT ?
|
||||
0 : (mi.base.textwidth - dim.wid) / 2;
|
||||
Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
|
||||
button_.setBox(b);
|
||||
|
||||
@ -594,7 +584,7 @@ void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
|
||||
|
||||
bool InsetInclude::PreviewImpl::previewWanted() const
|
||||
{
|
||||
return parent().params_.flag == InsetInclude::INPUT &&
|
||||
return type(parent().params_) == INPUT &&
|
||||
parent().params_.cparams.preview() &&
|
||||
IsFileReadable(parent().getFileName());
|
||||
}
|
||||
|
@ -26,29 +26,14 @@ struct LaTeXFeatures;
|
||||
/// for including tex/lyx files
|
||||
class InsetInclude: public InsetOld {
|
||||
public:
|
||||
/// the type of inclusion
|
||||
enum Flags {
|
||||
INCLUDE = 0, //<
|
||||
VERB = 1, //<
|
||||
INPUT = 2, //<
|
||||
VERBAST = 3 //<
|
||||
};
|
||||
|
||||
struct Params {
|
||||
Params(InsetCommandParams const & cp = InsetCommandParams("input"),
|
||||
Flags f = INPUT,
|
||||
string const & name = string())
|
||||
: cparams(cp), flag(f),
|
||||
: cparams(cp),
|
||||
masterFilename_(name) {}
|
||||
|
||||
InsetCommandParams cparams;
|
||||
Flags flag;
|
||||
string masterFilename_;
|
||||
|
||||
///
|
||||
bool operator==(Params const &) const;
|
||||
///
|
||||
bool operator!=(Params const &) const;
|
||||
};
|
||||
|
||||
///
|
||||
@ -117,8 +102,6 @@ private:
|
||||
void read(LyXLex &);
|
||||
/// get the text displayed on the button
|
||||
string const getScreenLabel(Buffer const &) const;
|
||||
/// is this a verbatim include ?
|
||||
bool isVerbatim() const;
|
||||
/// get the filename of the master buffer
|
||||
string const getMasterFilename() const;
|
||||
/// get the included file name
|
||||
@ -141,11 +124,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
inline bool InsetInclude::isVerbatim() const
|
||||
{
|
||||
return params_.flag == VERB || params_.flag == VERBAST;
|
||||
}
|
||||
|
||||
#include "mailinset.h"
|
||||
|
||||
class InsetIncludeMailer : public MailInset {
|
||||
|
Loading…
Reference in New Issue
Block a user