Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / sc / inc / dpdimsave.hxx
blobf1df1998afe61011d7a634a87b07c3366132fc06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_DPDIMSAVE_HXX
21 #define SC_DPDIMSAVE_HXX
23 #include <vector>
24 #include <map>
25 #include <tools/string.hxx>
26 #include "dpgroup.hxx" // for ScDPNumGroupInfo
27 #include "scdllapi.h"
28 #include "dptypes.hxx"
30 class ScDPGroupTableData;
31 class ScDPGroupDimension;
32 class ScDPObject;
33 class ScDPCache;
34 class SvNumberFormatter;
36 class ScDPSaveGroupDimension;
39 // Classes to save Data Pilot settings that create new dimensions (fields).
40 // These have to be applied before the other ScDPSaveData settings.
43 class SC_DLLPUBLIC ScDPSaveGroupItem
45 rtl::OUString aGroupName; // name of group
46 std::vector<rtl::OUString> aElements; // names of items in original dimension
47 mutable std::vector<ScDPItemData> maItems; // items converted from the strings.
49 public:
50 ScDPSaveGroupItem( const rtl::OUString& rName );
51 ~ScDPSaveGroupItem();
53 void AddToData(ScDPGroupDimension& rDataDim) const;
55 void AddElement( const rtl::OUString& rName );
56 void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup );
57 const rtl::OUString& GetGroupName() const { return aGroupName; }
58 bool RemoveElement( const rtl::OUString& rName ); // returns true if found (removed)
60 bool IsEmpty() const;
61 size_t GetElementCount() const;
62 const rtl::OUString* GetElementByIndex(size_t nIndex) const;
64 void Rename( const rtl::OUString& rNewName );
66 // remove this group's elements from their groups in rDimension
67 // (rDimension must be a different dimension from the one which contains this)
68 void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const;
70 void ConvertElementsToItems(SvNumberFormatter* pFormatter) const;
71 bool HasInGroup(const ScDPItemData& rItem) const;
74 typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec;
76 /**
77 * Represents a new group dimension whose dimension ID is higher than the
78 * highest source dimension ID.
80 class SC_DLLPUBLIC ScDPSaveGroupDimension
82 rtl::OUString aSourceDim; // always the real source from the original data
83 rtl::OUString aGroupDimName;
84 ScDPSaveGroupItemVec aGroups;
85 mutable ScDPNumGroupInfo aDateInfo;
86 sal_Int32 nDatePart;
88 public:
89 ScDPSaveGroupDimension( const rtl::OUString& rSource, const rtl::OUString& rName );
90 ScDPSaveGroupDimension( const rtl::OUString& rSource, const rtl::OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
91 ~ScDPSaveGroupDimension();
93 void AddToData( ScDPGroupTableData& rData ) const;
94 void AddToCache(ScDPCache& rCache) const;
95 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
97 void AddGroupItem( const ScDPSaveGroupItem& rItem );
98 const rtl::OUString& GetGroupDimName() const { return aGroupDimName; }
99 const rtl::OUString& GetSourceDimName() const { return aSourceDim; }
101 sal_Int32 GetDatePart() const { return nDatePart; }
102 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
104 rtl::OUString CreateGroupName( const rtl::OUString& rPrefix );
105 const ScDPSaveGroupItem* GetNamedGroup( const rtl::OUString& rGroupName ) const;
106 ScDPSaveGroupItem* GetNamedGroupAcc( const rtl::OUString& rGroupName );
107 void RemoveFromGroups( const rtl::OUString& rItemName );
108 void RemoveGroup(const rtl::OUString& rGroupName);
109 bool IsEmpty() const;
110 bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
112 long GetGroupCount() const;
113 const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
114 ScDPSaveGroupItem* GetGroupAccByIndex( long nIndex );
116 void Rename( const rtl::OUString& rNewName );
118 private:
119 bool IsInGroup(const ScDPItemData& rItem) const;
123 * Represents a group dimension that introduces a new hierarchy for an
124 * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it
125 * re-uses the source dimension name and ID.
127 class SC_DLLPUBLIC ScDPSaveNumGroupDimension
129 rtl::OUString aDimensionName;
130 mutable ScDPNumGroupInfo aGroupInfo;
131 mutable ScDPNumGroupInfo aDateInfo;
132 sal_Int32 nDatePart;
134 public:
135 ScDPSaveNumGroupDimension( const rtl::OUString& rName, const ScDPNumGroupInfo& rInfo );
136 ScDPSaveNumGroupDimension( const rtl::OUString& rName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart );
137 ~ScDPSaveNumGroupDimension();
139 void AddToData( ScDPGroupTableData& rData ) const;
140 void AddToCache(ScDPCache& rCache) const;
142 const rtl::OUString& GetDimensionName() const { return aDimensionName; }
143 const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
145 sal_Int32 GetDatePart() const { return nDatePart; }
146 const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; }
148 void SetGroupInfo( const ScDPNumGroupInfo& rNew );
149 void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
153 * This class has to do with handling exclusively grouped dimensions? TODO:
154 * Find out what this class does and document it here.
156 class SC_DLLPUBLIC ScDPDimensionSaveData
158 public:
159 ScDPDimensionSaveData();
160 ~ScDPDimensionSaveData();
162 bool operator==( const ScDPDimensionSaveData& r ) const;
164 void WriteToData( ScDPGroupTableData& rData ) const;
166 void WriteToCache(ScDPCache& rCache) const;
168 rtl::OUString CreateGroupDimName(
169 const rtl::OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource,
170 const ::std::vector<rtl::OUString>* pDeletedNames );
172 rtl::OUString CreateDateGroupDimName(
173 sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource,
174 const ::std::vector<rtl::OUString>* pDeletedNames );
176 void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
177 void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim );
178 void RemoveGroupDimension( const rtl::OUString& rGroupDimName );
180 void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
181 void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim );
182 void RemoveNumGroupDimension( const rtl::OUString& rGroupDimName );
184 const ScDPSaveGroupDimension* GetGroupDimForBase( const rtl::OUString& rBaseDimName ) const;
185 const ScDPSaveGroupDimension* GetNamedGroupDim( const rtl::OUString& rGroupDimName ) const;
186 const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const rtl::OUString& rBaseDimName ) const;
187 const ScDPSaveGroupDimension* GetNextNamedGroupDim( const rtl::OUString& rGroupDimName ) const;
188 const ScDPSaveNumGroupDimension* GetNumGroupDim( const rtl::OUString& rGroupDimName ) const;
190 ScDPSaveGroupDimension* GetGroupDimAccForBase( const rtl::OUString& rBaseDimName );
191 ScDPSaveGroupDimension* GetNamedGroupDimAcc( const rtl::OUString& rGroupDimName );
192 ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const rtl::OUString& rBaseDimName );
193 ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const rtl::OUString& rGroupDimName );
195 ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const rtl::OUString& rGroupDimName );
197 bool HasGroupDimensions() const;
199 sal_Int32 CollectDateParts( const rtl::OUString& rBaseDimName ) const;
201 private:
202 typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec;
203 typedef ::std::map<rtl::OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap;
205 ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& );
207 ScDPSaveGroupDimVec maGroupDims;
208 ScDPSaveNumGroupDimMap maNumGroupDims;
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */