Anyone want to give this approval?

On 04/13/2011 12:48 PM, Richard Heck wrote:
On 04/13/2011 12:06 PM, Jean-Marc Lasgouttes wrote:
Le 13/04/2011 16:58, Richard Heck a écrit :
On 04/12/2011 12:23 PM, Richard Heck wrote:

If you export LaTeX (XeTeX), then only the .tex file for the master
gets copied to the original directory, not those for the children.
They do seem to be generated in the temp dir, just not copied.

The attached patch fixes this bug. It appears there would have been a
similar bug with export of images, so I've also fixed that and tried to
do so in a general way. OK?

Why not use the Translator<> template instead?

Updated patch.

OK?

rh


Index: src/insets/InsetGraphics.cpp
===================================================================
--- src/insets/InsetGraphics.cpp	(revision 38361)
+++ src/insets/InsetGraphics.cpp	(working copy)
@@ -611,8 +611,7 @@
 
 	FileName source_file = runparams.nice ? FileName(params().filename) : temp_file;
 	// determine the export format
-	string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
-			"latex" : "pdflatex";
+	string const tex_format = flavor2format(runparams.flavor);
 
 	// If the file is compressed and we have specified that it
 	// should not be uncompressed, then just return its name and
Index: src/insets/InsetInclude.cpp
===================================================================
--- src/insets/InsetInclude.cpp	(revision 38361)
+++ src/insets/InsetInclude.cpp	(working copy)
@@ -547,8 +547,7 @@
 	LYXERR(Debug::LATEX, "exportfile:" << exportfile);
 	LYXERR(Debug::LATEX, "writefile:" << writefile);
 
-	string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
-			"latex" : "pdflatex";
+	string const tex_format = flavor2format(runparams.flavor);
 	if (runparams.inComment || runparams.dryrun) {
 		//Don't try to load or copy the file if we're
 		//in a comment or doing a dryrun
Index: src/Format.h
===================================================================
--- src/Format.h	(revision 38361)
+++ src/Format.h	(working copy)
@@ -14,6 +14,8 @@
 
 #include "support/docstring.h"
 
+#include "OutputParams.h"
+
 #include <vector>
 
 
@@ -168,6 +170,11 @@
 	FormatList formatlist;
 };
 
+///
+std::string flavor2format(OutputParams::FLAVOR flavor);
+// Not currently used.
+// OutputParams::FLAVOR format2flavor(std::string fmt);
+
 extern Formats formats;
 
 extern Formats system_formats;
Index: src/Format.cpp
===================================================================
--- src/Format.cpp	(revision 38361)
+++ src/Format.cpp	(working copy)
@@ -21,10 +21,12 @@
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Systemcall.h"
 #include "support/textutils.h"
+#include "support/Translator.h"
 
 #include <algorithm>
 
@@ -413,8 +415,42 @@
 }
 
 
+namespace {
+typedef Translator<OutputParams::FLAVOR, string> FlavorTranslator;
 
+FlavorTranslator initFlavorTranslator() 
+{
+	FlavorTranslator f(OutputParams::LATEX, "latex");
+	f.addPair(OutputParams::LUATEX, "luatex");
+	f.addPair(OutputParams::PDFLATEX, "pdflatex");
+	f.addPair(OutputParams::XETEX, "xetex");
+	f.addPair(OutputParams::XML, "docbook-xml");
+	f.addPair(OutputParams::HTML, "xhtml");
+	f.addPair(OutputParams::TEXT, "text");
+	return f;
+}
 
+
+FlavorTranslator const & flavorTranslator()
+{
+	static FlavorTranslator translator = initFlavorTranslator();
+	return translator;
+}
+}
+
+
+std::string flavor2format(OutputParams::FLAVOR flavor)
+{
+	return flavorTranslator().find(flavor);
+}
+
+
+/* Not currently needed, but I'll leave the code in case it is.
+OutputParams::FLAVOR format2flavor(std::string fmt)
+{
+	return flavorTranslator().find(fmt);
+} */
+
 Formats formats;
 
 Formats system_formats;

Reply via email to