LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - ContentProperties.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 18 0.0 %
Date: 2014-11-03 Functions: 0 15 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 INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_CONTENTPROPERTIES_HXX
      30             : #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_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             : 
      52             : 
      53             : // PropertyValueMap.
      54             : 
      55             : 
      56             : 
      57           0 : class PropertyValue
      58             : {
      59             : private:
      60             :     ::com::sun::star::uno::Any m_aValue;
      61             :     bool                       m_bIsCaseSensitive;
      62             : 
      63             : public:
      64           0 :     PropertyValue()
      65           0 :     : m_bIsCaseSensitive( true ) {}
      66             : 
      67           0 :     PropertyValue( const ::com::sun::star::uno::Any & rValue,
      68             :                    bool bIsCaseSensitive )
      69             :     : m_aValue( rValue),
      70           0 :       m_bIsCaseSensitive( bIsCaseSensitive ) {}
      71             : 
      72           0 :     bool isCaseSensitive() const { return m_bIsCaseSensitive; }
      73           0 :     const ::com::sun::star::uno::Any & value() const { return m_aValue; }
      74             : 
      75             : };
      76             : 
      77             : typedef boost::unordered_map
      78             : <
      79             :     OUString,
      80             :     PropertyValue,
      81             :     OUStringHash
      82             : >
      83             : PropertyValueMap;
      84             : 
      85             : struct DAVResource;
      86             : 
      87           0 : class ContentProperties
      88             : {
      89             : public:
      90             :     ContentProperties();
      91             : 
      92             :     ContentProperties( const DAVResource& rResource );
      93             : 
      94             :     // Mini props for transient contents.
      95             :     ContentProperties( const OUString & rTitle, bool bFolder );
      96             : 
      97             :     // Micro props for non-existing contents.
      98             :     ContentProperties( const OUString & rTitle );
      99             : 
     100             :     ContentProperties( const ContentProperties & rOther );
     101             : 
     102             :     bool contains( const OUString & rName ) const;
     103             : 
     104             :     const com::sun::star::uno::Any &
     105             :     getValue( const OUString & rName ) const;
     106             : 
     107             :     // Maps the UCB property names contained in rProps with their DAV property
     108             :     // counterparts, if possible. All unmappable properties will be included
     109             :     // unchanged in resulting vector unless bIncludeUnmatched is set to false.
     110             :     // The vector filles by this method can directly be handed over to
     111             :     // DAVResourceAccess::PROPFIND. The result from PROPFIND
     112             :     // (vector< DAVResource >) can be used to create a ContentProperties
     113             :     // instance which can map DAV properties back to UCB properties.
     114             :     static void UCBNamesToDAVNames( const com::sun::star::uno::Sequence<
     115             :                                         com::sun::star::beans::Property > &
     116             :                                             rProps,
     117             :                                     std::vector< OUString > & resources,
     118             :                                     bool bIncludeUnmatched = true );
     119             : 
     120             :     // Maps the UCB property names contained in rProps with their HTTP header
     121             :     // counterparts, if possible. All unmappable properties will be included
     122             :     // unchanged in resulting vector unless bIncludeUnmatched is set to false.
     123             :     // The vector filles by this method can directly be handed over to
     124             :     // DAVResourceAccess::HEAD. The result from HEAD (vector< DAVResource >)
     125             :     // can be used to create a ContentProperties instance which can map header
     126             :     // names back to UCB properties.
     127             :     static void UCBNamesToHTTPNames( const com::sun::star::uno::Sequence<
     128             :                                         com::sun::star::beans::Property > &
     129             :                                             rProps,
     130             :                                     std::vector< OUString > & resources,
     131             :                                     bool bIncludeUnmatched = true );
     132             : 
     133             :     // return true, if all properties contained in rProps are contained in
     134             :     // this ContentProperties instance. Otherwiese, false will be returned.
     135             :     // rNamesNotContained contain the missing names.
     136             :     bool containsAllNames(
     137             :                     const com::sun::star::uno::Sequence<
     138             :                         com::sun::star::beans::Property >& rProps,
     139             :                     std::vector< OUString > & rNamesNotContained ) const;
     140             : 
     141             :     // adds all properties described by rProps that are actually contained in
     142             :     // rContentProps to this instance. In case of duplicates the value
     143             :     // already contained in this will left unchanged.
     144             :     void addProperties( const std::vector< OUString > & rProps,
     145             :                         const ContentProperties & rContentProps );
     146             : 
     147             :     // overwrites probably existing entry.
     148             :     void addProperty( const OUString & rName,
     149             :                      const com::sun::star::uno::Any & rValue,
     150             :                      bool bIsCaseSensitive );
     151             : 
     152             :     // overwrites probably existing entry.
     153             :     void addProperty( const DAVPropertyValue & rProp );
     154             : 
     155           0 :     bool isTrailingSlash() const { return m_bTrailingSlash; }
     156             : 
     157           0 :     const OUString & getEscapedTitle() const { return m_aEscapedTitle; }
     158             : 
     159             :     // Not good to expose implementation details, but this is actually an
     160             :     // internal class.
     161           0 :     const std::unique_ptr< PropertyValueMap > & getProperties() const
     162           0 :     { return m_xProps; }
     163             : 
     164             : private:
     165             :     OUString m_aEscapedTitle;
     166             :     std::unique_ptr< PropertyValueMap > m_xProps;
     167             :     bool m_bTrailingSlash;
     168             : 
     169             :     static com::sun::star::uno::Any m_aEmptyAny;
     170             : 
     171             :     ContentProperties & operator=( const ContentProperties & ); // n.i.
     172             : 
     173             :     const PropertyValue * get( const OUString & rName ) const;
     174             : };
     175             : 
     176           0 : class CachableContentProperties
     177             : {
     178             : private:
     179             :     ContentProperties m_aProps;
     180             : 
     181             :     CachableContentProperties & operator=( const CachableContentProperties & ); // n.i.
     182             :     CachableContentProperties( const CachableContentProperties & ); // n.i.
     183             : 
     184             : public:
     185             :     CachableContentProperties( const ContentProperties & rProps );
     186             : 
     187             :     void addProperties( const ContentProperties & rProps );
     188             : 
     189             :     void addProperties( const std::vector< DAVPropertyValue > & rProps );
     190             : 
     191           0 :     bool containsAllNames(
     192             :                     const com::sun::star::uno::Sequence<
     193             :                         com::sun::star::beans::Property >& rProps,
     194             :                     std::vector< OUString > & rNamesNotContained ) const
     195           0 :     { return m_aProps.containsAllNames( rProps, rNamesNotContained ); }
     196             : 
     197             :     const com::sun::star::uno::Any &
     198           0 :     getValue( const OUString & rName ) const
     199           0 :     { return m_aProps.getValue( rName ); }
     200             : 
     201           0 :     operator const ContentProperties & () const { return m_aProps; }
     202             : };
     203             : 
     204             : } // namespace webdav_ucp
     205             : 
     206             : #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_CONTENTPROPERTIES_HXX
     207             : 
     208             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10