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 "xerecord.hxx"
23 #include "xeroot.hxx"
24 #include <externalrefmgr.hxx>
25 #include <memory>
26 #include <o3tl/typed_flags_set.hxx>
28 struct ScSingleRefData;
29 struct ScComplexRefData;
30 struct XclExpRefLogEntry;
32 /* ============================================================================
33 Classes 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 ============================================================================ */
43 // Excel sheet indexes ========================================================
45 enum class ExcTabBufFlags : sal_uInt8 {
46  NONE = 0x00,
47  Ignore = 0x01,
48  Extern = 0x02,
49  SkipMask = 0x03,
50  Visible = 0x10,
51  Selected = 0x20,
52  Mirrored = 0x40
53 };
54 namespace o3tl {
55  template<> struct typed_flags<ExcTabBufFlags> : is_typed_flags<ExcTabBufFlags, 0x73> {};
56 }
61 class XclExpTabInfo : protected XclExpRoot
62 {
63 public:
65  explicit XclExpTabInfo( const XclExpRoot& rRoot );
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;
83  sal_uInt16 GetXclTab( SCTAB nScTab ) const;
86  SCTAB GetRealScTab( SCTAB nSortedScTab ) const;
89  SCTAB GetScTabCount() const { return mnScCnt; }
92  sal_uInt16 GetXclTabCount() const { return mnXclCnt; }
94  sal_uInt16 GetXclExtTabCount() const { return mnXclExtCnt; }
96  sal_uInt16 GetXclSelectedCount() const { return mnXclSelCnt; }
99  sal_uInt16 GetDisplayedXclTab() const { return mnDisplXclTab; }
101  sal_uInt16 GetFirstVisXclTab() const { return mnFirstVisXclTab; }
103 private:
105  bool GetFlag( SCTAB nScTab, ExcTabBufFlags nFlags ) const;
107  void SetFlag( SCTAB nScTab, ExcTabBufFlags nFlags, bool bSet = true );
110  void CalcXclIndexes();
112  void CalcSortedIndexes();
114 private:
117  {
118  OUString maScName;
119  sal_uInt16 mnXclTab;
121  explicit XclExpTabInfoEntry() : mnXclTab( 0 ), mnFlags( ExcTabBufFlags::NONE ) {}
122  };
124  typedef ::std::vector< SCTAB > ScTabVec;
126  std::vector< XclExpTabInfoEntry >
130  sal_uInt16 mnXclCnt;
131  sal_uInt16 mnXclExtCnt;
132  sal_uInt16 mnXclSelCnt;
133  sal_uInt16 mnDisplXclTab;
134  sal_uInt16 mnFirstVisXclTab;
136  ScTabVec maFromSortedVec;
137  ScTabVec maToSortedVec;
138 };
140 // Export link manager ========================================================
146 {
147 public:
148  explicit XclExpLinkManager( const XclExpRoot& rRoot );
149  virtual ~XclExpLinkManager() override;
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 );
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 );
180  void StoreCell( const ScSingleRefData& rRef, const ScAddress& rPos );
182  void StoreCellRange( const ScComplexRefData& rRef, const ScAddress& rPos );
184  void StoreCell( sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rPos );
186  void StoreCellRange( sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange );
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 );
207  bool InsertExtName(
208  sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const OUString& rUrl,
209  const OUString& rName, const ScExternalRefCache::TokenArrayRef& rArray );
212  virtual void Save( XclExpStream& rStrm ) override;
215  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
217 private:
218  typedef std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr;
219  XclExpLinkMgrImplPtr mxImpl;
220 };
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CalcXclIndexes()
Searches for sheets not to be exported.
Definition: xelink.cxx:842
bool IsSelectedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is selected and will be exported.
Definition: xelink.cxx:791
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Definition: xelink.cxx:773
XclExpTabInfo(const XclExpRoot &rRoot)
Initializes the complete buffer from the current exported document.
Definition: xelink.cxx:670
bool InsertEuroTool(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rName)
Definition: xelink.cxx:2630
This class is used to export Excel record streams.
Definition: xestream.hxx:72
bool IsExternalTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is used to store external cell contents.
Definition: xelink.cxx:779
Single reference (one address) into the sheet.
Definition: refdata.hxx:29
bool IsVisibleTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is visible and will be exported.
Definition: xelink.cxx:786
OUString GetScTabName(SCTAB nScTab) const
Returns the Calc name of the specified sheet.
Definition: xelink.cxx:807
sal_uInt16 mnDisplXclTab
Count of selected and exported sheets.
Definition: xelink.hxx:133
sal_uInt16 mnXclCnt
Count of Calc sheets.
Definition: xelink.hxx:130
std::vector< XclExpTabInfoEntry > maTabInfoVec
Definition: xelink.hxx:127
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:2578
sal_uInt16 sal_Unicode
virtual void SaveXml(XclExpXmlStream &rStrm) override
Writes the entire Link table to OOXML.
Definition: xelink.cxx:2655
Access to global data from other classes.
Definition: xeroot.hxx:112
sal_uInt16 GetFirstVisXclTab() const
Returns the Excel index of the first visible sheet.
Definition: xelink.hxx:101
ScTabVec maToSortedVec
Sorted Calc sheet index -> real Calc sheet index.
Definition: xelink.hxx:137
sal_uInt16 mnFirstVisXclTab
Displayed (active) sheet.
Definition: xelink.hxx:134
Base class for all Excel records.
Definition: xerecord.hxx:38
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:824
void StoreCell(const ScSingleRefData &rRef, const ScAddress &rPos)
Stores the cell with the given address in a CRN record list.
Definition: xelink.cxx:2604
bool IsMirroredTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is displayed in right-to-left mode.
Definition: xelink.cxx:802
sal_uInt16 GetXclExtTabCount() const
Returns the number of external linked sheets.
Definition: xelink.hxx:94
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:2624
sal_uInt16 GetXclTab(SCTAB nScTab) const
Returns the Excel sheet index for a given Calc sheet.
Definition: xelink.cxx:813
Data structure with information about one Calc sheet.
Definition: xelink.hxx:116
virtual void Save(XclExpStream &rStrm) override
Writes the entire Link table.
Definition: xelink.cxx:2650
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:2636
XclExpLinkMgrImplPtr mxImpl
Definition: xelink.hxx:219
sal_uInt16 mnXclSelCnt
Count of external link sheets.
Definition: xelink.hxx:132
Array of Calc sheet index information.
Definition: xelink.hxx:129
::std::vector< SCTAB > ScTabVec
Definition: xelink.hxx:124
Stores the correct Excel sheet index for each Calc sheet.
Definition: xelink.hxx:61
XclExpLinkManager(const XclExpRoot &rRoot)
Definition: xelink.cxx:2558
Abstract base class for implementation classes of the link manager.
Definition: xelink.cxx:490
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
Definition: xelink.hxx:89
bool InsertExtName(sal_uInt16 &rnExtSheet, sal_uInt16 &rnExtName, const OUString &rUrl, const OUString &rName, const ScExternalRefCache::TokenArrayRef &rArray)
Definition: xelink.cxx:2643
void StoreCellRange(const ScComplexRefData &rRef, const ScAddress &rPos)
Stores all cells in the given range in a CRN record list.
Definition: xelink.cxx:2609
Stores all data for internal/external references (the link table).
Definition: xelink.hxx:145
sal_uInt16 GetXclSelectedCount() const
Returns the number of exported selected sheets.
Definition: xelink.hxx:96
std::shared_ptr< XclExpLinkManagerImpl > XclExpLinkMgrImplPtr
Definition: xelink.hxx:218
unsigned char sal_uInt8
sal_uInt16 GetXclTabCount() const
Returns the number of Excel sheets to be exported.
Definition: xelink.hxx:92
void CalcSortedIndexes()
Sorts the names of all tables and stores the indexes of the sorted indexes.
Definition: xelink.cxx:888
std::shared_ptr< ScTokenArray > TokenArrayRef
Log entry for external references in a formula, used i.e.
Definition: xeformula.hxx:31
Complex reference (a range) into the sheet.
Definition: refdata.hxx:122
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:830
sal_uInt16 GetDisplayedXclTab() const
Returns the Excel index of the active, displayed sheet.
Definition: xelink.hxx:99
virtual ~XclExpLinkManager() override
Definition: xelink.cxx:2574
sal_uInt16 mnXclExtCnt
Count of Excel sheets to be exported.
Definition: xelink.hxx:131
SCTAB GetRealScTab(SCTAB nSortedScTab) const
Returns the Calc sheet index of the nSortedTab-th entry in the sorted sheet names list...
Definition: xelink.cxx:818
void SvStream & rStrm
ScTabVec maFromSortedVec
First visible sheet.
Definition: xelink.hxx:136
bool IsDisplayedTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet is the displayed (active) sheet.
Definition: xelink.cxx:796
sal_Int16 SCTAB
Definition: types.hxx:22