+2003-07-23 Angus Leeming <leeming@lyx.org>
+
+ * factory.C (createInset): pass a
+ Buffer const * parameter to InsetExternalMailer's string2params.
+
2003-07-22 John Levon <levon@movementarian.org>
* Thesaurus.h: include the right aiksaurus header
return inset;
} else if (name == "external") {
+ Buffer const * buffer = cmd.view()->buffer();
InsetExternal::Params iep;
- InsetExternalMailer::string2params(cmd.argument, iep);
+ InsetExternalMailer::string2params(cmd.argument,
+ buffer, iep);
InsetExternal * inset = new InsetExternal;
- string const fpath = cmd.view()->buffer()->filePath();
- inset->setParams(iep, fpath);
+ inset->setParams(iep);
return inset;
} else if (name == "graphics") {
+2003-07-23 Angus Leeming <leeming@lyx.org>
+
+ * QExternal.C (apply, update_contents):
+ changes due to the use of the FileName class to store the external
+ file name.
+
+ * QGraphics.C (apply, update_contents): use Kernel::bufferFilepath()
+ wrapper.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* QGraphics.C (apply, update_contents):
{
InsetExternal::Params const & params = controller().params();
- dialog_->fileED->setText(toqstr(params.filename));
+ string const name =
+ params.filename.outputFilename(kernel().bufferFilepath());
+ dialog_->fileED->setText(toqstr(name));
dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templatename));
dialog_->externalTV->setText(toqstr(helpText()));
{
InsetExternal::Params params = controller().params();
- params.filename = fromqstr(dialog_->fileED->text());
+ params.filename.set(fromqstr(dialog_->fileED->text()),
+ kernel().bufferFilepath());
params.templatename =
controller().getTemplate(dialog_->externalCO->currentItem()).lyxName;
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "insets/insetgraphicsParams.h"
-#include "buffer.h"
+#include "bufferparams.h"
#include "lyxrc.h"
#include "lengthcombo.h"
#include "qt_helpers.h"
}
string const name =
- igp.filename.outputFilename(kernel().buffer()->filePath());
+ igp.filename.outputFilename(kernel().bufferFilepath());
dialog_->filename->setText(toqstr(name));
// set the bounding box values
InsetGraphicsParams & igp = controller().params();
igp.filename.set(fromqstr(dialog_->filename->text()),
- kernel().buffer()->filePath());
+ kernel().bufferFilepath());
// the bb section
igp.bb.erase();
+2003-07-23 Angus Leeming <leeming@lyx.org>
+
+ * FormExternal.C (apply, update):
+ changes due to the use of the FileName class to store the external
+ file name.
+
+ * FormGraphics.C (apply, update): use Kernel::bufferFilepath()
+ wrapper.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* FormGraphics.C (apply, update):
{
InsetExternal::Params params = controller().params();
- params.filename = fl_get_input(dialog_->input_filename);
+ string const buffer_path = kernel().bufferFilepath();
+ params.filename.set(getString(dialog_->input_filename), buffer_path);
int const choice = fl_get_choice(dialog_->choice_template) - 1;
params.templatename = controller().getTemplate(choice).lyxName;
{
InsetExternal::Params const & params = controller().params();
- fl_set_input(dialog_->input_filename, params.filename.c_str());
+ string const buffer_path = kernel().bufferFilepath();
+ string const name = params.filename.outputFilename(buffer_path);
+ fl_set_input(dialog_->input_filename, name.c_str());
int ID = controller().getTemplateNumber(params.templatename);
if (ID < 0) ID = 0;
#include "Tooltips.h"
#include "xforms_helpers.h"
-#include "buffer.h"
#include "debug.h" // for lyxerr
#include "lyxrc.h" // for lyxrc.display_graphics
// the file section
igp.filename.set(getString(file_->input_filename),
- kernel().buffer()->filePath());
+ kernel().bufferFilepath());
igp.lyxscale = strToInt(getString(file_->input_lyxscale));
if (igp.lyxscale == 0) {
// the file section
string const name =
- igp.filename.outputFilename(kernel().buffer()->filePath());
+ igp.filename.outputFilename(kernel().bufferFilepath());
fl_set_input(file_->input_filename, name.c_str());
fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
+2003-07-23 Angus Leeming <leeming@lyx.org>
+
+ * insetexternal.[Ch]: store the external file name in a FileName
+ member variable rather than a string + associated changes.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* insetgraphicsParams.[Ch]: store the graphics file name in
}
-InsetExternal::Params const & InsetExternal::params() const
-{
- return params_;
-}
-
-
dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
{
switch (cmd.action) {
case LFUN_EXTERNAL_EDIT: {
Assert(cmd.view());
+ Buffer const * buffer = cmd.view()->buffer();
InsetExternal::Params p;
- InsetExternalMailer::string2params(cmd.argument, p);
- editExternal(p, cmd.view()->buffer());
+ InsetExternalMailer::string2params(cmd.argument, buffer, p);
+ editExternal(p, buffer);
return DISPATCHED_NOUPDATE;
}
case LFUN_INSET_MODIFY: {
Assert(cmd.view());
+ Buffer const * buffer = cmd.view()->buffer();
InsetExternal::Params p;
- InsetExternalMailer::string2params(cmd.argument, p);
- setParams(p, cmd.view()->buffer()->filePath());
+ InsetExternalMailer::string2params(cmd.argument, buffer, p);
+ setParams(p);
cmd.view()->updateInset(this);
return DISPATCHED;
}
namespace {
-lyx::graphics::Params get_grfx_params(InsetExternal::Params const & eparams,
- string const & filepath)
+lyx::graphics::Params get_grfx_params(InsetExternal::Params const & eparams)
{
lyx::graphics::Params gparams;
- if (!eparams.filename.empty()) {
- Assert(AbsolutePath(filepath));
- gparams.filename = MakeAbsPath(eparams.filename, filepath);
- }
-
+ gparams.filename = eparams.filename.absFilename();
gparams.scale = eparams.lyxscale;
gparams.display = eparams.display;
} // namespace anon
-void InsetExternal::setParams(Params const & p, string const & filepath)
+InsetExternal::Params const & InsetExternal::params() const
+{
+ return params_;
+}
+
+
+void InsetExternal::setParams(Params const & p)
{
// The stored params; what we would like to happen in an ideal world.
params_.filename = p.filename;
// We display the inset as a button by default.
bool display_button = (!getTemplatePtr(params_) ||
params_.filename.empty() ||
- filepath.empty() ||
params_.display == lyx::graphics::NoDisplay);
if (display_button) {
renderer_.reset(graphic_ptr);
}
- graphic_ptr->update(get_grfx_params(params_, filepath));
+ graphic_ptr->update(get_grfx_params(params_));
}
}
+BufferView * InsetExternal::view() const
+{
+ return renderer_->view();
+}
+
+
string const InsetExternal::editMessage() const
{
return getScreenLabel(params_);
}
-void InsetExternal::write(Buffer const *, ostream & os) const
+void InsetExternal::write(Buffer const * buffer, ostream & os) const
{
os << "External\n"
<< "\ttemplate " << params_.templatename << '\n';
if (!params_.filename.empty())
- os << "\tfilename " << params_.filename << '\n';
+ os << "\tfilename "
+ << params_.filename.outputFilename(buffer->filePath())
+ << '\n';
if (params_.display != defaultDisplayType)
os << "\tdisplay " << lyx::graphics::displayTranslator.find(params_.display)
case EX_FILENAME: {
lex.next();
string const name = lex.getString();
- params.filename = name;
+ params.filename.set(name, buffer->filePath());
break;
}
lex.popTable();
// Replace the inset's store
- string const path = buffer ? buffer->filePath() : string();
- setParams(params, path);
+ setParams(params);
lyxerr[Debug::INFO] << "InsetExternal::Read: "
- << "template: '" << params_.templatename
- << "' filename: '" << params_.filename
- << "' display: '" << params_.display
- << "' scale: '" << params_.lyxscale
- << '\'' << endl;
+ << "template: '" << params_.templatename
+ << "' filename: '" << params_.filename.absFilename()
+ << "' display: '" << params_.display
+ << "' scale: '" << params_.lyxscale
+ << '\'' << endl;
}
if (from_format.empty())
return;
- string from_file = params_.filename.empty() ?
- string() : MakeAbsPath(params_.filename, buf->filePath());
+ string from_file = params_.filename.absFilename();
if (from_format == "*") {
if (from_file.empty())
Buffer const * buffer, string const & s)
{
string result;
- string const basename = ChangeExtension(params.filename, string());
+ string const absfilename = params.filename.absFilename();
+ string const basename = ChangeExtension(absfilename, string());
string filepath;
- result = subst(s, "$$FName", params.filename);
+ result = subst(s, "$$FName", absfilename);
result = subst(result, "$$Basename", basename);
result = subst(result, "$$FPath", filepath);
result = subst(result, "$$Tempname", params.tempname);
string const InsetExternalMailer::inset2string() const
{
- return params2string(inset_.params());
+ BufferView * bv = inset_.view();
+ if (!bv)
+ return string();
+ return params2string(inset_.params(), bv->buffer());
}
void InsetExternalMailer::string2params(string const & in,
+ Buffer const * buffer,
InsetExternal::Params & params)
{
params = InsetExternal::Params();
if (lex.isOK()) {
InsetExternal inset;
- inset.read(0, lex);
+ inset.read(buffer, lex);
params = inset.params();
}
}
string const
-InsetExternalMailer::params2string(InsetExternal::Params const & params)
+InsetExternalMailer::params2string(InsetExternal::Params const & params,
+ Buffer const * buffer)
{
InsetExternal inset;
- inset.setParams(params, string());
+ inset.setParams(params);
ostringstream data;
data << name_ << ' ';
- inset.write(0, data);
+ inset.write(buffer, data);
data << "\\end_inset\n";
return STRCONV(data.str());
}
#include "inset.h"
#include "graphics/GraphicsTypes.h"
+#include "support/filename.h"
#include "LString.h"
#include <boost/scoped_ptr.hpp>
Params();
~Params();
/// the filename
- string filename;
+ lyx::support::FileName filename;
/// the current template used
string templatename;
/// The name of the tempfile used for manipulations.
///
virtual InsetBase * clone() const;
+ /// return a copy of our current params
+ Params const & params() const;
+
/// Set the inset parameters.
- virtual void setParams(Params const &, string const & filepath);
+ virtual void setParams(Params const &);
+
+ virtual BufferView * view() const;
/** update the file represented by the template.
If \param external_in_tmpdir == true, then the generated file is
void updateExternal(string const &, Buffer const *,
bool external_in_tmpdir) const;
- /// return a copy of our current params
- Params const & params() const;
-
private:
/** This method is connected to the graphics loader, so we are
* informed when the image has been loaded.
///
virtual string const inset2string() const;
///
- static void string2params(string const &, InsetExternal::Params &);
+ static void string2params(string const &, Buffer const *,
+ InsetExternal::Params &);
///
- static string const params2string(InsetExternal::Params const &);
+ static string const params2string(InsetExternal::Params const &,
+ Buffer const *);
private:
///
static string const name_;