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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_AUTOFILTERBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_AUTOFILTERBUFFER_HXX
22 
23 #include <oox/helper/helper.hxx>
24 #include <oox/helper/refvector.hxx>
25 #include "workbookhelper.hxx"
26 #include <com/sun/star/sheet/TableFilterField3.hpp>
27 
28 namespace com::sun::star {
29  namespace sheet { class XDatabaseRange; }
30  namespace sheet { class XSheetFilterDescriptor3; }
31 }
32 
33 namespace oox { class AttributeList; }
34 namespace oox { class SequenceInputStream; }
35 
36 namespace oox {
37 namespace xls {
38 
41 {
42  typedef ::std::vector<css::sheet::TableFilterField3> FilterFieldVector;
43 
44  FilterFieldVector maFilterFields;
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, const std::vector<OUString>& rValues );
52 };
53 
57 {
58 public:
59  explicit FilterSettingsBase( const WorkbookHelper& rHelper );
60 
62  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs );
64  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
65 
67  virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
68 };
69 
70 
75 {
76 public:
77  explicit DiscreteFilter( const WorkbookHelper& rHelper );
78 
80  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
82  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
83 
85  virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
86 
87 private:
88 
89  std::vector< OUString > maValues;
90  sal_Int32 mnCalendarType;
92 };
93 
96 {
97 public:
98  explicit Top10Filter( const WorkbookHelper& rHelper );
99 
101  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
103  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
104 
106  virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
107 
108 private:
109  double mfValue;
110  bool mbTop;
111  bool mbPercent;
112 };
113 
116 {
117  css::uno::Any maValue;
118  sal_Int32 mnOperator;
120 
121  explicit FilterCriterionModel();
122 
124  void setBiffOperator( sal_uInt8 nOperator );
125 
127  void readBiffData( SequenceInputStream& rStrm );
128 };
129 
134 {
135 public:
136  explicit CustomFilter( const WorkbookHelper& rHelper );
137 
139  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
141  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
142 
144  virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
145 
146 private:
148  void appendCriterion( const FilterCriterionModel& rCriterion );
149 
150 private:
151  typedef ::std::vector< FilterCriterionModel > FilterCriterionVector;
152 
153  FilterCriterionVector maCriteria;
154  bool mbAnd;
155 };
156 
161 {
162 public:
163  explicit FilterColumn( const WorkbookHelper& rHelper );
164 
166  void importFilterColumn( const AttributeList& rAttribs );
169 
171  template< typename FilterSettingsType >
173  { mxSettings = std::make_shared<FilterSettingsType>( *this ); return *mxSettings; }
174 
177  ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
178 
179 private:
180  std::shared_ptr< FilterSettingsBase >
182  sal_Int32 mnColId;
185 };
186 
187 // class SortCondition
188 
190 {
191 public:
192  explicit SortCondition( const WorkbookHelper& rHelper );
193 
194  void importSortCondition( const AttributeList& rAttribs, sal_Int16 nSheet );
195 
196  ScRange maRange; // Column/Row that this sort condition applies to.
197  OUString maSortCustomList; // Sort by a custom list.
199 };
200 
201 // class AutoFilter
202 
204 {
205 public:
206  explicit AutoFilter( const WorkbookHelper& rHelper );
207 
209  void importAutoFilter( const AttributeList& rAttribs, sal_Int16 nSheet );
211  void importAutoFilter( SequenceInputStream& rStrm, sal_Int16 nSheet );
212 
213  void importSortState( const AttributeList& rAttribs, sal_Int16 nSheet );
214 
217 
219 
221  void finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
222  sal_Int16 nSheet );
223 
224 private:
226 
227  FilterColumnVector maFilterColumns;
229 
230  ScRange maSortRange; // The whole range of data to sort (not just the sort-by column).
232  SortConditionVector maSortConditions;
233 };
234 
236 {
237 public:
238  explicit AutoFilterBuffer( const WorkbookHelper& rHelper );
239 
242 
245  void finalizeImport( sal_Int16 nSheet );
246 
249  bool finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
250  sal_Int16 nSheet );
251 
252 private:
255 
256 private:
258  AutoFilterVector maAutoFilters;
259 };
260 
261 } // namespace xls
262 } // namespace oox
263 
264 #endif
265 
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
void importSortState(const AttributeList &rAttribs, sal_Int16 nSheet)
::std::vector< css::sheet::TableFilterField3 > FilterFieldVector
void appendCriterion(const FilterCriterionModel &rCriterion)
Appends the passed filter criterion, if it contains valid settings.
sal_Int32 mnOperator
Comparison operand.
bool mbTop
Number of items or percentage.
SortConditionVector maSortConditions
FilterColumnVector maFilterColumns
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs)
Derived classes import filter settings from the passed attribute list.
OptValue< bool > mobNeedsRegExp
List of UNO API filter settings.
Contains UNO API filter settings for a column in a filtered range.
exports com.sun.star. sheet
void importAutoFilter(const AttributeList &rAttribs, sal_Int16 nSheet)
Imports auto filter settings from the autoFilter element.
virtual ApiFilterSettings finalizeImport(sal_Int32 nMaxCount) override
Returns converted UNO API filter settings representing all filter settings.
AutoFilter & createAutoFilter()
Creates a new auto filter and stores it internally.
A filter criterion for a custom filter.
SortCondition & createSortCondition()
void importFilterColumn(const AttributeList &rAttribs)
Imports auto filter column settings from the filterColumn element.
FilterCriterionModel()
Operand data type (BIFF only).
RefVector< AutoFilter > AutoFilterVector
void importSortCondition(const AttributeList &rAttribs, sal_Int16 nSheet)
Settings for a custom filter, specifying one or two comparison operators associated with some values...
AutoFilter(const WorkbookHelper &rHelper)
FilterCriterionVector maCriteria
DiscreteFilter(const WorkbookHelper &rHelper)
CustomFilter(const WorkbookHelper &rHelper)
RefVector< SortCondition > SortConditionVector
FilterColumn(const WorkbookHelper &rHelper)
AutoFilter * getActiveAutoFilter()
Returns the auto filter object used to perform auto filtering.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
std::vector< OUString > maValues
ApiFilterSettings()
If set, requires regular expressions to be enabled/disabled.
FilterSettingsBase & createFilterSettings()
Creates and returns the specified filter settings object.
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs) override
Imports filter settings from the filters and filter elements.
sal_uInt8 mnDataType
Comparison operator.
void finalizeImport(sal_Int16 nSheet)
Applies filter settings to a new database range object (used for sheet autofilter or advanced filter ...
void appendField(bool bAnd, sal_Int32 nOperator, double fValue)
void readBiffData(SequenceInputStream &rStrm)
Imports the criterion model from the passed BIFF12 stream.
RefVector< FilterColumn > FilterColumnVector
FilterColumn & createFilterColumn()
Creates a new auto filter column and stores it internally.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Imports filter settings from the FILTERS and FILTER records.
ApiFilterSettings finalizeImport(sal_Int32 nMaxCount)
Returns converted UNO API filter settings representing all filter settings of this column...
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)
Derived classes import filter settings from the passed record.
SortCondition(const WorkbookHelper &rHelper)
bool mbPercent
True = show top (greatest) items/percentage.
unsigned char sal_uInt8
A column in a filtered range.
FilterSettingsBase(const WorkbookHelper &rHelper)
std::shared_ptr< FilterSettingsBase > mxSettings
::std::vector< FilterCriterionModel > FilterCriterionVector
virtual ApiFilterSettings finalizeImport(sal_Int32 nMaxCount) override
Returns converted UNO API filter settings representing all filter settings.
void finalizeImport(const css::uno::Reference< css::sheet::XDatabaseRange > &rxDatabaseRange, sal_Int16 nSheet)
Applies the filter to the passed filter descriptor.
Settings for a discrete filter, specifying a list of values to be shown in the filtered range...
Top10Filter(const WorkbookHelper &rHelper)
Base class for specific filter settings for a column in a filtered range.
Settings for a top-10 filter.
virtual ApiFilterSettings finalizeImport(sal_Int32 nMaxCount) 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.
void setBiffOperator(sal_uInt8 nOperator)
Sets the passed BIFF operator constant.
void SvStream & rStrm
AutoFilterBuffer(const WorkbookHelper &rHelper)
FilterFieldVector maFilterFields
virtual ApiFilterSettings finalizeImport(sal_Int32 nMaxCount)
Derived classes return converted UNO API filter settings representing all filter settings.