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 "autofilterbuffer.hxx"
23 #include "tablecolumnsbuffer.hxx"
24 #include "workbookhelper.hxx"
26 namespace oox::xls {
28 struct TableModel
29 {
31  OUString maProgName;
32  OUString maDisplayName;
33  sal_Int32 mnId;
34  sal_Int32 mnType;
35  sal_Int32 mnHeaderRows;
36  sal_Int32 mnTotalsRows;
38  explicit TableModel();
39 };
41 class Table : public WorkbookHelper
42 {
43 public:
44  explicit Table( const WorkbookHelper& rHelper );
47  void importTable( const AttributeList& rAttribs, sal_Int16 nSheet );
49  void importTable( SequenceInputStream& rStrm, sal_Int16 nSheet );
56  void finalizeImport();
57  void applyAutoFilters();
58  void applyTableColumns();
61  sal_Int32 getTableId() const { return maModel.mnId; }
63  sal_Int32 getTokenIndex() const { return mnTokenIndex; }
65  const OUString& getDisplayName() const { return maModel.maDisplayName; }
68  const ScRange& getOriginalRange() const { return maModel.maRange; }
70  const ScRange& getRange() const { return maDestRange; }
72  SCCOL getWidth() const { return maDestRange.aEnd.Col() - maDestRange.aStart.Col() + 1; }
74  SCROW getHeight() const { return maDestRange.aEnd.Row() - maDestRange.aStart.Row() + 1; }
76  sal_Int32 getHeaderRows() const { return maModel.mnHeaderRows; }
78  sal_Int32 getTotalsRows() const { return maModel.mnTotalsRows; }
80 private:
84  OUString maDBRangeName;
86  sal_Int32 mnTokenIndex;
87 };
89 typedef std::shared_ptr< Table > TableRef;
92 {
93 public:
94  explicit TableBuffer( const WorkbookHelper& rHelper );
97  Table& createTable();
100  void finalizeImport();
102  void applyAutoFilters();
104  void applyTableColumns();
106  TableRef getTable( sal_Int32 nTableId ) const;
108  TableRef getTable( const OUString& rDispName ) const;
110 private:
112  void insertTableToMaps( const TableRef& rxTable );
114 private:
117  TableVector maTables;
120 };
122 } // namespace oox::xls
124 /* 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:33
ScRange maDestRange
Name of the database range in the Calc document.
Definition: tablebuffer.hxx:85
Table & createTable()
Creates a new empty table.
ScAddress aStart
Definition: address.hxx:497
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:32
SCROW Row() const
Definition: address.hxx:274
void applyAutoFilters()
sal_Int32 mnHeaderRows
Table type (worksheet, query, etc.).
Definition: tablebuffer.hxx:35
sal_Int32 mnTotalsRows
Number of header rows.
Definition: tablebuffer.hxx:36
const ScRange & getRange() const
Returns the cell range of this table.
Definition: tablebuffer.hxx:70
ScAddress aEnd
Definition: address.hxx:498
void applyTableColumns()
sal_Int32 mnTokenIndex
Validated range of the table in the worksheet.
Definition: tablebuffer.hxx:86
Number of totals rows.
Definition: tablebuffer.cxx:41
TableModel maModel
Definition: tablebuffer.hxx:81
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:74
RefMap< sal_Int32, Table > maIdTables
std::shared_ptr< Table > TableRef
Definition: tablebuffer.hxx:89
sal_Int32 getHeaderRows() const
Returns the number of header rows in the table range.
Definition: tablebuffer.hxx:76
OUString maProgName
Original (unchecked) range of the table.
Definition: tablebuffer.hxx:31
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:68
AutoFilterBuffer maAutoFilters
Definition: tablebuffer.hxx:82
TableColumns & createTableColumns()
Creates a new tableColumns handler and stores it internally.
Definition: tablebuffer.hxx:53
sal_Int32 getTotalsRows() const
Returns the number of totals rows in the table range.
Definition: tablebuffer.hxx:78
void finalizeImport()
Creates database ranges from all imported tables.
AutoFilter & createAutoFilter()
Creates a new auto filter and stores it internally.
Definition: tablebuffer.hxx:51
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 getTableId() const
Returns the unique table identifier.
Definition: tablebuffer.hxx:61
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:65
SCCOL getWidth() const
Returns the number of columns of this table.
Definition: tablebuffer.hxx:72
SCCOL Col() const
Definition: address.hxx:279
void finalizeImport()
Creates a database range from this tables.
Definition: tablebuffer.cxx:85
sal_Int32 SCROW
Definition: types.hxx:17
sal_Int32 mnType
Unique table identifier.
Definition: tablebuffer.hxx:34
TableColumnsBuffer maTableColumns
Filter settings for this table.
Definition: tablebuffer.hxx:83
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 (
Definition: tablebuffer.hxx:63
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:84