summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-02 05:08:32 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-29 08:09:30 +0100
commit55656ee2e88b7a79a265f43fc3746a7e2186301e (patch)
treeeebc114793896d075fb5f361f01220c5fbfbc1d1 /chart2
parent893a7fc4e494f58d105f567c652bd2b6c6c825f8 (diff)
some improvements for the time based charting
The updating seems to work. It just does not update the references yet. Change-Id: I0a971dbe2beb113c1c3e9ef103d77d5d8c7174a0
Diffstat (limited to 'chart2')
-rw-r--r--chart2/inc/ChartView.hxx9
-rw-r--r--chart2/source/inc/LabeledDataSequence.hxx10
-rw-r--r--chart2/source/model/main/ChartModel.cxx28
-rw-r--r--chart2/source/tools/LabeledDataSequence.cxx31
-rw-r--r--chart2/source/view/main/ChartView.cxx55
5 files changed, 88 insertions, 45 deletions
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index b1c6b5f3eb25..766563a43c97 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -45,7 +45,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
-#include <salhelper/thread.hxx>
+#include <vcl/timer.hxx>
class SdrPage;
@@ -68,13 +68,12 @@ struct TimeBasedInfo
TimeBasedInfo():
bTimeBased(false),
nFrame(0),
- eMode(AUTOMATIC),
- mpThread(NULL) {}
+ eMode(AUTOMATIC) {}
bool bTimeBased;
size_t nFrame;
TimeBasedMode eMode;
- salhelper::Thread* mpThread;
+ Timer maTimer;
// only valid when we are in the time based mode
::std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
@@ -220,6 +219,8 @@ private: //methods
, bool bUseFixedInnerSize
, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& xDiagram_MarkHandles );
+ DECL_LINK( UpdateTimeBased, void* );
+
private: //member
::osl::Mutex m_aMutex;
diff --git a/chart2/source/inc/LabeledDataSequence.hxx b/chart2/source/inc/LabeledDataSequence.hxx
index 3cd8258b0017..41b7e2647dc4 100644
--- a/chart2/source/inc/LabeledDataSequence.hxx
+++ b/chart2/source/inc/LabeledDataSequence.hxx
@@ -21,21 +21,23 @@
#include "ServiceMacros.hxx"
#include "MutexContainer.hxx"
#include <comphelper/uno3.hxx>
-#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.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::WeakImplHelper2<
+typedef cppu::WeakImplHelper3<
::com::sun::star::chart2::data::XLabeledDataSequence2,
+ com::sun::star::chart2::XTimeBased,
::com::sun::star::lang::XServiceInfo >
LabeledDataSequence_Base;
}
@@ -77,6 +79,10 @@ 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 d65ab67ddf3c..a0d93d171e7b 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -1357,14 +1357,34 @@ bool ChartModel::isTimeBased() const
void ChartModel::setTimeBased(bool bTimeBased)
{
mbTimeBased = bTimeBased;
+ uno::Sequence<Reference< chart2::data::XLabeledDataSequence > >
+ xDataSequences = getDataSequences();
+ sal_Int32 n = xDataSequences.getLength();
+ for(sal_Int32 i = 0; i < n; ++i)
+ {
+ uno::Reference< chart2::XTimeBased > xTimeBased(xDataSequences[i]->getValues(), uno::UNO_QUERY);
+ SAL_WARN_IF(!xTimeBased.is(), "chart2", "does not support time based charting");
+ if(xTimeBased.is())
+ {
+ uno::Reference< beans::XPropertySet > xPropSet(xTimeBased, uno::UNO_QUERY_THROW);
+ xPropSet->setPropertyValue("TimeBased", uno::makeAny(bTimeBased));
+ }
+ }
}
void ChartModel::getNextTimePoint()
{
- uno::Reference< chart2::XTimeBased > xTimeBased(getUsedData(), uno::UNO_QUERY);
- SAL_WARN_IF(!xTimeBased.is(), "chart2", "does not support time based charting");
- if(xTimeBased.is())
- xTimeBased->switchToNext();
+ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = getDataSequences();
+ sal_Int32 n = xDataSequences.getLength();
+ for(sal_Int32 i = 0; i < n; ++i)
+ {
+ uno::Reference< chart2::XTimeBased > xTimeBased(xDataSequences[i]->getValues(), uno::UNO_QUERY);
+ SAL_WARN_IF(!xTimeBased.is(), "chart2", "does not support time based charting");
+ if(xTimeBased.is())
+ {
+ xTimeBased->switchToNext();
+ }
+ }
}
} // namespace chart
diff --git a/chart2/source/tools/LabeledDataSequence.cxx b/chart2/source/tools/LabeledDataSequence.cxx
index 68df3c83520c..cc0a6c199e17 100644
--- a/chart2/source/tools/LabeledDataSequence.cxx
+++ b/chart2/source/tools/LabeledDataSequence.cxx
@@ -101,6 +101,37 @@ 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 53ac9fc9702a..e462d7f9a707 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -125,32 +125,6 @@ namespace
{
class theExplicitValueProviderUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theExplicitValueProviderUnoTunnelId > {};
-class UpdateTimeBasedThread : public salhelper::Thread
-{
-public:
- UpdateTimeBasedThread(ChartView& rChartView, TimeBasedInfo& rTimeBasedInfo):
- salhelper::Thread("ChartUpdate"),
- mrChartView(rChartView),
- mrTimeBasedInfo(rTimeBasedInfo) {}
-private:
- virtual void execute()
- {
- TimeValue const aTime = { 0, 100 };
- for(size_t i = 0; i < 60; ++i)
- {
- mrChartView.setViewDirty();
- {
- SolarMutexGuard aSolarGuard;
- mrChartView.update();
- }
- wait(aTime);
- }
- }
-
- ChartView& mrChartView;
- TimeBasedInfo& mrTimeBasedInfo;
-};
-
}
const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId()
@@ -2404,13 +2378,6 @@ void ChartView::createShapes()
if(mrChartModel.isTimeBased())
{
maTimeBased.bTimeBased = true;
-
- if(!maTimeBased.mpThread)
- {
- maTimeBased.mpThread = new UpdateTimeBasedThread(*this, maTimeBased);
- maTimeBased.mpThread->launch();
- }
-
}
//make sure add-in is refreshed after creating the shapes
@@ -2606,7 +2573,7 @@ void ChartView::createShapes()
rSeriesPlotter[i]->getAllSeries();
std::vector< VDataSeries* >& rAllOldDataSeries =
maTimeBased.m_aDataSeriesList[i];
- size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size());
+ size_t m = aAllNewDataSeries.size();
for(size_t j = 0; j < m; ++j)
{
rAllOldDataSeries.push_back( aAllNewDataSeries[j]->
@@ -2614,7 +2581,17 @@ void ChartView::createShapes()
}
}
- mrChartModel.getNextTimePoint();
+ if(maTimeBased.eMode != MANUAL)
+ mrChartModel.getNextTimePoint();
+ else
+ maTimeBased.maTimer.Stop();
+ }
+
+ if(maTimeBased.bTimeBased && maTimeBased.eMode != MANUAL && !maTimeBased.maTimer.IsActive())
+ {
+ maTimeBased.maTimer.SetTimeout(15);
+ maTimeBased.maTimer.SetTimeoutHdl(LINK(this, ChartView, UpdateTimeBased));
+ maTimeBased.maTimer.Start();
}
}
@@ -3055,6 +3032,14 @@ void ChartView::setViewDirty()
m_bViewDirty = true;
}
+IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
+{
+ setViewDirty();
+ update();
+
+ return 0;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */