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_ucbhelper.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir /************************************************************************** 32*cdf0e10cSrcweir TODO 33*cdf0e10cSrcweir ************************************************************************** 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir *************************************************************************/ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "osl/diagnose.h" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "com/sun/star/beans/PropertyAttribute.hpp" 40*cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyAccess.hpp" 41*cdf0e10cSrcweir #include "com/sun/star/lang/IllegalAccessException.hpp" 42*cdf0e10cSrcweir #include "com/sun/star/sdbc/XRow.hpp" 43*cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandInfo.hpp" 44*cdf0e10cSrcweir #include "com/sun/star/ucb/XPersistentPropertySet.hpp" 45*cdf0e10cSrcweir #include "ucbhelper/contentidentifier.hxx" 46*cdf0e10cSrcweir #include "ucbhelper/propertyvalueset.hxx" 47*cdf0e10cSrcweir #include "ucbhelper/cancelcommandexecution.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include "myucp_content.hxx" 50*cdf0e10cSrcweir #include "myucp_provider.hxx" 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT 53*cdf0e10cSrcweir #include "com/sun/star/ucb/InsertCommandArgument.hpp" 54*cdf0e10cSrcweir #include "com/sun/star/ucb/MissingInputStreamException.hpp" 55*cdf0e10cSrcweir #include "com/sun/star/ucb/MissingPropertiesException.hpp" 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_OPEN 58*cdf0e10cSrcweir #include "com/sun/star/io/XOutputStream.hpp" 59*cdf0e10cSrcweir #include "com/sun/star/io/XActiveDataSink.hpp" 60*cdf0e10cSrcweir #include "com/sun/star/ucb/OpenCommandArgument2.hpp" 61*cdf0e10cSrcweir #include "com/sun/star/ucb/OpenMode.hpp" 62*cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedDataSinkException.hpp" 63*cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedOpenModeException.hpp" 64*cdf0e10cSrcweir #include "myucp_resultset.hxx" 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir using namespace com::sun::star; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir // @@@ Adjust namespace name. 70*cdf0e10cSrcweir using namespace myucp; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir //========================================================================= 73*cdf0e10cSrcweir //========================================================================= 74*cdf0e10cSrcweir // 75*cdf0e10cSrcweir // Content Implementation. 76*cdf0e10cSrcweir // 77*cdf0e10cSrcweir //========================================================================= 78*cdf0e10cSrcweir //========================================================================= 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir Content::Content( const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 81*cdf0e10cSrcweir ::ucbhelper::ContentProviderImplHelper* pProvider, 82*cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier ) 83*cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir // @@@ Fill m_aProps here or implement lazy evaluation logic for this. 86*cdf0e10cSrcweir // m_aProps.aTitle = 87*cdf0e10cSrcweir // m_aprops.aContentType = 88*cdf0e10cSrcweir // m_aProps.bIsDocument = 89*cdf0e10cSrcweir // m_aProps.bIsFolder = 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir //========================================================================= 93*cdf0e10cSrcweir // virtual 94*cdf0e10cSrcweir Content::~Content() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir //========================================================================= 99*cdf0e10cSrcweir // 100*cdf0e10cSrcweir // XInterface methods. 101*cdf0e10cSrcweir // 102*cdf0e10cSrcweir //========================================================================= 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // virtual 105*cdf0e10cSrcweir void SAL_CALL Content::acquire() 106*cdf0e10cSrcweir throw() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir ContentImplHelper::acquire(); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir //========================================================================= 112*cdf0e10cSrcweir // virtual 113*cdf0e10cSrcweir void SAL_CALL Content::release() 114*cdf0e10cSrcweir throw() 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir ContentImplHelper::release(); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir //========================================================================= 120*cdf0e10cSrcweir // virtual 121*cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) 122*cdf0e10cSrcweir throw ( uno::RuntimeException ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir uno::Any aRet; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // @@@ Add support for additional interfaces. 127*cdf0e10cSrcweir #if 0 128*cdf0e10cSrcweir aRet = cppu::queryInterface( rType, 129*cdf0e10cSrcweir static_cast< yyy::Xxxxxxxxx * >( this ) ); 130*cdf0e10cSrcweir #endif 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //========================================================================= 136*cdf0e10cSrcweir // 137*cdf0e10cSrcweir // XTypeProvider methods. 138*cdf0e10cSrcweir // 139*cdf0e10cSrcweir //========================================================================= 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //========================================================================= 144*cdf0e10cSrcweir // virtual 145*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes() 146*cdf0e10cSrcweir throw( uno::RuntimeException ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir // @@@ Add own interfaces. 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir static cppu::OTypeCollection* pCollection = 0; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir if ( !pCollection ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 155*cdf0e10cSrcweir if ( !pCollection ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 158*cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 159*cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 160*cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 161*cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 162*cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 163*cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 164*cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 165*cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 166*cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 167*cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ) ); 168*cdf0e10cSrcweir pCollection = &aCollection; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir return (*pCollection).getTypes(); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //========================================================================= 176*cdf0e10cSrcweir // 177*cdf0e10cSrcweir // XServiceInfo methods. 178*cdf0e10cSrcweir // 179*cdf0e10cSrcweir //========================================================================= 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir // virtual 182*cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName() 183*cdf0e10cSrcweir throw( uno::RuntimeException ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir // @@@ Adjust implementation name. 186*cdf0e10cSrcweir // Prefix with reversed company domain name. 187*cdf0e10cSrcweir return rtl::OUString::createFromAscii( "com.sun.star.comp.myucp.Content" ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir //========================================================================= 191*cdf0e10cSrcweir // virtual 192*cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames() 193*cdf0e10cSrcweir throw( uno::RuntimeException ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir // @@@ Adjust macro name. 196*cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 ); 197*cdf0e10cSrcweir aSNS.getArray()[ 0 ] 198*cdf0e10cSrcweir = rtl::OUString::createFromAscii( MYUCP_CONTENT_SERVICE_NAME ); 199*cdf0e10cSrcweir return aSNS; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //========================================================================= 203*cdf0e10cSrcweir // 204*cdf0e10cSrcweir // XContent methods. 205*cdf0e10cSrcweir // 206*cdf0e10cSrcweir //========================================================================= 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir // virtual 209*cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType() 210*cdf0e10cSrcweir throw( uno::RuntimeException ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir // @@@ Adjust macro name ( def in myucp_provider.hxx ). 213*cdf0e10cSrcweir return rtl::OUString::createFromAscii( MYUCP_CONTENT_TYPE ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir //========================================================================= 217*cdf0e10cSrcweir // 218*cdf0e10cSrcweir // XCommandProcessor methods. 219*cdf0e10cSrcweir // 220*cdf0e10cSrcweir //========================================================================= 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // virtual 223*cdf0e10cSrcweir uno::Any SAL_CALL Content::execute( 224*cdf0e10cSrcweir const ucb::Command& aCommand, 225*cdf0e10cSrcweir sal_Int32 /* CommandId */, 226*cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 227*cdf0e10cSrcweir throw( uno::Exception, 228*cdf0e10cSrcweir ucb::CommandAbortedException, 229*cdf0e10cSrcweir uno::RuntimeException ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir uno::Any aRet; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir if ( aCommand.Name.equalsAsciiL( 234*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 237*cdf0e10cSrcweir // getPropertyValues 238*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir uno::Sequence< beans::Property > Properties; 241*cdf0e10cSrcweir if ( !( aCommand.Argument >>= Properties ) ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 244*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 245*cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 246*cdf0e10cSrcweir rtl::OUString(), 247*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 248*cdf0e10cSrcweir -1 ) ), 249*cdf0e10cSrcweir Environment ); 250*cdf0e10cSrcweir // Unreachable 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir aRet <<= getPropertyValues( Properties, Environment ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 256*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 259*cdf0e10cSrcweir // setPropertyValues 260*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 263*cdf0e10cSrcweir if ( !( aCommand.Argument >>= aProperties ) ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 266*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 267*cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 268*cdf0e10cSrcweir rtl::OUString(), 269*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 270*cdf0e10cSrcweir -1 ) ), 271*cdf0e10cSrcweir Environment ); 272*cdf0e10cSrcweir // Unreachable 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir if ( !aProperties.getLength() ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir OSL_ENSURE( sal_False, "No properties!" ); 278*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 279*cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 280*cdf0e10cSrcweir rtl::OUString(), 281*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 282*cdf0e10cSrcweir -1 ) ), 283*cdf0e10cSrcweir Environment ); 284*cdf0e10cSrcweir // Unreachable 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir aRet <<= setPropertyValues( aProperties, Environment ); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 290*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 293*cdf0e10cSrcweir // getPropertySetInfo 294*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir // Note: Implemented by base class. 297*cdf0e10cSrcweir aRet <<= getPropertySetInfo( Environment ); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 300*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 303*cdf0e10cSrcweir // getCommandInfo 304*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir // Note: Implemented by base class. 307*cdf0e10cSrcweir aRet <<= getCommandInfo( Environment ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_OPEN 310*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 311*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "open" ) ) ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenCommand; 314*cdf0e10cSrcweir if ( !( aCommand.Argument >>= aOpenCommand ) ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 317*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 318*cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 319*cdf0e10cSrcweir rtl::OUString(), 320*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 321*cdf0e10cSrcweir -1 ) ), 322*cdf0e10cSrcweir Environment ); 323*cdf0e10cSrcweir // Unreachable 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir sal_Bool bOpenFolder = 327*cdf0e10cSrcweir ( ( aOpenCommand.Mode == ucb::OpenMode::ALL ) || 328*cdf0e10cSrcweir ( aOpenCommand.Mode == ucb::OpenMode::FOLDERS ) || 329*cdf0e10cSrcweir ( aOpenCommand.Mode == ucb::OpenMode::DOCUMENTS ) ); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if ( bOpenFolder /*&& isFolder( Environment )*/ ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir // open as folder - return result set 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir uno::Reference< ucb::XDynamicResultSet > xSet 336*cdf0e10cSrcweir = new DynamicResultSet( m_xSMgr, 337*cdf0e10cSrcweir this, 338*cdf0e10cSrcweir aOpenCommand, 339*cdf0e10cSrcweir Environment ); 340*cdf0e10cSrcweir aRet <<= xSet; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir if ( aOpenCommand.Sink.is() ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir // Open document - supply document data stream. 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // Check open mode 348*cdf0e10cSrcweir if ( ( aOpenCommand.Mode 349*cdf0e10cSrcweir == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) || 350*cdf0e10cSrcweir ( aOpenCommand.Mode 351*cdf0e10cSrcweir == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir // Unsupported. 354*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 355*cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedOpenModeException( 356*cdf0e10cSrcweir rtl::OUString(), 357*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 358*cdf0e10cSrcweir sal_Int16( aOpenCommand.Mode ) ) ), 359*cdf0e10cSrcweir Environment ); 360*cdf0e10cSrcweir // Unreachable 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 365*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut 366*cdf0e10cSrcweir = uno::Reference< io::XOutputStream >( 367*cdf0e10cSrcweir aOpenCommand.Sink, uno::UNO_QUERY ); 368*cdf0e10cSrcweir if ( xOut.is() ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir // @@@ write data into xOut 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir else 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir uno::Reference< io::XActiveDataSink > xDataSink( 375*cdf0e10cSrcweir aOpenCommand.Sink, uno::UNO_QUERY ); 376*cdf0e10cSrcweir if ( xDataSink.is() ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir uno::Reference< io::XInputStream > xIn 379*cdf0e10cSrcweir /* @@@ your XInputStream + XSeekable impl. object */; 380*cdf0e10cSrcweir xDataSink->setInputStream( xIn ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir else 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir // Note: aOpenCommand.Sink may contain an XStream 385*cdf0e10cSrcweir // implementation. Support for this type of 386*cdf0e10cSrcweir // sink is optional... 387*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 388*cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedDataSinkException( 389*cdf0e10cSrcweir rtl::OUString(), 390*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 391*cdf0e10cSrcweir aOpenCommand.Sink ) ), 392*cdf0e10cSrcweir Environment ); 393*cdf0e10cSrcweir // Unreachable 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_OPEN 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT 401*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 402*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 405*cdf0e10cSrcweir // insert 406*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir ucb::InsertCommandArgument arg; 409*cdf0e10cSrcweir if ( !( aCommand.Argument >>= arg ) ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 412*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 413*cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 414*cdf0e10cSrcweir rtl::OUString(), 415*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 416*cdf0e10cSrcweir -1 ) ), 417*cdf0e10cSrcweir Environment ); 418*cdf0e10cSrcweir // Unreachable 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir insert( arg.Data, arg.ReplaceExisting, Environment ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_INSERT 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE 426*cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 427*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 430*cdf0e10cSrcweir // delete 431*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir sal_Bool bDeletePhysical = sal_False; 434*cdf0e10cSrcweir aCommand.Argument >>= bDeletePhysical; 435*cdf0e10cSrcweir destroy( bDeletePhysical ); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 438*cdf0e10cSrcweir removeAdditionalPropertySet( sal_True ); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir // Remove own and all childrens(!) persistent data. 441*cdf0e10cSrcweir // removeData(); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_DELETE 444*cdf0e10cSrcweir else 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 447*cdf0e10cSrcweir // Unsupported command 448*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::execute - unsupported command!" ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 453*cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 454*cdf0e10cSrcweir rtl::OUString(), 455*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 456*cdf0e10cSrcweir Environment ); 457*cdf0e10cSrcweir // Unreachable 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir return aRet; 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir //========================================================================= 464*cdf0e10cSrcweir // virtual 465*cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 ) 466*cdf0e10cSrcweir throw( uno::RuntimeException ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir // @@@ Implement logic to abort running commands, if this makes 469*cdf0e10cSrcweir // sense for your content. 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir //========================================================================= 473*cdf0e10cSrcweir // 474*cdf0e10cSrcweir // Non-interface methods. 475*cdf0e10cSrcweir // 476*cdf0e10cSrcweir //========================================================================= 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir // virtual 479*cdf0e10cSrcweir rtl::OUString Content::getParentURL() 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir // @@@ Extract URL of parent from aURL and return it... 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir return rtl::OUString(); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir //========================================================================= 489*cdf0e10cSrcweir // static 490*cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 491*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr, 492*cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 493*cdf0e10cSrcweir const ContentProperties& rData, 494*cdf0e10cSrcweir const rtl::Reference< 495*cdf0e10cSrcweir ::ucbhelper::ContentProviderImplHelper >& rProvider, 496*cdf0e10cSrcweir const rtl::OUString& rContentId ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir // Note: Empty sequence means "get values of all supported properties". 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow 501*cdf0e10cSrcweir = new ::ucbhelper::PropertyValueSet( rSMgr ); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 504*cdf0e10cSrcweir if ( nCount ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xAdditionalPropSet; 507*cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir const beans::Property* pProps = rProperties.getConstArray(); 510*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir // Process Core properties. 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if ( rProp.Name.equalsAsciiL( 517*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir xRow->appendString ( rProp, rData.aContentType ); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 522*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir xRow->appendString ( rProp, rData.aTitle ); 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 527*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.bIsDocument ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 532*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.bIsFolder ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // @@@ Process other properties supported directly. 538*cdf0e10cSrcweir #if 0 539*cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 540*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir #endif 544*cdf0e10cSrcweir else 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir // @@@ Note: If your data source supports adding/removing 547*cdf0e10cSrcweir // properties, you should implement the interface 548*cdf0e10cSrcweir // XPropertyContainer by yourself and supply your own 549*cdf0e10cSrcweir // logic here. The base class uses the service 550*cdf0e10cSrcweir // "com.sun.star.ucb.Store" to maintain Additional Core 551*cdf0e10cSrcweir // properties. But using server functionality is preferred! 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir xAdditionalPropSet 558*cdf0e10cSrcweir = uno::Reference< beans::XPropertySet >( 559*cdf0e10cSrcweir rProvider->getAdditionalPropertySet( rContentId, 560*cdf0e10cSrcweir sal_False ), 561*cdf0e10cSrcweir uno::UNO_QUERY ); 562*cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir if ( !xRow->appendPropertySetValue( 568*cdf0e10cSrcweir xAdditionalPropSet, 569*cdf0e10cSrcweir rProp ) ) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir // Append empty entry. 572*cdf0e10cSrcweir xRow->appendVoid( rProp ); 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir else 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir // Append empty entry. 578*cdf0e10cSrcweir xRow->appendVoid( rProp ); 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir else 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir // Append all Core Properties. 586*cdf0e10cSrcweir xRow->appendString ( 587*cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "ContentType" ), 588*cdf0e10cSrcweir -1, 589*cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 590*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 591*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 592*cdf0e10cSrcweir rData.aContentType ); 593*cdf0e10cSrcweir xRow->appendString ( 594*cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "Title" ), 595*cdf0e10cSrcweir -1, 596*cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 597*cdf0e10cSrcweir beans::PropertyAttribute::BOUND ), 598*cdf0e10cSrcweir rData.aTitle ); 599*cdf0e10cSrcweir xRow->appendBoolean( 600*cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsDocument" ), 601*cdf0e10cSrcweir -1, 602*cdf0e10cSrcweir getCppuBooleanType(), 603*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 604*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 605*cdf0e10cSrcweir rData.bIsDocument ); 606*cdf0e10cSrcweir xRow->appendBoolean( 607*cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsFolder" ), 608*cdf0e10cSrcweir -1, 609*cdf0e10cSrcweir getCppuBooleanType(), 610*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 611*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 612*cdf0e10cSrcweir rData.bIsFolder ); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir // @@@ Append other properties supported directly. 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir // @@@ Note: If your data source supports adding/removing 617*cdf0e10cSrcweir // properties, you should implement the interface 618*cdf0e10cSrcweir // XPropertyContainer by yourself and supply your own 619*cdf0e10cSrcweir // logic here. The base class uses the service 620*cdf0e10cSrcweir // "com.sun.star.ucb.Store" to maintain Additional Core 621*cdf0e10cSrcweir // properties. But using server functionality is preferred! 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir // Append all Additional Core Properties. 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet( 626*cdf0e10cSrcweir rProvider->getAdditionalPropertySet( rContentId, sal_False ), 627*cdf0e10cSrcweir uno::UNO_QUERY ); 628*cdf0e10cSrcweir xRow->appendPropertySet( xSet ); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() ); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir //========================================================================= 635*cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 636*cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 637*cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& /* xEnv */) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 640*cdf0e10cSrcweir return getPropertyValues( m_xSMgr, 641*cdf0e10cSrcweir rProperties, 642*cdf0e10cSrcweir m_aProps, 643*cdf0e10cSrcweir rtl::Reference< 644*cdf0e10cSrcweir ::ucbhelper::ContentProviderImplHelper >( 645*cdf0e10cSrcweir m_xProvider.get() ), 646*cdf0e10cSrcweir m_xIdentifier->getContentIdentifier() ); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir //========================================================================= 650*cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues( 651*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rValues, 652*cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& /* xEnv */) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( rValues.getLength() ); 657*cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); 658*cdf0e10cSrcweir sal_Int32 nChanged = 0; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir beans::PropertyChangeEvent aEvent; 661*cdf0e10cSrcweir aEvent.Source = static_cast< cppu::OWeakObject * >( this ); 662*cdf0e10cSrcweir aEvent.Further = sal_False; 663*cdf0e10cSrcweir // aEvent.PropertyName = 664*cdf0e10cSrcweir aEvent.PropertyHandle = -1; 665*cdf0e10cSrcweir // aEvent.OldValue = 666*cdf0e10cSrcweir // aEvent.NewValue = 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir const beans::PropertyValue* pValues = rValues.getConstArray(); 669*cdf0e10cSrcweir sal_Int32 nCount = rValues.getLength(); 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet; 672*cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir const beans::PropertyValue& rValue = pValues[ n ]; 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir if ( rValue.Name.equalsAsciiL( 679*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir // Read-only property! 682*cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 683*cdf0e10cSrcweir rtl::OUString::createFromAscii( 684*cdf0e10cSrcweir "Property is read-only!" ), 685*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 688*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir // Read-only property! 691*cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 692*cdf0e10cSrcweir rtl::OUString::createFromAscii( 693*cdf0e10cSrcweir "Property is read-only!" ), 694*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 697*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir // Read-only property! 700*cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 701*cdf0e10cSrcweir rtl::OUString::createFromAscii( 702*cdf0e10cSrcweir "Property is read-only!" ), 703*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 706*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir rtl::OUString aNewValue; 709*cdf0e10cSrcweir if ( rValue.Value >>= aNewValue ) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir if ( aNewValue != m_aProps.aTitle ) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir aEvent.PropertyName = rValue.Name; 714*cdf0e10cSrcweir aEvent.OldValue = uno::makeAny( m_aProps.aTitle ); 715*cdf0e10cSrcweir aEvent.NewValue = uno::makeAny( aNewValue ); 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir m_aProps.aTitle = aNewValue; 720*cdf0e10cSrcweir nChanged++; 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir else 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir // Old value equals new value. No error! 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir else 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException( 730*cdf0e10cSrcweir rtl::OUString::createFromAscii( 731*cdf0e10cSrcweir "Property value has wrong type!" ), 732*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir // @@@ Process other properties supported directly. 737*cdf0e10cSrcweir #if 0 738*cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 739*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "xxxxxx" ) ) ) 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir #endif 743*cdf0e10cSrcweir else 744*cdf0e10cSrcweir { 745*cdf0e10cSrcweir // @@@ Note: If your data source supports adding/removing 746*cdf0e10cSrcweir // properties, you should implement the interface 747*cdf0e10cSrcweir // XPropertyContainer by yourself and supply your own 748*cdf0e10cSrcweir // logic here. The base class uses the service 749*cdf0e10cSrcweir // "com.sun.star.ucb.Store" to maintain Additional Core 750*cdf0e10cSrcweir // properties. But using server functionality is preferred! 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir xAdditionalPropSet = getAdditionalPropertySet( sal_False ); 757*cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir try 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir uno::Any aOldValue 765*cdf0e10cSrcweir = xAdditionalPropSet->getPropertyValue( rValue.Name ); 766*cdf0e10cSrcweir if ( aOldValue != rValue.Value ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir xAdditionalPropSet->setPropertyValue( 769*cdf0e10cSrcweir rValue.Name, rValue.Value ); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir aEvent.PropertyName = rValue.Name; 772*cdf0e10cSrcweir aEvent.OldValue = aOldValue; 773*cdf0e10cSrcweir aEvent.NewValue = rValue.Value; 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 776*cdf0e10cSrcweir nChanged++; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir else 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir // Old value equals new value. No error! 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir } 783*cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & e ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir aRet[ n ] <<= e; 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir catch ( lang::WrappedTargetException const & e ) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir aRet[ n ] <<= e; 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir catch ( beans::PropertyVetoException const & e ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir aRet[ n ] <<= e; 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & e ) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir aRet[ n ] <<= e; 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir else 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir aRet[ n ] <<= uno::Exception( 803*cdf0e10cSrcweir rtl::OUString::createFromAscii( 804*cdf0e10cSrcweir "No property set for storing the value!" ), 805*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir if ( nChanged > 0 ) 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir // @@@ Save changes. 813*cdf0e10cSrcweir // storeData(); 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir aGuard.clear(); 816*cdf0e10cSrcweir aChanges.realloc( nChanged ); 817*cdf0e10cSrcweir notifyPropertiesChange( aChanges ); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir return aRet; 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_INSERT 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir //========================================================================= 826*cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren ) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir // @@@ Adapt method to your URL scheme... 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir // Obtain a list with a snapshot of all currently instanciated contents 831*cdf0e10cSrcweir // from provider and extract the contents which are direct children 832*cdf0e10cSrcweir // of this content. 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir ::ucbhelper::ContentRefList aAllContents; 835*cdf0e10cSrcweir m_xProvider->queryExistingContents( aAllContents ); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir ::rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 838*cdf0e10cSrcweir sal_Int32 nPos = aURL.lastIndexOf( '/' ); 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir if ( nPos != ( aURL.getLength() - 1 ) ) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir // No trailing slash found. Append. 843*cdf0e10cSrcweir aURL += ::rtl::OUString::createFromAscii( "/" ); 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir sal_Int32 nLen = aURL.getLength(); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin(); 849*cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end(); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir while ( it != end ) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir ::ucbhelper::ContentImplHelperRef xChild = (*it); 854*cdf0e10cSrcweir ::rtl::OUString aChildURL 855*cdf0e10cSrcweir = xChild->getIdentifier()->getContentIdentifier(); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // Is aURL a prefix of aChildURL? 858*cdf0e10cSrcweir if ( ( aChildURL.getLength() > nLen ) && 859*cdf0e10cSrcweir ( aChildURL.compareTo( aURL, nLen ) == 0 ) ) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir nPos = aChildURL.indexOf( '/', nLen ); 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir if ( ( nPos == -1 ) || 864*cdf0e10cSrcweir ( nPos == ( aChildURL.getLength() - 1 ) ) ) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir // No further slashes / only a final slash. It's a child! 867*cdf0e10cSrcweir rChildren.push_back( 868*cdf0e10cSrcweir ContentRef( 869*cdf0e10cSrcweir static_cast< Content * >( xChild.get() ) ) ); 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir ++it; 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir //========================================================================= 877*cdf0e10cSrcweir void Content::insert( 878*cdf0e10cSrcweir const uno::Reference< io::XInputStream > & xInputStream, 879*cdf0e10cSrcweir sal_Bool bReplaceExisting, 880*cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 881*cdf0e10cSrcweir throw( uno::Exception ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir // Check, if all required properties were set. 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir #if 0 888*cdf0e10cSrcweir // @@@ add checks for property presence 889*cdf0e10cSrcweir if ( m_aProps.xxxx == yyyyy ) 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::insert - property value missing!" ); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir uno::Sequence< rtl::OUString > aProps( 1 ); 894*cdf0e10cSrcweir aProps[ 0 ] = rtl::OUString::createFromAscii( "zzzz" ); 895*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 896*cdf0e10cSrcweir uno::makeAny( ucb::MissingPropertiesException( 897*cdf0e10cSrcweir rtl::OUString(), 898*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 899*cdf0e10cSrcweir aProps ) ), 900*cdf0e10cSrcweir Environment ); 901*cdf0e10cSrcweir // Unreachable 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir #endif 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir bool bNeedInputStream = true; // @@@ adjust to real requirements 906*cdf0e10cSrcweir if ( bNeedInputStream && !xInputStream.is() ) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::insert - No data stream!" ); 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir ::ucbhelper::cancelCommandExecution( 911*cdf0e10cSrcweir uno::makeAny( ucb::MissingInputStreamException( 912*cdf0e10cSrcweir rtl::OUString(), 913*cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 914*cdf0e10cSrcweir Environment ); 915*cdf0e10cSrcweir // Unreachable 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir // Assemble new content identifier... 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId /* @@@ create content identifier */; 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir // Fail, if a resource with given id already exists. 923*cdf0e10cSrcweir if ( !bReplaceExisting /*&& hasData( xId ) @@@ impl for hasData() */ ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir uno::Any aProps 926*cdf0e10cSrcweir = uno::makeAny( beans::PropertyValue( 927*cdf0e10cSrcweir rtl::OUString( 928*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "Uri" ) ), 929*cdf0e10cSrcweir -1, 930*cdf0e10cSrcweir uno::makeAny( xId->getContentIdentifier() ), 931*cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE ) ); 932*cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 933*cdf0e10cSrcweir ucb::IOErrorCode_ALREADY_EXISTING, 934*cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 935*cdf0e10cSrcweir Environment, 936*cdf0e10cSrcweir rtl::OUString::createFromAscii( "content already existing!!" ), 937*cdf0e10cSrcweir this ); 938*cdf0e10cSrcweir // Unreachable 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir m_xIdentifier = xId; 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir // @@@ 944*cdf0e10cSrcweir // storeData(); 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir aGuard.clear(); 947*cdf0e10cSrcweir inserted(); 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_INSERT 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir #ifdef IMPLEMENT_COMMAND_DELETE 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir //========================================================================= 955*cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical ) 956*cdf0e10cSrcweir throw( uno::Exception ) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir // @@@ take care about bDeletePhysical -> trashcan support 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir deleted(); 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir // Process instanciated children... 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir ContentRefList aChildren; 969*cdf0e10cSrcweir queryChildren( aChildren ); 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin(); 972*cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end(); 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir while ( it != end ) 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir (*it)->destroy( bDeletePhysical ); 977*cdf0e10cSrcweir ++it; 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir #endif // IMPLEMENT_COMMAND_DELETE 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir 984