X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetbibtex.C;h=73ca790e50296ee3b8f9153b26cc62cb960ae606;hb=10ba1b8918e7da14334bb5573ce2a707671c8b51;hp=feec01537bd4d7ca777faa1cd8630126e68beec3;hpb=68b7ef25fb7d2da230d3eb11d6737701abfc2e64;p=lyx.git diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index feec01537b..73ca790e50 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; @@ -60,13 +62,13 @@ InsetBibtex::InsetBibtex(InsetCommandParams const & p) {} -std::auto_ptr InsetBibtex::clone() const +std::auto_ptr InsetBibtex::doClone() const { return std::auto_ptr(new InsetBibtex(*this)); } -void InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest & cmd) +void InsetBibtex::doDispatch(LCursor & cur, FuncRequest & cmd) { switch (cmd.action) { @@ -79,7 +81,7 @@ void InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest & cmd) } default: - InsetCommand::priv_dispatch(cur, cmd); + InsetCommand::doDispatch(cur, cmd); break; } } @@ -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; }