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 25*421ed02eSdamjan #include "precompiled_hier.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /************************************************************************** 28cdf0e10cSrcweir TODO 29cdf0e10cSrcweir ************************************************************************** 30cdf0e10cSrcweir 31cdf0e10cSrcweir - optimize transfer command. "Move" should be implementable much more 32cdf0e10cSrcweir efficient! 33cdf0e10cSrcweir 34cdf0e10cSrcweir ************************************************************************** 35cdf0e10cSrcweir 36cdf0e10cSrcweir - Root Folder vs. 'normal' Folder 37cdf0e10cSrcweir - root doesn't support command 'delete' 38cdf0e10cSrcweir - root doesn't support command 'insert' 39cdf0e10cSrcweir - root needs not created via XContentCreator - queryContent with root 40cdf0e10cSrcweir folder id ( HIERARCHY_ROOT_FOLDER_URL ) always returns a value != 0 41cdf0e10cSrcweir - root has no parent. 42cdf0e10cSrcweir 43cdf0e10cSrcweir *************************************************************************/ 44cdf0e10cSrcweir #include <osl/diagnose.h> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include "osl/doublecheckedlocking.h" 47cdf0e10cSrcweir #include <rtl/ustring.h> 48cdf0e10cSrcweir #include <rtl/ustring.hxx> 49cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 50cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp> 51cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 52cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp> 53cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp> 54cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 55cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfoAttribute.hpp> 56cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp> 57cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> 58cdf0e10cSrcweir #include <com/sun/star/ucb/MissingPropertiesException.hpp> 59cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp> 60cdf0e10cSrcweir #include <com/sun/star/ucb/NameClashException.hpp> 61cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 62cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp> 63cdf0e10cSrcweir #include <com/sun/star/ucb/UnsupportedNameClashException.hpp> 64cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp> 65cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp> 66cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 67cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 68cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx> 69cdf0e10cSrcweir #include <ucbhelper/propertyvalueset.hxx> 70cdf0e10cSrcweir #include <ucbhelper/cancelcommandexecution.hxx> 71cdf0e10cSrcweir #include "hierarchycontent.hxx" 72cdf0e10cSrcweir #include "hierarchyprovider.hxx" 73cdf0e10cSrcweir #include "dynamicresultset.hxx" 74cdf0e10cSrcweir #include "hierarchyuri.hxx" 75cdf0e10cSrcweir 76cdf0e10cSrcweir #include "../inc/urihelper.hxx" 77cdf0e10cSrcweir 78cdf0e10cSrcweir using namespace com::sun::star; 79cdf0e10cSrcweir using namespace hierarchy_ucp; 80cdf0e10cSrcweir 81cdf0e10cSrcweir //========================================================================= 82cdf0e10cSrcweir //========================================================================= 83cdf0e10cSrcweir // 84cdf0e10cSrcweir // HierarchyContent Implementation. 85cdf0e10cSrcweir // 86cdf0e10cSrcweir //========================================================================= 87cdf0e10cSrcweir //========================================================================= 88cdf0e10cSrcweir 89cdf0e10cSrcweir // static ( "virtual" ctor ) 90cdf0e10cSrcweir HierarchyContent* HierarchyContent::create( 91cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 92cdf0e10cSrcweir HierarchyContentProvider* pProvider, 93cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir // Fail, if content does not exist. 96cdf0e10cSrcweir HierarchyContentProperties aProps; 97cdf0e10cSrcweir if ( !loadData( rxSMgr, pProvider, Identifier, aProps ) ) 98cdf0e10cSrcweir return 0; 99cdf0e10cSrcweir 100cdf0e10cSrcweir return new HierarchyContent( rxSMgr, pProvider, Identifier, aProps ); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir //========================================================================= 104cdf0e10cSrcweir // static ( "virtual" ctor ) 105cdf0e10cSrcweir HierarchyContent* HierarchyContent::create( 106cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 107cdf0e10cSrcweir HierarchyContentProvider* pProvider, 108cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 109cdf0e10cSrcweir const ucb::ContentInfo& Info ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir if ( !Info.Type.getLength() ) 112cdf0e10cSrcweir return 0; 113cdf0e10cSrcweir 114cdf0e10cSrcweir if ( !Info.Type.equalsAsciiL( 115cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HIERARCHY_FOLDER_CONTENT_TYPE ) ) && 116cdf0e10cSrcweir !Info.Type.equalsAsciiL( 117cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HIERARCHY_LINK_CONTENT_TYPE ) ) ) 118cdf0e10cSrcweir return 0; 119cdf0e10cSrcweir 120cdf0e10cSrcweir #if 0 121cdf0e10cSrcweir // Fail, if content does exist. 122cdf0e10cSrcweir if ( hasData( rxSMgr, pProvider, Identifier ) ) 123cdf0e10cSrcweir return 0; 124cdf0e10cSrcweir #endif 125cdf0e10cSrcweir 126cdf0e10cSrcweir return new HierarchyContent( rxSMgr, pProvider, Identifier, Info ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //========================================================================= 130cdf0e10cSrcweir HierarchyContent::HierarchyContent( 131cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 132cdf0e10cSrcweir HierarchyContentProvider* pProvider, 133cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 134cdf0e10cSrcweir const HierarchyContentProperties& rProps ) 135cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 136cdf0e10cSrcweir m_aProps( rProps ), 137cdf0e10cSrcweir m_eState( PERSISTENT ), 138cdf0e10cSrcweir m_pProvider( pProvider ), 139cdf0e10cSrcweir m_bCheckedReadOnly( false ), 140cdf0e10cSrcweir m_bIsReadOnly( true ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir setKind( Identifier ); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir //========================================================================= 146cdf0e10cSrcweir HierarchyContent::HierarchyContent( 147cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 148cdf0e10cSrcweir HierarchyContentProvider* pProvider, 149cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 150cdf0e10cSrcweir const ucb::ContentInfo& Info ) 151cdf0e10cSrcweir : ContentImplHelper( rxSMgr, pProvider, Identifier ), 152cdf0e10cSrcweir m_aProps( Info.Type.equalsAsciiL( 153cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HIERARCHY_FOLDER_CONTENT_TYPE ) ) 154cdf0e10cSrcweir ? HierarchyEntryData::FOLDER 155cdf0e10cSrcweir : HierarchyEntryData::LINK ), 156cdf0e10cSrcweir m_eState( TRANSIENT ), 157cdf0e10cSrcweir m_pProvider( pProvider ), 158cdf0e10cSrcweir m_bCheckedReadOnly( false ), 159cdf0e10cSrcweir m_bIsReadOnly( true ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir setKind( Identifier ); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //========================================================================= 165cdf0e10cSrcweir // virtual 166cdf0e10cSrcweir HierarchyContent::~HierarchyContent() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir //========================================================================= 171cdf0e10cSrcweir // 172cdf0e10cSrcweir // XInterface methods. 173cdf0e10cSrcweir // 174cdf0e10cSrcweir //========================================================================= 175cdf0e10cSrcweir 176cdf0e10cSrcweir // virtual 177cdf0e10cSrcweir void SAL_CALL HierarchyContent::acquire() 178cdf0e10cSrcweir throw( ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir ContentImplHelper::acquire(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir //========================================================================= 184cdf0e10cSrcweir // virtual 185cdf0e10cSrcweir void SAL_CALL HierarchyContent::release() 186cdf0e10cSrcweir throw( ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir ContentImplHelper::release(); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir //========================================================================= 192cdf0e10cSrcweir // virtual 193cdf0e10cSrcweir uno::Any SAL_CALL HierarchyContent::queryInterface( const uno::Type & rType ) 194cdf0e10cSrcweir throw ( uno::RuntimeException ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir uno::Any aRet = ContentImplHelper::queryInterface( rType ); 197cdf0e10cSrcweir 198cdf0e10cSrcweir if ( !aRet.hasValue() ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir // Note: isReadOnly may be relative expensive. So avoid calling it 201cdf0e10cSrcweir // unless it is really necessary. 202cdf0e10cSrcweir aRet = cppu::queryInterface( 203cdf0e10cSrcweir rType, static_cast< ucb::XContentCreator * >( this ) ); 204cdf0e10cSrcweir if ( aRet.hasValue() ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir if ( !isFolder() || isReadOnly() ) 207cdf0e10cSrcweir return uno::Any(); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir return aRet; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir //========================================================================= 215cdf0e10cSrcweir // 216cdf0e10cSrcweir // XTypeProvider methods. 217cdf0e10cSrcweir // 218cdf0e10cSrcweir //========================================================================= 219cdf0e10cSrcweir 220cdf0e10cSrcweir XTYPEPROVIDER_COMMON_IMPL( HierarchyContent ); 221cdf0e10cSrcweir 222cdf0e10cSrcweir //========================================================================= 223cdf0e10cSrcweir // virtual 224cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL HierarchyContent::getTypes() 225cdf0e10cSrcweir throw( uno::RuntimeException ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir cppu::OTypeCollection * pCollection = 0; 228cdf0e10cSrcweir 229cdf0e10cSrcweir if ( isFolder() && !isReadOnly() ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir static cppu::OTypeCollection* pFolderTypes = 0; 232cdf0e10cSrcweir 233cdf0e10cSrcweir pCollection = pFolderTypes; 234cdf0e10cSrcweir if ( !pCollection ) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir pCollection = pFolderTypes; 239cdf0e10cSrcweir if ( !pCollection ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 242cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 243cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 244cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 245cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 246cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 247cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 248cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 249cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 250cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 251cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ), 252cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContentCreator ) ); // !! 253cdf0e10cSrcweir pCollection = &aCollection; 254cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 255cdf0e10cSrcweir pFolderTypes = pCollection; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir } 258cdf0e10cSrcweir else { 259cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir } 262cdf0e10cSrcweir else 263cdf0e10cSrcweir { 264cdf0e10cSrcweir static cppu::OTypeCollection* pDocumentTypes = 0; 265cdf0e10cSrcweir 266cdf0e10cSrcweir pCollection = pDocumentTypes; 267cdf0e10cSrcweir if ( !pCollection ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 270cdf0e10cSrcweir 271cdf0e10cSrcweir pCollection = pDocumentTypes; 272cdf0e10cSrcweir if ( !pCollection ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir static cppu::OTypeCollection aCollection( 275cdf0e10cSrcweir CPPU_TYPE_REF( lang::XTypeProvider ), 276cdf0e10cSrcweir CPPU_TYPE_REF( lang::XServiceInfo ), 277cdf0e10cSrcweir CPPU_TYPE_REF( lang::XComponent ), 278cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XContent ), 279cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandProcessor ), 280cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertiesChangeNotifier ), 281cdf0e10cSrcweir CPPU_TYPE_REF( ucb::XCommandInfoChangeNotifier ), 282cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertyContainer ), 283cdf0e10cSrcweir CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), 284cdf0e10cSrcweir CPPU_TYPE_REF( container::XChild ) ); 285cdf0e10cSrcweir pCollection = &aCollection; 286cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 287cdf0e10cSrcweir pDocumentTypes = pCollection; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir else { 291cdf0e10cSrcweir OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir return (*pCollection).getTypes(); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir //========================================================================= 299cdf0e10cSrcweir // 300cdf0e10cSrcweir // XServiceInfo methods. 301cdf0e10cSrcweir // 302cdf0e10cSrcweir //========================================================================= 303cdf0e10cSrcweir 304cdf0e10cSrcweir // virtual 305cdf0e10cSrcweir rtl::OUString SAL_CALL HierarchyContent::getImplementationName() 306cdf0e10cSrcweir throw( uno::RuntimeException ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir return rtl::OUString::createFromAscii( 309cdf0e10cSrcweir "com.sun.star.comp.ucb.HierarchyContent" ); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir //========================================================================= 313cdf0e10cSrcweir // virtual 314cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL 315cdf0e10cSrcweir HierarchyContent::getSupportedServiceNames() 316cdf0e10cSrcweir throw( uno::RuntimeException ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSNS( 1 ); 319cdf0e10cSrcweir 320cdf0e10cSrcweir if ( m_eKind == LINK ) 321cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 322cdf0e10cSrcweir HIERARCHY_LINK_CONTENT_SERVICE_NAME ); 323cdf0e10cSrcweir else if ( m_eKind == FOLDER ) 324cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 325cdf0e10cSrcweir HIERARCHY_FOLDER_CONTENT_SERVICE_NAME ); 326cdf0e10cSrcweir else 327cdf0e10cSrcweir aSNS.getArray()[ 0 ] = rtl::OUString::createFromAscii( 328cdf0e10cSrcweir HIERARCHY_ROOT_FOLDER_CONTENT_SERVICE_NAME ); 329cdf0e10cSrcweir 330cdf0e10cSrcweir return aSNS; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir //========================================================================= 334cdf0e10cSrcweir // 335cdf0e10cSrcweir // XContent methods. 336cdf0e10cSrcweir // 337cdf0e10cSrcweir //========================================================================= 338cdf0e10cSrcweir 339cdf0e10cSrcweir // virtual 340cdf0e10cSrcweir rtl::OUString SAL_CALL HierarchyContent::getContentType() 341cdf0e10cSrcweir throw( uno::RuntimeException ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir return m_aProps.getContentType(); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir //========================================================================= 347cdf0e10cSrcweir // virtual 348cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > SAL_CALL 349cdf0e10cSrcweir HierarchyContent::getIdentifier() 350cdf0e10cSrcweir throw( uno::RuntimeException ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir // Transient? 353cdf0e10cSrcweir if ( m_eState == TRANSIENT ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir // Transient contents have no identifier. 356cdf0e10cSrcweir return uno::Reference< ucb::XContentIdentifier >(); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir return ContentImplHelper::getIdentifier(); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //========================================================================= 363cdf0e10cSrcweir // 364cdf0e10cSrcweir // XCommandProcessor methods. 365cdf0e10cSrcweir // 366cdf0e10cSrcweir //========================================================================= 367cdf0e10cSrcweir 368cdf0e10cSrcweir // virtual 369cdf0e10cSrcweir uno::Any SAL_CALL HierarchyContent::execute( 370cdf0e10cSrcweir const ucb::Command& aCommand, 371cdf0e10cSrcweir sal_Int32 /*CommandId*/, 372cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment >& Environment ) 373cdf0e10cSrcweir throw( uno::Exception, 374cdf0e10cSrcweir ucb::CommandAbortedException, 375cdf0e10cSrcweir uno::RuntimeException ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir uno::Any aRet; 378cdf0e10cSrcweir 379cdf0e10cSrcweir if ( aCommand.Name.equalsAsciiL( 380cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertyValues" ) ) ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 383cdf0e10cSrcweir // getPropertyValues 384cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 385cdf0e10cSrcweir 386cdf0e10cSrcweir uno::Sequence< beans::Property > Properties; 387cdf0e10cSrcweir if ( !( aCommand.Argument >>= Properties ) ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 390cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 391cdf0e10cSrcweir rtl::OUString::createFromAscii( 392cdf0e10cSrcweir "Wrong argument type!" ), 393cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 394cdf0e10cSrcweir -1 ) ), 395cdf0e10cSrcweir Environment ); 396cdf0e10cSrcweir // Unreachable 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir aRet <<= getPropertyValues( Properties ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 402cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "setPropertyValues" ) ) ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 405cdf0e10cSrcweir // setPropertyValues 406cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 407cdf0e10cSrcweir 408cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProperties; 409cdf0e10cSrcweir if ( !( aCommand.Argument >>= aProperties ) ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 412cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 413cdf0e10cSrcweir rtl::OUString::createFromAscii( 414cdf0e10cSrcweir "Wrong argument type!" ), 415cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 416cdf0e10cSrcweir -1 ) ), 417cdf0e10cSrcweir Environment ); 418cdf0e10cSrcweir // Unreachable 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir if ( !aProperties.getLength() ) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 424cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 425cdf0e10cSrcweir rtl::OUString::createFromAscii( 426cdf0e10cSrcweir "No properties!" ), 427cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 428cdf0e10cSrcweir -1 ) ), 429cdf0e10cSrcweir Environment ); 430cdf0e10cSrcweir // Unreachable 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir aRet <<= setPropertyValues( aProperties, Environment ); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 436cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getPropertySetInfo" ) ) ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 439cdf0e10cSrcweir // getPropertySetInfo 440cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 441cdf0e10cSrcweir 442cdf0e10cSrcweir aRet <<= getPropertySetInfo( Environment ); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 445cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "getCommandInfo" ) ) ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 448cdf0e10cSrcweir // getCommandInfo 449cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 450cdf0e10cSrcweir 451cdf0e10cSrcweir aRet <<= getCommandInfo( Environment ); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 454cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "open" ) ) && isFolder() ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 457cdf0e10cSrcweir // open command for a folder content 458cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 459cdf0e10cSrcweir 460cdf0e10cSrcweir ucb::OpenCommandArgument2 aOpenCommand; 461cdf0e10cSrcweir if ( !( aCommand.Argument >>= aOpenCommand ) ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 464cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 465cdf0e10cSrcweir rtl::OUString::createFromAscii( 466cdf0e10cSrcweir "Wrong argument type!" ), 467cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 468cdf0e10cSrcweir -1 ) ), 469cdf0e10cSrcweir Environment ); 470cdf0e10cSrcweir // Unreachable 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir uno::Reference< ucb::XDynamicResultSet > xSet 474cdf0e10cSrcweir = new DynamicResultSet( m_xSMgr, this, aOpenCommand ); 475cdf0e10cSrcweir aRet <<= xSet; 476cdf0e10cSrcweir } 477cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 478cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "insert" ) ) && 479cdf0e10cSrcweir ( m_eKind != ROOT ) && !isReadOnly() ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 482cdf0e10cSrcweir // insert 483cdf0e10cSrcweir // ( Not available at root folder ) 484cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 485cdf0e10cSrcweir 486cdf0e10cSrcweir ucb::InsertCommandArgument aArg; 487cdf0e10cSrcweir if ( !( aCommand.Argument >>= aArg ) ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 490cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 491cdf0e10cSrcweir rtl::OUString::createFromAscii( 492cdf0e10cSrcweir "Wrong argument type!" ), 493cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 494cdf0e10cSrcweir -1 ) ), 495cdf0e10cSrcweir Environment ); 496cdf0e10cSrcweir // Unreachable 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir sal_Int32 nNameClash = aArg.ReplaceExisting 500cdf0e10cSrcweir ? ucb::NameClash::OVERWRITE 501cdf0e10cSrcweir : ucb::NameClash::ERROR; 502cdf0e10cSrcweir insert( nNameClash, Environment ); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 505cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "delete" ) ) && 506cdf0e10cSrcweir ( m_eKind != ROOT ) && !isReadOnly() ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 509cdf0e10cSrcweir // delete 510cdf0e10cSrcweir // ( Not available at root folder ) 511cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 512cdf0e10cSrcweir 513cdf0e10cSrcweir sal_Bool bDeletePhysical = sal_False; 514cdf0e10cSrcweir aCommand.Argument >>= bDeletePhysical; 515cdf0e10cSrcweir destroy( bDeletePhysical, Environment ); 516cdf0e10cSrcweir 517cdf0e10cSrcweir // Remove own and all children's persistent data. 518cdf0e10cSrcweir if ( !removeData() ) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir uno::Any aProps 521cdf0e10cSrcweir = uno::makeAny( 522cdf0e10cSrcweir beans::PropertyValue( 523cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 524cdf0e10cSrcweir "Uri")), 525cdf0e10cSrcweir -1, 526cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 527cdf0e10cSrcweir getContentIdentifier()), 528cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 529cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 530cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 531cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 532cdf0e10cSrcweir Environment, 533cdf0e10cSrcweir rtl::OUString::createFromAscii( 534cdf0e10cSrcweir "Cannot remove persistent data!" ), 535cdf0e10cSrcweir this ); 536cdf0e10cSrcweir // Unreachable 537cdf0e10cSrcweir } 538cdf0e10cSrcweir 539cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 540cdf0e10cSrcweir removeAdditionalPropertySet( sal_True ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 543cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) && 544cdf0e10cSrcweir isFolder() && !isReadOnly() ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 547cdf0e10cSrcweir // transfer 548cdf0e10cSrcweir // ( Not available at link objects ) 549cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 550cdf0e10cSrcweir 551cdf0e10cSrcweir ucb::TransferInfo aInfo; 552cdf0e10cSrcweir if ( !( aCommand.Argument >>= aInfo ) ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 555cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 556cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 557cdf0e10cSrcweir rtl::OUString::createFromAscii( 558cdf0e10cSrcweir "Wrong argument type!" ), 559cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 560cdf0e10cSrcweir -1 ) ), 561cdf0e10cSrcweir Environment ); 562cdf0e10cSrcweir // Unreachable 563cdf0e10cSrcweir } 564cdf0e10cSrcweir 565cdf0e10cSrcweir transfer( aInfo, Environment ); 566cdf0e10cSrcweir } 567cdf0e10cSrcweir else if ( aCommand.Name.equalsAsciiL( 568cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) && 569cdf0e10cSrcweir isFolder() && !isReadOnly() ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 572cdf0e10cSrcweir // createNewContent 573cdf0e10cSrcweir // ( Not available at link objects ) 574cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 575cdf0e10cSrcweir 576cdf0e10cSrcweir ucb::ContentInfo aInfo; 577cdf0e10cSrcweir if ( !( aCommand.Argument >>= aInfo ) ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir OSL_ENSURE( sal_False, "Wrong argument type!" ); 580cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 581cdf0e10cSrcweir uno::makeAny( lang::IllegalArgumentException( 582cdf0e10cSrcweir rtl::OUString::createFromAscii( 583cdf0e10cSrcweir "Wrong argument type!" ), 584cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 585cdf0e10cSrcweir -1 ) ), 586cdf0e10cSrcweir Environment ); 587cdf0e10cSrcweir // Unreachable 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir aRet <<= createNewContent( aInfo ); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir else 593cdf0e10cSrcweir { 594cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 595cdf0e10cSrcweir // Unsupported command 596cdf0e10cSrcweir ////////////////////////////////////////////////////////////////// 597cdf0e10cSrcweir 598cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 599cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 600cdf0e10cSrcweir rtl::OUString(), 601cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 602cdf0e10cSrcweir Environment ); 603cdf0e10cSrcweir // Unreachable 604cdf0e10cSrcweir } 605cdf0e10cSrcweir 606cdf0e10cSrcweir return aRet; 607cdf0e10cSrcweir } 608cdf0e10cSrcweir 609cdf0e10cSrcweir //========================================================================= 610cdf0e10cSrcweir // virtual 611cdf0e10cSrcweir void SAL_CALL HierarchyContent::abort( sal_Int32 /*CommandId*/ ) 612cdf0e10cSrcweir throw( uno::RuntimeException ) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir // @@@ Generally, no action takes much time... 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir //========================================================================= 618cdf0e10cSrcweir // 619cdf0e10cSrcweir // XContentCreator methods. 620cdf0e10cSrcweir // 621cdf0e10cSrcweir //========================================================================= 622cdf0e10cSrcweir 623cdf0e10cSrcweir // virtual 624cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > SAL_CALL 625cdf0e10cSrcweir HierarchyContent::queryCreatableContentsInfo() 626cdf0e10cSrcweir throw( uno::RuntimeException ) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir return m_aProps.getCreatableContentsInfo(); 629cdf0e10cSrcweir } 630cdf0e10cSrcweir 631cdf0e10cSrcweir //========================================================================= 632cdf0e10cSrcweir // virtual 633cdf0e10cSrcweir uno::Reference< ucb::XContent > SAL_CALL 634cdf0e10cSrcweir HierarchyContent::createNewContent( const ucb::ContentInfo& Info ) 635cdf0e10cSrcweir throw( uno::RuntimeException ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir if ( isFolder() ) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 640cdf0e10cSrcweir 641cdf0e10cSrcweir if ( !Info.Type.getLength() ) 642cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 643cdf0e10cSrcweir 644cdf0e10cSrcweir sal_Bool bCreateFolder = 645cdf0e10cSrcweir Info.Type.equalsAsciiL( 646cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HIERARCHY_FOLDER_CONTENT_TYPE ) ); 647cdf0e10cSrcweir 648cdf0e10cSrcweir if ( !bCreateFolder && 649cdf0e10cSrcweir !Info.Type.equalsAsciiL( 650cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( HIERARCHY_LINK_CONTENT_TYPE ) ) ) 651cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 652cdf0e10cSrcweir 653cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 654cdf0e10cSrcweir 655cdf0e10cSrcweir OSL_ENSURE( aURL.getLength() > 0, 656cdf0e10cSrcweir "HierarchyContent::createNewContent - empty identifier!" ); 657cdf0e10cSrcweir 658cdf0e10cSrcweir if ( ( aURL.lastIndexOf( '/' ) + 1 ) != aURL.getLength() ) 659cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 660cdf0e10cSrcweir 661cdf0e10cSrcweir if ( bCreateFolder ) 662cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Folder" ); 663cdf0e10cSrcweir else 664cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "New_Link" ); 665cdf0e10cSrcweir 666cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId 667cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL ); 668cdf0e10cSrcweir 669cdf0e10cSrcweir return create( m_xSMgr, m_pProvider, xId, Info ); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir else 672cdf0e10cSrcweir { 673cdf0e10cSrcweir OSL_ENSURE( sal_False, 674cdf0e10cSrcweir "createNewContent called on non-folder object!" ); 675cdf0e10cSrcweir return uno::Reference< ucb::XContent >(); 676cdf0e10cSrcweir } 677cdf0e10cSrcweir } 678cdf0e10cSrcweir 679cdf0e10cSrcweir //========================================================================= 680cdf0e10cSrcweir // virtual 681cdf0e10cSrcweir rtl::OUString HierarchyContent::getParentURL() 682cdf0e10cSrcweir { 683cdf0e10cSrcweir HierarchyUri aUri( m_xIdentifier->getContentIdentifier() ); 684cdf0e10cSrcweir return aUri.getParentUri(); 685cdf0e10cSrcweir } 686cdf0e10cSrcweir 687cdf0e10cSrcweir //========================================================================= 688cdf0e10cSrcweir //static 689cdf0e10cSrcweir sal_Bool HierarchyContent::hasData( 690cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 691cdf0e10cSrcweir HierarchyContentProvider* pProvider, 692cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir rtl::OUString aURL = Identifier->getContentIdentifier(); 695cdf0e10cSrcweir 696cdf0e10cSrcweir // Am I a root folder? 697cdf0e10cSrcweir HierarchyUri aUri( aURL ); 698cdf0e10cSrcweir if ( aUri.isRootFolder() ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir // hasData must always return 'true' for root folder 701cdf0e10cSrcweir // even if no persistent data exist!!! 702cdf0e10cSrcweir return sal_True; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir return HierarchyEntry( rxSMgr, pProvider, aURL ).hasData(); 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir //========================================================================= 709cdf0e10cSrcweir //static 710cdf0e10cSrcweir sal_Bool HierarchyContent::loadData( 711cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rxSMgr, 712cdf0e10cSrcweir HierarchyContentProvider* pProvider, 713cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier, 714cdf0e10cSrcweir HierarchyContentProperties& rProps ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir rtl::OUString aURL = Identifier->getContentIdentifier(); 717cdf0e10cSrcweir 718cdf0e10cSrcweir // Am I a root folder? 719cdf0e10cSrcweir HierarchyUri aUri( aURL ); 720cdf0e10cSrcweir if ( aUri.isRootFolder() ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir rProps = HierarchyContentProperties( HierarchyEntryData::FOLDER ); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir else 725cdf0e10cSrcweir { 726cdf0e10cSrcweir HierarchyEntry aEntry( rxSMgr, pProvider, aURL ); 727cdf0e10cSrcweir HierarchyEntryData aData; 728cdf0e10cSrcweir if ( !aEntry.getData( aData ) ) 729cdf0e10cSrcweir return sal_False; 730cdf0e10cSrcweir 731cdf0e10cSrcweir rProps = HierarchyContentProperties( aData ); 732cdf0e10cSrcweir } 733cdf0e10cSrcweir return sal_True; 734cdf0e10cSrcweir } 735cdf0e10cSrcweir 736cdf0e10cSrcweir //========================================================================= 737cdf0e10cSrcweir sal_Bool HierarchyContent::storeData() 738cdf0e10cSrcweir { 739cdf0e10cSrcweir HierarchyEntry aEntry( 740cdf0e10cSrcweir m_xSMgr, m_pProvider, m_xIdentifier->getContentIdentifier() ); 741cdf0e10cSrcweir return aEntry.setData( m_aProps.getHierarchyEntryData(), sal_True ); 742cdf0e10cSrcweir } 743cdf0e10cSrcweir 744cdf0e10cSrcweir //========================================================================= 745cdf0e10cSrcweir sal_Bool HierarchyContent::renameData( 746cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xOldId, 747cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xNewId ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir HierarchyEntry aEntry( 750cdf0e10cSrcweir m_xSMgr, m_pProvider, xOldId->getContentIdentifier() ); 751cdf0e10cSrcweir return aEntry.move( xNewId->getContentIdentifier(), 752cdf0e10cSrcweir m_aProps.getHierarchyEntryData() ); 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir //========================================================================= 756cdf0e10cSrcweir sal_Bool HierarchyContent::removeData() 757cdf0e10cSrcweir { 758cdf0e10cSrcweir HierarchyEntry aEntry( 759cdf0e10cSrcweir m_xSMgr, m_pProvider, m_xIdentifier->getContentIdentifier() ); 760cdf0e10cSrcweir return aEntry.remove(); 761cdf0e10cSrcweir } 762cdf0e10cSrcweir 763cdf0e10cSrcweir //========================================================================= 764cdf0e10cSrcweir void HierarchyContent::setKind( 765cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& Identifier ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir if ( m_aProps.getIsFolder() ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir // Am I a root folder? 770cdf0e10cSrcweir HierarchyUri aUri( Identifier->getContentIdentifier() ); 771cdf0e10cSrcweir if ( aUri.isRootFolder() ) 772cdf0e10cSrcweir m_eKind = ROOT; 773cdf0e10cSrcweir else 774cdf0e10cSrcweir m_eKind = FOLDER; 775cdf0e10cSrcweir } 776cdf0e10cSrcweir else 777cdf0e10cSrcweir m_eKind = LINK; 778cdf0e10cSrcweir } 779cdf0e10cSrcweir 780cdf0e10cSrcweir //========================================================================= 781cdf0e10cSrcweir bool HierarchyContent::isReadOnly() 782cdf0e10cSrcweir { 783cdf0e10cSrcweir if ( !m_bCheckedReadOnly ) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 786cdf0e10cSrcweir if ( !m_bCheckedReadOnly ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir m_bCheckedReadOnly = true; 789cdf0e10cSrcweir m_bIsReadOnly = true; 790cdf0e10cSrcweir 791cdf0e10cSrcweir HierarchyUri aUri( m_xIdentifier->getContentIdentifier() ); 792cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigProv 793cdf0e10cSrcweir = m_pProvider->getConfigProvider( aUri.getService() ); 794cdf0e10cSrcweir if ( xConfigProv.is() ) 795cdf0e10cSrcweir { 796cdf0e10cSrcweir uno::Sequence< rtl::OUString > aNames 797cdf0e10cSrcweir = xConfigProv->getAvailableServiceNames(); 798cdf0e10cSrcweir sal_Int32 nCount = aNames.getLength(); 799cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir if ( aNames[ n ].equalsAsciiL( 802cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( 803cdf0e10cSrcweir "com.sun.star.ucb.HierarchyDataReadWriteAccess" 804cdf0e10cSrcweir ) ) ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir m_bIsReadOnly = false; 807cdf0e10cSrcweir break; 808cdf0e10cSrcweir } 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir } 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir return m_bIsReadOnly; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir 817cdf0e10cSrcweir //========================================================================= 818cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > 819cdf0e10cSrcweir HierarchyContent::makeNewIdentifier( const rtl::OUString& rTitle ) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 822cdf0e10cSrcweir 823cdf0e10cSrcweir // Assemble new content identifier... 824cdf0e10cSrcweir HierarchyUri aUri( m_xIdentifier->getContentIdentifier() ); 825cdf0e10cSrcweir rtl::OUString aNewURL = aUri.getParentUri(); 826cdf0e10cSrcweir aNewURL += rtl::OUString::createFromAscii( "/" ); 827cdf0e10cSrcweir aNewURL += ::ucb_impl::urihelper::encodeSegment( rTitle ); 828cdf0e10cSrcweir 829cdf0e10cSrcweir return uno::Reference< ucb::XContentIdentifier >( 830cdf0e10cSrcweir new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewURL ) ); 831cdf0e10cSrcweir } 832cdf0e10cSrcweir 833cdf0e10cSrcweir //========================================================================= 834cdf0e10cSrcweir void HierarchyContent::queryChildren( HierarchyContentRefList& rChildren ) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir if ( ( m_eKind != FOLDER ) && ( m_eKind != ROOT ) ) 837cdf0e10cSrcweir return; 838cdf0e10cSrcweir 839cdf0e10cSrcweir // Obtain a list with a snapshot of all currently instanciated contents 840cdf0e10cSrcweir // from provider and extract the contents which are direct children 841cdf0e10cSrcweir // of this content. 842cdf0e10cSrcweir 843cdf0e10cSrcweir ::ucbhelper::ContentRefList aAllContents; 844cdf0e10cSrcweir m_xProvider->queryExistingContents( aAllContents ); 845cdf0e10cSrcweir 846cdf0e10cSrcweir rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); 847cdf0e10cSrcweir sal_Int32 nURLPos = aURL.lastIndexOf( '/' ); 848cdf0e10cSrcweir 849cdf0e10cSrcweir if ( nURLPos != ( aURL.getLength() - 1 ) ) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir // No trailing slash found. Append. 852cdf0e10cSrcweir aURL += rtl::OUString::createFromAscii( "/" ); 853cdf0e10cSrcweir } 854cdf0e10cSrcweir 855cdf0e10cSrcweir sal_Int32 nLen = aURL.getLength(); 856cdf0e10cSrcweir 857cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin(); 858cdf0e10cSrcweir ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end(); 859cdf0e10cSrcweir 860cdf0e10cSrcweir while ( it != end ) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir ::ucbhelper::ContentImplHelperRef xChild = (*it); 863cdf0e10cSrcweir rtl::OUString aChildURL 864cdf0e10cSrcweir = xChild->getIdentifier()->getContentIdentifier(); 865cdf0e10cSrcweir 866cdf0e10cSrcweir // Is aURL a prefix of aChildURL? 867cdf0e10cSrcweir if ( ( aChildURL.getLength() > nLen ) && 868cdf0e10cSrcweir ( aChildURL.compareTo( aURL, nLen ) == 0 ) ) 869cdf0e10cSrcweir { 870cdf0e10cSrcweir sal_Int32 nPos = nLen; 871cdf0e10cSrcweir nPos = aChildURL.indexOf( '/', nPos ); 872cdf0e10cSrcweir 873cdf0e10cSrcweir if ( ( nPos == -1 ) || 874cdf0e10cSrcweir ( nPos == ( aChildURL.getLength() - 1 ) ) ) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir // No further slashes/ only a final slash. It's a child! 877cdf0e10cSrcweir rChildren.push_back( 878cdf0e10cSrcweir HierarchyContentRef( 879cdf0e10cSrcweir static_cast< HierarchyContent * >( xChild.get() ) ) ); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir } 882cdf0e10cSrcweir ++it; 883cdf0e10cSrcweir } 884cdf0e10cSrcweir } 885cdf0e10cSrcweir 886cdf0e10cSrcweir //========================================================================= 887cdf0e10cSrcweir sal_Bool HierarchyContent::exchangeIdentity( 888cdf0e10cSrcweir const uno::Reference< ucb::XContentIdentifier >& xNewId ) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir if ( !xNewId.is() ) 891cdf0e10cSrcweir return sal_False; 892cdf0e10cSrcweir 893cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 894cdf0e10cSrcweir 895cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 896cdf0e10cSrcweir 897cdf0e10cSrcweir // Already persistent? 898cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 899cdf0e10cSrcweir { 900cdf0e10cSrcweir OSL_ENSURE( sal_False, 901cdf0e10cSrcweir "HierarchyContent::exchangeIdentity - Not persistent!" ); 902cdf0e10cSrcweir return sal_False; 903cdf0e10cSrcweir } 904cdf0e10cSrcweir 905cdf0e10cSrcweir // Am I the root folder? 906cdf0e10cSrcweir if ( m_eKind == ROOT ) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir OSL_ENSURE( sal_False, "HierarchyContent::exchangeIdentity - " 909cdf0e10cSrcweir "Not supported by root folder!" ); 910cdf0e10cSrcweir return sal_False; 911cdf0e10cSrcweir } 912cdf0e10cSrcweir 913cdf0e10cSrcweir // Exchange own identitity. 914cdf0e10cSrcweir 915cdf0e10cSrcweir // Fail, if a content with given id already exists. 916cdf0e10cSrcweir if ( !hasData( xNewId ) ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir rtl::OUString aOldURL = m_xIdentifier->getContentIdentifier(); 919cdf0e10cSrcweir 920cdf0e10cSrcweir aGuard.clear(); 921cdf0e10cSrcweir if ( exchange( xNewId ) ) 922cdf0e10cSrcweir { 923cdf0e10cSrcweir if ( m_eKind == FOLDER ) 924cdf0e10cSrcweir { 925cdf0e10cSrcweir // Process instanciated children... 926cdf0e10cSrcweir 927cdf0e10cSrcweir HierarchyContentRefList aChildren; 928cdf0e10cSrcweir queryChildren( aChildren ); 929cdf0e10cSrcweir 930cdf0e10cSrcweir HierarchyContentRefList::const_iterator it = aChildren.begin(); 931cdf0e10cSrcweir HierarchyContentRefList::const_iterator end = aChildren.end(); 932cdf0e10cSrcweir 933cdf0e10cSrcweir while ( it != end ) 934cdf0e10cSrcweir { 935cdf0e10cSrcweir HierarchyContentRef xChild = (*it); 936cdf0e10cSrcweir 937cdf0e10cSrcweir // Create new content identifier for the child... 938cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldChildId 939cdf0e10cSrcweir = xChild->getIdentifier(); 940cdf0e10cSrcweir rtl::OUString aOldChildURL 941cdf0e10cSrcweir = xOldChildId->getContentIdentifier(); 942cdf0e10cSrcweir rtl::OUString aNewChildURL 943cdf0e10cSrcweir = aOldChildURL.replaceAt( 944cdf0e10cSrcweir 0, 945cdf0e10cSrcweir aOldURL.getLength(), 946cdf0e10cSrcweir xNewId->getContentIdentifier() ); 947cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewChildId 948cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( 949cdf0e10cSrcweir m_xSMgr, aNewChildURL ); 950cdf0e10cSrcweir 951cdf0e10cSrcweir if ( !xChild->exchangeIdentity( xNewChildId ) ) 952cdf0e10cSrcweir return sal_False; 953cdf0e10cSrcweir 954cdf0e10cSrcweir ++it; 955cdf0e10cSrcweir } 956cdf0e10cSrcweir } 957cdf0e10cSrcweir return sal_True; 958cdf0e10cSrcweir } 959cdf0e10cSrcweir } 960cdf0e10cSrcweir 961cdf0e10cSrcweir OSL_ENSURE( sal_False, 962cdf0e10cSrcweir "HierarchyContent::exchangeIdentity - " 963cdf0e10cSrcweir "Panic! Cannot exchange identity!" ); 964cdf0e10cSrcweir return sal_False; 965cdf0e10cSrcweir } 966cdf0e10cSrcweir 967cdf0e10cSrcweir //========================================================================= 968cdf0e10cSrcweir // static 969cdf0e10cSrcweir uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues( 970cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rSMgr, 971cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties, 972cdf0e10cSrcweir const HierarchyContentProperties& rData, 973cdf0e10cSrcweir HierarchyContentProvider* pProvider, 974cdf0e10cSrcweir const rtl::OUString& rContentId ) 975cdf0e10cSrcweir { 976cdf0e10cSrcweir // Note: Empty sequence means "get values of all supported properties". 977cdf0e10cSrcweir 978cdf0e10cSrcweir rtl::Reference< ::ucbhelper::PropertyValueSet > xRow 979cdf0e10cSrcweir = new ::ucbhelper::PropertyValueSet( rSMgr ); 980cdf0e10cSrcweir 981cdf0e10cSrcweir sal_Int32 nCount = rProperties.getLength(); 982cdf0e10cSrcweir if ( nCount ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xAdditionalPropSet; 985cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 986cdf0e10cSrcweir 987cdf0e10cSrcweir const beans::Property* pProps = rProperties.getConstArray(); 988cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 991cdf0e10cSrcweir 992cdf0e10cSrcweir // Process Core properties. 993cdf0e10cSrcweir 994cdf0e10cSrcweir if ( rProp.Name.equalsAsciiL( 995cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 996cdf0e10cSrcweir { 997cdf0e10cSrcweir xRow->appendString ( rProp, rData.getContentType() ); 998cdf0e10cSrcweir } 999cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1000cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir xRow->appendString ( rProp, rData.getTitle() ); 1003cdf0e10cSrcweir } 1004cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1005cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 1006cdf0e10cSrcweir { 1007cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.getIsDocument() ); 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1010cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir xRow->appendBoolean( rProp, rData.getIsFolder() ); 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1015cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir xRow->appendObject( 1018cdf0e10cSrcweir rProp, uno::makeAny( rData.getCreatableContentsInfo() ) ); 1019cdf0e10cSrcweir } 1020cdf0e10cSrcweir else if ( rProp.Name.equalsAsciiL( 1021cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "TargetURL" ) ) ) 1022cdf0e10cSrcweir { 1023cdf0e10cSrcweir // TargetURL is only supported by links. 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir if ( rData.getIsDocument() ) 1026cdf0e10cSrcweir xRow->appendString( rProp, rData.getTargetURL() ); 1027cdf0e10cSrcweir else 1028cdf0e10cSrcweir xRow->appendVoid( rProp ); 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir else 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir xAdditionalPropSet 1037cdf0e10cSrcweir = uno::Reference< beans::XPropertySet >( 1038cdf0e10cSrcweir pProvider->getAdditionalPropertySet( rContentId, 1039cdf0e10cSrcweir sal_False ), 1040cdf0e10cSrcweir uno::UNO_QUERY ); 1041cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir if ( !xRow->appendPropertySetValue( 1047cdf0e10cSrcweir xAdditionalPropSet, 1048cdf0e10cSrcweir rProp ) ) 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir // Append empty entry. 1051cdf0e10cSrcweir xRow->appendVoid( rProp ); 1052cdf0e10cSrcweir } 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir else 1055cdf0e10cSrcweir { 1056cdf0e10cSrcweir // Append empty entry. 1057cdf0e10cSrcweir xRow->appendVoid( rProp ); 1058cdf0e10cSrcweir } 1059cdf0e10cSrcweir } 1060cdf0e10cSrcweir } 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir else 1063cdf0e10cSrcweir { 1064cdf0e10cSrcweir // Append all Core Properties. 1065cdf0e10cSrcweir xRow->appendString ( 1066cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "ContentType" ), 1067cdf0e10cSrcweir -1, 1068cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1069cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1070cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1071cdf0e10cSrcweir rData.getContentType() ); 1072cdf0e10cSrcweir xRow->appendString ( 1073cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "Title" ), 1074cdf0e10cSrcweir -1, 1075cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1076cdf0e10cSrcweir // @@@ Might actually be read-only! 1077cdf0e10cSrcweir beans::PropertyAttribute::BOUND ), 1078cdf0e10cSrcweir rData.getTitle() ); 1079cdf0e10cSrcweir xRow->appendBoolean( 1080cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsDocument" ), 1081cdf0e10cSrcweir -1, 1082cdf0e10cSrcweir getCppuBooleanType(), 1083cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1084cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1085cdf0e10cSrcweir rData.getIsDocument() ); 1086cdf0e10cSrcweir xRow->appendBoolean( 1087cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "IsFolder" ), 1088cdf0e10cSrcweir -1, 1089cdf0e10cSrcweir getCppuBooleanType(), 1090cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1091cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1092cdf0e10cSrcweir rData.getIsFolder() ); 1093cdf0e10cSrcweir 1094cdf0e10cSrcweir if ( rData.getIsDocument() ) 1095cdf0e10cSrcweir xRow->appendString( 1096cdf0e10cSrcweir beans::Property( rtl::OUString::createFromAscii( "TargetURL" ), 1097cdf0e10cSrcweir -1, 1098cdf0e10cSrcweir getCppuType( 1099cdf0e10cSrcweir static_cast< const rtl::OUString * >( 0 ) ), 1100cdf0e10cSrcweir // @@@ Might actually be read-only! 1101cdf0e10cSrcweir beans::PropertyAttribute::BOUND ), 1102cdf0e10cSrcweir rData.getTargetURL() ); 1103cdf0e10cSrcweir xRow->appendObject( 1104cdf0e10cSrcweir beans::Property( 1105cdf0e10cSrcweir rtl::OUString::createFromAscii( "CreatableContentsInfo" ), 1106cdf0e10cSrcweir -1, 1107cdf0e10cSrcweir getCppuType( static_cast< 1108cdf0e10cSrcweir const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 1109cdf0e10cSrcweir beans::PropertyAttribute::BOUND 1110cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ), 1111cdf0e10cSrcweir uno::makeAny( rData.getCreatableContentsInfo() ) ); 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir // Append all Additional Core Properties. 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet( 1116cdf0e10cSrcweir pProvider->getAdditionalPropertySet( rContentId, sal_False ), 1117cdf0e10cSrcweir uno::UNO_QUERY ); 1118cdf0e10cSrcweir xRow->appendPropertySet( xSet ); 1119cdf0e10cSrcweir } 1120cdf0e10cSrcweir 1121cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( xRow.get() ); 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir //========================================================================= 1125cdf0e10cSrcweir uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues( 1126cdf0e10cSrcweir const uno::Sequence< beans::Property >& rProperties ) 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( m_aMutex ); 1129cdf0e10cSrcweir return getPropertyValues( m_xSMgr, 1130cdf0e10cSrcweir rProperties, 1131cdf0e10cSrcweir m_aProps, 1132cdf0e10cSrcweir m_pProvider, 1133cdf0e10cSrcweir m_xIdentifier->getContentIdentifier() ); 1134cdf0e10cSrcweir } 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir //========================================================================= 1137cdf0e10cSrcweir uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( 1138cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rValues, 1139cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 1140cdf0e10cSrcweir throw( uno::Exception ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( rValues.getLength() ); 1145cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); 1146cdf0e10cSrcweir sal_Int32 nChanged = 0; 1147cdf0e10cSrcweir 1148cdf0e10cSrcweir beans::PropertyChangeEvent aEvent; 1149cdf0e10cSrcweir aEvent.Source = static_cast< cppu::OWeakObject * >( this ); 1150cdf0e10cSrcweir aEvent.Further = sal_False; 1151cdf0e10cSrcweir // aEvent.PropertyName = 1152cdf0e10cSrcweir aEvent.PropertyHandle = -1; 1153cdf0e10cSrcweir // aEvent.OldValue = 1154cdf0e10cSrcweir // aEvent.NewValue = 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir const beans::PropertyValue* pValues = rValues.getConstArray(); 1157cdf0e10cSrcweir sal_Int32 nCount = rValues.getLength(); 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xAdditionalPropSet; 1160cdf0e10cSrcweir sal_Bool bTriedToGetAdditonalPropSet = sal_False; 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir sal_Bool bExchange = sal_False; 1163cdf0e10cSrcweir rtl::OUString aOldTitle; 1164cdf0e10cSrcweir rtl::OUString aOldName; 1165cdf0e10cSrcweir sal_Int32 nTitlePos = -1; 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1168cdf0e10cSrcweir { 1169cdf0e10cSrcweir const beans::PropertyValue& rValue = pValues[ n ]; 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir if ( rValue.Name.equalsAsciiL( 1172cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) 1173cdf0e10cSrcweir { 1174cdf0e10cSrcweir // Read-only property! 1175cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1176cdf0e10cSrcweir rtl::OUString::createFromAscii( 1177cdf0e10cSrcweir "Property is read-only!" ), 1178cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1181cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir // Read-only property! 1184cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1185cdf0e10cSrcweir rtl::OUString::createFromAscii( 1186cdf0e10cSrcweir "Property is read-only!" ), 1187cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1190cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ) 1191cdf0e10cSrcweir { 1192cdf0e10cSrcweir // Read-only property! 1193cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1194cdf0e10cSrcweir rtl::OUString::createFromAscii( 1195cdf0e10cSrcweir "Property is read-only!" ), 1196cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1197cdf0e10cSrcweir } 1198cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1199cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) 1200cdf0e10cSrcweir { 1201cdf0e10cSrcweir // Read-only property! 1202cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1203cdf0e10cSrcweir rtl::OUString::createFromAscii( 1204cdf0e10cSrcweir "Property is read-only!" ), 1205cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1206cdf0e10cSrcweir } 1207cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1208cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir if ( isReadOnly() ) 1211cdf0e10cSrcweir { 1212cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1213cdf0e10cSrcweir rtl::OUString::createFromAscii( 1214cdf0e10cSrcweir "Property is read-only!" ), 1215cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1216cdf0e10cSrcweir } 1217cdf0e10cSrcweir else 1218cdf0e10cSrcweir { 1219cdf0e10cSrcweir rtl::OUString aNewValue; 1220cdf0e10cSrcweir if ( rValue.Value >>= aNewValue ) 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir // No empty titles! 1223cdf0e10cSrcweir if ( aNewValue.getLength() > 0 ) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir if ( aNewValue != m_aProps.getTitle() ) 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir // modified title -> modified URL -> exchange ! 1228cdf0e10cSrcweir if ( m_eState == PERSISTENT ) 1229cdf0e10cSrcweir bExchange = sal_True; 1230cdf0e10cSrcweir 1231cdf0e10cSrcweir aOldTitle = m_aProps.getTitle(); 1232cdf0e10cSrcweir aOldName = m_aProps.getName(); 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir m_aProps.setTitle( aNewValue ); 1235cdf0e10cSrcweir m_aProps.setName( 1236cdf0e10cSrcweir ::ucb_impl::urihelper::encodeSegment( 1237cdf0e10cSrcweir aNewValue ) ); 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir // property change event will be set later... 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir // remember position within sequence of values 1242cdf0e10cSrcweir // (for error handling). 1243cdf0e10cSrcweir nTitlePos = n; 1244cdf0e10cSrcweir } 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir else 1247cdf0e10cSrcweir { 1248cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException( 1249cdf0e10cSrcweir rtl::OUString::createFromAscii( 1250cdf0e10cSrcweir "Empty title not allowed!" ), 1251cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1252cdf0e10cSrcweir -1 ); 1253cdf0e10cSrcweir } 1254cdf0e10cSrcweir } 1255cdf0e10cSrcweir else 1256cdf0e10cSrcweir { 1257cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException( 1258cdf0e10cSrcweir rtl::OUString::createFromAscii( 1259cdf0e10cSrcweir "Property value has wrong type!" ), 1260cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1261cdf0e10cSrcweir } 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir } 1264cdf0e10cSrcweir else if ( rValue.Name.equalsAsciiL( 1265cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "TargetURL" ) ) ) 1266cdf0e10cSrcweir { 1267cdf0e10cSrcweir if ( isReadOnly() ) 1268cdf0e10cSrcweir { 1269cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalAccessException( 1270cdf0e10cSrcweir rtl::OUString::createFromAscii( 1271cdf0e10cSrcweir "Property is read-only!" ), 1272cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir else 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir // TargetURL is only supported by links. 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir if ( m_eKind == LINK ) 1279cdf0e10cSrcweir { 1280cdf0e10cSrcweir rtl::OUString aNewValue; 1281cdf0e10cSrcweir if ( rValue.Value >>= aNewValue ) 1282cdf0e10cSrcweir { 1283cdf0e10cSrcweir // No empty target URL's! 1284cdf0e10cSrcweir if ( aNewValue.getLength() > 0 ) 1285cdf0e10cSrcweir { 1286cdf0e10cSrcweir if ( aNewValue != m_aProps.getTargetURL() ) 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir aEvent.PropertyName = rValue.Name; 1289cdf0e10cSrcweir aEvent.OldValue 1290cdf0e10cSrcweir = uno::makeAny( m_aProps.getTargetURL() ); 1291cdf0e10cSrcweir aEvent.NewValue 1292cdf0e10cSrcweir = uno::makeAny( aNewValue ); 1293cdf0e10cSrcweir 1294cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir m_aProps.setTargetURL( aNewValue ); 1297cdf0e10cSrcweir nChanged++; 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir else 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir aRet[ n ] <<= lang::IllegalArgumentException( 1303cdf0e10cSrcweir rtl::OUString::createFromAscii( 1304cdf0e10cSrcweir "Empty target URL not allowed!" ), 1305cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1306cdf0e10cSrcweir -1 ); 1307cdf0e10cSrcweir } 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir else 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir aRet[ n ] <<= beans::IllegalTypeException( 1312cdf0e10cSrcweir rtl::OUString::createFromAscii( 1313cdf0e10cSrcweir "Property value has wrong type!" ), 1314cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir } 1317cdf0e10cSrcweir else 1318cdf0e10cSrcweir { 1319cdf0e10cSrcweir aRet[ n ] <<= beans::UnknownPropertyException( 1320cdf0e10cSrcweir rtl::OUString::createFromAscii( 1321cdf0e10cSrcweir "TargetURL only supported by links!" ), 1322cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir } 1325cdf0e10cSrcweir } 1326cdf0e10cSrcweir else 1327cdf0e10cSrcweir { 1328cdf0e10cSrcweir // Not a Core Property! Maybe it's an Additional Core Property?! 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir if ( !bTriedToGetAdditonalPropSet && !xAdditionalPropSet.is() ) 1331cdf0e10cSrcweir { 1332cdf0e10cSrcweir xAdditionalPropSet = getAdditionalPropertySet( sal_False ); 1333cdf0e10cSrcweir bTriedToGetAdditonalPropSet = sal_True; 1334cdf0e10cSrcweir } 1335cdf0e10cSrcweir 1336cdf0e10cSrcweir if ( xAdditionalPropSet.is() ) 1337cdf0e10cSrcweir { 1338cdf0e10cSrcweir try 1339cdf0e10cSrcweir { 1340cdf0e10cSrcweir uno::Any aOldValue = xAdditionalPropSet->getPropertyValue( 1341cdf0e10cSrcweir rValue.Name ); 1342cdf0e10cSrcweir if ( aOldValue != rValue.Value ) 1343cdf0e10cSrcweir { 1344cdf0e10cSrcweir xAdditionalPropSet->setPropertyValue( 1345cdf0e10cSrcweir rValue.Name, rValue.Value ); 1346cdf0e10cSrcweir 1347cdf0e10cSrcweir aEvent.PropertyName = rValue.Name; 1348cdf0e10cSrcweir aEvent.OldValue = aOldValue; 1349cdf0e10cSrcweir aEvent.NewValue = rValue.Value; 1350cdf0e10cSrcweir 1351cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1352cdf0e10cSrcweir nChanged++; 1353cdf0e10cSrcweir } 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir catch ( beans::UnknownPropertyException const & e ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir aRet[ n ] <<= e; 1358cdf0e10cSrcweir } 1359cdf0e10cSrcweir catch ( lang::WrappedTargetException const & e ) 1360cdf0e10cSrcweir { 1361cdf0e10cSrcweir aRet[ n ] <<= e; 1362cdf0e10cSrcweir } 1363cdf0e10cSrcweir catch ( beans::PropertyVetoException const & e ) 1364cdf0e10cSrcweir { 1365cdf0e10cSrcweir aRet[ n ] <<= e; 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & e ) 1368cdf0e10cSrcweir { 1369cdf0e10cSrcweir aRet[ n ] <<= e; 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir } 1372cdf0e10cSrcweir else 1373cdf0e10cSrcweir { 1374cdf0e10cSrcweir aRet[ n ] <<= uno::Exception( 1375cdf0e10cSrcweir rtl::OUString::createFromAscii( 1376cdf0e10cSrcweir "No property set for storing the value!" ), 1377cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir } 1380cdf0e10cSrcweir } 1381cdf0e10cSrcweir 1382cdf0e10cSrcweir if ( bExchange ) 1383cdf0e10cSrcweir { 1384cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xOldId 1385cdf0e10cSrcweir = m_xIdentifier; 1386cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xNewId 1387cdf0e10cSrcweir = makeNewIdentifier( m_aProps.getTitle() ); 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir aGuard.clear(); 1390cdf0e10cSrcweir if ( exchangeIdentity( xNewId ) ) 1391cdf0e10cSrcweir { 1392cdf0e10cSrcweir // Adapt persistent data. 1393cdf0e10cSrcweir renameData( xOldId, xNewId ); 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir // Adapt Additional Core Properties. 1396cdf0e10cSrcweir renameAdditionalPropertySet( xOldId->getContentIdentifier(), 1397cdf0e10cSrcweir xNewId->getContentIdentifier(), 1398cdf0e10cSrcweir sal_True ); 1399cdf0e10cSrcweir } 1400cdf0e10cSrcweir else 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir // Roll-back. 1403cdf0e10cSrcweir m_aProps.setTitle( aOldTitle ); 1404cdf0e10cSrcweir m_aProps.setName ( aOldName ); 1405cdf0e10cSrcweir 1406cdf0e10cSrcweir aOldTitle = aOldName = rtl::OUString(); 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir // Set error . 1409cdf0e10cSrcweir aRet[ nTitlePos ] <<= uno::Exception( 1410cdf0e10cSrcweir rtl::OUString::createFromAscii( "Exchange failed!" ), 1411cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ); 1412cdf0e10cSrcweir } 1413cdf0e10cSrcweir } 1414cdf0e10cSrcweir 1415cdf0e10cSrcweir if ( aOldTitle.getLength() ) 1416cdf0e10cSrcweir { 1417cdf0e10cSrcweir aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" ); 1418cdf0e10cSrcweir aEvent.OldValue = uno::makeAny( aOldTitle ); 1419cdf0e10cSrcweir aEvent.NewValue = uno::makeAny( m_aProps.getTitle() ); 1420cdf0e10cSrcweir 1421cdf0e10cSrcweir aChanges.getArray()[ nChanged ] = aEvent; 1422cdf0e10cSrcweir nChanged++; 1423cdf0e10cSrcweir } 1424cdf0e10cSrcweir 1425cdf0e10cSrcweir if ( nChanged > 0 ) 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir // Save changes, if content was already made persistent. 1428cdf0e10cSrcweir if ( !bExchange && ( m_eState == PERSISTENT ) ) 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir if ( !storeData() ) 1431cdf0e10cSrcweir { 1432cdf0e10cSrcweir uno::Any aProps 1433cdf0e10cSrcweir = uno::makeAny( 1434cdf0e10cSrcweir beans::PropertyValue( 1435cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1436cdf0e10cSrcweir "Uri")), 1437cdf0e10cSrcweir -1, 1438cdf0e10cSrcweir uno::makeAny(m_xIdentifier-> 1439cdf0e10cSrcweir getContentIdentifier()), 1440cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1441cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1442cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 1443cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1444cdf0e10cSrcweir xEnv, 1445cdf0e10cSrcweir rtl::OUString::createFromAscii( 1446cdf0e10cSrcweir "Cannot store persistent data!" ), 1447cdf0e10cSrcweir this ); 1448cdf0e10cSrcweir // Unreachable 1449cdf0e10cSrcweir } 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir 1452cdf0e10cSrcweir aChanges.realloc( nChanged ); 1453cdf0e10cSrcweir 1454cdf0e10cSrcweir aGuard.clear(); 1455cdf0e10cSrcweir notifyPropertiesChange( aChanges ); 1456cdf0e10cSrcweir } 1457cdf0e10cSrcweir 1458cdf0e10cSrcweir return aRet; 1459cdf0e10cSrcweir } 1460cdf0e10cSrcweir 1461cdf0e10cSrcweir //========================================================================= 1462cdf0e10cSrcweir void HierarchyContent::insert( sal_Int32 nNameClashResolve, 1463cdf0e10cSrcweir const uno::Reference< 1464cdf0e10cSrcweir ucb::XCommandEnvironment > & xEnv ) 1465cdf0e10cSrcweir throw( uno::Exception ) 1466cdf0e10cSrcweir { 1467cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir // Am I the root folder? 1470cdf0e10cSrcweir if ( m_eKind == ROOT ) 1471cdf0e10cSrcweir { 1472cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1473cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 1474cdf0e10cSrcweir rtl::OUString::createFromAscii( 1475cdf0e10cSrcweir "Not supported by root folder!" ), 1476cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1477cdf0e10cSrcweir xEnv ); 1478cdf0e10cSrcweir // Unreachable 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir // Check, if all required properties were set. 1482cdf0e10cSrcweir if ( m_aProps.getTitle().getLength() == 0 ) 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir uno::Sequence< rtl::OUString > aProps( 1 ); 1485cdf0e10cSrcweir aProps[ 0 ] = rtl::OUString::createFromAscii( "Title" ); 1486cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1487cdf0e10cSrcweir uno::makeAny( ucb::MissingPropertiesException( 1488cdf0e10cSrcweir rtl::OUString(), 1489cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1490cdf0e10cSrcweir aProps ) ), 1491cdf0e10cSrcweir xEnv ); 1492cdf0e10cSrcweir // Unreachable 1493cdf0e10cSrcweir } 1494cdf0e10cSrcweir 1495cdf0e10cSrcweir // Assemble new content identifier... 1496cdf0e10cSrcweir 1497cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId 1498cdf0e10cSrcweir = makeNewIdentifier( m_aProps.getTitle() ); 1499cdf0e10cSrcweir 1500cdf0e10cSrcweir // Handle possible name clash... 1501cdf0e10cSrcweir 1502cdf0e10cSrcweir switch ( nNameClashResolve ) 1503cdf0e10cSrcweir { 1504cdf0e10cSrcweir // fail. 1505cdf0e10cSrcweir case ucb::NameClash::ERROR: 1506cdf0e10cSrcweir if ( hasData( xId ) ) 1507cdf0e10cSrcweir { 1508cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1509cdf0e10cSrcweir uno::makeAny( 1510cdf0e10cSrcweir ucb::NameClashException( 1511cdf0e10cSrcweir rtl::OUString(), 1512cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1513cdf0e10cSrcweir task::InteractionClassification_ERROR, 1514cdf0e10cSrcweir m_aProps.getTitle() ) ), 1515cdf0e10cSrcweir xEnv ); 1516cdf0e10cSrcweir // Unreachable 1517cdf0e10cSrcweir } 1518cdf0e10cSrcweir break; 1519cdf0e10cSrcweir 1520cdf0e10cSrcweir // replace existing object. 1521cdf0e10cSrcweir case ucb::NameClash::OVERWRITE: 1522cdf0e10cSrcweir break; 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir // "invent" a new valid title. 1525cdf0e10cSrcweir case ucb::NameClash::RENAME: 1526cdf0e10cSrcweir if ( hasData( xId ) ) 1527cdf0e10cSrcweir { 1528cdf0e10cSrcweir sal_Int32 nTry = 0; 1529cdf0e10cSrcweir 1530cdf0e10cSrcweir do 1531cdf0e10cSrcweir { 1532cdf0e10cSrcweir rtl::OUString aNewId = xId->getContentIdentifier(); 1533cdf0e10cSrcweir aNewId += rtl::OUString::createFromAscii( "_" ); 1534cdf0e10cSrcweir aNewId += rtl::OUString::valueOf( ++nTry ); 1535cdf0e10cSrcweir xId = new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewId ); 1536cdf0e10cSrcweir } 1537cdf0e10cSrcweir while ( hasData( xId ) && ( nTry < 1000 ) ); 1538cdf0e10cSrcweir 1539cdf0e10cSrcweir if ( nTry == 1000 ) 1540cdf0e10cSrcweir { 1541cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1542cdf0e10cSrcweir uno::makeAny( 1543cdf0e10cSrcweir ucb::UnsupportedNameClashException( 1544cdf0e10cSrcweir rtl::OUString::createFromAscii( 1545cdf0e10cSrcweir "Unable to resolve name clash!" ), 1546cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1547cdf0e10cSrcweir nNameClashResolve ) ), 1548cdf0e10cSrcweir xEnv ); 1549cdf0e10cSrcweir // Unreachable 1550cdf0e10cSrcweir } 1551cdf0e10cSrcweir else 1552cdf0e10cSrcweir { 1553cdf0e10cSrcweir rtl::OUString aNewTitle( m_aProps.getTitle() ); 1554cdf0e10cSrcweir aNewTitle += rtl::OUString::createFromAscii( "_" ); 1555cdf0e10cSrcweir aNewTitle += rtl::OUString::valueOf( nTry ); 1556cdf0e10cSrcweir m_aProps.setTitle( aNewTitle ); 1557cdf0e10cSrcweir } 1558cdf0e10cSrcweir } 1559cdf0e10cSrcweir break; 1560cdf0e10cSrcweir 1561cdf0e10cSrcweir case ucb::NameClash::KEEP: // deprecated 1562cdf0e10cSrcweir case ucb::NameClash::ASK: 1563cdf0e10cSrcweir default: 1564cdf0e10cSrcweir if ( hasData( xId ) ) 1565cdf0e10cSrcweir { 1566cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1567cdf0e10cSrcweir uno::makeAny( 1568cdf0e10cSrcweir ucb::UnsupportedNameClashException( 1569cdf0e10cSrcweir rtl::OUString(), 1570cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ), 1571cdf0e10cSrcweir nNameClashResolve ) ), 1572cdf0e10cSrcweir xEnv ); 1573cdf0e10cSrcweir // Unreachable 1574cdf0e10cSrcweir } 1575cdf0e10cSrcweir break; 1576cdf0e10cSrcweir } 1577cdf0e10cSrcweir 1578cdf0e10cSrcweir // Identifier changed? 1579cdf0e10cSrcweir sal_Bool bNewId = ( xId->getContentIdentifier() 1580cdf0e10cSrcweir != m_xIdentifier->getContentIdentifier() ); 1581cdf0e10cSrcweir m_xIdentifier = xId; 1582cdf0e10cSrcweir 1583cdf0e10cSrcweir if ( !storeData() ) 1584cdf0e10cSrcweir { 1585cdf0e10cSrcweir uno::Any aProps 1586cdf0e10cSrcweir = uno::makeAny(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_WRITE, 1595cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1596cdf0e10cSrcweir xEnv, 1597cdf0e10cSrcweir rtl::OUString::createFromAscii( "Cannot store persistent data!" ), 1598cdf0e10cSrcweir this ); 1599cdf0e10cSrcweir // Unreachable 1600cdf0e10cSrcweir } 1601cdf0e10cSrcweir 1602cdf0e10cSrcweir m_eState = PERSISTENT; 1603cdf0e10cSrcweir 1604cdf0e10cSrcweir if ( bNewId ) 1605cdf0e10cSrcweir { 1606cdf0e10cSrcweir aGuard.clear(); 1607cdf0e10cSrcweir inserted(); 1608cdf0e10cSrcweir } 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir 1611cdf0e10cSrcweir //========================================================================= 1612cdf0e10cSrcweir void HierarchyContent::destroy( sal_Bool bDeletePhysical, 1613cdf0e10cSrcweir const uno::Reference< 1614cdf0e10cSrcweir ucb::XCommandEnvironment > & xEnv ) 1615cdf0e10cSrcweir throw( uno::Exception ) 1616cdf0e10cSrcweir { 1617cdf0e10cSrcweir // @@@ take care about bDeletePhysical -> trashcan support 1618cdf0e10cSrcweir 1619cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1620cdf0e10cSrcweir 1621cdf0e10cSrcweir uno::Reference< ucb::XContent > xThis = this; 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir // Persistent? 1624cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 1625cdf0e10cSrcweir { 1626cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1627cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 1628cdf0e10cSrcweir rtl::OUString::createFromAscii( 1629cdf0e10cSrcweir "Not persistent!" ), 1630cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1631cdf0e10cSrcweir xEnv ); 1632cdf0e10cSrcweir // Unreachable 1633cdf0e10cSrcweir } 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir // Am I the root folder? 1636cdf0e10cSrcweir if ( m_eKind == ROOT ) 1637cdf0e10cSrcweir { 1638cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1639cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 1640cdf0e10cSrcweir rtl::OUString::createFromAscii( 1641cdf0e10cSrcweir "Not supported by root folder!" ), 1642cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1643cdf0e10cSrcweir xEnv ); 1644cdf0e10cSrcweir // Unreachable 1645cdf0e10cSrcweir } 1646cdf0e10cSrcweir 1647cdf0e10cSrcweir m_eState = DEAD; 1648cdf0e10cSrcweir 1649cdf0e10cSrcweir aGuard.clear(); 1650cdf0e10cSrcweir deleted(); 1651cdf0e10cSrcweir 1652cdf0e10cSrcweir if ( m_eKind == FOLDER ) 1653cdf0e10cSrcweir { 1654cdf0e10cSrcweir // Process instanciated children... 1655cdf0e10cSrcweir 1656cdf0e10cSrcweir HierarchyContentRefList aChildren; 1657cdf0e10cSrcweir queryChildren( aChildren ); 1658cdf0e10cSrcweir 1659cdf0e10cSrcweir HierarchyContentRefList::const_iterator it = aChildren.begin(); 1660cdf0e10cSrcweir HierarchyContentRefList::const_iterator end = aChildren.end(); 1661cdf0e10cSrcweir 1662cdf0e10cSrcweir while ( it != end ) 1663cdf0e10cSrcweir { 1664cdf0e10cSrcweir (*it)->destroy( bDeletePhysical, xEnv ); 1665cdf0e10cSrcweir ++it; 1666cdf0e10cSrcweir } 1667cdf0e10cSrcweir } 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir //========================================================================= 1671cdf0e10cSrcweir void HierarchyContent::transfer( 1672cdf0e10cSrcweir const ucb::TransferInfo& rInfo, 1673cdf0e10cSrcweir const uno::Reference< ucb::XCommandEnvironment > & xEnv ) 1674cdf0e10cSrcweir throw( uno::Exception ) 1675cdf0e10cSrcweir { 1676cdf0e10cSrcweir osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir // Persistent? 1679cdf0e10cSrcweir if ( m_eState != PERSISTENT ) 1680cdf0e10cSrcweir { 1681cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1682cdf0e10cSrcweir uno::makeAny( ucb::UnsupportedCommandException( 1683cdf0e10cSrcweir rtl::OUString::createFromAscii( 1684cdf0e10cSrcweir "Not persistent!" ), 1685cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1686cdf0e10cSrcweir xEnv ); 1687cdf0e10cSrcweir // Unreachable 1688cdf0e10cSrcweir } 1689cdf0e10cSrcweir 1690cdf0e10cSrcweir // Is source a hierarchy content? 1691cdf0e10cSrcweir if ( ( rInfo.SourceURL.getLength() < HIERARCHY_URL_SCHEME_LENGTH + 2 ) || 1692cdf0e10cSrcweir ( rInfo.SourceURL.compareToAscii( HIERARCHY_URL_SCHEME ":/", 1693cdf0e10cSrcweir HIERARCHY_URL_SCHEME_LENGTH + 2 ) 1694cdf0e10cSrcweir != 0 ) ) 1695cdf0e10cSrcweir { 1696cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1697cdf0e10cSrcweir uno::makeAny( ucb::InteractiveBadTransferURLException( 1698cdf0e10cSrcweir rtl::OUString(), 1699cdf0e10cSrcweir static_cast< cppu::OWeakObject * >( this ) ) ), 1700cdf0e10cSrcweir xEnv ); 1701cdf0e10cSrcweir // Unreachable 1702cdf0e10cSrcweir } 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir // Is source not a parent of me / not me? 1705cdf0e10cSrcweir rtl::OUString aId = m_xIdentifier->getContentIdentifier(); 1706cdf0e10cSrcweir sal_Int32 nPos = aId.lastIndexOf( '/' ); 1707cdf0e10cSrcweir if ( nPos != ( aId.getLength() - 1 ) ) 1708cdf0e10cSrcweir { 1709cdf0e10cSrcweir // No trailing slash found. Append. 1710cdf0e10cSrcweir aId += rtl::OUString::createFromAscii( "/" ); 1711cdf0e10cSrcweir } 1712cdf0e10cSrcweir 1713cdf0e10cSrcweir if ( rInfo.SourceURL.getLength() <= aId.getLength() ) 1714cdf0e10cSrcweir { 1715cdf0e10cSrcweir if ( aId.compareTo( 1716cdf0e10cSrcweir rInfo.SourceURL, rInfo.SourceURL.getLength() ) == 0 ) 1717cdf0e10cSrcweir { 1718cdf0e10cSrcweir uno::Any aProps 1719cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 1720cdf0e10cSrcweir rtl::OUString( 1721cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Uri")), 1722cdf0e10cSrcweir -1, 1723cdf0e10cSrcweir uno::makeAny(rInfo.SourceURL), 1724cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1725cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1726cdf0e10cSrcweir ucb::IOErrorCode_RECURSIVE, 1727cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1728cdf0e10cSrcweir xEnv, 1729cdf0e10cSrcweir rtl::OUString::createFromAscii( 1730cdf0e10cSrcweir "Target is equal to or is a child of source!" ), 1731cdf0e10cSrcweir this ); 1732cdf0e10cSrcweir // Unreachable 1733cdf0e10cSrcweir } 1734cdf0e10cSrcweir } 1735cdf0e10cSrcweir 1736cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1737cdf0e10cSrcweir // 0) Obtain content object for source. 1738cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1739cdf0e10cSrcweir 1740cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier > xId 1741cdf0e10cSrcweir = new ::ucbhelper::ContentIdentifier( m_xSMgr, rInfo.SourceURL ); 1742cdf0e10cSrcweir 1743cdf0e10cSrcweir // Note: The static cast is okay here, because its sure that 1744cdf0e10cSrcweir // m_xProvider is always the HierarchyContentProvider. 1745cdf0e10cSrcweir rtl::Reference< HierarchyContent > xSource; 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir try 1748cdf0e10cSrcweir { 1749cdf0e10cSrcweir xSource = static_cast< HierarchyContent * >( 1750cdf0e10cSrcweir m_xProvider->queryContent( xId ).get() ); 1751cdf0e10cSrcweir } 1752cdf0e10cSrcweir catch ( ucb::IllegalIdentifierException const & ) 1753cdf0e10cSrcweir { 1754cdf0e10cSrcweir // queryContent 1755cdf0e10cSrcweir } 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir if ( !xSource.is() ) 1758cdf0e10cSrcweir { 1759cdf0e10cSrcweir uno::Any aProps 1760cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 1761cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1762cdf0e10cSrcweir "Uri")), 1763cdf0e10cSrcweir -1, 1764cdf0e10cSrcweir uno::makeAny(xId->getContentIdentifier()), 1765cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1766cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1767cdf0e10cSrcweir ucb::IOErrorCode_CANT_READ, 1768cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1769cdf0e10cSrcweir xEnv, 1770cdf0e10cSrcweir rtl::OUString::createFromAscii( 1771cdf0e10cSrcweir "Cannot instanciate source object!" ), 1772cdf0e10cSrcweir this ); 1773cdf0e10cSrcweir // Unreachable 1774cdf0e10cSrcweir } 1775cdf0e10cSrcweir 1776cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1777cdf0e10cSrcweir // 1) Create new child content. 1778cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1779cdf0e10cSrcweir 1780cdf0e10cSrcweir rtl::OUString aType = xSource->isFolder() 1781cdf0e10cSrcweir ? rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ) 1782cdf0e10cSrcweir : rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ); 1783cdf0e10cSrcweir ucb::ContentInfo aContentInfo; 1784cdf0e10cSrcweir aContentInfo.Type = aType; 1785cdf0e10cSrcweir aContentInfo.Attributes = 0; 1786cdf0e10cSrcweir 1787cdf0e10cSrcweir // Note: The static cast is okay here, because its sure that 1788cdf0e10cSrcweir // createNewContent always creates a HierarchyContent. 1789cdf0e10cSrcweir rtl::Reference< HierarchyContent > xTarget 1790cdf0e10cSrcweir = static_cast< HierarchyContent * >( 1791cdf0e10cSrcweir createNewContent( aContentInfo ).get() ); 1792cdf0e10cSrcweir if ( !xTarget.is() ) 1793cdf0e10cSrcweir { 1794cdf0e10cSrcweir uno::Any aProps 1795cdf0e10cSrcweir = uno::makeAny(beans::PropertyValue( 1796cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1797cdf0e10cSrcweir "Folder")), 1798cdf0e10cSrcweir -1, 1799cdf0e10cSrcweir uno::makeAny(aId), 1800cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1801cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1802cdf0e10cSrcweir ucb::IOErrorCode_CANT_CREATE, 1803cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1804cdf0e10cSrcweir xEnv, 1805cdf0e10cSrcweir rtl::OUString::createFromAscii( 1806cdf0e10cSrcweir "XContentCreator::createNewContent failed!" ), 1807cdf0e10cSrcweir this ); 1808cdf0e10cSrcweir // Unreachable 1809cdf0e10cSrcweir } 1810cdf0e10cSrcweir 1811cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1812cdf0e10cSrcweir // 2) Copy data from source content to child content. 1813cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1814cdf0e10cSrcweir 1815cdf0e10cSrcweir uno::Sequence< beans::Property > aSourceProps 1816cdf0e10cSrcweir = xSource->getPropertySetInfo( xEnv )->getProperties(); 1817cdf0e10cSrcweir sal_Int32 nCount = aSourceProps.getLength(); 1818cdf0e10cSrcweir 1819cdf0e10cSrcweir if ( nCount ) 1820cdf0e10cSrcweir { 1821cdf0e10cSrcweir sal_Bool bHadTitle = ( rInfo.NewTitle.getLength() == 0 ); 1822cdf0e10cSrcweir 1823cdf0e10cSrcweir // Get all source values. 1824cdf0e10cSrcweir uno::Reference< sdbc::XRow > xRow 1825cdf0e10cSrcweir = xSource->getPropertyValues( aSourceProps ); 1826cdf0e10cSrcweir 1827cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aValues( nCount ); 1828cdf0e10cSrcweir beans::PropertyValue* pValues = aValues.getArray(); 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir const beans::Property* pProps = aSourceProps.getConstArray(); 1831cdf0e10cSrcweir for ( sal_Int32 n = 0; n < nCount; ++n ) 1832cdf0e10cSrcweir { 1833cdf0e10cSrcweir const beans::Property& rProp = pProps[ n ]; 1834cdf0e10cSrcweir beans::PropertyValue& rValue = pValues[ n ]; 1835cdf0e10cSrcweir 1836cdf0e10cSrcweir rValue.Name = rProp.Name; 1837cdf0e10cSrcweir rValue.Handle = rProp.Handle; 1838cdf0e10cSrcweir 1839cdf0e10cSrcweir if ( !bHadTitle && rProp.Name.equalsAsciiL( 1840cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) 1841cdf0e10cSrcweir { 1842cdf0e10cSrcweir // Set new title instead of original. 1843cdf0e10cSrcweir bHadTitle = sal_True; 1844cdf0e10cSrcweir rValue.Value <<= rInfo.NewTitle; 1845cdf0e10cSrcweir } 1846cdf0e10cSrcweir else 1847cdf0e10cSrcweir rValue.Value = xRow->getObject( 1848cdf0e10cSrcweir n + 1, 1849cdf0e10cSrcweir uno::Reference< container::XNameAccess >() ); 1850cdf0e10cSrcweir 1851cdf0e10cSrcweir rValue.State = beans::PropertyState_DIRECT_VALUE; 1852cdf0e10cSrcweir 1853cdf0e10cSrcweir if ( rProp.Attributes & beans::PropertyAttribute::REMOVABLE ) 1854cdf0e10cSrcweir { 1855cdf0e10cSrcweir // Add Additional Core Property. 1856cdf0e10cSrcweir try 1857cdf0e10cSrcweir { 1858cdf0e10cSrcweir xTarget->addProperty( rProp.Name, 1859cdf0e10cSrcweir rProp.Attributes, 1860cdf0e10cSrcweir rValue.Value ); 1861cdf0e10cSrcweir } 1862cdf0e10cSrcweir catch ( beans::PropertyExistException const & ) 1863cdf0e10cSrcweir { 1864cdf0e10cSrcweir } 1865cdf0e10cSrcweir catch ( beans::IllegalTypeException const & ) 1866cdf0e10cSrcweir { 1867cdf0e10cSrcweir } 1868cdf0e10cSrcweir catch ( lang::IllegalArgumentException const & ) 1869cdf0e10cSrcweir { 1870cdf0e10cSrcweir } 1871cdf0e10cSrcweir } 1872cdf0e10cSrcweir } 1873cdf0e10cSrcweir 1874cdf0e10cSrcweir // Set target values. 1875cdf0e10cSrcweir xTarget->setPropertyValues( aValues, xEnv ); 1876cdf0e10cSrcweir } 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1879cdf0e10cSrcweir // 3) Commit (insert) child. 1880cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1881cdf0e10cSrcweir 1882cdf0e10cSrcweir xTarget->insert( rInfo.NameClash, xEnv ); 1883cdf0e10cSrcweir 1884cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1885cdf0e10cSrcweir // 4) Transfer (copy) children of source. 1886cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1887cdf0e10cSrcweir 1888cdf0e10cSrcweir if ( xSource->isFolder() ) 1889cdf0e10cSrcweir { 1890cdf0e10cSrcweir HierarchyEntry aFolder( 1891cdf0e10cSrcweir m_xSMgr, m_pProvider, xId->getContentIdentifier() ); 1892cdf0e10cSrcweir HierarchyEntry::iterator it; 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir while ( aFolder.next( it ) ) 1895cdf0e10cSrcweir { 1896cdf0e10cSrcweir const HierarchyEntryData& rResult = *it; 1897cdf0e10cSrcweir 1898cdf0e10cSrcweir rtl::OUString aChildId = xId->getContentIdentifier(); 1899cdf0e10cSrcweir if ( ( aChildId.lastIndexOf( '/' ) + 1 ) != aChildId.getLength() ) 1900cdf0e10cSrcweir aChildId += rtl::OUString::createFromAscii( "/" ); 1901cdf0e10cSrcweir 1902cdf0e10cSrcweir aChildId += rResult.getName(); 1903cdf0e10cSrcweir 1904cdf0e10cSrcweir ucb::TransferInfo aInfo; 1905cdf0e10cSrcweir aInfo.MoveData = sal_False; 1906cdf0e10cSrcweir aInfo.NewTitle = rtl::OUString(); 1907cdf0e10cSrcweir aInfo.SourceURL = aChildId; 1908cdf0e10cSrcweir aInfo.NameClash = rInfo.NameClash; 1909cdf0e10cSrcweir 1910cdf0e10cSrcweir // Transfer child to target. 1911cdf0e10cSrcweir xTarget->transfer( aInfo, xEnv ); 1912cdf0e10cSrcweir } 1913cdf0e10cSrcweir } 1914cdf0e10cSrcweir 1915cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1916cdf0e10cSrcweir // 5) Destroy source ( when moving only ) . 1917cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1918cdf0e10cSrcweir 1919cdf0e10cSrcweir if ( rInfo.MoveData ) 1920cdf0e10cSrcweir { 1921cdf0e10cSrcweir xSource->destroy( sal_True, xEnv ); 1922cdf0e10cSrcweir 1923cdf0e10cSrcweir // Remove all persistent data of source and its children. 1924cdf0e10cSrcweir if ( !xSource->removeData() ) 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir uno::Any aProps 1927cdf0e10cSrcweir = uno::makeAny( 1928cdf0e10cSrcweir beans::PropertyValue( 1929cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 1930cdf0e10cSrcweir "Uri")), 1931cdf0e10cSrcweir -1, 1932cdf0e10cSrcweir uno::makeAny( 1933cdf0e10cSrcweir xSource->m_xIdentifier-> 1934cdf0e10cSrcweir getContentIdentifier()), 1935cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE)); 1936cdf0e10cSrcweir ucbhelper::cancelCommandExecution( 1937cdf0e10cSrcweir ucb::IOErrorCode_CANT_WRITE, 1938cdf0e10cSrcweir uno::Sequence< uno::Any >(&aProps, 1), 1939cdf0e10cSrcweir xEnv, 1940cdf0e10cSrcweir rtl::OUString::createFromAscii( 1941cdf0e10cSrcweir "Cannot remove persistent data of source object!" ), 1942cdf0e10cSrcweir this ); 1943cdf0e10cSrcweir // Unreachable 1944cdf0e10cSrcweir } 1945cdf0e10cSrcweir 1946cdf0e10cSrcweir // Remove own and all children's Additional Core Properties. 1947cdf0e10cSrcweir xSource->removeAdditionalPropertySet( sal_True ); 1948cdf0e10cSrcweir } 1949cdf0e10cSrcweir } 1950cdf0e10cSrcweir 1951cdf0e10cSrcweir //========================================================================= 1952cdf0e10cSrcweir //========================================================================= 1953cdf0e10cSrcweir // 1954cdf0e10cSrcweir // HierarchyContentProperties Implementation. 1955cdf0e10cSrcweir // 1956cdf0e10cSrcweir //========================================================================= 1957cdf0e10cSrcweir //========================================================================= 1958cdf0e10cSrcweir 1959cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > 1960cdf0e10cSrcweir HierarchyContentProperties::getCreatableContentsInfo() const 1961cdf0e10cSrcweir { 1962cdf0e10cSrcweir if ( getIsFolder() ) 1963cdf0e10cSrcweir { 1964cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > aSeq( 2 ); 1965cdf0e10cSrcweir 1966cdf0e10cSrcweir // Folder. 1967cdf0e10cSrcweir aSeq.getArray()[ 0 ].Type 1968cdf0e10cSrcweir = rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ); 1969cdf0e10cSrcweir aSeq.getArray()[ 0 ].Attributes 1970cdf0e10cSrcweir = ucb::ContentInfoAttribute::KIND_FOLDER; 1971cdf0e10cSrcweir 1972cdf0e10cSrcweir uno::Sequence< beans::Property > aFolderProps( 1 ); 1973cdf0e10cSrcweir aFolderProps.getArray()[ 0 ] = beans::Property( 1974cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ), 1975cdf0e10cSrcweir -1, 1976cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1977cdf0e10cSrcweir beans::PropertyAttribute::BOUND ); 1978cdf0e10cSrcweir aSeq.getArray()[ 0 ].Properties = aFolderProps; 1979cdf0e10cSrcweir 1980cdf0e10cSrcweir // Link. 1981cdf0e10cSrcweir aSeq.getArray()[ 1 ].Type 1982cdf0e10cSrcweir = rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ); 1983cdf0e10cSrcweir aSeq.getArray()[ 1 ].Attributes 1984cdf0e10cSrcweir = ucb::ContentInfoAttribute::KIND_LINK; 1985cdf0e10cSrcweir 1986cdf0e10cSrcweir uno::Sequence< beans::Property > aLinkProps( 2 ); 1987cdf0e10cSrcweir aLinkProps.getArray()[ 0 ] = beans::Property( 1988cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ), 1989cdf0e10cSrcweir -1, 1990cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1991cdf0e10cSrcweir beans::PropertyAttribute::BOUND ); 1992cdf0e10cSrcweir aLinkProps.getArray()[ 1 ] = beans::Property( 1993cdf0e10cSrcweir rtl::OUString::createFromAscii( "TargetURL" ), 1994cdf0e10cSrcweir -1, 1995cdf0e10cSrcweir getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 1996cdf0e10cSrcweir beans::PropertyAttribute::BOUND ); 1997cdf0e10cSrcweir aSeq.getArray()[ 1 ].Properties = aLinkProps; 1998cdf0e10cSrcweir 1999cdf0e10cSrcweir return aSeq; 2000cdf0e10cSrcweir } 2001cdf0e10cSrcweir else 2002cdf0e10cSrcweir { 2003cdf0e10cSrcweir return uno::Sequence< ucb::ContentInfo >( 0 ); 2004cdf0e10cSrcweir } 2005cdf0e10cSrcweir } 2006