LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/ucb/source/ucp/webdav-neon - ContentProperties.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2013-07-09 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #ifndef _WEBDAV_UCP_CONTENTPROPERTIES_HXX
      30             : #define _WEBDAV_UCP_CONTENTPROPERTIES_HXX
      31             : 
      32             : #include <config_lgpl.h>
      33             : #include <memory>
      34             : #include <vector>
      35             : #include <boost/unordered_map.hpp>
      36             : #include <rtl/ustring.hxx>
      37             : #include <com/sun/star/uno/Any.hxx>
      38             : #include <com/sun/star/uno/Sequence.hxx>
      39             : 
      40             : namespace com { namespace sun { namespace star { namespace beans {
      41             :     struct Property;
      42             : } } } }
      43             : 
      44             : namespace webdav_ucp
      45             : {
      46             : 
      47             : struct DAVResource;
      48             : 
      49             : //=========================================================================
      50             : 
      51             : struct equalString
      52             : {
      53           0 :   bool operator()( const OUString& s1, const OUString& s2 ) const
      54             :   {
      55           0 :       return !!( s1 == s2 );
      56             :   }
      57             : };
      58             : 
      59             : struct hashString
      60             : {
      61           0 :     size_t operator()( const OUString & rName ) const
      62             :     {
      63           0 :         return rName.hashCode();
      64             :     }
      65             : };
      66             : 
      67             : //=========================================================================
      68             : //
      69             : // PropertyValueMap.
      70             : //
      71             : //=========================================================================
      72             : 
      73           0 : class PropertyValue
      74             : {
      75             : private:
      76             :     ::com::sun::star::uno::Any m_aValue;
      77             :     bool                       m_bIsCaseSensitive;
      78             : 
      79             : public:
      80           0 :     PropertyValue()
      81           0 :     : m_bIsCaseSensitive( true ) {}
      82             : 
      83           0 :     PropertyValue( const ::com::sun::star::uno::Any & rValue,
      84             :                    bool bIsCaseSensitive )
      85             :     : m_aValue( rValue),
      86           0 :       m_bIsCaseSensitive( bIsCaseSensitive ) {}
      87             : 
      88           0 :     bool isCaseSensitive() const { return m_bIsCaseSensitive; }
      89           0 :     const ::com::sun::star::uno::Any & value() const { return m_aValue; }
      90             : 
      91             : };
      92             : 
      93             : typedef boost::unordered_map
      94             : <
      95             :     OUString,
      96             :     PropertyValue,
      97             :     hashString,
      98             :     equalString
      99             : >
     100             : PropertyValueMap;
     101             : 
     102             : struct DAVResource;
     103             : 
     104           0 : class ContentProperties
     105             : {
     106             : public:
     107             :     ContentProperties();
     108             : 
     109             :     ContentProperties( const DAVResource& rResource );
     110             : 
     111             :     // Mini props for transient contents.
     112             :     ContentProperties( const OUString & rTitle, sal_Bool bFolder );
     113             : 
     114             :     // Micro props for non-existing contents.
     115             :     ContentProperties( const OUString & rTitle );
     116             : 
     117             :     ContentProperties( const ContentProperties & rOther );
     118             : 
     119             :     bool contains( const OUString & rName ) const;
     120             : 
     121             :     const com::sun::star::uno::Any &
     122             :     getValue( const OUString & rName ) const;
     123             : 
     124             :     // Maps the UCB property names contained in rProps with their DAV property
     125             :     // counterparts, if possible. All unmappable properties will be included
     126             :     // unchanged in resulting vector unless bIncludeUnmatched is set to false.
     127             :     // The vector filles by this method can directly be handed over to
     128             :     // DAVResourceAccess::PROPFIND. The result from PROPFIND
     129             :     // (vector< DAVResource >) can be used to create a ContentProperties
     130             :     // instance which can map DAV properties back to UCB properties.
     131             :     static void UCBNamesToDAVNames( const com::sun::star::uno::Sequence<
     132             :                                         com::sun::star::beans::Property > &
     133             :                                             rProps,
     134             :                                     std::vector< OUString > & resources,
     135             :                                     bool bIncludeUnmatched = true );
     136             : 
     137             :     // Maps the UCB property names contained in rProps with their HTTP header
     138             :     // counterparts, if possible. All unmappable properties will be included
     139             :     // unchanged in resulting vector unless bIncludeUnmatched is set to false.
     140             :     // The vector filles by this method can directly be handed over to
     141             :     // DAVResourceAccess::HEAD. The result from HEAD (vector< DAVResource >)
     142             :     // can be used to create a ContentProperties instance which can map header
     143             :     // names back to UCB properties.
     144             :     static void UCBNamesToHTTPNames( const com::sun::star::uno::Sequence<
     145             :                                         com::sun::star::beans::Property > &
     146             :                                             rProps,
     147             :                                     std::vector< OUString > & resources,
     148             :                                     bool bIncludeUnmatched = true );
     149             : 
     150             :     // return true, if all properties contained in rProps are contained in
     151             :     // this ContentProperties instance. Otherwiese, false will be returned.
     152             :     // rNamesNotContained contain the missing names.
     153             :     bool containsAllNames(
     154             :                     const com::sun::star::uno::Sequence<
     155             :                         com::sun::star::beans::Property >& rProps,
     156             :                     std::vector< OUString > & rNamesNotContained ) const;
     157             : 
     158             :     // adds all properties described by rProps that are actually contained in
     159             :     // rContentProps to this instance. In case of duplicates the value
     160             :     // already contained in this will left unchanged.
     161             :     void addProperties( const std::vector< OUString > & rProps,
     162             :                         const ContentProperties & rContentProps );
     163             : 
     164             :     // overwrites probably existing entry.
     165             :     void addProperty( const OUString & rName,
     166             :                      const com::sun::star::uno::Any & rValue,
     167             :                      bool bIsCaseSensitive );
     168             : 
     169             :     // overwrites probably existing entry.
     170             :     void addProperty( const DAVPropertyValue & rProp );
     171             : 
     172           0 :     bool isTrailingSlash() const { return m_bTrailingSlash; }
     173             : 
     174           0 :     const OUString & getEscapedTitle() const { return m_aEscapedTitle; }
     175             : 
     176             :     // Not good to expose implementation details, but this is actually an
     177             :     // internal class.
     178           0 :     const std::auto_ptr< PropertyValueMap > & getProperties() const
     179           0 :     { return m_xProps; }
     180             : 
     181             : private:
     182             :     OUString m_aEscapedTitle;
     183             :     std::auto_ptr< PropertyValueMap > m_xProps;
     184             :     bool m_bTrailingSlash;
     185             : 
     186             :     static com::sun::star::uno::Any m_aEmptyAny;
     187             : 
     188             :     ContentProperties & operator=( const ContentProperties & ); // n.i.
     189             : 
     190             :     const PropertyValue * get( const OUString & rName ) const;
     191             : };
     192             : 
     193           0 : class CachableContentProperties
     194             : {
     195             : private:
     196             :     ContentProperties m_aProps;
     197             : 
     198             :     CachableContentProperties & operator=( const CachableContentProperties & ); // n.i.
     199             :     CachableContentProperties( const CachableContentProperties & ); // n.i.
     200             : 
     201             : public:
     202             :     CachableContentProperties( const ContentProperties & rProps );
     203             : 
     204             :     void addProperties( const ContentProperties & rProps );
     205             : 
     206             :     void addProperties( const std::vector< DAVPropertyValue > & rProps );
     207             : 
     208           0 :     bool containsAllNames(
     209             :                     const com::sun::star::uno::Sequence<
     210             :                         com::sun::star::beans::Property >& rProps,
     211             :                     std::vector< OUString > & rNamesNotContained ) const
     212           0 :     { return m_aProps.containsAllNames( rProps, rNamesNotContained ); }
     213             : 
     214             :     const com::sun::star::uno::Any &
     215           0 :     getValue( const OUString & rName ) const
     216           0 :     { return m_aProps.getValue( rName ); }
     217             : 
     218           0 :     operator const ContentProperties & () const { return m_aProps; }
     219             : };
     220             : 
     221             : } // namespace webdav_ucp
     222             : 
     223             : #endif /* !_WEBDAV_UCP_CONTENTPROPERTIES_HXX */
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10