summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-02-03 11:53:02 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-02-12 02:46:32 +0100
commitffb1053b287fddd2c96757e5c6825381afc43fa1 (patch)
treeab5104f314cd8a83feaceb525e0cb1b8ed952cd7 /oox
parentf38a223d6d455b07a4fdbfe842b2b367306544d5 (diff)
fdo#74115 Fix for DOCX BitmapFill for Chart Wall
Fixed import and export for chart wall Bitmap Fill in DOCX Added UT for the same. Conflicts: oox/source/export/chartexport.cxx Change-Id: Id066b0e4c2007fcdfdbbfa67b40307463bf0cfe7
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/chartexport.cxx31
-rw-r--r--oox/source/export/drawingml.cxx34
-rw-r--r--oox/source/export/shapes.cxx2
3 files changed, 54 insertions, 13 deletions
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 );