xref: /aoo42x/main/sc/inc/sheetdata.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SC_SHEETDATA_HXX
29*cdf0e10cSrcweir #define SC_SHEETDATA_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <xmloff/maptype.hxx>
32*cdf0e10cSrcweir #include <editeng/editdata.hxx>
33*cdf0e10cSrcweir #include <vector>
34*cdf0e10cSrcweir #include <hash_set>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "address.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir class ScAddress;
39*cdf0e10cSrcweir class SvXMLNamespaceMap;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir struct ScStreamEntry
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir     sal_Int32   mnStartOffset;
45*cdf0e10cSrcweir     sal_Int32   mnEndOffset;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir                 ScStreamEntry() :
48*cdf0e10cSrcweir                     mnStartOffset(-1),
49*cdf0e10cSrcweir                     mnEndOffset(-1)
50*cdf0e10cSrcweir                 {
51*cdf0e10cSrcweir                 }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir                 ScStreamEntry( sal_Int32 nStart, sal_Int32 nEnd ) :
54*cdf0e10cSrcweir                     mnStartOffset(nStart),
55*cdf0e10cSrcweir                     mnEndOffset(nEnd)
56*cdf0e10cSrcweir                 {
57*cdf0e10cSrcweir                 }
58*cdf0e10cSrcweir };
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir struct ScCellStyleEntry
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     rtl::OUString   maName;
63*cdf0e10cSrcweir     ScAddress       maCellPos;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir                 ScCellStyleEntry( const rtl::OUString& rName, const ScAddress& rPos ) :
66*cdf0e10cSrcweir                     maName(rName),
67*cdf0e10cSrcweir                     maCellPos(rPos)
68*cdf0e10cSrcweir                 {
69*cdf0e10cSrcweir                 }
70*cdf0e10cSrcweir };
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir struct ScNoteStyleEntry
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     rtl::OUString   maStyleName;
75*cdf0e10cSrcweir     rtl::OUString   maTextStyle;
76*cdf0e10cSrcweir     ScAddress       maCellPos;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir                 ScNoteStyleEntry( const rtl::OUString& rStyle, const rtl::OUString& rText, const ScAddress& rPos ) :
79*cdf0e10cSrcweir                     maStyleName(rStyle),
80*cdf0e10cSrcweir                     maTextStyle(rText),
81*cdf0e10cSrcweir                     maCellPos(rPos)
82*cdf0e10cSrcweir                 {
83*cdf0e10cSrcweir                 }
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir struct ScTextStyleEntry
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     rtl::OUString   maName;
89*cdf0e10cSrcweir     ScAddress       maCellPos;
90*cdf0e10cSrcweir     ESelection      maSelection;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir                 ScTextStyleEntry( const rtl::OUString& rName, const ScAddress& rPos, const ESelection& rSel ) :
93*cdf0e10cSrcweir                     maName(rName),
94*cdf0e10cSrcweir                     maCellPos(rPos),
95*cdf0e10cSrcweir                     maSelection(rSel)
96*cdf0e10cSrcweir                 {
97*cdf0e10cSrcweir                 }
98*cdf0e10cSrcweir };
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir struct ScLoadedNamespaceEntry
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     rtl::OUString   maPrefix;
103*cdf0e10cSrcweir     rtl::OUString   maName;
104*cdf0e10cSrcweir     sal_uInt16      mnKey;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir                 ScLoadedNamespaceEntry( const rtl::OUString& rPrefix, const rtl::OUString& rName, sal_uInt16 nKey ) :
107*cdf0e10cSrcweir                     maPrefix(rPrefix),
108*cdf0e10cSrcweir                     maName(rName),
109*cdf0e10cSrcweir                     mnKey(nKey)
110*cdf0e10cSrcweir                 {
111*cdf0e10cSrcweir                 }
112*cdf0e10cSrcweir };
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir class ScSheetSaveData
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     std::hash_set<rtl::OUString, rtl::OUStringHash>  maInitialPrefixes;
117*cdf0e10cSrcweir     std::vector<ScLoadedNamespaceEntry>              maLoadedNamespaces;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maCellStyles;
120*cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maColumnStyles;
121*cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maRowStyles;
122*cdf0e10cSrcweir     std::vector<ScCellStyleEntry> maTableStyles;
123*cdf0e10cSrcweir     std::vector<ScNoteStyleEntry> maNoteStyles;
124*cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maNoteParaStyles;
125*cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maNoteTextStyles;
126*cdf0e10cSrcweir     std::vector<ScTextStyleEntry> maTextStyles;
127*cdf0e10cSrcweir     std::vector<bool>          maBlocked;
128*cdf0e10cSrcweir     std::vector<ScStreamEntry> maStreamEntries;
129*cdf0e10cSrcweir     std::vector<ScStreamEntry> maSaveEntries;
130*cdf0e10cSrcweir     sal_Int32   mnStartTab;
131*cdf0e10cSrcweir     sal_Int32   mnStartOffset;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     ScNoteStyleEntry    maPreviousNote;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     bool                mbInSupportedSave;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir public:
138*cdf0e10cSrcweir                 ScSheetSaveData();
139*cdf0e10cSrcweir                 ~ScSheetSaveData();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     void        AddCellStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
142*cdf0e10cSrcweir     void        AddColumnStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
143*cdf0e10cSrcweir     void        AddRowStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
144*cdf0e10cSrcweir     void        AddTableStyle( const rtl::OUString& rName, const ScAddress& rCellPos );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     void        HandleNoteStyles( const rtl::OUString& rStyleName, const rtl::OUString& rTextName, const ScAddress& rCellPos );
147*cdf0e10cSrcweir     void        AddNoteContentStyle( sal_uInt16 nFamily, const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     void        AddTextStyle( const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     void        BlockSheet( sal_Int32 nTab );
152*cdf0e10cSrcweir     bool        IsSheetBlocked( sal_Int32 nTab ) const;
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     void        AddStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
155*cdf0e10cSrcweir     void        GetStreamPos( sal_Int32 nTab, sal_Int32& rStartOffset, sal_Int32& rEndOffset ) const;
156*cdf0e10cSrcweir     bool        HasStreamPos( sal_Int32 nTab ) const;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     void        StartStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset );
159*cdf0e10cSrcweir     void        EndStreamPos( sal_Int32 nEndOffset );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     bool        HasStartPos() const { return mnStartTab >= 0; }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     void        ResetSaveEntries();
164*cdf0e10cSrcweir     void        AddSavePos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset );
165*cdf0e10cSrcweir     void        UseSaveEntries();
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     void        StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces );
168*cdf0e10cSrcweir     void        StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespaces );
169*cdf0e10cSrcweir     bool        AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetCellStyles() const   { return maCellStyles; }
172*cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetColumnStyles() const { return maColumnStyles; }
173*cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetRowStyles() const    { return maRowStyles; }
174*cdf0e10cSrcweir     const std::vector<ScCellStyleEntry>& GetTableStyles() const  { return maTableStyles; }
175*cdf0e10cSrcweir     const std::vector<ScNoteStyleEntry>& GetNoteStyles() const   { return maNoteStyles; }
176*cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetNoteParaStyles() const { return maNoteParaStyles; }
177*cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetNoteTextStyles() const { return maNoteTextStyles; }
178*cdf0e10cSrcweir     const std::vector<ScTextStyleEntry>& GetTextStyles() const   { return maTextStyles; }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     bool        IsInSupportedSave() const;
181*cdf0e10cSrcweir     void        SetInSupportedSave( bool bSet );
182*cdf0e10cSrcweir };
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir #endif
185*cdf0e10cSrcweir 
186