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