clone() at long last !

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7092 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-06-03 15:10:14 +00:00
parent 6412ac52b6
commit ad6e8a6e7b
73 changed files with 261 additions and 229 deletions

View File

@ -1,3 +1,15 @@
2003-06-03 John Levon <levon@movementarian.org>
* CutAndPaste.C: update tabular and include inset
buffer references
* buffer.h:
* paragraph.h:
* paragraph.C: remove owningBuffer(), don't pass Buffer
to clone()
* factory.C: insetGraphicsParams changed
2003-06-02 John Levon <levon@movementarian.org>
* LyXAction.C:

View File

@ -24,8 +24,8 @@
#include "gettext.h"
#include "paragraph_funcs.h"
#include "debug.h"
#include "insets/inseterror.h"
#include "insets/insetinclude.h"
#include "insets/insettabular.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
@ -273,6 +273,38 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
// the cursor paragraph.
simple_cut_clone.begin()->makeSameLayout(*pit);
// Prepare the paragraphs and insets for insertion
// A couple of insets store buffer references so need
// updating
ParIterator fpit(simple_cut_clone.begin(), simple_cut_clone);
ParIterator fend(simple_cut_clone.end(), simple_cut_clone);
for (; fpit != fend; ++fpit) {
InsetList::iterator lit = fpit->insetlist.begin();
InsetList::iterator eit = fpit->insetlist.end();
for (; lit != eit; ++lit) {
switch (lit->inset->lyxCode()) {
case Inset::INCLUDE_CODE: {
InsetInclude * ii = static_cast<InsetInclude*>(lit->inset);
InsetInclude::Params ip = ii->params();
ip.masterFilename_ = current_view->buffer()->fileName();
ii->set(ip);
break;
}
case Inset::TABULAR_CODE: {
InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
it->buffer(current_view->buffer());
break;
}
default:
break; // nothing
}
}
}
bool paste_the_end = false;
// Open the paragraph for inserting the buf

View File

@ -369,7 +369,6 @@ int Buffer::readParagraph(LyXLex & lex, string const & token,
lex.pushToken(token);
Paragraph par;
par.owningBuffer(*this);
par.params().depth(depth);
if (params.tracking_changes)
par.trackChanges();

View File

@ -206,8 +206,7 @@ Inset * createInset(FuncRequest const & cmd)
InsetGraphicsParams igp;
InsetGraphicsMailer::string2params(cmd.argument, igp);
InsetGraphics * inset = new InsetGraphics;
string const fpath = cmd.view()->buffer()->filePath();
inset->setParams(igp, fpath);
inset->setParams(igp);
return inset;
} else if (name == "include") {

View File

@ -1,3 +1,8 @@
2003-06-03 John Levon <levon@movementarian.org>
* ControlGraphics.C: make file path relative for the GUI,
absolute for the backend
2003-05-24 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlDocument.C (saveAsDefault): adjust

View File

@ -51,6 +51,9 @@ bool ControlGraphics::initialiseParams(string const & data)
InsetGraphicsParams params;
InsetGraphicsMailer::string2params(data, params);
params_.reset(new InsetGraphicsParams(params));
// make relative for good UI
params_->filename = MakeRelPath(params_->filename,
kernel().buffer()->filePath());
return true;
}
@ -63,7 +66,11 @@ void ControlGraphics::clearParams()
void ControlGraphics::dispatchParams()
{
string const lfun = InsetGraphicsMailer::params2string(params());
InsetGraphicsParams params(params());
// core requires absolute path during runtime
params.filename = MakeAbsPath(params.filename,
kernel().buffer()->filePath());
string const lfun = InsetGraphicsMailer::params2string(params);
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -18,7 +18,6 @@
#include "support/LAssert.h"
ControlTabular::ControlTabular(Dialog & parent)
: Dialog::Controller(parent), active_cell_(-1)
{}

View File

@ -1,3 +1,42 @@
2003-06-03 John Levon <levon@movementarian.org>
* inset.h:
* insetbibitem.[Ch]:
* insetbibtex.h:
* insetcite.h:
* insetcommand.[Ch]:
* insetenv.[Ch]:
* inseterror.h:
* insetert.[Ch]:
* insetexternal.[Ch]:
* insetfloat.[Ch]:
* insetfloatlist.h:
* insetfoot.[Ch]:
* insetgraphics.[Ch]:
* insethfill.h:
* insetinclude.[Ch]:
* insetindex.h:
* insetlabel.h:
* insetlatexaccent.[Ch]:
* insetmarginal.[Ch]:
* insetminipage.[Ch]:
* insetnewline.h:
* insetnote.[Ch]:
* insetoptarg.[Ch]:
* insetquotes.[Ch]:
* insetref.[Ch]:
* insetspace.[Ch]:
* insetspecialchar.[Ch]:
* insettabular.[Ch]:
* insettext.[Ch]:
* insetthereom.[Ch]:
* insettoc.h:
* inseturl.h:
* insetwrap.[Ch]: make clone() not take a Buffer * arg
* insetgraphics.[Ch]:
* insetgraphicsParams.[Ch]: always store an absolute
path at runtime
2003-06-02 André Pönitz <poenitz@gmx.net>

View File

@ -198,7 +198,7 @@ public:
}
///
virtual Inset * clone(Buffer const &) const = 0;
virtual Inset * clone() const = 0;
/// returns true to override begin and end inset in file
virtual bool directWrite() const;

