summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-01 08:39:11 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-03-07 02:37:36 +0100
commitd72145f9307c732ced4a546ac1e5093ec7c1a982 (patch)
tree648cf88d30ba3da260edb22829d8cd8be0c9345e /oox/source
parent6b39ed0eaffabb6ffe11496d833053c094c72f7b (diff)
Move BackGraphicURL property & friends to BackGraphic + fixes
This moves BackGraphicURL, HeaderGraphicURL, FooterGraphicURL and ParaBackGraphicURL properties to BackGraphic, HeaderBackGraphic, FooterBackGraphic and ParaBackGraphic. With this the property type changes from String to XGraphic. This change also fixes a bunch of test failures, changes the tests to use the new properties and the correct type, changes the import and export filters like xmloff and oox, to make the tests happy. Change-Id: Ie66097514203c6dc36ab27420faf265322e9279e Reviewed-on: https://gerrit.libreoffice.org/50760 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/fillproperties.cxx7
-rw-r--r--oox/source/drawingml/shape.cxx14
-rw-r--r--oox/source/drawingml/shapepropertymap.cxx17
-rw-r--r--oox/source/export/drawingml.cxx17
-rw-r--r--oox/source/helper/modelobjecthelper.cxx9
-rw-r--r--oox/source/token/properties.txt2
6 files changed, 48 insertions, 18 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 7f6a7044a386..c22654ebeb6f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -604,17 +604,14 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
// TODO: "rotate with shape" is not possible with our current core
- OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
- // push bitmap or named bitmap to property map
-
- if (!aGraphicUrl.isEmpty())
+ if (xGraphic.is())
{
if (rPropMap.supportsProperty(ShapeProperty::FillBitmapNameFromUrl) &&
rPropMap.setProperty(ShapeProperty::FillBitmapNameFromUrl, xGraphic))
{
eFillStyle = FillStyle_BITMAP;
}
- else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, aGraphicUrl))
+ else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, xGraphic))
{
eFillStyle = FillStyle_BITMAP;
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6d83c68e3df2..b3c48b0b67c7 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -54,6 +54,7 @@
#include <tools/mapunit.hxx>
#include <editeng/unoprnms.hxx>
#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -841,16 +842,19 @@ Reference< XShape > const & Shape::createAndInsert(
aShapeProps.setAnyProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
aShapeProps.erase(PROP_FillTransparence);
}
- // TextFrames have BackGrahicURL, not FillBitmapURL
- if (aShapeProps.hasProperty(PROP_FillBitmapURL))
+ // TextFrames have BackGrahic, not FillBitmap
+ if (aShapeProps.hasProperty(PROP_FillBitmap))
{
- aShapeProps.setAnyProperty(PROP_BackGraphicURL, aShapeProps.getProperty(PROP_FillBitmapURL));
- aShapeProps.erase(PROP_FillBitmapURL);
+ aShapeProps.setAnyProperty(PROP_BackGraphic, aShapeProps.getProperty(PROP_FillBitmap));
+ aShapeProps.erase(PROP_FillBitmap);
}
if (aShapeProps.hasProperty(PROP_FillBitmapName))
{
uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
- aShapeProps.setProperty(PROP_BackGraphicURL, rFilterBase.getModelObjectHelper().getFillBitmapUrl( aAny.get<OUString>() ));
+ OUString aFillBitmapName = aAny.get<OUString>();
+ uno::Reference<awt::XBitmap> xBitmap = rFilterBase.getModelObjectHelper().getFillBitmap(aFillBitmapName);
+ uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+ aShapeProps.setProperty(PROP_BackGraphic, xGraphic);
// aShapeProps.erase(PROP_FillBitmapName); // Maybe, leave the name as well
}
// And no LineColor property; individual borders can have colors
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index 53226434dfb1..c0704381b19c 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -180,17 +180,20 @@ bool ShapePropertyMap::setGradientTrans( sal_Int32 nPropId, const Any& rValue )
return false;
}
-bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue )
+bool ShapePropertyMap::setFillBitmapUrl(sal_Int32 nPropId, const Any& rValue)
{
- // push bitmap URL explicitly
- if( !maShapePropInfo.mbNamedFillBitmapUrl )
- return setAnyProperty( nPropId, rValue );
+ // push bitmap explicitly
+ if (!maShapePropInfo.mbNamedFillBitmapUrl)
+ {
+ return setAnyProperty(nPropId, rValue);
+ }
// create named bitmap URL and push its name
- if( rValue.has< OUString >() )
+ if (rValue.has<uno::Reference<graphic::XGraphic>>())
{
- OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() );
- return !aBitmapUrlName.isEmpty() && setProperty( nPropId, aBitmapUrlName );
+ auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
+ OUString aBitmapName = mrModelObjHelper.insertFillBitmapXGraphic(xGraphic);
+ return !aBitmapName.isEmpty() && setProperty(nPropId, aBitmapName);
}
return false;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 093ed3c4ec24..469420e0d616 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1227,7 +1227,22 @@ void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const
uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
if (xBitmap.is() && xGraphic.is())
{
- WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, true);
+ bool bWriteMode = false;
+ if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
+ bWriteMode = true;
+ WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
+ }
+ }
+ else if (mAny.has<uno::Reference<graphic::XGraphic>>())
+ {
+ uno::Reference<graphic::XGraphic> xGraphic;
+ xGraphic = mAny.get<uno::Reference<graphic::XGraphic>>();
+ if (xGraphic.is())
+ {
+ bool bWriteMode = false;
+ if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
+ bWriteMode = true;
+ WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
}
}
else
diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx
index 24f6e7fbb539..95c466f48a89 100644
--- a/oox/source/helper/modelobjecthelper.cxx
+++ b/oox/source/helper/modelobjecthelper.cxx
@@ -152,6 +152,15 @@ OUString ModelObjectHelper::getFillBitmapUrl( const OUString &rGraphicName )
return OUString();
}
+uno::Reference<awt::XBitmap> ModelObjectHelper::getFillBitmap(OUString const & rGraphicName)
+{
+ uno::Reference<awt::XBitmap> xBitmap;
+ uno::Any aAny = maBitmapUrlContainer.getObject(rGraphicName);
+ if (aAny.has<uno::Reference<awt::XBitmap>>())
+ xBitmap = aAny.get<uno::Reference<awt::XBitmap>>();
+ return xBitmap;
+}
+
} // namespace oox
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index b4da0cb63439..6754ee58558c 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -21,6 +21,7 @@ Autocomplete
BackColor
BackColorTransparency
BackGraphicLocation
+BackGraphic
BackGraphicURL
Background
BackgroundColor
@@ -167,6 +168,7 @@ FillBitmapRectanglePoint
FillBitmapSizeX
FillBitmapSizeY
FillBitmapURL
+FillBitmap
FillColor
FillGradient
FillGradientName