fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / webdav / ContentProperties.hxx
blob483cab83daa260b105230d6c098de3a260997cc1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_CONTENTPROPERTIES_HXX
23 #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_CONTENTPROPERTIES_HXX
25 #include <memory>
26 #include <unordered_map>
27 #include <vector>
28 #include <boost/scoped_ptr.hpp>
29 #include <rtl/ustring.hxx>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
33 namespace com { namespace sun { namespace star { namespace beans {
34 struct Property;
35 } } } }
37 namespace http_dav_ucp
40 struct DAVResource;
42 // PropertyValueMap.
43 class PropertyValue
45 private:
46 ::com::sun::star::uno::Any m_aValue;
47 bool m_bIsCaseSensitive;
49 public:
50 PropertyValue()
51 : m_bIsCaseSensitive( true ) {}
53 PropertyValue( const ::com::sun::star::uno::Any & rValue,
54 bool bIsCaseSensitive )
55 : m_aValue( rValue),
56 m_bIsCaseSensitive( bIsCaseSensitive ) {}
58 bool isCaseSensitive() const { return m_bIsCaseSensitive; }
59 const ::com::sun::star::uno::Any & value() const { return m_aValue; }
63 typedef std::unordered_map
65 OUString,
66 PropertyValue,
67 OUStringHash
69 PropertyValueMap;
71 struct DAVResource;
73 class ContentProperties
75 public:
76 ContentProperties();
78 ContentProperties( const DAVResource& rResource );
80 // Mini props for transient contents.
81 ContentProperties( const OUString & rTitle, bool bFolder );
83 // Micro props for non-existing contents.
84 ContentProperties( const OUString & rTitle );
86 ContentProperties( const ContentProperties & rOther );
88 bool contains( const OUString & rName ) const;
90 const com::sun::star::uno::Any &
91 getValue( const OUString & rName ) const;
93 // Maps the UCB property names contained in rProps with their DAV property
94 // counterparts, if possible. All unmappable properties will be included
95 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
96 // The vector filles by this method can directly be handed over to
97 // DAVResourceAccess::PROPFIND. The result from PROPFIND
98 // (vector< DAVResource >) can be used to create a ContentProperties
99 // instance which can map DAV properties back to UCB properties.
100 static void UCBNamesToDAVNames( const com::sun::star::uno::Sequence<
101 com::sun::star::beans::Property > &
102 rProps,
103 std::vector< OUString > & resources,
104 bool bIncludeUnmatched = true );
106 // Maps the UCB property names contained in rProps with their HTTP header
107 // counterparts, if possible. All unmappable properties will be included
108 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
109 // The vector filles by this method can directly be handed over to
110 // DAVResourceAccess::HEAD. The result from HEAD (vector< DAVResource >)
111 // can be used to create a ContentProperties instance which can map header
112 // names back to UCB properties.
113 static void UCBNamesToHTTPNames( const com::sun::star::uno::Sequence<
114 com::sun::star::beans::Property > &
115 rProps,
116 std::vector< OUString > & resources,
117 bool bIncludeUnmatched = true );
119 // return true, if all properties contained in rProps are contained in
120 // this ContentProperties instance. Otherwiese, false will be returned.
121 // rNamesNotContained contain the missing names.
122 bool containsAllNames(
123 const com::sun::star::uno::Sequence<
124 com::sun::star::beans::Property >& rProps,
125 std::vector< OUString > & rNamesNotContained ) const;
127 // adds all properties described by rProps that are actually contained in
128 // rContentProps to this instance. In case of duplicates the value
129 // already contained in this will left unchanged.
130 void addProperties( const std::vector< OUString > & rProps,
131 const ContentProperties & rContentProps );
133 // overwrites probably existing entries.
134 void addProperties( const ContentProperties & rProps );
136 // overwrites probably existing entries.
137 void addProperties( const std::vector< DAVPropertyValue > & rProps );
139 // overwrites probably existing entry.
140 void addProperty( const OUString & rName,
141 const com::sun::star::uno::Any & rValue,
142 bool bIsCaseSensitive );
144 // overwrites probably existing entry.
145 void addProperty( const DAVPropertyValue & rProp );
147 bool isTrailingSlash() const { return m_bTrailingSlash; }
149 const OUString & getEscapedTitle() const { return m_aEscapedTitle; }
151 // Not good to expose implementation details, but this is actually an
152 // internal class.
153 const boost::scoped_ptr< PropertyValueMap > & getProperties() const
154 { return m_xProps; }
156 private:
157 OUString m_aEscapedTitle;
158 boost::scoped_ptr< PropertyValueMap > m_xProps;
159 bool m_bTrailingSlash;
161 static com::sun::star::uno::Any m_aEmptyAny;
163 ContentProperties & operator=( const ContentProperties & ); // n.i.
165 const PropertyValue * get( const OUString & rName ) const;
168 class CachableContentProperties
170 private:
171 ContentProperties m_aProps;
173 CachableContentProperties & operator=( const CachableContentProperties & ); // n.i.
174 CachableContentProperties( const CachableContentProperties & ); // n.i.
176 public:
177 CachableContentProperties( const ContentProperties & rProps );
179 void addProperties( const ContentProperties & rProps );
181 void addProperties( const std::vector< DAVPropertyValue > & rProps );
183 bool containsAllNames(
184 const com::sun::star::uno::Sequence<
185 com::sun::star::beans::Property >& rProps,
186 std::vector< OUString > & rNamesNotContained ) const
187 { return m_aProps.containsAllNames( rProps, rNamesNotContained ); }
189 const com::sun::star::uno::Any &
190 getValue( const OUString & rName ) const
191 { return m_aProps.getValue( rName ); }
193 operator const ContentProperties & () const { return m_aProps; }
196 } // namespace http_dav_ucp
198 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_CONTENTPROPERTIES_HXX
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */