LibreOffice Module sc (master)  1
tablebuffer.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_TABLEBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_TABLEBUFFER_HXX
22 
23 #include "autofilterbuffer.hxx"
24 #include "tablecolumnsbuffer.hxx"
25 #include "workbookhelper.hxx"
26 
27 namespace oox::xls {
28 
29 struct TableModel
30 {
32  OUString maProgName;
33  OUString maDisplayName;
34  sal_Int32 mnId;
35  sal_Int32 mnType;
36  sal_Int32 mnHeaderRows;
37  sal_Int32 mnTotalsRows;
38 
39  explicit TableModel();
40 };
41 
42 class Table : public WorkbookHelper
43 {
44 public:
45  explicit Table( const WorkbookHelper& rHelper );
46 
48  void importTable( const AttributeList& rAttribs, sal_Int16 nSheet );
50  void importTable( SequenceInputStream& rStrm, sal_Int16 nSheet );
55 
57  void finalizeImport();
58  void applyAutoFilters();
59  void applyTableColumns();
60 
62  sal_Int32 getTableId() const { return maModel.mnId; }
64  sal_Int32 getTokenIndex() const { return mnTokenIndex; }
66  const OUString& getDisplayName() const { return maModel.maDisplayName; }
67 
69  const ScRange& getOriginalRange() const { return maModel.maRange; }
71  const ScRange& getRange() const { return maDestRange; }
73  SCCOL getWidth() const { return maDestRange.aEnd.Col() - maDestRange.aStart.Col() + 1; }
75  SCROW getHeight() const { return maDestRange.aEnd.Row() - maDestRange.aStart.Row() + 1; }
77  sal_Int32 getHeaderRows() const { return maModel.mnHeaderRows; }
79  sal_Int32 getTotalsRows() const { return maModel.mnTotalsRows; }
80 
81 private:
85  OUString maDBRangeName;
87  sal_Int32 mnTokenIndex;
88 };
89 
90 typedef std::shared_ptr< Table > TableRef;
91 
93 {
94 public:
95  explicit TableBuffer( const WorkbookHelper& rHelper );
96 
98  Table& createTable();
99 
101  void finalizeImport();
103  void applyAutoFilters();
105  void applyTableColumns();
107  TableRef getTable( sal_Int32 nTableId ) const;
109  TableRef getTable( const OUString& rDispName ) const;
110 
111 private:
113  void insertTableToMaps( const TableRef& rxTable );
114 
115 private:
117 
118  TableVector maTables;
121 };
122 
123 } // namespace oox::xls
124 
125 #endif
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void insertTableToMaps(const TableRef &rxTable)
Inserts the passed table into the maps according to its identifier and name.
Helper class to provide access to global workbook data.
sal_Int32 mnId
Display name.
Definition: tablebuffer.hxx:34
ScRange maDestRange
Name of the database range in the Calc document.
Definition: tablebuffer.hxx:86
Table & createTable()
Creates a new empty table.
ScAddress aStart
Definition: address.hxx:500
void importTable(const AttributeList &rAttribs, sal_Int16 nSheet)
Imports a table definition from the passed attributes.
Definition: tablebuffer.cxx:57
OUString maDisplayName
Programmatical name.
Definition: tablebuffer.hxx:33
SCROW Row() const
Definition: address.hxx:262
void applyAutoFilters()
sal_Int32 mnHeaderRows
Table type (worksheet, query, etc.).
Definition: tablebuffer.hxx:36
sal_Int32 mnTotalsRows
Number of header rows.
Definition: tablebuffer.hxx:37
const ScRange & getRange() const
Returns the cell range of this table.
Definition: tablebuffer.hxx:71
ScAddress aEnd
Definition: address.hxx:501
void applyTableColumns()
sal_Int32 mnTokenIndex
Validated range of the table in the worksheet.
Definition: tablebuffer.hxx:87
TableModel()
Number of totals rows.
Definition: tablebuffer.cxx:41
TableModel maModel
Definition: tablebuffer.hxx:82
AutoFilter & createAutoFilter()
Creates a new auto filter and stores it internally.
SCROW getHeight() const
Returns the number of rows of this table.
Definition: tablebuffer.hxx:75
RefMap< sal_Int32, Table > maIdTables
std::shared_ptr< Table > TableRef
Definition: tablebuffer.hxx:90
sal_Int32 getHeaderRows() const
Returns the number of header rows in the table range.
Definition: tablebuffer.hxx:77
OUString maProgName
Original (unchecked) range of the table.
Definition: tablebuffer.hxx:32
void applyAutoFilters()
Applies autofilters from created database range ( requires finalizeImport to have run before being ca...
const ScRange & getOriginalRange() const
Returns the original (unchecked) total range of the table.
Definition: tablebuffer.hxx:69
AutoFilterBuffer maAutoFilters
Definition: tablebuffer.hxx:83
TableColumns & createTableColumns()
Creates a new tableColumns handler and stores it internally.
Definition: tablebuffer.hxx:54
sal_Int32 getTotalsRows() const
Returns the number of totals rows in the table range.
Definition: tablebuffer.hxx:79
void finalizeImport()
Creates database ranges from all imported tables.
AutoFilter & createAutoFilter()
Creates a new auto filter and stores it internally.
Definition: tablebuffer.hxx:52
sal_Int16 SCCOL
Definition: types.hxx:22
sal_Int32 getTableId() const
Returns the unique table identifier.
Definition: tablebuffer.hxx:62
TableColumns & createTableColumns()
Creates a new table columns object and stores it internally.
void applyTableColumns()
Applies columns names from created database range ( requires finalizeImport to have run before being ...
const OUString & getDisplayName() const
Returns the original display name of the table.
Definition: tablebuffer.hxx:66
SCCOL getWidth() const
Returns the number of columns of this table.
Definition: tablebuffer.hxx:73
SCCOL Col() const
Definition: address.hxx:267
void finalizeImport()
Creates a database range from this tables.
Definition: tablebuffer.cxx:85
sal_Int32 SCROW
Definition: types.hxx:18
sal_Int32 mnType
Unique table identifier.
Definition: tablebuffer.hxx:35
TableColumnsBuffer maTableColumns
Filter settings for this table.
Definition: tablebuffer.hxx:84
TableRef getTable(sal_Int32 nTableId) const
Returns a table by its identifier.
sal_Int32 getTokenIndex() const
Returns the token index used in API token arrays (com.sun.star.sheet.FormulaToken).
Definition: tablebuffer.hxx:64
RefMap< OUString, Table > maNameTables
void SvStream & rStrm
Table(const WorkbookHelper &rHelper)
Definition: tablebuffer.cxx:49
TableBuffer(const WorkbookHelper &rHelper)
RefVector< Table > TableVector
OUString maDBRangeName
Column names of this table.
Definition: tablebuffer.hxx:85