On Tue, Jun 03, 2003 at 01:23:03AM +0200, Lars Gullik Bj?nnes wrote: > patch
and this one uses ParIterator based on Lars'. It seems to work OK, so I'll commit it soon... regards john Index: CutAndPaste.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v retrieving revision 1.99 diff -u -p -r1.99 CutAndPaste.C --- CutAndPaste.C 21 May 2003 21:20:48 -0000 1.99 +++ CutAndPaste.C 2 Jun 2003 23:56:08 -0000 @@ -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(ParagraphLis // 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 Index: buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.476 diff -u -p -r1.476 buffer.C --- buffer.C 2 Jun 2003 14:02:58 -0000 1.476 +++ buffer.C 2 Jun 2003 23:56:10 -0000 @@ -369,7 +369,6 @@ int Buffer::readParagraph(LyXLex & lex, lex.pushToken(token); Paragraph par; - par.owningBuffer(*this); par.params().depth(depth); if (params.tracking_changes) par.trackChanges(); Index: factory.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/factory.C,v retrieving revision 1.31 diff -u -p -r1.31 factory.C --- factory.C 2 Jun 2003 14:19:29 -0000 1.31 +++ factory.C 2 Jun 2003 23:56:11 -0000 @@ -206,8 +206,7 @@ Inset * createInset(FuncRequest const & 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") { Index: paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.279 diff -u -p -r1.279 paragraph.C --- paragraph.C 29 May 2003 11:19:50 -0000 1.279 +++ paragraph.C 2 Jun 2003 23:56:12 -0000 @@ -84,14 +84,13 @@ Paragraph::Paragraph(Paragraph const & l // 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(Buffe 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 = ' '; Index: paragraph.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v retrieving revision 1.85 diff -u -p -r1.85 paragraph.h --- paragraph.h 29 May 2003 11:19:51 -0000 1.85 +++ paragraph.h 2 Jun 2003 23:56:12 -0000 @@ -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; /// Index: frontends/controllers/ControlGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v retrieving revision 1.63 diff -u -p -r1.63 ControlGraphics.C --- frontends/controllers/ControlGraphics.C 13 May 2003 14:36:21 -0000 1.63 +++ frontends/controllers/ControlGraphics.C 2 Jun 2003 23:56:13 -0000 @@ -51,6 +51,9 @@ bool ControlGraphics::initialiseParams(s 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)); } Index: insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.98 diff -u -p -r1.98 inset.h --- insets/inset.h 2 Jun 2003 16:14:33 -0000 1.98 +++ insets/inset.h 2 Jun 2003 23:56:15 -0000 @@ -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; Index: insets/insetbibitem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibitem.C,v retrieving revision 1.14 diff -u -p -r1.14 insetbibitem.C --- insets/insetbibitem.C 28 May 2003 06:47:15 -0000 1.14 +++ insets/insetbibitem.C 2 Jun 2003 23:56:15 -0000 @@ -43,20 +43,12 @@ InsetBibitem::~InsetBibitem() } -Inset * InsetBibitem::clone(Buffer const &) const +Inset * InsetBibitem::clone() const { InsetBibitem * b = new InsetBibitem(params()); b->setCounter(counter); return b; } - - -// Inset * InsetBibitem::clone(Buffer const &, bool) const -// { -// InsetBibitem * b = new InsetBibitem(params()); -// b->setCounter(counter); -// return b; -// } dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) Index: insets/insetbibitem.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibitem.h,v retrieving revision 1.7 diff -u -p -r1.7 insetbibitem.h --- insets/insetbibitem.h 28 May 2003 23:09:14 -0000 1.7 +++ insets/insetbibitem.h 2 Jun 2003 23:56:15 -0000 @@ -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, Index: insets/insetbibtex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.h,v retrieving revision 1.9 diff -u -p -r1.9 insetbibtex.h --- insets/insetbibtex.h 28 May 2003 23:09:14 -0000 1.9 +++ insets/insetbibtex.h 2 Jun 2003 23:56:15 -0000 @@ -27,7 +27,7 @@ public: /// ~InsetBibtex(); /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetBibtex(params()); } /// small wrapper for the time being Index: insets/insetcite.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcite.h,v retrieving revision 1.33 diff -u -p -r1.33 insetcite.h --- insets/insetcite.h 28 May 2003 23:09:14 -0000 1.33 +++ insets/insetcite.h 2 Jun 2003 23:56:15 -0000 @@ -25,7 +25,7 @@ public: /// ~InsetCitation(); /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetCitation(params()); } /// Index: insets/insetcommand.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v retrieving revision 1.75 diff -u -p -r1.75 insetcommand.C --- insets/insetcommand.C 26 May 2003 09:13:53 -0000 1.75 +++ insets/insetcommand.C 2 Jun 2003 23:56:15 -0000 @@ -31,9 +31,10 @@ InsetCommand::InsetCommand(InsetCommandP {} -// 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 * dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) { - lyxerr << "InsetCommand::localDispatch: " << cmd.action << "\n"; switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetCommandParams p; Index: insets/insetcommand.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.h,v retrieving revision 1.63 diff -u -p -r1.63 insetcommand.h --- insets/insetcommand.h 28 May 2003 23:09:14 -0000 1.63 +++ insets/insetcommand.h 2 Jun 2003 23:56:15 -0000 @@ -33,6 +33,8 @@ public: explicit InsetCommand(InsetCommandParams const &); /// + InsetCommand(InsetCommand const &); + /// void write(Buffer const *, std::ostream & os) const { p_.write(os); } /// Index: insets/insetenv.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetenv.C,v retrieving revision 1.10 diff -u -p -r1.10 insetenv.C --- insets/insetenv.C 28 May 2003 23:09:14 -0000 1.10 +++ insets/insetenv.C 2 Jun 2003 23:56:15 -0000 @@ -40,7 +40,7 @@ InsetEnvironment::InsetEnvironment(Inset {} -Inset * InsetEnvironment::clone(Buffer const &) const +Inset * InsetEnvironment::clone() const { return new InsetEnvironment(*this); } Index: insets/insetenv.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetenv.h,v retrieving revision 1.8 diff -u -p -r1.8 insetenv.h --- insets/insetenv.h 28 May 2003 23:09:14 -0000 1.8 +++ insets/insetenv.h 2 Jun 2003 23:56:15 -0000 @@ -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; } /// Index: insets/inseterror.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inseterror.h,v retrieving revision 1.60 diff -u -p -r1.60 inseterror.h --- insets/inseterror.h 2 Jun 2003 10:03:22 -0000 1.60 +++ insets/inseterror.h 2 Jun 2003 23:56:16 -0000 @@ -54,7 +54,7 @@ public: /// EDITABLE editable() const { return IS_EDITABLE; } /// - Inset * clone(Buffer const &) const { + Inset * clone() const { return new InsetError(contents); } /// Index: insets/insetert.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v retrieving revision 1.128 diff -u -p -r1.128 insetert.C --- insets/insetert.C 2 Jun 2003 10:03:22 -0000 1.128 +++ insets/insetert.C 2 Jun 2003 23:56:16 -0000 @@ -70,7 +70,7 @@ InsetERT::InsetERT(InsetERT const & in) } -Inset * InsetERT::clone(Buffer const &) const +Inset * InsetERT::clone() const { return new InsetERT(*this); } Index: insets/insetert.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v retrieving revision 1.74 diff -u -p -r1.74 insetert.h --- insets/insetert.h 2 Jun 2003 10:03:22 -0000 1.74 +++ insets/insetert.h 2 Jun 2003 23:56:16 -0000 @@ -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); Index: insets/insetexternal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v retrieving revision 1.73 diff -u -p -r1.73 insetexternal.C --- insets/insetexternal.C 28 May 2003 23:09:14 -0000 1.73 +++ insets/insetexternal.C 2 Jun 2003 23:56:17 -0000 @@ -223,7 +223,7 @@ void InsetExternal::validate(LaTeXFeatur } -Inset * InsetExternal::clone(Buffer const &) const +Inset * InsetExternal::clone() const { InsetExternal * inset = new InsetExternal; inset->params_ = params_; Index: insets/insetexternal.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.h,v retrieving revision 1.35 diff -u -p -r1.35 insetexternal.h --- insets/insetexternal.h 28 May 2003 23:09:14 -0000 1.35 +++ insets/insetexternal.h 2 Jun 2003 23:56:17 -0000 @@ -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; Index: insets/insetfloat.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloat.C,v retrieving revision 1.81 diff -u -p -r1.81 insetfloat.C --- insets/insetfloat.C 28 May 2003 23:09:14 -0000 1.81 +++ insets/insetfloat.C 2 Jun 2003 23:56:17 -0000 @@ -259,7 +259,7 @@ void InsetFloat::validate(LaTeXFeatures } -Inset * InsetFloat::clone(Buffer const &) const +Inset * InsetFloat::clone() const { return new InsetFloat(*this); } Index: insets/insetfloat.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloat.h,v retrieving revision 1.43 diff -u -p -r1.43 insetfloat.h --- insets/insetfloat.h 28 May 2003 23:09:14 -0000 1.43 +++ insets/insetfloat.h 2 Jun 2003 23:56:17 -0000 @@ -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; } /// Index: insets/insetfloatlist.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.h,v retrieving revision 1.22 diff -u -p -r1.22 insetfloatlist.h --- insets/insetfloatlist.h 26 May 2003 09:13:53 -0000 1.22 +++ insets/insetfloatlist.h 2 Jun 2003 23:56:17 -0000 @@ -26,13 +26,9 @@ 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); /// Index: insets/insetfoot.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfoot.C,v retrieving revision 1.58 diff -u -p -r1.58 insetfoot.C --- insets/insetfoot.C 28 May 2003 23:09:14 -0000 1.58 +++ insets/insetfoot.C 2 Jun 2003 23:56:17 -0000 @@ -46,7 +46,7 @@ InsetFoot::InsetFoot(InsetFoot const & i } -Inset * InsetFoot::clone(Buffer const &) const +Inset * InsetFoot::clone() const { return new InsetFoot(*this); } Index: insets/insetfoot.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfoot.h,v retrieving revision 1.40 diff -u -p -r1.40 insetfoot.h --- insets/insetfoot.h 28 May 2003 23:09:14 -0000 1.40 +++ insets/insetfoot.h 2 Jun 2003 23:56:17 -0000 @@ -27,7 +27,7 @@ public: /// InsetFoot(InsetFoot const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// Inset::Code lyxCode() const { return Inset::FOOT_CODE; } /// Index: insets/insetgraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.179 diff -u -p -r1.179 insetgraphics.C --- insets/insetgraphics.C 2 Jun 2003 10:03:22 -0000 1.179 +++ insets/insetgraphics.C 2 Jun 2003 23:56:18 -0000 @@ -182,7 +182,7 @@ void InsetGraphics::Cache::update(string 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::localDisp 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,34 +327,15 @@ 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; - Dimension dim; - MetricsInfo mi; - mi.base.bv = pi.base.bv; - mi.base.font = pi.base.font; - metrics(mi, dim); - dim_ = dim; - // we may have changed while someone other was drawing us so better // to not draw anything as we surely call to redraw ourself soon. // This is not a nice thing to do and should be fixed properly somehow. // But I still don't know the best way to go. So let's do this like this // for now (Jug 20020311) - if (dim.asc != oasc) + if (dim_.asc != oasc) return; // Make sure now that x is updated upon exit from this routine @@ -407,10 +388,10 @@ Inset::EDITABLE InsetGraphics::editable( } -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()); } @@ -419,15 +400,15 @@ void InsetGraphics::read(Buffer const * 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; @@ -454,7 +435,7 @@ void InsetGraphics::readInsetGraphics(Ly // 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; } @@ -517,17 +498,13 @@ string const InsetGraphics::prepareFile( { // 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 @@ -535,9 +512,9 @@ string const InsetGraphics::prepareFile( 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. @@ -558,22 +535,21 @@ string const InsetGraphics::prepareFile( 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'; @@ -583,8 +559,8 @@ string const InsetGraphics::prepareFile( // 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 @@ -599,13 +575,13 @@ string const InsetGraphics::prepareFile( // 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); @@ -616,14 +592,14 @@ string const InsetGraphics::prepareFile( // 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; } @@ -679,9 +655,12 @@ int InsetGraphics::latex(Buffer const * << "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 @@ -725,7 +704,7 @@ int InsetGraphics::latex(Buffer const * // "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; } @@ -734,7 +713,7 @@ int InsetGraphics::latex(Buffer const * // 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. @@ -797,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()) @@ -808,7 +786,7 @@ bool InsetGraphics::setParams(InsetGraph 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; @@ -855,7 +833,8 @@ void InsetGraphicsMailer::string2params( if (lex.isOK()) { InsetGraphics inset; - inset.readInsetGraphics(lex); +#warning FIXME not setting bufpath is dubious + inset.readInsetGraphics(lex, string()); params = inset.params(); } } @@ -866,7 +845,8 @@ InsetGraphicsMailer::params2string(Inset { 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()); } Index: insets/insetgraphics.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.h,v retrieving revision 1.70 diff -u -p -r1.70 insetgraphics.h --- insets/insetgraphics.h 2 Jun 2003 10:03:22 -0000 1.70 +++ insets/insetgraphics.h 2 Jun 2003 23:56:18 -0000 @@ -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; Index: insets/insetgraphicsParams.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphicsParams.C,v retrieving revision 1.58 diff -u -p -r1.58 insetgraphicsParams.C --- insets/insetgraphicsParams.C 19 May 2003 17:03:08 -0000 1.58 +++ insets/insetgraphicsParams.C 2 Jun 2003 23:56:19 -0000 @@ -49,7 +49,7 @@ InsetGraphicsParams::operator=(InsetGrap { // 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 cons } -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 } -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,15 +254,12 @@ bool InsetGraphicsParams::Read(LyXLex & } -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; Index: insets/insetgraphicsParams.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphicsParams.h,v retrieving revision 1.31 diff -u -p -r1.31 insetgraphicsParams.h --- insets/insetgraphicsParams.h 25 Feb 2003 12:32:48 -0000 1.31 +++ insets/insetgraphicsParams.h 2 Jun 2003 23:56:19 -0000 @@ -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. Index: insets/insethfill.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insethfill.h,v retrieving revision 1.8 diff -u -p -r1.8 insethfill.h --- insets/insethfill.h 28 May 2003 23:09:14 -0000 1.8 +++ insets/insethfill.h 2 Jun 2003 23:56:19 -0000 @@ -20,7 +20,7 @@ public: /// InsetHFill(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetHFill; } /// Index: insets/insetinclude.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v retrieving revision 1.120 diff -u -p -r1.120 insetinclude.C --- insets/insetinclude.C 2 Jun 2003 10:03:22 -0000 1.120 +++ insets/insetinclude.C 2 Jun 2003 23:56:20 -0000 @@ -192,22 +192,14 @@ 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 Index: insets/insetinclude.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.h,v retrieving revision 1.68 diff -u -p -r1.68 insetinclude.h --- insets/insetinclude.h 2 Jun 2003 10:03:22 -0000 1.68 +++ insets/insetinclude.h 2 Jun 2003 23:56:20 -0000 @@ -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 Index: insets/insetindex.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.h,v retrieving revision 1.36 diff -u -p -r1.36 insetindex.h --- insets/insetindex.h 28 May 2003 23:09:14 -0000 1.36 +++ insets/insetindex.h 2 Jun 2003 23:56:20 -0000 @@ -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()); } /// Index: insets/insetlabel.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlabel.h,v retrieving revision 1.45 diff -u -p -r1.45 insetlabel.h --- insets/insetlabel.h 28 May 2003 23:09:14 -0000 1.45 +++ insets/insetlabel.h 2 Jun 2003 23:56:20 -0000 @@ -22,7 +22,7 @@ public: /// ~InsetLabel(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetLabel(params()); } /// Index: insets/insetlatexaccent.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.C,v retrieving revision 1.70 diff -u -p -r1.70 insetlatexaccent.C --- insets/insetlatexaccent.C 2 Jun 2003 10:03:22 -0000 1.70 +++ insets/insetlatexaccent.C 2 Jun 2003 23:56:20 -0000 @@ -654,16 +647,10 @@ bool InsetLatexAccent::directWrite() con } -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 Index: insets/insetlatexaccent.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.h,v retrieving revision 1.51 diff -u -p -r1.51 insetlatexaccent.h --- insets/insetlatexaccent.h 2 Jun 2003 10:03:22 -0000 1.51 +++ insets/insetlatexaccent.h 2 Jun 2003 23:56:20 -0000 @@ -57,7 +57,7 @@ public: /// bool directWrite() const; /// - virtual Inset * clone(Buffer const &) const; + virtual Inset * clone() const; /// Inset::Code lyxCode()const; /// Index: insets/insetmarginal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetmarginal.C,v retrieving revision 1.27 diff -u -p -r1.27 insetmarginal.C --- insets/insetmarginal.C 28 May 2003 23:09:14 -0000 1.27 +++ insets/insetmarginal.C 2 Jun 2003 23:56:20 -0000 @@ -41,7 +41,7 @@ InsetMarginal::InsetMarginal(InsetMargin } -Inset * InsetMarginal::clone(Buffer const &) const +Inset * InsetMarginal::clone() const { return new InsetMarginal(*this); } Index: insets/insetmarginal.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetmarginal.h,v retrieving revision 1.22 diff -u -p -r1.22 insetmarginal.h --- insets/insetmarginal.h 28 May 2003 23:09:14 -0000 1.22 +++ insets/insetmarginal.h 2 Jun 2003 23:56:20 -0000 @@ -26,7 +26,7 @@ public: /// InsetMarginal(InsetMarginal const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// Inset::Code lyxCode() const { return Inset::MARGIN_CODE; } /// Index: insets/insetminipage.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.C,v retrieving revision 1.76 diff -u -p -r1.76 insetminipage.C --- insets/insetminipage.C 2 Jun 2003 10:03:22 -0000 1.76 +++ insets/insetminipage.C 2 Jun 2003 23:56:21 -0000 @@ -93,7 +93,7 @@ InsetMinipage::InsetMinipage(InsetMinipa {} -Inset * InsetMinipage::clone(Buffer const &) const +Inset * InsetMinipage::clone() const { return new InsetMinipage(*this); } Index: insets/insetminipage.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.h,v retrieving revision 1.44 diff -u -p -r1.44 insetminipage.h --- insets/insetminipage.h 2 Jun 2003 10:03:22 -0000 1.44 +++ insets/insetminipage.h 2 Jun 2003 23:56:21 -0000 @@ -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; /// Index: insets/insetnewline.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnewline.h,v retrieving revision 1.10 diff -u -p -r1.10 insetnewline.h --- insets/insetnewline.h 2 Jun 2003 10:03:22 -0000 1.10 +++ insets/insetnewline.h 2 Jun 2003 23:56:21 -0000 @@ -20,7 +20,7 @@ public: InsetNewline() {} - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetNewline; } Index: insets/insetnote.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.C,v retrieving revision 1.24 diff -u -p -r1.24 insetnote.C --- insets/insetnote.C 28 May 2003 23:09:14 -0000 1.24 +++ insets/insetnote.C 2 Jun 2003 23:56:21 -0000 @@ -53,7 +53,7 @@ InsetNote::InsetNote(InsetNote const & i } -Inset * InsetNote::clone(Buffer const &) const +Inset * InsetNote::clone() const { return new InsetNote(*this); } Index: insets/insetnote.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.h,v retrieving revision 1.20 diff -u -p -r1.20 insetnote.h --- insets/insetnote.h 28 May 2003 23:09:14 -0000 1.20 +++ insets/insetnote.h 2 Jun 2003 23:56:21 -0000 @@ -25,7 +25,7 @@ public: /// InsetNote(InsetNote const &); /// - Inset * clone(Buffer const &) const; + Inset * clone() const; /// string const editMessage() const; /// Index: insets/insetoptarg.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetoptarg.C,v retrieving revision 1.10 diff -u -p -r1.10 insetoptarg.C --- insets/insetoptarg.C 28 May 2003 23:09:14 -0000 1.10 +++ insets/insetoptarg.C 2 Jun 2003 23:56:21 -0000 @@ -47,7 +47,7 @@ InsetOptArg::InsetOptArg(InsetOptArg con } -Inset * InsetOptArg::clone(Buffer const &) const +Inset * InsetOptArg::clone() const { return new InsetOptArg(*this); } Index: insets/insetoptarg.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetoptarg.h,v retrieving revision 1.11 diff -u -p -r1.11 insetoptarg.h --- insets/insetoptarg.h 28 May 2003 23:09:14 -0000 1.11 +++ insets/insetoptarg.h 2 Jun 2003 23:56:21 -0000 @@ -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 Index: insets/insetquotes.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.C,v retrieving revision 1.92 diff -u -p -r1.92 insetquotes.C --- insets/insetquotes.C 2 Jun 2003 10:03:22 -0000 1.92 +++ insets/insetquotes.C 2 Jun 2003 23:56:21 -0000 @@ -351,16 +351,10 @@ void InsetQuotes::validate(LaTeXFeatures } -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 Index: insets/insetquotes.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.h,v retrieving revision 1.50 diff -u -p -r1.50 insetquotes.h --- insets/insetquotes.h 2 Jun 2003 10:03:22 -0000 1.50 +++ insets/insetquotes.h 2 Jun 2003 23:56:21 -0000 @@ -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; /// Index: insets/insetref.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetref.C,v retrieving revision 1.65 diff -u -p -r1.65 insetref.C --- insets/insetref.C 28 May 2003 16:36:54 -0000 1.65 +++ insets/insetref.C 2 Jun 2003 23:56:22 -0000 @@ -28,9 +28,10 @@ InsetRef::InsetRef(InsetCommandParams co {} -// 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() Index: insets/insetref.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetref.h,v retrieving revision 1.48 diff -u -p -r1.48 insetref.h --- insets/insetref.h 28 May 2003 23:09:14 -0000 1.48 +++ insets/insetref.h 2 Jun 2003 23:56:22 -0000 @@ -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); Index: insets/insetspace.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspace.C,v retrieving revision 1.9 diff -u -p -r1.9 insetspace.C --- insets/insetspace.C 2 Jun 2003 10:03:22 -0000 1.9 +++ insets/insetspace.C 2 Jun 2003 23:56:22 -0000 @@ -252,16 +252,10 @@ int InsetSpace::docbook(Buffer 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 Index: insets/insetspace.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspace.h,v retrieving revision 1.9 diff -u -p -r1.9 insetspace.h --- insets/insetspace.h 2 Jun 2003 10:03:22 -0000 1.9 +++ insets/insetspace.h 2 Jun 2003 23:56:22 -0000 @@ -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 Index: insets/insetspecialchar.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspecialchar.C,v retrieving revision 1.69 diff -u -p -r1.69 insetspecialchar.C --- insets/insetspecialchar.C 2 Jun 2003 10:03:22 -0000 1.69 +++ insets/insetspecialchar.C 2 Jun 2003 23:56:22 -0000 @@ -238,16 +238,10 @@ int InsetSpecialChar::docbook(Buffer con } -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 Index: insets/insetspecialchar.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspecialchar.h,v retrieving revision 1.53 diff -u -p -r1.53 insetspecialchar.h --- insets/insetspecialchar.h 2 Jun 2003 10:03:22 -0000 1.53 +++ insets/insetspecialchar.h 2 Jun 2003 23:56:22 -0000 @@ -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 Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.284 diff -u -p -r1.284 insettabular.C --- insets/insettabular.C 2 Jun 2003 16:40:38 -0000 1.284 +++ insets/insettabular.C 2 Jun 2003 23:56:25 -0000 @@ -151,7 +151,7 @@ bool InsetTabular::hasPasteBuffer() cons 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 } -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(st 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(st 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) Index: insets/insettabular.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v retrieving revision 1.122 diff -u -p -r1.122 insettabular.h --- insets/insettabular.h 2 Jun 2003 10:03:23 -0000 1.122 +++ insets/insettabular.h 2 Jun 2003 23:56:26 -0000 @@ -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_; /// Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.404 diff -u -p -r1.404 insettext.C --- insets/insettext.C 2 Jun 2003 10:03:23 -0000 1.404 +++ insets/insettext.C 2 Jun 2003 23:56:28 -0000 @@ -224,7 +224,7 @@ void InsetText::clear(bool just_mark_era } -Inset * InsetText::clone(Buffer const &) const +Inset * InsetText::clone() const { return new InsetText(*this); } Index: insets/insettext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v retrieving revision 1.166 diff -u -p -r1.166 insettext.h --- insets/insettext.h 2 Jun 2003 10:03:23 -0000 1.166 +++ insets/insettext.h 2 Jun 2003 23:56:28 -0000 @@ -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 Index: insets/insettheorem.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.C,v retrieving revision 1.16 diff -u -p -r1.16 insettheorem.C --- insets/insettheorem.C 23 May 2003 08:59:47 -0000 1.16 +++ insets/insettheorem.C 2 Jun 2003 23:56:28 -0000 @@ -53,7 +53,7 @@ void InsetTheorem::write(Buffer 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) Index: insets/insettheorem.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.h,v retrieving revision 1.15 diff -u -p -r1.15 insettheorem.h --- insets/insettheorem.h 28 May 2003 23:09:16 -0000 1.15 +++ insets/insettheorem.h 2 Jun 2003 23:56:28 -0000 @@ -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; } /// Index: insets/insettoc.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.h,v retrieving revision 1.40 diff -u -p -r1.40 insettoc.h --- insets/insettoc.h 28 May 2003 23:09:16 -0000 1.40 +++ insets/insettoc.h 2 Jun 2003 23:56:28 -0000 @@ -24,7 +24,7 @@ public: /// ~InsetTOC(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetTOC(params()); } /// Index: insets/inseturl.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inseturl.h,v retrieving revision 1.54 diff -u -p -r1.54 inseturl.h --- insets/inseturl.h 28 May 2003 23:09:16 -0000 1.54 +++ insets/inseturl.h 2 Jun 2003 23:56:28 -0000 @@ -27,7 +27,7 @@ public: /// ~InsetUrl(); /// - virtual Inset * clone(Buffer const &) const { + virtual Inset * clone() const { return new InsetUrl(params()); } /// Index: insets/insetwrap.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetwrap.C,v retrieving revision 1.25 diff -u -p -r1.25 insetwrap.C --- insets/insetwrap.C 28 May 2003 23:09:16 -0000 1.25 +++ insets/insetwrap.C 2 Jun 2003 23:56:29 -0000 @@ -180,7 +180,7 @@ void InsetWrap::validate(LaTeXFeatures & } -Inset * InsetWrap::clone(Buffer const &) const +Inset * InsetWrap::clone() const { return new InsetWrap(*this); } Index: insets/insetwrap.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetwrap.h,v retrieving revision 1.13 diff -u -p -r1.13 insetwrap.h --- insets/insetwrap.h 28 May 2003 23:09:16 -0000 1.13 +++ insets/insetwrap.h 2 Jun 2003 23:56:29 -0000 @@ -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; } /// Index: mathed/formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.267 diff -u -p -r1.267 formula.C --- mathed/formula.C 2 Jun 2003 10:03:24 -0000 1.267 +++ mathed/formula.C 2 Jun 2003 23:56:29 -0000 @@ -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); Index: mathed/formula.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.h,v retrieving revision 1.88 diff -u -p -r1.88 formula.h --- mathed/formula.h 2 Jun 2003 10:03:24 -0000 1.88 +++ mathed/formula.h 2 Jun 2003 23:56:29 -0000 @@ -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; /// Index: mathed/formulabase.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.h,v retrieving revision 1.70 diff -u -p -r1.70 formulabase.h --- mathed/formulabase.h 2 Jun 2003 10:03:24 -0000 1.70 +++ mathed/formulabase.h 2 Jun 2003 23:56:29 -0000 @@ -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 Index: mathed/formulamacro.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.C,v retrieving revision 1.126 diff -u -p -r1.126 formulamacro.C --- mathed/formulamacro.C 2 Jun 2003 10:03:24 -0000 1.126 +++ mathed/formulamacro.C 2 Jun 2003 23:56:29 -0000 @@ -62,18 +62,12 @@ InsetFormulaMacro::InsetFormulaMacro(str } -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 "; Index: mathed/formulamacro.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulamacro.h,v retrieving revision 1.66 diff -u -p -r1.66 formulamacro.h --- mathed/formulamacro.h 2 Jun 2003 10:03:24 -0000 1.66 +++ mathed/formulamacro.h 2 Jun 2003 23:56:29 -0000 @@ -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; ///