LibreOffice Module sc (master)  1
excform.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 "xlformula.hxx"
23 #include "xiroot.hxx"
24 #include "xltools.hxx"
25 #include "formel.hxx"
26 
27 #include <vector>
28 
29 class ScFormulaCell;
30 class ScRangeList;
31 
32 class ExcelToSc : public ExcelConverterBase, protected XclImpRoot
33 {
34 protected:
36  typedef ::std::vector< ExtensionType > ExtensionTypeVec;
37 
38  static const sal_uInt16 nRowMask;
39 
41  const XclBiff meBiff;
42 
43  void DoMulArgs( DefTokenId eId, sal_uInt8 nNumArgs );
44 
45  void ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData&, const bool bName );
46 
47 public:
48  ExcelToSc( XclImpRoot& rRoot );
49  virtual ~ExcelToSc() override;
50  virtual ConvErr Convert( std::unique_ptr<ScTokenArray>&, XclImpStream& rStrm, std::size_t nFormulaLen,
51  bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ) override;
52 
53  virtual ConvErr Convert( ScRangeListTabs&, XclImpStream& rStrm, std::size_t nFormulaLen, SCTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula ) override;
54 
55  virtual void ConvertExternName( std::unique_ptr<ScTokenArray>& rpArray, XclImpStream& rStrm, std::size_t nFormulaLen,
56  const OUString& rUrl, const ::std::vector<OUString>& rTabNames );
57 
58  virtual void GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, std::size_t nLen );
59 
60  std::unique_ptr<ScTokenArray> GetDummy();
61  std::unique_ptr<ScTokenArray> GetBoolErr( XclBoolError );
62 
63  static bool ReadSharedFormulaPosition( XclImpStream& rStrm, SCCOL& rCol, SCROW& rRow );
64  const ScTokenArray* GetSharedFormula( const ScAddress& rRefPos ) const;
65 
66  static void SetError( ScFormulaCell& rCell, const ConvErr eErr );
67 
68  static inline bool IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 );
69  static inline bool IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
70 
73 
74  void ReadExtensions( const ExtensionTypeVec& rExtensions,
75  XclImpStream& aIn );
76  void ReadExtensionArray( unsigned int n,
77  XclImpStream& aIn );
78  static void ReadExtensionNlr( XclImpStream& aIn );
80 };
81 
82 inline bool ExcelToSc::IsComplColRange( const sal_uInt16 nCol1, const sal_uInt16 nCol2 )
83 {
84  return ( nCol1 == 0x00 ) && ( nCol2 == 0xFF );
85 }
86 
87 inline bool ExcelToSc::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
88 {
89  return ( ( nRow1 & 0x3FFF ) == 0x0000 ) && ( ( nRow2 & 0x3FFF ) == 0x3FFF );
90 }
91 
92 class XclImpLinkManager;
93 class XclImpExtName;
94 
95 class ExcelToSc8 : public ExcelToSc
96 {
97 public:
98 
100  {
102  OUString maTabName;
103  sal_uInt16 mnFileId;
105 
106  ExternalTabInfo();
107  };
108 
109 private:
111 
112  void ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nCol, ScSingleRefData&,
113  const bool bName );
114 
115  bool GetExternalFileIdFromXti( sal_uInt16 nIxti, sal_uInt16& rFileId ) const;
116 
117  virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
118 
119  bool HandleOleLink(sal_uInt16 nXtiIndex, const XclImpExtName& rExtName, ExternalTabInfo& rExtInfo);
120 public:
121  ExcelToSc8( XclImpRoot& rRoot );
122  virtual ~ExcelToSc8() override;
123 
124  virtual ConvErr Convert( std::unique_ptr<ScTokenArray>& rpTokArray, XclImpStream& rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ) override;
125 
126  virtual ConvErr Convert( ScRangeListTabs&, XclImpStream& rStrm, std::size_t nFormulaLen, SCTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula ) override;
127 
128  virtual void ConvertExternName( std::unique_ptr<ScTokenArray>& rpArray, XclImpStream& rStrm, std::size_t nFormulaLen,
129  const OUString& rUrl, const ::std::vector<OUString>& rTabNames ) override;
130 
131  static inline bool IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 );
132 
133  virtual void GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, std::size_t nLen ) override;
134 };
135 
136 inline bool ExcelToSc8::IsComplRowRange( const sal_uInt16 nRow1, const sal_uInt16 nRow2 )
137 {
138  return ( nRow1 == 0x0000 ) && ( nRow2 == 0xFFFF );
139 }
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ConvertExternName(std::unique_ptr< ScTokenArray > &rpArray, XclImpStream &rStrm, std::size_t nFormulaLen, const OUString &rUrl, const ::std::vector< OUString > &rTabNames) override
Definition: excform8.cxx:1286
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:29
bool GetExternalFileIdFromXti(sal_uInt16 nIxti, sal_uInt16 &rFileId) const
Definition: excform8.cxx:92
void ExcRelToScRel(sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &, const bool bName)
Definition: excform.cxx:1612
static void SetError(ScFormulaCell &rCell, const ConvErr eErr)
Definition: excform.cxx:1731
ConvErr
Definition: formel.hxx:39
Single reference (one address) into the sheet.
Definition: refdata.hxx:29
XclBoolError
An enumeration for all Excel error codes and the values true and false.
Definition: xltools.hxx:39
virtual ~ExcelToSc8() override
Definition: excform8.cxx:88
static bool IsComplRowRange(const sal_uInt16 nRow1, const sal_uInt16 nRow2)
Definition: excform.hxx:87
static bool IsComplColRange(const sal_uInt16 nCol1, const sal_uInt16 nCol2)
Definition: excform.hxx:82
::std::vector< ExtensionType > ExtensionTypeVec
Definition: excform.hxx:36
virtual ~ExcelToSc() override
Definition: excform.cxx:192
static bool IsComplRowRange(const sal_uInt16 nRow1, const sal_uInt16 nRow2)
Definition: excform.hxx:136
const XclBiff meBiff
Definition: excform.hxx:41
void SetComplCol(ScComplexRefData &)
Definition: excform.cxx:1745
virtual bool Read3DTabReference(sal_uInt16 nIxti, SCTAB &rFirstTab, SCTAB &rLastTab, ExternalTabInfo &rExtInfo)
Definition: excform8.cxx:105
static void ReadExtensionNlr(XclImpStream &aIn)
Definition: excform.cxx:1876
OpCode
ExcelToSc(XclImpRoot &rRoot)
Definition: excform.cxx:184
virtual void ConvertExternName(std::unique_ptr< ScTokenArray > &rpArray, XclImpStream &rStrm, std::size_t nFormulaLen, const OUString &rUrl, const ::std::vector< OUString > &rTabNames)
Definition: excform.cxx:1312
static bool ReadSharedFormulaPosition(XclImpStream &rStrm, SCCOL &rCol, SCROW &rRow)
Definition: excform.cxx:1704
static const sal_uInt16 nRowMask
Definition: excform.hxx:38
Stores contents of an external name.
Definition: xilink.hxx:111
std::unique_ptr< ScTokenArray > GetDummy()
Definition: excform.cxx:196
sal_Int16 SCCOL
Definition: types.hxx:21
const XclImpLinkManager & rLinkMan
Definition: excform.hxx:110
FORMULA_TYPE
Definition: formel.hxx:46
void SetComplRow(ScComplexRefData &)
Definition: excform.cxx:1755
Provides access to function info structs for all available functions.
Definition: xlformula.hxx:344
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
Definition: excform.cxx:206
const ScTokenArray * GetSharedFormula(const ScAddress &rRefPos) const
Definition: excform.cxx:1726
std::unique_ptr< ScTokenArray > GetBoolErr(XclBoolError)
Definition: excform.cxx:1663
void ExcRelToScRel8(sal_uInt16 nRow, sal_uInt16 nCol, ScSingleRefData &, const bool bName)
Definition: excform8.cxx:1436
sal_Int32 SCROW
Definition: types.hxx:17
bool HandleOleLink(sal_uInt16 nXtiIndex, const XclImpExtName &rExtName, ExternalTabInfo &rExtInfo)
Definition: excform8.cxx:121
void DoMulArgs(DefTokenId eId, sal_uInt8 nNumArgs)
Definition: excform.cxx:1532
virtual void GetAbsRefs(ScRangeList &rRangeList, XclImpStream &rStrm, std::size_t nLen) override
Definition: excform8.cxx:1491
unsigned char sal_uInt8
void ReadExtensions(const ExtensionTypeVec &rExtensions, XclImpStream &aIn)
Definition: excform.cxx:1892
virtual void GetAbsRefs(ScRangeList &rRangeList, XclImpStream &rStrm, std::size_t nLen)
Definition: excform.cxx:1317
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &rpTokArray, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
Definition: excform8.cxx:138
Complex reference (a range) into the sheet.
Definition: refdata.hxx:122
void ReadExtensionArray(unsigned int n, XclImpStream &aIn)
Definition: excform.cxx:1765
This class is used to import record oriented streams.
Definition: xistream.hxx:277
Access to global data from other classes.
Definition: xiroot.hxx:125
ExcelToSc8(XclImpRoot &rRoot)
Definition: excform8.cxx:82
XclFunctionProvider maFuncProv
Definition: excform.hxx:40
sal_Int16 SCTAB
Definition: types.hxx:22
This is the central class for the import of all internal/external links.
Definition: xilink.hxx:183
void ReadExtensionMemArea(XclImpStream &aIn)
Definition: excform.cxx:1885