1*2f86921cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2f86921cSAndrew Rist * distributed with this work for additional information 6*2f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2f86921cSAndrew Rist * "License"); you may not use this file except in compliance 9*2f86921cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2f86921cSAndrew Rist * software distributed under the License is distributed on an 15*2f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2f86921cSAndrew Rist * KIND, either express or implied. See the License for the 17*2f86921cSAndrew Rist * specific language governing permissions and limitations 18*2f86921cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2f86921cSAndrew Rist *************************************************************/ 21*2f86921cSAndrew Rist 22*2f86921cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucb.hxx" 26cdf0e10cSrcweir #include <rtl/uri.hxx> 27cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 28cdf0e10cSrcweir #include <osl/file.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include "osl/diagnose.h" 31cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp> 32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_ 33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #include <com/sun/star/ucb/XProgressHandler.hpp> 36cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 37cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataStreamer.hpp> 38cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 39cdf0e10cSrcweir #include <com/sun/star/ucb/NumberedSortingInfo.hpp> 40cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp> 41cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 42cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChange.hpp> 43cdf0e10cSrcweir #include <com/sun/star/ucb/ContentAction.hpp> 44cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp> 45cdf0e10cSrcweir #include "filglob.hxx" 46cdf0e10cSrcweir #include "filid.hxx" 47cdf0e10cSrcweir #include "filrow.hxx" 48cdf0e10cSrcweir #include "bc.hxx" 49cdf0e10cSrcweir #include "prov.hxx" 50cdf0e10cSrcweir #ifndef _FILERROR_HXX_ 51cdf0e10cSrcweir #include "filerror.hxx" 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #include "filinsreq.hxx" 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir using namespace fileaccess; 57cdf0e10cSrcweir using namespace com::sun::star; 58cdf0e10cSrcweir using namespace com::sun::star::uno; 59cdf0e10cSrcweir using namespace com::sun::star::ucb; 60cdf0e10cSrcweir 61cdf0e10cSrcweir // PropertyListeners 62cdf0e10cSrcweir 63cdf0e10cSrcweir 64cdf0e10cSrcweir typedef cppu::OMultiTypeInterfaceContainerHelperVar< rtl::OUString,hashOUString,equalOUString > 65cdf0e10cSrcweir PropertyListeners_impl; 66cdf0e10cSrcweir 67cdf0e10cSrcweir class fileaccess::PropertyListeners 68cdf0e10cSrcweir : public PropertyListeners_impl 69cdf0e10cSrcweir { 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir PropertyListeners( ::osl::Mutex& aMutex ) 72cdf0e10cSrcweir : PropertyListeners_impl( aMutex ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir } 75cdf0e10cSrcweir }; 76cdf0e10cSrcweir 77cdf0e10cSrcweir 78cdf0e10cSrcweir /****************************************************************************************/ 79cdf0e10cSrcweir /* */ 80cdf0e10cSrcweir /* BaseContent */ 81cdf0e10cSrcweir /* */ 82cdf0e10cSrcweir /****************************************************************************************/ 83cdf0e10cSrcweir 84cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 85cdf0e10cSrcweir // Private Constructor for just inserted Contents 86cdf0e10cSrcweir 87cdf0e10cSrcweir BaseContent::BaseContent( shell* pMyShell, 88cdf0e10cSrcweir const rtl::OUString& parentName, 89cdf0e10cSrcweir sal_Bool bFolder ) 90cdf0e10cSrcweir : m_pMyShell( pMyShell ), 91cdf0e10cSrcweir m_xContentIdentifier( 0 ), 92cdf0e10cSrcweir m_aUncPath( parentName ), 93cdf0e10cSrcweir m_bFolder( bFolder ), 94cdf0e10cSrcweir m_nState( JustInserted ), 95cdf0e10cSrcweir m_pDisposeEventListeners( 0 ), 96cdf0e10cSrcweir m_pContentEventListeners( 0 ), 97cdf0e10cSrcweir m_pPropertySetInfoChangeListeners( 0 ), 98cdf0e10cSrcweir m_pPropertyListener( 0 ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir m_pMyShell->m_pProvider->acquire(); 101cdf0e10cSrcweir // No registering, since we have no name 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 106cdf0e10cSrcweir // Constructor for full featured Contents 107cdf0e10cSrcweir 108cdf0e10cSrcweir BaseContent::BaseContent( shell* pMyShell, 109cdf0e10cSrcweir const Reference< XContentIdentifier >& xContentIdentifier, 110cdf0e10cSrcweir const rtl::OUString& aUncPath ) 111cdf0e10cSrcweir : m_pMyShell( pMyShell ), 112cdf0e10cSrcweir m_xContentIdentifier( xContentIdentifier ), 113cdf0e10cSrcweir m_aUncPath( aUncPath ), 114cdf0e10cSrcweir m_bFolder( false ), 115cdf0e10cSrcweir m_nState( FullFeatured ), 116cdf0e10cSrcweir m_pDisposeEventListeners( 0 ), 117cdf0e10cSrcweir m_pContentEventListeners( 0 ), 118cdf0e10cSrcweir m_pPropertySetInfoChangeListeners( 0 ), 119cdf0e10cSrcweir m_pPropertyListener( 0 ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir m_pMyShell->m_pProvider->acquire(); 122cdf0e10cSrcweir m_pMyShell->registerNotifier( m_aUncPath,this ); 123cdf0e10cSrcweir m_pMyShell->insertDefaultProperties( m_aUncPath ); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir BaseContent::~BaseContent( ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir if( ( m_nState & FullFeatured ) || ( m_nState & Deleted ) ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir m_pMyShell->deregisterNotifier( m_aUncPath,this ); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir m_pMyShell->m_pProvider->release(); 134cdf0e10cSrcweir 135cdf0e10cSrcweir delete m_pDisposeEventListeners; 136cdf0e10cSrcweir delete m_pContentEventListeners; 137cdf0e10cSrcweir delete m_pPropertyListener; 138cdf0e10cSrcweir delete m_pPropertySetInfoChangeListeners; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir 142cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 143cdf0e10cSrcweir // XInterface 144cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////// 145cdf0e10cSrcweir 146cdf0e10cSrcweir void SAL_CALL 147cdf0e10cSrcweir BaseContent::acquire( void ) 148cdf0e10cSrcweir throw() 149cdf0e10cSrcweir { 150cdf0e10cSrcweir OWeakObject::acquire(); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir 154cdf0e10cSrcweir void SAL_CALL 155cdf0e10cSrcweir BaseContent::release( void ) 156cdf0e10cSrcweir throw() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir OWeakObject::release(); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir Any SAL_CALL 163cdf0e10cSrcweir BaseContent::queryInterface( const Type& rType ) 164cdf0e10cSrcweir throw( RuntimeException ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir Any aRet = cppu::queryInterface( rType, 167cdf0e10cSrcweir SAL_STATIC_CAST( lang::XComponent*, this ), 168cdf0e10cSrcweir SAL_STATIC_CAST( lang::XTypeProvider*, this ), 169cdf0e10cSrcweir SAL_STATIC_CAST( lang::XServiceInfo*, this ), 170cdf0e10cSrcweir SAL_STATIC_CAST( XCommandProcessor*, this ), 171cdf0e10cSrcweir SAL_STATIC_CAST( container::XChild*, this ), 172cdf0e10cSrcweir SAL_STATIC_CAST( beans::XPropertiesChangeNotifier*, this ), 173cdf0e10cSrcweir SAL_STATIC_CAST( beans::XPropertyContainer*, this ), 174cdf0e10cSrcweir SAL_STATIC_CAST( XContentCreator*,this ), 175cdf0e10cSrcweir SAL_STATIC_CAST( beans::XPropertySetInfoChangeNotifier*, this ), 176cdf0e10cSrcweir SAL_STATIC_CAST( XContent*,this) ); 177cdf0e10cSrcweir return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir 181cdf0e10cSrcweir 182cdf0e10cSrcweir 183cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 184cdf0e10cSrcweir // XComponent 185cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////// 186cdf0e10cSrcweir 187cdf0e10cSrcweir void SAL_CALL 188cdf0e10cSrcweir BaseContent::addEventListener( const Reference< lang::XEventListener >& Listener ) 189cdf0e10cSrcweir throw( RuntimeException ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir if ( ! m_pDisposeEventListeners ) 194cdf0e10cSrcweir m_pDisposeEventListeners = 195cdf0e10cSrcweir new cppu::OInterfaceContainerHelper( m_aEventListenerMutex ); 196cdf0e10cSrcweir 197cdf0e10cSrcweir m_pDisposeEventListeners->addInterface( Listener ); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir 201cdf0e10cSrcweir void SAL_CALL 202cdf0e10cSrcweir BaseContent::removeEventListener( const Reference< lang::XEventListener >& Listener ) 203cdf0e10cSrcweir throw( RuntimeException ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( m_pDisposeEventListeners ) 208cdf0e10cSrcweir m_pDisposeEventListeners->removeInterface( Listener ); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir 212cdf0e10cSrcweir void SAL_CALL 213cdf0e10cSrcweir BaseContent::dispose() 214cdf0e10cSrcweir throw( RuntimeException ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir lang::EventObject aEvt; 217cdf0e10cSrcweir cppu::OInterfaceContainerHelper* pDisposeEventListeners; 218cdf0e10cSrcweir cppu::OInterfaceContainerHelper* pContentEventListeners; 219cdf0e10cSrcweir cppu::OInterfaceContainerHelper* pPropertySetInfoChangeListeners; 220cdf0e10cSrcweir PropertyListeners* pPropertyListener; 221cdf0e10cSrcweir 222cdf0e10cSrcweir { 223cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 224cdf0e10cSrcweir aEvt.Source = static_cast< XContent* >( this ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir pDisposeEventListeners = 228cdf0e10cSrcweir m_pDisposeEventListeners, m_pDisposeEventListeners = 0; 229cdf0e10cSrcweir 230cdf0e10cSrcweir pContentEventListeners = 231cdf0e10cSrcweir m_pContentEventListeners, m_pContentEventListeners = 0; 232cdf0e10cSrcweir 233cdf0e10cSrcweir pPropertySetInfoChangeListeners = 234cdf0e10cSrcweir m_pPropertySetInfoChangeListeners, 235cdf0e10cSrcweir m_pPropertySetInfoChangeListeners = 0; 236cdf0e10cSrcweir 237cdf0e10cSrcweir pPropertyListener = 238cdf0e10cSrcweir m_pPropertyListener, m_pPropertyListener = 0; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir if ( pDisposeEventListeners && pDisposeEventListeners->getLength() ) 242cdf0e10cSrcweir pDisposeEventListeners->disposeAndClear( aEvt ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir if ( pContentEventListeners && pContentEventListeners->getLength() ) 245cdf0e10cSrcweir pContentEventListeners->disposeAndClear( aEvt ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir if( pPropertyListener ) 248cdf0e10cSrcweir pPropertyListener->disposeAndClear( aEvt ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir if( pPropertySetInfoChangeListeners ) 251cdf0e10cSrcweir pPropertySetInfoChangeListeners->disposeAndClear( aEvt ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir delete pDisposeEventListeners; 254cdf0e10cSrcweir delete pContentEventListeners; 255cdf0e10cSrcweir delete pPropertyListener; 256cdf0e10cSrcweir delete pPropertySetInfoChangeListeners; 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir 260cdf0e10cSrcweir 261cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 262cdf0e10cSrcweir // XServiceInfo 263cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 264cdf0e10cSrcweir 265cdf0e10cSrcweir rtl::OUString SAL_CALL 266cdf0e10cSrcweir BaseContent::getImplementationName() 267cdf0e10cSrcweir throw( RuntimeException) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir return rtl::OUString::createFromAscii( "com.sun.star.comp.ucb.FileContent" ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir 273cdf0e10cSrcweir 274cdf0e10cSrcweir sal_Bool SAL_CALL 275cdf0e10cSrcweir BaseContent::supportsService( const rtl::OUString& ServiceName ) 276cdf0e10cSrcweir throw( RuntimeException) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir if( ServiceName.compareToAscii( "com.sun.star.ucb.FileContent" ) == 0 ) 279cdf0e10cSrcweir return true; 280cdf0e10cSrcweir else 281cdf0e10cSrcweir return false; 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir 285cdf0e10cSrcweir 286cdf0e10cSrcweir Sequence< rtl::OUString > SAL_CALL 287cdf0e10cSrcweir BaseContent::getSupportedServiceNames() 288cdf0e10cSrcweir throw( RuntimeException ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir Sequence< rtl::OUString > ret( 1 ); 291cdf0e10cSrcweir ret[0] = rtl::OUString::createFromAscii( "com.sun.star.ucb.FileContent" ); 292cdf0e10cSrcweir return ret; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir 296cdf0e10cSrcweir 297cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 298cdf0e10cSrcweir // XTypeProvider 299cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 300cdf0e10cSrcweir 301cdf0e10cSrcweir XTYPEPROVIDER_IMPL_10( BaseContent, 302cdf0e10cSrcweir lang::XComponent, 303cdf0e10cSrcweir lang::XTypeProvider, 304cdf0e10cSrcweir lang::XServiceInfo, 305cdf0e10cSrcweir XCommandProcessor, 306cdf0e10cSrcweir XContentCreator, 307cdf0e10cSrcweir XContent, 308cdf0e10cSrcweir container::XChild, 309cdf0e10cSrcweir beans::XPropertiesChangeNotifier, 310cdf0e10cSrcweir beans::XPropertyContainer, 311cdf0e10cSrcweir beans::XPropertySetInfoChangeNotifier ) 312cdf0e10cSrcweir 313cdf0e10cSrcweir 314cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 315cdf0e10cSrcweir // XCommandProcessor 316cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 317cdf0e10cSrcweir 318cdf0e10cSrcweir sal_Int32 SAL_CALL 319cdf0e10cSrcweir BaseContent::createCommandIdentifier( void ) 320cdf0e10cSrcweir throw( RuntimeException ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir return m_pMyShell->getCommandId(); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir 326cdf0e10cSrcweir void SAL_CALL 327cdf0e10cSrcweir BaseContent::abort( sal_Int32 CommandId ) 328cdf0e10cSrcweir throw( RuntimeException ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir m_pMyShell->abort( CommandId ); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir 334cdf0e10cSrcweir Any SAL_CALL 335cdf0e10cSrcweir BaseContent::execute( const Command& aCommand, 336cdf0e10cSrcweir sal_Int32 CommandId, 337cdf0e10cSrcweir const Reference< XCommandEnvironment >& Environment ) 338cdf0e10cSrcweir throw( Exception, 339cdf0e10cSrcweir CommandAbortedException, 340cdf0e10cSrcweir RuntimeException ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir if( ! CommandId ) 343cdf0e10cSrcweir // A Command with commandid zero cannot be aborted 344cdf0e10cSrcweir CommandId = createCommandIdentifier(); 345cdf0e10cSrcweir 346cdf0e10cSrcweir m_pMyShell->startTask( CommandId, 347cdf0e10cSrcweir Environment ); 348cdf0e10cSrcweir 349cdf0e10cSrcweir Any aAny; 350cdf0e10cSrcweir 351cdf0e10cSrcweir if( ! aCommand.Name.compareToAscii( "getPropertySetInfo" ) ) // No exceptions 352cdf0e10cSrcweir { 353cdf0e10cSrcweir aAny <<= getPropertySetInfo( CommandId ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "getCommandInfo" ) ) // no exceptions 356cdf0e10cSrcweir { 357cdf0e10cSrcweir aAny <<= getCommandInfo(); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "setPropertyValues" ) ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir Sequence< beans::PropertyValue > sPropertyValues; 362cdf0e10cSrcweir 363cdf0e10cSrcweir if( ! ( aCommand.Argument >>= sPropertyValues ) ) 364cdf0e10cSrcweir m_pMyShell->installError( CommandId, 365cdf0e10cSrcweir TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT ); 366cdf0e10cSrcweir else 367cdf0e10cSrcweir aAny <<= setPropertyValues( CommandId,sPropertyValues ); // calls endTask by itself 368cdf0e10cSrcweir } 369cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "getPropertyValues" ) ) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir Sequence< beans::Property > ListOfRequestedProperties; 372cdf0e10cSrcweir 373cdf0e10cSrcweir if( ! ( aCommand.Argument >>= ListOfRequestedProperties ) ) 374cdf0e10cSrcweir m_pMyShell->installError( CommandId, 375cdf0e10cSrcweir TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT ); 376cdf0e10cSrcweir else 377cdf0e10cSrcweir aAny <<= getPropertyValues( CommandId, 378cdf0e10cSrcweir ListOfRequestedProperties ); 379cdf0e10cSrcweir } 380cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "open" ) ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir OpenCommandArgument2 aOpenArgument; 383cdf0e10cSrcweir if( ! ( aCommand.Argument >>= aOpenArgument ) ) 384cdf0e10cSrcweir m_pMyShell->installError( CommandId, 385cdf0e10cSrcweir TASKHANDLING_WRONG_OPEN_ARGUMENT ); 386cdf0e10cSrcweir else 387cdf0e10cSrcweir { 388cdf0e10cSrcweir Reference< XDynamicResultSet > result = open( CommandId,aOpenArgument ); 389cdf0e10cSrcweir if( result.is() ) 390cdf0e10cSrcweir aAny <<= result; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "delete" ) ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir if( ! aCommand.Argument.has< sal_Bool >() ) 396cdf0e10cSrcweir m_pMyShell->installError( CommandId, 397cdf0e10cSrcweir TASKHANDLING_WRONG_DELETE_ARGUMENT ); 398cdf0e10cSrcweir else 399cdf0e10cSrcweir deleteContent( CommandId ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "transfer" ) ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir TransferInfo aTransferInfo; 404cdf0e10cSrcweir if( ! ( aCommand.Argument >>= aTransferInfo ) ) 405cdf0e10cSrcweir m_pMyShell->installError( CommandId, 406cdf0e10cSrcweir TASKHANDLING_WRONG_TRANSFER_ARGUMENT ); 407cdf0e10cSrcweir else 408cdf0e10cSrcweir transfer( CommandId, aTransferInfo ); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "insert" ) ) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir InsertCommandArgument aInsertArgument; 413cdf0e10cSrcweir if( ! ( aCommand.Argument >>= aInsertArgument ) ) 414cdf0e10cSrcweir m_pMyShell->installError( CommandId, 415cdf0e10cSrcweir TASKHANDLING_WRONG_INSERT_ARGUMENT ); 416cdf0e10cSrcweir else 417cdf0e10cSrcweir insert( CommandId,aInsertArgument ); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "getCasePreservingURL" ) ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir Sequence< beans::Property > seq(1); 422cdf0e10cSrcweir seq[0] = beans::Property( 423cdf0e10cSrcweir rtl::OUString::createFromAscii("CasePreservingURL"), 424cdf0e10cSrcweir -1, 425cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >(0) ), 426cdf0e10cSrcweir 0 ); 427cdf0e10cSrcweir Reference< sdbc::XRow > xRow = getPropertyValues( CommandId,seq ); 428cdf0e10cSrcweir rtl::OUString CasePreservingURL = xRow->getString(1); 429cdf0e10cSrcweir if(!xRow->wasNull()) 430cdf0e10cSrcweir aAny <<= CasePreservingURL; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir else if( ! aCommand.Name.compareToAscii( "createNewContent" ) ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir ucb::ContentInfo aArg; 435cdf0e10cSrcweir if ( !( aCommand.Argument >>= aArg ) ) 436cdf0e10cSrcweir m_pMyShell->installError( CommandId, 437cdf0e10cSrcweir TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT ); 438cdf0e10cSrcweir else 439cdf0e10cSrcweir aAny <<= createNewContent( aArg ); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir else 442cdf0e10cSrcweir m_pMyShell->installError( CommandId, 443cdf0e10cSrcweir TASKHANDLER_UNSUPPORTED_COMMAND ); 444cdf0e10cSrcweir 445cdf0e10cSrcweir 446cdf0e10cSrcweir // This is the only function allowed to throw an exception 447cdf0e10cSrcweir endTask( CommandId ); 448cdf0e10cSrcweir 449cdf0e10cSrcweir return aAny; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir 453cdf0e10cSrcweir 454cdf0e10cSrcweir void SAL_CALL 455cdf0e10cSrcweir BaseContent::addPropertiesChangeListener( 456cdf0e10cSrcweir const Sequence< rtl::OUString >& PropertyNames, 457cdf0e10cSrcweir const Reference< beans::XPropertiesChangeListener >& Listener ) 458cdf0e10cSrcweir throw( RuntimeException ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir if( ! Listener.is() ) 461cdf0e10cSrcweir return; 462cdf0e10cSrcweir 463cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 464cdf0e10cSrcweir 465cdf0e10cSrcweir if( ! m_pPropertyListener ) 466cdf0e10cSrcweir m_pPropertyListener = new PropertyListeners( m_aEventListenerMutex ); 467cdf0e10cSrcweir 468cdf0e10cSrcweir 469cdf0e10cSrcweir if( PropertyNames.getLength() == 0 ) 470cdf0e10cSrcweir m_pPropertyListener->addInterface( rtl::OUString(),Listener ); 471cdf0e10cSrcweir else 472cdf0e10cSrcweir { 473cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xProp = m_pMyShell->info_p( m_aUncPath ); 474cdf0e10cSrcweir for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i ) 475cdf0e10cSrcweir if( xProp->hasPropertyByName( PropertyNames[i] ) ) 476cdf0e10cSrcweir m_pPropertyListener->addInterface( PropertyNames[i],Listener ); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir 481cdf0e10cSrcweir void SAL_CALL 482cdf0e10cSrcweir BaseContent::removePropertiesChangeListener( const Sequence< rtl::OUString >& PropertyNames, 483cdf0e10cSrcweir const Reference< beans::XPropertiesChangeListener >& Listener ) 484cdf0e10cSrcweir throw( RuntimeException ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir if( ! Listener.is() ) 487cdf0e10cSrcweir return; 488cdf0e10cSrcweir 489cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 490cdf0e10cSrcweir 491cdf0e10cSrcweir if( ! m_pPropertyListener ) 492cdf0e10cSrcweir return; 493cdf0e10cSrcweir 494cdf0e10cSrcweir for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i ) 495cdf0e10cSrcweir m_pPropertyListener->removeInterface( PropertyNames[i],Listener ); 496cdf0e10cSrcweir 497cdf0e10cSrcweir m_pPropertyListener->removeInterface( rtl::OUString(), Listener ); 498cdf0e10cSrcweir } 499cdf0e10cSrcweir 500cdf0e10cSrcweir 501cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////////////// 502cdf0e10cSrcweir // XContent 503cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////////////// 504cdf0e10cSrcweir 505cdf0e10cSrcweir Reference< ucb::XContentIdentifier > SAL_CALL 506cdf0e10cSrcweir BaseContent::getIdentifier() 507cdf0e10cSrcweir throw( RuntimeException ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir return m_xContentIdentifier; 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir 513cdf0e10cSrcweir rtl::OUString SAL_CALL 514cdf0e10cSrcweir BaseContent::getContentType() 515cdf0e10cSrcweir throw( RuntimeException ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir if( !( m_nState & Deleted ) ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir if( m_nState & JustInserted ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if ( m_bFolder ) 522cdf0e10cSrcweir return m_pMyShell->FolderContentType; 523cdf0e10cSrcweir else 524cdf0e10cSrcweir return m_pMyShell->FileContentType; 525cdf0e10cSrcweir } 526cdf0e10cSrcweir else 527cdf0e10cSrcweir { 528cdf0e10cSrcweir try 529cdf0e10cSrcweir { 530cdf0e10cSrcweir // Who am I ? 531cdf0e10cSrcweir Sequence< beans::Property > seq(1); 532cdf0e10cSrcweir seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), 533cdf0e10cSrcweir -1, 534cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >(0) ), 535cdf0e10cSrcweir 0 ); 536cdf0e10cSrcweir Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq ); 537cdf0e10cSrcweir sal_Bool IsDocument = xRow->getBoolean( 1 ); 538cdf0e10cSrcweir 539cdf0e10cSrcweir if ( !xRow->wasNull() ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir if ( IsDocument ) 542cdf0e10cSrcweir return m_pMyShell->FileContentType; 543cdf0e10cSrcweir else 544cdf0e10cSrcweir return m_pMyShell->FolderContentType; 545cdf0e10cSrcweir } 546cdf0e10cSrcweir else 547cdf0e10cSrcweir { 548cdf0e10cSrcweir OSL_ENSURE( false, 549cdf0e10cSrcweir "BaseContent::getContentType - Property value was null!" ); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir } 552cdf0e10cSrcweir catch ( sdbc::SQLException const & ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir OSL_ENSURE( false, 555cdf0e10cSrcweir "BaseContent::getContentType - Caught SQLException!" ); 556cdf0e10cSrcweir } 557cdf0e10cSrcweir } 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir return rtl::OUString(); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir 564cdf0e10cSrcweir 565cdf0e10cSrcweir void SAL_CALL 566cdf0e10cSrcweir BaseContent::addContentEventListener( 567cdf0e10cSrcweir const Reference< XContentEventListener >& Listener ) 568cdf0e10cSrcweir throw( RuntimeException ) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 571cdf0e10cSrcweir 572cdf0e10cSrcweir if ( ! m_pContentEventListeners ) 573cdf0e10cSrcweir m_pContentEventListeners = 574cdf0e10cSrcweir new cppu::OInterfaceContainerHelper( m_aEventListenerMutex ); 575cdf0e10cSrcweir 576cdf0e10cSrcweir 577cdf0e10cSrcweir m_pContentEventListeners->addInterface( Listener ); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580cdf0e10cSrcweir 581cdf0e10cSrcweir void SAL_CALL 582cdf0e10cSrcweir BaseContent::removeContentEventListener( 583cdf0e10cSrcweir const Reference< XContentEventListener >& Listener ) 584cdf0e10cSrcweir throw( RuntimeException ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 587cdf0e10cSrcweir 588cdf0e10cSrcweir if ( m_pContentEventListeners ) 589cdf0e10cSrcweir m_pContentEventListeners->removeInterface( Listener ); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592cdf0e10cSrcweir 593cdf0e10cSrcweir 594cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 595cdf0e10cSrcweir // XPropertyContainer 596cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 597cdf0e10cSrcweir 598cdf0e10cSrcweir 599cdf0e10cSrcweir void SAL_CALL 600cdf0e10cSrcweir BaseContent::addProperty( 601cdf0e10cSrcweir const rtl::OUString& Name, 602cdf0e10cSrcweir sal_Int16 Attributes, 603cdf0e10cSrcweir const Any& DefaultValue ) 604cdf0e10cSrcweir throw( beans::PropertyExistException, 605cdf0e10cSrcweir beans::IllegalTypeException, 606cdf0e10cSrcweir lang::IllegalArgumentException, 607cdf0e10cSrcweir RuntimeException) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir if( ( m_nState & JustInserted ) || ( m_nState & Deleted ) || Name == rtl::OUString() ) 610cdf0e10cSrcweir { 611cdf0e10cSrcweir throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir m_pMyShell->associate( m_aUncPath,Name,DefaultValue,Attributes ); 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir 618cdf0e10cSrcweir void SAL_CALL 619cdf0e10cSrcweir BaseContent::removeProperty( 620cdf0e10cSrcweir const rtl::OUString& Name ) 621cdf0e10cSrcweir throw( beans::UnknownPropertyException, 622cdf0e10cSrcweir beans::NotRemoveableException, 623cdf0e10cSrcweir RuntimeException) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir 626cdf0e10cSrcweir if( m_nState & Deleted ) 627cdf0e10cSrcweir throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 628cdf0e10cSrcweir 629cdf0e10cSrcweir m_pMyShell->deassociate( m_aUncPath, Name ); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 633cdf0e10cSrcweir // XContentCreator 634cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 635cdf0e10cSrcweir 636cdf0e10cSrcweir Sequence< ContentInfo > SAL_CALL 637cdf0e10cSrcweir BaseContent::queryCreatableContentsInfo( 638cdf0e10cSrcweir void ) 639cdf0e10cSrcweir throw( RuntimeException ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir return m_pMyShell->queryCreatableContentsInfo(); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir 645cdf0e10cSrcweir Reference< XContent > SAL_CALL 646cdf0e10cSrcweir BaseContent::createNewContent( 647cdf0e10cSrcweir const ContentInfo& Info ) 648cdf0e10cSrcweir throw( RuntimeException ) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir // Check type. 651cdf0e10cSrcweir if ( !Info.Type.getLength() ) 652cdf0e10cSrcweir return Reference< XContent >(); 653cdf0e10cSrcweir 654cdf0e10cSrcweir sal_Bool bFolder 655cdf0e10cSrcweir = ( Info.Type.compareTo( m_pMyShell->FolderContentType ) == 0 ); 656cdf0e10cSrcweir if ( !bFolder ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir if ( Info.Type.compareTo( m_pMyShell->FileContentType ) != 0 ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir // Neither folder nor file to create! 661cdf0e10cSrcweir return Reference< XContent >(); 662cdf0e10cSrcweir } 663cdf0e10cSrcweir } 664cdf0e10cSrcweir 665cdf0e10cSrcweir // Who am I ? 666cdf0e10cSrcweir sal_Bool IsDocument = false; 667cdf0e10cSrcweir 668cdf0e10cSrcweir try 669cdf0e10cSrcweir { 670cdf0e10cSrcweir Sequence< beans::Property > seq(1); 671cdf0e10cSrcweir seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), 672cdf0e10cSrcweir -1, 673cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >(0) ), 674cdf0e10cSrcweir 0 ); 675cdf0e10cSrcweir Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq ); 676cdf0e10cSrcweir IsDocument = xRow->getBoolean( 1 ); 677cdf0e10cSrcweir 678cdf0e10cSrcweir if ( xRow->wasNull() ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir IsDocument = false; 681cdf0e10cSrcweir // OSL_ENSURE( false, 682cdf0e10cSrcweir // "BaseContent::createNewContent - Property value was null!" ); 683cdf0e10cSrcweir // return Reference< XContent >(); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir } 686cdf0e10cSrcweir catch ( sdbc::SQLException const & ) 687cdf0e10cSrcweir { 688cdf0e10cSrcweir OSL_ENSURE( false, 689cdf0e10cSrcweir "BaseContent::createNewContent - Caught SQLException!" ); 690cdf0e10cSrcweir return Reference< XContent >(); 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir rtl::OUString dstUncPath; 694cdf0e10cSrcweir 695cdf0e10cSrcweir if( IsDocument ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir // KSO: Why is a document a XContentCreator? This is quite unusual. 698cdf0e10cSrcweir dstUncPath = getParentName( m_aUncPath ); 699cdf0e10cSrcweir } 700cdf0e10cSrcweir else 701cdf0e10cSrcweir dstUncPath = m_aUncPath; 702cdf0e10cSrcweir 703cdf0e10cSrcweir BaseContent* p = new BaseContent( m_pMyShell, dstUncPath, bFolder ); 704cdf0e10cSrcweir return Reference< XContent >( p ); 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir 708cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 709cdf0e10cSrcweir // XPropertySetInfoChangeNotifier 710cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 711cdf0e10cSrcweir 712cdf0e10cSrcweir 713cdf0e10cSrcweir void SAL_CALL 714cdf0e10cSrcweir BaseContent::addPropertySetInfoChangeListener( 715cdf0e10cSrcweir const Reference< beans::XPropertySetInfoChangeListener >& Listener ) 716cdf0e10cSrcweir throw( RuntimeException ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 719cdf0e10cSrcweir if( ! m_pPropertySetInfoChangeListeners ) 720cdf0e10cSrcweir m_pPropertySetInfoChangeListeners = new cppu::OInterfaceContainerHelper( m_aEventListenerMutex ); 721cdf0e10cSrcweir 722cdf0e10cSrcweir m_pPropertySetInfoChangeListeners->addInterface( Listener ); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir 725cdf0e10cSrcweir 726cdf0e10cSrcweir void SAL_CALL 727cdf0e10cSrcweir BaseContent::removePropertySetInfoChangeListener( 728cdf0e10cSrcweir const Reference< beans::XPropertySetInfoChangeListener >& Listener ) 729cdf0e10cSrcweir throw( RuntimeException ) 730cdf0e10cSrcweir { 731cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 732cdf0e10cSrcweir 733cdf0e10cSrcweir if( m_pPropertySetInfoChangeListeners ) 734cdf0e10cSrcweir m_pPropertySetInfoChangeListeners->removeInterface( Listener ); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir 737cdf0e10cSrcweir 738cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 739cdf0e10cSrcweir // XChild 740cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////// 741cdf0e10cSrcweir 742cdf0e10cSrcweir Reference< XInterface > SAL_CALL 743cdf0e10cSrcweir BaseContent::getParent( 744cdf0e10cSrcweir void ) 745cdf0e10cSrcweir throw( RuntimeException ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir rtl::OUString ParentUnq = getParentName( m_aUncPath ); 748cdf0e10cSrcweir rtl::OUString ParentUrl; 749cdf0e10cSrcweir 750cdf0e10cSrcweir 751cdf0e10cSrcweir sal_Bool err = m_pMyShell->getUrlFromUnq( ParentUnq, ParentUrl ); 752cdf0e10cSrcweir if( err ) 753cdf0e10cSrcweir return Reference< XInterface >( 0 ); 754cdf0e10cSrcweir 755cdf0e10cSrcweir FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,ParentUnq ); 756cdf0e10cSrcweir Reference< XContentIdentifier > Identifier( p ); 757cdf0e10cSrcweir 758cdf0e10cSrcweir try 759cdf0e10cSrcweir { 760cdf0e10cSrcweir Reference< XContent > content = m_pMyShell->m_pProvider->queryContent( Identifier ); 761cdf0e10cSrcweir return Reference<XInterface>(content,UNO_QUERY); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir catch( IllegalIdentifierException ) 764cdf0e10cSrcweir { 765cdf0e10cSrcweir return Reference< XInterface >(); 766cdf0e10cSrcweir } 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir 770cdf0e10cSrcweir void SAL_CALL 771cdf0e10cSrcweir BaseContent::setParent( 772cdf0e10cSrcweir const Reference< XInterface >& ) 773cdf0e10cSrcweir throw( lang::NoSupportException, 774cdf0e10cSrcweir RuntimeException) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir throw lang::NoSupportException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 777cdf0e10cSrcweir } 778cdf0e10cSrcweir 779cdf0e10cSrcweir 780cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 781cdf0e10cSrcweir // Private Methods 782cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 783cdf0e10cSrcweir 784cdf0e10cSrcweir 785cdf0e10cSrcweir Reference< XCommandInfo > SAL_CALL 786cdf0e10cSrcweir BaseContent::getCommandInfo() 787cdf0e10cSrcweir throw( RuntimeException ) 788cdf0e10cSrcweir { 789cdf0e10cSrcweir if( m_nState & Deleted ) 790cdf0e10cSrcweir return Reference< XCommandInfo >(); 791cdf0e10cSrcweir 792cdf0e10cSrcweir return m_pMyShell->info_c(); 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir 796cdf0e10cSrcweir Reference< beans::XPropertySetInfo > SAL_CALL 797cdf0e10cSrcweir BaseContent::getPropertySetInfo( 798cdf0e10cSrcweir sal_Int32 ) 799cdf0e10cSrcweir throw( RuntimeException ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir if( m_nState & Deleted ) 802cdf0e10cSrcweir return Reference< beans::XPropertySetInfo >(); 803cdf0e10cSrcweir 804cdf0e10cSrcweir return m_pMyShell->info_p( m_aUncPath ); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir 808cdf0e10cSrcweir 809cdf0e10cSrcweir 810cdf0e10cSrcweir Reference< sdbc::XRow > SAL_CALL 811cdf0e10cSrcweir BaseContent::getPropertyValues( 812cdf0e10cSrcweir sal_Int32 nMyCommandIdentifier, 813cdf0e10cSrcweir const Sequence< beans::Property >& PropertySet ) 814cdf0e10cSrcweir throw( RuntimeException ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir sal_Int32 nProps = PropertySet.getLength(); 817cdf0e10cSrcweir if ( !nProps ) 818cdf0e10cSrcweir return Reference< sdbc::XRow >(); 819cdf0e10cSrcweir 820cdf0e10cSrcweir if( m_nState & Deleted ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir Sequence< Any > aValues( nProps ); 823cdf0e10cSrcweir return Reference< sdbc::XRow >( new XRow_impl( m_pMyShell, aValues ) ); 824cdf0e10cSrcweir } 825cdf0e10cSrcweir 826cdf0e10cSrcweir if( m_nState & JustInserted ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir Sequence< Any > aValues( nProps ); 829cdf0e10cSrcweir Any* pValues = aValues.getArray(); 830cdf0e10cSrcweir 831cdf0e10cSrcweir const beans::Property* pProps = PropertySet.getConstArray(); 832cdf0e10cSrcweir 833cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nProps; ++n ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 836cdf0e10cSrcweir Any& rValue = pValues[ n ]; 837cdf0e10cSrcweir 838cdf0e10cSrcweir if( rProp.Name.compareToAscii( "ContentType" ) == 0 ) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir rValue <<= m_bFolder ? m_pMyShell->FolderContentType 841cdf0e10cSrcweir : m_pMyShell->FileContentType; 842cdf0e10cSrcweir } 843cdf0e10cSrcweir else if( rProp.Name.compareToAscii( "IsFolder" ) == 0 ) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir rValue <<= m_bFolder; 846cdf0e10cSrcweir } 847cdf0e10cSrcweir else if( rProp.Name.compareToAscii( "IsDocument" ) == 0 ) 848cdf0e10cSrcweir { 849cdf0e10cSrcweir rValue <<= sal_Bool( !m_bFolder ); 850cdf0e10cSrcweir } 851cdf0e10cSrcweir } 852cdf0e10cSrcweir 853cdf0e10cSrcweir return Reference< sdbc::XRow >( 854cdf0e10cSrcweir new XRow_impl( m_pMyShell, aValues ) ); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir 857cdf0e10cSrcweir return m_pMyShell->getv( nMyCommandIdentifier, 858cdf0e10cSrcweir m_aUncPath, 859cdf0e10cSrcweir PropertySet ); 860cdf0e10cSrcweir } 861cdf0e10cSrcweir 862cdf0e10cSrcweir 863cdf0e10cSrcweir Sequence< Any > SAL_CALL 864cdf0e10cSrcweir BaseContent::setPropertyValues( 865cdf0e10cSrcweir sal_Int32 nMyCommandIdentifier, 866cdf0e10cSrcweir const Sequence< beans::PropertyValue >& Values ) 867cdf0e10cSrcweir throw() 868cdf0e10cSrcweir { 869cdf0e10cSrcweir if( m_nState & Deleted ) 870cdf0e10cSrcweir { // To do 871cdf0e10cSrcweir return Sequence< Any >( Values.getLength() ); 872cdf0e10cSrcweir } 873cdf0e10cSrcweir 874cdf0e10cSrcweir const rtl::OUString Title = rtl::OUString::createFromAscii( "Title" ); 875cdf0e10cSrcweir 876cdf0e10cSrcweir // Special handling for files which have to be inserted 877cdf0e10cSrcweir if( m_nState & JustInserted ) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir for( sal_Int32 i = 0; i < Values.getLength(); ++i ) 880cdf0e10cSrcweir { 881cdf0e10cSrcweir if( Values[i].Name == Title ) 882cdf0e10cSrcweir { 883cdf0e10cSrcweir rtl::OUString NewTitle; 884cdf0e10cSrcweir if( Values[i].Value >>= NewTitle ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir if ( m_nState & NameForInsertionSet ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir // User wants to set another Title before "insert". 889cdf0e10cSrcweir // m_aUncPath contains previous own URI. 890cdf0e10cSrcweir 891cdf0e10cSrcweir sal_Int32 nLastSlash = m_aUncPath.lastIndexOf( '/' ); 892cdf0e10cSrcweir bool bTrailingSlash = false; 893cdf0e10cSrcweir if ( nLastSlash == m_aUncPath.getLength() - 1 ) 894cdf0e10cSrcweir { 895cdf0e10cSrcweir bTrailingSlash = true; 896cdf0e10cSrcweir nLastSlash 897cdf0e10cSrcweir = m_aUncPath.lastIndexOf( '/', nLastSlash ); 898cdf0e10cSrcweir } 899cdf0e10cSrcweir 900cdf0e10cSrcweir OSL_ENSURE( nLastSlash != -1, 901cdf0e10cSrcweir "BaseContent::setPropertyValues: " 902cdf0e10cSrcweir "Invalid URL!" ); 903cdf0e10cSrcweir 904cdf0e10cSrcweir rtl::OUStringBuffer aBuf( 905cdf0e10cSrcweir m_aUncPath.copy( 0, nLastSlash + 1 ) ); 906cdf0e10cSrcweir 907cdf0e10cSrcweir if ( NewTitle.getLength() > 0 ) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir aBuf.append( NewTitle ); 910cdf0e10cSrcweir if ( bTrailingSlash ) 911cdf0e10cSrcweir aBuf.append( sal_Unicode( '/' ) ); 912cdf0e10cSrcweir } 913cdf0e10cSrcweir else 914cdf0e10cSrcweir { 915cdf0e10cSrcweir m_nState &= ~NameForInsertionSet; 916cdf0e10cSrcweir } 917cdf0e10cSrcweir 918cdf0e10cSrcweir m_aUncPath = aBuf.makeStringAndClear(); 919cdf0e10cSrcweir } 920cdf0e10cSrcweir else 921cdf0e10cSrcweir { 922cdf0e10cSrcweir if ( NewTitle.getLength() > 0 ) 923cdf0e10cSrcweir { 924cdf0e10cSrcweir // Initial Title before "insert". 925cdf0e10cSrcweir // m_aUncPath contains parent's URI. 926cdf0e10cSrcweir 927cdf0e10cSrcweir if( m_aUncPath.lastIndexOf( sal_Unicode('/') ) != m_aUncPath.getLength() - 1 ) 928cdf0e10cSrcweir m_aUncPath += rtl::OUString::createFromAscii("/"); 929cdf0e10cSrcweir 930cdf0e10cSrcweir m_aUncPath += rtl::Uri::encode( NewTitle, 931cdf0e10cSrcweir rtl_UriCharClassPchar, 932cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes, 933cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 934cdf0e10cSrcweir m_nState |= NameForInsertionSet; 935cdf0e10cSrcweir } 936cdf0e10cSrcweir } 937cdf0e10cSrcweir } 938cdf0e10cSrcweir } 939cdf0e10cSrcweir } 940cdf0e10cSrcweir 941cdf0e10cSrcweir return Sequence< Any >( Values.getLength() ); 942cdf0e10cSrcweir } 943cdf0e10cSrcweir else 944cdf0e10cSrcweir { 945cdf0e10cSrcweir Sequence< Any > ret = m_pMyShell->setv( m_aUncPath, // Does not handle Title 946cdf0e10cSrcweir Values ); 947cdf0e10cSrcweir 948cdf0e10cSrcweir // Special handling Title: Setting Title is equivalent to a renaming of the underlying file 949cdf0e10cSrcweir for( sal_Int32 i = 0; i < Values.getLength(); ++i ) 950cdf0e10cSrcweir { 951cdf0e10cSrcweir if( Values[i].Name != Title ) 952cdf0e10cSrcweir continue; // handled by setv 953cdf0e10cSrcweir 954cdf0e10cSrcweir rtl::OUString NewTitle; 955cdf0e10cSrcweir if( !( Values[i].Value >>= NewTitle ) ) 956cdf0e10cSrcweir { 957cdf0e10cSrcweir ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 958cdf0e10cSrcweir break; 959cdf0e10cSrcweir } 960cdf0e10cSrcweir else if( ! NewTitle.getLength() ) 961cdf0e10cSrcweir { 962cdf0e10cSrcweir ret[i] <<= lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); 963cdf0e10cSrcweir break; 964cdf0e10cSrcweir } 965cdf0e10cSrcweir 966cdf0e10cSrcweir 967cdf0e10cSrcweir rtl::OUString aDstName = getParentName( m_aUncPath ); 968cdf0e10cSrcweir if( aDstName.lastIndexOf( sal_Unicode('/') ) != aDstName.getLength() - 1 ) 969cdf0e10cSrcweir aDstName += rtl::OUString::createFromAscii("/"); 970cdf0e10cSrcweir 971cdf0e10cSrcweir aDstName += rtl::Uri::encode( NewTitle, 972cdf0e10cSrcweir rtl_UriCharClassPchar, 973cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes, 974cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 975cdf0e10cSrcweir 976cdf0e10cSrcweir m_pMyShell->move( nMyCommandIdentifier, // move notifies the childs also; 977cdf0e10cSrcweir m_aUncPath, 978cdf0e10cSrcweir aDstName, 979cdf0e10cSrcweir NameClash::KEEP ); 980cdf0e10cSrcweir 981cdf0e10cSrcweir try 982cdf0e10cSrcweir { 983cdf0e10cSrcweir endTask( nMyCommandIdentifier ); 984cdf0e10cSrcweir } 985cdf0e10cSrcweir catch( const Exception& e ) 986cdf0e10cSrcweir { 987cdf0e10cSrcweir ret[i] <<= e; 988cdf0e10cSrcweir } 989cdf0e10cSrcweir 990cdf0e10cSrcweir // NameChanges come back trough a ContentEvent 991cdf0e10cSrcweir break; // only handling Title 992cdf0e10cSrcweir } // end for 993cdf0e10cSrcweir 994cdf0e10cSrcweir return ret; 995cdf0e10cSrcweir } 996cdf0e10cSrcweir } 997cdf0e10cSrcweir 998cdf0e10cSrcweir 999cdf0e10cSrcweir 1000cdf0e10cSrcweir Reference< XDynamicResultSet > SAL_CALL 1001cdf0e10cSrcweir BaseContent::open( 1002cdf0e10cSrcweir sal_Int32 nMyCommandIdentifier, 1003cdf0e10cSrcweir const OpenCommandArgument2& aCommandArgument ) 1004cdf0e10cSrcweir throw() 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir Reference< XDynamicResultSet > retValue( 0 ); 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir if( ( m_nState & Deleted ) ) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1011cdf0e10cSrcweir TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND ); 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir else if( m_nState & JustInserted ) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1016cdf0e10cSrcweir TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND ); 1017cdf0e10cSrcweir } 1018cdf0e10cSrcweir else 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir if( aCommandArgument.Mode == OpenMode::DOCUMENT || 1021cdf0e10cSrcweir aCommandArgument.Mode == OpenMode::DOCUMENT_SHARE_DENY_NONE ) 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir Reference< io::XOutputStream > outputStream( aCommandArgument.Sink,UNO_QUERY ); 1025cdf0e10cSrcweir if( outputStream.is() ) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir m_pMyShell->page( nMyCommandIdentifier, 1028cdf0e10cSrcweir m_aUncPath, 1029cdf0e10cSrcweir outputStream ); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir sal_Bool bLock = ( aCommandArgument.Mode != OpenMode::DOCUMENT_SHARE_DENY_NONE ); 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir Reference< io::XActiveDataSink > activeDataSink( aCommandArgument.Sink,UNO_QUERY ); 1035cdf0e10cSrcweir if( activeDataSink.is() ) 1036cdf0e10cSrcweir { 1037cdf0e10cSrcweir activeDataSink->setInputStream( m_pMyShell->open( nMyCommandIdentifier, 1038cdf0e10cSrcweir m_aUncPath, 1039cdf0e10cSrcweir bLock ) ); 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir Reference< io::XActiveDataStreamer > activeDataStreamer( aCommandArgument.Sink,UNO_QUERY ); 1043cdf0e10cSrcweir if( activeDataStreamer.is() ) 1044cdf0e10cSrcweir { 1045cdf0e10cSrcweir activeDataStreamer->setStream( m_pMyShell->open_rw( nMyCommandIdentifier, 1046cdf0e10cSrcweir m_aUncPath, 1047cdf0e10cSrcweir bLock ) ); 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir else if ( aCommandArgument.Mode == OpenMode::ALL || 1051cdf0e10cSrcweir aCommandArgument.Mode == OpenMode::FOLDERS || 1052cdf0e10cSrcweir aCommandArgument.Mode == OpenMode::DOCUMENTS ) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir retValue = m_pMyShell->ls( nMyCommandIdentifier, 1055cdf0e10cSrcweir m_aUncPath, 1056cdf0e10cSrcweir aCommandArgument.Mode, 1057cdf0e10cSrcweir aCommandArgument.Properties, 1058cdf0e10cSrcweir aCommandArgument.SortingInfo ); 1059cdf0e10cSrcweir } 1060cdf0e10cSrcweir // else if( aCommandArgument.Mode == 1061cdf0e10cSrcweir // OpenMode::DOCUMENT_SHARE_DENY_NONE || 1062cdf0e10cSrcweir // aCommandArgument.Mode == 1063cdf0e10cSrcweir // OpenMode::DOCUMENT_SHARE_DENY_WRITE ) 1064cdf0e10cSrcweir // m_pMyShell->installError( nMyCommandIdentifier, 1065cdf0e10cSrcweir // TASKHANDLING_UNSUPPORTED_OPEN_MODE, 1066cdf0e10cSrcweir // aCommandArgument.Mode); 1067cdf0e10cSrcweir else 1068cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1069cdf0e10cSrcweir TASKHANDLING_UNSUPPORTED_OPEN_MODE, 1070cdf0e10cSrcweir aCommandArgument.Mode); 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir 1073cdf0e10cSrcweir return retValue; 1074cdf0e10cSrcweir } 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir void SAL_CALL 1079cdf0e10cSrcweir BaseContent::deleteContent( sal_Int32 nMyCommandIdentifier ) 1080cdf0e10cSrcweir throw() 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir if( m_nState & Deleted ) 1083cdf0e10cSrcweir return; 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir if( m_pMyShell->remove( nMyCommandIdentifier,m_aUncPath ) ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1088cdf0e10cSrcweir m_nState |= Deleted; 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir } 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir void SAL_CALL 1095cdf0e10cSrcweir BaseContent::transfer( sal_Int32 nMyCommandIdentifier, 1096cdf0e10cSrcweir const TransferInfo& aTransferInfo ) 1097cdf0e10cSrcweir throw() 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir if( m_nState & Deleted ) 1100cdf0e10cSrcweir return; 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir if( aTransferInfo.SourceURL.compareToAscii( "file:",5 ) != 0 ) 1103cdf0e10cSrcweir { 1104cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1105cdf0e10cSrcweir TASKHANDLING_TRANSFER_INVALIDSCHEME ); 1106cdf0e10cSrcweir return; 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir rtl::OUString srcUnc; 1110cdf0e10cSrcweir if( m_pMyShell->getUnqFromUrl( aTransferInfo.SourceURL,srcUnc ) ) 1111cdf0e10cSrcweir { 1112cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1113cdf0e10cSrcweir TASKHANDLING_TRANSFER_INVALIDURL ); 1114cdf0e10cSrcweir return; 1115cdf0e10cSrcweir } 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir rtl::OUString srcUncPath = srcUnc; 1118cdf0e10cSrcweir 1119cdf0e10cSrcweir // Determine the new title ! 1120cdf0e10cSrcweir rtl::OUString NewTitle; 1121cdf0e10cSrcweir if( aTransferInfo.NewTitle.getLength() ) 1122cdf0e10cSrcweir NewTitle = rtl::Uri::encode( aTransferInfo.NewTitle, 1123cdf0e10cSrcweir rtl_UriCharClassPchar, 1124cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes, 1125cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 1126cdf0e10cSrcweir else 1127cdf0e10cSrcweir NewTitle = srcUncPath.copy( 1 + srcUncPath.lastIndexOf( sal_Unicode('/') ) ); 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir // Is destination a document or a folder ? 1130cdf0e10cSrcweir Sequence< beans::Property > seq(1); 1131cdf0e10cSrcweir seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), 1132cdf0e10cSrcweir -1, 1133cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >(0) ), 1134cdf0e10cSrcweir 0 ); 1135cdf0e10cSrcweir Reference< sdbc::XRow > xRow = getPropertyValues( nMyCommandIdentifier,seq ); 1136cdf0e10cSrcweir sal_Bool IsDocument = xRow->getBoolean( 1 ); 1137cdf0e10cSrcweir if( xRow->wasNull() ) 1138cdf0e10cSrcweir { // Destination file type could not be determined 1139cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1140cdf0e10cSrcweir TASKHANDLING_TRANSFER_DESTFILETYPE ); 1141cdf0e10cSrcweir return; 1142cdf0e10cSrcweir } 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir rtl::OUString dstUncPath; 1145cdf0e10cSrcweir if( IsDocument ) 1146cdf0e10cSrcweir { // as sibling 1147cdf0e10cSrcweir sal_Int32 lastSlash = m_aUncPath.lastIndexOf( sal_Unicode('/') ); 1148cdf0e10cSrcweir dstUncPath = m_aUncPath.copy(0,lastSlash ); 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir else 1151cdf0e10cSrcweir // as child 1152cdf0e10cSrcweir dstUncPath = m_aUncPath; 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir dstUncPath += ( rtl::OUString::createFromAscii( "/" ) + NewTitle ); 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir sal_Int32 NameClash = aTransferInfo.NameClash; 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir if( aTransferInfo.MoveData ) 1159cdf0e10cSrcweir m_pMyShell->move( nMyCommandIdentifier,srcUncPath,dstUncPath,NameClash ); 1160cdf0e10cSrcweir else 1161cdf0e10cSrcweir m_pMyShell->copy( nMyCommandIdentifier,srcUncPath,dstUncPath,NameClash ); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir void SAL_CALL BaseContent::insert( sal_Int32 nMyCommandIdentifier, 1168cdf0e10cSrcweir const InsertCommandArgument& aInsertArgument ) 1169cdf0e10cSrcweir throw() 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir if( m_nState & FullFeatured ) 1172cdf0e10cSrcweir { 1173cdf0e10cSrcweir m_pMyShell->write( nMyCommandIdentifier, 1174cdf0e10cSrcweir m_aUncPath, 1175cdf0e10cSrcweir aInsertArgument.ReplaceExisting, 1176cdf0e10cSrcweir aInsertArgument.Data ); 1177cdf0e10cSrcweir return; 1178cdf0e10cSrcweir } 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir if( ! ( m_nState & JustInserted ) ) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1183cdf0e10cSrcweir TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND ); 1184cdf0e10cSrcweir return; 1185cdf0e10cSrcweir } 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir // Inserts the content, which has the flag m_bIsFresh 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir if( ! m_nState & NameForInsertionSet ) 1190cdf0e10cSrcweir { 1191cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1192cdf0e10cSrcweir TASKHANDLING_NONAMESET_INSERT_COMMAND ); 1193cdf0e10cSrcweir return; 1194cdf0e10cSrcweir } 1195cdf0e10cSrcweir 1196cdf0e10cSrcweir // Inserting a document or a file? 1197cdf0e10cSrcweir sal_Bool bDocument = false; 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir Sequence< beans::Property > seq(1); 1200cdf0e10cSrcweir seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), 1201cdf0e10cSrcweir -1, 1202cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >(0) ), 1203cdf0e10cSrcweir 0 ); 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq ); 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir bool contentTypeSet = true; // is set to false, if contentType not set 1208cdf0e10cSrcweir try 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir bDocument = xRow->getBoolean( 1 ); 1211cdf0e10cSrcweir if( xRow->wasNull() ) 1212cdf0e10cSrcweir contentTypeSet = false; 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir catch ( sdbc::SQLException const & ) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir OSL_ENSURE( false, 1218cdf0e10cSrcweir "BaseContent::insert - Caught SQLException!" ); 1219cdf0e10cSrcweir contentTypeSet = false; 1220cdf0e10cSrcweir } 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir if( ! contentTypeSet ) 1223cdf0e10cSrcweir { 1224cdf0e10cSrcweir m_pMyShell->installError( nMyCommandIdentifier, 1225cdf0e10cSrcweir TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND ); 1226cdf0e10cSrcweir return; 1227cdf0e10cSrcweir } 1228cdf0e10cSrcweir 1229cdf0e10cSrcweir 1230cdf0e10cSrcweir sal_Bool success = false; 1231cdf0e10cSrcweir if( bDocument ) 1232cdf0e10cSrcweir success = m_pMyShell->mkfil( nMyCommandIdentifier, 1233cdf0e10cSrcweir m_aUncPath, 1234cdf0e10cSrcweir aInsertArgument.ReplaceExisting, 1235cdf0e10cSrcweir aInsertArgument.Data ); 1236cdf0e10cSrcweir else 1237cdf0e10cSrcweir { 1238cdf0e10cSrcweir while( ! success ) 1239cdf0e10cSrcweir { 1240cdf0e10cSrcweir success = m_pMyShell->mkdir( nMyCommandIdentifier, 1241cdf0e10cSrcweir m_aUncPath, 1242cdf0e10cSrcweir aInsertArgument.ReplaceExisting ); 1243cdf0e10cSrcweir if( success ) 1244cdf0e10cSrcweir break; 1245cdf0e10cSrcweir 1246cdf0e10cSrcweir XInteractionRequestImpl *aRequestImpl = 1247cdf0e10cSrcweir new XInteractionRequestImpl( 1248cdf0e10cSrcweir rtl::Uri::decode( 1249cdf0e10cSrcweir getTitle(m_aUncPath), 1250cdf0e10cSrcweir rtl_UriDecodeWithCharset, 1251cdf0e10cSrcweir RTL_TEXTENCODING_UTF8), 1252cdf0e10cSrcweir (cppu::OWeakObject*)this, 1253cdf0e10cSrcweir m_pMyShell,nMyCommandIdentifier); 1254cdf0e10cSrcweir uno::Reference< task::XInteractionRequest > aReq( aRequestImpl ); 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir m_pMyShell->handleTask( nMyCommandIdentifier,aReq ); 1257cdf0e10cSrcweir if( aRequestImpl->aborted() || 1258cdf0e10cSrcweir !aRequestImpl->newName().getLength() ) 1259cdf0e10cSrcweir // means aborting 1260cdf0e10cSrcweir break; 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir // determine new uncpath 1263cdf0e10cSrcweir m_pMyShell->clearError( nMyCommandIdentifier ); 1264cdf0e10cSrcweir m_aUncPath = getParentName( m_aUncPath ); 1265cdf0e10cSrcweir if( m_aUncPath.lastIndexOf( sal_Unicode('/') ) != m_aUncPath.getLength() - 1 ) 1266cdf0e10cSrcweir m_aUncPath += rtl::OUString::createFromAscii("/"); 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir m_aUncPath += rtl::Uri::encode( aRequestImpl->newName(), 1269cdf0e10cSrcweir rtl_UriCharClassPchar, 1270cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes, 1271cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 1272cdf0e10cSrcweir } 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir if ( ! success ) 1276cdf0e10cSrcweir return; 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,m_aUncPath ); 1279cdf0e10cSrcweir m_xContentIdentifier = Reference< XContentIdentifier >( p ); 1280cdf0e10cSrcweir 1281cdf0e10cSrcweir m_pMyShell->registerNotifier( m_aUncPath,this ); 1282cdf0e10cSrcweir m_pMyShell->insertDefaultProperties( m_aUncPath ); 1283cdf0e10cSrcweir 1284cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1285cdf0e10cSrcweir m_nState = FullFeatured; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir 1289cdf0e10cSrcweir 1290cdf0e10cSrcweir void SAL_CALL BaseContent::endTask( sal_Int32 CommandId ) 1291cdf0e10cSrcweir { 1292cdf0e10cSrcweir // This is the only function allowed to throw an exception 1293cdf0e10cSrcweir m_pMyShell->endTask( CommandId,m_aUncPath,this ); 1294cdf0e10cSrcweir } 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir ContentEventNotifier* 1299cdf0e10cSrcweir BaseContent::cDEL( void ) 1300cdf0e10cSrcweir { 1301cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1302cdf0e10cSrcweir 1303cdf0e10cSrcweir m_nState |= Deleted; 1304cdf0e10cSrcweir 1305cdf0e10cSrcweir ContentEventNotifier* p; 1306cdf0e10cSrcweir if( m_pContentEventListeners ) 1307cdf0e10cSrcweir p = new ContentEventNotifier( m_pMyShell, 1308cdf0e10cSrcweir this, 1309cdf0e10cSrcweir m_xContentIdentifier, 1310cdf0e10cSrcweir m_pContentEventListeners->getElements() ); 1311cdf0e10cSrcweir else 1312cdf0e10cSrcweir p = 0; 1313cdf0e10cSrcweir 1314cdf0e10cSrcweir return p; 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir 1318cdf0e10cSrcweir ContentEventNotifier* 1319cdf0e10cSrcweir BaseContent::cEXC( const rtl::OUString aNewName ) 1320cdf0e10cSrcweir { 1321cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir Reference< XContentIdentifier > xOldRef = m_xContentIdentifier; 1324cdf0e10cSrcweir m_aUncPath = aNewName; 1325cdf0e10cSrcweir FileContentIdentifier* pp = new FileContentIdentifier( m_pMyShell,aNewName ); 1326cdf0e10cSrcweir m_xContentIdentifier = Reference< XContentIdentifier >( pp ); 1327cdf0e10cSrcweir 1328cdf0e10cSrcweir ContentEventNotifier* p = 0; 1329cdf0e10cSrcweir if( m_pContentEventListeners ) 1330cdf0e10cSrcweir p = new ContentEventNotifier( m_pMyShell, 1331cdf0e10cSrcweir this, 1332cdf0e10cSrcweir m_xContentIdentifier, 1333cdf0e10cSrcweir xOldRef, 1334cdf0e10cSrcweir m_pContentEventListeners->getElements() ); 1335cdf0e10cSrcweir 1336cdf0e10cSrcweir return p; 1337cdf0e10cSrcweir } 1338cdf0e10cSrcweir 1339cdf0e10cSrcweir 1340cdf0e10cSrcweir ContentEventNotifier* 1341cdf0e10cSrcweir BaseContent::cCEL( void ) 1342cdf0e10cSrcweir { 1343cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1344cdf0e10cSrcweir ContentEventNotifier* p = 0; 1345cdf0e10cSrcweir if( m_pContentEventListeners ) 1346cdf0e10cSrcweir p = new ContentEventNotifier( m_pMyShell, 1347cdf0e10cSrcweir this, 1348cdf0e10cSrcweir m_xContentIdentifier, 1349cdf0e10cSrcweir m_pContentEventListeners->getElements() ); 1350cdf0e10cSrcweir 1351cdf0e10cSrcweir return p; 1352cdf0e10cSrcweir } 1353cdf0e10cSrcweir 1354cdf0e10cSrcweir PropertySetInfoChangeNotifier* 1355cdf0e10cSrcweir BaseContent::cPSL( void ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1358cdf0e10cSrcweir PropertySetInfoChangeNotifier* p = 0; 1359cdf0e10cSrcweir if( m_pPropertySetInfoChangeListeners ) 1360cdf0e10cSrcweir p = new PropertySetInfoChangeNotifier( m_pMyShell, 1361cdf0e10cSrcweir this, 1362cdf0e10cSrcweir m_xContentIdentifier, 1363cdf0e10cSrcweir m_pPropertySetInfoChangeListeners->getElements() ); 1364cdf0e10cSrcweir 1365cdf0e10cSrcweir return p; 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir 1370cdf0e10cSrcweir PropertyChangeNotifier* 1371cdf0e10cSrcweir BaseContent::cPCL( void ) 1372cdf0e10cSrcweir { 1373cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1374cdf0e10cSrcweir 1375cdf0e10cSrcweir Sequence< rtl::OUString > seqNames; 1376cdf0e10cSrcweir 1377cdf0e10cSrcweir if( m_pPropertyListener ) 1378cdf0e10cSrcweir seqNames = m_pPropertyListener->getContainedTypes(); 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir PropertyChangeNotifier* p = 0; 1381cdf0e10cSrcweir 1382cdf0e10cSrcweir sal_Int32 length = seqNames.getLength(); 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir if( length ) 1385cdf0e10cSrcweir { 1386cdf0e10cSrcweir ListenerMap* listener = new ListenerMap(); 1387cdf0e10cSrcweir for( sal_Int32 i = 0; i < length; ++i ) 1388cdf0e10cSrcweir { 1389cdf0e10cSrcweir (*listener)[seqNames[i]] = m_pPropertyListener->getContainer( seqNames[i] )->getElements(); 1390cdf0e10cSrcweir } 1391cdf0e10cSrcweir 1392cdf0e10cSrcweir p = new PropertyChangeNotifier( m_pMyShell, 1393cdf0e10cSrcweir this, 1394cdf0e10cSrcweir m_xContentIdentifier, 1395cdf0e10cSrcweir listener ); 1396cdf0e10cSrcweir } 1397cdf0e10cSrcweir 1398cdf0e10cSrcweir return p; 1399cdf0e10cSrcweir } 1400cdf0e10cSrcweir 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir rtl::OUString BaseContent::getKey( void ) 1403cdf0e10cSrcweir { 1404cdf0e10cSrcweir return m_aUncPath; 1405cdf0e10cSrcweir } 1406