]> git.lyx.org Git - features.git/commitdiff
Partly fix for bug 1231
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 26 Apr 2004 11:05:19 +0000 (11:05 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 26 Apr 2004 11:05:19 +0000 (11:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8696 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LaTeXFeatures.C
src/insets/ChangeLog
src/insets/insetgraphics.C
src/lyx_sty.C
src/lyx_sty.h

index a791b44d1af4fce05ca49227341b32f97d45262d..b65a681ce6d3ec407e75129e5940d9205edb41b0 100644 (file)
@@ -1,3 +1,7 @@
+2004-04-26  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * LaTeXFeatures.C, lyx_sty.[Ch]: add \lyxdot macro
+
 2003-09-24  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * output_latex.C (TeXEnvironment): make sure that there is a line
index 99bb39ee299477a1efef29bf0849b0e4ef20dae2..c19dd75417c2d1e5155000798e209b986e53d21f 100644 (file)
@@ -377,6 +377,9 @@ string const LaTeXFeatures::getMacros() const
        if (isRequired("lyxgreyedout"))
                macros << lyxgreyedout_def;
 
+       if (isRequired("lyxdot"))
+               macros << lyxdot_def << '\n';
+
        // floats
        getFloatDefinitions(macros);
 
index bbff53fa77fc11aaf572184b3abd8ac448d1a98c..3f3e4c711ddb75c6755add9e6527286a1d1ec5c0 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-26  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * insetgraphics.C (latex): strip the extension and replace dots in
+       the filename if doing a "nice" export. This is a partial fix for
+       bug 1231 without reintroducing bug 655.
+
 2004-04-19  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * insetoptarg.h: remove the editable() method (InsetCollapsable
index 2b40892f5ee8f077241397bba333ce606c5b258a..3f9f3465a3448c239c6e6fe04fdd1609fbf6f58b 100644 (file)
@@ -93,6 +93,7 @@ using lyx::support::getExtFromContents;
 using lyx::support::IsFileReadable;
 using lyx::support::LibFileSearch;
 using lyx::support::rtrim;
+using lyx::support::subst;
 using lyx::support::Systemcall;
 using lyx::support::unzipFile;
 using lyx::support::unzippedFileName;
@@ -591,7 +592,16 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
        if (runparams.nice) {
                // a relative filename should be relative to the master
                // buffer.
-               latex_str += params().filename.outputFilename(m_buffer->filePath());
+               string basename = params().filename.outputFilename(m_buffer->filePath());
+               // Remove the extension so the LaTeX will use whatever
+               // is appropriate (when there are several versions in
+               // different formats)
+               if (!(IsFileReadable(file_ + ".eps") || IsFileReadable(file_ + ".ps")))
+                       basename = RemoveExtension(basename);
+               // This works only if the filename contains no dots besides
+               // the just removed one. We can fool here by replacing all
+               // dots with a macro whose definition is just a dot ;-)
+               latex_str += subst(basename, ".", "\\lyxdot ");
        } else if (file_exists) {
                // Make the filename relative to the lyx file
                // and remove the extension so the LaTeX will use whatever
@@ -663,6 +673,17 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
 
        features.require("graphicx");
 
+       if (features.nice()) {
+               Buffer const * m_buffer = features.buffer().getMasterBuffer();
+               string basename =
+                       params().filename.outputFilename(m_buffer->filePath());
+               string const file_ = params().filename.absFilename();
+               if (!(IsFileReadable(file_ + ".eps") || IsFileReadable(file_ + ".ps")))
+                       basename = RemoveExtension(basename);
+               if (contains(basename, "."))
+                       features.require("lyxdot");
+       }
+
        if (params().subcaption)
                features.require("subfigure");
 }
index 0d754ea08d6bdfb4a640777f14ac6180b705686f..ed25658d3e06d81e16370426ba12227d57fbbafd 100644 (file)
@@ -126,3 +126,10 @@ string const tabularnewline_def =
 string const lyxgreyedout_def =
        "%% The greyedout annotation environment\n"
        "\\newenvironment{lyxgreyedout}{\\color[gray]{0.8}}{}\n";
+
+// We want to omit the file extension for includegraphics, but this does not
+// work when the filename contains other dots.
+// Idea from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=unkgrfextn
+string const lyxdot_def =
+       "%% A simple dot to overcome graphicx limitations\n"
+       "\\newcommand{\\lyxdot}{.}\n";
index d549735f5e037dccc09616bf8f3a6dac8bcc3982..79c79a2952f0d8870bb078b427ca729b926debd5 100644 (file)
@@ -52,5 +52,7 @@ extern std::string const mathcircumflex_def;
 extern std::string const tabularnewline_def;
 ///
 extern std::string const lyxgreyedout_def;
+///
+extern std::string const lyxdot_def;
 
 #endif // LYX_STY_H