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 #ifndef INCLUDED_FPICKER_SOURCE_AQUA_FILTERHELPER_HXX
21 #define INCLUDED_FPICKER_SOURCE_AQUA_FILTERHELPER_HXX
23 #include <com/sun/star/beans/StringPair.hpp>
24 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/lang/IllegalArgumentException.hpp>
28 #include <com/sun/star/uno/RuntimeException.hpp>
34 #include <Cocoa/Cocoa.h>
37 typedef css::beans::StringPair UnoFilterEntry
;
38 typedef css::uno::Sequence
< UnoFilterEntry
> UnoFilterList
; // can be transported more effectively
39 typedef ::std::list
<NSString
*> NSStringList
;
40 typedef ::std::list
<OUString
> OUStringList
;
46 OUStringList m_sFilterSuffixList
;
47 UnoFilterList m_aSubFilters
;
50 FilterEntry( const OUString
& _rTitle
, const OUStringList _rFilter
)
52 , m_sFilterSuffixList( _rFilter
)
56 FilterEntry( const OUString
& _rTitle
, const UnoFilterList
& _rSubFilters
);
58 OUString
const & getTitle() const { return m_sTitle
; }
59 OUStringList
const & getFilterSuffixList() const { return m_sFilterSuffixList
; }
61 /// determines if the filter has sub filter (i.e., the filter is a filter group in real)
62 bool hasSubFilters( ) const;
64 /** retrieves the filters belonging to the entry
66 the number of sub filters
68 sal_Int32
getSubFilters( UnoFilterList
& _rSubFilterList
);
70 // helpers for iterating the sub filters
71 const UnoFilterEntry
* beginSubFilters() const { return m_aSubFilters
.getConstArray(); }
72 const UnoFilterEntry
* endSubFilters() const { return m_aSubFilters
.getConstArray() + m_aSubFilters
.getLength(); }
75 typedef ::std::vector
< FilterEntry
> FilterList
;
81 virtual ~FilterHelper();
83 //XFilterManager delegates
84 /// @throws css::lang::IllegalArgumentException
85 /// @throws css::uno::RuntimeException
86 void appendFilter( const OUString
& aTitle
, const OUString
& aFilter
);
88 /// @throws css::lang::IllegalArgumentException
89 /// @throws css::uno::RuntimeException
90 void setCurrentFilter( const OUString
& aTitle
);
92 /// @throws css::uno::RuntimeException
93 OUString
getCurrentFilter( );
95 //XFilterGroupManager delegates
96 /// @throws css::lang::IllegalArgumentException
97 /// @throws css::uno::RuntimeException
98 void appendFilterGroup( const OUString
& sGroupTitle
, const css::uno::Sequence
< css::beans::StringPair
>& aFilters
);
102 FilterList
* getFilterList();
103 NSStringList
* getFilterNames();
106 void SetCurFilter( const OUString
& rFilter
);
107 void SetFilterAtIndex(unsigned index
);
108 OUStringList
getCurrentFilterSuffixList();
109 int getCurrentFilterIndex();
111 bool filenameMatchesFilter(NSString
* sFilename
);
114 FilterList
*m_pFilterList
;
115 OUString m_aCurrentFilter
;
116 NSStringList
*m_pFilterNames
;
118 bool FilterNameExists( const OUString
& rTitle
);
119 bool FilterNameExists( const UnoFilterList
& _rGroupedFilters
);
121 void ensureFilterList( const OUString
& _rInitialCurrentFilter
);
124 #endif // INCLUDED_FPICKER_SOURCE_AQUA_FILTERHELPER_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */