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 ) || 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 {
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 {
75 }
76 
78  WorksheetContextBase( rParent ),
79  mrFilterColumn( rFilterColumn )
80 {
81 }
82 
83 ContextHandlerRef FilterColumnContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
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 
158 ContextHandlerRef 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 
188 ContextHandlerRef AutoFilterContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
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 ):
195  return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
196  }
197  return nullptr;
198 }
199 
201 {
203 }
204 
206 {
208  return new FilterColumnContext( *this, mrAutoFilter.createFilterColumn() );
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 onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
const sal_Int32 BIFF12_ID_CUSTOMFILTER
Definition: biffhelper.hxx:79
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)
Settings for a color filter.
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:96
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:32
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:80
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
const sal_Int32 BIFF12_ID_FILTERCOLUMN
Definition: biffhelper.hxx:121
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:95
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:230
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)