LibreOffice Module sc (master) 1
xelink.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 "xerecord.hxx"
23#include "xeroot.hxx"
24#include <externalrefmgr.hxx>
25#include <memory>
27
28struct ScSingleRefData;
29struct ScComplexRefData;
31
32/* ============================================================================
33Classes for export of different kinds of internal/external references.
34- 3D cell and cell range links
35- External cell and cell range links
36- External defined names
37- Macro calls
38- Add-in functions
39- DDE links
40- OLE object links
41============================================================================ */
42
43// Excel sheet indexes ========================================================
44
46 NONE = 0x00,
47 Ignore = 0x01,
48 Extern = 0x02,
49 SkipMask = 0x03,
50 Visible = 0x10,
51 Selected = 0x20,
52 Mirrored = 0x40
53};
54namespace o3tl {
55 template<> struct typed_flags<ExcTabBufFlags> : is_typed_flags<ExcTabBufFlags, 0x73> {};
56}
57
61class XclExpTabInfo : protected XclExpRoot
62{
63public:
65 explicit XclExpTabInfo( const XclExpRoot& rRoot );
66
68 bool IsExportTab( SCTAB nScTab ) const;
70 bool IsExternalTab( SCTAB nScTab ) const;
72 bool IsVisibleTab( SCTAB nScTab ) const;
74 bool IsSelectedTab( SCTAB nScTab ) const;
76 bool IsDisplayedTab( SCTAB nScTab ) const;
78 bool IsMirroredTab( SCTAB nScTab ) const;
80 OUString GetScTabName( SCTAB nScTab ) const;
81
83 sal_uInt16 GetXclTab( SCTAB nScTab ) const;
84
86 SCTAB GetRealScTab( SCTAB nSortedScTab ) const;
87
89 SCTAB GetScTabCount() const { return mnScCnt; }
90
92 sal_uInt16 GetXclTabCount() const { return mnXclCnt; }
94 sal_uInt16 GetXclExtTabCount() const { return mnXclExtCnt; }
96 sal_uInt16 GetXclSelectedCount() const { return mnXclSelCnt; }
97
99 sal_uInt16 GetDisplayedXclTab() const { return mnDisplXclTab; }
101 sal_uInt16 GetFirstVisXclTab() const { return mnFirstVisXclTab; }
102
103private:
105 bool GetFlag( SCTAB nScTab, ExcTabBufFlags nFlags ) const;
107 void SetFlag( SCTAB nScTab, ExcTabBufFlags nFlags, bool bSet = true );
108
110 void CalcXclIndexes();
112 void CalcSortedIndexes();
113
114private:
117 {
118 OUString maScName;
119 sal_uInt16 mnXclTab;
122 };
123
124 typedef ::std::vector< SCTAB > ScTabVec;
125
126 std::vector< XclExpTabInfoEntry >
128
130 sal_uInt16 mnXclCnt;
131 sal_uInt16 mnXclExtCnt;
132 sal_uInt16 mnXclSelCnt;
133 sal_uInt16 mnDisplXclTab;
134 sal_uInt16 mnFirstVisXclTab;
135
138};
139
140// Export link manager ========================================================
141
143
146{
147public:
148 explicit XclExpLinkManager( const XclExpRoot& rRoot );
149 virtual ~XclExpLinkManager() override;
150
157 void FindExtSheet( sal_uInt16& rnExtSheet,
158 sal_uInt16& rnXclTab, SCTAB nScTab,
159 XclExpRefLogEntry* pRefLogEntry = nullptr );
168 void FindExtSheet( sal_uInt16& rnExtSheet,
169 sal_uInt16& rnFirstXclTab, sal_uInt16& rnLastXclTab,
170 SCTAB nFirstScTab, SCTAB nLastScTab,
171 XclExpRefLogEntry* pRefLogEntry );
173 sal_uInt16 FindExtSheet( sal_Unicode cCode );
174
175 void FindExtSheet( sal_uInt16 nFileId, const OUString& rTabName, sal_uInt16 nXclTabSpan,
176 sal_uInt16& rnExtSheet, sal_uInt16& rnFirstSBTab, sal_uInt16& rnLastSBTab,
177 XclExpRefLogEntry* pRefLogEntry );
178
180 void StoreCell( const ScSingleRefData& rRef, const ScAddress& rPos );
182 void StoreCellRange( const ScComplexRefData& rRef, const ScAddress& rPos );
183
184 void StoreCell( sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rPos );
185
186 void StoreCellRange( sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange );
187
192 bool InsertAddIn(
193 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
194 const OUString& rName );
196 bool InsertEuroTool(
197 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
198 const OUString& rName );
203 bool InsertDde(
204 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
205 const OUString& rApplic, const OUString& rTopic, const OUString& rItem );
206
207 bool InsertExtName(
208 sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const OUString& rUrl,
209 const OUString& rName, const ScExternalRefCache::TokenArrayRef& rArray );
210
212 virtual void Save( XclExpStream& rStrm ) override;
213
215 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
216
217private:
218 typedef std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr;
220};
221
222/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< ScTokenArray > TokenArrayRef
Abstract base class for implementation classes of the link manager.
Definition: xelink.cxx:492
Stores all data for internal/external references (the link table).
Definition: xelink.hxx:146
std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr
Definition: xelink.hxx:218
bool InsertExtName(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rUrl, const OUString &rName, const ScExternalRefCache::TokenArrayRef &rArray)
Definition: xelink.cxx:2644
bool InsertDde(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rApplic, const OUString &rTopic, const OUString &rItem)
Finds or inserts an EXTERNNAME record for DDE links.
Definition: xelink.cxx:2637
void FindExtSheet(sal_uInt16 &rnExtSheet, sal_uInt16 &rnXclTab, SCTAB nScTab, XclExpRefLogEntry *pRefLogEntry=nullptr)
Searches for an EXTERNSHEET index for the given Calc sheet.
Definition: xelink.cxx:2579
void StoreCell(const ScSingleRefData &rRef, const ScAddress &rPos)
Stores the cell with the given address in a CRN record list.
Definition: xelink.cxx:2605
XclExpLinkManager(const XclExpRoot &rRoot)
Definition: xelink.cxx:2559
virtual void Save(XclExpStream &rStrm) override
Writes the entire Link table.
Definition: xelink.cxx:2651
void StoreCellRange(const ScComplexRefData &rRef, const ScAddress &rPos)
Stores all cells in the given range in a CRN record list.
Definition: xelink.cxx:2610
virtual void SaveXml(XclExpXmlStream &rStrm) override
Writes the entire Link table to OOXML.
Definition: xelink.cxx:2656
virtual ~XclExpLinkManager() override
Definition: xelink.cxx:2575
bool InsertAddIn(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rName)
Finds or inserts an EXTERNNAME record for an add-in function name.
Definition: xelink.cxx:2625
XclExpLinkMgrImplPtr mxImpl
Definition: xelink.hxx:219
bool InsertEuroTool(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rName)
InsertEuroTool.
Definition: xelink.cxx:2631
Base class for all Excel records.
Definition: xerecord.hxx:39
Access to global data from other classes.
Definition: xeroot.hxx:113
This class is used to export Excel record streams.
Definition: xestream.hxx:73
Stores the correct Excel sheet index for each Calc sheet.
Definition: xelink.hxx:62
bool IsMirroredTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is displayed in right-to-left mode.
Definition: xelink.cxx:803
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
Definition: xelink.hxx:89
bool GetFlag(SCTAB nScTab, ExcTabBufFlags nFlags) const
Returns true, if any of the passed flags is set for the specified Calc sheet.
Definition: xelink.cxx:825
void SetFlag(SCTAB nScTab, ExcTabBufFlags nFlags, bool bSet=true)
Sets or clears (depending on bSet) all passed flags for the specified Calc sheet.
Definition: xelink.cxx:831
SCTAB GetRealScTab(SCTAB nSortedScTab) const
Returns the Calc sheet index of the nSortedTab-th entry in the sorted sheet names list.
Definition: xelink.cxx:819
sal_uInt16 GetFirstVisXclTab() const
Returns the Excel index of the first visible sheet.
Definition: xelink.hxx:101
bool IsDisplayedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is the displayed (active) sheet.
Definition: xelink.cxx:797
sal_uInt16 GetXclSelectedCount() const
Returns the number of exported selected sheets.
Definition: xelink.hxx:96
::std::vector< SCTAB > ScTabVec
Definition: xelink.hxx:124
bool IsVisibleTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is visible and will be exported.
Definition: xelink.cxx:787
sal_uInt16 mnFirstVisXclTab
Displayed (active) sheet.
Definition: xelink.hxx:134
SCTAB mnScCnt
Array of Calc sheet index information.
Definition: xelink.hxx:129
sal_uInt16 mnXclSelCnt
Count of external link sheets.
Definition: xelink.hxx:132
sal_uInt16 GetXclTab(SCTAB nScTab) const
Returns the Excel sheet index for a given Calc sheet.
Definition: xelink.cxx:814
XclExpTabInfo(const XclExpRoot &rRoot)
Initializes the complete buffer from the current exported document.
Definition: xelink.cxx:671
std::vector< XclExpTabInfoEntry > maTabInfoVec
Definition: xelink.hxx:127
OUString GetScTabName(SCTAB nScTab) const
Returns the Calc name of the specified sheet.
Definition: xelink.cxx:808
void CalcXclIndexes()
Searches for sheets not to be exported.
Definition: xelink.cxx:843
sal_uInt16 mnDisplXclTab
Count of selected and exported sheets.
Definition: xelink.hxx:133
sal_uInt16 mnXclCnt
Count of Calc sheets.
Definition: xelink.hxx:130
ScTabVec maFromSortedVec
First visible sheet.
Definition: xelink.hxx:136
bool IsSelectedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is selected and will be exported.
Definition: xelink.cxx:792
bool IsExternalTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is used to store external cell contents.
Definition: xelink.cxx:780
sal_uInt16 GetXclTabCount() const
Returns the number of Excel sheets to be exported.
Definition: xelink.hxx:92
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Definition: xelink.cxx:774
sal_uInt16 GetDisplayedXclTab() const
Returns the Excel index of the active, displayed sheet.
Definition: xelink.hxx:99
sal_uInt16 GetXclExtTabCount() const
Returns the number of external linked sheets.
Definition: xelink.hxx:94
ScTabVec maToSortedVec
Sorted Calc sheet index -> real Calc sheet index.
Definition: xelink.hxx:137
sal_uInt16 mnXclExtCnt
Count of Excel sheets to be exported.
Definition: xelink.hxx:131
void CalcSortedIndexes()
Sorts the names of all tables and stores the indexes of the sorted indexes.
Definition: xelink.cxx:889
NONE
void SvStream & rStrm
Visible
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
Log entry for external references in a formula, used i.e.
Definition: xeformula.hxx:32
Data structure with information about one Calc sheet.
Definition: xelink.hxx:117
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
sal_Int16 SCTAB
Definition: types.hxx:22