1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "SchXMLAxisContext.hxx" 28cdf0e10cSrcweir #include "SchXMLChartContext.hxx" 29cdf0e10cSrcweir #include "SchXMLTools.hxx" 30cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx> 31cdf0e10cSrcweir #include <xmloff/xmlement.hxx> 32cdf0e10cSrcweir #include <xmloff/xmlstyle.hxx> 33cdf0e10cSrcweir #include <xmloff/prstylei.hxx> 34cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 35cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <tools/debug.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> 40cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> 41cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisPosition.hpp> 42cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisType.hpp> 43cdf0e10cSrcweir #include <com/sun/star/chart/TimeIncrement.hpp> 44cdf0e10cSrcweir #include <com/sun/star/chart/TimeInterval.hpp> 45cdf0e10cSrcweir #include <com/sun/star/chart/TimeUnit.hpp> 46cdf0e10cSrcweir #include <com/sun/star/chart/XAxis.hpp> 47cdf0e10cSrcweir #include <com/sun/star/chart/XAxisSupplier.hpp> 48cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp> 49cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp> 50cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp> 53cdf0e10cSrcweir 54cdf0e10cSrcweir using namespace ::xmloff::token; 55cdf0e10cSrcweir using namespace com::sun::star; 56cdf0e10cSrcweir 57cdf0e10cSrcweir using rtl::OUString; 58cdf0e10cSrcweir using com::sun::star::uno::Reference; 59cdf0e10cSrcweir 60cdf0e10cSrcweir //---------------------------------------- 61cdf0e10cSrcweir //---------------------------------------- 62cdf0e10cSrcweir 63cdf0e10cSrcweir static SvXMLEnumMapEntry aXMLAxisDimensionMap[] = 64cdf0e10cSrcweir { 65cdf0e10cSrcweir { XML_X, SCH_XML_AXIS_X }, 66cdf0e10cSrcweir { XML_Y, SCH_XML_AXIS_Y }, 67cdf0e10cSrcweir { XML_Z, SCH_XML_AXIS_Z }, 68cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir static SvXMLEnumMapEntry aXMLAxisTypeMap[] = 72cdf0e10cSrcweir { 73cdf0e10cSrcweir { XML_AUTO, ::com::sun::star::chart::ChartAxisType::AUTOMATIC }, 74cdf0e10cSrcweir { XML_TEXT, ::com::sun::star::chart::ChartAxisType::CATEGORY }, 75cdf0e10cSrcweir { XML_DATE, ::com::sun::star::chart::ChartAxisType::DATE }, 76cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir //---------------------------------------- 80cdf0e10cSrcweir //---------------------------------------- 81cdf0e10cSrcweir 82cdf0e10cSrcweir class SchXMLCategoriesContext : public SvXMLImportContext 83cdf0e10cSrcweir { 84cdf0e10cSrcweir private: 85cdf0e10cSrcweir SchXMLImportHelper& m_rImportHelper; 86cdf0e10cSrcweir OUString& mrAddress; 87cdf0e10cSrcweir 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper, 90cdf0e10cSrcweir SvXMLImport& rImport, 91cdf0e10cSrcweir sal_uInt16 nPrefix, 92cdf0e10cSrcweir const OUString& rLocalName, 93cdf0e10cSrcweir OUString& rAddress ); 94cdf0e10cSrcweir virtual ~SchXMLCategoriesContext(); 95cdf0e10cSrcweir virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir //---------------------------------------- 99cdf0e10cSrcweir //---------------------------------------- 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir class DateScaleContext : public SvXMLImportContext 103cdf0e10cSrcweir { 104cdf0e10cSrcweir public: 105cdf0e10cSrcweir DateScaleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, 106cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName, 107cdf0e10cSrcweir const Reference< beans::XPropertySet > xAxisProps ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir virtual ~DateScaleContext(); 110cdf0e10cSrcweir virtual void StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir private: 113cdf0e10cSrcweir SchXMLImportHelper& m_rImportHelper; 114cdf0e10cSrcweir Reference< beans::XPropertySet > m_xAxisProps; 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir //---------------------------------------- 119cdf0e10cSrcweir //---------------------------------------- 120cdf0e10cSrcweir 121cdf0e10cSrcweir SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper, 122cdf0e10cSrcweir SvXMLImport& rImport, const OUString& rLocalName, 123cdf0e10cSrcweir Reference< chart::XDiagram > xDiagram, 124cdf0e10cSrcweir std::vector< SchXMLAxis >& rAxes, 125cdf0e10cSrcweir OUString & rCategoriesAddress, 126cdf0e10cSrcweir bool bAddMissingXAxisForNetCharts, 127cdf0e10cSrcweir bool bAdaptWrongPercentScaleValues, 128cdf0e10cSrcweir bool bAdaptXAxisOrientationForOld2DBarCharts, 129cdf0e10cSrcweir bool& rbAxisPositionAttributeImported ) : 130cdf0e10cSrcweir SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), 131cdf0e10cSrcweir m_rImportHelper( rImpHelper ), 132cdf0e10cSrcweir m_xDiagram( xDiagram ), 133cdf0e10cSrcweir m_rAxes( rAxes ), 134cdf0e10cSrcweir m_rCategoriesAddress( rCategoriesAddress ), 135cdf0e10cSrcweir m_nAxisType(chart::ChartAxisType::AUTOMATIC), 136cdf0e10cSrcweir m_bAxisTypeImported(false), 137cdf0e10cSrcweir m_bDateScaleImported(false), 138cdf0e10cSrcweir m_bAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ), 139cdf0e10cSrcweir m_bAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ), 140cdf0e10cSrcweir m_bAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ), 141cdf0e10cSrcweir m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir SchXMLAxisContext::~SchXMLAxisContext() 146cdf0e10cSrcweir {} 147cdf0e10cSrcweir 148cdf0e10cSrcweir Reference< chart::XAxis > lcl_getChartAxis( SchXMLAxis aCurrentAxis, const Reference< chart::XDiagram > xDiagram ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir Reference< chart::XAxis > xAxis; 151cdf0e10cSrcweir Reference< chart::XAxisSupplier > xAxisSuppl( xDiagram, uno::UNO_QUERY ); 152cdf0e10cSrcweir if( !xAxisSuppl.is() ) 153cdf0e10cSrcweir return xAxis; 154cdf0e10cSrcweir if( aCurrentAxis.nAxisIndex == 0 ) 155cdf0e10cSrcweir xAxis = xAxisSuppl->getAxis(aCurrentAxis.eDimension); 156cdf0e10cSrcweir else 157cdf0e10cSrcweir xAxis = xAxisSuppl->getSecondaryAxis(aCurrentAxis.eDimension); 158cdf0e10cSrcweir return xAxis; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir /* returns a shape for the current axis's title. The property 162cdf0e10cSrcweir "Has...AxisTitle" is set to "True" to get the shape 163cdf0e10cSrcweir */ 164cdf0e10cSrcweir Reference< drawing::XShape > SchXMLAxisContext::getTitleShape() 165cdf0e10cSrcweir { 166cdf0e10cSrcweir Reference< drawing::XShape > xResult; 167cdf0e10cSrcweir Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); 168cdf0e10cSrcweir Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); 169cdf0e10cSrcweir if( !xDiaProp.is() || !xAxis.is() ) 170cdf0e10cSrcweir return xResult; 171cdf0e10cSrcweir 172cdf0e10cSrcweir rtl::OUString aPropName; 173cdf0e10cSrcweir switch( m_aCurrentAxis.eDimension ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir case SCH_XML_AXIS_X: 176cdf0e10cSrcweir if( m_aCurrentAxis.nAxisIndex == 0 ) 177cdf0e10cSrcweir aPropName = OUString::createFromAscii( "HasXAxisTitle" ); 178cdf0e10cSrcweir else 179cdf0e10cSrcweir aPropName = OUString::createFromAscii( "HasSecondaryXAxisTitle" ); 180cdf0e10cSrcweir break; 181cdf0e10cSrcweir case SCH_XML_AXIS_Y: 182cdf0e10cSrcweir if( m_aCurrentAxis.nAxisIndex == 0 ) 183cdf0e10cSrcweir aPropName = OUString::createFromAscii( "HasYAxisTitle" ); 184cdf0e10cSrcweir else 185cdf0e10cSrcweir aPropName = OUString::createFromAscii( "HasSecondaryYAxisTitle" ); 186cdf0e10cSrcweir break; 187cdf0e10cSrcweir case SCH_XML_AXIS_Z: 188cdf0e10cSrcweir aPropName = OUString::createFromAscii( "HasZAxisTitle" ); 189cdf0e10cSrcweir break; 190cdf0e10cSrcweir case SCH_XML_AXIS_UNDEF: 191cdf0e10cSrcweir DBG_ERROR( "Invalid axis" ); 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); 195cdf0e10cSrcweir xResult = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); 196cdf0e10cSrcweir return xResult; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir void SchXMLAxisContext::CreateGrid( OUString sAutoStyleName, bool bIsMajor ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); 202cdf0e10cSrcweir Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); 203cdf0e10cSrcweir if( !xDiaProp.is() || !xAxis.is() ) 204cdf0e10cSrcweir return; 205cdf0e10cSrcweir 206cdf0e10cSrcweir rtl::OUString aPropName; 207cdf0e10cSrcweir switch( m_aCurrentAxis.eDimension ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir case SCH_XML_AXIS_X: 210cdf0e10cSrcweir if( bIsMajor ) 211cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasXAxisGrid"); 212cdf0e10cSrcweir else 213cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasXAxisHelpGrid"); 214cdf0e10cSrcweir break; 215cdf0e10cSrcweir case SCH_XML_AXIS_Y: 216cdf0e10cSrcweir if( bIsMajor ) 217cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasYAxisGrid"); 218cdf0e10cSrcweir else 219cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasYAxisHelpGrid"); 220cdf0e10cSrcweir break; 221cdf0e10cSrcweir case SCH_XML_AXIS_Z: 222cdf0e10cSrcweir if( bIsMajor ) 223cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasZAxisGrid"); 224cdf0e10cSrcweir else 225cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasZAxisHelpGrid"); 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir case SCH_XML_AXIS_UNDEF: 228cdf0e10cSrcweir DBG_ERROR( "Invalid axis" ); 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); 232cdf0e10cSrcweir 233cdf0e10cSrcweir Reference< beans::XPropertySet > xGridProp; 234cdf0e10cSrcweir if( bIsMajor ) 235cdf0e10cSrcweir xGridProp = xAxis->getMajorGrid(); 236cdf0e10cSrcweir else 237cdf0e10cSrcweir xGridProp = xAxis->getMinorGrid(); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // set properties 240cdf0e10cSrcweir if( xGridProp.is()) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir // the line color is black as default, in the model it is a light gray 243cdf0e10cSrcweir xGridProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), 244cdf0e10cSrcweir uno::makeAny( COL_BLACK )); 245cdf0e10cSrcweir if( sAutoStyleName.getLength()) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); 248cdf0e10cSrcweir if( pStylesCtxt ) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( 251cdf0e10cSrcweir m_rImportHelper.GetChartFamilyID(), sAutoStyleName ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir if( pStyle && pStyle->ISA( XMLPropStyleContext )) 254cdf0e10cSrcweir (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp ); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir } 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir namespace 261cdf0e10cSrcweir { 262cdf0e10cSrcweir enum AxisAttributeTokens 263cdf0e10cSrcweir { 264cdf0e10cSrcweir XML_TOK_AXIS_DIMENSION, 265cdf0e10cSrcweir XML_TOK_AXIS_NAME, 266cdf0e10cSrcweir XML_TOK_AXIS_STYLE_NAME, 267cdf0e10cSrcweir XML_TOK_AXIS_TYPE, 268cdf0e10cSrcweir XML_TOK_AXIS_TYPE_EXT 269cdf0e10cSrcweir }; 270cdf0e10cSrcweir 271cdf0e10cSrcweir SvXMLTokenMapEntry aAxisAttributeTokenMap[] = 272cdf0e10cSrcweir { 273cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION }, 274cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME }, 275cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME }, 276cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE }, 277cdf0e10cSrcweir { XML_NAMESPACE_CHART_EXT, XML_AXIS_TYPE, XML_TOK_AXIS_TYPE_EXT }, 278cdf0e10cSrcweir XML_TOKEN_MAP_END 279cdf0e10cSrcweir }; 280cdf0e10cSrcweir 281cdf0e10cSrcweir class AxisAttributeTokenMap : public SvXMLTokenMap 282cdf0e10cSrcweir { 283cdf0e10cSrcweir public: 284cdf0e10cSrcweir AxisAttributeTokenMap(): SvXMLTokenMap( aAxisAttributeTokenMap ) {} 285cdf0e10cSrcweir virtual ~AxisAttributeTokenMap() {} 286cdf0e10cSrcweir }; 287cdf0e10cSrcweir 288cdf0e10cSrcweir //a AxisAttributeTokenMap Singleton 289cdf0e10cSrcweir struct theAxisAttributeTokenMap : public rtl::Static< AxisAttributeTokenMap, theAxisAttributeTokenMap > {}; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir void SchXMLAxisContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir // parse attributes 295cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; 296cdf0e10cSrcweir SchXMLImport& rImport = ( SchXMLImport& )GetImport(); 297cdf0e10cSrcweir const SvXMLTokenMap& rAttrTokenMap = theAxisAttributeTokenMap::get(); 298cdf0e10cSrcweir 299cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 302cdf0e10cSrcweir OUString aLocalName; 303cdf0e10cSrcweir OUString aValue = xAttrList->getValueByIndex( i ); 304cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 305cdf0e10cSrcweir 306cdf0e10cSrcweir switch( rAttrTokenMap.Get( nPrefix, aLocalName )) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir case XML_TOK_AXIS_DIMENSION: 309cdf0e10cSrcweir { 310cdf0e10cSrcweir sal_uInt16 nEnumVal; 311cdf0e10cSrcweir if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisDimensionMap )) 312cdf0e10cSrcweir m_aCurrentAxis.eDimension = ( SchXMLAxisDimension )nEnumVal; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir break; 315cdf0e10cSrcweir case XML_TOK_AXIS_NAME: 316cdf0e10cSrcweir m_aCurrentAxis.aName = aValue; 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir case XML_TOK_AXIS_TYPE: 319cdf0e10cSrcweir case XML_TOK_AXIS_TYPE_EXT: 320cdf0e10cSrcweir sal_uInt16 nEnumVal; 321cdf0e10cSrcweir if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisTypeMap )) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir m_nAxisType = nEnumVal; 324cdf0e10cSrcweir m_bAxisTypeImported = true; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir break; 327cdf0e10cSrcweir case XML_TOK_AXIS_STYLE_NAME: 328cdf0e10cSrcweir m_aAutoStyleName = aValue; 329cdf0e10cSrcweir break; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir // check for number of axes with same dimension 334cdf0e10cSrcweir m_aCurrentAxis.nAxisIndex = 0; 335cdf0e10cSrcweir sal_Int32 nNumOfAxes = m_rAxes.size(); 336cdf0e10cSrcweir for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir if( m_rAxes[ nCurrent ].eDimension == m_aCurrentAxis.eDimension ) 339cdf0e10cSrcweir m_aCurrentAxis.nAxisIndex++; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir CreateAxis(); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir namespace 344cdf0e10cSrcweir { 345cdf0e10cSrcweir 346cdf0e10cSrcweir Reference< chart2::XAxis > lcl_getAxis( const Reference< frame::XModel >& xChartModel, 347cdf0e10cSrcweir sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir Reference< chart2::XAxis > xAxis; 350cdf0e10cSrcweir 351cdf0e10cSrcweir try 352cdf0e10cSrcweir { 353cdf0e10cSrcweir Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY ); 354cdf0e10cSrcweir if( xChart2Document.is() ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram()); 357cdf0e10cSrcweir Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); 358cdf0e10cSrcweir uno::Sequence< Reference< chart2::XCoordinateSystem > > 359cdf0e10cSrcweir aCooSysSeq( xCooSysCnt->getCoordinateSystems()); 360cdf0e10cSrcweir sal_Int32 nCooSysIndex = 0; 361cdf0e10cSrcweir if( nCooSysIndex < aCooSysSeq.getLength() ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] ); 364cdf0e10cSrcweir if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); 367cdf0e10cSrcweir if( nAxisIndex <= nMaxAxisIndex ) 368cdf0e10cSrcweir xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir catch( uno::Exception & ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir DBG_ERROR( "Couldn't get axis" ); 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir return xAxis; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir bool lcl_divideBy100( uno::Any& rDoubleAny ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir bool bChanged = false; 384cdf0e10cSrcweir double fValue=0.0; 385cdf0e10cSrcweir if( (rDoubleAny>>=fValue) && (fValue!=0.0) ) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir fValue/=100.0; 388cdf0e10cSrcweir rDoubleAny = uno::makeAny(fValue); 389cdf0e10cSrcweir bChanged = true; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir return bChanged; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir bool bChanged = lcl_divideBy100( rScaleData.Minimum ); 397cdf0e10cSrcweir bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged; 398cdf0e10cSrcweir bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged; 399cdf0e10cSrcweir bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged; 400cdf0e10cSrcweir return bChanged; 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir }//end anonymous namespace 404cdf0e10cSrcweir 405cdf0e10cSrcweir void SchXMLAxisContext::CreateAxis() 406cdf0e10cSrcweir { 407cdf0e10cSrcweir m_rAxes.push_back( m_aCurrentAxis ); 408cdf0e10cSrcweir 409cdf0e10cSrcweir Reference< beans::XPropertySet > xDiaProp( m_rImportHelper.GetChartDocument()->getDiagram(), uno::UNO_QUERY ); 410cdf0e10cSrcweir if( !xDiaProp.is() ) 411cdf0e10cSrcweir return; 412cdf0e10cSrcweir rtl::OUString aPropName; 413cdf0e10cSrcweir switch( m_aCurrentAxis.eDimension ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir case SCH_XML_AXIS_X: 416cdf0e10cSrcweir if( m_aCurrentAxis.nAxisIndex == 0 ) 417cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasXAxis"); 418cdf0e10cSrcweir else 419cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasSecondaryXAxis"); 420cdf0e10cSrcweir break; 421cdf0e10cSrcweir case SCH_XML_AXIS_Y: 422cdf0e10cSrcweir if( m_aCurrentAxis.nAxisIndex == 0 ) 423cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasYAxis"); 424cdf0e10cSrcweir else 425cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasSecondaryYAxis"); 426cdf0e10cSrcweir break; 427cdf0e10cSrcweir case SCH_XML_AXIS_Z: 428cdf0e10cSrcweir if( m_aCurrentAxis.nAxisIndex == 0 ) 429cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasXAxis"); 430cdf0e10cSrcweir else 431cdf0e10cSrcweir aPropName = OUString::createFromAscii("HasSecondaryXAxis"); 432cdf0e10cSrcweir break; 433cdf0e10cSrcweir case SCH_XML_AXIS_UNDEF: 434cdf0e10cSrcweir DBG_ERROR( "Invalid axis" ); 435cdf0e10cSrcweir break; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir try 438cdf0e10cSrcweir { 439cdf0e10cSrcweir xDiaProp->setPropertyValue( aPropName, uno::makeAny(sal_True) ); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir catch( beans::UnknownPropertyException & ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir DBG_ERROR( "Couldn't turn on axis" ); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir if( m_aCurrentAxis.eDimension==SCH_XML_AXIS_Z ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir bool bSettingZAxisSuccedded = false; 448cdf0e10cSrcweir try 449cdf0e10cSrcweir { 450cdf0e10cSrcweir xDiaProp->getPropertyValue( aPropName ) >>= bSettingZAxisSuccedded; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir catch( beans::UnknownPropertyException & ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir DBG_ERROR( "Couldn't turn on z axis" ); 455cdf0e10cSrcweir } 456cdf0e10cSrcweir if( !bSettingZAxisSuccedded ) 457cdf0e10cSrcweir return; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir 461cdf0e10cSrcweir m_xAxisProps = Reference<beans::XPropertySet>( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ), uno::UNO_QUERY ); 462cdf0e10cSrcweir 463cdf0e10cSrcweir if( m_bAddMissingXAxisForNetCharts && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y && m_aCurrentAxis.nAxisIndex==0 ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir try 466cdf0e10cSrcweir { 467cdf0e10cSrcweir xDiaProp->setPropertyValue( OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) ); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir catch( beans::UnknownPropertyException & ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir DBG_ERROR( "Couldn't turn on x axis" ); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir // set properties 476cdf0e10cSrcweir if( m_xAxisProps.is()) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir uno::Any aTrueBool( uno::makeAny( sal_True )); 479cdf0e10cSrcweir uno::Any aFalseBool( uno::makeAny( sal_False )); 480cdf0e10cSrcweir 481cdf0e10cSrcweir // #i109879# the line color is black as default, in the model it is a light gray 482cdf0e10cSrcweir m_xAxisProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), 483cdf0e10cSrcweir uno::makeAny( COL_BLACK )); 484cdf0e10cSrcweir 485cdf0e10cSrcweir m_xAxisProps->setPropertyValue( OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); 486cdf0e10cSrcweir 487cdf0e10cSrcweir // #88077# AutoOrigin 'on' is default 488cdf0e10cSrcweir m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AutoOrigin" ), aTrueBool ); 489cdf0e10cSrcweir 490cdf0e10cSrcweir if( m_bAxisTypeImported ) 491cdf0e10cSrcweir m_xAxisProps->setPropertyValue( OUString::createFromAscii( "AxisType" ), uno::makeAny(m_nAxisType) ); 492cdf0e10cSrcweir 493cdf0e10cSrcweir if( m_aAutoStyleName.getLength()) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); 496cdf0e10cSrcweir if( pStylesCtxt ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( 499cdf0e10cSrcweir m_rImportHelper.GetChartFamilyID(), m_aAutoStyleName ); 500cdf0e10cSrcweir 501cdf0e10cSrcweir if( pStyle && pStyle->ISA( XMLPropStyleContext )) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir // note: SvXMLStyleContext::FillPropertySet is not const 504cdf0e10cSrcweir XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); 505cdf0e10cSrcweir if( pPropStyleContext ) 506cdf0e10cSrcweir pPropStyleContext->FillPropertySet( m_xAxisProps ); 507cdf0e10cSrcweir 508cdf0e10cSrcweir if( m_bAdaptWrongPercentScaleValues && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir //set scale data of added x axis back to default 511cdf0e10cSrcweir Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), 512cdf0e10cSrcweir m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); 513cdf0e10cSrcweir if( xAxis.is() ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir chart2::ScaleData aScaleData( xAxis->getScaleData()); 516cdf0e10cSrcweir if( lcl_AdaptWrongPercentScaleValues(aScaleData) ) 517cdf0e10cSrcweir xAxis->setScaleData( aScaleData ); 518cdf0e10cSrcweir } 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir if( m_bAddMissingXAxisForNetCharts ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir //copy style from y axis to added x axis: 524cdf0e10cSrcweir 525cdf0e10cSrcweir Reference< chart::XAxisSupplier > xAxisSuppl( xDiaProp, uno::UNO_QUERY ); 526cdf0e10cSrcweir if( xAxisSuppl.is() ) 527cdf0e10cSrcweir { 528cdf0e10cSrcweir Reference< beans::XPropertySet > xXAxisProp( xAxisSuppl->getAxis(0), uno::UNO_QUERY ); 529cdf0e10cSrcweir (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp ); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir //set scale data of added x axis back to default 533cdf0e10cSrcweir Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), 534cdf0e10cSrcweir 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) ); 535cdf0e10cSrcweir if( xAxis.is() ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir chart2::ScaleData aScaleData; 538cdf0e10cSrcweir aScaleData.AxisType = chart2::AxisType::CATEGORY; 539cdf0e10cSrcweir aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL; 540cdf0e10cSrcweir xAxis->setScaleData( aScaleData ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir //set line style of added x axis to invisible 544cdf0e10cSrcweir Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY ); 545cdf0e10cSrcweir if( xNewAxisProp.is() ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir xNewAxisProp->setPropertyValue( OUString::createFromAscii("LineStyle") 548cdf0e10cSrcweir , uno::makeAny(drawing::LineStyle_NONE)); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir if( m_bAdaptXAxisOrientationForOld2DBarCharts && m_aCurrentAxis.eDimension == SCH_XML_AXIS_X ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir bool bIs3DChart = false; 555cdf0e10cSrcweir if( xDiaProp.is() && ( xDiaProp->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart ) 556cdf0e10cSrcweir && !bIs3DChart ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY ); 559cdf0e10cSrcweir if( xChart2Document.is() ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY ); 562cdf0e10cSrcweir if( xCooSysCnt.is() ) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() ); 565cdf0e10cSrcweir if( aCooSysSeq.getLength() ) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir bool bSwapXandYAxis = false; 568cdf0e10cSrcweir Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); 569cdf0e10cSrcweir Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY ); 570cdf0e10cSrcweir if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis ) 571cdf0e10cSrcweir && bSwapXandYAxis ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, m_aCurrentAxis.nAxisIndex ); 574cdf0e10cSrcweir if( xAxis.is() ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir chart2::ScaleData aScaleData = xAxis->getScaleData(); 577cdf0e10cSrcweir aScaleData.Orientation = chart2::AxisOrientation_REVERSE; 578cdf0e10cSrcweir xAxis->setScaleData( aScaleData ); 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir } 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext( 588cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue(); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir } 593cdf0e10cSrcweir } 594cdf0e10cSrcweir 595cdf0e10cSrcweir void SchXMLAxisContext::SetAxisTitle() 596cdf0e10cSrcweir { 597cdf0e10cSrcweir if( !m_aCurrentAxis.aTitle.getLength() ) 598cdf0e10cSrcweir return; 599cdf0e10cSrcweir 600cdf0e10cSrcweir Reference< chart::XAxis > xAxis( lcl_getChartAxis( m_aCurrentAxis, m_xDiagram ) ); 601cdf0e10cSrcweir if( !xAxis.is() ) 602cdf0e10cSrcweir return; 603cdf0e10cSrcweir 604cdf0e10cSrcweir Reference< beans::XPropertySet > xTitleProp( xAxis->getAxisTitle() ); 605cdf0e10cSrcweir if( xTitleProp.is() ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir try 608cdf0e10cSrcweir { 609cdf0e10cSrcweir xTitleProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), uno::makeAny(m_aCurrentAxis.aTitle) ); 610cdf0e10cSrcweir } 611cdf0e10cSrcweir catch( beans::UnknownPropertyException & ) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir DBG_ERROR( "Property String for Title not available" ); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir } 616cdf0e10cSrcweir } 617cdf0e10cSrcweir 618cdf0e10cSrcweir //----------------------------------------------------------------------- 619cdf0e10cSrcweir namespace 620cdf0e10cSrcweir { 621cdf0e10cSrcweir enum AxisChildTokens 622cdf0e10cSrcweir { 623cdf0e10cSrcweir XML_TOK_AXIS_TITLE, 624cdf0e10cSrcweir XML_TOK_AXIS_CATEGORIES, 625cdf0e10cSrcweir XML_TOK_AXIS_GRID, 626cdf0e10cSrcweir XML_TOK_AXIS_DATE_SCALE, 627cdf0e10cSrcweir XML_TOK_AXIS_DATE_SCALE_EXT 628cdf0e10cSrcweir }; 629cdf0e10cSrcweir 630cdf0e10cSrcweir SvXMLTokenMapEntry aAxisChildTokenMap[] = 631cdf0e10cSrcweir { 632cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE }, 633cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES }, 634cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID }, 635cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE }, 636cdf0e10cSrcweir { XML_NAMESPACE_CHART_EXT, XML_DATE_SCALE, XML_TOK_AXIS_DATE_SCALE_EXT }, 637cdf0e10cSrcweir XML_TOKEN_MAP_END 638cdf0e10cSrcweir }; 639cdf0e10cSrcweir 640cdf0e10cSrcweir class AxisChildTokenMap : public SvXMLTokenMap 641cdf0e10cSrcweir { 642cdf0e10cSrcweir public: 643cdf0e10cSrcweir AxisChildTokenMap(): SvXMLTokenMap( aAxisChildTokenMap ) {} 644cdf0e10cSrcweir virtual ~AxisChildTokenMap() {} 645cdf0e10cSrcweir }; 646cdf0e10cSrcweir 647cdf0e10cSrcweir //a AxisChildTokenMap Singleton 648cdf0e10cSrcweir struct theAxisChildTokenMap : public rtl::Static< AxisChildTokenMap, theAxisChildTokenMap > {}; 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir SvXMLImportContext* SchXMLAxisContext::CreateChildContext( 652cdf0e10cSrcweir sal_uInt16 p_nPrefix, 653cdf0e10cSrcweir const OUString& rLocalName, 654cdf0e10cSrcweir const Reference< xml::sax::XAttributeList >& xAttrList ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir SvXMLImportContext* pContext = 0; 657cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = theAxisChildTokenMap::get(); 658cdf0e10cSrcweir 659cdf0e10cSrcweir switch( rTokenMap.Get( p_nPrefix, rLocalName )) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir case XML_TOK_AXIS_TITLE: 662cdf0e10cSrcweir { 663cdf0e10cSrcweir Reference< drawing::XShape > xTitleShape = getTitleShape(); 664cdf0e10cSrcweir pContext = new SchXMLTitleContext( m_rImportHelper, GetImport(), rLocalName, 665cdf0e10cSrcweir m_aCurrentAxis.aTitle, 666cdf0e10cSrcweir xTitleShape ); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir break; 669cdf0e10cSrcweir 670cdf0e10cSrcweir case XML_TOK_AXIS_CATEGORIES: 671cdf0e10cSrcweir pContext = new SchXMLCategoriesContext( m_rImportHelper, GetImport(), 672cdf0e10cSrcweir p_nPrefix, rLocalName, 673cdf0e10cSrcweir m_rCategoriesAddress ); 674cdf0e10cSrcweir m_aCurrentAxis.bHasCategories = true; 675cdf0e10cSrcweir break; 676cdf0e10cSrcweir 677cdf0e10cSrcweir case XML_TOK_AXIS_DATE_SCALE: 678cdf0e10cSrcweir case XML_TOK_AXIS_DATE_SCALE_EXT: 679cdf0e10cSrcweir pContext = new DateScaleContext( m_rImportHelper, GetImport(), 680cdf0e10cSrcweir p_nPrefix, rLocalName, m_xAxisProps ); 681cdf0e10cSrcweir m_bDateScaleImported = true; 682cdf0e10cSrcweir break; 683cdf0e10cSrcweir 684cdf0e10cSrcweir case XML_TOK_AXIS_GRID: 685cdf0e10cSrcweir { 686cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; 687cdf0e10cSrcweir bool bIsMajor = true; // default value for class is "major" 688cdf0e10cSrcweir OUString sAutoStyleName; 689cdf0e10cSrcweir 690cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 693cdf0e10cSrcweir OUString aLocalName; 694cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 695cdf0e10cSrcweir 696cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir if( IsXMLToken( aLocalName, XML_CLASS ) ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) ) 701cdf0e10cSrcweir bIsMajor = false; 702cdf0e10cSrcweir } 703cdf0e10cSrcweir else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 704cdf0e10cSrcweir sAutoStyleName = xAttrList->getValueByIndex( i ); 705cdf0e10cSrcweir } 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir CreateGrid( sAutoStyleName, bIsMajor ); 709cdf0e10cSrcweir 710cdf0e10cSrcweir // don't create a context => use default context. grid elements are empty 711cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir break; 714cdf0e10cSrcweir 715cdf0e10cSrcweir default: 716cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 717cdf0e10cSrcweir break; 718cdf0e10cSrcweir } 719cdf0e10cSrcweir 720cdf0e10cSrcweir return pContext; 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir void SchXMLAxisContext::EndElement() 724cdf0e10cSrcweir { 725cdf0e10cSrcweir if( !m_bDateScaleImported && m_nAxisType==chart::ChartAxisType::AUTOMATIC ) 726cdf0e10cSrcweir { 727cdf0e10cSrcweir Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(), m_aCurrentAxis.eDimension, m_aCurrentAxis.nAxisIndex ) ); 728cdf0e10cSrcweir if( xAxis.is() ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir chart2::ScaleData aScaleData( xAxis->getScaleData()); 731cdf0e10cSrcweir aScaleData.AutoDateAxis = false;//different default for older documents 732cdf0e10cSrcweir xAxis->setScaleData( aScaleData ); 733cdf0e10cSrcweir } 734cdf0e10cSrcweir } 735cdf0e10cSrcweir 736cdf0e10cSrcweir SetAxisTitle(); 737cdf0e10cSrcweir } 738cdf0e10cSrcweir 739cdf0e10cSrcweir // ======================================== 740cdf0e10cSrcweir 741cdf0e10cSrcweir namespace 742cdf0e10cSrcweir { 743cdf0e10cSrcweir 744cdf0e10cSrcweir Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir Reference< chart2::XAxis > xAxis; 747cdf0e10cSrcweir try 748cdf0e10cSrcweir { 749cdf0e10cSrcweir xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ); 750cdf0e10cSrcweir } 751cdf0e10cSrcweir catch( uno::Exception & ) 752cdf0e10cSrcweir { 753cdf0e10cSrcweir } 754cdf0e10cSrcweir return xAxis; 755cdf0e10cSrcweir } 756cdf0e10cSrcweir 757cdf0e10cSrcweir } // anonymous namespace 758cdf0e10cSrcweir 759cdf0e10cSrcweir void SchXMLAxisContext::CorrectAxisPositions( const Reference< chart2::XChartDocument >& xNewDoc, 760cdf0e10cSrcweir const OUString& rChartTypeServiceName, 761cdf0e10cSrcweir const OUString& rODFVersionOfFile, 762cdf0e10cSrcweir bool bAxisPositionAttributeImported ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir if( ( !rODFVersionOfFile.getLength() || rODFVersionOfFile.equalsAscii("1.0") 765cdf0e10cSrcweir || rODFVersionOfFile.equalsAscii("1.1") 766cdf0e10cSrcweir || ( rODFVersionOfFile.equalsAscii("1.2") && !bAxisPositionAttributeImported ) ) ) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir try 769cdf0e10cSrcweir { 770cdf0e10cSrcweir Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); 771cdf0e10cSrcweir uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); 772cdf0e10cSrcweir if( aCooSysSeq.getLength() ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] ); 775cdf0e10cSrcweir if( xCooSys.is() ) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 ); 778cdf0e10cSrcweir Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 ); 779cdf0e10cSrcweir //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 ); 780cdf0e10cSrcweir Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 ); 781cdf0e10cSrcweir Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 ); 782cdf0e10cSrcweir 783cdf0e10cSrcweir Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY ); 784cdf0e10cSrcweir Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY ); 785cdf0e10cSrcweir Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY ); 786cdf0e10cSrcweir Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY ); 787cdf0e10cSrcweir 788cdf0e10cSrcweir if( xMainXAxisProp.is() && xMainYAxisProp.is() ) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir chart2::ScaleData aMainXScale = xMainXAxis->getScaleData(); 791cdf0e10cSrcweir if( 0 == rChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) ) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 794cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); 795cdf0e10cSrcweir double fCrossoverValue = 0.0; 796cdf0e10cSrcweir aMainXScale.Origin >>= fCrossoverValue; 797cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") 798cdf0e10cSrcweir , uno::makeAny( fCrossoverValue ) ); 799cdf0e10cSrcweir 800cdf0e10cSrcweir if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") 803cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); 804cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") 805cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); 806cdf0e10cSrcweir if( xSecondaryYAxisProp.is() ) 807cdf0e10cSrcweir xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 808cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); 809cdf0e10cSrcweir } 810cdf0e10cSrcweir else 811cdf0e10cSrcweir { 812cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") 813cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); 814cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") 815cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); 816cdf0e10cSrcweir if( xSecondaryYAxisProp.is() ) 817cdf0e10cSrcweir xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 818cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); 819cdf0e10cSrcweir } 820cdf0e10cSrcweir } 821cdf0e10cSrcweir else 822cdf0e10cSrcweir { 823cdf0e10cSrcweir if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE ) 824cdf0e10cSrcweir { 825cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 826cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); 827cdf0e10cSrcweir if( xSecondaryYAxisProp.is() ) 828cdf0e10cSrcweir xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 829cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir else 832cdf0e10cSrcweir { 833cdf0e10cSrcweir xMainYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 834cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); 835cdf0e10cSrcweir if( xSecondaryYAxisProp.is() ) 836cdf0e10cSrcweir xSecondaryYAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 837cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir } 840cdf0e10cSrcweir 841cdf0e10cSrcweir chart2::ScaleData aMainYScale = xMainYAxis->getScaleData(); 842cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 843cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) ); 844cdf0e10cSrcweir double fCrossoverValue = 0.0; 845cdf0e10cSrcweir aMainYScale.Origin >>= fCrossoverValue; 846cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverValue") 847cdf0e10cSrcweir , uno::makeAny( fCrossoverValue ) ); 848cdf0e10cSrcweir 849cdf0e10cSrcweir if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE ) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") 852cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) ); 853cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") 854cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); 855cdf0e10cSrcweir if( xSecondaryXAxisProp.is() ) 856cdf0e10cSrcweir xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 857cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) ); 858cdf0e10cSrcweir } 859cdf0e10cSrcweir else 860cdf0e10cSrcweir { 861cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("LabelPosition") 862cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) ); 863cdf0e10cSrcweir xMainXAxisProp->setPropertyValue( OUString::createFromAscii("MarkPosition") 864cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) ); 865cdf0e10cSrcweir if( xSecondaryXAxisProp.is() ) 866cdf0e10cSrcweir xSecondaryXAxisProp->setPropertyValue( OUString::createFromAscii("CrossoverPosition") 867cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) ); 868cdf0e10cSrcweir } 869cdf0e10cSrcweir } 870cdf0e10cSrcweir } 871cdf0e10cSrcweir } 872cdf0e10cSrcweir } 873cdf0e10cSrcweir catch( uno::Exception & ) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir } 876cdf0e10cSrcweir } 877cdf0e10cSrcweir } 878cdf0e10cSrcweir 879cdf0e10cSrcweir // ======================================== 880cdf0e10cSrcweir 881cdf0e10cSrcweir SchXMLCategoriesContext::SchXMLCategoriesContext( 882cdf0e10cSrcweir SchXMLImportHelper& rImpHelper, 883cdf0e10cSrcweir SvXMLImport& rImport, 884cdf0e10cSrcweir sal_uInt16 nPrefix, 885cdf0e10cSrcweir const OUString& rLocalName, 886cdf0e10cSrcweir OUString& rAddress ) : 887cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ), 888cdf0e10cSrcweir m_rImportHelper( rImpHelper ), 889cdf0e10cSrcweir mrAddress( rAddress ) 890cdf0e10cSrcweir { 891cdf0e10cSrcweir } 892cdf0e10cSrcweir 893cdf0e10cSrcweir SchXMLCategoriesContext::~SchXMLCategoriesContext() 894cdf0e10cSrcweir { 895cdf0e10cSrcweir } 896cdf0e10cSrcweir 897cdf0e10cSrcweir void SchXMLCategoriesContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) 898cdf0e10cSrcweir { 899cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; 900cdf0e10cSrcweir 901cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ ) 902cdf0e10cSrcweir { 903cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 904cdf0e10cSrcweir OUString aLocalName; 905cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 906cdf0e10cSrcweir 907cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_TABLE && 908cdf0e10cSrcweir IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) ) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY ); 911cdf0e10cSrcweir mrAddress = xAttrList->getValueByIndex( i ); 912cdf0e10cSrcweir } 913cdf0e10cSrcweir } 914cdf0e10cSrcweir } 915cdf0e10cSrcweir 916cdf0e10cSrcweir // ======================================== 917cdf0e10cSrcweir 918cdf0e10cSrcweir DateScaleContext::DateScaleContext( 919cdf0e10cSrcweir SchXMLImportHelper& rImpHelper, 920cdf0e10cSrcweir SvXMLImport& rImport, 921cdf0e10cSrcweir sal_uInt16 nPrefix, 922cdf0e10cSrcweir const OUString& rLocalName, 923cdf0e10cSrcweir const Reference< beans::XPropertySet > xAxisProps ) : 924cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ), 925cdf0e10cSrcweir m_rImportHelper( rImpHelper ), 926cdf0e10cSrcweir m_xAxisProps( xAxisProps ) 927cdf0e10cSrcweir { 928cdf0e10cSrcweir } 929cdf0e10cSrcweir 930cdf0e10cSrcweir DateScaleContext::~DateScaleContext() 931cdf0e10cSrcweir { 932cdf0e10cSrcweir } 933cdf0e10cSrcweir 934cdf0e10cSrcweir namespace 935cdf0e10cSrcweir { 936cdf0e10cSrcweir enum DateScaleAttributeTokens 937cdf0e10cSrcweir { 938cdf0e10cSrcweir XML_TOK_DATESCALE_BASE_TIME_UNIT, 939cdf0e10cSrcweir XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE, 940cdf0e10cSrcweir XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT, 941cdf0e10cSrcweir XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE, 942cdf0e10cSrcweir XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT 943cdf0e10cSrcweir }; 944cdf0e10cSrcweir 945cdf0e10cSrcweir SvXMLTokenMapEntry aDateScaleAttributeTokenMap[] = 946cdf0e10cSrcweir { 947cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_BASE_TIME_UNIT, XML_TOK_DATESCALE_BASE_TIME_UNIT }, 948cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE }, 949cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_MAJOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT }, 950cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_VALUE, XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE }, 951cdf0e10cSrcweir { XML_NAMESPACE_CHART, XML_MINOR_INTERVAL_UNIT, XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT }, 952cdf0e10cSrcweir XML_TOKEN_MAP_END 953cdf0e10cSrcweir }; 954cdf0e10cSrcweir 955cdf0e10cSrcweir class DateScaleAttributeTokenMap : public SvXMLTokenMap 956cdf0e10cSrcweir { 957cdf0e10cSrcweir public: 958cdf0e10cSrcweir DateScaleAttributeTokenMap(): SvXMLTokenMap( aDateScaleAttributeTokenMap ) {} 959cdf0e10cSrcweir virtual ~DateScaleAttributeTokenMap() {} 960cdf0e10cSrcweir }; 961cdf0e10cSrcweir 962cdf0e10cSrcweir struct theDateScaleAttributeTokenMap : public rtl::Static< DateScaleAttributeTokenMap, theDateScaleAttributeTokenMap > {}; 963cdf0e10cSrcweir 964cdf0e10cSrcweir sal_Int32 lcl_getTimeUnit( const OUString& rValue ) 965cdf0e10cSrcweir { 966cdf0e10cSrcweir sal_Int32 nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; 967cdf0e10cSrcweir if( IsXMLToken( rValue, XML_DAYS ) ) 968cdf0e10cSrcweir nTimeUnit = ::com::sun::star::chart::TimeUnit::DAY; 969cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_MONTHS ) ) 970cdf0e10cSrcweir nTimeUnit = ::com::sun::star::chart::TimeUnit::MONTH; 971cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_YEARS ) ) 972cdf0e10cSrcweir nTimeUnit = ::com::sun::star::chart::TimeUnit::YEAR; 973cdf0e10cSrcweir return nTimeUnit; 974cdf0e10cSrcweir } 975cdf0e10cSrcweir 976cdf0e10cSrcweir } 977cdf0e10cSrcweir 978cdf0e10cSrcweir void DateScaleContext::StartElement( const Reference< xml::sax::XAttributeList >& xAttrList ) 979cdf0e10cSrcweir { 980cdf0e10cSrcweir if( !m_xAxisProps.is() ) 981cdf0e10cSrcweir return; 982cdf0e10cSrcweir 983cdf0e10cSrcweir // parse attributes 984cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; 985cdf0e10cSrcweir const SvXMLTokenMap& rAttrTokenMap = theDateScaleAttributeTokenMap::get(); 986cdf0e10cSrcweir 987cdf0e10cSrcweir bool bSetNewIncrement=false; 988cdf0e10cSrcweir chart::TimeIncrement aIncrement; 989cdf0e10cSrcweir m_xAxisProps->getPropertyValue( OUString::createFromAscii( "TimeIncrement" )) >>= aIncrement; 990cdf0e10cSrcweir 991cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ ) 992cdf0e10cSrcweir { 993cdf0e10cSrcweir OUString sAttrName = xAttrList->getNameByIndex( i ); 994cdf0e10cSrcweir OUString aLocalName; 995cdf0e10cSrcweir OUString aValue = xAttrList->getValueByIndex( i ); 996cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 997cdf0e10cSrcweir 998cdf0e10cSrcweir switch( rAttrTokenMap.Get( nPrefix, aLocalName )) 999cdf0e10cSrcweir { 1000cdf0e10cSrcweir case XML_TOK_DATESCALE_BASE_TIME_UNIT: 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir aIncrement.TimeResolution = uno::makeAny( lcl_getTimeUnit(aValue) ); 1003cdf0e10cSrcweir bSetNewIncrement = true; 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir break; 1006cdf0e10cSrcweir case XML_TOK_DATESCALE_MAJOR_INTERVAL_VALUE: 1007cdf0e10cSrcweir { 1008cdf0e10cSrcweir chart::TimeInterval aInterval(1,0); 1009cdf0e10cSrcweir aIncrement.MajorTimeInterval >>= aInterval; 1010cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); 1011cdf0e10cSrcweir aIncrement.MajorTimeInterval = uno::makeAny(aInterval); 1012cdf0e10cSrcweir bSetNewIncrement = true; 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir break; 1015cdf0e10cSrcweir case XML_TOK_DATESCALE_MAJOR_INTERVAL_UNIT: 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir chart::TimeInterval aInterval(1,0); 1018cdf0e10cSrcweir aIncrement.MajorTimeInterval >>= aInterval; 1019cdf0e10cSrcweir aInterval.TimeUnit = lcl_getTimeUnit(aValue); 1020cdf0e10cSrcweir aIncrement.MajorTimeInterval = uno::makeAny(aInterval); 1021cdf0e10cSrcweir bSetNewIncrement = true; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir break; 1024cdf0e10cSrcweir case XML_TOK_DATESCALE_MINOR_INTERVAL_VALUE: 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir chart::TimeInterval aInterval(1,0); 1027cdf0e10cSrcweir aIncrement.MinorTimeInterval >>= aInterval; 1028cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( aInterval.Number, aValue ); 1029cdf0e10cSrcweir aIncrement.MinorTimeInterval = uno::makeAny(aInterval); 1030cdf0e10cSrcweir bSetNewIncrement = true; 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir break; 1033cdf0e10cSrcweir case XML_TOK_DATESCALE_MINOR_INTERVAL_UNIT: 1034cdf0e10cSrcweir { 1035cdf0e10cSrcweir chart::TimeInterval aInterval(1,0); 1036cdf0e10cSrcweir aIncrement.MinorTimeInterval >>= aInterval; 1037cdf0e10cSrcweir aInterval.TimeUnit = lcl_getTimeUnit(aValue); 1038cdf0e10cSrcweir aIncrement.MinorTimeInterval = uno::makeAny(aInterval); 1039cdf0e10cSrcweir bSetNewIncrement = true; 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir break; 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir if( bSetNewIncrement ) 1046cdf0e10cSrcweir m_xAxisProps->setPropertyValue( OUString::createFromAscii( "TimeIncrement" ), uno::makeAny( aIncrement ) ); 1047cdf0e10cSrcweir } 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir // ======================================== 1050