[Libreoffice-commits] core.git: xmloff/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Wed Mar 7 01:39:28 UTC 2018
xmloff/source/draw/shapeexport.cxx | 98 +++++++++++++++----------------------
1 file changed, 42 insertions(+), 56 deletions(-)
New commits:
commit f7d3fc13333774f3ada2af1c752bc8a63055a2ff
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Mar 6 13:54:45 2018 +0900
xmloff: remove "GraphicURL" from XMLShapeExport
Change-Id: If1967a7d87a934e2eea776bcd41b305e800f711a
Reviewed-on: https://gerrit.libreoffice.org/50790
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 89a92f14229c..e028f56e846e 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2356,56 +2356,38 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
const bool bSaveBackwardsCompatible = bool( mrExport.getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE );
- OUString sImageURL;
- uno::Reference<graphic::XGraphic> xGraphic;
-
- if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
+ if (!bIsEmptyPresObj || bSaveBackwardsCompatible)
{
- if( !bIsEmptyPresObj )
+ uno::Reference<graphic::XGraphic> xGraphic;
+ OUString sOutMimeType;
+
+ if (!bIsEmptyPresObj)
{
OUString aStreamURL;
xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL;
-
OUString sRequestedName = getNameFromStreamURL(aStreamURL);
- xPropSet->getPropertyValue("GraphicURL") >>= sImageURL;
-
- uno::Any aGraphicAny = xPropSet->getPropertyValue("Graphic");
- if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>())
- xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>();
+ xPropSet->getPropertyValue("Graphic") >>= xGraphic;
- OUString aStoredURL;
+ OUString sInternalURL;
if (xGraphic.is())
- {
- aStoredURL = mrExport.AddEmbeddedXGraphic(xGraphic, sRequestedName);
- }
- else
- {
- OUString aResolveURL(sImageURL);
- if (!sRequestedName.isEmpty())
- aResolveURL += "?requestedName=" + sRequestedName;
-
- aStoredURL = mrExport.AddEmbeddedGraphicObject(aResolveURL);
- }
-
- mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStoredURL);
+ sInternalURL = mrExport.AddEmbeddedXGraphic(xGraphic, sOutMimeType, sRequestedName);
- if (!aStoredURL.isEmpty())
+ if (!sInternalURL.isEmpty())
{
- const OUString sPackageURL("vnd.sun.star.Package:");
-
// apply possible changed stream URL to embedded image object
if (!sRequestedName.isEmpty())
{
+ const OUString sPackageURL("vnd.sun.star.Package:");
OUString newStreamURL = sPackageURL;
- if (aStoredURL[0] == '#')
+ if (sInternalURL[0] == '#')
{
- newStreamURL += aStoredURL.copy(1, aStoredURL.getLength() - 1);
+ newStreamURL += sInternalURL.copy(1, sInternalURL.getLength() - 1);
}
else
{
- newStreamURL += aStoredURL;
+ newStreamURL += sInternalURL;
}
if (newStreamURL != aStreamURL)
@@ -2414,40 +2396,44 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
}
}
- 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 );
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sInternalURL);
+ 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);
}
}
else
{
- mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, OUString() );
- 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 );
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, OUString());
+ 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);
}
{
- // We can't guess the mimetype from sImageURL because the image type might be changed
- // while creating the stream (by SvXMLGraphicInputStream). So we first need to create
- // the stream, get the mime type and then write the stream.
- uno::Reference<io::XInputStream> xInputStream(
- mrExport.GetEmbeddedGraphicObjectStream(sImageURL));
- OUString aMimeType(
- comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageStream(xInputStream));
- if (!aMimeType.isEmpty())
- GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
-
- ImpExportSignatureLine( xShape );
- SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
-
- if( !sImageURL.isEmpty() )
+ if (GetExport().getDefaultVersion() > SvtSaveOptions::ODFVER_012)
{
- // optional office:binary-data
- mrExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
+ if (sOutMimeType.isEmpty())
+ {
+ GetExport().GetGraphicMimeTypeFromStream(xGraphic, sOutMimeType);
+ }
+ if (!sOutMimeType.isEmpty())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", sOutMimeType);
+ }
}
- if( !bIsEmptyPresObj )
- ImpExportText( xShape );
+
+ ImpExportSignatureLine(xShape);
+
+ SvXMLElementExport aElement(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
+
+ // optional office:binary-data
+ if (xGraphic.is())
+ {
+ mrExport.AddEmbeddedXGraphicAsBase64(xGraphic);
+ }
+ if (!bIsEmptyPresObj)
+ ImpExportText(xShape);
}
//Resolves: fdo#62461 put preferred image first above, followed by
More information about the Libreoffice-commits
mailing list