From 0aea0717055a95eea07a56f37cd5842426078370 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 20 Apr 2004 12:46:15 +0000 Subject: [PATCH] another fix related to bug 605; fix toggling of optarg inset git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8685 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 10 ++++++++++ src/insets/insetbibtex.C | 36 +++++++++++++++++++++++++----------- src/insets/insetoptarg.h | 2 -- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index e1ce8478c0..bbff53fa77 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ +2004-04-19 Jean-Marc Lasgouttes + + * insetoptarg.h: remove the editable() method (InsetCollapsable + does it better already) + + * insetbibtex.C (normalize_name): new helper function. Changes the + name to be suitable to use in a latex file (relative to master + buffer if necessary). + (latex): use normalize_name. + 2004-04-20 Angus Leeming * render_preview.C (startLoading): remove lyxerr statement. diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index feec01537b..e2359daa72 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -29,6 +29,7 @@ #include +using lyx::support::AbsolutePath; using lyx::support::ascii_lowercase; using lyx::support::ChangeExtension; using lyx::support::contains; @@ -36,6 +37,7 @@ using lyx::support::findtexfile; using lyx::support::IsFileReadable; using lyx::support::ltrim; using lyx::support::MakeAbsPath; +using lyx::support::MakeRelPath; using lyx::support::Path; using lyx::support::prefixIs; using lyx::support::rtrim; @@ -91,6 +93,23 @@ string const InsetBibtex::getScreenLabel(Buffer const &) const } +namespace { + +string normalize_name(Buffer const & buffer, OutputParams const & runparams, + string const & name, string const & ext) +{ + string const fname = MakeAbsPath(name, buffer.filePath()); + if (AbsolutePath(name) || !IsFileReadable(fname + ext)) + return name; + else if (!runparams.nice) + return fname; + else + return MakeRelPath(fname, buffer.getMasterBuffer()->filePath()); +} + +} + + int InsetBibtex::latex(Buffer const & buffer, ostream & os, OutputParams const & runparams) const { @@ -113,11 +132,8 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os, // have a comma-separated list of bibliographies string db_out; while (!adb.empty()) { - if (!runparams.nice && - IsFileReadable(MakeAbsPath(adb, buffer.filePath())+".bib")) - adb = os::external_path(MakeAbsPath(adb, - buffer.filePath())); - db_out += adb; + db_out += os::external_path(normalize_name(buffer, runparams, + adb, ".bib")); db_out += ','; db_in = split(db_in, adb,','); } @@ -136,13 +152,11 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os, // line count int i = 0; - if (!runparams.nice - && IsFileReadable(MakeAbsPath(style, buffer.filePath()) + ".bst")) { - style = MakeAbsPath(style, buffer.filePath()); - } - if (!style.empty()) { - os << "\\bibliographystyle{" << style << "}\n"; + os << "\\bibliographystyle{" + << os::external_path(normalize_name(buffer, runparams, + style, ".bst")) + << "}\n"; i += 1; } diff --git a/src/insets/insetoptarg.h b/src/insets/insetoptarg.h index 60828016c2..0b2deee38b 100644 --- a/src/insets/insetoptarg.h +++ b/src/insets/insetoptarg.h @@ -27,8 +27,6 @@ public: InsetOptArg(InsetOptArg const &); /// make a duplicate of this inset virtual std::auto_ptr clone() const; - /// this inset is editable - EDITABLE editable() const { return IS_EDITABLE; } /// code of the inset InsetOld::Code lyxCode() const { return InsetOld::OPTARG_CODE; } /// return an message upon editing -- 2.39.2