From 85570cb7d60809781d71b5eafaeae656a1d7f86b Mon Sep 17 00:00:00 2001 From: Baruch Even Date: Sat, 14 Jul 2001 20:11:35 +0000 Subject: [PATCH] Added a copy c-tor by request from Lars and handled the same_id case. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2243 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 5 +++++ src/insets/insetgraphics.C | 29 +++++++++++++++-------------- src/insets/insetgraphics.h | 2 ++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6182cce4e3..81d7b0e33a 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-07-14 Baruch Even + + * insetgraphics.h: + * insetgraphics.C: Added a copy c-tor and handled the same_id case. + 2001-07-13 Angus Leeming Consistent use of Lsstream.h: diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 6b66c8a036..26a03fde9f 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -165,6 +165,17 @@ InsetGraphics::InsetGraphics() {} +InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id) + : Inset(), SigC::Object() + , cacheHandle(ig.cacheHandle) + , imageLoaded(ig.imageLoaded) +{ + setParams(ig.getParams()); + if (same_id) + id_ = ig.id_; +} + + InsetGraphics::~InsetGraphics() { // Emits the hide signal to the dialog connected (if any) @@ -555,7 +566,8 @@ int InsetGraphics::docBook(Buffer const * buf, ostream & os) const { // Change the path to be relative to the main file. string const buffer_dir = OnlyPath(buf->fileName()); - string const filename = RemoveExtension(MakeRelPath(params.filename, buffer_dir)); + string const filename = RemoveExtension( + MakeRelPath(params.filename, buffer_dir)); // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will // need to switch to MediaObject. However, for now this is sufficient and @@ -621,18 +633,7 @@ InsetGraphicsParams InsetGraphics::getParams() const } -Inset * InsetGraphics::clone(Buffer const &, bool) const +Inset * InsetGraphics::clone(Buffer const &, bool same_id) const { -#ifdef WITH_WARNINGS -#warning use the copy constructor instead. (Lgb) -#warning and then please honor the same_id flag (Jug) -#endif - InsetGraphics * newInset = new InsetGraphics; - - newInset->cacheHandle = cacheHandle; - newInset->imageLoaded = imageLoaded; - - newInset->setParams(getParams()); - - return newInset; + return new InsetGraphics(*this, same_id); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index aa9dc9d6cf..9db4f94b78 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -36,6 +36,8 @@ public: /// InsetGraphics(); /// + InsetGraphics(InsetGraphics const &, bool same_id = false); + /// ~InsetGraphics(); /// int ascent(BufferView *, LyXFont const &) const;