xref: /aoo41x/main/sc/source/filter/inc/xiroot.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_XIROOT_HXX
25 #define SC_XIROOT_HXX
26 
27 #include "xlroot.hxx"
28 
29 // Forward declarations of objects in public use ==============================
30 
31 class XclImpStream;
32 class XclImpString;
33 
34 typedef ScfRef< XclImpString > XclImpStringRef;
35 
36 // Global data ================================================================
37 
38 class XclImpAddressConverter;
39 class XclImpFormulaCompiler;
40 class XclImpSst;
41 class XclImpPalette;
42 class XclImpFontBuffer;
43 class XclImpNumFmtBuffer;
44 class XclImpXFBuffer;
45 class XclImpXFRangeBuffer;
46 class XclImpTabInfo;
47 class XclImpNameManager;
48 class XclImpLinkManager;
49 class XclImpObjectManager;
50 class XclImpSheetDrawing;
51 class XclImpCondFormatManager;
52 class XclImpAutoFilterBuffer;
53 class XclImpWebQueryBuffer;
54 class XclImpPivotTableManager;
55 class XclImpPageSettings;
56 class XclImpDocViewSettings;
57 class XclImpTabViewSettings;
58 class XclImpSheetProtectBuffer;
59 class XclImpDocProtectBuffer;
60 
61 class _ScRangeListTabs;
62 class ExcelToSc;
63 
64 /** Stores global buffers and data needed for Excel import filter. */
65 struct XclImpRootData : public XclRootData
66 {
67     typedef ScfRef< XclImpAddressConverter >    XclImpAddrConvRef;
68     typedef ScfRef< XclImpFormulaCompiler >     XclImpFmlaCompRef;
69 
70     typedef ScfRef< XclImpSst >                 XclImpSstRef;
71     typedef ScfRef< XclImpPalette >             XclImpPaletteRef;
72     typedef ScfRef< XclImpFontBuffer >          XclImpFontBfrRef;
73     typedef ScfRef< XclImpNumFmtBuffer >        XclImpNumFmtBfrRef;
74     typedef ScfRef< XclImpXFBuffer >            XclImpXFBfrRef;
75     typedef ScfRef< XclImpXFRangeBuffer >       XclImpXFRangeBfrRef;
76     typedef ScfRef< XclImpTabInfo >             XclImpTabInfoRef;
77     typedef ScfRef< XclImpNameManager >         XclImpNameMgrRef;
78     typedef ScfRef< XclImpLinkManager >         XclImpLinkMgrRef;
79     typedef ScfRef< XclImpObjectManager >       XclImpObjectMgrRef;
80     typedef ScfRef< XclImpCondFormatManager >   XclImpCondFmtMgrRef;
81     typedef ScfRef< XclImpWebQueryBuffer >      XclImpWebQueryBfrRef;
82     typedef ScfRef< XclImpPivotTableManager >   XclImpPTableMgrRef;
83     typedef ScfRef< XclImpPageSettings >        XclImpPageSettRef;
84     typedef ScfRef< XclImpDocViewSettings >     XclImpDocViewSettRef;
85     typedef ScfRef< XclImpTabViewSettings >     XclImpTabViewSettRef;
86     typedef ScfRef< XclImpSheetProtectBuffer >  XclImpTabProtectRef;
87     typedef ScfRef< XclImpDocProtectBuffer >    XclImpDocProtectRef;
88 
89     XclImpAddrConvRef   mxAddrConv;         /// The address converter.
90     XclImpFmlaCompRef   mxFmlaComp;         /// The formula compiler.
91 
92     XclImpSstRef        mxSst;              /// The shared string table.
93     XclImpPaletteRef    mxPalette;          /// The color buffer.
94     XclImpFontBfrRef    mxFontBfr;          /// All fonts in the file.
95     XclImpNumFmtBfrRef  mxNumFmtBfr;        /// All number formats in the file.
96     XclImpXFBfrRef      mpXFBfr;            /// All XF record data in the file.
97     XclImpXFRangeBfrRef mxXFRangeBfr;       /// Buffer of XF index ranges in a sheet.
98 
99     XclImpTabInfoRef    mxTabInfo;          /// Sheet creation order list.
100     XclImpNameMgrRef    mxNameMgr;          /// Internal defined names.
101     XclImpLinkMgrRef    mxLinkMgr;          /// Manager for internal/external links.
102 
103     XclImpObjectMgrRef  mxObjMgr;           /// All drawing objects.
104     XclImpCondFmtMgrRef mxCondFmtMgr;       /// Conditional formattings.
105     XclImpWebQueryBfrRef mxWebQueryBfr;     /// All web queries.
106     XclImpPTableMgrRef  mxPTableMgr;        /// All pivot tables and pivot caches.
107 
108     XclImpPageSettRef   mxPageSett;         /// Page settings for current sheet.
109     XclImpDocViewSettRef mxDocViewSett;     /// View settings for entire document.
110     XclImpTabViewSettRef mxTabViewSett;     /// View settings for current sheet.
111     XclImpTabProtectRef mxTabProtect;       /// Sheet protection options for current sheet.
112     XclImpDocProtectRef mxDocProtect;       /// Document protection options.
113 
114     bool                mbHasCodePage;      /// true = CODEPAGE record exists.
115     bool                mbHasBasic;         /// true = document contains VB project.
116 
117     explicit            XclImpRootData( XclBiff eBiff, SfxMedium& rMedium,
118                             SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc );
119     virtual             ~XclImpRootData();
120 };
121 
122 // ----------------------------------------------------------------------------
123 
124 /** Access to global data from other classes. */
125 class XclImpRoot : public XclRoot
126 {
127 public:
128     explicit            XclImpRoot( XclImpRootData& rImpRootData );
129 
130     /** Returns this root instance - for code readability in derived classes. */
GetRoot() const131     inline const XclImpRoot& GetRoot() const { return *this; }
132 
133     /** Sets a code page read from a CODEPAGE record for byte string import. */
134     void                SetCodePage( sal_uInt16 nCodePage );
135     /** Sets text encoding from the default application font (in case of missing CODEPAGE record). */
136     void                SetAppFontEncoding( rtl_TextEncoding eAppFontEnc );
137 
138     /** Is called when import filter starts importing a single sheet (all BIFF versions). */
139     void                InitializeTable( SCTAB nScTab );
140     /** Is called when import filter stops importing a single sheet (all BIFF versions). */
141     void                FinalizeTable();
142 
143     /** Returns the address converter. */
144     XclImpAddressConverter& GetAddressConverter() const;
145     /** Returns the formula converter. */
146     XclImpFormulaCompiler& GetFormulaCompiler() const;
147     /** Returns the old formula converter. */
148     ExcelToSc&          GetOldFmlaConverter() const;
149 
150     /** Returns the shared string table. */
151     XclImpSst&          GetSst() const;
152     /** Returns the color buffer. */
153     XclImpPalette&      GetPalette() const;
154     /** Returns the font buffer. */
155     XclImpFontBuffer&   GetFontBuffer() const;
156     /** Returns the number format buffer. */
157     XclImpNumFmtBuffer& GetNumFmtBuffer() const;
158     /** Returns the cell formatting attributes buffer. */
159     XclImpXFBuffer&     GetXFBuffer() const;
160     /** Returns the buffer of XF index ranges for a sheet. */
161     XclImpXFRangeBuffer& GetXFRangeBuffer() const;
162 
163     /** Returns the buffer that contains all print areas in the document. */
164     _ScRangeListTabs&   GetPrintAreaBuffer() const;
165     /** Returns the buffer that contains all print titles in the document. */
166     _ScRangeListTabs&   GetTitleAreaBuffer() const;
167 
168     /** Returns the buffer that contains the sheet creation order. */
169     XclImpTabInfo&      GetTabInfo() const;
170     /** Returns the buffer that contains internal defined names. */
171     XclImpNameManager&  GetNameManager() const;
172     /** Returns the link manager. */
173     XclImpLinkManager&  GetLinkManager() const;
174 
175     /** Returns the drawing object manager. */
176     XclImpObjectManager& GetObjectManager() const;
177     /** Returns the drawing container of the current sheet. */
178     XclImpSheetDrawing& GetCurrSheetDrawing() const;
179     /** Returns the conditional formattings manager. */
180     XclImpCondFormatManager& GetCondFormatManager() const;
181     /** Returns the filter manager. */
182     XclImpAutoFilterBuffer& GetFilterManager() const;
183     /** Returns the web query buffer. */
184     XclImpWebQueryBuffer& GetWebQueryBuffer() const;
185     /** Returns the pivot table manager. */
186     XclImpPivotTableManager& GetPivotTableManager() const;
187     /** Returns the sheet protection options of the current sheet. */
188     XclImpSheetProtectBuffer& GetSheetProtectBuffer() const;
189     /** Returns the document protection options. */
190     XclImpDocProtectBuffer& GetDocProtectBuffer() const;
191 
192     /** Returns the page settings of the current sheet. */
193     XclImpPageSettings& GetPageSettings() const;
194     /** Returns the view settings of the entire document. */
195     XclImpDocViewSettings& GetDocViewSettings() const;
196     /** Returns the view settings of the current sheet. */
197     XclImpTabViewSettings& GetTabViewSettings() const;
198 
199     /** Returns the Calc add-in function name for an Excel function name. */
200     String              GetScAddInName( const String& rXclName ) const;
201 
202     /** Returns true, if the document contains a VB project. */
HasBasic() const203     inline bool         HasBasic() const { return mrImpData.mbHasBasic; }
204     /** Called to indicate that the document contains a VB project. */
SetHasBasic()205     inline void         SetHasBasic() { mrImpData.mbHasBasic = true; }
206     /** Reads the CODENAME record and inserts the codename into the document. */
207     void                ReadCodeName( XclImpStream& rStrm, bool bGlobals );
208 
209 private:
210     XclImpRootData& mrImpData;      /// Reference to the global import data struct.
211 };
212 
213 // ============================================================================
214 
215 #endif
216