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>
* BufferView_pimpl.C (buffer):

View File

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

View File

@ -1,6 +1,13 @@
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>

View File

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

View File

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

View File

@ -78,6 +78,7 @@ public:
/// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams const & params() const;
virtual BufferView * view() const;
private:
///
friend class InsetGraphicsMailer;
@ -121,9 +122,12 @@ public:
///
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:
///
static string const name_;