xref: /aoo41x/main/sc/inc/sheetdata.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_SHEETDATA_HXX
25cdf0e10cSrcweir #define SC_SHEETDATA_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <xmloff/maptype.hxx>
28cdf0e10cSrcweir #include <editeng/editdata.hxx>
29cdf0e10cSrcweir #include <vector>
30cdf0e10cSrcweir #include <hash_set>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "address.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class ScAddress;
35cdf0e10cSrcweir class SvXMLNamespaceMap;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir struct ScStreamEntry
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     sal_Int32   mnStartOffset;
41cdf0e10cSrcweir     sal_Int32   mnEndOffset;
42cdf0e10cSrcweir 
ScStreamEntryScStreamEntry43cdf0e10cSrcweir                 ScStreamEntry() :
44cdf0e10cSrcweir                     mnStartOffset(-1),
45cdf0e10cSrcweir                     mnEndOffset(-1)
46cdf0e10cSrcweir                 {
47cdf0e10cSrcweir                 }
48cdf0e10cSrcweir 
ScStreamEntryScStreamEntry49cdf0e10cSrcweir                 ScStreamEntry( sal_Int32 nStart, sal_Int32 nEnd ) :
50cdf0e10cSrcweir                     mnStartOffset(nStart),
51cdf0e10cSrcweir                     mnEndOffset(nEnd)
52cdf0e10cSrcweir                 {
53cdf0e10cSrcweir                 }
54cdf0e10cSrcweir };
55cdf0e10cSrcweir 
56cdf0e10cSrcweir struct ScCellStyleEntry
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     rtl::OUString   maName;
59cdf0e10cSrcweir     ScAddress       maCellPos;
60cdf0e10cSrcweir 
ScCellStyleEntryScCellStyleEntry61cdf0e10cSrcweir                 ScCellStyleEntry( const rtl::OUString& rName, const ScAddress& rPos ) :
62cdf0e10cSrcweir                     maName(rName),
63cdf0e10cSrcweir                     maCellPos(rPos)
64cdf0e10cSrcweir                 {
65cdf0e10cSrcweir                 }
66cdf0e10cSrcweir };
67cdf0e10cSrcweir 
68cdf0e10cSrcweir struct ScNoteStyleEntry
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     rtl::OUString   maStyleName;
71cdf0e10cSrcweir     rtl::OUString   maTextStyle;
72cdf0e10cSrcweir     ScAddress       maCellPos;
73cdf0e10cSrcweir 
ScNoteStyleEntryScNoteStyleEntry74cdf0e10cSrcweir                 ScNoteStyleEntry( const rtl::OUString& rStyle, const rtl::OUString& rText, const ScAddress& rPos ) :
75cdf0e10cSrcweir                     maStyleName(rStyle),
76cdf0e10cSrcweir                     maTextStyle(rText),
77cdf0e10cSrcweir                     maCellPos(rPos)
78cdf0e10cSrcweir                 {
79cdf0e10cSrcweir                 }
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir struct ScTextStyleEntry
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     rtl::OUString   maName;
85cdf0e10cSrcweir     ScAddress       maCellPos;
86cdf0e10cSrcweir     ESelection      maSelection;
87cdf0e10cSrcweir 
ScTextStyleEntryScTextStyleEntry88cdf0e10cSrcweir                 ScTextStyleEntry( const rtl::OUString& rName, const ScAddress& rPos, const ESelection& rSel ) :
89cdf0e10cSrcweir                     maName(rName),
90cdf0e10cSrcweir                     maCellPos(rPos),
91cdf0e10cSrcweir                     maSelection(rSel)
92cdf0e10cSrcweir                 {
93cdf0e10cSrcweir                 }
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
96cdf0e10cSrcweir struct ScLoadedNamespaceEntry
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     rtl::OUString   maPrefix;
99cdf0e10cSrcweir     rtl::OUString   maName;
100cdf0e10cSrcweir     sal_uInt16      mnKey;
101cdf0e10cSrcweir 
ScLoadedNamespaceEntryScLoadedNamespaceEntry102cdf0e10cSrcweir                 ScLoadedNamespaceEntry( const rtl::OUString& rPrefix, const rtl::OUString& rName, sal_uInt16 nKey ) :
103cdf0e10cSrcweir                     maPrefix(rPrefix),
104cdf0e10cSrcweir                     maName(rName),
105cdf0e10cSrcweir                     mnKey(nKey)
106cdf0e10cSrcweir                 {
107cdf0e10cSrcweir                 }
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir class ScSheetSaveData
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     std::hash_set<rtl::OUString, rtl::OUStringHash>  maInitialPrefixes;
113cdf0e10cSrcweir     std::vector<ScLoadedNamespaceEntry>              maLoadedNamespaces;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maCellStyles;
116cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maColumnStyles;
117cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maRowStyles;
118cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maTableStyles;
119cdf0e10cSrcweir     std::vector<ScNoteStyleEntry> maNoteStyles;
120cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maNoteParaStyles;
121cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maNoteTextStyles;
122cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maTextStyles;
123cdf0e10cSrcweir     std::vector<bool>          maBlocked;
124cdf0e10cSrcweir     std::vector<ScStreamEntry> maStreamEntries;
125cdf0e10cSrcweir     std::vector<ScStreamEntry> maSaveEntries;
126cdf0e10cSrcweir     sal_Int32   mnStartTab;
127cdf0e10cSrcweir     sal_Int32   mnStartOffset;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     ScNoteStyleEntry    maPreviousNote;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     bool                mbInSupportedSave;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir public:
134cdf0e10cSrcweir                 ScSheetSaveData();
135cdf0e10cSrcweir                 ~ScSheetSaveData();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     void        AddCellStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
138cdf0e10cSrcweir     void        AddColumnStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
139cdf0e10cSrcweir     void        AddRowStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
140cdf0e10cSrcweir     void        AddTableStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     void        HandleNoteStyles( const rtl::OUString& rStyleName, const rtl::OUString& rTextName, const ScAddress& rCellPos );
143cdf0e10cSrcweir     void        AddNoteContentStyle( sal_uInt16 nFamily, const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     void        AddTextStyle( const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     void        BlockSheet( sal_Int32 nTab );
148cdf0e10cSrcweir     bool        IsSheetBlocked( sal_Int32 nTab ) const;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     void        AddStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
151cdf0e10cSrcweir     void        GetStreamPos( sal_Int32 nTab, sal_Int32& rStartOffset, sal_Int32& rEndOffset ) const;
152cdf0e10cSrcweir     bool        HasStreamPos( sal_Int32 nTab ) const;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     void        StartStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset );
155cdf0e10cSrcweir     void        EndStreamPos( sal_Int32 nEndOffset );
156cdf0e10cSrcweir 
HasStartPos() const157cdf0e10cSrcweir     bool        HasStartPos() const { return mnStartTab >= 0; }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     void        ResetSaveEntries();
160cdf0e10cSrcweir     void        AddSavePos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
161cdf0e10cSrcweir     void        UseSaveEntries();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     void        StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces );
164cdf0e10cSrcweir     void        StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespaces );
165cdf0e10cSrcweir     bool        AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const;
166cdf0e10cSrcweir 
GetCellStyles() const167cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetCellStyles() const   { return maCellStyles; }
GetColumnStyles() const168cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetColumnStyles() const { return maColumnStyles; }
GetRowStyles() const169cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetRowStyles() const    { return maRowStyles; }
GetTableStyles() const170cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetTableStyles() const  { return maTableStyles; }
GetNoteStyles() const171cdf0e10cSrcweir     const std::vector<ScNoteStyleEntry>& GetNoteStyles() const   { return maNoteStyles; }
GetNoteParaStyles() const172cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetNoteParaStyles() const { return maNoteParaStyles; }
GetNoteTextStyles() const173cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetNoteTextStyles() const { return maNoteTextStyles; }
GetTextStyles() const174cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetTextStyles() const   { return maTextStyles; }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     bool        IsInSupportedSave() const;
177cdf0e10cSrcweir     void        SetInSupportedSave( bool bSet );
178cdf0e10cSrcweir };
179cdf0e10cSrcweir 
180cdf0e10cSrcweir #endif
181cdf0e10cSrcweir 
182