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