bump product version to 4.1.6.2
[LibreOffice.git] / fpicker / source / win32 / filepicker / FilterContainer.hxx
blob2ef15ac0b1ca88f6a520d04f90d9183b52dd4910
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 _FILTER_CONTAINER_HXX_
21 #define _FILTER_CONTAINER_HXX_
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
26 #include <vector>
28 //------------------------------------------------------
29 // helper class, only useable by OFilterContainer
30 //------------------------------------------------------
32 class CFilterContainer
34 public:
35 // defines a filter entry which is made of a name and a filter value
36 // e.g. 'Text *.txt'
37 typedef std::pair< OUString, OUString > FILTER_ENTRY_T;
39 public:
40 explicit CFilterContainer( sal_Int32 initSize = 0 );
42 // add a new filter
43 // returns true if the filter was successfully added
44 // returns false if duplicates are not allowed and
45 // the filter is already in the container
46 sal_Bool SAL_CALL addFilter(
47 const OUString& aName,
48 const OUString& aFilter,
49 sal_Bool bAllowDuplicates = sal_False );
51 // delete the specified filter returns true on
52 // success and false if the filter was not found
53 sal_Bool SAL_CALL delFilter( const OUString& aName );
55 // the number of filter already added
56 sal_Int32 SAL_CALL numFilter( );
58 // clear all entries
59 void SAL_CALL empty( );
61 // retrieve a filter from the container both methods
62 // return true on success and false if the specified
63 // filter was not found
64 sal_Bool SAL_CALL getFilter( const OUString& aName, OUString& theFilter ) const;
65 sal_Bool SAL_CALL getFilter( sal_Int32 aIndex, OUString& theFilter ) const;
67 // returns the position of the specified filter or -1
68 // if the filter was not found
69 sal_Int32 SAL_CALL getFilterPos( const OUString& aName ) const;
71 // starts enumerating the filter in the container
72 void SAL_CALL beginEnumFilter( );
74 // returns true if another filter has been retrieved
75 sal_Bool SAL_CALL getNextFilter( FILTER_ENTRY_T& nextFilterEntry );
77 // cache current filter
78 void SAL_CALL setCurrentFilter( const OUString& aName );
80 // returns cached current filter
81 OUString SAL_CALL getCurrentFilter() const;
83 protected:
84 typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T;
86 private:
87 // prevent copy and assignment
88 CFilterContainer( const CFilterContainer& );
89 CFilterContainer& SAL_CALL operator=( const CFilterContainer& );
91 sal_Int32 SAL_CALL getFilterTagPos( const OUString& aName ) const;
93 private:
94 FILTER_VECTOR_T m_vFilters;
95 FILTER_VECTOR_T::const_iterator m_iter;
96 sal_Bool m_bIterInitialized;
97 OUString m_sCurrentFilter;
100 //----------------------------------------------------------------
101 // a helper function to create a filter buffer in the format
102 // the Win32 API requires, e.g. "Text\0*.txt\0Doc\0*.doc;*xls\0\0"
103 //----------------------------------------------------------------
105 OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer );
107 #endif
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */