1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FilterContainer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FILTER_CONTAINER_HXX_
32 #define _FILTER_CONTAINER_HXX_
34 #include <sal/types.h>
35 #include <rtl/ustring.hxx>
39 //------------------------------------------------------
40 // helper class, only useable by OFilterContainer
41 //------------------------------------------------------
43 class CFilterContainer
46 // defines a filter entry which is made of a name and a filter value
48 typedef std::pair
< rtl::OUString
, rtl::OUString
> FILTER_ENTRY_T
;
51 explicit CFilterContainer( sal_Int32 initSize
= 0 );
54 // returns true if the filter was successfully added
55 // returns false if duplicates are not allowed and
56 // the filter is already in the container
57 sal_Bool SAL_CALL
addFilter(
58 const ::rtl::OUString
& aName
,
59 const ::rtl::OUString
& aFilter
,
60 sal_Bool bAllowDuplicates
= sal_False
);
62 // delete the specified filter returns true on
63 // success and false if the filter was not found
64 sal_Bool SAL_CALL
delFilter( const ::rtl::OUString
& aName
);
66 // the number of filter already added
67 sal_Int32 SAL_CALL
numFilter( );
70 void SAL_CALL
empty( );
72 // retrieve a filter from the container both methods
73 // return true on success and false if the specified
74 // filter was not found
75 sal_Bool SAL_CALL
getFilter( const ::rtl::OUString
& aName
, ::rtl::OUString
& theFilter
) const;
76 sal_Bool SAL_CALL
getFilter( sal_Int32 aIndex
, ::rtl::OUString
& theFilter
) const;
78 // returns the position of the specified filter or -1
79 // if the filter was not found
80 sal_Int32 SAL_CALL
getFilterPos( const ::rtl::OUString
& aName
) const;
82 // starts enumerating the filter in the container
83 void SAL_CALL
beginEnumFilter( );
85 // returns true if another filter has been retrieved
86 sal_Bool SAL_CALL
getNextFilter( FILTER_ENTRY_T
& nextFilterEntry
);
88 // cache current filter
89 void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aName
);
91 // returns cached current filter
92 ::rtl::OUString SAL_CALL
getCurrentFilter() const;
95 typedef std::vector
< FILTER_ENTRY_T
> FILTER_VECTOR_T
;
98 // prevent copy and assignment
99 CFilterContainer( const CFilterContainer
& );
100 CFilterContainer
& SAL_CALL
operator=( const CFilterContainer
& );
102 sal_Int32 SAL_CALL
getFilterTagPos( const ::rtl::OUString
& aName
) const;
105 FILTER_VECTOR_T m_vFilters
;
106 FILTER_VECTOR_T::const_iterator m_iter
;
107 sal_Bool m_bIterInitialized
;
108 ::rtl::OUString m_sCurrentFilter
;
111 //----------------------------------------------------------------
112 // a helper function to create a filter buffer in the format
113 // the Win32 API requires, e.g. "Text\0*.txt\0Doc\0*.doc;*xls\0\0"
114 //----------------------------------------------------------------
116 rtl::OUString SAL_CALL
makeWinFilterBuffer( CFilterContainer
& aFilterContainer
);