LibreOffice Module sc (master)  1
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
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 .
18  */
20 #pragma once
22 #include <memory>
23 #include <map>
24 #include "xllink.hxx"
25 #include "xiroot.hxx"
26 #include "ftools.hxx"
27 #include <types.hxx>
29 namespace svl {
31 class SharedStringPool;
33 }
35 /* ============================================================================
36 Classes for import of different kinds of internal/external references.
37 - 3D cell and cell range links
38 - External cell and cell range links
39 - External defined names
40 - Add-in functions
41 - DDE links
42 - OLE object links
43 ============================================================================ */
45 // Excel sheet indexes ========================================================
61 {
62 public:
63  // original Excel sheet names ---------------------------------------------
66  void AppendXclTabName( const OUString& rXclTabName, SCTAB nScTab );
68  void InsertScTab( SCTAB nScTab );
71  SCTAB GetScTabFromXclName( const OUString& rXclTabName ) const;
73  // record creation order - TABID record -----------------------------------
76  void ReadTabid( XclImpStream& rStrm );
84  sal_uInt16 GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId ) const;
86 private:
87  typedef ::std::map< OUString, SCTAB > XclTabNameMap;
89  XclTabNameMap maTabNames;
91 };
93 // External names =============================================================
97 {
103 };
105 class XclImpCachedMatrix;
106 class ScTokenArray;
107 class XclImpSupbook;
112 {
117  class MOper
118  {
119  public:
121  const ScMatrix& GetCache() const;
122  private:
124  };
126 public:
128  explicit XclImpExtName( XclImpSupbook& rSupbook, XclImpStream& rStrm,
129  XclSupbookType eSubType, ExcelToSc* pFormulaConv );
130  ~XclImpExtName();
133  void CreateDdeData( ScDocument& rDoc,
134  const OUString& rApplc, const OUString& rExtDoc ) const;
136  void CreateExtNameData( const ScDocument& rDoc, sal_uInt16 nFileId ) const;
143  bool CreateOleData(const ScDocument& rDoc, const OUString& rUrl,
144  sal_uInt16& rFileId, OUString& rTabName, ScRange& rRange) const;
146  bool HasFormulaTokens() const;
148  XclImpExtNameType GetType() const { return meType; }
149  const OUString& GetName() const { return maName; }
150  sal_uInt32 GetStorageId() const { return mnStorageId; }
152 private:
153  typedef ::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr;
154  typedef ::std::unique_ptr< ScTokenArray > TokenArrayPtr;
156  XclImpCachedMatrixPtr mxDdeMatrix;
157  std::unique_ptr<MOper> mpMOper;
158  TokenArrayPtr mxArray;
159  OUString maName;
160  sal_uInt32 mnStorageId;
162 };
164 // Import link manager ========================================================
183 class XclImpLinkManager : protected XclImpRoot
184 {
185 public:
186  explicit XclImpLinkManager( const XclImpRoot& rRoot );
187  virtual ~XclImpLinkManager() override;
192  void ReadSupbook( XclImpStream& rStrm );
194  void ReadXct( XclImpStream& rStrm );
196  void ReadCrn( XclImpStream& rStrm );
198  void ReadExternname( XclImpStream& rStrm, ExcelToSc* pFormulaConv );
201  bool IsSelfRef( sal_uInt16 nXtiIndex ) const;
204  bool GetScTabRange(
205  SCTAB& rnFirstScTab, SCTAB& rnLastScTab,
206  sal_uInt16 nXtiIndex ) const;
208  const XclImpExtName* GetExternName( sal_uInt16 nXtiIndex, sal_uInt16 nExtName ) const;
210  const OUString* GetSupbookUrl( sal_uInt16 nXtiIndex ) const;
212  OUString GetSupbookTabName( sal_uInt16 nXti, sal_uInt16 nXtiTab ) const;
218  bool GetLinkData( OUString& rApplic, OUString& rTopic, sal_uInt16 nXtiIndex ) const;
220  OUString GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
222 private:
223  typedef ::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr;
224  XclImpLinkMgrImplPtr mxImpl;
225 };
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:112
MOper, multiple operands, stores cached values of external range specified in the record...
Definition: xilink.hxx:117
void ReadExternsheet(XclImpStream &rStrm)
Reads the EXTERNSHEET record.
Definition: xilink.cxx:901
const ScMatrix & GetCache() const
Definition: xilink.cxx:339
MOper(svl::SharedStringPool &rPool, XclImpStream &rStrm)
Definition: xilink.cxx:277
This class represents an external linked document (record SUPBOOK).
Definition: xilink.cxx:90
::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr
Definition: xilink.hxx:153
XclImpExtNameType meType
Storage ID for OLE object storages.
Definition: xilink.hxx:161
void ReadTabid(XclImpStream &rStrm)
Reads the TABID record.
Definition: xilink.cxx:246
void ReadExternname(XclImpStream &rStrm, ExcelToSc *pFormulaConv)
Reads an EXTERNNAME record and appends it to the current SUPBOOK.
Definition: xilink.cxx:921
ScMatrixRef mxCached
Definition: xilink.hxx:123
bool GetScTabRange(SCTAB &rnFirstScTab, SCTAB &rnLastScTab, sal_uInt16 nXtiIndex) const
Returns the Calc sheet index range of the specified XTI entry.
Definition: xilink.cxx:931
void ReadXct(XclImpStream &rStrm)
Reads an XCT record and appends it to the current SUPBOOK.
Definition: xilink.cxx:911
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
void CreateDdeData(ScDocument &rDoc, const OUString &rApplc, const OUString &rExtDoc) const
Create and apply the cached list of this DDE Link to the document.
Definition: xilink.cxx:412
XclImpExtNameType GetType() const
Definition: xilink.hxx:148
XclImpLinkManager(const XclImpRoot &rRoot)
Definition: xilink.cxx:891
sal_uInt16 GetCurrentIndex(sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId) const
Returns the current sheet index calculated from creation index.
Definition: xilink.cxx:262
A buffer containing information about names and creation order of sheets.
Definition: xilink.hxx:60
Stores contents of an external name.
Definition: xilink.hxx:111
bool HasFormulaTokens() const
Definition: xilink.cxx:546
OUString GetMacroName(sal_uInt16 nExtSheet, sal_uInt16 nExtName) const
Returns the specified macro name or an empty string on error.
Definition: xilink.cxx:957
void InsertScTab(SCTAB nScTab)
Inserts a Calc sheet index (increases all following sheet indexes).
Definition: xilink.cxx:231
sal_uInt32 mnStorageId
The name of the external name.
Definition: xilink.hxx:160
XclTabNameMap maTabNames
Definition: xilink.hxx:89
Contains cached values in a 2-dimensional array.
Definition: xihelper.hxx:333
std::unique_ptr< MOper > mpMOper
Cached results of the DDE link.
Definition: xilink.hxx:157
const XclImpExtName * GetExternName(sal_uInt16 nXtiIndex, sal_uInt16 nExtName) const
Returns the specified external name or 0 on error.
Definition: xilink.cxx:937
bool GetLinkData(OUString &rApplic, OUString &rTopic, sal_uInt16 nXtiIndex) const
Tries to decode the URL of the specified XTI entry to OLE or DDE link components. ...
Definition: xilink.cxx:952
::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr
Definition: xilink.hxx:223
XclImpLinkMgrImplPtr mxImpl
Definition: xilink.hxx:224
virtual ~XclImpLinkManager() override
Definition: xilink.cxx:897
OUString maName
Formula tokens for external name.
Definition: xilink.hxx:159
bool CreateOleData(const ScDocument &rDoc, const OUString &rUrl, sal_uInt16 &rFileId, OUString &rTabName, ScRange &rRange) const
Create OLE link data.
Definition: xilink.cxx:471
::std::vector< sal_uInt16 > ScfUInt16Vec
Definition: ftools.hxx:255
void ReadSupbook(XclImpStream &rStrm)
Reads a SUPBOOK record.
Definition: xilink.cxx:906
sal_uInt32 GetStorageId() const
Definition: xilink.hxx:150
These need to be in global namespace just like their respective types are.
::std::map< OUString, SCTAB > XclTabNameMap
Definition: xilink.hxx:87
const OUString * GetSupbookUrl(sal_uInt16 nXtiIndex) const
Definition: xilink.cxx:942
XclImpExtName(XclImpSupbook &rSupbook, XclImpStream &rStrm, XclSupbookType eSubType, ExcelToSc *pFormulaConv)
Reads the external name from the stream.
Definition: xilink.cxx:344
SCTAB GetScTabFromXclName(const OUString &rXclTabName) const
Returns the Calc sheet index from the passed original Excel sheet name.
Definition: xilink.cxx:238
This class is used to import record oriented streams.
Definition: xistream.hxx:277
TokenArrayPtr mxArray
Cached values for OLE link.
Definition: xilink.hxx:158
XclImpCachedMatrixPtr mxDdeMatrix
Definition: xilink.hxx:156
Implementation of the link manager.
Definition: xilink.cxx:164
bool IsSelfRef(sal_uInt16 nXtiIndex) const
Returns true, if the specified XTI entry contains an internal reference.
Definition: xilink.cxx:926
void CreateExtNameData(const ScDocument &rDoc, sal_uInt16 nFileId) const
Definition: xilink.cxx:420
void SvStream & rStrm
Access to global data from other classes.
Definition: xiroot.hxx:125
ScfUInt16Vec maTabIdVec
All Excel sheet names with Calc sheet index.
Definition: xilink.hxx:90
const OUString & GetName() const
Definition: xilink.hxx:149
OUString GetSupbookTabName(sal_uInt16 nXti, sal_uInt16 nXtiTab) const
Definition: xilink.cxx:947
sal_Int16 SCTAB
Definition: types.hxx:22
This is the central class for the import of all internal/external links.
Definition: xilink.hxx:183
::std::unique_ptr< ScTokenArray > TokenArrayPtr
Definition: xilink.hxx:154
void ReadCrn(XclImpStream &rStrm)
Reads a CRN record and appends it to the current SUPBOOK.
Definition: xilink.cxx:916
void AppendXclTabName(const OUString &rXclTabName, SCTAB nScTab)
Appends an original Excel sheet name with corresponding Calc sheet index.
Definition: xilink.cxx:226