1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _BC_HXX_ 25 #define _BC_HXX_ 26 27 #include "osl/mutex.hxx" 28 #include "rtl/ustring.hxx" 29 #include <cppuhelper/weak.hxx> 30 #include <ucbhelper/macros.hxx> 31 #include <cppuhelper/interfacecontainer.h> 32 #include <com/sun/star/uno/XInterface.hpp> 33 #include <com/sun/star/lang/XTypeProvider.hpp> 34 #include <com/sun/star/lang/XComponent.hpp> 35 #include <com/sun/star/ucb/XCommandProcessor.hpp> 36 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> 37 #include <com/sun/star/ucb/XContent.hpp> 38 #include <com/sun/star/ucb/XContentProvider.hpp> 39 #ifndef _COM_SUN_STAR_UCB_XRESULTSET_HPP_ 40 #include <com/sun/star/ucb/XDynamicResultSet.hpp> 41 #endif 42 #include <com/sun/star/lang/XServiceInfo.hpp> 43 #include <com/sun/star/sdbc/XRow.hpp> 44 #include <com/sun/star/beans/PropertyChangeEvent.hpp> 45 #include <com/sun/star/beans/Property.hpp> 46 #include <com/sun/star/beans/PropertyValue.hpp> 47 #include <com/sun/star/ucb/XCommandInfo.hpp> 48 #include <com/sun/star/ucb/InsertCommandArgument.hpp> 49 #include <com/sun/star/beans/XPropertySetInfo.hpp> 50 #include <com/sun/star/beans/XPropertyContainer.hpp> 51 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> 52 #include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp> 53 #include <com/sun/star/container/XChild.hpp> 54 #include <com/sun/star/ucb/XContentCreator.hpp> 55 #include <com/sun/star/io/XInputStream.hpp> 56 #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 57 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> 58 #ifndef _COM_SUN_STAR_UCB_SHELL_HXX_ 59 #include "shell.hxx" 60 #endif 61 62 63 namespace fileaccess { 64 65 class PropertyListeners; 66 class shell; 67 class FileProvider; 68 69 class BaseContent: 70 public cppu::OWeakObject, 71 public com::sun::star::lang::XComponent, 72 public com::sun::star::lang::XServiceInfo, 73 public com::sun::star::lang::XTypeProvider, 74 public com::sun::star::ucb::XCommandProcessor, 75 public com::sun::star::beans::XPropertiesChangeNotifier, 76 public com::sun::star::beans::XPropertyContainer, 77 public com::sun::star::beans::XPropertySetInfoChangeNotifier, 78 public com::sun::star::ucb::XContentCreator, 79 public com::sun::star::container::XChild, 80 public com::sun::star::ucb::XContent, 81 public fileaccess::Notifier // implementation class 82 { 83 private: 84 85 // A special creator for inserted contents; Creates an ugly object 86 BaseContent( shell* pMyShell, 87 const rtl::OUString& parentName, 88 sal_Bool bFolder ); 89 90 public: 91 BaseContent( 92 shell* pMyShell, 93 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xContentIdentifier, 94 const rtl::OUString& aUnqPath ); 95 96 virtual ~BaseContent(); 97 98 // XInterface 99 virtual com::sun::star::uno::Any SAL_CALL 100 queryInterface( 101 const com::sun::star::uno::Type& aType ); 102 103 virtual void SAL_CALL 104 acquire( 105 void ) 106 throw(); 107 108 virtual void SAL_CALL 109 release( 110 void ) 111 throw(); 112 113 114 // XComponent 115 virtual void SAL_CALL 116 dispose( 117 void ); 118 119 virtual void SAL_CALL 120 addEventListener( 121 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener ); 122 123 virtual void SAL_CALL 124 removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener ); 125 126 127 // XTypeProvider 128 129 XTYPEPROVIDER_DECL() 130 131 132 // XServiceInfo 133 virtual rtl::OUString SAL_CALL 134 getImplementationName(); 135 136 virtual sal_Bool SAL_CALL 137 supportsService( const rtl::OUString& ServiceName ); 138 139 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 140 getSupportedServiceNames(); 141 142 143 // XCommandProcessor 144 virtual sal_Int32 SAL_CALL 145 createCommandIdentifier( 146 void ); 147 148 virtual com::sun::star::uno::Any SAL_CALL 149 execute( 150 const com::sun::star::ucb::Command& aCommand, 151 sal_Int32 CommandId, 152 const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment ); 153 154 virtual void SAL_CALL 155 abort( 156 sal_Int32 CommandId ); 157 158 159 // XContent 160 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL 161 getIdentifier( 162 void ); 163 164 virtual rtl::OUString SAL_CALL 165 getContentType( 166 void ); 167 168 virtual void SAL_CALL 169 addContentEventListener( 170 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener ); 171 172 virtual void SAL_CALL 173 removeContentEventListener( 174 const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener ); 175 176 // XPropertiesChangeNotifier 177 178 virtual void SAL_CALL 179 addPropertiesChangeListener( 180 const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames, 181 const com::sun::star::uno::Reference< 182 com::sun::star::beans::XPropertiesChangeListener >& Listener ); 183 184 virtual void SAL_CALL 185 removePropertiesChangeListener( const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames, 186 const com::sun::star::uno::Reference< 187 com::sun::star::beans::XPropertiesChangeListener >& Listener ); 188 189 // XPropertyContainer 190 191 virtual void SAL_CALL 192 addProperty( 193 const rtl::OUString& Name, 194 sal_Int16 Attributes, 195 const com::sun::star::uno::Any& DefaultValue ); 196 197 virtual void SAL_CALL 198 removeProperty( 199 const rtl::OUString& Name ); 200 201 // XPropertySetInfoChangeNotifier 202 203 virtual void SAL_CALL 204 addPropertySetInfoChangeListener( 205 const com::sun::star::uno::Reference< 206 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ); 207 208 virtual void SAL_CALL 209 removePropertySetInfoChangeListener( 210 const com::sun::star::uno::Reference< 211 com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ); 212 213 214 // XContentCreator 215 216 virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL 217 queryCreatableContentsInfo( 218 void ); 219 220 virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL 221 createNewContent( 222 const com::sun::star::ucb::ContentInfo& Info ); 223 224 225 // XChild 226 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL 227 getParent( 228 void ); 229 230 // Not supported 231 virtual void SAL_CALL 232 setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent ); 233 234 235 // Notifier 236 237 ContentEventNotifier* cDEL( void ); 238 ContentEventNotifier* cEXC( const rtl::OUString aNewName ); 239 ContentEventNotifier* cCEL( void ); 240 PropertySetInfoChangeNotifier* cPSL( void ); 241 PropertyChangeNotifier* cPCL( void ); 242 rtl::OUString getKey( void ); 243 244 private: 245 // Data members 246 shell* m_pMyShell; 247 com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > m_xContentIdentifier; 248 rtl::OUString m_aUncPath; 249 250 enum state { NameForInsertionSet = 1, 251 JustInserted = 2, 252 Deleted = 4, 253 FullFeatured = 8, 254 Connected = 16 }; 255 sal_Bool m_bFolder; 256 sal_uInt16 m_nState; 257 258 osl::Mutex m_aMutex; 259 260 osl::Mutex m_aEventListenerMutex; 261 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; 262 cppu::OInterfaceContainerHelper* m_pContentEventListeners; 263 cppu::OInterfaceContainerHelper* m_pPropertySetInfoChangeListeners; 264 PropertyListeners* m_pPropertyListener; 265 266 267 // Private Methods 268 com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > SAL_CALL 269 getCommandInfo(); 270 271 virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL 272 getPropertySetInfo( 273 sal_Int32 nMyCommandIdentifier ); 274 275 virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > SAL_CALL 276 getPropertyValues( 277 sal_Int32 nMyCommandIdentifier, 278 const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& PropertySet ); 279 280 com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL 281 setPropertyValues( 282 sal_Int32 nMyCommandIdentifier, 283 const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Values ) 284 throw( ); 285 286 com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet > SAL_CALL 287 open( 288 sal_Int32 nMyCommandIdentifier, 289 const com::sun::star::ucb::OpenCommandArgument2& aCommandArgument ) 290 throw(); 291 292 void SAL_CALL 293 deleteContent( sal_Int32 nMyCommandIdentifier ) 294 throw(); 295 296 297 void SAL_CALL 298 transfer( sal_Int32 nMyCommandIdentifier, 299 const com::sun::star::ucb::TransferInfo& aTransferInfo ) 300 throw(); 301 302 void SAL_CALL 303 insert( sal_Int32 nMyCommandIdentifier, 304 const com::sun::star::ucb::InsertCommandArgument& aInsertArgument ) 305 throw(); 306 307 void SAL_CALL endTask( sal_Int32 CommandId ); 308 309 friend class ContentEventNotifier; 310 }; 311 312 } // end namespace fileaccess 313 314 #endif 315