LibreOffice Module sc (master) 1
autofiltercontext.cxx
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#include <autofiltercontext.hxx>
21#include <biffhelper.hxx>
22
23#include <autofilterbuffer.hxx>
24#include <oox/token/namespaces.hxx>
25
26namespace oox::xls {
27
28using ::oox::core::ContextHandlerRef;
29
31 WorksheetContextBase( rParent ),
32 mrFilterSettings( rFilterSettings )
33{
34}
35
37{
38 switch( getCurrentElement() )
39 {
40 case XLS_TOKEN( filters ):
41 if( nElement == XLS_TOKEN( filter ) || nElement == XLS_TOKEN( dateGroupItem )) return this;
42 break;
43 case XLS_TOKEN( customFilters ):
44 if( nElement == XLS_TOKEN( customFilter ) ) return this;
45 break;
46 case XLS_TOKEN( colorFilter ):
47 if( nElement == XLS_TOKEN( colorFilter ) ) return this;
48 break;
49 }
50 return nullptr;
51}
52
54{
55 mrFilterSettings.importAttribs( getCurrentElement(), rAttribs );
56}
57
59{
60 switch( getCurrentElement() )
61 {
63 if( nRecId == BIFF12_ID_DISCRETEFILTER ) return this;
64 break;
66 if( nRecId == BIFF12_ID_CUSTOMFILTER ) return this;
67 break;
68 }
69 return nullptr;
70}
71
73{
74 mrFilterSettings.importRecord( getCurrentElement(), rStrm );
75}
76
78 WorksheetContextBase( rParent ),
79 mrFilterColumn( rFilterColumn )
80{
81}
82
84{
85 if( getCurrentElement() == XLS_TOKEN( filterColumn ) ) switch( nElement )
86 {
87 case XLS_TOKEN( filters ):
89 case XLS_TOKEN( top10 ):
91 case XLS_TOKEN( customFilters ):
93 case XLS_TOKEN( colorFilter ):
95 }
96 return nullptr;
97}
98
100{
102}
103
105{
106 if( getCurrentElement() == BIFF12_ID_FILTERCOLUMN ) switch( nRecId )
107 {
114 }
115 return nullptr;
116}
117
119{
121}
122
123// class SortConditionContext
124
126 WorksheetContextBase( rParent ),
127 mrSortCondition( rSortCondition )
128{
129}
130
132{
133 return nullptr;
134}
135
137{
139}
140
142{
143 return nullptr;
144}
145
147{
148}
149
150// class SortStateContext
151
153 WorksheetContextBase( rParent ),
154 mrAutoFilter( rAutoFilter )
155{
156}
157
158ContextHandlerRef SortStateContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
159{
160 if( getCurrentElement() == XLS_TOKEN( sortState ) ) switch( nElement )
161 {
162 case XLS_TOKEN( sortCondition ):
164 }
165 return nullptr;
166}
167
169{
171}
172
174{
175 return nullptr;
176}
177
179{
180}
181
183 WorksheetContextBase( rFragment ),
184 mrAutoFilter( rAutoFilter )
185{
186}
187
189{
190 if( getCurrentElement() == XLS_TOKEN( autoFilter ) ) switch( nElement )
191 {
192 case XLS_TOKEN( sortState ):
193 return new SortStateContext( *this, mrAutoFilter );
194 case XLS_TOKEN( filterColumn ):
196 }
197 return nullptr;
198}
199
201{
203}
204
206{
207 if( (getCurrentElement() == BIFF12_ID_AUTOFILTER) && (nRecId == BIFF12_ID_FILTERCOLUMN) )
209 return nullptr;
210}
211
213{
215}
216
217} // namespace oox::xls
218
219/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
AutoFilterContext(WorksheetFragmentBase &rFragment, AutoFilter &rAutoFilter)
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual void onStartElement(const AttributeList &rAttribs) override
SortCondition & createSortCondition()
void importSortState(const AttributeList &rAttribs, sal_Int16 nSheet)
void importAutoFilter(const AttributeList &rAttribs, sal_Int16 nSheet)
Imports auto filter settings from the autoFilter element.
FilterColumn & createFilterColumn()
Creates a new auto filter column and stores it internally.
Settings for a color filter.
Settings for a custom filter, specifying one or two comparison operators associated with some values.
Settings for a discrete filter, specifying a list of values to be shown in the filtered range.
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onStartElement(const AttributeList &rAttribs) override
FilterColumnContext(WorksheetContextBase &rParent, FilterColumn &rFilterColumn)
A column in a filtered range.
FilterSettingsBase & createFilterSettings()
Creates and returns the specified filter settings object.
void importFilterColumn(const AttributeList &rAttribs)
Imports auto filter column settings from the filterColumn element.
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 & mrFilterSettings
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
FilterSettingsContext(WorksheetContextBase &rParent, FilterSettingsBase &rFilterSettings)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual void onStartElement(const AttributeList &rAttribs) override
SortConditionContext(WorksheetContextBase &rFragment, SortCondition &rSortCondition)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual void onStartElement(const AttributeList &rAttribs) override
void importSortCondition(const AttributeList &rAttribs, sal_Int16 nSheet)
SortStateContext(WorksheetContextBase &rFragment, AutoFilter &rAutoFilter)
virtual void onStartElement(const AttributeList &rAttribs) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onStartRecord(SequenceInputStream &rStrm) override
Settings for a top-10 filter.
Context handler derived from the WorksheetHelper helper class.
Fragment handler derived from the WorksheetHelper helper class.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
void SvStream & rStrm
const sal_Int32 BIFF12_ID_FILTERCOLUMN
Definition: biffhelper.hxx:121
const sal_Int32 BIFF12_ID_DISCRETEFILTER
Definition: biffhelper.hxx:95
const sal_Int32 BIFF12_ID_CUSTOMFILTER
Definition: biffhelper.hxx:79
const sal_Int32 BIFF12_ID_CUSTOMFILTERS
Definition: biffhelper.hxx:80
const sal_Int32 BIFF12_ID_DISCRETEFILTERS
Definition: biffhelper.hxx:96
const sal_Int32 BIFF12_ID_TOP10FILTER
Definition: biffhelper.hxx:230
const sal_Int32 BIFF12_ID_AUTOFILTER
Definition: biffhelper.hxx:32