View File

@ -43,7 +43,7 @@ InsetBibitem::~InsetBibitem()
}
Inset * InsetBibitem::clone(Buffer const &) const
Inset * InsetBibitem::clone() const
{
InsetBibitem * b = new InsetBibitem(params());
b->setCounter(counter);
@ -51,14 +51,6 @@ Inset * InsetBibitem::clone(Buffer const &) const
}
// Inset * InsetBibitem::clone(Buffer const &, bool) const
// {
// InsetBibitem * b = new InsetBibitem(params());
// b->setCounter(counter);
// return b;
// }
dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
{
switch (cmd.action) {

View File

@ -29,7 +29,7 @@ public:
///
~InsetBibitem();
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
virtual dispatch_result localDispatch(FuncRequest const & cmd);
/** Currently \bibitem is used as a LyX2.x command,

View File

@ -27,7 +27,7 @@ public:
///
~InsetBibtex();
///
Inset * clone(Buffer const &) const {
Inset * clone() const {
return new InsetBibtex(params());
}
/// small wrapper for the time being

View File

@ -25,7 +25,7 @@ public:
///
~InsetCitation();
///
Inset * clone(Buffer const &) const {
Inset * clone() const {
return new InsetCitation(params());
}
///

View File

@ -31,9 +31,10 @@ InsetCommand::InsetCommand(InsetCommandParams const & p)
{}
// InsetCommand::InsetCommand(InsetCommandParams const & p, bool)
// : p_(p.getCmdName(), p.getContents(), p.getOptions())
// {}
InsetCommand::InsetCommand(InsetCommand const & ic)
: p_(ic.p_)
{
}
void InsetCommand::setParams(InsetCommandParams const & p)
@ -72,7 +73,6 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
{
lyxerr << "InsetCommand::localDispatch: " << cmd.action << "\n";
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p;

View File

@ -33,6 +33,8 @@ public:
explicit
InsetCommand(InsetCommandParams const &);
///
InsetCommand(InsetCommand const &);
///
void write(Buffer const *, std::ostream & os) const
{ p_.write(os); }
///

View File

@ -40,7 +40,7 @@ InsetEnvironment::InsetEnvironment(InsetEnvironment const & in)
{}
Inset * InsetEnvironment::clone(Buffer const &) const
Inset * InsetEnvironment::clone() const
{
return new InsetEnvironment(*this);
}

View File

@ -26,7 +26,7 @@ public:
///
void read(Buffer const * buf, LyXLex & lex);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::ENVIRONMENT_CODE; }
///

View File

@ -54,7 +54,7 @@ public:
///
EDITABLE editable() const { return IS_EDITABLE; }
///
Inset * clone(Buffer const &) const {
Inset * clone() const {
return new InsetError(contents);
}
///

View File

@ -70,7 +70,7 @@ InsetERT::InsetERT(InsetERT const & in)
}
Inset * InsetERT::clone(Buffer const &) const
Inset * InsetERT::clone() const
{
return new InsetERT(*this);
}

View File

@ -40,7 +40,7 @@ public:
///
InsetERT(InsetERT const &);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
InsetERT(BufferParams const &,
Language const *, string const & contents, bool collapsed);

View File

@ -223,7 +223,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
}
Inset * InsetExternal::clone(Buffer const &) const
Inset * InsetExternal::clone() const
{
InsetExternal * inset = new InsetExternal;
inset->params_ = params_;

View File

@ -69,7 +69,7 @@ public:
virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
/// returns the text of the button
virtual string const getScreenLabel(Buffer const *) const;

View File

@ -259,7 +259,7 @@ void InsetFloat::validate(LaTeXFeatures & features) const
}
Inset * InsetFloat::clone(Buffer const &) const
Inset * InsetFloat::clone() const
{
return new InsetFloat(*this);
}

View File

@ -53,7 +53,7 @@ public:
///
void validate(LaTeXFeatures & features) const;
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::FLOAT_CODE; }
///

View File

@ -26,14 +26,10 @@ public:
///
~InsetFloatList();
///
Inset * clone(Buffer const &) const {
Inset * clone() const {
return new InsetFloatList(getCmdName());
}
///
//Inset * clone(Buffer const &, bool = false) const {
// return new InsetFloatList(getCmdName());
//}
///
dispatch_result localDispatch(FuncRequest const & cmd);
///
string const getScreenLabel(Buffer const *) const;

View File

@ -46,7 +46,7 @@ InsetFoot::InsetFoot(InsetFoot const & in)
}
Inset * InsetFoot::clone(Buffer const &) const
Inset * InsetFoot::clone() const
{
return new InsetFoot(*this);
}

View File

@ -27,7 +27,7 @@ public:
///
InsetFoot(InsetFoot const &);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::FOOT_CODE; }
///

View File

@ -182,7 +182,7 @@ void InsetGraphics::Cache::update(string const & file_with_path)
lyx::Assert(!file_with_path.empty());
string const path = OnlyPath(file_with_path);
loader.reset(file_with_path, parent_.params().as_grfxParams(path));
loader.reset(file_with_path, parent_.params().as_grfxParams());
}
@ -192,19 +192,20 @@ InsetGraphics::InsetGraphics()
{}
InsetGraphics::InsetGraphics(InsetGraphics const & ig,
string const & filepath)
#warning I have zero idea about the trackable()
InsetGraphics::InsetGraphics(InsetGraphics const & ig)
: Inset(ig),
boost::signals::trackable(ig),
graphic_label(uniqueID()),
cache_(new Cache(*this))
{
setParams(ig.params(), filepath);
setParams(ig.params());
}
Inset * InsetGraphics::clone(Buffer const & buffer) const
Inset * InsetGraphics::clone() const
{
return new InsetGraphics(*this, buffer.filePath());
return new InsetGraphics(*this);
}
@ -222,8 +223,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
InsetGraphicsParams p;
InsetGraphicsMailer::string2params(cmd.argument, p);
if (!p.filename.empty()) {
string const filepath = cmd.view()->buffer()->filePath();
setParams(p, filepath);
setParams(p);
cmd.view()->updateInset(this);
}
return DISPATCHED;
@ -327,18 +327,6 @@ BufferView * InsetGraphics::view() const
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
{
BufferView * bv = pi.base.bv;
// MakeAbsPath returns params().filename unchanged if it absolute
// already.
string const file_with_path =
MakeAbsPath(params().filename, bv->buffer()->filePath());
// A 'paste' operation creates a new inset with the correct filepath,
// but then the 'old' inset stored in the 'copy' operation is actually
// added to the buffer.
// Thus, we should ensure that the filepath is correct.
if (file_with_path != cache_->loader.filename())
cache_->update(file_with_path);
cache_->view = bv->owner()->view();
int oasc = cache_->old_ascent;
@ -400,10 +388,10 @@ Inset::EDITABLE InsetGraphics::editable() const
}
void InsetGraphics::write(Buffer const *, ostream & os) const
void InsetGraphics::write(Buffer const * buf, ostream & os) const
{
os << "Graphics\n";
params().Write(os);
params().Write(os, buf->filePath());
}
@ -412,15 +400,15 @@ void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
string const token = lex.getString();
if (token == "Graphics")
readInsetGraphics(lex);
readInsetGraphics(lex, buf->filePath());
else
lyxerr[Debug::GRAPHICS] << "Not a Graphics inset!\n";
cache_->update(MakeAbsPath(params().filename, buf->filePath()));
cache_->update(params().filename);
}
void InsetGraphics::readInsetGraphics(LyXLex & lex)
void InsetGraphics::readInsetGraphics(LyXLex & lex, string const & bufpath)
{
bool finished = false;
@ -447,7 +435,7 @@ void InsetGraphics::readInsetGraphics(LyXLex & lex)
// TODO: Possibly open up a dialog?
}
else {
if (! params_.Read(lex, token))
if (!params_.Read(lex, token, bufpath))
lyxerr << "Unknown token, " << token << ", skipping."
<< std::endl;
}
@ -510,17 +498,13 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
{
// LaTeX can cope if the graphics file doesn't exist, so just return the
// filename.
string const orig_file = params().filename;
string orig_file_with_path =
MakeAbsPath(orig_file, buf->filePath());
lyxerr[Debug::GRAPHICS] << "[InsetGraphics::prepareFile] orig_file = "
<< orig_file << "\n\twith path: "
<< orig_file_with_path << endl;
string orig_file = params().filename;
string const rel_file = MakeRelPath(orig_file, buf->filePath());
if (!IsFileReadable(orig_file_with_path))
return orig_file;
if (!IsFileReadable(rel_file))
return rel_file;
bool const zipped = zippedFile(orig_file_with_path);
bool const zipped = zippedFile(orig_file);
// If the file is compressed and we have specified that it
// should not be uncompressed, then just return its name and
@ -528,9 +512,9 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
if (zipped && params().noUnzip) {
lyxerr[Debug::GRAPHICS]
<< "\tpass zipped file to LaTeX but with full path.\n";
// LaTeX needs an absolue path, otherwise the
// LaTeX needs an absolute path, otherwise the
// coresponding *.eps.bb file isn't found
return orig_file_with_path;
return orig_file;
}
// Ascertain whether the file has changed.
@ -551,22 +535,21 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
lyxerr[Debug::GRAPHICS]
<< "\ttemp_file: " << temp_file << endl;
if (file_has_changed || !IsFileReadable(temp_file)) {
bool const success = lyx::copy(orig_file_with_path,
temp_file);
bool const success = lyx::copy(orig_file, temp_file);
lyxerr[Debug::GRAPHICS]
<< "\tCopying zipped file from "
<< orig_file_with_path << " to " << temp_file
<< orig_file << " to " << temp_file
<< (success ? " succeeded\n" : " failed\n");
} else
lyxerr[Debug::GRAPHICS]
<< "\tzipped file " << temp_file
<< " exists! Maybe no tempdir ...\n";
orig_file_with_path = unzipFile(temp_file);
orig_file = unzipFile(temp_file);
lyxerr[Debug::GRAPHICS]
<< "\tunzipped to " << orig_file_with_path << endl;
<< "\tunzipped to " << orig_file << endl;
}
string const from = getExtFromContents(orig_file_with_path);
string const from = getExtFromContents(orig_file);
string const to = findTargetFormat(from, runparams);
lyxerr[Debug::GRAPHICS]
<< "\t we have: from " << from << " to " << to << '\n';
@ -576,8 +559,8 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
// graphic file as is.
// This is true even if the orig_file is compressed.
if (formats.getFormat(to)->extension() == GetExtension(orig_file))
return RemoveExtension(orig_file_with_path);
return orig_file_with_path;
return RemoveExtension(orig_file);
return orig_file;
}
// We're going to be running the exported buffer through the LaTeX
@ -592,13 +575,13 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
// to "any_dir_file.ext"! changing the dots in the
// dirname is important for the use of ChangeExtension
lyxerr[Debug::GRAPHICS]
<< "\tthe orig file is: " << orig_file_with_path << endl;
<< "\tthe orig file is: " << orig_file << endl;
if (lyxrc.use_tempdir) {
string const ext_tmp = GetExtension(orig_file_with_path);
string const ext_tmp = GetExtension(orig_file);
// without ext and /
temp_file = subst(
ChangeExtension(orig_file_with_path, string()), "/", "_");
ChangeExtension(orig_file, string()), "/", "_");
// without dots and again with ext
temp_file = ChangeExtension(
subst(temp_file, ".", "_"), ext_tmp);
@ -609,14 +592,14 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
// if the file doen't exists, copy it into the tempdir
if (file_has_changed || !IsFileReadable(temp_file)) {
bool const success = lyx::copy(orig_file_with_path, temp_file);
bool const success = lyx::copy(orig_file, temp_file);
lyxerr[Debug::GRAPHICS]
<< "\tcopying from " << orig_file_with_path << " to "
<< "\tcopying from " << orig_file << " to "
<< temp_file
<< (success ? " succeeded\n" : " failed\n");
if (!success) {
string str = bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."), orig_file_with_path);
"into the temporary directory."), orig_file);
Alert::error(_("Graphics display failed"), str);
return orig_file;
}
@ -672,9 +655,12 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os,
<< "insetgraphics::latex: Filename = "
<< params().filename << endl;
string const relative_file = MakeRelPath(params().filename, buf->filePath());
// A missing (e)ps-extension is no problem for LaTeX, so
// we have to test three different cases
string const file_ = MakeAbsPath(params().filename, buf->filePath());
#warning uh, but can our cache handle it ? no.
string const file_ = params().filename;
bool const file_exists =
!file_.empty() &&
(IsFileReadable(file_) || // original
@ -718,7 +704,7 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os,
// "nice" means that the buffer is exported to LaTeX format but not
// run through the LaTeX compiler.
if (runparams.nice) {
os << before <<'{' << params().filename << '}' << after;
os << before <<'{' << relative_file << '}' << after;
return 1;
}
@ -727,7 +713,7 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os,
// appropriate (when there are several versions in different formats)
string const latex_str = message.empty() ?
(before + '{' + os::external_path(prepareFile(buf, runparams)) + '}' + after) :
(before + '{' + params().filename + " not found!}" + after);
(before + '{' + relative_file + " not found!}" + after);
os << latex_str;
// Return how many newlines we issued.
@ -790,8 +776,7 @@ void InsetGraphics::statusChanged()
}
bool InsetGraphics::setParams(InsetGraphicsParams const & p,
string const & filepath)
bool InsetGraphics::setParams(InsetGraphicsParams const & p)
{
// If nothing is changed, just return and say so.
if (params() == p && !p.filename.empty())
@ -801,7 +786,7 @@ bool InsetGraphics::setParams(InsetGraphicsParams const & p,
params_ = p;
// Update the inset with the new parameters.
cache_->update(MakeAbsPath(params().filename, filepath));
cache_->update(params().filename);
// We have changed data, report it.
return true;
@ -848,7 +833,8 @@ void InsetGraphicsMailer::string2params(string const & in,
if (lex.isOK()) {
InsetGraphics inset;
inset.readInsetGraphics(lex);
#warning FIXME not setting bufpath is dubious
inset.readInsetGraphics(lex, string());
params = inset.params();
}
}
@ -859,7 +845,8 @@ InsetGraphicsMailer::params2string(InsetGraphicsParams const & params)
{
ostringstream data;
data << name_ << ' ';
params.Write(data);
#warning FIXME not setting bufpath is dubious
params.Write(data, string());
data << "\\end_inset\n";
return STRCONV(data.str());
}

View File

@ -29,7 +29,7 @@ public:
///
InsetGraphics();
///
InsetGraphics(InsetGraphics const &, string const & filepath);
InsetGraphics(InsetGraphics const &);
///
~InsetGraphics();
///
@ -67,13 +67,12 @@ public:
Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() 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,
string const & filepath);
bool setParams(InsetGraphicsParams const & params);
/// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams const & params() const;
@ -94,7 +93,7 @@ private:
void statusChanged();
/// Read the inset native format
void readInsetGraphics(LyXLex & lex);
void readInsetGraphics(LyXLex & lex, string const & bufpath);
/// Get the status message, depends on the image loading status.
string const statusMessage() const;

View File

@ -49,7 +49,7 @@ InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
{
// Are we assigning the object into itself?
if (this == &params)
return * this;
return *this;
copy(params);
return *this;
}
@ -137,12 +137,12 @@ bool operator!=(InsetGraphicsParams const & left,
}
void InsetGraphicsParams::Write(ostream & os) const
void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
{
// Do not write the default values
if (!filename.empty()) {
os << "\tfilename " << filename << '\n';
os << "\tfilename " << MakeRelPath(filename, bufpath) << '\n';
}
if (lyxscale != 100)
os << "\tlyxscale " << lyxscale << '\n';
@ -183,11 +183,11 @@ void InsetGraphicsParams::Write(ostream & os) const
}
bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
bool InsetGraphicsParams::Read(LyXLex & lex, string const & token, string const & bufpath)
{
if (token == "filename") {
lex.eatLine();
filename = lex.getString();
filename = MakeAbsPath(lex.getString(), bufpath);
} else if (token == "lyxscale") {
lex.next();
lyxscale = lex.getInteger();
@ -254,16 +254,13 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
}
grfx::Params InsetGraphicsParams::as_grfxParams(string const & filepath) const
grfx::Params InsetGraphicsParams::as_grfxParams() const
{
grfx::Params pars;
pars.filename = filename;
pars.scale = lyxscale;
pars.angle = rotateAngle;
if (!filepath.empty())
pars.filename = MakeAbsPath(pars.filename, filepath);
if (clip) {
pars.bb = bb;

View File

@ -69,14 +69,14 @@ struct InsetGraphicsParams
///
InsetGraphicsParams & operator=(InsetGraphicsParams const &);
/// Save the parameters in the LyX format stream.
void Write(std::ostream & os) const;
void Write(std::ostream & os, string const & bufpath) const;
/// If the token belongs to our parameters, read it.
bool Read(LyXLex & lex, string const & token);
bool Read(LyXLex & lex, string const & token, string const & bufpath);
/// convert
// Only a subset of InsetGraphicsParams is needed for display purposes.
// This function also interrogates lyxrc to ascertain whether
// to display or not.
grfx::Params as_grfxParams(string const & filepath = string()) const;
grfx::Params as_grfxParams() const;
private:
/// Initialize the object to a default status.

View File

@ -20,7 +20,7 @@ public:
///
InsetHFill();
///
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetHFill;
}
///

View File

@ -192,24 +192,16 @@ void InsetInclude::set(Params const & p)
}
Inset * InsetInclude::clone(Buffer const & buffer) const
Inset * InsetInclude::clone() const
{
Params p(params_);
p.masterFilename_ = buffer.fileName();
//Params p(params_);
//p.masterFilename_ = buffer.fileName();
#warning FIXME: broken cross-doc copy/paste - must fix
return new InsetInclude(p);
return new InsetInclude(params_);
}
// Inset * InsetInclude::clone(Buffer const & buffer, bool) const
// {
// Params p(params_);
// p.masterFilename_ = buffer.fileName();
// return new InsetInclude(p);
// }
void InsetInclude::write(Buffer const *, ostream & os) const
{
os << "Include " << params_.cparams.getCommand() << '\n'

View File

@ -71,7 +71,7 @@ public:
void set(Params const & params);
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
/// This returns the list of labels on the child buffer

View File

@ -26,7 +26,7 @@ public:
///
~InsetIndex();
///
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetIndex(params());
}
///
@ -49,7 +49,7 @@ public:
///
~InsetPrintIndex();
///
Inset * clone(Buffer const &) const {
Inset * clone() const {
return new InsetPrintIndex(params());
}
///

View File

@ -22,7 +22,7 @@ public:
///
~InsetLabel();
///
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetLabel(params());
}
///

View File

@ -647,18 +647,12 @@ bool InsetLatexAccent::directWrite() const
}
Inset * InsetLatexAccent::clone(Buffer const &) const
Inset * InsetLatexAccent::clone() const
{
return new InsetLatexAccent(contents);
}
// Inset * InsetLatexAccent::clone(Buffer const &, bool) const
// {
// return new InsetLatexAccent(contents);
// }
Inset::Code InsetLatexAccent::lyxCode() const
{
return Inset::ACCENT_CODE;

View File

@ -57,7 +57,7 @@ public:
///
bool directWrite() const;
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
///
Inset::Code lyxCode()const;
///

View File

@ -41,7 +41,7 @@ InsetMarginal::InsetMarginal(InsetMarginal const & in)
}
Inset * InsetMarginal::clone(Buffer const &) const
Inset * InsetMarginal::clone() const
{
return new InsetMarginal(*this);
}

View File

@ -26,7 +26,7 @@ public:
///
InsetMarginal(InsetMarginal const &);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::MARGIN_CODE; }
///

View File

@ -93,7 +93,7 @@ InsetMinipage::InsetMinipage(InsetMinipage const & in)
{}
Inset * InsetMinipage::clone(Buffer const &) const
Inset * InsetMinipage::clone() const
{
return new InsetMinipage(*this);
}

View File

@ -66,7 +66,7 @@ public:
///
void read(Buffer const * buf, LyXLex & lex);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
void metrics(MetricsInfo &, Dimension &) const;
///

View File

@ -20,7 +20,7 @@ public:
InsetNewline() {}
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetNewline;
}

View File

@ -53,7 +53,7 @@ InsetNote::InsetNote(InsetNote const & in)
}
Inset * InsetNote::clone(Buffer const &) const
Inset * InsetNote::clone() const
{
return new InsetNote(*this);
}

View File

@ -25,7 +25,7 @@ public:
///
InsetNote(InsetNote const &);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
string const editMessage() const;
///

View File

@ -47,7 +47,7 @@ InsetOptArg::InsetOptArg(InsetOptArg const & in)
}
Inset * InsetOptArg::clone(Buffer const &) const
Inset * InsetOptArg::clone() const
{
return new InsetOptArg(*this);
}

View File

@ -27,7 +27,7 @@ public:
InsetOptArg(InsetOptArg const &);
/// make a duplicate of this inset
Inset * clone(Buffer const &) const;
Inset * clone() const;
/// this inset is editable
EDITABLE editable() const { return IS_EDITABLE; }
/// code of the inset

View File

@ -351,18 +351,12 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
}
Inset * InsetQuotes::clone(Buffer const &) const
Inset * InsetQuotes::clone() const
{
return new InsetQuotes(language_, side_, times_);
}
// Inset * InsetQuotes::clone(Buffer const &, bool) const
// {
// return new InsetQuotes(language_, side_, times_);
// }
Inset::Code InsetQuotes::lyxCode() const
{
return Inset::QUOTE_CODE;

View File

@ -68,8 +68,7 @@ public:
/// Create the right quote inset after character c
InsetQuotes(char c, BufferParams const & params);
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
void metrics(MetricsInfo &, Dimension &) const;
///

View File

@ -28,9 +28,10 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
{}
// InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
// : InsetCommand(p, false), isLatex(buf.isLatex())
// {}
InsetRef::InsetRef(InsetRef const & ir)
: InsetCommand(ir), isLatex(ir.isLatex)
{
}
InsetRef::~InsetRef()

View File

@ -35,13 +35,15 @@ public:
///
static string const & getName(int type);
///
InsetRef(InsetCommandParams const &, Buffer const &);
///
InsetRef(InsetRef const &);
~InsetRef();
///
virtual Inset * clone(Buffer const & buffer) const {
return new InsetRef(params(), buffer);
virtual Inset * clone() const {
return new InsetRef(*this);
}
///
dispatch_result localDispatch(FuncRequest const & cmd);

View File

@ -252,18 +252,12 @@ int InsetSpace::docbook(Buffer const *, ostream & os, bool) const
}
Inset * InsetSpace::clone(Buffer const &) const
Inset * InsetSpace::clone() const
{
return new InsetSpace(kind_);
}
// Inset * InsetSpace::clone(Buffer const &, bool) const
// {
// return new InsetSpace(kind_);
// }
bool InsetSpace::isChar() const
{
return true;

View File

@ -71,7 +71,7 @@ public:
///
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::SPACE_CODE; }
/// We don't need \begin_inset and \end_inset

View File

@ -238,18 +238,12 @@ int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const
}
Inset * InsetSpecialChar::clone(Buffer const &) const
Inset * InsetSpecialChar::clone() const
{
return new InsetSpecialChar(kind_);
}
// Inset * InsetSpecialChar::clone(Buffer const &, bool) const
// {
// return new InsetSpecialChar(kind_);
// }
void InsetSpecialChar::validate(LaTeXFeatures & features) const
{
if (kind_ == MENU_SEPARATOR) {

View File

@ -63,7 +63,7 @@ public:
///
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::SPECIALCHAR_CODE; }
/// We don't need \begin_inset and \end_inset

View File

@ -151,7 +151,7 @@ bool InsetTabular::hasPasteBuffer() const
InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
: buffer(&buf)
: buffer_(&buf)
{
if (rows <= 0)
rows = 1;
@ -174,10 +174,10 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
}
InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
: UpdatableInset(tab), buffer(&buf)
InsetTabular::InsetTabular(InsetTabular const & tab)
: UpdatableInset(tab), buffer_(tab.buffer_)
{
tabular.reset(new LyXTabular(buf.params,
tabular.reset(new LyXTabular(buffer_->params,
this, *(tab.tabular)));
the_locking_inset = 0;
old_locking_inset = 0;
@ -200,15 +200,21 @@ InsetTabular::~InsetTabular()
}
Inset * InsetTabular::clone(Buffer const & buf) const
Inset * InsetTabular::clone() const
{
return new InsetTabular(*this, buf);
return new InsetTabular(*this);
}
BufferView * InsetTabular::view() const
{
return buffer->getUser();
return buffer_->getUser();
}
void InsetTabular::buffer(Buffer * b)
{
buffer_ = b;
}
@ -2891,6 +2897,7 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
if (!lex.isOK())
return -1;
// FIXME: even current_view would be better than this.
BufferView * const bv = inset.view();
Buffer const * const buffer = bv ? bv->buffer() : 0;
if (buffer)
@ -2904,6 +2911,7 @@ int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
string const InsetTabularMailer::params2string(InsetTabular const & inset)
{
// FIXME: even current_view would be better than this.
BufferView * const bv = inset.view();
Buffer const * const buffer = bv ? bv->buffer() : 0;
if (!buffer)

View File

@ -76,11 +76,11 @@ public:
///
InsetTabular(Buffer const &, int rows = 1, int columns = 1);
///
InsetTabular(InsetTabular const &, Buffer const &);
InsetTabular(InsetTabular const &);
///
~InsetTabular();
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
void read(Buffer const *, LyXLex &);
///
@ -228,6 +228,10 @@ public:
///
virtual BufferView * view() const;
/// set the owning buffer
void buffer(Buffer * b);
private:
///
void lfunMousePress(FuncRequest const &);
@ -315,7 +319,7 @@ private:
///
InsetText * old_locking_inset;
///
Buffer const * buffer;
Buffer const * buffer_;
///
mutable LyXCursor cursor_;
///

View File

@ -224,7 +224,7 @@ void InsetText::clear(bool just_mark_erased)
}
Inset * InsetText::clone(Buffer const &) const
Inset * InsetText::clone() const
{
return new InsetText(*this);
}

View File

@ -77,7 +77,7 @@ public:
///
~InsetText();
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
InsetText & operator=(InsetText const & it);
/// empty inset to empty par, or just mark as erased

View File

@ -53,7 +53,7 @@ void InsetTheorem::write(Buffer const * buf, ostream & os) const
}
Inset * InsetTheorem::clone(Buffer const &, bool) const
Inset * InsetTheorem::clone() const
{
#ifdef WITH_WARNINGS
#warning Is this inset used? If YES this is WRONG!!! (Jug)

View File

@ -25,7 +25,7 @@ public:
///
void write(Buffer const * buf, std::ostream & os) const;
///
virtual Inset * clone(Buffer const &) const;
virtual Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::THEOREM_CODE; }
///

View File

@ -24,7 +24,7 @@ public:
///
~InsetTOC();
///
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetTOC(params());
}
///

View File

@ -27,7 +27,7 @@ public:
///
~InsetUrl();
///
virtual Inset * clone(Buffer const &) const {
virtual Inset * clone() const {
return new InsetUrl(params());
}
///

View File

@ -180,7 +180,7 @@ void InsetWrap::validate(LaTeXFeatures & features) const
}
Inset * InsetWrap::clone(Buffer const &) const
Inset * InsetWrap::clone() const
{
return new InsetWrap(*this);
}

View File

@ -51,7 +51,7 @@ public:
///
void validate(LaTeXFeatures & features) const;
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const { return Inset::WRAP_CODE; }
///

View File

@ -1,3 +1,8 @@
2003-06-03 John Levon <levon@movementarian.org>
* formula.[Ch]:
* formulabase.h:
* formulamacro.[Ch]: clone() doesn't take a Buffer anymore
2003-06-02 André Pönitz <poenitz@gmx.net>

View File

@ -113,18 +113,12 @@ InsetFormula::~InsetFormula()
{}
Inset * InsetFormula::clone(Buffer const &) const
Inset * InsetFormula::clone() const
{
return new InsetFormula(*this);
}
// Inset * InsetFormula::clone(Buffer const &, bool) const
// {
// return new InsetFormula(*this);
// }
void InsetFormula::write(Buffer const *, ostream & os) const
{
WriteStream wi(os, false, false);

View File

@ -54,7 +54,7 @@ public:
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
void validate(LaTeXFeatures & features) const;
///

View File

@ -30,7 +30,7 @@ public:
///
InsetFormulaBase();
///
Inset * clone(Buffer const &) const = 0;
Inset * clone() const = 0;
/// lowest x coordinate
virtual int xlow() const;
/// highest x coordinate

View File

@ -62,18 +62,12 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
}
Inset * InsetFormulaMacro::clone(Buffer const &) const
Inset * InsetFormulaMacro::clone() const
{
return new InsetFormulaMacro(*this);
}
// Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
// {
// return new InsetFormulaMacro(*this);
// }
void InsetFormulaMacro::write(Buffer const *, ostream & os) const
{
os << "FormulaMacro ";

View File

@ -52,7 +52,7 @@ public:
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
Inset * clone(Buffer const &) const;
Inset * clone() const;
///
Inset::Code lyxCode() const;
///

View File

@ -84,14 +84,13 @@ Paragraph::Paragraph(Paragraph const & lp)
// this is because of the dummy layout of the paragraphs that
// follow footnotes
layout_ = lp.layout();
buffer_ = lp.buffer_;
// copy everything behind the break-position to the new paragraph
insetlist = lp.insetlist;
InsetList::iterator it = insetlist.begin();
InsetList::iterator end = insetlist.end();
for (; it != end; ++it) {
it->inset = it->inset->clone(**buffer_);
it->inset = it->inset->clone();
// tell the new inset who is the boss now
it->inset->parOwner(this);
}
@ -231,7 +230,7 @@ void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
minibuffer_inset = 0;
if (minibuffer_char == Paragraph::META_INSET) {
if (getInset(pos)) {
minibuffer_inset = getInset(pos)->clone(buffer);
minibuffer_inset = getInset(pos)->clone();
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';

View File

@ -20,8 +20,6 @@
#include "LString.h"
#include <boost/optional.hpp>
class Buffer;
class BufferParams;
class BufferView;
@ -293,15 +291,10 @@ public:
ParagraphParameters const & params() const;
///
InsetList insetlist;
///
void owningBuffer(Buffer const & b) {
buffer_.reset(&b);
}
private:
///
LyXLayout_ptr layout_;
///
boost::optional<Buffer const *> buffer_;
struct Pimpl;
///