diff options
author | sushil_shinde <sushil.shinde@synerzip.com> | 2013-12-27 14:38:53 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-01-16 14:41:05 +0100 |
commit | b1e6269d1c0b312a2990324f0334527d2c04414a (patch) | |
tree | 51d9a5d86a0daf09e88138228906beb8e16a14a3 /oox | |
parent | 5b8a16209f1e1d8fc43157463384f6ab407ac514 (diff) |
fdo#72520 : Exporting sheet external data for chart for docx files.
- Adding external data path relationship for chart[n].xml
for docx files.
- Added Unit Test.
Change-Id: If48ed21237433ddf6659454dda95d720aabdb300
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/chartexport.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 03ec2abd4339..ede7ff989932 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -747,6 +747,8 @@ void ChartExport::exportChartSpace( Reference< ::com::sun::star::chart::XChartDo //XML_chart exportChart(rChartDoc); + exportExternalData(rChartDoc); + // TODO: printSettings // TODO: style // TODO: text properties @@ -757,6 +759,53 @@ void ChartExport::exportChartSpace( Reference< ::com::sun::star::chart::XChartDo pFS->endElement( FSNS( XML_c, XML_chartSpace ) ); } +void ChartExport::exportExternalData( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc ) +{ + // Embedded external data is grab bagged for docx file hence adding export part of + // external data for docx files only. + if(GetDocumentType() != DOCUMENT_DOCX) + return; + + OUString externalDataPath; + Reference< beans::XPropertySet > xDocPropSet( rChartDoc->getDiagram(), uno::UNO_QUERY ); + if( xDocPropSet.is()) + { + try + { + Any aAny( xDocPropSet->getPropertyValue( + OUString( "ExternalData" ))); + aAny >>= externalDataPath; + } + catch( beans::UnknownPropertyException & ) + { + DBG_WARNING( "Required property not found in ChartDocument" ); + } + } + if(!externalDataPath.isEmpty()) + { + // Here adding external data entry to relationship. + OUString relationPath = externalDataPath; + // Converting absolute path to relative path. + if( externalDataPath[ 0 ] != '.' && externalDataPath[ 1 ] != '.') + { + sal_Int32 nStartPos = 0; + sal_Int32 nSepPos = externalDataPath.indexOf( '/', nStartPos ); + if( nSepPos > 0) + { + relationPath = relationPath.copy( nSepPos, ::std::max< sal_Int32 >( externalDataPath.getLength(), 0 ) - nSepPos ); + relationPath = OUStringBuffer( ".." ).append( relationPath ).makeStringAndClear(); + } + } + FSHelperPtr pFS = GetFS(); + OUString sRelId = GetFB()->addRelation(pFS->getOutputStream(), + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package", + relationPath); + pFS->singleElementNS( XML_c, XML_externalData, + FSNS(XML_r, XML_id), OUStringToOString(sRelId, RTL_TEXTENCODING_UTF8), + FSEND); + } +} + void ChartExport::exportChart( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc ) { Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY ); |