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