LibreOffice Module fpicker (master) 1
FilterHelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/beans/StringPair.hpp>
23#include <com/sun/star/uno/Sequence.hxx>
24
25#include <com/sun/star/lang/IllegalArgumentException.hpp>
26
27#include <com/sun/star/uno/RuntimeException.hpp>
28
29#include <list>
30#include <string_view>
31#include <vector>
32
33#include <premac.h>
34#include <Cocoa/Cocoa.h>
35#include <postmac.h>
36
37typedef css::beans::StringPair UnoFilterEntry;
38typedef css::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively
39typedef ::std::list<NSString *> NSStringList;
40typedef ::std::list<OUString> OUStringList;
41
42struct FilterEntry
43{
44protected:
45 OUString m_sTitle;
46 OUStringList m_sFilterSuffixList;
47 UnoFilterList m_aSubFilters;
48
49public:
50 FilterEntry( const OUString& _rTitle, const OUStringList _rFilter )
51 : m_sTitle( _rTitle )
52 , m_sFilterSuffixList( _rFilter )
53 {
54 }
55
56 FilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters );
57
58 OUString const & getTitle() const { return m_sTitle; }
59 OUStringList const & getFilterSuffixList() const { return m_sFilterSuffixList; }
60
62 bool hasSubFilters( ) const;
63
68 sal_Int32 getSubFilters( UnoFilterList& _rSubFilterList );
69
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(); }
73};
74
75typedef ::std::vector < FilterEntry > FilterList;
76
78
79public:
81 virtual ~FilterHelper();
82
83 //XFilterManager delegates
86 void appendFilter( const OUString& aTitle, std::u16string_view aFilter );
87
90 void setCurrentFilter( const OUString& aTitle );
91
93 OUString getCurrentFilter( );
94
95 //XFilterGroupManager delegates
98 void appendFilterGroup( const css::uno::Sequence< css::beans::StringPair >& aFilters );
99
100
101 //accessor
104
105 //misc
106 void SetCurFilter( const OUString& rFilter );
107 void SetFilterAtIndex(unsigned index);
110 void SetFilters();
111 bool filenameMatchesFilter(NSString * sFilename);
112
113private:
117
118 bool FilterNameExists( const OUString& rTitle );
119 bool FilterNameExists( const UnoFilterList& _rGroupedFilters );
120
121 void ensureFilterList( const OUString& _rInitialCurrentFilter );
122};
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::vector< FilterEntry > FilterList
css::uno::Sequence< UnoFilterEntry > UnoFilterList
::std::list< OUString > OUStringList
css::beans::StringPair UnoFilterEntry
::std::list< NSString * > NSStringList
int getCurrentFilterIndex()
void SetCurFilter(const OUString &rFilter)
OUString getCurrentFilter()
void ensureFilterList(const OUString &_rInitialCurrentFilter)
bool filenameMatchesFilter(NSString *sFilename)
void appendFilter(const OUString &aTitle, std::u16string_view aFilter)
FilterList * m_pFilterList
OUString m_aCurrentFilter
FilterList * getFilterList()
bool FilterNameExists(const OUString &rTitle)
void appendFilterGroup(const css::uno::Sequence< css::beans::StringPair > &aFilters)
NSStringList * m_pFilterNames
OUStringList getCurrentFilterSuffixList()
void SetFilterAtIndex(unsigned index)
virtual ~FilterHelper()
NSStringList * getFilterNames()
void SetFilters()
void setCurrentFilter(const OUString &aTitle)
OUString m_sTitle
index