diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-06 13:54:45 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-07 02:39:04 +0100 |
commit | f7d3fc13333774f3ada2af1c752bc8a63055a2ff (patch) | |
tree | 640a917d353d1da060e8ad5e4e39dd90c998482a /xmloff | |
parent | 27008aa028cde8d270e898c5743a9fe5c7701dab (diff) |
xmloff: remove "GraphicURL" from XMLShapeExport
Change-Id: If1967a7d87a934e2eea776bcd41b305e800f711a
Reviewed-on: https://gerrit.libreoffice.org/50790
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 98 |
1 files changed, 42 insertions, 56 deletions
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 |