+2003-07-21 Angus Leeming <leeming@lyx.org>
+
+ * ControlGraphics.C (initialiseParams, dispatchParams): no need
+ to modify the filename for reasons of 'good UI' anymore.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* ControlGraphics.C (initialiseParams, dispatchParams): pass a
InsetGraphicsParams params;
InsetGraphicsMailer::string2params(data, bufpath, params);
params_.reset(new InsetGraphicsParams(params));
- // make relative for good UI
- params_->filename = MakeRelPath(params_->filename, bufpath);
return true;
}
{
string const buffer_path = kernel().buffer()->filePath();
InsetGraphicsParams tmp_params(params());
- // core requires absolute path during runtime
- 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));
+2003-07-21 Angus Leeming <leeming@lyx.org>
+
+ * QGraphics.C (apply, update_contents):
+ changes due to the use of the FileName class to store the graphics
+ file name.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* QExternal.C (update_contents, apply):
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "insets/insetgraphicsParams.h"
+#include "buffer.h"
#include "lyxrc.h"
#include "lengthcombo.h"
#include "qt_helpers.h"
break;
}
- dialog_->filename->setText(toqstr(igp.filename));
+ string const name =
+ igp.filename.outputFilename(kernel().buffer()->filePath());
+ dialog_->filename->setText(toqstr(name));
// set the bounding box values
if (igp.bb.empty()) {
- string const bb = controller().readBB(igp.filename);
+ string const bb = controller().readBB(igp.filename.absFilename());
// the values from the file always have the bigpoint-unit bp
dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
{
InsetGraphicsParams & igp = controller().params();
- igp.filename = fromqstr(dialog_->filename->text());
+ igp.filename.set(fromqstr(dialog_->filename->text()),
+ kernel().buffer()->filePath());
// the bb section
igp.bb.erase();
+2003-07-21 Angus Leeming <leeming@lyx.org>
+
+ * FormGraphics.C (apply, update):
+ changes due to the use of the FileName class to store the graphics
+ file name.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* FormExternal.C (update, apply):
#include "Tooltips.h"
#include "xforms_helpers.h"
+#include "buffer.h"
#include "debug.h" // for lyxerr
#include "lyxrc.h" // for lyxrc.display_graphics
InsetGraphicsParams & igp = controller().params();
// the file section
- igp.filename = getString(file_->input_filename);
+ igp.filename.set(getString(file_->input_filename),
+ kernel().buffer()->filePath());
igp.lyxscale = strToInt(getString(file_->input_lyxscale));
if (igp.lyxscale == 0) {
InsetGraphicsParams & igp = controller().params();
// the file section
- fl_set_input(file_->input_filename, igp.filename.c_str());
+ string const name =
+ igp.filename.outputFilename(kernel().buffer()->filePath());
+ fl_set_input(file_->input_filename, name.c_str());
fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
switch (igp.display) {
// the bb section
// set the bounding box values, if exists. First we need the whole
// path, because the controller knows nothing about the doc-dir
- updateBB(igp.filename, igp.bb);
+ updateBB(igp.filename.absFilename(), igp.bb);
fl_set_button(bbox_->check_clip, igp.clip);
// the extra section
+2003-07-21 Angus Leeming <leeming@lyx.org>
+
+ * insetgraphicsParams.[Ch]: store the graphics file name in
+ a FileName member variable rather than a string.
+
+ * insetgraphics.[Ch]:
+ * insetgraphicsParams.[Ch]: Associated changes.
+
2003-07-21 Angus Leeming <leeming@lyx.org>
* insetgraphics.[Ch] (string2params, params2string): passed a
{
// LaTeX can cope if the graphics file doesn't exist, so just return the
// filename.
- string orig_file = params().filename;
- string const rel_file = MakeRelPath(orig_file, buf->filePath());
+ string orig_file = params().filename.absFilename();
+ string const rel_file = params().filename.relFilename(buf->filePath());
if (!IsFileReadable(orig_file)) {
lyxerr[Debug::GRAPHICS]
// just output a message about it in the latex output.
lyxerr[Debug::GRAPHICS]
<< "insetgraphics::latex: Filename = "
- << params().filename << endl;
+ << params().filename.absFilename() << endl;
- string const relative_file = MakeRelPath(params().filename, buf->filePath());
+ string const relative_file =
+ params().filename.relFilename(buf->filePath());
// A missing (e)ps-extension is no problem for LaTeX, so
// we have to test three different cases
#warning uh, but can our cache handle it ? no.
- string const file_ = params().filename;
+ string const file_ = params().filename.absFilename();
bool const file_exists =
!file_.empty() &&
(IsFileReadable(file_) || // original
// 1. Convert file to ascii using gifscii
// 2. Read ascii output file and add it to the output stream.
// at least we send the filename
- os << '<' << bformat(_("Graphics file: %1$s"), params().filename) << ">\n";
+ os << '<' << bformat(_("Graphics file: %1$s"),
+ params().filename.absFilename()) << ">\n";
return 0;
}
if (params().filename.empty())
return;
- features.includeFile(graphic_label, RemoveExtension(params().filename));
+ features.includeFile(graphic_label,
+ RemoveExtension(params().filename.absFilename()));
features.require("graphicx");
// Do not write the default values
if (!filename.empty()) {
- os << "\tfilename " << MakeRelPath(filename, bufpath) << '\n';
+ os << "\tfilename " << filename.outputFilename(bufpath) << '\n';
}
if (lyxscale != 100)
os << "\tlyxscale " << lyxscale << '\n';
{
if (token == "filename") {
lex.eatLine();
- filename = MakeAbsPath(lex.getString(), bufpath);
+ filename.set(lex.getString(), bufpath);
} else if (token == "lyxscale") {
lex.next();
lyxscale = lex.getInteger();
lyx::graphics::Params InsetGraphicsParams::as_grfxParams() const
{
lyx::graphics::Params pars;
- pars.filename = filename;
+ pars.filename = filename.absFilename();
pars.scale = lyxscale;
pars.angle = rotateAngle;
pars.bb = bb;
// Get the original Bounding Box from the file
- string const tmp = readBB_from_PSFile(filename);
+ string const tmp = readBB_from_PSFile(filename.absFilename());
lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
if (!tmp.empty()) {
unsigned int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
#include "graphics/GraphicsTypes.h"
#include "LString.h"
#include "lyxlength.h"
+#include "support/filename.h"
class LyXLex;
struct InsetGraphicsParams
{
/// Image filename.
- string filename;
+ lyx::support::FileName filename;
/// Scaling the Screen inside Lyx
unsigned int lyxscale;
/// How to display the image inside LyX
boost-inst.C \
chdir.C \
copy.C \
+ filename.C \
+ filename.h \
filetools.C \
filetools.h \
forkedcall.C \
--- /dev/null
+/**
+ * \file filename.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ */
+
+#include <config.h>
+
+#include "filename.h"
+#include "support/filetools.h"
+
+
+namespace lyx {
+namespace support {
+
+
+FileName::FileName()
+ : save_abs_path_(true)
+{}
+
+
+void FileName::set(string const & name, string const & buffer_path)
+{
+ save_abs_path_ = AbsolutePath(name);
+ name_ = save_abs_path_ ? name : MakeAbsPath(name, buffer_path);
+}
+
+
+void FileName::erase()
+{
+ name_.erase();
+}
+
+
+string const FileName::relFilename(string const & path) const
+{
+ return MakeRelPath(name_, path);
+}
+
+
+string const FileName::outputFilename(string const & buffer_path) const
+{
+ return save_abs_path_ ? name_ : MakeRelPath(name_, buffer_path);
+}
+
+
+bool operator==(FileName const & lhs, FileName const & rhs)
+{
+ return lhs.absFilename() == rhs.absFilename() &&
+ lhs.saveAbsPath() == rhs.saveAbsPath();
+}
+
+
+bool operator!=(FileName const & lhs, FileName const & rhs)
+{
+ return !(lhs == rhs);
+}
+
+} //namespace support
+} // namespace lyx
--- /dev/null
+// -*- C++-*-
+/**
+ * \file filename.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef FILENAME_H
+#define FILENAME_H
+
+#include "LString.h"
+
+
+namespace lyx {
+namespace support {
+
+
+class FileName {
+public:
+ FileName();
+
+ /** \param filename the file in question. May have either a relative
+ or an absolute path.
+ \param buffer_path if \c filename has a relative path, generate
+ the absolute path using this.
+ */
+ void set(string const & filename, string const & buffer_path);
+
+ void erase();
+ bool empty() const { return name_.empty(); }
+
+ bool saveAbsPath() const { return save_abs_path_; }
+ string const absFilename() const { return name_; }
+ string const relFilename(string const & buffer_path) const;
+ string const outputFilename(string const & buffer_path) const;
+
+private:
+ string name_;
+ bool save_abs_path_;
+};
+
+
+bool operator==(FileName const &, FileName const &);
+bool operator!=(FileName const &, FileName const &);
+
+
+} // namespace support
+} // namespace lyx
+
+#endif