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