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