Line data Source code
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 : #ifndef __FILTER_CONFIG_CACHEITEM_HXX_
21 : #define __FILTER_CONFIG_CACHEITEM_HXX_
22 :
23 : #include <boost/unordered_map.hpp>
24 : #include <deque>
25 : #include <list>
26 : #include <com/sun/star/uno/Any.h>
27 : #include <com/sun/star/uno/Sequence.h>
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <com/sun/star/beans/NamedValue.hpp>
30 : #include <comphelper/sequenceasvector.hxx>
31 : #include <comphelper/sequenceashashmap.hxx>
32 : #include <osl/mutex.hxx>
33 :
34 :
35 : namespace filter{
36 : namespace config{
37 :
38 :
39 : /** @short Must be used as first derived base class
40 : to get a full initialized mutex member,
41 : which can be used during the ctor runs too!
42 : */
43 27389 : struct BaseLock
44 : {
45 : public:
46 :
47 : // must be mutable to be useable in const environments too!
48 : mutable ::osl::Mutex m_aLock;
49 : };
50 :
51 :
52 : typedef ::comphelper::SequenceAsVector< ::rtl::OUString > OUStringList;
53 :
54 : //_______________________________________________
55 :
56 : /** @short represent an item of a FilterCache
57 : instance.
58 :
59 : @descr This class is not threadsafe tp perform
60 : operations, which use many instances of
61 : this class! Synchronizations must be done outside.
62 : */
63 63906 : class CacheItem : public ::comphelper::SequenceAsHashMap
64 : {
65 : //-------------------------------------------
66 : public:
67 :
68 : //---------------------------------------
69 : /** @short creates an empty item.
70 : */
71 : CacheItem();
72 :
73 : //---------------------------------------
74 :
75 : /** @short update only properties, which are given by the
76 : specified rItem.
77 :
78 : @descr Update means: - add new properties
79 : - change existing values
80 :
81 : @param rUpdateItem
82 : another cache item, which contains some special
83 : properties, which should by used for updating
84 : this one.
85 : */
86 : void update(const CacheItem& rUpdateItem);
87 :
88 : //---------------------------------------
89 :
90 : /** @short check, if the given properties exists
91 : at this item.
92 :
93 : @descr All properties are compared in its minimum.
94 : E.g: string lists => only the requested items
95 : are checked. Additional existing items are ignored.
96 :
97 : @param lProps
98 : contains all properties, which must exist at this item.
99 :
100 : @return sal_True if all given properties exists
101 : at this item; sal_False otherwhise.
102 : */
103 : sal_Bool haveProps(const CacheItem& lProps) const;
104 :
105 : //---------------------------------------
106 :
107 : /** @short check, if the given properties dont exists
108 : at this item.
109 :
110 : @descr All properties are compared in its minimum.
111 : E.g: string lists => only the requested items
112 : are checked. Additional existing items are ignored.
113 :
114 : @param lProps
115 : contains all properties, which should not exists at this item.
116 :
117 : @return sal_False if at least on property exists at this item(!);
118 : sal_True otherwhise.
119 : */
120 : sal_Bool dontHaveProps(const CacheItem& lProps) const;
121 :
122 : //---------------------------------------
123 :
124 : /** @short check, if the given properties dont exists
125 : at this item.
126 :
127 : @descr All properties are compared in its minimum.
128 : E.g: string lists => only the specified items
129 : are checked. Additional existing items are ignored.
130 :
131 : @param lProps
132 : contains all properties, which should be checked.
133 :
134 : @return sal_True if all given properties dont exists
135 : at this item; sal_False otherwhise.
136 : */
137 : sal_Bool excludeProps(const CacheItem& lProps) const;
138 :
139 : //---------------------------------------
140 :
141 : /** @short because we know two UIName properties
142 : (a list with all locales and the value
143 : for the current locale only), we must be shure
144 : that the correspond together.
145 :
146 : @param sActLocale
147 : must specify the current office locale.
148 : Its needed to address the UIName property inside
149 : the list of possible ones.
150 : */
151 : void validateUINames(const ::rtl::OUString& sActLocale);
152 :
153 : //---------------------------------------
154 :
155 : /** @short convert this structure to a seq< PropertyValue >
156 : and ignore all empty properties!
157 :
158 : @descr Normaly the converter routines of the base class
159 : SequenceAsHashMap do this job already.
160 : But it doesnt provide a "pack" mechanism to
161 : ignore properties with empty (means "void") values.
162 :
163 : @return css::uno::Sequence< css::beans::PropertyValue >
164 : as a list of all properties of this cacheitem,
165 : where empty properties was removed.
166 : */
167 : css::uno::Sequence< css::beans::PropertyValue > getAsPackedPropertyValueList();
168 : };
169 :
170 : //_______________________________________________
171 :
172 : /** @short represent an item list of a FilterCache
173 : instance.
174 : */
175 : typedef ::boost::unordered_map< ::rtl::OUString ,
176 : CacheItem ,
177 : ::rtl::OUStringHash ,
178 : ::std::equal_to< ::rtl::OUString > > CacheItemList;
179 :
180 : //_______________________________________________
181 :
182 : /** @short supports registration of multiple key to
183 : another string information.
184 :
185 : @descr E.g. a list of internal type names can be registered
186 : to an extension. Organization as an hash makes it
187 : faster than searching inside vectors.
188 :
189 : On the other side e.g. URLPattern cant be really addressed
190 : by a hash value ... because the use wildcards. But
191 : there we need key-value pairs too, which cant be provided
192 : by a pure vector!
193 : */
194 : typedef ::boost::unordered_map< ::rtl::OUString ,
195 : OUStringList ,
196 : ::rtl::OUStringHash ,
197 : ::std::equal_to< ::rtl::OUString > > CacheItemRegistration;
198 :
199 : //_______________________________________________
200 :
201 : /** @short is used to collect all matching types of an URL
202 : during type detection.
203 :
204 : @descr Every type in this list is combined with an information,
205 : which property matched to the given URL. The user of this
206 : structure can decide then, if a deep detection should be
207 : suppressed e.g. if an URLPattern was used.
208 : */
209 1794 : struct FlatDetectionInfo
210 : {
211 : // the internal type name
212 : ::rtl::OUString sType;
213 :
214 : // this type was found by a matching the URL extension
215 : sal_Bool bMatchByExtension;
216 :
217 : // this type was found by a matching URL Pattern
218 : sal_Bool bMatchByPattern;
219 :
220 : // the user selected this type implicit by selecting a corresponding office module
221 : sal_Bool bPreselectedByDocumentService;
222 :
223 598 : FlatDetectionInfo()
224 : : sType (::rtl::OUString())
225 : , bMatchByExtension (sal_False )
226 : , bMatchByPattern (sal_False )
227 598 : , bPreselectedByDocumentService(sal_False )
228 598 : {}
229 : };
230 :
231 : typedef ::std::list< FlatDetectionInfo > FlatDetection;
232 :
233 : } // namespace config
234 : } // namespace filter
235 :
236 : #endif // __FILTER_CONFIG_CACHEITEM_HXX_
237 :
238 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|