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