LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/ucbhelper - providerhelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 1 1 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                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef _UCBHELPER_PROVIDERHELPER_HXX
      21                 :            : #define _UCBHELPER_PROVIDERHELPER_HXX
      22                 :            : 
      23                 :            : #ifndef __LIST__
      24                 :            : #include <list>
      25                 :            : #endif
      26                 :            : #include <com/sun/star/ucb/XContentProvider.hpp>
      27                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      28                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29                 :            : #include <com/sun/star/lang/XTypeProvider.hpp>
      30                 :            : #include <cppuhelper/weak.hxx>
      31                 :            : 
      32                 :            : #include "osl/mutex.hxx"
      33                 :            : #include "rtl/ref.hxx"
      34                 :            : #include <ucbhelper/macros.hxx>
      35                 :            : #include "ucbhelper/ucbhelperdllapi.h"
      36                 :            : 
      37                 :            : //=========================================================================
      38                 :            : 
      39                 :            : namespace com { namespace sun { namespace star { namespace ucb {
      40                 :            :     class XPropertySetRegistry;
      41                 :            :     class XPersistentPropertySet;
      42                 :            : } } } }
      43                 :            : 
      44                 :            : namespace ucbhelper_impl { struct ContentProviderImplHelper_Impl; }
      45                 :            : 
      46                 :            : namespace ucbhelper {
      47                 :            : 
      48                 :            : //=========================================================================
      49                 :            : 
      50                 :            : class ContentImplHelper;
      51                 :            : typedef rtl::Reference< ContentImplHelper > ContentImplHelperRef;
      52                 :            : typedef std::list< ContentImplHelperRef > ContentRefList;
      53                 :            : 
      54                 :            : /**
      55                 :            :   * This is an abstract base class for implementations of the service
      56                 :            :   * com.sun.star.ucb.ContentProvider. It provides contents derived from
      57                 :            :   * class ucb::ContentImplHelper.
      58                 :            :   *
      59                 :            :   * Features of the base class implementation:
      60                 :            :   * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo )
      61                 :            :   * - maintains a set of ContentImplHelper objects, which were created by
      62                 :            :   *   the provider implementation. So there will be exactly one object for
      63                 :            :   *   one Content Identifier.
      64                 :            :   * - Provides access to the Additional Core PropertySet of a content.
      65                 :            :   *   ( These set contains the properties added to a content using its
      66                 :            :   *   XPropertyContainer interface )
      67                 :            :   */
      68                 :            : class UCBHELPER_DLLPUBLIC ContentProviderImplHelper : public cppu::OWeakObject,
      69                 :            :                                     public com::sun::star::lang::XTypeProvider,
      70                 :            :                                     public com::sun::star::lang::XServiceInfo,
      71                 :            :                                     public com::sun::star::ucb::XContentProvider
      72                 :            : {
      73                 :            :     friend class ContentImplHelper;
      74                 :            : 
      75                 :            :     ucbhelper_impl::ContentProviderImplHelper_Impl* m_pImpl;
      76                 :            : 
      77                 :            : protected:
      78                 :            :     osl::Mutex m_aMutex;
      79                 :            :     ::com::sun::star::uno::Reference<
      80                 :            :             ::com::sun::star::lang::XMultiServiceFactory >  m_xSMgr;
      81                 :            : 
      82                 :            : private:
      83                 :            :     UCBHELPER_DLLPRIVATE void removeContent( ContentImplHelper* pContent );
      84                 :            : 
      85                 :            :     UCBHELPER_DLLPRIVATE ::com::sun::star::uno::Reference<
      86                 :            :         ::com::sun::star::ucb::XPropertySetRegistry >
      87                 :            :     getAdditionalPropertySetRegistry();
      88                 :            : 
      89                 :            :     UCBHELPER_DLLPRIVATE void cleanupRegisteredContents();
      90                 :            : 
      91                 :            : protected:
      92                 :            :     /**
      93                 :            :       * This method returns a content with the given id, if it already exists.
      94                 :            :       * Use this method in your "queryContent" implementation to ensure unique
      95                 :            :       * objects.
      96                 :            :       *
      97                 :            :       * @param  Identifier is the content identifier, for that an existing
      98                 :            :       *         content object is requested.
      99                 :            :       * @return the content with the given identifier, if it exists or 0, if it
     100                 :            :       *         does not exist.
     101                 :            :       */
     102                 :            :     rtl::Reference< ContentImplHelper >
     103                 :            :     queryExistingContent( const ::com::sun::star::uno::Reference<
     104                 :            :                    ::com::sun::star::ucb::XContentIdentifier >& Identifier );
     105                 :            : 
     106                 :            :     /**
     107                 :            :       * This method returns a content with the given URL, if it already exists.
     108                 :            :       *
     109                 :            :       * @param  rURL is the URL ( content identifier string ), for that an
     110                 :            :       *         existing content object is requested.
     111                 :            :       * @return the content with the given URL, if it exists or 0, if it
     112                 :            :       *         does not exist.
     113                 :            :       */
     114                 :            :     rtl::Reference< ContentImplHelper >
     115                 :            :     queryExistingContent( const ::rtl::OUString& rURL );
     116                 :            : 
     117                 :            :     /**
     118                 :            :       * This method registers a newly created content instance with the
     119                 :            :       * content provider. It should be called directly after creating a new
     120                 :            :       * content instance. The provider can reuse a registered instance upon
     121                 :            :       * subsedent requests for content instances with an idententifier
     122                 :            :       * of a registered instance.
     123                 :            :       * Note that the provider does not hold a hard reference on the
     124                 :            :       * registered instance. If last external reference is gone, the provider
     125                 :            :       * will remove the instance from its inventory of known instances.
     126                 :            :       * Nothing will happen in case an already registered instance shall
     127                 :            :       * be registered more than once.
     128                 :            :       *
     129                 :            :       * @param  the content instance that is to be registered.
     130                 :            :      */
     131                 :            :     void registerNewContent(
     132                 :            :         const com::sun::star::uno::Reference<
     133                 :            :             ::com::sun::star::ucb::XContent > & xContent );
     134                 :            : 
     135                 :            : public:
     136                 :            : 
     137                 :            :     //////////////////////////////////////////////////////////////////////
     138                 :            :     // Contsruction/Destruction
     139                 :            :     //////////////////////////////////////////////////////////////////////
     140                 :            : 
     141                 :            :     ContentProviderImplHelper(
     142                 :            :                 const ::com::sun::star::uno::Reference<
     143                 :            :                     ::com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
     144                 :            :     virtual ~ContentProviderImplHelper();
     145                 :            : 
     146                 :            :     //////////////////////////////////////////////////////////////////////
     147                 :            :     // XInterface
     148                 :            :     //////////////////////////////////////////////////////////////////////
     149                 :            : 
     150                 :            :     XINTERFACE_DECL()
     151                 :            : 
     152                 :            :     //////////////////////////////////////////////////////////////////////
     153                 :            :     // XTypeProvider
     154                 :            :     //////////////////////////////////////////////////////////////////////
     155                 :            : 
     156                 :            :     XTYPEPROVIDER_DECL()
     157                 :            : 
     158                 :            :     //////////////////////////////////////////////////////////////////////
     159                 :            :     // XServiceInfo
     160                 :            :     //////////////////////////////////////////////////////////////////////
     161                 :            : 
     162                 :            :     virtual ::rtl::OUString SAL_CALL
     163                 :            :     getImplementationName()
     164                 :            :         throw( ::com::sun::star::uno::RuntimeException ) = 0;
     165                 :            :     virtual sal_Bool SAL_CALL
     166                 :            :     supportsService( const ::rtl::OUString& ServiceName )
     167                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     168                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
     169                 :            :     getSupportedServiceNames()
     170                 :            :         throw( ::com::sun::star::uno::RuntimeException ) = 0;
     171                 :            : 
     172                 :            :     //////////////////////////////////////////////////////////////////////
     173                 :            :     // XContentProvider
     174                 :            :     //////////////////////////////////////////////////////////////////////
     175                 :            : 
     176                 :            :     /**
     177                 :            :       * This method returns a content with the requested id.
     178                 :            :       *
     179                 :            :       * The implementation should:
     180                 :            :       *
     181                 :            :       * - Check, whether the Identifier is valid ( URL syntax ).
     182                 :            :       * - Use queryExistingContent(...) to determine, whether there exists
     183                 :            :       *   already a content with the given id.
     184                 :            :       * - Return the possibly existing content.Create and return a new
     185                 :            :       *   content, otherwise
     186                 :            :       */
     187                 :            :     virtual ::com::sun::star::uno::Reference<
     188                 :            :                 ::com::sun::star::ucb::XContent > SAL_CALL
     189                 :            :     queryContent( const ::com::sun::star::uno::Reference<
     190                 :            :                     ::com::sun::star::ucb::XContentIdentifier >& Identifier )
     191                 :            :         throw( ::com::sun::star::ucb::IllegalIdentifierException,
     192                 :            :                ::com::sun::star::uno::RuntimeException ) = 0;
     193                 :            :     virtual sal_Int32 SAL_CALL
     194                 :            :     compareContentIds( const ::com::sun::star::uno::Reference<
     195                 :            :                             ::com::sun::star::ucb::XContentIdentifier >& Id1,
     196                 :            :                        const ::com::sun::star::uno::Reference<
     197                 :            :                                ::com::sun::star::ucb::XContentIdentifier >& Id2 )
     198                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     199                 :            : 
     200                 :            :     //////////////////////////////////////////////////////////////////////
     201                 :            :     // Non-interface methods.
     202                 :            :     //////////////////////////////////////////////////////////////////////
     203                 :            : 
     204                 :            :     /**
     205                 :            :       * This method returns a mutex, which protects the content list of the
     206                 :            :       * provider. So you can prevent modifications of that list easyly.
     207                 :            :       *
     208                 :            :       * @return the mutex.
     209                 :            :       */
     210                 :        365 :     osl::Mutex& getContentListMutex() { return m_aMutex; }
     211                 :            : 
     212                 :            :     /**
     213                 :            :       * This method fills a list with all contents existing at calling time.
     214                 :            :       * Note: You may prevent modifications of the content list at any time
     215                 :            :       * by acquiring the content list mutex of the provider.
     216                 :            :       *
     217                 :            :       * @param  rContents is the list to fill with the children.
     218                 :            :       */
     219                 :            :     void queryExistingContents( ContentRefList& rContents );
     220                 :            : 
     221                 :            :     /**
     222                 :            :       * This method returns the propertyset containing the Additional Core
     223                 :            :       * Properties of a content.
     224                 :            :       *
     225                 :            :       * @param  rKey is the key for the propertyset.
     226                 :            :       * @param  bCreate is a flag indicating whether the propertyset shall
     227                 :            :       *         be created in case it does not exist.
     228                 :            :       * @return the propertyset containing the Additional Core Properties.
     229                 :            :       */
     230                 :            :     ::com::sun::star::uno::Reference<
     231                 :            :         com::sun::star::ucb::XPersistentPropertySet >
     232                 :            :     getAdditionalPropertySet( const ::rtl::OUString& rKey, sal_Bool bCreate );
     233                 :            : 
     234                 :            :     /**
     235                 :            :       * This method renames the propertyset containing the Additional Core
     236                 :            :       * Properties of a content.
     237                 :            :       *
     238                 :            :       * @param  rOldKey is the old key of the propertyset.
     239                 :            :       * @param  rNewKey is the new key for the propertyset.
     240                 :            :       * @param  bRecursive is a flag indicating whether propertysets for
     241                 :            :       *         children described by rOldKey shall be renamed, too.
     242                 :            :       * @return True, if the operation succeeded - False, otherwise.
     243                 :            :       */
     244                 :            :     sal_Bool renameAdditionalPropertySet( const ::rtl::OUString& rOldKey,
     245                 :            :                                           const ::rtl::OUString& rNewKey,
     246                 :            :                                           sal_Bool bRecursive );
     247                 :            : 
     248                 :            :     /**
     249                 :            :       * This method copies the propertyset containing the Additional Core
     250                 :            :       * Properties of a content.
     251                 :            :       *
     252                 :            :       * @param  rSourceKey is the key of the source propertyset.
     253                 :            :       * @param  rTargetKey is the key of the target propertyset.
     254                 :            :       * @param  bRecursive is a flag indicating whether propertysets for
     255                 :            :       *         children described by rSourceKey shall be copied, too.
     256                 :            :       * @return True, if the operation succeeded - False, otherwise.
     257                 :            :       */
     258                 :            :     sal_Bool copyAdditionalPropertySet( const ::rtl::OUString& rSourceKey,
     259                 :            :                                         const ::rtl::OUString& rTargetKey,
     260                 :            :                                         sal_Bool bRecursive );
     261                 :            : 
     262                 :            :     /**
     263                 :            :       * This method removes the propertyset containing the Additional Core
     264                 :            :       * Properties of a content.
     265                 :            :       *
     266                 :            :       * @param  rKey is the key of the propertyset.
     267                 :            :       * @param  bRecursive is a flag indicating whether propertysets for
     268                 :            :       *         children described by rOldKey shall be removed, too.
     269                 :            :       * @return True, if the operation succeeded - False, otherwise.
     270                 :            :       */
     271                 :            :     sal_Bool removeAdditionalPropertySet( const ::rtl::OUString& rKey,
     272                 :            :                                           sal_Bool bRecursive );
     273                 :            : };
     274                 :            : 
     275                 :            : } // namespace ucbhelper
     276                 :            : 
     277                 :            : #endif /* !_UCBHELPER_PROVIDERHELPER_HXX */
     278                 :            : 
     279                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10