xref: /aoo41x/main/sc/source/filter/inc/excform.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_EXCFORM_HXX
25cdf0e10cSrcweir #define SC_EXCFORM_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "xlformula.hxx"
28cdf0e10cSrcweir #include "xiroot.hxx"
29cdf0e10cSrcweir #include "formel.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <vector>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class ScRangeList;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class ExcelToSc : public ExcelConverterBase, protected XclImpRoot
37cdf0e10cSrcweir {
38cdf0e10cSrcweir protected:
39cdf0e10cSrcweir     enum ExtensionType { EXTENSION_ARRAY, EXTENSION_NLR, EXTENSION_MEMAREA };
40cdf0e10cSrcweir     typedef ::std::vector< ExtensionType >          ExtensionTypeVec;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	sal_Bool				bExternName;	// wenn External Name gefunden wurde
43cdf0e10cSrcweir 	static const sal_uInt16	nRowMask;
44cdf0e10cSrcweir 	static const sal_uInt16	nLastInd;		// letzter Index fuer Excel->SC-
45cdf0e10cSrcweir 										// Token Umsetzung
46cdf0e10cSrcweir     XclFunctionProvider maFuncProv;
47cdf0e10cSrcweir     const XclBiff       meBiff;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	// ---------------------------------------------------------------
50cdf0e10cSrcweir 	void				DoMulArgs( DefTokenId eId, sal_uInt8 nNumArgs, sal_uInt8 mnMinParamCount = 0 );
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	void				ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData&, const sal_Bool bName );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir                         ExcelToSc( const XclImpRoot& rRoot );
56cdf0e10cSrcweir 	virtual				~ExcelToSc();
57cdf0e10cSrcweir     virtual ConvErr     Convert( const ScTokenArray*&, XclImpStream& rStrm, sal_Size nFormulaLen,
58cdf0e10cSrcweir                                  bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     virtual ConvErr     Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, const FORMULA_TYPE eFT = FT_CellFormula );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     virtual ConvErr     ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
63cdf0e10cSrcweir                                            const String& rUrl, const ::std::vector<String>& rTabNames );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     virtual sal_Bool        GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	void				GetDummy( const ScTokenArray*& );
68cdf0e10cSrcweir     const ScTokenArray* GetBoolErr( XclBoolError );
69cdf0e10cSrcweir     sal_Bool                GetShrFmla( const ScTokenArray*&, XclImpStream& rStrm, sal_Size nFormulaLen );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #if 0
72cdf0e10cSrcweir                             // return = sal_True -> String-Record folgt!
73cdf0e10cSrcweir 	static sal_Bool			SetCurVal( ScFormulaCell& rCell, double& rCurVal );
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir 	static void			SetError( ScFormulaCell& rCell, const ConvErr eErr );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	static inline sal_Bool	IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 );
78cdf0e10cSrcweir 	static inline sal_Bool	IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	void				SetComplCol( ScComplexRefData& );
81cdf0e10cSrcweir 	void				SetComplRow( ScComplexRefData& );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     void                ReadExtensions( const ExtensionTypeVec& rExtensions,
84cdf0e10cSrcweir                                         XclImpStream& aIn );
85cdf0e10cSrcweir     void                ReadExtensionArray( unsigned int n,
86cdf0e10cSrcweir                                             XclImpStream& aIn );
87cdf0e10cSrcweir     void                ReadExtensionNlr( XclImpStream& aIn );
88cdf0e10cSrcweir     void                ReadExtensionMemArea( XclImpStream& aIn );
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
IsComplColRange(const sal_uInt16 nCol1,const sal_uInt16 nCol2)92cdf0e10cSrcweir inline sal_Bool ExcelToSc::IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	return ( nCol1 == 0x00 ) && ( nCol2 == 0xFF );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
IsComplRowRange(const sal_uInt16 nRow1,const sal_uInt16 nRow2)98cdf0e10cSrcweir inline sal_Bool ExcelToSc::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	return ( ( nRow1 & 0x3FFF ) == 0x0000 ) && ( ( nRow2 & 0x3FFF ) == 0x3FFF );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // ============================================================================
104cdf0e10cSrcweir 
105cdf0e10cSrcweir class XclImpLinkManager;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir class ExcelToSc8 : public ExcelToSc
108cdf0e10cSrcweir {
109cdf0e10cSrcweir public:
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     struct ExternalTabInfo
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         String      maTabName;
114cdf0e10cSrcweir         sal_uInt16  mnFileId;
115cdf0e10cSrcweir         bool        mbExternal;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         ExternalTabInfo();
118cdf0e10cSrcweir     };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir private:
121cdf0e10cSrcweir     const XclImpLinkManager&    rLinkMan;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     void                ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nCol, ScSingleRefData&,
124cdf0e10cSrcweir 							const sal_Bool bName );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     bool                GetExternalFileIdFromXti( sal_uInt16 nIxti, sal_uInt16& rFileId ) const;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     virtual bool        Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir public:
131cdf0e10cSrcweir                         ExcelToSc8( const XclImpRoot& rRoot );
132cdf0e10cSrcweir 	virtual				~ExcelToSc8();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual ConvErr     Convert( const ScTokenArray*& rpTokArray, XclImpStream& rStrm, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     virtual ConvErr     Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, const FORMULA_TYPE eFT = FT_CellFormula );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     virtual ConvErr     ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
139cdf0e10cSrcweir                                            const String& rUrl, const ::std::vector<String>& rTabNames );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	static inline sal_Bool	IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     virtual sal_Bool        GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen );
144cdf0e10cSrcweir };
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
IsComplRowRange(const sal_uInt16 nRow1,const sal_uInt16 nRow2)147cdf0e10cSrcweir inline sal_Bool ExcelToSc8::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	return ( nRow1 == 0x0000 ) && ( nRow2 == 0xFFFF );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir #endif
157