LibreOffice Module sc (master)  1
workbookhelper.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 <string_view>
24 
26 #include <address.hxx>
27 
28 namespace oox::drawingml::chart { class ChartConverter; }
29 namespace rtl { template <class reference_type> class Reference; }
30 
31 namespace com::sun::star {
32  namespace container { class XNameContainer; }
33  namespace sheet { class XDatabaseRange; }
34  namespace sheet { class XSpreadsheet; }
35  namespace sheet { class XSpreadsheetDocument; }
36  namespace sheet { struct FormulaToken; }
37  namespace style { class XStyle; }
38  namespace table { class XCellRange; }
39 }
40 
41 namespace oox {
42  class SegmentProgressBar;
43 }
44 
45 namespace oox::core {
46  class FilterBase;
47  class FragmentHandler;
48  class XmlFilterBase;
49  class FastParser;
50 }
51 
52 class ScDocument;
53 class ScDocumentImport;
55 class ScDBData;
56 class ScRangeData;
57 
58 namespace oox::xls {
59 
60 class ExcelFilter;
61 
64 {
65  bool operator()( const OUString& rName1, std::u16string_view rName2 ) const;
66 };
67 
68 class AddressConverter;
69 class ConnectionsBuffer;
70 class DefinedNamesBuffer;
71 class ExternalLinkBuffer;
72 class FormulaParser;
74 class PivotCacheBuffer;
75 class PivotTableBuffer;
76 class ScenarioBuffer;
78 class StylesBuffer;
79 class TableBuffer;
80 class ThemeBuffer;
81 class UnitConverter;
82 class ViewSettings;
83 class WorkbookSettings;
84 class WorksheetBuffer;
85 class FormulaBuffer;
86 
88 typedef std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef;
89 
102 {
103 public:
104  /*implicit*/ WorkbookHelper( WorkbookGlobals& rBookGlob ) : mrBookGlob( rBookGlob ) {}
105  virtual ~WorkbookHelper();
106 
107  WorkbookHelper(WorkbookHelper const &) = default;
108  WorkbookHelper(WorkbookHelper &&) = default;
109  WorkbookHelper & operator =(WorkbookHelper const &) = delete; // due to mrBookGlob
110  WorkbookHelper & operator =(WorkbookHelper &&) = delete; // due to mrBookGlob
111 
112  static WorkbookGlobalsRef constructGlobals( ExcelFilter& rFilter );
113 
114  // filter -----------------------------------------------------------------
115 
121  sal_Int16 getCurrentSheetIndex() const;
123  bool isGeneratorKnownGood() const;
124 
126  void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg );
128  void setCurrentSheetIndex( SCTAB nSheet );
130  void finalizeWorkbookImport();
131  void useInternalChartDataTable( bool bInternal );
132 
133  // document model ---------------------------------------------------------
135  const ScDocument& getScDocument() const;
136 
138  const ScDocumentImport& getDocImport() const;
139 
142  const css::uno::Reference< css::sheet::XSpreadsheetDocument >&
143  getDocument() const;
144 
146  css::uno::Reference< css::sheet::XSpreadsheet >
147  getSheetFromDoc( sal_Int32 nSheet ) const;
149  css::uno::Reference< css::sheet::XSpreadsheet >
150  getSheetFromDoc( const OUString& rSheet ) const;
151 
153  css::uno::Reference< css::table::XCellRange >
154  getCellRangeFromDoc( const ScRange& rRange ) const;
155 
157  css::uno::Reference< css::container::XNameContainer >
158  getCellStyleFamily() const;
160  css::uno::Reference< css::style::XStyle >
161  getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
162 
167  OUString& orName,
168  const css::uno::Sequence< css::sheet::FormulaToken>& rTokens,
169  sal_Int32 nIndex,
170  sal_Int32 nNameFlags ) const;
171 
176  OUString& orName,
177  const css::uno::Sequence< css::sheet::FormulaToken>& rTokens,
178  sal_Int32 nIndex,
179  sal_Int32 nNameFlags, sal_Int32 nTab ) const;
180 
184  css::uno::Reference< css::sheet::XDatabaseRange >
186  OUString& orName,
187  const ScRange& rRangeAddr ) const;
188 
191  css::uno::Reference< css::sheet::XDatabaseRange >
193  const ScRange& rRangeAddr ) const;
194 
196  ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex ) const;
197 
199  css::uno::Reference< css::style::XStyle >
201  OUString& orStyleName,
202  bool bPageStyle ) const;
203 
204  // buffers ----------------------------------------------------------------
205 
210  ViewSettings& getViewSettings() const;
214  ThemeBuffer& getTheme() const;
216  StylesBuffer& getStyles() const;
224  TableBuffer& getTables() const;
226  ScenarioBuffer& getScenarios() const;
233 
234  // converters -------------------------------------------------------------
235 
248 
249  // OOXML/BIFF12 specific (MUST NOT be called in BIFF filter) --------------
250 
254 
258 
260 
261  // BIFF2-BIFF8 specific (MUST NOT be called in OOXML/BIFF12 filter) -------
262 
264  rtl_TextEncoding getTextEncoding() const;
265 
266 private:
268 };
269 
270 } // namespace oox::xls
271 
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
void setCurrentSheetIndex(SCTAB nSheet)
Sets the index of the current Calc sheet, if filter currently processes a sheet.
ScDocumentImport & getDocImport()
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
oox::drawingml::chart::ChartConverter * getChartConverter() const
Returns the chart object converter.
Stores information about all sheets in a spreadsheet document.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
bool isGeneratorKnownGood() const
Returns true when reading a file generated by a known good generator.
css::uno::Reference< css::style::XStyle > getStyleObject(const OUString &rStyleName, bool bPageStyle) const
Returns the specified cell or page style from the Calc document.
Collects all strings from the shared strings substream.
Reference
exports com.sun.star. table
Helper class that provides functions to convert values from and to different units.
WorkbookGlobals & mrBookGlob
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
WorkbookHelper(WorkbookGlobals &rBookGlob)
rtl_TextEncoding getTextEncoding() const
Returns the text encoding used to import/export byte strings.
std::shared_ptr< StorageBase > StorageRef
Accessor class to ScDocument.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
exports com.sun.star. sheet
exports com.sun.star. container
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
css::uno::Reference< css::style::XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle) const
Creates and returns a com.sun.star.style.Style object for cells or pages.
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex) const
Finds the (already existing) database range of the given formula token index.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
sal_Int16 getCurrentSheetIndex() const
Returns the index of the current Calc sheet, if filter currently processes a sheet.
void useInternalChartDataTable(bool bInternal)
ScRangeData * createLocalNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab) const
Creates and returns a defined name on-the-fly in the sheet.
void finalizeWorkbookImport()
Final conversion after importing the workbook.
PageSettingsConverter & getPageSettingsConverter() const
Returns the page and print settings converter.
const css::uno::Reference< css::sheet::XSpreadsheetDocument > & getDocument() const
Returns a reference to the source/target spreadsheet document model.
css::uno::Reference< css::container::XNameContainer > getCellStyleFamily() const
Returns the cell styles container from the Calc document.
ExternalLinkBuffer & getExternalLinks() const
Returns the external links read from the external links substream.
FormulaParser * createFormulaParser() const
Returns an unshared import formula parser (import filter only!).
::oox::core::XmlFilterBase & getOoxFilter() const
Returns the base OOXML/BIFF12 filter object.
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef
ScRangeData * createNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags) const
Creates and returns a defined name on-the-fly in the Calc document.
ScEditEngineDefaulter & getEditEngine() const
exports com.sun.star. style
static WorkbookGlobalsRef constructGlobals(ExcelFilter &rFilter)
bool operator()(const OUString &rName1, std::u16string_view rName2) const
Converter for cell addresses and cell ranges for OOXML and BIFF filters.
css::uno::Reference< css::sheet::XDatabaseRange > createDatabaseRangeObject(OUString &orName, const ScRange &rRangeAddr) const
Creates and returns a database range on-the-fly in the Calc document.
SharedStringsBuffer & getSharedStrings() const
Returns the shared strings read from the shared strings substream.
Import formula parser for OOXML and BIFF filters.
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
FormulaParser & getFormulaParser() const
Returns a shared import formula parser (import filter only!).
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
PivotTableBuffer & getPivotTables() const
Returns the collection of pivot tables.
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
void setVbaProjectStorage(const StorageRef &rxVbaPrjStrg)
Sets the VBA project storage used to import VBA source code and forms.
css::uno::Reference< css::sheet::XDatabaseRange > createUnnamedDatabaseRangeObject(const ScRange &rRangeAddr) const
Creates and returns an unnamed database range on-the-fly in the Calc document.
WorkbookHelper & operator=(WorkbookHelper const &)=delete
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
sal_Int16 SCTAB
Definition: types.hxx:22
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
FormulaBuffer & getFormulaBuffer() const
Functor for case-insensitive string comparison, usable in maps etc.
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.