[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - comphelper/source xmloff/source
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Mon Jan 15 09:03:53 UTC 2018
comphelper/source/misc/graphicmimetype.cxx | 8 ++---
xmloff/source/core/xmlmultiimagehelper.cxx | 41 +++++++++++++++++++++--------
2 files changed, 35 insertions(+), 14 deletions(-)
New commits:
commit cbd6cd2fd24d72557957ad04eec75dc242d15e04
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Fri Jan 12 17:32:41 2018 +0100
tdf#114488 Rank multiple images also for flat odf
Only the file extension was considered before
which is not available in flat odf.
Now both internal and external URLs are resolved to their respective mimetype.
(cherry picked from commit 8a16c2a9a03c9fdf997a71caf9d8c675da4a46f2)
Change-Id: Id7e290cd9a441a1a6c2ce5e8d764391c50495bea
diff --git a/comphelper/source/misc/graphicmimetype.cxx b/comphelper/source/misc/graphicmimetype.cxx
index bf88312304b1..559c3087a2da 100644
--- a/comphelper/source/misc/graphicmimetype.cxx
+++ b/comphelper/source/misc/graphicmimetype.cxx
@@ -19,12 +19,12 @@
#include <comphelper/graphicmimetype.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/processfactory.hxx>
@@ -48,8 +48,8 @@ OUString GraphicMimeTypeHelper::GetMimeTypeForExtension(const OString& rExt)
static const XMLGraphicMimeTypeMapper aMapper[]
= { { "gif", "image/gif" }, { "png", "image/png" }, { "jpg", "image/jpeg" },
{ "tif", "image/tiff" }, { "svg", "image/svg+xml" }, { "pdf", "application/pdf" },
- { "wmf", "image/x-wmf" }, { "eps", "image/x-eps" }, { "bmp", "image/bmp" },
- { "pct", "image/x-pict" } };
+ { "wmf", "image/x-wmf" }, { "emf", "image/x-emf" }, { "eps", "image/x-eps" },
+ { "bmp", "image/bmp" }, { "pct", "image/x-pict" }, { "svm", "image/x-svm" } };
OUString aMimeType;
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index 9c70c0759ba8..a525831e88a9 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -20,51 +20,72 @@
#include <xmloff/xmlmultiimagehelper.hxx>
#include <rtl/ustring.hxx>
+#include <comphelper/graphicmimetype.hxx>
+
using namespace ::com::sun::star;
namespace
{
sal_uInt32 getQualityIndex(const OUString& rString)
{
- sal_uInt32 nRetval(0);
+ OUString sMimeType;
+ if (rString.startsWith("vnd.sun.star.GraphicObject"))
+ {
+ sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageUrl(rString);
+ }
+ else if (rString.startsWith("vnd.sun.star.Package"))
+ {
+ sMimeType
+ = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(OUStringToOString(
+ rString.copy(rString.lastIndexOf(".") + 1), RTL_TEXTENCODING_ASCII_US));
+ }
+ else
+ {
+ SAL_WARN("xmloff", "Unknown image source: " << rString);
+ return 0;
+ }
// pixel formats first
- if(rString.endsWith(".bmp"))
+ if(sMimeType == "image/bmp")
{
return 10;
}
- if(rString.endsWith(".gif"))
+ if(sMimeType == "image/gif")
{
return 20;
}
- if(rString.endsWith(".jpg"))
+ if(sMimeType == "image/jpeg")
{
return 30;
}
- if(rString.endsWith(".png"))
+ if(sMimeType == "image/png")
{
return 40;
}
// vector formats, prefer always
- if(rString.endsWith(".svm"))
+ if(sMimeType == "image/x-svm")
{
return 1000;
}
- if(rString.endsWith(".wmf"))
+ if(sMimeType == "image/x-wmf")
{
return 1010;
}
- if(rString.endsWith(".emf"))
+ if(sMimeType == "image/x-emf")
{
return 1020;
}
- if(rString.endsWith(".svg"))
+ if(sMimeType == "application/pdf")
{
return 1030;
}
+ if(sMimeType == "image/svg+xml")
+ {
+ return 1040;
+ }
- return nRetval;
+ return 0;
}
}
More information about the Libreoffice-commits
mailing list