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"
22 #include "autofilterbuffer.hxx"
23 #include "biffinputstream.hxx"
28 using ::oox::core::ContextHandlerRef
;
30 FilterSettingsContext::FilterSettingsContext( WorksheetContextBase
& rParent
, FilterSettingsBase
& rFilterSettings
) :
31 WorksheetContextBase( rParent
),
32 mrFilterSettings( rFilterSettings
)
36 ContextHandlerRef
FilterSettingsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
38 switch( getCurrentElement() )
40 case XLS_TOKEN( filters
):
41 if( nElement
== XLS_TOKEN( filter
) ) return this;
43 case XLS_TOKEN( customFilters
):
44 if( nElement
== XLS_TOKEN( customFilter
) ) return this;
50 void FilterSettingsContext::onStartElement( const AttributeList
& rAttribs
)
52 mrFilterSettings
.importAttribs( getCurrentElement(), rAttribs
);
55 ContextHandlerRef
FilterSettingsContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
57 switch( getCurrentElement() )
59 case BIFF12_ID_DISCRETEFILTERS
:
60 if( nRecId
== BIFF12_ID_DISCRETEFILTER
) return this;
62 case BIFF12_ID_CUSTOMFILTERS
:
63 if( nRecId
== BIFF12_ID_CUSTOMFILTER
) return this;
69 void FilterSettingsContext::onStartRecord( SequenceInputStream
& rStrm
)
71 mrFilterSettings
.importRecord( getCurrentElement(), rStrm
);
74 FilterColumnContext::FilterColumnContext( WorksheetContextBase
& rParent
, FilterColumn
& rFilterColumn
) :
75 WorksheetContextBase( rParent
),
76 mrFilterColumn( rFilterColumn
)
80 ContextHandlerRef
FilterColumnContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
82 if( getCurrentElement() == XLS_TOKEN( filterColumn
) ) switch( nElement
)
84 case XLS_TOKEN( filters
):
85 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< DiscreteFilter
>() );
86 case XLS_TOKEN( top10
):
87 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< Top10Filter
>() );
88 case XLS_TOKEN( customFilters
):
89 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< CustomFilter
>() );
94 void FilterColumnContext::onStartElement( const AttributeList
& rAttribs
)
96 mrFilterColumn
.importFilterColumn( rAttribs
);
99 ContextHandlerRef
FilterColumnContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
101 if( getCurrentElement() == BIFF12_ID_FILTERCOLUMN
) switch( nRecId
)
103 case BIFF12_ID_DISCRETEFILTERS
:
104 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< DiscreteFilter
>() );
105 case BIFF12_ID_TOP10FILTER
:
106 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< Top10Filter
>() );
107 case BIFF12_ID_CUSTOMFILTERS
:
108 return new FilterSettingsContext( *this, mrFilterColumn
.createFilterSettings
< CustomFilter
>() );
113 void FilterColumnContext::onStartRecord( SequenceInputStream
& rStrm
)
115 mrFilterColumn
.importFilterColumn( rStrm
);
118 AutoFilterContext::AutoFilterContext( WorksheetFragmentBase
& rFragment
, AutoFilter
& rAutoFilter
) :
119 WorksheetContextBase( rFragment
),
120 mrAutoFilter( rAutoFilter
)
124 ContextHandlerRef
AutoFilterContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& /*rAttribs*/ )
126 if( (getCurrentElement() == XLS_TOKEN( autoFilter
)) && (nElement
== XLS_TOKEN( filterColumn
)) )
127 return new FilterColumnContext( *this, mrAutoFilter
.createFilterColumn() );
131 void AutoFilterContext::onStartElement( const AttributeList
& rAttribs
)
133 mrAutoFilter
.importAutoFilter( rAttribs
, getSheetIndex() );
136 ContextHandlerRef
AutoFilterContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& /*rStrm*/ )
138 if( (getCurrentElement() == BIFF12_ID_AUTOFILTER
) && (nRecId
== BIFF12_ID_FILTERCOLUMN
) )
139 return new FilterColumnContext( *this, mrAutoFilter
.createFilterColumn() );
143 void AutoFilterContext::onStartRecord( SequenceInputStream
& rStrm
)
145 mrAutoFilter
.importAutoFilter( rStrm
, getSheetIndex() );
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */