1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef CHART2_INTERNALDATAPROVIDER_HXX
29 #define CHART2_INTERNALDATAPROVIDER_HXX
31 #include "InternalData.hxx"
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/chart/XDateCategories.hpp>
35 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
36 #include <com/sun/star/chart2/data/XDataProvider.hpp>
37 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
38 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
39 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
40 #include <com/sun/star/chart2/XChartDocument.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/util/XCloneable.hpp>
43 #include <cppuhelper/implbase7.hxx>
44 #include "ServiceMacros.hxx"
46 #include "CachedDataSequence.hxx"
57 typedef ::cppu::WeakImplHelper7
<
58 ::com::sun::star::chart2::XInternalDataProvider
,
59 ::com::sun::star::chart2::data::XRangeXMLConversion
,
60 ::com::sun::star::chart2::XAnyDescriptionAccess
,
61 ::com::sun::star::chart::XDateCategories
,
62 ::com::sun::star::util::XCloneable
,
63 ::com::sun::star::lang::XInitialization
,
64 ::com::sun::star::lang::XServiceInfo
>
65 InternalDataProvider_Base
;
68 /** Data provider that handles data internally. This is used for charts with
71 <p>The format for single ranges is "categories|label n|n" where n is a
72 non-negative number. Meaning return all categories, the label of sequence n,
73 or the data of sequence n.</p>
75 <p>The format for a complete range is "all". (Do we need more than
78 class InternalDataProvider
:
79 public impl::InternalDataProvider_Base
82 explicit InternalDataProvider(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & _xContext
);
83 explicit InternalDataProvider( const ::com::sun::star::uno::Reference
<
84 ::com::sun::star::chart2::XChartDocument
> & xChartDoc
, bool bConnectToModel
);
85 explicit InternalDataProvider( const InternalDataProvider
& rOther
);
86 virtual ~InternalDataProvider();
88 void createDefaultData();
90 /// declare XServiceInfo methods
91 APPHELPER_XSERVICEINFO_DECL()
92 APPHELPER_SERVICE_FACTORY_HELPER(InternalDataProvider
)
94 // ____ XInternalDataProvider ____
95 virtual ::sal_Bool SAL_CALL
hasDataByRangeRepresentation( const ::rtl::OUString
& aRange
)
96 throw (::com::sun::star::uno::RuntimeException
);
97 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
98 getDataByRangeRepresentation( const ::rtl::OUString
& aRange
)
99 throw (::com::sun::star::uno::RuntimeException
);
100 virtual void SAL_CALL
setDataByRangeRepresentation(
101 const ::rtl::OUString
& aRange
,
102 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aNewData
)
103 throw (::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
insertSequence( ::sal_Int32 nAfterIndex
)
105 throw (::com::sun::star::uno::RuntimeException
);
106 virtual void SAL_CALL
deleteSequence( ::sal_Int32 nAtIndex
)
107 throw (::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
appendSequence()
109 throw (::com::sun::star::uno::RuntimeException
);
110 virtual void SAL_CALL
insertComplexCategoryLevel( ::sal_Int32 nLevel
)
111 throw (::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
deleteComplexCategoryLevel( ::sal_Int32 nLevel
)
113 throw (::com::sun::star::uno::RuntimeException
);
114 virtual void SAL_CALL
insertDataPointForAllSequences( ::sal_Int32 nAfterIndex
)
115 throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
deleteDataPointForAllSequences( ::sal_Int32 nAtIndex
)
117 throw (::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex
)
119 throw (::com::sun::star::uno::RuntimeException
);
120 virtual void SAL_CALL
registerDataSequenceForChanges(
121 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
>& xSeq
)
122 throw (::com::sun::star::uno::RuntimeException
);
124 // ____ XDataProvider (base of XInternalDataProvider) ____
125 virtual ::sal_Bool SAL_CALL
createDataSourcePossible(
126 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArguments
)
127 throw (::com::sun::star::uno::RuntimeException
);
128 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
> SAL_CALL
createDataSource(
129 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArguments
)
130 throw (::com::sun::star::lang::IllegalArgumentException
,
131 ::com::sun::star::uno::RuntimeException
);
132 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
detectArguments(
133 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSource
>& xDataSource
)
134 throw (::com::sun::star::uno::RuntimeException
);
135 virtual ::sal_Bool SAL_CALL
createDataSequenceByRangeRepresentationPossible(
136 const ::rtl::OUString
& aRangeRepresentation
)
137 throw (::com::sun::star::uno::RuntimeException
);
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
> SAL_CALL
createDataSequenceByRangeRepresentation(
139 const ::rtl::OUString
& aRangeRepresentation
)
140 throw (::com::sun::star::lang::IllegalArgumentException
,
141 ::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XRangeSelection
> SAL_CALL
getRangeSelection()
143 throw (::com::sun::star::uno::RuntimeException
);
145 // ____ XRangeXMLConversion ____
146 virtual ::rtl::OUString SAL_CALL
convertRangeToXML(
147 const ::rtl::OUString
& aRangeRepresentation
)
148 throw (::com::sun::star::lang::IllegalArgumentException
,
149 ::com::sun::star::uno::RuntimeException
);
150 virtual ::rtl::OUString SAL_CALL
convertRangeFromXML(
151 const ::rtl::OUString
& aXMLRange
)
152 throw (::com::sun::star::lang::IllegalArgumentException
,
153 ::com::sun::star::uno::RuntimeException
);
155 // ____ XDateCategories ____
156 virtual ::com::sun::star::uno::Sequence
< double > SAL_CALL
getDateCategories() throw (::com::sun::star::uno::RuntimeException
);
157 virtual void SAL_CALL
setDateCategories( const ::com::sun::star::uno::Sequence
< double >& rDates
) throw (::com::sun::star::uno::RuntimeException
);
159 // ____ XAnyDescriptionAccess ____
160 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> > SAL_CALL
161 getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException
);
162 virtual void SAL_CALL
setAnyRowDescriptions(
163 const ::com::sun::star::uno::Sequence
<
164 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> >& aRowDescriptions
)
165 throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> > SAL_CALL
167 getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
setAnyColumnDescriptions(
169 const ::com::sun::star::uno::Sequence
<
170 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> >& aColumnDescriptions
)
171 throw (::com::sun::star::uno::RuntimeException
);
173 // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
174 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::rtl::OUString
> > SAL_CALL
175 getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException
);
176 virtual void SAL_CALL
setComplexRowDescriptions(
177 const ::com::sun::star::uno::Sequence
<
178 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> >& aRowDescriptions
)
179 throw (::com::sun::star::uno::RuntimeException
);
180 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::rtl::OUString
> > SAL_CALL
181 getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
setComplexColumnDescriptions(
183 const ::com::sun::star::uno::Sequence
<
184 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> >& aColumnDescriptions
)
185 throw (::com::sun::star::uno::RuntimeException
);
187 // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
188 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > > SAL_CALL
getData()
189 throw (::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
setData(
191 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< double > >& aData
)
192 throw (::com::sun::star::uno::RuntimeException
);
193 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getRowDescriptions()
194 throw (::com::sun::star::uno::RuntimeException
);
195 virtual void SAL_CALL
setRowDescriptions(
196 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aRowDescriptions
)
197 throw (::com::sun::star::uno::RuntimeException
);
198 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getColumnDescriptions()
199 throw (::com::sun::star::uno::RuntimeException
);
200 virtual void SAL_CALL
setColumnDescriptions(
201 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aColumnDescriptions
)
202 throw (::com::sun::star::uno::RuntimeException
);
204 // ____ XChartData (base of XChartDataArray) ____
205 virtual void SAL_CALL
addChartDataChangeEventListener(
206 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart::XChartDataChangeEventListener
>& aListener
)
207 throw (::com::sun::star::uno::RuntimeException
);
208 virtual void SAL_CALL
removeChartDataChangeEventListener(
209 const ::com::sun::star::uno::Reference
< ::com::sun::star::chart::XChartDataChangeEventListener
>& aListener
)
210 throw (::com::sun::star::uno::RuntimeException
);
211 virtual double SAL_CALL
getNotANumber()
212 throw (::com::sun::star::uno::RuntimeException
);
213 virtual ::sal_Bool SAL_CALL
isNotANumber(
215 throw (::com::sun::star::uno::RuntimeException
);
217 // ____ XCloneable ____
218 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloneable
> SAL_CALL
createClone()
219 throw (::com::sun::star::uno::RuntimeException
);
220 // ::com::sun::star::lang::XInitialization:
221 virtual void SAL_CALL
initialize(const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> & aArguments
)
222 throw (::com::sun::star::uno::RuntimeException
, ::com::sun::star::uno::Exception
);
225 void lcl_addDataSequenceToMap(
226 const ::rtl::OUString
& rRangeRepresentation
,
227 const ::com::sun::star::uno::Reference
<
228 ::com::sun::star::chart2::data::XDataSequence
> & xSequence
);
230 ::com::sun::star::uno::Reference
<
231 ::com::sun::star::chart2::data::XDataSequence
>
232 lcl_createDataSequenceAndAddToMap( const ::rtl::OUString
& rRangeRepresentation
,
233 const ::rtl::OUString
& rRole
);
234 ::com::sun::star::uno::Reference
<
235 ::com::sun::star::chart2::data::XDataSequence
>
236 lcl_createDataSequenceAndAddToMap( const ::rtl::OUString
& rRangeRepresentation
);
238 void lcl_deleteMapReferences( const ::rtl::OUString
& rRangeRepresentation
);
240 void lcl_adaptMapReferences(
241 const ::rtl::OUString
& rOldRangeRepresentation
,
242 const ::rtl::OUString
& rNewRangeRepresentation
);
244 void lcl_increaseMapReferences( sal_Int32 nBegin
, sal_Int32 nEnd
);
245 void lcl_decreaseMapReferences( sal_Int32 nBegin
, sal_Int32 nEnd
);
247 typedef ::std::multimap
< ::rtl::OUString
,
248 ::com::sun::star::uno::WeakReference
< ::com::sun::star::chart2::data::XDataSequence
> >
250 typedef ::std::pair
< tSequenceMap::iterator
, tSequenceMap::iterator
> tSequenceMapRange
;
251 typedef ::std::pair
< tSequenceMap::const_iterator
, tSequenceMap::const_iterator
> tConstSequenceMapRange
;
253 /** cache for all sequences that have been returned.
255 If the range-representation of a sequence changes and it is still
256 referred to by some component (weak reference is valid), the range will
259 tSequenceMap m_aSequenceMap
;
260 InternalData m_aInternalData
;
261 bool m_bDataInColumns
;
266 // CHART2_INTERNALDATAPROVIDER_HXX
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */