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 <unordered_map>
23 #include <com/sun/star/uno/Sequence.h>
24 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <comphelper/sequenceashashmap.hxx>
27 #include <o3tl/span.hxx>
29 namespace filter::config
{
32 /** @short represent an item of a FilterCache
35 @descr This class is not threadsafe tp perform
36 operations, which use many instances of
37 this class! Synchronizations must be done outside.
39 class CacheItem
: public ::comphelper::SequenceAsHashMap
45 /** @short creates an empty item.
50 /** @short update only properties, which are given by the
53 @descr Update means: - add new properties
54 - change existing values
57 another cache item, which contains some special
58 properties, which should by used for updating
61 void update(const CacheItem
& rUpdateItem
);
64 /** @short check, if the given properties exist
67 @descr All properties are compared in its minimum.
68 E.g: string lists => only the requested items
69 are checked. Additional existing items are ignored.
72 contains all properties, which must exist at this item.
74 @return sal_True if all given properties exists
75 at this item; sal_False otherwise.
77 bool haveProps(o3tl::span
< const css::beans::NamedValue
> lProps
) const;
80 /** @short check, if the given properties don't exist
83 @descr All properties are compared in its minimum.
84 E.g: string lists => only the requested items
85 are checked. Additional existing items are ignored.
88 contains all properties, which should not exist at this item.
90 @return sal_False if at least on property exists at this item(!);
93 bool dontHaveProps(o3tl::span
< const css::beans::NamedValue
> lProps
) const;
96 /** @short because we know two UIName properties
97 (a list with all locales and the value
98 for the current locale only), we must be sure
99 that the correspond together.
102 must specify the current office locale.
103 It's needed to address the UIName property inside
104 the list of possible ones.
106 void validateUINames(const OUString
& sActLocale
);
109 /** @short convert this structure to a seq< PropertyValue >
110 and ignore all empty properties!
112 @descr Normally the converter routines of the base class
113 SequenceAsHashMap do this job already.
114 But it doesn't provide a "pack" mechanism to
115 ignore properties with empty (means "void") values.
117 @return css::uno::Sequence< css::beans::PropertyValue >
118 as a list of all properties of this cacheitem,
119 where empty properties was removed.
121 css::uno::Sequence
< css::beans::PropertyValue
> getAsPackedPropertyValueList(bool bFinalized
, bool bMandatory
) const;
125 /** @short represent an item list of a FilterCache
128 typedef std::unordered_map
< OUString
,
129 CacheItem
> CacheItemList
;
132 /** @short supports registration of multiple key to
133 another string information.
135 @descr E.g. a list of internal type names can be registered
136 to an extension. Organization as an hash makes it
137 faster than searching inside vectors.
139 On the other side e.g. URLPattern can't be really addressed
140 by a hash value ... because the use wildcards. But
141 there we need key-value pairs too, which can't be provided
144 typedef std::unordered_map
< OUString
,
145 std::vector
<OUString
> > CacheItemRegistration
;
148 /** @short is used to collect all matching types of a URL
149 during type detection.
151 @descr Every type in this list is combined with an information,
152 which property matched to the given URL. The user of this
153 structure can decide then, if a deep detection should be
154 suppressed e.g. if a URLPattern was used.
156 struct FlatDetectionInfo
158 // the internal type name
161 // this type was found by a matching the URL extension
162 bool bMatchByExtension
;
164 // this type was found by a matching URL Pattern
165 bool bMatchByPattern
;
167 // the user selected this type implicit by selecting a corresponding office module
168 bool bPreselectedByDocumentService
;
173 typedef ::std::vector
< FlatDetectionInfo
> FlatDetection
;
175 } // namespace filter::config
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */