1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ContentProperties.hxx,v $
10 * $Revision: 1.12.34.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _WEBDAV_UCP_CONTENTPROPERTIES_HXX
32 #define _WEBDAV_UCP_CONTENTPROPERTIES_HXX
37 #include <rtl/ustring.hxx>
38 #include <com/sun/star/uno/Any.hxx>
39 #include <com/sun/star/uno/Sequence.hxx>
41 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{
50 //=========================================================================
54 bool operator()( const rtl::OUString
& s1
, const rtl::OUString
& s2
) const
56 return !!( s1
== s2
);
62 size_t operator()( const rtl::OUString
& rName
) const
64 return rName
.hashCode();
68 //=========================================================================
72 //=========================================================================
77 ::com::sun::star::uno::Any m_aValue
;
78 bool m_bIsCaseSensitive
;
82 : m_bIsCaseSensitive( true ) {}
84 PropertyValue( const ::com::sun::star::uno::Any
& rValue
,
85 bool bIsCaseSensitive
)
87 m_bIsCaseSensitive( bIsCaseSensitive
) {}
89 bool isCaseSensitive() const { return m_bIsCaseSensitive
; }
90 const ::com::sun::star::uno::Any
& value() const { return m_aValue
; }
105 class ContentProperties
108 ContentProperties( const DAVResource
& rResource
);
110 // Mini props for transient contents.
111 ContentProperties( const rtl::OUString
& rTitle
, sal_Bool bFolder
);
113 // Micro props for non-existing contents.
114 ContentProperties( const rtl::OUString
& rTitle
);
116 ContentProperties( const ContentProperties
& rOther
);
118 bool contains( const rtl::OUString
& rName
) const;
120 const com::sun::star::uno::Any
&
121 getValue( const rtl::OUString
& rName
) const;
123 // Maps the UCB property names contained in rProps with their DAV property
124 // counterparts, if possible. All unmappable properties will be included
125 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
126 // The vector filles by this method can directly be handed over to
127 // DAVResourceAccess::PROPFIND. The result from PROPFIND
128 // (vector< DAVResource >) can be used to create a ContentProperties
129 // instance which can map DAV properties back to UCB properties.
130 static void UCBNamesToDAVNames( const com::sun::star::uno::Sequence
<
131 com::sun::star::beans::Property
> &
133 std::vector
< rtl::OUString
> & resources
,
134 bool bIncludeUnmatched
= true );
136 // Maps the UCB property names contained in rProps with their HTTP header
137 // counterparts, if possible. All unmappable properties will be included
138 // unchanged in resulting vector unless bIncludeUnmatched is set to false.
139 // The vector filles by this method can directly be handed over to
140 // DAVResourceAccess::HEAD. The result from HEAD (vector< DAVResource >)
141 // can be used to create a ContentProperties instance which can map header
142 // names back to UCB properties.
143 static void UCBNamesToHTTPNames( const com::sun::star::uno::Sequence
<
144 com::sun::star::beans::Property
> &
146 std::vector
< rtl::OUString
> & resources
,
147 bool bIncludeUnmatched
= true );
149 // return true, if all properties contained in rProps are contained in
150 // this ContentProperties instance. Otherwiese, false will be returned.
151 // rNamesNotContained contain the missing names.
152 bool containsAllNames(
153 const com::sun::star::uno::Sequence
<
154 com::sun::star::beans::Property
>& rProps
,
155 std::vector
< rtl::OUString
> & rNamesNotContained
) const;
157 // adds all properties described by rProps that are actually contained in
158 // rContentProps to this instance. In case of duplicates the value
159 // already contained in this will left unchanged.
160 void addProperties( const std::vector
< rtl::OUString
> & rProps
,
161 const ContentProperties
& rContentProps
);
163 // overwrites probably existing entries.
164 void addProperties( const ContentProperties
& rProps
);
166 // overwrites probably existing entries.
167 void addProperties( const std::vector
< DAVPropertyValue
> & rProps
);
169 // overwrites probably existing entry.
170 void addProperty( const rtl::OUString
& rName
,
171 const com::sun::star::uno::Any
& rValue
,
172 bool bIsCaseSensitive
);
174 // overwrites probably existing entry.
175 void addProperty( const DAVPropertyValue
& rProp
);
177 bool isTrailingSlash() const { return m_bTrailingSlash
; }
179 const rtl::OUString
& getEscapedTitle() const { return m_aEscapedTitle
; }
181 // Not good to expose implementation details, but this is actually an
183 const std::auto_ptr
< PropertyValueMap
> & getProperties() const
187 ::rtl::OUString m_aEscapedTitle
; // escaped Title
188 std::auto_ptr
< PropertyValueMap
> m_xProps
;
189 bool m_bTrailingSlash
;
191 static com::sun::star::uno::Any m_aEmptyAny
;
193 ContentProperties
& operator=( const ContentProperties
& ); // n.i.
195 const PropertyValue
* get( const rtl::OUString
& rName
) const;
200 #endif /* !_WEBDAV_UCP_CONTENTPROPERTIES_HXX */