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