fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / ucb / source / ucp / webdav / ContentProperties.hxx
blobb9e075c1854b2ab3e9da7ede804f096005bfe1f1
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 _WEBDAV_UCP_CONTENTPROPERTIES_HXX
23 #define _WEBDAV_UCP_CONTENTPROPERTIES_HXX
25 #include <memory>
26 #include <vector>
27 #include <hash_map>
28 #include <rtl/ustring.hxx>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
32 namespace com { namespace sun { namespace star { namespace beans {
33 struct Property;
34 } } } }
36 namespace http_dav_ucp
39 struct DAVResource;
41 //=========================================================================
43 struct equalString
45 bool operator()( const OUString& s1, const OUString& s2 ) const
47 return !!( s1 == s2 );
51 struct hashString
53 size_t operator()( const OUString & rName ) const
55 return rName.hashCode();
59 //=========================================================================
61 // PropertyValueMap.
63 //=========================================================================
65 class PropertyValue
67 private:
68 ::com::sun::star::uno::Any m_aValue;
69 bool m_bIsCaseSensitive;
71 public:
72 PropertyValue()
73 : m_bIsCaseSensitive( true ) {}
75 PropertyValue( const ::com::sun::star::uno::Any & rValue,
76 bool bIsCaseSensitive )
77 : m_aValue( rValue),
78 m_bIsCaseSensitive( bIsCaseSensitive ) {}
80 bool isCaseSensitive() const { return m_bIsCaseSensitive; }
81 const ::com::sun::star::uno::Any & value() const { return m_aValue; }
85 typedef std::hash_map
87 OUString,
88 PropertyValue,
89 hashString,
90 equalString
92 PropertyValueMap;
94 struct DAVResource;
96 class ContentProperties
98 public:
99 ContentProperties();
101 ContentProperties( const DAVResource& rResource );
103 // Mini props for transient contents.
104 ContentProperties( const OUString & rTitle, sal_Bool bFolder );
106 // Micro props for non-existing contents.
107 ContentProperties( const OUString & rTitle );
109 ContentProperties( const ContentProperties & rOther );
111 bool contains( const OUString & rName ) const;
113 const com::sun::star::uno::Any &
114 getValue( const OUString & rName ) const;
116 // Maps the UCB property names contained in rProps with their DAV property
117 // counterparts, if possible. All unmappable properties will be included
118 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
119 // The vector filles by this method can directly be handed over to
120 // DAVResourceAccess::PROPFIND. The result from PROPFIND
121 // (vector< DAVResource >) can be used to create a ContentProperties
122 // instance which can map DAV properties back to UCB properties.
123 static void UCBNamesToDAVNames( const com::sun::star::uno::Sequence<
124 com::sun::star::beans::Property > &
125 rProps,
126 std::vector< OUString > & resources,
127 bool bIncludeUnmatched = true );
129 // Maps the UCB property names contained in rProps with their HTTP header
130 // counterparts, if possible. All unmappable properties will be included
131 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
132 // The vector filles by this method can directly be handed over to
133 // DAVResourceAccess::HEAD. The result from HEAD (vector< DAVResource >)
134 // can be used to create a ContentProperties instance which can map header
135 // names back to UCB properties.
136 static void UCBNamesToHTTPNames( const com::sun::star::uno::Sequence<
137 com::sun::star::beans::Property > &
138 rProps,
139 std::vector< OUString > & resources,
140 bool bIncludeUnmatched = true );
142 // return true, if all properties contained in rProps are contained in
143 // this ContentProperties instance. Otherwiese, false will be returned.
144 // rNamesNotContained contain the missing names.
145 bool containsAllNames(
146 const com::sun::star::uno::Sequence<
147 com::sun::star::beans::Property >& rProps,
148 std::vector< OUString > & rNamesNotContained ) const;
150 // adds all properties described by rProps that are actually contained in
151 // rContentProps to this instance. In case of duplicates the value
152 // already contained in this will left unchanged.
153 void addProperties( const std::vector< OUString > & rProps,
154 const ContentProperties & rContentProps );
156 // overwrites probably existing entries.
157 void addProperties( const ContentProperties & rProps );
159 // overwrites probably existing entries.
160 void addProperties( const std::vector< DAVPropertyValue > & rProps );
162 // overwrites probably existing entry.
163 void addProperty( const OUString & rName,
164 const com::sun::star::uno::Any & rValue,
165 bool bIsCaseSensitive );
167 // overwrites probably existing entry.
168 void addProperty( const DAVPropertyValue & rProp );
170 bool isTrailingSlash() const { return m_bTrailingSlash; }
172 const OUString & getEscapedTitle() const { return m_aEscapedTitle; }
174 // Not good to expose implementation details, but this is actually an
175 // internal class.
176 const std::auto_ptr< PropertyValueMap > & getProperties() const
177 { return m_xProps; }
179 private:
180 OUString m_aEscapedTitle;
181 std::auto_ptr< PropertyValueMap > m_xProps;
182 bool m_bTrailingSlash;
184 static com::sun::star::uno::Any m_aEmptyAny;
186 ContentProperties & operator=( const ContentProperties & ); // n.i.
188 const PropertyValue * get( const OUString & rName ) const;
191 class CachableContentProperties
193 private:
194 ContentProperties m_aProps;
196 CachableContentProperties & operator=( const CachableContentProperties & ); // n.i.
197 CachableContentProperties( const CachableContentProperties & ); // n.i.
199 public:
200 CachableContentProperties( const ContentProperties & rProps );
202 void addProperties( const ContentProperties & rProps );
204 void addProperties( const std::vector< DAVPropertyValue > & rProps );
206 bool containsAllNames(
207 const com::sun::star::uno::Sequence<
208 com::sun::star::beans::Property >& rProps,
209 std::vector< OUString > & rNamesNotContained ) const
210 { return m_aProps.containsAllNames( rProps, rNamesNotContained ); }
212 const com::sun::star::uno::Any &
213 getValue( const OUString & rName ) const
214 { return m_aProps.getValue( rName ); }
216 operator const ContentProperties & () const { return m_aProps; }
219 } // namespace http_dav_ucp
221 #endif /* !_WEBDAV_UCP_CONTENTPROPERTIES_HXX */
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */