diff options
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 10 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/fdo74115_WallBitmapFill.docx | bin | 0 -> 802053 bytes | |||
-rw-r--r-- | include/oox/export/chartexport.hxx | 1 | ||||
-rw-r--r-- | include/oox/export/drawingml.hxx | 16 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 31 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 34 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 2 |
7 files changed, 77 insertions, 17 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index d51bd1c96d62..7714084095c3 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -44,6 +44,7 @@ public: void testDoughnutChart(); void testDisplayUnits(); void testFdo74115WallGradientFill(); + void testFdo74115WallBitmapFill(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(test); @@ -60,6 +61,7 @@ public: CPPUNIT_TEST(testDoughnutChart); CPPUNIT_TEST(testDisplayUnits); CPPUNIT_TEST(testFdo74115WallGradientFill); + CPPUNIT_TEST(testFdo74115WallBitmapFill); CPPUNIT_TEST_SUITE_END(); protected: @@ -556,6 +558,14 @@ void Chart2ExportTest::testFdo74115WallGradientFill() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill"); } +void Chart2ExportTest::testFdo74115WallBitmapFill() +{ + load("/chart2/qa/extras/data/docx/", "fdo74115_WallBitmapFill.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:blipFill"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/docx/fdo74115_WallBitmapFill.docx b/chart2/qa/extras/data/docx/fdo74115_WallBitmapFill.docx Binary files differnew file mode 100644 index 000000000000..0c842fd0787b --- /dev/null +++ b/chart2/qa/extras/data/docx/fdo74115_WallBitmapFill.docx diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index c9c13ba40ff7..04a5e2029f0c 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -123,6 +123,7 @@ private: void exportPlotAreaShapeProps( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet ); void exportFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet ); void exportGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet ); + void exportBitmapFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet ); void exportDataTable( ); void exportAreaChart( com::sun::star::uno::Reference< com::sun::star::chart2::XChartType > xChartType ); diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 8b963f70ac52..36d94a648cb7 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -101,7 +101,9 @@ protected: OUString aName, ::com::sun::star::beans::PropertyState& eState ); const char* GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, sal_Bool& bIsField ); - OUString WriteImage( const OUString& rURL ); + + /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship + OUString WriteImage( const OUString& rURL, bool bRelPathToMedia = false); void WriteStyleProperties( sal_Int32 nTokenId, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties ); const char* GetComponentDir(); @@ -117,7 +119,8 @@ public: ::oox::core::XmlFilterBase* GetFB() { return mpFB; } DocumentType GetDocumentType() { return meDocumentType; } - OUString WriteImage( const Graphic &rGraphic ); + /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship + OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false); void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteColor( OUString sColorSchemeName, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aTransformations ); @@ -132,14 +135,19 @@ public: void WriteGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteGradientFill( ::com::sun::star::awt::Gradient rGradient ); void WriteGrabBagGradientFill( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aGradientStops, ::com::sun::star::awt::Gradient rGradient); - void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString sURLPropName, sal_Int32 nXmlNamespace ); + void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, + OUString sBitmapURL, sal_Int32 nXmlNamespace, + bool bWriteMode, bool bRelPathToMedia = false ); void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString sURLPropName ); + void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, + OUString sURLPropName, sal_Int32 nXmlNamespace ); void WriteSrcRect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, const OUString& ); void WriteOutline( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteStretch(); void WriteLinespacing( ::com::sun::star::style::LineSpacing& rLineSpacing ); - OUString WriteBlip( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString& rURL, const Graphic *pGraphic=NULL ); + OUString WriteBlip( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, + OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=NULL ); void WriteBlipMode( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteShapeTransformation( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape, diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 939e5a489a1b..19394de8c243 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1166,11 +1166,40 @@ void ChartExport::exportFill( Reference< XPropertySet > xPropSet ) case FillStyle_GRADIENT : exportGradientFill( xPropSet ); break; + case FillStyle_BITMAP : + exportBitmapFill( xPropSet ); + break; default: WriteFill( xPropSet ); } } +void ChartExport::exportBitmapFill( Reference< XPropertySet > xPropSet ) +{ + if( xPropSet.is() ) + { + OUString sFillGradientName; + xPropSet->getPropertyValue("FillBitmapName") >>= sFillGradientName; + + uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY ); + try + { + uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); + uno::Any rValue = xGradient->getByName( sFillGradientName ); + OUString sBitmapURL; + if( (rValue >>= sBitmapURL) ) + { + WriteBlipFill( xPropSet, sBitmapURL, XML_a, true, true ); + } + } + catch( const uno::Exception & rEx ) + { + DBG_WARNING( "Bitmap Property not Found; ChartExport::exportBitmapFill" ); + } + + } +} + void ChartExport::exportGradientFill( Reference< XPropertySet > xPropSet ) { if( xPropSet.is() ) @@ -1191,7 +1220,7 @@ void ChartExport::exportGradientFill( Reference< XPropertySet > xPropSet ) } catch( const uno::Exception & rEx ) { - DBG_WARNING( "Gradient Property not Found; ChartExport::exportPlotAreaGradientFill" ); + DBG_WARNING( "Gradient Property not Found; ChartExport::exportGradientFill" ); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index ee3f9b140999..42fec3f4593d 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -661,7 +661,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) mpFS->endElementNS( XML_a, XML_ln ); } -OUString DrawingML::WriteImage( const OUString& rURL ) +OUString DrawingML::WriteImage( const OUString& rURL, bool bRelPathToMedia ) { OString aURLBS(OUStringToOString(rURL, RTL_TEXTENCODING_UTF8)); @@ -673,7 +673,7 @@ OUString DrawingML::WriteImage( const OUString& rURL ) DBG(fprintf (stderr, "begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + RTL_CONSTASCII_LENGTH( aURLBegin ) )); Graphic aGraphic = GraphicObject( aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin)) ).GetTransformedGraphic (); - return WriteImage( aGraphic ); + return WriteImage( aGraphic , bRelPathToMedia ); } else { // add link to relations } @@ -705,7 +705,7 @@ const char* DrawingML::GetRelationCompPrefix() return "unknown"; } -OUString DrawingML::WriteImage( const Graphic& rGraphic ) +OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) { GfxLink aLink = rGraphic.GetLink (); OUString sMediaType; @@ -780,11 +780,14 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) xOutStream->writeBytes( Sequence< sal_Int8 >( (const sal_Int8*) aData, nDataSize ) ); xOutStream->closeOutput(); + OString sRelPathToMedia = "media/image"; + if ( bRelPathToMedia ) + sRelPathToMedia = "../" + sRelPathToMedia; sRelId = mpFB->addRelation( mpFS->getOutputStream(), "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", OUStringBuffer() .appendAscii( GetRelationCompPrefix() ) - .appendAscii( "media/image" ) + .appendAscii( sRelPathToMedia.getStr() ) .append( (sal_Int32) mnImageCounter ++ ) .appendAscii( pExtension ) .makeStringAndClear() ); @@ -792,9 +795,9 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) return sRelId; } -OUString DrawingML::WriteBlip( Reference< XPropertySet > rXPropSet, OUString& rURL, const Graphic *pGraphic ) +OUString DrawingML::WriteBlip( Reference< XPropertySet > rXPropSet, OUString& rURL, bool bRelPathToMedia, const Graphic *pGraphic ) { - OUString sRelId = pGraphic ? WriteImage( *pGraphic ) : WriteImage( rURL ); + OUString sRelId = pGraphic ? WriteImage( *pGraphic, bRelPathToMedia ) : WriteImage( rURL, bRelPathToMedia ); sal_Int16 nBright = 0; sal_Int32 nContrast = 0; @@ -845,17 +848,27 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sUR if ( GetProperty( rXPropSet, sURLPropName ) ) { OUString aURL; mAny >>= aURL; + bool bWriteMode = false; + if( sURLPropName == "FillBitmapURL" || sURLPropName == "BackGraphicURL") + bWriteMode = true; + WriteBlipFill( rXPropSet, aURL, nXmlNamespace, bWriteMode ); + } +} - DBG(fprintf (stderr, "URL: %s\n", OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() )); +void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sBitmapURL, sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia ) +{ + if ( !sBitmapURL.isEmpty() ) { + DBG(fprintf (stderr, "URL: %s\n", OUStringToOString( sBitmapURL, RTL_TEXTENCODING_UTF8 ).getStr() )); - if( aURL.isEmpty() ) + + if( sBitmapURL.isEmpty() ) return; mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND ); - WriteBlip( rXPropSet, aURL ); + WriteBlip( rXPropSet, sBitmapURL, bRelPathToMedia ); - if( sURLPropName == "FillBitmapURL" || sURLPropName == "BackGraphicURL") + if( bWriteMode ) WriteBlipMode( rXPropSet ); else if( GetProperty( rXPropSet, "FillBitmapStretch" ) ) { bool bStretch = false; @@ -864,7 +877,6 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sUR if( bStretch ) WriteStretch(); } - mpFS->endElementNS( nXmlNamespace, XML_blipFill ); } } diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index cd94303f6c87..f50cab451890 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -507,7 +507,7 @@ void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND ); - WriteBlip( xShapeProps, sGraphicURL, pGraphic ); + WriteBlip( xShapeProps, sGraphicURL, false, pGraphic ); WriteSrcRect( xShapeProps, sGraphicURL ); |