1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _FILTERHELPER_HXX_
30 #define _FILTERHELPER_HXX_
32 #include <com/sun/star/beans/StringPair.hpp>
33 #include <com/sun/star/uno/Sequence.hxx>
35 #include <com/sun/star/lang/IllegalArgumentException.hpp>
37 #include <com/sun/star/uno/RuntimeException.hpp>
43 #include <Cocoa/Cocoa.h>
46 typedef ::com::sun::star::beans::StringPair UnoFilterEntry
;
47 typedef ::com::sun::star::uno::Sequence
< UnoFilterEntry
> UnoFilterList
; // can be transported more effectively
48 typedef ::std::list
<NSString
*> NSStringList
;
49 typedef ::std::list
<rtl::OUString
> OUStringList
;
54 rtl::OUString m_sTitle
;
55 OUStringList m_sFilterSuffixList
;
56 UnoFilterList m_aSubFilters
;
59 FilterEntry( const rtl::OUString
& _rTitle
, const OUStringList _rFilter
)
61 , m_sFilterSuffixList( _rFilter
)
65 FilterEntry( const rtl::OUString
& _rTitle
, const UnoFilterList
& _rSubFilters
);
67 rtl::OUString
getTitle() const { return m_sTitle
; }
68 OUStringList
getFilterSuffixList() const { return m_sFilterSuffixList
; }
70 /// determines if the filter has sub filter (i.e., the filter is a filter group in real)
71 sal_Bool
hasSubFilters( ) const;
73 /** retrieves the filters belonging to the entry
75 the number of sub filters
77 sal_Int32
getSubFilters( UnoFilterList
& _rSubFilterList
);
79 // helpers for iterating the sub filters
80 const UnoFilterEntry
* beginSubFilters() const { return m_aSubFilters
.getConstArray(); }
81 const UnoFilterEntry
* endSubFilters() const { return m_aSubFilters
.getConstArray() + m_aSubFilters
.getLength(); }
84 typedef ::std::vector
< FilterEntry
> FilterList
;
90 virtual ~FilterHelper();
92 //XFilterManager delegates
93 void SAL_CALL
appendFilter( const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aFilter
)
94 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
96 void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
97 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
99 ::rtl::OUString SAL_CALL
getCurrentFilter( )
100 throw( ::com::sun::star::uno::RuntimeException
);
102 //XFilterGroupManager delegates
103 void SAL_CALL
appendFilterGroup( const ::rtl::OUString
& sGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& aFilters
)
104 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
108 FilterList
* getFilterList();
109 NSStringList
* getFilterNames();
112 void SetCurFilter( const rtl::OUString
& rFilter
);
113 void SetFilterAtIndex(unsigned index
);
114 OUStringList
getCurrentFilterSuffixList();
115 int getCurrentFilterIndex();
117 sal_Bool
filenameMatchesFilter(NSString
* sFilename
);
120 FilterList
*m_pFilterList
;
121 rtl::OUString m_aCurrentFilter
;
122 NSStringList
*m_pFilterNames
;
124 int implAddFilter( const rtl::OUString rFilter
, const OUStringList rSuffixList
);
125 int implAddFilterGroup( const rtl::OUString rFilter
,
126 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& _rFilters
);
128 sal_Bool
FilterNameExists( const rtl::OUString rTitle
);
129 sal_Bool
FilterNameExists( const UnoFilterList
& _rGroupedFilters
);
131 void ensureFilterList( const ::rtl::OUString
& _rInitialCurrentFilter
);
133 void fillSuffixList(OUStringList
& aSuffixList
, const ::rtl::OUString
& suffixString
);
137 #endif //_FILTERHELPER_HXX_
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */