Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7335 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-07-21 21:51:17 +00:00
parent 0d4d71dfe6
commit b249c0b0bb
7 changed files with 53 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2003-07-21 Angus Leeming <leeming@lyx.org>
* factory.C (createInset): pass a
buffer_path parameter to InsetGraphicsMailer's string2params.
2003-07-21 Angus Leeming <leeming@lyx.org> 2003-07-21 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (buffer): * BufferView_pimpl.C (buffer):

View File

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

View File

@ -1,6 +1,13 @@
2003-07-21 Angus Leeming <leeming@lyx.org> 2003-07-21 Angus Leeming <leeming@lyx.org>
* ControlGraphics.C (readBB): use namespace lyx::graphics rather than grfx shortcut. * ControlGraphics.C (initialiseParams, dispatchParams): pass a
buffer_path parameter to InsetGraphicsMailer's string2params,
params2string.
2003-07-21 Angus Leeming <leeming@lyx.org>
* ControlGraphics.C (readBB): use namespace lyx::graphics rather
than grfx shortcut.
2003-07-18 Lars Gullik Bjønnes <larsbj@gullik.net> 2003-07-18 Lars Gullik Bjønnes <larsbj@gullik.net>

View File

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

View File

@ -1,3 +1,9 @@
2003-07-21 Angus Leeming <leeming@lyx.org>
* insetgraphics.[Ch] (string2params, params2string): passed a
buffer_path argument.
(view): new method.
2003-07-21 Angus Leeming <leeming@lyx.org> 2003-07-21 Angus Leeming <leeming@lyx.org>
* insetexternal.C: * insetexternal.C:

View File

@ -177,8 +177,9 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
{ {
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {
string const bufpath = cmd.view()->buffer()->filePath();
InsetGraphicsParams p; InsetGraphicsParams p;
InsetGraphicsMailer::string2params(cmd.argument, p); InsetGraphicsMailer::string2params(cmd.argument, bufpath, p);
if (!p.filename.empty()) { if (!p.filename.empty()) {
setParams(p); setParams(p);
cmd.view()->updateInset(this); cmd.view()->updateInset(this);
@ -606,6 +607,12 @@ InsetGraphicsParams const & InsetGraphics::params() const
} }
BufferView * InsetGraphics::view() const
{
return graphic_->view();
}
string const InsetGraphicsMailer::name_("graphics"); string const InsetGraphicsMailer::name_("graphics");
InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset) InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
@ -615,12 +622,16 @@ InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
string const InsetGraphicsMailer::inset2string() const string const InsetGraphicsMailer::inset2string() const
{ {
return params2string(inset_.params()); BufferView * bv = inset_.view();
if (bv)
return params2string(inset_.params(), bv->buffer()->filePath());
return string();
} }
void InsetGraphicsMailer::string2params(string const & in, void InsetGraphicsMailer::string2params(string const & in,
InsetGraphicsParams & params) string const & buffer_path,
InsetGraphicsParams & params)
{ {
params = InsetGraphicsParams(); params = InsetGraphicsParams();
@ -640,20 +651,19 @@ void InsetGraphicsMailer::string2params(string const & in,
if (lex.isOK()) { if (lex.isOK()) {
InsetGraphics inset; InsetGraphics inset;
#warning FIXME not setting bufpath is dubious inset.readInsetGraphics(lex, buffer_path);
inset.readInsetGraphics(lex, string());
params = inset.params(); params = inset.params();
} }
} }
string const string const
InsetGraphicsMailer::params2string(InsetGraphicsParams const & params) InsetGraphicsMailer::params2string(InsetGraphicsParams const & params,
string const & buffer_path)
{ {
ostringstream data; ostringstream data;
data << name_ << ' '; data << name_ << ' ';
#warning FIXME not setting bufpath is dubious params.Write(data, buffer_path);
params.Write(data, string());
data << "\\end_inset\n"; data << "\\end_inset\n";
return STRCONV(data.str()); return STRCONV(data.str());
} }

View File

@ -78,6 +78,7 @@ public:
/// Get the inset parameters, used by the GUIndependent dialog. /// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams const & params() const; InsetGraphicsParams const & params() const;
virtual BufferView * view() const;
private: private:
/// ///
friend class InsetGraphicsMailer; friend class InsetGraphicsMailer;
@ -121,9 +122,12 @@ public:
/// ///
virtual string const inset2string() const; virtual string const inset2string() const;
/// ///
static void string2params(string const &, InsetGraphicsParams &); static void string2params(string const & data,
string const & buffer_path,
InsetGraphicsParams &);
/// ///
static string const params2string(InsetGraphicsParams const &); static string const params2string(InsetGraphicsParams const &,
string const & buffer_path);
private: private:
/// ///
static string const name_; static string const name_;