Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_EXCFORM_HXX
30 : : #define SC_EXCFORM_HXX
31 : :
32 : : #include "xlformula.hxx"
33 : : #include "xiroot.hxx"
34 : : #include "formel.hxx"
35 : :
36 : : #include <vector>
37 : :
38 : : class ScFormulaCell;
39 : : class ScRangeList;
40 : :
41 : :
42 : : class ExcelToSc : public ExcelConverterBase, protected XclImpRoot
43 : : {
44 : : protected:
45 : : enum ExtensionType { EXTENSION_ARRAY, EXTENSION_NLR, EXTENSION_MEMAREA };
46 : : typedef ::std::vector< ExtensionType > ExtensionTypeVec;
47 : :
48 : : sal_Bool bExternName; // wenn External Name gefunden wurde
49 : : static const sal_uInt16 nRowMask;
50 : : static const sal_uInt16 nLastInd; // letzter Index fuer Excel->SC-
51 : : // Token Umsetzung
52 : : XclFunctionProvider maFuncProv;
53 : : const XclBiff meBiff;
54 : :
55 : : // ---------------------------------------------------------------
56 : : void DoMulArgs( DefTokenId eId, sal_uInt8 nNumArgs );
57 : :
58 : : void ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData&, const sal_Bool bName );
59 : :
60 : : public:
61 : : ExcelToSc( const XclImpRoot& rRoot );
62 : : virtual ~ExcelToSc();
63 : : virtual ConvErr Convert( const ScTokenArray*&, XclImpStream& rStrm, sal_Size nFormulaLen,
64 : : bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula );
65 : :
66 : : virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula );
67 : :
68 : : virtual ConvErr ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
69 : : const String& rUrl, const ::std::vector<String>& rTabNames );
70 : :
71 : : virtual sal_Bool GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen );
72 : :
73 : : void GetDummy( const ScTokenArray*& );
74 : : const ScTokenArray* GetBoolErr( XclBoolError );
75 : : sal_Bool GetShrFmla( const ScTokenArray*&, XclImpStream& rStrm, sal_Size nFormulaLen );
76 : :
77 : : static void SetError( ScFormulaCell& rCell, const ConvErr eErr );
78 : :
79 : : static inline sal_Bool IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 );
80 : : static inline sal_Bool IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
81 : :
82 : : void SetComplCol( ScComplexRefData& );
83 : : void SetComplRow( ScComplexRefData& );
84 : :
85 : : void ReadExtensions( const ExtensionTypeVec& rExtensions,
86 : : XclImpStream& aIn );
87 : : void ReadExtensionArray( unsigned int n,
88 : : XclImpStream& aIn );
89 : : void ReadExtensionNlr( XclImpStream& aIn );
90 : : void ReadExtensionMemArea( XclImpStream& aIn );
91 : : };
92 : :
93 : :
94 : 5157 : inline sal_Bool ExcelToSc::IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 )
95 : : {
96 [ + + ][ - + ]: 5157 : return ( nCol1 == 0x00 ) && ( nCol2 == 0xFF );
97 : : }
98 : :
99 : :
100 : 0 : inline sal_Bool ExcelToSc::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
101 : : {
102 [ # # ][ # # ]: 0 : return ( ( nRow1 & 0x3FFF ) == 0x0000 ) && ( ( nRow2 & 0x3FFF ) == 0x3FFF );
103 : : }
104 : :
105 : : // ============================================================================
106 : :
107 : : class XclImpLinkManager;
108 : : class XclImpExtName;
109 : :
110 : : class ExcelToSc8 : public ExcelToSc
111 : : {
112 : : public:
113 : :
114 : 2763 : struct ExternalTabInfo
115 : : {
116 : : ScRange maRange;
117 : : ::rtl::OUString maTabName;
118 : : sal_uInt16 mnFileId;
119 : : bool mbExternal;
120 : :
121 : : ExternalTabInfo();
122 : : };
123 : :
124 : : private:
125 : : const XclImpLinkManager& rLinkMan;
126 : :
127 : : void ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nCol, ScSingleRefData&,
128 : : const sal_Bool bName );
129 : :
130 : : bool GetExternalFileIdFromXti( sal_uInt16 nIxti, sal_uInt16& rFileId ) const;
131 : :
132 : : virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
133 : :
134 : : bool HandleOleLink(sal_uInt16 nXtiIndex, const XclImpExtName& rExtName, ExternalTabInfo& rExtInfo);
135 : : public:
136 : : ExcelToSc8( const XclImpRoot& rRoot );
137 : : virtual ~ExcelToSc8();
138 : :
139 : : virtual ConvErr Convert( const ScTokenArray*& rpTokArray, XclImpStream& rStrm, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula );
140 : :
141 : : virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula );
142 : :
143 : : virtual ConvErr ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
144 : : const String& rUrl, const ::std::vector<String>& rTabNames );
145 : :
146 : : static inline sal_Bool IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
147 : :
148 : : virtual sal_Bool GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, sal_Size nLen );
149 : : };
150 : :
151 : :
152 : 5157 : inline sal_Bool ExcelToSc8::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
153 : : {
154 [ + + ][ - + ]: 5157 : return ( nRow1 == 0x0000 ) && ( nRow2 == 0xFFFF );
155 : : }
156 : :
157 : :
158 : :
159 : :
160 : :
161 : : #endif
162 : :
163 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|