summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-12-31 15:15:19 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-29 08:09:29 +0100
commit7a6d7265634bc16bc30841990147882ce1d240ac (patch)
tree0d0aaf395bacb5fa2f7a8a94096c6046792731c9
parent26ce0530cb608af1568e2689662cdc0c4b79d0e1 (diff)
time based charting calc side
Change-Id: I0d5963a691e4495ee14e4d1228ea0ba2b1dd66d7
-rwxr-xr-xoffapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/chart2/XTimeBased.idl30
-rw-r--r--sc/inc/chart2uno.hxx25
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx84
4 files changed, 135 insertions, 5 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index cd7434f19d0e..f2664e90d5e7 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2027,6 +2027,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2,\
XRegressionCurveContainer \
XScaling \
XTarget \
+ XTimeBased \
XTitle \
XTitled \
XTransformation \
diff --git a/offapi/com/sun/star/chart2/XTimeBased.idl b/offapi/com/sun/star/chart2/XTimeBased.idl
new file mode 100644
index 000000000000..70ce70152487
--- /dev/null
+++ b/offapi/com/sun/star/chart2/XTimeBased.idl
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef com_sun_star_chart2_XTimeBased_idl
+#define com_sun_star_chart2_XTimeBased_idl
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com { module sun { module star { module chart2 {
+
+interface XTimeBased : com::sun::star::uno::XInterface
+{
+
+ /**
+ * @return
+ * FALSE if the data wrapped around
+ */
+ boolean switchToNext();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index 9af4f93155b2..8f7e5dc67761 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -37,13 +37,14 @@
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/DataSequenceRole.hpp>
+#include <com/sun/star/chart2/XTimeBased.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase5.hxx>
-#include <cppuhelper/implbase7.hxx>
+#include <cppuhelper/implbase8.hxx>
#include <rtl/ustring.hxx>
#include <svl/itemprop.hxx>
@@ -189,8 +190,9 @@ private:
// DataSource
class ScChart2DataSource : public
- ::cppu::WeakImplHelper2<
+ ::cppu::WeakImplHelper3<
::com::sun::star::chart2::data::XDataSource,
+ com::sun::star::chart2::XTimeBased,
::com::sun::star::lang::XServiceInfo>,
SfxListener
{
@@ -205,6 +207,10 @@ public:
::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL
getDataSequences() throw (::com::sun::star::uno::RuntimeException);
+ // XTimeBased
+ virtual sal_Bool switchToNext() throw(
+ ::com::sun::star::uno::RuntimeException);
+
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw(
::com::sun::star::uno::RuntimeException);
@@ -220,20 +226,28 @@ public:
void AddLabeledSequence(const com::sun::star::uno::Reference < com::sun::star::chart2::data::XLabeledDataSequence >& xNew);
+ void SetTimeBased(SCTAB nTimeBasedStart, SCTAB nTimeBasedEnd);
+
private:
ScDocument* m_pDocument;
typedef std::list < com::sun::star::uno::Reference< com::sun::star::chart2::data::XLabeledDataSequence > > LabeledList;
LabeledList m_aLabeledSequences;
+ bool bTimeBased;
+ SCTAB mnTimeBasedStart;
+ SCTAB mnTimeBasedEnd;
+ SCTAB mnCurrentTab;
+
};
// DataSequence
class ScChart2DataSequence : public
- ::cppu::WeakImplHelper7<
+ ::cppu::WeakImplHelper8<
::com::sun::star::chart2::data::XDataSequence,
::com::sun::star::chart2::data::XTextualDataSequence,
::com::sun::star::chart2::data::XNumericalDataSequence,
+ com::sun::star::chart2::XTimeBased,
::com::sun::star::util::XCloneable,
::com::sun::star::util::XModifyBroadcaster,
::com::sun::star::beans::XPropertySet,
@@ -276,6 +290,9 @@ public:
throw (::com::sun::star::uno::RuntimeException,
std::exception);
+ // XTimeBased
+ virtual sal_Bool switchToNext() 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 90ad4e00dffa..d85f7c2678c7 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -1441,6 +1441,7 @@ ScChart2DataProvider::createDataSource(
bool bOrientCol = true;
OUString aRangeRepresentation;
uno::Sequence< sal_Int32 > aSequenceMapping;
+ sal_Bool bTimeBased = false;
for(sal_Int32 i = 0; i < aArguments.getLength(); ++i)
{
if ( aArguments[i].Name == "DataRowSource" )
@@ -1470,6 +1471,10 @@ ScChart2DataProvider::createDataSource(
{
aArguments[i].Value >>= aSequenceMapping;
}
+ else if ( aArguments[i].Name == "TimeBased" )
+ {
+ aArguments[i].Value >>= bTimeBased;
+ }
}
vector<ScTokenRef> aRefTokens;
@@ -1480,7 +1485,31 @@ ScChart2DataProvider::createDataSource(
// Invalid range representation. Bail out.
throw lang::IllegalArgumentException();
- shrinkToDataRange(m_pDocument, aRefTokens);
+ SCTAB nTimeBasedStart = MAXTAB;
+ SCTAB nTimeBasedEnd = 0;
+ if(bTimeBased)
+ {
+ // limit to first sheet
+ for(vector<ScTokenRef>::iterator itr = aRefTokens.begin(),
+ itrEnd = aRefTokens.end(); itr != itrEnd; ++itr)
+ {
+ if ((*itr)->GetType() != svDoubleRef)
+ continue;
+
+ ScComplexRefData& rData = (*itr)->GetDoubleRef();
+ ScSingleRefData& s = rData.Ref1;
+ ScSingleRefData& e = rData.Ref2;
+
+ nTimeBasedStart = std::min(nTimeBasedStart, s.Tab());
+ nTimeBasedEnd = std::min(nTimeBasedEnd, e.Tab());
+
+ if(s.Tab() != e.Tab())
+ e.SetAbsTab(s.Tab());
+ }
+ }
+
+ if(!bTimeBased)
+ shrinkToDataRange(m_pDocument, aRefTokens);
if (bLabel)
lcl_addUpperLeftCornerIfMissing(aRefTokens); //#i90669#
@@ -1550,6 +1579,8 @@ ScChart2DataProvider::createDataSource(
}
pDS = new ScChart2DataSource(m_pDocument);
+ if(bTimeBased)
+ pDS->SetTimeBased(nTimeBasedStart, nTimeBasedEnd);
::std::list< Reference< chart2::data::XLabeledDataSequence > >::iterator aItr( aSeqs.begin() );
::std::list< Reference< chart2::data::XLabeledDataSequence > >::iterator aEndItr( aSeqs.end() );
@@ -2424,6 +2455,32 @@ void ScChart2DataSource::AddLabeledSequence(const uno::Reference < chart2::data:
m_aLabeledSequences.push_back(xNew);
}
+sal_Bool ScChart2DataSource::switchToNext() throw ( uno::RuntimeException)
+{
+ if(mnCurrentTab != mnTimeBasedEnd)
+ {
+ for(LabeledList::iterator itr = m_aLabeledSequences.begin(),
+ itrEnd = m_aLabeledSequences.end(); itr != itrEnd; ++itr)
+ {
+ uno::Reference< chart2::XTimeBased> xTimeBased(*itr, uno::UNO_QUERY);
+ if(xTimeBased.is())
+ xTimeBased->switchToNext();
+ }
+ ++mnCurrentTab;
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+void ScChart2DataSource::SetTimeBased(SCTAB nTimeBasedStart, SCTAB nTimeBasedEnd)
+{
+ mnCurrentTab = nTimeBasedStart;
+ mnTimeBasedStart = nTimeBasedStart;
+ mnTimeBasedEnd = nTimeBasedEnd;
+ bTimeBased = true;
+}
+
// DataSequence ==============================================================
@@ -3550,4 +3607,29 @@ void ScChart2DataSequence::setDataChangedHint(bool b)
m_bGotDataChangedHint = b;
}
+sal_Bool ScChart2DataSequence::switchToNext()
+ throw (uno::RuntimeException)
+{
+ if(!m_pTokens)
+ return sal_True;
+
+ for(vector<ScTokenRef>::iterator itr = m_pTokens->begin(),
+ itrEnd = m_pTokens->end(); itr != itrEnd; ++itr)
+ {
+ if ((*itr)->GetType() != svDoubleRef)
+ continue;
+
+ ScComplexRefData& rData = (*itr)->GetDoubleRef();
+ ScSingleRefData& s = rData.Ref1;
+ ScSingleRefData& e = rData.Ref2;
+
+ s.IncTab(1);
+ e.IncTab(1);
+ }
+
+ RebuildDataCache();
+
+ return sal_True;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */