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

Generated by: LCOV version 1.10