From ad6e8a6e7be96b45671d9b111e53339739cf2702 Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 3 Jun 2003 15:10:14 +0000 Subject: [PATCH] clone() at long last ! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7092 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 12 +++ src/CutAndPaste.C | 36 ++++++- src/buffer.C | 1 - src/factory.C | 3 +- src/frontends/controllers/ChangeLog | 5 + src/frontends/controllers/ControlGraphics.C | 9 +- src/frontends/controllers/ControlTabular.C | 1 - src/insets/ChangeLog | 39 +++++++ src/insets/inset.h | 2 +- src/insets/insetbibitem.C | 10 +- src/insets/insetbibitem.h | 2 +- src/insets/insetbibtex.h | 2 +- src/insets/insetcite.h | 2 +- src/insets/insetcommand.C | 8 +- src/insets/insetcommand.h | 2 + src/insets/insetenv.C | 2 +- src/insets/insetenv.h | 2 +- src/insets/inseterror.h | 2 +- src/insets/insetert.C | 2 +- src/insets/insetert.h | 2 +- src/insets/insetexternal.C | 2 +- src/insets/insetexternal.h | 2 +- src/insets/insetfloat.C | 2 +- src/insets/insetfloat.h | 2 +- src/insets/insetfloatlist.h | 6 +- src/insets/insetfoot.C | 2 +- src/insets/insetfoot.h | 2 +- src/insets/insetgraphics.C | 107 +++++++++----------- src/insets/insetgraphics.h | 9 +- src/insets/insetgraphicsParams.C | 15 ++- src/insets/insetgraphicsParams.h | 6 +- src/insets/insethfill.h | 2 +- src/insets/insetinclude.C | 18 +--- src/insets/insetinclude.h | 2 +- src/insets/insetindex.h | 4 +- src/insets/insetlabel.h | 2 +- src/insets/insetlatexaccent.C | 8 +- src/insets/insetlatexaccent.h | 2 +- src/insets/insetmarginal.C | 2 +- src/insets/insetmarginal.h | 2 +- src/insets/insetminipage.C | 2 +- src/insets/insetminipage.h | 2 +- src/insets/insetnewline.h | 2 +- src/insets/insetnote.C | 2 +- src/insets/insetnote.h | 2 +- src/insets/insetoptarg.C | 2 +- src/insets/insetoptarg.h | 2 +- src/insets/insetquotes.C | 8 +- src/insets/insetquotes.h | 3 +- src/insets/insetref.C | 7 +- src/insets/insetref.h | 10 +- src/insets/insetspace.C | 8 +- src/insets/insetspace.h | 2 +- src/insets/insetspecialchar.C | 8 +- src/insets/insetspecialchar.h | 2 +- src/insets/insettabular.C | 22 ++-- src/insets/insettabular.h | 10 +- src/insets/insettext.C | 2 +- src/insets/insettext.h | 2 +- src/insets/insettheorem.C | 2 +- src/insets/insettheorem.h | 2 +- src/insets/insettoc.h | 2 +- src/insets/inseturl.h | 2 +- src/insets/insetwrap.C | 2 +- src/insets/insetwrap.h | 2 +- src/mathed/ChangeLog | 5 + src/mathed/formula.C | 8 +- src/mathed/formula.h | 2 +- src/mathed/formulabase.h | 2 +- src/mathed/formulamacro.C | 8 +- src/mathed/formulamacro.h | 2 +- src/paragraph.C | 5 +- src/paragraph.h | 9 +- 73 files changed, 262 insertions(+), 230 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 4d2b09be62..7453a74d7e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2003-06-03 John Levon + + * 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 * LyXAction.C: diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index c2c4c04b37..076d6eca7b 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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(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(lit->inset); + it->buffer(current_view->buffer()); + break; + } + + default: + break; // nothing + } + } + } + bool paste_the_end = false; // Open the paragraph for inserting the buf diff --git a/src/buffer.C b/src/buffer.C index e530479d85..0289a5da5b 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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(); diff --git a/src/factory.C b/src/factory.C index c2316ef39e..d6cbd41849 100644 --- a/src/factory.C +++ b/src/factory.C @@ -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") { diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index b6c83d3401..d384d6abab 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2003-06-03 John Levon + + * ControlGraphics.C: make file path relative for the GUI, + absolute for the backend + 2003-05-24 Lars Gullik Bjønnes * ControlDocument.C (saveAsDefault): adjust diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index 5134683f4e..d94cad7090 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -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)); } diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C index 8f83e0f1dd..3b96980c82 100644 --- a/src/frontends/controllers/ControlTabular.C +++ b/src/frontends/controllers/ControlTabular.C @@ -18,7 +18,6 @@ #include "support/LAssert.h" - ControlTabular::ControlTabular(Dialog & parent) : Dialog::Controller(parent), active_cell_(-1) {} diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b10aa5479f..955ec9f2ee 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,42 @@ +2003-06-03 John Levon + + * 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 diff --git a/src/insets/inset.h b/src/insets/inset.h index 1bdf567751..edd4d01fff 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -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; diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 42e31a999e..24da31f2d5 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -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) { diff --git a/src/insets/insetbibitem.h b/src/insets/insetbibitem.h index 637cd11f33..03a6406883 100644 --- a/src/insets/insetbibitem.h +++ b/src/insets/insetbibitem.h @@ -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, diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index 247c74a351..e618f43b4a 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -27,7 +27,7 @@ public: /// ~InsetBibtex(); /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetBibtex(params()); } /// small wrapper for the time being diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 2be5f686e2..5618e282b9 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -25,7 +25,7 @@ public: /// ~InsetCitation(); /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetCitation(params()); } /// diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index beb3ce9af3..9b2e873ee4 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -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; diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index be3015e65b..a3e14b818a 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -33,6 +33,8 @@ public: explicit InsetCommand(InsetCommandParams const &); /// + InsetCommand(InsetCommand const &); + /// void write(Buffer const *, std::ostream & os) const { p_.write(os); } /// diff --git a/src/insets/insetenv.C b/src/insets/insetenv.C index 7a5215af55..1158b1a1d0 100644 --- a/src/insets/insetenv.C +++ b/src/insets/insetenv.C @@ -40,7 +40,7 @@ InsetEnvironment::InsetEnvironment(InsetEnvironment const & in) {} -Inset * InsetEnvironment::clone(Buffer const &) const +Inset * InsetEnvironment::clone() const { return new InsetEnvironment(*this); } diff --git a/src/insets/insetenv.h b/src/insets/insetenv.h index fab8a56fd1..248f92107e 100644 --- a/src/insets/insetenv.h +++ b/src/insets/insetenv.h @@ -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; } /// diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index d5d951c4e3..bbc787631d 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -54,7 +54,7 @@ public: /// EDITABLE editable() const { return IS_EDITABLE; } /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetError(contents); } /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index a2c2d0478a..f7c10d35b3 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -70,7 +70,7 @@ InsetERT::InsetERT(InsetERT const & in) } -Inset * InsetERT::clone(Buffer const &) const +Inset * InsetERT::clone() const { return new InsetERT(*this); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 377d0ffc4f..7d793bd95e 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -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); diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 1e0f3f954f..1df86d5b7a 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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_; diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 6b0d2cd320..c4287f31c9 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -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; diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 7e08132ef4..e4b7c9944f 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -259,7 +259,7 @@ void InsetFloat::validate(LaTeXFeatures & features) const } -Inset * InsetFloat::clone(Buffer const &) const +Inset * InsetFloat::clone() const { return new InsetFloat(*this); } diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 6f8e341256..2b83382bc3 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -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; } /// diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index 52bedb6d29..ab0177cc43 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -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; diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index 857d5c0726..e53a1db876 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -46,7 +46,7 @@ InsetFoot::InsetFoot(InsetFoot const & in) } -Inset * InsetFoot::clone(Buffer const &) const +Inset * InsetFoot::clone() const { return new InsetFoot(*this); } diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h index 41410f9a94..b154412b4e 100644 --- a/src/insets/insetfoot.h +++ b/src/insets/insetfoot.h @@ -27,7 +27,7 @@ public: /// InsetFoot(InsetFoot const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// Inset::Code lyxCode() const { return Inset::FOOT_CODE; } /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 9ef8a9d0dc..01fc9f54f0 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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; - - if (!IsFileReadable(orig_file_with_path)) - return orig_file; + string orig_file = params().filename; + string const rel_file = MakeRelPath(orig_file, buf->filePath()); + + 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()); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index db6a01a29f..b67d7842b2 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -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; diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 1b8963802b..3f6a1b395b 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -49,7 +49,7 @@ InsetGraphicsParams::operator=(InsetGraphicsParams const & params) { // Are we assigning the object into itself? if (this == ¶ms) - 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; diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index edbafeb03d..93fde9aa45 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -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. diff --git a/src/insets/insethfill.h b/src/insets/insethfill.h index 77eef0a6dc..99bf805a70 100644 --- a/src/insets/insethfill.h +++ b/src/insets/insethfill.h @@ -20,7 +20,7 @@ public: /// InsetHFill(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetHFill; } /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 6863c93f11..4b93fde201 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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' diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index a81b77f447..0087799707 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -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 diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 0eac55b403..e3b4caa7fb 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -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()); } /// diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index 6edfda852d..10013a0da6 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -22,7 +22,7 @@ public: /// ~InsetLabel(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetLabel(params()); } /// diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 7ff01fe7fc..62af3e8be6 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -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; diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index c0b3dee272..707b0853f5 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -57,7 +57,7 @@ public: /// bool directWrite() const; /// - virtual Inset * clone(Buffer const &) const; + virtual Inset * clone() const; /// Inset::Code lyxCode()const; /// diff --git a/src/insets/insetmarginal.C b/src/insets/insetmarginal.C index 6e7a0ad90d..b5d140741a 100644 --- a/src/insets/insetmarginal.C +++ b/src/insets/insetmarginal.C @@ -41,7 +41,7 @@ InsetMarginal::InsetMarginal(InsetMarginal const & in) } -Inset * InsetMarginal::clone(Buffer const &) const +Inset * InsetMarginal::clone() const { return new InsetMarginal(*this); } diff --git a/src/insets/insetmarginal.h b/src/insets/insetmarginal.h index b69950d103..8414bdc2a4 100644 --- a/src/insets/insetmarginal.h +++ b/src/insets/insetmarginal.h @@ -26,7 +26,7 @@ public: /// InsetMarginal(InsetMarginal const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// Inset::Code lyxCode() const { return Inset::MARGIN_CODE; } /// diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 70440b4e5b..f7cd3b4e7b 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -93,7 +93,7 @@ InsetMinipage::InsetMinipage(InsetMinipage const & in) {} -Inset * InsetMinipage::clone(Buffer const &) const +Inset * InsetMinipage::clone() const { return new InsetMinipage(*this); } diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index 4d72d04777..9ba55571e5 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -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; /// diff --git a/src/insets/insetnewline.h b/src/insets/insetnewline.h index b2d7b13798..01597abf6d 100644 --- a/src/insets/insetnewline.h +++ b/src/insets/insetnewline.h @@ -20,7 +20,7 @@ public: InsetNewline() {} - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetNewline; } diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index 457aa1368f..0fb0fb6470 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -53,7 +53,7 @@ InsetNote::InsetNote(InsetNote const & in) } -Inset * InsetNote::clone(Buffer const &) const +Inset * InsetNote::clone() const { return new InsetNote(*this); } diff --git a/src/insets/insetnote.h b/src/insets/insetnote.h index 4b5b1d0c4a..e6bf5f4dff 100644 --- a/src/insets/insetnote.h +++ b/src/insets/insetnote.h @@ -25,7 +25,7 @@ public: /// InsetNote(InsetNote const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// string const editMessage() const; /// diff --git a/src/insets/insetoptarg.C b/src/insets/insetoptarg.C index 7a08236102..eb3268b89f 100644 --- a/src/insets/insetoptarg.C +++ b/src/insets/insetoptarg.C @@ -47,7 +47,7 @@ InsetOptArg::InsetOptArg(InsetOptArg const & in) } -Inset * InsetOptArg::clone(Buffer const &) const +Inset * InsetOptArg::clone() const { return new InsetOptArg(*this); } diff --git a/src/insets/insetoptarg.h b/src/insets/insetoptarg.h index a4999bdafd..4c3fec1306 100644 --- a/src/insets/insetoptarg.h +++ b/src/insets/insetoptarg.h @@ -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 diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 91cf57cbaa..3d7d57b42c 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -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; diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 8771546f65..b0cb73ca94 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -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; /// diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 651d9a3817..eab61a905d 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -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() diff --git a/src/insets/insetref.h b/src/insets/insetref.h index ce78a712f8..41ac981dad 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -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); diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C index ec1192d4d3..0ec7e91347 100644 --- a/src/insets/insetspace.C +++ b/src/insets/insetspace.C @@ -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; diff --git a/src/insets/insetspace.h b/src/insets/insetspace.h index f616ab7dad..8ff805ea3d 100644 --- a/src/insets/insetspace.h +++ b/src/insets/insetspace.h @@ -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 diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 76e4023ef8..e1da4d2e37 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -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) { diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index e34505cbf8..6fe2ecc4ec 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -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 diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index ae9ff709b1..985ebb2728 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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) diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 5c64dd11a0..49fec77fae 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -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_; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index bdbf361b74..6f68e04604 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index f32be50b43..52f76e7e2c 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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 diff --git a/src/insets/insettheorem.C b/src/insets/insettheorem.C index a5070d8051..a121bb19a0 100644 --- a/src/insets/insettheorem.C +++ b/src/insets/insettheorem.C @@ -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) diff --git a/src/insets/insettheorem.h b/src/insets/insettheorem.h index 60ea45cee4..53ba5267c6 100644 --- a/src/insets/insettheorem.h +++ b/src/insets/insettheorem.h @@ -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; } /// diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index 443ab69762..bb3b5ca003 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -24,7 +24,7 @@ public: /// ~InsetTOC(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetTOC(params()); } /// diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 8daee16a95..e2a16a5a58 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -27,7 +27,7 @@ public: /// ~InsetUrl(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetUrl(params()); } /// diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 8e281d0c9e..a5ffa5a7ba 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -180,7 +180,7 @@ void InsetWrap::validate(LaTeXFeatures & features) const } -Inset * InsetWrap::clone(Buffer const &) const +Inset * InsetWrap::clone() const { return new InsetWrap(*this); } diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index fd01ab8533..4563725054 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -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; } /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 4e81536691..ab6c9cdafb 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2003-06-03 John Levon + + * formula.[Ch]: + * formulabase.h: + * formulamacro.[Ch]: clone() doesn't take a Buffer anymore 2003-06-02 André Pönitz diff --git a/src/mathed/formula.C b/src/mathed/formula.C index de1f5640d8..3145c20f8a 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -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); diff --git a/src/mathed/formula.h b/src/mathed/formula.h index ec6cc3871c..946bb6dde1 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -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; /// diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index afa498d3a9..8933c60275 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -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 diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index a04e1b0948..cd27204f09 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -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 "; diff --git a/src/mathed/formulamacro.h b/src/mathed/formulamacro.h index a28efe39ea..41fd9bbf6e 100644 --- a/src/mathed/formulamacro.h +++ b/src/mathed/formulamacro.h @@ -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; /// diff --git a/src/paragraph.C b/src/paragraph.C index cd53424db6..844b2b50d3 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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 = ' '; diff --git a/src/paragraph.h b/src/paragraph.h index 23df61ad70..1524217ac3 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -20,8 +20,6 @@ #include "LString.h" -#include - 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_; struct Pimpl; /// -- 2.39.2