1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _BC_HXX_ 29 #define _BC_HXX_ 30 31 #include "osl/mutex.hxx" 32 #include "rtl/ustring.hxx" 33 #include <cppuhelper/weak.hxx> 34 #include <ucbhelper/macros.hxx> 35 #include <cppuhelper/interfacecontainer.h> 36 #include <com/sun/star/uno/XInterface.hpp> 37 #include <com/sun/star/lang/XTypeProvider.hpp> 38 #include <com/sun/star/lang/XComponent.hpp> 39 #include <com/sun/star/ucb/XCommandProcessor.hpp> 40 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> 41 #include <com/sun/star/ucb/XContent.hpp> 42 #include <com/sun/star/ucb/XContentProvider.hpp> 43 #ifndef _COM_SUN_STAR_UCB_XRESULTSET_HPP_ 44 #include <com/sun/star/ucb/XDynamicResultSet.hpp> 45 #endif 46 #include <com/sun/star/lang/XServiceInfo.hpp> 47 #include <com/sun/star/sdbc/XRow.hpp> 48 #include <com/sun/star/beans/PropertyChangeEvent.hpp> 49 #include <com/sun/star/beans/Property.hpp> 50 #include <com/sun/star/beans/PropertyValue.hpp> 51 #include <com/sun/star/ucb/XCommandInfo.hpp> 52 #include <com/sun/star/ucb/InsertCommandArgument.hpp> 53 #include <com/sun/star/beans/XPropertySetInfo.hpp> 54 #include <com/sun/star/beans/XPropertyContainer.hpp> 55 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> 56 #include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp> 57 #include <com/sun/star/container/XChild.hpp> 58 #include <com/sun/star/ucb/XContentCreator.hpp> 59 #include <com/sun/star/io/XInputStream.hpp> 60 #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 61 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> 62 #ifndef _COM_SUN_STAR_UCB_SHELL_HXX_ 63 #include "shell.hxx" 64 #endif 65 66 67 namespace fileaccess { 68 69 class PropertyListeners; 70 class shell; 71 class FileProvider; 72 73 class BaseContent: 74 public cppu::OWeakObject, 75 public com::sun::star::lang::XComponent, 76 public com::sun::star::lang::XServiceInfo, 77 public com::sun::star::lang::XTypeProvider, 78 public com::sun::star::ucb::XCommandProcessor, 79 public com::sun::star::beans::XPropertiesChangeNotifier, 80 public com::sun::star::beans::XPropertyContainer, 81 public com::sun::star::beans::XPropertySetInfoChangeNotifier, 82 public com::sun::star::ucb::XContentCreator, 83 public com::sun::star::container::XChild, 84 public com::sun::star::ucb::XContent, 85 public fileaccess::Notifier // implementation class 86 { 87 private: 88 89 // A special creator for inserted contents; Creates an ugly object 90 BaseContent( shell* pMyShell, 91 const rtl::OUString& parentName, 92 sal_Bool bFolder ); 93 94 public: 95 BaseContent( 96 shell* pMyShell, 97 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xContentIdentifier, 98 const rtl::OUString& aUnqPath ); 99 100 virtual ~BaseContent(); 101 102 // XInterface 103 virtual com::sun::star::uno::Any SAL_CALL 104 queryInterface( 105 const com::sun::star::uno::Type& aType ) 106 throw( com::sun::star::uno::RuntimeException); 107 108 virtual void SAL_CALL 109 acquire( 110 void ) 111 throw(); 112 113 virtual void SAL_CALL 114 release( 115 void ) 116 throw(); 117 118 119 // XComponent 120 virtual void SAL_CALL 121 dispose( 122 void ) 123 throw( com::sun::star::uno::RuntimeException ); 124 125 virtual void SAL_CALL 126 addEventListener( 127 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener ) 128 throw( com::sun::star::uno::RuntimeException ); 129 130 virtual void SAL_CALL 131 removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener ) 132 throw( com::sun::star::uno::RuntimeException ); 133 134 135 // XTypeProvider 136 137 XTYPEPROVIDER_DECL() 138 139 140 // XServiceInfo 141 virtual rtl::OUString SAL_CALL 142 getImplementationName() 143 throw( com::sun::star::uno::RuntimeException); 144 145 virtual sal_Bool SAL_CALL 146 supportsService( const rtl::OUString& ServiceName ) 147 throw( com::sun::star::uno::RuntimeException); 148 149 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 150 getSupportedServiceNames() 151 throw( com::sun::star::uno::RuntimeException ); 152 153 154 // XCommandProcessor 155 virtual sal_Int32 SAL_CALL 156 createCommandIdentifier( 157 void ) 158 throw( com::sun::star::uno::RuntimeException ); 159 160 virtual com::sun::star::uno::Any SAL_CALL 161 execute( 162 const com::sun::star::ucb::Command& aCommand, 163 sal_Int32 CommandId, 164 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment ) 165 throw( com::sun::star::uno::Exception, 166 com::sun::star::ucb::CommandAbortedException, 167 com::sun::star::uno::RuntimeException ); 168 169 virtual void SAL_CALL 170 abort( 171 sal_Int32 CommandId ) 172 throw( com::sun::star::uno::RuntimeException ); 173 174 175 // XContent 176 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL 177 getIdentifier( 178 void ) 179 throw( com::sun::star::uno::RuntimeException ); 180 181 virtual rtl::OUString SAL_CALL 182 getContentType( 183 void ) 184 throw( com::sun::star::uno::RuntimeException ); 185 186 virtual void SAL_CALL 187 addContentEventListener( 188 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener ) 189 throw( com::sun::star::uno::RuntimeException ); 190 191 virtual void SAL_CALL 192 removeContentEventListener( 193 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener ) 194 throw( com::sun::star::uno::RuntimeException ); 195 196 // XPropertiesChangeNotifier 197 198 virtual void SAL_CALL 199 addPropertiesChangeListener( 200 const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames, 201 const com::sun::star::uno::Reference< 202 com::sun::star::beans::XPropertiesChangeListener >& Listener ) 203 throw( com::sun::star::uno::RuntimeException ); 204 205 virtual void SAL_CALL 206 removePropertiesChangeListener( const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames, 207 const com::sun::star::uno::Reference< 208 com::sun::star::beans::XPropertiesChangeListener >& Listener ) 209 throw( com::sun::star::uno::RuntimeException ); 210 211 // XPropertyContainer 212 213 virtual void SAL_CALL 214 addProperty( 215 const rtl::OUString& Name, 216 sal_Int16 Attributes, 217 const com::sun::star::uno::Any& DefaultValue ) 218 throw( com::sun::star::beans::PropertyExistException, 219 com::sun::star::beans::IllegalTypeException, 220 com::sun::star::lang::IllegalArgumentException, 221 com::sun::star::uno::RuntimeException); 222 223 virtual void SAL_CALL 224 removeProperty( 225 const rtl::OUString& Name ) 226 throw( com::sun::star::beans::UnknownPropertyException, 227 com::sun::star::beans::NotRemoveableException, 228 com::sun::star::uno::RuntimeException ); 229 230 // XPropertySetInfoChangeNotifier 231 232 virtual void SAL_CALL 233 addPropertySetInfoChangeListener( 234 const com::sun::star::uno::Reference< 235 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) 236 throw( com::sun::star::uno::RuntimeException ); 237 238 virtual void SAL_CALL 239 removePropertySetInfoChangeListener( 240 const com::sun::star::uno::Reference< 241 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) 242 throw( com::sun::star::uno::RuntimeException ); 243 244 245 // XContentCreator 246 247 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL 248 queryCreatableContentsInfo( 249 void ) 250 throw( com::sun::star::uno::RuntimeException ); 251 252 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL 253 createNewContent( 254 const com::sun::star::ucb::ContentInfo& Info ) 255 throw( com::sun::star::uno::RuntimeException ); 256 257 258 // XChild 259 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL 260 getParent( 261 void ) throw( com::sun::star::uno::RuntimeException ); 262 263 // Not supported 264 virtual void SAL_CALL 265 setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent ) 266 throw( com::sun::star::lang::NoSupportException, 267 com::sun::star::uno::RuntimeException); 268 269 270 // Notifier 271 272 ContentEventNotifier* cDEL( void ); 273 ContentEventNotifier* cEXC( const rtl::OUString aNewName ); 274 ContentEventNotifier* cCEL( void ); 275 PropertySetInfoChangeNotifier* cPSL( void ); 276 PropertyChangeNotifier* cPCL( void ); 277 rtl::OUString getKey( void ); 278 279 private: 280 // Data members 281 shell* m_pMyShell; 282 com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > m_xContentIdentifier; 283 rtl::OUString m_aUncPath; 284 285 enum state { NameForInsertionSet = 1, 286 JustInserted = 2, 287 Deleted = 4, 288 FullFeatured = 8, 289 Connected = 16 }; 290 sal_Bool m_bFolder; 291 sal_uInt16 m_nState; 292 293 osl::Mutex m_aMutex; 294 295 osl::Mutex m_aEventListenerMutex; 296 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; 297 cppu::OInterfaceContainerHelper* m_pContentEventListeners; 298 cppu::OInterfaceContainerHelper* m_pPropertySetInfoChangeListeners; 299 PropertyListeners* m_pPropertyListener; 300 301 302 // Private Methods 303 com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > SAL_CALL 304 getCommandInfo() 305 throw( com::sun::star::uno::RuntimeException ); 306 307 virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL 308 getPropertySetInfo( 309 sal_Int32 nMyCommandIdentifier ) 310 throw( com::sun::star::uno::RuntimeException ); 311 312 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > SAL_CALL 313 getPropertyValues( 314 sal_Int32 nMyCommandIdentifier, 315 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& PropertySet ) 316 throw( com::sun::star::uno::RuntimeException ); 317 318 com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL 319 setPropertyValues( 320 sal_Int32 nMyCommandIdentifier, 321 const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Values ) 322 throw( ); 323 324 com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet > SAL_CALL 325 open( 326 sal_Int32 nMyCommandIdentifier, 327 const com::sun::star::ucb::OpenCommandArgument2& aCommandArgument ) 328 throw(); 329 330 void SAL_CALL 331 deleteContent( sal_Int32 nMyCommandIdentifier ) 332 throw(); 333 334 335 void SAL_CALL 336 transfer( sal_Int32 nMyCommandIdentifier, 337 const com::sun::star::ucb::TransferInfo& aTransferInfo ) 338 throw(); 339 340 void SAL_CALL 341 insert( sal_Int32 nMyCommandIdentifier, 342 const com::sun::star::ucb::InsertCommandArgument& aInsertArgument ) 343 throw(); 344 345 void SAL_CALL endTask( sal_Int32 CommandId ); 346 347 friend class ContentEventNotifier; 348 }; 349 350 } // end namespace fileaccess 351 352 #endif 353 354