LCOV - code coverage report
Current view: top level - dbaccess/source/core/inc - ContentHelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 8 75.0 %
Date: 2012-08-25 Functions: 4 7 57.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 18 50.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                 :            : #ifndef DBA_CONTENTHELPER_HXX
      20                 :            : #define DBA_CONTENTHELPER_HXX
      21                 :            : 
      22                 :            : #include <com/sun/star/ucb/XContent.hpp>
      23                 :            : #include <com/sun/star/ucb/XCommandProcessor.hpp>
      24                 :            : #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
      25                 :            : #include <com/sun/star/beans/XPropertyContainer.hpp>
      26                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      27                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      28                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      29                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      30                 :            : #include <com/sun/star/sdbc/XRow.hpp>
      31                 :            : #include <com/sun/star/embed/XStorage.hpp>
      32                 :            : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      33                 :            : #include <com/sun/star/lang/XUnoTunnel.hpp>
      34                 :            : #include <cppuhelper/compbase9.hxx>
      35                 :            : #include <comphelper/broadcasthelper.hxx>
      36                 :            : #include <comphelper/componentcontext.hxx>
      37                 :            : #include <comphelper/uno3.hxx>
      38                 :            : #include <comphelper/stl_types.hxx>
      39                 :            : #include <com/sun/star/beans/Property.hpp>
      40                 :            : #include <com/sun/star/container/XChild.hpp>
      41                 :            : #include <com/sun/star/sdbcx/XRename.hpp>
      42                 :            : #include <connectivity/sqlerror.hxx>
      43                 :            : #include <boost/shared_ptr.hpp>
      44                 :            : 
      45                 :            : namespace dbaccess
      46                 :            : {
      47                 :            :     class ODatabaseModelImpl;
      48         [ +  - ]:        838 :     struct ContentProperties
      49                 :            :     {
      50                 :            :         ::rtl::OUString aTitle;         // Title
      51                 :            :         ::boost::optional< ::rtl::OUString >
      52                 :            :                         aContentType;   // ContentType (aka MediaType aka MimeType)
      53                 :            :         sal_Bool        bIsDocument;    // IsDocument
      54                 :            :         sal_Bool        bIsFolder;      // IsFolder
      55                 :            :         sal_Bool        bAsTemplate;    // AsTemplate
      56                 :            :         ::rtl::OUString sPersistentName;// persistent name of the document
      57                 :            : 
      58                 :        838 :         ContentProperties()
      59                 :            :             :bIsDocument( sal_True )
      60                 :            :             ,bIsFolder( sal_False )
      61         [ +  - ]:        838 :             ,bAsTemplate( sal_False )
      62                 :            :         {
      63                 :        838 :         }
      64                 :            :     };
      65                 :            : 
      66                 :            :     class OContentHelper_Impl
      67                 :            :     {
      68                 :            :     public:
      69                 :            :         OContentHelper_Impl();
      70                 :            :         virtual ~OContentHelper_Impl();
      71                 :            : 
      72                 :            :         ContentProperties   m_aProps;
      73                 :            :         ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
      74                 :            :     };
      75                 :            : 
      76                 :            :     typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;
      77                 :            : 
      78                 :            : 
      79                 :            :     typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<  ::rtl::OUString,
      80                 :            :                                                             ::rtl::OUStringHash,
      81                 :            :                                                             ::comphelper::UStringEqual
      82                 :            :                                                         > PropertyChangeListenerContainer;
      83                 :            :     typedef ::comphelper::OBaseMutex    OContentHelper_MBASE;
      84                 :            :     typedef ::cppu::WeakComponentImplHelper9    <   ::com::sun::star::ucb::XContent
      85                 :            :                                                 ,   ::com::sun::star::ucb::XCommandProcessor
      86                 :            :                                                 ,   ::com::sun::star::lang::XServiceInfo
      87                 :            :                                                 ,   ::com::sun::star::beans::XPropertiesChangeNotifier
      88                 :            :                                                 ,   ::com::sun::star::beans::XPropertyContainer
      89                 :            :                                                 ,   ::com::sun::star::lang::XInitialization
      90                 :            :                                                 ,   ::com::sun::star::lang::XUnoTunnel
      91                 :            :                                                 ,   ::com::sun::star::container::XChild
      92                 :            :                                                 ,   ::com::sun::star::sdbcx::XRename
      93                 :            :                                                 >   OContentHelper_COMPBASE;
      94                 :            : 
      95 [ +  - ][ +  - ]:       1434 :     class OContentHelper :   public OContentHelper_MBASE
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ -  + ]
      96                 :            :                             ,public OContentHelper_COMPBASE
      97                 :            :     {
      98                 :            :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
      99                 :            :             setPropertyValues( const ::com::sun::star::uno::Sequence<
     100                 :            :                                 ::com::sun::star::beans::PropertyValue >& rValues,
     101                 :            :                             const ::com::sun::star::uno::Reference<
     102                 :            :                                 ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
     103                 :            :         com::sun::star::uno::Sequence< com::sun::star::beans::Property >
     104                 :            :             getProperties( const com::sun::star::uno::Reference<
     105                 :            :                             com::sun::star::ucb::XCommandEnvironment > & xEnv );
     106                 :            : 
     107                 :            :         void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true);
     108                 :            : 
     109                 :            :     protected:
     110                 :            :         ::cppu::OInterfaceContainerHelper       m_aContentListeners;
     111                 :            :         PropertyChangeListenerContainer         m_aPropertyChangeListeners;
     112                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     113                 :            :                                                 m_xParentContainer;
     114                 :            :         const ::comphelper::ComponentContext    m_aContext;
     115                 :            :         const ::connectivity::SQLError          m_aErrorHelper;
     116                 :            :         TContentPtr                             m_pImpl;
     117                 :            :         sal_uInt32                              m_nCommandId;
     118                 :            : 
     119                 :            :         // helper
     120                 :            :         virtual void SAL_CALL disposing();
     121                 :            : 
     122                 :            :         virtual void notifyDataSourceModified();
     123                 :            : 
     124                 :            :         /**
     125                 :            :         * This method can be used to propagate changes of property values.
     126                 :            :         *
     127                 :            :         * @param evt is a sequence of property change events.
     128                 :            :         */
     129                 :            :         void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
     130                 :            : 
     131                 :            :         ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
     132                 :            : 
     133                 :            :     public:
     134                 :            : 
     135                 :            :         OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
     136                 :            :                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&   _xParentContainer
     137                 :            :                         ,const TContentPtr& _pImpl
     138                 :            :                     );
     139                 :            : 
     140                 :            :         // com::sun::star::lang::XTypeProvider
     141                 :            :         virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
     142                 :            :         static ::com::sun::star::uno::Sequence< sal_Int8 >  getUnoTunnelImplementationId();
     143                 :            :         // ::com::sun::star::lang::XServiceInfo
     144                 :            :         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
     145                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
     146                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
     147                 :            : 
     148                 :            :         // XContent
     149                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
     150                 :            :         virtual ::rtl::OUString SAL_CALL getContentType(  ) throw (::com::sun::star::uno::RuntimeException) ;
     151                 :            :         virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
     152                 :            :         virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
     153                 :            : 
     154                 :            :         // XCommandProcessor
     155                 :            :         virtual sal_Int32 SAL_CALL createCommandIdentifier(  ) throw (::com::sun::star::uno::RuntimeException) ;
     156                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
     157                 :            :         virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;
     158                 :            : 
     159                 :            :         // XPropertiesChangeNotifier
     160                 :            :         virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
     161                 :            :         virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
     162                 :            : 
     163                 :            :         // XPropertyContainer
     164                 :            :         virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ;
     165                 :            :         virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ;
     166                 :            : 
     167                 :            :         // XInitialization
     168                 :            :         virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     169                 :            : 
     170                 :            :         // com::sun::star::lang::XUnoTunnel
     171                 :            :         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
     172                 :            :         static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
     173                 :            : 
     174                 :            :         // ::com::sun::star::container::XChild
     175                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
     176                 :            :         virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
     177                 :            : 
     178                 :            :         // XRename
     179                 :            :         virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     180                 :            : 
     181                 :          0 :         inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
     182                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     183                 :            :             getPropertyValues( const ::com::sun::star::uno::Sequence<
     184                 :            :                             ::com::sun::star::beans::Property >& rProperties );
     185                 :            : 
     186                 :          0 :         const ::comphelper::ComponentContext& getContext() const { return m_aContext; }
     187                 :            : 
     188                 :         80 :         inline TContentPtr getImpl() const { return m_pImpl; }
     189                 :            : 
     190                 :            :     protected:
     191                 :            :         virtual ::rtl::OUString determineContentType() const = 0;
     192                 :            :     };
     193                 :            : 
     194                 :            : }   // namespace dbaccess
     195                 :            : 
     196                 :            : #endif // DBA_CONTENTHELPER_HXX
     197                 :            : 
     198                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10