12f86921cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32f86921cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42f86921cSAndrew Rist * or more contributor license agreements. See the NOTICE file 52f86921cSAndrew Rist * distributed with this work for additional information 62f86921cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 72f86921cSAndrew Rist * to you under the Apache License, Version 2.0 (the 82f86921cSAndrew Rist * "License"); you may not use this file except in compliance 92f86921cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112f86921cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132f86921cSAndrew Rist * Unless required by applicable law or agreed to in writing, 142f86921cSAndrew Rist * software distributed under the License is distributed on an 152f86921cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162f86921cSAndrew Rist * KIND, either express or implied. See the License for the 172f86921cSAndrew Rist * specific language governing permissions and limitations 182f86921cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 202f86921cSAndrew Rist *************************************************************/ 212f86921cSAndrew Rist 222f86921cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_ucb.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /************************************************************************** 28cdf0e10cSrcweir TODO 29cdf0e10cSrcweir ************************************************************************** 30cdf0e10cSrcweir 31cdf0e10cSrcweir *************************************************************************/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "osl/diagnose.h" 34cdf0e10cSrcweir #include "osl/doublecheckedlocking.h" 35cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "com/sun/star/beans/PropertyAttribute.hpp" 38cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp" 39cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp" 40cdf0e10cSrcweir #include "com/sun/star/embed/ElementModes.hpp" 41cdf0e10cSrcweir #include "com/sun/star/embed/XStorage.hpp" 42cdf0e10cSrcweir #include "com/sun/star/embed/XTransactedObject.hpp" 43cdf0e10cSrcweir #include "com/sun/star/io/XActiveDataSink.hpp" 44cdf0e10cSrcweir #include "com/sun/star/io/XActiveDataStreamer.hpp" 45cdf0e10cSrcweir #include "com/sun/star/lang/IllegalAccessException.hpp" 46cdf0e10cSrcweir #include "com/sun/star/sdbc/XRow.hpp" 47cdf0e10cSrcweir #include "com/sun/star/ucb/ContentAction.hpp" 48cdf0e10cSrcweir #include "com/sun/star/ucb/ContentInfoAttribute.hpp" 49cdf0e10cSrcweir #include "com/sun/star/ucb/InsertCommandArgument.hpp" 50cdf0e10cSrcweir #include "com/sun/star/ucb/InteractiveBadTransferURLException.hpp" 51cdf0e10cSrcweir #include "com/sun/star/ucb/MissingInputStreamException.hpp" 52cdf0e10cSrcweir #include "com/sun/star/ucb/MissingPropertiesException.hpp" 53cdf0e10cSrcweir #include "com/sun/star/ucb/NameClash.hpp" 54cdf0e10cSrcweir #include "com/sun/star/ucb/NameClashException.hpp" 55cdf0e10cSrcweir #include "com/sun/star/ucb/OpenCommandArgument2.hpp" 56cdf0e10cSrcweir #include "com/sun/star/ucb/OpenMode.hpp" 57cdf0e10cSrcweir #include "com/sun/star/ucb/TransferInfo.hpp" 58cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedCommandException.hpp" 59cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedDataSinkException.hpp" 60cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedNameClashException.hpp" 61cdf0e10cSrcweir #include "com/sun/star/ucb/UnsupportedOpenModeException.hpp" 62cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandInfo.hpp" 63cdf0e10cSrcweir #include "com/sun/star/ucb/XPersistentPropertySet.hpp" 64cdf0e10cSrcweir 65cdf0e10cSrcweir #include "ucbhelper/cancelcommandexecution.hxx" 66cdf0e10cSrcweir #include "ucbhelper/contentidentifier.hxx" 67cdf0e10cSrcweir #include "ucbhelper/propertyvalueset.hxx" 68cdf0e10cSrcweir 69cdf0e10cSrcweir #include "tdoc_content.hxx" 70cdf0e10cSrcweir #include "tdoc_resultset.hxx" 71cdf0e10cSrcweir #include "tdoc_passwordrequest.hxx" 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include "../inc/urihelper.hxx" 74cdf0e10cSrcweir 75cdf0e10cSrcweir using namespace com::sun::star; 76cdf0e10cSrcweir using namespace tdoc_ucp; 77cdf0e10cSrcweir 78cdf0e10cSrcweir //========================================================================= 79cdf0e10cSrcweir static ContentType lcl_getContentType( const rtl::OUString & rType ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if ( rType.equalsAsciiL( 82cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_ROOT_CONTENT_TYPE ) ) ) 83cdf0e10cSrcweir return ROOT; 84cdf0e10cSrcweir else if ( rType.equalsAsciiL( 85cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_DOCUMENT_CONTENT_TYPE ) ) ) 86cdf0e10cSrcweir return DOCUMENT; 87cdf0e10cSrcweir else if ( rType.equalsAsciiL( 88cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_FOLDER_CONTENT_TYPE ) ) ) 89cdf0e10cSrcweir return FOLDER; 90cdf0e10cSrcweir else if ( rType.equalsAsciiL( 91cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_STREAM_CONTENT_TYPE ) ) ) 92cdf0e10cSrcweir return STREAM; 93cdf0e10cSrcweir else 94cdf0e10cSrcweir { 95cdf0e10cSrcweir OSL_ENSURE( sal_False, 96cdf0e10cSrcweir "Content::Content - unsupported content type string" ); 97cdf0e10cSrcweir return STREAM; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir //========================================================================= 102cdf0e10cSrcweir //========================================================================= 103cdf0e10cSrcweir // 104cdf0e10cSrcweir // Content Implementation. 105cdf0e10cSrcweir // 106cdf0e10cSrcweir //========================================================================= 107cdf0e10cSrcweir //========================================================================= 108cdf0e10cSrcweir 109cdf0e10cSrcweir // static ( "virtual" ctor ) 110cdf0e10cSrcweir Content* Content::create( 111cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 112cdf0e10cSrcweir ContentProvider* pProvider, 113cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir // Fail, if resource does not exist. 116cdf0e10cSrcweir ContentProperties aProps; 117cdf0e10cSrcweir if ( !Content::loadData( pProvider, 118cdf0e10cSrcweir Uri( Identifier->getContentIdentifier() ), 119cdf0e10cSrcweir aProps ) ) 120cdf0e10cSrcweir return 0; 121cdf0e10cSrcweir 122cdf0e10cSrcweir return new Content( rxSMgr, pProvider, Identifier, aProps ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir //========================================================================= 126cdf0e10cSrcweir // static ( "virtual" ctor ) 127cdf0e10cSrcweir Content* Content::create( 128cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 129cdf0e10cSrcweir ContentProvider* pProvider, 130cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 131cdf0e10cSrcweir const ucb::ContentInfo& Info ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir if ( !Info.Type.getLength() ) 134cdf0e10cSrcweir return 0; 135cdf0e10cSrcweir 136cdf0e10cSrcweir if ( !Info.Type.equalsAsciiL( 137cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_FOLDER_CONTENT_TYPE ) ) && 138cdf0e10cSrcweir !Info.Type.equalsAsciiL( 139cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_STREAM_CONTENT_TYPE ) ) ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::create - unsupported content type!" ); 142cdf0e10cSrcweir return 0; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir #if 0 146cdf0e10cSrcweir // Fail, if content does exist. 147cdf0e10cSrcweir if ( Content::hasData( pProvider, 148cdf0e10cSrcweir Uri( Identifier->getContentIdentifier() ) ) ) 149cdf0e10cSrcweir return 0; 150cdf0e10cSrcweir #endif 151cdf0e10cSrcweir 152cdf0e10cSrcweir return new Content( rxSMgr, pProvider, Identifier, Info ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir //========================================================================= 156cdf0e10cSrcweir Content::Content( 157cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & rxSMgr, 158cdf0e10cSrcweir ContentProvider * pProvider, 159cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier > & Identifier, 160cdf0e10cSrcweir const ContentProperties & rProps ) 161cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 162cdf0e10cSrcweir m_aProps( rProps ), 163cdf0e10cSrcweir m_eState( PERSISTENT ), 164cdf0e10cSrcweir m_pProvider( pProvider ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir //========================================================================= 169cdf0e10cSrcweir // ctor for a content just created via XContentCreator::createNewContent() 170cdf0e10cSrcweir Content::Content( 171cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 172cdf0e10cSrcweir ContentProvider* pProvider, 173cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 174cdf0e10cSrcweir const ucb::ContentInfo& Info ) 175cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 176cdf0e10cSrcweir m_aProps( lcl_getContentType( Info.Type ), rtl::OUString() ), // no Title (yet) 177cdf0e10cSrcweir m_eState( TRANSIENT ), 178cdf0e10cSrcweir m_pProvider( pProvider ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir //========================================================================= 183cdf0e10cSrcweir // virtual 184cdf0e10cSrcweir Content::~Content() 185cdf0e10cSrcweir { 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir //========================================================================= 189cdf0e10cSrcweir // 190cdf0e10cSrcweir // XInterface methods. 191cdf0e10cSrcweir // 192cdf0e10cSrcweir //========================================================================= 193cdf0e10cSrcweir 194cdf0e10cSrcweir // virtual 195cdf0e10cSrcweir void SAL_CALL Content::acquire() 196cdf0e10cSrcweir throw( ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir ContentImplHelper::acquire(); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir //========================================================================= 202cdf0e10cSrcweir // virtual 203cdf0e10cSrcweir void SAL_CALL Content::release() 204cdf0e10cSrcweir throw( ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir ContentImplHelper::release(); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir //========================================================================= 210cdf0e10cSrcweir // virtual 211cdf0e10cSrcweir uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) 212cdf0e10cSrcweir throw ( uno::RuntimeException ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir uno::Any aRet = ContentImplHelper::queryInterface( rType ); 215cdf0e10cSrcweir 216cdf0e10cSrcweir if ( !aRet.hasValue() ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir aRet = cppu::queryInterface( 219cdf0e10cSrcweir rType, static_cast< ucb::XContentCreator * >( this ) ); 220cdf0e10cSrcweir if ( aRet.hasValue() ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if ( !m_aProps.isContentCreator() ) 223cdf0e10cSrcweir return uno::Any(); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir return aRet; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir //========================================================================= 231cdf0e10cSrcweir // 232cdf0e10cSrcweir // XTypeProvider methods. 233cdf0e10cSrcweir // 234cdf0e10cSrcweir //========================================================================= 235cdf0e10cSrcweir 236cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( Content ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir //========================================================================= 239cdf0e10cSrcweir // virtual 240cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL Content::getTypes() 241cdf0e10cSrcweir throw( uno::RuntimeException ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir cppu::OTypeCollection * pCollection = 0; 244cdf0e10cSrcweir 245cdf0e10cSrcweir if ( m_aProps.isContentCreator() ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir static cppu::OTypeCollection* pFolderTypes = 0; 248cdf0e10cSrcweir 249cdf0e10cSrcweir pCollection = pFolderTypes; 250cdf0e10cSrcweir if ( !pCollection ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir pCollection = pFolderTypes; 255cdf0e10cSrcweir if ( !pCollection ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 258cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 259cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 260cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 261cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 262cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 263cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 264cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 265cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 266cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 267cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ), 268cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContentCreator ) ); // !! 269cdf0e10cSrcweir pCollection = &aCollection; 270cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 271cdf0e10cSrcweir pFolderTypes = pCollection; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir } 274cdf0e10cSrcweir else { 275cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir else 279cdf0e10cSrcweir { 280cdf0e10cSrcweir static cppu::OTypeCollection* pDocumentTypes = 0; 281cdf0e10cSrcweir 282cdf0e10cSrcweir pCollection = pDocumentTypes; 283cdf0e10cSrcweir if ( !pCollection ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir pCollection = pDocumentTypes; 288cdf0e10cSrcweir if ( !pCollection ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 291cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 292cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 293cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 294cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 295cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 296cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 297cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 298cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 299cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 300cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ) ); 301cdf0e10cSrcweir pCollection = &aCollection; 302cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 303cdf0e10cSrcweir pDocumentTypes = pCollection; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir else { 307cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir return (*pCollection).getTypes(); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir //========================================================================= 315cdf0e10cSrcweir // 316cdf0e10cSrcweir // XServiceInfo methods. 317cdf0e10cSrcweir // 318cdf0e10cSrcweir //========================================================================= 319cdf0e10cSrcweir 320cdf0e10cSrcweir // virtual 321cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getImplementationName() 322cdf0e10cSrcweir throw( uno::RuntimeException ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir return rtl::OUString::createFromAscii( 325cdf0e10cSrcweir "com.sun.star.comp.ucb.TransientDocumentsContent" ); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir //========================================================================= 329cdf0e10cSrcweir // virtual 330cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL Content::getSupportedServiceNames() 331cdf0e10cSrcweir throw( uno::RuntimeException ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 334cdf0e10cSrcweir 335cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 ); 336cdf0e10cSrcweir 337cdf0e10cSrcweir if ( m_aProps.getType() == STREAM ) 338cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 339cdf0e10cSrcweir TDOC_STREAM_CONTENT_SERVICE_NAME ); 340cdf0e10cSrcweir else if ( m_aProps.getType() == FOLDER ) 341cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 342cdf0e10cSrcweir TDOC_FOLDER_CONTENT_SERVICE_NAME ); 343cdf0e10cSrcweir else if ( m_aProps.getType() == DOCUMENT ) 344cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 345cdf0e10cSrcweir TDOC_DOCUMENT_CONTENT_SERVICE_NAME ); 346cdf0e10cSrcweir else 347cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 348cdf0e10cSrcweir TDOC_ROOT_CONTENT_SERVICE_NAME ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir return aSNS; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir //========================================================================= 354cdf0e10cSrcweir // 355cdf0e10cSrcweir // XContent methods. 356cdf0e10cSrcweir // 357cdf0e10cSrcweir //========================================================================= 358cdf0e10cSrcweir 359cdf0e10cSrcweir // virtual 360cdf0e10cSrcweir rtl::OUString SAL_CALL Content::getContentType() 361cdf0e10cSrcweir throw( uno::RuntimeException ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 364cdf0e10cSrcweir return m_aProps.getContentType(); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir //========================================================================= 368cdf0e10cSrcweir // virtual 369cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > SAL_CALL 370cdf0e10cSrcweir Content::getIdentifier() 371cdf0e10cSrcweir throw( uno::RuntimeException ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir { 374cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 375cdf0e10cSrcweir 376cdf0e10cSrcweir // Transient? 377cdf0e10cSrcweir if ( m_eState == TRANSIENT ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir // Transient contents have no identifier. 380cdf0e10cSrcweir return uno::Reference< ucb::XContentIdentifier >(); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir } 383cdf0e10cSrcweir return ContentImplHelper::getIdentifier(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir //========================================================================= 387cdf0e10cSrcweir // 388cdf0e10cSrcweir // XCommandProcessor methods. 389cdf0e10cSrcweir // 390cdf0e10cSrcweir //========================================================================= 391cdf0e10cSrcweir 392cdf0e10cSrcweir // virtual 393cdf0e10cSrcweir uno::Any SAL_CALL Content::execute( 394cdf0e10cSrcweir const ucb::Command& aCommand, 395cdf0e10cSrcweir sal_Int32 /*CommandId*/, 396cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 397cdf0e10cSrcweir throw( uno::Exception, 398cdf0e10cSrcweir ucb::CommandAbortedException, 399cdf0e10cSrcweir uno::RuntimeException ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir uno::Any aRet; 402cdf0e10cSrcweir 403cdf0e10cSrcweir if ( aCommand.Name.equalsAsciiL( 404cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 407cdf0e10cSrcweir // getPropertyValues 408cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 409cdf0e10cSrcweir 410cdf0e10cSrcweir uno::Sequence< beans::Property > Properties; 411cdf0e10cSrcweir if ( !( aCommand.Argument >>= Properties ) ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 414cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 415cdf0e10cSrcweir rtl::OUString::createFromAscii( 416cdf0e10cSrcweir "Wrong argument type!" ), 417cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 418cdf0e10cSrcweir -1 ) ), 419cdf0e10cSrcweir Environment ); 420cdf0e10cSrcweir // Unreachable 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir aRet <<= getPropertyValues( Properties ); 424cdf0e10cSrcweir } 425cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 426cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 429cdf0e10cSrcweir // setPropertyValues 430cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 431cdf0e10cSrcweir 432cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 433cdf0e10cSrcweir if ( !( aCommand.Argument >>= aProperties ) ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 436cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 437cdf0e10cSrcweir rtl::OUString::createFromAscii( 438cdf0e10cSrcweir "Wrong argument type!" ), 439cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 440cdf0e10cSrcweir -1 ) ), 441cdf0e10cSrcweir Environment ); 442cdf0e10cSrcweir // Unreachable 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir if ( !aProperties.getLength() ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 448cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 449cdf0e10cSrcweir rtl::OUString::createFromAscii( 450cdf0e10cSrcweir "No properties!" ), 451cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 452cdf0e10cSrcweir -1 ) ), 453cdf0e10cSrcweir Environment ); 454cdf0e10cSrcweir // Unreachable 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457cdf0e10cSrcweir aRet <<= setPropertyValues( aProperties, Environment ); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 460cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 463cdf0e10cSrcweir // getPropertySetInfo 464cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 465cdf0e10cSrcweir 466cdf0e10cSrcweir aRet <<= getPropertySetInfo( Environment ); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 469cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 472cdf0e10cSrcweir // getCommandInfo 473cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 474cdf0e10cSrcweir 475cdf0e10cSrcweir aRet <<= getCommandInfo( Environment ); 476cdf0e10cSrcweir } 477cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 478cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "open" ) ) ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 481cdf0e10cSrcweir // open 482cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 483cdf0e10cSrcweir 484cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenCommand; 485cdf0e10cSrcweir if ( !( aCommand.Argument >>= aOpenCommand ) ) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 488cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 489cdf0e10cSrcweir rtl::OUString::createFromAscii( 490cdf0e10cSrcweir "Wrong argument type!" ), 491cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 492cdf0e10cSrcweir -1 ) ), 493cdf0e10cSrcweir Environment ); 494cdf0e10cSrcweir // Unreachable 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir aRet = open( aOpenCommand, Environment ); 498cdf0e10cSrcweir } 499cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 500cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 503cdf0e10cSrcweir // insert ( Supported by folders and streams only ) 504cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 505cdf0e10cSrcweir 506cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 507cdf0e10cSrcweir if ( ( eType != FOLDER ) && ( eType != STREAM ) ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 510cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 511cdf0e10cSrcweir rtl::OUString( 512cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 513cdf0e10cSrcweir "insert command only supported by " 514cdf0e10cSrcweir "folders and streams!" ) ), 515cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 516cdf0e10cSrcweir Environment ); 517cdf0e10cSrcweir // Unreachable 518cdf0e10cSrcweir } 519cdf0e10cSrcweir 520cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 521cdf0e10cSrcweir if ( eType == STREAM ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 524cdf0e10cSrcweir Uri aParentUri( aUri.getParentUri() ); 525cdf0e10cSrcweir if ( aParentUri.isDocument() ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 528cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 529cdf0e10cSrcweir rtl::OUString( 530cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 531cdf0e10cSrcweir "insert command not supported by " 532cdf0e10cSrcweir "streams that are direct children " 533cdf0e10cSrcweir "of document root!" ) ), 534cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( 535cdf0e10cSrcweir this ) ) ), 536cdf0e10cSrcweir Environment ); 537cdf0e10cSrcweir // Unreachable 538cdf0e10cSrcweir } 539cdf0e10cSrcweir } 540cdf0e10cSrcweir #endif 541cdf0e10cSrcweir ucb::InsertCommandArgument aArg; 542cdf0e10cSrcweir if ( !( aCommand.Argument >>= aArg ) ) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 545cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 546cdf0e10cSrcweir rtl::OUString::createFromAscii( 547cdf0e10cSrcweir "Wrong argument type!" ), 548cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 549cdf0e10cSrcweir -1 ) ), 550cdf0e10cSrcweir Environment ); 551cdf0e10cSrcweir // Unreachable 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir sal_Int32 nNameClash = aArg.ReplaceExisting 555cdf0e10cSrcweir ? ucb::NameClash::OVERWRITE 556cdf0e10cSrcweir : ucb::NameClash::ERROR; 557cdf0e10cSrcweir insert( aArg.Data, nNameClash, Environment ); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 560cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 563cdf0e10cSrcweir // delete ( Supported by folders and streams only ) 564cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 565cdf0e10cSrcweir 566cdf0e10cSrcweir { 567cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 568cdf0e10cSrcweir 569cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 570cdf0e10cSrcweir if ( ( eType != FOLDER ) && ( eType != STREAM ) ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 573cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 574cdf0e10cSrcweir rtl::OUString( 575cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 576cdf0e10cSrcweir "delete command only supported by " 577cdf0e10cSrcweir "folders and streams!" ) ), 578cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( 579cdf0e10cSrcweir this ) ) ), 580cdf0e10cSrcweir Environment ); 581cdf0e10cSrcweir // Unreachable 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir sal_Bool bDeletePhysical = sal_False; 586cdf0e10cSrcweir aCommand.Argument >>= bDeletePhysical; 587cdf0e10cSrcweir destroy( bDeletePhysical, Environment ); 588cdf0e10cSrcweir 589cdf0e10cSrcweir // Remove own and all children's persistent data. 590cdf0e10cSrcweir if ( !removeData() ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir uno::Any aProps 593cdf0e10cSrcweir = uno::makeAny( 594cdf0e10cSrcweir beans::PropertyValue( 595cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 596cdf0e10cSrcweir "Uri")), 597cdf0e10cSrcweir -1, 598cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 599cdf0e10cSrcweir getContentIdentifier()), 600cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 601cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 602cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 603cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 604cdf0e10cSrcweir Environment, 605cdf0e10cSrcweir rtl::OUString::createFromAscii( 606cdf0e10cSrcweir "Cannot remove persistent data!" ), 607cdf0e10cSrcweir this ); 608cdf0e10cSrcweir // Unreachable 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 612cdf0e10cSrcweir removeAdditionalPropertySet( sal_True ); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 615cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) ) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 618cdf0e10cSrcweir // transfer ( Supported by document and folders only ) 619cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 620cdf0e10cSrcweir 621cdf0e10cSrcweir { 622cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 623cdf0e10cSrcweir 624cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 625cdf0e10cSrcweir if ( ( eType != FOLDER ) && ( eType != DOCUMENT ) ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 628cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 629cdf0e10cSrcweir rtl::OUString( 630cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 631cdf0e10cSrcweir "transfer command only supported " 632cdf0e10cSrcweir "by folders and documents!" ) ), 633cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( 634cdf0e10cSrcweir this ) ) ), 635cdf0e10cSrcweir Environment ); 636cdf0e10cSrcweir // Unreachable 637cdf0e10cSrcweir } 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir ucb::TransferInfo aInfo; 641cdf0e10cSrcweir if ( !( aCommand.Argument >>= aInfo ) ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 644cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 645cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 646cdf0e10cSrcweir rtl::OUString::createFromAscii( 647cdf0e10cSrcweir "Wrong argument type!" ), 648cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 649cdf0e10cSrcweir -1 ) ), 650cdf0e10cSrcweir Environment ); 651cdf0e10cSrcweir // Unreachable 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir transfer( aInfo, Environment ); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 657cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 660cdf0e10cSrcweir // createNewContent ( Supported by document and folders only ) 661cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 662cdf0e10cSrcweir 663cdf0e10cSrcweir { 664cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 665cdf0e10cSrcweir 666cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 667cdf0e10cSrcweir if ( ( eType != FOLDER ) && ( eType != DOCUMENT ) ) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 670cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 671cdf0e10cSrcweir rtl::OUString( 672cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 673cdf0e10cSrcweir "createNewContent command only " 674cdf0e10cSrcweir "supported by folders and " 675cdf0e10cSrcweir "documents!" ) ), 676cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( 677cdf0e10cSrcweir this ) ) ), 678cdf0e10cSrcweir Environment ); 679cdf0e10cSrcweir // Unreachable 680cdf0e10cSrcweir } 681cdf0e10cSrcweir } 682cdf0e10cSrcweir 683cdf0e10cSrcweir ucb::ContentInfo aInfo; 684cdf0e10cSrcweir if ( !( aCommand.Argument >>= aInfo ) ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 687cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 688cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 689cdf0e10cSrcweir rtl::OUString::createFromAscii( 690cdf0e10cSrcweir "Wrong argument type!" ), 691cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 692cdf0e10cSrcweir -1 ) ), 693cdf0e10cSrcweir Environment ); 694cdf0e10cSrcweir // Unreachable 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir aRet <<= createNewContent( aInfo ); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir else 700cdf0e10cSrcweir { 701cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 702cdf0e10cSrcweir // Unsupported command 703cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 704cdf0e10cSrcweir 705cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 706cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 707cdf0e10cSrcweir rtl::OUString(), 708cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 709cdf0e10cSrcweir Environment ); 710cdf0e10cSrcweir // Unreachable 711cdf0e10cSrcweir } 712cdf0e10cSrcweir 713cdf0e10cSrcweir return aRet; 714cdf0e10cSrcweir } 715cdf0e10cSrcweir 716cdf0e10cSrcweir //========================================================================= 717cdf0e10cSrcweir // virtual 718cdf0e10cSrcweir void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ ) 719cdf0e10cSrcweir throw( uno::RuntimeException ) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir //========================================================================= 724cdf0e10cSrcweir // 725cdf0e10cSrcweir // XContentCreator methods. 726cdf0e10cSrcweir // 727cdf0e10cSrcweir //========================================================================= 728cdf0e10cSrcweir 729cdf0e10cSrcweir // virtual 730cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > SAL_CALL 731cdf0e10cSrcweir Content::queryCreatableContentsInfo() 732cdf0e10cSrcweir throw( uno::RuntimeException ) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir return m_aProps.getCreatableContentsInfo(); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir 737cdf0e10cSrcweir //========================================================================= 738cdf0e10cSrcweir // virtual 739cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL 740cdf0e10cSrcweir Content::createNewContent( const ucb::ContentInfo& Info ) 741cdf0e10cSrcweir throw( uno::RuntimeException ) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir if ( m_aProps.isContentCreator() ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 746cdf0e10cSrcweir 747cdf0e10cSrcweir if ( !Info.Type.getLength() ) 748cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 749cdf0e10cSrcweir 750cdf0e10cSrcweir sal_Bool bCreateFolder = 751cdf0e10cSrcweir Info.Type.equalsAsciiL( 752cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_FOLDER_CONTENT_TYPE ) ); 753cdf0e10cSrcweir 754cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 755cdf0e10cSrcweir // streams cannot be created as direct children of document root 756cdf0e10cSrcweir if ( !bCreateFolder && ( m_aProps.getType() == DOCUMENT ) ) 757cdf0e10cSrcweir { 758cdf0e10cSrcweir OSL_ENSURE( sal_False, 759cdf0e10cSrcweir "Content::createNewContent - streams cannot be " 760cdf0e10cSrcweir "created as direct children of document root!" ); 761cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir #endif 764cdf0e10cSrcweir if ( !bCreateFolder && 765cdf0e10cSrcweir !Info.Type.equalsAsciiL( 766cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_STREAM_CONTENT_TYPE ) ) ) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir OSL_ENSURE( sal_False, 769cdf0e10cSrcweir "Content::createNewContent - unsupported type!" ); 770cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 771cdf0e10cSrcweir } 772cdf0e10cSrcweir 773cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 774cdf0e10cSrcweir 775cdf0e10cSrcweir OSL_ENSURE( aURL.getLength() > 0, 776cdf0e10cSrcweir "Content::createNewContent - empty identifier!" ); 777cdf0e10cSrcweir 778cdf0e10cSrcweir if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() ) 779cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 780cdf0e10cSrcweir 781cdf0e10cSrcweir if ( bCreateFolder ) 782cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Folder" ); 783cdf0e10cSrcweir else 784cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Stream" ); 785cdf0e10cSrcweir 786cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId 787cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL ); 788cdf0e10cSrcweir 789cdf0e10cSrcweir return create( m_xSMgr, m_pProvider, xId, Info ); 790cdf0e10cSrcweir } 791cdf0e10cSrcweir else 792cdf0e10cSrcweir { 793cdf0e10cSrcweir OSL_ENSURE( sal_False, 794cdf0e10cSrcweir "createNewContent called on non-contentcreator object!" ); 795cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 796cdf0e10cSrcweir } 797cdf0e10cSrcweir } 798cdf0e10cSrcweir 799cdf0e10cSrcweir //========================================================================= 800cdf0e10cSrcweir // virtual 801cdf0e10cSrcweir rtl::OUString Content::getParentURL() 802cdf0e10cSrcweir { 803cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 804cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 805cdf0e10cSrcweir return aUri.getParentUri(); 806cdf0e10cSrcweir } 807cdf0e10cSrcweir 808cdf0e10cSrcweir //========================================================================= 809cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > 810cdf0e10cSrcweir Content::makeNewIdentifier( const rtl::OUString& rTitle ) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 813cdf0e10cSrcweir 814cdf0e10cSrcweir // Assemble new content identifier... 815cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 816cdf0e10cSrcweir rtl::OUStringBuffer aNewURL = aUri.getParentUri(); 817cdf0e10cSrcweir aNewURL.append( ::ucb_impl::urihelper::encodeSegment( rTitle ) ); 818cdf0e10cSrcweir 819cdf0e10cSrcweir return 820cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier >( 821cdf0e10cSrcweir new ::ucbhelper::ContentIdentifier( 822cdf0e10cSrcweir m_xSMgr, aNewURL.makeStringAndClear() ) ); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir //========================================================================= 826cdf0e10cSrcweir void Content::queryChildren( ContentRefList& rChildren ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 829cdf0e10cSrcweir 830cdf0e10cSrcweir // Only folders (root, documents, folders) have children. 831cdf0e10cSrcweir if ( !m_aProps.getIsFolder() ) 832cdf0e10cSrcweir return; 833cdf0e10cSrcweir 834cdf0e10cSrcweir // Obtain a list with a snapshot of all currently instanciated contents 835cdf0e10cSrcweir // from provider and extract the contents which are direct children 836cdf0e10cSrcweir // of this content. 837cdf0e10cSrcweir 838cdf0e10cSrcweir ::ucbhelper::ContentRefList aAllContents; 839cdf0e10cSrcweir m_xProvider->queryExistingContents( aAllContents ); 840cdf0e10cSrcweir 841cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 842cdf0e10cSrcweir sal_Int32 nURLPos = aURL.lastIndexOf( '/' ); 843cdf0e10cSrcweir 844cdf0e10cSrcweir if ( nURLPos != ( aURL.getLength() - 1 ) ) 845cdf0e10cSrcweir { 846cdf0e10cSrcweir // No trailing slash found. Append. 847cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 848cdf0e10cSrcweir } 849cdf0e10cSrcweir 850cdf0e10cSrcweir sal_Int32 nLen = aURL.getLength(); 851cdf0e10cSrcweir 852cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin(); 853cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end(); 854cdf0e10cSrcweir 855cdf0e10cSrcweir while ( it != end ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir ::ucbhelper::ContentImplHelperRef xChild = (*it); 858cdf0e10cSrcweir rtl::OUString aChildURL 859cdf0e10cSrcweir = xChild->getIdentifier()->getContentIdentifier(); 860cdf0e10cSrcweir 861cdf0e10cSrcweir // Is aURL a prefix of aChildURL? 862cdf0e10cSrcweir if ( ( aChildURL.getLength() > nLen ) && 863cdf0e10cSrcweir ( aChildURL.compareTo( aURL, nLen ) == 0 ) ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir sal_Int32 nPos = nLen; 866cdf0e10cSrcweir nPos = aChildURL.indexOf( '/', nPos ); 867cdf0e10cSrcweir 868cdf0e10cSrcweir if ( ( nPos == -1 ) || 869cdf0e10cSrcweir ( nPos == ( aChildURL.getLength() - 1 ) ) ) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir // No further slashes / only a final slash. It's a child! 872cdf0e10cSrcweir rChildren.push_back( 873cdf0e10cSrcweir ContentRef( 874cdf0e10cSrcweir static_cast< Content * >( xChild.get() ) ) ); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir } 877cdf0e10cSrcweir ++it; 878cdf0e10cSrcweir } 879cdf0e10cSrcweir } 880cdf0e10cSrcweir 881cdf0e10cSrcweir //========================================================================= 882cdf0e10cSrcweir sal_Bool Content::exchangeIdentity( 883cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xNewId ) 884cdf0e10cSrcweir { 885cdf0e10cSrcweir if ( !xNewId.is() ) 886cdf0e10cSrcweir return sal_False; 887cdf0e10cSrcweir 888cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 889cdf0e10cSrcweir 890cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 891cdf0e10cSrcweir 892cdf0e10cSrcweir // Already persistent? 893cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 894cdf0e10cSrcweir { 895cdf0e10cSrcweir OSL_ENSURE( sal_False, 896cdf0e10cSrcweir "Content::exchangeIdentity - Not persistent!" ); 897cdf0e10cSrcweir return sal_False; 898cdf0e10cSrcweir } 899cdf0e10cSrcweir 900cdf0e10cSrcweir // Only folders and streams can be renamed -> exchange identity. 901cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 902cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir OSL_ENSURE( sal_False, "Content::exchangeIdentity - " 905cdf0e10cSrcweir "Not supported by root or document!" ); 906cdf0e10cSrcweir return sal_False; 907cdf0e10cSrcweir } 908cdf0e10cSrcweir 909cdf0e10cSrcweir // Exchange own identitity. 910cdf0e10cSrcweir 911cdf0e10cSrcweir // Fail, if a content with given id already exists. 912cdf0e10cSrcweir if ( !hasData( Uri( xNewId->getContentIdentifier() ) ) ) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier(); 915cdf0e10cSrcweir 916cdf0e10cSrcweir aGuard.clear(); 917cdf0e10cSrcweir if ( exchange( xNewId ) ) 918cdf0e10cSrcweir { 919cdf0e10cSrcweir if ( eType == FOLDER ) 920cdf0e10cSrcweir { 921cdf0e10cSrcweir // Process instanciated children... 922cdf0e10cSrcweir 923cdf0e10cSrcweir ContentRefList aChildren; 924cdf0e10cSrcweir queryChildren( aChildren ); 925cdf0e10cSrcweir 926cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin(); 927cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end(); 928cdf0e10cSrcweir 929cdf0e10cSrcweir while ( it != end ) 930cdf0e10cSrcweir { 931cdf0e10cSrcweir ContentRef xChild = (*it); 932cdf0e10cSrcweir 933cdf0e10cSrcweir // Create new content identifier for the child... 934cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldChildId 935cdf0e10cSrcweir = xChild->getIdentifier(); 936cdf0e10cSrcweir rtl::OUString aOldChildURL 937cdf0e10cSrcweir = xOldChildId->getContentIdentifier(); 938cdf0e10cSrcweir rtl::OUString aNewChildURL 939cdf0e10cSrcweir = aOldChildURL.replaceAt( 940cdf0e10cSrcweir 0, 941cdf0e10cSrcweir aOldURL.getLength(), 942cdf0e10cSrcweir xNewId->getContentIdentifier() ); 943cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewChildId 944cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( 945cdf0e10cSrcweir m_xSMgr, aNewChildURL ); 946cdf0e10cSrcweir 947cdf0e10cSrcweir if ( !xChild->exchangeIdentity( xNewChildId ) ) 948cdf0e10cSrcweir return sal_False; 949cdf0e10cSrcweir 950cdf0e10cSrcweir ++it; 951cdf0e10cSrcweir } 952cdf0e10cSrcweir } 953cdf0e10cSrcweir return sal_True; 954cdf0e10cSrcweir } 955cdf0e10cSrcweir } 956cdf0e10cSrcweir 957cdf0e10cSrcweir OSL_ENSURE( sal_False, 958cdf0e10cSrcweir "Content::exchangeIdentity - " 959cdf0e10cSrcweir "Panic! Cannot exchange identity!" ); 960cdf0e10cSrcweir return sal_False; 961cdf0e10cSrcweir } 962cdf0e10cSrcweir 963cdf0e10cSrcweir //========================================================================= 964cdf0e10cSrcweir // static 965cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 966cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr, 967cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 968cdf0e10cSrcweir ContentProvider* pProvider, 969cdf0e10cSrcweir const rtl::OUString& rContentId ) 970cdf0e10cSrcweir { 971cdf0e10cSrcweir ContentProperties aData; 972cdf0e10cSrcweir if ( loadData( pProvider, rContentId, aData ) ) 973cdf0e10cSrcweir { 974cdf0e10cSrcweir return getPropertyValues( 975cdf0e10cSrcweir rSMgr, rProperties, aData, pProvider, rContentId ); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir else 978cdf0e10cSrcweir { 979cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow 980cdf0e10cSrcweir = new ::ucbhelper::PropertyValueSet( rSMgr ); 981cdf0e10cSrcweir 982cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 983cdf0e10cSrcweir if ( nCount ) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir const beans::Property* pProps = rProperties.getConstArray(); 986cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 987cdf0e10cSrcweir xRow->appendVoid( pProps[ n ] ); 988cdf0e10cSrcweir } 989cdf0e10cSrcweir 990cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() ); 991cdf0e10cSrcweir } 992cdf0e10cSrcweir } 993cdf0e10cSrcweir 994cdf0e10cSrcweir //========================================================================= 995cdf0e10cSrcweir // static 996cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 997cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr, 998cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 999cdf0e10cSrcweir const ContentProperties& rData, 1000cdf0e10cSrcweir ContentProvider* pProvider, 1001cdf0e10cSrcweir const rtl::OUString& rContentId ) 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir // Note: Empty sequence means "get values of all supported properties". 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow 1006cdf0e10cSrcweir = new ::ucbhelper::PropertyValueSet( rSMgr ); 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 1009cdf0e10cSrcweir if ( nCount ) 1010cdf0e10cSrcweir { 1011cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xAdditionalPropSet; 1012cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir const beans::Property* pProps = rProperties.getConstArray(); 1015cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir // Process Core properties. 1020cdf0e10cSrcweir 1021cdf0e10cSrcweir if ( rProp.Name.equalsAsciiL( 1022cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir xRow->appendString ( rProp, rData.getContentType() ); 1025cdf0e10cSrcweir } 1026cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1027cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir xRow->appendString ( rProp, rData.getTitle() ); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1032cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.getIsDocument() ); 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1037cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 1038cdf0e10cSrcweir { 1039cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.getIsFolder() ); 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1042cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1043cdf0e10cSrcweir { 1044cdf0e10cSrcweir xRow->appendObject( 1045cdf0e10cSrcweir rProp, uno::makeAny( rData.getCreatableContentsInfo() ) ); 1046cdf0e10cSrcweir } 1047cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1048cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Storage" ) ) ) 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir // Storage is only supported by folders. 1051cdf0e10cSrcweir ContentType eType = rData.getType(); 1052cdf0e10cSrcweir if ( eType == FOLDER ) 1053cdf0e10cSrcweir xRow->appendObject( 1054cdf0e10cSrcweir rProp, 1055cdf0e10cSrcweir uno::makeAny( 1056cdf0e10cSrcweir pProvider->queryStorageClone( rContentId ) ) ); 1057cdf0e10cSrcweir else 1058cdf0e10cSrcweir xRow->appendVoid( rProp ); 1059cdf0e10cSrcweir } 1060cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1061cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "DocumentModel" ) ) ) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir // DocumentModel is only supported by documents. 1064cdf0e10cSrcweir ContentType eType = rData.getType(); 1065cdf0e10cSrcweir if ( eType == DOCUMENT ) 1066cdf0e10cSrcweir xRow->appendObject( 1067cdf0e10cSrcweir rProp, 1068cdf0e10cSrcweir uno::makeAny( 1069cdf0e10cSrcweir pProvider->queryDocumentModel( rContentId ) ) ); 1070cdf0e10cSrcweir else 1071cdf0e10cSrcweir xRow->appendVoid( rProp ); 1072cdf0e10cSrcweir } 1073cdf0e10cSrcweir else 1074cdf0e10cSrcweir { 1075cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 1078cdf0e10cSrcweir { 1079cdf0e10cSrcweir xAdditionalPropSet 1080cdf0e10cSrcweir = uno::Reference< beans::XPropertySet >( 1081cdf0e10cSrcweir pProvider->getAdditionalPropertySet( rContentId, 1082cdf0e10cSrcweir sal_False ), 1083cdf0e10cSrcweir uno::UNO_QUERY ); 1084cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir if ( !xRow->appendPropertySetValue( 1090cdf0e10cSrcweir xAdditionalPropSet, 1091cdf0e10cSrcweir rProp ) ) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir // Append empty entry. 1094cdf0e10cSrcweir xRow->appendVoid( rProp ); 1095cdf0e10cSrcweir } 1096cdf0e10cSrcweir } 1097cdf0e10cSrcweir else 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir // Append empty entry. 1100cdf0e10cSrcweir xRow->appendVoid( rProp ); 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir else 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir // Append all Core Properties. 1108cdf0e10cSrcweir xRow->appendString ( 1109cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "ContentType" ), 1110cdf0e10cSrcweir -1, 1111cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1112cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1113cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1114cdf0e10cSrcweir rData.getContentType() ); 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir ContentType eType = rData.getType(); 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir xRow->appendString ( 1119cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "Title" ), 1120cdf0e10cSrcweir -1, 1121cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1122cdf0e10cSrcweir // Title is read-only for root and documents. 1123cdf0e10cSrcweir beans::PropertyAttribute::BOUND || 1124cdf0e10cSrcweir ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 1125cdf0e10cSrcweir ? beans::PropertyAttribute::READONLY 1126cdf0e10cSrcweir : 0 ), 1127cdf0e10cSrcweir rData.getTitle() ); 1128cdf0e10cSrcweir xRow->appendBoolean( 1129cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsDocument" ), 1130cdf0e10cSrcweir -1, 1131cdf0e10cSrcweir getCppuBooleanType(), 1132cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1133cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1134cdf0e10cSrcweir rData.getIsDocument() ); 1135cdf0e10cSrcweir xRow->appendBoolean( 1136cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsFolder" ), 1137cdf0e10cSrcweir -1, 1138cdf0e10cSrcweir getCppuBooleanType(), 1139cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1140cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1141cdf0e10cSrcweir rData.getIsFolder() ); 1142cdf0e10cSrcweir xRow->appendObject( 1143cdf0e10cSrcweir beans::Property( 1144cdf0e10cSrcweir rtl::OUString::createFromAscii( "CreatableContentsInfo" ), 1145cdf0e10cSrcweir -1, 1146cdf0e10cSrcweir getCppuType( static_cast< 1147cdf0e10cSrcweir const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 1148cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1149cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1150cdf0e10cSrcweir uno::makeAny( rData.getCreatableContentsInfo() ) ); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir // Storage is only supported by folders. 1153cdf0e10cSrcweir if ( eType == FOLDER ) 1154cdf0e10cSrcweir xRow->appendObject( 1155cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "Storage" ), 1156cdf0e10cSrcweir -1, 1157cdf0e10cSrcweir getCppuType( 1158cdf0e10cSrcweir static_cast< 1159cdf0e10cSrcweir const uno::Reference< embed::XStorage > * >( 0 ) ), 1160cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1161cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1162cdf0e10cSrcweir uno::makeAny( pProvider->queryStorageClone( rContentId ) ) ); 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir // DocumentModel is only supported by documents. 1165cdf0e10cSrcweir if ( eType == DOCUMENT ) 1166cdf0e10cSrcweir xRow->appendObject( 1167cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "DocumentModel" ), 1168cdf0e10cSrcweir -1, 1169cdf0e10cSrcweir getCppuType( 1170cdf0e10cSrcweir static_cast< 1171cdf0e10cSrcweir const uno::Reference< frame::XModel > * >( 0 ) ), 1172cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1173cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1174cdf0e10cSrcweir uno::makeAny( 1175cdf0e10cSrcweir pProvider->queryDocumentModel( rContentId ) ) ); 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir // Append all Additional Core Properties. 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet( 1180cdf0e10cSrcweir pProvider->getAdditionalPropertySet( rContentId, sal_False ), 1181cdf0e10cSrcweir uno::UNO_QUERY ); 1182cdf0e10cSrcweir xRow->appendPropertySet( xSet ); 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() ); 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir //========================================================================= 1189cdf0e10cSrcweir uno::Reference< sdbc::XRow > Content::getPropertyValues( 1190cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties ) 1191cdf0e10cSrcweir { 1192cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1193cdf0e10cSrcweir return getPropertyValues( m_xSMgr, 1194cdf0e10cSrcweir rProperties, 1195cdf0e10cSrcweir m_aProps, 1196cdf0e10cSrcweir m_pProvider, 1197cdf0e10cSrcweir m_xIdentifier->getContentIdentifier() ); 1198cdf0e10cSrcweir } 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir //========================================================================= 1201cdf0e10cSrcweir uno::Sequence< uno::Any > Content::setPropertyValues( 1202cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rValues, 1203cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 1204cdf0e10cSrcweir throw( uno::Exception ) 1205cdf0e10cSrcweir { 1206cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( rValues.getLength() ); 1209cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); 1210cdf0e10cSrcweir sal_Int32 nChanged = 0; 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir beans::PropertyChangeEvent aEvent; 1213cdf0e10cSrcweir aEvent.Source = static_cast< cppu::OWeakObject * >( this ); 1214cdf0e10cSrcweir aEvent.Further = sal_False; 1215cdf0e10cSrcweir // aEvent.PropertyName = 1216cdf0e10cSrcweir aEvent.PropertyHandle = -1; 1217cdf0e10cSrcweir // aEvent.OldValue = 1218cdf0e10cSrcweir // aEvent.NewValue = 1219cdf0e10cSrcweir 1220cdf0e10cSrcweir const beans::PropertyValue* pValues = rValues.getConstArray(); 1221cdf0e10cSrcweir sal_Int32 nCount = rValues.getLength(); 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet; 1224cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 1225cdf0e10cSrcweir 1226cdf0e10cSrcweir sal_Bool bExchange = sal_False; 1227cdf0e10cSrcweir rtl::OUString aOldTitle; 1228cdf0e10cSrcweir sal_Int32 nTitlePos = -1; 1229cdf0e10cSrcweir 1230cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir const beans::PropertyValue& rValue = pValues[ n ]; 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir if ( rValue.Name.equalsAsciiL( 1235cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 1236cdf0e10cSrcweir { 1237cdf0e10cSrcweir // Read-only property! 1238cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1239cdf0e10cSrcweir rtl::OUString::createFromAscii( 1240cdf0e10cSrcweir "Property is read-only!" ), 1241cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1242cdf0e10cSrcweir } 1243cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1244cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 1245cdf0e10cSrcweir { 1246cdf0e10cSrcweir // Read-only property! 1247cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1248cdf0e10cSrcweir rtl::OUString::createFromAscii( 1249cdf0e10cSrcweir "Property is read-only!" ), 1250cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1253cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir // Read-only property! 1256cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1257cdf0e10cSrcweir rtl::OUString::createFromAscii( 1258cdf0e10cSrcweir "Property is read-only!" ), 1259cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1260cdf0e10cSrcweir } 1261cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1262cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1263cdf0e10cSrcweir { 1264cdf0e10cSrcweir // Read-only property! 1265cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1266cdf0e10cSrcweir rtl::OUString::createFromAscii( 1267cdf0e10cSrcweir "Property is read-only!" ), 1268cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1271cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir // Title is read-only for root and documents. 1274cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 1275cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 1276cdf0e10cSrcweir { 1277cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1278cdf0e10cSrcweir rtl::OUString::createFromAscii( 1279cdf0e10cSrcweir "Property is read-only!" ), 1280cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1281cdf0e10cSrcweir } 1282cdf0e10cSrcweir else 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir rtl::OUString aNewValue; 1285cdf0e10cSrcweir if ( rValue.Value >>= aNewValue ) 1286cdf0e10cSrcweir { 1287cdf0e10cSrcweir // No empty titles! 1288cdf0e10cSrcweir if ( aNewValue.getLength() > 0 ) 1289cdf0e10cSrcweir { 1290cdf0e10cSrcweir if ( aNewValue != m_aProps.getTitle() ) 1291cdf0e10cSrcweir { 1292cdf0e10cSrcweir // modified title -> modified URL -> exchange ! 1293cdf0e10cSrcweir if ( m_eState == PERSISTENT ) 1294cdf0e10cSrcweir bExchange = sal_True; 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir aOldTitle = m_aProps.getTitle(); 1297cdf0e10cSrcweir m_aProps.setTitle( aNewValue ); 1298cdf0e10cSrcweir 1299cdf0e10cSrcweir // property change event will be sent later... 1300cdf0e10cSrcweir 1301cdf0e10cSrcweir // remember position within sequence of values 1302cdf0e10cSrcweir // (for error handling). 1303cdf0e10cSrcweir nTitlePos = n; 1304cdf0e10cSrcweir } 1305cdf0e10cSrcweir } 1306cdf0e10cSrcweir else 1307cdf0e10cSrcweir { 1308cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException( 1309cdf0e10cSrcweir rtl::OUString::createFromAscii( 1310cdf0e10cSrcweir "Empty Title not allowed!" ), 1311cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1312cdf0e10cSrcweir -1 ); 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir } 1315cdf0e10cSrcweir else 1316cdf0e10cSrcweir { 1317cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException( 1318cdf0e10cSrcweir rtl::OUString::createFromAscii( 1319cdf0e10cSrcweir "Title Property value has wrong type!" ), 1320cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir } 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1325cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Storage" ) ) ) 1326cdf0e10cSrcweir { 1327cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 1328cdf0e10cSrcweir if ( eType == FOLDER ) 1329cdf0e10cSrcweir { 1330cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1331cdf0e10cSrcweir rtl::OUString::createFromAscii( 1332cdf0e10cSrcweir "Property is read-only!" ), 1333cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1334cdf0e10cSrcweir } 1335cdf0e10cSrcweir else 1336cdf0e10cSrcweir { 1337cdf0e10cSrcweir // Storage is only supported by folders. 1338cdf0e10cSrcweir aRet[ n ] <<= beans::UnknownPropertyException( 1339cdf0e10cSrcweir rtl::OUString::createFromAscii( 1340cdf0e10cSrcweir "Storage property only supported by folders" ), 1341cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1342cdf0e10cSrcweir } 1343cdf0e10cSrcweir } 1344cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1345cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "DocumentModel" ) ) ) 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 1348cdf0e10cSrcweir if ( eType == DOCUMENT ) 1349cdf0e10cSrcweir { 1350cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1351cdf0e10cSrcweir rtl::OUString::createFromAscii( 1352cdf0e10cSrcweir "Property is read-only!" ), 1353cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir else 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir // Storage is only supported by folders. 1358cdf0e10cSrcweir aRet[ n ] <<= beans::UnknownPropertyException( 1359cdf0e10cSrcweir rtl::OUString::createFromAscii( 1360cdf0e10cSrcweir "DocumentModel property only supported by " 1361cdf0e10cSrcweir "documents" ), 1362cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir else 1366cdf0e10cSrcweir { 1367cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 1370cdf0e10cSrcweir { 1371cdf0e10cSrcweir xAdditionalPropSet = getAdditionalPropertySet( sal_False ); 1372cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1373cdf0e10cSrcweir } 1374cdf0e10cSrcweir 1375cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 1376cdf0e10cSrcweir { 1377cdf0e10cSrcweir try 1378cdf0e10cSrcweir { 1379cdf0e10cSrcweir uno::Any aOldValue = xAdditionalPropSet->getPropertyValue( 1380cdf0e10cSrcweir rValue.Name ); 1381cdf0e10cSrcweir if ( aOldValue != rValue.Value ) 1382cdf0e10cSrcweir { 1383cdf0e10cSrcweir xAdditionalPropSet->setPropertyValue( 1384cdf0e10cSrcweir rValue.Name, rValue.Value ); 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir aEvent.PropertyName = rValue.Name; 1387cdf0e10cSrcweir aEvent.OldValue = aOldValue; 1388cdf0e10cSrcweir aEvent.NewValue = rValue.Value; 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1391cdf0e10cSrcweir nChanged++; 1392cdf0e10cSrcweir } 1393cdf0e10cSrcweir } 1394cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & e ) 1395cdf0e10cSrcweir { 1396cdf0e10cSrcweir aRet[ n ] <<= e; 1397cdf0e10cSrcweir } 1398cdf0e10cSrcweir catch ( lang::WrappedTargetException const & e ) 1399cdf0e10cSrcweir { 1400cdf0e10cSrcweir aRet[ n ] <<= e; 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir catch ( beans::PropertyVetoException const & e ) 1403cdf0e10cSrcweir { 1404cdf0e10cSrcweir aRet[ n ] <<= e; 1405cdf0e10cSrcweir } 1406cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & e ) 1407cdf0e10cSrcweir { 1408cdf0e10cSrcweir aRet[ n ] <<= e; 1409cdf0e10cSrcweir } 1410cdf0e10cSrcweir } 1411cdf0e10cSrcweir else 1412cdf0e10cSrcweir { 1413cdf0e10cSrcweir aRet[ n ] <<= uno::Exception( 1414cdf0e10cSrcweir rtl::OUString::createFromAscii( 1415cdf0e10cSrcweir "No property set for storing the value!" ), 1416cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1417cdf0e10cSrcweir } 1418cdf0e10cSrcweir } 1419cdf0e10cSrcweir } 1420cdf0e10cSrcweir 1421cdf0e10cSrcweir if ( bExchange ) 1422cdf0e10cSrcweir { 1423cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldId 1424cdf0e10cSrcweir = m_xIdentifier; 1425cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewId 1426cdf0e10cSrcweir = makeNewIdentifier( m_aProps.getTitle() ); 1427cdf0e10cSrcweir 1428cdf0e10cSrcweir aGuard.clear(); 1429cdf0e10cSrcweir if ( exchangeIdentity( xNewId ) ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir // Adapt persistent data. 1432cdf0e10cSrcweir renameData( xOldId, xNewId ); 1433cdf0e10cSrcweir 1434cdf0e10cSrcweir // Adapt Additional Core Properties. 1435cdf0e10cSrcweir renameAdditionalPropertySet( xOldId->getContentIdentifier(), 1436cdf0e10cSrcweir xNewId->getContentIdentifier(), 1437cdf0e10cSrcweir sal_True ); 1438cdf0e10cSrcweir } 1439cdf0e10cSrcweir else 1440cdf0e10cSrcweir { 1441cdf0e10cSrcweir // Roll-back. 1442cdf0e10cSrcweir m_aProps.setTitle( aOldTitle ); 1443cdf0e10cSrcweir aOldTitle = rtl::OUString(); 1444cdf0e10cSrcweir 1445cdf0e10cSrcweir // Set error . 1446cdf0e10cSrcweir aRet[ nTitlePos ] <<= uno::Exception( 1447cdf0e10cSrcweir rtl::OUString::createFromAscii( "Exchange failed!" ), 1448cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1449cdf0e10cSrcweir } 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir 1452cdf0e10cSrcweir if ( aOldTitle.getLength() ) 1453cdf0e10cSrcweir { 1454cdf0e10cSrcweir aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" ); 1455cdf0e10cSrcweir aEvent.OldValue = uno::makeAny( aOldTitle ); 1456cdf0e10cSrcweir aEvent.NewValue = uno::makeAny( m_aProps.getTitle() ); 1457cdf0e10cSrcweir 1458cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1459cdf0e10cSrcweir nChanged++; 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir if ( nChanged > 0 ) 1463cdf0e10cSrcweir { 1464cdf0e10cSrcweir // Save changes, if content was already made persistent. 1465cdf0e10cSrcweir if ( !bExchange && ( m_eState == PERSISTENT ) ) 1466cdf0e10cSrcweir { 1467cdf0e10cSrcweir if ( !storeData( uno::Reference< io::XInputStream >(), xEnv ) ) 1468cdf0e10cSrcweir { 1469cdf0e10cSrcweir uno::Any aProps 1470cdf0e10cSrcweir = uno::makeAny( 1471cdf0e10cSrcweir beans::PropertyValue( 1472cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1473cdf0e10cSrcweir "Uri")), 1474cdf0e10cSrcweir -1, 1475cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1476cdf0e10cSrcweir getContentIdentifier()), 1477cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1478cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1479cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 1480cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1481cdf0e10cSrcweir xEnv, 1482cdf0e10cSrcweir rtl::OUString::createFromAscii( 1483cdf0e10cSrcweir "Cannot store persistent data!" ), 1484cdf0e10cSrcweir this ); 1485cdf0e10cSrcweir // Unreachable 1486cdf0e10cSrcweir } 1487cdf0e10cSrcweir } 1488cdf0e10cSrcweir 1489cdf0e10cSrcweir aChanges.realloc( nChanged ); 1490cdf0e10cSrcweir 1491cdf0e10cSrcweir aGuard.clear(); 1492cdf0e10cSrcweir notifyPropertiesChange( aChanges ); 1493cdf0e10cSrcweir } 1494cdf0e10cSrcweir 1495cdf0e10cSrcweir return aRet; 1496cdf0e10cSrcweir } 1497cdf0e10cSrcweir 1498cdf0e10cSrcweir //========================================================================= 1499cdf0e10cSrcweir uno::Any Content::open( 1500cdf0e10cSrcweir const ucb::OpenCommandArgument2& rArg, 1501cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& xEnv ) 1502cdf0e10cSrcweir throw( uno::Exception ) 1503cdf0e10cSrcweir { 1504cdf0e10cSrcweir if ( rArg.Mode == ucb::OpenMode::ALL || 1505cdf0e10cSrcweir rArg.Mode == ucb::OpenMode::FOLDERS || 1506cdf0e10cSrcweir rArg.Mode == ucb::OpenMode::DOCUMENTS ) 1507cdf0e10cSrcweir { 1508cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1509cdf0e10cSrcweir // open command for a folder content 1510cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir uno::Reference< ucb::XDynamicResultSet > xSet 1513cdf0e10cSrcweir = new DynamicResultSet( m_xSMgr, this, rArg ); 1514cdf0e10cSrcweir return uno::makeAny( xSet ); 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir else 1517cdf0e10cSrcweir { 1518cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1519cdf0e10cSrcweir // open command for a document content 1520cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 1521cdf0e10cSrcweir 1522cdf0e10cSrcweir if ( ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) || 1523cdf0e10cSrcweir ( rArg.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) 1524cdf0e10cSrcweir { 1525cdf0e10cSrcweir // Currently(?) unsupported. 1526cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1527cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedOpenModeException( 1528cdf0e10cSrcweir rtl::OUString(), 1529cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1530cdf0e10cSrcweir sal_Int16( rArg.Mode ) ) ), 1531cdf0e10cSrcweir xEnv ); 1532cdf0e10cSrcweir // Unreachable 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir 1535cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1536cdf0e10cSrcweir 1537cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 1538cdf0e10cSrcweir 1539cdf0e10cSrcweir uno::Reference< io::XActiveDataStreamer > xDataStreamer( 1540cdf0e10cSrcweir rArg.Sink, uno::UNO_QUERY ); 1541cdf0e10cSrcweir if ( xDataStreamer.is() ) 1542cdf0e10cSrcweir { 1543cdf0e10cSrcweir // May throw CommandFailedException, DocumentPasswordRequest! 1544cdf0e10cSrcweir uno::Reference< io::XStream > xStream = getStream( xEnv ); 1545cdf0e10cSrcweir if ( !xStream.is() ) 1546cdf0e10cSrcweir { 1547cdf0e10cSrcweir // No interaction if we are not persistent! 1548cdf0e10cSrcweir uno::Any aProps 1549cdf0e10cSrcweir = uno::makeAny( 1550cdf0e10cSrcweir beans::PropertyValue( 1551cdf0e10cSrcweir rtl::OUString( 1552cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Uri")), 1553cdf0e10cSrcweir -1, 1554cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1555cdf0e10cSrcweir getContentIdentifier()), 1556cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1557cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1558cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 1559cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1560cdf0e10cSrcweir m_eState == PERSISTENT 1561cdf0e10cSrcweir ? xEnv 1562cdf0e10cSrcweir : uno::Reference< ucb::XCommandEnvironment >(), 1563cdf0e10cSrcweir rtl::OUString::createFromAscii( 1564cdf0e10cSrcweir "Got no data stream!" ), 1565cdf0e10cSrcweir this ); 1566cdf0e10cSrcweir // Unreachable 1567cdf0e10cSrcweir } 1568cdf0e10cSrcweir 1569cdf0e10cSrcweir // Done. 1570cdf0e10cSrcweir xDataStreamer->setStream( xStream ); 1571cdf0e10cSrcweir } 1572cdf0e10cSrcweir else 1573cdf0e10cSrcweir { 1574cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut( rArg.Sink, uno::UNO_QUERY ); 1575cdf0e10cSrcweir if ( xOut.is() ) 1576cdf0e10cSrcweir { 1577cdf0e10cSrcweir // PUSH: write data into xOut 1578cdf0e10cSrcweir 1579cdf0e10cSrcweir // May throw CommandFailedException, DocumentPasswordRequest! 1580cdf0e10cSrcweir uno::Reference< io::XInputStream > xIn = getInputStream( xEnv ); 1581cdf0e10cSrcweir if ( !xIn.is() ) 1582cdf0e10cSrcweir { 1583cdf0e10cSrcweir // No interaction if we are not persistent! 1584cdf0e10cSrcweir uno::Any aProps 1585cdf0e10cSrcweir = uno::makeAny( 1586cdf0e10cSrcweir beans::PropertyValue( 1587cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1588cdf0e10cSrcweir "Uri")), 1589cdf0e10cSrcweir -1, 1590cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1591cdf0e10cSrcweir getContentIdentifier()), 1592cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1593cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1594cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 1595cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1596cdf0e10cSrcweir m_eState == PERSISTENT 1597cdf0e10cSrcweir ? xEnv 1598cdf0e10cSrcweir : uno::Reference< ucb::XCommandEnvironment >(), 1599cdf0e10cSrcweir rtl::OUString::createFromAscii( "Got no data stream!" ), 1600cdf0e10cSrcweir this ); 1601cdf0e10cSrcweir // Unreachable 1602cdf0e10cSrcweir } 1603cdf0e10cSrcweir 1604cdf0e10cSrcweir try 1605cdf0e10cSrcweir { 1606cdf0e10cSrcweir uno::Sequence< sal_Int8 > aBuffer; 1607cdf0e10cSrcweir sal_Int32 nRead = xIn->readSomeBytes( aBuffer, 65536 ); 1608cdf0e10cSrcweir 1609cdf0e10cSrcweir while ( nRead > 0 ) 1610cdf0e10cSrcweir { 1611cdf0e10cSrcweir aBuffer.realloc( nRead ); 1612cdf0e10cSrcweir xOut->writeBytes( aBuffer ); 1613cdf0e10cSrcweir aBuffer.realloc( 0 ); 1614cdf0e10cSrcweir nRead = xIn->readSomeBytes( aBuffer, 65536 ); 1615cdf0e10cSrcweir } 1616cdf0e10cSrcweir 1617cdf0e10cSrcweir xOut->closeOutput(); 1618cdf0e10cSrcweir } 1619cdf0e10cSrcweir catch ( io::NotConnectedException const & ) 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir // closeOutput, readSomeBytes, writeBytes 1622cdf0e10cSrcweir } 1623cdf0e10cSrcweir catch ( io::BufferSizeExceededException const & ) 1624cdf0e10cSrcweir { 1625cdf0e10cSrcweir // closeOutput, readSomeBytes, writeBytes 1626cdf0e10cSrcweir } 1627cdf0e10cSrcweir catch ( io::IOException const & ) 1628cdf0e10cSrcweir { 1629cdf0e10cSrcweir // closeOutput, readSomeBytes, writeBytes 1630cdf0e10cSrcweir } 1631cdf0e10cSrcweir } 1632cdf0e10cSrcweir else 1633cdf0e10cSrcweir { 1634cdf0e10cSrcweir uno::Reference< io::XActiveDataSink > xDataSink( 1635cdf0e10cSrcweir rArg.Sink, uno::UNO_QUERY ); 1636cdf0e10cSrcweir if ( xDataSink.is() ) 1637cdf0e10cSrcweir { 1638cdf0e10cSrcweir // PULL: wait for client read 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir // May throw CommandFailedException, DocumentPasswordRequest! 1641cdf0e10cSrcweir uno::Reference< io::XInputStream > xIn = getInputStream( xEnv ); 1642cdf0e10cSrcweir if ( !xIn.is() ) 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir // No interaction if we are not persistent! 1645cdf0e10cSrcweir uno::Any aProps 1646cdf0e10cSrcweir = uno::makeAny( 1647cdf0e10cSrcweir beans::PropertyValue( 1648cdf0e10cSrcweir rtl::OUString( 1649cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Uri")), 1650cdf0e10cSrcweir -1, 1651cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1652cdf0e10cSrcweir getContentIdentifier()), 1653cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1654cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1655cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 1656cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1657cdf0e10cSrcweir m_eState == PERSISTENT 1658cdf0e10cSrcweir ? xEnv 1659cdf0e10cSrcweir : uno::Reference< 1660cdf0e10cSrcweir ucb::XCommandEnvironment >(), 1661cdf0e10cSrcweir rtl::OUString::createFromAscii( 1662cdf0e10cSrcweir "Got no data stream!" ), 1663cdf0e10cSrcweir this ); 1664cdf0e10cSrcweir // Unreachable 1665cdf0e10cSrcweir } 1666cdf0e10cSrcweir 1667cdf0e10cSrcweir // Done. 1668cdf0e10cSrcweir xDataSink->setInputStream( xIn ); 1669cdf0e10cSrcweir } 1670cdf0e10cSrcweir else 1671cdf0e10cSrcweir { 1672cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1673cdf0e10cSrcweir uno::makeAny( 1674cdf0e10cSrcweir ucb::UnsupportedDataSinkException( 1675cdf0e10cSrcweir rtl::OUString(), 1676cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1677cdf0e10cSrcweir rArg.Sink ) ), 1678cdf0e10cSrcweir xEnv ); 1679cdf0e10cSrcweir // Unreachable 1680cdf0e10cSrcweir } 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir } 1683cdf0e10cSrcweir } 1684cdf0e10cSrcweir 1685cdf0e10cSrcweir return uno::Any(); 1686cdf0e10cSrcweir } 1687cdf0e10cSrcweir 1688cdf0e10cSrcweir //========================================================================= 1689cdf0e10cSrcweir void Content::insert( const uno::Reference< io::XInputStream >& xData, 1690cdf0e10cSrcweir sal_Int32 nNameClashResolve, 1691cdf0e10cSrcweir const uno::Reference< 1692cdf0e10cSrcweir ucb::XCommandEnvironment > & xEnv ) 1693cdf0e10cSrcweir throw( uno::Exception ) 1694cdf0e10cSrcweir { 1695cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1696cdf0e10cSrcweir 1697cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 1698cdf0e10cSrcweir 1699cdf0e10cSrcweir OSL_ENSURE( ( eType == FOLDER ) || ( eType == STREAM ), 1700cdf0e10cSrcweir "insert command only supported by streams and folders!" ); 1701cdf0e10cSrcweir 1702cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 1705cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 1706cdf0e10cSrcweir if ( eType == STREAM ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir Uri aParentUri( aUri.getParentUri() ); 1709cdf0e10cSrcweir OSL_ENSURE( !aParentUri.isDocument(), 1710cdf0e10cSrcweir "insert command not supported by streams that are direct " 1711cdf0e10cSrcweir "children of document root!" ); 1712cdf0e10cSrcweir } 1713cdf0e10cSrcweir #endif 1714cdf0e10cSrcweir #endif 1715cdf0e10cSrcweir 1716cdf0e10cSrcweir // Check, if all required properties were set. 1717cdf0e10cSrcweir if ( eType == FOLDER ) 1718cdf0e10cSrcweir { 1719cdf0e10cSrcweir // Required: Title 1720cdf0e10cSrcweir 1721cdf0e10cSrcweir if ( m_aProps.getTitle().getLength() == 0 ) 1722cdf0e10cSrcweir m_aProps.setTitle( aUri.getDecodedName() ); 1723cdf0e10cSrcweir } 1724cdf0e10cSrcweir else // stream 1725cdf0e10cSrcweir { 1726cdf0e10cSrcweir // Required: data 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir if ( !xData.is() ) 1729cdf0e10cSrcweir { 1730cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1731cdf0e10cSrcweir uno::makeAny( ucb::MissingInputStreamException( 1732cdf0e10cSrcweir rtl::OUString(), 1733cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1734cdf0e10cSrcweir xEnv ); 1735cdf0e10cSrcweir // Unreachable 1736cdf0e10cSrcweir } 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir // Required: Title 1739cdf0e10cSrcweir 1740cdf0e10cSrcweir if ( m_aProps.getTitle().getLength() == 0 ) 1741cdf0e10cSrcweir m_aProps.setTitle( aUri.getDecodedName() ); 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir 1744cdf0e10cSrcweir rtl::OUStringBuffer aNewURL = aUri.getParentUri(); 1745cdf0e10cSrcweir aNewURL.append( m_aProps.getTitle() ); 1746cdf0e10cSrcweir Uri aNewUri( aNewURL.makeStringAndClear() ); 1747cdf0e10cSrcweir 1748cdf0e10cSrcweir // Handle possible name clash... 1749cdf0e10cSrcweir switch ( nNameClashResolve ) 1750cdf0e10cSrcweir { 1751cdf0e10cSrcweir // fail. 1752cdf0e10cSrcweir case ucb::NameClash::ERROR: 1753cdf0e10cSrcweir if ( hasData( aNewUri ) ) 1754cdf0e10cSrcweir { 1755cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1756cdf0e10cSrcweir uno::makeAny( ucb::NameClashException( 1757cdf0e10cSrcweir rtl::OUString(), 1758cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1759cdf0e10cSrcweir task::InteractionClassification_ERROR, 1760cdf0e10cSrcweir m_aProps.getTitle() ) ), 1761cdf0e10cSrcweir xEnv ); 1762cdf0e10cSrcweir // Unreachable 1763cdf0e10cSrcweir } 1764cdf0e10cSrcweir break; 1765cdf0e10cSrcweir 1766cdf0e10cSrcweir // replace (possibly) existing object. 1767cdf0e10cSrcweir case ucb::NameClash::OVERWRITE: 1768cdf0e10cSrcweir break; 1769cdf0e10cSrcweir 1770cdf0e10cSrcweir // "invent" a new valid title. 1771cdf0e10cSrcweir case ucb::NameClash::RENAME: 1772cdf0e10cSrcweir if ( hasData( aNewUri ) ) 1773cdf0e10cSrcweir { 1774cdf0e10cSrcweir sal_Int32 nTry = 0; 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir do 1777cdf0e10cSrcweir { 1778cdf0e10cSrcweir rtl::OUStringBuffer aNew = aNewUri.getUri(); 1779cdf0e10cSrcweir aNew.appendAscii( "_" ); 1780cdf0e10cSrcweir aNew.append( rtl::OUString::valueOf( ++nTry ) ); 1781cdf0e10cSrcweir aNewUri.setUri( aNew.makeStringAndClear() ); 1782cdf0e10cSrcweir } 1783cdf0e10cSrcweir while ( hasData( aNewUri ) && ( nTry < 1000 ) ); 1784cdf0e10cSrcweir 1785cdf0e10cSrcweir if ( nTry == 1000 ) 1786cdf0e10cSrcweir { 1787cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1788cdf0e10cSrcweir uno::makeAny( 1789cdf0e10cSrcweir ucb::UnsupportedNameClashException( 1790cdf0e10cSrcweir rtl::OUString::createFromAscii( 1791cdf0e10cSrcweir "Unable to resolve name clash!" ), 1792cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1793cdf0e10cSrcweir nNameClashResolve ) ), 1794cdf0e10cSrcweir xEnv ); 1795cdf0e10cSrcweir // Unreachable 1796cdf0e10cSrcweir } 1797cdf0e10cSrcweir else 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir rtl::OUStringBuffer aNewTitle = m_aProps.getTitle(); 1800cdf0e10cSrcweir aNewTitle.appendAscii( "_" ); 1801cdf0e10cSrcweir aNewTitle.append( rtl::OUString::valueOf( ++nTry ) ); 1802cdf0e10cSrcweir m_aProps.setTitle( aNewTitle.makeStringAndClear() ); 1803cdf0e10cSrcweir } 1804cdf0e10cSrcweir } 1805cdf0e10cSrcweir break; 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir case ucb::NameClash::KEEP: // deprecated 1808cdf0e10cSrcweir case ucb::NameClash::ASK: 1809cdf0e10cSrcweir default: 1810cdf0e10cSrcweir if ( hasData( aNewUri ) ) 1811cdf0e10cSrcweir { 1812cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1813cdf0e10cSrcweir uno::makeAny( 1814cdf0e10cSrcweir ucb::UnsupportedNameClashException( 1815cdf0e10cSrcweir rtl::OUString(), 1816cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1817cdf0e10cSrcweir nNameClashResolve ) ), 1818cdf0e10cSrcweir xEnv ); 1819cdf0e10cSrcweir // Unreachable 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir break; 1822cdf0e10cSrcweir } 1823cdf0e10cSrcweir 1824cdf0e10cSrcweir // Identifier changed? 1825cdf0e10cSrcweir sal_Bool bNewId = ( aUri != aNewUri ); 1826cdf0e10cSrcweir 1827cdf0e10cSrcweir if ( bNewId ) 1828cdf0e10cSrcweir { 1829cdf0e10cSrcweir m_xIdentifier 1830cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewUri.getUri() ); 1831cdf0e10cSrcweir } 1832cdf0e10cSrcweir 1833cdf0e10cSrcweir if ( !storeData( xData, xEnv ) ) 1834cdf0e10cSrcweir { 1835cdf0e10cSrcweir uno::Any aProps 1836cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 1837cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1838cdf0e10cSrcweir "Uri")), 1839cdf0e10cSrcweir -1, 1840cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1841cdf0e10cSrcweir getContentIdentifier()), 1842cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1843cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1844cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 1845cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1846cdf0e10cSrcweir xEnv, 1847cdf0e10cSrcweir rtl::OUString::createFromAscii( "Cannot store persistent data!" ), 1848cdf0e10cSrcweir this ); 1849cdf0e10cSrcweir // Unreachable 1850cdf0e10cSrcweir } 1851cdf0e10cSrcweir 1852cdf0e10cSrcweir m_eState = PERSISTENT; 1853cdf0e10cSrcweir 1854cdf0e10cSrcweir if ( bNewId ) 1855cdf0e10cSrcweir { 1856cdf0e10cSrcweir //loadData( m_pProvider, m_aUri, m_aProps ); 1857cdf0e10cSrcweir 1858cdf0e10cSrcweir aGuard.clear(); 1859cdf0e10cSrcweir inserted(); 1860cdf0e10cSrcweir } 1861cdf0e10cSrcweir } 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir //========================================================================= 1864cdf0e10cSrcweir void Content::destroy( sal_Bool bDeletePhysical, 1865cdf0e10cSrcweir const uno::Reference< 1866cdf0e10cSrcweir ucb::XCommandEnvironment > & xEnv ) 1867cdf0e10cSrcweir throw( uno::Exception ) 1868cdf0e10cSrcweir { 1869cdf0e10cSrcweir // @@@ take care about bDeletePhysical -> trashcan support 1870cdf0e10cSrcweir 1871cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 1874cdf0e10cSrcweir 1875cdf0e10cSrcweir OSL_ENSURE( ( eType == FOLDER ) || ( eType == STREAM ), 1876cdf0e10cSrcweir "delete command only supported by streams and folders!" ); 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir // Persistent? 1881cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 1882cdf0e10cSrcweir { 1883cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1884cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 1885cdf0e10cSrcweir rtl::OUString::createFromAscii( 1886cdf0e10cSrcweir "Not persistent!" ), 1887cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1888cdf0e10cSrcweir xEnv ); 1889cdf0e10cSrcweir // Unreachable 1890cdf0e10cSrcweir } 1891cdf0e10cSrcweir 1892cdf0e10cSrcweir m_eState = DEAD; 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir aGuard.clear(); 1895cdf0e10cSrcweir deleted(); 1896cdf0e10cSrcweir 1897cdf0e10cSrcweir if ( eType == FOLDER ) 1898cdf0e10cSrcweir { 1899cdf0e10cSrcweir // Process instanciated children... 1900cdf0e10cSrcweir 1901cdf0e10cSrcweir ContentRefList aChildren; 1902cdf0e10cSrcweir queryChildren( aChildren ); 1903cdf0e10cSrcweir 1904cdf0e10cSrcweir ContentRefList::const_iterator it = aChildren.begin(); 1905cdf0e10cSrcweir ContentRefList::const_iterator end = aChildren.end(); 1906cdf0e10cSrcweir 1907cdf0e10cSrcweir while ( it != end ) 1908cdf0e10cSrcweir { 1909cdf0e10cSrcweir (*it)->destroy( bDeletePhysical, xEnv ); 1910cdf0e10cSrcweir ++it; 1911cdf0e10cSrcweir } 1912cdf0e10cSrcweir } 1913cdf0e10cSrcweir } 1914cdf0e10cSrcweir 1915cdf0e10cSrcweir //========================================================================= 1916cdf0e10cSrcweir void Content::notifyDocumentClosed() 1917cdf0e10cSrcweir { 1918cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1919cdf0e10cSrcweir 1920cdf0e10cSrcweir m_eState = DEAD; 1921cdf0e10cSrcweir 1922cdf0e10cSrcweir // @@@ anything else to reset or such? 1923cdf0e10cSrcweir 1924cdf0e10cSrcweir // callback follows! 1925cdf0e10cSrcweir aGuard.clear(); 1926cdf0e10cSrcweir 1927cdf0e10cSrcweir // Propagate destruction to content event listeners 1928cdf0e10cSrcweir // Remove this from provider's content list. 1929cdf0e10cSrcweir deleted(); 1930cdf0e10cSrcweir } 1931cdf0e10cSrcweir 1932cdf0e10cSrcweir //========================================================================= 1933cdf0e10cSrcweir uno::Reference< ucb::XContent > 1934cdf0e10cSrcweir Content::queryChildContent( const rtl::OUString & rRelativeChildUri ) 1935cdf0e10cSrcweir { 1936cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1937cdf0e10cSrcweir 1938cdf0e10cSrcweir const rtl::OUString aMyId = getIdentifier()->getContentIdentifier(); 1939cdf0e10cSrcweir rtl::OUStringBuffer aBuf( aMyId ); 1940cdf0e10cSrcweir if ( aMyId.getStr()[ aMyId.getLength() - 1 ] != sal_Unicode( '/' ) ) 1941cdf0e10cSrcweir aBuf.appendAscii( "/" ); 1942cdf0e10cSrcweir if ( rRelativeChildUri.getStr()[ 0 ] != sal_Unicode( '/' ) ) 1943cdf0e10cSrcweir aBuf.append( rRelativeChildUri ); 1944cdf0e10cSrcweir else 1945cdf0e10cSrcweir aBuf.append( rRelativeChildUri.copy( 1 ) ); 1946cdf0e10cSrcweir 1947cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xChildId 1948cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( 1949cdf0e10cSrcweir m_xSMgr, aBuf.makeStringAndClear() ); 1950cdf0e10cSrcweir 1951cdf0e10cSrcweir uno::Reference< ucb::XContent > xChild; 1952cdf0e10cSrcweir try 1953cdf0e10cSrcweir { 1954cdf0e10cSrcweir xChild = m_pProvider->queryContent( xChildId ); 1955cdf0e10cSrcweir } 1956cdf0e10cSrcweir catch ( ucb::IllegalIdentifierException const & ) 1957cdf0e10cSrcweir { 1958cdf0e10cSrcweir // handled below. 1959cdf0e10cSrcweir } 1960cdf0e10cSrcweir 1961cdf0e10cSrcweir OSL_ENSURE( xChild.is(), 1962cdf0e10cSrcweir "Content::queryChildContent - unable to create child content!" ); 1963cdf0e10cSrcweir return xChild; 1964cdf0e10cSrcweir } 1965cdf0e10cSrcweir 1966cdf0e10cSrcweir //========================================================================= 1967cdf0e10cSrcweir void Content::notifyChildRemoved( const rtl::OUString & rRelativeChildUri ) 1968cdf0e10cSrcweir { 1969cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir // Ugly! Need to create child content object, just to fill event properly. 1972cdf0e10cSrcweir uno::Reference< ucb::XContent > xChild 1973cdf0e10cSrcweir = queryChildContent( rRelativeChildUri ); 1974cdf0e10cSrcweir 1975cdf0e10cSrcweir if ( xChild.is() ) 1976cdf0e10cSrcweir { 1977cdf0e10cSrcweir // callback follows! 1978cdf0e10cSrcweir aGuard.clear(); 1979cdf0e10cSrcweir 1980cdf0e10cSrcweir // Notify "REMOVED" event. 1981cdf0e10cSrcweir ucb::ContentEvent aEvt( 1982cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1983cdf0e10cSrcweir ucb::ContentAction::REMOVED, 1984cdf0e10cSrcweir xChild, 1985cdf0e10cSrcweir getIdentifier() ); 1986cdf0e10cSrcweir notifyContentEvent( aEvt ); 1987cdf0e10cSrcweir } 1988cdf0e10cSrcweir } 1989cdf0e10cSrcweir 1990cdf0e10cSrcweir //========================================================================= 1991cdf0e10cSrcweir void Content::notifyChildInserted( const rtl::OUString & rRelativeChildUri ) 1992cdf0e10cSrcweir { 1993cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1994cdf0e10cSrcweir 1995cdf0e10cSrcweir // Ugly! Need to create child content object, just to fill event properly. 1996cdf0e10cSrcweir uno::Reference< ucb::XContent > xChild 1997cdf0e10cSrcweir = queryChildContent( rRelativeChildUri ); 1998cdf0e10cSrcweir 1999cdf0e10cSrcweir if ( xChild.is() ) 2000cdf0e10cSrcweir { 2001cdf0e10cSrcweir // callback follows! 2002cdf0e10cSrcweir aGuard.clear(); 2003cdf0e10cSrcweir 2004cdf0e10cSrcweir // Notify "INSERTED" event. 2005cdf0e10cSrcweir ucb::ContentEvent aEvt( 2006cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2007cdf0e10cSrcweir ucb::ContentAction::INSERTED, 2008cdf0e10cSrcweir xChild, 2009cdf0e10cSrcweir getIdentifier() ); 2010cdf0e10cSrcweir notifyContentEvent( aEvt ); 2011cdf0e10cSrcweir } 2012cdf0e10cSrcweir } 2013cdf0e10cSrcweir 2014cdf0e10cSrcweir //========================================================================= 2015cdf0e10cSrcweir void Content::transfer( 2016cdf0e10cSrcweir const ucb::TransferInfo& rInfo, 2017cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 2018cdf0e10cSrcweir throw( uno::Exception ) 2019cdf0e10cSrcweir { 2020cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 2021cdf0e10cSrcweir 2022cdf0e10cSrcweir // Persistent? 2023cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 2024cdf0e10cSrcweir { 2025cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2026cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 2027cdf0e10cSrcweir rtl::OUString::createFromAscii( 2028cdf0e10cSrcweir "Not persistent!" ), 2029cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2030cdf0e10cSrcweir xEnv ); 2031cdf0e10cSrcweir // Unreachable 2032cdf0e10cSrcweir } 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir // Does source URI scheme match? Only vnd.sun.star.tdoc is supported. 2035cdf0e10cSrcweir 2036cdf0e10cSrcweir if ( ( rInfo.SourceURL.getLength() < TDOC_URL_SCHEME_LENGTH + 2 ) ) 2037cdf0e10cSrcweir { 2038*30acf5e8Spfg // Invalid length (to short). 2039cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2040cdf0e10cSrcweir uno::makeAny( ucb::InteractiveBadTransferURLException( 2041cdf0e10cSrcweir rtl::OUString(), 2042cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2043cdf0e10cSrcweir xEnv ); 2044cdf0e10cSrcweir // Unreachable 2045cdf0e10cSrcweir } 2046cdf0e10cSrcweir 2047cdf0e10cSrcweir rtl::OUString aScheme 2048cdf0e10cSrcweir = rInfo.SourceURL.copy( 0, TDOC_URL_SCHEME_LENGTH + 2 ) 2049cdf0e10cSrcweir .toAsciiLowerCase(); 2050cdf0e10cSrcweir if ( !aScheme.equalsAsciiL( 2051cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( TDOC_URL_SCHEME ":/" ) ) ) 2052cdf0e10cSrcweir { 2053cdf0e10cSrcweir // Invalid scheme. 2054cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2055cdf0e10cSrcweir uno::makeAny( ucb::InteractiveBadTransferURLException( 2056cdf0e10cSrcweir rtl::OUString(), 2057cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 2058cdf0e10cSrcweir xEnv ); 2059cdf0e10cSrcweir // Unreachable 2060cdf0e10cSrcweir } 2061cdf0e10cSrcweir 2062cdf0e10cSrcweir // Does source URI describe a tdoc folder or stream? 2063cdf0e10cSrcweir Uri aSourceUri( rInfo.SourceURL ); 2064cdf0e10cSrcweir if ( !aSourceUri.isValid() ) 2065cdf0e10cSrcweir { 2066cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2067cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 2068cdf0e10cSrcweir rtl::OUString::createFromAscii( 2069cdf0e10cSrcweir "Invalid source URI! Syntax!" ), 2070cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2071cdf0e10cSrcweir -1 ) ), 2072cdf0e10cSrcweir xEnv ); 2073cdf0e10cSrcweir // Unreachable 2074cdf0e10cSrcweir } 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir if ( aSourceUri.isRoot() || aSourceUri.isDocument() ) 2077cdf0e10cSrcweir { 2078cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2079cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 2080cdf0e10cSrcweir rtl::OUString::createFromAscii( 2081cdf0e10cSrcweir "Invalid source URI! " 2082cdf0e10cSrcweir "Must describe a folder or stream!" ), 2083cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2084cdf0e10cSrcweir -1 ) ), 2085cdf0e10cSrcweir xEnv ); 2086cdf0e10cSrcweir // Unreachable 2087cdf0e10cSrcweir } 2088cdf0e10cSrcweir 2089cdf0e10cSrcweir // Is source not a parent of me / not me? 2090cdf0e10cSrcweir rtl::OUString aId = m_xIdentifier->getContentIdentifier(); 2091cdf0e10cSrcweir sal_Int32 nPos = aId.lastIndexOf( '/' ); 2092cdf0e10cSrcweir if ( nPos != ( aId.getLength() - 1 ) ) 2093cdf0e10cSrcweir { 2094cdf0e10cSrcweir // No trailing slash found. Append. 2095cdf0e10cSrcweir aId += rtl::OUString::createFromAscii( "/" ); 2096cdf0e10cSrcweir } 2097cdf0e10cSrcweir 2098cdf0e10cSrcweir if ( rInfo.SourceURL.getLength() <= aId.getLength() ) 2099cdf0e10cSrcweir { 2100cdf0e10cSrcweir if ( aId.compareTo( 2101cdf0e10cSrcweir rInfo.SourceURL, rInfo.SourceURL.getLength() ) == 0 ) 2102cdf0e10cSrcweir { 2103cdf0e10cSrcweir uno::Any aProps 2104cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 2105cdf0e10cSrcweir rtl::OUString( 2106cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Uri")), 2107cdf0e10cSrcweir -1, 2108cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2109cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2110cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2111cdf0e10cSrcweir ucb::IOErrorCode_RECURSIVE, 2112cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2113cdf0e10cSrcweir xEnv, 2114cdf0e10cSrcweir rtl::OUString::createFromAscii( 2115cdf0e10cSrcweir "Target is equal to or is a child of source!" ), 2116cdf0e10cSrcweir this ); 2117cdf0e10cSrcweir // Unreachable 2118cdf0e10cSrcweir } 2119cdf0e10cSrcweir } 2120cdf0e10cSrcweir 2121cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 2122cdf0e10cSrcweir if ( m_aProps.getType() == DOCUMENT ) 2123cdf0e10cSrcweir { 2124cdf0e10cSrcweir bool bOK = false; 2125cdf0e10cSrcweir 2126cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2127cdf0e10cSrcweir = m_pProvider->queryStorage( 2128cdf0e10cSrcweir aSourceUri.getParentUri(), READ_WRITE_NOCREATE ); 2129cdf0e10cSrcweir if ( xStorage.is() ) 2130cdf0e10cSrcweir { 2131cdf0e10cSrcweir try 2132cdf0e10cSrcweir { 2133cdf0e10cSrcweir if ( xStorage->isStreamElement( aSourceUri.getDecodedName() ) ) 2134cdf0e10cSrcweir { 2135cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2136cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 2137cdf0e10cSrcweir rtl::OUString::createFromAscii( 2138cdf0e10cSrcweir "Invalid source URI! " 2139cdf0e10cSrcweir "Streams cannot be created as " 2140cdf0e10cSrcweir "children of document root!" ), 2141cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( 2142cdf0e10cSrcweir this ), 2143cdf0e10cSrcweir -1 ) ), 2144cdf0e10cSrcweir xEnv ); 2145cdf0e10cSrcweir // Unreachable 2146cdf0e10cSrcweir } 2147cdf0e10cSrcweir bOK = true; 2148cdf0e10cSrcweir } 2149cdf0e10cSrcweir catch ( container::NoSuchElementException const & ) 2150cdf0e10cSrcweir { 2151cdf0e10cSrcweir // handled below. 2152cdf0e10cSrcweir } 2153cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2154cdf0e10cSrcweir { 2155cdf0e10cSrcweir // handled below. 2156cdf0e10cSrcweir } 2157cdf0e10cSrcweir catch ( embed::InvalidStorageException const & ) 2158cdf0e10cSrcweir { 2159cdf0e10cSrcweir // handled below. 2160cdf0e10cSrcweir } 2161cdf0e10cSrcweir } 2162cdf0e10cSrcweir 2163cdf0e10cSrcweir if ( !bOK ) 2164cdf0e10cSrcweir { 2165cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2166cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 2167cdf0e10cSrcweir rtl::OUString::createFromAscii( 2168cdf0e10cSrcweir "Invalid source URI! " 2169cdf0e10cSrcweir "Unabale to determine source type!" ), 2170cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 2171cdf0e10cSrcweir -1 ) ), 2172cdf0e10cSrcweir xEnv ); 2173cdf0e10cSrcweir // Unreachable 2174cdf0e10cSrcweir } 2175cdf0e10cSrcweir } 2176cdf0e10cSrcweir #endif 2177cdf0e10cSrcweir 2178cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2179cdf0e10cSrcweir // Copy data. 2180cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2181cdf0e10cSrcweir 2182cdf0e10cSrcweir rtl::OUString aNewName( rInfo.NewTitle.getLength() > 0 2183cdf0e10cSrcweir ? rInfo.NewTitle 2184cdf0e10cSrcweir : aSourceUri.getDecodedName() ); 2185cdf0e10cSrcweir 2186cdf0e10cSrcweir if ( !copyData( aSourceUri, aNewName ) ) 2187cdf0e10cSrcweir { 2188cdf0e10cSrcweir uno::Any aProps 2189cdf0e10cSrcweir = uno::makeAny( 2190cdf0e10cSrcweir beans::PropertyValue( 2191cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2192cdf0e10cSrcweir "Uri")), 2193cdf0e10cSrcweir -1, 2194cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2195cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2196cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2197cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 2198cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2199cdf0e10cSrcweir xEnv, 2200cdf0e10cSrcweir rtl::OUString( 2201cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "Cannot copy data!" ) ), 2202cdf0e10cSrcweir this ); 2203cdf0e10cSrcweir // Unreachable 2204cdf0e10cSrcweir } 2205cdf0e10cSrcweir 2206cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2207cdf0e10cSrcweir // Copy own and all children's Additional Core Properties. 2208cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2209cdf0e10cSrcweir 2210cdf0e10cSrcweir rtl::OUString aTargetUri = m_xIdentifier->getContentIdentifier(); 2211cdf0e10cSrcweir if ( ( aTargetUri.lastIndexOf( '/' ) + 1 ) != aTargetUri.getLength() ) 2212cdf0e10cSrcweir aTargetUri += rtl::OUString::createFromAscii( "/" ); 2213cdf0e10cSrcweir 2214cdf0e10cSrcweir if ( rInfo.NewTitle.getLength() > 0 ) 2215cdf0e10cSrcweir aTargetUri += ::ucb_impl::urihelper::encodeSegment( rInfo.NewTitle ); 2216cdf0e10cSrcweir else 2217cdf0e10cSrcweir aTargetUri += aSourceUri.getName(); 2218cdf0e10cSrcweir 2219cdf0e10cSrcweir if ( !copyAdditionalPropertySet( 2220cdf0e10cSrcweir aSourceUri.getUri(), aTargetUri, sal_True ) ) 2221cdf0e10cSrcweir { 2222cdf0e10cSrcweir uno::Any aProps 2223cdf0e10cSrcweir = uno::makeAny( 2224cdf0e10cSrcweir beans::PropertyValue( 2225cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2226cdf0e10cSrcweir "Uri")), 2227cdf0e10cSrcweir -1, 2228cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2229cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2230cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2231cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 2232cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2233cdf0e10cSrcweir xEnv, 2234cdf0e10cSrcweir rtl::OUString( 2235cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 2236cdf0e10cSrcweir "Cannot copy additional properties!" ) ), 2237cdf0e10cSrcweir this ); 2238cdf0e10cSrcweir // Unreachable 2239cdf0e10cSrcweir } 2240cdf0e10cSrcweir 2241cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2242cdf0e10cSrcweir // Propagate new content. 2243cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2244cdf0e10cSrcweir 2245cdf0e10cSrcweir rtl::Reference< Content > xTarget; 2246cdf0e10cSrcweir try 2247cdf0e10cSrcweir { 2248cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xTargetId 2249cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aTargetUri ); 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir // Note: The static cast is okay here, because its sure that 2252cdf0e10cSrcweir // m_xProvider is always the WebDAVContentProvider. 2253cdf0e10cSrcweir xTarget = static_cast< Content * >( 2254cdf0e10cSrcweir m_pProvider->queryContent( xTargetId ).get() ); 2255cdf0e10cSrcweir 2256cdf0e10cSrcweir } 2257cdf0e10cSrcweir catch ( ucb::IllegalIdentifierException const & ) 2258cdf0e10cSrcweir { 2259cdf0e10cSrcweir // queryContent 2260cdf0e10cSrcweir } 2261cdf0e10cSrcweir 2262cdf0e10cSrcweir if ( !xTarget.is() ) 2263cdf0e10cSrcweir { 2264cdf0e10cSrcweir uno::Any aProps 2265cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 2266cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2267cdf0e10cSrcweir "Uri")), 2268cdf0e10cSrcweir -1, 2269cdf0e10cSrcweir uno::makeAny( aTargetUri ), 2270cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2271cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2272cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 2273cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2274cdf0e10cSrcweir xEnv, 2275cdf0e10cSrcweir rtl::OUString::createFromAscii( 2276cdf0e10cSrcweir "Cannot instanciate target object!" ), 2277cdf0e10cSrcweir this ); 2278cdf0e10cSrcweir // Unreachable 2279cdf0e10cSrcweir } 2280cdf0e10cSrcweir 228186e1cf34SPedro Giffuni // Announce transferred content in its new folder. 2282cdf0e10cSrcweir xTarget->inserted(); 2283cdf0e10cSrcweir 2284cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2285cdf0e10cSrcweir // Remove source, if requested 2286cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////// 2287cdf0e10cSrcweir 2288cdf0e10cSrcweir if ( rInfo.MoveData ) 2289cdf0e10cSrcweir { 2290cdf0e10cSrcweir rtl::Reference< Content > xSource; 2291cdf0e10cSrcweir try 2292cdf0e10cSrcweir { 2293cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > 2294cdf0e10cSrcweir xSourceId = new ::ucbhelper::ContentIdentifier( 2295cdf0e10cSrcweir m_xSMgr, rInfo.SourceURL ); 2296cdf0e10cSrcweir 2297cdf0e10cSrcweir // Note: The static cast is okay here, because its sure 2298cdf0e10cSrcweir // that m_xProvider is always the ContentProvider. 2299cdf0e10cSrcweir xSource = static_cast< Content * >( 2300cdf0e10cSrcweir m_xProvider->queryContent( xSourceId ).get() ); 2301cdf0e10cSrcweir } 2302cdf0e10cSrcweir catch ( ucb::IllegalIdentifierException const & ) 2303cdf0e10cSrcweir { 2304cdf0e10cSrcweir // queryContent 2305cdf0e10cSrcweir } 2306cdf0e10cSrcweir 2307cdf0e10cSrcweir if ( !xSource.is() ) 2308cdf0e10cSrcweir { 2309cdf0e10cSrcweir uno::Any aProps 2310cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 2311cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2312cdf0e10cSrcweir "Uri")), 2313cdf0e10cSrcweir -1, 2314cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2315cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2316cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2317cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 2318cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2319cdf0e10cSrcweir xEnv, 2320cdf0e10cSrcweir rtl::OUString::createFromAscii( 2321cdf0e10cSrcweir "Cannot instanciate target object!" ), 2322cdf0e10cSrcweir this ); 2323cdf0e10cSrcweir // Unreachable 2324cdf0e10cSrcweir } 2325cdf0e10cSrcweir 2326cdf0e10cSrcweir // Propagate destruction (recursively). 2327cdf0e10cSrcweir xSource->destroy( sal_True, xEnv ); 2328cdf0e10cSrcweir 2329cdf0e10cSrcweir // Remove all persistent data of source and its children. 2330cdf0e10cSrcweir if ( !xSource->removeData() ) 2331cdf0e10cSrcweir { 2332cdf0e10cSrcweir uno::Any aProps 2333cdf0e10cSrcweir = uno::makeAny( 2334cdf0e10cSrcweir beans::PropertyValue( 2335cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2336cdf0e10cSrcweir "Uri")), 2337cdf0e10cSrcweir -1, 2338cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2339cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2340cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2341cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 2342cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2343cdf0e10cSrcweir xEnv, 2344cdf0e10cSrcweir rtl::OUString::createFromAscii( 2345cdf0e10cSrcweir "Cannot remove persistent data of source object!" ), 2346cdf0e10cSrcweir this ); 2347cdf0e10cSrcweir // Unreachable 2348cdf0e10cSrcweir } 2349cdf0e10cSrcweir 2350cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 2351cdf0e10cSrcweir if ( !xSource->removeAdditionalPropertySet( sal_True ) ) 2352cdf0e10cSrcweir { 2353cdf0e10cSrcweir uno::Any aProps 2354cdf0e10cSrcweir = uno::makeAny( 2355cdf0e10cSrcweir beans::PropertyValue( 2356cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 2357cdf0e10cSrcweir "Uri")), 2358cdf0e10cSrcweir -1, 2359cdf0e10cSrcweir uno::makeAny( rInfo.SourceURL ), 2360cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 2361cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 2362cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 2363cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 2364cdf0e10cSrcweir xEnv, 2365cdf0e10cSrcweir rtl::OUString::createFromAscii( 2366cdf0e10cSrcweir "Cannot remove additional properties of source object!" ), 2367cdf0e10cSrcweir this ); 2368cdf0e10cSrcweir // Unreachable 2369cdf0e10cSrcweir } 2370cdf0e10cSrcweir 2371cdf0e10cSrcweir } // rInfo.MoveData 2372cdf0e10cSrcweir } 2373cdf0e10cSrcweir 2374cdf0e10cSrcweir //========================================================================= 2375cdf0e10cSrcweir //static 2376cdf0e10cSrcweir bool Content::hasData( ContentProvider* pProvider, const Uri & rUri ) 2377cdf0e10cSrcweir { 2378cdf0e10cSrcweir if ( rUri.isRoot() ) 2379cdf0e10cSrcweir { 2380cdf0e10cSrcweir return true; // root has no storage 2381cdf0e10cSrcweir } 2382cdf0e10cSrcweir else if ( rUri.isDocument() ) 2383cdf0e10cSrcweir { 2384cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2385cdf0e10cSrcweir = pProvider->queryStorage( rUri.getUri(), READ ); 2386cdf0e10cSrcweir return xStorage.is(); 2387cdf0e10cSrcweir } 2388cdf0e10cSrcweir else 2389cdf0e10cSrcweir { 2390cdf0e10cSrcweir // folder or stream 2391cdf0e10cSrcweir 2392cdf0e10cSrcweir // Ask parent storage. In case that rUri describes a stream, 2393cdf0e10cSrcweir // ContentProvider::queryStorage( rUri ) would return null. 2394cdf0e10cSrcweir 2395cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2396cdf0e10cSrcweir = pProvider->queryStorage( rUri.getParentUri(), READ ); 2397cdf0e10cSrcweir 2398cdf0e10cSrcweir if ( !xStorage.is() ) 2399cdf0e10cSrcweir return false; 2400cdf0e10cSrcweir 2401cdf0e10cSrcweir uno::Reference< container::XNameAccess > xParentNA( 2402cdf0e10cSrcweir xStorage, uno::UNO_QUERY ); 2403cdf0e10cSrcweir 2404cdf0e10cSrcweir OSL_ENSURE( xParentNA.is(), "Got no css.container.XNameAccess!" ); 2405cdf0e10cSrcweir 2406cdf0e10cSrcweir return xParentNA->hasByName( rUri.getDecodedName() ); 2407cdf0e10cSrcweir } 2408cdf0e10cSrcweir } 2409cdf0e10cSrcweir 2410cdf0e10cSrcweir //========================================================================= 2411cdf0e10cSrcweir //static 2412cdf0e10cSrcweir bool Content::loadData( ContentProvider* pProvider, 2413cdf0e10cSrcweir const Uri & rUri, 2414cdf0e10cSrcweir ContentProperties& rProps ) 2415cdf0e10cSrcweir { 2416cdf0e10cSrcweir if ( rUri.isRoot() ) // root has no storage, but can always be created 2417cdf0e10cSrcweir { 2418cdf0e10cSrcweir rProps 2419cdf0e10cSrcweir = ContentProperties( 2420cdf0e10cSrcweir ROOT, pProvider->queryStorageTitle( rUri.getUri() ) ); 2421cdf0e10cSrcweir } 2422cdf0e10cSrcweir else if ( rUri.isDocument() ) // document must have storage 2423cdf0e10cSrcweir { 2424cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2425cdf0e10cSrcweir = pProvider->queryStorage( rUri.getUri(), READ ); 2426cdf0e10cSrcweir 2427cdf0e10cSrcweir if ( !xStorage.is() ) 2428cdf0e10cSrcweir return false; 2429cdf0e10cSrcweir 2430cdf0e10cSrcweir rProps 2431cdf0e10cSrcweir = ContentProperties( 2432cdf0e10cSrcweir DOCUMENT, pProvider->queryStorageTitle( rUri.getUri() ) ); 2433cdf0e10cSrcweir } 2434cdf0e10cSrcweir else // stream or folder; stream has no storage; folder has storage 2435cdf0e10cSrcweir { 2436cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2437cdf0e10cSrcweir = pProvider->queryStorage( rUri.getParentUri(), READ ); 2438cdf0e10cSrcweir 2439cdf0e10cSrcweir if ( !xStorage.is() ) 2440cdf0e10cSrcweir return false; 2441cdf0e10cSrcweir 2442cdf0e10cSrcweir // Check whether exists at all, is stream or folder 2443cdf0e10cSrcweir try 2444cdf0e10cSrcweir { 2445cdf0e10cSrcweir // return: true -> folder 2446cdf0e10cSrcweir // return: false -> stream 2447cdf0e10cSrcweir // NoSuchElementException -> neither folder nor stream 2448cdf0e10cSrcweir bool bIsFolder 2449cdf0e10cSrcweir = xStorage->isStorageElement( rUri.getDecodedName() ); 2450cdf0e10cSrcweir 2451cdf0e10cSrcweir rProps 2452cdf0e10cSrcweir = ContentProperties( 2453cdf0e10cSrcweir bIsFolder ? FOLDER : STREAM, 2454cdf0e10cSrcweir pProvider->queryStorageTitle( rUri.getUri() ) ); 2455cdf0e10cSrcweir } 2456cdf0e10cSrcweir catch ( container::NoSuchElementException const & ) 2457cdf0e10cSrcweir { 2458cdf0e10cSrcweir // there is no element with such name 2459cdf0e10cSrcweir //OSL_ENSURE( false, "Caught NoSuchElementException!" ); 2460cdf0e10cSrcweir return false; 2461cdf0e10cSrcweir } 2462cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2463cdf0e10cSrcweir { 2464cdf0e10cSrcweir // an illegal argument is provided 2465cdf0e10cSrcweir OSL_ENSURE( false, "Caught IllegalArgumentException!" ); 2466cdf0e10cSrcweir return false; 2467cdf0e10cSrcweir } 2468cdf0e10cSrcweir catch ( embed::InvalidStorageException const & ) 2469cdf0e10cSrcweir { 2470cdf0e10cSrcweir // this storage is in invalid state for any reason 2471cdf0e10cSrcweir OSL_ENSURE( false, "Caught InvalidStorageException!" ); 2472cdf0e10cSrcweir return false; 2473cdf0e10cSrcweir } 2474cdf0e10cSrcweir } 2475cdf0e10cSrcweir return true; 2476cdf0e10cSrcweir } 2477cdf0e10cSrcweir 2478cdf0e10cSrcweir //========================================================================= 2479cdf0e10cSrcweir bool Content::storeData( const uno::Reference< io::XInputStream >& xData, 2480cdf0e10cSrcweir const uno::Reference< 2481cdf0e10cSrcweir ucb::XCommandEnvironment >& xEnv ) 2482cdf0e10cSrcweir throw ( ucb::CommandFailedException, 2483cdf0e10cSrcweir task::DocumentPasswordRequest ) 2484cdf0e10cSrcweir { 2485cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2486cdf0e10cSrcweir 2487cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 2488cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 2489cdf0e10cSrcweir { 2490cdf0e10cSrcweir OSL_ENSURE( false, "storeData not supported by root and documents!" ); 2491cdf0e10cSrcweir return false; 2492cdf0e10cSrcweir } 2493cdf0e10cSrcweir 2494cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 2495cdf0e10cSrcweir 2496cdf0e10cSrcweir if ( eType == FOLDER ) 2497cdf0e10cSrcweir { 2498cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2499cdf0e10cSrcweir = m_pProvider->queryStorage( aUri.getUri(), READ_WRITE_CREATE ); 2500cdf0e10cSrcweir 2501cdf0e10cSrcweir if ( !xStorage.is() ) 2502cdf0e10cSrcweir return false; 2503cdf0e10cSrcweir 2504cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( 2505cdf0e10cSrcweir xStorage, uno::UNO_QUERY ); 2506cdf0e10cSrcweir OSL_ENSURE( xPropSet.is(), 2507cdf0e10cSrcweir "Content::storeData - Got no XPropertySet interface!" ); 2508cdf0e10cSrcweir if ( !xPropSet.is() ) 2509cdf0e10cSrcweir return false; 2510cdf0e10cSrcweir 2511cdf0e10cSrcweir try 2512cdf0e10cSrcweir { 2513cdf0e10cSrcweir // According to MBA, if no mediatype is set, folder and all 2514cdf0e10cSrcweir // its contents will be lost on save of the document!!! 2515cdf0e10cSrcweir xPropSet->setPropertyValue( 2516cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), 2517cdf0e10cSrcweir uno::makeAny( 2518cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 2519cdf0e10cSrcweir // @@@ better mediatype 2520cdf0e10cSrcweir "application/binary" ) ) ) ); 2521cdf0e10cSrcweir } 2522cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & ) 2523cdf0e10cSrcweir { 2524cdf0e10cSrcweir OSL_ENSURE( false, "Property MediaType not supported!" ); 2525cdf0e10cSrcweir return false; 2526cdf0e10cSrcweir } 2527cdf0e10cSrcweir catch ( beans::PropertyVetoException const & ) 2528cdf0e10cSrcweir { 2529cdf0e10cSrcweir OSL_ENSURE( false, "Caught PropertyVetoException!" ); 2530cdf0e10cSrcweir return false; 2531cdf0e10cSrcweir } 2532cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2533cdf0e10cSrcweir { 2534cdf0e10cSrcweir OSL_ENSURE( false, "Caught IllegalArgumentException!" ); 2535cdf0e10cSrcweir return false; 2536cdf0e10cSrcweir } 2537cdf0e10cSrcweir catch ( lang::WrappedTargetException const & ) 2538cdf0e10cSrcweir { 2539cdf0e10cSrcweir OSL_ENSURE( false, "Caught WrappedTargetException!" ); 2540cdf0e10cSrcweir return false; 2541cdf0e10cSrcweir } 2542cdf0e10cSrcweir 2543cdf0e10cSrcweir if ( !commitStorage( xStorage ) ) 2544cdf0e10cSrcweir return false; 2545cdf0e10cSrcweir } 2546cdf0e10cSrcweir else if ( eType == STREAM ) 2547cdf0e10cSrcweir { 2548cdf0e10cSrcweir // stream 2549cdf0e10cSrcweir 2550cdf0e10cSrcweir // Important: Parent storage and output stream must be kept alive until 2551cdf0e10cSrcweir // changes have been committed! 2552cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2553cdf0e10cSrcweir = m_pProvider->queryStorage( 2554cdf0e10cSrcweir aUri.getParentUri(), READ_WRITE_CREATE ); 2555cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOut; 2556cdf0e10cSrcweir 2557cdf0e10cSrcweir if ( !xStorage.is() ) 2558cdf0e10cSrcweir return false; 2559cdf0e10cSrcweir 2560cdf0e10cSrcweir if ( xData.is() ) 2561cdf0e10cSrcweir { 2562cdf0e10cSrcweir // May throw CommandFailedException, DocumentPasswordRequest! 2563cdf0e10cSrcweir xOut = getTruncatedOutputStream( xEnv ); 2564cdf0e10cSrcweir 2565cdf0e10cSrcweir OSL_ENSURE( xOut.is(), "No target data stream!" ); 2566cdf0e10cSrcweir 2567cdf0e10cSrcweir try 2568cdf0e10cSrcweir { 2569cdf0e10cSrcweir uno::Sequence< sal_Int8 > aBuffer; 2570cdf0e10cSrcweir sal_Int32 nRead = xData->readSomeBytes( aBuffer, 65536 ); 2571cdf0e10cSrcweir 2572cdf0e10cSrcweir while ( nRead > 0 ) 2573cdf0e10cSrcweir { 2574cdf0e10cSrcweir aBuffer.realloc( nRead ); 2575cdf0e10cSrcweir xOut->writeBytes( aBuffer ); 2576cdf0e10cSrcweir aBuffer.realloc( 0 ); 2577cdf0e10cSrcweir nRead = xData->readSomeBytes( aBuffer, 65536 ); 2578cdf0e10cSrcweir } 2579cdf0e10cSrcweir 2580cdf0e10cSrcweir closeOutputStream( xOut ); 2581cdf0e10cSrcweir } 2582cdf0e10cSrcweir catch ( io::NotConnectedException const & ) 2583cdf0e10cSrcweir { 2584cdf0e10cSrcweir // readSomeBytes, writeBytes 2585cdf0e10cSrcweir OSL_ENSURE( false, "Caught NotConnectedException!" ); 2586cdf0e10cSrcweir closeOutputStream( xOut ); 2587cdf0e10cSrcweir return false; 2588cdf0e10cSrcweir } 2589cdf0e10cSrcweir catch ( io::BufferSizeExceededException const & ) 2590cdf0e10cSrcweir { 2591cdf0e10cSrcweir // readSomeBytes, writeBytes 2592cdf0e10cSrcweir OSL_ENSURE( false, "Caught BufferSizeExceededException!" ); 2593cdf0e10cSrcweir closeOutputStream( xOut ); 2594cdf0e10cSrcweir return false; 2595cdf0e10cSrcweir } 2596cdf0e10cSrcweir catch ( io::IOException const & ) 2597cdf0e10cSrcweir { 2598cdf0e10cSrcweir // readSomeBytes, writeBytes 2599cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2600cdf0e10cSrcweir closeOutputStream( xOut ); 2601cdf0e10cSrcweir return false; 2602cdf0e10cSrcweir } 2603cdf0e10cSrcweir catch ( ... ) 2604cdf0e10cSrcweir { 2605cdf0e10cSrcweir closeOutputStream( xOut ); 2606cdf0e10cSrcweir throw; 2607cdf0e10cSrcweir } 2608cdf0e10cSrcweir } 2609cdf0e10cSrcweir 2610cdf0e10cSrcweir // Commit changes. 2611cdf0e10cSrcweir if ( !commitStorage( xStorage ) ) 2612cdf0e10cSrcweir return false; 2613cdf0e10cSrcweir } 2614cdf0e10cSrcweir else 2615cdf0e10cSrcweir { 2616cdf0e10cSrcweir OSL_ENSURE( false, "Unknown content type!" ); 2617cdf0e10cSrcweir return false; 2618cdf0e10cSrcweir } 2619cdf0e10cSrcweir return true; 2620cdf0e10cSrcweir } 2621cdf0e10cSrcweir 2622cdf0e10cSrcweir //========================================================================= 2623cdf0e10cSrcweir bool Content::renameData( 2624cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xOldId, 2625cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xNewId ) 2626cdf0e10cSrcweir { 2627cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2628cdf0e10cSrcweir 2629cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 2630cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 2631cdf0e10cSrcweir { 2632cdf0e10cSrcweir OSL_ENSURE( false, "renameData not supported by root and documents!" ); 2633cdf0e10cSrcweir return false; 2634cdf0e10cSrcweir } 2635cdf0e10cSrcweir 2636cdf0e10cSrcweir Uri aOldUri( xOldId->getContentIdentifier() ); 2637cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2638cdf0e10cSrcweir = m_pProvider->queryStorage( 2639cdf0e10cSrcweir aOldUri.getParentUri(), READ_WRITE_NOCREATE ); 2640cdf0e10cSrcweir 2641cdf0e10cSrcweir if ( !xStorage.is() ) 2642cdf0e10cSrcweir return false; 2643cdf0e10cSrcweir 2644cdf0e10cSrcweir try 2645cdf0e10cSrcweir { 2646cdf0e10cSrcweir Uri aNewUri( xNewId->getContentIdentifier() ); 2647cdf0e10cSrcweir xStorage->renameElement( 2648cdf0e10cSrcweir aOldUri.getDecodedName(), aNewUri.getDecodedName() ); 2649cdf0e10cSrcweir } 2650cdf0e10cSrcweir catch ( embed::InvalidStorageException const & ) 2651cdf0e10cSrcweir { 2652cdf0e10cSrcweir // this storage is in invalid state for eny reason 2653cdf0e10cSrcweir OSL_ENSURE( false, "Caught InvalidStorageException!" ); 2654cdf0e10cSrcweir return false; 2655cdf0e10cSrcweir } 2656cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2657cdf0e10cSrcweir { 2658cdf0e10cSrcweir // an illegal argument is provided 2659cdf0e10cSrcweir OSL_ENSURE( false, "Caught IllegalArgumentException!" ); 2660cdf0e10cSrcweir return false; 2661cdf0e10cSrcweir } 2662cdf0e10cSrcweir catch ( container::NoSuchElementException const & ) 2663cdf0e10cSrcweir { 2664cdf0e10cSrcweir // there is no element with old name in this storage 2665cdf0e10cSrcweir OSL_ENSURE( false, "Caught NoSuchElementException!" ); 2666cdf0e10cSrcweir return false; 2667cdf0e10cSrcweir } 2668cdf0e10cSrcweir catch ( container::ElementExistException const & ) 2669cdf0e10cSrcweir { 2670cdf0e10cSrcweir // an element with new name already exists in this storage 2671cdf0e10cSrcweir OSL_ENSURE( false, "Caught ElementExistException!" ); 2672cdf0e10cSrcweir return false; 2673cdf0e10cSrcweir } 2674cdf0e10cSrcweir catch ( io::IOException const & ) 2675cdf0e10cSrcweir { 2676cdf0e10cSrcweir // in case of io errors during renaming 2677cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2678cdf0e10cSrcweir return false; 2679cdf0e10cSrcweir } 2680cdf0e10cSrcweir catch ( embed::StorageWrappedTargetException const & ) 2681cdf0e10cSrcweir { 2682cdf0e10cSrcweir // wraps other exceptions 2683cdf0e10cSrcweir OSL_ENSURE( false, "Caught StorageWrappedTargetException!" ); 2684cdf0e10cSrcweir return false; 2685cdf0e10cSrcweir } 2686cdf0e10cSrcweir 2687cdf0e10cSrcweir return commitStorage( xStorage ); 2688cdf0e10cSrcweir } 2689cdf0e10cSrcweir 2690cdf0e10cSrcweir //========================================================================= 2691cdf0e10cSrcweir bool Content::removeData() 2692cdf0e10cSrcweir { 2693cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2694cdf0e10cSrcweir 2695cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 2696cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == DOCUMENT ) ) 2697cdf0e10cSrcweir { 2698cdf0e10cSrcweir OSL_ENSURE( false, "removeData not supported by root and documents!" ); 2699cdf0e10cSrcweir return false; 2700cdf0e10cSrcweir } 2701cdf0e10cSrcweir 2702cdf0e10cSrcweir Uri aUri( m_xIdentifier->getContentIdentifier() ); 2703cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage 2704cdf0e10cSrcweir = m_pProvider->queryStorage( 2705cdf0e10cSrcweir aUri.getParentUri(), READ_WRITE_NOCREATE ); 2706cdf0e10cSrcweir 2707cdf0e10cSrcweir if ( !xStorage.is() ) 2708cdf0e10cSrcweir return false; 2709cdf0e10cSrcweir 2710cdf0e10cSrcweir try 2711cdf0e10cSrcweir { 2712cdf0e10cSrcweir xStorage->removeElement( aUri.getDecodedName() ); 2713cdf0e10cSrcweir } 2714cdf0e10cSrcweir catch ( embed::InvalidStorageException const & ) 2715cdf0e10cSrcweir { 2716cdf0e10cSrcweir // this storage is in invalid state for eny reason 2717cdf0e10cSrcweir OSL_ENSURE( false, "Caught InvalidStorageException!" ); 2718cdf0e10cSrcweir return false; 2719cdf0e10cSrcweir } 2720cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2721cdf0e10cSrcweir { 2722cdf0e10cSrcweir // an illegal argument is provided 2723cdf0e10cSrcweir OSL_ENSURE( false, "Caught IllegalArgumentException!" ); 2724cdf0e10cSrcweir return false; 2725cdf0e10cSrcweir } 2726cdf0e10cSrcweir catch ( container::NoSuchElementException const & ) 2727cdf0e10cSrcweir { 2728cdf0e10cSrcweir // there is no element with this name in this storage 2729cdf0e10cSrcweir OSL_ENSURE( false, "Caught NoSuchElementException!" ); 2730cdf0e10cSrcweir return false; 2731cdf0e10cSrcweir } 2732cdf0e10cSrcweir catch ( io::IOException const & ) 2733cdf0e10cSrcweir { 2734cdf0e10cSrcweir // in case of io errors during renaming 2735cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2736cdf0e10cSrcweir return false; 2737cdf0e10cSrcweir } 2738cdf0e10cSrcweir catch ( embed::StorageWrappedTargetException const & ) 2739cdf0e10cSrcweir { 2740cdf0e10cSrcweir // wraps other exceptions 2741cdf0e10cSrcweir OSL_ENSURE( false, "Caught StorageWrappedTargetException!" ); 2742cdf0e10cSrcweir return false; 2743cdf0e10cSrcweir } 2744cdf0e10cSrcweir 2745cdf0e10cSrcweir return commitStorage( xStorage ); 2746cdf0e10cSrcweir } 2747cdf0e10cSrcweir 2748cdf0e10cSrcweir //========================================================================= 2749cdf0e10cSrcweir bool Content::copyData( const Uri & rSourceUri, const rtl::OUString & rNewName ) 2750cdf0e10cSrcweir { 2751cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2752cdf0e10cSrcweir 2753cdf0e10cSrcweir ContentType eType = m_aProps.getType(); 2754cdf0e10cSrcweir if ( ( eType == ROOT ) || ( eType == STREAM ) ) 2755cdf0e10cSrcweir { 2756cdf0e10cSrcweir OSL_ENSURE( false, "copyData not supported by root and streams!" ); 2757cdf0e10cSrcweir return false; 2758cdf0e10cSrcweir } 2759cdf0e10cSrcweir 2760cdf0e10cSrcweir Uri aDestUri( m_xIdentifier->getContentIdentifier() ); 2761cdf0e10cSrcweir uno::Reference< embed::XStorage > xDestStorage 2762cdf0e10cSrcweir = m_pProvider->queryStorage( aDestUri.getUri(), READ_WRITE_NOCREATE ); 2763cdf0e10cSrcweir 2764cdf0e10cSrcweir if ( !xDestStorage.is() ) 2765cdf0e10cSrcweir return false; 2766cdf0e10cSrcweir 2767cdf0e10cSrcweir uno::Reference< embed::XStorage > xSourceStorage 2768cdf0e10cSrcweir = m_pProvider->queryStorage( rSourceUri.getParentUri(), READ ); 2769cdf0e10cSrcweir 2770cdf0e10cSrcweir if ( !xSourceStorage.is() ) 2771cdf0e10cSrcweir return false; 2772cdf0e10cSrcweir 2773cdf0e10cSrcweir try 2774cdf0e10cSrcweir { 2775cdf0e10cSrcweir xSourceStorage->copyElementTo( rSourceUri.getDecodedName(), 2776cdf0e10cSrcweir xDestStorage, 2777cdf0e10cSrcweir rNewName ); 2778cdf0e10cSrcweir } 2779cdf0e10cSrcweir catch ( embed::InvalidStorageException const & ) 2780cdf0e10cSrcweir { 2781cdf0e10cSrcweir // this storage is in invalid state for eny reason 2782cdf0e10cSrcweir OSL_ENSURE( false, "Caught InvalidStorageException!" ); 2783cdf0e10cSrcweir return false; 2784cdf0e10cSrcweir } 2785cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 2786cdf0e10cSrcweir { 2787cdf0e10cSrcweir // an illegal argument is provided 2788cdf0e10cSrcweir OSL_ENSURE( false, "Caught IllegalArgumentException!" ); 2789cdf0e10cSrcweir return false; 2790cdf0e10cSrcweir } 2791cdf0e10cSrcweir catch ( container::NoSuchElementException const & ) 2792cdf0e10cSrcweir { 2793cdf0e10cSrcweir // there is no element with this name in this storage 2794cdf0e10cSrcweir OSL_ENSURE( false, "Caught NoSuchElementException!" ); 2795cdf0e10cSrcweir return false; 2796cdf0e10cSrcweir } 2797cdf0e10cSrcweir catch ( container::ElementExistException const & ) 2798cdf0e10cSrcweir { 2799cdf0e10cSrcweir // there is no element with this name in this storage 2800cdf0e10cSrcweir OSL_ENSURE( false, "Caught ElementExistException!" ); 2801cdf0e10cSrcweir return false; 2802cdf0e10cSrcweir } 2803cdf0e10cSrcweir catch ( io::IOException const & ) 2804cdf0e10cSrcweir { 2805cdf0e10cSrcweir // in case of io errors during renaming 2806cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2807cdf0e10cSrcweir return false; 2808cdf0e10cSrcweir } 2809cdf0e10cSrcweir catch ( embed::StorageWrappedTargetException const & ) 2810cdf0e10cSrcweir { 2811cdf0e10cSrcweir // wraps other exceptions 2812cdf0e10cSrcweir OSL_ENSURE( false, "Caught StorageWrappedTargetException!" ); 2813cdf0e10cSrcweir return false; 2814cdf0e10cSrcweir } 2815cdf0e10cSrcweir 2816cdf0e10cSrcweir return commitStorage( xDestStorage ); 2817cdf0e10cSrcweir } 2818cdf0e10cSrcweir 2819cdf0e10cSrcweir //========================================================================= 2820cdf0e10cSrcweir // static 2821cdf0e10cSrcweir bool Content::commitStorage( const uno::Reference< embed::XStorage > & xStorage ) 2822cdf0e10cSrcweir { 2823cdf0e10cSrcweir // Commit changes 2824cdf0e10cSrcweir uno::Reference< embed::XTransactedObject > xTO( xStorage, uno::UNO_QUERY ); 2825cdf0e10cSrcweir 2826cdf0e10cSrcweir OSL_ENSURE( xTO.is(), 2827cdf0e10cSrcweir "Required interface css.embed.XTransactedObject missing!" ); 2828cdf0e10cSrcweir try 2829cdf0e10cSrcweir { 2830cdf0e10cSrcweir xTO->commit(); 2831cdf0e10cSrcweir } 2832cdf0e10cSrcweir catch ( io::IOException const & ) 2833cdf0e10cSrcweir { 2834cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2835cdf0e10cSrcweir return false; 2836cdf0e10cSrcweir } 2837cdf0e10cSrcweir catch ( lang::WrappedTargetException const & ) 2838cdf0e10cSrcweir { 2839cdf0e10cSrcweir OSL_ENSURE( false, "Caught WrappedTargetException!" ); 2840cdf0e10cSrcweir return false; 2841cdf0e10cSrcweir } 2842cdf0e10cSrcweir 2843cdf0e10cSrcweir return true; 2844cdf0e10cSrcweir } 2845cdf0e10cSrcweir 2846cdf0e10cSrcweir //========================================================================= 2847cdf0e10cSrcweir // static 2848cdf0e10cSrcweir bool Content::closeOutputStream( 2849cdf0e10cSrcweir const uno::Reference< io::XOutputStream > & xOut ) 2850cdf0e10cSrcweir { 2851cdf0e10cSrcweir if ( xOut.is() ) 2852cdf0e10cSrcweir { 2853cdf0e10cSrcweir try 2854cdf0e10cSrcweir { 2855cdf0e10cSrcweir xOut->closeOutput(); 2856cdf0e10cSrcweir return true; 2857cdf0e10cSrcweir } 2858cdf0e10cSrcweir catch ( io::NotConnectedException const & ) 2859cdf0e10cSrcweir { 2860cdf0e10cSrcweir OSL_ENSURE( false, "Caught NotConnectedException!" ); 2861cdf0e10cSrcweir } 2862cdf0e10cSrcweir catch ( io::BufferSizeExceededException const & ) 2863cdf0e10cSrcweir { 2864cdf0e10cSrcweir OSL_ENSURE( false, "Caught BufferSizeExceededException!" ); 2865cdf0e10cSrcweir } 2866cdf0e10cSrcweir catch ( io::IOException const & ) 2867cdf0e10cSrcweir { 2868cdf0e10cSrcweir OSL_ENSURE( false, "Caught IOException!" ); 2869cdf0e10cSrcweir } 2870cdf0e10cSrcweir } 2871cdf0e10cSrcweir return false; 2872cdf0e10cSrcweir } 2873cdf0e10cSrcweir 2874cdf0e10cSrcweir //========================================================================= 2875cdf0e10cSrcweir static rtl::OUString obtainPassword( 2876cdf0e10cSrcweir const rtl::OUString & rName, 2877cdf0e10cSrcweir task::PasswordRequestMode eMode, 2878cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 2879cdf0e10cSrcweir throw ( ucb::CommandFailedException, 2880cdf0e10cSrcweir task::DocumentPasswordRequest ) 2881cdf0e10cSrcweir { 2882cdf0e10cSrcweir rtl::Reference< DocumentPasswordRequest > xRequest 2883cdf0e10cSrcweir = new DocumentPasswordRequest( eMode, rName ); 2884cdf0e10cSrcweir 2885cdf0e10cSrcweir if ( xEnv.is() ) 2886cdf0e10cSrcweir { 2887cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xIH 2888cdf0e10cSrcweir = xEnv->getInteractionHandler(); 2889cdf0e10cSrcweir if ( xIH.is() ) 2890cdf0e10cSrcweir { 2891cdf0e10cSrcweir xIH->handle( xRequest.get() ); 2892cdf0e10cSrcweir 2893cdf0e10cSrcweir rtl::Reference< ucbhelper::InteractionContinuation > xSelection 2894cdf0e10cSrcweir = xRequest->getSelection(); 2895cdf0e10cSrcweir 2896cdf0e10cSrcweir if ( xSelection.is() ) 2897cdf0e10cSrcweir { 2898cdf0e10cSrcweir // Handler handled the request. 2899cdf0e10cSrcweir uno::Reference< task::XInteractionAbort > xAbort( 2900cdf0e10cSrcweir xSelection.get(), uno::UNO_QUERY ); 2901cdf0e10cSrcweir if ( xAbort.is() ) 2902cdf0e10cSrcweir { 2903cdf0e10cSrcweir throw ucb::CommandFailedException( 2904cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 2905cdf0e10cSrcweir "Abort requested by Interaction Handler." ) ), 2906cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 2907cdf0e10cSrcweir xRequest->getRequest() ); 2908cdf0e10cSrcweir } 2909cdf0e10cSrcweir 2910cdf0e10cSrcweir uno::Reference< task::XInteractionPassword > xPassword( 2911cdf0e10cSrcweir xSelection.get(), uno::UNO_QUERY ); 2912cdf0e10cSrcweir if ( xPassword.is() ) 2913cdf0e10cSrcweir { 2914cdf0e10cSrcweir return xPassword->getPassword(); 2915cdf0e10cSrcweir } 2916cdf0e10cSrcweir 2917cdf0e10cSrcweir // Unknown selection. Should never happen. 2918cdf0e10cSrcweir throw ucb::CommandFailedException( 2919cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 2920cdf0e10cSrcweir "Interaction Handler selected unknown continuation!" ) ), 2921cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 2922cdf0e10cSrcweir xRequest->getRequest() ); 2923cdf0e10cSrcweir } 2924cdf0e10cSrcweir } 2925cdf0e10cSrcweir } 2926cdf0e10cSrcweir 2927cdf0e10cSrcweir // No IH or IH did not handle exception. 2928cdf0e10cSrcweir task::DocumentPasswordRequest aRequest; 2929cdf0e10cSrcweir xRequest->getRequest() >>= aRequest; 2930cdf0e10cSrcweir throw aRequest; 2931cdf0e10cSrcweir } 2932cdf0e10cSrcweir 2933cdf0e10cSrcweir //========================================================================= 2934cdf0e10cSrcweir uno::Reference< io::XInputStream > Content::getInputStream( 2935cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 2936cdf0e10cSrcweir throw ( ucb::CommandFailedException, 2937cdf0e10cSrcweir task::DocumentPasswordRequest ) 2938cdf0e10cSrcweir { 2939cdf0e10cSrcweir rtl::OUString aUri; 2940cdf0e10cSrcweir rtl::OUString aPassword; 2941cdf0e10cSrcweir bool bPasswordRequested = false; 2942cdf0e10cSrcweir 2943cdf0e10cSrcweir { 2944cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2945cdf0e10cSrcweir 2946cdf0e10cSrcweir OSL_ENSURE( m_aProps.getType() == STREAM, 2947cdf0e10cSrcweir "Content::getInputStream - content is no stream!" ); 2948cdf0e10cSrcweir 2949cdf0e10cSrcweir aUri = Uri( m_xIdentifier->getContentIdentifier() ).getUri(); 2950cdf0e10cSrcweir } 2951cdf0e10cSrcweir 2952cdf0e10cSrcweir for ( ;; ) 2953cdf0e10cSrcweir { 2954cdf0e10cSrcweir try 2955cdf0e10cSrcweir { 2956cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 2957cdf0e10cSrcweir return uno::Reference< io::XInputStream >( 2958cdf0e10cSrcweir m_pProvider->queryInputStream( aUri, aPassword ) ); 2959cdf0e10cSrcweir } 2960cdf0e10cSrcweir catch ( packages::WrongPasswordException const & ) 2961cdf0e10cSrcweir { 2962cdf0e10cSrcweir // Obtain (new) password. 2963cdf0e10cSrcweir aPassword 2964cdf0e10cSrcweir = obtainPassword( aUri, /* @@@ find better title */ 2965cdf0e10cSrcweir bPasswordRequested 2966cdf0e10cSrcweir ? task::PasswordRequestMode_PASSWORD_REENTER 2967cdf0e10cSrcweir : task::PasswordRequestMode_PASSWORD_ENTER, 2968cdf0e10cSrcweir xEnv ); 2969cdf0e10cSrcweir bPasswordRequested = true; 2970cdf0e10cSrcweir } 2971cdf0e10cSrcweir } 2972cdf0e10cSrcweir } 2973cdf0e10cSrcweir 2974cdf0e10cSrcweir //========================================================================= 2975cdf0e10cSrcweir static uno::Reference< io::XOutputStream > lcl_getTruncatedOutputStream( 2976cdf0e10cSrcweir const rtl::OUString & rUri, 2977cdf0e10cSrcweir ContentProvider * pProvider, 2978cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 2979cdf0e10cSrcweir throw ( ucb::CommandFailedException, 2980cdf0e10cSrcweir task::DocumentPasswordRequest ) 2981cdf0e10cSrcweir { 2982cdf0e10cSrcweir rtl::OUString aPassword; 2983cdf0e10cSrcweir bool bPasswordRequested = false; 2984cdf0e10cSrcweir for ( ;; ) 2985cdf0e10cSrcweir { 2986cdf0e10cSrcweir try 2987cdf0e10cSrcweir { 2988cdf0e10cSrcweir return uno::Reference< io::XOutputStream >( 2989cdf0e10cSrcweir pProvider->queryOutputStream( 2990cdf0e10cSrcweir rUri, aPassword, true /* truncate */ ) ); 2991cdf0e10cSrcweir } 2992cdf0e10cSrcweir catch ( packages::WrongPasswordException const & ) 2993cdf0e10cSrcweir { 2994cdf0e10cSrcweir // Obtain (new) password. 2995cdf0e10cSrcweir aPassword 2996cdf0e10cSrcweir = obtainPassword( rUri, /* @@@ find better title */ 2997cdf0e10cSrcweir bPasswordRequested 2998cdf0e10cSrcweir ? task::PasswordRequestMode_PASSWORD_REENTER 2999cdf0e10cSrcweir : task::PasswordRequestMode_PASSWORD_ENTER, 3000cdf0e10cSrcweir xEnv ); 3001cdf0e10cSrcweir bPasswordRequested = true; 3002cdf0e10cSrcweir } 3003cdf0e10cSrcweir } 3004cdf0e10cSrcweir } 3005cdf0e10cSrcweir 3006cdf0e10cSrcweir //========================================================================= 3007cdf0e10cSrcweir uno::Reference< io::XOutputStream > Content::getTruncatedOutputStream( 3008cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 3009cdf0e10cSrcweir throw ( ucb::CommandFailedException, 3010cdf0e10cSrcweir task::DocumentPasswordRequest ) 3011cdf0e10cSrcweir { 3012cdf0e10cSrcweir OSL_ENSURE( m_aProps.getType() == STREAM, 3013cdf0e10cSrcweir "Content::getTruncatedOutputStream - content is no stream!" ); 3014cdf0e10cSrcweir 3015cdf0e10cSrcweir return lcl_getTruncatedOutputStream( 3016cdf0e10cSrcweir Uri( m_xIdentifier->getContentIdentifier() ).getUri(), 3017cdf0e10cSrcweir m_pProvider, 3018cdf0e10cSrcweir xEnv ); 3019cdf0e10cSrcweir } 3020cdf0e10cSrcweir 3021cdf0e10cSrcweir //========================================================================= 3022cdf0e10cSrcweir uno::Reference< io::XStream > Content::getStream( 3023cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 3024cdf0e10cSrcweir throw ( ucb::CommandFailedException, 3025cdf0e10cSrcweir task::DocumentPasswordRequest ) 3026cdf0e10cSrcweir { 3027cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 3028cdf0e10cSrcweir 3029cdf0e10cSrcweir OSL_ENSURE( m_aProps.getType() == STREAM, 3030cdf0e10cSrcweir "Content::getStream - content is no stream!" ); 3031cdf0e10cSrcweir 3032cdf0e10cSrcweir rtl::OUString aUri( Uri( m_xIdentifier->getContentIdentifier() ).getUri() ); 3033cdf0e10cSrcweir rtl::OUString aPassword; 3034cdf0e10cSrcweir bool bPasswordRequested = false; 3035cdf0e10cSrcweir for ( ;; ) 3036cdf0e10cSrcweir { 3037cdf0e10cSrcweir try 3038cdf0e10cSrcweir { 3039cdf0e10cSrcweir return uno::Reference< io::XStream >( 3040cdf0e10cSrcweir m_pProvider->queryStream( 3041cdf0e10cSrcweir aUri, aPassword, false /* no truncate */ ) ); 3042cdf0e10cSrcweir } 3043cdf0e10cSrcweir catch ( packages::WrongPasswordException const & ) 3044cdf0e10cSrcweir { 3045cdf0e10cSrcweir // Obtain (new) password. 3046cdf0e10cSrcweir aPassword 3047cdf0e10cSrcweir = obtainPassword( aUri, /* @@@ find better title */ 3048cdf0e10cSrcweir bPasswordRequested 3049cdf0e10cSrcweir ? task::PasswordRequestMode_PASSWORD_REENTER 3050cdf0e10cSrcweir : task::PasswordRequestMode_PASSWORD_ENTER, 3051cdf0e10cSrcweir xEnv ); 3052cdf0e10cSrcweir bPasswordRequested = true; 3053cdf0e10cSrcweir } 3054cdf0e10cSrcweir } 3055cdf0e10cSrcweir } 3056cdf0e10cSrcweir 3057cdf0e10cSrcweir //========================================================================= 3058cdf0e10cSrcweir //========================================================================= 3059cdf0e10cSrcweir // 3060cdf0e10cSrcweir // ContentProperties Implementation. 3061cdf0e10cSrcweir // 3062cdf0e10cSrcweir //========================================================================= 3063cdf0e10cSrcweir //========================================================================= 3064cdf0e10cSrcweir 3065cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > 3066cdf0e10cSrcweir ContentProperties::getCreatableContentsInfo() const 3067cdf0e10cSrcweir { 3068cdf0e10cSrcweir if ( isContentCreator() ) 3069cdf0e10cSrcweir { 3070cdf0e10cSrcweir uno::Sequence< beans::Property > aProps( 1 ); 3071cdf0e10cSrcweir aProps.getArray()[ 0 ] = beans::Property( 3072cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ), 3073cdf0e10cSrcweir -1, 3074cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 3075cdf0e10cSrcweir beans::PropertyAttribute::BOUND ); 3076cdf0e10cSrcweir 3077cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 3078cdf0e10cSrcweir if ( getType() == DOCUMENT ) 3079cdf0e10cSrcweir { 3080cdf0e10cSrcweir // streams cannot be created as direct children of document root 3081cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > aSeq( 1 ); 3082cdf0e10cSrcweir 3083cdf0e10cSrcweir // Folder. 3084cdf0e10cSrcweir aSeq.getArray()[ 0 ].Type 3085cdf0e10cSrcweir = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE ); 3086cdf0e10cSrcweir aSeq.getArray()[ 0 ].Attributes 3087cdf0e10cSrcweir = ucb::ContentInfoAttribute::KIND_FOLDER; 3088cdf0e10cSrcweir aSeq.getArray()[ 0 ].Properties = aProps; 3089cdf0e10cSrcweir 3090cdf0e10cSrcweir return aSeq; 3091cdf0e10cSrcweir } 3092cdf0e10cSrcweir else 3093cdf0e10cSrcweir { 3094cdf0e10cSrcweir #endif 3095cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > aSeq( 2 ); 3096cdf0e10cSrcweir 3097cdf0e10cSrcweir // Folder. 3098cdf0e10cSrcweir aSeq.getArray()[ 0 ].Type 3099cdf0e10cSrcweir = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE ); 3100cdf0e10cSrcweir aSeq.getArray()[ 0 ].Attributes 3101cdf0e10cSrcweir = ucb::ContentInfoAttribute::KIND_FOLDER; 3102cdf0e10cSrcweir aSeq.getArray()[ 0 ].Properties = aProps; 3103cdf0e10cSrcweir 3104cdf0e10cSrcweir // Stream. 3105cdf0e10cSrcweir aSeq.getArray()[ 1 ].Type 3106cdf0e10cSrcweir = rtl::OUString::createFromAscii( TDOC_STREAM_CONTENT_TYPE ); 3107cdf0e10cSrcweir aSeq.getArray()[ 1 ].Attributes 3108cdf0e10cSrcweir = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM 3109cdf0e10cSrcweir | ucb::ContentInfoAttribute::KIND_DOCUMENT; 3110cdf0e10cSrcweir aSeq.getArray()[ 1 ].Properties = aProps; 3111cdf0e10cSrcweir 3112cdf0e10cSrcweir return aSeq; 3113cdf0e10cSrcweir #ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 3114cdf0e10cSrcweir } 3115cdf0e10cSrcweir #endif 3116cdf0e10cSrcweir } 3117cdf0e10cSrcweir else 3118cdf0e10cSrcweir { 3119cdf0e10cSrcweir OSL_ENSURE( sal_False, 3120cdf0e10cSrcweir "getCreatableContentsInfo called on non-contentcreator " 3121cdf0e10cSrcweir "object!" ); 3122cdf0e10cSrcweir 3123cdf0e10cSrcweir return uno::Sequence< ucb::ContentInfo >( 0 ); 3124cdf0e10cSrcweir } 3125cdf0e10cSrcweir } 3126cdf0e10cSrcweir 3127cdf0e10cSrcweir //========================================================================= 3128cdf0e10cSrcweir bool ContentProperties::isContentCreator() const 3129cdf0e10cSrcweir { 3130cdf0e10cSrcweir return ( getType() == FOLDER ) || ( getType() == DOCUMENT ); 3131cdf0e10cSrcweir } 3132