PageRenderTime 202ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/dbaccess/source/core/inc/ContentHelper.hxx

https://bitbucket.org/markjenkins/libreoffice_ubuntu-debian-fixes
C++ Header | 198 lines | 130 code | 33 blank | 35 comment | 0 complexity | 0f6993b7d8d7c42365a59382dd9d9ea0 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause-No-Nuclear-License-2014
  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. #include <com/sun/star/ucb/XContent.hpp>
  22. #include <com/sun/star/ucb/XCommandProcessor.hpp>
  23. #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
  24. #include <com/sun/star/beans/XPropertyContainer.hpp>
  25. #include <com/sun/star/lang/XServiceInfo.hpp>
  26. #include <com/sun/star/lang/XSingleServiceFactory.hpp>
  27. #include <com/sun/star/lang/XInitialization.hpp>
  28. #include <com/sun/star/container/XNameAccess.hpp>
  29. #include <com/sun/star/sdbc/XRow.hpp>
  30. #include <com/sun/star/embed/XStorage.hpp>
  31. #include <com/sun/star/embed/XEmbeddedObject.hpp>
  32. #include <com/sun/star/lang/XUnoTunnel.hpp>
  33. #include <cppuhelper/compbase9.hxx>
  34. #include <comphelper/broadcasthelper.hxx>
  35. #include <comphelper/componentcontext.hxx>
  36. #include <comphelper/uno3.hxx>
  37. #include <comphelper/stl_types.hxx>
  38. #include <com/sun/star/beans/Property.hpp>
  39. #include <com/sun/star/container/XChild.hpp>
  40. #include <com/sun/star/sdbcx/XRename.hpp>
  41. #include <connectivity/sqlerror.hxx>
  42. #include <boost/shared_ptr.hpp>
  43. namespace dbaccess
  44. {
  45. class ODatabaseModelImpl;
  46. struct ContentProperties
  47. {
  48. ::rtl::OUString aTitle; // Title
  49. ::boost::optional< ::rtl::OUString >
  50. aContentType; // ContentType (aka MediaType aka MimeType)
  51. sal_Bool bIsDocument; // IsDocument
  52. sal_Bool bIsFolder; // IsFolder
  53. sal_Bool bAsTemplate; // AsTemplate
  54. ::rtl::OUString sPersistentName;// persistent name of the document
  55. ContentProperties()
  56. :bIsDocument( sal_True )
  57. ,bIsFolder( sal_False )
  58. ,bAsTemplate( sal_False )
  59. {
  60. }
  61. };
  62. class OContentHelper_Impl
  63. {
  64. public:
  65. OContentHelper_Impl();
  66. virtual ~OContentHelper_Impl();
  67. ContentProperties m_aProps;
  68. ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists
  69. };
  70. typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr;
  71. typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString,
  72. ::rtl::OUStringHash,
  73. ::comphelper::UStringEqual
  74. > PropertyChangeListenerContainer;
  75. typedef ::comphelper::OBaseMutex OContentHelper_MBASE;
  76. typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent
  77. , ::com::sun::star::ucb::XCommandProcessor
  78. , ::com::sun::star::lang::XServiceInfo
  79. , ::com::sun::star::beans::XPropertiesChangeNotifier
  80. , ::com::sun::star::beans::XPropertyContainer
  81. , ::com::sun::star::lang::XInitialization
  82. , ::com::sun::star::lang::XUnoTunnel
  83. , ::com::sun::star::container::XChild
  84. , ::com::sun::star::sdbcx::XRename
  85. > OContentHelper_COMPBASE;
  86. class OContentHelper : public OContentHelper_MBASE
  87. ,public OContentHelper_COMPBASE
  88. {
  89. ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
  90. setPropertyValues( const ::com::sun::star::uno::Sequence<
  91. ::com::sun::star::beans::PropertyValue >& rValues,
  92. const ::com::sun::star::uno::Reference<
  93. ::com::sun::star::ucb::XCommandEnvironment >& xEnv );
  94. com::sun::star::uno::Sequence< com::sun::star::beans::Property >
  95. getProperties( const com::sun::star::uno::Reference<
  96. com::sun::star::ucb::XCommandEnvironment > & xEnv );
  97. void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true);
  98. protected:
  99. ::cppu::OInterfaceContainerHelper m_aContentListeners;
  100. PropertyChangeListenerContainer m_aPropertyChangeListeners;
  101. ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
  102. m_xParentContainer;
  103. const ::comphelper::ComponentContext m_aContext;
  104. const ::connectivity::SQLError m_aErrorHelper;
  105. TContentPtr m_pImpl;
  106. sal_uInt32 m_nCommandId;
  107. // helper
  108. virtual void SAL_CALL disposing();
  109. virtual void notifyDataSourceModified();
  110. /**
  111. * This method can be used to propagate changes of property values.
  112. *
  113. * @param evt is a sequence of property change events.
  114. */
  115. void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const;
  116. ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
  117. public:
  118. OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
  119. ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
  120. ,const TContentPtr& _pImpl
  121. );
  122. // com::sun::star::lang::XTypeProvider
  123. virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
  124. static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
  125. // ::com::sun::star::lang::XServiceInfo
  126. virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
  127. virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
  128. virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
  129. // XContent
  130. virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
  131. virtual ::rtl::OUString SAL_CALL getContentType( ) throw (::com::sun::star::uno::RuntimeException) ;
  132. virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
  133. virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ;
  134. // XCommandProcessor
  135. virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ;
  136. 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) ;
  137. virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ;
  138. // XPropertiesChangeNotifier
  139. 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) ;
  140. 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) ;
  141. // XPropertyContainer
  142. 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) ;
  143. 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) ;
  144. // XInitialization
  145. 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);
  146. // com::sun::star::lang::XUnoTunnel
  147. virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
  148. static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
  149. // ::com::sun::star::container::XChild
  150. virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
  151. 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);
  152. // XRename
  153. 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);
  154. inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
  155. ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
  156. getPropertyValues( const ::com::sun::star::uno::Sequence<
  157. ::com::sun::star::beans::Property >& rProperties );
  158. const ::comphelper::ComponentContext& getContext() const { return m_aContext; }
  159. inline TContentPtr getImpl() const { return m_pImpl; }
  160. protected:
  161. virtual ::rtl::OUString determineContentType() const = 0;
  162. };
  163. } // namespace dbaccess
  164. #endif // DBA_CONTENTHELPER_HXX
  165. /* vim:set shiftwidth=4 softtabstop=4 expandtab: */