LibreOffice Module fpicker (master) 1
FilterContainer.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 <sal/types.h>
23#include <rtl/ustring.hxx>
24
25#include <vector>
26
27
28// helper class, only usable by OFilterContainer
29
30
32{
33public:
34 // defines a filter entry which is made of a name and a filter value
35 // e.g. 'Text *.txt'
36 typedef std::pair< OUString, OUString > FILTER_ENTRY_T;
37
38public:
39 explicit CFilterContainer( sal_Int32 initSize = 0 );
40
41 // add a new filter
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
45 bool addFilter(
46 const OUString& aName,
47 const OUString& aFilter,
48 bool bAllowDuplicates = false );
49
50 // delete the specified filter returns true on
51 // success and false if the filter was not found
52 bool delFilter( const OUString& aName );
53
54 // the number of filter already added
55 sal_Int32 numFilter( );
56
57 // clear all entries
58 void empty( );
59
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;
66
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;
70
71 // starts enumerating the filter in the container
72 void beginEnumFilter( );
73
74 // returns true if another filter has been retrieved
75 bool getNextFilter( FILTER_ENTRY_T& nextFilterEntry );
76
77 // cache current filter
78 void setCurrentFilter( const OUString& aName );
79
80 // returns cached current filter
81 OUString getCurrentFilter() const;
82
83protected:
84 typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T;
85
86private:
87 // prevent copy and assignment
90
91 sal_Int32 getFilterTagPos( const OUString& aName ) const;
92
93private:
95 FILTER_VECTOR_T::const_iterator m_iter;
98};
99
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
104
105OUString makeWinFilterBuffer( CFilterContainer& aFilterContainer );
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString makeWinFilterBuffer(CFilterContainer &aFilterContainer)
bool getFilterByIndex(sal_Int32 aIndex, OUString &theFilter) const
void setCurrentFilter(const OUString &aName)
std::pair< OUString, OUString > FILTER_ENTRY_T
std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T
bool getFilterByName(const OUString &aName, OUString &theFilter) const
CFilterContainer(sal_Int32 initSize=0)
sal_Int32 getFilterTagPos(const OUString &aName) const
CFilterContainer(const CFilterContainer &)
sal_Int32 numFilter()
OUString getCurrentFilter() const
FILTER_VECTOR_T m_vFilters
sal_Int32 getFilterPos(const OUString &aName) const
CFilterContainer &SAL_CALL operator=(const CFilterContainer &)
bool getFilterNameByIndex(sal_Int32 aIndex, OUString &theName) const
FILTER_VECTOR_T::const_iterator m_iter
bool getNextFilter(FILTER_ENTRY_T &nextFilterEntry)
bool addFilter(const OUString &aName, const OUString &aFilter, bool bAllowDuplicates=false)
bool delFilter(const OUString &aName)