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