bump product version to 6.4.0.3
[LibreOffice.git] / fpicker / source / win32 / FilterContainer.hxx
blobf54b10a7f3f0c80cc6fcd69eb790fa74fe6d09e2
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_WIN32_FILEPICKER_FILTERCONTAINER_HXX
21 #define INCLUDED_FPICKER_SOURCE_WIN32_FILEPICKER_FILTERCONTAINER_HXX
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
26 #include <vector>
29 // helper class, only usable by OFilterContainer
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 bool addFilter(
47 const OUString& aName,
48 const OUString& aFilter,
49 bool bAllowDuplicates = false );
51 // delete the specified filter returns true on
52 // success and false if the filter was not found
53 bool delFilter( const OUString& aName );
55 // the number of filter already added
56 sal_Int32 numFilter( );
58 // clear all entries
59 void empty( );
61 // retrieve a filter from the container. These methods
62 // return true on success and false if the specified
63 // filter was not found
64 bool getFilterByName(const OUString& aName, OUString& theFilter) const;
65 bool getFilterByIndex(sal_Int32 aIndex, OUString& theFilter) const;
66 bool getFilterNameByIndex(sal_Int32 aIndex, OUString& theName) const;
68 // returns the position of the specified filter or -1
69 // if the filter was not found
70 sal_Int32 getFilterPos( const OUString& aName ) const;
72 // starts enumerating the filter in the container
73 void beginEnumFilter( );
75 // returns true if another filter has been retrieved
76 bool getNextFilter( FILTER_ENTRY_T& nextFilterEntry );
78 // cache current filter
79 void setCurrentFilter( const OUString& aName );
81 // returns cached current filter
82 OUString getCurrentFilter() const;
84 protected:
85 typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T;
87 private:
88 // prevent copy and assignment
89 CFilterContainer( const CFilterContainer& );
90 CFilterContainer& SAL_CALL operator=( const CFilterContainer& );
92 sal_Int32 getFilterTagPos( const OUString& aName ) const;
94 private:
95 FILTER_VECTOR_T m_vFilters;
96 FILTER_VECTOR_T::const_iterator m_iter;
97 bool m_bIterInitialized;
98 OUString m_sCurrentFilter;
102 // a helper function to create a filter buffer in the format
103 // the Win32 API requires, e.g. "Text\0*.txt\0Doc\0*.doc;*xls\0\0"
106 OUString makeWinFilterBuffer( CFilterContainer& aFilterContainer );
108 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */