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

Generated by: LCOV version 1.11