Il 29/07/2011 10:30, Pavel Sanda ha scritto:
So, my question: does it make sense to have these 2 separate insets ?
to me yes. spreadsheat table is no graphics material.
secondly its kind of API for people who want to develop their own external
material.
Thanks for your comments, Pavel.
If you had a look at those 2 patches (images and ext material), I had a
common need, i.e., the patch below.
Do you think it may be a safe/right one, or might it be dangerous or
have unforeseeable side effects ?
Thanks,
T.
Index: src/Format.cpp
===================================================================
--- src/Format.cpp (revisione 39372)
+++ src/Format.cpp (copia locale)
@@ -128,15 +128,25 @@
}
+/// For a zipped format, try the filename extension first, then the contents
+/// (otherwise it is always guessed as zip and we're in trouble)
string Formats::getFormatFromFile(FileName const& filename) const
{
if (filename.empty())
return string();
- string const format = filename.guessFormatFromContents();
- if (!format.empty())
- return format;
+ string const& ex = filename.extension();
+ bool zipped_format = (ex == "odg" || ex == "sxd"
+ || ex == "odt" || ex == "sxw" || ex == "docx"
+ || ex == "ods" || ex == "sxc" || ex == "xlsx"
+ || ex == "gnumeric");
+ if (!zipped_format) {
+ string const format = filename.guessFormatFromContents();
+ if (!format.empty())
+ return format;
+ }
+
// try to find a format from the file extension.
string const ext = getExtension(filename.absFileName());
if (!ext.empty()) {
@@ -151,6 +161,12 @@
return cit->name();
}
}
+
+ if (zipped_format) {
+ string const format = filename.guessFormatFromContents();
+ if (!format.empty())
+ return format;
+ }
return string();
}