xref: /aoo41x/main/sc/inc/sheetdata.hxx (revision 38d50f7b)
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_SHEETDATA_HXX
25 #define SC_SHEETDATA_HXX
26 
27 #include <xmloff/maptype.hxx>
28 #include <editeng/editdata.hxx>
29 #include <vector>
30 #include <hash_set>
31 
32 #include "address.hxx"
33 
34 class ScAddress;
35 class SvXMLNamespaceMap;
36 
37 
38 struct ScStreamEntry
39 {
40     sal_Int32   mnStartOffset;
41     sal_Int32   mnEndOffset;
42 
ScStreamEntryScStreamEntry43                 ScStreamEntry() :
44                     mnStartOffset(-1),
45                     mnEndOffset(-1)
46                 {
47                 }
48 
ScStreamEntryScStreamEntry49                 ScStreamEntry( sal_Int32 nStart, sal_Int32 nEnd ) :
50                     mnStartOffset(nStart),
51                     mnEndOffset(nEnd)
52                 {
53                 }
54 };
55 
56 struct ScCellStyleEntry
57 {
58     rtl::OUString   maName;
59     ScAddress       maCellPos;
60 
ScCellStyleEntryScCellStyleEntry61                 ScCellStyleEntry( const rtl::OUString& rName, const ScAddress& rPos ) :
62                     maName(rName),
63                     maCellPos(rPos)
64                 {
65                 }
66 };
67 
68 struct ScNoteStyleEntry
69 {
70     rtl::OUString   maStyleName;
71     rtl::OUString   maTextStyle;
72     ScAddress       maCellPos;
73 
ScNoteStyleEntryScNoteStyleEntry74                 ScNoteStyleEntry( const rtl::OUString& rStyle, const rtl::OUString& rText, const ScAddress& rPos ) :
75                     maStyleName(rStyle),
76                     maTextStyle(rText),
77                     maCellPos(rPos)
78                 {
79                 }
80 };
81 
82 struct ScTextStyleEntry
83 {
84     rtl::OUString   maName;
85     ScAddress       maCellPos;
86     ESelection      maSelection;
87 
ScTextStyleEntryScTextStyleEntry88                 ScTextStyleEntry( const rtl::OUString& rName, const ScAddress& rPos, const ESelection& rSel ) :
89                     maName(rName),
90                     maCellPos(rPos),
91                     maSelection(rSel)
92                 {
93                 }
94 };
95 
96 struct ScLoadedNamespaceEntry
97 {
98     rtl::OUString   maPrefix;
99     rtl::OUString   maName;
100     sal_uInt16      mnKey;
101 
ScLoadedNamespaceEntryScLoadedNamespaceEntry102                 ScLoadedNamespaceEntry( const rtl::OUString& rPrefix, const rtl::OUString& rName, sal_uInt16 nKey ) :
103                     maPrefix(rPrefix),
104                     maName(rName),
105                     mnKey(nKey)
106                 {
107                 }
108 };
109 
110 class ScSheetSaveData
111 {
112     std::hash_set<rtl::OUString, rtl::OUStringHash>  maInitialPrefixes;
113     std::vector<ScLoadedNamespaceEntry>              maLoadedNamespaces;
114 
115     std::vector<ScCellStyleEntry> maCellStyles;
116     std::vector<ScCellStyleEntry> maColumnStyles;
117     std::vector<ScCellStyleEntry> maRowStyles;
118     std::vector<ScCellStyleEntry> maTableStyles;
119     std::vector<ScNoteStyleEntry> maNoteStyles;
120     std::vector<ScTextStyleEntry> maNoteParaStyles;
121     std::vector<ScTextStyleEntry> maNoteTextStyles;
122     std::vector<ScTextStyleEntry> maTextStyles;
123     std::vector<bool>          maBlocked;
124     std::vector<ScStreamEntry> maStreamEntries;
125     std::vector<ScStreamEntry> maSaveEntries;
126     sal_Int32   mnStartTab;
127     sal_Int32   mnStartOffset;
128 
129     ScNoteStyleEntry    maPreviousNote;
130 
131     bool                mbInSupportedSave;
132 
133 public:
134                 ScSheetSaveData();
135                 ~ScSheetSaveData();
136 
137     void        AddCellStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
138     void        AddColumnStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
139     void        AddRowStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
140     void        AddTableStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
141 
142     void        HandleNoteStyles( const rtl::OUString& rStyleName, const rtl::OUString& rTextName, const ScAddress& rCellPos );
143     void        AddNoteContentStyle( sal_uInt16 nFamily, const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
144 
145     void        AddTextStyle( const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
146 
147     void        BlockSheet( sal_Int32 nTab );
148     bool        IsSheetBlocked( sal_Int32 nTab ) const;
149 
150     void        AddStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
151     void        GetStreamPos( sal_Int32 nTab, sal_Int32& rStartOffset, sal_Int32& rEndOffset ) const;
152     bool        HasStreamPos( sal_Int32 nTab ) const;
153 
154     void        StartStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset );
155     void        EndStreamPos( sal_Int32 nEndOffset );
156 
HasStartPos() const157     bool        HasStartPos() const { return mnStartTab >= 0; }
158 
159     void        ResetSaveEntries();
160     void        AddSavePos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
161     void        UseSaveEntries();
162 
163     void        StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces );
164     void        StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespaces );
165     bool        AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const;
166 
GetCellStyles() const167     const std::vector<ScCellStyleEntry>& GetCellStyles() const   { return maCellStyles; }
GetColumnStyles() const168     const std::vector<ScCellStyleEntry>& GetColumnStyles() const { return maColumnStyles; }
GetRowStyles() const169     const std::vector<ScCellStyleEntry>& GetRowStyles() const    { return maRowStyles; }
GetTableStyles() const170     const std::vector<ScCellStyleEntry>& GetTableStyles() const  { return maTableStyles; }
GetNoteStyles() const171     const std::vector<ScNoteStyleEntry>& GetNoteStyles() const   { return maNoteStyles; }
GetNoteParaStyles() const172     const std::vector<ScTextStyleEntry>& GetNoteParaStyles() const { return maNoteParaStyles; }
GetNoteTextStyles() const173     const std::vector<ScTextStyleEntry>& GetNoteTextStyles() const { return maNoteTextStyles; }
GetTextStyles() const174     const std::vector<ScTextStyleEntry>& GetTextStyles() const   { return maTextStyles; }
175 
176     bool        IsInSupportedSave() const;
177     void        SetInSupportedSave( bool bSet );
178 };
179 
180 #endif
181 
182