summaryrefslogtreecommitdiff
path: root/chart2/source/view
diff options
context:
space:
mode:
authorIngrid Halama [iha] <Ingrid.Halama@oracle.com>2010-11-30 01:45:03 +0100
committerIngrid Halama [iha] <Ingrid.Halama@oracle.com>2010-11-30 01:45:03 +0100
commitedaa216847e59ad93b8b99e95f293f8bb04344cc (patch)
tree7193a7fdd5a3520b21755c675cb4d3de4e3100cb /chart2/source/view
parent0e5566e9ff510bedc9837e12ee37103c553897da (diff)
chart46: #i25706# implement date axis
Diffstat (limited to 'chart2/source/view')
-rw-r--r--chart2/source/view/axes/DateHelper.cxx132
-rw-r--r--chart2/source/view/axes/DateScaling.cxx211
-rw-r--r--chart2/source/view/axes/DateScaling.hxx114
-rw-r--r--chart2/source/view/axes/MinimumAndMaximumSupplier.cxx21
-rw-r--r--chart2/source/view/axes/ScaleAutomatism.cxx330
-rw-r--r--chart2/source/view/axes/Tickmarks.cxx333
-rw-r--r--chart2/source/view/axes/Tickmarks.hxx166
-rw-r--r--chart2/source/view/axes/Tickmarks_Dates.cxx171
-rw-r--r--chart2/source/view/axes/Tickmarks_Dates.hxx65
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.cxx (renamed from chart2/source/view/axes/TickmarkHelper.cxx)772
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.hxx (renamed from chart2/source/view/axes/TickmarkHelper.hxx)160
-rw-r--r--chart2/source/view/axes/VAxisBase.cxx26
-rw-r--r--chart2/source/view/axes/VAxisBase.hxx21
-rw-r--r--chart2/source/view/axes/VAxisOrGridBase.cxx17
-rw-r--r--chart2/source/view/axes/VAxisOrGridBase.hxx21
-rw-r--r--chart2/source/view/axes/VAxisProperties.cxx19
-rw-r--r--chart2/source/view/axes/VAxisProperties.hxx1
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx289
-rw-r--r--chart2/source/view/axes/VCartesianAxis.hxx27
-rw-r--r--chart2/source/view/axes/VCartesianCoordinateSystem.cxx17
-rw-r--r--chart2/source/view/axes/VCartesianGrid.cxx13
-rw-r--r--chart2/source/view/axes/VCartesianGrid.hxx2
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx26
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.cxx16
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.hxx9
-rw-r--r--chart2/source/view/axes/VPolarAxis.cxx6
-rw-r--r--chart2/source/view/axes/VPolarAxis.hxx8
-rw-r--r--chart2/source/view/axes/VPolarCoordinateSystem.cxx9
-rw-r--r--chart2/source/view/axes/VPolarGrid.cxx23
-rw-r--r--chart2/source/view/axes/VPolarGrid.hxx14
-rw-r--r--chart2/source/view/axes/VPolarRadiusAxis.cxx27
-rw-r--r--chart2/source/view/axes/VPolarRadiusAxis.hxx24
-rw-r--r--chart2/source/view/axes/makefile.mk6
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx29
-rw-r--r--chart2/source/view/charttypes/AreaChart.hxx13
-rw-r--r--[-rwxr-xr-x]chart2/source/view/charttypes/BarChart.cxx99
-rw-r--r--chart2/source/view/charttypes/BarChart.hxx18
-rw-r--r--chart2/source/view/charttypes/BarPositionHelper.cxx79
-rw-r--r--chart2/source/view/charttypes/BarPositionHelper.hxx19
-rw-r--r--chart2/source/view/charttypes/BubbleChart.hxx6
-rw-r--r--chart2/source/view/charttypes/CandleStickChart.cxx103
-rw-r--r--chart2/source/view/charttypes/CandleStickChart.hxx13
-rw-r--r--chart2/source/view/charttypes/CategoryPositionHelper.cxx17
-rw-r--r--chart2/source/view/charttypes/CategoryPositionHelper.hxx5
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx6
-rw-r--r--chart2/source/view/charttypes/PieChart.hxx18
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx104
-rw-r--r--chart2/source/view/diagram/VDiagram.cxx2
-rw-r--r--chart2/source/view/inc/DateHelper.hxx60
-rw-r--r--chart2/source/view/inc/MinimumAndMaximumSupplier.hxx9
-rw-r--r--chart2/source/view/inc/PlotterBase.hxx31
-rw-r--r--chart2/source/view/inc/PlottingPositionHelper.hxx65
-rw-r--r--chart2/source/view/inc/ScaleAutomatism.hxx37
-rw-r--r--chart2/source/view/inc/VCoordinateSystem.hxx27
-rw-r--r--chart2/source/view/inc/VDataSeries.hxx4
-rw-r--r--chart2/source/view/inc/VDiagram.hxx2
-rw-r--r--chart2/source/view/inc/VSeriesPlotter.hxx10
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx84
-rw-r--r--chart2/source/view/main/ChartView.cxx136
-rw-r--r--chart2/source/view/main/ChartView.hxx4
-rw-r--r--chart2/source/view/main/NumberFormatterWrapper.cxx19
-rw-r--r--chart2/source/view/main/PlotterBase.cxx9
-rw-r--r--chart2/source/view/main/PlottingPositionHelper.cxx80
-rw-r--r--chart2/source/view/main/VDataSeries.cxx16
-rw-r--r--chart2/source/view/main/VLegend.cxx2
-rw-r--r--chart2/source/view/main/VLegend.hxx2
-rw-r--r--chart2/source/view/main/VTitle.cxx2
-rw-r--r--chart2/source/view/main/VTitle.hxx2
68 files changed, 2699 insertions, 1529 deletions
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 );