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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XELINK_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XELINK_HXX
22 
23 #include "xerecord.hxx"
24 #include "xeroot.hxx"
25 #include <externalrefmgr.hxx>
26 #include <memory>
27 #include <o3tl/typed_flags_set.hxx>
28 
29 struct ScSingleRefData;
30 struct ScComplexRefData;
31 struct XclExpRefLogEntry;
32 
33 /* ============================================================================
34 Classes for export of different kinds of internal/external references.
35 - 3D cell and cell range links
36 - External cell and cell range links
37 - External defined names
38 - Macro calls
39 - Add-in functions
40 - DDE links
41 - OLE object links
42 ============================================================================ */
43 
44 // Excel sheet indexes ========================================================
45 
46 enum class ExcTabBufFlags : sal_uInt8 {
47  NONE = 0x00,
48  Ignore = 0x01,
49  Extern = 0x02,
50  SkipMask = 0x03,
51  Visible = 0x10,
52  Selected = 0x20,
53  Mirrored = 0x40
54 };
55 namespace o3tl {
56  template<> struct typed_flags<ExcTabBufFlags> : is_typed_flags<ExcTabBufFlags, 0x73> {};
57 }
58 
62 class XclExpTabInfo : protected XclExpRoot
63 {
64 public:
66  explicit XclExpTabInfo( const XclExpRoot& rRoot );
67 
69  bool IsExportTab( SCTAB nScTab ) const;
71  bool IsExternalTab( SCTAB nScTab ) const;
73  bool IsVisibleTab( SCTAB nScTab ) const;
75  bool IsSelectedTab( SCTAB nScTab ) const;
77  bool IsDisplayedTab( SCTAB nScTab ) const;
79  bool IsMirroredTab( SCTAB nScTab ) const;
81  OUString GetScTabName( SCTAB nScTab ) const;
82 
84  sal_uInt16 GetXclTab( SCTAB nScTab ) const;
85 
87  SCTAB GetRealScTab( SCTAB nSortedScTab ) const;
88 
90  SCTAB GetScTabCount() const { return mnScCnt; }
91 
93  sal_uInt16 GetXclTabCount() const { return mnXclCnt; }
95  sal_uInt16 GetXclExtTabCount() const { return mnXclExtCnt; }
97  sal_uInt16 GetXclSelectedCount() const { return mnXclSelCnt; }
98 
100  sal_uInt16 GetDisplayedXclTab() const { return mnDisplXclTab; }
102  sal_uInt16 GetFirstVisXclTab() const { return mnFirstVisXclTab; }
103 
104 private:
106  bool GetFlag( SCTAB nScTab, ExcTabBufFlags nFlags ) const;
108  void SetFlag( SCTAB nScTab, ExcTabBufFlags nFlags, bool bSet = true );
109 
111  void CalcXclIndexes();
113  void CalcSortedIndexes();
114 
115 private:
118  {
119  OUString maScName;
120  sal_uInt16 mnXclTab;
122  explicit XclExpTabInfoEntry() : mnXclTab( 0 ), mnFlags( ExcTabBufFlags::NONE ) {}
123  };
124 
125  typedef ::std::vector< SCTAB > ScTabVec;
126 
127  std::vector< XclExpTabInfoEntry >
129 
131  sal_uInt16 mnXclCnt;
132  sal_uInt16 mnXclExtCnt;
133  sal_uInt16 mnXclSelCnt;
134  sal_uInt16 mnDisplXclTab;
135  sal_uInt16 mnFirstVisXclTab;
136 
137  ScTabVec maFromSortedVec;
138  ScTabVec maToSortedVec;
139 };
140 
141 // Export link manager ========================================================
142 
144 
147 {
148 public:
149  explicit XclExpLinkManager( const XclExpRoot& rRoot );
150  virtual ~XclExpLinkManager() override;
151 
158  void FindExtSheet( sal_uInt16& rnExtSheet,
159  sal_uInt16& rnXclTab, SCTAB nScTab,
160  XclExpRefLogEntry* pRefLogEntry = nullptr );
169  void FindExtSheet( sal_uInt16& rnExtSheet,
170  sal_uInt16& rnFirstXclTab, sal_uInt16& rnLastXclTab,
171  SCTAB nFirstScTab, SCTAB nLastScTab,
172  XclExpRefLogEntry* pRefLogEntry );
174  sal_uInt16 FindExtSheet( sal_Unicode cCode );
175 
176  void FindExtSheet( sal_uInt16 nFileId, const OUString& rTabName, sal_uInt16 nXclTabSpan,
177  sal_uInt16& rnExtSheet, sal_uInt16& rnFirstSBTab, sal_uInt16& rnLastSBTab,
178  XclExpRefLogEntry* pRefLogEntry );
179 
181  void StoreCell( const ScSingleRefData& rRef, const ScAddress& rPos );
183  void StoreCellRange( const ScComplexRefData& rRef, const ScAddress& rPos );
184 
185  void StoreCell( sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rPos );
186 
187  void StoreCellRange( sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange );
188 
193  bool InsertAddIn(
194  sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
195  const OUString& rName );
197  bool InsertEuroTool(
198  sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
199  const OUString& rName );
204  bool InsertDde(
205  sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
206  const OUString& rApplic, const OUString& rTopic, const OUString& rItem );
207 
208  bool InsertExtName(
209  sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const OUString& rUrl,
210  const OUString& rName, const ScExternalRefCache::TokenArrayRef& rArray );
211 
213  virtual void Save( XclExpStream& rStrm ) override;
214 
216  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
217 
218 private:
219  typedef std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr;
220  XclExpLinkMgrImplPtr mxImpl;
221 };
222 
223 #endif
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CalcXclIndexes()
Searches for sheets not to be exported.
Definition: xelink.cxx:840
bool IsSelectedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is selected and will be exported.
Definition: xelink.cxx:789
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Definition: xelink.cxx:771
XclExpTabInfo(const XclExpRoot &rRoot)
Initializes the complete buffer from the current exported document.
Definition: xelink.cxx:668
bool InsertEuroTool(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rName)
InsertEuroTool.
Definition: xelink.cxx:2595
This class is used to export Excel record streams.
Definition: xestream.hxx:71
bool IsExternalTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is used to store external cell contents.
Definition: xelink.cxx:777
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
Visible
bool IsVisibleTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is visible and will be exported.
Definition: xelink.cxx:784
OUString GetScTabName(SCTAB nScTab) const
Returns the Calc name of the specified sheet.
Definition: xelink.cxx:805
sal_uInt16 mnDisplXclTab
Count of selected and exported sheets.
Definition: xelink.hxx:134
sal_uInt16 mnXclCnt
Count of Calc sheets.
Definition: xelink.hxx:131
std::vector< XclExpTabInfoEntry > maTabInfoVec
Definition: xelink.hxx:128
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:2543
NONE
sal_uInt16 sal_Unicode
virtual void SaveXml(XclExpXmlStream &rStrm) override
Writes the entire Link table to OOXML.
Definition: xelink.cxx:2620
Access to global data from other classes.
Definition: xeroot.hxx:113
sal_uInt16 GetFirstVisXclTab() const
Returns the Excel index of the first visible sheet.
Definition: xelink.hxx:102
ScTabVec maToSortedVec
Sorted Calc sheet index -> real Calc sheet index.
Definition: xelink.hxx:138
sal_uInt16 mnFirstVisXclTab
Displayed (active) sheet.
Definition: xelink.hxx:135
Base class for all Excel records.
Definition: xerecord.hxx:39
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:822
void StoreCell(const ScSingleRefData &rRef, const ScAddress &rPos)
Stores the cell with the given address in a CRN record list.
Definition: xelink.cxx:2569
bool IsMirroredTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is displayed in right-to-left mode.
Definition: xelink.cxx:800
sal_uInt16 GetXclExtTabCount() const
Returns the number of external linked sheets.
Definition: xelink.hxx:95
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:2589
sal_uInt16 GetXclTab(SCTAB nScTab) const
Returns the Excel sheet index for a given Calc sheet.
Definition: xelink.cxx:811
Data structure with information about one Calc sheet.
Definition: xelink.hxx:117
virtual void Save(XclExpStream &rStrm) override
Writes the entire Link table.
Definition: xelink.cxx:2615
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:2601
XclExpLinkMgrImplPtr mxImpl
Definition: xelink.hxx:220
sal_uInt16 mnXclSelCnt
Count of external link sheets.
Definition: xelink.hxx:133
SCTAB mnScCnt
Array of Calc sheet index information.
Definition: xelink.hxx:130
::std::vector< SCTAB > ScTabVec
Definition: xelink.hxx:125
Stores the correct Excel sheet index for each Calc sheet.
Definition: xelink.hxx:62
XclExpLinkManager(const XclExpRoot &rRoot)
Definition: xelink.cxx:2523
Abstract base class for implementation classes of the link manager.
Definition: xelink.cxx:488
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
Definition: xelink.hxx:90
bool InsertExtName(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rUrl, const OUString &rName, const ScExternalRefCache::TokenArrayRef &rArray)
Definition: xelink.cxx:2608
void StoreCellRange(const ScComplexRefData &rRef, const ScAddress &rPos)
Stores all cells in the given range in a CRN record list.
Definition: xelink.cxx:2574
Stores all data for internal/external references (the link table).
Definition: xelink.hxx:146
sal_uInt16 GetXclSelectedCount() const
Returns the number of exported selected sheets.
Definition: xelink.hxx:97
std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr
Definition: xelink.hxx:219
unsigned char sal_uInt8
sal_uInt16 GetXclTabCount() const
Returns the number of Excel sheets to be exported.
Definition: xelink.hxx:93
void CalcSortedIndexes()
Sorts the names of all tables and stores the indexes of the sorted indexes.
Definition: xelink.cxx:886
std::shared_ptr< ScTokenArray > TokenArrayRef
Log entry for external references in a formula, used i.e.
Definition: xeformula.hxx:32
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
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:828
sal_uInt16 GetDisplayedXclTab() const
Returns the Excel index of the active, displayed sheet.
Definition: xelink.hxx:100
virtual ~XclExpLinkManager() override
Definition: xelink.cxx:2539
sal_uInt16 mnXclExtCnt
Count of Excel sheets to be exported.
Definition: xelink.hxx:132
SCTAB GetRealScTab(SCTAB nSortedScTab) const
Returns the Calc sheet index of the nSortedTab-th entry in the sorted sheet names list...
Definition: xelink.cxx:816
void SvStream & rStrm
ScTabVec maFromSortedVec
First visible sheet.
Definition: xelink.hxx:137
bool IsDisplayedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is the displayed (active) sheet.
Definition: xelink.cxx:794
sal_Int16 SCTAB
Definition: types.hxx:23