LCOV - code coverage report
Current view: top level - ucb/source/ucp/hierarchy - hierarchyprovider.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 6 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 _HIERARCHYPROVIDER_HXX
      30                 :            : #define _HIERARCHYPROVIDER_HXX
      31                 :            : 
      32                 :            : #include <boost/unordered_map.hpp>
      33                 :            : #include <ucbhelper/providerhelper.hxx>
      34                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      35                 :            : 
      36                 :            : namespace com { namespace sun { namespace star {
      37                 :            :     namespace container {
      38                 :            :         class XHierarchicalNameAccess;
      39                 :            :     }
      40                 :            :     namespace util {
      41                 :            :         class XOfficeInstallationDirectories;
      42                 :            :     }
      43                 :            : } } }
      44                 :            : 
      45                 :            : namespace hierarchy_ucp {
      46                 :            : 
      47                 :            : //=========================================================================
      48                 :            : 
      49                 :            : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
      50                 :            :                 "com.sun.star.ucb.HierarchyContentProvider"
      51                 :            : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME_LENGTH  41
      52                 :            : 
      53                 :            : #define HIERARCHY_URL_SCHEME \
      54                 :            :                 "vnd.sun.star.hier"
      55                 :            : #define HIERARCHY_URL_SCHEME_LENGTH 17
      56                 :            : 
      57                 :            : #define HIERARCHY_FOLDER_CONTENT_TYPE \
      58                 :            :                 "application/" HIERARCHY_URL_SCHEME "-folder"
      59                 :            : #define HIERARCHY_LINK_CONTENT_TYPE \
      60                 :            :                 "application/" HIERARCHY_URL_SCHEME "-link"
      61                 :            : 
      62                 :            : //=========================================================================
      63                 :            : 
      64                 :          6 : struct ConfigProviderMapEntry
      65                 :            : {
      66                 :            :     com::sun::star::uno::Reference<
      67                 :            :         com::sun::star::lang::XMultiServiceFactory > xConfigProvider;
      68                 :            :     com::sun::star::uno::Reference<
      69                 :            :         com::sun::star::container::XHierarchicalNameAccess > xRootReadAccess;
      70                 :            :     bool bTriedToGetRootReadAccess;  // #82494#
      71                 :            : 
      72                 :          4 :     ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
      73                 :            : };
      74                 :            : 
      75                 :            : struct equalString
      76                 :            : {
      77                 :        284 :     bool operator()(
      78                 :            :         const rtl::OUString& rKey1, const rtl::OUString& rKey2 ) const
      79                 :            :     {
      80                 :        284 :         return !!( rKey1 == rKey2 );
      81                 :            :     }
      82                 :            : };
      83                 :            : 
      84                 :            : struct hashString
      85                 :            : {
      86                 :        286 :     size_t operator()( const rtl::OUString & rName ) const
      87                 :            :     {
      88                 :        286 :         return rName.hashCode();
      89                 :            :     }
      90                 :            : };
      91                 :            : 
      92                 :            : typedef boost::unordered_map
      93                 :            : <
      94                 :            :     rtl::OUString,  // servcie specifier
      95                 :            :     ConfigProviderMapEntry,
      96                 :            :     hashString,
      97                 :            :     equalString
      98                 :            : >
      99                 :            : ConfigProviderMap;
     100                 :            : 
     101                 :            : //=========================================================================
     102                 :            : 
     103                 :            : class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
     104                 :            :                                  public com::sun::star::lang::XInitialization
     105                 :            : {
     106                 :            :     ConfigProviderMap   m_aConfigProviderMap;
     107                 :            :     com::sun::star::uno::Reference<
     108                 :            :         com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
     109                 :            : 
     110                 :            : public:
     111                 :            :     HierarchyContentProvider(
     112                 :            :                 const com::sun::star::uno::Reference<
     113                 :            :                     com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
     114                 :            :     virtual ~HierarchyContentProvider();
     115                 :            : 
     116                 :            :     // XInterface
     117                 :            :     XINTERFACE_DECL()
     118                 :            : 
     119                 :            :     // XTypeProvider
     120                 :            :     XTYPEPROVIDER_DECL()
     121                 :            : 
     122                 :            :     // XServiceInfo
     123                 :            :     XSERVICEINFO_DECL()
     124                 :            : 
     125                 :            :     // XContentProvider
     126                 :            :     virtual com::sun::star::uno::Reference<
     127                 :            :                 com::sun::star::ucb::XContent > SAL_CALL
     128                 :            :     queryContent( const com::sun::star::uno::Reference<
     129                 :            :                     com::sun::star::ucb::XContentIdentifier >& Identifier )
     130                 :            :         throw( com::sun::star::ucb::IllegalIdentifierException,
     131                 :            :                com::sun::star::uno::RuntimeException );
     132                 :            : 
     133                 :            :     // XInitialization
     134                 :            :     virtual void SAL_CALL
     135                 :            :     initialize( const ::com::sun::star::uno::Sequence<
     136                 :            :                         ::com::sun::star::uno::Any >& aArguments )
     137                 :            :         throw( ::com::sun::star::uno::Exception,
     138                 :            :                ::com::sun::star::uno::RuntimeException );
     139                 :            : 
     140                 :            :     // Non-Interface methods
     141                 :            :     com::sun::star::uno::Reference<
     142                 :            :         com::sun::star::lang::XMultiServiceFactory >
     143                 :            :     getConfigProvider( const rtl::OUString & rServiceSpecifier );
     144                 :            :     com::sun::star::uno::Reference<
     145                 :            :         com::sun::star::container::XHierarchicalNameAccess >
     146                 :            :     getRootConfigReadNameAccess( const rtl::OUString & rServiceSpecifier );
     147                 :            : 
     148                 :            :     // Note: may retrun an empty reference.
     149                 :            :     com::sun::star::uno::Reference<
     150                 :            :         com::sun::star::util::XOfficeInstallationDirectories >
     151                 :            :     getOfficeInstallationDirectories();
     152                 :            : };
     153                 :            : 
     154                 :            : } // namespace hierarchy_ucp
     155                 :            : 
     156                 :            : #endif /* !_HIERARCHYPROVIDER_HXX */
     157                 :            : 
     158                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10