1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBA_CONTENTHELPER_HXX 24cdf0e10cSrcweir #define DBA_CONTENTHELPER_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_ 27cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp> 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_ 30cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_ 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_ 36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ 42cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ 45cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 48cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 51cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ 54cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp> 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_ 57cdf0e10cSrcweir #include <com/sun/star/embed/XEmbeddedObject.hpp> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ 60cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPBASE9_HXX_ 63cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx> 64cdf0e10cSrcweir #endif 65cdf0e10cSrcweir #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 66cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 67cdf0e10cSrcweir #endif 68cdf0e10cSrcweir #ifndef COMPHELPER_COMPONENTCONTEXT_HXX 69cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 70cdf0e10cSrcweir #endif 71cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_ 72cdf0e10cSrcweir #include <comphelper/uno3.hxx> 73cdf0e10cSrcweir #endif 74cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_ 75cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 76cdf0e10cSrcweir #endif 77cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ 78cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 79cdf0e10cSrcweir #endif 80cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ 81cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 82cdf0e10cSrcweir #endif 83cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ 84cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRename.hpp> 85cdf0e10cSrcweir #endif 86cdf0e10cSrcweir #ifndef CONNECTIVITY_SQLERROR_HXX 87cdf0e10cSrcweir #include <connectivity/sqlerror.hxx> 88cdf0e10cSrcweir #endif 89cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 90cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 91cdf0e10cSrcweir #endif 92cdf0e10cSrcweir 93cdf0e10cSrcweir namespace dbaccess 94cdf0e10cSrcweir { 95cdf0e10cSrcweir class ODatabaseModelImpl; 96cdf0e10cSrcweir struct ContentProperties 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ::rtl::OUString aTitle; // Title 99cdf0e10cSrcweir ::boost::optional< ::rtl::OUString > 100cdf0e10cSrcweir aContentType; // ContentType (aka MediaType aka MimeType) 101cdf0e10cSrcweir sal_Bool bIsDocument; // IsDocument 102cdf0e10cSrcweir sal_Bool bIsFolder; // IsFolder 103cdf0e10cSrcweir sal_Bool bAsTemplate; // AsTemplate 104cdf0e10cSrcweir ::rtl::OUString sPersistentName;// persistent name of the document 105cdf0e10cSrcweir ContentPropertiesdbaccess::ContentProperties106cdf0e10cSrcweir ContentProperties() 107cdf0e10cSrcweir :bIsDocument( sal_True ) 108cdf0e10cSrcweir ,bIsFolder( sal_False ) 109cdf0e10cSrcweir ,bAsTemplate( sal_False ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir } 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir class OContentHelper_Impl 115cdf0e10cSrcweir { 116cdf0e10cSrcweir public: 117cdf0e10cSrcweir OContentHelper_Impl(); 118cdf0e10cSrcweir virtual ~OContentHelper_Impl(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir ContentProperties m_aProps; 121cdf0e10cSrcweir ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir typedef ::boost::shared_ptr<OContentHelper_Impl> TContentPtr; 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString, 128cdf0e10cSrcweir ::comphelper::UStringHash, 129cdf0e10cSrcweir ::comphelper::UStringEqual 130cdf0e10cSrcweir > PropertyChangeListenerContainer; 131cdf0e10cSrcweir typedef ::comphelper::OBaseMutex OContentHelper_MBASE; 132cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent 133cdf0e10cSrcweir , ::com::sun::star::ucb::XCommandProcessor 134cdf0e10cSrcweir , ::com::sun::star::lang::XServiceInfo 135cdf0e10cSrcweir , ::com::sun::star::beans::XPropertiesChangeNotifier 136cdf0e10cSrcweir , ::com::sun::star::beans::XPropertyContainer 137cdf0e10cSrcweir , ::com::sun::star::lang::XInitialization 138cdf0e10cSrcweir , ::com::sun::star::lang::XUnoTunnel 139cdf0e10cSrcweir , ::com::sun::star::container::XChild 140cdf0e10cSrcweir , ::com::sun::star::sdbcx::XRename 141cdf0e10cSrcweir > OContentHelper_COMPBASE; 142cdf0e10cSrcweir 143cdf0e10cSrcweir class OContentHelper : public OContentHelper_MBASE 144cdf0e10cSrcweir ,public OContentHelper_COMPBASE 145cdf0e10cSrcweir { 146cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 147cdf0e10cSrcweir setPropertyValues( const ::com::sun::star::uno::Sequence< 148cdf0e10cSrcweir ::com::sun::star::beans::PropertyValue >& rValues, 149cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 150cdf0e10cSrcweir ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); 151cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::beans::Property > 152cdf0e10cSrcweir getProperties( const com::sun::star::uno::Reference< 153cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true); 156cdf0e10cSrcweir 157cdf0e10cSrcweir protected: 158cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper m_aContentListeners; 159cdf0e10cSrcweir PropertyChangeListenerContainer m_aPropertyChangeListeners; 160cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 161cdf0e10cSrcweir m_xParentContainer; 162cdf0e10cSrcweir const ::comphelper::ComponentContext m_aContext; 163cdf0e10cSrcweir const ::connectivity::SQLError m_aErrorHelper; 164cdf0e10cSrcweir TContentPtr m_pImpl; 165cdf0e10cSrcweir sal_uInt32 m_nCommandId; 166cdf0e10cSrcweir 167cdf0e10cSrcweir // helper 168cdf0e10cSrcweir virtual void SAL_CALL disposing(); 169cdf0e10cSrcweir 170cdf0e10cSrcweir virtual void notifyDataSourceModified(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir /** 173cdf0e10cSrcweir * This method can be used to propagate changes of property values. 174cdf0e10cSrcweir * 175cdf0e10cSrcweir * @param evt is a sequence of property change events. 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir void notifyPropertiesChange( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const; 178cdf0e10cSrcweir 179cdf0e10cSrcweir ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const; 180cdf0e10cSrcweir 181cdf0e10cSrcweir public: 182cdf0e10cSrcweir 183cdf0e10cSrcweir OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB 184cdf0e10cSrcweir ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer 185cdf0e10cSrcweir ,const TContentPtr& _pImpl 186cdf0e10cSrcweir ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir // com::sun::star::lang::XTypeProvider 189cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 190cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 191cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 192cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 193cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 194cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 195cdf0e10cSrcweir 196cdf0e10cSrcweir // XContent 197cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ; 198cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getContentType( ) throw (::com::sun::star::uno::RuntimeException) ; 199cdf0e10cSrcweir virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; 200cdf0e10cSrcweir virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; 201cdf0e10cSrcweir 202cdf0e10cSrcweir // XCommandProcessor 203cdf0e10cSrcweir virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ; 204cdf0e10cSrcweir 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) ; 205cdf0e10cSrcweir virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ; 206cdf0e10cSrcweir 207cdf0e10cSrcweir // XPropertiesChangeNotifier 208cdf0e10cSrcweir 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) ; 209cdf0e10cSrcweir 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) ; 210cdf0e10cSrcweir 211cdf0e10cSrcweir // XPropertyContainer 212cdf0e10cSrcweir 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) ; 213cdf0e10cSrcweir 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) ; 214cdf0e10cSrcweir 215cdf0e10cSrcweir // XInitialization 216cdf0e10cSrcweir 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); 217cdf0e10cSrcweir 218cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel 219cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 220cdf0e10cSrcweir static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); 221cdf0e10cSrcweir 222cdf0e10cSrcweir // ::com::sun::star::container::XChild 223cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); 224cdf0e10cSrcweir 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); 225cdf0e10cSrcweir 226cdf0e10cSrcweir // XRename 227cdf0e10cSrcweir 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); 228cdf0e10cSrcweir getContentProperties() const229cdf0e10cSrcweir inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; } 230cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > 231cdf0e10cSrcweir getPropertyValues( const ::com::sun::star::uno::Sequence< 232cdf0e10cSrcweir ::com::sun::star::beans::Property >& rProperties ); 233cdf0e10cSrcweir getContext() const234cdf0e10cSrcweir const ::comphelper::ComponentContext& getContext() const { return m_aContext; } 235cdf0e10cSrcweir getImpl() const236cdf0e10cSrcweir inline TContentPtr getImpl() const { return m_pImpl; } 237cdf0e10cSrcweir 238cdf0e10cSrcweir protected: 239cdf0e10cSrcweir virtual ::rtl::OUString determineContentType() const = 0; 240cdf0e10cSrcweir }; 241cdf0e10cSrcweir 242cdf0e10cSrcweir //........................................................................ 243cdf0e10cSrcweir } // namespace dbaccess 244cdf0e10cSrcweir //........................................................................ 245cdf0e10cSrcweir #endif // DBA_CONTENTHELPER_HXX 246