LibreOffice Module sc (master) 1
xilink.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 <memory>
23#include <map>
24#include "xllink.hxx"
25#include "xiroot.hxx"
26#include "ftools.hxx"
27#include <types.hxx>
28
29namespace svl {
30
31class SharedStringPool;
32
33}
34
35/* ============================================================================
36Classes 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============================================================================ */
44
45// Excel sheet indexes ========================================================
46
61{
62public:
63 // original Excel sheet names ---------------------------------------------
64
66 void AppendXclTabName( const OUString& rXclTabName, SCTAB nScTab );
68 void InsertScTab( SCTAB nScTab );
69
71 SCTAB GetScTabFromXclName( const OUString& rXclTabName ) const;
72
73 // record creation order - TABID record -----------------------------------
74
77
84 sal_uInt16 GetCurrentIndex( sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId ) const;
85
86private:
87 typedef ::std::map< OUString, SCTAB > XclTabNameMap;
88
91};
92
93// External names =============================================================
94
97{
104
106class ScTokenArray;
107class XclImpSupbook;
108
112{
117 class MOper
118 {
119 public:
121 const ScMatrix& GetCache() const;
122 private:
124 };
125
126public:
128 explicit XclImpExtName( XclImpSupbook& rSupbook, XclImpStream& rStrm,
129 XclSupbookType eSubType, ExcelToSc* pFormulaConv );
131
133 void CreateDdeData( ScDocument& rDoc,
134 const OUString& rApplc, const OUString& rExtDoc ) const;
135
136 void CreateExtNameData( const ScDocument& rDoc, sal_uInt16 nFileId ) const;
137
143 bool CreateOleData(const ScDocument& rDoc, const OUString& rUrl,
144 sal_uInt16& rFileId, OUString& rTabName, ScRange& rRange) const;
145
146 bool HasFormulaTokens() const;
147
148 XclImpExtNameType GetType() const { return meType; }
149 const OUString& GetName() const { return maName; }
150 sal_uInt32 GetStorageId() const { return mnStorageId; }
151
152private:
153 typedef ::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr;
154 typedef ::std::unique_ptr< ScTokenArray > TokenArrayPtr;
155
157 std::unique_ptr<MOper> mpMOper;
159 OUString maName;
160 sal_uInt32 mnStorageId;
162};
163
164// Import link manager ========================================================
165
167
184{
185public:
186 explicit XclImpLinkManager( const XclImpRoot& rRoot );
187 virtual ~XclImpLinkManager() override;
188
194 void ReadXct( XclImpStream& rStrm );
196 void ReadCrn( XclImpStream& rStrm );
198 void ReadExternname( XclImpStream& rStrm, ExcelToSc* pFormulaConv );
199
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;
209
210 const OUString* GetSupbookUrl( sal_uInt16 nXtiIndex ) const;
211
212 OUString GetSupbookTabName( sal_uInt16 nXti, sal_uInt16 nXtiTab ) const;
213
218 bool GetLinkData( OUString& rApplic, OUString& rTopic, sal_uInt16 nXtiIndex ) const;
220 OUString GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
221
222private:
223 typedef ::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr;
225};
226
227/* 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:118
MOper(svl::SharedStringPool &rPool, XclImpStream &rStrm)
Definition: xilink.cxx:277
const ScMatrix & GetCache() const
Definition: xilink.cxx:339
ScMatrixRef mxCached
Definition: xilink.hxx:123
Stores contents of an external name.
Definition: xilink.hxx:112
XclImpCachedMatrixPtr mxDdeMatrix
Definition: xilink.hxx:156
::std::unique_ptr< XclImpCachedMatrix > XclImpCachedMatrixPtr
Definition: xilink.hxx:153
const OUString & GetName() const
Definition: xilink.hxx:149
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
std::unique_ptr< MOper > mpMOper
Cached results of the DDE link.
Definition: xilink.hxx:157
TokenArrayPtr mxArray
Cached values for OLE link.
Definition: xilink.hxx:158
bool CreateOleData(const ScDocument &rDoc, const OUString &rUrl, sal_uInt16 &rFileId, OUString &rTabName, ScRange &rRange) const
Create OLE link data.
Definition: xilink.cxx:471
bool HasFormulaTokens() const
Definition: xilink.cxx:546
XclImpExtNameType meType
Storage ID for OLE object storages.
Definition: xilink.hxx:161
XclImpExtName(XclImpSupbook &rSupbook, XclImpStream &rStrm, XclSupbookType eSubType, ExcelToSc *pFormulaConv)
Reads the external name from the stream.
Definition: xilink.cxx:344
XclImpExtNameType GetType() const
Definition: xilink.hxx:148
sal_uInt32 GetStorageId() const
Definition: xilink.hxx:150
::std::unique_ptr< ScTokenArray > TokenArrayPtr
Definition: xilink.hxx:154
OUString maName
Formula tokens for external name.
Definition: xilink.hxx:159
sal_uInt32 mnStorageId
The name of the external name.
Definition: xilink.hxx:160
void CreateExtNameData(const ScDocument &rDoc, sal_uInt16 nFileId) const
Definition: xilink.cxx:420
Implementation of the link manager.
Definition: xilink.cxx:165
This is the central class for the import of all internal/external links.
Definition: xilink.hxx:184
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 ReadSupbook(XclImpStream &rStrm)
Reads a SUPBOOK record.
Definition: xilink.cxx:906
void ReadExternname(XclImpStream &rStrm, ExcelToSc *pFormulaConv)
Reads an EXTERNNAME record and appends it to the current SUPBOOK.
Definition: xilink.cxx:921
void ReadXct(XclImpStream &rStrm)
Reads an XCT record and appends it to the current SUPBOOK.
Definition: xilink.cxx:911
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
void ReadCrn(XclImpStream &rStrm)
Reads a CRN record and appends it to the current SUPBOOK.
Definition: xilink.cxx:916
XclImpLinkManager(const XclImpRoot &rRoot)
Definition: xilink.cxx:891
const OUString * GetSupbookUrl(sal_uInt16 nXtiIndex) const
Definition: xilink.cxx:942
::std::unique_ptr< XclImpLinkManagerImpl > XclImpLinkMgrImplPtr
Definition: xilink.hxx:223
virtual ~XclImpLinkManager() override
Definition: xilink.cxx:897
void ReadExternsheet(XclImpStream &rStrm)
Reads the EXTERNSHEET record.
Definition: xilink.cxx:901
bool IsSelfRef(sal_uInt16 nXtiIndex) const
Returns true, if the specified XTI entry contains an internal reference.
Definition: xilink.cxx:926
OUString GetSupbookTabName(sal_uInt16 nXti, sal_uInt16 nXtiTab) const
Definition: xilink.cxx:947
OUString GetMacroName(sal_uInt16 nExtSheet, sal_uInt16 nExtName) const
Returns the specified macro name or an empty string on error.
Definition: xilink.cxx:957
const XclImpExtName * GetExternName(sal_uInt16 nXtiIndex, sal_uInt16 nExtName) const
Returns the specified external name or 0 on error.
Definition: xilink.cxx:937
XclImpLinkMgrImplPtr mxImpl
Definition: xilink.hxx:224
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:91
A buffer containing information about names and creation order of sheets.
Definition: xilink.hxx:61
ScfUInt16Vec maTabIdVec
All Excel sheet names with Calc sheet index.
Definition: xilink.hxx:90
SCTAB GetScTabFromXclName(const OUString &rXclTabName) const
Returns the Calc sheet index from the passed original Excel sheet name.
Definition: xilink.cxx:238
sal_uInt16 GetCurrentIndex(sal_uInt16 nCreatedId, sal_uInt16 nMaxTabId) const
Returns the current sheet index calculated from creation index.
Definition: xilink.cxx:262
::std::map< OUString, SCTAB > XclTabNameMap
Definition: xilink.hxx:87
XclTabNameMap maTabNames
Definition: xilink.hxx:89
void ReadTabid(XclImpStream &rStrm)
Reads the TABID record.
Definition: xilink.cxx:246
void InsertScTab(SCTAB nScTab)
Inserts a Calc sheet index (increases all following sheet indexes).
Definition: xilink.cxx:231
void AppendXclTabName(const OUString &rXclTabName, SCTAB nScTab)
Appends an original Excel sheet name with corresponding Calc sheet index.
Definition: xilink.cxx:226
::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