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 
26 namespace oox::xls {
27 
28 using ::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 ) ) return this;
42  break;
43  case XLS_TOKEN( customFilters ):
44  if( nElement == XLS_TOKEN( customFilter ) ) return this;
45  break;
46  }
47  return nullptr;
48 }
49 
51 {
53 }
54 
56 {
57  switch( getCurrentElement() )
58  {
60  if( nRecId == BIFF12_ID_DISCRETEFILTER ) return this;
61  break;
63  if( nRecId == BIFF12_ID_CUSTOMFILTER ) return this;
64  break;
65  }
66  return nullptr;
67 }
68 
70 {
72 }
73 
75  WorksheetContextBase( rParent ),
76  mrFilterColumn( rFilterColumn )
77 {
78 }
79 
80 ContextHandlerRef FilterColumnContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
81 {
82  if( getCurrentElement() == XLS_TOKEN( filterColumn ) ) switch( nElement )
83  {
84  case XLS_TOKEN( filters ):
86  case XLS_TOKEN( top10 ):
88  case XLS_TOKEN( customFilters ):
90  }
91  return nullptr;
92 }
93 
95 {
97 }
98 
100 {
101  if( getCurrentElement() == BIFF12_ID_FILTERCOLUMN ) switch( nRecId )
102  {
109  }
110  return nullptr;
111 }
112 
114 {
116 }
117 
118 // class SortConditionContext
119 
121  WorksheetContextBase( rParent ),
122  mrSortCondition( rSortCondition )
123 {
124 }
125 
127 {
128  return nullptr;
129 }
130 
132 {
134 }
135 
137 {
138  return nullptr;
139 }
140 
142 {
143 }
144 
145 // class SortStateContext
146 
148  WorksheetContextBase( rParent ),
149  mrAutoFilter( rAutoFilter )
150 {
151 }
152 
153 ContextHandlerRef SortStateContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
154 {
155  if( getCurrentElement() == XLS_TOKEN( sortState ) ) switch( nElement )
156  {
157  case XLS_TOKEN( sortCondition ):
159  }
160  return nullptr;
161 }
162 
164 {
166 }
167 
169 {
170  return nullptr;
171 }
172 
174 {
175 }
176 
178  WorksheetContextBase( rFragment ),
179  mrAutoFilter( rAutoFilter )
180 {
181 }
182 
183 ContextHandlerRef AutoFilterContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
184 {
185  if( getCurrentElement() == XLS_TOKEN( autoFilter ) ) switch( nElement )
186  {
187  case XLS_TOKEN( sortState ):
188  return new SortStateContext( *this, mrAutoFilter );
189  case XLS_TOKEN( filterColumn ):
190  return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
191  }
192  return nullptr;
193 }
194 
196 {
198 }
199 
201 {
203  return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
204  return nullptr;
205 }
206 
208 {
210 }
211 
212 } // namespace oox::xls
213 
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
const sal_Int32 BIFF12_ID_CUSTOMFILTER
Definition: biffhelper.hxx:80
void importSortState(const AttributeList &rAttribs, sal_Int16 nSheet)
FilterColumnContext(WorksheetContextBase &rParent, FilterColumn &rFilterColumn)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
SortConditionContext(WorksheetContextBase &rFragment, SortCondition &rSortCondition)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void importAttribs(sal_Int32 nElement, const AttributeList &rAttribs)
Derived classes import filter settings from the passed attribute list.
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void importAutoFilter(const AttributeList &rAttribs, sal_Int16 nSheet)
Imports auto filter settings from the autoFilter element.
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onStartElement(const AttributeList &rAttribs) override
SortCondition & createSortCondition()
void importFilterColumn(const AttributeList &rAttribs)
Imports auto filter column settings from the filterColumn element.
const sal_Int32 BIFF12_ID_DISCRETEFILTERS
Definition: biffhelper.hxx:97
void importSortCondition(const AttributeList &rAttribs, sal_Int16 nSheet)
Settings for a custom filter, specifying one or two comparison operators associated with some values...
const sal_Int32 BIFF12_ID_AUTOFILTER
Definition: biffhelper.hxx:33
SortStateContext(WorksheetContextBase &rFragment, AutoFilter &rAutoFilter)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
sal_Int32 getCurrentElement() const
virtual void onStartElement(const AttributeList &rAttribs) override
const sal_Int32 BIFF12_ID_CUSTOMFILTERS
Definition: biffhelper.hxx:81
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
const sal_Int32 BIFF12_ID_FILTERCOLUMN
Definition: biffhelper.hxx:122
FilterSettingsBase & createFilterSettings()
Creates and returns the specified filter settings object.
virtual void onStartRecord(SequenceInputStream &rStrm) override
FilterColumn & createFilterColumn()
Creates a new auto filter column and stores it internally.
const sal_Int32 BIFF12_ID_DISCRETEFILTER
Definition: biffhelper.hxx:96
Fragment handler derived from the WorksheetHelper helper class.
virtual void onStartElement(const AttributeList &rAttribs) override
virtual void onStartRecord(SequenceInputStream &rStrm) override
virtual void importRecord(sal_Int32 nRecId, SequenceInputStream &rStrm)
Derived classes import filter settings from the passed record.
A column in a filtered range.
Context handler derived from the WorksheetHelper helper class.
virtual void onStartRecord(SequenceInputStream &rStrm) override
const sal_Int32 BIFF12_ID_TOP10FILTER
Definition: biffhelper.hxx:231
SCTAB getSheetIndex() const
Returns the index of the current sheet.
virtual void onStartElement(const AttributeList &rAttribs) override
virtual void onStartElement(const AttributeList &rAttribs) override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
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
Base class for specific filter settings for a column in a filtered range.
Settings for a top-10 filter.
FilterSettingsBase & mrFilterSettings
FilterSettingsContext(WorksheetContextBase &rParent, FilterSettingsBase &rFilterSettings)
virtual void onStartRecord(SequenceInputStream &rStrm) override
AutoFilterContext(WorksheetFragmentBase &rFragment, AutoFilter &rAutoFilter)