1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
28 // helper class, only usable by OFilterContainer
31 class CFilterContainer
34 // defines a filter entry which is made of a name and a filter value
36 typedef std::pair
< OUString
, OUString
> FILTER_ENTRY_T
;
39 explicit CFilterContainer( sal_Int32 initSize
= 0 );
42 // returns true if the filter was successfully added
43 // returns false if duplicates are not allowed and
44 // the filter is already in the container
46 const OUString
& aName
,
47 const OUString
& aFilter
,
48 bool bAllowDuplicates
= false );
50 // delete the specified filter returns true on
51 // success and false if the filter was not found
52 bool delFilter( const OUString
& aName
);
54 // the number of filter already added
55 sal_Int32
numFilter( );
60 // retrieve a filter from the container. These methods
61 // return true on success and false if the specified
62 // filter was not found
63 bool getFilterByName(const OUString
& aName
, OUString
& theFilter
) const;
64 bool getFilterByIndex(sal_Int32 aIndex
, OUString
& theFilter
) const;
65 bool getFilterNameByIndex(sal_Int32 aIndex
, OUString
& theName
) const;
67 // returns the position of the specified filter or -1
68 // if the filter was not found
69 sal_Int32
getFilterPos( const OUString
& aName
) const;
71 // starts enumerating the filter in the container
72 void beginEnumFilter( );
74 // returns true if another filter has been retrieved
75 bool getNextFilter( FILTER_ENTRY_T
& nextFilterEntry
);
77 // cache current filter
78 void setCurrentFilter( const OUString
& aName
);
80 // returns cached current filter
81 OUString
getCurrentFilter() const;
84 typedef std::vector
< FILTER_ENTRY_T
> FILTER_VECTOR_T
;
87 // prevent copy and assignment
88 CFilterContainer( const CFilterContainer
& );
89 CFilterContainer
& SAL_CALL
operator=( const CFilterContainer
& );
91 sal_Int32
getFilterTagPos( const OUString
& aName
) const;
94 FILTER_VECTOR_T m_vFilters
;
95 FILTER_VECTOR_T::const_iterator m_iter
;
96 bool m_bIterInitialized
;
97 OUString m_sCurrentFilter
;
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"
105 OUString
makeWinFilterBuffer( CFilterContainer
& aFilterContainer
);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */