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 _FILTERHELPER_HXX_
21 #define _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 ::com::sun::star::beans::StringPair UnoFilterEntry
;
38 typedef ::com::sun::star::uno::Sequence
< UnoFilterEntry
> UnoFilterList
; // can be transported more effectively
39 typedef ::std::list
<NSString
*> NSStringList
;
40 typedef ::std::list
<rtl::OUString
> OUStringList
;
45 rtl::OUString m_sTitle
;
46 OUStringList m_sFilterSuffixList
;
47 UnoFilterList m_aSubFilters
;
50 FilterEntry( const rtl::OUString
& _rTitle
, const OUStringList _rFilter
)
52 , m_sFilterSuffixList( _rFilter
)
56 FilterEntry( const rtl::OUString
& _rTitle
, const UnoFilterList
& _rSubFilters
);
58 rtl::OUString
getTitle() const { return m_sTitle
; }
59 OUStringList
getFilterSuffixList() const { return m_sFilterSuffixList
; }
61 /// determines if the filter has sub filter (i.e., the filter is a filter group in real)
62 sal_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 void SAL_CALL
appendFilter( const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aFilter
)
85 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
87 void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
88 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
90 ::rtl::OUString SAL_CALL
getCurrentFilter( )
91 throw( ::com::sun::star::uno::RuntimeException
);
93 //XFilterGroupManager delegates
94 void SAL_CALL
appendFilterGroup( const ::rtl::OUString
& sGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& aFilters
)
95 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
99 FilterList
* getFilterList();
100 NSStringList
* getFilterNames();
103 void SetCurFilter( const rtl::OUString
& rFilter
);
104 void SetFilterAtIndex(unsigned index
);
105 OUStringList
getCurrentFilterSuffixList();
106 int getCurrentFilterIndex();
108 sal_Bool
filenameMatchesFilter(NSString
* sFilename
);
111 FilterList
*m_pFilterList
;
112 rtl::OUString m_aCurrentFilter
;
113 NSStringList
*m_pFilterNames
;
115 int implAddFilter( const rtl::OUString rFilter
, const OUStringList rSuffixList
);
116 int implAddFilterGroup( const rtl::OUString rFilter
,
117 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& _rFilters
);
119 sal_Bool
FilterNameExists( const rtl::OUString rTitle
);
120 sal_Bool
FilterNameExists( const UnoFilterList
& _rGroupedFilters
);
122 void ensureFilterList( const ::rtl::OUString
& _rInitialCurrentFilter
);
124 void fillSuffixList(OUStringList
& aSuffixList
, const ::rtl::OUString
& suffixString
);
128 #endif //_FILTERHELPER_HXX_
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */