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>
23 #include <oox/helper/refvector.hxx>
24 #include "workbookhelper.hxx"
25 #include <com/sun/star/sheet/TableFilterField3.hpp>
26 
27 namespace com::sun::star {
28  namespace sheet { class XDatabaseRange; }
29  namespace sheet { class XSheetFilterDescriptor3; }
30 }
31 
32 namespace oox { class AttributeList; }
33 namespace oox { class SequenceInputStream; }
34 
35 namespace oox {
36 namespace xls {
37 
40 {
41  typedef ::std::vector<css::sheet::TableFilterField3> FilterFieldVector;
42 
43  FilterFieldVector maFilterFields;
45 
46  explicit ApiFilterSettings();
47 
48  void appendField( bool bAnd, sal_Int32 nOperator, double fValue );
49  void appendField( bool bAnd, sal_Int32 nOperator, const OUString& rValue );
50  void appendField( bool bAnd, const std::vector<std::pair<OUString, bool>>& rValues );
51 };
52 
56 {
57 public:
58  explicit FilterSettingsBase( const WorkbookHelper& rHelper );
59 
61  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs );
63  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
64 
67 };
68 
69 
74 {
75 public:
76  explicit DiscreteFilter( const WorkbookHelper& rHelper );
77 
79  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
81  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
82 
84  virtual ApiFilterSettings finalizeImport() override;
85 
86 private:
87 
88  std::vector<std::pair<OUString, bool>> maValues; // first->values, second->bDatefFormat
89  sal_Int32 mnCalendarType;
91 };
92 
95 {
96 public:
97  explicit Top10Filter( const WorkbookHelper& rHelper );
98 
100  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
102  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
103 
105  virtual ApiFilterSettings finalizeImport() override;
106 
107 private:
108  double mfValue;
109  bool mbTop;
110  bool mbPercent;
111 };
112 
115 {
116  css::uno::Any maValue;
117  sal_Int32 mnOperator;
119 
120  explicit FilterCriterionModel();
121 
123  void setBiffOperator( sal_uInt8 nOperator );
124 
126  void readBiffData( SequenceInputStream& rStrm );
127 };
128 
133 {
134 public:
135  explicit CustomFilter( const WorkbookHelper& rHelper );
136 
138  virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) override;
140  virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
141 
143  virtual ApiFilterSettings finalizeImport() override;
144 
145 private:
147  void appendCriterion( const FilterCriterionModel& rCriterion );
148 
149 private:
150  typedef ::std::vector< FilterCriterionModel > FilterCriterionVector;
151 
152  FilterCriterionVector maCriteria;
153  bool mbAnd;
154 };
155 
160 {
161 public:
162  explicit FilterColumn( const WorkbookHelper& rHelper );
163 
165  void importFilterColumn( const AttributeList& rAttribs );
168 
170  template< typename FilterSettingsType >
172  { mxSettings = std::make_shared<FilterSettingsType>( *this ); return *mxSettings; }
173 
177 
178 private:
179  std::shared_ptr< FilterSettingsBase >
181  sal_Int32 mnColId;
184 };
185 
186 // class SortCondition
187 
189 {
190 public:
191  explicit SortCondition( const WorkbookHelper& rHelper );
192 
193  void importSortCondition( const AttributeList& rAttribs, sal_Int16 nSheet );
194 
195  ScRange maRange; // Column/Row that this sort condition applies to.
196  OUString maSortCustomList; // Sort by a custom list.
198 };
199 
200 // class AutoFilter
201 
203 {
204 public:
205  explicit AutoFilter( const WorkbookHelper& rHelper );
206 
208  void importAutoFilter( const AttributeList& rAttribs, sal_Int16 nSheet );
210  void importAutoFilter( SequenceInputStream& rStrm, sal_Int16 nSheet );
211 
212  void importSortState( const AttributeList& rAttribs, sal_Int16 nSheet );
213 
216 
218 
220  void finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
221  sal_Int16 nSheet );
222 
223 private:
225 
226  FilterColumnVector maFilterColumns;
228 
229  ScRange maSortRange; // The whole range of data to sort (not just the sort-by column).
231  SortConditionVector maSortConditions;
232 };
233 
235 {
236 public:
237  explicit AutoFilterBuffer( const WorkbookHelper& rHelper );
238 
241 
244  void finalizeImport( sal_Int16 nSheet );
245 
248  bool finalizeImport( const css::uno::Reference< css::sheet::XDatabaseRange >& rxDatabaseRange,
249  sal_Int16 nSheet );
250 
251 private:
254 
255 private:
257  AutoFilterVector maAutoFilters;
258 };
259 
260 } // namespace xls
261 } // namespace oox
262 
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
void importSortState(const AttributeList &rAttribs, sal_Int16 nSheet)
::std::vector< css::sheet::TableFilterField3 > FilterFieldVector
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
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.
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
virtual ApiFilterSettings finalizeImport()
Derived classes return converted UNO API filter settings representing all filter settings.
FilterColumn(const WorkbookHelper &rHelper)
AutoFilter * getActiveAutoFilter()
Returns the auto filter object used to perform auto filtering.
ApiFilterSettings finalizeImport()
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.
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.
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
virtual ApiFilterSettings finalizeImport() override
Returns converted UNO API filter settings representing all filter settings.
::std::vector< FilterCriterionModel > FilterCriterionVector
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 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
std::vector< std::pair< OUString, bool > > maValues