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_LOTFORM_HXX
25 #define SC_LOTFORM_HXX
26
27 #include "formel.hxx"
28 #include <tools/string.hxx>
29
30
31
32
33 enum FUNC_TYPE
34 {
35 FT_Return = 0, // End Formula
36 FT_FuncFix0, // Funktion, 0 Parameter
37 FT_FuncFix1, // Funktion, 0 Parameter
38 FT_FuncFix2, // Funktion, 0 Parameter
39 FT_FuncFix3, // Funktion, 0 Parameter
40 FT_FuncFix4, // Funktion, 0 Parameter
41 FT_FuncVar, // ~, var. P.
42 FT_Neg, // Negierung
43 FT_Op, // Operator
44 FT_NotImpl, // nicht implementiert
45 FT_ConstFloat, // Double (8-Byte)
46 FT_Variable, // Single Ref
47 FT_Range, // Double Ref
48 FT_Braces, // Klammmern
49 FT_ConstInt, // Integer
50 FT_ConstString, // String
51 FT_NOP, // nichts
52 // zusaetzlich ab WK3
53 FT_Cref, // Cell Reference
54 FT_Rref, // Range Reference
55 FT_Nrref, // Named range reference
56 FT_Absnref, // Absolut named range
57 FT_Erref, // Err range reference
58 FT_Ecref, // Err cell reference
59 FT_Econstant, // Err constant
60 FT_Splfunc, // SPLfunction
61 FT_Const10Float,// Float (10-Byte)
62 FT_Snum // Const Short Num
63 // fuer 'Problemfaelle' beim Import
64 };
65
66
67
68
69 class LotusToSc : public LotusConverterBase
70 {
71 private:
72 CharSet eSrcChar;
73 TokenId nAddToken; // ')+1.0'
74 TokenId nSubToken; // ~
75 TokenId n0Token; // '0.0';
76 // ---------------------------------------------------------------
77 static FUNC_TYPE IndexToType( sal_uInt8 );
78 static DefTokenId IndexToToken( sal_uInt8 );
79 static FUNC_TYPE IndexToTypeWK123( sal_uInt8 );
80 static DefTokenId IndexToTokenWK123( sal_uInt8 );
81 void DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtName );
82 void LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow,
83 ScSingleRefData& rSRD );
84 sal_Bool bWK3; // alternative Codeumsetzung statt fuer < WK1
85 sal_Bool bWK123; // alternative for 123
86 // -------------------------------------------------------------------
87 void ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nFlags );
88 inline void ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nFlags );
89 void IncToken( TokenId &rParam );
90 // ACHTUNG: hier wird die aktuelle Token-Kette im Pool
91 // mit '(<rParam>)+1' fortgeschrieben und mit
92 // Store() abgeschlossen!
93 void DecToken( TokenId& rParam );
94 // ACHTUNG: ~
95 void NegToken( TokenId& rParam );
96 // ACHTUNG: wie ~, nur wird '-(<rParam>)' gebildet
97 public:
98 LotusToSc( SvStream& aStr, CharSet eSrc, sal_Bool b );
99 virtual ConvErr Convert( const ScTokenArray*& rpErg, sal_Int32& nRest,
100 const FORMULA_TYPE eFT = FT_CellFormula );
101
102 void Reset( const ScAddress& rEingPos );
103 inline void SetWK3( void );
104
105 private:
106 using LotusConverterBase::Reset;
107 };
108
109
ReadCRD(ScComplexRefData & rCRD,sal_uInt8 nRelBit)110 inline void LotusToSc::ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nRelBit )
111 {
112 // erster Teil
113 ReadSRD( rCRD.Ref1, nRelBit );
114
115 // zweiter Teil
116 ReadSRD( rCRD.Ref2, nRelBit >> 3 );
117 }
118
119
SetWK3(void)120 inline void LotusToSc::SetWK3( void )
121 {
122 bWK3 = sal_True;
123 }
124
125
126
127 #endif
128
129