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 SC_IMP_OP_HXX
21 : #define SC_IMP_OP_HXX
22 :
23 : #include <sal/types.h>
24 : #include "xiroot.hxx"
25 : #include "xistream.hxx"
26 : #include "xistyle.hxx"
27 : #include "flttypes.hxx"
28 : #include "namebuff.hxx"
29 : #include "root.hxx"
30 : #include "otlnbuff.hxx"
31 : #include "colrowst.hxx"
32 : #include "excdefs.hxx"
33 : #include "rtl/ref.hxx"
34 :
35 : #include <boost/shared_ptr.hpp>
36 : #include <boost/ptr_container/ptr_vector.hpp>
37 : #include <boost/unordered_map.hpp>
38 :
39 : class SvStream;
40 :
41 : class ScFormulaCell;
42 : class ScDocument;
43 :
44 : class ExcelToSc;
45 :
46 :
47 : class ImportTyp
48 : {
49 : protected:
50 : rtl_TextEncoding eQuellChar; // Quell-Zeichensatz
51 : ScDocument* pD; // Dokument
52 :
53 : public:
54 : ImportTyp( ScDocument*, rtl_TextEncoding eSrc );
55 : virtual ~ImportTyp();
56 :
57 : virtual FltError Read( void );
58 : };
59 :
60 : class XclImpOutlineDataBuffer : protected XclImpRoot
61 : {
62 : public:
63 : explicit XclImpOutlineDataBuffer( const XclImpRoot& rRoot, SCTAB nScTab );
64 : virtual ~XclImpOutlineDataBuffer();
65 :
66 0 : inline XclImpColRowSettings* GetColRowBuff() const { return mxColRowBuff.get(); }
67 0 : inline XclImpOutlineBuffer* GetColOutline() const { return mxColOutlineBuff.get(); }
68 0 : inline XclImpOutlineBuffer* GetRowOutline() const { return mxRowOutlineBuff.get(); }
69 : void Convert();
70 :
71 : private:
72 : typedef boost::shared_ptr< XclImpOutlineBuffer > XclImpOutlineBfrRef;
73 : typedef boost::shared_ptr< XclImpColRowSettings > XclImpColRowSettRef;
74 :
75 : XclImpOutlineBfrRef mxColOutlineBuff;
76 : XclImpOutlineBfrRef mxRowOutlineBuff;
77 : XclImpColRowSettRef mxColRowBuff;
78 : SCTAB mnScTab;
79 : };
80 :
81 : class ImportExcel : public ImportTyp, protected XclImpRoot
82 : {
83 : protected:
84 : struct LastFormula
85 : {
86 : SCCOL mnCol;
87 : SCROW mnRow;
88 : double mfValue;
89 : sal_uInt16 mnXF;
90 : ScFormulaCell* mpCell;
91 : };
92 : typedef boost::unordered_map<SCCOL, LastFormula> LastFormulaMapType;
93 :
94 : static const double fExcToTwips; // Umrechnung 1/256 Zeichen -> Twips
95 :
96 : RootData* pExcRoot;
97 :
98 : XclImpStream maStrm; // input stream
99 : XclImpStream& aIn; // input stream
100 :
101 : ScfUInt32Vec maSheetOffsets;
102 : ScRange maScOleSize; /// Visible range if embedded.
103 :
104 : NameBuffer* pExtNameBuff; // ... externe Namen (Ind.-Basis=1)
105 : ExcelToSc* pFormConv; // Formel-Konverter
106 :
107 : XclImpOutlineBuffer* pColOutlineBuff;
108 : XclImpOutlineBuffer* pRowOutlineBuff;
109 : XclImpColRowSettings* pColRowBuff; // Col/Row-Einstellungen 1 Tabelle
110 :
111 : typedef boost::ptr_vector< XclImpOutlineDataBuffer > XclImpOutlineListBuffer;
112 : XclImpOutlineListBuffer* pOutlineListBuffer;
113 :
114 : LastFormulaMapType maLastFormulaCells; // Keep track of last formula cells in each column.
115 : LastFormula* mpLastFormula;
116 :
117 : sal_Int16 mnLastRefIdx;
118 : sal_uInt16 mnIxfeIndex; /// Current XF identifier from IXFE record.
119 : sal_uInt16 mnLastRecId;
120 :
121 : SCTAB nBdshtTab; // Counter fuer Boundsheet
122 :
123 : bool bTabTruncated; // wenn Bereichsueberschreitung zum
124 : // Abschneiden von Zellen fuehrt
125 :
126 : bool mbBiff2HasXfs:1; /// Select XF formatting or direct formatting in BIFF2.
127 : bool mbBiff2HasXfsValid:1; /// False = mbBiff2HasXfs is undetermined yet.
128 :
129 : void SetLastFormula( SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell* pCell );
130 :
131 : // Record-Funktionen
132 : void ReadFileSharing();
133 :
134 : sal_uInt16 ReadXFIndex( const ScAddress& rScPos, bool bBiff2 );
135 :
136 : void ReadDimensions();
137 : void ReadBlank();
138 : void ReadInteger();
139 : void ReadNumber();
140 : void ReadLabel();
141 : void ReadBoolErr();
142 : void ReadRk();
143 :
144 : void Window1();
145 : void Formula25( void ); // 0x06 -> excform.cxx
146 : void Row25( void ); // 0x08
147 : void Bof2( void ); // 0x09
148 : void Eof( void ); // 0x0A
149 : void DocProtect( void ); // 0x12
150 : void SheetProtect( void ); // 0x12 Sheet Protection
151 : void DocPasssword( void ); // 0x13 document password
152 : void SheetPassword( void ); // 0x13 sheet password
153 : void Externsheet( void ); // 0x17
154 : void WinProtection( void ); // 0x19
155 : void Columndefault( void ); // 0x20
156 : void Array25( void ); // 0x21
157 : void Rec1904( void ); // 0x22
158 : void Externname25( void ); // 0x23
159 : void Colwidth( void ); // 0x24
160 : void Defrowheight2( void ); // 0x25
161 : // void Window1( void ); // 0x3D
162 : void Codepage( void ); // 0x42
163 : void Ixfe( void ); // 0x44
164 : void DefColWidth( void ); // 0x55
165 : void Builtinfmtcnt( void ); // 0x56
166 : void Colinfo( void ); // 0x7D
167 : void Wsbool( void ); // 0x81
168 : void Boundsheet( void ); // 0x85
169 : void Country( void ); // 0x8C
170 : void Hideobj( void ); // 0x8D
171 : void Bundleheader( void ); // 0x8F
172 : void Standardwidth( void ); // 0x99
173 : void Shrfmla( void ); // 0xBC
174 : void Mulrk( void ); // 0xBD
175 : void Mulblank( void ); // 0xBE
176 : void Rstring( void ); // 0xD6
177 : void Cellmerging( void ); // 0xE5
178 : void Olesize( void ); // 0xDE
179 : void ReadUsesElfs(); // 0x0160
180 : void Formula3( void ); // 0x0206 -> excform.cxx
181 : // 0x0207 -> 0x07
182 : void Row34( void ); // 0x0208
183 : void Bof3( void ); // 0x0209
184 : void Array34( void ); // 0x0221
185 : void Externname34( void ); // 0x0223
186 : void Defrowheight345( void ); // 0x0225
187 : void TableOp( void ); // 0x0236
188 : //void Rk( void ); // 0x027E -> 0x7E
189 : void Formula4( void ); // 0x0406 -> excform.cxx
190 : void Bof4( void ); // 0x0409
191 : void Bof5( void ); // 0x0809
192 :
193 :
194 : void Formula(
195 : const XclAddress& rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla);
196 : // -> excform.cxx
197 :
198 : virtual void EndSheet( void );
199 : void NewTable( void );
200 : const ScTokenArray* ErrorToFormula( sal_uInt8 bErrOrVal, sal_uInt8 nError,
201 : double& rVal );
202 :
203 : virtual void AdjustRowHeight();
204 : virtual void PostDocLoad( void );
205 :
206 : public:
207 : ImportExcel( XclImpRootData& rImpData, SvStream& rStrm );
208 :
209 : virtual ~ImportExcel( void );
210 :
211 : virtual FltError Read( void ) SAL_OVERRIDE;
212 : };
213 :
214 : #endif
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|