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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_WORKBOOKHELPER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_WORKBOOKHELPER_HXX
22 
23 #include <memory>
25 #include <address.hxx>
26 
27 namespace oox::drawingml::chart { class ChartConverter; }
28 namespace rtl { template <class reference_type> class Reference; }
29 
30 namespace com::sun::star {
31  namespace container { class XNameContainer; }
32  namespace sheet { class XDatabaseRange; }
33  namespace sheet { class XSpreadsheet; }
34  namespace sheet { class XSpreadsheetDocument; }
35  namespace sheet { struct FormulaToken; }
36  namespace style { class XStyle; }
37  namespace table { class XCellRange; }
38 }
39 
40 namespace oox {
41  class SegmentProgressBar;
42 }
43 
44 namespace oox::core {
45  class FilterBase;
46  class FragmentHandler;
47  class XmlFilterBase;
48  class FastParser;
49 }
50 
51 class ScDocument;
52 class ScDocumentImport;
54 class ScDBData;
55 class ScRangeData;
56 
57 namespace oox::xls {
58 
59 class ExcelFilter;
60 
63 {
64  bool operator()( const OUString& rName1, const OUString& rName2 ) const;
65 };
66 
67 class AddressConverter;
68 class ConnectionsBuffer;
69 class DefinedNamesBuffer;
70 class ExternalLinkBuffer;
71 class FormulaParser;
73 class PivotCacheBuffer;
74 class PivotTableBuffer;
75 class ScenarioBuffer;
77 class StylesBuffer;
78 class TableBuffer;
79 class ThemeBuffer;
80 class UnitConverter;
81 class ViewSettings;
82 class WorkbookSettings;
83 class WorksheetBuffer;
84 class FormulaBuffer;
85 
87 typedef std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef;
88 
101 {
102 public:
103  /*implicit*/ WorkbookHelper( WorkbookGlobals& rBookGlob ) : mrBookGlob( rBookGlob ) {}
104  virtual ~WorkbookHelper();
105 
106  WorkbookHelper(WorkbookHelper const &) = default;
107  WorkbookHelper(WorkbookHelper &&) = default;
108  WorkbookHelper & operator =(WorkbookHelper const &) = delete; // due to mrBookGlob
109  WorkbookHelper & operator =(WorkbookHelper &&) = delete; // due to mrBookGlob
110 
111  static WorkbookGlobalsRef constructGlobals( ExcelFilter& rFilter );
112 
113  // filter -----------------------------------------------------------------
114 
120  sal_Int16 getCurrentSheetIndex() const;
122  bool isGeneratorKnownGood() const;
123 
125  void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg );
127  void setCurrentSheetIndex( SCTAB nSheet );
129  void finalizeWorkbookImport();
130  void useInternalChartDataTable( bool bInternal );
131 
132  // document model ---------------------------------------------------------
134  const ScDocument& getScDocument() const;
135 
137  const ScDocumentImport& getDocImport() const;
138 
141  const css::uno::Reference< css::sheet::XSpreadsheetDocument >&
142  getDocument() const;
143 
145  css::uno::Reference< css::sheet::XSpreadsheet >
146  getSheetFromDoc( sal_Int32 nSheet ) const;
148  css::uno::Reference< css::sheet::XSpreadsheet >
149  getSheetFromDoc( const OUString& rSheet ) const;
150 
152  css::uno::Reference< css::table::XCellRange >
153  getCellRangeFromDoc( const ScRange& rRange ) const;
154 
156  css::uno::Reference< css::container::XNameContainer >
157  getCellStyleFamily() const;
159  css::uno::Reference< css::style::XStyle >
160  getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
161 
166  OUString& orName,
167  const css::uno::Sequence< css::sheet::FormulaToken>& rTokens,
168  sal_Int32 nIndex,
169  sal_Int32 nNameFlags ) const;
170 
175  OUString& orName,
176  const css::uno::Sequence< css::sheet::FormulaToken>& rTokens,
177  sal_Int32 nIndex,
178  sal_Int32 nNameFlags, sal_Int32 nTab ) const;
179 
183  css::uno::Reference< css::sheet::XDatabaseRange >
185  OUString& orName,
186  const ScRange& rRangeAddr ) const;
187 
190  css::uno::Reference< css::sheet::XDatabaseRange >
192  const ScRange& rRangeAddr ) const;
193 
195  ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex ) const;
196 
198  css::uno::Reference< css::style::XStyle >
200  OUString& orStyleName,
201  bool bPageStyle ) const;
202 
203  // buffers ----------------------------------------------------------------
204 
209  ViewSettings& getViewSettings() const;
213  ThemeBuffer& getTheme() const;
215  StylesBuffer& getStyles() const;
223  TableBuffer& getTables() const;
225  ScenarioBuffer& getScenarios() const;
232 
233  // converters -------------------------------------------------------------
234 
247 
248  // OOXML/BIFF12 specific (MUST NOT be called in BIFF filter) --------------
249 
253 
257 
259 
260  // BIFF2-BIFF8 specific (MUST NOT be called in OOXML/BIFF12 filter) -------
261 
263  rtl_TextEncoding getTextEncoding() const;
264 
265 private:
267 };
268 
269 } // namespace oox::xls
270 
271 #endif
272 
273 /* 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)
bool operator()(const OUString &rName1, const OUString &rName2) const
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)
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:23
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.