diff options
author | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2010-11-30 01:45:03 +0100 |
---|---|---|
committer | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2010-11-30 01:45:03 +0100 |
commit | edaa216847e59ad93b8b99e95f293f8bb04344cc (patch) | |
tree | 7193a7fdd5a3520b21755c675cb4d3de4e3100cb /chart2/source | |
parent | 0e5566e9ff510bedc9837e12ee37103c553897da (diff) |
chart46: #i25706# implement date axis
Diffstat (limited to 'chart2/source')
117 files changed, 5009 insertions, 2159 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 6d53fb8b01f6..fe24a0bf4eb0 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -82,6 +82,8 @@ enum PROP_AXIS_AUTO_MIN, PROP_AXIS_AUTO_STEPMAIN, PROP_AXIS_AUTO_STEPHELP, + PROP_AXIS_TYPE, + PROP_AXIS_TIME_INCREMENT, PROP_AXIS_LOGARITHMIC, PROP_AXIS_REVERSEDIRECTION, PROP_AXIS_VISIBLE, @@ -174,6 +176,20 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT )); rOutProperties.push_back( + Property( C2U( "AxisType" ), + PROP_AXIS_TYPE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), //type com::sun::star::chart::ChartAxisType + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TimeIncrement" ), + PROP_AXIS_TIME_INCREMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)), + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( Property( C2U( "Logarithmic" ), PROP_AXIS_LOGARITHMIC, ::getBooleanCppuType(), diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index e20167e216c2..dafef0f2aa72 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -27,8 +27,7 @@ #ifndef CHART_CHART2MODELCONTACT_HXX #define CHART_CHART2MODELCONTACT_HXX -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <chartview/ExplicitScaleValues.hxx> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XDataSeries.hpp> @@ -79,8 +78,8 @@ public: sal_Bool getExplicitValuesForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > & xAxis, - ::com::sun::star::chart2::ExplicitScaleData & rOutExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData & rOutExplicitIncrement ); + ExplicitScaleData & rOutExplicitScale, + ExplicitIncrementData & rOutExplicitIncrement ); sal_Int32 getExplicitNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 062dcc1a129d..6ab0e6c5f483 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -64,9 +64,11 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; using ::osl::MutexGuard; +using ::com::sun::star::chart2::XAnyDescriptionAccess; using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; +using ::com::sun::star::chart::XDateCategories; namespace { @@ -132,7 +134,7 @@ struct lcl_Operator virtual ~lcl_Operator() { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) = 0; + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0; virtual bool setsCategories( bool /*bDataInColumns*/ ) { @@ -155,13 +157,20 @@ struct lcl_AllOperator : public lcl_Operator return true; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( !xDataAccess.is() ) return; + Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY ); Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY ); - if( xNewComplex.is() ) + if( xNewAny.is() ) + { + xDataAccess->setData( xNewAny->getData() ); + xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() ); + xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() ); + } + else if( xNewComplex.is() ) { xDataAccess->setData( xNewComplex->getData() ); xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() ); @@ -192,7 +201,7 @@ struct lcl_DataOperator : public lcl_Operator { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) ); @@ -205,96 +214,208 @@ struct lcl_DataOperator : public lcl_Operator struct lcl_RowDescriptionsOperator : public lcl_Operator { - lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions ) + lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rRowDescriptions( rRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setRowDescriptions( m_rRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator { - lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions ) + lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexRowDescriptions( rComplexRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { - return !bDataInColumns; + m_bDataInColumns = bDataInColumns; + return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; +//-------------------------------------------------------------------------- + +struct lcl_AnyRowDescriptionsOperator : public lcl_Operator +{ + lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions ) + : lcl_Operator() + , m_rAnyRowDescriptions( rAnyRowDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions; }; //-------------------------------------------------------------------------- struct lcl_ColumnDescriptionsOperator : public lcl_Operator { - lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions ) + lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rColumnDescriptions( rColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setColumnDescriptions( m_rColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator { - lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions ) + lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexColumnDescriptions( rComplexColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; + +//-------------------------------------------------------------------------- + +struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator +{ + lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions ) + : lcl_Operator() + , m_rAnyColumnDescriptions( rAnyColumnDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return !bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions; +}; + +//-------------------------------------------------------------------------- + +struct lcl_DateCategoriesOperator : public lcl_Operator +{ + lcl_DateCategoriesOperator( const Sequence< double >& rDates ) + : lcl_Operator() + , m_rDates( rDates ) + { + } + + virtual bool setsCategories( bool /*bDataInColumns*/ ) + { + return true; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + xDateCategories->setDateCategories( m_rDates ); + } + + const Sequence< double >& m_rDates; }; //-------------------------------------------------------------------------- @@ -353,6 +474,7 @@ Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions() return m_xDataAccess->getColumnDescriptions(); return Sequence< OUString > (); } + // ____ XComplexDescriptionAccess (read) ____ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException) { @@ -369,6 +491,32 @@ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDesc return Sequence< Sequence< OUString > >(); } +// ____ XAnyDescriptionAccess (read) ____ +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyRowDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyColumnDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} + +// ____ XDateCategories (read) ____ +Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories() throw (uno::RuntimeException) +{ + initDataAccess(); + Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + return xDateCategories->getDateCategories(); + return Sequence< double >(); +} + // ____ XChartDataArray (write)____ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData ) throw (uno::RuntimeException) @@ -379,26 +527,48 @@ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& r void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_RowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } // ____ XComplexDescriptionAccess (write) ____ void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); + applyData( aOperator ); +} + +// ____ XAnyDescriptionAccess (write) ____ +void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions ); + applyData( aOperator ); +} +void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions ); + applyData( aOperator ); +} + +// ____ XDateCategories (write) ____ +void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + lcl_DateCategoriesOperator aOperator( rDates ); applyData( aOperator ); + DiagramHelper::switchToDateCategories( xChartDoc ); } //-------------------------------------------------------------------------------------- @@ -508,11 +678,11 @@ void ChartDataWrapper::initDataAccess() if( !xChartDoc.is() ) return; if( xChartDoc->hasInternalDataProvider() ) - m_xDataAccess = Reference< XComplexDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); + m_xDataAccess = Reference< XAnyDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); else { //create a separate "internal data provider" that is not connected to the model - m_xDataAccess = Reference< XComplexDescriptionAccess >( ChartModelHelper::createInternalDataProvider( + m_xDataAccess = Reference< XAnyDescriptionAccess >( ChartModelHelper::createInternalDataProvider( xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW ); } } diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx index d56397953d79..16695914f892 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -29,9 +29,10 @@ #include "ServiceMacros.hxx" #include "MutexContainer.hxx" -#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> #include <cppuhelper/interfacecontainer.hxx> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/chart/XDateCategories.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -48,8 +49,9 @@ class Chart2ModelContact; struct lcl_Operator; class ChartDataWrapper : public MutexContainer, public - ::cppu::WeakImplHelper4< - com::sun::star::chart::XComplexDescriptionAccess, + ::cppu::WeakImplHelper5< + com::sun::star::chart2::XAnyDescriptionAccess, + com::sun::star::chart::XDateCategories, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XEventListener, com::sun::star::lang::XComponent > @@ -64,7 +66,25 @@ public: APPHELPER_XSERVICEINFO_DECL() protected: - // ____ XComplexDescriptionAccess ____ + // ____ XDateCategories ____ + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XAnyDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyRowDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyColumnDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setComplexRowDescriptions( @@ -136,7 +156,7 @@ private: //methods private: //member ::com::sun::star::uno::Reference< - ::com::sun::star::chart::XComplexDescriptionAccess > m_xDataAccess; + ::com::sun::star::chart2::XAnyDescriptionAccess > m_xDataAccess; ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index d6487d425657..8dd846474170 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -60,7 +60,6 @@ #include <com/sun/star/chart2/XTitled.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <comphelper/InlineContainer.hxx> // header for function SvxShapeCollection_NewInstance #include <svx/unoshcol.hxx> @@ -81,7 +80,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart; -using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index b0fc030d0fbf..037a5795baa5 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -33,9 +33,8 @@ #include "CommonConverters.hxx" #include "AxisHelper.hxx" #include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <chartview/ExplicitScaleValues.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -43,6 +42,7 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using ::com::sun::star::chart::TimeIncrement; //............................................................................. namespace chart @@ -91,6 +91,12 @@ WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty case SCALE_PROP_AUTO_STEPHELP: m_aOuterName = C2U("AutoStepHelp"); break; + case SCALE_PROP_AXIS_TYPE: + m_aOuterName = C2U("AxisType"); + break; + case SCALE_PROP_DATE_INCREMENT: + m_aOuterName = C2U("TimeIncrement"); + break; case SCALE_PROP_LOGARITHMIC: m_aOuterName = C2U("Logarithmic"); break; @@ -122,6 +128,8 @@ void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* > rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); } @@ -266,6 +274,40 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons bSetScaleData = true; break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType; + if( (rOuterValue >>= nType) ) + { + if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType ) + { + aScaleData.AutoDateAxis = true; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::CATEGORY == nType ) + { + aScaleData.AutoDateAxis = false; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::DATE == nType ) + { + if( aScaleData.AxisType == AxisType::CATEGORY ) + aScaleData.AxisType = AxisType::DATE; + } + bSetScaleData = true; + } + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + TimeIncrement aTimeIncrement; + rOuterValue >>= aTimeIncrement; + aScaleData.TimeIncrement = aTimeIncrement; + bSetScaleData = true; + break; + } case SCALE_PROP_LOGARITHMIC: { if( rOuterValue >>= bBool ) @@ -320,8 +362,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const chart2::ScaleData aScaleData( xAxis->getScaleData() ); - chart2::ExplicitScaleData aExplicitScale; - chart2::ExplicitIncrementData aExplicitIncrement; + ExplicitScaleData aExplicitScale; + ExplicitIncrementData aExplicitIncrement; switch( eScaleProperty ) { @@ -401,7 +443,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 && + + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 ) { if( bLogarithmic ) @@ -440,7 +483,7 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const if( bNeedToCalculateExplicitValues ) { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 ) + if( !aExplicitIncrement.SubIncrements.empty() ) nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; } aRet = uno::makeAny( nIntervalCount ); @@ -486,6 +529,27 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const aRet <<= !hasDoubleValue(aScaleData.Origin); break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType = ::com::sun::star::chart::ChartAxisType::AUTOMATIC; + if( aScaleData.AxisType == AxisType::DATE ) + { + nType = ::com::sun::star::chart::ChartAxisType::DATE; + } + else if( aScaleData.AxisType == AxisType::CATEGORY ) + { + if( !aScaleData.AutoDateAxis ) + nType = ::com::sun::star::chart::ChartAxisType::CATEGORY; + } + aRet = uno::makeAny( nType ); + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + aRet = uno::makeAny( aScaleData.TimeIncrement ); + break; + } case SCALE_PROP_LOGARITHMIC: { aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 4d29bc009777..1543d7b645fb 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -55,6 +55,8 @@ public: , SCALE_PROP_AUTO_ORIGIN , SCALE_PROP_AUTO_STEPMAIN , SCALE_PROP_AUTO_STEPHELP + , SCALE_PROP_AXIS_TYPE + , SCALE_PROP_DATE_INCREMENT , SCALE_PROP_LOGARITHMIC , SCALE_PROP_REVERSEDIRECTION }; diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 513d49b6aad8..38eae1f962d1 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -517,6 +517,20 @@ DataBrowser::~DataBrowser() { } +bool DataBrowser::HasDateCategories() const +{ + if( m_apDataBrowserModel.get() ) + return m_apDataBrowserModel->hasDateCategories(); + return false; +} + +bool DataBrowser::MayToggleDateCategories() const +{ + return ! IsReadOnly() + && DiagramHelper::mayToggleDateCategories( m_xChartDoc ); + return true; +} + bool DataBrowser::MayInsertRow() const { return ! IsReadOnly() @@ -993,6 +1007,19 @@ void DataBrowser::SwapRow() } } +void DataBrowser::ToggleDateCategories() +{ + if( m_apDataBrowserModel.get() ) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->toggleDateCategories(); + RenewTable(); + } +} + void DataBrowser::SetCursorMovedHdl( const Link& rLink ) { m_aCursorMovedHdlLink = rLink; diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 3583db2770c0..7a7cd120fb5f 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -113,6 +113,9 @@ public: // predicates to determine what actions are possible at the current cursor // position. This depends on the implementation of the according mutators // below. (They are used for enabling toolbar icons) + bool HasDateCategories() const; + bool MayToggleDateCategories() const; + bool MayInsertRow() const; bool MayInsertColumn() const; bool MayDeleteRow() const; @@ -131,6 +134,8 @@ public: using BrowseBox::RemoveColumn; using BrowseBox::MouseButtonDown; + void ToggleDateCategories(); + void SwapRow(); void SwapColumn(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c0b865536686..7e93afd3b42e 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -568,6 +568,12 @@ void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) // unlockControllers } +void DataBrowserModel::toggleDateCategories() +{ + DiagramHelper::toggleDateCategories( Reference<chart2::XChartDocument>( m_apDialogModel->getChartModel(), uno::UNO_QUERY ) ); + updateFromModel(); +} + DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( const Reference< chart2::XDataSeries > & xSeries ) const { @@ -589,7 +595,7 @@ Reference< chart2::XDataSeries > return 0; } -DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) +DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) const { eCellType eResult = TEXT; tDataColumnVector::size_type nIndex( nAtColumn ); @@ -755,6 +761,12 @@ sal_Int32 DataBrowserModel::getCategoryColumnCount() } return nLastTextColumnIndex+1; } +bool DataBrowserModel::hasDateCategories() const +{ + if( NUMBER == getCellType( 0, 0 ) ) + return true; + return false; +} const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const { @@ -771,6 +783,10 @@ void DataBrowserModel::updateFromModel() Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); if( !xDiagram.is()) return; + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); + if( !xCooSysCnt.is()) + return; + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); // set template at DialogModel uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ); @@ -785,6 +801,10 @@ void DataBrowserModel::updateFromModel() { Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY ); ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); + bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); + sal_Int32 nDateCategoriesNumberFormat = 0; + if( bIsDateAxis && aCooSysSeq.getLength() ) + nDateCategoriesNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[0], 0, 0 ); const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); @@ -798,18 +818,24 @@ void DataBrowserModel::updateFromModel() aCategories.m_xLabeledDataSequence.set( xCategories ); if( lcl_ShowCategoriesAsDataLabel( xDiagram )) aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); + else if( bIsDateAxis ) + aCategories.m_aUIRoleName = DialogModel::GetRoleDates(); else aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); - aCategories.m_eCellType = TEXT; + if( bIsDateAxis ) + { + aCategories.m_eCellType = NUMBER; + aCategories.m_nNumberFormatKey = nDateCategoriesNumberFormat; + } + else + { + aCategories.m_eCellType = TEXT; + } m_aColumns.push_back( aCategories ); ++nHeaderStart; } } - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) - return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) { Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index a4378972f70f..d6c82a2f15ea 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -78,13 +78,15 @@ public: void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); void removeDataPointForAllSeries( sal_Int32 nAtIndex ); + void toggleDateCategories(); + enum eCellType { NUMBER, TEXT }; - eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); @@ -103,6 +105,8 @@ public: ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; + bool hasDateCategories() const; + struct tDataHeader { ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index f32a882aa1e9..00b25fb701fb 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -160,7 +160,7 @@ void lcl_createRoleIndexMap( lcl_tRoleIndexMap & rOutMap ) struct lcl_DataSeriesContainerAppend : public ::std::iterator< ::std::output_iterator_tag, Reference< XDataSeriesContainer > > { - typedef ::std::vector< chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; + typedef ::std::vector< ::chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; explicit lcl_DataSeriesContainerAppend( tContainerType & rCnt ) : m_rDestCnt( rCnt ) @@ -180,7 +180,7 @@ struct lcl_DataSeriesContainerAppend : public for( sal_Int32 nI = 0; nI < aSeq.getLength(); ++ nI ) { m_rDestCnt.push_back( - chart::DialogModel::tSeriesWithChartTypeByName( + ::chart::DialogModel::tSeriesWithChartTypeByName( ::chart::DataSeriesHelper::getDataSeriesLabel( aSeq[nI], aRole ), ::std::make_pair( aSeq[nI], xCT ))); } @@ -737,6 +737,12 @@ OUString DialogModel::GetRoleDataLabel() } // static +OUString DialogModel::GetRoleDates() +{ + return OUString( String( ::chart::SchResId( STR_DATA_DATE_CATEGORIES ))); +} + +// static sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) { diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index dcca6c716b8d..25bbc2669a9b 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -152,6 +152,7 @@ public: static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); static ::rtl::OUString GetRoleDataLabel(); + static ::rtl::OUString GetRoleDates(); // pass a role string (not translated) and get an index that serves for // relative ordering, to get e.g. x-values and y-values in the right order diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 4b4cec65426e..b25c99454cef 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -548,6 +548,10 @@ String STR_DATA_ROLE_CATEGORIES { Text [ en-US ] = "Categories"; }; +String STR_DATA_DATE_CATEGORIES +{ + Text [ en-US ] = "Dates"; +}; String STR_DATA_UNNAMED_SERIES { diff --git a/chart2/source/controller/dialogs/Strings_Scale.src b/chart2/source/controller/dialogs/Strings_Scale.src index e7a3d6c2b1cf..6f8b75d9509c 100644 --- a/chart2/source/controller/dialogs/Strings_Scale.src +++ b/chart2/source/controller/dialogs/Strings_Scale.src @@ -42,3 +42,11 @@ String STR_MIN_GREATER_MAX { Text [ en-US ] = "The minimum must be lower than the maximum. Check your input." ; }; +String STR_INVALID_INTERVALS +{ + Text [ en-US ] = "The major interval needs to be greater than the minor interval. Check your input." ; +}; +String STR_INVALID_TIME_UNIT +{ + Text [ en-US ] = "The major and minor interval need to be greater or equal to the resolution. Check your input." ; +}; diff --git a/chart2/source/controller/dialogs/TabPages.hrc b/chart2/source/controller/dialogs/TabPages.hrc index 1f445083738f..dbc166e4f2cd 100644 --- a/chart2/source/controller/dialogs/TabPages.hrc +++ b/chart2/source/controller/dialogs/TabPages.hrc @@ -111,31 +111,6 @@ #define FT_AXIS_TEXTDIR 19 #define LB_AXIS_TEXTDIR 20 -//#define TP_SCALE 903 - -#define FL_SCALE 1 - -#define TXT_MIN 1 -#define TXT_MAX 2 -#define TXT_STEP_MAIN 3 -#define TXT_STEP_HELP 4 -#define TXT_ORIGIN 5 - -#define CBX_AUTO_MIN 1 -#define CBX_AUTO_MAX 2 -#define CBX_AUTO_STEP_MAIN 3 -#define CBX_AUTO_STEP_HELP 4 -#define CBX_AUTO_ORIGIN 5 -#define CBX_LOGARITHM 6 -#define CBX_REVERSE 7 - -#define EDT_STEP_MAIN 1 -#define EDT_MAX 2 -#define EDT_MIN 3 -#define EDT_ORIGIN 4 - -#define MT_STEPHELP 10 - //#define TP_AXIS_POSITIONS 904 #define FL_AXIS_LINE 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index f1d441921a6a..ff365ae460a3 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -160,6 +160,9 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) case TBI_DATA_SWAP_ROW : m_apBrwData->SwapRow (); break; + case TBI_DATA_TOGGLE_DATE_CATEGOGRIES: + m_apBrwData->ToggleDateCategories (); + break; } return 0; @@ -175,13 +178,15 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() ); m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() && !m_apBrwData->HasDateCategories() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); + return 0; } @@ -198,6 +203,7 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGOGRIES, FALSE ); } m_apBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc index d2675c5bb29e..b4f1cbe1b3a7 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -41,6 +41,7 @@ #define TBI_DATA_SWAP_COL 5 #define TBI_DATA_SWAP_ROW 6 #define TBI_DATA_INSERT_TEXT_COL 7 +#define TBI_DATA_TOGGLE_DATE_CATEGOGRIES 8 // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src index 02ccc98b7a82..64919d64b0b2 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.src +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -116,6 +116,12 @@ ModalDialog DLG_DIAGRAM_DATA { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; + Identifier = TBI_DATA_TOGGLE_DATE_CATEGOGRIES ; + Text [ en-US ] = "Categories: Date/Text" ; + }; }; }; @@ -129,8 +135,9 @@ ModalDialog DLG_DIAGRAM_DATA TBI_DATA_DELETE_COL; \ TBI_DATA_SWAP_COL; \ TBI_DATA_SWAP_ROW; \ + TBI_DATA_TOGGLE_DATE_CATEGOGRIES; \ }; \ - IdCount = { 7; } + IdCount = { 8; } ImageList IL_DIAGRAM_DATA { diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index 9c4438b6f1ca..a362c883567d 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -119,7 +119,7 @@ double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement ); fStepWidth = aExplicitIncrement.Distance; - if( aExplicitIncrement.SubIncrements.getLength() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount); else fStepWidth/=10; diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2a41d35313e8..5b3b96c705b3 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -179,7 +179,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel ScaleData aData( xAxis->getScaleData() ); if( chart2::AxisType::SERIES == aData.AxisType ) m_bHasScaleProperties = false; - if( chart2::AxisType::REALNUMBER == aData.AxisType || chart2::AxisType::PERCENT == aData.AxisType ) + if( chart2::AxisType::SERIES != aData.AxisType ) m_bHasNumberProperties = true; sal_Int32 nCooSysIndex=0; diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 3dcaa3092e57..876cb0f78c91 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -141,13 +141,13 @@ BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) bRadioButtonChecked = false; if( bRadioButtonChecked ) - rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_TEXT_ORDER )); + rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER )); } if( aCbTextOverlap.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_OVERLAP, aCbTextOverlap.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) ); if( aCbTextBreak.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXTBREAK, aCbTextBreak.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) ); if( aCbShowDescription.GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) ); @@ -211,7 +211,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); // Text overlap ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextOverlap.EnableTriState( TRUE ); @@ -230,7 +230,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) } // text break ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextBreak.EnableTriState( TRUE ); @@ -255,7 +255,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { - aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, FALSE, &pPoolItem ); if( aState == SFX_ITEM_SET ) { SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 34fc0702bafe..7544faf88bd6 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "tp_Scale.hxx" +#include "tp_Scale.hrc" #include "ResId.hxx" -#include "TabPages.hrc" #include "Strings.hrc" #include "chartview/ChartSfxItemIds.hxx" #include "NoWarningThisInCTOR.hxx" @@ -72,6 +72,20 @@ namespace chart namespace { +void lcl_placeControlAtX( Control& rControl, long nNewXPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.X() = nNewXPos; + rControl.SetPosPixel(aPos); +} + +void lcl_placeControlAtY( Control& rControl, long nNewYPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.Y() = nNewYPos; + rControl.SetPosPixel(aPos); +} + void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) { Point aPos( rEdit.GetPosPixel() ); @@ -84,50 +98,57 @@ void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) rAuto.SetPosPixel(aPos); } -void lcl_placeControlsAtY( Control& rTop, Control& rBottom, long nNewYPos ) -{ - Point aPos( rTop.GetPosPixel() ); - long nShift = nNewYPos - aPos.Y(); - aPos.Y() = nNewYPos; - rTop.SetPosPixel(aPos); - - aPos = rBottom.GetPosPixel(); - aPos.Y() += nShift; - rBottom.SetPosPixel(aPos); -} - } ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs), aFlScale(this, SchResId(FL_SCALE)), + + aCbxReverse(this, SchResId(CBX_REVERSE)), + aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), + + m_aTxt_AxisType(this, SchResId (TXT_AXIS_TYPE)), + m_aLB_AxisType(this, SchResId(LB_AXIS_TYPE)), + aTxtMin (this, SchResId (TXT_MIN)), aFmtFldMin(this, SchResId(EDT_MIN)), aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)), + aTxtMax(this, SchResId (TXT_MAX)), aFmtFldMax(this, SchResId(EDT_MAX)), aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)), + + m_aTxt_TimeResolution(this, SchResId (TXT_TIME_RESOLUTION)), + m_aLB_TimeResolution(this, SchResId(LB_TIME_RESOLUTION)), + m_aCbx_AutoTimeResolution(this, SchResId(CBX_AUTO_TIME_RESOLUTION)), + aTxtMain (this, SchResId (TXT_STEP_MAIN)), aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)), + m_aMt_MainDateStep(this, SchResId(MT_MAIN_DATE_STEP)), + m_aLB_MainTimeUnit(this, SchResId(LB_MAIN_TIME_UNIT)), aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)), + + aTxtHelpCount (this, SchResId (TXT_STEP_HELP_COUNT)), aTxtHelp (this, SchResId (TXT_STEP_HELP)), aMtStepHelp (this, SchResId (MT_STEPHELP)), + m_aLB_HelpTimeUnit(this, SchResId(LB_HELP_TIME_UNIT)), aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)), aTxtOrigin (this, SchResId (TXT_ORIGIN)), aFmtFldOrigin(this, SchResId(EDT_ORIGIN)), aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)), - aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), - aCbxReverse(this, SchResId(CBX_REVERSE)), - fMin(0.0), fMax(0.0), fStepMain(0.0), nStepHelp(0), fOrigin(0.0), - nAxisType(chart2::AxisType::REALNUMBER), + m_nTimeResolution(1), + m_nMainTimeUnit(1), + m_nHelpTimeUnit(1), + m_nAxisType(chart2::AxisType::REALNUMBER), + m_bAllowDateAxis(false), pNumFormatter(NULL), m_bShowAxisOrigin(false) { @@ -139,6 +160,14 @@ ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + m_aCbx_AutoTimeResolution.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + + m_aLB_AxisType.SetDropDownLineCount(3); + m_aLB_AxisType.SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl)); + + m_aLB_TimeResolution.SetDropDownLineCount(3); + m_aLB_MainTimeUnit.SetDropDownLineCount(3); + m_aLB_HelpTimeUnit.SetDropDownLineCount(3); } void ScaleTabPage::StateChanged( StateChangedType nType ) @@ -149,16 +178,24 @@ void ScaleTabPage::StateChanged( StateChangedType nType ) AdjustControlPositions(); } +long lcl_getLabelDistance( Control& rControl ) +{ + return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); +} + void ScaleTabPage::AdjustControlPositions() { //optimize position of the controls long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() ); nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( aTxtHelpCount.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_TimeResolution.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_AxisType.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth+=1; - long nLabelDistance = aTxtMin.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance; //ensure that the auto checkboxes are wide enough and have correct size for calculation @@ -167,9 +204,10 @@ void ScaleTabPage::AdjustControlPositions() aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() ); aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() ); aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() ); + m_aCbx_AutoTimeResolution.SetSizePixel( m_aCbx_AutoTimeResolution.CalcMinimumSize() ); //ensure new pos is ok - long nWidthOfOtherControls = aCbxAutoMin.GetPosPixel().X() + aCbxAutoMin.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); + long nWidthOfOtherControls = m_aLB_MainTimeUnit.GetPosPixel().X() + m_aLB_MainTimeUnit.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); long nDialogWidth = GetSizePixel().Width(); long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls; @@ -181,72 +219,180 @@ void ScaleTabPage::AdjustControlPositions() aTxtMax.SetSizePixel(aSize); aTxtMain.SetSizePixel(aSize); aTxtHelp.SetSizePixel(aSize); + aTxtHelpCount.SetSizePixel(aSize); aTxtOrigin.SetSizePixel(aSize); + m_aTxt_TimeResolution.SetSizePixel(aSize); + m_aTxt_AxisType.SetSizePixel(aSize); + + long nOrgAutoCheckX = aCbxAutoMin.GetPosPixel().X(); + lcl_placeControlAtX( aCbxAutoStepMain, nOrgAutoCheckX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nOrgAutoCheckX ); lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos ); lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos ); lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos ); + lcl_placeControlAtX( m_aMt_MainDateStep, aFmtFldStepMain.GetPosPixel().X() ); lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos ); lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos ); + lcl_shiftControls( m_aLB_TimeResolution, m_aCbx_AutoTimeResolution, nNewXPos ); + lcl_placeControlAtX( m_aLB_AxisType, nNewXPos ); + + nNewXPos = aCbxAutoStepMain.GetPosPixel().X() + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nNewXPos ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nNewXPos ); } + PlaceIntervalControlsAccordingToAxisType(); } -void ScaleTabPage::EnableControls() +void ScaleTabPage::PlaceIntervalControlsAccordingToAxisType() { - bool bEnableForValueOrPercentAxis = chart2::AxisType::REALNUMBER == nAxisType || chart2::AxisType::PERCENT == nAxisType; - aFlScale.Enable( bEnableForValueOrPercentAxis ); - aTxtMin.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMin.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMin.Enable( bEnableForValueOrPercentAxis ); - aTxtMax.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMax.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMax.Enable( bEnableForValueOrPercentAxis ); - aTxtMain.Enable( bEnableForValueOrPercentAxis ); - aFmtFldStepMain.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepMain.Enable( bEnableForValueOrPercentAxis ); - aTxtHelp.Enable( bEnableForValueOrPercentAxis ); - aMtStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxLogarithm.Enable( bEnableForValueOrPercentAxis ); - - aTxtOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aFmtFldOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aCbxAutoOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - - long nNewYPos = aTxtOrigin.GetPosPixel().Y(); - if( m_bShowAxisOrigin ) - nNewYPos += ( aTxtOrigin.GetPosPixel().Y() - aTxtHelp.GetPosPixel().Y() ); - lcl_placeControlsAtY( aCbxLogarithm, aCbxReverse, nNewYPos ); + long nMinX = std::min( aCbxAutoStepMain.GetPosPixel().X(), m_aLB_MainTimeUnit.GetPosPixel().X() ); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); + long nListWidth = m_aLB_MainTimeUnit.GetSizePixel().Width(); + + if( chart2::AxisType::DATE == m_nAxisType ) + { + lcl_placeControlAtX( m_aLB_MainTimeUnit, nMinX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nMinX ); + long nSecondX = nMinX + nListWidth + nLabelDistance; + lcl_placeControlAtX( aCbxAutoStepMain, nSecondX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nSecondX ); + + long nOne = m_aMt_MainDateStep.LogicToPixel( Size(0, 1), MapMode(MAP_APPFONT) ).Height(); + + long nYMajor = m_aMt_MainDateStep.GetPosPixel().Y(); + lcl_placeControlAtY( aCbxAutoStepMain , nYMajor+(3*nOne)); + lcl_placeControlAtY( aTxtMain , nYMajor+nOne+nOne); + + long nYMinor = m_aLB_HelpTimeUnit.GetPosPixel().Y(); + lcl_placeControlAtY( aMtStepHelp , nYMinor ); + lcl_placeControlAtY( aCbxAutoStepHelp , nYMinor+(3*nOne)); + } + else + { + lcl_placeControlAtX( aCbxAutoStepMain, nMinX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nMinX ); + long nSecondX = nMinX + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + long nSecondXMax = GetSizePixel().Width() - nListWidth; + if( nSecondX > nSecondXMax ) + nSecondX = nSecondXMax; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nSecondX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nSecondX ); + } } +void ScaleTabPage::EnableControls() +{ + bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType || chart2::AxisType::PERCENT == m_nAxisType || chart2::AxisType::DATE == m_nAxisType; + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + + m_aTxt_AxisType.Show(m_bAllowDateAxis); + m_aLB_AxisType.Show(m_bAllowDateAxis); + + aCbxLogarithm.Show( bValueAxis && !bDateAxis ); + aTxtMin.Show( bValueAxis ); + aFmtFldMin.Show( bValueAxis ); + aCbxAutoMin.Show( bValueAxis ); + aTxtMax.Show( bValueAxis ); + aFmtFldMax.Show( bValueAxis ); + aCbxAutoMax.Show( bValueAxis ); + aTxtMain.Show( bValueAxis ); + aFmtFldStepMain.Show( bValueAxis ); + aCbxAutoStepMain.Show( bValueAxis ); + aTxtHelp.Show( bValueAxis ); + aTxtHelpCount.Show( bValueAxis ); + aMtStepHelp.Show( bValueAxis ); + aCbxAutoStepHelp.Show( bValueAxis ); + + aTxtOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aFmtFldOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aCbxAutoOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + + aTxtHelpCount.Show( bValueAxis && !bDateAxis ); + aTxtHelp.Show( bDateAxis ); + + m_aTxt_TimeResolution.Show( bDateAxis ); + m_aLB_TimeResolution.Show( bDateAxis ); + m_aCbx_AutoTimeResolution.Show( bDateAxis ); + + bool bWasDateAxis = m_aMt_MainDateStep.IsVisible(); + if( bWasDateAxis != bDateAxis ) + { + //transport value from one to other control + if( bWasDateAxis ) + aFmtFldStepMain.SetValue( m_aMt_MainDateStep.GetValue() ); + else + m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(aFmtFldStepMain.GetValue()) ); + } + aFmtFldStepMain.Show( bValueAxis && !bDateAxis ); + m_aMt_MainDateStep.Show( bDateAxis ); + m_aLB_MainTimeUnit.Show( bDateAxis ); + m_aLB_HelpTimeUnit.Show( bDateAxis ); + + EnableValueHdl(&aCbxAutoMin); + EnableValueHdl(&aCbxAutoMax); + EnableValueHdl(&aCbxAutoStepMain); + EnableValueHdl(&aCbxAutoStepHelp); + EnableValueHdl(&aCbxAutoOrigin); + EnableValueHdl(&m_aCbx_AutoTimeResolution); +} IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx ) { + bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled(); if (pCbx == &aCbxAutoMin) { - aFmtFldMin.Enable(!aCbxAutoMin.IsChecked()); + aFmtFldMin.Enable( bEnable ); } else if (pCbx == &aCbxAutoMax) { - aFmtFldMax.Enable(!aCbxAutoMax.IsChecked()); + aFmtFldMax.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepMain) { - aFmtFldStepMain.Enable(!aCbxAutoStepMain.IsChecked()); + aFmtFldStepMain.Enable( bEnable ); + m_aMt_MainDateStep.Enable( bEnable ); + m_aLB_MainTimeUnit.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepHelp) { - aMtStepHelp.Show (); - aMtStepHelp.Enable( ! aCbxAutoStepHelp.IsChecked() ); + aMtStepHelp.Enable( bEnable ); + m_aLB_HelpTimeUnit.Enable( bEnable ); + } + else if (pCbx == &m_aCbx_AutoTimeResolution) + { + m_aLB_TimeResolution.Enable( bEnable ); } else if (pCbx == &aCbxAutoOrigin) { - aFmtFldOrigin.Enable(!aCbxAutoOrigin.IsChecked()); + aFmtFldOrigin.Enable( bEnable ); } return 0; } +enum AxisTypeListBoxEntry +{ + TYPE_AUTO=0, + TYPE_TEXT=1, + TYPE_DATE=2 +}; + +IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG ) +{ + USHORT nPos = m_aLB_AxisType.GetSelectEntryPos(); + if( nPos==TYPE_DATE ) + m_nAxisType = chart2::AxisType::DATE; + else + m_nAxisType = chart2::AxisType::CATEGORY; + if( chart2::AxisType::DATE == m_nAxisType ) + aCbxLogarithm.Check(false); + EnableControls(); + PlaceIntervalControlsAccordingToAxisType(); + SetNumFormat(); + return 0; +} + SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) { return new ScaleTabPage(pWindow, rOutAttrs); @@ -256,10 +402,18 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) { DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,aCbxAutoMin.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,aCbxAutoMax.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,aCbxAutoStepHelp.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,aCbxAutoOrigin.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType)); + if(m_bAllowDateAxis) + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_aLB_AxisType.GetSelectEntryPos())); + + bool bAutoScale = false; + if( m_nAxisType==chart2::AxisType::CATEGORY ) + bAutoScale = true;//reset scaling for category charts + + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || aCbxAutoMin.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || aCbxAutoMax.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || aCbxAutoStepHelp.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || aCbxAutoOrigin.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX)); @@ -270,6 +424,12 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution)); + + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit)); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit)); + return TRUE; } @@ -280,12 +440,34 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) return; const SfxPoolItem *pPoolItem = NULL; - nAxisType=chart2::AxisType::REALNUMBER; + if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + m_nAxisType=chart2::AxisType::REALNUMBER; if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); + if( m_bAllowDateAxis ) { - nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); - EnableControls(); + bool bAutoDateAxis = false; + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + + USHORT nPos = 0; + if( m_nAxisType==chart2::AxisType::DATE ) + nPos=TYPE_DATE; + else if( bAutoDateAxis ) + nPos=TYPE_AUTO; + else + nPos=TYPE_TEXT; + m_aLB_AxisType.SelectEntryPos( nPos ); } + PlaceIntervalControlsAccordingToAxisType(); + + aCbxAutoMin.Check( true ); + aCbxAutoMax.Check( true ); + aCbxAutoStepMain.Check( true ); + aCbxAutoStepHelp.Check( true ); + aCbxAutoOrigin.Check( true ); + m_aCbx_AutoTimeResolution.Check( true ); if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); @@ -312,6 +494,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) { fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); aFmtFldStepMain.SetValue( fStepMain ); + m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(fStepMain) ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); @@ -332,11 +515,27 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) aFmtFldOrigin.SetValue( fOrigin ); } - EnableValueHdl(&aCbxAutoMin); - EnableValueHdl(&aCbxAutoMax); - EnableValueHdl(&aCbxAutoStepMain); - EnableValueHdl(&aCbxAutoStepHelp); - EnableValueHdl(&aCbxAutoOrigin); + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution ); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit ); + } + if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit ); + } + + EnableControls(); + SetNumFormat(); } int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) @@ -347,6 +546,8 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) return LEAVE_PAGE; } + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); const SfxPoolItem *pPoolItem = NULL; if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) @@ -356,75 +557,105 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) OSL_ENSURE( false, "Using Standard Language" ); } - Edit* pEdit = NULL; + Control* pControl = NULL; USHORT nErrStrId = 0; double fDummy; fMax = aFmtFldMax.GetValue(); fMin = aFmtFldMin.GetValue(); fOrigin = aFmtFldOrigin.GetValue(); - fStepMain = aFmtFldStepMain.GetValue(); + fStepMain = bDateAxis ? m_aMt_MainDateStep.GetValue() : aFmtFldStepMain.GetValue(); nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue()); + m_nTimeResolution = m_aLB_TimeResolution.GetSelectEntryPos(); + m_nMainTimeUnit = m_aLB_MainTimeUnit.GetSelectEntryPos(); + m_nHelpTimeUnit = m_aLB_HelpTimeUnit.GetSelectEntryPos(); + + if( chart2::AxisType::REALNUMBER != m_nAxisType ) + aCbxLogarithm.Show( false ); + + //check wich entries need user action - //do some reasonable automatic correction of user input if necessary - if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && - fMin >= fMax) - { - pEdit = &aFmtFldMin; - nErrStrId = STR_MIN_GREATER_MAX; - } - // check for entries in invalid ranges if ( aCbxLogarithm.IsChecked() && ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 ) || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) ) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_BAD_LOGARITHM; } - if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) + else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && + fMin >= fMax) + { + pControl = &aFmtFldMin; + nErrStrId = STR_MIN_GREATER_MAX; + } + else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } - - //check wich entries need user action - // check for entries that cannot be parsed for the current number format - if ( aFmtFldMin.IsModified() + else if ( aFmtFldMin.IsModified() && !aCbxAutoMin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_INVALID_NUMBER; } else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMax; + pControl = &aFmtFldMax; nErrStrId = STR_INVALID_NUMBER; } - else if (aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && + else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldOrigin; + pControl = &aFmtFldOrigin; nErrStrId = STR_INVALID_NUMBER; } else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } + else if( bDateAxis ) + { + if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() ) + { + if( m_nHelpTimeUnit > m_nMainTimeUnit ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + } + if( !nErrStrId && !m_aCbx_AutoTimeResolution.IsChecked() ) + { + if( (!aCbxAutoStepMain.IsChecked() && m_nTimeResolution > m_nMainTimeUnit ) + || + (!aCbxAutoStepHelp.IsChecked() && m_nTimeResolution > m_nHelpTimeUnit ) + ) + { + pControl = &m_aLB_TimeResolution; + nErrStrId = STR_INVALID_TIME_UNIT; + } + } + } - if( ShowWarning( nErrStrId, pEdit ) ) + if( ShowWarning( nErrStrId, pControl ) ) return KEEP_PAGE; if( pItemSet ) @@ -486,6 +717,19 @@ void ScaleTabPage::SetNumFormat() else nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME ); } + + if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) ) + { + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE ); + + aFmtFldMax.SetFormatKey( nFmt ); + aFmtFldMin.SetFormatKey( nFmt ); + aFmtFldOrigin.SetFormatKey( nFmt ); + } } aFmtFldStepMain.SetFormatKey( nFmt ); @@ -499,7 +743,7 @@ void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) m_bShowAxisOrigin = true; } -bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ ) +bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Control* pControl /* = NULL */ ) { if( nResIdMessage == 0 ) return false; @@ -508,7 +752,9 @@ bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL if( pControl ) { pControl->GrabFocus(); - pControl->SetSelection( Selection( 0, SELECTION_MAX )); + Edit* pEdit = dynamic_cast<Edit*>(pControl); + if(pEdit) + pEdit->SetSelection( Selection( 0, SELECTION_MAX )); } return true; } diff --git a/chart2/source/controller/dialogs/tp_Scale.hrc b/chart2/source/controller/dialogs/tp_Scale.hrc new file mode 100644 index 000000000000..bde6c21c7924 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.hrc @@ -0,0 +1,63 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_SCALE 1 + +#define TXT_MIN 1 +#define TXT_MAX 2 +#define TXT_STEP_MAIN 3 +#define TXT_STEP_HELP_COUNT 4 +#define TXT_ORIGIN 5 +#define TXT_TIME_RESOLUTION 6 +#define TXT_AXIS_TYPE 7 +#define TXT_STEP_HELP 8 + +#define CBX_AUTO_MIN 1 +#define CBX_AUTO_MAX 2 +#define CBX_AUTO_STEP_MAIN 3 +#define CBX_AUTO_STEP_HELP 4 +#define CBX_AUTO_ORIGIN 5 +#define CBX_LOGARITHM 6 +#define CBX_REVERSE 7 +#define CBX_AUTO_TIME_RESOLUTION 8 + +#define EDT_STEP_MAIN 1 +#define EDT_MAX 2 +#define EDT_MIN 3 +#define EDT_ORIGIN 4 + +#define MT_STEPHELP 10 +#define MT_MAIN_DATE_STEP 11 + +#define LB_AXIS_TYPE 1 +#define LB_MAIN_TIME_UNIT 2 +#define LB_HELP_TIME_UNIT 3 +#define LB_TIME_RESOLUTION 4 + +#define STR_LIST_TIME_UNIT 1 diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 8d0e02186c38..953187d1d9cf 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -37,6 +37,8 @@ #include <vcl/button.hxx> // header for MetricField #include <vcl/field.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> //............................................................................. namespace chart @@ -64,6 +66,13 @@ public: private: FixedLine aFlScale; + CheckBox aCbxReverse; + + CheckBox aCbxLogarithm; + + FixedText m_aTxt_AxisType; + ListBox m_aLB_AxisType; + FixedText aTxtMin; FormattedField aFmtFldMin; CheckBox aCbxAutoMin; @@ -72,34 +81,45 @@ private: FormattedField aFmtFldMax; CheckBox aCbxAutoMax; + FixedText m_aTxt_TimeResolution; + ListBox m_aLB_TimeResolution; + CheckBox m_aCbx_AutoTimeResolution; + FixedText aTxtMain; FormattedField aFmtFldStepMain; + MetricField m_aMt_MainDateStep; + ListBox m_aLB_MainTimeUnit; CheckBox aCbxAutoStepMain; + FixedText aTxtHelpCount; FixedText aTxtHelp; MetricField aMtStepHelp; + ListBox m_aLB_HelpTimeUnit; CheckBox aCbxAutoStepHelp; FixedText aTxtOrigin; FormattedField aFmtFldOrigin; CheckBox aCbxAutoOrigin; - CheckBox aCbxLogarithm; - CheckBox aCbxReverse; - double fMin; double fMax; double fStepMain; sal_Int32 nStepHelp; double fOrigin; - int nAxisType; + sal_Int32 m_nTimeResolution; + sal_Int32 m_nMainTimeUnit; + sal_Int32 m_nHelpTimeUnit; + int m_nAxisType; + bool m_bAllowDateAxis; SvNumberFormatter* pNumFormatter; bool m_bShowAxisOrigin; void AdjustControlPositions(); void EnableControls(); + void PlaceIntervalControlsAccordingToAxisType(); + DECL_LINK( SelectAxisTypeHdl, void* ); DECL_LINK( EnableValueHdl, CheckBox* ); /** shows a warning window due to an invalid input. @@ -115,7 +135,7 @@ private: @return false, if nResIdMessage was 0, true otherwise */ - bool ShowWarning( USHORT nResIdMessage, Edit * pControl = NULL ); + bool ShowWarning( USHORT nResIdMessage, Control* pControl = NULL ); }; //............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Scale.src b/chart2/source/controller/dialogs/tp_Scale.src index 9e92e70f6f43..f5a9221af20d 100644..100755 --- a/chart2/source/controller/dialogs/tp_Scale.src +++ b/chart2/source/controller/dialogs/tp_Scale.src @@ -25,7 +25,7 @@ * ************************************************************************/ #include "HelpIds.hrc" -#include "TabPages.hrc" +#include "tp_Scale.hrc" #define YLine1 3 #define Y1 (YLine1+13) @@ -33,16 +33,26 @@ #define Y3 (Y2+16) #define Y4 (Y3+16) #define Y5 (Y4+16) -#define Y6 (Y5+17) -#define Y7 (Y6+15) +#define Y6 (Y5+16) +#define Y7 (Y6+16) +#define Y8 (Y7+16) #define LABELWIDTH 88 -#define AUTOCHECKWIDTH 88 +#define AUTOCHECKWIDTH 41 #define EDITWIDTH 50 #define X1 6 #define X2 11 #define X3 (X2+LABELWIDTH+4) #define X4 (X3+EDITWIDTH+5) +#define X5 (X4+AUTOCHECKWIDTH+5) + +#define STR_LIST_TIME_UNIT \ + StringList [ en-US ] = \ + { \ + "Days" ; \ + "Months" ; \ + "Years" ; \ + }; TabPage TP_SCALE { @@ -57,86 +67,201 @@ TabPage TP_SCALE Size = MAP_APPFONT ( 248 , 8 ) ; Text [ en-US ] = "Scale" ; }; - FixedText TXT_MIN + //--------------------------- + CheckBox CBX_REVERSE { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; Pos = MAP_APPFONT ( X2 , Y1 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Reverse direction" ; + }; + //--------------------------- + CheckBox CBX_LOGARITHM + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Logarithmic scale" ; + }; + //--------------------------- + FixedText TXT_AXIS_TYPE + { + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "T~ype" ; + }; + ListBox LB_AXIS_TYPE + { + HelpID = "chart2:ListBox:TP_SCALE:LB_AXIS_TYPE"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Automatic" ; + "Text" ; + "Date" ; + }; + }; + //--------------------------- + FixedText TXT_MIN + { + Pos = MAP_APPFONT ( X2 , Y3 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "~Minimum:" ; + Text [ en-US ] = "~Minimum" ; }; SpinField EDT_MIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_MIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y1-2 ) ; + Pos = MAP_APPFONT ( X3 , Y3-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MIN"; - Pos = MAP_APPFONT ( X4 , Y1-1 ) ; + Pos = MAP_APPFONT ( X4 , Y3+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Automatic" ; }; - + //--------------------------- FixedText TXT_MAX { - Pos = MAP_APPFONT ( X2 , Y2 ) ; + Pos = MAP_APPFONT ( X2 , Y4 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~ximum:" ; + Text [ en-US ] = "Ma~ximum" ; }; SpinField EDT_MAX { HelpID = "chart2:SpinField:TP_SCALE:EDT_MAX"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Pos = MAP_APPFONT ( X3 , Y4-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MAX { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MAX"; - Pos = MAP_APPFONT ( X4 , Y2-1 ) ; + Pos = MAP_APPFONT ( X4 , Y4+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "A~utomatic" ; }; + //--------------------------- + FixedText TXT_TIME_RESOLUTION + { + Pos = MAP_APPFONT ( X2 , Y5 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "R~esolution" ; + }; + ListBox LB_TIME_RESOLUTION + { + HelpID = "chart2:ListBox:TP_SCALE:LB_TIME_RESOLUTION"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_TIME_RESOLUTION + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_TIME_RESOLUTION"; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Automat~ic" ; + }; + //--------------------------- FixedText TXT_STEP_MAIN { - Pos = MAP_APPFONT ( X2 , Y3 ) ; + Pos = MAP_APPFONT ( X2 , Y5 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~jor interval:" ; + Text [ en-US ] = "Ma~jor interval" ; }; SpinField EDT_STEP_MAIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_STEP_MAIN"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y3-2 ) ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; + MetricField MT_MAIN_DATE_STEP + { + HelpID = "chart2:MetricField:TP_SCALE:MT_MAIN_DATE_STEP"; + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100000 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100000 ; + SpinSize = 1 ; + }; + + ListBox LB_MAIN_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_MAIN_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_STEP_MAIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_MAIN"; - Pos = MAP_APPFONT ( X4 , Y3-1 ) ; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Au~tomatic" ; }; + //--------------------------- + FixedText TXT_STEP_HELP_COUNT + { + Pos = MAP_APPFONT ( X2 , Y6 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Minor inter~val count" ; + }; FixedText TXT_STEP_HELP { - Pos = MAP_APPFONT ( X2 , Y4 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Minor interval ~count:" ; + Text [ en-US ] = "Minor inter~val" ; }; MetricField MT_STEPHELP { HelpID = "chart2:MetricField:TP_SCALE:MT_STEPHELP"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y4-2 ) ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; Repeat = TRUE ; @@ -149,55 +274,51 @@ TabPage TP_SCALE Last = 100 ; SpinSize = 1 ; }; + ListBox LB_HELP_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_HELP_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y7-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; CheckBox CBX_AUTO_STEP_HELP { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_HELP"; - Pos = MAP_APPFONT ( X4 , Y4-1 ) ; + Pos = MAP_APPFONT ( X4 , Y6+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Aut~omatic" ; }; - + //--------------------------- FixedText TXT_ORIGIN { - Pos = MAP_APPFONT ( X2 , Y5 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Reference ~value:" ; + Text [ en-US ] = "Re~ference value" ; }; SpinField EDT_ORIGIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_ORIGIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Pos = MAP_APPFONT ( X3 , Y7-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_ORIGIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_ORIGIN"; - Pos = MAP_APPFONT ( X4 , Y5-1 ) ; + Pos = MAP_APPFONT ( X4 , Y7+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Automat~ic" ; }; - - CheckBox CBX_LOGARITHM - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; - Pos = MAP_APPFONT ( X2 , Y6 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Logarithmic scale" ; - }; - - CheckBox CBX_REVERSE - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; - Pos = MAP_APPFONT ( X2 , Y7 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Reverse direction" ; - }; - + //--------------------------- }; diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 7c8f83452963..647f82a9eb6a 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -27,8 +27,7 @@ #ifndef CHART_AXISITEMCONVERTER_HXX #define CHART_AXISITEMCONVERTER_HXX -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <chartview/ExplicitScaleValues.hxx> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/awt/Size.hpp> @@ -55,8 +54,8 @@ public: SdrModel& rDrawModel, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, - ::com::sun::star::chart2::ExplicitScaleData * pScale = NULL, - ::com::sun::star::chart2::ExplicitIncrementData * pIncrement = NULL, + ExplicitScaleData * pScale = NULL, + ExplicitIncrementData * pIncrement = NULL, ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = ::std::auto_ptr< ::com::sun::star::awt::Size >() ); virtual ~AxisItemConverter(); @@ -81,8 +80,8 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; - ::com::sun::star::chart2::ExplicitScaleData * m_pExplicitScale; - ::com::sun::star::chart2::ExplicitIncrementData * m_pExplicitIncrement; + ExplicitScaleData* m_pExplicitScale; + ExplicitIncrementData* m_pExplicitIncrement; }; } // namespace wrapper diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index 5e20b7980c8b..aa9ef0332b76 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -52,6 +52,7 @@ #define HID_SCH_TBI_DATA_SWAP_COL "CHART2_HID_SCH_TBI_DATA_SWAP_COL" #define HID_SCH_TBI_DATA_SWAP_ROW "CHART2_HID_SCH_TBI_DATA_SWAP_ROW" #define HID_SCH_TBI_DATA_INSERT_TEXT_COL "CHART2_HID_SCH_TBI_DATA_INSERT_TEXT_COL" +#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGOGRIES" #define HID_SCH_TBX_DATA "CHART2_HID_SCH_TBX_DATA" #define HID_SCH_ALIGNMENT_CTR_DIAL "CHART2_HID_SCH_ALIGNMENT_CTR_DIAL" diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 8cf07aabad08..b1f861461817 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -38,12 +38,14 @@ #include "ChartModelHelper.hxx" #include "AxisHelper.hxx" #include "CommonConverters.hxx" +#include "ChartTypeHelper.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/chart2/XAxis.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart2/AxisType.hpp> // for SfxBoolItem #include <svl/eitem.hxx> @@ -58,6 +60,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; +using ::com::sun::star::chart::TimeInterval; +using ::com::sun::star::chart::TimeIncrement; namespace { @@ -65,13 +69,13 @@ namespace { static ::comphelper::ItemPropertyMapType aAxisPropertyMap( ::comphelper::MakeItemPropertyMap - IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_ORDER, "ArrangeOrder", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXTBREAK, "TextBreak", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_OVERLAP, "TextOverlap", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_ORDER, "ArrangeOrder", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_BREAK, "TextBreak", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_OVERLAP, "TextOverlap", 0 ) ); return aAxisPropertyMap; @@ -88,8 +92,8 @@ AxisItemConverter::AxisItemConverter( SfxItemPool& rItemPool, SdrModel& rDrawModel, const Reference< chart2::XChartDocument > & xChartDoc, - chart2::ExplicitScaleData * pScale /* = NULL */, - chart2::ExplicitIncrementData * pIncrement /* = NULL */, + ::chart::ExplicitScaleData * pScale /* = NULL */, + ::chart::ExplicitIncrementData * pIncrement /* = NULL */, ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) : ItemConverter( rPropertySet, rItemPool ), m_xChartDoc( xChartDoc ), @@ -99,9 +103,9 @@ AxisItemConverter::AxisItemConverter( Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY ); if( pScale ) - m_pExplicitScale = new chart2::ExplicitScaleData( *pScale ); + m_pExplicitScale = new ::chart::ExplicitScaleData( *pScale ); if( pIncrement ) - m_pExplicitIncrement = new chart2::ExplicitIncrementData( *pIncrement ); + m_pExplicitIncrement = new ::chart::ExplicitIncrementData( *pIncrement ); m_aConverters.push_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, @@ -162,30 +166,40 @@ bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWit return true; } +bool lcl_hasTimeIntervalValue( const uno::Any& rAny ) +{ + bool bRet = false; + TimeInterval aValue; + if( rAny >>= aValue ) + bRet = true; + return bRet; +} + void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { - if( ! m_xAxis.is() ) + if( !m_xAxis.is() ) return; - const chart2::ScaleData aScale( m_xAxis->getScaleData() ); - const chart2::IncrementData aInc( aScale.IncrementData ); - const uno::Sequence< chart2::SubIncrement > aSubIncs( aScale.IncrementData.SubIncrements ); + const chart2::ScaleData& rScale( m_xAxis->getScaleData() ); + const chart2::IncrementData& rIncrement( rScale.IncrementData ); + const uno::Sequence< chart2::SubIncrement >& rSubIncrements( rScale.IncrementData.SubIncrements ); + const TimeIncrement& rTimeIncrement( rScale.TimeIncrement ); + bool bDateAxis = (chart2::AxisType::DATE == rScale.AxisType); + if( m_pExplicitScale ) + bDateAxis = (chart2::AxisType::DATE == m_pExplicitScale->AxisType); switch( nWhichId ) { case SCHATTR_AXIS_AUTO_MAX: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Maximum) ) ); break; case SCHATTR_AXIS_MAX: { double fMax = 10.0; - if( aScale.Maximum >>= fMax ) - { + if( rScale.Maximum >>= fMax ) rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); - } else { if( m_pExplicitScale ) @@ -196,106 +210,141 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXIS_AUTO_MIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Minimum) ) ); break; case SCHATTR_AXIS_MIN: { double fMin = 0.0; - if( aScale.Minimum >>= fMin ) - { + if( rScale.Minimum >>= fMin ) rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) ); - } - else - { - if( m_pExplicitScale ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); - } + else if( m_pExplicitScale ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); } break; case SCHATTR_AXIS_LOGARITHM: - { - BOOL bValue = AxisHelper::isLogarithmic( aScale.Scaling ); - rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); - } - break; + { + BOOL bValue = AxisHelper::isLogarithmic( rScale.Scaling ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + break; case SCHATTR_AXIS_REVERSE: - rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == aScale.Orientation) )); + rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == rScale.Orientation) )); break; // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aInc.Distance) ) ); + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) ); + break; + + case SCHATTR_AXIS_MAIN_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) ); + } break; case SCHATTR_AXIS_STEP_MAIN: + if( bDateAxis ) + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, nWhichId )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId )); + } + else { double fDistance = 1.0; - if( aInc.Distance >>= fDistance ) - { + if( rIncrement.Distance >>= fDistance ) rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId )); - } - else - { - if( m_pExplicitIncrement ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); - } + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); } break; // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - { - // if the any has no value => auto is on - rOutItemSet.Put( - SfxBoolItem( - nWhichId, - ! ( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue() ))); - } - break; + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, + ! ( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue() ))); + break; + + case SCHATTR_AXIS_HELP_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) ); + } + break; case SCHATTR_AXIS_STEP_HELP: - { - if( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue()) + if( bDateAxis ) { - OSL_ASSERT( aSubIncs[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - *reinterpret_cast< const sal_Int32 * >( - aSubIncs[0].IntervalCount.getValue()) )); + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number )); } else { - if( m_pExplicitIncrement && - m_pExplicitIncrement->SubIncrements.getLength() > 0 ) + if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue()) + { + OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); + rOutItemSet.Put( SfxInt32Item( nWhichId, + *reinterpret_cast< const sal_Int32 * >( + rSubIncrements[0].IntervalCount.getValue()) )); + } + else { - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, + m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + } } } - } - break; + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + { + rOutItemSet.Put( SfxBoolItem( nWhichId, + !rTimeIncrement.TimeResolution.hasValue() )); + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + { + long nTimeResolution=0; + if( rTimeIncrement.TimeResolution >>= nTimeResolution ) + rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); + else if( m_pExplicitScale ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) ); + } + break; case SCHATTR_AXIS_AUTO_ORIGIN: { - // if the any has no double value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); + rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(rScale.Origin) ))); } break; case SCHATTR_AXIS_ORIGIN: { double fOrigin = 0.0; - if( !(aScale.Origin >>= fOrigin) ) + if( !(rScale.Origin >>= fOrigin) ) { if( m_pExplicitScale ) fOrigin = m_pExplicitScale->Origin; @@ -367,7 +416,6 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -391,11 +439,44 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXISTYPE: - rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); + rOutItemSet.Put( SfxInt32Item( nWhichId, rScale.AxisType )); + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + rOutItemSet.Put( SfxBoolItem( nWhichId, rScale.AutoDateAxis )); + break; + + case SCHATTR_AXIS_ALLOW_DATEAXIS: + { + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; + AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); + } break; } } +bool lcl_isDateAxis( const SfxItemSet & rItemSet ) +{ + sal_Int32 nAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_AXISTYPE )).GetValue();//::com::sun::star::chart2::AxisType + return (chart2::AxisType::DATE == nAxisType); +} + +bool lcl_isAutoMajor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue(); + return bRet; +} + +bool lcl_isAutoMinor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue(); + return bRet; +} + bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { @@ -502,23 +583,47 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() )) + if( lcl_isAutoMajor(rItemSet) ) { aScale.IncrementData.Distance.clear(); + aScale.TimeIncrement.MajorTimeInterval.clear(); bSetScale = true; } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_MAIN_TIME_UNIT: + if( !lcl_isAutoMajor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_MAIN: // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue() )) + if( !lcl_isAutoMajor(rItemSet) ) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - - if( aScale.IncrementData.Distance != aValue ) + if( lcl_isDateAxis(rItemSet) ) + { + double fValue = 1.0; + if( aValue >>= fValue ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aTimeInterval.Number = static_cast<double>(fValue); + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + else if( aScale.IncrementData.Distance != aValue ) { aScale.IncrementData.Distance = aValue; bSetScale = true; @@ -528,35 +633,85 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 && - aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + if( lcl_isAutoMinor(rItemSet) ) { - aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + if( aScale.IncrementData.SubIncrements.getLength() > 0 && + aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + { + aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + bSetScale = true; + } + if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) + { + aScale.TimeIncrement.MinorTimeInterval.clear(); bSetScale = true; + } } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_HELP_TIME_UNIT: + if( !lcl_isAutoMinor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_HELP: - // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 ) + // only if auto is false + if( !lcl_isAutoMinor(rItemSet) ) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + if( lcl_isDateAxis(rItemSet) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.Number; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny(aTimeInterval); + bSetScale = true; + } + else if( aScale.IncrementData.SubIncrements.getLength() > 0 ) + { + if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || + aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + { + OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); + aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + bSetScale = true; + } + } + } + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + if( (static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.TimeIncrement.TimeResolution.clear(); + bSetScale = true; + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + // only if auto is false + if( ! (static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION )).GetValue() )) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || - aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + if( aScale.TimeIncrement.TimeResolution != aValue ) { - OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); - aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + aScale.TimeIncrement.TimeResolution = aValue; bSetScale = true; } } break; + case SCHATTR_AXIS_AUTO_ORIGIN: { if( (static_cast< const SfxBoolItem & >( @@ -757,7 +912,6 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -821,7 +975,23 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SCHATTR_AXISTYPE: - //don't allow to change the axis type so far + { + sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//::com::sun::star::chart2::AxisType + aScale.AxisType = nNewAxisType; + bSetScale = true; + } + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + { + bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + bool bOldValue = aScale.AutoDateAxis; + if( bOldValue != bNewValue ) + { + aScale.AutoDateAxis = bNewValue; + bSetScale = true; + } + } break; } diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index f7ddeb42c11e..139283b92e23 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -45,8 +45,7 @@ namespace const USHORT nTitleWhichPairs[] = { - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx @@ -60,24 +59,17 @@ const USHORT nAxisWhichPairs[] = CHARACTER_WHICHPAIRS, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432 svx/svxids.hrc - SCHATTR_AXISTYPE, SCHATTR_AXISTYPE, // 39 sch/schattr.hxx - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_START, SCHATTR_AXIS_END, // 70 - 95 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_START, SCHATTR_AXIS_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nAllAxisWhichPairs[] = { - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_LINE_FIRST, XATTR_LINE_LAST, CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, // 85 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; @@ -102,8 +94,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, 0 @@ -117,8 +107,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ \ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, \ SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \ SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \ @@ -165,16 +153,14 @@ const USHORT nAreaWhichPairs[] = const USHORT nTextWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nTextOrientWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx index 57e8e7315334..e45329465d45 100644 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ b/chart2/source/controller/main/ImplUndoManager.cxx @@ -36,7 +36,7 @@ #include "DataSourceHelper.hxx" #include "ChartModelHelper.hxx" -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> #include <com/sun/star/chart2/XTitled.hpp> @@ -52,7 +52,7 @@ using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; -using ::com::sun::star::chart::XComplexDescriptionAccess; +using ::com::sun::star::chart2::XAnyDescriptionAccess; namespace chart { @@ -69,13 +69,13 @@ void ImplApplyDataToModel( // copy data from stored internal data provider if( xDoc.is() && xDoc->hasInternalDataProvider()) { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); + Reference< XAnyDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); + Reference< XAnyDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); if( xCurrentData.is() && xSavedData.is()) { xCurrentData->setData( xSavedData->getData()); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); + xCurrentData->setAnyRowDescriptions( xSavedData->getAnyRowDescriptions()); + xCurrentData->setAnyColumnDescriptions( xSavedData->getAnyColumnDescriptions()); } } } diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index 75e69436a784..eaaee11abe10 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -29,6 +29,7 @@ #include "charttoolsdllapi.hxx" #include "ReferenceSizeProvider.hxx" +#include "ExplicitCategoriesProvider.hxx" #include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/chart2/XCoordinateSystem.hpp> #include <com/sun/star/chart2/XDiagram.hpp> @@ -58,6 +59,9 @@ public: static bool isLogarithmic( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScaling ); + static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ); + static ::com::sun::star::chart2::ScaleData getDateCheckedScale( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > createAxis( sal_Int32 nDimensionIndex, bool bMainAxis diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index 729cfc86bc52..67df6027d2d7 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -61,8 +61,9 @@ public: static bool isSupportingStartingAngle( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); //starting value for bars or baseline for areas for example static bool isSupportingBaseValue( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); - static bool shiftTicksAtXAxisPerDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); + static bool shiftCategoryPosAtXAxisPerDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); static bool isSupportingAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); + static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); //returns sequence of ::com::sun::star::chart::DataLabelPlacement static ::com::sun::star::uno::Sequence < sal_Int32 > getSupportedLabelPlacements( diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index c7cda6189680..858454497db5 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -240,6 +240,22 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCooSys ); + static bool mayToggleDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void toggleDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void switchToDateCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + + static void switchToTextCategories( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > getChartTypeByIndex( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx index 18d54eb6e2ad..dfa6379a42a1 100644 --- a/chart2/source/inc/ExplicitCategoriesProvider.hxx +++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx @@ -58,6 +58,24 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0; }; +struct DatePlusIndex +{ + DatePlusIndex() + : fValue(1.0) + , nIndex( -1 ) + { + } + + DatePlusIndex( const double& _fValue, sal_Int32 _nIndex ) + : fValue(_fValue) + , nIndex( _nIndex ) + { + } + + double fValue; + sal_Int32 nIndex; +}; + class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider { public: @@ -70,6 +88,9 @@ public: void init(); + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence > getOriginalCategories(); + ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories(); ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel ); @@ -89,17 +110,26 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList(); + bool isDateAxis(); + const std::vector< DatePlusIndex >& getDateCategories(); + private: //member - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; - ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; bool volatile m_bDirty; - ::com::sun::star::uno::WeakReference< - ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; + ::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XModel > m_xChartModel; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories; + + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; + ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList; + + bool m_bIsDateAxis; + bool m_bIsAutoDate; + std::vector< DatePlusIndex > m_aDateCategories; }; } // namespace chart diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx index 6b6590cffdac..48a8ee86f6ab 100755 --- a/chart2/source/inc/InternalData.hxx +++ b/chart2/source/inc/InternalData.hxx @@ -53,11 +53,11 @@ public: void setColumnValues( sal_Int32 nColumnIndex, const ::std::vector< double > & rNewData ); void setRowValues( sal_Int32 nRowIndex, const ::std::vector< double > & rNewData ); - void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel ); - void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel ); + void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel ); + void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::com::sun::star::uno::Any >& rComplexLabel ); - ::std::vector< ::rtl::OUString > getComplexColumnLabel( sal_Int32 nColumnIndex ) const; - ::std::vector< ::rtl::OUString > getComplexRowLabel( sal_Int32 nRowIndex ) const; + ::std::vector< ::com::sun::star::uno::Any > getComplexColumnLabel( sal_Int32 nColumnIndex ) const; + ::std::vector< ::com::sun::star::uno::Any > getComplexRowLabel( sal_Int32 nRowIndex ) const; void swapRowWithNext( sal_Int32 nRowIndex ); void swapColumnWithNext( sal_Int32 nColumnIndex ); @@ -76,12 +76,12 @@ public: sal_Int32 getColumnCount() const; typedef ::std::valarray< double > tDataType; - typedef ::std::vector< ::std::vector< ::rtl::OUString > > tVecVecString; //inner index is hierarchical level + typedef ::std::vector< ::std::vector< ::com::sun::star::uno::Any > > tVecVecAny; //inner index is hierarchical level - void setComplexRowLabels( const tVecVecString& rNewRowLabels ); - tVecVecString getComplexRowLabels() const; - void setComplexColumnLabels( const tVecVecString& rNewColumnLabels ); - tVecVecString getComplexColumnLabels() const; + void setComplexRowLabels( const tVecVecAny& rNewRowLabels ); + tVecVecAny getComplexRowLabels() const; + void setComplexColumnLabels( const tVecVecAny& rNewColumnLabels ); + tVecVecAny getComplexColumnLabels() const; #if OSL_DEBUG_LEVEL > 2 void traceData() const; @@ -99,9 +99,9 @@ private: sal_Int32 m_nColumnCount; sal_Int32 m_nRowCount; - tDataType m_aData; - tVecVecString m_aRowLabels;//outer index is row index, inner index is category level - tVecVecString m_aColumnLabels;//outer index is column index + tDataType m_aData; + tVecVecAny m_aRowLabels;//outer index is row index, inner index is category level + tVecVecAny m_aColumnLabels;//outer index is column index }; #endif diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx index f5e12f87f505..e467a9746df4 100644 --- a/chart2/source/inc/InternalDataProvider.hxx +++ b/chart2/source/inc/InternalDataProvider.hxx @@ -30,7 +30,8 @@ #include "InternalData.hxx" #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> +#include <com/sun/star/chart/XDateCategories.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> @@ -38,7 +39,7 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/util/XCloneable.hpp> -#include <cppuhelper/implbase6.hxx> +#include <cppuhelper/implbase7.hxx> #include "ServiceMacros.hxx" #include "CachedDataSequence.hxx" @@ -52,10 +53,11 @@ namespace chart namespace impl { -typedef ::cppu::WeakImplHelper6< +typedef ::cppu::WeakImplHelper7< ::com::sun::star::chart2::XInternalDataProvider, ::com::sun::star::chart2::data::XRangeXMLConversion, - ::com::sun::star::chart::XComplexDescriptionAccess, + ::com::sun::star::chart2::XAnyDescriptionAccess, + ::com::sun::star::chart::XDateCategories, ::com::sun::star::util::XCloneable, ::com::sun::star::lang::XInitialization, ::com::sun::star::lang::XServiceInfo > @@ -149,7 +151,25 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - // ____ XComplexDescriptionAccess ____ + // ____ XDateCategories ____ + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XAnyDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyRowDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyColumnDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setComplexRowDescriptions( diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index 47ed75e80a9a..d263881a0905 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -30,8 +30,7 @@ // this includes no link dependency #include <svl/solar.hrc> -//next free is 291 -//single free is: 134 +//next free is 294 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -165,6 +164,8 @@ #define STR_STEP_GT_ZERO (RID_APP_START + 102) #define STR_BAD_LOGARITHM (RID_APP_START + 111) #define STR_MIN_GREATER_MAX (RID_APP_START + 101) +#define STR_INVALID_INTERVALS (RID_APP_START + 291) +#define STR_INVALID_TIME_UNIT (RID_APP_START + 292) //----------------------------------------------------------------------------- //for range didalog @@ -193,6 +194,8 @@ #define STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS (RID_APP_START + 21) #define STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS (RID_APP_START + 267) +#define STR_DATA_DATE_CATEGORIES (RID_APP_START + 293) + //----------------------------------------------------------------------------- //chart objects //e.g. used as titles for insert dialogs and object properties dialog diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index fbcce70bd1d6..b6390ab12b22 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -27,13 +27,6 @@ #ifndef CHARTSFXITEMIDS_HXX #define CHARTSFXITEMIDS_HXX -#include <sfx2/sfxdefs.hxx> - -/* -// header for SID_OBJ1_START -#include <sfx2/sfxsids.hrc> -*/ - // ============================================================ // SCHATTR // ============================================================ @@ -49,68 +42,23 @@ #define SCHATTR_DATADESCR_PLACEMENT (SCHATTR_DATADESCR_START + 5) #define SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS (SCHATTR_DATADESCR_START + 6) #define SCHATTR_DATADESCR_NO_PERCENTVALUE (SCHATTR_DATADESCR_START + 7) //percentage values should not be offered -#define SCHATTR_DATADESCR_END SCHATTR_DATADESCR_NO_PERCENTVALUE +#define SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_DATADESCR_START + 8) +#define SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_DATADESCR_START + 9) +#define SCHATTR_DATADESCR_END SCHATTR_PERCENT_NUMBERFORMAT_SOURCE +//legend #define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1) #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START #define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS +//text #define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) -// #define SCHATTR_TEXT_ORIENT SCHATTR_TEXT_START -// name changed: -#define SCHATTR_TEXT_STACKED SCHATTR_TEXT_START -#define SCHATTR_TEXT_ORDER (SCHATTR_TEXT_START + 1) -#define SCHATTR_TEXT_END SCHATTR_TEXT_ORDER - -#define SCHATTR_Y_AXIS_START (SCHATTR_TEXT_END + 1) -#define SCHATTR_Y_AXIS_AUTO_MIN SCHATTR_Y_AXIS_START -#define SCHATTR_Y_AXIS_MIN (SCHATTR_Y_AXIS_START + 1) -#define SCHATTR_Y_AXIS_AUTO_MAX (SCHATTR_Y_AXIS_START + 2) -#define SCHATTR_Y_AXIS_MAX (SCHATTR_Y_AXIS_START + 3) -#define SCHATTR_Y_AXIS_AUTO_STEP_MAIN (SCHATTR_Y_AXIS_START + 4) -#define SCHATTR_Y_AXIS_STEP_MAIN (SCHATTR_Y_AXIS_START + 5) -#define SCHATTR_Y_AXIS_AUTO_STEP_HELP (SCHATTR_Y_AXIS_START + 6) -#define SCHATTR_Y_AXIS_STEP_HELP (SCHATTR_Y_AXIS_START + 7) -#define SCHATTR_Y_AXIS_LOGARITHM (SCHATTR_Y_AXIS_START + 8) -#define SCHATTR_Y_AXIS_AUTO_ORIGIN (SCHATTR_Y_AXIS_START + 9) -#define SCHATTR_Y_AXIS_ORIGIN (SCHATTR_Y_AXIS_START + 10) -#define SCHATTR_Y_AXIS_END SCHATTR_Y_AXIS_ORIGIN - -#define SCHATTR_X_AXIS_START (SCHATTR_Y_AXIS_END + 1) -#define SCHATTR_X_AXIS_AUTO_MIN SCHATTR_X_AXIS_START -#define SCHATTR_X_AXIS_MIN (SCHATTR_X_AXIS_START + 1) -#define SCHATTR_X_AXIS_AUTO_MAX (SCHATTR_X_AXIS_START + 2) -#define SCHATTR_X_AXIS_MAX (SCHATTR_X_AXIS_START + 3) -#define SCHATTR_X_AXIS_AUTO_STEP_MAIN (SCHATTR_X_AXIS_START + 4) -#define SCHATTR_X_AXIS_STEP_MAIN (SCHATTR_X_AXIS_START + 5) -#define SCHATTR_X_AXIS_AUTO_STEP_HELP (SCHATTR_X_AXIS_START + 6) -#define SCHATTR_X_AXIS_STEP_HELP (SCHATTR_X_AXIS_START + 7) -#define SCHATTR_X_AXIS_LOGARITHM (SCHATTR_X_AXIS_START + 8) -#define SCHATTR_X_AXIS_AUTO_ORIGIN (SCHATTR_X_AXIS_START + 9) -#define SCHATTR_X_AXIS_ORIGIN (SCHATTR_X_AXIS_START + 10) -#define SCHATTR_X_AXIS_END SCHATTR_X_AXIS_ORIGIN +#define SCHATTR_TEXT_DEGREES SCHATTR_TEXT_START +#define SCHATTR_TEXT_STACKED (SCHATTR_TEXT_START + 1) +#define SCHATTR_TEXT_END SCHATTR_TEXT_STACKED -#define SCHATTR_Z_AXIS_START (SCHATTR_X_AXIS_END + 1) -#define SCHATTR_Z_AXIS_AUTO_MIN SCHATTR_Z_AXIS_START -#define SCHATTR_Z_AXIS_MIN (SCHATTR_Z_AXIS_START + 1) -#define SCHATTR_Z_AXIS_AUTO_MAX (SCHATTR_Z_AXIS_START + 2) -#define SCHATTR_Z_AXIS_MAX (SCHATTR_Z_AXIS_START + 3) -#define SCHATTR_Z_AXIS_AUTO_STEP_MAIN (SCHATTR_Z_AXIS_START + 4) -#define SCHATTR_Z_AXIS_STEP_MAIN (SCHATTR_Z_AXIS_START + 5) -#define SCHATTR_Z_AXIS_AUTO_STEP_HELP (SCHATTR_Z_AXIS_START + 6) -#define SCHATTR_Z_AXIS_STEP_HELP (SCHATTR_Z_AXIS_START + 7) -#define SCHATTR_Z_AXIS_LOGARITHM (SCHATTR_Z_AXIS_START + 8) -#define SCHATTR_Z_AXIS_AUTO_ORIGIN (SCHATTR_Z_AXIS_START + 9) -#define SCHATTR_Z_AXIS_ORIGIN (SCHATTR_Z_AXIS_START + 10) -#define SCHATTR_Z_AXIS_END SCHATTR_Z_AXIS_ORIGIN - -// miscellaneous - -#define SCHATTR_AXISTYPE (SCHATTR_Z_AXIS_END + 1) -#define SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_Z_AXIS_END + 2) -#define SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_Z_AXIS_END + 3) - -#define SCHATTR_STAT_START (SCHATTR_PERCENT_NUMBERFORMAT_SOURCE + 1) +// statistic +#define SCHATTR_STAT_START (SCHATTR_TEXT_END + 1) #define SCHATTR_STAT_AVERAGE SCHATTR_STAT_START #define SCHATTR_STAT_KIND_ERROR (SCHATTR_STAT_START + 1) #define SCHATTR_STAT_PERCENT (SCHATTR_STAT_START + 2) @@ -122,16 +70,11 @@ #define SCHATTR_STAT_RANGE_NEG (SCHATTR_STAT_START + 8) #define SCHATTR_STAT_END SCHATTR_STAT_RANGE_NEG -#define SCHATTR_TEXT2_START ( SCHATTR_STAT_END + 1) -#define SCHATTR_TEXT_DEGREES ( SCHATTR_TEXT2_START ) -#define SCHATTR_TEXT_OVERLAP (SCHATTR_TEXT2_START +1) -#define SCHATTR_TEXT2_END ( SCHATTR_TEXT_OVERLAP ) - // -------------------------------------------------------- // these attributes are for replacement of enum eChartStyle // -------------------------------------------------------- -#define SCHATTR_STYLE_START ( SCHATTR_TEXT2_END +1 ) +#define SCHATTR_STYLE_START ( SCHATTR_STAT_END +1 ) // for whole chart #define SCHATTR_STYLE_DEEP ( SCHATTR_STYLE_START ) @@ -155,35 +98,44 @@ #define SCHATTR_AXIS (SCHATTR_STYLE_END + 1)// see chtmodel.hxx defines CHART_AXIS_PRIMARY_X, etc. //Ummappen: #define SCHATTR_AXIS_START (SCHATTR_AXIS + 1) -#define SCHATTR_AXIS_AUTO_MIN SCHATTR_AXIS_START -#define SCHATTR_AXIS_MIN (SCHATTR_AXIS_START + 1) -#define SCHATTR_AXIS_AUTO_MAX (SCHATTR_AXIS_START + 2) -#define SCHATTR_AXIS_MAX (SCHATTR_AXIS_START + 3) -#define SCHATTR_AXIS_AUTO_STEP_MAIN (SCHATTR_AXIS_START + 4) -#define SCHATTR_AXIS_STEP_MAIN (SCHATTR_AXIS_START + 5) -#define SCHATTR_AXIS_AUTO_STEP_HELP (SCHATTR_AXIS_START + 6) -// SCHATTR_AXIS_STEP_HELP: type changed from double to sal_Int32 ! -#define SCHATTR_AXIS_STEP_HELP (SCHATTR_AXIS_START + 7) -#define SCHATTR_AXIS_LOGARITHM (SCHATTR_AXIS_START + 8) -#define SCHATTR_AXIS_AUTO_ORIGIN (SCHATTR_AXIS_START + 9) -#define SCHATTR_AXIS_ORIGIN (SCHATTR_AXIS_START + 10) -//Neu: -#define SCHATTR_AXIS_TICKS (SCHATTR_AXIS_START + 11) -#define SCHATTR_AXIS_NUMFMT (SCHATTR_AXIS_START + 12) -#define SCHATTR_AXIS_NUMFMTPERCENT (SCHATTR_AXIS_START + 13) -#define SCHATTR_AXIS_SHOWAXIS (SCHATTR_AXIS_START + 14) -#define SCHATTR_AXIS_SHOWDESCR (SCHATTR_AXIS_START + 15) -#define SCHATTR_AXIS_SHOWMAINGRID (SCHATTR_AXIS_START + 16) -#define SCHATTR_AXIS_SHOWHELPGRID (SCHATTR_AXIS_START + 17) -#define SCHATTR_AXIS_TOPDOWN (SCHATTR_AXIS_START + 18) -#define SCHATTR_AXIS_HELPTICKS (SCHATTR_AXIS_START + 19) -#define SCHATTR_AXIS_REVERSE (SCHATTR_AXIS_START + 20) -#define SCHATTR_AXIS_POSITION (SCHATTR_AXIS_START + 21) -#define SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_START + 22) -#define SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_START + 23) -#define SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_START + 24) -#define SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_START + 25) -#define SCHATTR_AXIS_END SCHATTR_AXIS_MARK_POSITION +//axis scale +#define SCHATTR_AXISTYPE SCHATTR_AXIS_START +#define SCHATTR_AXIS_REVERSE (SCHATTR_AXIS_START + 1) +#define SCHATTR_AXIS_AUTO_MIN (SCHATTR_AXIS_START + 2) +#define SCHATTR_AXIS_MIN (SCHATTR_AXIS_START + 3) +#define SCHATTR_AXIS_AUTO_MAX (SCHATTR_AXIS_START + 4) +#define SCHATTR_AXIS_MAX (SCHATTR_AXIS_START + 5) +#define SCHATTR_AXIS_AUTO_STEP_MAIN (SCHATTR_AXIS_START + 6) +#define SCHATTR_AXIS_STEP_MAIN (SCHATTR_AXIS_START + 7) +#define SCHATTR_AXIS_MAIN_TIME_UNIT (SCHATTR_AXIS_START + 8) +#define SCHATTR_AXIS_AUTO_STEP_HELP (SCHATTR_AXIS_START + 9) +#define SCHATTR_AXIS_STEP_HELP (SCHATTR_AXIS_START + 10) +#define SCHATTR_AXIS_HELP_TIME_UNIT (SCHATTR_AXIS_START + 11) +#define SCHATTR_AXIS_AUTO_TIME_RESOLUTION (SCHATTR_AXIS_START + 12) +#define SCHATTR_AXIS_TIME_RESOLUTION (SCHATTR_AXIS_START + 13) +#define SCHATTR_AXIS_LOGARITHM (SCHATTR_AXIS_START + 14) +#define SCHATTR_AXIS_AUTO_DATEAXIS (SCHATTR_AXIS_START + 15) +#define SCHATTR_AXIS_ALLOW_DATEAXIS (SCHATTR_AXIS_START + 16) +#define SCHATTR_AXIS_AUTO_ORIGIN (SCHATTR_AXIS_START + 17) +#define SCHATTR_AXIS_ORIGIN (SCHATTR_AXIS_START + 18) +//axis position +#define SCHATTR_AXIS_POSITION_START (SCHATTR_AXIS_ORIGIN +1) +#define SCHATTR_AXIS_TICKS SCHATTR_AXIS_POSITION_START +#define SCHATTR_AXIS_HELPTICKS (SCHATTR_AXIS_POSITION_START + 1) +#define SCHATTR_AXIS_POSITION (SCHATTR_AXIS_POSITION_START + 2) +#define SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_POSITION_START + 3) +#define SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_POSITION_START + 4) +#define SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_POSITION_START + 5) +#define SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_POSITION_START + 6) +//axis label +#define SCHATTR_AXIS_LABEL_START (SCHATTR_AXIS_MARK_POSITION +1) +#define SCHATTR_AXIS_SHOWDESCR SCHATTR_AXIS_LABEL_START +#define SCHATTR_AXIS_LABEL_ORDER (SCHATTR_AXIS_LABEL_START + 1) +#define SCHATTR_AXIS_LABEL_OVERLAP (SCHATTR_AXIS_LABEL_START + 2) +#define SCHATTR_AXIS_LABEL_BREAK (SCHATTR_AXIS_LABEL_START + 3) +#define SCHATTR_AXIS_LABEL_END SCHATTR_AXIS_LABEL_BREAK + +#define SCHATTR_AXIS_END SCHATTR_AXIS_LABEL_END #define SCHATTR_SYMBOL_BRUSH (SCHATTR_AXIS_END + 1) #define SCHATTR_STOCK_VOLUME (SCHATTR_AXIS_END + 2) @@ -201,13 +153,12 @@ #define SCHATTR_SPLINE_ORDER (SCHATTR_CHARTTYPE_START + 4) #define SCHATTR_SPLINE_RESOLUTION (SCHATTR_CHARTTYPE_START + 5) #define SCHATTR_DIAGRAM_STYLE (SCHATTR_CHARTTYPE_START + 6) -#define SCHATTR_TEXTBREAK (SCHATTR_CHARTTYPE_START + 7) -#define SCHATTR_GROUP_BARS_PER_AXIS (SCHATTR_CHARTTYPE_START + 8) -#define SCHATTR_STARTING_ANGLE (SCHATTR_CHARTTYPE_START + 9) -#define SCHATTR_CLOCKWISE (SCHATTR_CHARTTYPE_START + 10) -#define SCHATTR_MISSING_VALUE_TREATMENT (SCHATTR_CHARTTYPE_START + 11) -#define SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS (SCHATTR_CHARTTYPE_START + 12) -#define SCHATTR_INCLUDE_HIDDEN_CELLS (SCHATTR_CHARTTYPE_START + 13) +#define SCHATTR_GROUP_BARS_PER_AXIS (SCHATTR_CHARTTYPE_START + 7) +#define SCHATTR_STARTING_ANGLE (SCHATTR_CHARTTYPE_START + 8) +#define SCHATTR_CLOCKWISE (SCHATTR_CHARTTYPE_START + 9) +#define SCHATTR_MISSING_VALUE_TREATMENT (SCHATTR_CHARTTYPE_START + 10) +#define SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS (SCHATTR_CHARTTYPE_START + 11) +#define SCHATTR_INCLUDE_HIDDEN_CELLS (SCHATTR_CHARTTYPE_START + 12) #define SCHATTR_CHARTTYPE_END SCHATTR_INCLUDE_HIDDEN_CELLS @@ -236,9 +187,11 @@ #define CHAXIS_MARK_NONE 0 // values for SCHATTR_AXISTYPE items -#define CHART_AXIS_X 0 -#define CHART_AXIS_Y 1 -#define CHART_AXIS_Z 2 +#define CHART_AXIS_REALNUMBER 0 +#define CHART_AXIS_PERCENT 1 +#define CHART_AXIS_CATEGORY 2 +#define CHART_AXIS_SERIES 3 +#define CHART_AXIS_DATE 4 // values for SCHATTR_STYLE_SHAPE items #define CHART_SHAPE3D_IGNORE -2 //intern! (GetChartShapeStyle()!) diff --git a/chart2/source/inc/chartview/ExplicitScaleValues.hxx b/chart2/source/inc/chartview/ExplicitScaleValues.hxx new file mode 100644 index 000000000000..a2902391b6c2 --- /dev/null +++ b/chart2/source/inc/chartview/ExplicitScaleValues.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * 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 _CHART2_EXPLICITSCALEVALUES_HXX +#define _CHART2_EXPLICITSCALEVALUES_HXX + +#include "chartviewdllapi.hxx" +#include <com/sun/star/chart/TimeInterval.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> +#include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart2/AxisType.hpp> +#include <com/sun/star/chart2/XScaling.hpp> +#include <tools/date.hxx> +#include <vector> +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** This structure contains the explicit values for a scale like Minimum and Maximum. + See also ::com::sun::star::chart2::ScaleData. +*/ + +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitScaleData +{ + ExplicitScaleData(); + + double Minimum; + double Maximum; + double Origin; + + ::com::sun::star::chart2::AxisOrientation Orientation; + + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > Scaling; + + long AxisType;//see ::com::sun::star::chart2::AxisType + bool ShiftedCategoryPosition; + long TimeResolution; //constant of type <type>::com::sun::star::chart::TimeUnit</type> + Date NullDate; +}; + +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitSubIncrement +{ + ExplicitSubIncrement(); + + /** Numbers of intervals between two superior ticks. For an axis + this usually means, that <code>IntervalCount - 1</code> + sub-tick-marks are displayed between two superior ticks. + + */ + long IntervalCount; + + /** If <TRUE/>, the distance between two sub-tick-marks on the + screen is always the same. If <FALSE/>, the distances may + differ depending on the <type>XScaling</type>. + */ + bool PostEquidistant; +}; + +/** describes how tickmarks are positioned on the scale of an axis. +*/ +struct OOO_DLLPUBLIC_CHARTVIEW ExplicitIncrementData +{ + ExplicitIncrementData(); + + /** the following two members are only for date-time axis + */ + ::com::sun::star::chart::TimeInterval MajorTimeInterval; + ::com::sun::star::chart::TimeInterval MinorTimeInterval; + + /** the other members are for *not* date-time axis + */ + + /** <member>Distance</member> describes the distance between two + neighboring main tickmarks on a <type>Scale</type> of an axis. + All neighboring main tickmarks have the same constant distance. + + <p>If the Scale has a <type>XScaling</type> the <member>Distance</member> + may be measured in two different ways - that is - before or after the + scaling is applied.</p> + + <p>On a logarithmic scale for example the distance between two main + tickmarks is typically measured after the scaling is applied: + Distance = log(tick2)-log(tick1) + ( log(1000)-log(100)==log(100)-log(10)==log(10)-log(1)==1==Distance ). + The resulting tickmarks will always look equidistant on the screen. + The other possibility is to have a Distance = tick2-tick1 measured constant + before a scaling is applied, which may lead to non equidistant tickmarks + on the screen.</p> + + <p><member>PostEquidistant</member> rules wether the <member>Distance</member> + is meant to be a value before or after scaling.</p> + */ + double Distance; + + /** + <member>PostEquidistant</member> rules wether the member <member>Distance</member> + describes a distance before or after the scaling is applied. + + <p>If <member>PostEquidistant</member> equals <TRUE/> <member>Distance</member> + is given in values after <type>XScaling</type> is applied, thus resulting + main tickmarks will always look equidistant on the screen. + If <member>PostEquidistant</member> equals <FALSE/> <member>Distance</member> + is given in values before <type>XScaling</type> is applied.</p> + */ + bool PostEquidistant; + + /** The <member>BaseValue</member> gives a starting point on the scale + to which all further main tickmarks are relatively positioned. + + <p>The <member>BaseValue</member> is always a value on the scale before + a possible scaling is applied. If the given value is not valid in the + associated scaling the minimum of the scaling is assumed, + if there is no minimum any other obvious value will be assumed.</p> + + <p>E.g.: assume a scale from 0 to 6 with identical scaling. + Further assume this Increment to have Distance==2 and PostEquidistant==false. + Setting BaseValue=0 would lead to main tickmarks 0; 2; 4; 6; + Setting BaseValue=1,3 would lead to main tickmarks 1,3; 3,3; 5,3; + Setting BaseValue=-0,7 would also lead to main tickmarks 1,3; 3,3; 5,3; + And setting BaseValue to 2, -2, 4, -4 etc. in this example + leads to the same result as BaseValue=0.</p> + */ + double BaseValue; + + /** <member>SubIncrements</member> describes the positioning of further + sub tickmarks on the scale of an axis. + + <p>The first SubIncrement in this sequence determines how the + distance between two neighboring main tickmarks is divided for positioning + of further sub tickmarks. Every following SubIncrement determines the + positions of subsequent tickmarks in relation to their parent tickmarks + iven by the preceding SubIncrement.</p> + */ + ::std::vector< ExplicitSubIncrement > SubIncrements; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index d10ee8d415fc..231b1acef6db 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -27,9 +27,9 @@ #ifndef _CHART2_EXPLICITVALUEPROVIDER_HXX #define _CHART2_EXPLICITVALUEPROVIDER_HXX +#include "ExplicitScaleValues.hxx" + #include <boost/shared_ptr.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XCoordinateSystem.hpp> #include <com/sun/star/chart2/XDataSeries.hpp> @@ -59,8 +59,8 @@ public: */ virtual sal_Bool getExplicitValuesForAxis( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis - , ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement )=0; + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement )=0; /** for rotated objects the shape size and position differs from the visible rectangle if bSnapRect is set to true you get the resulting visible position (left-top) and size diff --git a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx index 9f5f44107997..5eb2160a8765 100644 --- a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/chartview/NumberFormatterWrapper.hxx @@ -52,6 +52,7 @@ public: getNumberFormatsSupplier() { return m_xNumberFormatsSupplier; }; rtl::OUString getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const; + Date getNullDate() const; private: //private member ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index e3943e9eb45f..498be4e2daf9 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -651,9 +651,18 @@ void ChartTypeTemplate::adaptScales( { ScaleData aData( xAxis->getScaleData() ); aData.Categories = xCategories; - aData.AxisType = bSupportsCategories ? AxisType::CATEGORY : AxisType::REALNUMBER; - if( bSupportsCategories ) - AxisHelper::removeExplicitScaling( aData ); + if(bSupportsCategories) + { + if( aData.AxisType != AxisType::CATEGORY && aData.AxisType != AxisType::DATE ) + { + aData.AxisType = AxisType::CATEGORY; + aData.AutoDateAxis = true; + AxisHelper::removeExplicitScaling( aData ); + } + } + else + aData.AxisType = AxisType::REALNUMBER; + xAxis->setScaleData( aData ); } } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 8cdd24e4dc05..506c0a96295a 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -38,7 +38,9 @@ #include "servicenames_coosystems.hxx" #include "DataSeriesHelper.hxx" #include "Scaling.hxx" +#include "ChartModelHelper.hxx" +#include <tools/debug.hxx> #include <unotools/saveopt.hxx> #include <com/sun/star/chart/ChartAxisPosition.hpp> @@ -81,6 +83,8 @@ ScaleData AxisHelper::createDefaultScale() { ScaleData aScaleData; aScaleData.AxisType = chart2::AxisType::REALNUMBER; + aScaleData.AutoDateAxis = true; + aScaleData.ShiftedCategoryPosition = false;//this is adapted in the view code currently Sequence< SubIncrement > aSubIncrements(1); aSubIncrements[0] = SubIncrement(); aScaleData.IncrementData.SubIncrements = aSubIncrements; @@ -93,6 +97,9 @@ void AxisHelper::removeExplicitScaling( ScaleData& rScaleData ) uno::Any aEmpty; rScaleData.Minimum = rScaleData.Maximum = rScaleData.Origin = aEmpty; rScaleData.Scaling = 0; + ScaleData aDefaultScale( createDefaultScale() ); + rScaleData.IncrementData = aDefaultScale.IncrementData; + rScaleData.TimeIncrement = aDefaultScale.TimeIncrement; } //static @@ -105,6 +112,39 @@ bool AxisHelper::isLogarithmic( const Reference< XScaling >& xScaling ) return bReturn; } +chart2::ScaleData AxisHelper::getDateCheckedScale( const Reference< chart2::XAxis >& xAxis, const Reference< frame::XModel >& xChartModel ) +{ + DBG_ASSERT(xChartModel.is(),"missing chart model"); + ScaleData aScale = xAxis->getScaleData(); + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( aScale.AutoDateAxis && aScale.AxisType == AxisType::CATEGORY ) + { + sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; + AxisHelper::getIndicesForAxis(xAxis, xCooSys, nDimensionIndex, nAxisIndex ); + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex ); + if( bChartTypeAllowsDateAxis ) + aScale.AxisType = AxisType::DATE; + } + if( aScale.AxisType == AxisType::DATE ) + { + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys,xChartModel ); + if( !aExplicitCategoriesProvider.isDateAxis() ) + aScale.AxisType = AxisType::CATEGORY; + } + return aScale; +} + +void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ) +{ + if( rScale.AutoDateAxis && rScale.AxisType == AxisType::CATEGORY && bChartTypeAllowsDateAxis ) + rScale.AxisType = AxisType::DATE; + if( rScale.AxisType == AxisType::DATE && (!pExplicitCategoriesProvider || !pExplicitCategoriesProvider->isDateAxis()) ) + { + rScale.AxisType = AxisType::CATEGORY; + removeExplicitScaling( rScale ); + } +} + //static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex @@ -137,6 +177,7 @@ Reference< XAxis > AxisHelper::createAxis( ScaleData aMainScale = xMainAxis->getScaleData(); aScale.AxisType = aMainScale.AxisType; + aScale.AutoDateAxis = aMainScale.AutoDateAxis; aScale.Categories = aMainScale.Categories; aScale.Orientation = aMainScale.Orientation; diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index b851a3864b97..cd0a62312387 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -415,13 +415,34 @@ bool ChartTypeHelper::isSupportingAxisPositioning( const uno::Reference< chart2: return true; } -bool ChartTypeHelper::shiftTicksAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType ) +bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 /*nDimensionCount*/, sal_Int32 nDimensionIndex ) +{ + if( nDimensionIndex!=0 ) + return false; + if( xChartType.is() ) + { + sal_Int32 nType = ChartTypeHelper::getAxisType( xChartType, nDimensionIndex ); + if( nType != AxisType::CATEGORY ) + return false; + rtl::OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) + return false; + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) ) + return false; + } + return true; +} + +bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType ) { if(xChartType.is()) { rtl::OUString aChartTypeName = xChartType->getChartType(); if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) - || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) return true; } return false; diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 36afef60a6d4..d19e8819f069 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/chart/MissingValueTreatment.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart/XDiagramPositioning.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart2/XTitled.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XChartTypeTemplate.hpp> @@ -57,10 +58,15 @@ #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> +#include <com/sun/star/util/NumberFormat.hpp> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + #include <unotools/saveopt.hxx> #include <rtl/math.hxx> -#include <com/sun/star/util/XModifiable.hpp> +// header for class Application +#include <vcl/svapp.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -68,7 +74,9 @@ using namespace ::std; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; using ::rtl::OUString; +using ::com::sun::star::chart2::XAnyDescriptionAccess; namespace chart { @@ -880,7 +888,7 @@ bool DiagramHelper::isCategoryDiagram( if( xAxis.is()) { ScaleData aScaleData = xAxis->getScaleData(); - if( aScaleData.AxisType == AxisType::CATEGORY ) + if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE ) return true; } } @@ -919,7 +927,7 @@ void DiagramHelper::setCategoriesToDiagram( { if( bCategoryAxis ) aScaleData.AxisType = AxisType::CATEGORY; - else if( aScaleData.AxisType == AxisType::CATEGORY ) + else if( aScaleData.AxisType == AxisType::CATEGORY || aScaleData.AxisType == AxisType::DATE ) aScaleData.AxisType = AxisType::REALNUMBER; } xCatAxis->setScaleData( aScaleData ); @@ -1037,6 +1045,186 @@ Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories( return aRet; } +bool DiagramHelper::mayToggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + if( xAxis.is() ) + { + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType == chart2::AxisType::DATE || aScale.AxisType == chart2::AxisType::CATEGORY ) + return true; + } + } + } + return false; +} + +namespace +{ +void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) +{ + if( !xAxis.is() ) + return; + if( !xChartDoc.is() ) + return; + + ScaleData aScale( xAxis->getScaleData() ); + if( xChartDoc->hasInternalDataProvider() ) + { + //remove all content the is not of type double and remove multiple level + Reference< XAnyDescriptionAccess > xDataAccess( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + if( xDataAccess.is() ) + { + Sequence< Sequence< Any > > aAnyCategories( xDataAccess->getAnyRowDescriptions() ); + double fTest = 0.0; + double fNan = 0.0; + ::rtl::math::setNan( & fNan ); + sal_Int32 nN = aAnyCategories.getLength(); + for( ; nN--; ) + { + Sequence< Any >& rCat = aAnyCategories[nN]; + if( rCat.getLength() > 1 ) + rCat.realloc(1); + if( rCat.getLength() == 1 ) + { + Any& rAny = rCat[0]; + if( !(rAny>>=fTest) ) + { + rAny = uno::makeAny(fNan); + } + } + } + xDataAccess->setAnyRowDescriptions( aAnyCategories ); + } + //check the numberformat at the axis + Reference< beans::XPropertySet > xAxisProps( xAxis, uno::UNO_QUERY ); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartDoc, uno::UNO_QUERY ); + if( xAxisProps.is() && xNumberFormatsSupplier.is() ) + { + sal_Int32 nNumberFormat = -1; + xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nNumberFormat; + + Reference< util::XNumberFormats > xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + Reference< beans::XPropertySet > xKeyProps; + try + { + xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + sal_Int32 nType = util::NumberFormat::UNDEFINED; + if( xKeyProps.is() ) + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + if( nType!=util::NumberFormat::DATE && nType!=util::NumberFormat::DATETIME ) + { + //set a date format to the axis + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + xAxisProps->setPropertyValue( C2U("NumberFormat"), uno::makeAny(aKeySeq[0]) ); + } + } + } + } + } + if( aScale.AxisType != chart2::AxisType::DATE ) + AxisHelper::removeExplicitScaling( aScale ); + aScale.AxisType = chart2::AxisType::DATE; + xAxis->setScaleData( aScale ); +} + +void lcl_switchToTextCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) +{ + if( !xAxis.is() ) + return; + if( !xChartDoc.is() ) + return; + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType != chart2::AxisType::CATEGORY ) + AxisHelper::removeExplicitScaling( aScale ); + //todo migrate dates to text? + aScale.AxisType = chart2::AxisType::CATEGORY; + aScale.AutoDateAxis = false; + xAxis->setScaleData( aScale ); +} + +} + +void DiagramHelper::switchToDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + lcl_switchToDateCategories( xChartDoc, xAxis ); + } + } +} + +void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + lcl_switchToTextCategories( xChartDoc, xAxis ); + } + } +} + +void DiagramHelper::toggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +{ + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + if(xChartModel.is()) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + + Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSys.is() ) + { + Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); + if( xAxis.is() ) + { + ScaleData aScale( xAxis->getScaleData() ); + if( aScale.AxisType == chart2::AxisType::DATE ) + { + lcl_switchToTextCategories( xChartDoc, xAxis ); + } + else if( aScale.AxisType == chart2::AxisType::CATEGORY ) + { + lcl_switchToDateCategories( xChartDoc, xAxis ); + } + else + { + DBG_ERROR("Cannot toggle Date Categories for this axis type"); + } + } + } + } +} + // static Sequence< Reference< XChartType > > DiagramHelper::getChartTypesFromDiagram( diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index bd1c1bb79813..5411e94ee18c 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -30,12 +30,18 @@ #include "ExplicitCategoriesProvider.hxx" #include "DiagramHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "AxisHelper.hxx" #include "CommonConverters.hxx" #include "DataSourceHelper.hxx" #include "ChartModelHelper.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" +#include <com/sun/star/chart2/AxisType.hpp> +#include <com/sun/star/util/NumberFormat.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + //............................................................................. namespace chart { @@ -53,7 +59,10 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: , const uno::Reference< frame::XModel >& xChartModel ) : m_bDirty(true) , m_xCooSysModel( xCooSysModel ) + , m_xChartModel( xChartModel ) , m_xOriginalCategories() + , m_bIsDateAxis(false) + , m_bIsAutoDate(false) { try { @@ -61,7 +70,12 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: { uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) ); if( xAxis.is() ) - m_xOriginalCategories = xAxis->getScaleData().Categories; + { + ScaleData aScale( xAxis->getScaleData() ); + m_xOriginalCategories = aScale.Categories; + m_bIsAutoDate = (aScale.AutoDateAxis && aScale.AxisType==chart2::AxisType::CATEGORY); + m_bIsDateAxis = (aScale.AxisType == chart2::AxisType::DATE || m_bIsAutoDate); + } } if( m_xOriginalCategories.is() ) @@ -134,6 +148,13 @@ ExplicitCategoriesProvider::~ExplicitCategoriesProvider() { } +Reference< chart2::data::XDataSequence > ExplicitCategoriesProvider::getOriginalCategories() +{ + if( m_xOriginalCategories.is() ) + return m_xOriginalCategories->getValues(); + return 0; +} + const Sequence< Reference< data::XLabeledDataSequence> >& ExplicitCategoriesProvider::getSplitCategoriesList() { return m_aSplitCategoriesList; @@ -363,21 +384,125 @@ Sequence< OUString > ExplicitCategoriesProvider::getExplicitSimpleCategories( return lcl_getExplicitSimpleCategories( rSplitCategoriesProvider, aComplexCats ); } +struct DatePlusIndexComparator +{ + inline bool operator() ( const DatePlusIndex& aFirst, + const DatePlusIndex& aSecond ) + { + return ( aFirst.fValue < aSecond.fValue ); + } +}; + +bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) +{ + bool bIsDate = false; + if( !xNumberFormats.is() ) + return bIsDate; + + Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + if( xKeyProps.is() ) + { + sal_Int32 nType = util::NumberFormat::DATETIME; + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + bIsDate = (nType==util::NumberFormat::DATE || nType==util::NumberFormat::DATETIME); + } + return bIsDate; +} + +bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataSequence, std::vector< DatePlusIndex >& rDateCategories, bool bIsAutoDate, Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier ) +{ + bool bOnlyDatesFound = true; + + if( xDataSequence.is() ) + { + uno::Sequence< uno::Any > aValues = xDataSequence->getData(); + sal_Int32 nCount = aValues.getLength(); + rDateCategories.reserve(nCount); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + + bool bOwnData = false; + bool bOwnDataAndDateFormat = false; + sal_Int32 nAxisNumberFormat = 0; + Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); + Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ) ); + if( xChartDoc.is() && xCooSysModel.is() ) + { + if( xChartDoc->hasInternalDataProvider() ) + { + bOwnData = true; + Reference< beans::XPropertySet > xAxisProps( xCooSysModel->getAxisByDimension(0,0), uno::UNO_QUERY ); + if( xAxisProps.is() && (xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nAxisNumberFormat) ) + bOwnDataAndDateFormat = lcl_isDateFormat( nAxisNumberFormat, xNumberFormats ); + } + } + + for(sal_Int32 nN=0;nN<nCount;nN++) + { + bool bIsDate = false; + if( bIsAutoDate ) + { + if( bOwnData ) + bIsDate = bOwnDataAndDateFormat; + else + bIsDate = lcl_isDateFormat( xDataSequence->getNumberFormatKeyByIndex( nN ), xNumberFormats ); + } + else + bIsDate = true; + + uno::Any aAny = aValues[nN]; + DatePlusIndex aDatePlusIndex( 1.0, nN ); + if( bIsDate && (aAny >>= aDatePlusIndex.fValue) ) + rDateCategories.push_back( aDatePlusIndex ); + else + { + if( aAny.hasValue() ) + { + OUString aTest; + if( !( (aAny>>=aTest) && !aTest.getLength() ) )//empty string does not count as non date value! + bOnlyDatesFound=false; + } + ::rtl::math::setNan( &aDatePlusIndex.fValue ); + rDateCategories.push_back( aDatePlusIndex ); + } + } + ::std::sort( rDateCategories.begin(), rDateCategories.end(), DatePlusIndexComparator() ); + } + + return bOnlyDatesFound; +} + void ExplicitCategoriesProvider::init() { if( m_bDirty ) { m_aExplicitCategories.realloc(0); m_aComplexCats.clear();//not one per index + m_aDateCategories.clear(); if( m_xOriginalCategories.is() ) { if( !hasComplexCategories() ) + { m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues()); + if(m_bIsDateAxis) + { + if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 2, 0 ) ) + m_bIsDateAxis = lcl_fillDateCategories( m_xOriginalCategories->getValues(), m_aDateCategories, m_bIsAutoDate, Reference< util::XNumberFormatsSupplier >( m_xChartModel.get(), uno::UNO_QUERY ) ); + else + m_bIsDateAxis = false; + } + } else + { m_aExplicitCategories = lcl_getExplicitSimpleCategories( SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats ); + m_bIsDateAxis = false; + } } + else + m_bIsDateAxis=false; if(!m_aExplicitCategories.getLength()) m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); m_bDirty = false; @@ -417,6 +542,18 @@ OUString ExplicitCategoriesProvider::getCategoryByIndex( return OUString(); } +bool ExplicitCategoriesProvider::isDateAxis() +{ + init(); + return m_bIsDateAxis; +} + +const std::vector< DatePlusIndex >& ExplicitCategoriesProvider::getDateCategories() +{ + init(); + return m_aDateCategories; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index 65fc97a04b38..e9b0cf689768 100755 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -38,6 +38,7 @@ using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using namespace ::com::sun::star; using namespace ::std; namespace chart @@ -55,10 +56,10 @@ struct lcl_NumberedStringGenerator m_nWildcardLength( rWildcard.getLength()) { } - vector< OUString > operator()() + vector< uno::Any > operator()() { - vector< OUString > aRet(1); - aRet[0] = m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter )); + vector< uno::Any > aRet(1); + aRet[0] = uno::makeAny( m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter )) ); return aRet; } private: @@ -113,12 +114,12 @@ void InternalData::createDefaultData() m_aRowLabels.clear(); m_aRowLabels.reserve( m_nRowCount ); generate_n( back_inserter( m_aRowLabels ), m_nRowCount, - lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") )); + lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") )); m_aColumnLabels.clear(); m_aColumnLabels.reserve( m_nColumnCount ); generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount, - lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") )); + lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") )); } void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows ) @@ -199,7 +200,7 @@ void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & r m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice; } -void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< OUString >& rComplexLabel ) +void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel ) { if( nColumnIndex < 0 ) return; @@ -208,10 +209,10 @@ void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< m_aColumnLabels.resize(nColumnIndex+1); enlargeData( nColumnIndex+1, 0 ); } - m_aColumnLabels[nColumnIndex]=rComplexLabel; } -void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUString >& rComplexLabel ) + +void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel ) { if( nRowIndex < 0 ) return; @@ -220,23 +221,22 @@ void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUStri m_aRowLabels.resize(nRowIndex+1); enlargeData( 0, nRowIndex+1 ); } - m_aRowLabels[nRowIndex] = rComplexLabel; } -vector< OUString > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const +vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const { if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) ) return m_aColumnLabels[nColumnIndex]; else - return vector< OUString >(); + return vector< uno::Any >(); } -vector< OUString > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const +vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const { if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) ) return m_aRowLabels[nRowIndex]; else - return vector< OUString >(); + return vector< uno::Any >(); } void InternalData::swapRowWithNext( sal_Int32 nRowIndex ) @@ -253,7 +253,7 @@ void InternalData::swapRowWithNext( sal_Int32 nRowIndex ) m_aData[nIndex2] = fTemp; } - vector< OUString > aTemp( m_aRowLabels[nRowIndex] ); + vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] ); m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1]; m_aRowLabels[nRowIndex + 1] = aTemp; } @@ -273,7 +273,7 @@ void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex ) m_aData[nIndex2] = fTemp; } - vector< OUString > aTemp( m_aColumnLabels[nColumnIndex] ); + vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] ); m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1]; m_aColumnLabels[nColumnIndex + 1] = aTemp; } @@ -336,7 +336,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex ) // labels if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size())) - m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< OUString >(1) ); + m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) ); #if OSL_DEBUG_LEVEL > 2 traceData(); @@ -388,7 +388,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex ) // labels if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size())) - m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< OUString> (1)); + m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1)); #if OSL_DEBUG_LEVEL > 2 traceData(); @@ -481,7 +481,7 @@ sal_Int32 InternalData::getColumnCount() const return m_nColumnCount; } -void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNewRowLabels ) +void InternalData::setComplexRowLabels( const vector< vector< uno::Any > >& rNewRowLabels ) { m_aRowLabels = rNewRowLabels; sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() ); @@ -491,12 +491,12 @@ void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNew enlargeData( 0, nNewRowCount ); } -vector< vector< OUString > > InternalData::getComplexRowLabels() const +vector< vector< uno::Any > > InternalData::getComplexRowLabels() const { return m_aRowLabels; } -void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& rNewColumnLabels ) +void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& rNewColumnLabels ) { m_aColumnLabels = rNewColumnLabels; sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() ); @@ -506,7 +506,7 @@ void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& r enlargeData( nNewColumnCount, 0 ); } -vector< vector< OUString > > InternalData::getComplexColumnLabels() const +vector< vector< uno::Any > > InternalData::getComplexColumnLabels() const { return m_aColumnLabels; } diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 4abc51be31af..b3f3058d6f05 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -93,6 +93,24 @@ static const ::rtl::OUString lcl_aCompleteRange( typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > > lcl_tSequenceMap; +Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) +{ + Sequence< OUString > aResult; + aResult.realloc( aAnySeq.getLength() ); + transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), + aResult.getArray(), CommonFunctors::AnyToString() ); + return aResult; +} + +Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq ) +{ + Sequence< uno::Any > aResult; + aResult.realloc( aStringSeq.getLength() ); + transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + return aResult; +} + struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void > { void operator() ( const lcl_tSequenceMap::value_type & rMapEntry ) @@ -154,9 +172,9 @@ struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2:: if( xLabel.is() ) { if( m_bDataInColumns ) - m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); else - m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); if( m_bConnectToModel ) { Reference< chart2::data::XDataSequence > xNewLabel( @@ -187,37 +205,37 @@ private: bool m_bDataInColumns; }; -struct lcl_makeAnyFromLevelVector : public ::std::unary_function< vector< OUString >, uno::Any > +struct lcl_copyFromLevel : public ::std::unary_function< vector< uno::Any >, uno::Any > { public: - explicit lcl_makeAnyFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - uno::Any operator() ( const vector< OUString >& rVector ) + uno::Any operator() ( const vector< uno::Any >& rVector ) { - OUString aString; + uno::Any aRet; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; - return uno::makeAny( aString ); + aRet = rVector[m_nLevel]; + return aRet; } private: sal_Int32 m_nLevel; }; -struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< OUString >, OUString > +struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< uno::Any >, OUString > { public: explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - OUString operator() ( const vector< OUString >& rVector ) + OUString operator() ( const vector< uno::Any >& rVector ) { OUString aString; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; + aString = CommonFunctors::AnyToString()(rVector[m_nLevel]); return aString; } @@ -226,19 +244,39 @@ private: }; -struct lcl_setStringAtLevel : public ::std::binary_function< vector< OUString >, OUString, vector< OUString > > +struct lcl_setAnyAtLevel : public ::std::binary_function< vector< uno::Any >, uno::Any, vector< uno::Any > > +{ +public: + + explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + {} + + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue ) + { + vector< uno::Any > aRet( rVector ); + if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) + aRet.resize( m_nLevel+1 ); + aRet[ m_nLevel ]=rNewValue; + return aRet; + } + +private: + sal_Int32 m_nLevel; +}; + +struct lcl_setAnyAtLevelFromStringSequence : public ::std::binary_function< vector< uno::Any >, OUString, vector< uno::Any > > { public: - explicit lcl_setStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - vector< OUString > operator() ( const vector< OUString >& rVector, const OUString& rNewText ) + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue ) { - vector< OUString > aRet( rVector ); + vector< uno::Any > aRet( rVector ); if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) aRet.resize( m_nLevel+1 ); - aRet[ m_nLevel ]=rNewText; + aRet[ m_nLevel ]=uno::makeAny(rNewValue); return aRet; } @@ -246,41 +284,41 @@ private: sal_Int32 m_nLevel; }; -struct lcl_insertStringAtLevel : public ::std::unary_function< vector< OUString >, void > +struct lcl_insertAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_insertStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) ) rVector.resize( m_nLevel ); - vector< OUString >::iterator aIt( rVector.begin() ); + vector< uno::Any >::iterator aIt( rVector.begin() ); for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++) { if( nN==m_nLevel ) break; } - rVector.insert( aIt, OUString() ); + rVector.insert( aIt, uno::Any() ); } private: sal_Int32 m_nLevel; }; -struct lcl_removeStringAtLevel : public ::std::unary_function< vector< OUString >, void > +struct lcl_removeAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_removeStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { - vector< OUString >::iterator aIt( rVector.begin() ); + vector< uno::Any >::iterator aIt( rVector.begin() ); for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++) { if( nN==m_nLevel ) @@ -295,23 +333,6 @@ private: sal_Int32 m_nLevel; }; -vector< OUString > lcl_AnyToStringVector( const Sequence< uno::Any >& aAnySeq ) -{ - vector< OUString > aStringVec; - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - back_inserter( aStringVec ), CommonFunctors::AnyToString() ); - return aStringVec; -} - -Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) -{ - Sequence< OUString > aResult; - aResult.realloc( aAnySeq.getLength() ); - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - aResult.getArray(), CommonFunctors::AnyToString() ); - return aResult; -} - } // anonymous namespace // ================================================================================ @@ -341,9 +362,11 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum // categories { - vector< vector< OUString > > aNewCategories;//inner count is level + vector< vector< uno::Any > > aNewCategories;//inner count is level { ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); + bool bIsDateAxis = aExplicitCategoriesProvider.isDateAxis(); + const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); for( sal_Int32 nL = 0; nL<nLevelCount; nL++ ) @@ -351,16 +374,24 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] ); if( !xLDS.is() ) continue; - Reference< chart2::data::XTextualDataSequence > xSeq( xLDS->getValues(), uno::UNO_QUERY ); - Sequence< OUString > aStringSeq; - if( xSeq.is() ) - aStringSeq = xSeq->getTextualData(); // @todo: be able to deal with XDataSequence, too - sal_Int32 nLength = aStringSeq.getLength(); + Sequence< uno::Any > aDataSeq; + Reference< chart2::data::XTextualDataSequence > xTextSeq( xLDS->getValues(), uno::UNO_QUERY ); + if( !bIsDateAxis && xTextSeq.is() ) + { + aDataSeq = lcl_StringToAnySequence( xTextSeq->getTextualData() ); + } + else + { + Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); + if( xSeq.is() ) + aDataSeq = xSeq->getData(); + } + sal_Int32 nLength = aDataSeq.getLength(); if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) aNewCategories.resize( nLength ); - transform( aNewCategories.begin(), aNewCategories.end(), aStringSeq.getConstArray(), - aNewCategories.begin(), lcl_setStringAtLevel(nL) ); + transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(), + aNewCategories.begin(), lcl_setAnyAtLevel(nL) ); } if( !nLevelCount ) { @@ -369,9 +400,9 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum aNewCategories.reserve( nLength ); for( sal_Int32 nN=0; nN<nLength; nN++) { - vector< OUString > aStringVector(1); - aStringVector[0] = aSimplecategories[nN]; - aNewCategories.push_back( aStringVector ); + vector< uno::Any > aVector(1); + aVector[0] = uno::makeAny( aSimplecategories[nN] ); + aNewCategories.push_back( aVector ); } } } @@ -518,14 +549,14 @@ void InternalDataProvider::createDefaultData() namespace { -sal_Int32 lcl_getInnerLevelCount( const vector< vector< OUString > >& rLabels ) +sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels ) { sal_Int32 nCount = 1;//minimum is 1! - vector< vector< OUString > >::const_iterator aLevelIt( rLabels.begin() ); - vector< vector< OUString > >::const_iterator aLevelEnd( rLabels.end() ); + vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() ); + vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() ); for( ;aLevelIt!=aLevelEnd; ++aLevelIt ) { - const vector< ::rtl::OUString >& rCurrentLevelLabels = *aLevelIt; + const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt; nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount ); } return nCount; @@ -549,7 +580,7 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData { //return split complex categories if we have any: ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories; - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( bUseColumns==m_bDataInColumns ) { sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); @@ -731,46 +762,74 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation if( aRange.match( lcl_aLabelRangePrefix ) ) { sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); - vector< OUString > aComplexLabel = m_bDataInColumns + vector< uno::Any > aComplexLabel = m_bDataInColumns ? m_aInternalData.getComplexColumnLabel( nIndex ) : m_aInternalData.getComplexRowLabel( nIndex ); if( !aComplexLabel.empty() ) - { - aResult.realloc( aComplexLabel.size() ); - transform( aComplexLabel.begin(), aComplexLabel.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexLabel); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32(); - vector< OUString > aComplexCategory = m_bDataInColumns + vector< uno::Any > aComplexCategory = m_bDataInColumns ? m_aInternalData.getComplexRowLabel( nPointIndex ) : m_aInternalData.getComplexColumnLabel( nPointIndex ); if( !aComplexCategory.empty() ) - { - aResult.realloc( aComplexCategory.size() ); - transform( aComplexCategory.begin(), aComplexCategory.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexCategory); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32(); - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( nLevel < lcl_getInnerLevelCount( aCategories ) ) { aResult.realloc( aCategories.size() ); transform( aCategories.begin(), aCategories.end(), - aResult.getArray(), lcl_makeAnyFromLevelVector(nLevel) ); + aResult.getArray(), lcl_copyFromLevel(nLevel) ); } } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { - Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); - aResult.realloc( aLabels.getLength() ); - transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), - aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + bool bReturnText = true; + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); + if( nLevelCount == 1 ) + { + sal_Int32 nL=0; + aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) ); + bool bOnlyDatesFound = true; + double fTest = 0.0; + OUString aTest; + for(sal_Int32 nN=aResult.getLength(); nN--;) + { + uno::Any aAny(aResult[nN]); + if( !( aAny >>= fTest) ) + { + if( aAny.hasValue() ) + { + if( (aAny>>=aTest) && !aTest.getLength() ) + { + //empty string does not count as non date value! + aResult[nN] = uno::Any(); + } + else + { + bOnlyDatesFound=false; + break; + } + } + } + } + if( bOnlyDatesFound ) + bReturnText = false; + } + if( bReturnText ) + { + Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); + aResult.realloc( aLabels.getLength() ); + transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + } } else { @@ -798,38 +857,36 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( const OUString& aRange, const Sequence< uno::Any >& aNewData ) throw (uno::RuntimeException) { + vector< uno::Any > aNewVector( ContainerHelper::SequenceToVector(aNewData) ); if( aRange.match( lcl_aLabelRangePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexColumnLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nIndex, aNewVector ); else - m_aInternalData.setComplexRowLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexRowLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector ); else - m_aInternalData.setComplexColumnLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); //ensure equal length - if( aNewStrings.size() > aComplexCategories.size() ) - aComplexCategories.resize( aNewStrings.size() ); - else if( aNewStrings.size() < aComplexCategories.size() ) - aNewStrings.resize( aComplexCategories.size() ); + if( aNewVector.size() > aComplexCategories.size() ) + aComplexCategories.resize( aNewVector.size() ); + else if( aNewVector.size() < aComplexCategories.size() ) + aNewVector.resize( aComplexCategories.size() ); - transform( aComplexCategories.begin(), aComplexCategories.end(), aNewStrings.begin(), - aComplexCategories.begin(), lcl_setStringAtLevel(nLevel) ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); @@ -838,10 +895,14 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { + vector< vector< uno::Any > > aComplexCategories; + aComplexCategories.resize( aNewVector.size() ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(0) ); if( m_bDataInColumns ) - this->setRowDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexRowLabels( aComplexCategories ); else - this->setColumnDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexColumnLabels( aComplexCategories ); } else { @@ -906,8 +967,8 @@ void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -923,8 +984,8 @@ void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -1134,7 +1195,36 @@ OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXM namespace { -Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vector< vector< OUString > >& rIn ) + +template< class Type > +Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn ) +{ + Sequence< Sequence< Type > > aRet; + sal_Int32 nOuterCount = rIn.size(); + if( nOuterCount ) + { + aRet.realloc(nOuterCount); + for( sal_Int32 nN=0; nN<nOuterCount; nN++) + aRet[nN]= ContainerHelper::ContainerToSequence( rIn[nN] ); + } + return aRet; +} + +template< class Type > +vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn ) +{ + vector< vector< Type > > aRet; + sal_Int32 nOuterCount = rIn.getLength(); + if( nOuterCount ) + { + aRet.resize(nOuterCount); + for( sal_Int32 nN=0; nN<nOuterCount; nN++) + aRet[nN]= ContainerHelper::SequenceToVector( rIn[nN] ); + } + return aRet; +} + +Sequence< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn ) { Sequence< Sequence< OUString > > aRet; sal_Int32 nOuterCount = rIn.size(); @@ -1142,17 +1232,17 @@ Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vecto { aRet.realloc(nOuterCount); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet[nN]=ContainerHelper::ContainerToSequence( rIn[nN] ); + aRet[nN]= lcl_AnyToStringSequence( ContainerHelper::ContainerToSequence( rIn[nN] ) ); } return aRet; } -vector< vector< OUString > > lcl_convertComplexSequenceToVector( const Sequence< Sequence< OUString > >& rIn ) +vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn ) { - vector< vector< OUString > > aRet; + vector< vector< uno::Any > > aRet; sal_Int32 nOuterCount = rIn.getLength(); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet.push_back( ContainerHelper::SequenceToVector( rIn[nN] ) ); + aRet.push_back( ContainerHelper::SequenceToVector( lcl_StringToAnySequence( rIn[nN] ) ) ); return aRet; } @@ -1160,7 +1250,7 @@ class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesPro { public: - explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< ::rtl::OUString > >& rComplexDescriptions ) + explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< uno::Any > >& rComplexDescriptions ) : m_rComplexDescriptions( rComplexDescriptions ) {} virtual ~SplitCategoriesProvider_ForComplexDescriptions() @@ -1170,7 +1260,7 @@ public: virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const; private: - const ::std::vector< ::std::vector< ::rtl::OUString > >& m_rComplexDescriptions; + const ::std::vector< ::std::vector< uno::Any > >& m_rComplexDescriptions; }; sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const @@ -1191,22 +1281,78 @@ uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::g }//anonymous namespace +// ____ XDateCategories ____ +Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() throw (uno::RuntimeException) +{ + double fNan = InternalDataProvider::getNotANumber(); + double fValue = fNan; + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nCount = aCategories.size(); + Sequence< double > aDoubles( nCount ); + vector< vector< uno::Any > >::iterator aIt( aCategories.begin() ); + vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() ); + for(sal_Int32 nN=0; nN<nCount && aIt!=aEnd; ++nN, ++aIt ) + { + if( !( !aIt->empty() && ((*aIt)[0]>>=fValue) ) ) + fValue = fNan; + aDoubles[nN]=fValue; + } + return aDoubles; +} + +void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + sal_Int32 nCount = rDates.getLength(); + vector< vector< uno::Any > > aNewCategories; + aNewCategories.reserve(nCount); + vector< uno::Any > aSingleLabel(1); + + for(sal_Int32 nN=0; nN<nCount; ++nN ) + { + aSingleLabel[0]=uno::makeAny(rDates[nN]); + aNewCategories.push_back(aSingleLabel); + } + + if( m_bDataInColumns ) + m_aInternalData.setComplexRowLabels( aNewCategories ); + else + m_aInternalData.setComplexColumnLabels( aNewCategories ); +} + +// ____ XAnyDescriptionAccess ____ +Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexRowLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& aRowDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexRowLabels( lcl_convertSequenceSequenceToVectorVector( aRowDescriptions ) ); +} +Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexColumnLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& aColumnDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexColumnLabels( lcl_convertSequenceSequenceToVectorVector( aColumnDescriptions ) ); +} + // ____ XComplexDescriptionAccess ____ Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexRowLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() ); } void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexRowLabels( lcl_convertComplexSequenceToVector(aRowDescriptions) ); + m_aInternalData.setComplexRowLabels( lcl_convertComplexStringSequenceToAnyVector(aRowDescriptions) ); } Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexColumnLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() ); } void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexColumnLabels( lcl_convertComplexSequenceToVector(aColumnDescriptions) ); + m_aInternalData.setComplexColumnLabels( lcl_convertComplexStringSequenceToAnyVector(aColumnDescriptions) ); } // ____ XChartDataArray ____ @@ -1225,25 +1371,25 @@ void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aRowDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexRowLabels( aComplexDescriptions ); } void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aColumnDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexColumnLabels( aComplexDescriptions ); } Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } @@ -1251,7 +1397,7 @@ Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx new file mode 100644 index 000000000000..45f958ab2898 --- /dev/null +++ b/chart2/source/view/axes/DateHelper.cxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * 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_chart2.hxx" +#include "DateHelper.hxx" +#include "DateScaling.hxx" +#include <rtl/math.hxx> +#include <com/sun/star/chart/TimeUnit.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +bool DateHelper::IsInSameYear( const Date& rD1, const Date& rD2 ) +{ + return rD1.GetYear() == rD2.GetYear(); +} +bool DateHelper::IsInSameMonth( const Date& rD1, const Date& rD2 ) +{ + return (rD1.GetYear() == rD2.GetYear()) + && (rD1.GetMonth() == rD2.GetMonth()); +} +long DateHelper::GetMonthsBetweenDates( Date aD1, Date aD2 ) +{ + Date aHelp = aD1; + long nSign = 1; + if( aD1 < aD2 ) + { + aD1 = aD2; + aD2 = aHelp; + nSign = -1; + } + + return nSign*( ( aD1.GetMonth() - aD2.GetMonth() ) + + ( aD1.GetYear() - aD2.GetYear() )*12 ); +} + +Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) +{ + Date aRet(rD); + long nMonth = rD.GetMonth()+nMonthDistance; + long nNewMonth = nMonth%12; + long nNewYear = rD.GetYear() + nMonth/12; + if( nMonth <= 0 || !nNewMonth ) + nNewYear--; + if( nNewMonth <= 0 ) + nNewMonth += 12; + aRet.SetMonth( USHORT(nNewMonth) ); + aRet.SetYear( USHORT(nNewYear) ); + while(!aRet.IsValid()) + aRet--; + return aRet; +} + +Date DateHelper::GetDateSomeYearsAway( const Date& rD, long nYearDistance ) +{ + Date aRet(rD); + aRet.SetYear( static_cast<USHORT>(rD.GetYear()+nYearDistance) ); + while(!aRet.IsValid()) + aRet--; + return aRet; +} + +bool DateHelper::IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ) +{ + Date aDMin( DateHelper::GetDateSomeMonthsAway( rD1, -1 ) ); + Date aDMax( DateHelper::GetDateSomeMonthsAway( rD1, 1 ) ); + + if( rD2 > aDMin && rD2 < aDMax ) + return true; + return false; +} + +bool DateHelper::IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ) +{ + Date aDMin( DateHelper::GetDateSomeYearsAway( rD1, -1 ) ); + Date aDMax( DateHelper::GetDateSomeYearsAway( rD1, 1 ) ); + + if( rD2 > aDMin && rD2 < aDMax ) + return true; + return false; +} + +double DateHelper::RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution ) +{ + Date aDate(rNullDate); aDate += static_cast<long>(::rtl::math::approxFloor(fValue)); + switch(TimeResolution) + { + case ::com::sun::star::chart::TimeUnit::DAY: + break; + case ::com::sun::star::chart::TimeUnit::YEAR: + aDate.SetMonth(1); + aDate.SetDay(1); + break; + case ::com::sun::star::chart::TimeUnit::MONTH: + default: + aDate.SetDay(1); + break; + } + return aDate - rNullDate; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/DateScaling.cxx b/chart2/source/view/axes/DateScaling.cxx new file mode 100644 index 000000000000..65d6771ee2e9 --- /dev/null +++ b/chart2/source/view/axes/DateScaling.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * 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_chart2.hxx" +#include "DateScaling.hxx" +#include <com/sun/star/chart/TimeUnit.hpp> +#include <rtl/math.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName_DateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.DateScaling" )); +static const ::rtl::OUString lcl_aServiceName_InverseDateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.InverseDateScaling" )); + +static const ::rtl::OUString lcl_aImplementationName_DateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.DateScaling" )); +static const ::rtl::OUString lcl_aImplementationName_InverseDateScaling( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.InverseDateScaling" )); + +static const double lcl_fNumberOfMonths = 12.0;//todo: this needs to be offered by basic tools Date class if it should be more generic +} + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; + +DateScaling::DateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ) + : m_aNullDate( rNullDate ) + , m_nTimeUnit( nTimeUnit ) + , m_bShifted( bShifted ) +{ +} + +DateScaling::~DateScaling() +{ +} + +double SAL_CALL DateScaling::doScaling( double value ) + throw (uno::RuntimeException) +{ + double fResult(value); + if( ::rtl::math::isNan( value ) || ::rtl::math::isInf( value ) ) + ::rtl::math::setNan( & fResult ); + else + { + Date aDate(m_aNullDate); + aDate += static_cast<long>(::rtl::math::approxFloor(value)); + switch( m_nTimeUnit ) + { + case DAY: + fResult = value; + if(m_bShifted) + fResult+=0.5; + break; + case YEAR: + case MONTH: + default: + fResult = aDate.GetYear(); + fResult *= lcl_fNumberOfMonths;//asssuming equal count of months in each year + fResult += aDate.GetMonth(); + + double fDayOfMonth = aDate.GetDay(); + fDayOfMonth -= 1.0; + double fDaysInMonth = aDate.GetDaysInMonth(); + fResult += fDayOfMonth/fDaysInMonth; + if(m_bShifted) + { + if( YEAR==m_nTimeUnit ) + fResult += 0.5*lcl_fNumberOfMonths; + else + fResult += 0.5; + } + break; + } + } + return fResult; +} + +uno::Reference< XScaling > SAL_CALL DateScaling::getInverseScaling() + throw (uno::RuntimeException) +{ + return new InverseDateScaling( m_aNullDate, m_nTimeUnit, m_bShifted ); +} + +::rtl::OUString SAL_CALL DateScaling::getServiceName() + throw (uno::RuntimeException) +{ + return lcl_aServiceName_DateScaling; +} + +uno::Sequence< ::rtl::OUString > DateScaling::getSupportedServiceNames_Static() +{ + return uno::Sequence< ::rtl::OUString >( & lcl_aServiceName_DateScaling, 1 ); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( DateScaling, lcl_aServiceName_DateScaling ) + +// ---------------------------------------- + +InverseDateScaling::InverseDateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ) + : m_aNullDate( rNullDate ) + , m_nTimeUnit( nTimeUnit ) + , m_bShifted( bShifted ) +{ +} + +InverseDateScaling::~InverseDateScaling() +{ +} + +double SAL_CALL InverseDateScaling::doScaling( double value ) + throw (uno::RuntimeException) +{ + double fResult(value); + if( ::rtl::math::isNan( value ) || ::rtl::math::isInf( value ) ) + ::rtl::math::setNan( & fResult ); + else + { + switch( m_nTimeUnit ) + { + case DAY: + if(m_bShifted) + value -= 0.5; + fResult = value; + break; + case YEAR: + case MONTH: + default: + //Date aDate(m_aNullDate); + if(m_bShifted) + { + if( YEAR==m_nTimeUnit ) + value -= 0.5*lcl_fNumberOfMonths; + else + value -= 0.5; + } + Date aDate; + double fYear = ::rtl::math::approxFloor(value/lcl_fNumberOfMonths); + double fMonth = ::rtl::math::approxFloor(value-(fYear*lcl_fNumberOfMonths)); + aDate.SetYear( static_cast<USHORT>(fYear) ); + aDate.SetMonth( static_cast<USHORT>(fMonth) ); + aDate.SetDay( 1 ); + double fMonthCount = (fYear*lcl_fNumberOfMonths)+fMonth; + double fDay = (value-fMonthCount)*aDate.GetDaysInMonth(); + fDay += 1.0; + aDate.SetDay( static_cast<USHORT>(::rtl::math::round(fDay)) ); + fResult = aDate - m_aNullDate; + break; + } + } + return fResult; +} + +uno::Reference< XScaling > SAL_CALL InverseDateScaling::getInverseScaling() + throw (uno::RuntimeException) +{ + return new DateScaling( m_aNullDate, m_nTimeUnit, m_bShifted ); +} + +::rtl::OUString SAL_CALL InverseDateScaling::getServiceName() + throw (uno::RuntimeException) +{ + return lcl_aServiceName_InverseDateScaling; +} + +uno::Sequence< ::rtl::OUString > InverseDateScaling::getSupportedServiceNames_Static() +{ + return uno::Sequence< ::rtl::OUString >( & lcl_aServiceName_InverseDateScaling, 1 ); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( InverseDateScaling, lcl_aServiceName_InverseDateScaling ) + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/DateScaling.hxx b/chart2/source/view/axes/DateScaling.hxx new file mode 100644 index 000000000000..5e550604a957 --- /dev/null +++ b/chart2/source/view/axes/DateScaling.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * 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 _CHART2_DATESCALING_HXX +#define _CHART2_DATESCALING_HXX +#include "ServiceMacros.hxx" +#include <com/sun/star/chart2/XScaling.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/implbase3.hxx> +#include <tools/date.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class DateScaling : + public ::cppu::WeakImplHelper3 < + ::com::sun::star::chart2::XScaling, + ::com::sun::star::lang::XServiceName, + ::com::sun::star::lang::XServiceInfo + > +{ +public: + DateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ); + virtual ~DateScaling(); + + /// declare XServiceInfo methods + APPHELPER_XSERVICEINFO_DECL() + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > SAL_CALL + getInverseScaling() throw (::com::sun::star::uno::RuntimeException); + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + +private: + const Date m_aNullDate; + const sal_Int32 m_nTimeUnit; + const bool m_bShifted; +}; + +class InverseDateScaling : + public ::cppu::WeakImplHelper3 < + ::com::sun::star::chart2::XScaling, + ::com::sun::star::lang::XServiceName, + ::com::sun::star::lang::XServiceInfo + > +{ +public: + InverseDateScaling( const Date& rNullDate, sal_Int32 nTimeUnit, bool bShifted ); + virtual ~InverseDateScaling(); + + /// declare XServiceInfo methods + APPHELPER_XSERVICEINFO_DECL() + + // ____ XScaling ____ + virtual double SAL_CALL doScaling( double value ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > SAL_CALL + getInverseScaling() throw (::com::sun::star::uno::RuntimeException); + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() + throw (::com::sun::star::uno::RuntimeException); + +private: + const Date m_aNullDate; + const sal_Int32 m_nTimeUnit; + const bool m_bShifted; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif + diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx index 88f99b493144..97523d38758f 100644 --- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx +++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx @@ -29,6 +29,9 @@ #include "precompiled_chart2.hxx" #include "MinimumAndMaximumSupplier.hxx" + +#include <com/sun/star/chart/TimeUnit.hpp> + #include <rtl/math.hxx> #include <com/sun/star/awt/Size.hpp> @@ -196,6 +199,24 @@ void MergedMinimumAndMaximumSupplier::clearMinimumAndMaximumSupplierList() m_aMinimumAndMaximumSupplierList.clear(); } +long MergedMinimumAndMaximumSupplier::calculateTimeResolutionOnXAxis() +{ + long nRet = ::com::sun::star::chart::TimeUnit::YEAR; + for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) + { + long nCurrent = (*aIt)->calculateTimeResolutionOnXAxis(); + if(nRet>nCurrent) + nRet=nCurrent; + } + return nRet; +} + +void MergedMinimumAndMaximumSupplier::setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ) +{ + for( MinimumAndMaximumSupplierSet::iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) + (*aIt)->setTimeResolutionOnXAxis( nTimeResolution, rNullDate ); +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 890bf87df96e..441592c400eb 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -29,8 +29,12 @@ #include "precompiled_chart2.hxx" #include "ScaleAutomatism.hxx" #include "macros.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks_Equidistant.hxx" +#include "DateHelper.hxx" +#include "DateScaling.hxx" #include "AxisHelper.hxx" +#include <com/sun/star/chart/TimeUnit.hpp> + #include <rtl/math.hxx> #include <tools/debug.hxx> @@ -40,6 +44,9 @@ namespace chart //............................................................................. using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; const sal_Int32 MAXIMUM_MANUAL_INCREMENT_COUNT = 500; const sal_Int32 MAXIMUM_AUTO_INCREMENT_COUNT = 10; @@ -56,7 +63,42 @@ void lcl_ensureMaximumSubIncrementCount( sal_Int32& rnSubIntervalCount ) }//end anonymous namespace -ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale ) + +//............................................................................. + +ExplicitScaleData::ExplicitScaleData() + : Minimum(0.0) + , Maximum(10.0) + , Origin(0.0) + , Orientation(::com::sun::star::chart2::AxisOrientation_MATHEMATICAL) + , Scaling() + , AxisType(::com::sun::star::chart2::AxisType::REALNUMBER) + , ShiftedCategoryPosition(false) + , TimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , NullDate(30,12,1899) +{ +} + +ExplicitSubIncrement::ExplicitSubIncrement() + : IntervalCount(2) + , PostEquidistant(true) +{ +} + + +ExplicitIncrementData::ExplicitIncrementData() + : MajorTimeInterval(1,::com::sun::star::chart::TimeUnit::DAY) + , MinorTimeInterval(1,::com::sun::star::chart::TimeUnit::DAY) + , Distance(1.0) + , PostEquidistant(true) + , BaseValue(0.0) + , SubIncrements() +{ +} + +//............................................................................. + +ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale, const Date& rNullDate ) : m_aSourceScale( rSourceScale ) , m_fValueMinimum( 0.0 ) , m_fValueMaximum( 0.0 ) @@ -65,6 +107,8 @@ ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale ) , m_bExpandIfValuesCloseToBorder( false ) , m_bExpandWideValuesToZero( false ) , m_bExpandNarrowValuesTowardZero( false ) + , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , m_aNullDate(rNullDate) { ::rtl::math::setNan( &m_fValueMinimum ); ::rtl::math::setNan( &m_fValueMaximum ); @@ -111,14 +155,19 @@ void ScaleAutomatism::setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMa m_nMaximumAutoMainIncrementCount = nMaximumAutoMainIncrementCount; } +void ScaleAutomatism::setAutomaticTimeResolution( sal_Int32 nTimeResolution ) +{ + m_nTimeResolution = nTimeResolution; +} + void ScaleAutomatism::calculateExplicitScaleAndIncrement( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement ) const { // fill explicit scale rExplicitScale.Orientation = m_aSourceScale.Orientation; rExplicitScale.Scaling = m_aSourceScale.Scaling; - rExplicitScale.Breaks = m_aSourceScale.Breaks; rExplicitScale.AxisType = m_aSourceScale.AxisType; + rExplicitScale.NullDate = m_aNullDate; bool bAutoMinimum = !(m_aSourceScale.Minimum >>= rExplicitScale.Minimum); bool bAutoMaximum = !(m_aSourceScale.Maximum >>= rExplicitScale.Maximum); @@ -130,7 +179,12 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( m_aSourceScale.AxisType==AxisType::PERCENT ) rExplicitScale.Minimum = 0.0; else if( ::rtl::math::isNan( m_fValueMinimum ) ) - rExplicitScale.Minimum = 0.0; //@todo get Minimum from scaling or from plotter???? + { + if( m_aSourceScale.AxisType==AxisType::DATE ) + rExplicitScale.Minimum = 36526.0; //1.1.2000 + else + rExplicitScale.Minimum = 0.0; //@todo get Minimum from scaling or from plotter???? + } else rExplicitScale.Minimum = m_fValueMinimum; } @@ -141,7 +195,12 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( if( m_aSourceScale.AxisType==AxisType::PERCENT ) rExplicitScale.Maximum = 1.0; else if( ::rtl::math::isNan( m_fValueMaximum ) ) - rExplicitScale.Maximum = 10.0; //@todo get Maximum from scaling or from plotter???? + { + if( m_aSourceScale.AxisType==AxisType::DATE ) + rExplicitScale.Maximum = 40179.0; //1.1.2010 + else + rExplicitScale.Maximum = 10.0; //@todo get Maximum from scaling or from plotter???? + } else rExplicitScale.Maximum = m_fValueMaximum; } @@ -149,14 +208,14 @@ void ScaleAutomatism::calculateExplicitScaleAndIncrement( //--------------------------------------------------------------- //fill explicit increment - rExplicitIncrement.ShiftedPosition = (m_aSourceScale.AxisType==AxisType::SERIES) ? true : false; + rExplicitScale.ShiftedCategoryPosition = m_aSourceScale.ShiftedCategoryPosition; bool bIsLogarithm = false; //minimum and maximum of the ExplicitScaleData may be changed if allowed - if( m_aSourceScale.AxisType==AxisType::CATEGORY || m_aSourceScale.AxisType==AxisType::SERIES ) - { + if( m_aSourceScale.AxisType==AxisType::DATE ) + calculateExplicitIncrementAndScaleForDateTimeAxis( rExplicitScale, rExplicitIncrement, bAutoMinimum, bAutoMaximum ); + else if( m_aSourceScale.AxisType==AxisType::CATEGORY || m_aSourceScale.AxisType==AxisType::SERIES ) calculateExplicitIncrementAndScaleForCategory( rExplicitScale, rExplicitIncrement, bAutoMinimum, bAutoMaximum ); - } else { bIsLogarithm = AxisHelper::isLogarithmic( rExplicitScale.Scaling ); @@ -186,6 +245,11 @@ ScaleData ScaleAutomatism::getScale() const return m_aSourceScale; } +Date ScaleAutomatism::getNullDate() const +{ + return m_aNullDate; +} + // private -------------------------------------------------------------------- void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( @@ -207,9 +271,12 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( // automatic minimum and maximum if( bAutoMinimum && m_bExpandBorderToIncrementRhythm ) - rExplicitScale.Minimum = TickmarkHelper::getMinimumAtIncrement( rExplicitScale.Minimum, rExplicitIncrement ); + rExplicitScale.Minimum = EquidistantTickFactory::getMinimumAtIncrement( rExplicitScale.Minimum, rExplicitIncrement ); if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) - rExplicitScale.Maximum = TickmarkHelper::getMaximumAtIncrement( rExplicitScale.Maximum, rExplicitIncrement ); + rExplicitScale.Maximum = EquidistantTickFactory::getMaximumAtIncrement( rExplicitScale.Maximum, rExplicitIncrement ); + + if( rExplicitScale.ShiftedCategoryPosition ) + rExplicitScale.Maximum += 1.0; //prevent performace killover double fDistanceCount = ::rtl::math::approxFloor( (rExplicitScale.Maximum-rExplicitScale.Minimum) / rExplicitIncrement.Distance ); @@ -223,29 +290,28 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN<nSubCount; nN++ ) { - const SubIncrement& rSubIncrement = m_aSourceScale.IncrementData.SubIncrements[nN]; - ExplicitSubIncrement& rExplicitSubIncrement = rExplicitIncrement.SubIncrements[nN]; - - if(!(rSubIncrement.IntervalCount>>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement= m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 2; + aExplicitSubIncrement.IntervalCount = 2; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } -//@todo these method should become part of the scaling interface and implementation somehow -//@todo problem with outparamters at api +//----------------------------------------------------------------------------------------- + void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement, @@ -412,7 +478,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( // round to entire multiples of the distance and add additional space if( bAutoMinimum && m_bExpandBorderToIncrementRhythm ) { - fAxisMinimum = TickmarkHelper::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); + fAxisMinimum = EquidistantTickFactory::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); //ensure valid values after scaling #i100995# if( !bAutoDistance ) @@ -428,7 +494,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( } if( bAutoMaximum && m_bExpandBorderToIncrementRhythm ) { - fAxisMaximum = TickmarkHelper::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); + fAxisMaximum = EquidistantTickFactory::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); //ensure valid values after scaling #i100995# if( !bAutoDistance ) @@ -488,27 +554,204 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN<nSubCount; nN++ ) { - const SubIncrement& rSubIncrement = m_aSourceScale.IncrementData.SubIncrements[nN]; - ExplicitSubIncrement& rExplicitSubIncrement = rExplicitIncrement.SubIncrements[nN]; - - if(!(rSubIncrement.IntervalCount>>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement = m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 9; + aExplicitSubIncrement.IntervalCount = 9; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } +//----------------------------------------------------------------------------------------- + +void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const +{ + Date aMinDate(m_aNullDate); aMinDate += static_cast<long>(::rtl::math::approxFloor(rExplicitScale.Minimum)); + Date aMaxDate(m_aNullDate); aMaxDate += static_cast<long>(::rtl::math::approxFloor(rExplicitScale.Maximum)); + rExplicitIncrement.PostEquidistant = sal_False; + + if( aMinDate > aMaxDate ) + { + std::swap(aMinDate,aMaxDate); + } + + if( !(m_aSourceScale.TimeIncrement.TimeResolution >>= rExplicitScale.TimeResolution) ) + rExplicitScale.TimeResolution = m_nTimeResolution; + + rExplicitScale.Scaling = new DateScaling(m_aNullDate,rExplicitScale.TimeResolution,false); + + // choose min and max suitable to time resolution + switch( rExplicitScale.TimeResolution ) + { + case DAY: + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate++;//for explicit scales we need one interval more (maximum excluded) + break; + case MONTH: + aMinDate.SetDay(1); + aMaxDate.SetDay(1); + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,1);//for explicit scales we need one interval more (maximum excluded) + if( DateHelper::IsLessThanOneMonthAway( aMinDate, aMaxDate ) ) + { + if( bAutoMaximum || !bAutoMinimum ) + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMinDate,1); + else + aMinDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + } + break; + case YEAR: + aMinDate.SetDay(1); + aMinDate.SetMonth(1); + aMaxDate.SetDay(1); + aMaxDate.SetMonth(1); + if( rExplicitScale.ShiftedCategoryPosition ) + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,1);//for explicit scales we need one interval more (maximum excluded) + if( DateHelper::IsLessThanOneYearAway( aMinDate, aMaxDate ) ) + { + if( bAutoMaximum || !bAutoMinimum ) + aMaxDate = DateHelper::GetDateSomeYearsAway(aMinDate,1); + else + aMinDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + } + break; + } + + // set the resulting limits (swap back to negative range if needed) + rExplicitScale.Minimum = aMinDate - m_aNullDate; + rExplicitScale.Maximum = aMaxDate - m_aNullDate; + + bool bAutoMajor = !(m_aSourceScale.TimeIncrement.MajorTimeInterval >>= rExplicitIncrement.MajorTimeInterval); + bool bAutoMinor = !(m_aSourceScale.TimeIncrement.MinorTimeInterval >>= rExplicitIncrement.MinorTimeInterval); + + sal_Int32 nMaxMainIncrementCount = bAutoMajor ? + m_nMaximumAutoMainIncrementCount : MAXIMUM_MANUAL_INCREMENT_COUNT; + if( nMaxMainIncrementCount > 1 ) + nMaxMainIncrementCount--; + + + //choose major time interval: + long nDayCount = (aMaxDate-aMinDate); + long nMainIncrementCount = 1; + if( !bAutoMajor ) + { + long nIntervalDayCount = rExplicitIncrement.MajorTimeInterval.Number; + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + nIntervalDayCount*=31;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + case YEAR: + nIntervalDayCount*=365;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + } + nMainIncrementCount = nDayCount/nIntervalDayCount; + if( nMainIncrementCount > nMaxMainIncrementCount ) + bAutoMajor = true; + } + if( bAutoMajor ) + { + long nNumer = 1; + long nIntervalDays = nDayCount / nMaxMainIncrementCount; + double nDaysPerInterval = 1.0; + if( nIntervalDays>365 ) + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = YEAR; + nDaysPerInterval = 365.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + } + else if( nIntervalDays>31 ) + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = MONTH; + nDaysPerInterval = 31.0;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + } + else + { + rExplicitIncrement.MajorTimeInterval.TimeUnit = DAY; + nDaysPerInterval = 1.0; + } + + nNumer = static_cast<sal_Int32>( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) ); + if(nNumer<=0) + nNumer=1; + rExplicitIncrement.MajorTimeInterval.Number = nNumer; + nMainIncrementCount = nDayCount/(nNumer*nDaysPerInterval); + } + + //choose minor time interval: + if( !bAutoMinor ) + { + long nIntervalDayCount = rExplicitIncrement.MinorTimeInterval.Number; + switch( rExplicitIncrement.MinorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + nIntervalDayCount*=31;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + case YEAR: + nIntervalDayCount*=365;//todo: maybe different for other calendars... get localized calendar according to set number format at axis ... + break; + } + if( nDayCount/nIntervalDayCount > nMaxMainIncrementCount ) + bAutoMinor = true; + } + if( bAutoMinor ) + { + rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; + rExplicitIncrement.MinorTimeInterval.Number = 1; + if( nMainIncrementCount > 100 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + else + { + if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + { + if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; + else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + } + else + { + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + break; + case MONTH: + rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; + break; + case YEAR: + rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; + break; + } + } + } + } + +} + +//----------------------------------------------------------------------------------------- + void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( ExplicitScaleData& rExplicitScale, ExplicitIncrementData& rExplicitIncrement, @@ -692,7 +935,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( { // round to entire multiples of the distance, based on the base value if( m_bExpandBorderToIncrementRhythm ) - fAxisMinimum = TickmarkHelper::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); + fAxisMinimum = EquidistantTickFactory::getMinimumAtIncrement( fAxisMinimum, rExplicitIncrement ); // additional space, if source minimum is to near at axis minimum if( m_bExpandIfValuesCloseToBorder ) if( (fAxisMinimum != 0.0) && ((fAxisMaximum - fSourceMinimum) / (fAxisMaximum - fAxisMinimum) > 20.0 / 21.0) ) @@ -702,7 +945,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( { // round to entire multiples of the distance, based on the base value if( m_bExpandBorderToIncrementRhythm ) - fAxisMaximum = TickmarkHelper::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); + fAxisMaximum = EquidistantTickFactory::getMaximumAtIncrement( fAxisMaximum, rExplicitIncrement ); // additional space, if source maximum is to near at axis maximum if( m_bExpandIfValuesCloseToBorder ) if( (fAxisMaximum != 0.0) && ((fSourceMaximum - fAxisMinimum) / (fAxisMaximum - fAxisMinimum) > 20.0 / 21.0) ) @@ -734,24 +977,23 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear( //--------------------------------------------------------------- //fill explicit sub increment sal_Int32 nSubCount = m_aSourceScale.IncrementData.SubIncrements.getLength(); - rExplicitIncrement.SubIncrements.realloc(nSubCount); for( sal_Int32 nN=0; nN<nSubCount; nN++ ) { - const SubIncrement& rSubIncrement = m_aSourceScale.IncrementData.SubIncrements[nN]; - ExplicitSubIncrement& rExplicitSubIncrement = rExplicitIncrement.SubIncrements[nN]; - - if(!(rSubIncrement.IntervalCount>>=rExplicitSubIncrement.IntervalCount)) + ExplicitSubIncrement aExplicitSubIncrement; + const SubIncrement& rSubIncrement= m_aSourceScale.IncrementData.SubIncrements[nN]; + if(!(rSubIncrement.IntervalCount>>=aExplicitSubIncrement.IntervalCount)) { //scaling dependent //@todo autocalculate IntervalCount dependent on MainIncrement and scaling - rExplicitSubIncrement.IntervalCount = 2; + aExplicitSubIncrement.IntervalCount = 2; } - lcl_ensureMaximumSubIncrementCount( rExplicitSubIncrement.IntervalCount ); - if(!(rSubIncrement.PostEquidistant>>=rExplicitSubIncrement.PostEquidistant)) + lcl_ensureMaximumSubIncrementCount( aExplicitSubIncrement.IntervalCount ); + if(!(rSubIncrement.PostEquidistant>>=aExplicitSubIncrement.PostEquidistant)) { //scaling dependent - rExplicitSubIncrement.PostEquidistant = sal_False; + aExplicitSubIncrement.PostEquidistant = sal_False; } + rExplicitIncrement.SubIncrements.push_back(aExplicitSubIncrement); } } diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx new file mode 100644 index 000000000000..c5e198acea3f --- /dev/null +++ b/chart2/source/view/axes/Tickmarks.cxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * 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_chart2.hxx" +#include "Tickmarks.hxx" +#include "Tickmarks_Equidistant.hxx" +#include "Tickmarks_Dates.hxx" +#include "ViewDefines.hxx" +#include <rtl/math.hxx> +#include <tools/debug.hxx> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; + +TickInfo::TickInfo( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling >& xInverseScaling ) +: fScaledTickValue( 0.0 ) +, xInverseScaling( xInverseScaling ) +, aTickScreenPosition(0.0,0.0) +, bPaintIt( true ) +, xTextShape( NULL ) +, nFactorForLimitedTextWidth(1) +{ +} + +double TickInfo::getUnscaledTickValue() const +{ + if( xInverseScaling.is() ) + return xInverseScaling->doScaling( fScaledTickValue ); + else + return fScaledTickValue; +} + +sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const +{ + //return the positive distance between the two first tickmarks in screen values + + B2DVector aDistance = rOherTickInfo.aTickScreenPosition - aTickScreenPosition; + sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength()); + if(nRet<0) + nRet *= -1; + return nRet; +} + +PureTickIter::PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ) + : m_rTickVector(rTickInfoVector) + , m_aTickIter(m_rTickVector.begin()) +{ +} +PureTickIter::~PureTickIter() +{ +} +TickInfo* PureTickIter::firstInfo() +{ + m_aTickIter = m_rTickVector.begin(); + if(m_aTickIter!=m_rTickVector.end()) + return &*m_aTickIter; + return 0; +} +TickInfo* PureTickIter::nextInfo() +{ + if(m_aTickIter!=m_rTickVector.end()) + { + m_aTickIter++; + if(m_aTickIter!=m_rTickVector.end()) + return &*m_aTickIter; + } + return 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +TickFactory::TickFactory( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : m_rScale( rScale ) + , m_rIncrement( rIncrement ) + , m_xInverseScaling(NULL) +{ + //@todo: make sure that the scale is valid for the scaling + + if( m_rScale.Scaling.is() ) + { + m_xInverseScaling = m_rScale.Scaling->getInverseScaling(); + DBG_ASSERT( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" ); + } + + m_fScaledVisibleMin = m_rScale.Minimum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMin = m_rScale.Scaling->doScaling(m_fScaledVisibleMin); + + m_fScaledVisibleMax = m_rScale.Maximum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMax = m_rScale.Scaling->doScaling(m_fScaledVisibleMax); +} + +TickFactory::~TickFactory() +{ +} + +bool TickFactory::isDateAxis() const +{ + return m_rScale.AxisType == AxisType::DATE; +} + +void TickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + if( isDateAxis() ) + DateTickFactory( m_rScale, m_rIncrement ).getAllTicks( rAllTickInfos ); + else + EquidistantTickFactory( m_rScale, m_rIncrement ).getAllTicks( rAllTickInfos ); +} + +void TickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + if( isDateAxis() ) + DateTickFactory( m_rScale, m_rIncrement ).getAllTicksShifted( rAllTickInfos ); + else + EquidistantTickFactory( m_rScale, m_rIncrement ).getAllTicksShifted( rAllTickInfos ); +} + +//----------------------------------------------------------------------------- +// ___TickFactory_2D___ +//----------------------------------------------------------------------------- +TickFactory_2D::TickFactory_2D( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement + //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ) + , const B2DVector& rStartScreenPos, const B2DVector& rEndScreenPos + , const B2DVector& rAxisLineToLabelLineShift ) + : TickFactory( rScale, rIncrement ) + , m_aAxisStartScreenPosition2D(rStartScreenPos) + , m_aAxisEndScreenPosition2D(rEndScreenPos) + , m_aAxisLineToLabelLineShift(rAxisLineToLabelLineShift) + , m_fStrech_LogicToScreen(1.0) + , m_fOffset_LogicToScreen(0.0) +{ + double fWidthY = m_fScaledVisibleMax - m_fScaledVisibleMin; + if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation ) + { + m_fStrech_LogicToScreen = 1.0/fWidthY; + m_fOffset_LogicToScreen = -m_fScaledVisibleMin; + } + else + { + B2DVector aSwap(m_aAxisStartScreenPosition2D); + m_aAxisStartScreenPosition2D = m_aAxisEndScreenPosition2D; + m_aAxisEndScreenPosition2D = aSwap; + + m_fStrech_LogicToScreen = -1.0/fWidthY; + m_fOffset_LogicToScreen = -m_fScaledVisibleMax; + } +} + +TickFactory_2D::~TickFactory_2D() +{ +} + +bool TickFactory_2D::isHorizontalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() ); +} +bool TickFactory_2D::isVerticalAxis() const +{ + return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() ); +} + +//static +sal_Int32 TickFactory_2D::getTickScreenDistance( TickIter& rIter ) +{ + //return the positive distance between the two first tickmarks in screen values + //if there are less than two tickmarks -1 is returned + + const TickInfo* pFirstTickInfo = rIter.firstInfo(); + const TickInfo* pSecondTickInfo = rIter.nextInfo(); + if(!pSecondTickInfo || !pFirstTickInfo) + return -1; + + return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo ); +} + +B2DVector TickFactory_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const +{ + B2DVector aRet(m_aAxisStartScreenPosition2D); + aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D) + *((fScaledLogicTickValue+m_fOffset_LogicToScreen)*m_fStrech_LogicToScreen); + return aRet; +} + +void TickFactory_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints + , sal_Int32 nSequenceIndex + , double fScaledLogicTickValue, double fInnerDirectionSign + , const TickmarkProperties& rTickmarkProperties + , bool bPlaceAtLabels ) const +{ + if( fInnerDirectionSign==0.0 ) + fInnerDirectionSign = 1.0; + + B2DVector aTickScreenPosition = this->getTickScreenPosition2D(fScaledLogicTickValue); + if( bPlaceAtLabels ) + aTickScreenPosition += m_aAxisLineToLabelLineShift; + + B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; + aMainDirection.normalize(); + B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); + aOrthoDirection *= fInnerDirectionSign; + aOrthoDirection.normalize(); + + B2DVector aStart = aTickScreenPosition + aOrthoDirection*rTickmarkProperties.RelativePos; + B2DVector aEnd = aStart - aOrthoDirection*rTickmarkProperties.Length; + + rPoints[nSequenceIndex].realloc(2); + rPoints[nSequenceIndex][0].X = static_cast<sal_Int32>(aStart.getX()); + rPoints[nSequenceIndex][0].Y = static_cast<sal_Int32>(aStart.getY()); + rPoints[nSequenceIndex][1].X = static_cast<sal_Int32>(aEnd.getX()); + rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY()); +} + +B2DVector TickFactory_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const +{ + bool bFarAwayLabels = false; + if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos + || ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == rAxisProperties.m_eLabelPos ) + bFarAwayLabels = true; + + double fInnerDirectionSign = rAxisProperties.m_fInnerDirectionSign; + if( fInnerDirectionSign==0.0 ) + fInnerDirectionSign = 1.0; + + B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; + aMainDirection.normalize(); + B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); + aOrthoDirection *= fInnerDirectionSign; + aOrthoDirection.normalize(); + + B2DVector aStart(0,0), aEnd(0,0); + if( bFarAwayLabels ) + { + TickmarkProperties aProps( AxisProperties::getBiggestTickmarkProperties() ); + aStart = aOrthoDirection*aProps.RelativePos; + aEnd = aStart - aOrthoDirection*aProps.Length; + } + else + { + for( sal_Int32 nN=rAxisProperties.m_aTickmarkPropertiesList.size();nN--;) + { + const TickmarkProperties& rProps = rAxisProperties.m_aTickmarkPropertiesList[nN]; + B2DVector aNewStart = aOrthoDirection*rProps.RelativePos; + B2DVector aNewEnd = aNewStart - aOrthoDirection*rProps.Length; + if(aNewStart.getLength()>aStart.getLength()) + aStart=aNewStart; + if(aNewEnd.getLength()>aEnd.getLength()) + aEnd=aNewEnd; + } + } + + B2DVector aLabelDirection(aStart); + if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) + aLabelDirection = aEnd; + + B2DVector aOrthoLabelDirection(aOrthoDirection); + if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) + aOrthoLabelDirection*=-1.0; + aOrthoLabelDirection.normalize(); + if( bIncludeSpaceBetweenTickAndText ) + aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING; + if( bFarAwayLabels && bIncludeFarAwayDistanceIfSo ) + aLabelDirection += m_aAxisLineToLabelLineShift; + return aLabelDirection; +} + +void TickFactory_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const +{ + rPoints[0].realloc(2); + rPoints[0][0].X = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getX()); + rPoints[0][0].Y = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getY()); + rPoints[0][1].X = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getX()); + rPoints[0][1].Y = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getY()); +} + +void TickFactory_2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + //get the transformed screen values for all tickmarks in rAllTickInfos + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); + for( ; aDepthIter != aDepthEnd; aDepthIter++ ) + { + ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + TickInfo& rTickInfo = (*aTickIter); + rTickInfo.aTickScreenPosition = + this->getTickScreenPosition2D( rTickInfo.fScaledTickValue ); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/Tickmarks.hxx b/chart2/source/view/axes/Tickmarks.hxx new file mode 100644 index 000000000000..62fa5fef92d0 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * 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 _CHART2_TICKMARKS_HXX +#define _CHART2_TICKMARKS_HXX + +#include "TickmarkProperties.hxx" +#include "VAxisProperties.hxx" +#include "chartview/ExplicitScaleValues.hxx" +#include <basegfx/vector/b2dvector.hxx> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/uno/Sequence.h> + +#include <vector> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using ::basegfx::B2DVector; +//----------------------------------------------------------------------------- +/** +*/ + +struct TickInfo +{ + double fScaledTickValue; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling > xInverseScaling; + + ::basegfx::B2DVector aTickScreenPosition; + bool bPaintIt; + + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > xTextShape; + + rtl::OUString aText;//used only for complex categories so far + sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category + +//methods: + TickInfo( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XScaling >& xInverseScaling ); + + double getUnscaledTickValue() const; + sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; +private: + TickInfo(); +}; +class TickIter +{ +public: + virtual ~TickIter(){}; + virtual TickInfo* firstInfo()=0; + virtual TickInfo* nextInfo()=0; +}; + +class PureTickIter : public TickIter +{ +public: + PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); + virtual ~PureTickIter(); + virtual TickInfo* firstInfo(); + virtual TickInfo* nextInfo(); + +private: + ::std::vector< TickInfo >& m_rTickVector; + ::std::vector< TickInfo >::iterator m_aTickIter; +}; + +class TickFactory +{ +public: + TickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + virtual ~TickFactory(); + + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} + +private: //methods + bool isDateAxis() const; + +protected: //member + ExplicitScaleData m_rScale; + ExplicitIncrementData m_rIncrement; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > + m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; +}; + +class TickFactory_2D : public TickFactory +{ +public: + TickFactory_2D( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement + , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos + , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); + //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); + virtual ~TickFactory_2D(); + + static sal_Int32 getTickScreenDistance( TickIter& rIter ); + + void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; + void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints + , sal_Int32 nSequenceIndex + , double fScaledLogicTickValue, double fInnerDirectionSign + , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; + ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties + , bool bIncludeFarAwayDistanceIfSo = false + , bool bIncludeSpaceBetweenTickAndText = true ) const; + + virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + + bool isHorizontalAxis() const; + bool isVerticalAxis() const; + +protected: //methods + ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; + +private: //member + ::basegfx::B2DVector m_aAxisStartScreenPosition2D; + ::basegfx::B2DVector m_aAxisEndScreenPosition2D; + + //labels might be posioned high or low on the border of the diagram far away from the axis + //add this vector to go from the axis line to the label line (border of the diagram) + ::basegfx::B2DVector m_aAxisLineToLabelLineShift; + + double m_fStrech_LogicToScreen; + double m_fOffset_LogicToScreen; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/Tickmarks_Dates.cxx b/chart2/source/view/axes/Tickmarks_Dates.cxx new file mode 100644 index 000000000000..b5177fe307b8 --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Dates.cxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * 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_chart2.hxx" +#include "Tickmarks_Dates.hxx" +#include "DateScaling.hxx" +#include <rtl/math.hxx> +#include <tools/debug.hxx> +#include "DateHelper.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::rtl::math; +using ::basegfx::B2DVector; +using ::com::sun::star::chart::TimeUnit::DAY; +using ::com::sun::star::chart::TimeUnit::MONTH; +using ::com::sun::star::chart::TimeUnit::YEAR; + +DateTickFactory::DateTickFactory( + const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) + : m_aScale( rScale ) + , m_aIncrement( rIncrement ) + , m_xInverseScaling(NULL) +{ + //@todo: make sure that the scale is valid for the scaling + + if( m_aScale.Scaling.is() ) + { + m_xInverseScaling = m_aScale.Scaling->getInverseScaling(); + DBG_ASSERT( m_xInverseScaling.is(), "each Scaling needs to return a inverse Scaling" ); + } + + m_fScaledVisibleMin = m_aScale.Minimum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMin = m_aScale.Scaling->doScaling(m_fScaledVisibleMin); + + m_fScaledVisibleMax = m_aScale.Maximum; + if( m_xInverseScaling.is() ) + m_fScaledVisibleMax = m_aScale.Scaling->doScaling(m_fScaledVisibleMax); +} + +DateTickFactory::~DateTickFactory() +{ +} + +void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShifted ) const +{ + rAllTickInfos.resize(2); + ::std::vector< TickInfo >& rMajorTicks = rAllTickInfos[0]; + ::std::vector< TickInfo >& rMinorTicks = rAllTickInfos[1]; + rMajorTicks.clear(); + rMinorTicks.clear(); + + Date aNull(m_aScale.NullDate); + + Date aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); + Date aMaxDate = aNull + ::rtl::math::approxFloor(m_aScale.Maximum); + + uno::Reference< chart2::XScaling > xScaling(m_aScale.Scaling); + uno::Reference< chart2::XScaling > xInverseScaling(m_xInverseScaling); + if( bShifted ) + { + xScaling = new DateScaling(aNull,m_aScale.TimeResolution,true/*bShifted*/); + xInverseScaling = xScaling->getInverseScaling(); + } + + //create major date tickinfos + while( aDate<= aMaxDate ) + { + if( bShifted && aDate==aMaxDate ) + break; + + TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull; + + if( xInverseScaling.is() ) + aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue); + rMajorTicks.push_back( aNewTick ); + + if(m_aIncrement.MajorTimeInterval.Number<=0) + break; + + //find next major date + switch( m_aIncrement.MajorTimeInterval.TimeUnit ) + { + case DAY: + aDate += m_aIncrement.MajorTimeInterval.Number; + break; + case YEAR: + aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MajorTimeInterval.Number ); + break; + case MONTH: + default: + aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MajorTimeInterval.Number ); + break; + } + } + + //create minor date tickinfos + aDate = aNull + ::rtl::math::approxFloor(m_aScale.Minimum); + while( aDate<= aMaxDate ) + { + if( bShifted && aDate==aMaxDate ) + break; + + TickInfo aNewTick(xInverseScaling); aNewTick.fScaledTickValue = aDate - aNull; + if( xInverseScaling.is() ) + aNewTick.fScaledTickValue = xScaling->doScaling(aNewTick.fScaledTickValue); + rMinorTicks.push_back( aNewTick ); + + if(m_aIncrement.MinorTimeInterval.Number<=0) + break; + + //find next minor date + switch( m_aIncrement.MinorTimeInterval.TimeUnit ) + { + case DAY: + aDate += m_aIncrement.MinorTimeInterval.Number; + break; + case YEAR: + aDate = DateHelper::GetDateSomeYearsAway( aDate, m_aIncrement.MinorTimeInterval.Number ); + break; + case MONTH: + default: + aDate = DateHelper::GetDateSomeMonthsAway( aDate, m_aIncrement.MinorTimeInterval.Number ); + break; + } + } +} + +void DateTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + getAllTicks( rAllTickInfos, false ); +} + +void DateTickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + getAllTicks( rAllTickInfos, true ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/Tickmarks_Dates.hxx b/chart2/source/view/axes/Tickmarks_Dates.hxx new file mode 100644 index 000000000000..464e8b4ca24c --- /dev/null +++ b/chart2/source/view/axes/Tickmarks_Dates.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * 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 _CHART2_TICKMARKS_DATES_HXX +#define _CHART2_TICKMARKS_DATES_HXX + +#include "Tickmarks.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class DateTickFactory +{ +public: + DateTickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + ~DateTickFactory(); + + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + +private: //methods + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShifted ) const; + +private: //member + ExplicitScaleData m_aScale; + ExplicitIncrementData m_aIncrement; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > + m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index 9e2e2707c035..9344af1ffac9 100644 --- a/chart2/source/view/axes/TickmarkHelper.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -27,7 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks_Equidistant.hxx" #include "ViewDefines.hxx" #include <rtl/math.hxx> #include <tools/debug.hxx> @@ -42,305 +42,8 @@ using namespace ::com::sun::star::chart2; using namespace ::rtl::math; using ::basegfx::B2DVector; -TickInfo::TickInfo() -: fScaledTickValue( 0.0 ) -, fUnscaledTickValue( 0.0 ) -, aTickScreenPosition(0.0,0.0) -, bPaintIt( true ) -, xTextShape( NULL ) -, nFactorForLimitedTextWidth(1) -{ -} - -void TickInfo::updateUnscaledValue( const uno::Reference< XScaling >& xInverseScaling ) -{ - if( xInverseScaling.is() ) - this->fUnscaledTickValue = xInverseScaling->doScaling( this->fScaledTickValue ); - else - this->fUnscaledTickValue = this->fScaledTickValue; -} - -sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const -{ - //return the positive distance between the two first tickmarks in screen values - - B2DVector aDistance = rOherTickInfo.aTickScreenPosition - aTickScreenPosition; - sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength()); - if(nRet<0) - nRet *= -1; - return nRet; -} - -PureTickIter::PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ) - : m_rTickVector(rTickInfoVector) - , m_aTickIter(m_rTickVector.begin()) -{ -} -PureTickIter::~PureTickIter() -{ -} -TickInfo* PureTickIter::firstInfo() -{ - m_aTickIter = m_rTickVector.begin(); - if(m_aTickIter!=m_rTickVector.end()) - return &*m_aTickIter; - return 0; -} -TickInfo* PureTickIter::nextInfo() -{ - m_aTickIter++; - if(m_aTickIter!=m_rTickVector.end()) - return &*m_aTickIter; - return 0; -} - -EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks - , const ExplicitIncrementData& rIncrement - , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) - : m_pSimpleTicks(&rTicks) - , m_pInfoTicks(0) - , m_rIncrement(rIncrement) - , m_nMinDepth(0), m_nMaxDepth(0) - , m_nTickCount(0), m_pnPositions(NULL) - , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) - , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) -{ - initIter( nMinDepth, nMaxDepth ); -} - -EquidistantTickIter::EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks - , const ExplicitIncrementData& rIncrement - , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) - : m_pSimpleTicks(NULL) - , m_pInfoTicks(&rTicks) - , m_rIncrement(rIncrement) - , m_nMinDepth(0), m_nMaxDepth(0) - , m_nTickCount(0), m_pnPositions(NULL) - , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) - , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) -{ - initIter( nMinDepth, nMaxDepth ); -} - -void EquidistantTickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth ) -{ - m_nMaxDepth = nMaxDepth; - if(nMaxDepth<0 || m_nMaxDepth>getMaxDepth()) - m_nMaxDepth=getMaxDepth(); - - sal_Int32 nDepth = 0; - for( nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) - m_nTickCount += getTickCount(nDepth); - - if(!m_nTickCount) - return; - - m_pnPositions = new sal_Int32[m_nMaxDepth+1]; - - m_pnPreParentCount = new sal_Int32[m_nMaxDepth+1]; - m_pbIntervalFinished = new bool[m_nMaxDepth+1]; - m_pnPreParentCount[0] = 0; - m_pbIntervalFinished[0] = false; - double fParentValue = getTickValue(0,0); - for( nDepth = 1; nDepth<=m_nMaxDepth ;nDepth++ ) - { - m_pbIntervalFinished[nDepth] = false; - - sal_Int32 nPreParentCount = 0; - sal_Int32 nCount = getTickCount(nDepth); - for(sal_Int32 nN = 0; nN<nCount; nN++) - { - if(getTickValue(nDepth,nN) < fParentValue) - nPreParentCount++; - else - break; - } - m_pnPreParentCount[nDepth] = nPreParentCount; - if(nCount) - { - double fNextParentValue = getTickValue(nDepth,0); - if( fNextParentValue < fParentValue ) - fParentValue = fNextParentValue; - } - } -} - -EquidistantTickIter::~EquidistantTickIter() -{ - delete[] m_pnPositions; - delete[] m_pnPreParentCount; - delete[] m_pbIntervalFinished; -} - -sal_Int32 EquidistantTickIter::getStartDepth() const -{ - //find the depth of the first visible tickmark: - //it is the depth of the smallest value - sal_Int32 nReturnDepth=0; - double fMinValue = DBL_MAX; - for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) - { - sal_Int32 nCount = getTickCount(nDepth); - if( !nCount ) - continue; - double fThisValue = getTickValue(nDepth,0); - if(fThisValue<fMinValue) - { - nReturnDepth = nDepth; - fMinValue = fThisValue; - } - } - return nReturnDepth; -} - -double* EquidistantTickIter::firstValue() -{ - if( gotoFirst() ) - { - m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); - return &m_fCurrentValue; - } - return NULL; -} - -TickInfo* EquidistantTickIter::firstInfo() -{ - if( m_pInfoTicks && gotoFirst() ) - return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; - return NULL; -} - -sal_Int32 EquidistantTickIter::getIntervalCount( sal_Int32 nDepth ) -{ - if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<0) - return 0; - - if(!nDepth) - return m_nTickCount; - - return m_rIncrement.SubIncrements[nDepth-1].IntervalCount; -} - -bool EquidistantTickIter::isAtLastPartTick() -{ - if(!m_nCurrentDepth) - return false; - sal_Int32 nIntervalCount = getIntervalCount( m_nCurrentDepth ); - if(!nIntervalCount || nIntervalCount == 1) - return true; - if( m_pbIntervalFinished[m_nCurrentDepth] ) - return false; - sal_Int32 nPos = m_pnPositions[m_nCurrentDepth]+1; - if(m_pnPreParentCount[m_nCurrentDepth]) - nPos += nIntervalCount-1 - m_pnPreParentCount[m_nCurrentDepth]; - bool bRet = nPos && nPos % (nIntervalCount-1) == 0; - if(!nPos && !m_pnPreParentCount[m_nCurrentDepth] - && m_pnPositions[m_nCurrentDepth-1]==-1 ) - bRet = true; - return bRet; -} - -bool EquidistantTickIter::gotoFirst() -{ - if( m_nMaxDepth<0 ) - return false; - if( !m_nTickCount ) - return false; - - for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) - m_pnPositions[nDepth] = -1; - - m_nCurrentPos = 0; - m_nCurrentDepth = getStartDepth(); - m_pnPositions[m_nCurrentDepth] = 0; - return true; -} - -bool EquidistantTickIter::gotoNext() -{ - if( m_nCurrentPos < 0 ) - return false; - m_nCurrentPos++; - - if( m_nCurrentPos >= m_nTickCount ) - return false; - - if( m_nCurrentDepth==m_nMaxDepth && isAtLastPartTick() ) - { - do - { - m_pbIntervalFinished[m_nCurrentDepth] = true; - m_nCurrentDepth--; - } - while( m_nCurrentDepth && isAtLastPartTick() ); - } - else if( m_nCurrentDepth<m_nMaxDepth ) - { - do - { - m_nCurrentDepth++; - } - while( m_nCurrentDepth<m_nMaxDepth ); - } - m_pbIntervalFinished[m_nCurrentDepth] = false; - m_pnPositions[m_nCurrentDepth] = m_pnPositions[m_nCurrentDepth]+1; - return true; -} - -bool EquidistantTickIter::gotoIndex( sal_Int32 nTickIndex ) -{ - if( nTickIndex < 0 ) - return false; - if( nTickIndex >= m_nTickCount ) - return false; - - if( nTickIndex < m_nCurrentPos ) - if( !gotoFirst() ) - return false; - - while( nTickIndex > m_nCurrentPos ) - if( !gotoNext() ) - return false; - - return true; -} - -sal_Int32 EquidistantTickIter::getCurrentIndex() const -{ - return m_nCurrentPos; -} -sal_Int32 EquidistantTickIter::getMaxIndex() const -{ - return m_nTickCount-1; -} - -double* EquidistantTickIter::nextValue() -{ - if( gotoNext() ) - { - m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); - return &m_fCurrentValue; - } - return NULL; -} - -TickInfo* EquidistantTickIter::nextInfo() -{ - if( m_pInfoTicks && gotoNext() && - static_cast< sal_Int32 >( - (*m_pInfoTicks)[m_nCurrentDepth].size()) > m_pnPositions[m_nCurrentDepth] ) - { - return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; - } - return NULL; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - //static -double TickmarkHelper::getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ) +double EquidistantTickFactory::getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ) { //the returned value will be <= fMin and on a Major Tick given by rIncrement if(rIncrement.Distance<=0.0) @@ -359,7 +62,7 @@ double TickmarkHelper::getMinimumAtIncrement( double fMin, const ExplicitIncreme return fRet; } //static -double TickmarkHelper::getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ) +double EquidistantTickFactory::getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ) { //the returned value will be >= fMax and on a Major Tick given by rIncrement if(rIncrement.Distance<=0.0) @@ -378,11 +81,7 @@ double TickmarkHelper::getMaximumAtIncrement( double fMax, const ExplicitIncreme return fRet; } -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -TickmarkHelper::TickmarkHelper( +EquidistantTickFactory::EquidistantTickFactory( const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) : m_rScale( rScale ) , m_rIncrement( rIncrement ) @@ -416,8 +115,8 @@ TickmarkHelper::TickmarkHelper( } //-- - m_fOuterMajorTickBorderMin = TickmarkHelper::getMinimumAtIncrement( fMin, m_rIncrement ); - m_fOuterMajorTickBorderMax = TickmarkHelper::getMaximumAtIncrement( fMax, m_rIncrement ); + m_fOuterMajorTickBorderMin = EquidistantTickFactory::getMinimumAtIncrement( fMin, m_rIncrement ); + m_fOuterMajorTickBorderMax = EquidistantTickFactory::getMaximumAtIncrement( fMax, m_rIncrement ); //-- m_fOuterMajorTickBorderMin_Scaled = m_fOuterMajorTickBorderMin; @@ -442,24 +141,58 @@ TickmarkHelper::TickmarkHelper( } } -TickmarkHelper* TickmarkHelper::createShiftedTickmarkHelper() const +EquidistantTickFactory::~EquidistantTickFactory() { - ExplicitIncrementData aShiftedIncrement( m_rIncrement ); - aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; - return new TickmarkHelper( m_rScale, aShiftedIncrement ); + delete[] m_pfCurrentValues; } -TickmarkHelper::~TickmarkHelper() +sal_Int32 EquidistantTickFactory::getTickDepth() const { - delete[] m_pfCurrentValues; + return static_cast<sal_Int32>(m_rIncrement.SubIncrements.size()) + 1; } -sal_Int32 TickmarkHelper::getTickDepth() const +void EquidistantTickFactory::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence< double > >& rParentTicks ) const { - return m_rIncrement.SubIncrements.getLength() + 1; + EquidistantTickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 ); + double* pfNextParentTick = aIter.firstValue(); + if(!pfNextParentTick) + return; + double fLastParentTick = *pfNextParentTick; + pfNextParentTick = aIter.nextValue(); + if(!pfNextParentTick) + return; + + sal_Int32 nMaxSubTickCount = this->getMaxTickCount( nDepth ); + if(!nMaxSubTickCount) + return; + + uno::Sequence< double > aSubTicks(nMaxSubTickCount); + sal_Int32 nRealSubTickCount = 0; + sal_Int32 nIntervalCount = m_rIncrement.SubIncrements[nDepth-1].IntervalCount; + + double* pValue = NULL; + for(; pfNextParentTick; fLastParentTick=*pfNextParentTick, pfNextParentTick = aIter.nextValue()) + { + for( sal_Int32 nPartTick = 1; nPartTick<nIntervalCount; nPartTick++ ) + { + pValue = this->getMinorTick( nPartTick, nDepth + , fLastParentTick, *pfNextParentTick ); + if(!pValue) + continue; + + aSubTicks[nRealSubTickCount] = *pValue; + nRealSubTickCount++; + } + } + + aSubTicks.realloc(nRealSubTickCount); + rParentTicks[nDepth] = aSubTicks; + if(static_cast<sal_Int32>(m_rIncrement.SubIncrements.size())>nDepth) + addSubTicks( nDepth+1, rParentTicks ); } -sal_Int32 TickmarkHelper::getMaxTickCount( sal_Int32 nDepth ) const + +sal_Int32 EquidistantTickFactory::getMaxTickCount( sal_Int32 nDepth ) const { //return the maximum amount of ticks //possibly open intervals at the two ends of the region are handled as if they were completely visible @@ -497,7 +230,7 @@ sal_Int32 TickmarkHelper::getMaxTickCount( sal_Int32 nDepth ) const return nTickCount; } -double* TickmarkHelper::getMajorTick( sal_Int32 nTick ) const +double* EquidistantTickFactory::getMajorTick( sal_Int32 nTick ) const { m_pfCurrentValues[0] = m_fOuterMajorTickBorderMin + nTick*m_rIncrement.Distance; @@ -519,7 +252,7 @@ double* TickmarkHelper::getMajorTick( sal_Int32 nTick ) const return &m_pfCurrentValues[0]; } -double* TickmarkHelper::getMinorTick( sal_Int32 nTick, sal_Int32 nDepth +double* EquidistantTickFactory::getMinorTick( sal_Int32 nTick, sal_Int32 nDepth , double fStartParentTick, double fNextParentTick ) const { //check validity of arguments @@ -527,7 +260,7 @@ double* TickmarkHelper::getMinorTick( sal_Int32 nTick, sal_Int32 nDepth //DBG_ASSERT( fStartParentTick < fNextParentTick, "fStartParentTick >= fNextParentTick"); if(fStartParentTick >= fNextParentTick) return NULL; - if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<=0) + if(nDepth>static_cast<sal_Int32>(m_rIncrement.SubIncrements.size()) || nDepth<=0) return NULL; //subticks are only calculated if they are laying between parent ticks: @@ -562,7 +295,7 @@ double* TickmarkHelper::getMinorTick( sal_Int32 nTick, sal_Int32 nDepth return &m_pfCurrentValues[nDepth]; } -bool TickmarkHelper::isWithinOuterBorder( double fScaledValue ) const +bool EquidistantTickFactory::isWithinOuterBorder( double fScaledValue ) const { if(fScaledValue>m_fOuterMajorTickBorderMax_Scaled) return false; @@ -572,8 +305,7 @@ bool TickmarkHelper::isWithinOuterBorder( double fScaledValue ) const return true; } - -bool TickmarkHelper::isVisible( double fScaledValue ) const +bool EquidistantTickFactory::isVisible( double fScaledValue ) const { if(fScaledValue>m_fScaledVisibleMax) { @@ -588,7 +320,7 @@ bool TickmarkHelper::isVisible( double fScaledValue ) const return true; } -void TickmarkHelper::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +void EquidistantTickFactory::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const { uno::Sequence< uno::Sequence< double > > aAllTicks; @@ -669,267 +401,269 @@ void TickmarkHelper::getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rA for( nDepth=0 ;nDepth<aAllTicks.getLength(); nDepth++ ) { sal_Int32 nCount = aAllTicks[nDepth].getLength(); - rAllTickInfos[nDepth].resize( nCount ); + + ::std::vector< TickInfo >& rTickInfoVector = rAllTickInfos[nDepth]; + rTickInfoVector.clear(); + rTickInfoVector.reserve( nCount ); for(sal_Int32 nN = 0; nN<nCount; nN++) { - rAllTickInfos[nDepth][nN].fScaledTickValue = aAllTicks[nDepth][nN]; + TickInfo aTickInfo(m_xInverseScaling); + aTickInfo.fScaledTickValue = aAllTicks[nDepth][nN]; + rTickInfoVector.push_back(aTickInfo); } } } -void TickmarkHelper::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +void EquidistantTickFactory::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const { - std::auto_ptr< TickmarkHelper > apShiftedTickmarkHelper( createShiftedTickmarkHelper() ); - apShiftedTickmarkHelper->getAllTicks( rAllTickInfos ); + ExplicitIncrementData aShiftedIncrement( m_rIncrement ); + aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; + EquidistantTickFactory( m_rScale, aShiftedIncrement ).getAllTicks(rAllTickInfos); } -void TickmarkHelper::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence< double > >& rParentTicks ) const +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) + : m_pSimpleTicks(&rTicks) + , m_pInfoTicks(0) + , m_rIncrement(rIncrement) + , m_nMinDepth(0), m_nMaxDepth(0) + , m_nTickCount(0), m_pnPositions(NULL) + , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) + , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) { - EquidistantTickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 ); - double* pfNextParentTick = aIter.firstValue(); - if(!pfNextParentTick) - return; - double fLastParentTick = *pfNextParentTick; - pfNextParentTick = aIter.nextValue(); - if(!pfNextParentTick) - return; + initIter( nMinDepth, nMaxDepth ); +} - sal_Int32 nMaxSubTickCount = this->getMaxTickCount( nDepth ); - if(!nMaxSubTickCount) +EquidistantTickIter::EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks + , const ExplicitIncrementData& rIncrement + , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) + : m_pSimpleTicks(NULL) + , m_pInfoTicks(&rTicks) + , m_rIncrement(rIncrement) + , m_nMinDepth(0), m_nMaxDepth(0) + , m_nTickCount(0), m_pnPositions(NULL) + , m_pnPreParentCount(NULL), m_pbIntervalFinished(NULL) + , m_nCurrentDepth(-1), m_nCurrentPos(-1), m_fCurrentValue( 0.0 ) +{ + initIter( nMinDepth, nMaxDepth ); +} + +void EquidistantTickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth ) +{ + m_nMaxDepth = nMaxDepth; + if(nMaxDepth<0 || m_nMaxDepth>getMaxDepth()) + m_nMaxDepth=getMaxDepth(); + + sal_Int32 nDepth = 0; + for( nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) + m_nTickCount += getTickCount(nDepth); + + if(!m_nTickCount) return; - uno::Sequence< double > aSubTicks(nMaxSubTickCount); - sal_Int32 nRealSubTickCount = 0; - sal_Int32 nIntervalCount = m_rIncrement.SubIncrements[nDepth-1].IntervalCount; + m_pnPositions = new sal_Int32[m_nMaxDepth+1]; - double* pValue = NULL; - for(; pfNextParentTick; fLastParentTick=*pfNextParentTick, pfNextParentTick = aIter.nextValue()) + m_pnPreParentCount = new sal_Int32[m_nMaxDepth+1]; + m_pbIntervalFinished = new bool[m_nMaxDepth+1]; + m_pnPreParentCount[0] = 0; + m_pbIntervalFinished[0] = false; + double fParentValue = getTickValue(0,0); + for( nDepth = 1; nDepth<=m_nMaxDepth ;nDepth++ ) { - for( sal_Int32 nPartTick = 1; nPartTick<nIntervalCount; nPartTick++ ) - { - pValue = this->getMinorTick( nPartTick, nDepth - , fLastParentTick, *pfNextParentTick ); - if(!pValue) - continue; + m_pbIntervalFinished[nDepth] = false; - aSubTicks[nRealSubTickCount] = *pValue; - nRealSubTickCount++; + sal_Int32 nPreParentCount = 0; + sal_Int32 nCount = getTickCount(nDepth); + for(sal_Int32 nN = 0; nN<nCount; nN++) + { + if(getTickValue(nDepth,nN) < fParentValue) + nPreParentCount++; + else + break; + } + m_pnPreParentCount[nDepth] = nPreParentCount; + if(nCount) + { + double fNextParentValue = getTickValue(nDepth,0); + if( fNextParentValue < fParentValue ) + fParentValue = fNextParentValue; } } +} - aSubTicks.realloc(nRealSubTickCount); - rParentTicks[nDepth] = aSubTicks; - if(m_rIncrement.SubIncrements.getLength()>nDepth) - addSubTicks( nDepth+1, rParentTicks ); +EquidistantTickIter::~EquidistantTickIter() +{ + delete[] m_pnPositions; + delete[] m_pnPreParentCount; + delete[] m_pbIntervalFinished; } -//----------------------------------------------------------------------------- -// ___TickmarkHelper_2D___ -//----------------------------------------------------------------------------- -TickmarkHelper_2D::TickmarkHelper_2D( - const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement - //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ) - , const B2DVector& rStartScreenPos, const B2DVector& rEndScreenPos - , const B2DVector& rAxisLineToLabelLineShift ) - : TickmarkHelper( rScale, rIncrement ) - , m_aAxisStartScreenPosition2D(rStartScreenPos) - , m_aAxisEndScreenPosition2D(rEndScreenPos) - , m_aAxisLineToLabelLineShift(rAxisLineToLabelLineShift) - , m_fStrech_LogicToScreen(1.0) - , m_fOffset_LogicToScreen(0.0) +sal_Int32 EquidistantTickIter::getStartDepth() const { - double fWidthY = m_fScaledVisibleMax - m_fScaledVisibleMin; - if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation ) - { - m_fStrech_LogicToScreen = 1.0/fWidthY; - m_fOffset_LogicToScreen = -m_fScaledVisibleMin; - } - else + //find the depth of the first visible tickmark: + //it is the depth of the smallest value + sal_Int32 nReturnDepth=0; + double fMinValue = DBL_MAX; + for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) { - B2DVector aSwap(m_aAxisStartScreenPosition2D); - m_aAxisStartScreenPosition2D = m_aAxisEndScreenPosition2D; - m_aAxisEndScreenPosition2D = aSwap; - - m_fStrech_LogicToScreen = -1.0/fWidthY; - m_fOffset_LogicToScreen = -m_fScaledVisibleMax; + sal_Int32 nCount = getTickCount(nDepth); + if( !nCount ) + continue; + double fThisValue = getTickValue(nDepth,0); + if(fThisValue<fMinValue) + { + nReturnDepth = nDepth; + fMinValue = fThisValue; + } } + return nReturnDepth; } -TickmarkHelper* TickmarkHelper_2D::createShiftedTickmarkHelper() const +double* EquidistantTickIter::firstValue() { - ExplicitIncrementData aShiftedIncrement( m_rIncrement ); - aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; - - ::basegfx::B2DVector aStart( m_aAxisStartScreenPosition2D ); - ::basegfx::B2DVector aEnd( m_aAxisEndScreenPosition2D ); - if( AxisOrientation_MATHEMATICAL==m_rScale.Orientation ) - std::swap( aStart, aEnd ); - - return new TickmarkHelper_2D( m_rScale, aShiftedIncrement, aStart, aEnd, m_aAxisLineToLabelLineShift ); + if( gotoFirst() ) + { + m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); + return &m_fCurrentValue; + } + return NULL; } -TickmarkHelper_2D::~TickmarkHelper_2D() +TickInfo* EquidistantTickIter::firstInfo() { + if( m_pInfoTicks && gotoFirst() ) + return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; + return NULL; } -bool TickmarkHelper_2D::isHorizontalAxis() const +sal_Int32 EquidistantTickIter::getIntervalCount( sal_Int32 nDepth ) { - return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() ); + if(nDepth>static_cast<sal_Int32>(m_rIncrement.SubIncrements.size()) || nDepth<0) + return 0; + + if(!nDepth) + return m_nTickCount; + + return m_rIncrement.SubIncrements[nDepth-1].IntervalCount; } -bool TickmarkHelper_2D::isVerticalAxis() const + +bool EquidistantTickIter::isAtLastPartTick() { - return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() ); + if(!m_nCurrentDepth) + return false; + sal_Int32 nIntervalCount = getIntervalCount( m_nCurrentDepth ); + if(!nIntervalCount || nIntervalCount == 1) + return true; + if( m_pbIntervalFinished[m_nCurrentDepth] ) + return false; + sal_Int32 nPos = m_pnPositions[m_nCurrentDepth]+1; + if(m_pnPreParentCount[m_nCurrentDepth]) + nPos += nIntervalCount-1 - m_pnPreParentCount[m_nCurrentDepth]; + bool bRet = nPos && nPos % (nIntervalCount-1) == 0; + if(!nPos && !m_pnPreParentCount[m_nCurrentDepth] + && m_pnPositions[m_nCurrentDepth-1]==-1 ) + bRet = true; + return bRet; } -//static -sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter ) +bool EquidistantTickIter::gotoFirst() { - //return the positive distance between the two first tickmarks in screen values - //if there are less than two tickmarks -1 is returned + if( m_nMaxDepth<0 ) + return false; + if( !m_nTickCount ) + return false; - const TickInfo* pFirstTickInfo = rIter.firstInfo(); - const TickInfo* pSecondTickInfo = rIter.nextInfo(); - if(!pSecondTickInfo || !pFirstTickInfo) - return -1; + for(sal_Int32 nDepth = 0; nDepth<=m_nMaxDepth ;nDepth++ ) + m_pnPositions[nDepth] = -1; - return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo ); + m_nCurrentPos = 0; + m_nCurrentDepth = getStartDepth(); + m_pnPositions[m_nCurrentDepth] = 0; + return true; } -B2DVector TickmarkHelper_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const +bool EquidistantTickIter::gotoNext() { - B2DVector aRet(m_aAxisStartScreenPosition2D); - aRet += (m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D) - *((fScaledLogicTickValue+m_fOffset_LogicToScreen)*m_fStrech_LogicToScreen); - return aRet; -} + if( m_nCurrentPos < 0 ) + return false; + m_nCurrentPos++; -void TickmarkHelper_2D::addPointSequenceForTickLine( drawing::PointSequenceSequence& rPoints - , sal_Int32 nSequenceIndex - , double fScaledLogicTickValue, double fInnerDirectionSign - , const TickmarkProperties& rTickmarkProperties - , bool bPlaceAtLabels ) const -{ - if( fInnerDirectionSign==0.0 ) - fInnerDirectionSign = 1.0; - - B2DVector aTickScreenPosition = this->getTickScreenPosition2D(fScaledLogicTickValue); - if( bPlaceAtLabels ) - aTickScreenPosition += m_aAxisLineToLabelLineShift; - - B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; - aMainDirection.normalize(); - B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); - aOrthoDirection *= fInnerDirectionSign; - aOrthoDirection.normalize(); - - B2DVector aStart = aTickScreenPosition + aOrthoDirection*rTickmarkProperties.RelativePos; - B2DVector aEnd = aStart - aOrthoDirection*rTickmarkProperties.Length; - - rPoints[nSequenceIndex].realloc(2); - rPoints[nSequenceIndex][0].X = static_cast<sal_Int32>(aStart.getX()); - rPoints[nSequenceIndex][0].Y = static_cast<sal_Int32>(aStart.getY()); - rPoints[nSequenceIndex][1].X = static_cast<sal_Int32>(aEnd.getX()); - rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY()); -} + if( m_nCurrentPos >= m_nTickCount ) + return false; -B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const -{ - bool bFarAwayLabels = false; - if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos - || ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == rAxisProperties.m_eLabelPos ) - bFarAwayLabels = true; - - double fInnerDirectionSign = rAxisProperties.m_fInnerDirectionSign; - if( fInnerDirectionSign==0.0 ) - fInnerDirectionSign = 1.0; - - B2DVector aMainDirection = m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D; - aMainDirection.normalize(); - B2DVector aOrthoDirection(-aMainDirection.getY(),aMainDirection.getX()); - aOrthoDirection *= fInnerDirectionSign; - aOrthoDirection.normalize(); - - B2DVector aStart(0,0), aEnd(0,0); - if( bFarAwayLabels ) + if( m_nCurrentDepth==m_nMaxDepth && isAtLastPartTick() ) { - TickmarkProperties aProps( AxisProperties::getBiggestTickmarkProperties() ); - aStart = aOrthoDirection*aProps.RelativePos; - aEnd = aStart - aOrthoDirection*aProps.Length; + do + { + m_pbIntervalFinished[m_nCurrentDepth] = true; + m_nCurrentDepth--; + } + while( m_nCurrentDepth && isAtLastPartTick() ); } - else + else if( m_nCurrentDepth<m_nMaxDepth ) { - for( sal_Int32 nN=rAxisProperties.m_aTickmarkPropertiesList.size();nN--;) + do { - const TickmarkProperties& rProps = rAxisProperties.m_aTickmarkPropertiesList[nN]; - B2DVector aNewStart = aOrthoDirection*rProps.RelativePos; - B2DVector aNewEnd = aNewStart - aOrthoDirection*rProps.Length; - if(aNewStart.getLength()>aStart.getLength()) - aStart=aNewStart; - if(aNewEnd.getLength()>aEnd.getLength()) - aEnd=aNewEnd; + m_nCurrentDepth++; } + while( m_nCurrentDepth<m_nMaxDepth ); } - - B2DVector aLabelDirection(aStart); - if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) - aLabelDirection = aEnd; - - B2DVector aOrthoLabelDirection(aOrthoDirection); - if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign ) - aOrthoLabelDirection*=-1.0; - aOrthoLabelDirection.normalize(); - if( bIncludeSpaceBetweenTickAndText ) - aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING; - if( bFarAwayLabels && bIncludeFarAwayDistanceIfSo ) - aLabelDirection += m_aAxisLineToLabelLineShift; - return aLabelDirection; + m_pbIntervalFinished[m_nCurrentDepth] = false; + m_pnPositions[m_nCurrentDepth] = m_pnPositions[m_nCurrentDepth]+1; + return true; } -void TickmarkHelper_2D::createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints ) const +bool EquidistantTickIter::gotoIndex( sal_Int32 nTickIndex ) { - rPoints[0].realloc(2); - rPoints[0][0].X = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getX()); - rPoints[0][0].Y = static_cast<sal_Int32>(m_aAxisStartScreenPosition2D.getY()); - rPoints[0][1].X = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getX()); - rPoints[0][1].Y = static_cast<sal_Int32>(m_aAxisEndScreenPosition2D.getY()); + if( nTickIndex < 0 ) + return false; + if( nTickIndex >= m_nTickCount ) + return false; + + if( nTickIndex < m_nCurrentPos ) + if( !gotoFirst() ) + return false; + + while( nTickIndex > m_nCurrentPos ) + if( !gotoNext() ) + return false; + + return true; } -void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +sal_Int32 EquidistantTickIter::getCurrentIndex() const { - //get the transformed screen values for all tickmarks in rAllTickInfos - ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); - const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); - for( ; aDepthIter != aDepthEnd; aDepthIter++ ) - { - ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin(); - const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); - for( ; aTickIter != aTickEnd; aTickIter++ ) - { - TickInfo& rTickInfo = (*aTickIter); - rTickInfo.aTickScreenPosition = - this->getTickScreenPosition2D( rTickInfo.fScaledTickValue ); - } - } + return m_nCurrentPos; } - -//----------------------------------------------------------------------------- -// ___TickmarkHelper_3D___ -//----------------------------------------------------------------------------- -TickmarkHelper_3D::TickmarkHelper_3D( - const ExplicitScaleData& rScale, const ExplicitIncrementData& rIncrement ) - : TickmarkHelper( rScale, rIncrement ) +sal_Int32 EquidistantTickIter::getMaxIndex() const { + return m_nTickCount-1; } -TickmarkHelper* TickmarkHelper_3D::createShiftedTickmarkHelper() const +double* EquidistantTickIter::nextValue() { - ExplicitIncrementData aShiftedIncrement( m_rIncrement ); - aShiftedIncrement.BaseValue = m_rIncrement.BaseValue-m_rIncrement.Distance/2.0; - return new TickmarkHelper_3D( m_rScale, aShiftedIncrement ); + if( gotoNext() ) + { + m_fCurrentValue = getTickValue(m_nCurrentDepth, m_pnPositions[m_nCurrentDepth]); + return &m_fCurrentValue; + } + return NULL; } -TickmarkHelper_3D::~TickmarkHelper_3D() +TickInfo* EquidistantTickIter::nextInfo() { + if( m_pInfoTicks && gotoNext() && + static_cast< sal_Int32 >( + (*m_pInfoTicks)[m_nCurrentDepth].size()) > m_pnPositions[m_nCurrentDepth] ) + { + return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]]; + } + return NULL; } //............................................................................. diff --git a/chart2/source/view/axes/TickmarkHelper.hxx b/chart2/source/view/axes/Tickmarks_Equidistant.hxx index 78fc2fe1c502..836a93d28db2 100644 --- a/chart2/source/view/axes/TickmarkHelper.hxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.hxx @@ -24,19 +24,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _CHART2_TICKMARKHELPER_HXX -#define _CHART2_TICKMARKHELPER_HXX +#ifndef _CHART2_TICKMARKS_EQUIDISTANT_HXX +#define _CHART2_TICKMARKS_EQUIDISTANT_HXX -#include "TickmarkProperties.hxx" -#include "VAxisProperties.hxx" -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <basegfx/vector/b2dvector.hxx> -#include <com/sun/star/drawing/PointSequenceSequence.hpp> -#include <com/sun/star/drawing/XShape.hpp> -#include <com/sun/star/uno/Sequence.h> - -#include <vector> +#include "Tickmarks.hxx" //............................................................................. namespace chart @@ -48,57 +39,15 @@ using ::basegfx::B2DVector; /** */ -struct TickInfo -{ - double fScaledTickValue; - double fUnscaledTickValue; - - ::basegfx::B2DVector aTickScreenPosition; - bool bPaintIt; - - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > xTextShape; - - rtl::OUString aText;//used only for complex categories so far - sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category - -//methods: - TickInfo(); - void updateUnscaledValue( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XScaling >& xInverseScaling ); - - sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; -}; -class TickIter -{ -public: - virtual ~TickIter(){}; - virtual TickInfo* firstInfo()=0; - virtual TickInfo* nextInfo()=0; -}; - -class PureTickIter : public TickIter -{ -public: - PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); - virtual ~PureTickIter(); - virtual TickInfo* firstInfo(); - virtual TickInfo* nextInfo(); - -private: - ::std::vector< TickInfo >& m_rTickVector; - ::std::vector< TickInfo >::iterator m_aTickIter; -}; - class EquidistantTickIter : public TickIter { public: EquidistantTickIter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& rTicks - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + , const ExplicitIncrementData& rIncrement , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + , const ExplicitIncrementData& rIncrement , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); virtual ~EquidistantTickIter(); @@ -152,7 +101,7 @@ private: //member const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks; ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks; - const ::com::sun::star::chart2::ExplicitIncrementData& m_rIncrement; + const ExplicitIncrementData& m_rIncrement; //iteration from m_nMinDepth to m_nMaxDepth sal_Int32 m_nMinDepth; sal_Int32 m_nMaxDepth; @@ -166,24 +115,21 @@ private: //member double m_fCurrentValue; }; -class TickmarkHelper +class EquidistantTickFactory { public: - TickmarkHelper( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - virtual ~TickmarkHelper(); + EquidistantTickFactory( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ); + ~EquidistantTickFactory(); - virtual TickmarkHelper* createShiftedTickmarkHelper() const; + void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ); + static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ); - // - static double getMinimumAtIncrement( double fMin, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - static double getMaximumAtIncrement( double fMax, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - -protected: //methods +private: //methods void addSubTicks( sal_Int32 nDepth, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const; @@ -192,82 +138,26 @@ protected: //methods , double fStartParentTick, double fNextParentTick ) const; sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const; sal_Int32 getTickDepth() const; + bool isVisible( double fValue ) const; bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks - virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} - -protected: //member - ::com::sun::star::chart2::ExplicitScaleData m_rScale; - ::com::sun::star::chart2::ExplicitIncrementData m_rIncrement; - +private: //member + ExplicitScaleData m_rScale; + ExplicitIncrementData m_rIncrement; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > m_xInverseScaling; + + //minimum and maximum of the visible range after scaling + double m_fScaledVisibleMin; + double m_fScaledVisibleMax; + double* m_pfCurrentValues; //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders double m_fOuterMajorTickBorderMin; double m_fOuterMajorTickBorderMax; double m_fOuterMajorTickBorderMin_Scaled; double m_fOuterMajorTickBorderMax_Scaled; - - //minimum and maximum of the visible range after scaling - double m_fScaledVisibleMin; - double m_fScaledVisibleMax; -}; - -class TickmarkHelper_2D : public TickmarkHelper -{ -public: - TickmarkHelper_2D( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos - , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); - //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); - virtual ~TickmarkHelper_2D(); - - virtual TickmarkHelper* createShiftedTickmarkHelper() const; - - static sal_Int32 getTickScreenDistance( TickIter& rIter ); - - void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; - void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints - , sal_Int32 nSequenceIndex - , double fScaledLogicTickValue, double fInnerDirectionSign - , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; - ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties - , bool bIncludeFarAwayDistanceIfSo = false - , bool bIncludeSpaceBetweenTickAndText = true ) const; - - virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; - - bool isHorizontalAxis() const; - bool isVerticalAxis() const; - -protected: //methods - ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; - -private: //member - ::basegfx::B2DVector m_aAxisStartScreenPosition2D; - ::basegfx::B2DVector m_aAxisEndScreenPosition2D; - - //labels might be posioned high or low on the border of the diagram far away from the axis - //add this vector to go from the axis line to the label line (border of the diagram) - ::basegfx::B2DVector m_aAxisLineToLabelLineShift; - - double m_fStrech_LogicToScreen; - double m_fOffset_LogicToScreen; -}; - -class TickmarkHelper_3D : public TickmarkHelper -{ -public: - TickmarkHelper_3D( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ); - virtual ~TickmarkHelper_3D(); - - virtual TickmarkHelper* createShiftedTickmarkHelper() const; }; //............................................................................. diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 0159fb20cad6..fb193ec93a95 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -31,7 +31,7 @@ #include "VAxisBase.hxx" #include "ShapeFactory.hxx" #include "CommonConverters.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "macros.hxx" // header for define DBG_ASSERT @@ -70,7 +70,7 @@ sal_Int32 VAxisBase::getDimensionCount() return m_nDimension; } -void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize +void VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) { m_aAxisLabelProperties.m_aFontReferenceSize = rFontReferenceSize; @@ -106,6 +106,15 @@ void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::S m_aAxisLabelProperties.eStaggering = SIDE_BY_SIDE; } +bool VAxisBase::isDateAxis() const +{ + return AxisType::DATE == m_aScale.AxisType; +} +bool VAxisBase::isComplexCategoryAxis() const +{ + return m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels; +} + void VAxisBase::recordMaximumTextSize( const Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) { if( m_bRecordMaximumTextSize && xShape.is() ) @@ -130,7 +139,7 @@ void VAxisBase::setExrtaLinePositionAtOtherAxis( const double& fCrossingAt ) m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = new double(fCrossingAt); } -sal_Bool SAL_CALL VAxisBase::isAnythingToDraw() +sal_Bool VAxisBase::isAnythingToDraw() { if( !m_aAxisProperties.m_xAxisModel.is() ) return false; @@ -150,7 +159,7 @@ sal_Bool SAL_CALL VAxisBase::isAnythingToDraw() return true; } -void SAL_CALL VAxisBase::setExplicitScaleAndIncrement( +void VAxisBase::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -162,8 +171,11 @@ void SAL_CALL VAxisBase::setExplicitScaleAndIncrement( void VAxisBase::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) { - std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); - apTickmarkHelper->getAllTicks( rAllTickInfos ); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); + if( m_aScale.ShiftedCategoryPosition ) + apTickFactory->getAllTicksShifted( rAllTickInfos ); + else + apTickFactory->getAllTicks( rAllTickInfos ); } bool VAxisBase::prepareShapeCreation() @@ -244,7 +256,7 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter& rIter ) for( TickInfo* pTickInfo = rIter.firstInfo() ; pTickInfo; pTickInfo = rIter.nextInfo() ) { - pTickInfo->updateUnscaledValue( xInverseScaling ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); } } diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx index ba7e94b2070c..e51e2d8dbd9b 100644 --- a/chart2/source/view/axes/VAxisBase.hxx +++ b/chart2/source/view/axes/VAxisBase.hxx @@ -29,7 +29,7 @@ #include "VAxisOrGridBase.hxx" #include "VAxisProperties.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include <com/sun/star/util/XNumberFormatsSupplier.hpp> //............................................................................. @@ -52,18 +52,18 @@ public: sal_Int32 getDimensionCount(); - virtual void SAL_CALL createMaximumLabels()=0; - virtual void SAL_CALL createLabels()=0; - virtual void SAL_CALL updatePositions()=0; + virtual void createMaximumLabels()=0; + virtual void createLabels()=0; + virtual void updatePositions()=0; - virtual sal_Bool SAL_CALL isAnythingToDraw(); - virtual void SAL_CALL initAxisLabelProperties( + virtual sal_Bool isAnythingToDraw(); + virtual void initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); @@ -83,6 +83,9 @@ protected: //methods ::com::sun::star::drawing::XShape >& xShape , double fRotationAngleDegree ); + bool isDateAxis() const; + bool isComplexCategoryAxis() const; + protected: //member ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; AxisProperties m_aAxisProperties; diff --git a/chart2/source/view/axes/VAxisOrGridBase.cxx b/chart2/source/view/axes/VAxisOrGridBase.cxx index f2e2e90c1045..715da4972390 100644 --- a/chart2/source/view/axes/VAxisOrGridBase.cxx +++ b/chart2/source/view/axes/VAxisOrGridBase.cxx @@ -31,7 +31,7 @@ #include "VAxisOrGridBase.hxx" #include "ShapeFactory.hxx" #include "CommonConverters.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" // header for define DBG_ASSERT #include <tools/debug.hxx> @@ -57,7 +57,7 @@ VAxisOrGridBase::~VAxisOrGridBase() { } -void SAL_CALL VAxisOrGridBase::setExplicitScaleAndIncrement( +void VAxisOrGridBase::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -79,18 +79,9 @@ void VAxisOrGridBase::set3DWallPositions( CuboidPlanePosition eLeftWallPos, Cubo m_eBottomPos = eBottomPos; } -TickmarkHelper* VAxisOrGridBase::createTickmarkHelper() +TickFactory* VAxisOrGridBase::createTickFactory() { - TickmarkHelper* pRet=NULL; - if( 2==m_nDimension ) - { - pRet = new TickmarkHelper( m_aScale, m_aIncrement ); - } - else - { - pRet = new TickmarkHelper_3D( m_aScale, m_aIncrement ); - } - return pRet; + return new TickFactory( m_aScale, m_aIncrement ); } //............................................................................. diff --git a/chart2/source/view/axes/VAxisOrGridBase.hxx b/chart2/source/view/axes/VAxisOrGridBase.hxx index 35b32b2b1c03..9091aabf0dc5 100644 --- a/chart2/source/view/axes/VAxisOrGridBase.hxx +++ b/chart2/source/view/axes/VAxisOrGridBase.hxx @@ -29,9 +29,8 @@ #include "PlotterBase.hxx" #include "ThreeDHelper.hxx" +#include "chartview/ExplicitScaleValues.hxx" -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -46,7 +45,7 @@ namespace chart /** */ class ShapeFactory; -class TickmarkHelper; +class TickFactory; class VAxisOrGridBase : public PlotterBase { @@ -55,22 +54,22 @@ public: virtual ~VAxisOrGridBase(); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); - virtual TickmarkHelper* createTickmarkHelper(); + virtual TickFactory* createTickFactory(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- protected: //member - ::com::sun::star::chart2::ExplicitScaleData m_aScale; - ::com::sun::star::chart2::ExplicitIncrementData m_aIncrement; - sal_Int32 m_nDimensionIndex; + ExplicitScaleData m_aScale; + ExplicitIncrementData m_aIncrement; + sal_Int32 m_nDimensionIndex; - ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; + ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; CuboidPlanePosition m_eLeftWallPos; CuboidPlanePosition m_eBackWallPos; diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 1e3e62894741..d700ee9d27be 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -183,7 +183,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel , m_pfExrtaLinePositionAtOtherAxis(NULL) , m_bCrossingAxisHasReverseDirection(false) , m_bCrossingAxisIsCategoryAxes(false) - , m_bAxisBetweenCategories(false) , m_fLabelDirectionSign(1.0) , m_fInnerDirectionSign(1.0) , m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP) @@ -213,7 +212,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties ) , m_pfExrtaLinePositionAtOtherAxis( NULL ) , m_bCrossingAxisHasReverseDirection( rAxisProperties.m_bCrossingAxisHasReverseDirection ) , m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes ) - , m_bAxisBetweenCategories( rAxisProperties.m_bAxisBetweenCategories ) , m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign ) , m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign ) , m_aLabelAlignment( rAxisProperties.m_aLabelAlignment ) @@ -280,11 +278,7 @@ void AxisProperties::initAxisPositioning( const uno::Reference< beans::XProperty xAxisProp->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue; if( m_bCrossingAxisIsCategoryAxes ) - { fValue = ::rtl::math::round(fValue); - if( m_bAxisBetweenCategories ) - fValue-=0.5; - } m_pfMainLinePositionAtOtherAxis = new double(fValue); } else if( ::com::sun::star::chart::ChartAxisPosition_ZERO == m_eCrossoverType ) @@ -318,8 +312,17 @@ void AxisProperties::init( bool bCartesian ) if( m_nDimensionIndex<2 ) initAxisPositioning( xProp ); + ScaleData aScaleData = m_xAxisModel->getScaleData(); + if( m_nDimensionIndex==0 ) + AxisHelper::checkDateAxis( aScaleData, m_pExplicitCategoriesProvider, bCartesian ); + m_nAxisType = aScaleData.AxisType; + if( bCartesian ) { + if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY + && m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) + m_bComplexCategories = true; + if( ::com::sun::star::chart::ChartAxisPosition_END == m_eCrossoverType ) m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1; else @@ -361,10 +364,6 @@ void AxisProperties::init( bool bCartesian ) //init display labels xProp->getPropertyValue( C2U( "DisplayLabels" ) ) >>= m_bDisplayLabels; - //init categories - ScaleData aScaleData = m_xAxisModel->getScaleData(); - m_nAxisType = aScaleData.AxisType; - //init TickmarkProperties xProp->getPropertyValue( C2U( "MajorTickmarks" ) ) >>= m_nMajorTickmarks; xProp->getPropertyValue( C2U( "MinorTickmarks" ) ) >>= m_nMinorTickmarks; diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx index 5b6bfe98f777..69e0edb82730 100644 --- a/chart2/source/view/axes/VAxisProperties.hxx +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -111,7 +111,6 @@ struct AxisProperties bool m_bCrossingAxisHasReverseDirection; bool m_bCrossingAxisIsCategoryAxes; - bool m_bAxisBetweenCategories; //this direction is used to indicate in which direction the labels are to be drawn double m_fLabelDirectionSign; diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8ec895fbd452..869e1292ed7a 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -41,6 +41,7 @@ #include "TrueGuard.hxx" #include "BaseGFXHelper.hxx" #include "AxisHelper.hxx" +#include "Tickmarks_Equidistant.hxx" #include <rtl/math.hxx> #include <tools/color.hxx> @@ -176,7 +177,7 @@ void removeShapesAtWrongRhythm( TickIter& rIter } } -class EquidistantLabelIterator : public EquidistantTickIter +class LabelIterator : public TickIter { //this Iterator iterates over existing text labels @@ -190,39 +191,36 @@ class EquidistantLabelIterator : public EquidistantTickIter //we iterate through all labels public: - EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + LabelIterator( ::std::vector< TickInfo >& rTickInfoVector , const AxisLabelStaggering eAxisLabelStaggering - , bool bInnerLine - , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); + , bool bInnerLine ); virtual TickInfo* firstInfo(); virtual TickInfo* nextInfo(); private: //methods - EquidistantLabelIterator(); + LabelIterator(); private: //member const AxisLabelStaggering m_eAxisLabelStaggering; - bool m_bInnerLine; + bool m_bInnerLine; + PureTickIter m_aPureTickIter; }; -EquidistantLabelIterator::EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement +LabelIterator::LabelIterator( ::std::vector< TickInfo >& rTickInfoVector , const AxisLabelStaggering eAxisLabelStaggering - , bool bInnerLine - , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) - : EquidistantTickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth ) + , bool bInnerLine ) + : m_aPureTickIter( rTickInfoVector ) , m_eAxisLabelStaggering(eAxisLabelStaggering) , m_bInnerLine(bInnerLine) { } -TickInfo* EquidistantLabelIterator::firstInfo() +TickInfo* LabelIterator::firstInfo() { - TickInfo* pTickInfo = EquidistantTickIter::firstInfo(); + TickInfo* pTickInfo = m_aPureTickIter.firstInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ) - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); if(!pTickInfo) return NULL; if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine) @@ -232,7 +230,7 @@ TickInfo* EquidistantLabelIterator::firstInfo() { //skip first label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); } if(!pTickInfo) @@ -240,12 +238,12 @@ TickInfo* EquidistantLabelIterator::firstInfo() return pTickInfo; } -TickInfo* EquidistantLabelIterator::nextInfo() +TickInfo* LabelIterator::nextInfo() { TickInfo* pTickInfo = NULL; //get next label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); if( STAGGER_EVEN==m_eAxisLabelStaggering @@ -253,7 +251,7 @@ TickInfo* EquidistantLabelIterator::nextInfo() { //skip one label do - pTickInfo = EquidistantTickIter::nextInfo(); + pTickInfo = m_aPureTickIter.nextInfo(); while( pTickInfo && !pTickInfo->xTextShape.is() ); } return pTickInfo; @@ -319,30 +317,30 @@ void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance ) } } -class MaxLabelEquidistantTickIter : public EquidistantTickIter +class MaxLabelTickIter : public TickIter { //iterate over first two and last two labels and the longest label public: - MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement + MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector , sal_Int32 nLongestLabelIndex ); - virtual ~MaxLabelEquidistantTickIter(); + virtual ~MaxLabelTickIter(); - virtual TickInfo* nextInfo(); + virtual TickInfo* firstInfo(); + virtual TickInfo* nextInfo(); private: + ::std::vector< TickInfo >& m_rTickInfoVector; sal_Int32 m_nLongestLabelIndex; + sal_Int32 m_nCurrentIndex; }; -MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement +MaxLabelTickIter::MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector , sal_Int32 nLongestLabelIndex ) - : EquidistantTickIter( rTickInfos, rIncrement, 0//nMinDepth - , 0//nMaxDepth - ) + : m_rTickInfoVector(rTickInfoVector) , m_nLongestLabelIndex( nLongestLabelIndex ) + , m_nCurrentIndex(0) { - sal_Int32 nMaxIndex = getMaxIndex(); + sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; //ensure correct value: if( m_nLongestLabelIndex<0 || m_nLongestLabelIndex>nMaxIndex) @@ -355,28 +353,43 @@ MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std:: if( m_nLongestLabelIndex+1==nMaxIndex ) m_nLongestLabelIndex = 0; } -MaxLabelEquidistantTickIter::~MaxLabelEquidistantTickIter() +MaxLabelTickIter::~MaxLabelTickIter() +{ +} + +TickInfo* MaxLabelTickIter::firstInfo() { + m_nCurrentIndex = 0; + if( m_nCurrentIndex < m_rTickInfoVector.size() ) + return &m_rTickInfoVector[m_nCurrentIndex]; + return 0; } -TickInfo* MaxLabelEquidistantTickIter::nextInfo() +TickInfo* MaxLabelTickIter::nextInfo() { - sal_Int32 nCurrentPos = getCurrentIndex(); - sal_Int32 nMaxIndex = getMaxIndex(); - if( nCurrentPos>0 ) + sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; + if( m_nLongestLabelIndex >= nMaxIndex-1 ) + m_nLongestLabelIndex = 0; + + if( m_nCurrentIndex==0 ) + m_nCurrentIndex++; + else if( m_nCurrentIndex==1 && m_nCurrentIndex<m_nLongestLabelIndex ) + m_nCurrentIndex=m_nLongestLabelIndex; + else if( m_nCurrentIndex==m_nLongestLabelIndex ) { - if( m_nLongestLabelIndex>1 && nCurrentPos<m_nLongestLabelIndex ) - gotoIndex( m_nLongestLabelIndex-1 ) ; - else - { - if( nMaxIndex>3 && nCurrentPos<nMaxIndex-1 ) - gotoIndex( nMaxIndex-2 ); - else if( nMaxIndex>2 && nCurrentPos<nMaxIndex ) - gotoIndex( nMaxIndex-1 ); - } + if( nMaxIndex>=3 ) + m_nCurrentIndex=nMaxIndex-1; + else if( nMaxIndex>=2 ) + m_nCurrentIndex=nMaxIndex; } + else if( m_nCurrentIndex==nMaxIndex-1 ) + m_nCurrentIndex=nMaxIndex; + else + m_nCurrentIndex=nMaxIndex+1; - return EquidistantTickIter::nextInfo(); + if( m_nCurrentIndex>=0 && m_nCurrentIndex<m_rTickInfoVector.size() ) + return &m_rTickInfoVector[m_nCurrentIndex]; + return 0; } bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties @@ -446,27 +459,27 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end()); for(;aIt!=aEnd;++aIt) { - TickInfo aTickInfo; + TickInfo aTickInfo(0); ComplexCategory aCat(*aIt); sal_Int32 nCount = aCat.Count; - if( nCatIndex + 0.5 + nCount >= m_aScale.Maximum ) + if( nCatIndex + 1.0 + nCount >= m_aScale.Maximum ) { - nCount = static_cast<sal_Int32>(m_aScale.Maximum - 0.5 - nCatIndex); + nCount = static_cast<sal_Int32>(m_aScale.Maximum - 1.0 - nCatIndex); if( nCount <= 0 ) nCount = 1; } - aTickInfo.fScaledTickValue = nCatIndex + 0.5 + nCount/2.0; + aTickInfo.fScaledTickValue = nCatIndex + 1.0 + nCount/2.0; aTickInfo.nFactorForLimitedTextWidth = nCount; aTickInfo.aText = aCat.Text; aTickInfoVector.push_back(aTickInfo); nCatIndex += nCount; - if( nCatIndex + 0.5 >= m_aScale.Maximum ) + if( nCatIndex + 1.0 >= m_aScale.Maximum ) break; } rAllTickInfos.push_back(aTickInfoVector); } } - else //bShiftedPosition==true + else //bShiftedPosition==false { rAllTickInfos.clear(); sal_Int32 nLevel=0; @@ -480,19 +493,19 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end()); for(;aIt!=aEnd;++aIt) { - TickInfo aTickInfo; + TickInfo aTickInfo(0); ComplexCategory aCat(*aIt); - aTickInfo.fScaledTickValue = nCatIndex + 0.5; + aTickInfo.fScaledTickValue = nCatIndex + 1.0; aTickInfoVector.push_back(aTickInfo); nCatIndex += aCat.Count; - if( nCatIndex + 0.5 > m_aScale.Maximum ) + if( nCatIndex + 1.0 > m_aScale.Maximum ) break; } //fill up with single ticks until maximum scale - while( nCatIndex + 0.5 < m_aScale.Maximum ) + while( nCatIndex + 1.0 < m_aScale.Maximum ) { - TickInfo aTickInfo; - aTickInfo.fScaledTickValue = nCatIndex + 0.5; + TickInfo aTickInfo(0); + aTickInfo.fScaledTickValue = nCatIndex + 1.0; aTickInfoVector.push_back(aTickInfo); nCatIndex ++; if( nLevel>0 ) @@ -500,7 +513,7 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s } //add an additional tick at the end { - TickInfo aTickInfo; + TickInfo aTickInfo(0); aTickInfo.fScaledTickValue = m_aScale.Maximum; aTickInfoVector.push_back(aTickInfo); } @@ -511,7 +524,7 @@ void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::s void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) createAllTickInfosFromComplexCategories( rAllTickInfos, false ); else VAxisBase::createAllTickInfos(rAllTickInfos); @@ -519,21 +532,13 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo ::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) - { - if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) - return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); - } - else - { - if(nTextLevel==0) - return ::std::auto_ptr< TickIter >( new EquidistantTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 ) ); - } + if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) + return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); return ::std::auto_ptr< TickIter >(); } ::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() || isDateAxis() ) { return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here } @@ -541,8 +546,11 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo { if(nTextLevel==0) { - sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; - return ::std::auto_ptr< TickIter >( new MaxLabelEquidistantTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex ) ); + if( !m_aAllTickInfos.empty() ) + { + sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; + return ::std::auto_ptr< TickIter >( new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ) ); + } } } return ::std::auto_ptr< TickIter >(); @@ -551,7 +559,7 @@ void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo sal_Int32 VCartesianAxis::getTextLevelCount() const { sal_Int32 nTextLevelCount = 1; - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount(); return nTextLevelCount; } @@ -560,7 +568,7 @@ bool VCartesianAxis::createTextShapes( const Reference< drawing::XShapes >& xTarget , TickIter& rTickIter , AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper + , TickFactory_2D* pTickFactory , sal_Int32 nScreenDistanceBetweenTicks ) { //returns true if the text shapes have been created succesfully @@ -574,10 +582,10 @@ bool VCartesianAxis::createTextShapes( FixedNumberFormatter aFixedNumberFormatter( m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey ); - const bool bIsHorizontalAxis = pTickmarkHelper->isHorizontalAxis(); - const bool bIsVerticalAxis = pTickmarkHelper->isVerticalAxis(); + const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis(); + const bool bIsVerticalAxis = pTickFactory->isVerticalAxis(); bool bIsStaggered = rAxisLabelProperties.getIsStaggered(); - B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties, true ) ); + B2DVector aTextToTickDistance( pTickFactory->getDistanceAxisTickToText( m_aAxisProperties, true ) ); sal_Int32 nLimitedSpaceForText = -1; if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) ) { @@ -673,7 +681,7 @@ bool VCartesianAxis::createTextShapes( } } - pTickInfo->updateUnscaledValue( xInverseScaling ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); bool bHasExtraColor=false; sal_Int32 nExtraColor=0; @@ -681,7 +689,7 @@ bool VCartesianAxis::createTextShapes( rtl::OUString aLabel; if(pCategories) { - sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->fUnscaledTickValue) - 1; //first category (index 0) matches with real number 1.0 + sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0 if( nIndex>=0 && nIndex<pCategories->getLength() ) aLabel = (*pCategories)[nIndex]; } @@ -690,7 +698,7 @@ bool VCartesianAxis::createTextShapes( aLabel = pTickInfo->aText; } else - aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor ); if(pColorAny) *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); @@ -1189,12 +1197,12 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub } } -TickmarkHelper* VCartesianAxis::createTickmarkHelper() +TickFactory* VCartesianAxis::createTickFactory() { - return createTickmarkHelper2D(); + return createTickFactory2D(); } -TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D() +TickFactory_2D* VCartesianAxis::createTickFactory2D() { B2DVector aStart, aEnd; this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() ); @@ -1202,7 +1210,7 @@ TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D() B2DVector aLabelLineStart, aLabelLineEnd; this->get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, this->getLogicValueWhereLabelLineCrossesOtherAxis() ); - return new TickmarkHelper_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart ); + return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart ); } void lcl_hideIdenticalScreenValues( TickIter& rTickIter ) @@ -1226,7 +1234,7 @@ void lcl_hideIdenticalScreenValues( TickIter& rTickIter ) //'hide' tickmarks with identical screen values in aAllTickInfos void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const { - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() || isDateAxis() ) { sal_Int32 nCount = rTickInfos.size(); for( sal_Int32 nN=0; nN<nCount; nN++ ) @@ -1272,12 +1280,12 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount() return nRet; } -void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickmarkHelper_2D* pTickmarkHelper2D ) +void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickFactory_2D* pTickFactory2D ) { - if( !pTickmarkHelper2D ) + if( !pTickFactory2D ) return; - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) { sal_Int32 nTextLevelCount = getTextLevelCount(); B2DVector aCummulatedLabelsDistance(0,0); @@ -1289,24 +1297,25 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel if( nTextLevel>0 ) lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance ); aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ); + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ); } } } else if( rAxisLabelProperties.getIsStaggered() ) { - EquidistantLabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement - , rAxisLabelProperties.eStaggering, true, 0, 0 ); - EquidistantLabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement - , rAxisLabelProperties.eStaggering, false, 0, 0 ); - - lcl_shiftLables( aOuterIter - , lcl_getLabelsDistance( aInnerIter - , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + if( !m_aAllTickInfos.empty() ) + { + LabelIterator aInnerIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, true ); + LabelIterator aOuterIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, false ); + + lcl_shiftLables( aOuterIter + , lcl_getLabelsDistance( aInnerIter + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + } } } -void SAL_CALL VCartesianAxis::createLabels() +void VCartesianAxis::createLabels() { if( !prepareShapeCreation() ) return; @@ -1315,14 +1324,14 @@ void SAL_CALL VCartesianAxis::createLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); //----------------------------------------- //'hide' tickmarks with identical screen values in aAllTickInfos hideIdenticalScreenValues( m_aAllTickInfos ); @@ -1339,7 +1348,7 @@ void SAL_CALL VCartesianAxis::createLabels() { if(nTextLevel==0) { - nScreenDistanceBetweenTicks = TickmarkHelper_2D::getTickScreenDistance( *apTickIter.get() ); + nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() ); if( nTextLevelCount>1 ) nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half } @@ -1348,16 +1357,16 @@ void SAL_CALL VCartesianAxis::createLabels() aCopy.bRhythmIsFix = true; aCopy.nRhythm = 1; AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy; - while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickmarkHelper2D, nScreenDistanceBetweenTicks ) ) + while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) ) { }; } } - doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); } } -void SAL_CALL VCartesianAxis::createMaximumLabels() +void VCartesianAxis::createMaximumLabels() { TrueGuard aRecordMaximumTextSize(m_bRecordMaximumTextSize); @@ -1368,20 +1377,20 @@ void SAL_CALL VCartesianAxis::createMaximumLabels() //create labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); //create tick mark text shapes //@todo: iterate through all tick depth wich should be labeled AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); - if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D->isHorizontalAxis(), pTickmarkHelper2D->isVerticalAxis() ) ) + if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) ) aAxisLabelProperties.eStaggering = STAGGER_EVEN; aAxisLabelProperties.bOverlapAllowed = true; aAxisLabelProperties.bLineBreakAllowed = false; @@ -1391,29 +1400,29 @@ void SAL_CALL VCartesianAxis::createMaximumLabels() ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel ); if(apTickIter.get()) { - while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickmarkHelper2D, -1 ) ) + while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) ) { }; } } - doStaggeringOfLabels( aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D ); } } -void SAL_CALL VCartesianAxis::updatePositions() +void VCartesianAxis::updatePositions() { //----------------------------------------- //update positions of labels if( m_aAxisProperties.m_bDisplayLabels ) { - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- //update positions of all existing text shapes - pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos ); + pTickFactory2D->updateScreenValues( m_aAllTickInfos ); ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); @@ -1427,7 +1436,7 @@ void SAL_CALL VCartesianAxis::updatePositions() Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape ); if( xShape2DText.is() ) { - B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); + B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition ); aTickScreenPos2D += aTextToTickDistance; awt::Point aAnchorScreenPosition2D( @@ -1459,11 +1468,11 @@ void SAL_CALL VCartesianAxis::updatePositions() } } - doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D ); + doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); } } -void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels ) +void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ) { sal_Int32 nPointCount = rTickInfos.size(); drawing::PointSequenceSequence aPoints(2*nPointCount); @@ -1482,11 +1491,11 @@ void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickI fInnerDirectionSign *= -1.0; bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels; //add ticks at labels: - rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue + rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels ); //add ticks at axis (without lables): if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ) - rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue + rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels ); } aPoints.realloc(nN); @@ -1494,14 +1503,14 @@ void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickI , &rTickmarkProperties.aLineProperties ); } -void SAL_CALL VCartesianAxis::createShapes() +void VCartesianAxis::createShapes() { if( !prepareShapeCreation() ) return; - std::auto_ptr< TickmarkHelper_2D > apTickmarkHelper2D( this->createTickmarkHelper2D() ); - TickmarkHelper_2D* pTickmarkHelper2D = apTickmarkHelper2D.get(); - if( !pTickmarkHelper2D ) + std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); + TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); + if( !pTickFactory2D ) return; //----------------------------------------- @@ -1510,23 +1519,23 @@ void SAL_CALL VCartesianAxis::createShapes() { //----------------------------------------- //create extra long ticks to separate complex categories (create them only there where the labels are) - if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) + if( isComplexCategoryAxis() ) { ::std::vector< ::std::vector< TickInfo > > aComplexTickInfos; createAllTickInfosFromComplexCategories( aComplexTickInfos, true ); - pTickmarkHelper2D->updateScreenValues( aComplexTickInfos ); + pTickFactory2D->updateScreenValues( aComplexTickInfos ); hideIdenticalScreenValues( aComplexTickInfos ); ::std::vector<TickmarkProperties> aTickmarkPropertiesList; static bool bIncludeSpaceBetweenTickAndText = false; - sal_Int32 nOffset = static_cast<sal_Int32>(pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength()); + sal_Int32 nOffset = static_cast<sal_Int32>(pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength()); sal_Int32 nTextLevelCount = getTextLevelCount(); for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) { ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); if( apTickIter.get() ) { - B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); + B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); sal_Int32 nCurrentLength = static_cast<sal_Int32>(aLabelsDistance.getLength()); aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); nOffset += nCurrentLength; @@ -1540,20 +1549,20 @@ void SAL_CALL VCartesianAxis::createShapes() { if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks) continue; - createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, true /*bOnlyAtLabels*/ ); + createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickFactory2D, true /*bOnlyAtLabels*/ ); } } //----------------------------------------- //create normal ticks for major and minor intervals { - ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos; - if( m_aIncrement.ShiftedPosition || ( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) ) + ::std::vector< ::std::vector< TickInfo > > aUnshiftedTickInfos; + if( m_aScale.ShiftedCategoryPosition )// if ShiftedCategoryPosition==true the tickmarks in m_aAllTickInfos are shifted { - pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos ); - pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos ); - hideIdenticalScreenValues( aAllShiftedTickInfos ); + pTickFactory2D->getAllTicks( aUnshiftedTickInfos ); + pTickFactory2D->updateScreenValues( aUnshiftedTickInfos ); + hideIdenticalScreenValues( aUnshiftedTickInfos ); } - ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos; + ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aScale.ShiftedCategoryPosition ? aUnshiftedTickInfos : m_aAllTickInfos; ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); @@ -1562,14 +1571,14 @@ void SAL_CALL VCartesianAxis::createShapes() sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size(); for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ ) - createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, false /*bOnlyAtLabels*/ ); + createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ ); } //----------------------------------------- //create axis main lines //it serves also as the handle shape for the axis selection { drawing::PointSequenceSequence aPoints(1); - apTickmarkHelper2D->createPointSequenceForAxisMainLine( aPoints ); + apTickFactory2D->createPointSequenceForAxisMainLine( aPoints ); Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints , &m_aAxisProperties.m_aLineProperties ); diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index 4fbcd2409196..d199a112bab1 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -55,20 +55,11 @@ public: virtual ~VCartesianAxis(); - //------------------------------------------------------------------------- - // partly chart2::XPlotter - //------------------------------------------------------------------------- - - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); @@ -79,7 +70,7 @@ public: sal_Int32 getTextLevelCount() const; //------------------------------------------------------------------------- - virtual TickmarkHelper* createTickmarkHelper(); + virtual TickFactory* createTickFactory(); //------------------------------------------------------------------------- double getLogicValueWhereMainLineCrossesOtherAxis() const; @@ -122,16 +113,16 @@ protected: //methods ::com::sun::star::drawing::XShapes >& xTarget , TickIter& rTickIter , AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper + , TickFactory_2D* pTickFactory , sal_Int32 nScreenDistanceBetweenTicks ); - void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels ); + void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ); - TickmarkHelper_2D* createTickmarkHelper2D(); + TickFactory_2D* createTickFactory2D(); void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const; void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties - , TickmarkHelper_2D* pTickmarkHelper2D ); + , TickFactory_2D* pTickFactory2D ); bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties , bool bIsHorizontalAxis, bool bIsVerticalAxis ); bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ); diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx index a196397e0e9f..ca83850a88ff 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -151,11 +151,7 @@ void VCartesianCoordinateSystem::createVAxisList( aAxisProperties.m_bCrossingAxisHasReverseDirection = (AxisOrientation_REVERSE==aCrossingScale.Orientation); if( aCrossingScale.AxisType == AxisType::CATEGORY ) - { aAxisProperties.m_bCrossingAxisIsCategoryAxes = true; - aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) ) - || ( aAxisProperties.m_pExplicitCategoriesProvider && aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() ); - } } if( nDimensionIndex == 2 ) @@ -169,25 +165,12 @@ void VCartesianCoordinateSystem::createVAxisList( aAxisProperties.init(true); if(aAxisProperties.m_bDisplayLabels) aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier ); - - if( nDimensionIndex == 0 && aAxisProperties.m_nAxisType == AxisType::CATEGORY - && aAxisProperties.m_pExplicitCategoriesProvider ) - { - if( aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() ) - aAxisProperties.m_bComplexCategories = true; - } //------------------- ::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) ); tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex ); m_aAxisMap[aFullAxisIndex] = apVAxis; apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos ); - //apVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); - //apVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory - // , this->createCIDForAxis( xAxis, nDimensionIndex, nAxisIndex ) ); - //if(2==nDimensionCount) - // apVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); - //apVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); } } diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index 7fe6b9937ca6..0baa9b2b6e9a 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "VCartesianGrid.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" #include "ObjectIdentifier.hxx" @@ -211,7 +211,7 @@ void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector<VLinePropert } }; -void SAL_CALL VCartesianGrid::createShapes() +void VCartesianGrid::createShapes() { if(!m_aGridPropertiesList.getLength()) return; @@ -231,13 +231,10 @@ void SAL_CALL VCartesianGrid::createShapes() //----------------------------------------- //create all scaled tickmark values - std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); - TickmarkHelper& aTickmarkHelper = *apTickmarkHelper.get(); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); + TickFactory& aTickFactory = *apTickFactory.get(); ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; - if( m_aIncrement.ShiftedPosition ) - aTickmarkHelper.getAllTicksShifted( aAllTickInfos ); - else - aTickmarkHelper.getAllTicks( aAllTickInfos ); + aTickFactory.getAllTicks( aAllTickInfos ); //----------------------------------------- //create tick mark line shapes diff --git a/chart2/source/view/axes/VCartesianGrid.hxx b/chart2/source/view/axes/VCartesianGrid.hxx index 274b543900e3..0a0f8b91716f 100644 --- a/chart2/source/view/axes/VCartesianGrid.hxx +++ b/chart2/source/view/axes/VCartesianGrid.hxx @@ -52,7 +52,7 @@ public: ); virtual ~VCartesianGrid(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); static void fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList , const ::com::sun::star::uno::Sequence< diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index bc908acdf85a..f184fbe0a1e3 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -107,7 +107,7 @@ VCoordinateSystem::~VCoordinateSystem() { } -void SAL_CALL VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes >& xLogicTarget +void VCoordinateSystem::initPlottingTargets( const Reference< drawing::XShapes >& xLogicTarget , const Reference< drawing::XShapes >& xFinalTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory , Reference< drawing::XShapes >& xLogicTargetForSeriesBehindAxis ) @@ -271,9 +271,9 @@ ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider() return m_apExplicitCategoriesProvider.get(); } -Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const +std::vector< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const { - Sequence< ExplicitScaleData > aRet(m_aExplicitScales); + std::vector< ExplicitScaleData > aRet(m_aExplicitScales); impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex ); aRet[nDimensionIndex]=this->getExplicitScale( nDimensionIndex, nAxisIndex ); @@ -281,9 +281,9 @@ Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nD return aRet; } -Sequence< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const +std::vector< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const { - Sequence< ExplicitIncrementData > aRet(m_aExplicitIncrements); + std::vector< ExplicitIncrementData > aRet(m_aExplicitIncrements); impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex ); aRet[nDimensionIndex]=this->getExplicitIncrement( nDimensionIndex, nAxisIndex ); @@ -382,6 +382,17 @@ void VCoordinateSystem::updateScalesAndIncrementsOnAxes() void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ) { + if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 ) + { + sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::MONTH; + if( !(rScaleAutomatism.getScale().TimeIncrement.TimeResolution >>= nTimeResolution) ) + { + nTimeResolution = m_aMergedMinimumAndMaximumSupplier.calculateTimeResolutionOnXAxis(); + rScaleAutomatism.setAutomaticTimeResolution( nTimeResolution ); + } + m_aMergedMinimumAndMaximumSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() ); + } + double fMin = 0.0; double fMax = 0.0; ::rtl::math::setInf(&fMin, false); @@ -403,11 +414,6 @@ void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomat fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumZ(); } - this->prepareScaleAutomatism( rScaleAutomatism, fMin, fMax, nDimIndex, nAxisIndex ); -} - -void VCoordinateSystem::prepareScaleAutomatism( ScaleAutomatism& rScaleAutomatism, double fMin, double fMax, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ) -{ //merge our values with those already contained in rScaleAutomatism rScaleAutomatism.expandValueRange( fMin, fMax ); diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index 865a7848aa9a..dcb7cd5a6303 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -120,17 +120,17 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis( rtl::OUString aLabel; if(pLabels) { - sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->fUnscaledTickValue) - 1; //first category (index 0) matches with real number 1.0 + sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0 if( nIndex>=0 && nIndex<pLabels->getLength() ) aLabel = (*pLabels)[nIndex]; } else - aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor ); if(pColorAny) *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); - double fLogicAngle = pTickInfo->fUnscaledTickValue; + double fLogicAngle = pTickInfo->getUnscaledTickValue(); LabelAlignment eLabelAlignment(LABEL_ALIGN_CENTER); PolarLabelPositionHelper aPolarLabelPositionHelper(m_pPosHelper,nDimensionCount,xTarget,&aShapeFactory); @@ -154,7 +154,7 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis( return true; } -void SAL_CALL VPolarAngleAxis::createMaximumLabels() +void VPolarAngleAxis::createMaximumLabels() { if( !prepareShapeCreation() ) return; @@ -162,7 +162,7 @@ void SAL_CALL VPolarAngleAxis::createMaximumLabels() createLabels(); } -void SAL_CALL VPolarAngleAxis::updatePositions() +void VPolarAngleAxis::updatePositions() { //todo: really only update the positions @@ -172,7 +172,7 @@ void SAL_CALL VPolarAngleAxis::updatePositions() createLabels(); } -void SAL_CALL VPolarAngleAxis::createLabels() +void VPolarAngleAxis::createLabels() { if( !prepareShapeCreation() ) return; @@ -184,7 +184,7 @@ void SAL_CALL VPolarAngleAxis::createLabels() { //----------------------------------------- //get the transformed screen values for all tickmarks in aAllTickInfos - std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + std::auto_ptr< TickFactory > apTickFactory( this->createTickFactory() ); //create tick mark text shapes //@todo: iterate through all tick depth wich should be labeled @@ -207,7 +207,7 @@ void SAL_CALL VPolarAngleAxis::createLabels() } } -void SAL_CALL VPolarAngleAxis::createShapes() +void VPolarAngleAxis::createShapes() { if( !prepareShapeCreation() ) return; diff --git a/chart2/source/view/axes/VPolarAngleAxis.hxx b/chart2/source/view/axes/VPolarAngleAxis.hxx index c03cf533e22c..011033faaefa 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.hxx +++ b/chart2/source/view/axes/VPolarAngleAxis.hxx @@ -28,6 +28,7 @@ #define _CHART2_VPOLARANGLEAXIS_HXX #include "VPolarAxis.hxx" +#include "Tickmarks_Equidistant.hxx" //............................................................................. namespace chart @@ -46,11 +47,11 @@ public: , sal_Int32 nDimensionCount ); virtual ~VPolarAngleAxis(); - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); private: //methods bool createTextShapes_ForAngleAxis( diff --git a/chart2/source/view/axes/VPolarAxis.cxx b/chart2/source/view/axes/VPolarAxis.cxx index 23908585ec3a..5f818da6c959 100644 --- a/chart2/source/view/axes/VPolarAxis.cxx +++ b/chart2/source/view/axes/VPolarAxis.cxx @@ -31,7 +31,7 @@ #include "VPolarAngleAxis.hxx" #include "VPolarRadiusAxis.hxx" #include "macros.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "ShapeFactory.hxx" #include <memory> @@ -68,12 +68,12 @@ VPolarAxis::~VPolarAxis() m_pPosHelper = NULL; } -void VPolarAxis::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements ) +void VPolarAxis::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) { m_aIncrements = rIncrements; } -sal_Bool SAL_CALL VPolarAxis::isAnythingToDraw() +sal_Bool VPolarAxis::isAnythingToDraw() { return ( 2==m_nDimension && VAxisBase::isAnythingToDraw() ); } diff --git a/chart2/source/view/axes/VPolarAxis.hxx b/chart2/source/view/axes/VPolarAxis.hxx index 8d4c14188258..a72b338416e2 100644 --- a/chart2/source/view/axes/VPolarAxis.hxx +++ b/chart2/source/view/axes/VPolarAxis.hxx @@ -47,10 +47,9 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount ); - void setIncrements( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData >& rIncrements ); + void setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ); - virtual sal_Bool SAL_CALL isAnythingToDraw(); + virtual sal_Bool isAnythingToDraw(); virtual ~VPolarAxis(); @@ -61,8 +60,7 @@ protected: protected: //member PolarPlottingPositionHelper* m_pPosHelper; - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements; + ::std::vector< ExplicitIncrementData > m_aIncrements; }; //............................................................................. diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx index 76e057a2b32d..5d13f5c46f66 100644 --- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx +++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx @@ -107,15 +107,6 @@ void VPolarCoordinateSystem::createVAxisList( tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex ); m_aAxisMap[aFullAxisIndex] = apVAxis; - //apVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) ); - //apVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory - // , this->createCIDForAxis( xAxis, nDimensionIndex, nAxisIndex ) ); - //VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( apVAxis.get() ); - //if( pVPolarAxis ) - // pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) ); - //if(2==nDimensionCount) - // apVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen ); - //apVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); } } diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index 0bd98b642acb..953b729bd453 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -29,12 +29,13 @@ #include "precompiled_chart2.hxx" #include "VPolarGrid.hxx" #include "VCartesianGrid.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" #include "ObjectIdentifier.hxx" #include "macros.hxx" #include "CommonConverters.hxx" +#include "Tickmarks_Equidistant.hxx" #include <com/sun/star/drawing/LineStyle.hpp> #include <vector> @@ -64,16 +65,16 @@ VPolarGrid::~VPolarGrid() m_pPosHelper = NULL; } -void VPolarGrid::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements ) +void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) { m_aIncrements = rIncrements; } void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const { - TickmarkHelper aTickmarkHelper( + TickFactory aTickFactory( m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] ); - aTickmarkHelper.getAllTicks( rAllTickInfos ); + aTickFactory.getAllTicks( rAllTickInfos ); } //static @@ -98,8 +99,8 @@ void VPolarGrid::createLinePointSequence_ForAngleAxis( if(nTick>=rPoints[0].getLength()) rPoints[0].realloc(rPoints[0].getLength()+30); - pTickInfo->updateUnscaledValue( xInverseScaling ); - double fLogicAngle = pTickInfo->fUnscaledTickValue; + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); + double fLogicAngle = pTickInfo->getUnscaledTickValue(); drawing::Position3D aScenePosition3D( pPosHelper->transformAngleRadiusToScene( fLogicAngle, fLogicRadius, fLogicZ ) ); rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX); @@ -153,8 +154,8 @@ void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicT if( !rTickInfo.bPaintIt ) continue; - rTickInfo.updateUnscaledValue( xInverseScaling ); - double fLogicAngle = rTickInfo.fUnscaledTickValue; + //xxxxx rTickInfo.updateUnscaledValue( xInverseScaling ); + double fLogicAngle = rTickInfo.getUnscaledTickValue(); drawing::PointSequenceSequence aPoints(1); aPoints[0].realloc(2); @@ -220,8 +221,8 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic if( !rTickInfo.bPaintIt ) continue; - rTickInfo.updateUnscaledValue( xInverseRadiusScaling ); - double fLogicRadius = rTickInfo.fUnscaledTickValue; + //xxxxx rTickInfo.updateUnscaledValue( xInverseRadiusScaling ); + double fLogicRadius = rTickInfo.getUnscaledTickValue(); double fLogicZ = -0.5;//as defined drawing::PointSequenceSequence aPoints(1); @@ -238,7 +239,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic } } -void SAL_CALL VPolarGrid::createShapes() +void VPolarGrid::createShapes() { DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized"); if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is())) diff --git a/chart2/source/view/axes/VPolarGrid.hxx b/chart2/source/view/axes/VPolarGrid.hxx index 3289d6c88be8..1ea3bccc1f90 100644 --- a/chart2/source/view/axes/VPolarGrid.hxx +++ b/chart2/source/view/axes/VPolarGrid.hxx @@ -28,7 +28,7 @@ #define _CHART2_VPOLARGRID_HXX #include "VAxisOrGridBase.hxx" -#include "TickmarkHelper.hxx" +#include "Tickmarks.hxx" #include "VLineProperties.hxx" #include <com/sun/star/drawing/PointSequenceSequence.hpp> @@ -55,16 +55,15 @@ public: ); virtual ~VPolarGrid(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); - void setIncrements( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData >& rIncrements ); + void setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ); static void createLinePointSequence_ForAngleAxis( ::com::sun::star::drawing::PointSequenceSequence& rPoints , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement - , const ::com::sun::star::chart2::ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement + , const ExplicitScaleData& rScale , PolarPlottingPositionHelper* pPosHelper , double fLogicRadius, double fLogicZ ); @@ -73,8 +72,7 @@ private: //member ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > > m_aGridPropertiesList;//main grid, subgrid, subsubgrid etc PolarPlottingPositionHelper* m_pPosHelper; - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements; + ::std::vector< ExplicitIncrementData > m_aIncrements; void getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx index 2206d4d8f559..bc56b3824e6e 100644 --- a/chart2/source/view/axes/VPolarRadiusAxis.cxx +++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx @@ -32,6 +32,7 @@ #include "VCartesianAxis.hxx" #include "PlottingPositionHelper.hxx" #include "CommonConverters.hxx" +#include "Tickmarks_Equidistant.hxx" #include <rtl/math.hxx> //............................................................................. @@ -70,7 +71,7 @@ void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMat m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix ); } -void SAL_CALL VPolarRadiusAxis::setExplicitScaleAndIncrement( +void VPolarRadiusAxis::setExplicitScaleAndIncrement( const ExplicitScaleData& rScale , const ExplicitIncrementData& rIncrement ) throw (uno::RuntimeException) @@ -79,7 +80,7 @@ void SAL_CALL VPolarRadiusAxis::setExplicitScaleAndIncrement( m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement ); } -void SAL_CALL VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget +void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory , const rtl::OUString& rCID ) @@ -89,15 +90,13 @@ void SAL_CALL VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XSh m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID ); } -void SAL_CALL VPolarRadiusAxis::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (uno::RuntimeException) +void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { VPolarAxis::setScales( rScales, bSwapXAndYAxis ); m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis ); } -void SAL_CALL VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize +void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ) { VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels ); @@ -121,22 +120,22 @@ bool VPolarRadiusAxis::prepareShapeCreation() return true; } -void SAL_CALL VPolarRadiusAxis::createMaximumLabels() +void VPolarRadiusAxis::createMaximumLabels() { m_apAxisWithLabels->createMaximumLabels(); } -void SAL_CALL VPolarRadiusAxis::updatePositions() +void VPolarRadiusAxis::updatePositions() { m_apAxisWithLabels->updatePositions(); } -void SAL_CALL VPolarRadiusAxis::createLabels() +void VPolarRadiusAxis::createLabels() { m_apAxisWithLabels->createLabels(); } -void SAL_CALL VPolarRadiusAxis::createShapes() +void VPolarRadiusAxis::createShapes() { if( !prepareShapeCreation() ) return; @@ -145,8 +144,8 @@ void SAL_CALL VPolarRadiusAxis::createShapes() const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0]; ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos; - TickmarkHelper aAngleTickmarkHelper( rAngleScale, rAngleIncrement ); - aAngleTickmarkHelper.getAllTicks( aAngleTickInfos ); + TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement ); + aAngleTickFactory.getAllTicks( aAngleTickInfos ); uno::Reference< XScaling > xInverseScaling( NULL ); if( rAngleScale.Scaling.is() ) @@ -165,8 +164,8 @@ void SAL_CALL VPolarRadiusAxis::createShapes() continue; } - pTickInfo->updateUnscaledValue( xInverseScaling ); - aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->fUnscaledTickValue ); + //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); + aAxisProperties.m_pfMainLinePositionAtOtherAxis = new double( pTickInfo->getUnscaledTickValue() ); aAxisProperties.m_bDisplayLabels=false; //------------------- diff --git a/chart2/source/view/axes/VPolarRadiusAxis.hxx b/chart2/source/view/axes/VPolarRadiusAxis.hxx index b5c5191e4c98..e1dbb8c1b1c0 100644 --- a/chart2/source/view/axes/VPolarRadiusAxis.hxx +++ b/chart2/source/view/axes/VPolarRadiusAxis.hxx @@ -50,7 +50,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~VPolarRadiusAxis(); - virtual void SAL_CALL initPlotter( + virtual void initPlotter( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -62,28 +62,24 @@ public: virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); - virtual void SAL_CALL setExplicitScaleAndIncrement( - const ::com::sun::star::chart2::ExplicitScaleData& rScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement ) + virtual void setExplicitScaleAndIncrement( + const ExplicitScaleData& rScale + , const ExplicitIncrementData& rIncrement ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL initAxisLabelProperties( + virtual void initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels ); virtual sal_Int32 estimateMaximumAutoMainIncrementCount(); - virtual void SAL_CALL createMaximumLabels(); - virtual void SAL_CALL createLabels(); - virtual void SAL_CALL updatePositions(); + virtual void createMaximumLabels(); + virtual void createLabels(); + virtual void updatePositions(); - virtual void SAL_CALL createShapes(); + virtual void createShapes(); protected: //methods virtual bool prepareShapeCreation(); diff --git a/chart2/source/view/axes/makefile.mk b/chart2/source/view/axes/makefile.mk index 96191a3a3a25..af88a61b6b37 100644 --- a/chart2/source/view/axes/makefile.mk +++ b/chart2/source/view/axes/makefile.mk @@ -47,7 +47,11 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES = \ $(SLO)$/VAxisOrGridBase.obj \ $(SLO)$/VAxisBase.obj \ - $(SLO)$/TickmarkHelper.obj \ + $(SLO)$/DateHelper.obj \ + $(SLO)$/DateScaling.obj \ + $(SLO)$/Tickmarks.obj \ + $(SLO)$/Tickmarks_Equidistant.obj \ + $(SLO)$/Tickmarks_Dates.obj \ $(SLO)$/MinimumAndMaximumSupplier.obj \ $(SLO)$/ScaleAutomatism.obj \ $(SLO)$/VAxisProperties.obj \ diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index fd1aaa81c3a0..59cde85a13fe 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -43,6 +43,7 @@ #include "Clipping.hxx" #include "Stripe.hxx" #include "PolarLabelPositionHelper.hxx" +#include "DateHelper.hxx" #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> @@ -96,6 +97,8 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel { if( !m_pMainPosHelper ) m_pMainPosHelper = new PlottingPositionHelper(); + if( m_pMainPosHelper ) + m_pMainPosHelper->DoShiftCategoryXIfShiftIsIndicated(true); PlotterBase::m_pPosHelper = m_pMainPosHelper; VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; @@ -121,18 +124,12 @@ AreaChart::~AreaChart() delete m_pMainPosHelper; } -double AreaChart::getMinimumX() -{ - if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling - return 1.0;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} - double AreaChart::getMaximumX() { + double fMax = VSeriesPlotter::getMaximumX(); if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling - return getPointCount()+1; - return VSeriesPlotter::getMaximumX(); + fMax += 1.0; + return fMax; } bool AreaChart::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) @@ -183,18 +180,6 @@ APPHELPER_XSERVICEINFO_IMPL(AreaChart,CHART2_VIEW_AREACHART_SERVICE_IMPLEMENTATI return aSNS; } */ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL AreaChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const { if( m_nKeepAspectRatio == 1 ) @@ -729,6 +714,8 @@ void AreaChart::createShapes() //collect data point information (logic coordinates, style ): double fLogicX = (*aSeriesIter)->getXValue(nIndex); + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution ); double fLogicY = (*aSeriesIter)->getYValue(nIndex); if( m_bIsPolarCooSys && m_bArea && diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 6924509a62a1..4b6ff3f45251 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -55,17 +55,7 @@ public: ); virtual ~AreaChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- @@ -75,7 +65,6 @@ public: //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - virtual double getMinimumX(); virtual double getMaximumX(); virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 0d7ef403f87d..6d94cea682dc 100755..100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -40,6 +40,7 @@ #include "macros.hxx" #include "AxisIndexDefines.hxx" #include "Clipping.hxx" +#include "DateHelper.hxx" #include <com/sun/star/chart/DataLabelPlacement.hpp> @@ -91,7 +92,6 @@ BarChart::~BarChart() PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisIndex ) const { PlottingPositionHelper& rPosHelper = VSeriesPlotter::getPlottingPositionHelper( nAxisIndex ); - BarPositionHelper* pBarPosHelper = dynamic_cast<BarPositionHelper*>(&rPosHelper); if( pBarPosHelper && nAxisIndex >= 0 ) { @@ -100,7 +100,6 @@ PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisInde if( nAxisIndex < m_aGapwidthSequence.getLength() ) pBarPosHelper->setOuterDistance( m_aGapwidthSequence[nAxisIndex]/100.0 ); } - return rPosHelper; } @@ -118,7 +117,7 @@ drawing::Direction3D BarChart::getPreferredDiagramAspectRatio() const if(!m_aZSlots.empty()) fXSlotCount = m_aZSlots.begin()->size(); - aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getSlotWidth()); + aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getScaledSlotWidth()); } else return VSeriesPlotter::getPreferredDiagramAspectRatio(); @@ -146,54 +145,6 @@ bool BarChart::keepAspectRatio() const return true; } -//------------------------------------------------------------------------- -// MinimumAndMaximumSupplier -//------------------------------------------------------------------------- - -double BarChart::getMinimumX() -{ - if( m_bCategoryXAxis ) - return 0.5;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} -double BarChart::getMaximumX() -{ - if( m_bCategoryXAxis ) - { - //return category count - sal_Int32 nPointCount = getPointCount(); - return nPointCount+0.5;//first category (index 0) matches with real number 1.0 - } - return VSeriesPlotter::getMaximumX(); -} - -//----------------------------------------------------------------- -// lang::XServiceInfo -//----------------------------------------------------------------- -/* -APPHELPER_XSERVICEINFO_IMPL(BarChart,CHART2_VIEW_BARCHART_SERVICE_IMPLEMENTATION_NAME) - - uno::Sequence< rtl::OUString > BarChart -::getSupportedServiceNames_Static() -{ - uno::Sequence< rtl::OUString > aSNS( 1 ); - aSNS.getArray()[ 0 ] = CHART2_VIEW_BARCHART_SERVICE_NAME; - return aSNS; -} -*/ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL BarChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ - awt::Point BarChart::getLabelScreenPositionAndAlignment( LabelAlignment& rAlignment, sal_Int32 nLabelPlacement , double fScaledX, double fScaledLowerYValue, double fScaledUpperYValue, double fScaledZ @@ -514,12 +465,11 @@ void BarChart::createShapes() sal_Int32 nCreatedPoints = 0; // - //(@todo maybe different iteration for breaks in axis ?) - sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive - sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive + sal_Int32 nStartIndex = 0; + sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); //============================================================================= - //iterate through all shown categories - for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex < nEndCategoryIndex; nCatIndex++ ) + //iterate through all x values per indices + for( sal_Int32 nPointIndex = nStartIndex; nPointIndex < nEndIndex; nPointIndex++ ) { ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin(); const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end(); @@ -538,7 +488,7 @@ void BarChart::createShapes() aLogicYSumMap[nAttachedAxisIndex]=0.0; double fMinimumY = 0.0, fMaximumY = 0.0; - aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex + aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex , isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); if( !::rtl::math::isNan( fMaximumY ) && fMaximumY > 0) @@ -574,14 +524,14 @@ void BarChart::createShapes() //update/create information for current group pPosHelper->updateSeriesCount( aZSlotIter->size() ); - double fLogicBaseWidth = pPosHelper->getSlotWidth(); + double fLogicBaseWidth = pPosHelper->getScaledSlotWidth(); ::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector); // get distance from base value to maximum and minimum double fMinimumY = 0.0, fMaximumY = 0.0; - aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex + aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex , isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); double fLogicPositiveYSum = 0.0; @@ -633,7 +583,7 @@ void BarChart::createShapes() bOnlyConnectionLinesForThisPoint = false; - if(nCatIndex==nStartCategoryIndex)//do not create a regression line for each point + if(nPointIndex==nStartIndex)//do not create a regression line for each point createRegressionCurvesShapes( **aSeriesIter, xRegressionCurveTarget, xRegressionCurveEquationTarget, m_pPosHelper->maySkipPointsInRegressionCalculation()); @@ -658,8 +608,17 @@ void BarChart::createShapes() getSeriesGroupShape(*aSeriesIter, xSeriesTarget) ); //collect data point information (logic coordinates, style ): - double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nCatIndex ), fSlotX ); - double fLogicBarHeight = (*aSeriesIter)->getYValue( nCatIndex ); + double fUnscaledLogicX = (*aSeriesIter)->getXValue( nPointIndex ); + fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution ); + if(fUnscaledLogicX<pPosHelper->getLogicMinX()) + continue;//point not visible + if(fUnscaledLogicX>pPosHelper->getLogicMaxX()) + continue;//point not visible + if(pPosHelper->isStrongLowerXRequested() && fUnscaledLogicX==pPosHelper->getLogicMaxX()) + continue;//point not visible + double fLogicX = pPosHelper->getScaledSlotPos( fUnscaledLogicX, fSlotX ); + + double fLogicBarHeight = (*aSeriesIter)->getYValue( nPointIndex ); if( ::rtl::math::isNan( fLogicBarHeight )) //no value at this category continue; @@ -686,7 +645,7 @@ void BarChart::createShapes() if(m_nDimension==3) fLogicZ = nZ; - drawing::Position3D aUnscaledLogicPosition( fLogicX, fUpperYValue, fLogicZ ); + drawing::Position3D aUnscaledLogicPosition( fUnscaledLogicX, fUpperYValue, fLogicZ ); //@todo ... start an iteration over the different breaks of the axis //each subsystem may add an additional shape to form the whole point @@ -696,7 +655,7 @@ void BarChart::createShapes() // uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY ); //as long as we do not iterate we do not need to create an additional group for each point uno::Reference< drawing::XShapes > xPointGroupShape_Shapes = xSeriesGroupShape_Shapes; - uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nCatIndex ) ); + uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nPointIndex ) ); sal_Int32 nGeometry3D = DataPointGeometry3D::CUBOID; if(m_nDimension==3) try { @@ -763,7 +722,7 @@ void BarChart::createShapes() //better performance for big data FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); - if( !pSeries->isAttributedDataPoint(nCatIndex) + if( !pSeries->isAttributedDataPoint(nPointIndex) && pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fUpperY, aFormerPoint.m_fZ , fLogicX, fUpperYValue, fLogicZ ) @@ -883,20 +842,20 @@ void BarChart::createShapes() //set name/classified ObjectID (CID) ShapeFactory::setShapeName(xShape , ObjectIdentifier::createPointCID( - (*aSeriesIter)->getPointCID_Stub(),nCatIndex) ); + (*aSeriesIter)->getPointCID_Stub(),nPointIndex) ); } //create error bar - createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nCatIndex, m_xLogicTarget ); + createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nPointIndex, m_xLogicTarget ); //------------ //create data point label - if( (**aSeriesIter).getDataPointLabelIfLabel(nCatIndex) ) + if( (**aSeriesIter).getDataPointLabelIfLabel(nPointIndex) ) { double fLogicSum = aLogicYSumMap[nAttachedAxisIndex]; LabelAlignment eAlignment(LABEL_ALIGN_CENTER); - sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nCatIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() ); + sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nPointIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() ); double fLowerBarDepth = fLogicBarDepth; double fUpperBarDepth = fLogicBarDepth; @@ -921,7 +880,7 @@ void BarChart::createShapes() if( m_nDimension == 3 ) nOffset = 260; } - this->createDataLabel( xTextTarget, **aSeriesIter, nCatIndex + this->createDataLabel( xTextTarget, **aSeriesIter, nPointIndex , fLogicValueForLabeDisplay, fLogicSum, aScreenPosition2D, eAlignment, nOffset ); } diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx index 403628f7fc43..c20c85168b5d 100644 --- a/chart2/source/view/charttypes/BarChart.hxx +++ b/chart2/source/view/charttypes/BarChart.hxx @@ -47,17 +47,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~BarChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- @@ -65,12 +55,6 @@ public: virtual bool keepAspectRatio() const; //------------------------------------------------------------------------- - // MinimumAndMaximumSupplier - //------------------------------------------------------------------------- - virtual double getMinimumX(); - virtual double getMaximumX(); - - //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/BarPositionHelper.cxx b/chart2/source/view/charttypes/BarPositionHelper.cxx index b1735e99de5d..bd013b08207d 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.cxx +++ b/chart2/source/view/charttypes/BarPositionHelper.cxx @@ -32,6 +32,8 @@ #include "Linear3DTransformation.hxx" #include "ViewDefines.hxx" #include "CommonConverters.hxx" +#include "DateHelper.hxx" +#include <com/sun/star/chart/TimeUnit.hpp> //............................................................................. namespace chart @@ -43,6 +45,7 @@ using namespace ::com::sun::star::chart2; BarPositionHelper::BarPositionHelper( bool /* bSwapXAndY */ ) : CategoryPositionHelper( 1 ) { + DoShiftCategoryXIfShiftIsIndicated(true); } BarPositionHelper::BarPositionHelper( const BarPositionHelper& rSource ) @@ -66,73 +69,23 @@ void BarPositionHelper::updateSeriesCount( double fSeriesCount ) m_fSeriesCount = fSeriesCount; } -uno::Reference< XTransformation > BarPositionHelper::getTransformationScaledLogicToScene() const +double BarPositionHelper::getScaledSlotPos( double fUnscaledLogicX, double fSeriesNumber ) const { - //transformation from 2) to 4) //@todo 2) and 4) need a link to a document + if( m_bDateAxis ) + fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution ); + double fScaledLogicX(fUnscaledLogicX); + doLogicScaling(&fScaledLogicX,NULL,NULL); + fScaledLogicX = CategoryPositionHelper::getScaledSlotPos( fScaledLogicX, fSeriesNumber ); + //MaybeShiftCategoryX( fScaledLogicX ); + return fScaledLogicX; - //we need to apply this transformation to each geometric object because of a bug/problem - //of the old drawing layer (the UNO_NAME_3D_EXTRUDE_DEPTH is an integer value instead of an double ) - - if( !m_xTransformationLogicToScene.is() ) - { - ::basegfx::B3DHomMatrix aMatrix; - - double MinX = getLogicMinX(); - double MinY = getLogicMinY(); - double MinZ = getLogicMinZ(); - double MaxX = getLogicMaxX(); - double MaxY = getLogicMaxY(); - double MaxZ = getLogicMaxZ(); - - AxisOrientation nXAxisOrientation = m_aScales[0].Orientation; - AxisOrientation nYAxisOrientation = m_aScales[1].Orientation; - AxisOrientation nZAxisOrientation = m_aScales[2].Orientation; - - //apply scaling - //scaling of x axis is refused/ignored - doLogicScaling( NULL, &MinY, &MinZ ); - doLogicScaling( NULL, &MaxY, &MaxZ); - - if(m_bSwapXAndY) - { - std::swap(MinX,MinY); - std::swap(MaxX,MaxY); - std::swap(nXAxisOrientation,nYAxisOrientation); - } - - if( AxisOrientation_MATHEMATICAL==nXAxisOrientation ) - aMatrix.translate(-MinX,0.0,0.0); - else - aMatrix.translate(-MaxX,0.0,0.0); - if( AxisOrientation_MATHEMATICAL==nYAxisOrientation ) - aMatrix.translate(0.0,-MinY,0.0); - else - aMatrix.translate(0.0,-MaxY,0.0); - if( AxisOrientation_MATHEMATICAL==nZAxisOrientation ) - aMatrix.translate(0.0,0.0,-MaxZ);//z direction in draw is reverse mathematical direction - else - aMatrix.translate(0.0,0.0,-MinZ); - - double fWidthX = MaxX - MinX; - double fWidthY = MaxY - MinY; - double fWidthZ = MaxZ - MinZ; - - double fScaleDirectionX = AxisOrientation_MATHEMATICAL==nXAxisOrientation ? 1.0 : -1.0; - double fScaleDirectionY = AxisOrientation_MATHEMATICAL==nYAxisOrientation ? 1.0 : -1.0; - double fScaleDirectionZ = AxisOrientation_MATHEMATICAL==nZAxisOrientation ? -1.0 : 1.0; - - aMatrix.scale(fScaleDirectionX*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthX - , fScaleDirectionY*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY - , fScaleDirectionZ*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthZ); - - //if(nDim==2) - aMatrix = m_aMatrixScreenToScene*aMatrix; - - m_xTransformationLogicToScene = new Linear3DTransformation(B3DHomMatrixToHomogenMatrix( aMatrix ),m_bSwapXAndY); - } - return m_xTransformationLogicToScene; } +void BarPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth ) +{ + m_fScaledCategoryWidth = fScaledCategoryWidth; + CategoryPositionHelper::setCategoryWidth( m_fScaledCategoryWidth ); +} //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/charttypes/BarPositionHelper.hxx b/chart2/source/view/charttypes/BarPositionHelper.hxx index 32899de62aef..3a905877bcb9 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.hxx +++ b/chart2/source/view/charttypes/BarPositionHelper.hxx @@ -49,25 +49,10 @@ public: virtual PlottingPositionHelper* clone() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation > - getTransformationScaledLogicToScene() const; - void updateSeriesCount( double fSeriesCount ); /*only enter the size of x stacked series*/ - sal_Int32 getStartCategoryIndex() const { - //first category (index 0) matches with real number 1.0 - sal_Int32 nStart = static_cast<sal_Int32>(getLogicMinX() - 0.5); - if( nStart < 0 ) - nStart = 0; - return nStart; - } - sal_Int32 getEndCategoryIndex() const { - //first category (index 0) matches with real number 1.0 - sal_Int32 nEnd = static_cast<sal_Int32>(getLogicMaxX() - 0.5); - if( nEnd < 0 ) - nEnd = 0; - return nEnd; - } + virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const; + virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); }; //............................................................................. diff --git a/chart2/source/view/charttypes/BubbleChart.hxx b/chart2/source/view/charttypes/BubbleChart.hxx index 9c04ce8d3719..ed3d9e051cc4 100644 --- a/chart2/source/view/charttypes/BubbleChart.hxx +++ b/chart2/source/view/charttypes/BubbleChart.hxx @@ -46,11 +46,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~BubbleChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index ddfe50deed2f..b9ce0883d2f0 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -30,8 +30,6 @@ #include "CandleStickChart.hxx" #include "ShapeFactory.hxx" -//#include "chartview/servicenames_charttypes.hxx" -//#include "servicenames_coosystems.hxx" #include "CommonConverters.hxx" #include "ObjectIdentifier.hxx" #include "LabelPositionHelper.hxx" @@ -40,6 +38,7 @@ #include "VLegendSymbolFactory.hxx" #include "FormattedStringHelper.hxx" #include "DataSeriesHelper.hxx" +#include "DateHelper.hxx" #include <tools/debug.hxx> #include <rtl/math.hxx> #include <editeng/unoprnms.hxx> @@ -76,22 +75,6 @@ CandleStickChart::~CandleStickChart() // MinimumAndMaximumSupplier //------------------------------------------------------------------------- -double CandleStickChart::getMinimumX() -{ - if( m_bCategoryXAxis ) - return 0.5;//first category (index 0) matches with real number 1.0 - return VSeriesPlotter::getMinimumX(); -} -double CandleStickChart::getMaximumX() -{ - if( m_bCategoryXAxis ) - { - //return category count - sal_Int32 nPointCount = getPointCount(); - return nPointCount+0.5;//first category (index 0) matches with real number 1.0 - } - return VSeriesPlotter::getMaximumX(); -} bool CandleStickChart::isSeperateStackingForDifferentSigns( sal_Int32 /* nDimensionIndex */ ) { return false; @@ -120,18 +103,6 @@ APPHELPER_XSERVICEINFO_IMPL(CandleStickChart,CHART2_VIEW_CANDLESTICKCHART_SERVIC return aSNS; } */ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL CandleStickChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; -} -*/ drawing::Direction3D CandleStickChart::getPreferredDiagramAspectRatio() const { @@ -205,11 +176,11 @@ void CandleStickChart::createShapes() } //(@todo maybe different iteration for breaks in axis ?) - sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive - sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive + sal_Int32 nStartIndex = 0; + sal_Int32 nEndIndex = VSeriesPlotter::getPointCount(); //============================================================================= - //iterate through all shown categories - for( sal_Int32 nIndex = nStartCategoryIndex; nIndex < nEndCategoryIndex; nIndex++ ) + //iterate through all x values per indices + for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ ) { ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin(); const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end(); @@ -247,28 +218,48 @@ void CandleStickChart::createShapes() for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ ) { //collect data point information (logic coordinates, style ): - double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nIndex ), fSlotX ); - double fY_First = (*aSeriesIter)->getY_First( nIndex ); - double fY_Last = (*aSeriesIter)->getY_Last( nIndex ); - double fY_Min = (*aSeriesIter)->getY_Min( nIndex ); - double fY_Max = (*aSeriesIter)->getY_Max( nIndex ); + double fUnscaledX = (*aSeriesIter)->getXValue( nIndex ); + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + fUnscaledX = DateHelper::RasterizeDateValue( fUnscaledX, m_aNullDate, m_nTimeResolution ); + if(fUnscaledX<pPosHelper->getLogicMinX() || fUnscaledX>pPosHelper->getLogicMaxX()) + continue;//point not visible + double fScaledX = pPosHelper->getScaledSlotPos( fUnscaledX, fSlotX ); + + double fUnscaledY_First = (*aSeriesIter)->getY_First( nIndex ); + double fUnscaledY_Last = (*aSeriesIter)->getY_Last( nIndex ); + double fUnscaledY_Min = (*aSeriesIter)->getY_Min( nIndex ); + double fUnscaledY_Max = (*aSeriesIter)->getY_Max( nIndex ); bool bBlack=false; - if(fY_Last<=fY_First) + if(fUnscaledY_Last<=fUnscaledY_First) { - std::swap(fY_First,fY_Last); + std::swap(fUnscaledY_First,fUnscaledY_Last); bBlack=true; } - if(fY_Max<fY_Min) - std::swap(fY_Min,fY_Max); + if(fUnscaledY_Max<fUnscaledY_Min) + std::swap(fUnscaledY_Min,fUnscaledY_Max); //transformation 3) -> 4) - double fHalfWidth = pPosHelper->getSlotWidth()/2.0; - drawing::Position3D aPosLeftFirst( pPosHelper->transformLogicToScene( fLogicX-fHalfWidth, fY_First ,0 ,true ) ); - drawing::Position3D aPosRightLast( pPosHelper->transformLogicToScene( fLogicX+fHalfWidth, fY_Last ,0 ,true ) ); - drawing::Position3D aPosMiddleFirst( pPosHelper->transformLogicToScene( fLogicX, fY_First ,0 ,true ) ); - drawing::Position3D aPosMiddleLast( pPosHelper->transformLogicToScene( fLogicX, fY_Last ,0 ,true ) ); - drawing::Position3D aPosMiddleMinimum( pPosHelper->transformLogicToScene( fLogicX, fY_Min ,0 ,true ) ); - drawing::Position3D aPosMiddleMaximum( pPosHelper->transformLogicToScene( fLogicX, fY_Max ,0 ,true ) ); + double fHalfScaledWidth = pPosHelper->getScaledSlotWidth()/2.0; + + double fScaledY_First(fUnscaledY_First); + double fScaledY_Last(fUnscaledY_Last); + double fScaledY_Min(fUnscaledY_Min); + double fScaledY_Max(fUnscaledY_Max); + pPosHelper->clipLogicValues( 0,&fScaledY_First,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Last,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Min,0 ); + pPosHelper->clipLogicValues( 0,&fScaledY_Max,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_First,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Last,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Min,0 ); + pPosHelper->doLogicScaling( 0,&fScaledY_Max,0 ); + + drawing::Position3D aPosLeftFirst( pPosHelper->transformScaledLogicToScene( fScaledX-fHalfScaledWidth, fScaledY_First ,0 ,true ) ); + drawing::Position3D aPosRightLast( pPosHelper->transformScaledLogicToScene( fScaledX+fHalfScaledWidth, fScaledY_Last ,0 ,true ) ); + drawing::Position3D aPosMiddleFirst( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_First ,0 ,true ) ); + drawing::Position3D aPosMiddleLast( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Last ,0 ,true ) ); + drawing::Position3D aPosMiddleMinimum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Min ,0 ,true ) ); + drawing::Position3D aPosMiddleMaximum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Max ,0 ,true ) ); uno::Reference< drawing::XShapes > xLossGainTarget( xGainTarget ); if(bBlack) @@ -329,13 +320,13 @@ void CandleStickChart::createShapes() drawing::PolyPolygonShape3D aPoly; sal_Int32 nLineIndex = 0; - if( bShowFirst && pPosHelper->isLogicVisible( fLogicX, fY_First ,0 ) + if( bShowFirst && pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_First ,0 ) && isValidPosition(aPosLeftFirst) && isValidPosition(aPosMiddleFirst) ) { AddPointToPoly( aPoly, aPosLeftFirst, nLineIndex ); AddPointToPoly( aPoly, aPosMiddleFirst, nLineIndex++ ); } - if( pPosHelper->isLogicVisible( fLogicX, fY_Last ,0 ) + if( pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_Last ,0 ) && isValidPosition(aPosMiddleLast) && isValidPosition(aPosRightLast) ) { AddPointToPoly( aPoly, aPosMiddleLast, nLineIndex ); @@ -361,16 +352,16 @@ void CandleStickChart::createShapes() { if(isValidPosition(aPosMiddleFirst)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM ); + , fUnscaledY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM ); if(isValidPosition(aPosMiddleLast)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP ); + , fUnscaledY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP ); if(isValidPosition(aPosMiddleMinimum)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM ); + , fUnscaledY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM ); if(isValidPosition(aPosMiddleMaximum)) this->createDataLabel( xTextTarget, **aSeriesIter, nIndex - , fY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP ); + , fUnscaledY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP ); } }//next series in x slot (next y slot) }//next x slot diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index 60018dbe8621..6fbf980058e7 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -47,16 +47,7 @@ public: , sal_Int32 nDimensionCount ); virtual ~CandleStickChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ + virtual void createShapes(); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const; @@ -64,8 +55,6 @@ public: //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - virtual double getMinimumX(); - virtual double getMaximumX(); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.cxx b/chart2/source/view/charttypes/CategoryPositionHelper.cxx index d43fd0856e02..76f07168bdf2 100644 --- a/chart2/source/view/charttypes/CategoryPositionHelper.cxx +++ b/chart2/source/view/charttypes/CategoryPositionHelper.cxx @@ -57,7 +57,7 @@ CategoryPositionHelper::~CategoryPositionHelper() { } -double CategoryPositionHelper::getSlotWidth() const +double CategoryPositionHelper::getScaledSlotWidth() const { double fWidth = m_fCategoryWidth / ( m_fSeriesCount @@ -66,14 +66,14 @@ double CategoryPositionHelper::getSlotWidth() const return fWidth; } -double CategoryPositionHelper::getSlotPos( double fCategoryX, double fSeriesNumber ) const +double CategoryPositionHelper::getScaledSlotPos( double fScaledXPos, double fSeriesNumber ) const { //the returned position is in the middle of the rect //fSeriesNumber 0...n-1 - double fPos = fCategoryX - (m_fCategoryWidth/2.0) - + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getSlotWidth() - + getSlotWidth()/2.0; - + double fPos = fScaledXPos + - (m_fCategoryWidth/2.0) + + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getScaledSlotWidth() + + getScaledSlotWidth()/2.0; return fPos; } @@ -95,6 +95,11 @@ void CategoryPositionHelper::setOuterDistance( double fOuterDistance ) m_fOuterDistance = fOuterDistance; } +void CategoryPositionHelper::setCategoryWidth( double fCategoryWidth ) +{ + m_fCategoryWidth = fCategoryWidth; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.hxx b/chart2/source/view/charttypes/CategoryPositionHelper.hxx index 08cb1978faa1..c12d17d40b03 100644 --- a/chart2/source/view/charttypes/CategoryPositionHelper.hxx +++ b/chart2/source/view/charttypes/CategoryPositionHelper.hxx @@ -44,8 +44,9 @@ public: CategoryPositionHelper( const CategoryPositionHelper& rSource ); virtual ~CategoryPositionHelper(); - double getSlotWidth() const; - double getSlotPos( double fCategoryX, double fSeriesNumber ) const; + double getScaledSlotWidth() const; + virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const; + virtual void setCategoryWidth( double fCategoryWidth ); //Distance between two neighboring bars in same category, seen relative to width of the bar void setInnerDistance( double fInnerDistance ); diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index eee13848b11b..1c26f0596c78 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -159,11 +159,9 @@ PieChart::~PieChart() //----------------------------------------------------------------- -void SAL_CALL PieChart::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool /* bSwapXAndYAxis */ ) - throw (uno::RuntimeException) +void PieChart::setScales( const std::vector< ExplicitScaleData >& rScales, bool /* bSwapXAndYAxis */ ) { - DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + DBG_ASSERT(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); m_pPosHelper->setScales( rScales, true ); } diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index e6fedb05d52e..c306e2db256f 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -49,24 +49,10 @@ public: , sal_Int32 nDimensionCount, bool bExcludingPositioning ); virtual ~PieChart(); - //------------------------------------------------------------------------- - // chart2::XPlotter - //------------------------------------------------------------------------- - - virtual void SAL_CALL createShapes(); + virtual void createShapes(); virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ - + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); //------------------- diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 840cbbe3e1e1..6ec5e1613c45 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -52,6 +52,7 @@ #include "ResId.hxx" #include "Strings.hrc" #include "RelativePositionHelper.hxx" +#include "DateHelper.hxx" //only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory #include "BarChart.hxx" @@ -62,6 +63,7 @@ // #include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/chart/TimeUnit.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> @@ -155,6 +157,8 @@ VSeriesPlotter::VSeriesPlotter( const uno::Reference<XChartType>& xChartTypeMode , m_xChartTypeModelProps( uno::Reference< beans::XPropertySet >::query( xChartTypeModel )) , m_aZSlots() , m_bCategoryXAxis(bCategoryXAxis) + , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY) + , m_aNullDate(30,12,1899) , m_xColorScheme() , m_pExplicitCategoriesProvider(0) , m_bPointsWereSkipped(false) @@ -201,7 +205,17 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 return; if(m_bCategoryXAxis) - pSeries->setCategoryXAxis(); + { + if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + pSeries->setXValues( m_pExplicitCategoriesProvider->getOriginalCategories() ); + else + pSeries->setCategoryXAxis(); + } + else + { + if( m_pExplicitCategoriesProvider ) + pSeries->setXValuesIfNone( m_pExplicitCategoriesProvider->getOriginalCategories() ); + } if(zSlot<0 || zSlot>=static_cast<sal_Int32>(m_aZSlots.size())) { @@ -936,13 +950,13 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries aRegressionPoly.SequenceZ[0].realloc(nRegressionPointCount); sal_Int32 nRealPointCount=0; - uno::Sequence< chart2::ExplicitScaleData > aScaleDataSeq( m_pPosHelper->getScales()); + std::vector< ExplicitScaleData > aScales( m_pPosHelper->getScales()); uno::Reference< chart2::XScaling > xScalingX; uno::Reference< chart2::XScaling > xScalingY; - if( aScaleDataSeq.getLength() >= 2 ) + if( aScales.size() >= 2 ) { - xScalingX.set( aScaleDataSeq[0].Scaling ); - xScalingY.set( aScaleDataSeq[1].Scaling ); + xScalingX.set( aScales[0].Scaling ); + xScalingY.set( aScales[1].Scaling ); } uno::Sequence< geometry::RealPoint2D > aCalculatedPoints( @@ -1126,19 +1140,71 @@ void VSeriesPlotter::setMappedProperties( PropertyMapper::setMappedProperties(xTargetProp,xSource,rMap,pOverwriteMap); } +void VSeriesPlotter::setTimeResolutionOnXAxis( long TimeResolution, const Date& rNullDate ) +{ + m_nTimeResolution = TimeResolution; + m_aNullDate = rNullDate; +} + //------------------------------------------------------------------------- // MinimumAndMaximumSupplier //------------------------------------------------------------------------- - +long VSeriesPlotter::calculateTimeResolutionOnXAxis() +{ + long nRet = ::com::sun::star::chart::TimeUnit::YEAR; + if( m_pExplicitCategoriesProvider ) + { + const std::vector< DatePlusIndex >& rDateCategories = m_pExplicitCategoriesProvider->getDateCategories(); + std::vector< DatePlusIndex >::const_iterator aIt = rDateCategories.begin(), aEnd = rDateCategories.end(); + Date aNullDate(30,12,1899); + if( m_apNumberFormatterWrapper.get() ) + aNullDate = m_apNumberFormatterWrapper->getNullDate(); + if( aIt!=aEnd ) + { + Date aPrevious(aNullDate); aPrevious+=rtl::math::approxFloor(aIt->fValue); + ++aIt; + for(;aIt!=aEnd;++aIt) + { + Date aCurrent(aNullDate); aCurrent+=rtl::math::approxFloor(aIt->fValue); + if( ::com::sun::star::chart::TimeUnit::YEAR == nRet ) + { + if( DateHelper::IsInSameYear( aPrevious, aCurrent ) ) + nRet = ::com::sun::star::chart::TimeUnit::MONTH; + } + if( ::com::sun::star::chart::TimeUnit::MONTH == nRet ) + { + if( DateHelper::IsInSameMonth( aPrevious, aCurrent ) ) + nRet = ::com::sun::star::chart::TimeUnit::DAY; + } + if( ::com::sun::star::chart::TimeUnit::DAY == nRet ) + break; + aPrevious=aCurrent; + } + } + } + return nRet; +} double VSeriesPlotter::getMinimumX() { + /* if( m_bCategoryXAxis ) { - double fRet = 1.0;//first category (index 0) matches with real number 1.0 + double fRet = 1.0;//first text category (index 0) matches with real number 1.0 if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) fRet -= 0.5; + else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + { + const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); + DBG_ASSERT(!rDateCategories.empty(),"need date values"); + if(!rDateCategories.empty()) + { + DatePlusIndex aFirst = rDateCategories.front(); + fRet = aFirst.fValue; + } + } return fRet; } + */ double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); @@ -1146,14 +1212,26 @@ double VSeriesPlotter::getMinimumX() } double VSeriesPlotter::getMaximumX() { + /* if( m_bCategoryXAxis ) { - //return category count + //return category count for pure text axis double fRet = getPointCount();//first category (index 0) matches with real number 1.0 if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) fRet += 0.5; + else if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) + { + const std::vector< DatePlusIndex >& rDateCategories( m_pExplicitCategoriesProvider->getDateCategories() ); + DBG_ASSERT(!rDateCategories.empty(),"need date values"); + if(!rDateCategories.empty()) + { + DatePlusIndex aLast = rDateCategories.back(); + fRet = aLast.fValue; + } + } return fRet; } + */ double fMinimum, fMaximum; this->getMinimumAndMaximiumX( fMinimum, fMaximum ); @@ -1162,7 +1240,7 @@ double VSeriesPlotter::getMaximumX() double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) { - if( !m_bCategoryXAxis ) + if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) ) { double fMinY, fMaxY; this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex ); @@ -1196,7 +1274,7 @@ double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, s double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) { - if( !m_bCategoryXAxis ) + if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) ) { double fMinY, fMaxY; this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex ); @@ -1603,7 +1681,7 @@ double VSeriesPlotter::getTransformedDepth() const return FIXED_SIZE_FOR_3D_CHART_VOLUME/(MaxZ-MinZ); } -void SAL_CALL VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) +void VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) throw (uno::RuntimeException) { if( nAxisIndex<1 ) @@ -1633,9 +1711,9 @@ PlottingPositionHelper& VSeriesPlotter::getPlottingPositionHelper( sal_Int32 nAx } } if( !pRet ) - { pRet = m_pMainPosHelper; - } + if(pRet) + pRet->setTimeResolution( m_nTimeResolution, m_aNullDate ); return *pRet; } diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 4174226b6f62..1e5911b76358 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -107,7 +107,7 @@ VDiagram::~VDiagram() delete m_pShapeFactory; } -void SAL_CALL VDiagram::init( +void VDiagram::init( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xFactory ) diff --git a/chart2/source/view/inc/DateHelper.hxx b/chart2/source/view/inc/DateHelper.hxx new file mode 100644 index 000000000000..c2352e246695 --- /dev/null +++ b/chart2/source/view/inc/DateHelper.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * 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 _CHART2_DATEHELPER_HXX +#define _CHART2_DATEHELPER_HXX + +#include <com/sun/star/chart2/XScaling.hpp> +#include <tools/date.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class DateHelper +{ +public: + static bool IsInSameYear( const Date& rD1, const Date& rD2 ); + static bool IsInSameMonth( const Date& rD1, const Date& rD2 ); + + static long GetMonthsBetweenDates( Date aD1, Date aD2 ); + static Date GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ); + static Date GetDateSomeYearsAway( const Date& rD, long nYearDistance ); + static bool IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ); + static bool IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ); + + static double RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx index 1e53d5c144c5..dee1fec8e67d 100644 --- a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx +++ b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx @@ -29,7 +29,7 @@ #define _CHART2_MINIMUMANDMAXIMUMSUPPLIER_HXX #include <sal/types.h> - +#include <tools/date.hxx> #include <set> //............................................................................. @@ -60,6 +60,10 @@ public: virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) = 0; virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) = 0; virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) = 0; + + //return a constant out of ::com::sun::star::chart::TimeUnit that allows to display the smallest distance between occuring dates + virtual long calculateTimeResolutionOnXAxis() = 0; + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ) = 0; }; class MergedMinimumAndMaximumSupplier : public MinimumAndMaximumSupplier @@ -86,6 +90,9 @@ public: virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); + virtual long calculateTimeResolutionOnXAxis(); + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ); + private: typedef ::std::set< MinimumAndMaximumSupplier* > MinimumAndMaximumSupplierSet; MinimumAndMaximumSupplierSet m_aMinimumAndMaximumSupplierList; diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx index 63e276b19e44..7920845248e4 100644 --- a/chart2/source/view/inc/PlotterBase.hxx +++ b/chart2/source/view/inc/PlotterBase.hxx @@ -27,28 +27,18 @@ #ifndef _CHART2_PLOTTERBASE_HXX #define _CHART2_PLOTTERBASE_HXX +#include "chartview/ExplicitScaleValues.hxx" + #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/drawing/Position3D.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -/* -#include <com/sun/star/lang/XComponent.hpp> -*/ - -//---- -#include <vector> - -//---- chart2 -#include <com/sun/star/chart2/ExplicitScaleData.hpp> #include <com/sun/star/chart2/XTransformation.hpp> -/* -#include <com/sun/star/chart2/XPlotter.hpp> -*/ -//---- #include <cppuhelper/implbase1.hxx> +#include <vector> //............................................................................. namespace chart @@ -64,8 +54,7 @@ public: PlotterBase( sal_Int32 nDimension ); virtual ~PlotterBase(); - // ___chart2::XPlotter___ - virtual void SAL_CALL initPlotter( + virtual void initPlotter( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -75,21 +64,13 @@ public: , const rtl::OUString& rCID ) throw (::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setScales( - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (::com::sun::star::uno::RuntimeException); + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); - virtual void SAL_CALL createShapes() = 0; + virtual void createShapes() = 0; static bool isValidPosition( const ::com::sun::star::drawing::Position3D& rPos ); - /* - virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); - */ //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index a1f16883b779..6bd25d8f92e3 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -28,9 +28,10 @@ #define _CHART2_PLOTTINGPOSITIONHELPER_HXX #include "LabelAlignment.hxx" +#include "chartview/ExplicitScaleValues.hxx" + #include <basegfx/range/b2drectangle.hxx> #include <rtl/math.hxx> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> #include <com/sun/star/chart2/XTransformation.hpp> #include <com/sun/star/drawing/Direction3D.hpp> #include <com/sun/star/drawing/HomogenMatrix.hpp> @@ -62,23 +63,22 @@ public: virtual ~PlottingPositionHelper(); virtual PlottingPositionHelper* clone() const; - virtual PlottingPositionHelper* createSecondaryPosHelper( const ::com::sun::star::chart2::ExplicitScaleData& rSecondaryScale ); + virtual PlottingPositionHelper* createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ); virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix); - virtual void setScales( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ); - const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& getScales() const; + virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); + const ::std::vector< ExplicitScaleData >& getScales() const; //better performance for big data inline void setCoordinateSystemResolution( const ::com::sun::star::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution ); inline bool isSameForGivenResolution( double fX, double fY, double fZ , double fX2, double fY2, double fZ2 ); + inline bool isStrongLowerXRequested() const; inline bool isLogicVisible( double fX, double fY, double fZ ) const; inline void doLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; + inline void doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip=false ) const; inline void clipLogicValues( double* pX, double* pY, double* pZ ) const; void clipScaledLogicValues( double* pX, double* pY, double* pZ ) const; inline bool clipYRange( double& rMin, double& rMax ) const; @@ -123,10 +123,14 @@ public: inline bool maySkipPointsInRegressionCalculation() const; + void setTimeResolution( long nTimeResolution, const Date& rNullDate ); + virtual void setScaledCategoryWidth( double fScaledCategoryWidth ); + void MaybeShiftCategoryX( double& fScaledXValue ) const; + void DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ); + protected: //member - ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData > m_aScales; - ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; + ::std::vector< ExplicitScaleData > m_aScales; + ::basegfx::B3DHomMatrix m_aMatrixScreenToScene; //this is calculated based on m_aScales and m_aMatrixScreenToScene mutable ::com::sun::star::uno::Reference< @@ -139,6 +143,13 @@ protected: //member sal_Int32 m_nZResolution; bool m_bMaySkipPointsInRegressionCalculation; + + bool m_bDateAxis; + long m_nTimeResolution; + Date m_aNullDate; + + double m_fScaledCategoryWidth; + bool m_DoShiftCategoryXIfShiftIsIndicated; }; //describes wich axis of the drawinglayer scene or sreen axis are the normal axis @@ -163,9 +174,7 @@ public: virtual PlottingPositionHelper* clone() const; virtual void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix); - virtual void setScales( const ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ); + virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ); ::basegfx::B3DHomMatrix getUnitCartesianToScene() const; @@ -227,14 +236,14 @@ private: bool PolarPlottingPositionHelper::isMathematicalOrientationAngle() const { - const ::com::sun::star::chart2::ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2]; + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[2]; if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) return true; return false; } bool PolarPlottingPositionHelper::isMathematicalOrientationRadius() const { - const ::com::sun::star::chart2::ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1]; + const ExplicitScaleData& rScale = m_bSwapXAndY ? m_aScales[0] : m_aScales[1]; if( ::com::sun::star::chart2::AxisOrientation_MATHEMATICAL==rScale.Orientation ) return true; return false; @@ -283,10 +292,17 @@ bool PlottingPositionHelper::isSameForGivenResolution( double fX, double fY, dou return (bSameX && bSameY && bSameZ); } +bool PlottingPositionHelper::isStrongLowerXRequested() const +{ + if( !m_aScales.empty() ) + return m_DoShiftCategoryXIfShiftIsIndicated && m_aScales[0].ShiftedCategoryPosition; + return false; +} + bool PlottingPositionHelper::isLogicVisible( double fX, double fY, double fZ ) const { - return fX >= m_aScales[0].Minimum && fX <= m_aScales[0].Maximum + return fX >= m_aScales[0].Minimum && ( isStrongLowerXRequested() ? fX < m_aScales[0].Maximum : fX <= m_aScales[0].Maximum ) && fY >= m_aScales[1].Minimum && fY <= m_aScales[1].Maximum && fZ >= m_aScales[2].Minimum && fZ <= m_aScales[2].Maximum; } @@ -296,6 +312,23 @@ void PlottingPositionHelper::doLogicScaling( double* pX, double* pY, double* pZ, if(bClip) this->clipLogicValues( pX,pY,pZ ); + if(pX) + { + if( m_aScales[0].Scaling.is()) + *pX = m_aScales[0].Scaling->doScaling(*pX); + MaybeShiftCategoryX(*pX); + } + if(pY && m_aScales[1].Scaling.is()) + *pY = m_aScales[1].Scaling->doScaling(*pY); + if(pZ && m_aScales[2].Scaling.is()) + *pZ = m_aScales[2].Scaling->doScaling(*pZ); +} + +void PlottingPositionHelper::doUnshiftedLogicScaling( double* pX, double* pY, double* pZ, bool bClip ) const +{ + if(bClip) + this->clipLogicValues( pX,pY,pZ ); + if(pX && m_aScales[0].Scaling.is()) *pX = m_aScales[0].Scaling->doScaling(*pX); if(pY && m_aScales[1].Scaling.is()) diff --git a/chart2/source/view/inc/ScaleAutomatism.hxx b/chart2/source/view/inc/ScaleAutomatism.hxx index 4440ad26ac5a..327027efcf39 100644 --- a/chart2/source/view/inc/ScaleAutomatism.hxx +++ b/chart2/source/view/inc/ScaleAutomatism.hxx @@ -27,10 +27,11 @@ #ifndef _CHART2_SCALEAUTOMATISM_HXX #define _CHART2_SCALEAUTOMATISM_HXX -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> +#include "chartview/ExplicitScaleValues.hxx" #include <com/sun/star/chart2/ScaleData.hpp> +#include <tools/date.hxx> + //............................................................................. namespace chart { @@ -44,7 +45,7 @@ class ScaleAutomatism { public: explicit ScaleAutomatism( - const ::com::sun::star::chart2::ScaleData& rSourceScale ); + const ::com::sun::star::chart2::ScaleData& rSourceScale, const Date& rNullDate ); virtual ~ScaleAutomatism(); /** Expands own value range with the passed minimum and maximum. */ @@ -75,30 +76,41 @@ public: of the axis and the font size of the axis caption text. */ void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount ); + /** Sets the time resolution to be used in case it is not set explicitly within the scale + */ + void setAutomaticTimeResolution( sal_Int32 nTimeResolution ); + /** Fills the passed scale data and increment data according to the own settings. */ void calculateExplicitScaleAndIncrement( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ) const; + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement ) const; ::com::sun::star::chart2::ScaleData getScale() const; + Date getNullDate() const; private: /** Fills the passed scale data and increment data for category scaling. */ void calculateExplicitIncrementAndScaleForCategory( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; /** Fills the passed scale data and increment data for logarithmic scaling. */ void calculateExplicitIncrementAndScaleForLogarithmic( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; /** Fills the passed scale data and increment data for linear scaling. */ void calculateExplicitIncrementAndScaleForLinear( - ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement, + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, + bool bAutoMinimum, bool bAutoMaximum ) const; + + /** Fills the passed scale data and increment data for date-time axis. */ + void calculateExplicitIncrementAndScaleForDateTimeAxis( + ExplicitScaleData& rExplicitScale, + ExplicitIncrementData& rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum ) const; private: @@ -111,6 +123,9 @@ private: bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders. bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero. bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range). + sal_Int32 m_nTimeResolution;// a constant out of ::com::sun::star::chart::TimeUnit + + Date m_aNullDate; }; //............................................................................. diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx index e884af865d6e..f4fd12547118 100644 --- a/chart2/source/view/inc/VCoordinateSystem.hxx +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -31,9 +31,8 @@ #include "ScaleAutomatism.hxx" #include "ThreeDHelper.hxx" #include "ExplicitCategoriesProvider.hxx" +#include "chartview/ExplicitScaleValues.hxx" -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> #include <com/sun/star/chart2/XCoordinateSystem.hpp> #include "comphelper/implementationreference.hxx" #include <com/sun/star/awt/Rectangle.hpp> @@ -63,7 +62,7 @@ public: static VCoordinateSystem* createCoordinateSystem( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel ); - virtual void SAL_CALL initPlottingTargets( + virtual void initPlottingTargets( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< @@ -83,16 +82,16 @@ public: virtual ::com::sun::star::uno::Sequence< sal_Int32 > getCoordinateSystemResolution( const ::com::sun::star::awt::Size& rPageSize , const ::com::sun::star::awt::Size& rPageResolution ); - ::com::sun::star::chart2::ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; - ::com::sun::star::chart2::ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ ); ExplicitCategoriesProvider* getExplicitCategoriesProvider(); // returns a coplete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ::std::vector< ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; // returns a coplete increment set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; + ::std::vector< ExplicitIncrementData > getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const; void addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); bool hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier ); @@ -101,8 +100,8 @@ public: void prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); void setExplicitScaleAndIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex - , const ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , const ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ); + , const ExplicitScaleData& rExplicitScale + , const ExplicitIncrementData& rExplicitIncrement ); void set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos ); @@ -143,8 +142,6 @@ protected: //methods VAxisBase* getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); - void prepareScaleAutomatism( ScaleAutomatism& rScaleAutomatism, double fMin, double fMax, sal_Int32 nDimIndex, sal_Int32 nAxisIndex ); - rtl::OUString createCIDForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis , sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); @@ -194,11 +191,11 @@ protected: //member tVAxisMap m_aAxisMap; private: - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > m_aExplicitScales; - ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitIncrementData > m_aExplicitIncrements; + std::vector< ExplicitScaleData > m_aExplicitScales; + std::vector< ExplicitIncrementData > m_aExplicitIncrements; - typedef std::map< tFullAxisIndex, ::com::sun::star::chart2::ExplicitScaleData > tFullExplicitScaleMap; - typedef std::map< tFullAxisIndex, ::com::sun::star::chart2::ExplicitIncrementData > tFullExplicitIncrementMap; + typedef std::map< tFullAxisIndex, ExplicitScaleData > tFullExplicitScaleMap; + typedef std::map< tFullAxisIndex, ExplicitIncrementData > tFullExplicitIncrementMap; tFullExplicitScaleMap m_aSecondaryExplicitScales; tFullExplicitIncrementMap m_aSecondaryExplicitIncrements; diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx index 93aba58dbec4..62d61cb17269 100644 --- a/chart2/source/view/inc/VDataSeries.hxx +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -81,6 +81,10 @@ public: getModel() const; void setCategoryXAxis(); + void setXValues( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence >& xValues ); + void setXValuesIfNone( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataSequence >& xValues ); void setParticle( const rtl::OUString& rSeriesParticle ); void setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ); void setPageReferenceSize( const ::com::sun::star::awt::Size & rPageRefSize ); diff --git a/chart2/source/view/inc/VDiagram.hxx b/chart2/source/view/inc/VDiagram.hxx index 5df198c2f539..6bcef92111ef 100644 --- a/chart2/source/view/inc/VDiagram.hxx +++ b/chart2/source/view/inc/VDiagram.hxx @@ -56,7 +56,7 @@ public: //methods , sal_Int32 nDimension=3, sal_Bool bPolar=sal_False ); virtual ~VDiagram(); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xFinalTarget diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 6b6b06437542..a786c607c73c 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -174,8 +174,7 @@ public: ) */ - virtual void SAL_CALL addSecondaryValueScale( const - ::com::sun::star::chart2::ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) + virtual void addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex ) throw (::com::sun::star::uno::RuntimeException); //------------------------------------------------------------------------- @@ -197,6 +196,9 @@ public: virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ); virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex ); + virtual long calculateTimeResolutionOnXAxis(); + virtual void setTimeResolutionOnXAxis( long nTimeResolution, const Date& rNullDate ); + //------ void getMinimumAndMaximiumX( double& rfMinimum, double& rfMaximum ) const; @@ -425,6 +427,8 @@ protected: //member ::std::vector< ::std::vector< VDataSeriesGroup > > m_aZSlots; bool m_bCategoryXAxis;//true->xvalues are indices (this would not be necessary if series for category chart wouldn't have x-values) + long m_nTimeResolution; + Date m_aNullDate; ::std::auto_ptr< NumberFormatterWrapper > m_apNumberFormatterWrapper; AxesNumberFormats m_aAxesNumberFormats;//direct numberformats on axes, if empty ask the data series instead @@ -439,7 +443,7 @@ protected: //member bool m_bPointsWereSkipped; private: //member - typedef std::map< sal_Int32 , ::com::sun::star::chart2::ExplicitScaleData > tSecondaryValueScales; + typedef std::map< sal_Int32 , ExplicitScaleData > tSecondaryValueScales; tSecondaryValueScales m_aSecondaryValueScales; typedef std::map< sal_Int32 , PlottingPositionHelper* > tSecondaryPosHelperMap; diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index d8f997d36da9..525f0a8de951 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -65,52 +65,17 @@ ChartItemPool::ChartItemPool(): SvULongs aTmp; ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS,aTmp); ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); + ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); + ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); + //legend ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); -// ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; + + //text + ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); - ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); - - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Y_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_X_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Z_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_X); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); + //statistic ppPoolDefaults[SCHATTR_STAT_AVERAGE - SCHATTR_START] = new SfxBoolItem (SCHATTR_STAT_AVERAGE); ppPoolDefaults[SCHATTR_STAT_KIND_ERROR - SCHATTR_START] = new SvxChartKindErrorItem (CHERROR_NONE, SCHATTR_STAT_KIND_ERROR); ppPoolDefaults[SCHATTR_STAT_PERCENT - SCHATTR_START] = new SvxDoubleItem (0.0, SCHATTR_STAT_PERCENT); @@ -121,9 +86,6 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_STAT_RANGE_POS - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_POS, String()); ppPoolDefaults[SCHATTR_STAT_RANGE_NEG - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String()); - ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); - ppPoolDefaults[SCHATTR_TEXT_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_OVERLAP,FALSE); - ppPoolDefaults[SCHATTR_STYLE_DEEP - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0); ppPoolDefaults[SCHATTR_STYLE_3D - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0); ppPoolDefaults[SCHATTR_STYLE_VERTICAL - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_VERTICAL, 0); @@ -137,37 +99,43 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_AXIS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS,2); //2 = Y-Achse!!! + //axis scale + ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_REALNUMBER); + ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); ppPoolDefaults[SCHATTR_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MIN); ppPoolDefaults[SCHATTR_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MIN); ppPoolDefaults[SCHATTR_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MAX); ppPoolDefaults[SCHATTR_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MAX); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN); ppPoolDefaults[SCHATTR_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_STEP_MAIN); + ppPoolDefaults[SCHATTR_AXIS_MAIN_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,2); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP); -// ppPoolDefaults[SCHATTR_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_STEP_HELP); - // type changed from double to sal_Int32 ppPoolDefaults[SCHATTR_AXIS_STEP_HELP - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_STEP_HELP,0); + ppPoolDefaults[SCHATTR_AXIS_HELP_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,2); + ppPoolDefaults[SCHATTR_AXIS_AUTO_TIME_RESOLUTION - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION); + ppPoolDefaults[SCHATTR_AXIS_TIME_RESOLUTION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,2); ppPoolDefaults[SCHATTR_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LOGARITHM); + ppPoolDefaults[SCHATTR_AXIS_AUTO_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS); + ppPoolDefaults[SCHATTR_AXIS_ALLOW_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_ALLOW_DATEAXIS); ppPoolDefaults[SCHATTR_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN); ppPoolDefaults[SCHATTR_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_ORIGIN); + //axis position ppPoolDefaults[SCHATTR_AXIS_TICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TICKS,CHAXIS_MARK_OUTER); - ppPoolDefaults[SCHATTR_AXIS_NUMFMT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMT,0); - ppPoolDefaults[SCHATTR_AXIS_NUMFMTPERCENT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMTPERCENT,11); - ppPoolDefaults[SCHATTR_AXIS_SHOWAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWAXIS,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWMAINGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWMAINGRID,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWHELPGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWHELPGRID,0); - ppPoolDefaults[SCHATTR_AXIS_TOPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_TOPDOWN,0); ppPoolDefaults[SCHATTR_AXIS_HELPTICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELPTICKS,0); - ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); - ppPoolDefaults[SCHATTR_AXIS_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_POSITION_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_POSITION_VALUE); ppPoolDefaults[SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT,0); ppPoolDefaults[SCHATTR_AXIS_LABEL_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_LABEL_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_MARK_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MARK_POSITION,0); + //axis label + ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); + ppPoolDefaults[SCHATTR_AXIS_LABEL_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_AXIS_LABEL_ORDER); + ppPoolDefaults[SCHATTR_AXIS_LABEL_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_OVERLAP,FALSE); + ppPoolDefaults[SCHATTR_AXIS_LABEL_BREAK - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_BREAK, FALSE ); + + //-- ppPoolDefaults[SCHATTR_SYMBOL_BRUSH - SCHATTR_START] = new SvxBrushItem(SCHATTR_SYMBOL_BRUSH); ppPoolDefaults[SCHATTR_STOCK_VOLUME - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_VOLUME,0); ppPoolDefaults[SCHATTR_STOCK_UPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_UPDOWN,0); @@ -181,16 +149,16 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_SPLINE_ORDER - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_ORDER, 3 ); ppPoolDefaults[SCHATTR_SPLINE_RESOLUTION - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, 20 ); ppPoolDefaults[SCHATTR_DIAGRAM_STYLE - SCHATTR_START] = new SvxChartStyleItem( CHSTYLE_2D_COLUMN, SCHATTR_DIAGRAM_STYLE ); - ppPoolDefaults[SCHATTR_TEXTBREAK - SCHATTR_START] = new SfxBoolItem( SCHATTR_TEXTBREAK, FALSE ); ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, FALSE); - ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); ppPoolDefaults[SCHATTR_STARTING_ANGLE - SCHATTR_START] = new SfxInt32Item( SCHATTR_STARTING_ANGLE, 90 ); ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, FALSE ); ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0); ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp); + ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); ppPoolDefaults[SCHATTR_AXIS_FOR_ALL_SERIES - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_FOR_ALL_SERIES, 0); + ppPoolDefaults[SCHATTR_REGRESSION_TYPE - SCHATTR_START] = new SvxChartRegressItem (CHREGRESS_NONE, SCHATTR_REGRESSION_TYPE); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_EQUATION - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_EQUATION, 0); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_COEFF - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_COEFF, 0); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 2347824664c5..3098005d6bfa 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -31,6 +31,7 @@ #include "ChartView.hxx" #include "chartview/DrawModelWrapper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" @@ -56,6 +57,7 @@ #include "ControllerLockGuard.hxx" #include "BaseGFXHelper.hxx" #include "DataSeriesHelper.hxx" +#include "DateHelper.hxx" #include <comphelper/scopeguard.hxx> #include <boost/bind.hpp> @@ -78,7 +80,6 @@ #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> -#include <com/sun/star/chart2/ExplicitSubIncrement.hpp> #include <com/sun/star/chart2/StackingDirection.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -474,7 +475,7 @@ private: }; AxisUsage::AxisUsage() - : aScaleAutomatism(AxisHelper::createDefaultScale()) + : aScaleAutomatism(AxisHelper::createDefaultScale(),Date()) { } @@ -565,7 +566,7 @@ public: ~SeriesPlotterContainer(); void initializeCooSysAndSeriesPlotter( const uno::Reference< frame::XModel >& xChartModel ); - void initAxisUsageList(); + void initAxisUsageList(const Date& rNullDate); void doAutoScaling( const uno::Reference< frame::XModel >& xChartModel ); void updateScalesAndIncrementsOnAxes(); void setScalesFromCooSysToPlotter(); @@ -583,13 +584,13 @@ private: std::vector< VCoordinateSystem* >& m_rVCooSysList; ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList; sal_Int32 m_nMaxAxisIndex; - bool m_bChartTypeUsesShiftedXAxisTicksPerDefault; + bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) - , m_bChartTypeUsesShiftedXAxisTicksPerDefault(false) + , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) { } @@ -684,7 +685,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( uno::Reference< XChartType > xChartType( aChartTypeList[nT] ); if(nT==0) - m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType ); + m_bChartTypeUsesShiftedCategoryPositionPerDefault = ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType ); bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ); VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning ); @@ -795,7 +796,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } } -void SeriesPlotterContainer::initAxisUsageList() +void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) { m_aAxisUsageList.clear(); size_t nC; @@ -805,8 +806,10 @@ void SeriesPlotterContainer::initAxisUsageList() for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++) { uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel(); - if( nDimensionIndex >= xCooSys->getDimension() ) + sal_Int32 nDimensionCount = xCooSys->getDimension(); + if( nDimensionIndex >= nDimensionCount ) continue; + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionCount, nDimensionIndex ); const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex) { @@ -815,7 +818,20 @@ void SeriesPlotterContainer::initAxisUsageList() if( xAxis.is()) { if(m_aAxisUsageList.find(xAxis)==m_aAxisUsageList.end()) - m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(xAxis->getScaleData()); + { + chart2::ScaleData aSourceScale = xAxis->getScaleData(); + ExplicitCategoriesProvider* pExplicitCategoriesProvider = pVCooSys->getExplicitCategoriesProvider(); + if( nDimensionIndex==0 ) + AxisHelper::checkDateAxis( aSourceScale, pExplicitCategoriesProvider, bChartTypeAllowsDateAxis ); + if( (aSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault) + || (aSourceScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) + || aSourceScale.AxisType == AxisType::DATE + || aSourceScale.AxisType == AxisType::SERIES ) + aSourceScale.ShiftedCategoryPosition = true; + else + aSourceScale.ShiftedCategoryPosition = false; + m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale,rNullDate); + } AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis]; rAxisUsage.addCoordinateSystem(pVCooSys,nDimensionIndex,nAxisIndex); } @@ -938,13 +954,7 @@ void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement ); for( nC=0; nC < aVCooSysList_X.size(); nC++) - { - ExplicitCategoriesProvider* pExplicitCategoriesProvider = aVCooSysList_X[nC]->getExplicitCategoriesProvider(); - - if( m_bChartTypeUsesShiftedXAxisTicksPerDefault || (aExplicitScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) ) - aExplicitIncrement.ShiftedPosition = true; aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement ); - } for( nC=0; nC < aVCooSysList_Z.size(); nC++) aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement ); } @@ -1029,7 +1039,6 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation; aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling; - aExplicitScaleDest.Breaks = aExplicitScaleSource.Breaks; aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType; aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue; @@ -1067,7 +1076,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ); if( bAutoMinorInterval ) { - if( aExplicitIncrementDest.SubIncrements.getLength() && aExplicitIncrementSource.SubIncrements.getLength() ) + if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() ) aExplicitIncrementDest.SubIncrements[0].IntervalCount = aExplicitIncrementSource.SubIncrements[0].IntervalCount; } @@ -1382,7 +1391,8 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& // - prepare list of all axis and how they are used - rSeriesPlotterContainer.initAxisUsageList(); + Date aNullDate = NumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >( m_xChartModel, uno::UNO_QUERY ) ).getNullDate(); + rSeriesPlotterContainer.initAxisUsageList(aNullDate); rSeriesPlotterContainer.doAutoScaling( m_xChartModel ); rSeriesPlotterContainer.setScalesFromCooSysToPlotter(); rSeriesPlotterContainer.setNumberFormatsFromAxes(); @@ -1665,6 +1675,29 @@ sal_Bool ChartView::getExplicitValuesForAxis( { rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex); rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex); + if( rExplicitScale.ShiftedCategoryPosition ) + { + //remove 'one' from max + if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + Date aMaxDate(rExplicitScale.NullDate); aMaxDate += static_cast<long>(::rtl::math::approxFloor(rExplicitScale.Maximum)); + //for explicit scales with shifted categories we need one interval more + switch( rExplicitScale.TimeResolution ) + { + case ::com::sun::star::chart::TimeUnit::DAY: + aMaxDate--;break; + case ::com::sun::star::chart::TimeUnit::MONTH: + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + break; + case ::com::sun::star::chart::TimeUnit::YEAR: + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + break; + } + rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate; + } + else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::CATEGORY ) + rExplicitScale.Maximum -= 1.0; + } return sal_True; } return sal_False; @@ -1793,6 +1826,24 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } +sal_Int32 lcl_getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + nRet = aKeySeq[0]; + } + } + return nRet; +} + sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem @@ -1803,23 +1854,35 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) { - bool bPercentFormatSet = false; + bool bFormatSet = false; //check wether we have a percent scale -> use percent format if( xNumberFormatsSupplier.is() ) { - ScaleData aData = xAxis->getScaleData(); + ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); if( aData.AxisType==AxisType::PERCENT ) { sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); if( nPercentFormat != -1 ) { nNumberFormatKey = nPercentFormat; - bPercentFormatSet = true; + bFormatSet = true; + } + } + else if( aData.AxisType==AxisType::DATE ) + { + if( aData.Categories.is() ) + { + Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); + if( xSeq.is() ) + nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); + else + nNumberFormatKey = lcl_getDateNumberFormat( xNumberFormatsSupplier ); + bFormatSet = true; } } } - if( !bPercentFormatSet ) + if( !bFormatSet ) { typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; tNumberformatFrequency aKeyMap; @@ -1857,22 +1920,20 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( continue; } - Sequence< Reference< data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences()); - for( sal_Int32 nLSeqIdx=0; nLSeqIdx<aLabeledSeq.getLength(); ++nLSeqIdx ) + Reference< data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); + + if( !xLabeledSeq.is() && nDimensionIndex==0 ) { - if(!aLabeledSeq[nLSeqIdx].is()) - continue; - Reference< data::XDataSequence > xSeq( aLabeledSeq[nLSeqIdx]->getValues()); - if(!xSeq.is()) - continue; - Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); - ::rtl::OUString aRole; - bool bTakeIntoAccount = - ( xSeqProp.is() && (aRoleToMatch.getLength() > 0) && - (xSeqProp->getPropertyValue(C2U("Role")) >>= aRole ) && - aRole.equals( aRoleToMatch )); - - if( bTakeIntoAccount ) + ScaleData aData = xAxis->getScaleData(); + if( aData.AxisType==AxisType::REALNUMBER ) + xLabeledSeq = aData.Categories; + } + + if( xLabeledSeq.is() ) + { + Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); + if( xSeq.is() ) { sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); // initialize the value @@ -1954,7 +2015,6 @@ sal_Int32 ExplicitValueProvider::getPercentNumberFormat( const Reference< util:: return nRet; } - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const uno::Reference< XDataSeries >& xSeries, diff --git a/chart2/source/view/main/ChartView.hxx b/chart2/source/view/main/ChartView.hxx index 476adae03674..76c1ce5c4858 100644 --- a/chart2/source/view/main/ChartView.hxx +++ b/chart2/source/view/main/ChartView.hxx @@ -103,8 +103,8 @@ public: // ___ExplicitValueProvider___ virtual sal_Bool getExplicitValuesForAxis( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis - , ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ); + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getShapeForCID( const rtl::OUString& rObjectCID ); diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx index 4e4cd342506c..de7dde79e789 100644 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ b/chart2/source/view/main/NumberFormatterWrapper.cxx @@ -100,6 +100,25 @@ SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const return m_pNumberFormatter; } +Date NumberFormatterWrapper::getNullDate() const +{ + USHORT nYear = 1899,nDay = 30,nMonth = 12; + Date aRet(nDay,nMonth,nYear); + + util::DateTime aUtilDate; + if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) ) + { + aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year); + } + else if( m_pNumberFormatter ) + { + Date* pDate = m_pNumberFormatter->GetNullDate(); + if( pDate ) + aRet = *pDate; + } + return aRet; +} + rtl::OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const { diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index 08f43dc7064d..8a71f45b4dbb 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -56,8 +56,7 @@ PlotterBase::PlotterBase( sal_Int32 nDimensionCount ) { } - void SAL_CALL PlotterBase -::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget +void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory , const rtl::OUString& rCID ) @@ -77,11 +76,9 @@ PlotterBase::~PlotterBase() delete m_pShapeFactory; } -void SAL_CALL PlotterBase::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (uno::RuntimeException) +void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { - DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + DBG_ASSERT(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); m_pPosHelper->setScales( rScales, bSwapXAndYAxis ); } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index deb390b70a79..5d9105605f62 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -32,12 +32,14 @@ #include "ViewDefines.hxx" #include "Linear3DTransformation.hxx" #include "VPolarTransformation.hxx" - #include "ShapeFactory.hxx" #include "PropertyMapper.hxx" +#include "DateHelper.hxx" + +#include <com/sun/star/chart/TimeUnit.hpp> +#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/drawing/DoubleSequence.hpp> #include <com/sun/star/drawing/Position3D.hpp> -#include <com/sun/star/chart2/AxisType.hpp> #include <rtl/math.hxx> @@ -57,6 +59,11 @@ PlottingPositionHelper::PlottingPositionHelper() , m_nYResolution( 1000 ) , m_nZResolution( 1000 ) , m_bMaySkipPointsInRegressionCalculation( true ) + , m_bDateAxis(false) + , m_nTimeResolution( ::com::sun::star::chart::TimeUnit::DAY ) + , m_aNullDate(30,12,1899) + , m_fScaledCategoryWidth(1.0) + , m_DoShiftCategoryXIfShiftIsIndicated(false) { } PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rSource ) @@ -68,6 +75,11 @@ PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rS , m_nYResolution( rSource.m_nYResolution ) , m_nZResolution( rSource.m_nZResolution ) , m_bMaySkipPointsInRegressionCalculation( rSource.m_bMaySkipPointsInRegressionCalculation ) + , m_nTimeResolution( rSource.m_nTimeResolution ) + , m_aNullDate( rSource.m_aNullDate ) + , m_bDateAxis( rSource.m_bDateAxis ) + , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth ) + , m_DoShiftCategoryXIfShiftIsIndicated( rSource.m_DoShiftCategoryXIfShiftIsIndicated ) { } @@ -95,13 +107,13 @@ void PlottingPositionHelper::setTransformationSceneToScreen( const drawing::Homo m_xTransformationLogicToScene = NULL; } -void PlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { m_aScales = rScales; m_bSwapXAndY = bSwapXAndYAxis; m_xTransformationLogicToScene = NULL; } -const uno::Sequence< ExplicitScaleData >& PlottingPositionHelper::getScales() const +const std::vector< ExplicitScaleData >& PlottingPositionHelper::getScales() const { return m_aScales; } @@ -129,8 +141,8 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale AxisOrientation nZAxisOrientation = m_aScales[2].Orientation; //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(m_bSwapXAndY) { @@ -176,9 +188,9 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale drawing::Position3D PlottingPositionHelper::transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const { - if(bClip) - this->clipLogicValues( &fX,&fY,&fZ ); this->doLogicScaling( &fX,&fY,&fZ ); + if(bClip) + this->clipScaledLogicValues( &fX,&fY,&fZ ); return this->transformScaledLogicToScene( fX, fY, fZ, false ); } @@ -255,8 +267,8 @@ void PlottingPositionHelper::clipScaledLogicValues( double* pX, double* pY, doub double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(pX) { @@ -292,8 +304,8 @@ basegfx::B2DRectangle PlottingPositionHelper::getScaledLogicClipDoubleRect() con double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); basegfx::B2DRectangle aRet( MinX, MaxY, MaxX, MinY ); return aRet; @@ -356,7 +368,7 @@ void PolarPlottingPositionHelper::setTransformationSceneToScreen( const drawing: PlottingPositionHelper::setTransformationSceneToScreen( rMatrix); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); } -void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PolarPlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { PlottingPositionHelper::setScales( rScales, bSwapXAndYAxis ); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); @@ -366,7 +378,7 @@ void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleD { ::basegfx::B3DHomMatrix aRet; - if( !m_aScales.getLength() ) + if( m_aScales.empty() ) return aRet; double fTranslate =1.0; @@ -641,6 +653,46 @@ double PlottingPositionHelper::getBaseValueY() const return m_aScales[1].Origin; } +void PlottingPositionHelper::setTimeResolution( long nTimeResolution, const Date& rNullDate ) +{ + m_nTimeResolution = nTimeResolution; + m_aNullDate = rNullDate; + + //adapt category width + double fCategoryWidth = 1.0; + if( !m_aScales.empty() ) + { + if( m_aScales[0].AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + m_bDateAxis = true; + if( nTimeResolution == ::com::sun::star::chart::TimeUnit::YEAR ) + { + const double fMonthCount = 12.0;//todo: this depends on the DateScaling and must be adjusted in case we use more generic calendars in future + fCategoryWidth = fMonthCount; + } + } + } + setScaledCategoryWidth(fCategoryWidth); +} + +void PlottingPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth ) +{ + m_fScaledCategoryWidth = fScaledCategoryWidth; +} +void PlottingPositionHelper::MaybeShiftCategoryX( double& fScaledXValue ) const +{ + if( m_DoShiftCategoryXIfShiftIsIndicated && !m_aScales.empty() ) + { + if(m_aScales[0].ShiftedCategoryPosition) + fScaledXValue += m_fScaledCategoryWidth/2.0; + } +} + +void PlottingPositionHelper::DoShiftCategoryXIfShiftIsIndicated( bool bAllowShift ) +{ + m_DoShiftCategoryXIfShiftIsIndicated = bAllowShift; +} + /* // ____ XTransformation ____ uno::Sequence< double > SAL_CALL PolarPlottingPositionHelper::transform( diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 8bb6a11b4baf..2b9512d4af2a 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -352,6 +352,22 @@ void VDataSeries::setCategoryXAxis() m_bAllowPercentValueInDataLabel = true; } +void VDataSeries::setXValues( const Reference< chart2::data::XDataSequence >& xValues ) +{ + m_aValues_X.clear(); + m_aValues_X.init( xValues ); + m_bAllowPercentValueInDataLabel = true; +} + +void VDataSeries::setXValuesIfNone( const Reference< chart2::data::XDataSequence >& xValues ) +{ + if( m_aValues_X.is() ) + return; + + m_aValues_X.init( xValues ); + lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xValues ); +} + void VDataSeries::setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ) { m_nGlobalSeriesIndex = nGlobalSeriesIndex; diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 7101a984ee24..e247060fe8d4 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -632,7 +632,7 @@ VLegend::VLegend( // ---------------------------------------- -void SAL_CALL VLegend::init( +void VLegend::init( const Reference< drawing::XShapes >& xTargetPage, const Reference< lang::XMultiServiceFactory >& xFactory, const Reference< frame::XModel >& xModel ) diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx index 9587b50f71e7..4534a350f4f4 100644 --- a/chart2/source/view/main/VLegend.hxx +++ b/chart2/source/view/main/VLegend.hxx @@ -56,7 +56,7 @@ public: ::com::sun::star::uno::XComponentContext > & xContext, const std::vector< LegendEntryProvider* >& rLegendEntryProviderList ); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index f62142735b7c..c2aa01163b17 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -65,7 +65,7 @@ VTitle::~VTitle() { } -void SAL_CALL VTitle::init( +void VTitle::init( const uno::Reference< drawing::XShapes >& xTargetPage , const uno::Reference< lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ) diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx index 8a6e7d6e4f16..e097ecd3bbcc 100644 --- a/chart2/source/view/main/VTitle.hxx +++ b/chart2/source/view/main/VTitle.hxx @@ -47,7 +47,7 @@ public: ::com::sun::star::chart2::XTitle > & xTitle ); virtual ~VTitle(); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ); |