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 -*- */
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 <optional>
24#include <map>
25#include "xllink.hxx"
26#include "xiroot.hxx"
27#include "ftools.hxx"
28#include <types.hxx>
30namespace svl {
32class SharedStringPool;
36/* ============================================================================
37Classes for import of different kinds of internal/external references.
38- 3D cell and cell range links
39- External cell and cell range links
40- External defined names
41- Add-in functions
42- DDE links
43- OLE object links
44============================================================================ */
46// Excel sheet indexes ========================================================
64 // original Excel sheet names ---------------------------------------------
67 void AppendXclTabName( const OUString& rXclTabName, SCTAB nScTab );
69 void InsertScTab( SCTAB nScTab );
72 SCTAB GetScTabFromXclName( const OUString& rXclTabName ) const;
74 // record creation order - TABID record -----------------------------------
85 sal_uInt16 GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId ) const;
88 typedef ::std::map< OUString, SCTAB > XclTabNameMap;
94// External names =============================================================
107class ScTokenArray;
108class XclImpSupbook;
118 class MOper
119 {
120 public:
122 const ScMatrix& GetCache() const;
123 private:
125 };
129 explicit XclImpExtName( XclImpSupbook& rSupbook, XclImpStream& rStrm,
130 XclSupbookType eSubType, ExcelToSc* pFormulaConv );
134 void CreateDdeData( ScDocument& rDoc,
135 const OUString& rApplc, const OUString& rExtDoc ) const;
137 void CreateExtNameData( const ScDocument& rDoc, sal_uInt16 nFileId ) const;
144 bool CreateOleData(const ScDocument& rDoc, const OUString& rUrl,
145 sal_uInt16& rFileId, OUString& rTabName, ScRange& rRange) const;
147 bool HasFormulaTokens() const;
149 XclImpExtNameType GetType() const { return meType; }
150 const OUString& GetName() const { return maName; }
151 sal_uInt32 GetStorageId() const { return mnStorageId; }
154 typedef ::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr;
155 typedef ::std::unique_ptr< ScTokenArray > TokenArrayPtr;
158 std::optional<MOper> moMOper;
160 OUString maName;
161 sal_uInt32 mnStorageId;
165// Import link manager ========================================================
187 explicit XclImpLinkManager( const XclImpRoot& rRoot );
188 virtual ~XclImpLinkManager() override;
195 void ReadXct( XclImpStream& rStrm );
197 void ReadCrn( XclImpStream& rStrm );
199 void ReadExternname( XclImpStream& rStrm, ExcelToSc* pFormulaConv );
202 bool IsSelfRef( sal_uInt16 nXtiIndex ) const;
205 bool GetScTabRange(
206 SCTAB& rnFirstScTab, SCTAB& rnLastScTab,
207 sal_uInt16 nXtiIndex ) const;
209 const XclImpExtName* GetExternName( sal_uInt16 nXtiIndex, sal_uInt16 nExtName ) const;
211 const OUString* GetSupbookUrl( sal_uInt16 nXtiIndex ) const;
213 OUString GetSupbookTabName( sal_uInt16 nXti, sal_uInt16 nXtiTab ) const;
219 bool GetLinkData( OUString& rApplic, OUString& rTopic, sal_uInt16 nXtiIndex ) const;
221 OUString GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
224 typedef ::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr;
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
Contains cached values in a 2-dimensional array.
Definition: xihelper.hxx:334
MOper, multiple operands, stores cached values of external range specified in the record.
Definition: xilink.hxx:119
MOper(svl::SharedStringPool &rPool, XclImpStream &rStrm)
Definition: xilink.cxx:278
const ScMatrix & GetCache() const
Definition: xilink.cxx:340
ScMatrixRef mxCached
Definition: xilink.hxx:124
Stores contents of an external name.
Definition: xilink.hxx:113
XclImpCachedMatrixPtr mxDdeMatrix
Definition: xilink.hxx:157
::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr
Definition: xilink.hxx:154
const OUString & GetName() const
Definition: xilink.hxx:150
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:413
std::optional< MOper > moMOper
Cached results of the DDE link.
Definition: xilink.hxx:158
TokenArrayPtr mxArray
Cached values for OLE link.
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:472
bool HasFormulaTokens() const
Definition: xilink.cxx:547
XclImpExtNameType meType
Storage ID for OLE object storages.
Definition: xilink.hxx:162
XclImpExtName(XclImpSupbook &rSupbook, XclImpStream &rStrm, XclSupbookType eSubType, ExcelToSc *pFormulaConv)
Reads the external name from the stream.
Definition: xilink.cxx:345
XclImpExtNameType GetType() const
Definition: xilink.hxx:149
sal_uInt32 GetStorageId() const
Definition: xilink.hxx:151
::std::unique_ptr< ScTokenArray > TokenArrayPtr
Definition: xilink.hxx:155
OUString maName
Formula tokens for external name.
Definition: xilink.hxx:160
sal_uInt32 mnStorageId
The name of the external name.
Definition: xilink.hxx:161
void CreateExtNameData(const ScDocument &rDoc, sal_uInt16 nFileId) const
Definition: xilink.cxx:421
Implementation of the link manager.
Definition: xilink.cxx:166
This is the central class for the import of all internal/external links.
Definition: xilink.hxx:185
bool GetScTabRange(SCTAB &rnFirstScTab, SCTAB &rnLastScTab, sal_uInt16 nXtiIndex) const
Returns the Calc sheet index range of the specified XTI entry.
Definition: xilink.cxx:932
void ReadSupbook(XclImpStream &rStrm)
Reads a SUPBOOK record.
Definition: xilink.cxx:907
void ReadExternname(XclImpStream &rStrm, ExcelToSc *pFormulaConv)
Reads an EXTERNNAME record and appends it to the current SUPBOOK.
Definition: xilink.cxx:922
void ReadXct(XclImpStream &rStrm)
Reads an XCT record and appends it to the current SUPBOOK.
Definition: xilink.cxx:912
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:953
void ReadCrn(XclImpStream &rStrm)
Reads a CRN record and appends it to the current SUPBOOK.
Definition: xilink.cxx:917
XclImpLinkManager(const XclImpRoot &rRoot)
Definition: xilink.cxx:892
const OUString * GetSupbookUrl(sal_uInt16 nXtiIndex) const
Definition: xilink.cxx:943
::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr
Definition: xilink.hxx:224
virtual ~XclImpLinkManager() override
Definition: xilink.cxx:898
void ReadExternsheet(XclImpStream &rStrm)
Reads the EXTERNSHEET record.
Definition: xilink.cxx:902
bool IsSelfRef(sal_uInt16 nXtiIndex) const
Returns true, if the specified XTI entry contains an internal reference.
Definition: xilink.cxx:927
OUString GetSupbookTabName(sal_uInt16 nXti, sal_uInt16 nXtiTab) const
Definition: xilink.cxx:948
OUString GetMacroName(sal_uInt16 nExtSheet, sal_uInt16 nExtName) const
Returns the specified macro name or an empty string on error.
Definition: xilink.cxx:958
const XclImpExtName * GetExternName(sal_uInt16 nXtiIndex, sal_uInt16 nExtName) const
Returns the specified external name or 0 on error.
Definition: xilink.cxx:938
XclImpLinkMgrImplPtr mxImpl
Definition: xilink.hxx:225
Access to global data from other classes.
Definition: xiroot.hxx:129
This class is used to import record oriented streams.
Definition: xistream.hxx:278
This class represents an external linked document (record SUPBOOK).
Definition: xilink.cxx:92
A buffer containing information about names and creation order of sheets.
Definition: xilink.hxx:62
ScfUInt16Vec maTabIdVec
All Excel sheet names with Calc sheet index.
Definition: xilink.hxx:91
SCTAB GetScTabFromXclName(const OUString &rXclTabName) const
Returns the Calc sheet index from the passed original Excel sheet name.
Definition: xilink.cxx:239
sal_uInt16 GetCurrentIndex(sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId) const
Returns the current sheet index calculated from creation index.
Definition: xilink.cxx:263
::std::map< OUString, SCTAB > XclTabNameMap
Definition: xilink.hxx:88
XclTabNameMap maTabNames
Definition: xilink.hxx:90
void ReadTabid(XclImpStream &rStrm)
Reads the TABID record.
Definition: xilink.cxx:247
void InsertScTab(SCTAB nScTab)
Inserts a Calc sheet index (increases all following sheet indexes).
Definition: xilink.cxx:232
void AppendXclTabName(const OUString &rXclTabName, SCTAB nScTab)
Appends an original Excel sheet name with corresponding Calc sheet index.
Definition: xilink.cxx:227
::std::vector< sal_uInt16 > ScfUInt16Vec
Definition: ftools.hxx:255
void SvStream & rStrm
These need to be in global namespace just like their respective types are.
sal_Int16 SCTAB
Definition: types.hxx:22
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25