summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/export/drawingml.hxx22
-rw-r--r--include/oox/helper/modelobjecthelper.hxx5
-rw-r--r--include/xmloff/xmlexp.hxx5
-rw-r--r--include/xmloff/xmlimp.hxx5
-rw-r--r--oox/source/drawingml/fillproperties.cxx19
-rw-r--r--oox/source/drawingml/shapepropertymap.cxx11
-rw-r--r--oox/source/export/chartexport.cxx21
-rw-r--r--oox/source/export/drawingml.cxx177
-rw-r--r--oox/source/helper/modelobjecthelper.cxx10
-rw-r--r--sd/qa/unit/export-tests.cxx42
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx23
-rw-r--r--svx/source/unodraw/unobtabl.cxx5
-rw-r--r--svx/source/xml/xmlxtexp.cxx5
-rw-r--r--svx/source/xml/xmlxtimp.cxx12
-rw-r--r--xmloff/source/core/xmlexp.cxx39
-rw-r--r--xmloff/source/core/xmlimp.cxx16
-rw-r--r--xmloff/source/style/FillStyleContext.cxx65
-rw-r--r--xmloff/source/style/ImageStyle.cxx100
18 files changed, 475 insertions, 107 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index c8faa08001fd..2f02f783462c 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -63,6 +63,9 @@ namespace drawing {
struct EnhancedCustomShapeParameterPair;
struct EnhancedCustomShapeParameter;
}
+namespace graphic {
+ class XGraphic;
+}
namespace style {
struct LineSpacing;
}
@@ -187,18 +190,37 @@ public:
const OUString& sURLPropName );
void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
const OUString& sURLPropName, sal_Int32 nXmlNamespace );
+
+ void WriteXGraphicBlipFill(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia);
+
void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WritePattFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
const css::drawing::Hatch& rHatch);
void WriteSrcRect( const css::uno::Reference< css::beans::XPropertySet >&, const OUString& );
void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL );
+
+ void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
void WriteLinespacing( const css::style::LineSpacing& rLineSpacing );
OUString WriteBlip( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
const OUString& rURL, bool bRelPathToMedia, const Graphic *pGraphic=nullptr );
+
+ OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+ bool bRelPathToMedia);
+
+ void WriteImageBrightnessContrastTransparence(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet);
+
void WriteBlipMode( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL );
+ void WriteXGraphicBlipMode(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
+ css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape >& rXShape,
sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false, bool bSuppressFlipping = false, bool bFlippedBeforeRotation = false);
void WriteTransformation(const tools::Rectangle& rRectangle,
diff --git a/include/oox/helper/modelobjecthelper.hxx b/include/oox/helper/modelobjecthelper.hxx
index 986e0c7c5945..67980b57f6c8 100644
--- a/include/oox/helper/modelobjecthelper.hxx
+++ b/include/oox/helper/modelobjecthelper.hxx
@@ -28,6 +28,7 @@
namespace com { namespace sun { namespace star {
namespace awt { struct Gradient; }
+ namespace graphic { class XGraphic; }
namespace container { class XNameContainer; }
namespace drawing { struct LineDash; }
namespace drawing { struct PolyPolygonBezierCoords; }
@@ -107,6 +108,10 @@ public:
an internal constant name with a new unused index appended. */
OUString insertFillBitmapUrl( const OUString& rGraphicUrl );
+ /** Inserts a new named fill graphic, returns the bitmap name, based on
+ an internal constant name with a new unused index appended. */
+ OUString insertFillBitmapXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
OUString getFillBitmapUrl( const OUString& rGraphicName );
private:
diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index fe73d0d6ab5d..203be8fdfd0f 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -48,6 +48,7 @@
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XGraphicObjectResolver.hpp>
#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
@@ -461,6 +462,10 @@ public:
OUString AddEmbeddedGraphicObject(
const OUString& rGraphicObjectURL );
+
+ OUString AddEmbeddedXGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+ bool AddEmbeddedXGraphicAsBase64(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
+
css::uno::Reference<css::io::XInputStream> GetEmbeddedGraphicObjectStream(
const OUString& rGraphicObjectURL);
bool AddEmbeddedGraphicObjectAsBase64(
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 339b8cdf7a54..50c4e0f10612 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -27,6 +27,7 @@
#include <xmloff/dllapi.h>
#include <sal/types.h>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
@@ -158,7 +159,6 @@ public:
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
};
-
class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
css::xml::sax::XExtendedDocumentHandler,
css::xml::sax::XFastDocumentHandler,
@@ -400,9 +400,12 @@ public:
mxNumberFormatsSupplier = _xNumberFormatSupplier;
}
+ css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(const OUString& rURL);
+
// Convert a local package URL into either a graphic manager or a
// internal package URL. The later one happens only if bLoadURL is true
OUString ResolveGraphicObjectURL( const OUString& rURL, bool bLoadOnDemand );
+
css::uno::Reference< css::io::XOutputStream >
GetStreamForGraphicObjectURLFromBase64();
OUString ResolveGraphicObjectURLFromBase64(
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index d2d2775a3e3d..acb0b25e7526 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/ColorMode.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
@@ -600,14 +601,24 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( ShapeProperty::FillBitmapUrl ) )
{
Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
+ 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() && rPropMap.supportsProperty( ShapeProperty::FillBitmapNameFromUrl ) && rPropMap.setProperty( ShapeProperty::FillBitmapNameFromUrl, aGraphicUrl ) )
- eFillStyle = FillStyle_BITMAP;
- else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( ShapeProperty::FillBitmapUrl, aGraphicUrl ) )
- eFillStyle = FillStyle_BITMAP;
+
+ if (!aGraphicUrl.isEmpty())
+ {
+ if (rPropMap.supportsProperty(ShapeProperty::FillBitmapNameFromUrl) &&
+ rPropMap.setProperty(ShapeProperty::FillBitmapNameFromUrl, xGraphic))
+ {
+ eFillStyle = FillStyle_BITMAP;
+ }
+ else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, aGraphicUrl))
+ {
+ eFillStyle = FillStyle_BITMAP;
+ }
+ }
// set other bitmap properties, if bitmap has been inserted into the map
if( eFillStyle == FillStyle_BITMAP )
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index b1cf0239237e..53226434dfb1 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+
#include <oox/helper/modelobjecthelper.hxx>
#include <oox/token/properties.hxx>
@@ -194,12 +196,13 @@ bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue )
return false;
}
-bool ShapePropertyMap::setFillBitmapNameFromUrl( const Any& rValue )
+bool ShapePropertyMap::setFillBitmapNameFromUrl(const Any& rValue)
{
- if( rValue.has< OUString >() )
+ if (rValue.has<uno::Reference<graphic::XGraphic>>())
{
- OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() );
- return !aBitmapUrlName.isEmpty() && setProperty( PROP_FillBitmapName, aBitmapUrlName );
+ auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
+ OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapXGraphic(xGraphic);
+ return !aBitmapUrlName.isEmpty() && setProperty(PROP_FillBitmapName, aBitmapUrlName);
}
return false;
}
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 4c8bda4ea97b..684a8983503d 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -76,6 +76,7 @@
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
@@ -1313,19 +1314,27 @@ void ChartExport::exportBitmapFill( const Reference< XPropertySet >& xPropSet )
uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
try
{
- uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
- uno::Any rValue = xBitmap->getByName( sFillBitmapName );
- OUString sBitmapURL;
- if( rValue >>= sBitmapURL )
+ uno::Reference< container::XNameAccess > xBitmapTable( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
+ uno::Any rValue = xBitmapTable->getByName( sFillBitmapName );
+ if (rValue.has<uno::Reference<awt::XBitmap>>())
{
- WriteBlipFill( xPropSet, sBitmapURL, XML_a, true, true );
+ uno::Reference<awt::XBitmap> xBitmap = rValue.get<uno::Reference<awt::XBitmap>>();
+ uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+ if (xGraphic.is())
+ {
+ WriteXGraphicBlipFill(xPropSet, xGraphic, XML_a, true, true);
+ }
+ }
+ else if (rValue.has<OUString>()) // TODO: Remove, when not used anymore
+ {
+ OUString sBitmapURL = rValue.get<OUString>();
+ WriteBlipFill(xPropSet, sBitmapURL, XML_a, true, true);
}
}
catch (const uno::Exception & rEx)
{
SAL_INFO("oox", "ChartExport::exportBitmapFill " << rEx);
}
-
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 1deec7c82f74..d56077c5240a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -64,6 +64,7 @@
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
@@ -1055,6 +1056,36 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra
GetFS()->endElementNS(XML_p, XML_nvPr);
}
+void DrawingML::WriteImageBrightnessContrastTransparence(uno::Reference<beans::XPropertySet> const & rXPropSet)
+{
+ sal_Int16 nBright = 0;
+ sal_Int32 nContrast = 0;
+ sal_Int32 nTransparence = 0;
+
+ if (GetProperty(rXPropSet, "AdjustLuminance"))
+ nBright = mAny.get<sal_Int16>();
+ if (GetProperty(rXPropSet, "AdjustContrast"))
+ nContrast = mAny.get<sal_Int32>();
+ if (GetProperty(rXPropSet, "FillTransparence"))
+ nTransparence = mAny.get<sal_Int32>();
+
+
+ if (nBright || nContrast)
+ {
+ mpFS->singleElementNS(XML_a, XML_lum,
+ XML_bright, nBright ? I32S(nBright * 1000) : nullptr,
+ XML_contrast, nContrast ? I32S(nContrast * 1000) : nullptr,
+ FSEND);
+ }
+
+ if (nTransparence)
+ {
+ sal_Int32 nAlphaMod = (100 - nTransparence ) * PER_PERCENT;
+ mpFS->singleElementNS(XML_a, XML_alphaModFix,
+ XML_amt, I32S(nAlphaMod), FSEND);
+ }
+}
+
OUString DrawingML::WriteBlip( const Reference< XPropertySet >& rXPropSet, const OUString& rURL, bool bRelPathToMedia, const Graphic *pGraphic )
{
OUString sRelId;
@@ -1074,35 +1105,54 @@ OUString DrawingML::WriteBlip( const Reference< XPropertySet >& rXPropSet, const
if (!rURL.isEmpty() && mpTextExport)
mpTextExport->CacheRelId(nChecksum, sRelId);
}
- sal_Int16 nBright = 0;
- sal_Int32 nContrast = 0;
- sal_Int32 nTransparence = 0;
-
- GET( nBright, AdjustLuminance );
- GET( nContrast, AdjustContrast );
- GET( nTransparence, FillTransparence );
mpFS->startElementNS( XML_a, XML_blip,
- FSNS( XML_r, XML_embed), sRelId.toUtf8().getStr(),
- FSEND );
- if( nBright || nContrast )
+ FSNS( XML_r, XML_embed), sRelId.toUtf8().getStr(),
+ FSEND );
+
+ WriteImageBrightnessContrastTransparence(rXPropSet);
+
+ WriteArtisticEffect( rXPropSet );
+
+ mpFS->endElementNS( XML_a, XML_blip );
+
+ return sRelId;
+}
+
+OUString DrawingML::WriteXGraphicBlip(uno::Reference<beans::XPropertySet> const & rXPropSet,
+ uno::Reference<graphic::XGraphic> const & rxGraphic,
+ bool bRelPathToMedia)
+{
+ OUString sRelId;
+
+ if (!rxGraphic.is())
+ return sRelId;
+
+ Graphic aGraphic(rxGraphic);
+ if (mpTextExport)
{
- mpFS->singleElementNS( XML_a, XML_lum,
- XML_bright, nBright ? I32S( nBright*1000 ) : nullptr,
- XML_contrast, nContrast ? I32S( nContrast*1000 ) : nullptr,
- FSEND );
+ BitmapChecksum nChecksum = aGraphic.GetChecksum();
+ sRelId = mpTextExport->FindRelId(nChecksum);
}
-
- if( nTransparence )
+ if (sRelId.isEmpty())
{
- sal_Int32 nAlphaMod = (100 - nTransparence ) * PER_PERCENT;
- mpFS->singleElementNS( XML_a, XML_alphaModFix,
- XML_amt, I32S( nAlphaMod), FSEND );
+ sRelId = WriteImage(aGraphic, bRelPathToMedia);
+ if (mpTextExport)
+ {
+ BitmapChecksum nChecksum = aGraphic.GetChecksum();
+ mpTextExport->CacheRelId(nChecksum, sRelId);
+ }
}
- WriteArtisticEffect( rXPropSet );
+ mpFS->startElementNS(XML_a, XML_blip,
+ FSNS(XML_r, XML_embed), sRelId.toUtf8().getStr(),
+ FSEND);
- mpFS->endElementNS( XML_a, XML_blip );
+ WriteImageBrightnessContrastTransparence(rXPropSet);
+
+ WriteArtisticEffect(rXPropSet);
+
+ mpFS->endElementNS(XML_a, XML_blip);
return sRelId;
}
@@ -1128,6 +1178,28 @@ void DrawingML::WriteBlipMode( const Reference< XPropertySet >& rXPropSet, const
}
}
+void DrawingML::WriteXGraphicBlipMode(uno::Reference<beans::XPropertySet> const & rXPropSet,
+ uno::Reference<graphic::XGraphic> const & rxGraphic)
+{
+ BitmapMode eBitmapMode(BitmapMode_NO_REPEAT);
+ if (GetProperty(rXPropSet, "FillBitmapMode"))
+ mAny >>= eBitmapMode;
+
+ SAL_INFO("oox.shape", "fill bitmap mode: " << int(eBitmapMode));
+
+ switch (eBitmapMode)
+ {
+ case BitmapMode_REPEAT:
+ mpFS->singleElementNS(XML_a, XML_tile, FSEND);
+ break;
+ case BitmapMode_STRETCH:
+ WriteXGraphicStretch(rXPropSet, rxGraphic);
+ break;
+ default:
+ break;
+ }
+}
+
void DrawingML::WriteBlipOrNormalFill( const Reference< XPropertySet >& xPropSet, const OUString& rURLPropName )
{
// check for blip and otherwise fall back to normal fill
@@ -1183,6 +1255,33 @@ void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const
}
}
+void DrawingML::WriteXGraphicBlipFill(uno::Reference<beans::XPropertySet> const & rXPropSet,
+ uno::Reference<graphic::XGraphic> const & rxGraphic,
+ sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia)
+{
+ if (!rxGraphic.is() )
+ return;
+
+ mpFS->startElementNS(nXmlNamespace , XML_blipFill, XML_rotWithShape, "0", FSEND);
+
+ WriteXGraphicBlip(rXPropSet, rxGraphic, bRelPathToMedia);
+
+ if (bWriteMode)
+ {
+ WriteXGraphicBlipMode(rXPropSet, rxGraphic);
+ }
+ else if(GetProperty(rXPropSet, "FillBitmapStretch"))
+ {
+ bool bStretch = mAny.get<bool>();
+
+ if (bStretch)
+ {
+ WriteXGraphicStretch(rXPropSet, rxGraphic);
+ }
+ }
+ mpFS->endElementNS(nXmlNamespace, XML_blipFill);
+}
+
void DrawingML::WritePattFill( const Reference< XPropertySet >& rXPropSet )
{
if ( GetProperty( rXPropSet, "FillHatch" ) )
@@ -1284,6 +1383,42 @@ void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySe
mpFS->endElementNS( XML_a, XML_stretch );
}
+void DrawingML::WriteXGraphicStretch(uno::Reference<beans::XPropertySet> const & rXPropSet,
+ uno::Reference<graphic::XGraphic> const & rxGraphic)
+{
+ mpFS->startElementNS(XML_a, XML_stretch, FSEND);
+
+ bool bCrop = false;
+ if (GetProperty(rXPropSet, "GraphicCrop"))
+ {
+ css::text::GraphicCrop aGraphicCropStruct;
+ mAny >>= aGraphicCropStruct;
+
+ if ((0 != aGraphicCropStruct.Left)
+ || (0 != aGraphicCropStruct.Top)
+ || (0 != aGraphicCropStruct.Right)
+ || (0 != aGraphicCropStruct.Bottom))
+ {
+ Graphic aGraphic(rxGraphic);
+ Size aOriginalSize(aGraphic.GetPrefSize());
+ mpFS->singleElementNS(XML_a, XML_fillRect,
+ XML_l, I32S(((aGraphicCropStruct.Left) * 100000) / aOriginalSize.Width()),
+ XML_t, I32S(((aGraphicCropStruct.Top) * 100000) / aOriginalSize.Height()),
+ XML_r, I32S(((aGraphicCropStruct.Right) * 100000) / aOriginalSize.Width()),
+ XML_b, I32S(((aGraphicCropStruct.Bottom) * 100000) / aOriginalSize.Height()),
+ FSEND);
+ bCrop = true;
+ }
+ }
+
+ if (!bCrop)
+ {
+ mpFS->singleElementNS(XML_a, XML_fillRect, FSEND);
+ }
+
+ mpFS->endElementNS(XML_a, XML_stretch);
+}
+
void DrawingML::WriteTransformation(const tools::Rectangle& rRect,
sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation, bool bIsGroupShape)
{
diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx
index 79f53fe66d28..24f6e7fbb539 100644
--- a/oox/source/helper/modelobjecthelper.cxx
+++ b/oox/source/helper/modelobjecthelper.cxx
@@ -24,6 +24,8 @@
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <oox/helper/containerhelper.hxx>
#include <oox/helper/helper.hxx>
#include <osl/diagnose.h>
@@ -134,6 +136,14 @@ OUString ModelObjectHelper::insertFillBitmapUrl( const OUString& rGraphicUrl )
return OUString();
}
+OUString ModelObjectHelper::insertFillBitmapXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic)
+{
+ uno::Reference<awt::XBitmap> xBitmap(rxGraphic, uno::UNO_QUERY);
+ if (xBitmap.is())
+ return maBitmapUrlContainer.insertObject(maBitmapUrlNameBase, Any(xBitmap), true);
+ return OUString();
+}
+
OUString ModelObjectHelper::getFillBitmapUrl( const OUString &rGraphicName )
{
Any aAny = maBitmapUrlContainer.getObject( rGraphicName );
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 8bc274400520..b27c55b55ba8 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -144,6 +144,33 @@ public:
};
+namespace
+{
+
+uno::Reference<awt::XBitmap> getBitmapFromTable(sd::DrawDocShellRef xDocShRef, OUString const & rName)
+{
+ uno::Reference<awt::XBitmap> xBitmap;
+
+ uno::Reference<lang::XMultiServiceFactory> xFactory(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
+
+ try
+ {
+ uno::Reference<container::XNameAccess> xBitmapTable(xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY);
+ uno::Any rValue = xBitmapTable->getByName(rName);
+ if (rValue.has<uno::Reference<awt::XBitmap>>())
+ {
+ return rValue.get<uno::Reference<awt::XBitmap>>();
+ }
+ }
+ catch (const uno::Exception & /*rEx*/)
+ {
+ }
+
+ return xBitmap;
+}
+
+}
+
void SdExportTest::testBackgroundImage()
{
// Initial bug: N821567
@@ -168,7 +195,10 @@ void SdExportTest::testBackgroundImage()
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
- CPPUNIT_ASSERT_MESSAGE("Slide Background is not imported from PPTX correctly", !bgImageName.isEmpty());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not imported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName);
+
+ uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
+ CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when imported from PPTX", xBitmap.is());
}
// Save as PPTX, reload and check again so we make sure exporting to PPTX is working correctly
@@ -187,7 +217,10 @@ void SdExportTest::testBackgroundImage()
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
- CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported to PPTX correctly", !bgImageName.isEmpty());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName);
+
+ uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
+ CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported from PPTX", xBitmap.is());
}
// Save as ODP, reload and check again so we make sure exporting and importing to ODP is working correctly
@@ -206,7 +239,10 @@ void SdExportTest::testBackgroundImage()
aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
aAny >>= bgImageName;
}
- CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported or imported to ODP correctly", !bgImageName.isEmpty());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported or imported from ODP correctly", OUString("msFillBitmap 1"), bgImageName);
+
+ uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName);
+ CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported or imported from ODP", xBitmap.is());
}
xDocShRef->DoClose();
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx
index 55ca9a09cc90..1765cee285ab 100644
--- a/svx/source/unodraw/XPropertyTable.cxx
+++ b/svx/source/unodraw/XPropertyTable.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/Hatch.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -613,28 +615,27 @@ uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyLi
// SvxUnoXPropertyTable
uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const
{
- OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX);
- const GraphicObject& rGraphicObject(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
- aURL += OStringToOUString(rGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
-
- return uno::Any(aURL);
+ auto xBitmapEntry = static_cast<const XBitmapEntry*>(pEntry);
+ css::uno::Reference<css::awt::XBitmap> xBitmap(xBitmapEntry->GetGraphicObject().GetGraphic().GetXGraphic(), uno::UNO_QUERY);
+ return uno::Any(xBitmap);
}
std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString& rName, const uno::Any& rAny) const
{
- OUString aURL;
- if(!(rAny >>= aURL))
+ if (!rAny.has<uno::Reference<awt::XBitmap>>())
return std::unique_ptr<XPropertyEntry>();
- const GraphicObject aGrafObj(GraphicObject::CreateGraphicObjectFromURL(aURL));
-
- return o3tl::make_unique<XBitmapEntry>(aGrafObj, rName);
+ auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>();
+ uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+ Graphic aGraphic(xGraphic);
+ GraphicObject aGraphicObject(aGraphic);
+ return o3tl::make_unique<XBitmapEntry>(aGraphicObject, rName);
}
// XElementAccess
uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
{
- return ::cppu::UnoType<OUString>::get();
+ return ::cppu::UnoType<awt::XBitmap>::get();
}
// XServiceInfo
diff --git a/svx/source/unodraw/unobtabl.cxx b/svx/source/unodraw/unobtabl.cxx
index 5e8c4ad39def..ab1d48660d58 100644
--- a/svx/source/unodraw/unobtabl.cxx
+++ b/svx/source/unodraw/unobtabl.cxx
@@ -31,6 +31,7 @@
#include <editeng/unoprnms.hxx>
#include <svx/unofill.hxx>
#include <editeng/memberids.h>
+#include <com/sun/star/awt/XBitmap.hpp>
using namespace ::com::sun::star;
using namespace ::cppu;
@@ -52,7 +53,7 @@ public:
};
SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
-: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL )
+: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_BITMAP )
{
}
@@ -91,7 +92,7 @@ NameOrIndex* SvxUnoBitmapTable::createItem() const
// XElementAccess
uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( )
{
- return ::cppu::UnoType<OUString>::get();
+ return ::cppu::UnoType<awt::XBitmap>::get();
}
/**
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index 8162ff851112..2254de22e652 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/drawing/Hatch.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -363,7 +364,7 @@ bool SvxXMLXTableExportComponent::exportTable() throw()
pExporter.reset(new SvxXMLGradientEntryExporter(*this));
pEleName = "gradient-table";
}
- else if( aExportType == cppu::UnoType<OUString>::get())
+ else if( aExportType == cppu::UnoType<awt::XBitmap>::get())
{
pExporter.reset(new SvxXMLBitmapEntryExporter(*this));
pEleName = "bitmap-table";
@@ -484,7 +485,7 @@ SvxXMLBitmapEntryExporter::SvxXMLBitmapEntryExporter( SvXMLExport& rExport )
void SvxXMLBitmapEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
{
- XMLImageStyle::exportXML( rStrName, rValue, mrExport );
+ XMLImageStyle::exportXML(rStrName, rValue, mrExport);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index 14b4156dd14b..5cfc80c7ced8 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/drawing/Hatch.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XSeekable.hpp>
@@ -275,7 +276,14 @@ void SvxXMLTableImportContext::importBitmap( const uno::Reference< XAttributeLis
{
try
{
- XMLImageStyle::importXML( xAttrList, rAny, rName, GetImport() );
+ uno::Any aGraphicAny;
+ XMLImageStyle::importXML(xAttrList, aGraphicAny, rName, GetImport());
+ if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>())
+ {
+ auto xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>();
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY_THROW);
+ rAny <<= xBitmap;
+ }
}
catch (const Exception&)
{
@@ -453,7 +461,7 @@ SvXMLImportContext *SvxXMLXTableImport::CreateDocumentContext(
}
else if ( rLocalName == "bitmap-table" )
{
- if( aType == ::cppu::UnoType<OUString>::get())
+ if( aType == ::cppu::UnoType<awt::XBitmap>::get())
return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Bitmap, mrTable, bOOoFormat );
}
}
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index d06eb49da770..cfee78ca7762 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -87,6 +87,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XMLOasisBasicExporter.hpp>
#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
+#include <com/sun/star/document/XGraphicStorageHandler.hpp>
#include <com/sun/star/rdf/XMetadatable.hpp>
#include <RDFaExportHelper.hxx>
@@ -1881,6 +1882,23 @@ OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectUR
return sRet;
}
+OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic)
+{
+ OUString sInternalURL;
+
+ uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY);
+
+ if (mxGraphicResolver.is() && xGraphicStorageHandler.is())
+ {
+ if (!(getExportFlags() & SvXMLExportFlags::EMBEDDED))
+ {
+ sInternalURL = xGraphicStorageHandler->saveGraphic(rxGraphic);
+ }
+ }
+
+ return sInternalURL;
+}
+
Reference< XInputStream > SvXMLExport::GetEmbeddedGraphicObjectStream( const OUString& rGraphicObjectURL )
{
if( (getExportFlags() & SvXMLExportFlags::EMBEDDED) &&
@@ -1899,6 +1917,27 @@ Reference< XInputStream > SvXMLExport::GetEmbeddedGraphicObjectStream( const OUS
return nullptr;
}
+bool SvXMLExport::AddEmbeddedXGraphicAsBase64(uno::Reference<graphic::XGraphic> const & rxGraphic)
+{
+ if ((getExportFlags() & SvXMLExportFlags::EMBEDDED) &&
+ mxGraphicResolver.is())
+ {
+ uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY);
+
+ if (xGraphicStorageHandler.is())
+ {
+ Reference<XInputStream> xInputStream(xGraphicStorageHandler->createInputStream(rxGraphic));
+ if (xInputStream.is())
+ {
+ XMLBase64Export aBase64Exp(*this);
+ return aBase64Exp.exportOfficeBinaryDataElement(xInputStream);
+ }
+ }
+ }
+
+ return false;
+}
+
bool SvXMLExport::AddEmbeddedGraphicObjectAsBase64( const OUString& rGraphicObjectURL )
{
bool bRet = false;
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index c8a2417603c9..5203cdc4d751 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/util/MeasureUnit.hpp>
#include <com/sun/star/document/XBinaryStreamResolver.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/document/XGraphicStorageHandler.hpp>
#include <com/sun/star/xml/sax/XLocator.hpp>
#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
@@ -1312,6 +1313,8 @@ bool SvXMLImport::IsPackageURL( const OUString& rURL ) const
if( (mnImportFlags & nTest) == nTest )
return false;
+ // TODO: from this point extract to own static function
+
// Some quick tests: Some may rely on the package structure!
sal_Int32 nLen = rURL.getLength();
if( nLen > 0 && '/' == rURL[0] )
@@ -1350,6 +1353,19 @@ bool SvXMLImport::IsPackageURL( const OUString& rURL ) const
return true;
}
+css::uno::Reference<css::graphic::XGraphic> SvXMLImport::loadGraphicByURL(const OUString& rURL)
+{
+ css::uno::Reference<css::graphic::XGraphic> xGraphic;
+ uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY);
+
+ if (IsPackageURL(rURL) && xGraphicStorageHandler.is())
+ {
+ xGraphic = xGraphicStorageHandler->loadGraphic(rURL);
+ }
+
+ return xGraphic;
+}
+
OUString SvXMLImport::ResolveGraphicObjectURL( const OUString& rURL,
bool bLoadOnDemand )
{
diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx
index 89c73965749f..5c89613e826f 100644
--- a/xmloff/source/style/FillStyleContext.cxx
+++ b/xmloff/source/style/FillStyleContext.cxx
@@ -18,6 +18,8 @@
*/
#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
#include "FillStyleContext.hxx"
#include <xmloff/xmlimp.hxx>
#include <xmloff/GradientStyle.hxx>
@@ -158,34 +160,61 @@ SvXMLImportContextRef XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPre
void XMLBitmapStyleContext::EndElement()
{
- OUString sURL;
- maAny >>= sURL;
-
- if( sURL.isEmpty() && mxBase64Stream.is() )
+ if (maAny.has<uno::Reference<graphic::XGraphic>>())
{
- sURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
- mxBase64Stream = nullptr;
- maAny <<= sURL;
- }
+ uno::Reference<container::XNameContainer> xBitmapContainer(GetImport().GetBitmapHelper());
- uno::Reference< container::XNameContainer > xBitmap( GetImport().GetBitmapHelper() );
+ uno::Reference<graphic::XGraphic> xGraphic = maAny.get<uno::Reference<graphic::XGraphic>>();
+ uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
- try
- {
- if(xBitmap.is())
+ try
{
- if( xBitmap->hasByName( maStrName ) )
+ if (xBitmapContainer.is())
{
- xBitmap->replaceByName( maStrName, maAny );
+ if (xBitmapContainer->hasByName(maStrName))
+ {
+ xBitmapContainer->replaceByName(maStrName, uno::Any(xBitmap));
+ }
+ else
+ {
+ xBitmapContainer->insertByName(maStrName, uno::Any(xBitmap));
+ }
}
- else
+ }
+ catch (container::ElementExistException&)
+ {}
+ }
+ else
+ {
+ OUString sURL;
+ maAny >>= sURL;
+
+ if( sURL.isEmpty() && mxBase64Stream.is() )
+ {
+ sURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
+ mxBase64Stream = nullptr;
+ maAny <<= sURL;
+ }
+
+ uno::Reference< container::XNameContainer > xBitmap( GetImport().GetBitmapHelper() );
+
+ try
+ {
+ if(xBitmap.is())
{
- xBitmap->insertByName( maStrName, maAny );
+ if( xBitmap->hasByName( maStrName ) )
+ {
+ xBitmap->replaceByName( maStrName, maAny );
+ }
+ else
+ {
+ xBitmap->insertByName( maStrName, maAny );
+ }
}
}
+ catch( container::ElementExistException& )
+ {}
}
- catch( container::ElementExistException& )
- {}
}
bool XMLBitmapStyleContext::IsTransient() const
diff --git a/xmloff/source/style/ImageStyle.cxx b/xmloff/source/style/ImageStyle.cxx
index d4be8a0a2a1f..cd8b7fcb4659 100644
--- a/xmloff/source/style/ImageStyle.cxx
+++ b/xmloff/source/style/ImageStyle.cxx
@@ -45,39 +45,73 @@ enum SvXMLTokenMapAttrs
void XMLImageStyle::exportXML(OUString const & rStrName, uno::Any const & rValue, SvXMLExport& rExport)
{
- OUString sImageURL;
+ if (rStrName.isEmpty())
+ return;
- if( !rStrName.isEmpty() )
+ if (rValue.has<uno::Reference<awt::XBitmap>>())
{
- if( rValue >>= sImageURL )
+ // Name
+ bool bEncoded = false;
+ rExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,
+ rExport.EncodeStyleName(rStrName, &bEncoded));
+ if (bEncoded)
{
- // Name
- bool bEncoded = false;
- rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
- rExport.EncodeStyleName( rStrName,
- &bEncoded ) );
- if( bEncoded )
- rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY_NAME,
- rStrName );
-
- // uri
- const OUString aStr( rExport.AddEmbeddedGraphicObject( sImageURL ) );
- if( !aStr.isEmpty() )
- {
- rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
- rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
- rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
- rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
- }
-
- // Do Write
- SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_FILL_IMAGE, true, true );
-
- if( !sImageURL.isEmpty() )
- {
- // optional office:binary-data
- rExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
- }
+ rExport.AddAttribute(XML_NAMESPACE_DRAW, XML_DISPLAY_NAME, rStrName);
+ }
+
+ auto xBitmap = rValue.get<uno::Reference<awt::XBitmap>>();
+ uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+
+ const OUString aStr = rExport.AddEmbeddedXGraphic(xGraphic);
+
+ // uri
+ if (!aStr.isEmpty())
+ {
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
+ }
+
+ // Do Write
+ SvXMLElementExport aElem(rExport, XML_NAMESPACE_DRAW, XML_FILL_IMAGE, true, true);
+
+ if (xBitmap.is() && xGraphic.is())
+ {
+ // optional office:binary-data
+ rExport.AddEmbeddedXGraphicAsBase64(xGraphic);
+ }
+ }
+ else if (rValue.has<OUString>()) // TODO: Remove when GraphicObject URL aren't used anymore
+ {
+ OUString sImageURL = rValue.get<OUString>();
+
+ // Name
+ bool bEncoded = false;
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME,
+ rExport.EncodeStyleName( rStrName,
+ &bEncoded ) );
+ if( bEncoded )
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY_NAME,
+ rStrName );
+
+ // uri
+ const OUString aStr( rExport.AddEmbeddedGraphicObject( sImageURL ) );
+ if( !aStr.isEmpty() )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStr );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
+ rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
+ }
+
+ // Do Write
+ SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_FILL_IMAGE, true, true );
+
+ if( !sImageURL.isEmpty() )
+ {
+ // optional office:binary-data
+ rExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
}
}
}
@@ -98,8 +132,8 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x
bool bHasHRef = false;
bool bHasName = false;
- OUString aStrURL;
OUString aDisplayName;
+ uno::Reference<graphic::XGraphic> xGraphic;
SvXMLTokenMap aTokenMap( aHatchAttrTokenMap );
@@ -126,7 +160,7 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x
break;
case XML_TOK_IMAGE_URL:
{
- aStrURL = rImport.ResolveGraphicObjectURL( rStrValue, false );
+ xGraphic = rImport.loadGraphicByURL(rStrValue);
bHasHRef = true;
}
break;
@@ -144,7 +178,7 @@ bool XMLImageStyle::importXML(uno::Reference<xml::sax::XAttributeList> const & x
}
}
- rValue <<= aStrURL;
+ rValue <<= xGraphic;
if( !aDisplayName.isEmpty() )
{