summaryrefslogtreecommitdiff
path: root/xmloff/source/draw/shapeexport.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-13 21:49:57 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-14 07:47:26 +0100
commit1b02ba03bd62a712e15c15384a3d105d2c088120 (patch)
treeb46f383c7ea60de65dbbede5b658a7babd813610 /xmloff/source/draw/shapeexport.cxx
parent733d77570771e2536d5ce1f18ba82f68ac6c22ee (diff)
shapes: don't use "GraphicURL" property, always use "Graphic"
With GraphicURL property on shapes (XShape) we transported the external or internal URL to the model, which also included the GraphicObject uniqueID style URLs. This changes that - now we always use "Graphic" property and transfer XGraphic to and from graphic filters. "Graphic" property is already present for XShape so it wasn't needed to add it. Filters changed are: OOXML (oox), ODF (xmloff), RTF and binary MS (esherex). Also start using originURL on Graphic which now transports the URL of the external (linked) graphic/image if it was created that way. Change-Id: Ic338c60b7cfaaae354cf1e1ca3ae7a6373220230 Reviewed-on: https://gerrit.libreoffice.org/49648 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff/source/draw/shapeexport.cxx')
-rw-r--r--xmloff/source/draw/shapeexport.cxx82
1 files changed, 55 insertions, 27 deletions
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 81293655dea7..b1b5ea0e1537 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2307,6 +2307,33 @@ void XMLShapeExport::ImpExportPolygonShape(
}
+namespace
+{
+
+OUString getNameFromStreamURL(OUString const & rURL)
+{
+ const OUString sPackageURL("vnd.sun.star.Package:");
+
+ OUString sResult;
+
+ if (rURL.match(sPackageURL))
+ {
+ OUString sRequestedName = rURL.copy(sPackageURL.getLength());
+ sal_Int32 nLastIndex = sRequestedName.lastIndexOf('/') + 1;
+ if ((nLastIndex > 0) && (nLastIndex < sRequestedName.getLength()))
+ sRequestedName = sRequestedName.copy(nLastIndex);
+ nLastIndex = sRequestedName.lastIndexOf('.');
+ if (nLastIndex >= 0)
+ sRequestedName = sRequestedName.copy(0, nLastIndex);
+ if (!sRequestedName.isEmpty())
+ sResult = sRequestedName;
+ }
+
+ return sResult;
+}
+
+} // end anonymous namespace
+
void XMLShapeExport::ImpExportGraphicObjectShape(
const uno::Reference< drawing::XShape >& xShape,
XmlShapeType eShapeType, XMLShapeExportFlags nFeatures, awt::Point* pRefPoint)
@@ -2320,8 +2347,6 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
// Transformation
ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
- OUString sImageURL;
-
if(eShapeType == XmlShapeTypePresGraphicObjectShape)
bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_GRAPHIC) );
@@ -2331,53 +2356,56 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
const bool bSaveBackwardsCompatible = bool( mrExport.getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE );
+ OUString sImageURL;
+ uno::Reference<graphic::XGraphic> xGraphic;
+
if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
{
if( !bIsEmptyPresObj )
{
OUString aStreamURL;
-
xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL;
+
+ OUString sRequestedName = getNameFromStreamURL(aStreamURL);
+
xPropSet->getPropertyValue("GraphicURL") >>= sImageURL;
- OUString aResolveURL( sImageURL );
- const OUString sPackageURL( "vnd.sun.star.Package:" );
+ uno::Any aGraphicAny = xPropSet->getPropertyValue("Graphic");
+ if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>())
+ xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>();
+
+ OUString aStoredURL;
- // trying to preserve the filename for embedded images which already have its stream inside the package
- bool bIsEmbeddedImageWithExistingStreamInPackage = false;
- if ( aStreamURL.match( sPackageURL ) )
+ if (xGraphic.is())
{
- bIsEmbeddedImageWithExistingStreamInPackage = true;
-
- OUString sRequestedName = aStreamURL.copy( sPackageURL.getLength() );
- sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1;
- if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) )
- sRequestedName = sRequestedName.copy( nLastIndex );
- nLastIndex = sRequestedName.lastIndexOf( '.' );
- if ( nLastIndex >= 0 )
- sRequestedName = sRequestedName.copy( 0, nLastIndex );
- if ( !sRequestedName.isEmpty() )
- {
+ aStoredURL = mrExport.AddEmbeddedXGraphic(xGraphic, sRequestedName);
+ }
+ else
+ {
+ OUString aResolveURL(sImageURL);
+ if (!sRequestedName.isEmpty())
aResolveURL += "?requestedName=" + sRequestedName;
- }
+
+ aStoredURL = mrExport.AddEmbeddedGraphicObject(aResolveURL);
}
- const OUString aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL );
- mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
+ mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStoredURL);
- if( !aStr.isEmpty() )
+ if (!aStoredURL.isEmpty())
{
+ const OUString sPackageURL("vnd.sun.star.Package:");
+
// apply possible changed stream URL to embedded image object
- if ( bIsEmbeddedImageWithExistingStreamInPackage )
+ if (!sRequestedName.isEmpty())
{
OUString newStreamURL = sPackageURL;
- if ( aStr[0] == '#' )
+ if (aStoredURL[0] == '#')
{
- newStreamURL += aStr.copy( 1, aStr.getLength() - 1 );
+ newStreamURL += aStoredURL.copy(1, aStoredURL.getLength() - 1);
}
else
{
- newStreamURL += aStr;
+ newStreamURL += aStoredURL;
}
if (newStreamURL != aStreamURL)