Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SC_DPTABSRC_HXX
21 : #define SC_DPTABSRC_HXX
22 :
23 : #include "global.hxx"
24 : #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
25 : #include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
26 : #include <com/sun/star/sheet/XLevelsSupplier.hpp>
27 : #include <com/sun/star/sheet/XMembersSupplier.hpp>
28 : #include <com/sun/star/sheet/XDataPilotResults.hpp>
29 : #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
30 : #include <com/sun/star/sheet/MemberResult.hpp>
31 : #include <com/sun/star/sheet/GeneralFunction.hpp>
32 : #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
33 : #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
34 : #include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
35 : #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
36 : #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
37 : #include <com/sun/star/util/XRefreshable.hpp>
38 : #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
39 : #include <com/sun/star/util/XCloneable.hpp>
40 : #include <com/sun/star/beans/XPropertySet.hpp>
41 : #include <com/sun/star/lang/XServiceInfo.hpp>
42 : #include <com/sun/star/container/XNamed.hpp>
43 : #include <cppuhelper/implbase2.hxx>
44 : #include <cppuhelper/implbase3.hxx>
45 : #include <cppuhelper/implbase5.hxx>
46 : #include <cppuhelper/implbase6.hxx>
47 : #include "rtl/ref.hxx"
48 :
49 : #include "dptabdat.hxx"
50 : #include "dpglobal.hxx"
51 : #include "dpresfilter.hxx"
52 :
53 : #include <boost/unordered_map.hpp>
54 : #include <boost/unordered_set.hpp>
55 : #include <boost/noncopyable.hpp>
56 : #include <boost/scoped_ptr.hpp>
57 : #include <vector>
58 : #include <list>
59 :
60 : namespace com { namespace sun { namespace star {
61 : namespace sheet {
62 : struct DataPilotFieldFilter;
63 : }
64 : namespace table {
65 : struct CellAddress;
66 : }
67 : }}}
68 :
69 : class ScDPResultMember;
70 : class ScDPResultData;
71 : class ScDPItemData;
72 : class ScDPTableData;
73 :
74 :
75 : // implementation of DataPilotSource using ScDPTableData
76 :
77 : class ScDPDimensions;
78 : class ScDPDimension;
79 : class ScDPHierarchies;
80 : class ScDPHierarchy;
81 : class ScDPLevels;
82 : class ScDPLevel;
83 : class ScDPMembers;
84 : class ScDPMember;
85 :
86 :
87 : class ScDPSource : public cppu::WeakImplHelper6<
88 : com::sun::star::sheet::XDimensionsSupplier,
89 : com::sun::star::sheet::XDataPilotResults,
90 : com::sun::star::util::XRefreshable,
91 : com::sun::star::sheet::XDrillDownDataSupplier,
92 : com::sun::star::beans::XPropertySet,
93 : com::sun::star::lang::XServiceInfo >
94 : {
95 : private:
96 : ScDPTableData* pData; // data source (ScDPObject manages its life time)
97 : ScDPDimensions* pDimensions; // api objects
98 : // settings:
99 :
100 : std::vector<long> maColDims;
101 : std::vector<long> maRowDims;
102 : std::vector<long> maDataDims;
103 : std::vector<long> maPageDims;
104 : ScDPResultTree maResFilterSet;
105 :
106 : bool bColumnGrand;
107 : bool bRowGrand;
108 : bool bIgnoreEmptyRows;
109 : bool bRepeatIfEmpty;
110 :
111 : long nDupCount;
112 :
113 : // results:
114 : ScDPResultData* pResData; // keep the rest in this!
115 : ScDPResultMember* pColResRoot;
116 : ScDPResultMember* pRowResRoot;
117 : com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pColResults;
118 : com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>* pRowResults;
119 : std::vector<ScDPLevel*> aColLevelList;
120 : std::vector<ScDPLevel*> aRowLevelList;
121 : bool bResultOverflow;
122 : bool bPageFiltered; // set if page field filters have been applied to cache table
123 :
124 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
125 : ::std::auto_ptr<OUString> mpGrandTotalName;
126 : SAL_WNODEPRECATED_DECLARATIONS_POP
127 :
128 : void CreateRes_Impl();
129 : void FillMemberResults();
130 : void FillLevelList( sal_uInt16 nOrientation, std::vector<ScDPLevel*> &rList );
131 : void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow);
132 :
133 : /**
134 : * Compile a list of dimension indices that are either, column, row or
135 : * page dimensions (i.e. all but data dimensions).
136 : */
137 : void GetCategoryDimensionIndices(::boost::unordered_set<sal_Int32>& rCatDims);
138 :
139 : /**
140 : * Set visibilities of individual rows in the cache table based on the
141 : * page field data.
142 : */
143 : void FilterCacheByPageDimensions();
144 :
145 : void SetDupCount( long nNew );
146 :
147 : OUString getDataDescription(); //! ???
148 :
149 : void setIgnoreEmptyRows(bool bSet);
150 : void setRepeatIfEmpty(bool bSet);
151 :
152 : void disposeData();
153 :
154 : public:
155 : ScDPSource( ScDPTableData* pD );
156 : virtual ~ScDPSource();
157 :
158 0 : ScDPTableData* GetData() { return pData; }
159 0 : const ScDPTableData* GetData() const { return pData; }
160 :
161 : const OUString* GetGrandTotalName() const;
162 :
163 : sal_uInt16 GetOrientation(long nColumn);
164 : void SetOrientation(long nColumn, sal_uInt16 nNew);
165 : long GetPosition(long nColumn);
166 :
167 : long GetDataDimensionCount();
168 : ScDPDimension* GetDataDimension(long nIndex);
169 : OUString GetDataDimName(long nIndex);
170 : const ScDPCache* GetCache();
171 : const ScDPItemData* GetItemDataById( long nDim, long nId );
172 : long GetDataLayoutDim(){ return pData->GetColumnCount(); }
173 : SCROW GetMemberId( long nDim, const ScDPItemData& rData );
174 : bool IsDataLayoutDimension(long nDim);
175 : sal_uInt16 GetDataLayoutOrientation();
176 :
177 : bool IsDateDimension(long nDim);
178 :
179 : bool SubTotalAllowed(long nColumn); //! move to ScDPResultData
180 :
181 : ScDPDimension* AddDuplicated(long nSource, const OUString& rNewName);
182 0 : long GetDupCount() const { return nDupCount; }
183 :
184 : long GetSourceDim(long nDim);
185 :
186 : const com::sun::star::uno::Sequence<com::sun::star::sheet::MemberResult>*
187 : GetMemberResults( ScDPLevel* pLevel );
188 :
189 : ScDPDimensions* GetDimensionsObject();
190 :
191 : // XDimensionsSupplier
192 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
193 : SAL_CALL getDimensions( )
194 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 :
196 : // XDataPilotResults
197 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<
198 : ::com::sun::star::sheet::DataResult > > SAL_CALL getResults( )
199 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 :
201 : virtual com::sun::star::uno::Sequence<double> SAL_CALL
202 : getFilteredResults(
203 : const com::sun::star::uno::Sequence<com::sun::star::sheet::DataPilotFieldFilter>& aFilters )
204 : throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
205 :
206 : // XRefreshable
207 : virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 : virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
209 : ::com::sun::star::util::XRefreshListener >& l )
210 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 : virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
212 : ::com::sun::star::util::XRefreshListener >& l )
213 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
214 :
215 : // XDrillDownDataSupplier
216 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >
217 : SAL_CALL getDrillDownData(const ::com::sun::star::uno::Sequence<
218 : ::com::sun::star::sheet::DataPilotFieldFilter >& aFilters )
219 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
220 :
221 : // XPropertySet
222 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
223 : SAL_CALL getPropertySetInfo( )
224 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
226 : const ::com::sun::star::uno::Any& aValue )
227 : throw(::com::sun::star::beans::UnknownPropertyException,
228 : ::com::sun::star::beans::PropertyVetoException,
229 : ::com::sun::star::lang::IllegalArgumentException,
230 : ::com::sun::star::lang::WrappedTargetException,
231 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
232 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
233 : const OUString& PropertyName )
234 : throw(::com::sun::star::beans::UnknownPropertyException,
235 : ::com::sun::star::lang::WrappedTargetException,
236 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
237 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
238 : const ::com::sun::star::uno::Reference<
239 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
240 : throw(::com::sun::star::beans::UnknownPropertyException,
241 : ::com::sun::star::lang::WrappedTargetException,
242 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
243 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
244 : const ::com::sun::star::uno::Reference<
245 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
246 : throw(::com::sun::star::beans::UnknownPropertyException,
247 : ::com::sun::star::lang::WrappedTargetException,
248 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
249 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
250 : const ::com::sun::star::uno::Reference<
251 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
252 : throw(::com::sun::star::beans::UnknownPropertyException,
253 : ::com::sun::star::lang::WrappedTargetException,
254 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
255 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
256 : const ::com::sun::star::uno::Reference<
257 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
258 : throw(::com::sun::star::beans::UnknownPropertyException,
259 : ::com::sun::star::lang::WrappedTargetException,
260 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
261 :
262 : // XServiceInfo
263 : virtual OUString SAL_CALL getImplementationName( )
264 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
265 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
266 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
267 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
268 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
269 :
270 : #if DEBUG_PIVOT_TABLE
271 : void DumpResults() const;
272 : #endif
273 : };
274 :
275 : class ScDPDimensions : public cppu::WeakImplHelper2<
276 : com::sun::star::container::XNameAccess,
277 : com::sun::star::lang::XServiceInfo >
278 : {
279 : private:
280 : ScDPSource* pSource;
281 : long nDimCount;
282 : ScDPDimension** ppDims;
283 :
284 : public:
285 : ScDPDimensions( ScDPSource* pSrc );
286 : virtual ~ScDPDimensions();
287 :
288 : void CountChanged();
289 :
290 : // XNameAccess
291 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
292 : throw(::com::sun::star::container::NoSuchElementException,
293 : ::com::sun::star::lang::WrappedTargetException,
294 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
295 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
296 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
297 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
298 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 :
300 : // XElementAccess
301 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
302 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
303 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
304 :
305 : // XServiceInfo
306 : virtual OUString SAL_CALL getImplementationName( )
307 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
308 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
309 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
310 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
311 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
312 :
313 : virtual long getCount() const;
314 : virtual ScDPDimension* getByIndex(long nIndex) const;
315 : };
316 :
317 : class ScDPDimension : boost::noncopyable, public cppu::WeakImplHelper5<
318 : com::sun::star::sheet::XHierarchiesSupplier,
319 : com::sun::star::container::XNamed,
320 : com::sun::star::util::XCloneable,
321 : com::sun::star::beans::XPropertySet,
322 : com::sun::star::lang::XServiceInfo >
323 : {
324 : ScDPSource* pSource;
325 : long nDim; // dimension index (== column ID)
326 : ScDPHierarchies* pHierarchies;
327 : long nUsedHier;
328 : sal_uInt16 nFunction; // enum GeneralFunction
329 : OUString aName; // if empty, take from source
330 : boost::scoped_ptr<OUString> mpLayoutName;
331 : boost::scoped_ptr<OUString> mpSubtotalName;
332 : long nSourceDim; // >=0 if dup'ed
333 : ::com::sun::star::sheet::DataPilotFieldReference
334 : aReferenceValue; // settings for "show data as" / "displayed value"
335 : bool bHasSelectedPage;
336 : OUString aSelectedPage;
337 : ScDPItemData* pSelectedData; // internal, temporary, created from aSelectedPage
338 : bool mbHasHiddenMember;
339 :
340 : public:
341 : ScDPDimension( ScDPSource* pSrc, long nD );
342 : virtual ~ScDPDimension();
343 :
344 0 : long GetDimension() const { return nDim; } // dimension index in source
345 0 : long GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed
346 :
347 : ScDPDimension* CreateCloneObject();
348 : ScDPHierarchies* GetHierarchiesObject();
349 :
350 : SC_DLLPUBLIC const OUString* GetLayoutName() const;
351 : const OUString* GetSubtotalName() const;
352 :
353 : // XNamed
354 : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
355 : virtual void SAL_CALL setName( const OUString& aName )
356 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
357 :
358 : // XHierarchiesSupplier
359 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
360 : getHierarchies() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
361 :
362 : // XCloneable
363 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL
364 : createClone() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
365 :
366 : // XPropertySet
367 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
368 : SAL_CALL getPropertySetInfo( )
369 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
370 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
371 : const ::com::sun::star::uno::Any& aValue )
372 : throw(::com::sun::star::beans::UnknownPropertyException,
373 : ::com::sun::star::beans::PropertyVetoException,
374 : ::com::sun::star::lang::IllegalArgumentException,
375 : ::com::sun::star::lang::WrappedTargetException,
376 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
377 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
378 : const OUString& PropertyName )
379 : throw(::com::sun::star::beans::UnknownPropertyException,
380 : ::com::sun::star::lang::WrappedTargetException,
381 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
383 : const ::com::sun::star::uno::Reference<
384 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
385 : throw(::com::sun::star::beans::UnknownPropertyException,
386 : ::com::sun::star::lang::WrappedTargetException,
387 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
388 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
389 : const ::com::sun::star::uno::Reference<
390 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
391 : throw(::com::sun::star::beans::UnknownPropertyException,
392 : ::com::sun::star::lang::WrappedTargetException,
393 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
394 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
395 : const ::com::sun::star::uno::Reference<
396 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
397 : throw(::com::sun::star::beans::UnknownPropertyException,
398 : ::com::sun::star::lang::WrappedTargetException,
399 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
400 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
401 : const ::com::sun::star::uno::Reference<
402 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
403 : throw(::com::sun::star::beans::UnknownPropertyException,
404 : ::com::sun::star::lang::WrappedTargetException,
405 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
406 :
407 : // XServiceInfo
408 : virtual OUString SAL_CALL getImplementationName( )
409 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
410 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
411 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
412 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
413 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
414 :
415 : sal_uInt16 getOrientation() const;
416 : void setOrientation(sal_uInt16 nNew);
417 : long getPosition() const;
418 : bool getIsDataLayoutDimension() const;
419 : sal_uInt16 getFunction() const;
420 : void setFunction(sal_uInt16 nNew); // for data dimension
421 : long getUsedHierarchy() const;
422 : void setUsedHierarchy(long nNew);
423 :
424 0 : bool HasSelectedPage() const { return bHasSelectedPage; }
425 : const ScDPItemData& GetSelectedData();
426 :
427 : const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
428 : };
429 :
430 : class ScDPHierarchies : public cppu::WeakImplHelper2<
431 : com::sun::star::container::XNameAccess,
432 : com::sun::star::lang::XServiceInfo >
433 : {
434 : private:
435 : ScDPSource* pSource;
436 : long nDim;
437 : long nHierCount;
438 : ScDPHierarchy** ppHiers;
439 :
440 : public:
441 : ScDPHierarchies( ScDPSource* pSrc, long nD );
442 : virtual ~ScDPHierarchies();
443 :
444 : // XNameAccess
445 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
446 : throw(::com::sun::star::container::NoSuchElementException,
447 : ::com::sun::star::lang::WrappedTargetException,
448 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
449 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
450 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
451 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
452 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
453 :
454 : // XElementAccess
455 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
456 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
457 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
458 :
459 : // XServiceInfo
460 : virtual OUString SAL_CALL getImplementationName( )
461 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
462 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
463 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
464 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
465 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
466 :
467 : virtual long getCount() const;
468 : virtual ScDPHierarchy* getByIndex(long nIndex) const;
469 : };
470 :
471 : class ScDPHierarchy : public cppu::WeakImplHelper3<
472 : com::sun::star::sheet::XLevelsSupplier,
473 : com::sun::star::container::XNamed,
474 : com::sun::star::lang::XServiceInfo >
475 : {
476 : private:
477 : ScDPSource* pSource;
478 : long nDim;
479 : long nHier;
480 : ScDPLevels* pLevels;
481 :
482 : public:
483 : ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
484 : virtual ~ScDPHierarchy();
485 :
486 : ScDPLevels* GetLevelsObject();
487 :
488 : // XNamed
489 : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
490 : virtual void SAL_CALL setName( const OUString& aName )
491 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
492 :
493 : // XLevelsSupplier
494 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
495 : getLevels() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
496 :
497 : // XServiceInfo
498 : virtual OUString SAL_CALL getImplementationName( )
499 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
500 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
501 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
502 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
503 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
504 : };
505 :
506 : class ScDPLevels : public cppu::WeakImplHelper2<
507 : com::sun::star::container::XNameAccess,
508 : com::sun::star::lang::XServiceInfo >
509 : {
510 : private:
511 : ScDPSource* pSource;
512 : long nDim;
513 : long nHier;
514 : long nLevCount;
515 : ScDPLevel** ppLevs;
516 :
517 : public:
518 : ScDPLevels( ScDPSource* pSrc, long nD, long nH );
519 : virtual ~ScDPLevels();
520 :
521 : // XNameAccess
522 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
523 : throw(::com::sun::star::container::NoSuchElementException,
524 : ::com::sun::star::lang::WrappedTargetException,
525 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
526 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
527 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
528 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
529 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
530 :
531 : // XElementAccess
532 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
533 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
534 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
535 :
536 : // XServiceInfo
537 : virtual OUString SAL_CALL getImplementationName( )
538 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
539 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
540 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
541 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
542 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
543 :
544 : virtual long getCount() const;
545 : virtual ScDPLevel* getByIndex(long nIndex) const;
546 : };
547 :
548 : class ScDPLevel : public cppu::WeakImplHelper5<
549 : com::sun::star::sheet::XMembersSupplier,
550 : com::sun::star::container::XNamed,
551 : com::sun::star::sheet::XDataPilotMemberResults,
552 : com::sun::star::beans::XPropertySet,
553 : com::sun::star::lang::XServiceInfo >
554 : {
555 : private:
556 : ScDPSource* pSource;
557 : long nDim;
558 : long nHier;
559 : long nLev;
560 : ScDPMembers* pMembers;
561 : com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> aSubTotals;
562 : ::com::sun::star::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
563 : ::com::sun::star::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
564 : ::com::sun::star::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings
565 : // valid only from result calculation:
566 : ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position
567 : long nSortMeasure; // measure (index of data dimension) to sort by
568 : long nAutoMeasure; // measure (index of data dimension) for AutoShow
569 : bool bShowEmpty:1;
570 : bool bEnableLayout:1; // enabled only for row fields, not for the innermost one
571 :
572 : public:
573 : ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL );
574 : virtual ~ScDPLevel();
575 :
576 : ScDPMembers* GetMembersObject();
577 :
578 : // XNamed
579 : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
580 : virtual void SAL_CALL setName( const OUString& aName )
581 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
582 :
583 : // XMembersSupplier
584 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
585 : getMembers() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
586 :
587 : // XDataPilotMemberResults
588 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::MemberResult > SAL_CALL
589 : getResults() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
590 :
591 : // XPropertySet
592 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
593 : SAL_CALL getPropertySetInfo( )
594 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
595 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
596 : const ::com::sun::star::uno::Any& aValue )
597 : throw(::com::sun::star::beans::UnknownPropertyException,
598 : ::com::sun::star::beans::PropertyVetoException,
599 : ::com::sun::star::lang::IllegalArgumentException,
600 : ::com::sun::star::lang::WrappedTargetException,
601 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
602 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
603 : const OUString& PropertyName )
604 : throw(::com::sun::star::beans::UnknownPropertyException,
605 : ::com::sun::star::lang::WrappedTargetException,
606 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
607 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
608 : const ::com::sun::star::uno::Reference<
609 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
610 : throw(::com::sun::star::beans::UnknownPropertyException,
611 : ::com::sun::star::lang::WrappedTargetException,
612 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
613 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
614 : const ::com::sun::star::uno::Reference<
615 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
616 : throw(::com::sun::star::beans::UnknownPropertyException,
617 : ::com::sun::star::lang::WrappedTargetException,
618 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
619 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
620 : const ::com::sun::star::uno::Reference<
621 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
622 : throw(::com::sun::star::beans::UnknownPropertyException,
623 : ::com::sun::star::lang::WrappedTargetException,
624 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
625 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
626 : const ::com::sun::star::uno::Reference<
627 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
628 : throw(::com::sun::star::beans::UnknownPropertyException,
629 : ::com::sun::star::lang::WrappedTargetException,
630 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
631 :
632 : // XServiceInfo
633 : virtual OUString SAL_CALL getImplementationName( )
634 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
635 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
636 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
637 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
638 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
639 :
640 : com::sun::star::uno::Sequence<com::sun::star::sheet::GeneralFunction> getSubTotals() const;
641 : bool getShowEmpty() const;
642 :
643 0 : const ::com::sun::star::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; }
644 0 : const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; }
645 :
646 : void EvaluateSortOrder();
647 : void SetEnableLayout(bool bSet);
648 :
649 : const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; }
650 0 : ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; }
651 0 : long GetSortMeasure() const { return nSortMeasure; }
652 0 : long GetAutoMeasure() const { return nAutoMeasure; }
653 :
654 0 : bool IsOutlineLayout() const
655 : {
656 0 : return bEnableLayout &&
657 0 : aLayoutInfo.LayoutMode !=
658 0 : ::com::sun::star::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT;
659 : }
660 :
661 0 : bool IsSubtotalsAtTop() const
662 : {
663 0 : return bEnableLayout &&
664 0 : aLayoutInfo.LayoutMode ==
665 0 : ::com::sun::star::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
666 : }
667 :
668 0 : bool IsAddEmpty() const
669 : {
670 0 : return bEnableLayout && aLayoutInfo.AddEmptyLines;
671 : }
672 :
673 : //! number format (for data fields and date fields)
674 : };
675 :
676 : // hash map from name to index in the member array, for fast name access
677 : typedef ::boost::unordered_map< OUString, sal_Int32, OUStringHash > ScDPMembersHashMap;
678 :
679 : class ScDPMembers : public cppu::WeakImplHelper2<
680 : com::sun::star::container::XNameAccess,
681 : com::sun::star::lang::XServiceInfo >
682 : {
683 : private:
684 : typedef std::vector<rtl::Reference<ScDPMember> > MembersType;
685 : ScDPSource* pSource;
686 : long nDim;
687 : long nHier;
688 : long nLev;
689 : long nMbrCount;
690 : mutable MembersType maMembers;
691 : mutable ScDPMembersHashMap aHashMap;
692 :
693 : public:
694 : ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL );
695 : virtual ~ScDPMembers();
696 :
697 : // XNameAccess
698 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
699 : throw(::com::sun::star::container::NoSuchElementException,
700 : ::com::sun::star::lang::WrappedTargetException,
701 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
702 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
703 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
704 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
705 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
706 :
707 : // XElementAccess
708 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
709 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
710 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
711 :
712 : // XServiceInfo
713 : virtual OUString SAL_CALL getImplementationName( )
714 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
715 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
716 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
717 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
718 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
719 :
720 : long getCount() const;
721 : ScDPMember* getByIndex(long nIndex) const;
722 :
723 : long getMinMembers() const;
724 :
725 : sal_Int32 GetIndexFromName( const OUString& rName ) const; // <0 if not found
726 : const std::vector<sal_Int32>& GetGlobalOrder();
727 : const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
728 : SCROW GetSrcItemsCount();
729 : };
730 :
731 : class ScDPMember : boost::noncopyable, public cppu::WeakImplHelper3<
732 : com::sun::star::container::XNamed,
733 : com::sun::star::beans::XPropertySet,
734 : com::sun::star::lang::XServiceInfo >
735 : {
736 : private:
737 : ScDPSource* pSource;
738 : long nDim;
739 : long nHier;
740 : long nLev;
741 :
742 : SCROW mnDataId;
743 : boost::scoped_ptr<OUString> mpLayoutName;
744 :
745 : sal_Int32 nPosition; // manual sorting
746 : bool bVisible;
747 : bool bShowDet;
748 :
749 : public:
750 : ScDPMember(ScDPSource* pSrc, long nD, long nH, long nL, SCROW nIndex);
751 : virtual ~ScDPMember();
752 :
753 : OUString GetNameStr() const;
754 : void FillItemData( ScDPItemData& rData ) const;
755 : const ScDPItemData* GetItemData() const;
756 0 : SCROW GetItemDataId() const { return mnDataId; }
757 : bool IsNamedItem(SCROW nIndex) const;
758 :
759 : SC_DLLPUBLIC const OUString* GetLayoutName() const;
760 : long GetDim() const;
761 :
762 : sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
763 :
764 : // XNamed
765 : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
766 : virtual void SAL_CALL setName( const OUString& aName )
767 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
768 :
769 : // XPropertySet
770 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
771 : SAL_CALL getPropertySetInfo( )
772 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
773 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
774 : const ::com::sun::star::uno::Any& aValue )
775 : throw(::com::sun::star::beans::UnknownPropertyException,
776 : ::com::sun::star::beans::PropertyVetoException,
777 : ::com::sun::star::lang::IllegalArgumentException,
778 : ::com::sun::star::lang::WrappedTargetException,
779 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
780 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
781 : const OUString& PropertyName )
782 : throw(::com::sun::star::beans::UnknownPropertyException,
783 : ::com::sun::star::lang::WrappedTargetException,
784 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
785 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
786 : const ::com::sun::star::uno::Reference<
787 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
788 : throw(::com::sun::star::beans::UnknownPropertyException,
789 : ::com::sun::star::lang::WrappedTargetException,
790 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
791 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
792 : const ::com::sun::star::uno::Reference<
793 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
794 : throw(::com::sun::star::beans::UnknownPropertyException,
795 : ::com::sun::star::lang::WrappedTargetException,
796 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
797 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
798 : const ::com::sun::star::uno::Reference<
799 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
800 : throw(::com::sun::star::beans::UnknownPropertyException,
801 : ::com::sun::star::lang::WrappedTargetException,
802 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
803 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
804 : const ::com::sun::star::uno::Reference<
805 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
806 : throw(::com::sun::star::beans::UnknownPropertyException,
807 : ::com::sun::star::lang::WrappedTargetException,
808 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
809 :
810 : // XServiceInfo
811 : virtual OUString SAL_CALL getImplementationName( )
812 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
813 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
814 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
815 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
816 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
817 :
818 : bool isVisible() const;
819 : bool getShowDetails() const;
820 : };
821 :
822 :
823 : #endif
824 :
825 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|