1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <autofiltercontext.hxx>
21 #include <biffhelper.hxx>
23 #include <autofilterbuffer.hxx>
24 #include <oox/token/namespaces.hxx>
29 using ::oox::core::ContextHandlerRef
;
31 FilterSettingsContext::FilterSettingsContext( WorksheetContextBase
& rParent
, FilterSettingsBase
& rFilterSettings
) :
32 WorksheetContextBase( rParent
),
33 mrFilterSettings( rFilterSettings
)
37 ContextHandlerRef
FilterSettingsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
39 switch( getCurrentElement() )
41 case XLS_TOKEN( filters
):
42 if( nElement
== XLS_TOKEN( filter
) ) return this;
44 case XLS_TOKEN( customFilters
):
45 if( nElement
== XLS_TOKEN( customFilter
) ) return this;
51 void FilterSettingsContext::onStartElement( const AttributeList
& rAttribs
)
53 mrFilterSettings
.importAttribs( getCurrentElement(), rAttribs
);
56 ContextHandlerRef
FilterSettingsContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
58 switch( getCurrentElement() )
60 case BIFF12_ID_DISCRETEFILTERS
:
61 if( nRecId
== BIFF12_ID_DISCRETEFILTER
) return this;
63 case BIFF12_ID_CUSTOMFILTERS
:
64 if( nRecId
== BIFF12_ID_CUSTOMFILTER
) return this;
70 void FilterSettingsContext::onStartRecord( SequenceInputStream
& rStrm
)
72 mrFilterSettings
.importRecord( getCurrentElement(), rStrm
);
75 FilterColumnContext::FilterColumnContext( WorksheetContextBase
& rParent
, FilterColumn
& rFilterColumn
) :
76 WorksheetContextBase( rParent
),
77 mrFilterColumn( rFilterColumn
)
81 ContextHandlerRef
FilterColumnContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
83 if( getCurrentElement() == XLS_TOKEN( filterColumn
) ) switch( nElement
)
85 case XLS_TOKEN( filters
):
86 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< DiscreteFilter
>() );
87 case XLS_TOKEN( top10
):
88 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< Top10Filter
>() );
89 case XLS_TOKEN( customFilters
):
90 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< CustomFilter
>() );
95 void FilterColumnContext::onStartElement( const AttributeList
& rAttribs
)
97 mrFilterColumn
.importFilterColumn( rAttribs
);
100 ContextHandlerRef
FilterColumnContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
102 if( getCurrentElement() == BIFF12_ID_FILTERCOLUMN
) switch( nRecId
)
104 case BIFF12_ID_DISCRETEFILTERS
:
105 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< DiscreteFilter
>() );
106 case BIFF12_ID_TOP10FILTER
:
107 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< Top10Filter
>() );
108 case BIFF12_ID_CUSTOMFILTERS
:
109 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< CustomFilter
>() );
114 void FilterColumnContext::onStartRecord( SequenceInputStream
& rStrm
)
116 mrFilterColumn
.importFilterColumn( rStrm
);
119 AutoFilterContext::AutoFilterContext( WorksheetFragmentBase
& rFragment
, AutoFilter
& rAutoFilter
) :
120 WorksheetContextBase( rFragment
),
121 mrAutoFilter( rAutoFilter
)
125 ContextHandlerRef
AutoFilterContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
127 if( (getCurrentElement() == XLS_TOKEN( autoFilter
)) && (nElement
== XLS_TOKEN( filterColumn
)) )
128 return new FilterColumnContext( *this, mrAutoFilter
.createFilterColumn() );
132 void AutoFilterContext::onStartElement( const AttributeList
& rAttribs
)
134 mrAutoFilter
.importAutoFilter( rAttribs
, getSheetIndex() );
137 ContextHandlerRef
AutoFilterContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
139 if( (getCurrentElement() == BIFF12_ID_AUTOFILTER
) && (nRecId
== BIFF12_ID_FILTERCOLUMN
) )
140 return new FilterColumnContext( *this, mrAutoFilter
.createFilterColumn() );
144 void AutoFilterContext::onStartRecord( SequenceInputStream
& rStrm
)
146 mrAutoFilter
.importAutoFilter( rStrm
, getSheetIndex() );
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */