Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_LOTFORM_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_INC_LOTFORM_HXX
22 :
23 : #include "formel.hxx"
24 : #include <rtl/ustring.hxx>
25 :
26 : enum FUNC_TYPE
27 : {
28 : FT_Return = 0, // End Formula
29 : FT_FuncFix0, // Function, 0 Parameter
30 : FT_FuncFix1, // Function, 0 Parameter
31 : FT_FuncFix2, // Function, 0 Parameter
32 : FT_FuncFix3, // Function, 0 Parameter
33 : FT_FuncFix4, // Function, 0 Parameter
34 : FT_FuncVar, // ~, var. P.
35 : FT_Neg, // Negation
36 : FT_Op, // Operator
37 : FT_NotImpl, // not implemented
38 : FT_ConstFloat, // Double (8-Byte)
39 : FT_Variable, // Single Ref
40 : FT_Range, // Double Ref
41 : FT_Braces, // Braces
42 : FT_ConstInt, // Integer
43 : FT_ConstString, // String
44 : FT_NOP, // nothing
45 : // additionally since WK3
46 : FT_Cref, // Cell Reference
47 : FT_Rref, // Range Reference
48 : FT_Nrref, // Named range reference
49 : FT_Absnref, // Absolute named range
50 : FT_Erref, // Err range reference
51 : FT_Ecref, // Err cell reference
52 : FT_Econstant, // Err constant
53 : FT_Splfunc, // SPLfunction
54 : FT_Const10Float,// Float (10-Byte)
55 : FT_Snum // Const Short Num
56 : // for 'Problem Cases' during Import
57 : };
58 :
59 : struct LotusContext;
60 :
61 170 : class LotusToSc : public LotusConverterBase
62 : {
63 : private:
64 : LotusContext& m_rContext;
65 : rtl_TextEncoding eSrcChar;
66 : TokenId nAddToken; // ')+1.0'
67 : TokenId nSubToken; // ~
68 : TokenId n0Token; // '0.0';
69 :
70 : static FUNC_TYPE IndexToType( sal_uInt8 );
71 : static DefTokenId IndexToToken( sal_uInt8 );
72 : static FUNC_TYPE IndexToTypeWK123( sal_uInt8 );
73 : static DefTokenId IndexToTokenWK123( sal_uInt8 );
74 : void DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtName );
75 : void LotusRelToScRel(sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefData& rSRD);
76 : bool bWK3; // alternative Code translation for < WK1
77 : bool bWK123; // alternative for 123
78 :
79 : void ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nFlags );
80 : inline void ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nFlags );
81 : void IncToken( TokenId &rParam );
82 : // Attention: here the Token-chain is extended in Pool
83 : // with '(<rParam>)+1' and finished with Store() !
84 :
85 : void DecToken( TokenId& rParam );
86 : // Attention: ~
87 : void NegToken( TokenId& rParam );
88 : // Attention: like ~, but with '-(<rParam>)'
89 : public:
90 : LotusToSc(LotusContext &rContext, SvStream& aStr, svl::SharedStringPool& rSPool, rtl_TextEncoding eSrc, bool b);
91 :
92 : virtual ConvErr Convert( const ScTokenArray*& rpErg, sal_Int32& nRest,
93 : const FORMULA_TYPE eFT = FT_CellFormula ) SAL_OVERRIDE;
94 :
95 : void Reset( const ScAddress& rEingPos );
96 : inline void SetWK3();
97 4 : LotusContext& getContext() { return m_rContext; }
98 :
99 : private:
100 : using LotusConverterBase::Reset;
101 : };
102 :
103 0 : inline void LotusToSc::ReadCRD( ScComplexRefData& rCRD, sal_uInt8 nRelBit )
104 : {
105 : // 1st part
106 0 : ReadSRD( rCRD.Ref1, nRelBit );
107 :
108 : // 2nd part
109 0 : ReadSRD( rCRD.Ref2, nRelBit >> 3 );
110 0 : }
111 :
112 0 : inline void LotusToSc::SetWK3()
113 : {
114 0 : bWK3 = true;
115 0 : }
116 :
117 : #endif
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|