summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-19 21:52:33 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-22 09:28:12 +0100
commit1cf55d6397418dd3cd86eae59c2f75085dbb0d51 (patch)
treed35d2dd19703a6491c7c120dde5bceeb0b6753f1 /xmloff
parent6a9f851e54f416820c61baf8caa79e4d91c8c61f (diff)
Replace "ReplacementGraphicURL" with "ReplacementGraphic" property
To transport the replacement graphic we use "ReplacementGraphicURL" property, but as it uses an GraphicObject URL it needs to be replaced. The new "ReplacementGraphic" does this with an XGraphic object as instead of the String URL. Change-Id: Iddf01c9aecb2a31a467e7b9d399495e0428d1859 Reviewed-on: https://gerrit.libreoffice.org/49993 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/shapeexport.cxx27
-rw-r--r--xmloff/source/text/txtparae.cxx23
2 files changed, 24 insertions, 26 deletions
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index b1b5ea0e1537..89a92f14229c 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2454,34 +2454,33 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
//fallback here
if( !bIsEmptyPresObj )
{
- OUString aReplacementUrl;
- xPropSet->getPropertyValue("ReplacementGraphicURL") >>= aReplacementUrl;
+ uno::Reference<graphic::XGraphic> xReplacementGraphic;
+ xPropSet->getPropertyValue("ReplacementGraphic") >>= xReplacementGraphic;
// If there is no url, then the graphic is empty
- if(!aReplacementUrl.isEmpty())
+ if (xReplacementGraphic.is())
{
- const OUString aStr = mrExport.AddEmbeddedGraphicObject(aReplacementUrl);
+ OUString aMimeType;
+ const OUString aHref = mrExport.AddEmbeddedXGraphic(xReplacementGraphic, aMimeType);
- if(!aStr.isEmpty())
+ if (aMimeType.isEmpty())
+ mrExport.GetGraphicMimeTypeFromStream(xReplacementGraphic, aMimeType);
+
+ if (!aHref.isEmpty())
{
- mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr);
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aHref);
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
}
- uno::Reference<io::XInputStream> xInputStream(
- mrExport.GetEmbeddedGraphicObjectStream(aReplacementUrl));
- OUString aMimeType(
- comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageStream(xInputStream));
if (!aMimeType.isEmpty())
- GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
- SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
+ SvXMLElementExport aElement(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
// optional office:binary-data
- mrExport.AddEmbeddedGraphicObjectAsBase64(aReplacementUrl);
-
+ mrExport.AddEmbeddedXGraphicAsBase64(xReplacementGraphic);
}
}
}
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 2cc83399191a..75a192125d16 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -1194,7 +1194,6 @@ XMLTextParagraphExport::XMLTextParagraphExport(
sGraphicFilter("GraphicFilter"),
sGraphicRotation("GraphicRotation"),
sGraphicURL("GraphicURL"),
- sReplacementGraphicURL("ReplacementGraphicURL"),
sHeight("Height"),
sHoriOrient("HoriOrient"),
sHoriOrientPosition("HoriOrientPosition"),
@@ -3107,8 +3106,8 @@ void XMLTextParagraphExport::_exportTextGraphic(
// replacement graphic for backwards compatibility, but
// only for SVG and metafiles currently
- OUString sReplacementOrigURL;
- rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL;
+ uno::Reference<graphic::XGraphic> xReplacementGraphic;
+ rPropSet->getPropertyValue("ReplacementGraphic") >>= xReplacementGraphic;
// xlink:href
OUString sOrigURL;
@@ -3159,30 +3158,30 @@ void XMLTextParagraphExport::_exportTextGraphic(
//Resolves: fdo#62461 put preferred image first above, followed by
//fallback here
- if (!sReplacementOrigURL.isEmpty())
+ if (xReplacementGraphic.is())
{
- const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL ));
+ OUString aMimeType;
+ const OUString sHref = GetExport().AddEmbeddedXGraphic(xReplacementGraphic, aMimeType);
+
+ if (aMimeType.isEmpty())
+ GetExport().GetGraphicMimeTypeFromStream(xReplacementGraphic, aMimeType);
// If there is no url, then graphic is empty
- if(!sReplacementURL.isEmpty())
+ if (!sHref.isEmpty())
{
- GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL);
+ GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sHref);
GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED);
GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD);
}
- uno::Reference<io::XInputStream> xInputStream(
- GetExport().GetEmbeddedGraphicObjectStream(sReplacementOrigURL));
- OUString aMimeType(
- comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageStream(xInputStream));
if (!aMimeType.isEmpty())
GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
// optional office:binary-data
- GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementOrigURL);
+ GetExport().AddEmbeddedXGraphicAsBase64(xReplacementGraphic);
}
// script:events