diff options
author | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
commit | 8b873ae44c244cf458f16df1e0e422b192ab985d (patch) | |
tree | 4cdd0b914db0f1a2987b018cd8daa6f6b4426100 /xmloff | |
parent | 1851104998e0996874dbebccbfbd4778848f1f17 (diff) | |
parent | a1a2a5a68046e75aba3dfd6ba06083a314f12182 (diff) |
CWS gnumake3: resync to m99
Diffstat (limited to 'xmloff')
23 files changed, 1755 insertions, 1755 deletions
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index 8efabefa47b1..9576341f0ffb 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\ xmloff/source/chart/ColorPropertySet \ xmloff/source/chart/PropertyMaps \ xmloff/source/chart/SchXMLAutoStylePoolP \ + xmloff/source/chart/SchXMLAxisContext \ xmloff/source/chart/SchXMLCalculationSettingsContext \ xmloff/source/chart/SchXMLChartContext \ xmloff/source/chart/SchXMLExport \ diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 7168b2b811a8..936217fb8dc5 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -90,13 +90,6 @@ enum SchXMLSeriesElemTokenMap XML_TOK_SERIES_ERROR_INDICATOR }; -enum SchXMLAxisElemTokenMap -{ - XML_TOK_AXIS_TITLE, - XML_TOK_AXIS_CATEGORIES, - XML_TOK_AXIS_GRID -}; - // ---------------------------------------- enum SchXMLChartAttrMap @@ -134,13 +127,6 @@ enum SchXMLPlotAreaAttrTokenMap XML_TOK_PA_LIGHTING_MODE }; -enum SchXMLAxisAttrTokenMap -{ - XML_TOK_AXIS_DIMENSION, - XML_TOK_AXIS_NAME, - XML_TOK_AXIS_STYLE_NAME -}; - enum SchXMLLegendAttrMap { XML_TOK_LEGEND_POSITION, diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx index 03fa8c8e16c0..d15b19ee5d38 100644 --- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx +++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx @@ -80,11 +80,9 @@ private: SvXMLTokenMap* mpChartElemTokenMap; SvXMLTokenMap* mpPlotAreaElemTokenMap; SvXMLTokenMap* mpSeriesElemTokenMap; - SvXMLTokenMap* mpAxisElemTokenMap; SvXMLTokenMap* mpChartAttrTokenMap; SvXMLTokenMap* mpPlotAreaAttrTokenMap; - SvXMLTokenMap* mpAxisAttrTokenMap; SvXMLTokenMap* mpLegendAttrTokenMap; SvXMLTokenMap* mpAutoStyleAttrTokenMap; SvXMLTokenMap* mpCellAttrTokenMap; @@ -123,11 +121,9 @@ public: const SvXMLTokenMap& GetChartElemTokenMap(); const SvXMLTokenMap& GetPlotAreaElemTokenMap(); const SvXMLTokenMap& GetSeriesElemTokenMap(); - const SvXMLTokenMap& GetAxisElemTokenMap(); const SvXMLTokenMap& GetChartAttrTokenMap(); const SvXMLTokenMap& GetPlotAreaAttrTokenMap(); - const SvXMLTokenMap& GetAxisAttrTokenMap(); const SvXMLTokenMap& GetLegendAttrTokenMap(); const SvXMLTokenMap& GetAutoStyleAttrTokenMap(); const SvXMLTokenMap& GetCellAttrTokenMap(); diff --git a/xmloff/inc/xmloff/formlayerexport.hxx b/xmloff/inc/xmloff/formlayerexport.hxx index c9325139474f..476b2f9d8272 100644 --- a/xmloff/inc/xmloff/formlayerexport.hxx +++ b/xmloff/inc/xmloff/formlayerexport.hxx @@ -165,9 +165,6 @@ namespace xmloff */ bool documentContainsXForms() const; - /// retrieves the property mapper for control styles - ::vos::ORef< SvXMLExportPropertyMapper > getStylePropertyMapper(); - /** exports the controls number styles */ void exportControlNumberStyles(); diff --git a/xmloff/inc/xmloff/formlayerimport.hxx b/xmloff/inc/xmloff/formlayerimport.hxx index 36a2a87a7ad3..37aa8e440444 100644 --- a/xmloff/inc/xmloff/formlayerimport.hxx +++ b/xmloff/inc/xmloff/formlayerimport.hxx @@ -62,11 +62,6 @@ namespace xmloff OFormLayerXMLImport(SvXMLImport& _rImporter); ~OFormLayerXMLImport(); - /** retrieves the property mapper form form related auto styles. - */ - ::vos::ORef< SvXMLImportPropertyMapper > - getStylePropertyMapper() const; - /** start importing the forms of the given page <p>starting the import of a new page (by using this method) invalidates the current page position diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 291c99c7be21..ecadbbdc196f 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3113,6 +3113,14 @@ namespace xmloff { namespace token { XML_OUTSIDE_MINIMUM,//#i114142# XML_OUTSIDE_MAXIMUM,//#i114142# + XML_AXIS_TYPE, //#i25706# + XML_DATE_SCALE, + XML_BASE_TIME_UNIT, + XML_MAJOR_INTERVAL_VALUE, + XML_MINOR_INTERVAL_VALUE, + XML_MAJOR_INTERVAL_UNIT, + XML_MINOR_INTERVAL_UNIT, + XML_MIN_VALUE, XML_MAX_VALUE, diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx new file mode 100755 index 000000000000..d08e4937ff22 --- /dev/null +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -0,0 +1,1053 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_xmloff.hxx" + +#include "SchXMLAxisContext.hxx" +#include "SchXMLChartContext.hxx" +#include "SchXMLTools.hxx" +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmlement.hxx> +#include <xmloff/xmlstyle.hxx> +#include <xmloff/prstylei.hxx> +#include <xmloff/nmspmap.hxx> +#include <xmloff/xmluconv.hxx> + +#include <tools/debug.hxx> + +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <com/sun/star/chart/TimeIncrement.hpp> +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> +#include <com/sun/star/chart/XAxis.hpp> +#include <com/sun/star/chart/XAxisSupplier.hpp> +#include <com/sun/star/chart2/AxisType.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> + +#include <com/sun/star/drawing/LineStyle.hpp> + +using namespace ::xmloff::token; +using namespace com::sun::star; + +using rtl::OUString; +using com::sun::star::uno::Reference; + +//---------------------------------------- +//---------------------------------------- + +static SvXMLEnumMapEntry aXMLAxisDimensionMap[] = +{ + { XML_X, SCH_XML_AXIS_X }, + { XML_Y, SCH_XML_AXIS_Y }, + { XML_Z, SCH_XML_AXIS_Z }, + { XML_TOKEN_INVALID, 0 } +}; + +static SvXMLEnumMapEntry aXMLAxisTypeMap[] = +{ + { XML_AUTO, ::com::sun::star::chart::ChartAxisType::AUTOMATIC }, + { XML_TEXT, ::com::sun::star::chart::ChartAxisType::CATEGORY }, + { XML_DATE, ::com::sun::star::chart::ChartAxisType::DATE }, + { XML_TOKEN_INVALID, 0 } +}; + +//---------------------------------------- +//---------------------------------------- + +class SchXMLCategoriesContext : public SvXMLImportContext +{ +private: + SchXMLImportHelper& m_rImportHelper; + OUString& mrAddress; + +public: + SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + OUString& rAddress ); + virtual ~SchXMLCategoriesContext(); + virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); +}; + +//---------------------------------------- +//---------------------------------------- + + +class DateScaleContext : public SvXMLImportContext +{ +public: + DateScaleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, + sal_uInt16 nPrefix, const OUString& rLocalName, + const Reference< beans::XPropertySet > xAxisProps ); + + virtual ~DateScaleContext(); + virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + +private: + SchXMLImportHelper& m_rImportHelper; + Reference< beans::XPropertySet > m_xAxisProps; +}; + + +//---------------------------------------- +//---------------------------------------- + +SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, const OUString& rLocalName, + Reference< chart::XDiagram > xDiagram, + std::vector< SchXMLAxis >& rAxes, + OUString & rCategoriesAddress, + bool bAddMissingXAxisForNetCharts, + bool bAdaptWrongPercentScaleValues, + bool bAdaptXAxisOrientationForOld2DBarCharts, + bool& rbAxisPositionAttributeImported ) : + SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), + m_rImportHelper( rImpHelper ), + m_xDiagram( xDiagram ), + m_rAxes( rAxes ), + m_rCategoriesAddress( rCategoriesAddress ), + m_nAxisType(chart::ChartAxisType::AUTOMATIC), + m_bAxisTypeImported(false), + m_bDateScaleImported(false), + m_bAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ), + m_bAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ), + m_bAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ), + m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported ) +{ +} + +SchXMLAxisContext::~SchXMLAxisContext() +{} + +Reference< chart::XAxis > lcl_getChartAxis( SchXMLAxis aCurrentAxis, const Reference< chart::XDiagram > xDiagram ) +{ + Reference< chart::XAxis > xAxis; + Reference< chart::XAxisSupplier > xAxisSuppl( xDiagram, uno::UNO_QUERY ); + if( !xAxisSuppl.is() ) + return xAxis; + if( aCurrentAxis.nAxisIndex == 0 ) + xAxis = xAxisSuppl->getAxis(aCurrentAxis.eDimension); + else + xAxis = xAxisSuppl->getSecondaryAxis(aCurrentAxis.eDimension); + return xAxis; +} + +/* returns a shape for the current axis's title. The property + "Has...AxisTitle" is set to "True" to get the shape + */ +Reference< drawing::XShape > SchXMLAxisContext::getTitleShape() +{ + Reference< drawing::XShape > xResult; + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xDiaProp.is() || !xAxis.is() ) + return xResult; + + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii( "HasXAxisTitle" ); + else + aPropName = OUString::createFromAscii( "HasSecondaryXAxisTitle" ); + break; + case SCH_XML_AXIS_Y: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii( "HasYAxisTitle" ); + else + aPropName = OUString::createFromAscii( "HasSecondaryYAxisTitle" ); + break; + case SCH_XML_AXIS_Z: + aPropName = OUString::createFromAscii( "HasZAxisTitle" ); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + xResult = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xResult; +} + +void SchXMLAxisContext::CreateGrid( OUString sAutoStyleName, bool bIsMajor ) +{ + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xDiaProp.is() || !xAxis.is() ) + return; + + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasXAxisGrid"); + else + aPropName = OUString::createFromAscii("HasXAxisHelpGrid"); + break; + case SCH_XML_AXIS_Y: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasYAxisGrid"); + else + aPropName = OUString::createFromAscii("HasYAxisHelpGrid"); + break; + case SCH_XML_AXIS_Z: + if( bIsMajor ) + aPropName = OUString::createFromAscii("HasZAxisGrid"); + else + aPropName = OUString::createFromAscii("HasZAxisHelpGrid"); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + + Reference< beans::XPropertySet > xGridProp; + if( bIsMajor ) + xGridProp = xAxis->getMajorGrid(); + else + xGridProp = xAxis->getMinorGrid(); + + // set properties + if( xGridProp.is()) + { + // the line color is black as default, in the model it is a light gray + xGridProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), + uno::makeAny( COL_BLACK )); + if( sAutoStyleName.getLength()) + { + const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) + { + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + m_rImportHelper.GetChartFamilyID(), sAutoStyleName ); + + if( pStyle && pStyle->ISA( XMLPropStyleContext )) + (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp ); + } + } + } +} + +namespace +{ +enum AxisAttributeTokens +{ + XML_TOK_AXIS_DIMENSION, + XML_TOK_AXIS_NAME, + XML_TOK_AXIS_STYLE_NAME, + XML_TOK_AXIS_TYPE, + XML_TOK_AXIS_TYPE_EXT +}; + +SvXMLTokenMapEntry aAxisAttributeTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION }, + { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME }, + { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME }, + { XML_NAMESPACE_CHART, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE }, + { XML_NAMESPACE_CHART_EXT, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE_EXT }, + XML_TOKEN_MAP_END +}; + +class AxisAttributeTokenMap : public SvXMLTokenMap +{ +public: + AxisAttributeTokenMap(): SvXMLTokenMap( aAxisAttributeTokenMap ) {} + virtual ~AxisAttributeTokenMap() {} +}; + +//a AxisAttributeTokenMap Singleton +struct theAxisAttributeTokenMap : public rtl::Static< AxisAttributeTokenMap, theAxisAttributeTokenMap > {}; +} + +void SchXMLAxisContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + // parse attributes + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + SchXMLImport& rImport = ( SchXMLImport& )GetImport(); + const SvXMLTokenMap& rAttrTokenMap = theAxisAttributeTokenMap::get(); + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + OUString aValue = xAttrList->getValueByIndex( i ); + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName )) + { + case XML_TOK_AXIS_DIMENSION: + { + USHORT nEnumVal; + if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisDimensionMap )) + m_aCurrentAxis.eDimension = ( SchXMLAxisDimension )nEnumVal; + } + break; + case XML_TOK_AXIS_NAME: + m_aCurrentAxis.aName = aValue; + break; + case XML_TOK_AXIS_TYPE: + case XML_TOK_AXIS_TYPE_EXT: + USHORT nEnumVal; + if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisTypeMap )) + { + m_nAxisType = nEnumVal; + m_bAxisTypeImported = true; + } + break; + case XML_TOK_AXIS_STYLE_NAME: + m_aAutoStyleName = aValue; + break; + } + } + + // check for number of axes with same dimension + m_aCurrentAxis.nAxisIndex = 0; + sal_Int32 nNumOfAxes = m_rAxes.size(); + for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) + { + if( m_rAxes[ nCurrent ].eDimension == m_aCurrentAxis.eDimension ) + m_aCurrentAxis.nAxisIndex++; + } + CreateAxis(); +} +namespace +{ + +Reference< chart2::XAxis > lcl_getAxis( const Reference< frame::XModel >& xChartModel, + sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) +{ + Reference< chart2::XAxis > xAxis; + + try + { + Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY ); + if( xChart2Document.is() ) + { + Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram()); + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + uno::Sequence< Reference< chart2::XCoordinateSystem > > + aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + sal_Int32 nCooSysIndex = 0; + if( nCooSysIndex < aCooSysSeq.getLength() ) + { + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] ); + if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() ) + { + const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); + if( nAxisIndex <= nMaxAxisIndex ) + xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); + } + } + } + } + catch( uno::Exception & ) + { + DBG_ERROR( "Couldn't get axis" ); + } + + return xAxis; +} + +bool lcl_divideBy100( uno::Any& rDoubleAny ) +{ + bool bChanged = false; + double fValue=0.0; + if( (rDoubleAny>>=fValue) && (fValue!=0.0) ) + { + fValue/=100.0; + rDoubleAny = uno::makeAny(fValue); + bChanged = true; + } + return bChanged; +} + +bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData) +{ + bool bChanged = lcl_divideBy100( rScaleData.Minimum ); + bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged; + bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged; + bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged; + return bChanged; +} + +}//end anonymous namespace + +void SchXMLAxisContext::CreateAxis() +{ + m_rAxes.push_back( m_aCurrentAxis ); + + Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); + if( !xDiaProp.is() ) + return; + rtl::OUString aPropName; + switch( m_aCurrentAxis.eDimension ) + { + case SCH_XML_AXIS_X: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasXAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryXAxis"); + break; + case SCH_XML_AXIS_Y: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasYAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryYAxis"); + break; + case SCH_XML_AXIS_Z: + if( m_aCurrentAxis.nAxisIndex == 0 ) + aPropName = OUString::createFromAscii("HasXAxis"); + else + aPropName = OUString::createFromAscii("HasSecondaryXAxis"); + break; + case SCH_XML_AXIS_UNDEF: + DBG_ERROR( "Invalid axis" ); + break; + } + try + { + xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on axis" ); + } + if( m_aCurrentAxis.eDimension==SCH_XML_AXIS_Z ) + { + bool bSettingZAxisSuccedded = false; + try + { + xDiaProp->getPropertyValue( aPropName ) >>= bSettingZAxisSuccedded; + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on z axis" ); + } + if( !bSettingZAxisSuccedded ) + return; + } + + + m_xAxisProps = Reference<beans::XPropertySet>( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ), uno::UNO_QUERY ); + + if( m_bAddMissingXAxisForNetCharts && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y && m_aCurrentAxis.nAxisIndex==0 ) + { + try + { + xDiaProp->setPropertyValue( OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Couldn't turn on x axis" ); + } + } + + // set properties + if( m_xAxisProps.is()) + { + uno::Any aTrueBool( uno::makeAny( sal_True )); + uno::Any aFalseBool( uno::makeAny( sal_False )); + + // #i109879# the line color is black as default, in the model it is a light gray + m_xAxisProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), + uno::makeAny( COL_BLACK )); + + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); + + // #88077# AutoOrigin 'on' is default + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AutoOrigin" ), aTrueBool ); + + if( m_bAxisTypeImported ) + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AxisType" ), uno::makeAny(m_nAxisType) ); + + if( m_aAutoStyleName.getLength()) + { + const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); + if( pStylesCtxt ) + { + const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( + m_rImportHelper.GetChartFamilyID(), m_aAutoStyleName ); + + if( pStyle && pStyle->ISA( XMLPropStyleContext )) + { + // note: SvXMLStyleContext::FillPropertySet is not const + XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); + if( pPropStyleContext ) + pPropStyleContext->FillPropertySet( m_xAxisProps ); + + if( m_bAdaptWrongPercentScaleValues && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y ) + { + //set scale data of added x axis back to default + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), + m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData( xAxis->getScaleData()); + if( lcl_AdaptWrongPercentScaleValues(aScaleData) ) + xAxis->setScaleData( aScaleData ); + } + } + + if( m_bAddMissingXAxisForNetCharts ) + { + //copy style from y axis to added x axis: + + Reference< chart::XAxisSupplier > xAxisSuppl( xDiaProp, uno::UNO_QUERY ); + if( xAxisSuppl.is() ) + { + Reference< beans::XPropertySet > xXAxisProp( xAxisSuppl->getAxis(0), uno::UNO_QUERY ); + (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp ); + } + + //set scale data of added x axis back to default + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), + 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData; + aScaleData.AxisType = chart2::AxisType::CATEGORY; + aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL; + xAxis->setScaleData( aScaleData ); + } + + //set line style of added x axis to invisible + Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY ); + if( xNewAxisProp.is() ) + { + xNewAxisProp->setPropertyValue( OUString::createFromAscii("LineStyle") + , uno::makeAny(drawing::LineStyle_NONE)); + } + } + + if( m_bAdaptXAxisOrientationForOld2DBarCharts && m_aCurrentAxis.eDimension == SCH_XML_AXIS_X ) + { + bool bIs3DChart = false; + if( xDiaProp.is() && ( xDiaProp->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart ) + && !bIs3DChart ) + { + Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY ); + if( xChart2Document.is() ) + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY ); + if( xCooSysCnt.is() ) + { + uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); + if( aCooSysSeq.getLength() ) + { + bool bSwapXandYAxis = false; + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); + Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); + if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis ) + && bSwapXandYAxis ) + { + Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, m_aCurrentAxis.nAxisIndex ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData = xAxis->getScaleData(); + aScaleData.Orientation = chart2::AxisOrientation_REVERSE; + xAxis->setScaleData( aScaleData ); + } + } + } + } + } + } + } + + m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext( + OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue(); + } + } + } + } +} + +void SchXMLAxisContext::SetAxisTitle() +{ + if( !m_aCurrentAxis.aTitle.getLength() ) + return; + + Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); + if( !xAxis.is() ) + return; + + Reference< beans::XPropertySet > xTitleProp( xAxis->getAxisTitle() ); + if( xTitleProp.is() ) + { + try + { + xTitleProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), uno::makeAny(m_aCurrentAxis.aTitle) ); + } + catch( beans::UnknownPropertyException & ) + { + DBG_ERROR( "Property String for Title not available" ); + } + } +} + +//----------------------------------------------------------------------- +namespace +{ +enum AxisChildTokens +{ + XML_TOK_AXIS_TITLE, + XML_TOK_AXIS_CATEGORIES, + XML_TOK_AXIS_GRID, + XML_TOK_AXIS_DATE_SCALE, + XML_TOK_AXIS_DATE_SCALE_EXT +}; + +SvXMLTokenMapEntry aAxisChildTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE }, + { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES }, + { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID }, + { XML_NAMESPACE_CHART, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE }, + { XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE_EXT }, + XML_TOKEN_MAP_END +}; + +class AxisChildTokenMap : public SvXMLTokenMap +{ +public: + AxisChildTokenMap(): SvXMLTokenMap( aAxisChildTokenMap ) {} + virtual ~AxisChildTokenMap() {} +}; + +//a AxisChildTokenMap Singleton +struct theAxisChildTokenMap : public rtl::Static< AxisChildTokenMap, theAxisChildTokenMap > {}; +} + +SvXMLImportContext* SchXMLAxisContext::CreateChildContext( + USHORT p_nPrefix, + const OUString& rLocalName, + const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + SvXMLImportContext* pContext = 0; + const SvXMLTokenMap& rTokenMap = theAxisChildTokenMap::get(); + + switch( rTokenMap.Get( p_nPrefix, rLocalName )) + { + case XML_TOK_AXIS_TITLE: + { + Reference< drawing::XShape > xTitleShape = getTitleShape(); + pContext = new SchXMLTitleContext( m_rImportHelper, GetImport(), rLocalName, + m_aCurrentAxis.aTitle, + xTitleShape ); + } + break; + + case XML_TOK_AXIS_CATEGORIES: + pContext = new SchXMLCategoriesContext( m_rImportHelper, GetImport(), + p_nPrefix, rLocalName, + m_rCategoriesAddress ); + m_aCurrentAxis.bHasCategories = true; + break; + + case XML_TOK_AXIS_DATE_SCALE: + case XML_TOK_AXIS_DATE_SCALE_EXT: + pContext = new DateScaleContext( m_rImportHelper, GetImport(), + p_nPrefix, rLocalName, m_xAxisProps ); + m_bDateScaleImported = true; + break; + + case XML_TOK_AXIS_GRID: + { + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + bool bIsMajor = true; // default value for class is "major" + OUString sAutoStyleName; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if( nPrefix == XML_NAMESPACE_CHART ) + { + if( IsXMLToken( aLocalName, XML_CLASS ) ) + { + if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) ) + bIsMajor = false; + } + else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) + sAutoStyleName = xAttrList->getValueByIndex( i ); + } + } + + CreateGrid( sAutoStyleName, bIsMajor ); + + // don't create a context => use default context. grid elements are empty + pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + } + break; + + default: + pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + break; + } + + return pContext; +} + +void SchXMLAxisContext::EndElement() +{ + if( !m_bDateScaleImported && m_nAxisType==chart::ChartAxisType::AUTOMATIC ) + { + Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData( xAxis->getScaleData()); + aScaleData.AutoDateAxis = false;//different default for older documents + xAxis->setScaleData( aScaleData ); + } + } + + SetAxisTitle(); +} + +// ======================================== + +namespace +{ + +Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) +{ + Reference< chart2::XAxis > xAxis; + try + { + xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); + } + catch( uno::Exception & ) + { + } + return xAxis; +} + +} // anonymous namespace + +void SchXMLAxisContext::CorrectAxisPositions( const Reference< chart2::XChartDocument >& xNewDoc, + const OUString& rChartTypeServiceName, + const OUString& rODFVersionOfFile, + bool bAxisPositionAttributeImported ) +{ + if( ( !rODFVersionOfFile.getLength() || rODFVersionOfFile.equalsAscii("1.0") + || rODFVersionOfFile.equalsAscii("1.1") + || ( rODFVersionOfFile.equalsAscii("1.2") && !bAxisPositionAttributeImported ) ) ) + { + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); + uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + if( aCooSysSeq.getLength() ) + { + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); + if( xCooSys.is() ) + { + Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 ); + Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 ); + //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 ); + Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 ); + Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 ); + + Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY ); + + if( xMainXAxisProp.is() && xMainYAxisProp.is() ) + { + chart2::ScaleData aMainXScale = xMainXAxis->getScaleData(); + if( 0 == rChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); + double fCrossoverValue = 0.0; + aMainXScale.Origin >>= fCrossoverValue; + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") + , uno::makeAny( fCrossoverValue ) ); + + if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + else + { + if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + if( xSecondaryYAxisProp.is() ) + xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + + chart2::ScaleData aMainYScale = xMainYAxis->getScaleData(); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); + double fCrossoverValue = 0.0; + aMainYScale.Origin >>= fCrossoverValue; + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") + , uno::makeAny( fCrossoverValue ) ); + + if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE ) + { + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryXAxisProp.is() ) + xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); + } + else + { + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); + xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); + if( xSecondaryXAxisProp.is() ) + xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") + , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); + } + } + } + } + } + catch( uno::Exception & ) + { + } + } +} + +// ======================================== + +SchXMLCategoriesContext::SchXMLCategoriesContext( + SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + OUString& rAddress ) : + SvXMLImportContext( rImport, nPrefix, rLocalName ), + m_rImportHelper( rImpHelper ), + mrAddress( rAddress ) +{ +} + +SchXMLCategoriesContext::~SchXMLCategoriesContext() +{ +} + +void SchXMLCategoriesContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + if( nPrefix == XML_NAMESPACE_TABLE && + IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) ) + { + Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY ); + mrAddress = xAttrList->getValueByIndex( i ); + } + } +} + +// ======================================== + +DateScaleContext::DateScaleContext( + SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference< beans::XPropertySet > xAxisProps ) : + SvXMLImportContext( rImport, nPrefix, rLocalName ), + m_rImportHelper( rImpHelper ), + m_xAxisProps( xAxisProps ) +{ +} + +DateScaleContext::~DateScaleContext() +{ +} + +namespace +{ +enum DateScaleAttributeTokens +{ + XML_TOK_DATESCALE_BASE_TIME_UNIT, + XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE, + XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT, + XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE, + XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT +}; + +SvXMLTokenMapEntry aDateScaleAttributeTokenMap[] = +{ + { XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, XML_TOK_DATESCALE_BASE_TIME_UNIT }, + { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE }, + { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT }, + { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE }, + { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT }, + XML_TOKEN_MAP_END +}; + +class DateScaleAttributeTokenMap : public SvXMLTokenMap +{ +public: + DateScaleAttributeTokenMap(): SvXMLTokenMap( aDateScaleAttributeTokenMap ) {} + virtual ~DateScaleAttributeTokenMap() {} +}; + +struct theDateScaleAttributeTokenMap : public rtl::Static< DateScaleAttributeTokenMap, theDateScaleAttributeTokenMap > {}; + +sal_Int32 lcl_getTimeUnit( const OUString& rValue ) +{ + sal_Int32 nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; + if( IsXMLToken( rValue, XML_DAYS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; + else if( IsXMLToken( rValue, XML_MONTHS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::MONTH; + else if( IsXMLToken( rValue, XML_YEARS ) ) + nTimeUnit = ::com::sun::star::chart::TimeUnit::YEAR; + return nTimeUnit; +} + +} + +void DateScaleContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) +{ + if( !m_xAxisProps.is() ) + return; + + // parse attributes + sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; + const SvXMLTokenMap& rAttrTokenMap = theDateScaleAttributeTokenMap::get(); + + bool bSetNewIncrement=false; + chart::TimeIncrement aIncrement; + m_xAxisProps->getPropertyValue( OUString::createFromAscii( "TimeIncrement" )) >>= aIncrement; + + for( sal_Int16 i = 0; i < nAttrCount; i++ ) + { + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aLocalName; + OUString aValue = xAttrList->getValueByIndex( i ); + USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName )) + { + case XML_TOK_DATESCALE_BASE_TIME_UNIT: + { + aIncrement.TimeResolution = uno::makeAny( lcl_getTimeUnit(aValue) ); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MajorTimeInterval >>= aInterval; + SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); + aIncrement.MajorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MajorTimeInterval >>= aInterval; + aInterval.TimeUnit = lcl_getTimeUnit(aValue); + aIncrement.MajorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MinorTimeInterval >>= aInterval; + SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); + aIncrement.MinorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + case XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT: + { + chart::TimeInterval aInterval(1,0); + aIncrement.MinorTimeInterval >>= aInterval; + aInterval.TimeUnit = lcl_getTimeUnit(aValue); + aIncrement.MinorTimeInterval = uno::makeAny(aInterval); + bSetNewIncrement = true; + } + break; + } + } + + if( bSetNewIncrement ) + m_xAxisProps->setPropertyValue( OUString::createFromAscii( "TimeIncrement" ), uno::makeAny( aIncrement ) ); +} + +// ======================================== diff --git a/xmloff/source/chart/SchXMLAxisContext.hxx b/xmloff/source/chart/SchXMLAxisContext.hxx new file mode 100755 index 000000000000..78ce22415630 --- /dev/null +++ b/xmloff/source/chart/SchXMLAxisContext.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SCH_XMLAXISCONTEXT_HXX_ +#define _SCH_XMLAXISCONTEXT_HXX_ + +#include "SchXMLImport.hxx" +#include "transporttypes.hxx" + +// ---------------------------------------- + +class SchXMLAxisContext : public SvXMLImportContext +{ +public: + SchXMLAxisContext( SchXMLImportHelper& rImpHelper, + SvXMLImport& rImport, const rtl::OUString& rLocalName, + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > xDiagram, + std::vector< SchXMLAxis >& aAxes, + ::rtl::OUString& rCategoriesAddress, + bool bAddMissingXAxisForNetCharts, + bool bAdaptWrongPercentScaleValues, + bool bAdaptXAxisOrientationForOld2DBarCharts, + bool& rbAxisPositionAttributeImported ); + virtual ~SchXMLAxisContext(); + + virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + virtual void EndElement(); + virtual SvXMLImportContext* CreateChildContext( + USHORT nPrefix, + const rtl::OUString& rLocalName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); + + static void CorrectAxisPositions( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xNewDoc, + const ::rtl::OUString& rChartTypeServiceName, + const ::rtl::OUString& rODFVersionOfFile, + bool bAxisPositionAttributeImported ); + +private: + SchXMLImportHelper& m_rImportHelper; + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > m_xDiagram; + SchXMLAxis m_aCurrentAxis; + std::vector< SchXMLAxis >& m_rAxes; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAxisProps; + rtl::OUString m_aAutoStyleName; + rtl::OUString& m_rCategoriesAddress; + sal_Int32 m_nAxisType;//::com::sun::star::chart::ChartAxisType + bool m_bAxisTypeImported; + bool m_bDateScaleImported; + bool m_bAddMissingXAxisForNetCharts; //to correct errors from older versions + bool m_bAdaptWrongPercentScaleValues; //to correct errors from older versions + bool m_bAdaptXAxisOrientationForOld2DBarCharts; //to correct different behaviour from older versions + bool& m_rbAxisPositionAttributeImported; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTitleShape(); + void CreateGrid( ::rtl::OUString sAutoStyleName, bool bIsMajor ); + void CreateAxis(); + void SetAxisTitle(); +}; + +#endif // _SCH_XMLAXISCONTEXT_HXX_ diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 9df601407199..2a19d2949ff9 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -63,7 +63,6 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XChartTypeTemplate.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -78,48 +77,6 @@ using namespace ::SchXMLTools; namespace { -uno::Reference< chart2::XChartTypeTemplate > lcl_getTemplate( const uno::Reference< chart2::XChartDocument > & xDoc ) -{ - uno::Reference< chart2::XChartTypeTemplate > xResult; - try - { - if( !xDoc.is()) - return xResult; - uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( xDoc->getChartTypeManager(), uno::UNO_QUERY ); - if( !xChartTypeManager.is()) - return xResult; - uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram()); - if( !xDiagram.is()) - return xResult; - - uno::Sequence< ::rtl::OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames()); - const sal_Int32 nLength = aServiceNames.getLength(); - - for( sal_Int32 i = 0; i < nLength; ++i ) - { - try - { - uno::Reference< chart2::XChartTypeTemplate > xTempl( - xChartTypeManager->createInstance( aServiceNames[ i ] ), uno::UNO_QUERY_THROW ); - - if( xTempl->matchesTemplate( xDiagram, sal_True )) - { - xResult.set( xTempl ); - break; - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Exception during determination of chart type template" ); - } - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Exception during import lcl_getTemplate" ); - } - return xResult; -} void lcl_setRoleAtLabeledSequence( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq, @@ -685,10 +642,6 @@ void lcl_ApplyDataFromRectangularRangeToDiagram( if( !xNewDia.is() || !xDataProvider.is() ) return; - uno::Reference< chart2::XChartTypeTemplate > xTemplate( lcl_getTemplate( xNewDoc )); - if(!xTemplate.is()) - return; - sal_Bool bFirstCellAsLabel = (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels; sal_Bool bHasCateories = @@ -754,13 +707,17 @@ void lcl_ApplyDataFromRectangularRangeToDiagram( uno::Reference< chart2::data::XDataSource > xDataSource( xDataProvider->createDataSource( aArgs )); - aArgs.realloc( aArgs.getLength() + 1 ); - aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue( + aArgs.realloc( aArgs.getLength() + 2 ); + aArgs[ aArgs.getLength() - 2 ] = beans::PropertyValue( ::rtl::OUString::createFromAscii("HasCategories"), -1, uno::makeAny( bHasCateories ), beans::PropertyState_DIRECT_VALUE ); + aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("UseCategoriesAsX"), + -1, uno::makeAny( sal_False ),//categories in ODF files are not to be used as x values (independent from what is offered in our ui) + beans::PropertyState_DIRECT_VALUE ); - xTemplate->changeDiagramData( xNewDia, xDataSource, aArgs ); + xNewDia->setDiagramData( xDataSource, aArgs ); } void SchXMLChartContext::EndElement() @@ -810,8 +767,7 @@ void SchXMLChartContext::EndElement() // cleanup: remove empty chart type groups lcl_removeEmptyChartTypeGroups( xNewDoc ); - // set stack mode before a potential template detection (in case we have a - // rectangular range) + // set stack mode before a potential chart type detection (in case we have a rectangular range) uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() ); uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); if( xDiaProp.is()) @@ -890,8 +846,7 @@ void SchXMLChartContext::EndElement() { //apply data from rectangular range - // create datasource from data provider with rectangular range - // parameters and change the diagram via template mechanism + // create datasource from data provider with rectangular range parameters and change the diagram setDiagramData try { if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 3b28fb4839bd..cc13eb2de733 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -64,20 +64,24 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/chart/XAxis.hpp> +#include <com/sun/star/chart/XAxisSupplier.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart/ChartLegendPosition.hpp> -#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> -#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> -#include <com/sun/star/chart/XAxisZSupplier.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/ChartAxisAssign.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <com/sun/star/chart/TimeIncrement.hpp> +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/chart/X3DDisplay.hpp> #include <com/sun/star/chart/XStatisticDisplay.hpp> #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XDiagram.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> @@ -201,6 +205,13 @@ public: void exportAxes( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > & xDiagram, const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram, sal_Bool bExportContent ); + void exportAxis( enum XMLTokenEnum eDimension, enum XMLTokenEnum eAxisName, + const Reference< beans::XPropertySet > xAxisProps, const Reference< chart2::XAxis >& xChart2Axis, + const OUString& rCategoriesRanges, + bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, bool bExportContent ); + void exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent ); + void exportDateScale( const Reference< beans::XPropertySet > xAxisProps ); + void exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent ); void exportSeries( const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram, @@ -694,6 +705,7 @@ bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSeque } typedef vector< OUString > tStringVector; +typedef vector< double > tDoubleVector; typedef vector< vector< OUString > > t2DStringVector; typedef vector< vector< double > > t2DNumberContainer; @@ -708,8 +720,8 @@ struct lcl_TableData tStringVector aRowDescriptions; tStringVector aRowDescriptions_Ranges; - Sequence< Sequence< OUString > > aComplexColumnDescriptions;//outer index is columns - inner index is level - Sequence< Sequence< OUString > > aComplexRowDescriptions;//outer index is rows - inner index is level + Sequence< Sequence< uno::Any > > aComplexColumnDescriptions;//outer index is columns - inner index is level + Sequence< Sequence< uno::Any > > aComplexRowDescriptions;//outer index is rows - inner index is level ::std::vector< sal_Int32 > aHiddenColumns; }; @@ -776,7 +788,7 @@ void lcl_ReorderInternalSequencesAccordingToTheirRangeName( lcl_TableData lcl_getDataForLocalTable( const SchXMLExportHelper_Impl::tDataSequenceCont & aSequencesToExport, - const Reference< chart::XComplexDescriptionAccess >& xComplexDescriptionAccess, + const Reference< chart2::XAnyDescriptionAccess >& xAnyDescriptionAccess, const OUString& rCategoriesRange, bool bSeriesFromColumns, const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion ) @@ -786,15 +798,15 @@ lcl_TableData lcl_getDataForLocalTable( try { Sequence< OUString > aSimpleCategories; - if( xComplexDescriptionAccess.is() ) + if( xAnyDescriptionAccess.is() ) { if( bSeriesFromColumns ) - aSimpleCategories = xComplexDescriptionAccess->getRowDescriptions(); + aSimpleCategories = xAnyDescriptionAccess->getRowDescriptions(); else - aSimpleCategories = xComplexDescriptionAccess->getColumnDescriptions(); + aSimpleCategories = xAnyDescriptionAccess->getColumnDescriptions(); - aResult.aComplexColumnDescriptions = xComplexDescriptionAccess->getComplexColumnDescriptions(); - aResult.aComplexRowDescriptions = xComplexDescriptionAccess->getComplexRowDescriptions(); + aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions(); + aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions(); } SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size(); @@ -1580,7 +1592,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& delete pElChart; } -void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExport& rExport ) +void lcl_exportComplexLabel( const Sequence< uno::Any >& rComplexLabel, SvXMLExport& rExport ) { sal_Int32 nLength = rComplexLabel.getLength(); if( nLength<=1 ) @@ -1589,7 +1601,12 @@ void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExp for(sal_Int32 nN=0; nN<nLength; nN++) { SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, sal_True, sal_True ); - SchXMLTools::exportText( rExport, rComplexLabel[nN], false /*bConvertTabsLFs*/ ); + OUString aString; + if( !(rComplexLabel[nN]>>=aString) ) + { + //todo? + } + SchXMLTools::exportText( rExport, aString, false /*bConvertTabsLFs*/ ); } } @@ -1624,17 +1641,17 @@ void SchXMLExportHelper_Impl::exportTable() xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY ); } - Reference< chart::XComplexDescriptionAccess > xComplexDescriptionAccess; + Reference< chart2::XAnyDescriptionAccess > xAnyDescriptionAccess; { Reference< chart::XChartDocument > xChartDoc( mrExport.GetModel(), uno::UNO_QUERY ); if( xChartDoc.is() ) - xComplexDescriptionAccess = Reference< chart::XComplexDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY ); + xAnyDescriptionAccess = Reference< chart2::XAnyDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY ); } if( bHasOwnData ) lcl_ReorderInternalSequencesAccordingToTheirRangeName( m_aDataSequencesToExport ); lcl_TableData aData( lcl_getDataForLocalTable( m_aDataSequencesToExport - , xComplexDescriptionAccess, maCategoriesRange + , xAnyDescriptionAccess, maCategoriesRange , mbRowSourceColumns, xRangeConversion )); tStringVector::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin()); @@ -1695,17 +1712,40 @@ void SchXMLExportHelper_Impl::exportTable() //export column descriptions tStringVector::const_iterator aColumnDescriptions_RangeIter( aData.aColumnDescriptions_Ranges.begin()); const tStringVector::const_iterator aColumnDescriptions_RangeEnd( aData.aColumnDescriptions_Ranges.end()); - const Sequence< Sequence< OUString > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions; + const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions; sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength(); sal_Int32 nC = 0; - for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin()); - aIt != aData.aColumnDescriptions.end(); ++aIt ) + for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin()) + ; (aIt != aData.aColumnDescriptions.end()) + ; aIt++, nC++ ) { - mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + bool bExportString = true; + if( nC < nComplexCount ) + { + const Sequence< uno::Any >& rComplexLabel = rComplexColumnDescriptions[nC]; + if( rComplexLabel.getLength()>0 ) + { + double fValue=0.0; + if( rComplexLabel[0] >>=fValue ) + { + bExportString = false; + + SvXMLUnitConverter::convertDouble( msStringBuffer, fValue ); + msString = msStringBuffer.makeStringAndClear(); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT ); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString ); + } + } + } + if( bExportString ) + { + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + } + SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); exportText( *aIt ); if( nC < nComplexCount ) - lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport ); + lcl_exportComplexLabel( rComplexColumnDescriptions[nC], mrExport ); if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd ) { // remind the original range to allow a correct re-association when copying via clipboard @@ -1721,25 +1761,47 @@ void SchXMLExportHelper_Impl::exportTable() { SvXMLElementExport aRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROWS, sal_True, sal_True ); tStringVector::const_iterator aRowDescriptionsIter( aData.aRowDescriptions.begin()); - const Sequence< Sequence< OUString > >& rComplexRowDescriptions = aData.aComplexRowDescriptions; + const Sequence< Sequence< uno::Any > >& rComplexRowDescriptions = aData.aComplexRowDescriptions; sal_Int32 nComplexCount = rComplexRowDescriptions.getLength(); sal_Int32 nC = 0; - for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin()); - aRowIt != aData.aDataInRows.end(); ++aRowIt ) + for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin()) + ; aRowIt != aData.aDataInRows.end() + ; aRowIt++, nC++, aRowDescriptionsIter++ ) { SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True ); //export row descriptions { - mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + bool bExportString = true; + if( nC < nComplexCount ) + { + const Sequence< uno::Any >& rComplexLabel = rComplexRowDescriptions[nC]; + if( rComplexLabel.getLength()>0 ) + { + double fValue=0.0; + if( rComplexLabel[0] >>=fValue ) + { + bExportString = false; + + SvXMLUnitConverter::convertDouble( msStringBuffer, fValue ); + msString = msStringBuffer.makeStringAndClear(); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT ); + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString ); + } + } + } + if( bExportString ) + { + mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING ); + } + SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True ); if( aRowDescriptionsIter != aData.aRowDescriptions.end()) { exportText( *aRowDescriptionsIter ); - ++aRowDescriptionsIter; if( nC < nComplexCount ) - lcl_exportComplexLabel( rComplexRowDescriptions[nC++], mrExport ); + lcl_exportComplexLabel( rComplexRowDescriptions[nC], mrExport ); if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd ) { // remind the original range to allow a correct re-association when copying via clipboard @@ -1775,6 +1837,57 @@ void SchXMLExportHelper_Impl::exportTable() OSL_ASSERT( bHasOwnData || (aRowDescriptions_RangeIter == aRowDescriptions_RangeEnd) ); } +namespace +{ + +Reference< chart2::XCoordinateSystem > lcl_getCooSys( const Reference< chart2::XDiagram > & xNewDiagram ) +{ + Reference< chart2::XCoordinateSystem > xCooSys; + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDiagram, uno::UNO_QUERY ); + if(xCooSysCnt.is()) + { + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); + if(aCooSysSeq.getLength()>0) + xCooSys = aCooSysSeq[0]; + } + return xCooSys; +} + +Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem >& xCooSys, + enum XMLTokenEnum eDimension, bool bPrimary=true ) +{ + Reference< chart2::XAxis > xNewAxis; + try + { + if( xCooSys.is() ) + { + sal_Int32 nDimensionIndex=0; + switch( eDimension ) + { + case XML_X: + nDimensionIndex=0; + break; + case XML_Y: + nDimensionIndex=1; + break; + case XML_Z: + nDimensionIndex=2; + break; + default: + break; + } + + xNewAxis = xCooSys->getAxisByDimension( nDimensionIndex, bPrimary ? 0 : 1 ); + } + } + catch( const uno::Exception & ) + { + } + return xNewAxis; +} + +} + void SchXMLExportHelper_Impl::exportPlotArea( Reference< chart::XDiagram > xDiagram, Reference< chart2::XDiagram > xNewDiagram, @@ -1790,8 +1903,6 @@ void SchXMLExportHelper_Impl::exportPlotArea( Reference< beans::XPropertySet > xPropSet; std::vector< XMLPropertyState > aPropertyStates; - OUString aASName; - sal_Bool bHasTwoYAxes = sal_False; sal_Bool bIs3DChart = sal_False; drawing::HomogenMatrix aTransMatrix; @@ -1899,16 +2010,6 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xPropSet.is()) { Any aAny; - try - { - aAny = xPropSet->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSecondaryYAxis" ))); - aAny >>= bHasTwoYAxes; - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property HasSecondaryYAxis not found in Diagram" ); - } // 3d attributes try @@ -1959,7 +2060,8 @@ void SchXMLExportHelper_Impl::exportPlotArea( // series elements // --------------- - exportSeries( xNewDiagram, rPageSize, bExportContent, bHasTwoYAxes ); + Reference< chart2::XAxis > xSecondYAxis = lcl_getAxis( lcl_getCooSys( xNewDiagram ), XML_Y, false ); + exportSeries( xNewDiagram, rPageSize, bExportContent, xSecondYAxis.is() ); // stock-chart elements OUString sChartType ( xDiagram->getDiagramType()); @@ -2121,6 +2223,222 @@ void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< char SvXMLElementExport aCoordinateRegion( mrExport, XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, sal_True, sal_True );//#i100778# todo: change to chart namespace in future - dependent on fileformat } +namespace +{ + XMLTokenEnum lcl_getTimeUnitToken( sal_Int32 nTimeUnit ) + { + XMLTokenEnum eToken = XML_DAYS; + switch( nTimeUnit ) + { + case ::com::sun::star::chart::TimeUnit::YEAR: + eToken = XML_YEARS; + break; + case ::com::sun::star::chart::TimeUnit::MONTH: + eToken = XML_MONTHS; + break; + default://days + break; + } + return eToken; + } +} + +void SchXMLExportHelper_Impl::exportDateScale( const Reference< beans::XPropertySet > xAxisProps ) +{ + if( !xAxisProps.is() ) + return; + + chart::TimeIncrement aIncrement; + if( (xAxisProps->getPropertyValue( OUString::createFromAscii( "TimeIncrement" )) >>= aIncrement) ) + { + sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::DAY; + if( aIncrement.TimeResolution >>= nTimeResolution ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, lcl_getTimeUnitToken( nTimeResolution ) ); + + OUStringBuffer aValue; + chart::TimeInterval aInterval; + if( aIncrement.MajorTimeInterval >>= aInterval ) + { + SvXMLUnitConverter::convertNumber( aValue, aInterval.Number ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, aValue.makeStringAndClear() ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) ); + } + if( aIncrement.MinorTimeInterval >>= aInterval ) + { + SvXMLUnitConverter::convertNumber( aValue, aInterval.Number ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, aValue.makeStringAndClear() ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, lcl_getTimeUnitToken( aInterval.TimeUnit ) ); + } + + SvXMLElementExport aDateScale( mrExport, XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, sal_True, sal_True );//#i25706#todo: change namespace for next ODF version + } +} + +void SchXMLExportHelper_Impl::exportAxisTitle( const Reference< beans::XPropertySet > xTitleProps, bool bExportContent ) +{ + if( !xTitleProps.is() ) + return; + std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xTitleProps ); + if( bExportContent ) + { + OUString aText; + Any aAny( xTitleProps->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); + aAny >>= aText; + + Reference< drawing::XShape > xShape( xTitleProps, uno::UNO_QUERY ); + if( xShape.is()) + addPosition( xShape ); + + AddAutoStyleAttribute( aPropertyStates ); + SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); + + // paragraph containing title + exportText( aText ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); +} + +void SchXMLExportHelper_Impl::exportGrid( const Reference< beans::XPropertySet > xGridProperties, bool bMajor, bool bExportContent ) +{ + if( !xGridProperties.is() ) + return; + std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xGridProperties ); + if( bExportContent ) + { + AddAutoStyleAttribute( aPropertyStates ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, bMajor ? XML_MAJOR : XML_MINOR ); + SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); +} + +namespace +{ + +//returns true if a date scale needs to be exported +bool lcl_exportAxisType( const Reference< chart2::XAxis > xChart2Axis, SvXMLExport& rExport) +{ + bool bExportDateScale = false; + if( !xChart2Axis.is() ) + return bExportDateScale; + + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion != SvtSaveOptions::ODFVER_LATEST ) //#i25706#todo: change version for next ODF version + return bExportDateScale; + + chart2::ScaleData aScale( xChart2Axis->getScaleData() ); + //#i25706#todo: change namespace for next ODF version + sal_uInt16 nNameSpace = XML_NAMESPACE_CHART_EXT; + + switch(aScale.AxisType) + { + case chart2::AxisType::CATEGORY: + if( aScale.AutoDateAxis ) + { + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO ); + bExportDateScale = true; + } + else + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_TEXT ); + break; + case chart2::AxisType::DATE: + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_DATE ); + bExportDateScale = true; + break; + default: //AUTOMATIC + rExport.AddAttribute( nNameSpace, XML_AXIS_TYPE, XML_AUTO ); + break; + } + + return bExportDateScale; +} + +} + +void SchXMLExportHelper_Impl::exportAxis( + enum XMLTokenEnum eDimension, + enum XMLTokenEnum eAxisName, + const Reference< beans::XPropertySet > xAxisProps, + const Reference< chart2::XAxis >& xChart2Axis, + const OUString& rCategoriesRange, + bool bHasTitle, bool bHasMajorGrid, bool bHasMinorGrid, + bool bExportContent ) +{ + static const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" )); + std::vector< XMLPropertyState > aPropertyStates; + SvXMLElementExport* pAxis = NULL; + + // get property states for autostyles + if( xAxisProps.is() && mxExpPropMapper.is() ) + { + lcl_exportNumberFormat( sNumFormat, xAxisProps, mrExport ); + aPropertyStates = mxExpPropMapper->Filter( xAxisProps ); + } + + bool bExportDateScale = false; + if( bExportContent ) + { + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, eDimension ); + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, eAxisName ); + AddAutoStyleAttribute( aPropertyStates ); // write style name + if( rCategoriesRange.getLength() ) + bExportDateScale = lcl_exportAxisType( xChart2Axis, mrExport ); + + // open axis element + pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); + } + else + { + CollectAutoStyle( aPropertyStates ); + } + aPropertyStates.clear(); + + //date scale + if( bExportDateScale ) + exportDateScale( xAxisProps ); + + Reference< beans::XPropertySet > xTitleProps; + Reference< beans::XPropertySet > xMajorGridProps; + Reference< beans::XPropertySet > xMinorGridProps; + Reference< chart::XAxis > xAxis( xAxisProps, uno::UNO_QUERY ); + if( xAxis.is() ) + { + xTitleProps = bHasTitle ? xAxis->getAxisTitle() : 0; + xMajorGridProps = bHasMajorGrid ? xAxis->getMajorGrid() : 0; + xMinorGridProps = bHasMinorGrid ? xAxis->getMinorGrid() : 0; + } + + // axis-title + exportAxisTitle( xTitleProps , bExportContent ); + + // categories if we have a categories chart + if( bExportContent && rCategoriesRange.getLength() ) + { + mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, rCategoriesRange ); + SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True ); + } + + // grid + exportGrid( xMajorGridProps, true, bExportContent ); + exportGrid( xMinorGridProps, false, bExportContent ); + + if( pAxis ) + { + //close axis element + delete pAxis; + pAxis = NULL; + } +} + void SchXMLExportHelper_Impl::exportAxes( const Reference< chart::XDiagram > & xDiagram, const Reference< chart2::XDiagram > & xNewDiagram, @@ -2130,13 +2448,6 @@ void SchXMLExportHelper_Impl::exportAxes( if( ! xDiagram.is()) return; - // variables for autostyles - const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" )); - Reference< beans::XPropertySet > xPropSet; - std::vector< XMLPropertyState > aPropertyStates; - - OUString aASName; - // get some properties from document first sal_Bool bHasXAxis = sal_False, bHasYAxis = sal_False, @@ -2154,46 +2465,20 @@ void SchXMLExportHelper_Impl::exportAxes( bHasYAxisMinorGrid = sal_False, bHasZAxisMajorGrid = sal_False, bHasZAxisMinorGrid = sal_False; - sal_Bool bIs3DChart = sal_False; // get multiple properties using XMultiPropertySet MultiPropertySetHandler aDiagramProperties (xDiagram); - // Check for supported services and then the properties provided by this service. - Reference<lang::XServiceInfo> xServiceInfo (xDiagram, uno::UNO_QUERY); - if (xServiceInfo.is()) - { - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisXSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis")), bHasXAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisYSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis")), bHasYAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartAxisZSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis")), bHasZAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisXSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis")), bHasSecondaryXAxis); - } - if (xServiceInfo->supportsService( - OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisYSupplier"))) - { - aDiagramProperties.Add ( - OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis")), bHasSecondaryYAxis); - } - } + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis")), bHasXAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis")), bHasYAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis")), bHasZAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis")), bHasSecondaryXAxis); + aDiagramProperties.Add ( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis")), bHasSecondaryYAxis); aDiagramProperties.Add ( OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle")), bHasXAxisTitle); @@ -2220,506 +2505,139 @@ void SchXMLExportHelper_Impl::exportAxes( aDiagramProperties.Add ( OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid")), bHasZAxisMinorGrid); - aDiagramProperties.Add( - OUString (RTL_CONSTASCII_USTRINGPARAM ("Dim3D")), bIs3DChart); - if ( ! aDiagramProperties.GetProperties ()) { DBG_WARNING ("Required properties not found in Chart diagram"); } - SvXMLElementExport* pAxis = NULL; + Reference< chart2::XCoordinateSystem > xCooSys( lcl_getCooSys(xNewDiagram) ); + + // write an axis element also if the axis itself is not visible, but a grid or a title + + OUString aCategoriesRange; + Reference< chart::XAxisSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); // x axis // ------- - - // write axis element also if the axis itself is not visible, but a grid or - // title - Reference< chart::XAxisXSupplier > xAxisXSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisXSupp.is()) + Reference< ::com::sun::star::chart2::XAxis > xNewAxis = lcl_getAxis( xCooSys, XML_X ); + if( xNewAxis.is() ) { - bool bHasAxisProperties = false; - // get property states for autostyles - if( mxExpPropMapper.is()) + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(0) : 0, uno::UNO_QUERY ); + if( mbHasCategoryLabels && bExportContent ) { - xPropSet = xAxisXSupp->getXAxis(); - if( xPropSet.is()) + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); + if( xCategories.is() ) { - bHasAxisProperties = true; - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - } - - if( bHasXAxis || - bHasXAxisTitle || bHasXAxisMajorGrid || bHasXAxisMinorGrid || - mbHasCategoryLabels || bHasAxisProperties ) - { - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_X ); - - // write style name - AddAutoStyleAttribute( aPropertyStates ); - - // element - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - // axis-title - if( bHasXAxisTitle ) - { - Reference< beans::XPropertySet > xTitleProp( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) + Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); + if( xValues.is() ) { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); + Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); + maCategoriesRange = xValues->getSourceRangeRepresentation(); + aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc ); } } - - // categories if we have a categories chart - if( bExportContent && - mbHasCategoryLabels ) - { - OUString aCategoriesRange; - // fill msString with cell-range-address of categories - // export own table references - if( xNewDiagram.is()) - { - Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); - if( xCategories.is() ) - { - Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); - if( xValues.is()) - { - Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); - maCategoriesRange = xValues->getSourceRangeRepresentation(); - aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc ); - } - } - } - - if( aCategoriesRange.getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aCategoriesRange ); - SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True ); - } - - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY ); - if( bHasXAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - Reference< beans::XPropertySet > xMinorGrid( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY ); - if( bHasXAxisMinorGrid && xMinorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } } + exportAxis( XML_X, XML_PRIMARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasXAxisTitle, bHasXAxisMajorGrid, bHasXAxisMinorGrid, bExportContent ); + aCategoriesRange = OUString(); } // secondary x axis - if( bHasSecondaryXAxis || bHasSecondaryXAxisTitle ) + // ------- + Reference< chart::XSecondAxisTitleSupplier > xSecondTitleSupp( xDiagram, uno::UNO_QUERY ); + xNewAxis = lcl_getAxis( xCooSys, XML_X, false ); + if( xNewAxis.is() ) { - Reference< chart::XTwoAxisXSupplier > xAxisTwoXSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisTwoXSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisTwoXSupp->getSecondaryXAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_X ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - if( bHasSecondaryXAxisTitle ) - { - Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); - Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(0) : 0, uno::UNO_QUERY ); + exportAxis( XML_X, XML_SECONDARY_X, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryXAxisTitle, false, false, bExportContent ); } // y axis // ------- - - // write axis element also if the axis itself is not visible, but a grid or - // title - Reference< chart::XAxisYSupplier > xAxisYSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisYSupp.is()) + xNewAxis = lcl_getAxis( xCooSys, XML_Y ); + if( xNewAxis.is() ) { - bool bHasAxisProperties = false; - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisYSupp->getYAxis(); - if( xPropSet.is()) - { - bHasAxisProperties = true; - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - } - - if( bHasYAxis || - bHasYAxisTitle || bHasYAxisMajorGrid || bHasYAxisMinorGrid || bHasAxisProperties ) - { - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Y ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - - // axis-title - if( bHasYAxisTitle ) - { - Reference< beans::XPropertySet > xTitleProp( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY ); - if( bHasYAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - // minor grid - Reference< beans::XPropertySet > xMinorGrid( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); - if( bHasYAxisMinorGrid && xMinorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(1) : 0, uno::UNO_QUERY ); + exportAxis( XML_Y, XML_PRIMARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasYAxisTitle, bHasYAxisMajorGrid, bHasYAxisMinorGrid, bExportContent ); } - if( bHasSecondaryYAxis || bHasSecondaryYAxisTitle ) + // secondary y axis + // ------- + xNewAxis = lcl_getAxis( xCooSys, XML_Y, false ); + if( xNewAxis.is() ) { - Reference< chart::XTwoAxisYSupplier > xAxisTwoYSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisTwoYSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisTwoYSupp->getSecondaryYAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_Y ); - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else // autostyles - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - if( bHasSecondaryYAxisTitle ) - { - Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY ); - Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - } - - if( pAxis ) - { - delete pAxis; - pAxis = NULL; - } - } + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getSecondaryAxis(1) : 0, uno::UNO_QUERY ); + exportAxis( XML_Y, XML_SECONDARY_Y, xAxisProps, xNewAxis, aCategoriesRange, bHasSecondaryYAxisTitle, false, false, bExportContent ); } // z axis // ------- + xNewAxis = lcl_getAxis( xCooSys, XML_Z ); + if( xNewAxis.is() ) + { + Reference< beans::XPropertySet > xAxisProps( xAxisSupp.is() ? xAxisSupp->getAxis(2) : 0, uno::UNO_QUERY ); + exportAxis( XML_Z, XML_PRIMARY_Z, xAxisProps, xNewAxis, aCategoriesRange, bHasZAxisTitle, bHasZAxisMajorGrid, bHasZAxisMinorGrid, bExportContent ); + } +} - if( bHasZAxis && - bIs3DChart ) +namespace +{ + bool lcl_hasNoValuesButText( const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) { - Reference< chart::XAxisZSupplier > xAxisZSupp( xDiagram, uno::UNO_QUERY ); - if( xAxisZSupp.is()) - { - // get property states for autostyles - if( mxExpPropMapper.is()) - { - xPropSet = xAxisZSupp->getZAxis(); - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - } - if( bExportContent ) - { - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Z ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Z ); + if( !xDataSequence.is() ) + return false;//have no data - AddAutoStyleAttribute( aPropertyStates ); - pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True ); - } - else + Sequence< uno::Any > aData; + Reference< chart2::data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY ); + if( xNumericalDataSequence.is() ) + { + Sequence< double > aDoubles( xNumericalDataSequence->getNumericalData() ); + sal_Int32 nCount = aDoubles.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - CollectAutoStyle( aPropertyStates ); + if( !::rtl::math::isNan( aDoubles[i] ) ) + return false;//have double value } - aPropertyStates.clear(); - - // axis-title - if( bHasZAxisTitle ) + } + else + { + aData = xDataSequence->getData(); + double fDouble = 0.0; + sal_Int32 nCount = aData.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - Reference< beans::XPropertySet > xTitleProp( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xTitleProp ); - if( bExportContent ) - { - OUString aText; - Any aAny( xTitleProp->getPropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )))); - aAny >>= aText; - - Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); - if( xShape.is()) - addPosition( xShape ); - - AddAutoStyleAttribute( aPropertyStates ); - SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True ); - - // paragraph containing title - exportText( aText ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } + if( (aData[i] >>= fDouble) && !::rtl::math::isNan( fDouble ) ) + return false;//have double value } - // grid - Reference< beans::XPropertySet > xMajorGrid( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY ); - if( bHasZAxisMajorGrid && xMajorGrid.is()) - { - aPropertyStates = mxExpPropMapper->Filter( xMajorGrid ); + } + //no values found - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); - } - // minor grid - Reference< beans::XPropertySet > xMinorGrid( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY ); - if( bHasZAxisMinorGrid && xMinorGrid.is()) + Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); + if( xTextualDataSequence.is() ) + { + uno::Sequence< rtl::OUString > aStrings( xTextualDataSequence->getTextualData() ); + sal_Int32 nCount = aStrings.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) { - aPropertyStates = mxExpPropMapper->Filter( xMinorGrid ); - - if( bExportContent ) - { - AddAutoStyleAttribute( aPropertyStates ); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR ); - SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } - aPropertyStates.clear(); + if( aStrings[i].getLength() ) + return true;//have text } } - if( pAxis ) + else { - delete pAxis; - pAxis = NULL; + if( !aData.getLength() ) + aData = xDataSequence->getData(); + uno::Any aAny; + OUString aString; + sal_Int32 nCount = aData.getLength(); + for( sal_Int32 i = 0; i < nCount; ++i ) + { + if( (aData[i]>>=aString) && aString.getLength() ) + return true;//have text + } } + //no doubles and no texts + return false; } } @@ -2964,6 +2882,17 @@ void SchXMLExportHelper_Impl::exportSeries( if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ) ) m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues )); } + else if( nSeriesIdx==0 ) + { + //might be that the categories are used as x-values (e.g. for date axis) -> export them accordingly + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) ); + if( xCategories.is() ) + { + Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() ); + if( !lcl_hasNoValuesButText( xValues ) ) + lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ); + } + } } if( xYValuesForBubbleChart.is() ) m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xYValuesForBubbleChart )); diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 338b9c23a004..72a324fe772b 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -143,11 +143,9 @@ SchXMLImportHelper::SchXMLImportHelper() : mpChartElemTokenMap( 0 ), mpPlotAreaElemTokenMap( 0 ), mpSeriesElemTokenMap( 0 ), - mpAxisElemTokenMap( 0 ), mpChartAttrTokenMap( 0 ), mpPlotAreaAttrTokenMap( 0 ), - mpAxisAttrTokenMap( 0 ), mpLegendAttrTokenMap( 0 ), mpAutoStyleAttrTokenMap( 0 ), mpCellAttrTokenMap( 0 ), @@ -169,15 +167,11 @@ SchXMLImportHelper::~SchXMLImportHelper() delete mpPlotAreaElemTokenMap; if( mpSeriesElemTokenMap ) delete mpSeriesElemTokenMap; - if( mpAxisElemTokenMap ) - delete mpAxisElemTokenMap; if( mpChartAttrTokenMap ) delete mpChartAttrTokenMap; if( mpPlotAreaAttrTokenMap ) delete mpPlotAreaAttrTokenMap; - if( mpAxisAttrTokenMap ) - delete mpAxisAttrTokenMap; if( mpLegendAttrTokenMap ) delete mpLegendAttrTokenMap; if( mpAutoStyleAttrTokenMap ) @@ -320,24 +314,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap() return *mpSeriesElemTokenMap; } -const SvXMLTokenMap& SchXMLImportHelper::GetAxisElemTokenMap() -{ - if( ! mpAxisElemTokenMap ) - { - static __FAR_DATA SvXMLTokenMapEntry aAxisElemTokenMap[] = -{ - { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE }, - { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES }, - { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID }, - XML_TOKEN_MAP_END -}; - - mpAxisElemTokenMap = new SvXMLTokenMap( aAxisElemTokenMap ); - } // if( ! mpAxisElemTokenMap ) - - return *mpAxisElemTokenMap; -} - // ---------------------------------------- const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap() @@ -395,24 +371,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap() return *mpPlotAreaAttrTokenMap; } -const SvXMLTokenMap& SchXMLImportHelper::GetAxisAttrTokenMap() -{ - if( ! mpAxisAttrTokenMap ) - { - static __FAR_DATA SvXMLTokenMapEntry aAxisAttrTokenMap[] = -{ - { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION }, - { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME }, - { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME }, - XML_TOKEN_MAP_END -}; - - mpAxisAttrTokenMap = new SvXMLTokenMap( aAxisAttrTokenMap ); - } // if( ! mpAxisAttrTokenMap ) - - return *mpAxisAttrTokenMap; -} - const SvXMLTokenMap& SchXMLImportHelper::GetLegendAttrTokenMap() { if( ! mpLegendAttrTokenMap ) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index ef1544b4a280..91b99bb1ff2d 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -30,6 +30,7 @@ #include "SchXMLPlotAreaContext.hxx" #include "SchXMLImport.hxx" +#include "SchXMLAxisContext.hxx" #include "SchXMLSeries2Context.hxx" #include "SchXMLTools.hxx" #include <tools/debug.hxx> @@ -39,7 +40,6 @@ #include <comphelper/processfactory.hxx> #include "xmloff/xmlnmspe.hxx" -#include <xmloff/xmltoken.hxx> #include <xmloff/xmlement.hxx> #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> @@ -51,29 +51,18 @@ #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> -#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> -#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> -#include <com/sun/star/chart/ChartAxisPosition.hpp> -#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> -#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> -#include <com/sun/star/chart/XAxisZSupplier.hpp> -#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/X3DDisplay.hpp> #include <com/sun/star/chart/XStatisticDisplay.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> -#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/drawing/CameraGeometry.hpp> #include <com/sun/star/drawing/FillStyle.hpp> -#include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XStringMapping.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> @@ -84,14 +73,6 @@ using namespace ::xmloff::token; using ::rtl::OUString; using com::sun::star::uno::Reference; -static __FAR_DATA SvXMLEnumMapEntry aXMLAxisClassMap[] = -{ - { XML_X, SCH_XML_AXIS_X }, - { XML_Y, SCH_XML_AXIS_Y }, - { XML_Z, SCH_XML_AXIS_Z }, - { XML_TOKEN_INVALID, 0 } -}; - namespace { @@ -115,19 +96,6 @@ OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< return aResult; } -Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) -{ - Reference< chart2::XAxis > xAxis; - try - { - xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); - } - catch( uno::Exception & ) - { - } - return xAxis; -} - } // anonymous namespace SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter ) @@ -239,47 +207,33 @@ SchXMLPlotAreaContext::SchXMLPlotAreaContext( { try { - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisXSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool ); - } - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisXSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool ); - } + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool ); + + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool ); + + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool ); + xProp->setPropertyValue( + rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool ); - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisYSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool ); - } - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisYSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool ); - } - - if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisZSupplier" ))) - { - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool ); - xProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool ); - } uno::Any aAny; chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS; aAny <<= eSource; @@ -623,7 +577,7 @@ void SchXMLPlotAreaContext::EndElement() ::std::vector< SchXMLAxis >::const_iterator aIt( ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories())); if( aIt != maAxes.end()) - nDimension = static_cast< sal_Int32 >( (*aIt).eClass ); + nDimension = static_cast< sal_Int32 >( (*aIt).eDimension ); SchXMLTools::CreateCategories( xDataProvider, mxNewDoc, mrCategoriesAddress, 0 /* nCooSysIndex */, @@ -708,875 +662,7 @@ void SchXMLPlotAreaContext::EndElement() } } - CorrectAxisPositions(); -} - -void SchXMLPlotAreaContext::CorrectAxisPositions() -{ - ::rtl::OUString aODFVersionOfFile( GetImport().GetODFVersion() ); - - if( ( !aODFVersionOfFile.getLength() || aODFVersionOfFile.equalsAscii("1.0") - || aODFVersionOfFile.equalsAscii("1.1") - || ( aODFVersionOfFile.equalsAscii("1.2") && !m_bAxisPositionAttributeImported ) ) ) - { - uno::Reference< chart2::XChartDocument > xNewDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - try - { - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); - uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - if( aCooSysSeq.getLength() ) - { - Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); - if( xCooSys.is() ) - { - Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 ); - Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 ); - //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 ); - Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 ); - Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 ); - - uno::Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY ); - - if( xMainXAxisProp.is() && xMainYAxisProp.is() ) - { - chart2::ScaleData aMainXScale = xMainXAxis->getScaleData(); - if( 0 == maChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); - double fCrossoverValue = 0.0; - aMainXScale.Origin >>= fCrossoverValue; - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue") - , uno::makeAny( fCrossoverValue ) ); - - if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - else - { - if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - if( xSecondaryYAxisProp.is() ) - xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - - chart2::ScaleData aMainYScale = xMainYAxis->getScaleData(); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); - double fCrossoverValue = 0.0; - aMainYScale.Origin >>= fCrossoverValue; - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue") - , uno::makeAny( fCrossoverValue ) ); - - if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE ) - { - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryXAxisProp.is() ) - xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); - } - else - { - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); - xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); - if( xSecondaryXAxisProp.is() ) - xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition") - , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); - } - } - } - } - } - catch( uno::Exception & ) - { - } - } -} - -// ======================================== - -SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName, - uno::Reference< chart::XDiagram > xDiagram, - std::vector< SchXMLAxis >& aAxes, - ::rtl::OUString & rCategoriesAddress, - bool bAddMissingXAxisForNetCharts, - bool bAdaptWrongPercentScaleValues, - bool bAdaptXAxisOrientationForOld2DBarCharts, - bool& rbAxisPositionAttributeImported ) : - SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), - mrImportHelper( rImpHelper ), - mxDiagram( xDiagram ), - maAxes( aAxes ), - mrCategoriesAddress( rCategoriesAddress ), - mbAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ), - mbAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ), - mbAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ), - m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported ) -{ -} - -SchXMLAxisContext::~SchXMLAxisContext() -{} - -/* returns a shape for the current axis's title. The property - "Has...AxisTitle" is set to "True" to get the shape - */ -uno::Reference< drawing::XShape > SchXMLAxisContext::getTitleShape() -{ - uno::Reference< drawing::XShape > xResult; - uno::Any aTrueBool; - aTrueBool <<= (sal_Bool)(sal_True); - uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasXAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getXAxisTitle(), uno::UNO_QUERY ); - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - if( xDiaProp.is() ) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryXAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY ); - } - } - break; - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasYAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getYAxisTitle(), uno::UNO_QUERY ); - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - if( xDiaProp.is() ) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryYAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY ); - } - } - break; - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasZAxisTitle" ), aTrueBool ); - xResult = uno::Reference< drawing::XShape >( xSuppl->getZAxisTitle(), uno::UNO_QUERY ); - } - break; - } - case SCH_XML_AXIS_UNDEF: - DBG_ERROR( "Invalid axis" ); - break; - } - - return xResult; -} - -void SchXMLAxisContext::CreateGrid( ::rtl::OUString sAutoStyleName, - sal_Bool bIsMajor ) -{ - uno::Reference< chart::XDiagram > xDia = mrImportHelper.GetChartDocument()->getDiagram(); - uno::Reference< beans::XPropertySet > xGridProp; - ::rtl::OUString sPropertyName; - DBG_ASSERT( xDia.is(), "diagram object is invalid!" ); - - uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); - uno::Any aTrueBool( uno::makeAny( true )); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - { - uno::Reference< chart::XAxisXSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getXMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getXHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_Y: - { - uno::Reference< chart::XAxisYSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getYMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getYHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( xDia, uno::UNO_QUERY ); - if( xSuppl.is()) - { - if( bIsMajor ) - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisGrid"), aTrueBool ); - xGridProp = xSuppl->getZMainGrid(); - } - else - { - if( xDiaProp.is()) - xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisHelpGrid"), aTrueBool ); - xGridProp = xSuppl->getZHelpGrid(); - } - } - } - break; - case SCH_XML_AXIS_UNDEF: - DBG_ERROR( "Invalid axis" ); - break; - } - - // set properties - if( xGridProp.is()) - { - // the line color is black as default, in the model it is a light gray - xGridProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), - uno::makeAny( COL_BLACK )); - if( sAutoStyleName.getLength()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), sAutoStyleName ); - - if( pStyle && pStyle->ISA( XMLPropStyleContext )) - (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp ); - } - } - } -} - -void SchXMLAxisContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - // parse attributes - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - SchXMLImport& rImport = ( SchXMLImport& )GetImport(); - const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetAxisAttrTokenMap(); - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - rtl::OUString aValue = xAttrList->getValueByIndex( i ); - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - switch( rAttrTokenMap.Get( nPrefix, aLocalName )) - { - case XML_TOK_AXIS_DIMENSION: - { - USHORT nEnumVal; - if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisClassMap )) - maCurrentAxis.eClass = ( SchXMLAxisClass )nEnumVal; - } - break; - case XML_TOK_AXIS_NAME: - maCurrentAxis.aName = aValue; - break; - case XML_TOK_AXIS_STYLE_NAME: - msAutoStyleName = aValue; - break; - } - } - - // check for number of axes with same category - maCurrentAxis.nIndexInCategory = 0; - sal_Int32 nNumOfAxes = maAxes.size(); - for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) - { - if( maAxes[ nCurrent ].eClass == maCurrentAxis.eClass ) - maCurrentAxis.nIndexInCategory++; - } - CreateAxis(); -} -namespace -{ - -uno::Reference< chart2::XAxis > lcl_getAxis( const uno::Reference< frame::XModel >& xChartModel, - sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) -{ - uno::Reference< chart2::XAxis > xAxis; - - try - { - uno::Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY ); - if( xChart2Document.is() ) - { - uno::Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram()); - uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > - aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - sal_Int32 nCooSysIndex = 0; - if( nCooSysIndex < aCooSysSeq.getLength() ) - { - uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] ); - if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() ) - { - const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); - if( nAxisIndex <= nMaxAxisIndex ) - xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); - } - } - } - } - catch( uno::Exception & ) - { - DBG_ERROR( "Couldn't get axis" ); - } - - return xAxis; -} - -bool lcl_divideBy100( uno::Any& rDoubleAny ) -{ - bool bChanged = false; - double fValue=0.0; - if( (rDoubleAny>>=fValue) && (fValue!=0.0) ) - { - fValue/=100.0; - rDoubleAny = uno::makeAny(fValue); - bChanged = true; - } - return bChanged; -} - -bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData) -{ - bool bChanged = lcl_divideBy100( rScaleData.Minimum ); - bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged; - bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged; - bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged; - return bChanged; -} - -}//end anonymous namespace - -void SchXMLAxisContext::CreateAxis() -{ - // add new Axis to list - maAxes.push_back( maCurrentAxis ); - - // set axis at chart - uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xProp; - uno::Any aTrueBool; - aTrueBool <<= (sal_Bool)(sal_True); - uno::Any aFalseBool; - aFalseBool <<= (sal_Bool)(sal_False); - uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on x axis" ); - } - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getXAxis(); - } - else - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on second x axis" ); - } - uno::Reference< chart::XTwoAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getSecondaryXAxis(); - } - break; - - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasYAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on y axis" ); - } - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getYAxis(); - - - if( mbAddMissingXAxisForNetCharts ) - { - if( xDiaProp.is() ) - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on x axis" ); - } - } - } - } - else - { - try - { - xDiaProp->setPropertyValue( - rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aTrueBool ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on second y axis" ); - } - uno::Reference< chart::XTwoAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getSecondaryYAxis(); - } - break; - - case SCH_XML_AXIS_Z: - { - bool bSettingZAxisSuccedded = false; - try - { - rtl::OUString sHasZAxis( rtl::OUString::createFromAscii( "HasZAxis" ) ); - xDiaProp->setPropertyValue( sHasZAxis, aTrueBool ); - xDiaProp->getPropertyValue( sHasZAxis ) >>= bSettingZAxisSuccedded; - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Couldn't turn on z axis" ); - } - if( bSettingZAxisSuccedded ) - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is()) - xProp = xSuppl->getZAxis(); - } - } - break; - case SCH_XML_AXIS_UNDEF: - // nothing - break; - } - - // set properties - if( xProp.is()) - { - // #i109879# the line color is black as default, in the model it is a light gray - xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), - uno::makeAny( COL_BLACK )); - - xProp->setPropertyValue( rtl::OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); - - // #88077# AutoOrigin 'on' is default - xProp->setPropertyValue( rtl::OUString::createFromAscii( "AutoOrigin" ), aTrueBool ); - - if( msAutoStyleName.getLength()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), msAutoStyleName ); - - if( pStyle && pStyle->ISA( XMLPropStyleContext )) - { - // note: SvXMLStyleContext::FillPropertySet is not const - XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - if( pPropStyleContext ) - pPropStyleContext->FillPropertySet( xProp ); - - if( mbAdaptWrongPercentScaleValues && maCurrentAxis.eClass==SCH_XML_AXIS_Y ) - { - //set scale data of added x axis back to default - uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), - 1 /*nDimensionIndex*/, maCurrentAxis.nIndexInCategory /*nAxisIndex*/ ) ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData( xAxis->getScaleData()); - if( lcl_AdaptWrongPercentScaleValues(aScaleData) ) - xAxis->setScaleData( aScaleData ); - } - } - - if( mbAddMissingXAxisForNetCharts ) - { - //copy style from y axis to added x axis: - - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() ) - { - uno::Reference< beans::XPropertySet > xXAxisProp( xSuppl->getXAxis() ); - (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp ); - } - - //set scale data of added x axis back to default - uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), - 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData; - aScaleData.AxisType = chart2::AxisType::CATEGORY; - aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL; - xAxis->setScaleData( aScaleData ); - } - - //set line style of added x axis to invisible - uno::Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY ); - if( xNewAxisProp.is() ) - { - xNewAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LineStyle") - , uno::makeAny(drawing::LineStyle_NONE)); - } - } - - if( mbAdaptXAxisOrientationForOld2DBarCharts && maCurrentAxis.eClass == SCH_XML_AXIS_X ) - { - bool bIs3DChart = false; - if( xDiaProp.is() && ( xDiaProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart ) - && !bIs3DChart ) - { - uno::Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY ); - if( xChart2Document.is() ) - { - uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY ); - if( xCooSysCnt.is() ) - { - uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); - if( aCooSysSeq.getLength() ) - { - bool bSwapXandYAxis = false; - uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); - uno::Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); - if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis ) - && bSwapXandYAxis ) - { - uno::Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, maCurrentAxis.nIndexInCategory ); - if( xAxis.is() ) - { - chart2::ScaleData aScaleData = xAxis->getScaleData(); - aScaleData.Orientation = chart2::AxisOrientation_REVERSE; - xAxis->setScaleData( aScaleData ); - } - } - } - } - } - } - } - - m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue(); - } - } - } - } -} - -void SchXMLAxisContext::SetAxisTitle() -{ - // add new Axis to list - maAxes.push_back( maCurrentAxis ); - - // set axis at chart - sal_Bool bHasTitle = ( maCurrentAxis.aTitle.getLength() > 0 ); - uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); - - switch( maCurrentAxis.eClass ) - { - case SCH_XML_AXIS_X: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - - case SCH_XML_AXIS_Y: - if( maCurrentAxis.nIndexInCategory == 0 ) - { - uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - else - { - uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - - case SCH_XML_AXIS_Z: - { - uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY ); - if( xSuppl.is() && - bHasTitle ) - { - uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getZAxisTitle(), uno::UNO_QUERY ); - if( xTitleProp.is()) - { - try - { - uno::Any aAny; - aAny <<= maCurrentAxis.aTitle; - xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny ); - } - catch( beans::UnknownPropertyException & ) - { - DBG_ERROR( "Property String for Title not available" ); - } - } - } - } - break; - case SCH_XML_AXIS_UNDEF: - // nothing - break; - } -} - -SvXMLImportContext* SchXMLAxisContext::CreateChildContext( - USHORT p_nPrefix, - const rtl::OUString& rLocalName, - const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - SvXMLImportContext* pContext = 0; - const SvXMLTokenMap& rTokenMap = mrImportHelper.GetAxisElemTokenMap(); - - switch( rTokenMap.Get( p_nPrefix, rLocalName )) - { - case XML_TOK_AXIS_TITLE: - { - uno::Reference< drawing::XShape > xTitleShape = getTitleShape(); - pContext = new SchXMLTitleContext( mrImportHelper, GetImport(), rLocalName, - maCurrentAxis.aTitle, - xTitleShape ); - } - break; - - case XML_TOK_AXIS_CATEGORIES: - pContext = new SchXMLCategoriesContext( mrImportHelper, GetImport(), - p_nPrefix, rLocalName, - mrCategoriesAddress ); - maCurrentAxis.bHasCategories = true; - break; - - case XML_TOK_AXIS_GRID: - { - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - sal_Bool bIsMajor = sal_True; // default value for class is "major" - rtl::OUString sAutoStyleName; - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_CHART ) - { - if( IsXMLToken( aLocalName, XML_CLASS ) ) - { - if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) ) - bIsMajor = sal_False; - } - else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) - sAutoStyleName = xAttrList->getValueByIndex( i ); - } - } - - CreateGrid( sAutoStyleName, bIsMajor ); - - // don't create a context => use default context. grid elements are empty - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - } - break; - - default: - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - break; - } - - return pContext; -} - -void SchXMLAxisContext::EndElement() -{ - SetAxisTitle(); + SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported ); } // ======================================== @@ -1636,44 +722,6 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr // ======================================== -SchXMLCategoriesContext::SchXMLCategoriesContext( - SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const rtl::OUString& rLocalName, - rtl::OUString& rAddress ) : - SvXMLImportContext( rImport, nPrefix, rLocalName ), - mrImportHelper( rImpHelper ), - mrAddress( rAddress ) -{ -} - -SchXMLCategoriesContext::~SchXMLCategoriesContext() -{ -} - -void SchXMLCategoriesContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) -{ - sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; - - for( sal_Int16 i = 0; i < nAttrCount; i++ ) - { - rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); - rtl::OUString aLocalName; - USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - - if( nPrefix == XML_NAMESPACE_TABLE && - IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) ) - { - uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY ); - mrAddress = xAttrList->getValueByIndex( i ); - // lcl_ConvertRange( xAttrList->getValueByIndex( i ), xNewDoc ); - } - } -} - -// ======================================== - SchXMLPositonAttributesHelper::SchXMLPositonAttributesHelper( SvXMLImport& rImporter ) : m_rImport( rImporter ) , m_aPosition(0,0) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx index 1f0de466dcb1..ca44e127cfb8 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.hxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx @@ -131,8 +131,6 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); virtual void EndElement(); - void CorrectAxisPositions(); - private: SchXMLImportHelper& mrImportHelper; ::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram; @@ -166,47 +164,6 @@ private: ::com::sun::star::awt::Size maChartSize; }; -// ---------------------------------------- - -class SchXMLAxisContext : public SvXMLImportContext -{ -private: - SchXMLImportHelper& mrImportHelper; - ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > mxDiagram; - SchXMLAxis maCurrentAxis; - std::vector< SchXMLAxis >& maAxes; - rtl::OUString msAutoStyleName; - rtl::OUString& mrCategoriesAddress; - bool mbAddMissingXAxisForNetCharts; //to correct errors from older versions - bool mbAdaptWrongPercentScaleValues; //to correct errors from older versions - bool mbAdaptXAxisOrientationForOld2DBarCharts; //to correct different behaviour from older versions - bool& m_rbAxisPositionAttributeImported; - - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTitleShape(); - void CreateGrid( ::rtl::OUString sAutoStyleName, sal_Bool bIsMajor ); - void CreateAxis(); - void SetAxisTitle(); - -public: - SchXMLAxisContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName, - ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > xDiagram, - std::vector< SchXMLAxis >& aAxes, - ::rtl::OUString& rCategoriesAddress, - bool bAddMissingXAxisForNetCharts, - bool bAdaptWrongPercentScaleValues, - bool bAdaptXAxisOrientationForOld2DBarCharts, - bool& rbAxisPositionAttributeImported ); - virtual ~SchXMLAxisContext(); - - virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); - virtual void EndElement(); - virtual SvXMLImportContext* CreateChildContext( - USHORT nPrefix, - const rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); -}; - //---------------------------------------- class SchXMLDataPointContext : public SvXMLImportContext @@ -233,24 +190,6 @@ public: // ---------------------------------------- -class SchXMLCategoriesContext : public SvXMLImportContext -{ -private: - SchXMLImportHelper& mrImportHelper; - rtl::OUString& mrAddress; - -public: - SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, - sal_uInt16 nPrefix, - const rtl::OUString& rLocalName, - rtl::OUString& rAddress ); - virtual ~SchXMLCategoriesContext(); - virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); -}; - -// ---------------------------------------- - class SchXMLCoordinateRegionContext : public SvXMLImportContext { public: diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index b3b322568ea6..f42154b056c9 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -336,7 +336,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) { if( aValue.equals( mrAxes[ nCurrent ].aName ) && - mrAxes[ nCurrent ].eClass == SCH_XML_AXIS_Y ) + mrAxes[ nCurrent ].eDimension == SCH_XML_AXIS_Y ) { mpAttachedAxis = &( mrAxes[ nCurrent ] ); } @@ -364,7 +364,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib if( mpAttachedAxis ) { - if( mpAttachedAxis->nIndexInCategory > 0 ) + if( mpAttachedAxis->nAxisIndex > 0 ) { // secondary axis => property has to be set (primary is default) mnAttachedAxis = 2; diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index 8f584bb5d6ac..a7214fa558bd 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -42,11 +42,11 @@ #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <com/sun/star/chart/ChartSeriesAddress.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> @@ -846,15 +846,25 @@ void SchXMLTableCellContext::EndElement() // ======================================== -void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< OUString >& rComplexLabel ) +void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< uno::Any >& rComplexLabel ) { if( rCell.eType == SCH_CELL_TYPE_STRING ) { rComplexLabel.realloc(1); - rComplexLabel[0] = rCell.aString; + rComplexLabel[0] = uno::makeAny( rCell.aString ); } else if( rCell.pComplexString && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING ) - rComplexLabel = *rCell.pComplexString; + { + sal_Int32 nCount = rCell.pComplexString->getLength(); + rComplexLabel.realloc( nCount ); + for( sal_Int32 nN=0; nN<nCount; nN++) + rComplexLabel[nN] = uno::makeAny((*rCell.pComplexString)[nN]); + } + else if( rCell.eType == SCH_CELL_TYPE_FLOAT ) + { + rComplexLabel.realloc(1); + rComplexLabel[0] = uno::makeAny( rCell.fValue ); + } } void SchXMLTableHelper::applyTableToInternalDataProvider( @@ -885,8 +895,8 @@ void SchXMLTableHelper::applyTableToInternalDataProvider( } Sequence< Sequence< double > > aDataInRows( nNumRows ); - Sequence< Sequence< OUString > > aComplexRowDescriptions( nNumRows ); - Sequence< Sequence< OUString > > aComplexColumnDescriptions( nNumColumns ); + Sequence< Sequence< uno::Any > > aComplexRowDescriptions( nNumRows ); + Sequence< Sequence< uno::Any > > aComplexColumnDescriptions( nNumColumns ); for( sal_Int32 i=0; i<nNumRows; ++i ) aDataInRows[i].realloc( nNumColumns ); @@ -926,15 +936,15 @@ void SchXMLTableHelper::applyTableToInternalDataProvider( } //apply the collected data to the chart - Reference< chart::XComplexDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY ); + Reference< chart2::XAnyDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY ); if( !xDataAccess.is() ) return; xDataAccess->setData( aDataInRows ); if( rTable.bHasHeaderColumn ) - xDataAccess->setComplexRowDescriptions( aComplexRowDescriptions ); + xDataAccess->setAnyRowDescriptions( aComplexRowDescriptions ); if( rTable.bHasHeaderRow ) - xDataAccess->setComplexColumnDescriptions( aComplexColumnDescriptions ); + xDataAccess->setAnyColumnDescriptions( aComplexColumnDescriptions ); if ( rTable.bProtected ) { diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk new file mode 100644 index 000000000000..2f61a3d6f0e5 --- /dev/null +++ b/xmloff/source/chart/makefile.mk @@ -0,0 +1,71 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/.. +PRJNAME = xmloff +TARGET = chart +AUTOSEG = true +ENABLE_EXCEPTIONS = TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = $(SLO)$/ColorPropertySet.obj \ + $(SLO)$/SchXMLTools.obj \ + $(SLO)$/SchXMLExport.obj \ + $(SLO)$/SchXMLImport.obj \ + $(SLO)$/contexts.obj \ + $(SLO)$/SchXMLTableContext.obj \ + $(SLO)$/SchXMLChartContext.obj \ + $(SLO)$/SchXMLPlotAreaContext.obj \ + $(SLO)$/SchXMLAxisContext.obj \ + $(SLO)$/SchXMLParagraphContext.obj \ + $(SLO)$/SchXMLTextListContext.obj \ + $(SLO)$/SchXMLSeriesHelper.obj \ + $(SLO)$/SchXMLSeries2Context.obj \ + $(SLO)$/PropertyMaps.obj \ + $(SLO)$/XMLChartStyleContext.obj \ + $(SLO)$/XMLErrorIndicatorPropertyHdl.obj \ + $(SLO)$/XMLErrorBarStylePropertyHdl.obj \ + $(SLO)$/SchXMLAutoStylePoolP.obj \ + $(SLO)$/XMLChartPropertyContext.obj \ + $(SLO)$/XMLSymbolImageContext.obj \ + $(SLO)$/XMLLabelSeparatorContext.obj \ + $(SLO)$/XMLTextOrientationHdl.obj \ + $(SLO)$/XMLSymbolTypePropertyHdl.obj \ + $(SLO)$/XMLAxisPositionPropertyHdl.obj \ + $(SLO)$/SchXMLCalculationSettingsContext.obj \ + $(SLO)$/transporttypes.obj + +# --- Targets -------------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx index 599741dfe273..30f70d882ed0 100644 --- a/xmloff/source/chart/transporttypes.hxx +++ b/xmloff/source/chart/transporttypes.hxx @@ -135,7 +135,7 @@ struct SchNumericCellRangeAddress // ---------------------------------------- -enum SchXMLAxisClass +enum SchXMLAxisDimension { SCH_XML_AXIS_X = 0, SCH_XML_AXIS_Y, @@ -145,13 +145,13 @@ enum SchXMLAxisClass struct SchXMLAxis { - enum SchXMLAxisClass eClass; - sal_Int8 nIndexInCategory; + enum SchXMLAxisDimension eDimension; + sal_Int8 nAxisIndex;//0->primary axis; 1->secondary axis rtl::OUString aName; rtl::OUString aTitle; bool bHasCategories; - SchXMLAxis() : eClass( SCH_XML_AXIS_UNDEF ), nIndexInCategory( 0 ), bHasCategories( false ) {} + SchXMLAxis() : eDimension( SCH_XML_AXIS_UNDEF ), nAxisIndex( 0 ), bHasCategories( false ) {} }; // ---------------------------------------- diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 6cfacbd93905..824d28a51a5c 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3113,6 +3113,14 @@ namespace xmloff { namespace token { TOKEN( "outside-minimum", XML_OUTSIDE_MINIMUM ), TOKEN( "outside-maximum", XML_OUTSIDE_MAXIMUM ), + TOKEN( "axis-type", XML_AXIS_TYPE ), //#i25706# + TOKEN( "date-scale", XML_DATE_SCALE ), + TOKEN( "base-time-unit", XML_BASE_TIME_UNIT ), + TOKEN( "major-interval-value", XML_MAJOR_INTERVAL_VALUE ), + TOKEN( "minor-interval-value", XML_MINOR_INTERVAL_VALUE ), + TOKEN( "major-interval-unit", XML_MAJOR_INTERVAL_UNIT ), + TOKEN( "minor-interval-unit", XML_MINOR_INTERVAL_UNIT ), + TOKEN( "min-value", XML_MIN_VALUE ), TOKEN( "max-value", XML_MAX_VALUE ), diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 45411162a183..bd79d4d2cbde 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -183,12 +183,6 @@ XMLShapeImportHelper::XMLShapeImportHelper( mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImporter)); mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaDefaultExtPropMapper(rImporter)); -/* - // chain form attributes - const UniReference< SvXMLImportPropertyMapper> xFormMapper( rImporter.GetFormImport()->getStylePropertyMapper().getBodyPtr() ); - mpPropertySetMapper->ChainImportMapper(xFormMapper); -*/ - // construct PresPagePropsMapper xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, mpSdPropHdlFactory); mpPresPagePropsMapper = new SvXMLImportPropertyMapper( xMapper, rImporter ); diff --git a/xmloff/source/forms/formlayerexport.cxx b/xmloff/source/forms/formlayerexport.cxx index 50245fad1d2a..517c499595ca 100644 --- a/xmloff/source/forms/formlayerexport.cxx +++ b/xmloff/source/forms/formlayerexport.cxx @@ -93,12 +93,6 @@ namespace xmloff } //--------------------------------------------------------------------- - ::vos::ORef< SvXMLExportPropertyMapper > OFormLayerXMLExport::getStylePropertyMapper() - { - return m_pImpl->getStylePropertyMapper(); - } - - //--------------------------------------------------------------------- void OFormLayerXMLExport::initialize() { m_pImpl->clear(); diff --git a/xmloff/source/forms/formlayerimport.cxx b/xmloff/source/forms/formlayerimport.cxx index a31b6397f51f..17a0a3bc9bb3 100644 --- a/xmloff/source/forms/formlayerimport.cxx +++ b/xmloff/source/forms/formlayerimport.cxx @@ -60,12 +60,6 @@ namespace xmloff } //--------------------------------------------------------------------- - ::vos::ORef< SvXMLImportPropertyMapper > OFormLayerXMLImport::getStylePropertyMapper() const - { - return m_pImpl->getStylePropertyMapper(); - } - - //--------------------------------------------------------------------- void OFormLayerXMLImport::setAutoStyleContext(SvXMLStylesContext* _pNewContext) { m_pImpl->setAutoStyleContext(_pNewContext); diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index cf5155f6a9a1..4a4bc4e7f942 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -237,11 +237,6 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) TabulatorCycle_RECORDS, OEnumMapper::getEnumMap(OEnumMapper::epTabCyle), &::getCppuType( static_cast<TabulatorCycle*>(NULL) )); - // initialize our style map - m_xPropertyHandlerFactory = new OControlPropertyHandlerFactory(); - ::vos::ORef< XMLPropertySetMapper > xStylePropertiesMapper = new XMLPropertySetMapper(getControlStylePropertyMap(), m_xPropertyHandlerFactory.getBodyPtr()); - m_xImportMapper = new SvXMLImportPropertyMapper(xStylePropertiesMapper.getBodyPtr(), _rImporter); - // 'initialize' m_aCurrentPageIds = m_aControlIds.end(); } @@ -416,12 +411,6 @@ void OFormLayerXMLImport_Impl::registerControlReferences(const Reference< XPrope } //--------------------------------------------------------------------- -::vos::ORef< SvXMLImportPropertyMapper > OFormLayerXMLImport_Impl::getStylePropertyMapper() const -{ - return m_xImportMapper; -} - -//--------------------------------------------------------------------- void OFormLayerXMLImport_Impl::startPage(const Reference< XDrawPage >& _rxDrawPage) { m_xCurrentPageFormsSupp.clear(); diff --git a/xmloff/source/forms/layerimport.hxx b/xmloff/source/forms/layerimport.hxx index bd88a67975fd..9bbc4c53d9df 100644 --- a/xmloff/source/forms/layerimport.hxx +++ b/xmloff/source/forms/layerimport.hxx @@ -92,10 +92,6 @@ namespace xmloff SvXMLStylesContext* m_pAutoStyles; protected: - // style handling - ::vos::ORef< XMLPropertyHandlerFactory > m_xPropertyHandlerFactory; - ::vos::ORef< SvXMLImportPropertyMapper > m_xImportMapper; - DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, MapString2PropertySet ); DECLARE_STL_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >, MapString2PropertySet, ODrawPageCompare, MapDrawPage2Map); @@ -168,10 +164,6 @@ namespace xmloff OFormLayerXMLImport_Impl(SvXMLImport& _rImporter); virtual ~OFormLayerXMLImport_Impl(); - /** retrieves the property mapper form form related auto styles. - */ - ::vos::ORef< SvXMLImportPropertyMapper > getStylePropertyMapper() const; - /** start importing the forms of the given page */ void startPage( |