xref: /aoo41x/main/sc/source/filter/inc/xihelper.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2*38d50f7bSAndrew Rist  *
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_XIHELPER_HXX
25cdf0e10cSrcweir #define SC_XIHELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <editeng/editdata.hxx>
28cdf0e10cSrcweir #include "scmatrix.hxx"
29cdf0e10cSrcweir #include "xladdress.hxx"
30cdf0e10cSrcweir #include "xiroot.hxx"
31cdf0e10cSrcweir #include "xistring.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Excel->Calc cell address/range conversion ==================================
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /** Provides functions to convert Excel cell addresses to Calc cell addresses. */
36cdf0e10cSrcweir class XclImpAddressConverter : public XclAddressConverterBase
37cdf0e10cSrcweir {
38cdf0e10cSrcweir public:
39cdf0e10cSrcweir     explicit            XclImpAddressConverter( const XclImpRoot& rRoot );
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     // cell address -----------------------------------------------------------
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     /** Checks if the passed Excel cell address is valid.
44cdf0e10cSrcweir         @param rXclPos  The Excel cell address to check.
45cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
46cdf0e10cSrcweir             after loading/saving the file, if the cell address is not valid.
47cdf0e10cSrcweir         @return  true = Cell address in rXclPos is valid. */
48cdf0e10cSrcweir     bool                CheckAddress( const XclAddress& rXclPos, bool bWarn );
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     /** Converts the passed Excel cell address to a Calc cell address.
51cdf0e10cSrcweir         @param rScPos  (Out) The converted Calc cell address, if valid.
52cdf0e10cSrcweir         @param rXclPos  The Excel cell address to convert.
53cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
54cdf0e10cSrcweir             after loading/saving the file, if the cell address is invalid.
55cdf0e10cSrcweir         @return  true = Cell address returned in rScPos is valid. */
56cdf0e10cSrcweir     bool                ConvertAddress( ScAddress& rScPos,
57cdf0e10cSrcweir                             const XclAddress& rXclPos, SCTAB nScTab, bool bWarn );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /** Returns a valid cell address by moving it into allowed dimensions.
60cdf0e10cSrcweir         @param rXclPos  The Excel cell address to convert.
61cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
62cdf0e10cSrcweir             after loading/saving the file, if the cell address is invalid.
63cdf0e10cSrcweir         @return  The converted Calc cell address. */
64cdf0e10cSrcweir     ScAddress           CreateValidAddress( const XclAddress& rXclPos,
65cdf0e10cSrcweir                             SCTAB nScTab, bool bWarn );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     // cell range -------------------------------------------------------------
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /** Checks if the passed cell range is valid (checks start and end position).
70cdf0e10cSrcweir         @param rXclRange  The Excel cell range to check.
71cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
72cdf0e10cSrcweir             after loading/saving the file, if the cell range is not valid.
73cdf0e10cSrcweir         @return  true = Cell range in rXclRange is valid. */
74cdf0e10cSrcweir     bool                CheckRange( const XclRange& rXclRange, bool bWarn );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /** Converts the passed Excel cell range to a Calc cell range.
77cdf0e10cSrcweir         @param rScRange  (Out) The converted Calc cell range, if valid.
78cdf0e10cSrcweir         @param rXclRange  The Excel cell range to convert.
79cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
80cdf0e10cSrcweir             after loading/saving the file, if the cell range contains invalid cells.
81cdf0e10cSrcweir         @return  true = Cell range returned in rScRange is valid (original or cropped). */
82cdf0e10cSrcweir     bool                ConvertRange( ScRange& rScRange, const XclRange& rXclRange,
83cdf0e10cSrcweir                             SCTAB nScTab1, SCTAB nScTab2, bool bWarn );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //UNUSED2009-05 /** Returns a valid cell range by moving it into allowed dimensions.
86cdf0e10cSrcweir //UNUSED2009-05     @descr  The start and/or end position of the range may be modified.
87cdf0e10cSrcweir //UNUSED2009-05     @param rXclRange  The Excel cell range to convert.
88cdf0e10cSrcweir //UNUSED2009-05     @param bWarn  true = Sets the internal flag that produces a warning box
89cdf0e10cSrcweir //UNUSED2009-05         after loading/saving the file, if the cell range contains invalid cells.
90cdf0e10cSrcweir //UNUSED2009-05     @return  The converted Calc cell range. */
91cdf0e10cSrcweir //UNUSED2009-05 ScRange             CreateValidRange( const XclRange& rXclRange,
92cdf0e10cSrcweir //UNUSED2009-05                         SCTAB nScTab1, SCTAB nScTab2, bool bWarn );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     // cell range list --------------------------------------------------------
95cdf0e10cSrcweir 
96cdf0e10cSrcweir //UNUSED2009-05 /** Checks if the passed cell range list is valid.
97cdf0e10cSrcweir //UNUSED2009-05     @param rXclRanges  The Excel cell range list to check.
98cdf0e10cSrcweir //UNUSED2009-05     @param bWarn  true = Sets the internal flag that produces a warning box
99cdf0e10cSrcweir //UNUSED2009-05         after loading/saving the file, if the cell range list contains at
100cdf0e10cSrcweir //UNUSED2009-05         least one invalid range.
101cdf0e10cSrcweir //UNUSED2009-05     @return  true = Cell range list in rScRanges is completly valid. */
102cdf0e10cSrcweir //UNUSED2009-05 bool                CheckRangeList( const XclRangeList& rXclRanges, bool bWarn );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     /** Converts the passed Excel cell range list to a Calc cell range list.
105cdf0e10cSrcweir         @descr  The start position of the ranges will not be modified. Cell
106cdf0e10cSrcweir             ranges that fit partly into valid dimensions are cropped
107cdf0e10cSrcweir             accordingly. Cell ranges that do not fit at all, are not inserted
108cdf0e10cSrcweir             into the Calc cell range list.
109cdf0e10cSrcweir         @param rScRanges  (Out) The converted Calc cell range list.
110cdf0e10cSrcweir         @param rXclRanges  The Excel cell range list to convert.
111cdf0e10cSrcweir         @param bWarn  true = Sets the internal flag that produces a warning box
112cdf0e10cSrcweir             after loading/saving the file, if at least one of the cell ranges
113cdf0e10cSrcweir             contains invalid cells. */
114cdf0e10cSrcweir     void                ConvertRangeList( ScRangeList& rScRanges,
115cdf0e10cSrcweir                             const XclRangeList& rXclRanges, SCTAB nScTab, bool bWarn );
116cdf0e10cSrcweir };
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // String->EditEngine conversion ==============================================
119cdf0e10cSrcweir 
120cdf0e10cSrcweir class ScBaseCell;
121cdf0e10cSrcweir class EditTextObject;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir /** This class provides methods to convert an XclImpString.
124cdf0e10cSrcweir     @The string can be converted to an edit engine text object or directly
125cdf0e10cSrcweir     to a Calc edit cell. */
126cdf0e10cSrcweir class XclImpStringHelper : ScfNoInstance
127cdf0e10cSrcweir {
128cdf0e10cSrcweir public:
129cdf0e10cSrcweir     /** Returns a new edit engine text object.
130cdf0e10cSrcweir         @param nXFIndex  Index to XF for first text portion (for escapement). */
131cdf0e10cSrcweir     static EditTextObject* CreateTextObject(
132cdf0e10cSrcweir                             const XclImpRoot& rRoot,
133cdf0e10cSrcweir                             const XclImpString& rString );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir //UNUSED2009-05 /** Returns a new edit engine text object for a cell note.
136cdf0e10cSrcweir //UNUSED2009-05     @param nXFIndex  Index to XF for first text portion (for escapement). */
137cdf0e10cSrcweir //UNUSED2009-05 static EditTextObject* CreateNoteObject(
138cdf0e10cSrcweir //UNUSED2009-05                         const XclImpRoot& rRoot,
139cdf0e10cSrcweir //UNUSED2009-05                         const XclImpString& rString );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     /** Creates a new text cell or edit cell for a Calc document.
142cdf0e10cSrcweir         @param nXFIndex  Index to XF for first text portion (for escapement). */
143cdf0e10cSrcweir     static ScBaseCell*  CreateCell(
144cdf0e10cSrcweir                             const XclImpRoot& rRoot,
145cdf0e10cSrcweir                             const XclImpString& rString,
146cdf0e10cSrcweir                             sal_uInt16 nXFIndex = 0 );
147cdf0e10cSrcweir };
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // Header/footer conversion ===================================================
150cdf0e10cSrcweir 
151cdf0e10cSrcweir class EditEngine;
152cdf0e10cSrcweir class EditTextObject;
153cdf0e10cSrcweir class SfxItemSet;
154cdf0e10cSrcweir class SvxFieldItem;
155cdf0e10cSrcweir struct XclFontData;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir /** Converts an Excel header/footer string into three edit engine text objects.
158cdf0e10cSrcweir     @descr  Header/footer content is divided into three parts: Left, center and
159cdf0e10cSrcweir     right portion. All formatting information is encoded in the Excel string
160cdf0e10cSrcweir     using special character seuences. A control sequence starts with the ampersand
161cdf0e10cSrcweir     character.
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     Supported control sequences:
164cdf0e10cSrcweir     &L                      start of left portion
165cdf0e10cSrcweir     &C                      start of center portion
166cdf0e10cSrcweir     &R                      start of right portion
167cdf0e10cSrcweir     &P                      current page number
168cdf0e10cSrcweir     &N                      page count
169cdf0e10cSrcweir     &D                      current date
170cdf0e10cSrcweir     &T                      current time
171cdf0e10cSrcweir     &A                      table name
172cdf0e10cSrcweir     &F                      file name without path (see also &Z&F)
173cdf0e10cSrcweir     &Z                      file path without file name (converted to full file name, see also &Z&F)
174cdf0e10cSrcweir     &Z&F                    file path and name
175cdf0e10cSrcweir     &U                      underlining on/off
176cdf0e10cSrcweir     &E                      double underlining on/off
177cdf0e10cSrcweir     &S                      strikeout characters on/off
178cdf0e10cSrcweir     &X                      superscript on/off
179cdf0e10cSrcweir     &Y                      subscript on/off
180cdf0e10cSrcweir     &"fontname,fontstyle"   use font with name 'fontname' and style 'fontstyle'
181cdf0e10cSrcweir     &fontheight             set font height in points ('fontheight' is a decimal value)
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     Known but unsupported control sequences:
184cdf0e10cSrcweir     &G                      picture
185cdf0e10cSrcweir  */
186cdf0e10cSrcweir class XclImpHFConverter : protected XclImpRoot, ScfNoCopy
187cdf0e10cSrcweir {
188cdf0e10cSrcweir public:
189cdf0e10cSrcweir     explicit            XclImpHFConverter( const XclImpRoot& rRoot );
190cdf0e10cSrcweir                         ~XclImpHFConverter();
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     /** Parses the passed string and creates three new edit engine text objects. */
193cdf0e10cSrcweir     void                ParseString( const String& rHFString );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     /** Creates a ScPageHFItem and inserts it into the passed item set. */
196cdf0e10cSrcweir     void                FillToItemSet( SfxItemSet& rItemSet, sal_uInt16 nWhichId ) const;
197cdf0e10cSrcweir     /** Returns the total height of the converted header or footer in twips. */
198cdf0e10cSrcweir     sal_Int32           GetTotalHeight() const;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir private:    // types
201cdf0e10cSrcweir     typedef ::std::auto_ptr< XclFontData > XclFontDataPtr;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     /** Enumerates the supported header/footer portions. */
204cdf0e10cSrcweir     enum XclImpHFPortion { EXC_HF_LEFT, EXC_HF_CENTER, EXC_HF_RIGHT, EXC_HF_PORTION_COUNT };
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     /** Contains all information about a header/footer portion. */
207cdf0e10cSrcweir     struct XclImpHFPortionInfo
208cdf0e10cSrcweir     {
209cdf0e10cSrcweir         typedef ScfRef< EditTextObject > EditTextObjectRef;
210cdf0e10cSrcweir         EditTextObjectRef   mxObj;          /// Edit engine text object.
211cdf0e10cSrcweir         ESelection          maSel;          /// Edit engine selection.
212cdf0e10cSrcweir         sal_Int32           mnHeight;       /// Height of previous lines in twips.
213cdf0e10cSrcweir         sal_uInt16          mnMaxLineHt;    /// Maximum font height for the current text line.
214cdf0e10cSrcweir         explicit            XclImpHFPortionInfo();
215cdf0e10cSrcweir     };
216cdf0e10cSrcweir     typedef ::std::vector< XclImpHFPortionInfo > XclImpHFPortionInfoVec;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir private:
219cdf0e10cSrcweir     /** Returns the current edit engine text object. */
GetCurrInfo()220cdf0e10cSrcweir     inline XclImpHFPortionInfo& GetCurrInfo() { return maInfos[ meCurrObj ]; }
221cdf0e10cSrcweir     /** Returns the current edit engine text object. */
GetCurrObj()222cdf0e10cSrcweir     inline XclImpHFPortionInfo::EditTextObjectRef& GetCurrObj() { return GetCurrInfo().mxObj; }
223cdf0e10cSrcweir     /** Returns the current selection. */
GetCurrSel()224cdf0e10cSrcweir     inline ESelection&  GetCurrSel() { return GetCurrInfo().maSel; }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     /** Returns the maximum line height of the specified portion. */
227cdf0e10cSrcweir     sal_uInt16          GetMaxLineHeight( XclImpHFPortion ePortion ) const;
228cdf0e10cSrcweir     /** Returns the current maximum line height. */
229cdf0e10cSrcweir     sal_uInt16          GetCurrMaxLineHeight() const;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     /** Updates the maximum line height of the specified portion, using the current font size. */
232cdf0e10cSrcweir     void                UpdateMaxLineHeight( XclImpHFPortion ePortion );
233cdf0e10cSrcweir     /** Updates the current maximum line height, using the current font size. */
234cdf0e10cSrcweir     void                UpdateCurrMaxLineHeight();
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     /** Sets the font attributes at the current selection.
237cdf0e10cSrcweir         @descr  After that, the start position of the current selection object is
238cdf0e10cSrcweir         adjusted to the end of the selection. */
239cdf0e10cSrcweir     void                SetAttribs();
240cdf0e10cSrcweir     /** Resets font data to application default font. */
241cdf0e10cSrcweir     void                ResetFontData();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     /** Inserts maCurrText into edit engine and adjusts the current selection object.
244cdf0e10cSrcweir         @descr  The text shall not contain a newline character.
245cdf0e10cSrcweir         The text will be cleared after insertion. */
246cdf0e10cSrcweir     void                InsertText();
247cdf0e10cSrcweir     /** Inserts the passed text field and adjusts the current selection object. */
248cdf0e10cSrcweir     void                InsertField( const SvxFieldItem& rFieldItem );
249cdf0e10cSrcweir     /** Inserts a line break and adjusts the current selection object. */
250cdf0e10cSrcweir     void                InsertLineBreak();
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     /** Creates the edit engine text object of current portion from edit engine. */
253cdf0e10cSrcweir     void                CreateCurrObject();
254cdf0e10cSrcweir     /** Changes current header/footer portion to eNew.
255cdf0e10cSrcweir         @descr  Creates text object of current portion and reinitializes edit engine. */
256cdf0e10cSrcweir     void                SetNewPortion( XclImpHFPortion eNew );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir private:
259cdf0e10cSrcweir     EditEngine&         mrEE;               /// The header/footer edit engine.
260cdf0e10cSrcweir     XclImpHFPortionInfoVec maInfos;         /// Edit engine text objects for all portions.
261cdf0e10cSrcweir     String              maCurrText;         /// Current text to insert into edit engine.
262cdf0e10cSrcweir     XclFontDataPtr      mxFontData;         /// Font data of current text.
263cdf0e10cSrcweir     XclImpHFPortion     meCurrObj;          /// The current portion.
264cdf0e10cSrcweir };
265cdf0e10cSrcweir 
266cdf0e10cSrcweir // URL conversion =============================================================
267cdf0e10cSrcweir 
268cdf0e10cSrcweir /** This class contains static methods to decode an URL stored in an Excel file.
269cdf0e10cSrcweir     @descr  Excel URLs can contain a sheet name, for instance: path\[test.xls]Sheet1
270cdf0e10cSrcweir     This sheet name will be extracted automatically. */
271cdf0e10cSrcweir class XclImpUrlHelper : ScfNoInstance
272cdf0e10cSrcweir {
273cdf0e10cSrcweir public:
274cdf0e10cSrcweir     /** Decodes an encoded external document URL with optional sheet name.
275cdf0e10cSrcweir         @param rUrl  Returns the decoded file name incl. path.
276cdf0e10cSrcweir         @param rTabName  Returns the decoded sheet name.
277cdf0e10cSrcweir         @param rbSameWb  Returns true, if the URL is a reference to the own workbook.
278cdf0e10cSrcweir         @param rEncodedUrl   An encoded URL from Excel. */
279cdf0e10cSrcweir     static void         DecodeUrl(
280cdf0e10cSrcweir                             String& rUrl,
281cdf0e10cSrcweir                             String& rTabName,
282cdf0e10cSrcweir                             bool& rbSameWb,
283cdf0e10cSrcweir                             const XclImpRoot& rRoot,
284cdf0e10cSrcweir                             const String& rEncodedUrl );
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     /** Decodes an encoded external document URL without sheet name.
287cdf0e10cSrcweir         @param rUrl  Returns the decoded file name incl. path.
288cdf0e10cSrcweir         @param rbSameWb  Returns true, if the URL is a reference to the own workbook.
289cdf0e10cSrcweir         @param rEncodedUrl   An encoded URL from Excel. */
290cdf0e10cSrcweir     static void         DecodeUrl(
291cdf0e10cSrcweir                             String& rUrl,
292cdf0e10cSrcweir                             bool& rbSameWb,
293cdf0e10cSrcweir                             const XclImpRoot& rRoot,
294cdf0e10cSrcweir                             const String& rEncodedUrl );
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     /** Decodes the passed URL to OLE or DDE link components.
297cdf0e10cSrcweir         @descr  For DDE links: Decodes to application name and topic.
298cdf0e10cSrcweir         For OLE object links: Decodes to class name and document URL.
299cdf0e10cSrcweir         @return  true = decoding was successful, returned strings are valid (not empty). */
300cdf0e10cSrcweir     static bool         DecodeLink( String& rApplic, String& rTopic, const String rEncUrl );
301cdf0e10cSrcweir };
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // Cached values ==============================================================
304cdf0e10cSrcweir 
305cdf0e10cSrcweir class ScTokenArray;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir /** This class stores one cached value of a cached value list (used for instance in
308cdf0e10cSrcweir     CRN, EXTERNNAME, tArray). */
309cdf0e10cSrcweir class XclImpCachedValue : ScfNoCopy
310cdf0e10cSrcweir {
311cdf0e10cSrcweir public:
312cdf0e10cSrcweir     /** Creates a cached value and reads contents from stream and stores it with its array address. */
313cdf0e10cSrcweir     explicit            XclImpCachedValue( XclImpStream& rStrm );
314cdf0e10cSrcweir     virtual             ~XclImpCachedValue();
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     /** Returns the type of the cached value (EXC_CACHEDVAL_*). */
GetType() const317cdf0e10cSrcweir     inline sal_uInt8    GetType() const     { return mnType; }
318cdf0e10cSrcweir     /** Returns the cached string value, if this value is a string, else an empty string. */
GetString() const319cdf0e10cSrcweir     inline const String& GetString() const  { return mxStr.get() ? *mxStr : EMPTY_STRING; }
320cdf0e10cSrcweir     /** Returns the cached number, if this value has number type, else 0.0. */
GetValue() const321cdf0e10cSrcweir     inline double       GetValue() const    { return mfValue; }
322cdf0e10cSrcweir     /** Returns the cached Boolean value, if this value has Boolean type, else false. */
GetBool() const323cdf0e10cSrcweir     inline bool         GetBool() const     { return (mnType == EXC_CACHEDVAL_BOOL) && (mnBoolErr != 0); }
324cdf0e10cSrcweir     /** Returns the cached Calc error code, if this value has Error type, else 0. */
GetXclError() const325cdf0e10cSrcweir     inline sal_uInt8    GetXclError() const { return (mnType == EXC_CACHEDVAL_ERROR) ? mnBoolErr : EXC_ERR_NA; }
326cdf0e10cSrcweir     /** Returns the cached Calc error code, if this value has Error type, else 0. */
327cdf0e10cSrcweir     sal_uInt16              GetScError() const;
328cdf0e10cSrcweir     /** Returns the token array if this is a Boolean value or error value, else 0. */
GetBoolErrFmla() const329cdf0e10cSrcweir     inline const ScTokenArray* GetBoolErrFmla() const { return mxTokArr.get(); }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir protected:
332cdf0e10cSrcweir     typedef ::std::auto_ptr< String >               StringPtr;
333cdf0e10cSrcweir     typedef ::std::auto_ptr< const ScTokenArray >   ScTokenArrayPtr;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir     StringPtr           mxStr;      /// Cached value is a string.
336cdf0e10cSrcweir     double              mfValue;    /// Cached value is a double.
337cdf0e10cSrcweir     ScTokenArrayPtr     mxTokArr;   /// Cached value is a formula or error code or Boolean.
338cdf0e10cSrcweir     sal_uInt8           mnBoolErr;  /// Boolean value or Excel error code.
339cdf0e10cSrcweir     sal_uInt8           mnType;     /// The type of the cached value (EXC_CACHEDVAL_*).
340cdf0e10cSrcweir };
341cdf0e10cSrcweir 
342cdf0e10cSrcweir // ----------------------------------------------------------------------------
343cdf0e10cSrcweir 
344cdf0e10cSrcweir /** Contains cached values in a 2-dimensional array. */
345cdf0e10cSrcweir class XclImpCachedMatrix
346cdf0e10cSrcweir {
347cdf0e10cSrcweir public:
348cdf0e10cSrcweir     explicit            XclImpCachedMatrix( XclImpStream& rStrm );
349cdf0e10cSrcweir                         ~XclImpCachedMatrix();
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     /** Creates a new ScMatrix object and fills it with the contained values. */
352cdf0e10cSrcweir     ScMatrixRef         CreateScMatrix() const;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir private:
355cdf0e10cSrcweir     typedef ScfDelList< XclImpCachedValue > XclImpValueList;
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     XclImpValueList     maValueList;    /// List of cached cell values.
358cdf0e10cSrcweir     SCSIZE              mnScCols;       /// Number of cached columns.
359cdf0e10cSrcweir     SCSIZE              mnScRows;       /// Number of cached rows.
360cdf0e10cSrcweir };
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // ============================================================================
363cdf0e10cSrcweir 
364cdf0e10cSrcweir #endif
365cdf0e10cSrcweir 
366