Make sure that all inputed filenames are in internal style, and avoid

a bug on Windows due to an unnecessary conversion to external style.

	* src/insets/ExternalSupport.C
	(subst_path): avoid a bug in the external material inset on Windows
	by don't using external_path. The filename will be quoted and thus
	there will be no problems with forward slashes.

	* src/frontends/qt4/QGraphics.C
	* src/frontends/qt4/QExternal.C
	* src/frontends/qt4/QInclude.C:
	(Qxxx::apply): On Windows, the user could input an absolute path in
	native style by hand (without using the file dialog), so make sure
	that no backslashes can slip in by this way.

	* src/frontends/qt4/QPrefsDialog.C
	(internal_path_list, external_path_list): new wrappers for the
	corresponding functions in the os namespace.
	(PrefPaths::apply): make sure that path_prefix is stored in the
	internal style, i.e., without backslashes.
	(PrefPaths::update): make sure that path_prefix is displayed to
	the user in the native style.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16659 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2007-01-12 03:19:58 +00:00
parent 4a5f2915a7
commit 6b513c51f1
5 changed files with 31 additions and 7 deletions

View File

@ -23,6 +23,7 @@
#include "support/lstrings.h"
#include "support/convert.h"
#include "support/os.h"
#include "QExternal.h"
#include "QExternalDialog.h"
@ -45,6 +46,8 @@ using lyx::support::isStrDbl;
using lyx::support::token;
using lyx::support::trim;
using lyx::support::os::internal_path;
using std::string;
using std::vector;
using std::find;
@ -452,7 +455,7 @@ void QExternal::apply()
{
InsetExternalParams params = controller().params();
params.filename.set(fromqstr(dialog_->fileED->text()),
params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
kernel().bufferFilepath());
params.settemplate(controller().getTemplate(

View File

@ -32,6 +32,7 @@
#include "support/convert.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include <QLineEdit>
#include <QPushButton>
@ -43,6 +44,8 @@
using lyx::support::float_equal;
using lyx::support::token;
using lyx::support::os::internal_path;
#ifndef CXX_GLOBAL_CSTD
using std::floor;
#endif
@ -267,7 +270,7 @@ void QGraphics::apply()
{
InsetGraphicsParams & igp = controller().params();
igp.filename.set(fromqstr(dialog_->filename->text()),
igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
kernel().bufferFilepath());
// the bb section

View File

@ -10,6 +10,8 @@
#include <config.h>
#include "support/os.h"
#include "QIncludeDialog.h"
#include "QInclude.h"
@ -28,6 +30,8 @@
using std::string;
using lyx::support::os::internal_path;
namespace lyx {
namespace frontend {
@ -99,7 +103,7 @@ void QInclude::apply()
{
InsetCommandParams params = controller().params();
params["filename"] = qstring_to_ucs4(dialog_->filenameED->text());
params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
params.preview(dialog_->previewCB->isChecked());
int const item = dialog_->typeCO->currentIndex();

View File

@ -170,11 +170,23 @@ QString const external_path(string const & input)
}
QString const external_path_list(string const & input)
{
return toqstr(lyx::support::os::external_path_list(input));
}
string const internal_path(QString const & input)
{
return lyx::support::os::internal_path(fromqstr(input));
}
string const internal_path_list(QString const & input)
{
return lyx::support::os::internal_path_list(fromqstr(input));
}
} // end namespace anon
@ -684,7 +696,7 @@ void PrefPaths::apply(LyXRC & rc) const
rc.template_path = internal_path(templateDirED->text());
rc.backupdir_path = internal_path(backupDirED->text());
rc.tempdir_path = internal_path(tempDirED->text());
rc.path_prefix = fromqstr(pathPrefixED->text());
rc.path_prefix = internal_path_list(pathPrefixED->text());
// FIXME: should be a checkbox only
rc.lyxpipes = internal_path(lyxserverDirED->text());
}
@ -696,7 +708,7 @@ void PrefPaths::update(LyXRC const & rc)
templateDirED->setText(external_path(rc.template_path));
backupDirED->setText(external_path(rc.backupdir_path));
tempDirED->setText(external_path(rc.tempdir_path));
pathPrefixED->setText(toqstr(rc.path_prefix));
pathPrefixED->setText(external_path_list(rc.path_prefix));
// FIXME: should be a checkbox only
lyxserverDirED->setText(external_path(rc.lyxpipes));
}

View File

@ -67,9 +67,11 @@ string const subst_path(string const & input,
{
if (input.find(placeholder) == string::npos)
return input;
// Don't use external_path here when use_latex_path is false, as the
// path will be compared with another one in internal style later
// in Converters::move.
string const path2 = use_latex_path ?
support::latex_path(path, ext, dots) :
support::os::external_path(path);
support::latex_path(path, ext, dots) : path;
return support::subst(input, placeholder, path2);
}