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