]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetGraphics.cpp
Do not output deleted rows columns if show changes in output is false
[lyx.git] / src / insets / InsetGraphics.cpp
index 04edf265a87ecf7e8bef12754baf30becde15a1f..92de4c043f8f98386671fbaa541b3072aafc77e3 100644 (file)
@@ -54,6 +54,7 @@ TODO
 #include "Converter.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
+#include "Encoding.h"
 #include "ErrorList.h"
 #include "Exporter.h"
 #include "Format.h"
@@ -399,7 +400,7 @@ string InsetGraphics::createLatexOptions(bool const ps) const
                if (!params().width.zero())
                        size << "width=" << params().width.asLatexString() << ',';
                if (!params().height.zero())
-                       size << "height=" << params().height.asLatexString() << ',';
+                       size << "totalheight=" << params().height.asLatexString() << ',';
                if (params().keepAspectRatio)
                        size << "keepaspectratio,";
        }
@@ -851,7 +852,7 @@ void InsetGraphics::latex(otexstream & os,
                // We have a language that makes = active. Deactivate locally
                // for keyval option parsing (#2005).
                before = "\\begingroup\\catcode`\\=12";
-               after = "\\endgroup";
+               after = "\\endgroup ";
        }
 
        if (runparams.moving_arg)
@@ -871,8 +872,43 @@ void InsetGraphics::latex(otexstream & os,
        // Convert the file if necessary.
        // Remove the extension so LaTeX will use whatever is appropriate
        // (when there are several versions in different formats)
-       string file_path = prepareFile(runparams);
-       latex_str += file_path;
+       docstring file_path = from_utf8(prepareFile(runparams));
+       // we can only output characters covered by the current
+       // encoding!
+       docstring uncodable;
+       docstring encodable_file_path;
+       for (size_type i = 0 ; i < file_path.size() ; ++i) {
+               char_type c = file_path[i];
+               try {
+                       if (runparams.encoding->encodable(c))
+                               encodable_file_path += c;
+                       else if (runparams.dryrun) {
+                               encodable_file_path += "<" + _("LyX Warning: ")
+                                               + _("uncodable character") + " '";
+                               encodable_file_path += docstring(1, c);
+                               encodable_file_path += "'>";
+                       } else
+                               uncodable += c;
+               } catch (EncodingException & /* e */) {
+                       if (runparams.dryrun) {
+                               encodable_file_path += "<" + _("LyX Warning: ")
+                                               + _("uncodable character") + " '";
+                               encodable_file_path += docstring(1, c);
+                               encodable_file_path += "'>";
+                       } else
+                               uncodable += c;
+               }
+       }
+       if (!uncodable.empty() && !runparams.silent) {
+               // issue a warning about omitted characters
+               // FIXME: should be passed to the error dialog
+               frontend::Alert::warning(_("Uncodable character in file path"),
+                       bformat(_("The following characters in one of the graphic paths are\n"
+                                 "not representable in the current encoding and have been omitted: %1$s.\n"
+                                 "You need to adapt either the encoding or the path."),
+                       uncodable));
+       }
+       latex_str += to_utf8(encodable_file_path);
        latex_str += '}' + after;
        // FIXME UNICODE
        os << from_utf8(latex_str);
@@ -1100,6 +1136,10 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
                if (contains(rel_file, "."))
                        features.require("lyxdot");
        }
+       if (features.inDeletedInset()) {
+               features.require("tikz");
+               features.require("ct-tikz-object-sout");
+       }
 }