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
28namespace oox::drawingml::chart { class ChartConverter; }
29namespace rtl { template <class reference_type> class Reference; }
30
31namespace 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
41namespace oox {
42 class SegmentProgressBar;
43}
44
45namespace oox::core {
46 class FilterBase;
47 class FragmentHandler;
48 class XmlFilterBase;
49 class FastParser;
50}
51
52class ScDocument;
55class ScDBData;
56class ScRangeData;
57
58namespace oox::xls {
59
60class ExcelFilter;
61
64{
65 bool operator()( std::u16string_view rName1, std::u16string_view rName2 ) const;
66};
67
72class FormulaParser;
76class ScenarioBuffer;
78class StylesBuffer;
79class TableBuffer;
80class ThemeBuffer;
81class UnitConverter;
82class ViewSettings;
84class WorksheetBuffer;
85class FormulaBuffer;
86
87class WorkbookGlobals;
88typedef std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef;
89
102{
103public:
104 /*implicit*/ WorkbookHelper( WorkbookGlobals& rBookGlob ) : mrBookGlob( rBookGlob ) {}
105 virtual ~WorkbookHelper();
106
107 WorkbookHelper(WorkbookHelper const &) = default;
109 WorkbookHelper & operator =(WorkbookHelper const &) = delete; // due to mrBookGlob
110 WorkbookHelper & operator =(WorkbookHelper &&) = delete; // due to mrBookGlob
111
113
114 // filter -----------------------------------------------------------------
115
121 sal_Int16 getCurrentSheetIndex() const;
123 bool isGeneratorKnownGood() const;
125 bool hasCalculatedFormulaCells() const;
128
130 void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg );
132 void setCurrentSheetIndex( SCTAB nSheet );
135 void useInternalChartDataTable( bool bInternal );
136
137 // document model ---------------------------------------------------------
139 const ScDocument& getScDocument() const;
140
142 const ScDocumentImport& getDocImport() const;
143
146 const css::uno::Reference< css::sheet::XSpreadsheetDocument >&
147 getDocument() const;
148
150 css::uno::Reference< css::sheet::XSpreadsheet >
151 getSheetFromDoc( sal_Int32 nSheet ) const;
153 css::uno::Reference< css::sheet::XSpreadsheet >
154 getSheetFromDoc( const OUString& rSheet ) const;
155
157 css::uno::Reference< css::table::XCellRange >
158 getCellRangeFromDoc( const ScRange& rRange ) const;
159
161 css::uno::Reference< css::container::XNameContainer >
162 getCellStyleFamily() const;
164 css::uno::Reference< css::style::XStyle >
165 getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
166
167 // second is true if ownership belongs to the caller
168 typedef std::pair<ScRangeData*, bool> RangeDataRet;
169
174 OUString& orName,
175 sal_Int32 nIndex,
176 sal_Int32 nNameFlags, bool bHidden ) const;
177
182 OUString& orName,
183 sal_Int32 nIndex,
184 sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden ) const;
185
189 css::uno::Reference< css::sheet::XDatabaseRange >
191 OUString& orName,
192 const ScRange& rRangeAddr ) const;
193
196 css::uno::Reference< css::sheet::XDatabaseRange >
198 const ScRange& rRangeAddr ) const;
199
201 ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex ) const;
202
204 css::uno::Reference< css::style::XStyle >
206 OUString& orStyleName,
207 bool bPageStyle ) const;
208
209 // buffers ----------------------------------------------------------------
210
219 ThemeBuffer& getTheme() const;
221 StylesBuffer& getStyles() const;
229 TableBuffer& getTables() const;
238
239 // converters -------------------------------------------------------------
240
253
254 // OOXML/BIFF12 specific (MUST NOT be called in BIFF filter) --------------
255
259
263
265
266 // BIFF2-BIFF8 specific (MUST NOT be called in OOXML/BIFF12 filter) -------
267
269 rtl_TextEncoding getTextEncoding() const;
270
271private:
273};
274
275} // namespace oox::xls
276
277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Accessor class to ScDocument.
Converter for cell addresses and cell ranges for OOXML and BIFF filters.
Import formula parser for OOXML and BIFF filters.
Collects all strings from the shared strings substream.
Helper class that provides functions to convert values from and to different units.
Helper class to provide access to global workbook data.
void useInternalChartDataTable(bool bInternal)
bool isGeneratorKnownGood() const
Returns true when reading a file generated by a known good generator.
oox::drawingml::chart::ChartConverter * getChartConverter() const
Returns the chart object converter.
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.
void setCalculatedFormulaCells()
Set if any formula cell is calculated.
WorkbookHelper(WorkbookGlobals &rBookGlob)
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler, oox::core::FastParser &rParser)
SharedStringsBuffer & getSharedStrings() const
Returns the shared strings read from the shared strings substream.
ScEditEngineDefaulter & getEditEngine() const
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
bool hasCalculatedFormulaCells() const
Returns true if any formula cell is calculated.
static WorkbookGlobalsRef constructGlobals(ExcelFilter &rFilter)
rtl_TextEncoding getTextEncoding() const
Returns the text encoding used to import/export byte strings.
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...
::oox::core::XmlFilterBase & getOoxFilter() const
Returns the base OOXML/BIFF12 filter object.
WorkbookHelper & operator=(WorkbookHelper const &)=delete
std::pair< ScRangeData *, bool > RangeDataRet
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
PageSettingsConverter & getPageSettingsConverter() const
Returns the page and print settings converter.
void setCurrentSheetIndex(SCTAB nSheet)
Sets the index of the current Calc sheet, if filter currently processes a sheet.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
WorkbookHelper(WorkbookHelper const &)=default
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.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
WorkbookGlobals & mrBookGlob
sal_Int16 getCurrentSheetIndex() const
Returns the index of the current Calc sheet, if filter currently processes a sheet.
css::uno::Reference< css::container::XNameContainer > getCellStyleFamily() const
Returns the cell styles container from the Calc document.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex) const
Finds the (already existing) database range of the given formula token index.
RangeDataRet createLocalNamedRangeObject(OUString &orName, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden) const
Creates and returns a defined name on-the-fly in the sheet.
FormulaBuffer & getFormulaBuffer() const
PivotTableBuffer & getPivotTables() const
Returns the collection of pivot tables.
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
WorkbookHelper(WorkbookHelper &&)=default
ScDocumentImport & getDocImport()
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
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.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
FormulaParser * createFormulaParser() const
Returns an unshared import formula parser (import filter only!).
void setVbaProjectStorage(const StorageRef &rxVbaPrjStrg)
Sets the VBA project storage used to import VBA source code and forms.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
void finalizeWorkbookImport()
Final conversion after importing the workbook.
css::uno::Reference< css::style::XStyle > getStyleObject(const OUString &rStyleName, bool bPageStyle) const
Returns the specified cell or page style from the Calc document.
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
const css::uno::Reference< css::sheet::XSpreadsheetDocument > & getDocument() const
Returns a reference to the source/target spreadsheet document model.
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
FormulaParser & getFormulaParser() const
Returns a shared import formula parser (import filter only!).
ExternalLinkBuffer & getExternalLinks() const
Returns the external links read from the external links substream.
RangeDataRet createNamedRangeObject(OUString &orName, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden) const
Creates and returns a defined name on-the-fly in the Calc document.
Stores information about all sheets in a spreadsheet document.
@ table
Reference
std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef
std::shared_ptr< StorageBase > StorageRef
Functor for case-insensitive string comparison, usable in maps etc.
bool operator()(std::u16string_view rName1, std::u16string_view rName2) const
sal_Int16 SCTAB
Definition: types.hxx:22