update emoji autocorrect entries from po-files
[LibreOffice.git] / fpicker / source / aqua / FilterHelper.hxx
blob7c30d53cc62ca0dd235f9d4075f486fe7b8741ce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
30 #include <list>
31 #include <vector>
33 #include <premac.h>
34 #include <Cocoa/Cocoa.h>
35 #include <postmac.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<OUString> OUStringList;
42 struct FilterEntry
44 protected:
45 OUString m_sTitle;
46 OUStringList m_sFilterSuffixList;
47 UnoFilterList m_aSubFilters;
49 public:
50 FilterEntry( const OUString& _rTitle, const OUStringList _rFilter )
51 : m_sTitle( _rTitle )
52 , m_sFilterSuffixList( _rFilter )
56 FilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters );
58 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 bool hasSubFilters( ) const;
64 /** retrieves the filters belonging to the entry
65 @return
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;
77 class FilterHelper {
79 public:
80 FilterHelper();
81 virtual ~FilterHelper();
83 //XFilterManager delegates
84 void SAL_CALL appendFilter( const OUString& aTitle, const OUString& aFilter )
85 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
87 void SAL_CALL setCurrentFilter( const OUString& aTitle )
88 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
90 OUString SAL_CALL getCurrentFilter( )
91 throw( ::com::sun::star::uno::RuntimeException );
93 //XFilterGroupManager delegates
94 void SAL_CALL appendFilterGroup( const 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);
98 //accessor
99 FilterList* getFilterList();
100 NSStringList* getFilterNames();
102 //misc
103 void SetCurFilter( const OUString& rFilter );
104 void SetFilterAtIndex(unsigned index);
105 OUStringList getCurrentFilterSuffixList();
106 int getCurrentFilterIndex();
107 void SetFilters();
108 bool filenameMatchesFilter(NSString * sFilename);
110 private:
111 FilterList *m_pFilterList;
112 OUString m_aCurrentFilter;
113 NSStringList *m_pFilterNames;
115 bool FilterNameExists( const OUString& rTitle );
116 bool FilterNameExists( const UnoFilterList& _rGroupedFilters );
118 void ensureFilterList( const OUString& _rInitialCurrentFilter );
121 #endif // INCLUDED_FPICKER_SOURCE_AQUA_FILTERHELPER_HXX
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */