diff options
-rw-r--r-- | chart2/inc/ChartModel.hxx | 5 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/DialogModel.cxx | 12 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/DialogModel.hxx | 6 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_RangeChooser.cxx | 10 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_RangeChooser.hxx | 3 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc | 3 | ||||
-rw-r--r-- | chart2/source/inc/LabeledDataSequence.hxx | 10 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 20 | ||||
-rw-r--r-- | chart2/source/tools/LabeledDataSequence.cxx | 31 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 4 | ||||
-rw-r--r-- | chart2/source/view/main/VDataSeries.cxx | 6 | ||||
-rw-r--r-- | offapi/com/sun/star/chart2/XTimeBased.idl | 4 | ||||
-rw-r--r-- | sc/inc/chart2uno.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 24 |
14 files changed, 94 insertions, 48 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index 158e4d1f8a69..d987cdd765a6 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -586,6 +586,11 @@ public: void setTimeBased(bool bTimeBased); void getNextTimePoint(); + void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd); + + sal_Int32 mnStart; + sal_Int32 mnEnd; + bool bSet; }; } // namespace chart diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index c6d4f84ff146..0285548da4f3 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -716,6 +716,11 @@ bool DialogModel::setData( return true; } +void DialogModel::setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd) const +{ + getModel().setTimeBasedRange(nStart, nEnd); +} + OUString DialogModel::ConvertRoleFromInternalToUI( const OUString & rRoleString ) { return lcl_ConvertRole( rRoleString, true ); @@ -820,6 +825,13 @@ sal_Int32 DialogModel::countSeries() const return ::std::accumulate( aCnt.begin(), aCnt.end(), 0, lcl_addSeriesNumber()); } +ChartModel& DialogModel::getModel() const +{ + uno::Reference< frame::XModel > xModel = getChartModel(); + ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get()); + return *pModel; +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index ee236cf5cb69..f6735f5758a9 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -24,6 +24,8 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include "ChartModel.hxx" + #include <vector> #include <map> #include <boost/shared_ptr.hpp> @@ -140,6 +142,8 @@ public: bool setData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArguments ); + void setTimeBasedRange( sal_Int32 nStart, sal_Int32 nEnd) const; + void startControllerLockTimer(); static OUString ConvertRoleFromInternalToUI( const OUString & rRoleString ); @@ -177,6 +181,8 @@ private: bool bSetStyles ); sal_Int32 countSeries() const; + + ChartModel& getModel() const; }; } // namespace chart diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 52f8509d48e9..0687aaa2458f 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -89,6 +89,9 @@ RangeChooserTabPage::RangeChooserTabPage( Window* pParent get(m_pCB_FirstColumnAsLabel, "CB_FIRST_COLUMN_ASLABELS"); get(m_pFTTitle, "STR_PAGE_DATA_RANGE");// OH:remove later with dialog title m_pCB_TimeBased = NULL; + m_pFt_TimeBased = NULL; + m_pEd_TimeStart = NULL; + m_pEd_TimeEnd = NULL; m_pFT_Caption->Show(!bHideDescription); @@ -230,6 +233,13 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() beans::PropertyState_DIRECT_VALUE ); m_rDialogModel.setData( aArguments ); m_bIsDirty = false; + + if(bTimeBased) + { + sal_Int32 nStart = m_pEd_TimeStart->GetText().toInt32(); + sal_Int32 nEnd = m_pEd_TimeEnd->GetText().toInt32(); + m_rDialogModel.setTimeBasedRange(nStart, nEnd); + } } //@todo warn user that the selected range is not valid diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.hxx b/chart2/source/controller/dialogs/tp_RangeChooser.hxx index 57ab2ee1f613..9f3e5386dd75 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.hxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.hxx @@ -90,6 +90,9 @@ protected: //member FixedText* m_pFTTitle; CheckBox* m_pCB_TimeBased; + FixedText* m_pFt_TimeBased; + Edit* m_pEd_TimeStart; + Edit* m_pEd_TimeEnd; sal_Int32 m_nChangingControlCalls; bool m_bIsDirty; diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc index 6bfc0d259764..685c4fe8e6c0 100644 --- a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc @@ -29,5 +29,8 @@ #define CB_Z_SECONDARY 6 #define CB_TIME_BASED 3 +#define FT_TIME_BASED 4 +#define ED_TIME_START 5 +#define ED_TIME_END 6 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/LabeledDataSequence.hxx b/chart2/source/inc/LabeledDataSequence.hxx index 41b7e2647dc4..3cd8258b0017 100644 --- a/chart2/source/inc/LabeledDataSequence.hxx +++ b/chart2/source/inc/LabeledDataSequence.hxx @@ -21,23 +21,21 @@ #include "ServiceMacros.hxx" #include "MutexContainer.hxx" #include <comphelper/uno3.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase2.hxx> #include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/chart2/XTimeBased.hpp> namespace chart { namespace impl { -typedef cppu::WeakImplHelper3< +typedef cppu::WeakImplHelper2< ::com::sun::star::chart2::data::XLabeledDataSequence2, - com::sun::star::chart2::XTimeBased, ::com::sun::star::lang::XServiceInfo > LabeledDataSequence_Base; } @@ -79,10 +77,6 @@ protected: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSequence ) throw (::com::sun::star::uno::RuntimeException); - // XTimeBased - virtual sal_Bool switchToNext() throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool setToPointInTime(sal_Int32 nPoint) throw (::com::sun::star::uno::RuntimeException); - // ____ XCloneable ____ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() throw (::com::sun::star::uno::RuntimeException); diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index a0d93d171e7b..26256682755d 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -93,7 +93,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) , m_bModified( sal_False ) , m_nInLoad(0) , m_bUpdateNotificationsPending(false) - , mbTimeBased(true) + , mbTimeBased(false) , mpChartView(NULL) , m_pUndoManager( NULL ) , m_aControllers( m_aModelMutex ) @@ -105,6 +105,9 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) , m_xPageBackground( new PageBackground( m_xContext ) ) , m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ), "com.sun.star.xml.NamespaceMap", "com.sun.star.comp.chart.XMLNameSpaceMap" ), uno::UNO_QUERY) + , mnStart(0) + , mnEnd(0) + ,bSet(false) { OSL_TRACE( "ChartModel: CTOR called" ); @@ -147,6 +150,9 @@ ChartModel::ChartModel( const ChartModel & rOther ) , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector ) , m_xDataProvider( rOther.m_xDataProvider ) , m_xInternalDataProvider( rOther.m_xInternalDataProvider ) + , mnStart(rOther.mnStart) + , mnEnd(rOther.mnEnd) + , bSet(false) { OSL_TRACE( "ChartModel: Copy-CTOR called" ); @@ -1382,9 +1388,19 @@ void ChartModel::getNextTimePoint() SAL_WARN_IF(!xTimeBased.is(), "chart2", "does not support time based charting"); if(xTimeBased.is()) { - xTimeBased->switchToNext(); + if(!bSet) + xTimeBased->setRange(mnStart, mnEnd); + xTimeBased->switchToNext(sal_True); } } + bSet = true; +} + +void ChartModel::setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd) +{ + bSet = false; + mnStart = nStart; + mnEnd = nEnd; } } // namespace chart diff --git a/chart2/source/tools/LabeledDataSequence.cxx b/chart2/source/tools/LabeledDataSequence.cxx index cc0a6c199e17..68df3c83520c 100644 --- a/chart2/source/tools/LabeledDataSequence.cxx +++ b/chart2/source/tools/LabeledDataSequence.cxx @@ -101,37 +101,6 @@ void SAL_CALL LabeledDataSequence::setLabel( } } -// XTimeBased - -sal_Bool LabeledDataSequence::switchToNext() - throw (uno::RuntimeException) -{ - uno::Reference< chart2::XTimeBased > xTimeBasedValues(m_xData, uno::UNO_QUERY); - if(xTimeBasedValues.is()) - xTimeBasedValues->switchToNext(); - - uno::Reference< chart2::XTimeBased > xTimeBasedLabels(m_xLabel, uno::UNO_QUERY); - if(xTimeBasedLabels.is()) - xTimeBasedLabels->switchToNext(); - - return sal_True; -} - -sal_Bool LabeledDataSequence::setToPointInTime(sal_Int32 nPoint) - throw (uno::RuntimeException) -{ - sal_Bool bRet = sal_False; - uno::Reference< chart2::XTimeBased > xTimeBasedValues(m_xData, uno::UNO_QUERY); - if(xTimeBasedValues.is()) - bRet = xTimeBasedValues->setToPointInTime(nPoint); - - uno::Reference< chart2::XTimeBased > xTimeBasedLabels(m_xLabel, uno::UNO_QUERY); - if(xTimeBasedLabels.is()) - xTimeBasedLabels->setToPointInTime(nPoint); - - return bRet; -} - // ____ XCloneable ____ uno::Reference< util::XCloneable > SAL_CALL LabeledDataSequence::createClone() throw (uno::RuntimeException) diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index e462d7f9a707..c3b2ac20f835 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -192,6 +192,7 @@ void SAL_CALL ChartView::initialize( const uno::Sequence< uno::Any >& ) ChartView::~ChartView() { + maTimeBased.maTimer.Stop(); // #i120831#. In ChartView::initialize(), m_xShapeFactory is created from SdrModel::getUnoModel() and indirectly // from SfxBaseModel, it needs call dispose() to make sure SfxBaseModel object is freed correctly. uno::Reference< lang::XComponent > xComp( m_xShapeFactory, uno::UNO_QUERY); @@ -2582,7 +2583,10 @@ void ChartView::createShapes() } if(maTimeBased.eMode != MANUAL) + { + mrChartModel.setTimeBased(true); mrChartModel.getNextTimePoint(); + } else maTimeBased.maTimer.Stop(); } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 981d832d211a..52b510f89597 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -469,7 +469,7 @@ double VDataSeries::getXValue( sal_Int32 index ) const if( 0<=index && index<m_aValues_X.getLength() ) { fRet = m_aValues_X.Doubles[index]; - if(mpOldSeries) + if(mpOldSeries && index < mpOldSeries->m_aValues_X.getLength()) { double nOldVal = mpOldSeries->m_aValues_X.Doubles[index]; fRet = nOldVal + (fRet - nOldVal) * mnPercent; @@ -498,7 +498,7 @@ double VDataSeries::getYValue( sal_Int32 index ) const if( 0<=index && index<m_aValues_Y.getLength() ) { fRet = m_aValues_Y.Doubles[index]; - if(mpOldSeries) + if(mpOldSeries && index < mpOldSeries->m_aValues_Y.getLength()) { double nOldVal = mpOldSeries->m_aValues_Y.Doubles[index]; fRet = nOldVal + (fRet - nOldVal) * mnPercent; @@ -565,7 +565,7 @@ double VDataSeries::getY_Last( sal_Int32 index ) const double VDataSeries::getBubble_Size( sal_Int32 index ) const { double nNewVal = m_aValues_Bubble_Size.getValue( index ); - if(mpOldSeries) + if(mpOldSeries && index < mpOldSeries->m_aValues_Bubble_Size.getLength()) { double nOldVal = mpOldSeries->m_aValues_Bubble_Size.getValue( index ); nNewVal = nOldVal + (nNewVal - nOldVal) * mnPercent; diff --git a/offapi/com/sun/star/chart2/XTimeBased.idl b/offapi/com/sun/star/chart2/XTimeBased.idl index 328b54c28d6c..487e22ecb698 100644 --- a/offapi/com/sun/star/chart2/XTimeBased.idl +++ b/offapi/com/sun/star/chart2/XTimeBased.idl @@ -20,7 +20,7 @@ interface XTimeBased : com::sun::star::uno::XInterface * @return * FALSE if the data wrapped around */ - boolean switchToNext(); + boolean switchToNext( [in] boolean wrap); /** * point is the zero based index into the time based array @@ -28,6 +28,8 @@ interface XTimeBased : com::sun::star::uno::XInterface * @return FALSE if the point is outside of the supported array */ boolean setToPointInTime( [in] long point ); + + void setRange( [in] long start, [in] long end ); }; }; }; }; }; diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx index ce36c268dea1..0eb58e1b4a5d 100644 --- a/sc/inc/chart2uno.hxx +++ b/sc/inc/chart2uno.hxx @@ -279,9 +279,11 @@ public: std::exception); // XTimeBased - virtual sal_Bool switchToNext() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool switchToNext(sal_Bool bWrap) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool setToPointInTime(sal_Int32 nPoint) throw (::com::sun::star::uno::RuntimeException); + virtual void setRange(sal_Int32 nStart, sal_Int32 nEnd) throw (::com::sun::star::uno::RuntimeException); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 0dfd65f1f00e..05121150e8ee 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2491,6 +2491,10 @@ ScChart2DataSequence::ScChart2DataSequence( ScDocument* pDoc, , m_pValueListener( NULL ) , m_bGotDataChangedHint(false) , m_bExtDataRebuildQueued(false) + , mbTimeBased(false) + , mnTimeBasedStart(0) + , mnTimeBasedEnd(0) + , mnCurrentTab(0) { OSL_ENSURE(pTokens, "reference token list is null"); @@ -3588,14 +3592,18 @@ void ScChart2DataSequence::setDataChangedHint(bool b) m_bGotDataChangedHint = b; } -sal_Bool ScChart2DataSequence::switchToNext() +sal_Bool ScChart2DataSequence::switchToNext(sal_Bool bWrap) throw (uno::RuntimeException) { - if(!m_pTokens) + if(!m_pTokens || !mbTimeBased) return sal_True; if(mnCurrentTab >= mnTimeBasedEnd) + { + if(bWrap) + setToPointInTime(0); return false; + } for(vector<ScTokenRef>::iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end(); itr != itrEnd; ++itr) @@ -3611,11 +3619,21 @@ sal_Bool ScChart2DataSequence::switchToNext() e.IncTab(1); } + ++mnCurrentTab; + RebuildDataCache(); return sal_True; } +void ScChart2DataSequence::setRange(sal_Int32 nStart, sal_Int32 nEnd) + throw (uno::RuntimeException) +{ + mnTimeBasedStart = nStart; + mnTimeBasedEnd = nEnd; + mnCurrentTab = mnTimeBasedStart; +} + sal_Bool ScChart2DataSequence::setToPointInTime(sal_Int32 nPoint) throw (uno::RuntimeException) { @@ -3640,6 +3658,8 @@ sal_Bool ScChart2DataSequence::setToPointInTime(sal_Int32 nPoint) e.SetAbsTab(nTab); } + mnCurrentTab = nTab; + RebuildDataCache(); return sal_True; |