summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/chart
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2009-07-13 08:56:32 +0000
committerDaniel Rentz <dr@openoffice.org>2009-07-13 08:56:32 +0000
commita386089b5304685c37f9cacf107a374b0083c326 (patch)
tree21a6ad9eb2594aac7739a12d895c8cc588a8b411 /oox/source/drawingml/chart
parentf2f5cbfdd200561ca465eadb3526bfdaba3ef58f (diff)
#i12587# import shapes in charts from MSOOXML
Diffstat (limited to 'oox/source/drawingml/chart')
-rw-r--r--oox/source/drawingml/chart/chartconverter.cxx5
-rw-r--r--oox/source/drawingml/chart/chartspaceconverter.cxx37
-rw-r--r--oox/source/drawingml/chart/chartspacefragment.cxx3
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx19
-rw-r--r--oox/source/drawingml/chart/makefile.mk1
5 files changed, 49 insertions, 16 deletions
diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx
index f4633e3cad66..6358e6b899e6 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -37,6 +37,7 @@
using ::rtl::OUString;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Exception;
+using ::com::sun::star::awt::Size;
using ::com::sun::star::chart2::XChartDocument;
using ::com::sun::star::chart2::data::XDataProvider;
using ::com::sun::star::chart2::data::XDataSequence;
@@ -57,12 +58,12 @@ ChartConverter::~ChartConverter()
}
void ChartConverter::convertFromModel( XmlFilterBase& rFilter,
- ChartSpaceModel& rModel, const Reference< XChartDocument >& rxChartDoc )
+ ChartSpaceModel& rModel, const Reference< XChartDocument >& rxChartDoc, const Size& rChartSize )
{
OSL_ENSURE( rxChartDoc.is(), "ChartConverter::convertFromModel - missing chart document" );
if( rxChartDoc.is() )
{
- ConverterRoot aConvBase( rFilter, *this, rxChartDoc, rModel );
+ ConverterRoot aConvBase( rFilter, *this, rxChartDoc, rChartSize, rModel );
ChartSpaceConverter aSpaceConv( aConvBase, rModel );
aSpaceConv.convertFromModel();
}
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index e6e62af3b5d2..ccd19a2e73e3 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -30,13 +30,15 @@
************************************************************************/
#include "oox/drawingml/chart/chartspaceconverter.hxx"
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
-#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include "oox/core/xmlfilterbase.hxx"
#include "oox/drawingml/chart/chartconverter.hxx"
+#include "oox/drawingml/chart/chartdrawingfragment.hxx"
#include "oox/drawingml/chart/chartspacemodel.hxx"
#include "oox/drawingml/chart/plotareaconverter.hxx"
#include "oox/drawingml/chart/titleconverter.hxx"
@@ -48,6 +50,8 @@ using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::util::XNumberFormatsSupplier;
+using ::com::sun::star::drawing::XDrawPageSupplier;
+using ::com::sun::star::drawing::XShapes;
using ::com::sun::star::chart2::XDiagram;
using ::com::sun::star::chart2::XTitled;
using ::com::sun::star::chart2::data::XDataReceiver;
@@ -85,8 +89,8 @@ void ChartSpaceConverter::convertFromModel()
}
// formatting of the chart background
- PropertySet aPropSet( getChartDocument()->getPageBackground() );
- getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, OBJECTTYPE_CHARTSPACE );
+ PropertySet aBackPropSet( getChartDocument()->getPageBackground() );
+ getFormatter().convertFrameFormatting( aBackPropSet, mrModel.mxShapeProp, OBJECTTYPE_CHARTSPACE );
// convert plot area (container of all chart type groups)
PlotAreaConverter aPlotAreaConv( *this, mrModel.mxPlotArea.getOrCreate() );
@@ -125,10 +129,10 @@ void ChartSpaceConverter::convertFromModel()
}
// legend
- if( mrModel.mxLegend.is() )
+ if( xDiagram.is() && mrModel.mxLegend.is() )
{
LegendConverter aLegendConv( *this, *mrModel.mxLegend );
- aLegendConv.convertFromModel( getChartDocument()->getFirstDiagram() );
+ aLegendConv.convertFromModel( xDiagram );
}
// treatment of missing values
@@ -146,12 +150,25 @@ void ChartSpaceConverter::convertFromModel()
aDiaProp.setProperty( PROP_MissingValueTreatment, nMissingValues );
}
- // set the IncludeHiddenCells property via the old API as only this ensures that the data provider and al created sequences get this flag correctly
- Reference< com::sun::star::chart::XChartDocument > xStandardApiChartDoc( getChartDocument(), UNO_QUERY );
- if( xStandardApiChartDoc.is() )
+ Reference< com::sun::star::chart::XChartDocument > xOldChartDoc( getChartDocument(), UNO_QUERY );
+ if( xOldChartDoc.is() )
+ {
+ /* Set the IncludeHiddenCells property via the old API as only this
+ ensures that the data provider and all created sequences get this
+ flag correctly. */
+ PropertySet aOldDiaProp( xOldChartDoc->getDiagram() );
+ aOldDiaProp.setProperty( PROP_IncludeHiddenCells, !mrModel.mbPlotVisOnly );
+ }
+
+ // embedded drawing shapes
+ if( mrModel.maDrawingPath.getLength() > 0 ) try
+ {
+ Reference< XDrawPageSupplier > xDrawPageSupp( getChartDocument(), UNO_QUERY_THROW );
+ Reference< XShapes > xShapes( xDrawPageSupp->getDrawPage(), UNO_QUERY_THROW );
+ getFilter().importFragment( new ChartDrawingFragment( getFilter(), mrModel.maDrawingPath, xShapes, getChartSize() ) );
+ }
+ catch( Exception& )
{
- PropertySet aStandardApiDiagramProp( xStandardApiChartDoc->getDiagram() );
- aStandardApiDiagramProp.setProperty( PROP_IncludeHiddenCells, !mrModel.mbPlotVisOnly );
}
}
diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx
index c1d23d5d9dbd..10e3128753e0 100644
--- a/oox/source/drawingml/chart/chartspacefragment.cxx
+++ b/oox/source/drawingml/chart/chartspacefragment.cxx
@@ -79,6 +79,9 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const
return 0;
case C_TOKEN( txPr ):
return new TextBodyContext( *this, mrModel.mxTextProp.create() );
+ case C_TOKEN( userShapes ):
+ mrModel.maDrawingPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
+ return 0;
}
break;
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index c9b91e308414..950c351278ee 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -44,6 +44,7 @@ using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::frame::XModel;
+using ::com::sun::star::awt::Size;
using ::com::sun::star::chart2::XChartDocument;
using ::oox::core::XmlFilterBase;
@@ -58,12 +59,14 @@ struct ConverterData
XmlFilterBase& mrFilter;
ChartConverter& mrConverter;
Reference< XChartDocument > mxDoc;
+ Size maSize;
ObjectFormatter maFormatter;
explicit ConverterData(
XmlFilterBase& rFilter,
ChartConverter& rChartConverter,
const Reference< XChartDocument >& rxChartDoc,
+ const Size& rChartSize,
const ChartSpaceModel& rChartSpace );
~ConverterData();
};
@@ -74,11 +77,13 @@ ConverterData::ConverterData(
XmlFilterBase& rFilter,
ChartConverter& rChartConverter,
const Reference< XChartDocument >& rxChartDoc,
- const ChartSpaceModel& rChartSpace ) :
+ const Size& rChartSize,
+ const ChartSpaceModel& rChartModel ) :
mrFilter( rFilter ),
mrConverter( rChartConverter ),
mxDoc( rxChartDoc ),
- maFormatter( rFilter, rxChartDoc, rChartSpace )
+ maSize( rChartSize ),
+ maFormatter( rFilter, rxChartDoc, rChartModel )
{
OSL_ENSURE( mxDoc.is(), "ConverterData::ConverterData - missing chart document" );
// lock the model to suppress internal updates during conversion
@@ -111,8 +116,9 @@ ConverterRoot::ConverterRoot(
XmlFilterBase& rFilter,
ChartConverter& rChartConverter,
const Reference< XChartDocument >& rxChartDoc,
- const ChartSpaceModel& rChartSpace ) :
- mxData( new ConverterData( rFilter, rChartConverter, rxChartDoc, rChartSpace ) )
+ const Size& rChartSize,
+ const ChartSpaceModel& rChartModel ) :
+ mxData( new ConverterData( rFilter, rChartConverter, rxChartDoc, rChartSize, rChartModel ) )
{
}
@@ -155,6 +161,11 @@ Reference< XChartDocument > ConverterRoot::getChartDocument() const
return mxData->mxDoc;
}
+const Size& ConverterRoot::getChartSize() const
+{
+ return mxData->maSize;
+}
+
ObjectFormatter& ConverterRoot::getFormatter() const
{
return mxData->maFormatter;
diff --git a/oox/source/drawingml/chart/makefile.mk b/oox/source/drawingml/chart/makefile.mk
index 6cb46853a7ab..a02d0d5cc4bd 100644
--- a/oox/source/drawingml/chart/makefile.mk
+++ b/oox/source/drawingml/chart/makefile.mk
@@ -50,6 +50,7 @@ SLOFILES = \
$(SLO)$/axismodel.obj \
$(SLO)$/chartcontextbase.obj \
$(SLO)$/chartconverter.obj \
+ $(SLO)$/chartdrawingfragment.obj \
$(SLO)$/chartspaceconverter.obj \
$(SLO)$/chartspacefragment.obj \
$(SLO)$/chartspacemodel.obj \