LibreOffice Module sc (master) 1
autofilterbuffer.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 <oox/helper/helper.hxx>
24#include "workbookhelper.hxx"
25#include <com/sun/star/sheet/TableFilterField3.hpp>
26#include <com/sun/star/util/Color.hpp>
27
28namespace com::sun::star {
29 namespace sheet { class XDatabaseRange; }
30 namespace sheet { class XSheetFilterDescriptor3; }
31}
32
33namespace oox { class AttributeList; }
34namespace oox { class SequenceInputStream; }
35
36namespace oox {
37namespace xls {
38
41{
42 typedef ::std::vector<css::sheet::TableFilterField3> FilterFieldVector;
43
45 std::optional< bool > mobNeedsRegExp;
46
47 explicit ApiFilterSettings();
48
49 void appendField( bool bAnd, sal_Int32 nOperator, double fValue );
50 void appendField( bool bAnd, sal_Int32 nOperator, const OUString& rValue );
51 void appendField( bool bAnd, css::util::Color aColor, bool bIsBackgroundColor );
52 void appendField( bool bAnd, const std::vector<std::pair<OUString, bool>>& rValues );
53};
54
58{
59public:
60 explicit FilterSettingsBase( const WorkbookHelper& rHelper );
61
63 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs );
65 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
66
69};
70
71
76{
77public:
78 explicit DiscreteFilter( const WorkbookHelper& rHelper );
79
81 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
83 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
84
86 virtual ApiFilterSettings finalizeImport() override;
87
88private:
89
90 std::vector<std::pair<OUString, bool>> maValues; // first->values, second->bDatefFormat
91 sal_Int32 mnCalendarType;
93};
94
96class Top10Filter final : public FilterSettingsBase
97{
98public:
99 explicit Top10Filter( const WorkbookHelper& rHelper );
100
102 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
104 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
105
107 virtual ApiFilterSettings finalizeImport() override;
108
109private:
110 double mfValue;
111 bool mbTop;
113};
114
116class ColorFilter final : public FilterSettingsBase
117{
118public:
119 explicit ColorFilter(const WorkbookHelper& rHelper);
120
122 virtual void importAttribs(sal_Int32 nElement, const AttributeList& rAttribs) override;
124 virtual void importRecord(sal_Int32 nRecId, SequenceInputStream& rStrm) override;
125
127 virtual ApiFilterSettings finalizeImport() override;
128
129private:
133 OUString msStyleName;
134};
135
138{
139 css::uno::Any maValue;
140 sal_Int32 mnOperator;
142
143 explicit FilterCriterionModel();
144
146 void setBiffOperator( sal_uInt8 nOperator );
147
149 void readBiffData( SequenceInputStream& rStrm );
150};
151
156{
157public:
158 explicit CustomFilter( const WorkbookHelper& rHelper );
159
161 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
163 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
164
166 virtual ApiFilterSettings finalizeImport() override;
167
168private:
170 void appendCriterion( const FilterCriterionModel& rCriterion );
171
172private:
173 typedef ::std::vector< FilterCriterionModel > FilterCriterionVector;
174
176 bool mbAnd;
177};
178
182class FilterColumn final : public WorkbookHelper
183{
184public:
185 explicit FilterColumn( const WorkbookHelper& rHelper );
186
188 void importFilterColumn( const AttributeList& rAttribs );
191
193 template< typename FilterSettingsType >
195 { mxSettings = std::make_shared<FilterSettingsType>( *this ); return *mxSettings; }
196
200
201private:
202 std::shared_ptr< FilterSettingsBase >
204 sal_Int32 mnColId;
207};
208
209// class SortCondition
210
211class SortCondition final : public WorkbookHelper
212{
213public:
214 explicit SortCondition( const WorkbookHelper& rHelper );
215
216 void importSortCondition( const AttributeList& rAttribs, sal_Int16 nSheet );
217
218 ScRange maRange; // Column/Row that this sort condition applies to.
219 OUString maSortCustomList; // Sort by a custom list.
221};
222
223// class AutoFilter
224
225class AutoFilter final : public WorkbookHelper
226{
227public:
228 explicit AutoFilter( const WorkbookHelper& rHelper );
229
231 void importAutoFilter( const AttributeList& rAttribs, sal_Int16 nSheet );
233 void importAutoFilter( SequenceInputStream& rStrm, sal_Int16 nSheet );
234
235 void importSortState( const AttributeList& rAttribs, sal_Int16 nSheet );
236
239
241
243 void finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
244 sal_Int16 nSheet );
245
246private:
248
251
252 ScRange maSortRange; // The whole range of data to sort (not just the sort-by column).
255};
256
258{
259public:
260 explicit AutoFilterBuffer( const WorkbookHelper& rHelper );
261
264
267 void finalizeImport( sal_Int16 nSheet );
268
271 bool finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
272 sal_Int16 nSheet );
273
274private:
277
278private:
281};
282
283} // namespace xls
284} // namespace oox
285
286/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool finalizeImport(const css::uno::Reference< css::sheet::XDatabaseRange > &rxDatabaseRange, sal_Int16 nSheet)
Applies the filters to the passed database range object.
AutoFilter * getActiveAutoFilter()
Returns the auto filter object used to perform auto filtering.
void finalizeImport(sal_Int16 nSheet)
Applies filter settings to a new database range object (used for sheet autofilter or advanced filter ...
AutoFilter & createAutoFilter()
Creates a new auto filter and stores it internally.
AutoFilterBuffer(const WorkbookHelper &rHelper)
RefVector< AutoFilter > AutoFilterVector
AutoFilter(const WorkbookHelper &rHelper)
RefVector< SortCondition > SortConditionVector
SortCondition & createSortCondition()
void importSortState(const AttributeList &rAttribs, sal_Int16 nSheet)
void finalizeImport(const css::uno::Reference< css::sheet::XDatabaseRange > &rxDatabaseRange, sal_Int16 nSheet)
Applies the filter to the passed filter descriptor.
void importAutoFilter(const AttributeList &rAttribs, sal_Int16 nSheet)
Imports auto filter settings from the autoFilter element.
FilterColumnVector maFilterColumns
FilterColumn & createFilterColumn()
Creates a new auto filter column and stores it internally.
RefVector< FilterColumn > FilterColumnVector
SortConditionVector maSortConditions
Settings for a color filter.
OUString msStyleName
Style name to retrieve the color from.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
ColorFilter(const WorkbookHelper &rHelper)
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
bool mbIsBackgroundColor
Whether we are dealing with the background color (vs. text color)
Settings for a custom filter, specifying one or two comparison operators associated with some values.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
void appendCriterion(const FilterCriterionModel &rCriterion)
Appends the passed filter criterion, if it contains valid settings.
::std::vector< FilterCriterionModel > FilterCriterionVector
FilterCriterionVector maCriteria
CustomFilter(const WorkbookHelper &rHelper)
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
Settings for a discrete filter, specifying a list of values to be shown in the filtered range.
DiscreteFilter(const WorkbookHelper &rHelper)
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
std::vector< std::pair< OUString, bool > > maValues
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
A column in a filtered range.
FilterColumn(const WorkbookHelper &rHelper)
FilterSettingsBase & createFilterSettings()
Creates and returns the specified filter settings object.
void importFilterColumn(const AttributeList &rAttribs)
Imports auto filter column settings from the filterColumn element.
ApiFilterSettings finalizeImport()
Returns converted UNO API filter settings representing all filter settings of this column.
std::shared_ptr< FilterSettingsBase > mxSettings
Base class for specific filter settings for a column in a filtered range.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs)
Derived classes import filter settings from the passed attribute list.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm)
Derived classes import filter settings from the passed record.
FilterSettingsBase(const WorkbookHelper &rHelper)
virtual ApiFilterSettings finalizeImport()
Derived classes return converted UNO API filter settings representing all filter settings.
SortCondition(const WorkbookHelper &rHelper)
void importSortCondition(const AttributeList &rAttribs, sal_Int16 nSheet)
Settings for a top-10 filter.
Top10Filter(const WorkbookHelper &rHelper)
bool mbTop
Number of items or percentage.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
bool mbPercent
True = show top (greatest) items/percentage.
Helper class to provide access to global workbook data.
void SvStream & rStrm
Contains UNO API filter settings for a column in a filtered range.
::std::vector< css::sheet::TableFilterField3 > FilterFieldVector
FilterFieldVector maFilterFields
std::optional< bool > mobNeedsRegExp
List of UNO API filter settings.
void appendField(bool bAnd, sal_Int32 nOperator, double fValue)
ApiFilterSettings()
If set, requires regular expressions to be enabled/disabled.
void appendField(bool bAnd, css::util::Color aColor, bool bIsBackgroundColor)
A filter criterion for a custom filter.
void readBiffData(SequenceInputStream &rStrm)
Imports the criterion model from the passed BIFF12 stream.
sal_Int32 mnOperator
Comparison operand.
void setBiffOperator(sal_uInt8 nOperator)
Sets the passed BIFF operator constant.
FilterCriterionModel()
Operand data type (BIFF only).
sal_uInt8 mnDataType
Comparison operator.
unsigned char sal_uInt8