Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FILTER_CONFIG_CACHEITEM_HXX_
30 : : #define __FILTER_CONFIG_CACHEITEM_HXX_
31 : :
32 : : #include <boost/unordered_map.hpp>
33 : : #include <deque>
34 : : #include <list>
35 : : #include <com/sun/star/uno/Any.h>
36 : : #include <com/sun/star/uno/Sequence.h>
37 : : #include <com/sun/star/beans/PropertyValue.hpp>
38 : : #include <com/sun/star/beans/NamedValue.hpp>
39 : : #include <comphelper/sequenceasvector.hxx>
40 : : #include <comphelper/sequenceashashmap.hxx>
41 : : #include <osl/mutex.hxx>
42 : :
43 : :
44 : : namespace filter{
45 : : namespace config{
46 : :
47 : : namespace css = ::com::sun::star;
48 : :
49 : :
50 : : /** @short Must be used as first derived base class
51 : : to get a full initialized mutex member,
52 : : which can be used during the ctor runs too!
53 : : */
54 : 52785 : struct BaseLock
55 : : {
56 : : public:
57 : :
58 : : // must be mutable to be useable in const environments too!
59 : : mutable ::osl::Mutex m_aLock;
60 : : };
61 : :
62 : :
63 : : typedef ::comphelper::SequenceAsVector< ::rtl::OUString > OUStringList;
64 : :
65 : : //_______________________________________________
66 : :
67 : : /** @short represent an item of a FilterCache
68 : : instance.
69 : :
70 : : @descr This class is not threadsafe tp perform
71 : : operations, which use many instances of
72 : : this class! Synchronizations must be done outside.
73 : : */
74 : 407860 : class CacheItem : public ::comphelper::SequenceAsHashMap
75 : : {
76 : : //-------------------------------------------
77 : : public:
78 : :
79 : : //---------------------------------------
80 : : /** @short creates an empty item.
81 : : */
82 : : CacheItem();
83 : :
84 : : //---------------------------------------
85 : :
86 : : /** @short update only properties, which are given by the
87 : : specified rItem.
88 : :
89 : : @descr Update means: - add new properties
90 : : - change existing values
91 : :
92 : : @param rUpdateItem
93 : : another cache item, which contains some special
94 : : properties, which should by used for updating
95 : : this one.
96 : : */
97 : : void update(const CacheItem& rUpdateItem);
98 : :
99 : : //---------------------------------------
100 : :
101 : : /** @short check, if the given properties exists
102 : : at this item.
103 : :
104 : : @descr All properties are compared in its minimum.
105 : : E.g: string lists => only the requested items
106 : : are checked. Additional existing items are ignored.
107 : :
108 : : @param lProps
109 : : contains all properties, which must exist at this item.
110 : :
111 : : @return sal_True if all given properties exists
112 : : at this item; sal_False otherwhise.
113 : : */
114 : : sal_Bool haveProps(const CacheItem& lProps) const;
115 : :
116 : : //---------------------------------------
117 : :
118 : : /** @short check, if the given properties dont exists
119 : : at this item.
120 : :
121 : : @descr All properties are compared in its minimum.
122 : : E.g: string lists => only the requested items
123 : : are checked. Additional existing items are ignored.
124 : :
125 : : @param lProps
126 : : contains all properties, which should not exists at this item.
127 : :
128 : : @return sal_False if at least on property exists at this item(!);
129 : : sal_True otherwhise.
130 : : */
131 : : sal_Bool dontHaveProps(const CacheItem& lProps) const;
132 : :
133 : : //---------------------------------------
134 : :
135 : : /** @short check, if the given properties dont exists
136 : : at this item.
137 : :
138 : : @descr All properties are compared in its minimum.
139 : : E.g: string lists => only the specified items
140 : : are checked. Additional existing items are ignored.
141 : :
142 : : @param lProps
143 : : contains all properties, which should be checked.
144 : :
145 : : @return sal_True if all given properties dont exists
146 : : at this item; sal_False otherwhise.
147 : : */
148 : : sal_Bool excludeProps(const CacheItem& lProps) const;
149 : :
150 : : //---------------------------------------
151 : :
152 : : /** @short because we know two UIName properties
153 : : (a list with all locales and the value
154 : : for the current locale only), we must be shure
155 : : that the correspond together.
156 : :
157 : : @param sActLocale
158 : : must specify the current office locale.
159 : : Its needed to address the UIName property inside
160 : : the list of possible ones.
161 : : */
162 : : void validateUINames(const ::rtl::OUString& sActLocale);
163 : :
164 : : //---------------------------------------
165 : :
166 : : /** @short convert this structure to a seq< PropertyValue >
167 : : and ignore all empty properties!
168 : :
169 : : @descr Normaly the converter routines of the base class
170 : : SequenceAsHashMap do this job already.
171 : : But it doesnt provide a "pack" mechanism to
172 : : ignore properties with empty (means "void") values.
173 : :
174 : : @return css::uno::Sequence< css::beans::PropertyValue >
175 : : as a list of all properties of this cacheitem,
176 : : where empty properties was removed.
177 : : */
178 : : css::uno::Sequence< css::beans::PropertyValue > getAsPackedPropertyValueList();
179 : : };
180 : :
181 : : //_______________________________________________
182 : :
183 : : /** @short represent an item list of a FilterCache
184 : : instance.
185 : : */
186 : : typedef ::boost::unordered_map< ::rtl::OUString ,
187 : : CacheItem ,
188 : : ::rtl::OUStringHash ,
189 : : ::std::equal_to< ::rtl::OUString > > CacheItemList;
190 : :
191 : : //_______________________________________________
192 : :
193 : : /** @short supports registration of multiple key to
194 : : another string information.
195 : :
196 : : @descr E.g. a list of internal type names can be registered
197 : : to an extension. Organization as an hash makes it
198 : : faster than searching inside vectors.
199 : :
200 : : On the other side e.g. URLPattern cant be really addressed
201 : : by a hash value ... because the use wildcards. But
202 : : there we need key-value pairs too, which cant be provided
203 : : by a pure vector!
204 : : */
205 : : typedef ::boost::unordered_map< ::rtl::OUString ,
206 : : OUStringList ,
207 : : ::rtl::OUStringHash ,
208 : : ::std::equal_to< ::rtl::OUString > > CacheItemRegistration;
209 : :
210 : : //_______________________________________________
211 : :
212 : : /** @short is used to collect all matching types of an URL
213 : : during type detection.
214 : :
215 : : @descr Every type in this list is combined with an information,
216 : : which property matched to the given URL. The user of this
217 : : structure can decide then, if a deep detection should be
218 : : suppressed e.g. if an URLPattern was used.
219 : : */
220 : 9153 : struct FlatDetectionInfo
221 : : {
222 : : // the internal type name
223 : : ::rtl::OUString sType;
224 : :
225 : : // this type was found by a matching the URL extension
226 : : sal_Bool bMatchByExtension;
227 : :
228 : : // this type was found by a matching URL Pattern
229 : : sal_Bool bMatchByPattern;
230 : :
231 : : // the user selected this type implicit by selecting a corresponding office module
232 : : sal_Bool bPreselectedByDocumentService;
233 : :
234 : 2941 : FlatDetectionInfo()
235 : : : sType (::rtl::OUString())
236 : : , bMatchByExtension (sal_False )
237 : : , bMatchByPattern (sal_False )
238 : 2941 : , bPreselectedByDocumentService(sal_False )
239 : 2941 : {}
240 : : };
241 : :
242 : : typedef ::std::list< FlatDetectionInfo > FlatDetection;
243 : :
244 : : } // namespace config
245 : : } // namespace filter
246 : :
247 : : #endif // __FILTER_CONFIG_CACHEITEM_HXX_
248 : :
249 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|