summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 10:25:31 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 10:25:31 +0000
commit95f06f82c2d55e254a268e1e2409b2fda68dfddc (patch)
treeda6ddd356e0932d7b90b421989352cdc9406a027
parent75b528862b759700fe14367d9a64c48123e9703a (diff)
CWS-TOOLING: integrate CWS chart39
2009-06-30 16:55:46 +0200 iha r273522 : #i103209# im-/export attribute xlink:href at chart:chart element + some cleanup in naming 2009-06-30 16:45:59 +0200 iha r273521 : #i102701# apply patch for P1 issue on dev300m50 to be able to save again 2009-06-30 16:32:32 +0200 iha r273520 : #i103209# im-/export attribute xlink:href at chart:chart element + some cleanup in naming 2009-06-29 10:04:34 +0200 iha r273454 : #i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area 2009-06-26 19:31:16 +0200 iha r273437 : #i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area 2009-06-25 10:36:28 +0200 iha r273367 : #i101968# text values in data range cause incorrect x values 2009-06-24 17:34:18 +0200 iha r273357 : #i102428# x values are wrong in xy-scatter-chart with own data table if empty cells are contained in x values 2009-06-24 10:16:25 +0200 iha r273317 : #i99915# wrong matrix translation causes broken chart display for small values 2009-06-19 17:20:06 +0200 iha r273174 : #i78025# charts own borders are not completely visible 2009-06-19 17:18:41 +0200 iha r273172 : #i102950# don't paint additional borders for charts 2009-06-11 16:27:54 +0200 iha r272884 : CWS-TOOLING: rebase CWS chart39 to trunk@272827 (milestone: DEV300:m50) 2009-06-09 17:50:10 +0200 iha r272790 : #i97222# when converting a chart via API to 3D categories get lost and for line,area&xy the stacking mode is wrong 2009-06-09 16:00:27 +0200 iha r272775 : #i98319# data point properties get lost while copying charts from calc to impress 2009-06-09 10:26:51 +0200 iha r272755 : #i98392# correct orienation of gradient fillings on 3D walls 2009-05-29 10:35:16 +0200 iha r272436 : #i100529# Plot missing values - leave gap fails for smoothed lines 2009-05-04 18:20:31 +0200 iha r271478 : #i99841# Title with Vertically stacked attribute is wrong after editing 2009-05-04 18:03:01 +0200 iha r271477 : #i101050# avoid a corner in closed lines, which are smoothed by spline 2009-05-04 16:45:18 +0200 iha r271472 : #i101050# avoid crash in case the normals sequence has less points than the polygon
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dpolygon.cxx17
-rw-r--r--xmloff/inc/SchXMLImport.hxx1
-rw-r--r--xmloff/inc/xmloff/SchXMLExportHelper.hxx7
-rw-r--r--xmloff/inc/xmloff/SchXMLImportHelper.hxx7
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx231
-rw-r--r--xmloff/source/chart/SchXMLChartContext.hxx7
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx51
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx37
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx28
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.hxx6
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx4
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx60
-rw-r--r--xmloff/source/chart/SchXMLTableContext.hxx6
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx105
-rw-r--r--xmloff/source/chart/SchXMLTools.hxx10
15 files changed, 334 insertions, 243 deletions
diff --git a/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx b/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx
index 61d5cc78cb..e61c73c2d8 100644
--- a/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx
+++ b/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx
@@ -75,8 +75,8 @@ namespace sdr
basegfx::B3DPolyPolygon aPolyPolygon3D(GetE3dPolygonObj().GetPolyPolygon3D());
const basegfx::B3DPolyPolygon aPolyNormals3D(GetE3dPolygonObj().GetPolyNormals3D());
const basegfx::B2DPolyPolygon aPolyTexture2D(GetE3dPolygonObj().GetPolyTexture2D());
- const bool bNormals(aPolyNormals3D.count());
- const bool bTexture(aPolyTexture2D.count());
+ const bool bNormals(aPolyNormals3D.count() && aPolyNormals3D.count() == aPolyPolygon3D.count());
+ const bool bTexture(aPolyTexture2D.count() && aPolyTexture2D.count() == aPolyPolygon3D.count());
if(bNormals || bTexture)
{
@@ -100,12 +100,19 @@ namespace sdr
{
if(bNormals)
{
- aCandidate3D.setNormal(b, aNormals3D.getB3DPoint(b));
+ sal_uInt32 nNormalCount = aNormals3D.count();
+ if( b < nNormalCount )
+ aCandidate3D.setNormal(b, aNormals3D.getB3DPoint(b));
+ else if( nNormalCount > 0 )
+ aCandidate3D.setNormal(b, aNormals3D.getB3DPoint(0));
}
-
if(bTexture)
{
- aCandidate3D.setTextureCoordinate(b, aTexture2D.getB2DPoint(b));
+ sal_uInt32 nTextureCount = aTexture2D.count();
+ if( b < nTextureCount )
+ aCandidate3D.setTextureCoordinate(b, aTexture2D.getB2DPoint(b));
+ else if( nTextureCount > 0 )
+ aCandidate3D.setTextureCoordinate(b, aTexture2D.getB2DPoint(0));
}
}
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index ed1c501569..396a2ba5d2 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -102,6 +102,7 @@ enum SchXMLAxisElemTokenMap
enum SchXMLChartAttrMap
{
+ XML_TOK_CHART_HREF,
XML_TOK_CHART_CLASS,
XML_TOK_CHART_WIDTH,
XML_TOK_CHART_HEIGHT,
diff --git a/xmloff/inc/xmloff/SchXMLExportHelper.hxx b/xmloff/inc/xmloff/SchXMLExportHelper.hxx
index 284c6d9662..37b7af0840 100644
--- a/xmloff/inc/xmloff/SchXMLExportHelper.hxx
+++ b/xmloff/inc/xmloff/SchXMLExportHelper.hxx
@@ -233,13 +233,6 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc );
- // if no data provider exists by, now the model (as XChild) is asked for its
- // parent which creates the data provider that is finally set at the chart
- // document
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- GetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
::com::sun::star::awt::Size getPageSize(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc ) const;
diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
index 7630c8e453..e89c1d667e 100644
--- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx
+++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
@@ -143,13 +143,6 @@ public:
sal_Int32 GetLengthOfSeries();
void ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoints = -1 );
- // if no data provider exists by, now the model (as XChild) is asked for its
- // parent which creates the data provider that is finally set at the chart
- // document
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- GetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
/** @param bPushLastChartType If </FALSE>, in case a new chart type has to
be added (because it does not exist yet), it is appended at the
end of the chart-type container. When </TRUE>, a new chart type
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 281f591ee7..f44f23a939 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -228,6 +228,57 @@ void lcl_removeEmptyChartTypeGroups( const uno::Reference< chart2::XChartDocumen
}
}
+uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
+{
+ const sal_Unicode aSpace( ' ' );
+
+ // count number of entries
+ ::std::vector< sal_Int32 > aVec;
+ sal_Int32 nLastPos = 0;
+ sal_Int32 nPos = 0;
+ while( nPos != -1 )
+ {
+ nPos = rStr.indexOf( aSpace, nLastPos );
+ if( nPos > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
+ }
+ if( nPos != -1 )
+ nLastPos = nPos + 1;
+ }
+ // last entry
+ if( nLastPos != 0 &&
+ rStr.getLength() > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
+ }
+
+ const sal_Int32 nVecSize = aVec.size();
+ uno::Sequence< sal_Int32 > aSeq( nVecSize );
+
+ if(!bAddOneToEachOldIndex)
+ {
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos ] = aVec[ nPos ];
+ }
+ }
+ else if( bAddOneToEachOldIndex )
+ {
+ aSeq.realloc( nVecSize+1 );
+ aSeq[0]=0;
+
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
+ }
+ }
+
+ return aSeq;
+}
+
} // anonymous namespace
static __FAR_DATA SvXMLEnumMapEntry aXMLLegendAlignmentMap[] =
@@ -249,7 +300,8 @@ SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
mrImportHelper( rImpHelper ),
- mbHasOwnTable( sal_True ),
+ m_bHasRangeAtPlotArea( false ),
+ m_bHasTableElement( false ),
mbAllRangeAddressesAvailable( sal_True ),
mbColHasLabels( sal_False ),
mbRowHasLabels( sal_False ),
@@ -283,6 +335,10 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut
switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
{
+ case XML_TOK_CHART_HREF:
+ m_aXLinkHRefAttributeToIndicateDataProvider = aValue;
+ break;
+
case XML_TOK_CHART_CLASS:
{
rtl::OUString sClassName;
@@ -606,14 +662,21 @@ bool lcl_SpecialHandlingForDonutChartNeeded(
} // anonymous namespace
-void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
- const uno::Reference< chart2::XChartDocument >& xNewDoc )
+
+void lcl_ApplyDataFromRectangularRangeToDiagram(
+ const uno::Reference< chart2::XChartDocument >& xNewDoc
+ , const rtl::OUString& rRectangularRange
+ , ::com::sun::star::chart::ChartDataRowSource eDataRowSource
+ , bool bRowHasLabels, bool bColHasLabels
+ , bool bSwitchOnLabelsAndCategoriesForOwnData
+ , const rtl::OUString& sColTrans
+ , const rtl::OUString& sRowTrans )
{
if( !xNewDoc.is() )
return;
uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
- uno::Reference< chart2::data::XDataProvider > xDataProvider( mrImportHelper.GetDataProvider( xNewDoc ) );
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
if( !xNewDia.is() || !xDataProvider.is() )
return;
@@ -622,11 +685,11 @@ void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
return;
sal_Bool bFirstCellAsLabel =
- (meDataRowSource==chart::ChartDataRowSource_COLUMNS)? mbRowHasLabels : mbColHasLabels;
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
sal_Bool bHasCateories =
- (meDataRowSource==chart::ChartDataRowSource_COLUMNS)? mbColHasLabels : mbRowHasLabels;
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
- if( mbHasOwnTable )
+ if( bSwitchOnLabelsAndCategoriesForOwnData )
{
bFirstCellAsLabel = true;
bHasCateories = true;
@@ -635,25 +698,25 @@ void SchXMLChartContext::ChangeDiagramAccordingToTemplate(
uno::Sequence< beans::PropertyValue > aArgs( 3 );
aArgs[0] = beans::PropertyValue(
::rtl::OUString::createFromAscii("CellRangeRepresentation"),
- -1, uno::makeAny( msChartAddress ),
+ -1, uno::makeAny( rRectangularRange ),
beans::PropertyState_DIRECT_VALUE );
aArgs[1] = beans::PropertyValue(
::rtl::OUString::createFromAscii("DataRowSource"),
- -1, uno::makeAny( meDataRowSource ),
+ -1, uno::makeAny( eDataRowSource ),
beans::PropertyState_DIRECT_VALUE );
aArgs[2] = beans::PropertyValue(
::rtl::OUString::createFromAscii("FirstCellAsLabel"),
-1, uno::makeAny( bFirstCellAsLabel ),
beans::PropertyState_DIRECT_VALUE );
- if( msColTrans.getLength() || msRowTrans.getLength() )
+ if( sColTrans.getLength() || sRowTrans.getLength() )
{
aArgs.realloc( aArgs.getLength() + 1 );
aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue(
::rtl::OUString::createFromAscii("SequenceMapping"),
- -1, uno::makeAny( msColTrans.getLength()
- ? GetNumberSequenceFromString( msColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
- : GetNumberSequenceFromString( msRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
+ -1, uno::makeAny( sColTrans.getLength()
+ ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
+ : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
beans::PropertyState_DIRECT_VALUE );
}
@@ -766,21 +829,36 @@ void SchXMLChartContext::EndElement()
if(!xNewDoc.is())
return;
- // if we already have an internal data provider, we know that we cannot have
- // external data here. If we can have external data but know that we have
- // internal data due to missing ranges, we must create an internal data
- // provider
+ bool bHasOwnData = false;
+ if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bHasOwnData = true;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bHasOwnData = false;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself if data are available
+ bHasOwnData = m_bHasTableElement;
+ else
+ bHasOwnData = !m_bHasRangeAtPlotArea;
+
if( xNewDoc->hasInternalDataProvider())
- mbHasOwnTable = true;
- else if( mbHasOwnTable )
+ {
+ if( !m_bHasTableElement && !m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) )
+ {
+ //#i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
+ bool bSwitchSuccessful = SchXMLTools::switchBackToDataProviderFromParent( xNewDoc, maLSequencesPerIndex );
+ bHasOwnData = !bSwitchSuccessful;
+ }
+ else
+ bHasOwnData = true;//e.g. in case of copy->paste from calc to impress
+ }
+ else if( bHasOwnData )
{
xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
}
- if( mbHasOwnTable )
+ if( bHasOwnData )
msChartAddress = ::rtl::OUString::createFromAscii("all");
- bool bPostProcessTable = false;
- if( !mbHasOwnTable && mbAllRangeAddressesAvailable )
+ bool bSwitchRangesFromOuterToInternalIfNecessary = false;
+ if( !bHasOwnData && mbAllRangeAddressesAvailable )
{
// special handling for stock chart (merge series together)
if( mbIsStockChart )
@@ -788,24 +866,28 @@ void SchXMLChartContext::EndElement()
}
else if( msChartAddress.getLength() )
{
- // in this case there are range addresses that are simply wrong.
+ //own data or only rectangular range available
+
bool bOlderThan2_3 = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( Reference< frame::XModel >( xNewDoc, uno::UNO_QUERY ));
- bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && mbHasOwnTable && (meDataRowSource==chart::ChartDataRowSource_ROWS));
+ bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (meDataRowSource==chart::ChartDataRowSource_ROWS)); // in this case there are range addresses that are simply wrong.
+
if( mbAllRangeAddressesAvailable && !bSpecialHandlingForDonutChart && !mbIsStockChart &&
!bOldFileWithOwnDataFromRows )
{
- // note: mbRowHasLabels means the first row contains labels, that
- // means we have "column-descriptions", (analogously mbColHasLabels
- // means we have "row-descriptions")
- SchXMLTableHelper::applyTable( maTable, xNewDoc );
- bPostProcessTable = true;
+ //bHasOwnData is true in this case!
+ //e.g. for normal files with own data or also in case of copy paste scenario (e.g. calc to impress)
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+ bSwitchRangesFromOuterToInternalIfNecessary = true;
}
else
{
+ //apply data from rectangular range
+
// apply data read from the table sub-element to the chart
// if the data provider supports the XChartDataArray interface like
// the internal data provider
- uno::Reference< chart::XChartDataArray > xChartData( mrImportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ uno::Reference< chart::XChartDataArray > xChartData( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( xChartData.is())
SchXMLTableHelper::applyTableSimple( maTable, xChartData );
@@ -815,29 +897,32 @@ void SchXMLChartContext::EndElement()
{
if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly
xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IncludeHiddenCells")),uno::makeAny(false));
- ChangeDiagramAccordingToTemplate( xNewDoc );
+
+ // note: mbRowHasLabels means the first row contains labels, that means we have "column-descriptions",
+ // (analogously mbColHasLabels means we have "row-descriptions")
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
}
catch( uno::Exception & )
{
//try to fallback to internal data
- DBG_ERROR( "Exception during import SchXMLChartContext::ChangeDiagramAccordingToTemplate try to fallback to internal data" );
- if(!mbHasOwnTable)
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
+ if(!bHasOwnData)
{
- mbHasOwnTable = true;
+ bHasOwnData = true;
msChartAddress = ::rtl::OUString::createFromAscii("all");
if( !xNewDoc->hasInternalDataProvider() )
{
xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
- xChartData = uno::Reference< chart::XChartDataArray >( mrImportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ xChartData = uno::Reference< chart::XChartDataArray >( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( xChartData.is())
SchXMLTableHelper::applyTableSimple( maTable, xChartData );
try
{
- ChangeDiagramAccordingToTemplate( xNewDoc );
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
}
catch( uno::Exception & )
{
- DBG_ERROR( "Exception during import SchXMLChartContext::ChangeDiagramAccordingToTemplate fallback to internal data failed also" );
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
}
}
}
@@ -893,16 +978,23 @@ void SchXMLChartContext::EndElement()
SchXMLSeries2Context::setStylesToStatisticsObjects( maSeriesDefaultsAndStyles
, pStylesCtxt, pStyle, sCurrStyleName );
}
+ }
+ //#i98319# call switchRangesFromOuterToInternalIfNecessary before the data point styles are applied, otherwise in copy->paste scenario the data point styles do get lost
+ if( bSwitchRangesFromOuterToInternalIfNecessary )
+ {
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
+ }
+
+ if( pStylesCtxt )
+ {
// ... then iterate over data-point attributes, so the latter are not overwritten
SchXMLSeries2Context::setStylesToDataPoints( maSeriesDefaultsAndStyles
, pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, bSpecialHandlingForDonutChart, bSwitchOffLinesForScatter );
}
}
- if( bPostProcessTable )
- SchXMLTableHelper::postProcessTable( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
-
if( xProp.is())
xProp->setPropertyValue( rtl::OUString::createFromAscii( "RefreshAddInAllowed" ) , uno::makeAny( sal_True) );
}
@@ -1003,8 +1095,9 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
{
case XML_TOK_CHART_PLOT_AREA:
pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(), rLocalName,
+ m_aXLinkHRefAttributeToIndicateDataProvider,
maSeriesAddresses, msCategoriesAddress,
- msChartAddress, mbHasOwnTable, mbAllRangeAddressesAvailable,
+ msChartAddress, m_bHasRangeAtPlotArea, mbAllRangeAddressesAvailable,
mbColHasLabels, mbRowHasLabels,
meDataRowSource,
maSeriesDefaultsAndStyles,
@@ -1046,6 +1139,7 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
{
SchXMLTableContext * pTableContext =
new SchXMLTableContext( mrImportHelper, GetImport(), rLocalName, maTable );
+ m_bHasTableElement = true;
// #i85913# take into account column- and row- mapping for
// charts with own data only for those which were not copied
// from a place where they got data from the container. Note,
@@ -1060,12 +1154,12 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext(
if( msColTrans.getLength() > 0 )
{
OSL_ASSERT( msRowTrans.getLength() == 0 );
- pTableContext->setColumnPermutation( GetNumberSequenceFromString( msColTrans, true ));
+ pTableContext->setColumnPermutation( lcl_getNumberSequenceFromString( msColTrans, true ));
msColTrans = OUString();
}
else if( msRowTrans.getLength() > 0 )
{
- pTableContext->setRowPermutation( GetNumberSequenceFromString( msRowTrans, true ));
+ pTableContext->setRowPermutation( lcl_getNumberSequenceFromString( msRowTrans, true ));
msRowTrans = OUString();
}
}
@@ -1143,57 +1237,6 @@ void SchXMLChartContext::InitChart(
}
}
-uno::Sequence< sal_Int32 > SchXMLChartContext::GetNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
-{
- const sal_Unicode aSpace( ' ' );
-
- // count number of entries
- ::std::vector< sal_Int32 > aVec;
- sal_Int32 nLastPos = 0;
- sal_Int32 nPos = 0;
- while( nPos != -1 )
- {
- nPos = rStr.indexOf( aSpace, nLastPos );
- if( nPos > nLastPos )
- {
- aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
- }
- if( nPos != -1 )
- nLastPos = nPos + 1;
- }
- // last entry
- if( nLastPos != 0 &&
- rStr.getLength() > nLastPos )
- {
- aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
- }
-
- const sal_Int32 nVecSize = aVec.size();
- uno::Sequence< sal_Int32 > aSeq( nVecSize );
-
- if(!bAddOneToEachOldIndex)
- {
- sal_Int32* pSeqArr = aSeq.getArray();
- for( nPos = 0; nPos < nVecSize; ++nPos )
- {
- pSeqArr[ nPos ] = aVec[ nPos ];
- }
- }
- else if( bAddOneToEachOldIndex )
- {
- aSeq.realloc( nVecSize+1 );
- aSeq[0]=0;
-
- sal_Int32* pSeqArr = aSeq.getArray();
- for( nPos = 0; nPos < nVecSize; ++nPos )
- {
- pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
- }
- }
-
- return aSeq;
-}
-
// ----------------------------------------
SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index 573cac8645..bfb823fa94 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -114,7 +114,9 @@ private:
::rtl::OUString maMainTitle, maSubTitle;
com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos;
- sal_Bool mbHasOwnTable;
+ ::rtl::OUString m_aXLinkHRefAttributeToIndicateDataProvider;
+ bool m_bHasRangeAtPlotArea;
+ bool m_bHasTableElement;
sal_Bool mbAllRangeAddressesAvailable;
sal_Bool mbColHasLabels;
sal_Bool mbRowHasLabels;
@@ -147,9 +149,6 @@ private:
const ::rtl::OUString & rChartTypeServiceName,
sal_Bool bSetSwitchData);
- void ChangeDiagramAccordingToTemplate(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xNewDoc );
- ::com::sun::star::uno::Sequence< sal_Int32 > GetNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex );
void MergeSeriesForStockChart();
};
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index b4d5f9ca80..25bcf43171 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -353,8 +353,10 @@ bool lcl_isSeriesAttachedToFirstAxis(
OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc )
{
OUString aResult = rRange;
+ if( !xDoc.is() )
+ return aResult;
Reference< chart2::data::XRangeXMLConversion > xConversion(
- SchXMLExportHelper::GetDataProvider( xDoc ), uno::UNO_QUERY );
+ xDoc->getDataProvider(), uno::UNO_QUERY );
if( xConversion.is())
aResult = xConversion->convertRangeToXML( rRange );
return aResult;
@@ -1114,6 +1116,16 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha
if( bExportContent )
{
+ //export data provider in xlink:href attribute
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
+ {
+ OUString aDataProviderURL( RTL_CONSTASCII_USTRINGPARAM( ".." ) );
+ if( xNewDoc->hasInternalDataProvider() )
+ aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL );
+ }
+
OUString sChartType( xDiagram->getDiagramType() );
// attributes
@@ -3521,7 +3533,7 @@ void SchXMLExport::_ExportContent()
// check if we have own data. If so we must not export the complete
// range string, as this is our only indicator for having own or
// external data. @todo: fix this in the file format!
- Reference< lang::XServiceInfo > xDPServiceInfo( maExportHelper.GetDataProvider( xNewDoc ), uno::UNO_QUERY );
+ Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
if( ! (xDPServiceInfo.is() &&
xDPServiceInfo->getImplementationName().equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ))))
@@ -3581,45 +3593,12 @@ void SchXMLExport::SetProgress( sal_Int32 nPercentage )
mxStatusIndicator->setValue( nPercentage );
}
-// static
-Reference< chart2::data::XDataProvider > SchXMLExportHelper::GetDataProvider(
- const Reference< chart2::XChartDocument > & xDoc )
-{
- Reference< chart2::data::XDataProvider > xResult;
- if( xDoc.is())
- {
- xResult.set( xDoc->getDataProvider());
- // allowed to attach a new data provider in export?
-// if( ! xResult.is())
-// {
-// Reference< container::XChild > xChild( xDoc, uno::UNO_QUERY );
-// if( xChild.is())
-// {
-// Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
-// if( xFact.is())
-// {
-// xResult.set(
-// xFact->createInstance( OUString::createFromAscii("com.sun.star.chart2.data.DataProvider")),
-// uno::UNO_QUERY );
-// if( xResult.is())
-// {
-// Reference< chart2::data::XDataReceiver > xReceiver( xDoc, uno::UNO_QUERY );
-// if( xReceiver.is())
-// xReceiver->attachDataProvider( xResult );
-// }
-// }
-// }
-// }
- }
- return xResult;
-}
-
void SchXMLExportHelper::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
{
if( xChartDoc.is())
try
{
- Reference< chart2::data::XDataProvider > xDataProvider( GetDataProvider( xChartDoc ));
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
if( xDataProvider.is())
{
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 1576bd263c..7dde79f930 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -346,6 +346,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap()
{
static __FAR_DATA SvXMLTokenMapEntry aChartAttrTokenMap[] =
{
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_CHART_HREF },
{ XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_CHART_CLASS },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_CHART_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CHART_HEIGHT },
@@ -614,38 +615,6 @@ void SchXMLImportHelper::ResizeChartData( sal_Int32 nSeries, sal_Int32 nDataPoin
}
}
-// static
-Reference< chart2::data::XDataProvider > SchXMLImportHelper::GetDataProvider(
- const Reference< chart2::XChartDocument > & xDoc )
-{
- Reference< chart2::data::XDataProvider > xResult;
- if( xDoc.is())
- {
- try
- {
- xResult.set( xDoc->getDataProvider());
-// if( ! xResult.is())
-// {
-// Reference< container::XChild > xChild( xDoc, uno::UNO_QUERY_THROW );
-// Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
-// if( xFact.is())
-// {
-// Reference< chart2::data::XDataReceiver > xReceiver( xDoc, uno::UNO_QUERY_THROW );
-// xResult.set(
-// xFact->createInstance( OUString::createFromAscii("com.sun.star.chart2.data.DataProvider")),
-// uno::UNO_QUERY_THROW );
-// xReceiver->attachDataProvider( xResult );
-// }
-// }
- }
- catch( const uno::Exception & )
- {
- // didn't get a data provider from the container
- }
- }
- return xResult;
-}
-
//static
void SchXMLImportHelper::DeleteDataSeries(
const Reference< chart2::XDataSeries > & xSeries,
@@ -796,6 +765,8 @@ SchXMLImport::SchXMLImport(
sal_uInt16 nImportFlags ) :
SvXMLImport( xServiceFactory, nImportFlags )
{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+
mbIsGraphicLoadOnDemandSupported = false;
}
@@ -807,6 +778,8 @@ SchXMLImport::SchXMLImport(
sal_Bool /*bLoadDoc*/, sal_Bool bShowProgress )
: SvXMLImport( xServiceFactory, xModel, rGrfContainer )
{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+
// get status indicator (if requested)
if( bShowProgress )
{
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index 81affca7d5..3d8a8495f4 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -108,8 +108,10 @@ struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
{
OUString aResult = rRange;
+ if(!xDoc.is())
+ return aResult;
uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
- SchXMLImportHelper::GetDataProvider( xDoc ), uno::UNO_QUERY );
+ xDoc->getDataProvider(), uno::UNO_QUERY );
if( xConversion.is())
aResult = xConversion->convertRangeFromXML( rRange );
return aResult;
@@ -177,10 +179,11 @@ SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
SchXMLPlotAreaContext::SchXMLPlotAreaContext(
SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
uno::Sequence< chart::ChartSeriesAddress >& rSeriesAddresses,
::rtl::OUString& rCategoriesAddress,
::rtl::OUString& rChartAddress,
- sal_Bool & rHasOwnTable,
+ bool& rbHasRangeAtPlotArea,
sal_Bool & rAllRangeAddressesAvailable,
sal_Bool & rColHasLabels,
sal_Bool & rRowHasLabels,
@@ -203,8 +206,9 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext(
mbHasPosition(false),
mbPercentStacked(false),
m_bAxisPositionAttributeImported(false),
+ m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
mrChartAddress( rChartAddress ),
- mrHasOwnTable( rHasOwnTable ),
+ m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
mrColHasLabels( rColHasLabels ),
mrRowHasLabels( rRowHasLabels ),
mrDataRowSource( rDataRowSource ),
@@ -213,6 +217,8 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext(
mbGlobalChartTypeUsedBySeries( false ),
maChartSize( rChartSize )
{
+ m_rbHasRangeAtPlotArea = false;
+
// get Diagram
uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
if( xDoc.is())
@@ -338,7 +344,7 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri
case XML_TOK_PA_CHART_ADDRESS:
mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
// indicator for getting data from the outside
- mrHasOwnTable = sal_False;
+ m_rbHasRangeAtPlotArea = true;
break;
case XML_TOK_PA_DS_HAS_LABELS:
{
@@ -514,7 +520,17 @@ void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttri
}
//
- if( mrHasOwnTable && mxNewDoc.is())
+ bool bCreateInternalDataProvider = false;
+ if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bCreateInternalDataProvider = true;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bCreateInternalDataProvider = false;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
+ bCreateInternalDataProvider = true;
+ else if( !m_rbHasRangeAtPlotArea )
+ bCreateInternalDataProvider = true;
+
+ if( bCreateInternalDataProvider && mxNewDoc.is() )
{
// we have no complete range => we have own data, so switch the data
// provider to internal. Clone is not necessary, as we don't have any
@@ -625,7 +641,7 @@ void SchXMLPlotAreaContext::EndElement()
if( mrCategoriesAddress.getLength() && mxNewDoc.is())
{
uno::Reference< chart2::data::XDataProvider > xDataProvider(
- mrImportHelper.GetDataProvider( mxNewDoc ));
+ mxNewDoc->getDataProvider() );
// @todo: correct coordinate system index
sal_Int32 nDimension( 0 );
::std::vector< SchXMLAxis >::const_iterator aIt(
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
index 0a4a1ba9f9..9ec09f3f07 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -74,11 +74,12 @@ class SchXMLPlotAreaContext : public SvXMLImportContext
public:
SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
::com::sun::star::uno::Sequence<
::com::sun::star::chart::ChartSeriesAddress >& rSeriesAddresses,
::rtl::OUString& rCategoriesAddress,
::rtl::OUString& rChartAddress,
- sal_Bool & rHasOwnTable,
+ bool& bHasRangeAtPlotArea,
sal_Bool & rAllRangeAddressesAvailable,
sal_Bool & rColHasLabels,
sal_Bool & rRowHasLabels,
@@ -119,8 +120,9 @@ private:
bool mbPercentStacked;
bool m_bAxisPositionAttributeImported;
::rtl::OUString msAutoStyleName;
+ const ::rtl::OUString& m_rXLinkHRefAttributeToIndicateDataProvider;
::rtl::OUString& mrChartAddress;
- sal_Bool & mrHasOwnTable;
+ bool& m_rbHasRangeAtPlotArea;
sal_Bool & mrColHasLabels;
sal_Bool & mrRowHasLabels;
::com::sun::star::chart::ChartDataRowSource & mrDataRowSource;
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index d37e9206ee..2702ec94e9 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -341,7 +341,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
if( mxNewDoc.is())
- xRangeConversion.set( mrImportHelper.GetDataProvider( mxNewDoc ), uno::UNO_QUERY );
+ xRangeConversion.set( mxNewDoc->getDataProvider(), uno::UNO_QUERY );
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -409,7 +409,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
- Reference< chart2::data::XDataProvider > xDataProvider( mrImportHelper.GetDataProvider( mxNewDoc ));
+ Reference< chart2::data::XDataProvider > xDataProvider( mxNewDoc->getDataProvider() );
if( xDataProvider.is())
{
bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index cacdc1307e..8681ecea36 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -343,37 +343,6 @@ void lcl_fillRangeMapping(
}
}
-void lcl_copyProperties(
- const Reference< beans::XPropertySet > & xSource,
- const Reference< beans::XPropertySet > & xDestination )
-{
- if( ! (xSource.is() && xDestination.is()))
- return;
-
- try
- {
- Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_QUERY_THROW );
- Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
- const sal_Int32 nLength = aProperties.getLength();
- for( sal_Int32 i = 0; i < nLength; ++i )
- {
- OUString aName( aProperties[i].Name);
- if( xDestInfo->hasPropertyByName( aName ))
- {
- beans::Property aProp( xDestInfo->getPropertyByName( aName ));
- if( (aProp.Attributes & beans::PropertyAttribute::READONLY) == 0 )
- xDestination->setPropertyValue(
- aName, xSource->getPropertyValue( aName ));
- }
- }
- }
- catch( const uno::Exception & )
- {
- OSL_ENSURE( false, "Copying property sets failed!" );
- }
-}
-
Reference< chart2::data::XDataSequence >
lcl_reassignDataSequence(
const Reference< chart2::data::XDataSequence > & xSequence,
@@ -1016,7 +985,7 @@ void SchXMLTableHelper::applyTableSimple(
// ----------------------------------------
-void SchXMLTableHelper::applyTable(
+void SchXMLTableHelper::applyTableToInternalDataProvider(
const SchXMLTable& rTable,
uno::Reference< chart2::XChartDocument > xChartDoc )
{
@@ -1031,19 +1000,12 @@ void SchXMLTableHelper::applyTable(
// prerequisite for this method: all objects (data series, domains, etc.)
// need their own range string.
- // If the range-strings are valid (starting with "local-table") they should
- // be interpreted like given, otherwise (when the ranges refer to Calc- or
- // Writer-ranges, but the container is not available like when pasting a
- // chart from Calc to Impress) the range is ignored, and every object gets
- // one table column in the order of appearance, which is: 1. categories,
- // 2. data series: 2.a) domains, 2.b) values (main-role, usually y-values)
-
// apply all data read in the table to the chart data-array of the internal
// data provider
lcl_applyXMLTableToInternalDataprovider( rTable, xDataArray );
}
-void SchXMLTableHelper::postProcessTable(
+void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
const SchXMLTable& rTable,
const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
uno::Reference< chart2::XChartDocument > xChartDoc,
@@ -1051,6 +1013,14 @@ void SchXMLTableHelper::postProcessTable(
{
if( ! (xChartDoc.is() && xChartDoc->hasInternalDataProvider()))
return;
+
+ // If the range-strings are valid (starting with "local-table") they should
+ // be interpreted like given, otherwise (when the ranges refer to Calc- or
+ // Writer-ranges, but the container is not available like when pasting a
+ // chart from Calc to Impress) the range is ignored, and every object gets
+ // one table column in the order of appearance, which is: 1. categories,
+ // 2. data series: 2.a) domains, 2.b) values (main-role, usually y-values)
+
Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider());
// create a mapping from original ranges to new ranges
@@ -1079,7 +1049,7 @@ void SchXMLTableHelper::postProcessTable(
lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
if( xNewSeq != xSeq )
{
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSeq );
}
@@ -1099,7 +1069,7 @@ void SchXMLTableHelper::postProcessTable(
Reference< chart2::data::XDataSequence > xNewSequence(
xDataProv->createDataSequenceByRangeRepresentation(
OUString(RTL_CONSTASCII_USTRINGPARAM("categories"))));
- lcl_copyProperties(
+ SchXMLTools::copyProperties(
xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSequence );
bCategoriesApplied = true;
@@ -1110,7 +1080,7 @@ void SchXMLTableHelper::postProcessTable(
OUString aRep( OUString::valueOf( aLSeqIt->first.first ));
Reference< chart2::data::XDataSequence > xNewSequence(
xDataProv->createDataSequenceByRangeRepresentation( aRep ));
- lcl_copyProperties(
+ SchXMLTools::copyProperties(
xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
aLSeqIt->second->setValues( xNewSequence );
}
@@ -1131,7 +1101,7 @@ void SchXMLTableHelper::postProcessTable(
lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
if( xNewSeq != xSeq )
{
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setLabel( xNewSeq );
}
@@ -1143,7 +1113,7 @@ void SchXMLTableHelper::postProcessTable(
Reference< chart2::data::XDataSequence > xNewSeq(
xDataProv->createDataSequenceByRangeRepresentation( aRep ));
- lcl_copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
aLSeqIt->second->setLabel( xNewSeq );
}
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx
index 461426f118..a49c70b8a8 100644
--- a/xmloff/source/chart/SchXMLTableContext.hxx
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -108,14 +108,14 @@ public:
table, the addresses of series, the addresses of labels,
the cell-range-address for the categories
*/
- static void applyTable( const SchXMLTable& rTable,
+ static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
- /** Second part of applyTable that has to be called after the data series
+ /** Second part of applyTableToInternalDataProvider that has to be called after the data series
got their styles set. This function reorders local data to fit the
correct data structure.
*/
- static void postProcessTable( const SchXMLTable& rTable,
+ static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable,
const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
::com::sun::star::chart::ChartDataRowSource eDataRowSource );
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index a453cd5d7a..b1db2ec8c5 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -54,8 +54,10 @@
#include <xmloff/xmlexp.hxx>
#include "xmlnmspe.hxx"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
@@ -123,6 +125,24 @@ sal_Int32 lcl_getBuildIDFromGenerator( const ::rtl::OUString& rGenerator )
return nBuildId;
}
+Reference< chart2::data::XDataSequence > lcl_createNewSequenceFromCachedXMLRange( const Reference< chart2::data::XDataSequence >& xSeq, const Reference< chart2::data::XDataProvider >& xDataProvider )
+{
+ Reference< chart2::data::XDataSequence > xRet;
+ OUString aRange;
+ Reference< chart2::data::XRangeXMLConversion > xRangeConversion( xDataProvider, uno::UNO_QUERY );
+ if( xRangeConversion.is() )
+ {
+ if( xSeq.is() && SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) )
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation(
+ xRangeConversion->convertRangeFromXML( aRange )) );
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xRet, uno::UNO_QUERY ));
+ }
+ }
+ return xRet;
+}
+
} // anonymous namespace
// ----------------------------------------
@@ -591,6 +611,68 @@ bool getXMLRangePropertyFromDataSequence(
return bResult;
}
+void copyProperties(
+ const Reference< beans::XPropertySet > & xSource,
+ const Reference< beans::XPropertySet > & xDestination )
+{
+ if( ! (xSource.is() && xDestination.is()) )
+ return;
+
+ try
+ {
+ Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
+ const sal_Int32 nLength = aProperties.getLength();
+ for( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ OUString aName( aProperties[i].Name);
+ if( xDestInfo->hasPropertyByName( aName ))
+ {
+ beans::Property aProp( xDestInfo->getPropertyByName( aName ));
+ if( (aProp.Attributes & beans::PropertyAttribute::READONLY) == 0 )
+ xDestination->setPropertyValue(
+ aName, xSource->getPropertyValue( aName ));
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ OSL_ENSURE( false, "Copying property sets failed!" );
+ }
+}
+
+bool switchBackToDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc, const tSchXMLLSequencesPerIndex & rLSequencesPerIndex )
+{
+ //return whether the switch is successful
+ if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() )
+ return false;
+ Reference< chart2::data::XDataProvider > xDataProviderFromParent( SchXMLTools::getDataProviderFromParent( xChartDoc ) );
+ if( !xDataProviderFromParent.is() )
+ return false;
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY );
+ if( !xDataReceiver.is() )
+ return false;
+
+ xDataReceiver->attachDataProvider( xDataProviderFromParent );
+
+ for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin() );
+ aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( aLSeqIt->second );
+ if( !xLabeledSeq.is() )
+ continue;
+ Reference< chart2::data::XDataSequence > xNewSeq;
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getValues(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setValues( xNewSeq );
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getLabel(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setLabel( xNewSeq );
+ }
+ return true;
+}
+
bool isDocumentGeneratedWithOpenOfficeOlderThan3_0( const uno::Reference< frame::XModel >& xChartModel )
{
bool bResult = isDocumentGeneratedWithOpenOfficeOlderThan2_3( xChartModel );
@@ -649,4 +731,27 @@ bool isDocumentGeneratedWithOpenOfficeOlderThan2_3( const uno::Reference< frame:
return bResult;
}
+Reference< chart2::data::XDataProvider > getDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ Reference< chart2::data::XDataProvider > xRet;
+ uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY );
+ if( xChild.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
+ if( xFact.is() )
+ {
+ const OUString aDataProviderServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"));
+ const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames());
+ const OUString * pBegin = aServiceNames.getConstArray();
+ const OUString * pEnd = pBegin + aServiceNames.getLength();
+ if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd )
+ {
+ xRet = Reference< chart2::data::XDataProvider >(
+ xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY );
+ }
+ }
+ }
+ return xRet;
+}
+
} // namespace SchXMLTools
diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx
index 60a71397f3..eba5a69387 100644
--- a/xmloff/source/chart/SchXMLTools.hxx
+++ b/xmloff/source/chart/SchXMLTools.hxx
@@ -127,6 +127,16 @@ namespace SchXMLTools
::com::sun::star::chart2::data::XDataSequence > & xDataSequence,
::rtl::OUString & rOutXMLRange,
bool bClearProp = false );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > getDataProviderFromParent( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+
+ bool switchBackToDataProviderFromParent( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc
+ , const tSchXMLLSequencesPerIndex & rLSequencesPerIndex );
+
+ void copyProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xDestination );
}
#endif // SCH_XML_TOOLS_HXX_