summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmlmultiimagehelper.hxx1
-rw-r--r--xmloff/source/core/xmlmultiimagehelper.cxx28
-rw-r--r--xmloff/source/draw/ximpshap.cxx24
-rw-r--r--xmloff/source/draw/ximpshap.hxx3
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx12
-rw-r--r--xmloff/source/text/XMLTextFrameContext.hxx1
6 files changed, 54 insertions, 15 deletions
diff --git a/xmloff/inc/xmlmultiimagehelper.hxx b/xmloff/inc/xmlmultiimagehelper.hxx
index adfdce2e9285..b55e59324ed4 100644
--- a/xmloff/inc/xmlmultiimagehelper.hxx
+++ b/xmloff/inc/xmlmultiimagehelper.hxx
@@ -32,6 +32,7 @@ protected:
/// helper to get the created xShape instance, override this
virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) = 0;
virtual OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const = 0;
+ virtual OUString getMimeTypeFromImportContext(const SvXMLImportContext& rContext) const = 0;
virtual css::uno::Reference<css::graphic::XGraphic> getGraphicFromImportContext(const SvXMLImportContext& rContext) const = 0;
public:
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index 000c6151ee81..99e4b1f6080d 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -114,19 +114,23 @@ SvXMLImportContextRef MultiImageImportHelper::solveMultipleImages()
{
const SvXMLImportContext& rContext = *maImplContextVector[a];
-
- OUString sMimeType;
-
- const OUString aStreamURL(getGraphicPackageURLFromImportContext(rContext));
- if (!aStreamURL.isEmpty())
- {
- sMimeType = getMimeTypeForURL(aStreamURL);
- }
- else
+ // First try the mime type provided by the document
+ OUString sMimeType = getMimeTypeFromImportContext(rContext);
+ if (sMimeType.isEmpty())
{
- uno::Reference<graphic::XGraphic> xGraphic(getGraphicFromImportContext(rContext));
- if (xGraphic.is())
- sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic);
+ // Try to determine the mime type from the extension
+ const OUString aStreamURL(getGraphicPackageURLFromImportContext(rContext));
+ if (!aStreamURL.isEmpty())
+ {
+ sMimeType = getMimeTypeForURL(aStreamURL);
+ }
+ else
+ {
+ // Try to determine the mime type from the graphic itself
+ uno::Reference<graphic::XGraphic> xGraphic(getGraphicFromImportContext(rContext));
+ if (xGraphic.is())
+ sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic);
+ }
}
sal_uInt32 nNewQuality = getQualityIndex(sMimeType);
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 3961c8d546f8..aaee9668fa37 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -2368,10 +2368,18 @@ SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
// this is called from the parent group for each unparsed attribute in the attribute list
bool SdXMLGraphicObjectShapeContext::processAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
- if( aIter.getToken() == XML_ELEMENT(XLINK, XML_HREF) )
+ switch (aIter.getToken())
+ {
+ case XML_ELEMENT(XLINK, XML_HREF):
maURL = aIter.toString();
- else
- return SdXMLShapeContext::processAttribute( aIter );
+ break;
+ case XML_ELEMENT(DRAW, XML_MIME_TYPE):
+ case XML_ELEMENT(LO_EXT, XML_MIME_TYPE):
+ msMimeType = aIter.toString();
+ break;
+ default:
+ return SdXMLShapeContext::processAttribute(aIter);
+ }
return true;
}
@@ -3370,6 +3378,16 @@ uno::Reference<graphic::XGraphic> SdXMLFrameShapeContext::getGraphicFromImportCo
return xGraphic;
}
+OUString SdXMLFrameShapeContext::getMimeTypeFromImportContext(const SvXMLImportContext& rContext) const
+{
+ OUString aMimeType;
+ const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&rContext);
+
+ if (pSdXMLGraphicObjectShapeContext)
+ aMimeType = pSdXMLGraphicObjectShapeContext->getMimeType();
+ return aMimeType;
+}
+
OUString SdXMLFrameShapeContext::getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const
{
OUString aRetval;
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index 3450a16e5780..9a61f4b594de 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -390,9 +390,11 @@ class SdXMLGraphicObjectShapeContext : public SdXMLShapeContext
{
private:
OUString maURL;
+ OUString msMimeType;
css::uno::Reference < css::io::XOutputStream > mxBase64Stream;
public:
+ OUString const& getMimeType() const { return msMimeType; }
SdXMLGraphicObjectShapeContext( SvXMLImport& rImport,
const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
@@ -564,6 +566,7 @@ protected:
/// helper to get the created xShape instance, needs to be overridden
void removeGraphicFromImportContext(const SvXMLImportContext& rContext) override;
OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const override;
+ OUString getMimeTypeFromImportContext(const SvXMLImportContext& rContext) const override;
css::uno::Reference<css::graphic::XGraphic> getGraphicFromImportContext(const SvXMLImportContext& rContext) const override;
public:
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index eb49a0d77678..723a168a52b9 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -411,6 +411,7 @@ public:
const OUString& GetOrigName() const { return m_sOrigName; }
css::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
+ OUString GetMimeType() const { return sMimeType; }
const css::uno::Reference < css::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
};
@@ -768,6 +769,16 @@ void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContex
}
}
+OUString XMLTextFrameContext::getMimeTypeFromImportContext(const SvXMLImportContext& rContext) const
+{
+ const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast<const XMLTextFrameContext_Impl*>(&rContext);
+
+ if (pXMLTextFrameContext_Impl)
+ return pXMLTextFrameContext_Impl->GetMimeType();
+
+ return OUString();
+}
+
OUString XMLTextFrameContext::getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const
{
const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
@@ -1071,6 +1082,7 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
case XML_ELEMENT(DRAW, XML_MIME_TYPE):
case XML_ELEMENT(LO_EXT, XML_MIME_TYPE):
sMimeType = aIter.toString();
+ printf ("MIME %s\n", sMimeType.toUtf8().getStr());
break;
case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES):
case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE):
diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx
index 27c9b4c2b81f..4f7e01118b2c 100644
--- a/xmloff/source/text/XMLTextFrameContext.hxx
+++ b/xmloff/source/text/XMLTextFrameContext.hxx
@@ -60,6 +60,7 @@ protected:
/// helper to get the created xShape instance, needs to be overridden
void removeGraphicFromImportContext(const SvXMLImportContext& rContext) override;
OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const override;
+ OUString getMimeTypeFromImportContext(const SvXMLImportContext& rContext) const override;
css::uno::Reference<css::graphic::XGraphic> getGraphicFromImportContext(const SvXMLImportContext& rContext) const override;
public: