LibreOffice Module sc (master)  1
imp_op.hxx
Go to the documentation of this file.
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 "ftools.hxx"
27 
28 #include <vector>
29 #include <memory>
30 #include <unordered_map>
31 
32 class SvStream;
33 
34 class ScFormulaCell;
35 class ScDocument;
36 class ScTokenArray;
37 
38 class ExcelToSc;
41 struct XclAddress;
42 
43 class ImportTyp
44 {
45 protected:
46  rtl_TextEncoding eQuellChar; // source (Quelle) character set
47  ScDocument& rD; // document
48 
49 public:
50  ImportTyp( ScDocument&, rtl_TextEncoding eSrc );
51  virtual ~ImportTyp();
52 };
53 
55 {
56 public:
57  explicit XclImpOutlineDataBuffer( const XclImpRoot& rRoot, SCTAB nScTab );
58  virtual ~XclImpOutlineDataBuffer() override;
59 
60  XclImpColRowSettings* GetColRowBuff() const { return mxColRowBuff.get(); }
63  void Convert();
64 
65 private:
66  typedef std::shared_ptr< XclImpOutlineBuffer > XclImpOutlineBfrRef;
67  typedef std::shared_ptr< XclImpColRowSettings > XclImpColRowSettRef;
68 
69  XclImpOutlineBfrRef mxColOutlineBuff;
70  XclImpOutlineBfrRef mxRowOutlineBuff;
71  XclImpColRowSettRef mxColRowBuff;
73 };
74 
75 class ImportExcel : public ImportTyp, protected XclImpRoot
76 {
77 protected:
78  struct LastFormula
79  {
80  sal_uInt16 mnXF;
83  double mfValue;
85  };
86  typedef std::unordered_map<SCCOL, LastFormula> LastFormulaMapType;
87 
89 
90  XclImpStream maStrm; // input stream
91  XclImpStream& aIn; // input stream
92 
95 
96  std::unique_ptr<ExcelToSc> pFormConv; // formula-converter
97 
100  XclImpColRowSettings* pColRowBuff; // Col/Row settings 1 table
101 
102  typedef std::vector< std::unique_ptr<XclImpOutlineDataBuffer> > XclImpOutlineListBuffer;
103  std::unique_ptr<XclImpOutlineListBuffer> pOutlineListBuffer;
104 
105  LastFormulaMapType maLastFormulaCells; // Keep track of last formula cells in each column.
107 
108  sal_Int16 mnLastRefIdx;
109  sal_uInt16 mnIxfeIndex;
110  sal_uInt16 mnLastRecId;
111 
112  SCTAB nBdshtTab; // Counter for Boundsheet
113 
114  bool bTabTruncated; // if extended range leads to
115  // truncation of cells
116 
117  bool mbBiff2HasXfs:1;
119 
120  void SetLastFormula( SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell* pCell );
121 
122  // Record functions
123  void ReadFileSharing();
124 
125  sal_uInt16 ReadXFIndex( const ScAddress& rScPos, bool bBiff2 );
126 
127  void ReadDimensions();
128  void ReadBlank();
129  void ReadInteger();
130  void ReadNumber();
131  void ReadLabel();
132  void ReadBoolErr();
133  void ReadRk();
134 
135  void Window1();
136  void Formula25(); // 0x06 -> excform.cxx
137  void Row25(); // 0x08
138  void Bof2(); // 0x09
139  void Eof(); // 0x0A
140  void DocProtect(); // 0x12
141  void SheetProtect(); // 0x12 Sheet Protection
142  void DocPassword(); // 0x13 document password
143  void SheetPassword(); // 0x13 sheet password
144  void Externsheet(); // 0x17
145  void WinProtection(); // 0x19
146  void Columndefault(); // 0x20
147  void Array25(); // 0x21
148  void Rec1904(); // 0x22
149  void Externname25(); // 0x23
150  void Colwidth(); // 0x24
151  void Defrowheight2(); // 0x25
152 // void Window1(); // 0x3D
153  void Codepage(); // 0x42
154  void Ixfe(); // 0x44
155  void DefColWidth(); // 0x55
156  void Colinfo(); // 0x7D
157  void Wsbool(); // 0x81
158  void Boundsheet(); // 0x85
159  void Country(); // 0x8C
160  void Hideobj(); // 0x8D
161  void Standardwidth(); // 0x99
162  void Shrfmla(); // 0xBC
163  void Mulrk(); // 0xBD
164  void Mulblank(); // 0xBE
165  void Rstring(); // 0xD6
166  void Cellmerging(); // 0xE5
167  void Olesize(); // 0xDE
168  void ReadUsesElfs(); // 0x0160
169  void Formula3(); // 0x0206 -> excform.cxx
170  // 0x0207 -> 0x07
171  void Row34(); // 0x0208
172  void Bof3(); // 0x0209
173  void Array34(); // 0x0221
174  void Defrowheight345(); // 0x0225
175  void TableOp(); // 0x0236
176  //void Rk(); // 0x027E -> 0x7E
177  void Formula4(); // 0x0406 -> excform.cxx
178  void Bof4(); // 0x0409
179  void Bof5(); // 0x0809
180 
181  void Formula(
182  const XclAddress& rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla);
183  // -> excform.cxx
184 
185  virtual void EndSheet();
186  void NewTable();
187  std::unique_ptr<ScTokenArray> ErrorToFormula( bool bErrOrVal, sal_uInt8 nError,
188  double& rVal );
189 
190  void AdjustRowHeight();
191  virtual void PostDocLoad();
192 
193 public:
194  ImportExcel( XclImpRootData& rImpData, SvStream& rStrm );
195 
196  virtual ~ImportExcel() override;
197 
198  virtual ErrCode Read();
199 };
200 
201 #endif
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RootData * pExcRoot
Definition: imp_op.hxx:88
void AdjustRowHeight()
Definition: impop.cxx:1222
XclImpColRowSettings * GetColRowBuff() const
Definition: imp_op.hxx:60
virtual ~ImportExcel() override
Definition: impop.cxx:132
void SheetProtect()
Definition: impop.cxx:601
XclImpStream maStrm
Definition: imp_op.hxx:90
void ReadUsesElfs()
Definition: impop.cxx:745
void Columndefault()
Definition: impop.cxx:471
Stores global buffers and data needed for Excel import filter.
Definition: xiroot.hxx:64
void Externsheet()
Definition: impop.cxx:454
std::unique_ptr< ScTokenArray > ErrorToFormula(bool bErrOrVal, sal_uInt8 nError, double &rVal)
Definition: impop.cxx:1217
void Row34()
Definition: impop.cxx:948
XclImpOutlineBuffer * GetRowOutline() const
Definition: imp_op.hxx:62
void DocPassword()
Definition: impop.cxx:617
std::vector< std::unique_ptr< XclImpOutlineDataBuffer > > XclImpOutlineListBuffer
Definition: imp_op.hxx:102
void Standardwidth()
Definition: impop.cxx:790
void Country()
Definition: impop.cxx:728
void Bof2()
Definition: impop.cxx:424
void Boundsheet()
Definition: impop.cxx:695
void Colwidth()
Definition: impop.cxx:576
void Row25()
Definition: impop.cxx:394
std::shared_ptr< XclImpOutlineBuffer > XclImpOutlineBfrRef
Definition: imp_op.hxx:66
LastFormula * mpLastFormula
Definition: imp_op.hxx:106
void Formula25()
Definition: excform.cxx:43
void Defrowheight2()
Definition: impop.cxx:593
void Formula3()
Definition: excform.cxx:77
void Ixfe()
Definition: impop.cxx:630
SCTAB nBdshtTab
Definition: imp_op.hxx:112
ScfUInt32Vec maSheetOffsets
Definition: imp_op.hxx:93
XclImpColRowSettings * pColRowBuff
Definition: imp_op.hxx:100
void Olesize()
Definition: impop.cxx:938
void ReadNumber()
Definition: impop.cxx:297
void DocProtect()
Definition: impop.cxx:609
void Externname25()
Definition: impop.cxx:552
virtual ~ImportTyp()
Definition: impop.cxx:80
void Array25()
Definition: impop.cxx:497
void ReadFileSharing()
Definition: impop.cxx:160
XclImpOutlineBfrRef mxRowOutlineBuff
Definition: imp_op.hxx:70
XclImpOutlineBuffer * pColOutlineBuff
Definition: imp_op.hxx:98
ScDocument & rD
Definition: imp_op.hxx:47
void Rec1904()
Definition: impop.cxx:537
void Bof3()
Definition: impop.cxx:978
rtl_TextEncoding eQuellChar
Definition: imp_op.hxx:46
virtual void PostDocLoad()
Definition: impop.cxx:1232
ImportExcel(XclImpRootData &rImpData, SvStream &rStrm)
Definition: impop.cxx:84
virtual ~XclImpOutlineDataBuffer() override
Definition: impop.cxx:1357
void ReadLabel()
Definition: impop.cxx:314
void TableOp()
Definition: impop.cxx:1044
bool mbBiff2HasXfs
Definition: imp_op.hxx:117
ScFormulaCell * mpCell
Definition: imp_op.hxx:84
void Window1()
Definition: impop.cxx:389
void Shrfmla()
Definition: impop.cxx:801
void Mulblank()
Definition: impop.cxx:881
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
Definition: imp_op.hxx:96
void Bof5()
Definition: impop.cxx:1149
virtual ErrCode Read()
Definition: read.cxx:70
sal_Int16 SCCOL
Definition: types.hxx:22
std::shared_ptr< XclImpColRowSettings > XclImpColRowSettRef
Definition: imp_op.hxx:67
void Eof()
Definition: impop.cxx:439
bool bTabTruncated
Definition: imp_op.hxx:114
void Hideobj()
Definition: impop.cxx:755
XclImpOutlineBfrRef mxColOutlineBuff
Definition: imp_op.hxx:69
void Rstring()
Definition: impop.cxx:898
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
void Defrowheight345()
Definition: impop.cxx:1029
sal_uInt16 ReadXFIndex(const ScAddress &rScPos, bool bBiff2)
Definition: impop.cxx:181
void ReadBlank()
Definition: impop.cxx:266
void NewTable()
Definition: impop.cxx:1190
std::unique_ptr< XclImpOutlineListBuffer > pOutlineListBuffer
Definition: imp_op.hxx:103
sal_Int32 SCROW
Definition: types.hxx:18
::std::vector< sal_uInt32 > ScfUInt32Vec
Definition: ftools.hxx:256
void Cellmerging()
Definition: impop.cxx:921
ScRange maScOleSize
Definition: imp_op.hxx:94
void Formula4()
Definition: excform.cxx:82
void WinProtection()
Definition: impop.cxx:463
unsigned char sal_uInt8
void Mulrk()
Definition: impop.cxx:859
XclImpColRowSettRef mxColRowBuff
Definition: imp_op.hxx:71
void Array34()
Definition: impop.cxx:996
XclImpOutlineBuffer * pRowOutlineBuff
Definition: imp_op.hxx:99
sal_Int16 mnLastRefIdx
Definition: imp_op.hxx:108
XclImpOutlineBuffer * GetColOutline() const
Definition: imp_op.hxx:61
void Colinfo()
Definition: impop.cxx:654
void SetLastFormula(SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell *pCell)
False = mbBiff2HasXfs is undetermined yet.
Definition: impop.cxx:141
void Formula(const XclAddress &rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
Definition: excform.cxx:95
void Bof4()
Definition: impop.cxx:1132
void ReadInteger()
Definition: impop.cxx:280
void Codepage()
Definition: impop.cxx:625
virtual void EndSheet()
Definition: impop.cxx:1177
void SheetPassword()
Definition: impop.cxx:446
void Wsbool()
Definition: impop.cxx:684
This class is used to import record oriented streams.
Definition: xistream.hxx:278
sal_uInt16 mnLastRecId
Current XF identifier from IXFE record.
Definition: imp_op.hxx:110
XclImpStream & aIn
Definition: imp_op.hxx:91
std::unordered_map< SCCOL, LastFormula > LastFormulaMapType
Definition: imp_op.hxx:86
bool mbBiff2HasXfsValid
Select XF formatting or direct formatting in BIFF2.
Definition: imp_op.hxx:118
Access to global data from other classes.
Definition: xiroot.hxx:126
void ReadBoolErr()
Definition: impop.cxx:344
sal_uInt16 mnIxfeIndex
Definition: imp_op.hxx:109
void ReadDimensions()
Definition: impop.cxx:223
sal_Int16 SCTAB
Definition: types.hxx:23
void DefColWidth()
Definition: impop.cxx:635
void ReadRk()
Definition: impop.cxx:372
LastFormulaMapType maLastFormulaCells
Definition: imp_op.hxx:105
XclImpOutlineDataBuffer(const XclImpRoot &rRoot, SCTAB nScTab)
Definition: impop.cxx:1348
ImportTyp(ScDocument &, rtl_TextEncoding eSrc)
Definition: impop.cxx:73