fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / autofilterbuffer.hxx
blobb96c753e868ccd4ec917343abd8e6ad08f28bcf3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_AUTOFILTERBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_AUTOFILTERBUFFER_HXX
23 #include <com/sun/star/table/CellRangeAddress.hpp>
24 #include <oox/helper/refvector.hxx>
25 #include "workbookhelper.hxx"
27 namespace com { namespace sun { namespace star {
28 namespace sheet { struct TableFilterField3; }
29 namespace sheet { class XDatabaseRange; }
30 namespace sheet { class XSheetFilterDescriptor3; }
31 } } }
33 namespace oox {
34 namespace xls {
36 /** Contains UNO API filter settings for a column in a filtered range. */
37 struct ApiFilterSettings
39 typedef ::std::vector<com::sun::star::sheet::TableFilterField3> FilterFieldVector;
41 FilterFieldVector maFilterFields; /// List of UNO API filter settings.
42 OptValue< bool > mobNeedsRegExp; /// If set, requires regular expressions to be enabled/disabled.
44 explicit ApiFilterSettings();
46 void appendField( bool bAnd, sal_Int32 nOperator, double fValue );
47 void appendField( bool bAnd, sal_Int32 nOperator, const OUString& rValue );
48 void appendField( bool bAnd, const std::vector<OUString>& rValues );
51 /** Base class for specific filter settings for a column in a filtered range.
53 class FilterSettingsBase : public WorkbookHelper
55 public:
56 explicit FilterSettingsBase( const WorkbookHelper& rHelper );
58 /** Derived classes import filter settings from the passed attribute list. */
59 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs );
60 /** Derived classes import filter settings from the passed record. */
61 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
63 /** Derived classes return converted UNO API filter settings representing all filter settings. */
64 virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
67 typedef ::boost::shared_ptr< FilterSettingsBase > FilterSettingsRef;
69 /** Settings for a discrete filter, specifying a list of values to be shown in
70 the filtered range.
72 class DiscreteFilter : public FilterSettingsBase
74 public:
75 explicit DiscreteFilter( const WorkbookHelper& rHelper );
77 /** Imports filter settings from the filters and filter elements. */
78 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
79 /** Imports filter settings from the FILTERS and FILTER records. */
80 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) SAL_OVERRIDE;
82 /** Returns converted UNO API filter settings representing all filter settings. */
83 virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) SAL_OVERRIDE;
85 private:
86 typedef ::std::vector< OUString > FilterValueVector;
88 FilterValueVector maValues;
89 sal_Int32 mnCalendarType;
90 bool mbShowBlank;
93 /** Settings for a top-10 filter. */
94 class Top10Filter : public FilterSettingsBase
96 public:
97 explicit Top10Filter( const WorkbookHelper& rHelper );
99 /** Imports filter settings from the filters and filter elements. */
100 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
101 /** Imports filter settings from the FILTERS and FILTER records. */
102 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) SAL_OVERRIDE;
104 /** Returns converted UNO API filter settings representing all filter settings. */
105 virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) SAL_OVERRIDE;
107 private:
108 double mfValue; /// Number of items or percentage.
109 bool mbTop; /// True = show top (greatest) items/percentage.
110 bool mbPercent; /// True = percentage, false = number of items.
113 /** A filter criterion for a custom filter. */
114 struct FilterCriterionModel
116 ::com::sun::star::uno::Any maValue; /// Comparison operand.
117 sal_Int32 mnOperator; /// Comparison operator.
118 sal_uInt8 mnDataType; /// Operand data type (BIFF only).
119 sal_uInt8 mnStrLen; /// Length of string operand (BIFF5-BIFF8 only).
121 explicit FilterCriterionModel();
123 /** Sets the passed BIFF operator constant. */
124 void setBiffOperator( sal_uInt8 nOperator );
126 /** Imports the criterion model from the passed BIFF12 stream. */
127 void readBiffData( SequenceInputStream& rStrm );
130 /** Settings for a custom filter, specifying one or two comparison operators
131 associated with some values.
133 class CustomFilter : public FilterSettingsBase
135 public:
136 explicit CustomFilter( const WorkbookHelper& rHelper );
138 /** Imports filter settings from the filters and filter elements. */
139 virtual void importAttribs( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
140 /** Imports filter settings from the FILTERS and FILTER records. */
141 virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) SAL_OVERRIDE;
143 /** Returns converted UNO API filter settings representing all filter settings. */
144 virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) SAL_OVERRIDE;
146 private:
147 /** Apeends the passed filter criteriom, if it contains valid settings. */
148 void appendCriterion( const FilterCriterionModel& rCriterion );
150 private:
151 typedef ::std::vector< FilterCriterionModel > FilterCriterionVector;
153 FilterCriterionVector maCriteria;
154 bool mbAnd;
157 /** A column in a filtered range. Contains an object with specific filter
158 settings for the cells in the column.
160 class FilterColumn : public WorkbookHelper
162 public:
163 explicit FilterColumn( const WorkbookHelper& rHelper );
165 /** Imports auto filter column settings from the filterColumn element. */
166 void importFilterColumn( const AttributeList& rAttribs );
167 /** Imports auto filter column settings from the FILTERCOLUMN record. */
168 void importFilterColumn( SequenceInputStream& rStrm );
170 /** Creates and returns the specified filter settings object. */
171 template< typename FilterSettingsType >
172 inline FilterSettingsBase& createFilterSettings()
173 { mxSettings.reset( new FilterSettingsType( *this ) ); return *mxSettings; }
175 /** Returns the index of the column in the filtered range this object is related to. */
176 inline sal_Int32 getColumnId() const { return mnColId; }
178 /** Returns converted UNO API filter settings representing all filter
179 settings of this column. */
180 ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
182 private:
183 FilterSettingsRef mxSettings;
184 sal_Int32 mnColId;
185 bool mbHiddenButton;
186 bool mbShowButton;
189 class AutoFilter : public WorkbookHelper
191 public:
192 explicit AutoFilter( const WorkbookHelper& rHelper );
194 /** Imports auto filter settings from the autoFilter element. */
195 void importAutoFilter( const AttributeList& rAttribs, sal_Int16 nSheet );
196 /** Imports auto filter settings from the AUTOFILTER record. */
197 void importAutoFilter( SequenceInputStream& rStrm, sal_Int16 nSheet );
199 /** Creates a new auto filter column and stores it internally. */
200 FilterColumn& createFilterColumn();
202 /** Applies the filter to the passed filter descriptor. */
203 void finalizeImport(
204 const ::com::sun::star::uno::Reference<
205 ::com::sun::star::sheet::XSheetFilterDescriptor3>& rxFilterDesc );
207 private:
208 typedef RefVector< FilterColumn > FilterColumnVector;
210 FilterColumnVector maFilterColumns;
211 ::com::sun::star::table::CellRangeAddress maRange;
214 class AutoFilterBuffer : public WorkbookHelper
216 public:
217 explicit AutoFilterBuffer( const WorkbookHelper& rHelper );
219 /** Creates a new auto filter and stores it internally. */
220 AutoFilter& createAutoFilter();
222 /** Applies filter settings to a new database range object (used for sheet
223 autofilter or advanced filter as specified by built-in defined names). */
224 void finalizeImport( sal_Int16 nSheet );
226 /** Applies the filters to the passed database range object.
227 @return True = this buffer contains valid auto filter settings. */
228 bool finalizeImport( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >& rxDatabaseRange );
230 private:
231 /** Returns the auto filter object used to perform auto filtering. */
232 AutoFilter* getActiveAutoFilter();
234 private:
235 typedef RefVector< AutoFilter > AutoFilterVector;
236 AutoFilterVector maAutoFilters;
239 } // namespace xls
240 } // namespace oox
242 #endif
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */