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_DPSAVE_HXX 25 #define SC_DPSAVE_HXX 26 27 #include <tools/string.hxx> 28 #include <tools/list.hxx> 29 #include <com/sun/star/sheet/XDimensionsSupplier.hpp> 30 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> 31 #include "scdllapi.h" 32 #include <hash_map> 33 #include <list> 34 #include <memory> 35 36 namespace com { namespace sun { namespace star { namespace sheet { 37 struct DataPilotFieldReference; 38 struct DataPilotFieldSortInfo; 39 struct DataPilotFieldAutoShowInfo; 40 struct DataPilotFieldLayoutInfo; 41 } } } } 42 43 class ScDPDimensionSaveData; 44 class ScDPTableData; 45 class ScDPObject; 46 47 // -------------------------------------------------------------------- 48 // 49 // classes to save Data Pilot settings 50 // 51 52 53 class ScDPSaveMember 54 { 55 private: 56 String aName; 57 ::std::auto_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table. 58 sal_uInt16 nVisibleMode; 59 sal_uInt16 nShowDetailsMode; 60 61 public: 62 ScDPSaveMember(const String& rName); 63 ScDPSaveMember(const ScDPSaveMember& r); 64 ~ScDPSaveMember(); 65 66 sal_Bool operator== ( const ScDPSaveMember& r ) const; 67 GetName() const68 const String& GetName() const { return aName; } 69 SC_DLLPUBLIC sal_Bool HasIsVisible() const; 70 SC_DLLPUBLIC void SetIsVisible(sal_Bool bSet); GetIsVisible() const71 sal_Bool GetIsVisible() const { return sal_Bool(nVisibleMode); } 72 SC_DLLPUBLIC sal_Bool HasShowDetails() const; 73 SC_DLLPUBLIC void SetShowDetails(sal_Bool bSet); GetShowDetails() const74 sal_Bool GetShowDetails() const { return sal_Bool(nShowDetailsMode); } 75 76 void SetName( const String& rNew ); // used if the source member was renamed (groups) 77 78 SC_DLLPUBLIC void SetLayoutName( const ::rtl::OUString& rName ); 79 SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const; 80 void RemoveLayoutName(); 81 82 void WriteToSource( const com::sun::star::uno::Reference< 83 com::sun::star::uno::XInterface>& xMember, 84 sal_Int32 nPosition ); 85 }; 86 87 88 bool operator == (const ::com::sun::star::sheet::DataPilotFieldSortInfo &l, const ::com::sun::star::sheet::DataPilotFieldSortInfo &r ); 89 bool operator == (const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &l, const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &r ); 90 bool operator == (const ::com::sun::star::sheet::DataPilotFieldReference &l, const ::com::sun::star::sheet::DataPilotFieldReference &r ); 91 class SC_DLLPUBLIC ScDPSaveDimension 92 { 93 private: 94 String aName; 95 String* pSelectedPage; 96 ::std::auto_ptr<rtl::OUString> mpLayoutName; 97 ::std::auto_ptr<rtl::OUString> mpSubtotalName; 98 sal_Bool bIsDataLayout; 99 sal_Bool bDupFlag; 100 sal_uInt16 nOrientation; 101 sal_uInt16 nFunction; // enum GeneralFunction, for data dimensions 102 long nUsedHierarchy; 103 sal_uInt16 nShowEmptyMode; //! at level 104 sal_Bool bSubTotalDefault; //! at level 105 long nSubTotalCount; 106 sal_uInt16* pSubTotalFuncs; // enum GeneralFunction 107 ::com::sun::star::sheet::DataPilotFieldReference* pReferenceValue; 108 ::com::sun::star::sheet::DataPilotFieldSortInfo* pSortInfo; // (level) 109 ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo; // (level) 110 ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pLayoutInfo; // (level) 111 112 public: 113 typedef std::hash_map <String, ScDPSaveMember*, rtl::OUStringHash> MemberHash; 114 typedef std::list <ScDPSaveMember*> MemberList; 115 private: 116 MemberHash maMemberHash; 117 MemberList maMemberList; 118 public: 119 ScDPSaveDimension(const String& rName, sal_Bool bDataLayout); 120 ScDPSaveDimension(const ScDPSaveDimension& r); 121 ~ScDPSaveDimension(); 122 123 sal_Bool operator== ( const ScDPSaveDimension& r ) const; 124 GetMembers() const125 const MemberList& GetMembers() const { return maMemberList; } 126 void AddMember(ScDPSaveMember* pMember); 127 SetDupFlag(sal_Bool bSet)128 void SetDupFlag(sal_Bool bSet) { bDupFlag = bSet; } GetDupFlag() const129 sal_Bool GetDupFlag() const { return bDupFlag; } 130 GetName() const131 const String& GetName() const { return aName; } IsDataLayout() const132 sal_Bool IsDataLayout() const { return bIsDataLayout; } 133 134 void SetName( const String& rNew ); // used if the source dim was renamed (groups) 135 136 void SetOrientation(sal_uInt16 nNew); 137 void SetSubTotals(long nCount, const sal_uInt16* pFuncs); GetSubTotalsCount() const138 long GetSubTotalsCount() const { return nSubTotalCount; } GetSubTotalFunc(long nIndex) const139 sal_uInt16 GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; } 140 bool HasShowEmpty() const; 141 void SetShowEmpty(sal_Bool bSet); GetShowEmpty() const142 sal_Bool GetShowEmpty() const { return sal_Bool(nShowEmptyMode); } 143 void SetFunction(sal_uInt16 nNew); // enum GeneralFunction GetFunction() const144 sal_uInt16 GetFunction() const { return nFunction; } 145 void SetUsedHierarchy(long nNew); GetUsedHierarchy() const146 long GetUsedHierarchy() const { return nUsedHierarchy; } 147 148 void SetLayoutName(const ::rtl::OUString& rName); 149 const ::rtl::OUString* GetLayoutName() const; 150 void RemoveLayoutName(); 151 void SetSubtotalName(const ::rtl::OUString& rName); 152 const ::rtl::OUString* GetSubtotalName() const; 153 154 bool IsMemberNameInUse(const ::rtl::OUString& rName) const; 155 GetReferenceValue() const156 const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const { return pReferenceValue; } 157 void SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew); 158 GetSortInfo() const159 const ::com::sun::star::sheet::DataPilotFieldSortInfo* GetSortInfo() const { return pSortInfo; } 160 void SetSortInfo(const ::com::sun::star::sheet::DataPilotFieldSortInfo* pNew); GetAutoShowInfo() const161 const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const { return pAutoShowInfo; } 162 void SetAutoShowInfo(const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pNew); GetLayoutInfo() const163 const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const { return pLayoutInfo; } 164 void SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew); 165 166 void SetCurrentPage( const String* pPage ); // NULL = no selection (all) 167 sal_Bool HasCurrentPage() const; 168 const String& GetCurrentPage() const; 169 GetOrientation() const170 sal_uInt16 GetOrientation() const { return nOrientation; } 171 172 ScDPSaveMember* GetExistingMemberByName(const String& rName); 173 ScDPSaveMember* GetMemberByName(const String& rName); 174 175 void SetMemberPosition( const String& rName, sal_Int32 nNewPos ); 176 177 void WriteToSource( const com::sun::star::uno::Reference< 178 com::sun::star::uno::XInterface>& xDim ); 179 void Refresh( const com::sun::star::uno::Reference< 180 com::sun::star::sheet::XDimensionsSupplier>& xSource , 181 const std::list<String> & deletedDims); 182 183 void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData); 184 185 bool HasInvisibleMember() const; 186 }; 187 188 189 class ScDPSaveData 190 { 191 private: 192 List aDimList; 193 ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions 194 sal_uInt16 nColumnGrandMode; 195 sal_uInt16 nRowGrandMode; 196 sal_uInt16 nIgnoreEmptyMode; 197 sal_uInt16 nRepeatEmptyMode; 198 sal_Bool bFilterButton; // not passed to DataPilotSource 199 sal_Bool bDrillDown; // not passed to DataPilotSource 200 // Wang Xu Ming -- 2009-8-17 201 // DataPilot Migration - Cache&&Performance 202 long mnCacheId; 203 // End Comments 204 205 /** if true, all dimensions already have all of their member instances 206 * created. */ 207 bool mbDimensionMembersBuilt; 208 209 ::std::auto_ptr<rtl::OUString> mpGrandTotalName; 210 211 public: 212 SC_DLLPUBLIC ScDPSaveData(); 213 ScDPSaveData(const ScDPSaveData& r); 214 SC_DLLPUBLIC ~ScDPSaveData(); 215 216 ScDPSaveData& operator= ( const ScDPSaveData& r ); 217 218 sal_Bool operator== ( const ScDPSaveData& r ) const; 219 220 SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName); 221 SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const; 222 GetDimensions() const223 const List& GetDimensions() const { return aDimList; } AddDimension(ScDPSaveDimension * pDim)224 void AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); } 225 226 ScDPSaveDimension* GetDimensionByName(const String& rName); 227 SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension(); 228 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const; 229 230 ScDPSaveDimension* DuplicateDimension(const String& rName); 231 SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim); 232 233 SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName) const; 234 SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const String& rName); 235 236 void RemoveDimensionByName(const String& rName); 237 238 ScDPSaveDimension* GetInnermostDimension(sal_uInt16 nOrientation); 239 ScDPSaveDimension* GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation); 240 long GetDataDimensionCount() const; 241 242 243 void SetPosition( ScDPSaveDimension* pDim, long nNew ); 244 SC_DLLPUBLIC void SetColumnGrand( sal_Bool bSet ); GetColumnGrand() const245 sal_Bool GetColumnGrand() const { return sal_Bool(nColumnGrandMode); } 246 SC_DLLPUBLIC void SetRowGrand( sal_Bool bSet ); GetRowGrand() const247 sal_Bool GetRowGrand() const { return sal_Bool(nRowGrandMode); } 248 void SetIgnoreEmptyRows( sal_Bool bSet ); GetIgnoreEmptyRows() const249 sal_Bool GetIgnoreEmptyRows() const { return sal_Bool(nIgnoreEmptyMode); } 250 void SetRepeatIfEmpty( sal_Bool bSet ); GetRepeatIfEmpty() const251 sal_Bool GetRepeatIfEmpty() const { return sal_Bool(nRepeatEmptyMode); } 252 253 SC_DLLPUBLIC void SetFilterButton( sal_Bool bSet ); GetFilterButton() const254 sal_Bool GetFilterButton() const { return bFilterButton; } 255 SC_DLLPUBLIC void SetDrillDown( sal_Bool bSet ); GetDrillDown() const256 sal_Bool GetDrillDown() const { return bDrillDown; } 257 258 void WriteToSource( const com::sun::star::uno::Reference< 259 com::sun::star::sheet::XDimensionsSupplier>& xSource ); 260 // Wang Xu Ming -- 2009-8-17 261 // DataPilot Migration - Cache&&Performance 262 void Refresh( const com::sun::star::uno::Reference< 263 com::sun::star::sheet::XDimensionsSupplier>& xSource ); 264 sal_Bool IsEmpty() const; GetCacheId() const265 inline long GetCacheId() const{ return mnCacheId; } SetCacheId(long nCacheId)266 inline void SetCacheId( long nCacheId ){ mnCacheId = nCacheId; } 267 // End Comments GetExistingDimensionData() const268 const ScDPDimensionSaveData* GetExistingDimensionData() const { return pDimensionData; } 269 SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there 270 void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied 271 void BuildAllDimensionMembers(ScDPTableData* pData); 272 void BuildAllDimensionMembersFromSource(ScDPObject* pDPObj); 273 274 /** 275 * Check whether a dimension has one or more invisible members. 276 * 277 * @param rDimName dimension name 278 */ 279 SC_DLLPUBLIC bool HasInvisibleMember(const ::rtl::OUString& rDimName) const; 280 }; 281 282 283 #endif 284 285