1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_ucb.hxx" 30*cdf0e10cSrcweir #ifndef INCLUDED_STL_STACK 31*cdf0e10cSrcweir #include <stack> 32*cdf0e10cSrcweir #define INCLUDED_STL_STACK 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "osl/diagnose.h" 36*cdf0e10cSrcweir #include <rtl/uri.hxx> 37*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 38*cdf0e10cSrcweir #include <osl/time.h> 39*cdf0e10cSrcweir #include <osl/file.hxx> 40*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/beans/IllegalTypeException.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifier.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfoAttribute.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeListener.hpp> 57*cdf0e10cSrcweir #include <rtl/string.hxx> 58*cdf0e10cSrcweir #include "filerror.hxx" 59*cdf0e10cSrcweir #include "filglob.hxx" 60*cdf0e10cSrcweir #include "filcmd.hxx" 61*cdf0e10cSrcweir #include "filinpstr.hxx" 62*cdf0e10cSrcweir #include "filstr.hxx" 63*cdf0e10cSrcweir #include "filrset.hxx" 64*cdf0e10cSrcweir #include "filrow.hxx" 65*cdf0e10cSrcweir #include "filprp.hxx" 66*cdf0e10cSrcweir #include "filid.hxx" 67*cdf0e10cSrcweir #include "shell.hxx" 68*cdf0e10cSrcweir #include "prov.hxx" 69*cdf0e10cSrcweir #include "bc.hxx" 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir using namespace fileaccess; 73*cdf0e10cSrcweir using namespace com::sun::star; 74*cdf0e10cSrcweir using namespace com::sun::star::ucb; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir shell::UnqPathData::UnqPathData() 78*cdf0e10cSrcweir : properties( 0 ), 79*cdf0e10cSrcweir notifier( 0 ), 80*cdf0e10cSrcweir xS( 0 ), 81*cdf0e10cSrcweir xC( 0 ), 82*cdf0e10cSrcweir xA( 0 ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir // empty 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir shell::UnqPathData::UnqPathData( const UnqPathData& a ) 89*cdf0e10cSrcweir : properties( a.properties ), 90*cdf0e10cSrcweir notifier( a.notifier ), 91*cdf0e10cSrcweir xS( a.xS ), 92*cdf0e10cSrcweir xC( a.xC ), 93*cdf0e10cSrcweir xA( a.xA ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir shell::UnqPathData& shell::UnqPathData::operator=( UnqPathData& a ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir properties = a.properties; 101*cdf0e10cSrcweir notifier = a.notifier; 102*cdf0e10cSrcweir xS = a.xS; 103*cdf0e10cSrcweir xC = a.xC; 104*cdf0e10cSrcweir xA = a.xA; 105*cdf0e10cSrcweir a.properties = 0; 106*cdf0e10cSrcweir a.notifier = 0; 107*cdf0e10cSrcweir a.xS = 0; 108*cdf0e10cSrcweir a.xC = 0; 109*cdf0e10cSrcweir a.xA = 0; 110*cdf0e10cSrcweir return *this; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir shell::UnqPathData::~UnqPathData() 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir if( properties ) 116*cdf0e10cSrcweir delete properties; 117*cdf0e10cSrcweir if( notifier ) 118*cdf0e10cSrcweir delete notifier; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////// 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir shell::MyProperty::MyProperty( const rtl::OUString& __PropertyName ) 130*cdf0e10cSrcweir : PropertyName( __PropertyName ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir // empty 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir shell::MyProperty::MyProperty( const sal_Bool& __isNative, 137*cdf0e10cSrcweir const rtl::OUString& __PropertyName, 138*cdf0e10cSrcweir const sal_Int32& __Handle, 139*cdf0e10cSrcweir const com::sun::star::uno::Type& __Typ, 140*cdf0e10cSrcweir const com::sun::star::uno::Any& __Value, 141*cdf0e10cSrcweir const com::sun::star::beans::PropertyState& __State, 142*cdf0e10cSrcweir const sal_Int16& __Attributes ) 143*cdf0e10cSrcweir : PropertyName( __PropertyName ), 144*cdf0e10cSrcweir Handle( __Handle ), 145*cdf0e10cSrcweir isNative( __isNative ), 146*cdf0e10cSrcweir Typ( __Typ ), 147*cdf0e10cSrcweir Value( __Value ), 148*cdf0e10cSrcweir State( __State ), 149*cdf0e10cSrcweir Attributes( __Attributes ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir // empty 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir shell::MyProperty::~MyProperty() 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir // empty for now 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir #include "filinl.hxx" 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceFactory, 164*cdf0e10cSrcweir FileProvider* pProvider, sal_Bool bWithConfig ) 165*cdf0e10cSrcweir : TaskManager(), 166*cdf0e10cSrcweir m_bWithConfig( bWithConfig ), 167*cdf0e10cSrcweir m_pProvider( pProvider ), 168*cdf0e10cSrcweir m_xMultiServiceFactory( xMultiServiceFactory ), 169*cdf0e10cSrcweir Title( rtl::OUString::createFromAscii( "Title" ) ), 170*cdf0e10cSrcweir CasePreservingURL( 171*cdf0e10cSrcweir rtl::OUString::createFromAscii( "CasePreservingURL" ) ), 172*cdf0e10cSrcweir IsDocument( rtl::OUString::createFromAscii( "IsDocument" ) ), 173*cdf0e10cSrcweir IsFolder( rtl::OUString::createFromAscii( "IsFolder" ) ), 174*cdf0e10cSrcweir DateModified( rtl::OUString::createFromAscii( "DateModified" ) ), 175*cdf0e10cSrcweir Size( rtl::OUString::createFromAscii( "Size" ) ), 176*cdf0e10cSrcweir IsVolume( rtl::OUString::createFromAscii( "IsVolume" ) ), 177*cdf0e10cSrcweir IsRemoveable( rtl::OUString::createFromAscii( "IsRemoveable" ) ), 178*cdf0e10cSrcweir IsRemote( rtl::OUString::createFromAscii( "IsRemote" ) ), 179*cdf0e10cSrcweir IsCompactDisc( rtl::OUString::createFromAscii( "IsCompactDisc" ) ), 180*cdf0e10cSrcweir IsFloppy( rtl::OUString::createFromAscii( "IsFloppy" ) ), 181*cdf0e10cSrcweir IsHidden( rtl::OUString::createFromAscii( "IsHidden" ) ), 182*cdf0e10cSrcweir ContentType( rtl::OUString::createFromAscii( "ContentType" ) ), 183*cdf0e10cSrcweir IsReadOnly( rtl::OUString::createFromAscii( "IsReadOnly" ) ), 184*cdf0e10cSrcweir CreatableContentsInfo( rtl::OUString::createFromAscii( "CreatableContentsInfo" ) ), 185*cdf0e10cSrcweir FolderContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ) ), 186*cdf0e10cSrcweir FileContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-file" ) ), 187*cdf0e10cSrcweir m_sCommandInfo( 9 ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir // Title 190*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 191*cdf0e10cSrcweir Title, 192*cdf0e10cSrcweir -1 , 193*cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ), 194*cdf0e10cSrcweir uno::Any(), 195*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 196*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 197*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) ); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // CasePreservingURL 200*cdf0e10cSrcweir m_aDefaultProperties.insert( 201*cdf0e10cSrcweir MyProperty( true, 202*cdf0e10cSrcweir CasePreservingURL, 203*cdf0e10cSrcweir -1 , 204*cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ), 205*cdf0e10cSrcweir uno::Any(), 206*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 207*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 208*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 209*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // IsFolder 213*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 214*cdf0e10cSrcweir IsFolder, 215*cdf0e10cSrcweir -1 , 216*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 217*cdf0e10cSrcweir uno::Any(), 218*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 219*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 220*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 221*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // IsDocument 225*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 226*cdf0e10cSrcweir IsDocument, 227*cdf0e10cSrcweir -1 , 228*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 229*cdf0e10cSrcweir uno::Any(), 230*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 231*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 232*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 233*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir // Removable 236*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 237*cdf0e10cSrcweir IsVolume, 238*cdf0e10cSrcweir -1 , 239*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 240*cdf0e10cSrcweir uno::Any(), 241*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 242*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 243*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 244*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir // Removable 248*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 249*cdf0e10cSrcweir IsRemoveable, 250*cdf0e10cSrcweir -1 , 251*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 252*cdf0e10cSrcweir uno::Any(), 253*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 254*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 255*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 256*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // Remote 259*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 260*cdf0e10cSrcweir IsRemote, 261*cdf0e10cSrcweir -1 , 262*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 263*cdf0e10cSrcweir uno::Any(), 264*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 265*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 266*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 267*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir // CompactDisc 270*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 271*cdf0e10cSrcweir IsCompactDisc, 272*cdf0e10cSrcweir -1 , 273*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 274*cdf0e10cSrcweir uno::Any(), 275*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 276*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 277*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 278*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir // Floppy 281*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 282*cdf0e10cSrcweir IsFloppy, 283*cdf0e10cSrcweir -1 , 284*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 285*cdf0e10cSrcweir uno::Any(), 286*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 287*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 288*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 289*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir // Hidden 292*cdf0e10cSrcweir m_aDefaultProperties.insert( 293*cdf0e10cSrcweir MyProperty( 294*cdf0e10cSrcweir true, 295*cdf0e10cSrcweir IsHidden, 296*cdf0e10cSrcweir -1 , 297*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 298*cdf0e10cSrcweir uno::Any(), 299*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 300*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 301*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 302*cdf0e10cSrcweir #if defined( WNT ) || defined( OS2 ) 303*cdf0e10cSrcweir )); 304*cdf0e10cSrcweir #else 305*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY)); // under unix/linux only readable 306*cdf0e10cSrcweir #endif 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // ContentType 310*cdf0e10cSrcweir uno::Any aAny; 311*cdf0e10cSrcweir aAny <<= rtl::OUString(); 312*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( false, 313*cdf0e10cSrcweir ContentType, 314*cdf0e10cSrcweir -1 , 315*cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ), 316*cdf0e10cSrcweir aAny, 317*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 318*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 319*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 320*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // DateModified 324*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 325*cdf0e10cSrcweir DateModified, 326*cdf0e10cSrcweir -1 , 327*cdf0e10cSrcweir getCppuType( static_cast< util::DateTime* >( 0 ) ), 328*cdf0e10cSrcweir uno::Any(), 329*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 330*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 331*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) ); 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir // Size 334*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 335*cdf0e10cSrcweir Size, 336*cdf0e10cSrcweir -1, 337*cdf0e10cSrcweir getCppuType( static_cast< sal_Int64* >( 0 ) ), 338*cdf0e10cSrcweir uno::Any(), 339*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 340*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 341*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) ); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir // IsReadOnly 344*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 345*cdf0e10cSrcweir IsReadOnly, 346*cdf0e10cSrcweir -1 , 347*cdf0e10cSrcweir getCppuType( static_cast< sal_Bool* >( 0 ) ), 348*cdf0e10cSrcweir uno::Any(), 349*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 350*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 351*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ) ); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir // CreatableContentsInfo 355*cdf0e10cSrcweir m_aDefaultProperties.insert( MyProperty( true, 356*cdf0e10cSrcweir CreatableContentsInfo, 357*cdf0e10cSrcweir -1 , 358*cdf0e10cSrcweir getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 359*cdf0e10cSrcweir uno::Any(), 360*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 361*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 362*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND 363*cdf0e10cSrcweir | beans::PropertyAttribute::READONLY ) ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // Commands 366*cdf0e10cSrcweir m_sCommandInfo[0].Name = rtl::OUString::createFromAscii( "getCommandInfo" ); 367*cdf0e10cSrcweir m_sCommandInfo[0].Handle = -1; 368*cdf0e10cSrcweir m_sCommandInfo[0].ArgType = getCppuVoidType(); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir m_sCommandInfo[1].Name = rtl::OUString::createFromAscii( "getPropertySetInfo" ); 371*cdf0e10cSrcweir m_sCommandInfo[1].Handle = -1; 372*cdf0e10cSrcweir m_sCommandInfo[1].ArgType = getCppuVoidType(); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir m_sCommandInfo[2].Name = rtl::OUString::createFromAscii( "getPropertyValues" ); 375*cdf0e10cSrcweir m_sCommandInfo[2].Handle = -1; 376*cdf0e10cSrcweir m_sCommandInfo[2].ArgType = getCppuType( static_cast< uno::Sequence< beans::Property >* >( 0 ) ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir m_sCommandInfo[3].Name = rtl::OUString::createFromAscii( "setPropertyValues" ); 379*cdf0e10cSrcweir m_sCommandInfo[3].Handle = -1; 380*cdf0e10cSrcweir m_sCommandInfo[3].ArgType = getCppuType( static_cast< uno::Sequence< beans::PropertyValue >* >( 0 ) ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir m_sCommandInfo[4].Name = rtl::OUString::createFromAscii( "open" ); 383*cdf0e10cSrcweir m_sCommandInfo[4].Handle = -1; 384*cdf0e10cSrcweir m_sCommandInfo[4].ArgType = getCppuType( static_cast< OpenCommandArgument* >( 0 ) ); 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir m_sCommandInfo[5].Name = rtl::OUString::createFromAscii( "transfer" ); 387*cdf0e10cSrcweir m_sCommandInfo[5].Handle = -1; 388*cdf0e10cSrcweir m_sCommandInfo[5].ArgType = getCppuType( static_cast< TransferInfo* >( 0 ) ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir m_sCommandInfo[6].Name = rtl::OUString::createFromAscii( "delete" ); 391*cdf0e10cSrcweir m_sCommandInfo[6].Handle = -1; 392*cdf0e10cSrcweir m_sCommandInfo[6].ArgType = getCppuType( static_cast< sal_Bool* >( 0 ) ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "insert" ); 395*cdf0e10cSrcweir m_sCommandInfo[7].Handle = -1; 396*cdf0e10cSrcweir m_sCommandInfo[7].ArgType = getCppuType( static_cast< InsertCommandArgument* > ( 0 ) ); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "createNewContent" ); 399*cdf0e10cSrcweir m_sCommandInfo[7].Handle = -1; 400*cdf0e10cSrcweir m_sCommandInfo[7].ArgType = getCppuType( static_cast< ucb::ContentInfo * > ( 0 ) ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir if(m_bWithConfig) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir rtl::OUString Store = rtl::OUString::createFromAscii( "com.sun.star.ucb.Store" ); 405*cdf0e10cSrcweir uno::Reference< XPropertySetRegistryFactory > xRegFac( 406*cdf0e10cSrcweir m_xMultiServiceFactory->createInstance( Store ), 407*cdf0e10cSrcweir uno::UNO_QUERY ); 408*cdf0e10cSrcweir if ( xRegFac.is() ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir // Open/create a registry 411*cdf0e10cSrcweir m_xFileRegistry = xRegFac->createPropertySetRegistry( rtl::OUString() ); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir shell::~shell() 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir /*********************************************************************************/ 423*cdf0e10cSrcweir /* */ 424*cdf0e10cSrcweir /* de/registerNotifier-Implementation */ 425*cdf0e10cSrcweir /* */ 426*cdf0e10cSrcweir /*********************************************************************************/ 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir // 429*cdf0e10cSrcweir // This two methods register and deregister a change listener for the content belonging 430*cdf0e10cSrcweir // to URL aUnqPath 431*cdf0e10cSrcweir // 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir void SAL_CALL 434*cdf0e10cSrcweir shell::registerNotifier( const rtl::OUString& aUnqPath, Notifier* pNotifier ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir ContentMap::iterator it = 439*cdf0e10cSrcweir m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir if( ! it->second.notifier ) 442*cdf0e10cSrcweir it->second.notifier = new NotifierList(); 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir std::list< Notifier* >& nlist = *( it->second.notifier ); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = nlist.begin(); 447*cdf0e10cSrcweir while( it1 != nlist.end() ) // Every "Notifier" only once 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir if( *it1 == pNotifier ) return; 450*cdf0e10cSrcweir ++it1; 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir nlist.push_back( pNotifier ); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void SAL_CALL 458*cdf0e10cSrcweir shell::deregisterNotifier( const rtl::OUString& aUnqPath,Notifier* pNotifier ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir ContentMap::iterator it = m_aContent.find( aUnqPath ); 463*cdf0e10cSrcweir if( it == m_aContent.end() ) 464*cdf0e10cSrcweir return; 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir it->second.notifier->remove( pNotifier ); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir if( ! it->second.notifier->size() ) 469*cdf0e10cSrcweir m_aContent.erase( it ); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir /*********************************************************************************/ 475*cdf0e10cSrcweir /* */ 476*cdf0e10cSrcweir /* de/associate-Implementation */ 477*cdf0e10cSrcweir /* */ 478*cdf0e10cSrcweir /*********************************************************************************/ 479*cdf0e10cSrcweir // 480*cdf0e10cSrcweir // Used to associate and deassociate a new property with 481*cdf0e10cSrcweir // the content belonging to URL UnqPath. 482*cdf0e10cSrcweir // The default value and the the attributes are input 483*cdf0e10cSrcweir // 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir void SAL_CALL 486*cdf0e10cSrcweir shell::associate( const rtl::OUString& aUnqPath, 487*cdf0e10cSrcweir const rtl::OUString& PropertyName, 488*cdf0e10cSrcweir const uno::Any& DefaultValue, 489*cdf0e10cSrcweir const sal_Int16 Attributes ) 490*cdf0e10cSrcweir throw( beans::PropertyExistException, 491*cdf0e10cSrcweir beans::IllegalTypeException, 492*cdf0e10cSrcweir uno::RuntimeException ) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir MyProperty newProperty( false, 495*cdf0e10cSrcweir PropertyName, 496*cdf0e10cSrcweir -1, 497*cdf0e10cSrcweir DefaultValue.getValueType(), 498*cdf0e10cSrcweir DefaultValue, 499*cdf0e10cSrcweir beans::PropertyState_DEFAULT_VALUE, 500*cdf0e10cSrcweir Attributes ); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.find( newProperty ); 503*cdf0e10cSrcweir if( it1 != m_aDefaultProperties.end() ) 504*cdf0e10cSrcweir throw beans::PropertyExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir // Load the XPersistentPropertySetInfo and create it, if it does not exist 512*cdf0e10cSrcweir load( it,true ); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir PropertySet& properties = *(it->second.properties); 515*cdf0e10cSrcweir it1 = properties.find( newProperty ); 516*cdf0e10cSrcweir if( it1 != properties.end() ) 517*cdf0e10cSrcweir throw beans::PropertyExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir // Property does not exist 520*cdf0e10cSrcweir properties.insert( newProperty ); 521*cdf0e10cSrcweir it->second.xC->addProperty( PropertyName,Attributes,DefaultValue ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir notifyPropertyAdded( getPropertySetListeners( aUnqPath ), PropertyName ); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir void SAL_CALL 530*cdf0e10cSrcweir shell::deassociate( const rtl::OUString& aUnqPath, 531*cdf0e10cSrcweir const rtl::OUString& PropertyName ) 532*cdf0e10cSrcweir throw( beans::UnknownPropertyException, 533*cdf0e10cSrcweir beans::NotRemoveableException, 534*cdf0e10cSrcweir uno::RuntimeException ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir MyProperty oldProperty( PropertyName ); 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.find( oldProperty ); 539*cdf0e10cSrcweir if( it1 != m_aDefaultProperties.end() ) 540*cdf0e10cSrcweir throw beans::NotRemoveableException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir load( it,false ); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir PropertySet& properties = *(it->second.properties); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir it1 = properties.find( oldProperty ); 551*cdf0e10cSrcweir if( it1 == properties.end() ) 552*cdf0e10cSrcweir throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir properties.erase( it1 ); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir if( it->second.xC.is() ) 557*cdf0e10cSrcweir it->second.xC->removeProperty( PropertyName ); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir if( properties.size() == 9 ) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir MyProperty ContentTProperty( ContentType ); 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir if( properties.find( ContentTProperty )->getState() == beans::PropertyState_DEFAULT_VALUE ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir it->second.xS = 0; 566*cdf0e10cSrcweir it->second.xC = 0; 567*cdf0e10cSrcweir it->second.xA = 0; 568*cdf0e10cSrcweir if(m_xFileRegistry.is()) 569*cdf0e10cSrcweir m_xFileRegistry->removePropertySet( aUnqPath ); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir notifyPropertyRemoved( getPropertySetListeners( aUnqPath ), PropertyName ); 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir /*********************************************************************************/ 579*cdf0e10cSrcweir /* */ 580*cdf0e10cSrcweir /* page-Implementation */ 581*cdf0e10cSrcweir /* */ 582*cdf0e10cSrcweir /*********************************************************************************/ 583*cdf0e10cSrcweir // 584*cdf0e10cSrcweir // Given an xOutputStream, this method writes the content of the file belonging to 585*cdf0e10cSrcweir // URL aUnqPath into the XOutputStream 586*cdf0e10cSrcweir // 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir void SAL_CALL shell::page( sal_Int32 CommandId, 590*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 591*cdf0e10cSrcweir const uno::Reference< io::XOutputStream >& xOutputStream ) 592*cdf0e10cSrcweir throw() 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir uno::Reference< XContentProvider > xProvider( m_pProvider ); 595*cdf0e10cSrcweir osl::File aFile( aUnqPath ); 596*cdf0e10cSrcweir osl::FileBase::RC err = aFile.open( OpenFlag_Read ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir aFile.close(); 601*cdf0e10cSrcweir installError( CommandId, 602*cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING, 603*cdf0e10cSrcweir err ); 604*cdf0e10cSrcweir return; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir const sal_uInt64 bfz = 4*1024; 608*cdf0e10cSrcweir sal_Int8 BFF[bfz]; 609*cdf0e10cSrcweir sal_uInt64 nrc; // Retrieved number of Bytes; 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir do 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir err = aFile.read( (void*) BFF,bfz,nrc ); 614*cdf0e10cSrcweir if( err == osl::FileBase::E_None ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir uno::Sequence< sal_Int8 > seq( BFF, (sal_uInt32)nrc ); 617*cdf0e10cSrcweir try 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir xOutputStream->writeBytes( seq ); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir catch( io::NotConnectedException ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir installError( CommandId, 624*cdf0e10cSrcweir TASKHANDLING_NOTCONNECTED_FOR_PAGING ); 625*cdf0e10cSrcweir break; 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir catch( io::BufferSizeExceededException ) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir installError( CommandId, 630*cdf0e10cSrcweir TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING ); 631*cdf0e10cSrcweir break; 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir catch( io::IOException ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir installError( CommandId, 636*cdf0e10cSrcweir TASKHANDLING_IOEXCEPTION_FOR_PAGING ); 637*cdf0e10cSrcweir break; 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir else 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir installError( CommandId, 643*cdf0e10cSrcweir TASKHANDLING_READING_FILE_FOR_PAGING, 644*cdf0e10cSrcweir err ); 645*cdf0e10cSrcweir break; 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir } while( nrc == bfz ); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir aFile.close(); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir try 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir xOutputStream->closeOutput(); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir catch( io::NotConnectedException ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir catch( io::BufferSizeExceededException ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir catch( io::IOException ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir /*********************************************************************************/ 670*cdf0e10cSrcweir /* */ 671*cdf0e10cSrcweir /* open-Implementation */ 672*cdf0e10cSrcweir /* */ 673*cdf0e10cSrcweir /*********************************************************************************/ 674*cdf0e10cSrcweir // 675*cdf0e10cSrcweir // Given a file URL aUnqPath, this methods returns a XInputStream which reads from the open file. 676*cdf0e10cSrcweir // 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir uno::Reference< io::XInputStream > SAL_CALL 680*cdf0e10cSrcweir shell::open( sal_Int32 CommandId, 681*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 682*cdf0e10cSrcweir sal_Bool bLock ) 683*cdf0e10cSrcweir throw() 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir XInputStream_impl* xInputStream = new XInputStream_impl( this, aUnqPath, bLock ); // from filinpstr.hxx 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir sal_Int32 ErrorCode = xInputStream->CtorSuccess(); 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir installError( CommandId, 692*cdf0e10cSrcweir ErrorCode, 693*cdf0e10cSrcweir xInputStream->getMinorError() ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir delete xInputStream; 696*cdf0e10cSrcweir xInputStream = 0; 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir return uno::Reference< io::XInputStream >( xInputStream ); 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir /*********************************************************************************/ 706*cdf0e10cSrcweir /* */ 707*cdf0e10cSrcweir /* open for read/write access-Implementation */ 708*cdf0e10cSrcweir /* */ 709*cdf0e10cSrcweir /*********************************************************************************/ 710*cdf0e10cSrcweir // 711*cdf0e10cSrcweir // Given a file URL aUnqPath, this methods returns a XStream which can be used 712*cdf0e10cSrcweir // to read and write from/to the file. 713*cdf0e10cSrcweir // 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL 717*cdf0e10cSrcweir shell::open_rw( sal_Int32 CommandId, 718*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 719*cdf0e10cSrcweir sal_Bool bLock ) 720*cdf0e10cSrcweir throw() 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir XStream_impl* xStream = new XStream_impl( this, aUnqPath, bLock ); // from filstr.hxx 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir sal_Int32 ErrorCode = xStream->CtorSuccess(); 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir installError( CommandId, 729*cdf0e10cSrcweir ErrorCode, 730*cdf0e10cSrcweir xStream->getMinorError() ); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir delete xStream; 733*cdf0e10cSrcweir xStream = 0; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir return uno::Reference< io::XStream >( xStream ); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir /*********************************************************************************/ 741*cdf0e10cSrcweir /* */ 742*cdf0e10cSrcweir /* ls-Implementation */ 743*cdf0e10cSrcweir /* */ 744*cdf0e10cSrcweir /*********************************************************************************/ 745*cdf0e10cSrcweir // 746*cdf0e10cSrcweir // This method returns the result set containing the the children of the directory belonging 747*cdf0e10cSrcweir // to file URL aUnqPath 748*cdf0e10cSrcweir // 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir uno::Reference< XDynamicResultSet > SAL_CALL 752*cdf0e10cSrcweir shell::ls( sal_Int32 CommandId, 753*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 754*cdf0e10cSrcweir const sal_Int32 OpenMode, 755*cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq, 756*cdf0e10cSrcweir const uno::Sequence< NumberedSortingInfo >& seqSort ) 757*cdf0e10cSrcweir throw() 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir XResultSet_impl* p = new XResultSet_impl( this,aUnqPath,OpenMode,seq,seqSort ); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir sal_Int32 ErrorCode = p->CtorSuccess(); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir if( ErrorCode != TASKHANDLER_NO_ERROR ) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir installError( CommandId, 766*cdf0e10cSrcweir ErrorCode, 767*cdf0e10cSrcweir p->getMinorError() ); 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir delete p; 770*cdf0e10cSrcweir p = 0; 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir return uno::Reference< XDynamicResultSet > ( p ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir /*********************************************************************************/ 780*cdf0e10cSrcweir /* */ 781*cdf0e10cSrcweir /* info_c implementation */ 782*cdf0e10cSrcweir /* */ 783*cdf0e10cSrcweir /*********************************************************************************/ 784*cdf0e10cSrcweir // Info for commands 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir uno::Reference< XCommandInfo > SAL_CALL 787*cdf0e10cSrcweir shell::info_c() 788*cdf0e10cSrcweir throw() 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir XCommandInfo_impl* p = new XCommandInfo_impl( this ); 791*cdf0e10cSrcweir return uno::Reference< XCommandInfo >( p ); 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir /*********************************************************************************/ 798*cdf0e10cSrcweir /* */ 799*cdf0e10cSrcweir /* info_p-Implementation */ 800*cdf0e10cSrcweir /* */ 801*cdf0e10cSrcweir /*********************************************************************************/ 802*cdf0e10cSrcweir // Info for the properties 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL 805*cdf0e10cSrcweir shell::info_p( const rtl::OUString& aUnqPath ) 806*cdf0e10cSrcweir throw() 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 809*cdf0e10cSrcweir XPropertySetInfo_impl* p = new XPropertySetInfo_impl( this,aUnqPath ); 810*cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >( p ); 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir /*********************************************************************************/ 817*cdf0e10cSrcweir /* */ 818*cdf0e10cSrcweir /* setv-Implementation */ 819*cdf0e10cSrcweir /* */ 820*cdf0e10cSrcweir /*********************************************************************************/ 821*cdf0e10cSrcweir // 822*cdf0e10cSrcweir // Sets the values of the properties belonging to fileURL aUnqPath 823*cdf0e10cSrcweir // 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL 827*cdf0e10cSrcweir shell::setv( const rtl::OUString& aUnqPath, 828*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& values ) 829*cdf0e10cSrcweir throw() 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir sal_Int32 propChanged = 0; 834*cdf0e10cSrcweir uno::Sequence< uno::Any > ret( values.getLength() ); 835*cdf0e10cSrcweir uno::Sequence< beans::PropertyChangeEvent > seqChanged( values.getLength() ); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath ); 838*cdf0e10cSrcweir PropertySet& properties = *( it->second.properties ); 839*cdf0e10cSrcweir shell::PropertySet::iterator it1; 840*cdf0e10cSrcweir uno::Any aAny; 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir for( sal_Int32 i = 0; i < values.getLength(); ++i ) 843*cdf0e10cSrcweir { 844*cdf0e10cSrcweir MyProperty toset( values[i].Name ); 845*cdf0e10cSrcweir it1 = properties.find( toset ); 846*cdf0e10cSrcweir if( it1 == properties.end() ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir ret[i] <<= beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 849*cdf0e10cSrcweir continue; 850*cdf0e10cSrcweir } 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir aAny = it1->getValue(); 853*cdf0e10cSrcweir if( aAny == values[i].Value ) 854*cdf0e10cSrcweir continue; // nothing needs to be changed 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir if( it1->getAttributes() & beans::PropertyAttribute::READONLY ) 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir ret[i] <<= lang::IllegalAccessException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 859*cdf0e10cSrcweir continue; 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir seqChanged[ propChanged ].PropertyName = values[i].Name; 863*cdf0e10cSrcweir seqChanged[ propChanged ].PropertyHandle = -1; 864*cdf0e10cSrcweir seqChanged[ propChanged ].Further = false; 865*cdf0e10cSrcweir seqChanged[ propChanged ].OldValue <<= aAny; 866*cdf0e10cSrcweir seqChanged[ propChanged++ ].NewValue = values[i].Value; 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir it1->setValue( values[i].Value ); // Put the new value into the local cash 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir if( ! it1->IsNative() ) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir // Also put logical properties into storage 873*cdf0e10cSrcweir if( !it->second.xS.is() ) 874*cdf0e10cSrcweir load( it,true ); 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir if( ( values[i].Name == ContentType ) && 877*cdf0e10cSrcweir it1->getState() == beans::PropertyState_DEFAULT_VALUE ) 878*cdf0e10cSrcweir { // Special logic for ContentType 879*cdf0e10cSrcweir // 09.07.01: Not reached anymore, because ContentType is readonly 880*cdf0e10cSrcweir it1->setState( beans::PropertyState_DIRECT_VALUE ); 881*cdf0e10cSrcweir it->second.xC->addProperty( values[i].Name, 882*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID, 883*cdf0e10cSrcweir values[i].Value ); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir try 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir it->second.xS->setPropertyValue( values[i].Name,values[i].Value ); 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir catch( const uno::Exception& e ) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir --propChanged; // unsuccessful setting 893*cdf0e10cSrcweir ret[i] <<= e; 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir else 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir // native properties 899*cdf0e10cSrcweir // Setting of physical file properties 900*cdf0e10cSrcweir if( values[i].Name == Size ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir sal_Int64 newSize = 0; 903*cdf0e10cSrcweir if( values[i].Value >>= newSize ) 904*cdf0e10cSrcweir { // valid value for the size 905*cdf0e10cSrcweir osl::File aFile(aUnqPath); 906*cdf0e10cSrcweir bool err = 907*cdf0e10cSrcweir aFile.open(OpenFlag_Write) != osl::FileBase::E_None || 908*cdf0e10cSrcweir aFile.setSize(sal_uInt64(newSize)) != osl::FileBase::E_None || 909*cdf0e10cSrcweir aFile.close() != osl::FileBase::E_None; 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir if( err ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir --propChanged; // unsuccessful setting 914*cdf0e10cSrcweir uno::Sequence< uno::Any > names( 1 ); 915*cdf0e10cSrcweir ret[0] <<= beans::PropertyValue( 916*cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1, 917*cdf0e10cSrcweir uno::makeAny(aUnqPath), 918*cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE); 919*cdf0e10cSrcweir IOErrorCode ioError(IOErrorCode_GENERAL); 920*cdf0e10cSrcweir ret[i] <<= InteractiveAugmentedIOException( 921*cdf0e10cSrcweir rtl::OUString(), 922*cdf0e10cSrcweir 0, 923*cdf0e10cSrcweir task::InteractionClassification_ERROR, 924*cdf0e10cSrcweir ioError, 925*cdf0e10cSrcweir names ); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir else 929*cdf0e10cSrcweir ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir else if(values[i].Name == IsReadOnly || 932*cdf0e10cSrcweir values[i].Name == IsHidden) 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir sal_Bool value = sal_False; 935*cdf0e10cSrcweir if( values[i].Value >>= value ) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir osl::DirectoryItem aDirItem; 938*cdf0e10cSrcweir osl::FileBase::RC err = 939*cdf0e10cSrcweir osl::DirectoryItem::get(aUnqPath,aDirItem); 940*cdf0e10cSrcweir sal_uInt64 nAttributes(0); 941*cdf0e10cSrcweir if(err == osl::FileBase::E_None) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir osl::FileStatus aFileStatus(FileStatusMask_Attributes); 944*cdf0e10cSrcweir err = aDirItem.getFileStatus(aFileStatus); 945*cdf0e10cSrcweir if(err == osl::FileBase::E_None && 946*cdf0e10cSrcweir aFileStatus.isValid(FileStatusMask_Attributes)) 947*cdf0e10cSrcweir nAttributes = aFileStatus.getAttributes(); 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir // now we have the attributes provided all went well. 950*cdf0e10cSrcweir if(err == osl::FileBase::E_None) { 951*cdf0e10cSrcweir if(values[i].Name == IsReadOnly) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir nAttributes &= ~(Attribute_OwnWrite | 954*cdf0e10cSrcweir Attribute_GrpWrite | 955*cdf0e10cSrcweir Attribute_OthWrite | 956*cdf0e10cSrcweir Attribute_ReadOnly); 957*cdf0e10cSrcweir if(value) 958*cdf0e10cSrcweir nAttributes |= Attribute_ReadOnly; 959*cdf0e10cSrcweir else 960*cdf0e10cSrcweir nAttributes |= ( 961*cdf0e10cSrcweir Attribute_OwnWrite | 962*cdf0e10cSrcweir Attribute_GrpWrite | 963*cdf0e10cSrcweir Attribute_OthWrite); 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir else if(values[i].Name == IsHidden) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir nAttributes &= ~(Attribute_Hidden); 968*cdf0e10cSrcweir if(value) 969*cdf0e10cSrcweir nAttributes |= Attribute_Hidden; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir err = osl::File::setAttributes( 972*cdf0e10cSrcweir aUnqPath,nAttributes); 973*cdf0e10cSrcweir } 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 976*cdf0e10cSrcweir { 977*cdf0e10cSrcweir --propChanged; // unsuccessful setting 978*cdf0e10cSrcweir uno::Sequence< uno::Any > names( 1 ); 979*cdf0e10cSrcweir names[0] <<= beans::PropertyValue( 980*cdf0e10cSrcweir rtl::OUString::createFromAscii("Uri"), -1, 981*cdf0e10cSrcweir uno::makeAny(aUnqPath), 982*cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE); 983*cdf0e10cSrcweir IOErrorCode ioError; 984*cdf0e10cSrcweir switch( err ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir case osl::FileBase::E_NOMEM: 987*cdf0e10cSrcweir // not enough memory for allocating structures <br> 988*cdf0e10cSrcweir ioError = IOErrorCode_OUT_OF_MEMORY; 989*cdf0e10cSrcweir break; 990*cdf0e10cSrcweir case osl::FileBase::E_INVAL: 991*cdf0e10cSrcweir // the format of the parameters was not valid<p> 992*cdf0e10cSrcweir ioError = IOErrorCode_INVALID_PARAMETER; 993*cdf0e10cSrcweir break; 994*cdf0e10cSrcweir case osl::FileBase::E_NAMETOOLONG: 995*cdf0e10cSrcweir // File name too long<br> 996*cdf0e10cSrcweir ioError = IOErrorCode_NAME_TOO_LONG; 997*cdf0e10cSrcweir break; 998*cdf0e10cSrcweir case osl::FileBase::E_NOENT: 999*cdf0e10cSrcweir // No such file or directory<br> 1000*cdf0e10cSrcweir case osl::FileBase::E_NOLINK: 1001*cdf0e10cSrcweir // Link has been severed<br> 1002*cdf0e10cSrcweir ioError = IOErrorCode_NOT_EXISTING; 1003*cdf0e10cSrcweir break; 1004*cdf0e10cSrcweir case osl::FileBase::E_ROFS: 1005*cdf0e10cSrcweir // #i4735# handle ROFS transparently 1006*cdf0e10cSrcweir // as ACCESS_DENIED 1007*cdf0e10cSrcweir case osl::FileBase::E_PERM: 1008*cdf0e10cSrcweir case osl::FileBase::E_ACCES: 1009*cdf0e10cSrcweir // permission denied<br> 1010*cdf0e10cSrcweir ioError = IOErrorCode_ACCESS_DENIED; 1011*cdf0e10cSrcweir break; 1012*cdf0e10cSrcweir case osl::FileBase::E_LOOP: 1013*cdf0e10cSrcweir // Too many symbolic links encountered<br> 1014*cdf0e10cSrcweir case osl::FileBase::E_FAULT: 1015*cdf0e10cSrcweir // Bad address<br> 1016*cdf0e10cSrcweir case osl::FileBase::E_IO: 1017*cdf0e10cSrcweir // I/O error<br> 1018*cdf0e10cSrcweir case osl::FileBase::E_NOSYS: 1019*cdf0e10cSrcweir // Function not implemented<br> 1020*cdf0e10cSrcweir case osl::FileBase::E_MULTIHOP: 1021*cdf0e10cSrcweir // Multihop attempted<br> 1022*cdf0e10cSrcweir case osl::FileBase::E_INTR: 1023*cdf0e10cSrcweir // function call was interrupted<p> 1024*cdf0e10cSrcweir default: 1025*cdf0e10cSrcweir ioError = IOErrorCode_GENERAL; 1026*cdf0e10cSrcweir break; 1027*cdf0e10cSrcweir } 1028*cdf0e10cSrcweir ret[i] <<= InteractiveAugmentedIOException( 1029*cdf0e10cSrcweir rtl::OUString(), 1030*cdf0e10cSrcweir 0, 1031*cdf0e10cSrcweir task::InteractionClassification_ERROR, 1032*cdf0e10cSrcweir ioError, 1033*cdf0e10cSrcweir names ); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir else 1037*cdf0e10cSrcweir ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 1038*cdf0e10cSrcweir } 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir } // end for 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir if( propChanged ) 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir seqChanged.realloc( propChanged ); 1045*cdf0e10cSrcweir notifyPropertyChanges( getPropertyChangeNotifier( aUnqPath ),seqChanged ); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir return ret; 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir 1051*cdf0e10cSrcweir /*********************************************************************************/ 1052*cdf0e10cSrcweir /* */ 1053*cdf0e10cSrcweir /* getv-Implementation */ 1054*cdf0e10cSrcweir /* */ 1055*cdf0e10cSrcweir /*********************************************************************************/ 1056*cdf0e10cSrcweir // 1057*cdf0e10cSrcweir // Reads the values of the properties belonging to fileURL aUnqPath; 1058*cdf0e10cSrcweir // Returns an XRow object containing the values in the requested order. 1059*cdf0e10cSrcweir // 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir uno::Reference< sdbc::XRow > SAL_CALL 1063*cdf0e10cSrcweir shell::getv( sal_Int32 CommandId, 1064*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 1065*cdf0e10cSrcweir const uno::Sequence< beans::Property >& properties ) 1066*cdf0e10cSrcweir throw() 1067*cdf0e10cSrcweir { 1068*cdf0e10cSrcweir uno::Sequence< uno::Any > seq( properties.getLength() ); 1069*cdf0e10cSrcweir 1070*cdf0e10cSrcweir sal_Int32 n_Mask; 1071*cdf0e10cSrcweir getMaskFromProperties( n_Mask,properties ); 1072*cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask ); 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir osl::DirectoryItem aDirItem; 1075*cdf0e10cSrcweir osl::FileBase::RC nError1 = osl::DirectoryItem::get( aUnqPath,aDirItem ); 1076*cdf0e10cSrcweir if( nError1 != osl::FileBase::E_None ) 1077*cdf0e10cSrcweir installError(CommandId, 1078*cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED 1079*cdf0e10cSrcweir nError1); 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir osl::FileBase::RC nError2 = aDirItem.getFileStatus( aFileStatus ); 1082*cdf0e10cSrcweir if( nError1 == osl::FileBase::E_None && 1083*cdf0e10cSrcweir nError2 != osl::FileBase::E_None ) 1084*cdf0e10cSrcweir installError(CommandId, 1085*cdf0e10cSrcweir TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED 1086*cdf0e10cSrcweir nError2); 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath ); 1092*cdf0e10cSrcweir commit( it,aFileStatus ); 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir shell::PropertySet::iterator it1; 1095*cdf0e10cSrcweir PropertySet& propset = *(it->second.properties); 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i ) 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir MyProperty readProp( properties[i].Name ); 1100*cdf0e10cSrcweir it1 = propset.find( readProp ); 1101*cdf0e10cSrcweir if( it1 == propset.end() ) 1102*cdf0e10cSrcweir seq[i] = uno::Any(); 1103*cdf0e10cSrcweir else 1104*cdf0e10cSrcweir seq[i] = it1->getValue(); 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir XRow_impl* p = new XRow_impl( this,seq ); 1109*cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( p ); 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir 1113*cdf0e10cSrcweir /********************************************************************************/ 1114*cdf0e10cSrcweir /* */ 1115*cdf0e10cSrcweir /* transfer-commandos */ 1116*cdf0e10cSrcweir /* */ 1117*cdf0e10cSrcweir /********************************************************************************/ 1118*cdf0e10cSrcweir 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir /********************************************************************************/ 1121*cdf0e10cSrcweir /* */ 1122*cdf0e10cSrcweir /* move-implementation */ 1123*cdf0e10cSrcweir /* */ 1124*cdf0e10cSrcweir /********************************************************************************/ 1125*cdf0e10cSrcweir // 1126*cdf0e10cSrcweir // Moves the content belonging to fileURL srcUnqPath to fileURL dstUnqPath. 1127*cdf0e10cSrcweir // 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir void SAL_CALL 1130*cdf0e10cSrcweir shell::move( sal_Int32 CommandId, 1131*cdf0e10cSrcweir const rtl::OUString srcUnqPath, 1132*cdf0e10cSrcweir const rtl::OUString dstUnqPathIn, 1133*cdf0e10cSrcweir const sal_Int32 NameClash ) 1134*cdf0e10cSrcweir throw() 1135*cdf0e10cSrcweir { 1136*cdf0e10cSrcweir // --> #i88446# Method notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) ); crashes if 1137*cdf0e10cSrcweir // srcUnqPath and dstUnqPathIn are equal 1138*cdf0e10cSrcweir if( srcUnqPath == dstUnqPathIn ) 1139*cdf0e10cSrcweir return; 1140*cdf0e10cSrcweir // <-- 1141*cdf0e10cSrcweir // 1142*cdf0e10cSrcweir osl::FileBase::RC nError; 1143*cdf0e10cSrcweir rtl::OUString dstUnqPath( dstUnqPathIn ); 1144*cdf0e10cSrcweir 1145*cdf0e10cSrcweir switch( NameClash ) 1146*cdf0e10cSrcweir { 1147*cdf0e10cSrcweir case NameClash::KEEP: 1148*cdf0e10cSrcweir { 1149*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true ); 1150*cdf0e10cSrcweir if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST ) 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir installError( CommandId, 1153*cdf0e10cSrcweir TASKHANDLING_KEEPERROR_FOR_MOVE, 1154*cdf0e10cSrcweir nError ); 1155*cdf0e10cSrcweir return; 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir break; 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir case NameClash::OVERWRITE: 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir // stat to determine whether we have a symlink 1162*cdf0e10cSrcweir rtl::OUString targetPath(dstUnqPath); 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir osl::FileStatus aStatus(FileStatusMask_Type|FileStatusMask_LinkTargetURL); 1165*cdf0e10cSrcweir osl::DirectoryItem aItem; 1166*cdf0e10cSrcweir osl::DirectoryItem::get(dstUnqPath,aItem); 1167*cdf0e10cSrcweir aItem.getFileStatus(aStatus); 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir if( aStatus.isValid(FileStatusMask_Type) && 1170*cdf0e10cSrcweir aStatus.isValid(FileStatusMask_LinkTargetURL) && 1171*cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link ) 1172*cdf0e10cSrcweir targetPath = aStatus.getLinkTargetURL(); 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir // Will do nothing if file does not exist. 1175*cdf0e10cSrcweir osl::File::remove( targetPath ); 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,targetPath ); 1178*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1179*cdf0e10cSrcweir { 1180*cdf0e10cSrcweir installError( CommandId, 1181*cdf0e10cSrcweir TASKHANDLING_OVERWRITE_FOR_MOVE, 1182*cdf0e10cSrcweir nError ); 1183*cdf0e10cSrcweir return; 1184*cdf0e10cSrcweir } 1185*cdf0e10cSrcweir break; 1186*cdf0e10cSrcweir } 1187*cdf0e10cSrcweir case NameClash::RENAME: 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir rtl::OUString newDstUnqPath; 1190*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true ); 1191*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1192*cdf0e10cSrcweir { 1193*cdf0e10cSrcweir // "invent" a new valid title. 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir sal_Int32 nPos = -1; 1196*cdf0e10cSrcweir sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' ); 1197*cdf0e10cSrcweir sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' ); 1198*cdf0e10cSrcweir if( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment 1199*cdf0e10cSrcweir && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot 1200*cdf0e10cSrcweir nPos = nLastDot; 1201*cdf0e10cSrcweir else 1202*cdf0e10cSrcweir nPos = dstUnqPath.getLength(); 1203*cdf0e10cSrcweir 1204*cdf0e10cSrcweir sal_Int32 nTry = 0; 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir do 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir newDstUnqPath = dstUnqPath; 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir rtl::OUString aPostFix( rtl::OUString::createFromAscii( "_" ) ); 1211*cdf0e10cSrcweir aPostFix += rtl::OUString::valueOf( ++nTry ); 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostFix ); 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,newDstUnqPath,true ); 1216*cdf0e10cSrcweir } 1217*cdf0e10cSrcweir while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) ); 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1221*cdf0e10cSrcweir { 1222*cdf0e10cSrcweir installError( CommandId, 1223*cdf0e10cSrcweir TASKHANDLING_RENAME_FOR_MOVE ); 1224*cdf0e10cSrcweir return; 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir else if( nError != osl::FileBase::E_None ) 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir installError( CommandId, 1229*cdf0e10cSrcweir TASKHANDLING_RENAMEMOVE_FOR_MOVE, 1230*cdf0e10cSrcweir nError ); 1231*cdf0e10cSrcweir return; 1232*cdf0e10cSrcweir } 1233*cdf0e10cSrcweir else 1234*cdf0e10cSrcweir dstUnqPath = newDstUnqPath; 1235*cdf0e10cSrcweir 1236*cdf0e10cSrcweir break; 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir case NameClash::ERROR: 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true ); 1241*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1242*cdf0e10cSrcweir { 1243*cdf0e10cSrcweir installError( CommandId, 1244*cdf0e10cSrcweir TASKHANDLING_NAMECLASH_FOR_MOVE ); 1245*cdf0e10cSrcweir return; 1246*cdf0e10cSrcweir } 1247*cdf0e10cSrcweir else if( nError != osl::FileBase::E_None ) 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir installError( CommandId, 1250*cdf0e10cSrcweir TASKHANDLING_NAMECLASHMOVE_FOR_MOVE, 1251*cdf0e10cSrcweir nError ); 1252*cdf0e10cSrcweir return; 1253*cdf0e10cSrcweir } 1254*cdf0e10cSrcweir break; 1255*cdf0e10cSrcweir } 1256*cdf0e10cSrcweir case NameClash::ASK: 1257*cdf0e10cSrcweir default: 1258*cdf0e10cSrcweir { 1259*cdf0e10cSrcweir nError = osl_File_move( srcUnqPath,dstUnqPath,true ); 1260*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir installError( CommandId, 1263*cdf0e10cSrcweir TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE, 1264*cdf0e10cSrcweir NameClash::ASK); 1265*cdf0e10cSrcweir return; 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir } 1268*cdf0e10cSrcweir break; 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir // Determine, whether we have moved a file or a folder 1272*cdf0e10cSrcweir osl::DirectoryItem aItem; 1273*cdf0e10cSrcweir nError = osl::DirectoryItem::get( dstUnqPath,aItem ); 1274*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1275*cdf0e10cSrcweir { 1276*cdf0e10cSrcweir installError( CommandId, 1277*cdf0e10cSrcweir TASKHANDLING_TRANSFER_BY_MOVE_SOURCE, 1278*cdf0e10cSrcweir nError ); 1279*cdf0e10cSrcweir return; 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir osl::FileStatus aStatus( FileStatusMask_Type ); 1282*cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus ); 1283*cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( FileStatusMask_Type ) ) 1284*cdf0e10cSrcweir { 1285*cdf0e10cSrcweir installError( CommandId, 1286*cdf0e10cSrcweir TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT, 1287*cdf0e10cSrcweir nError ); 1288*cdf0e10cSrcweir return; 1289*cdf0e10cSrcweir } 1290*cdf0e10cSrcweir sal_Bool isDocument = ( aStatus.getFileType() == osl::FileStatus::Regular ); 1291*cdf0e10cSrcweir 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir copyPersistentSet( srcUnqPath,dstUnqPath,!isDocument ); 1294*cdf0e10cSrcweir 1295*cdf0e10cSrcweir rtl::OUString aDstParent = getParentName( dstUnqPath ); 1296*cdf0e10cSrcweir rtl::OUString aDstTitle = getTitle( dstUnqPath ); 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir rtl::OUString aSrcParent = getParentName( srcUnqPath ); 1299*cdf0e10cSrcweir rtl::OUString aSrcTitle = getTitle( srcUnqPath ); 1300*cdf0e10cSrcweir 1301*cdf0e10cSrcweir notifyInsert( getContentEventListeners( aDstParent ),dstUnqPath ); 1302*cdf0e10cSrcweir if( aDstParent != aSrcParent ) 1303*cdf0e10cSrcweir notifyContentRemoved( getContentEventListeners( aSrcParent ),srcUnqPath ); 1304*cdf0e10cSrcweir 1305*cdf0e10cSrcweir notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) ); 1306*cdf0e10cSrcweir erasePersistentSet( srcUnqPath,!isDocument ); 1307*cdf0e10cSrcweir } 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir /********************************************************************************/ 1312*cdf0e10cSrcweir /* */ 1313*cdf0e10cSrcweir /* copy-implementation */ 1314*cdf0e10cSrcweir /* */ 1315*cdf0e10cSrcweir /********************************************************************************/ 1316*cdf0e10cSrcweir // 1317*cdf0e10cSrcweir // Copies the content belonging to fileURL srcUnqPath to fileURL dstUnqPath ( files and directories ) 1318*cdf0e10cSrcweir // 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir namespace { 1321*cdf0e10cSrcweir 1322*cdf0e10cSrcweir bool getType( 1323*cdf0e10cSrcweir TaskManager & task, sal_Int32 id, rtl::OUString const & fileUrl, 1324*cdf0e10cSrcweir osl::DirectoryItem * item, osl::FileStatus::Type * type) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir OSL_ASSERT(item != 0 && type != 0); 1327*cdf0e10cSrcweir osl::FileBase::RC err = osl::DirectoryItem::get(fileUrl, *item); 1328*cdf0e10cSrcweir if (err != osl::FileBase::E_None) { 1329*cdf0e10cSrcweir task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCE, err); 1330*cdf0e10cSrcweir return false; 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir osl::FileStatus stat(FileStatusMask_Type); 1333*cdf0e10cSrcweir err = item->getFileStatus(stat); 1334*cdf0e10cSrcweir if (err != osl::FileBase::E_None) { 1335*cdf0e10cSrcweir task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, err); 1336*cdf0e10cSrcweir return false; 1337*cdf0e10cSrcweir } 1338*cdf0e10cSrcweir *type = stat.getFileType(); 1339*cdf0e10cSrcweir return true; 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir } 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir void SAL_CALL 1345*cdf0e10cSrcweir shell::copy( 1346*cdf0e10cSrcweir sal_Int32 CommandId, 1347*cdf0e10cSrcweir const rtl::OUString srcUnqPath, 1348*cdf0e10cSrcweir const rtl::OUString dstUnqPathIn, 1349*cdf0e10cSrcweir sal_Int32 NameClash ) 1350*cdf0e10cSrcweir throw() 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir osl::FileBase::RC nError; 1353*cdf0e10cSrcweir rtl::OUString dstUnqPath( dstUnqPathIn ); 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir // Resolve symbolic links within the source path. If srcUnqPath denotes a 1356*cdf0e10cSrcweir // symbolic link (targeting either a file or a folder), the contents of the 1357*cdf0e10cSrcweir // target is copied (recursively, in the case of a folder). However, if 1358*cdf0e10cSrcweir // recursively copying the contents of a folder causes a symbolic link to be 1359*cdf0e10cSrcweir // copied, the symbolic link itself is copied. 1360*cdf0e10cSrcweir osl::DirectoryItem item; 1361*cdf0e10cSrcweir osl::FileStatus::Type type; 1362*cdf0e10cSrcweir if (!getType(*this, CommandId, srcUnqPath, &item, &type)) { 1363*cdf0e10cSrcweir return; 1364*cdf0e10cSrcweir } 1365*cdf0e10cSrcweir rtl::OUString rslvdSrcUnqPath; 1366*cdf0e10cSrcweir if (type == osl::FileStatus::Link) { 1367*cdf0e10cSrcweir osl::FileStatus stat(FileStatusMask_LinkTargetURL); 1368*cdf0e10cSrcweir nError = item.getFileStatus(stat); 1369*cdf0e10cSrcweir if (nError != osl::FileBase::E_None) { 1370*cdf0e10cSrcweir installError( 1371*cdf0e10cSrcweir CommandId, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, nError); 1372*cdf0e10cSrcweir return; 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir rslvdSrcUnqPath = stat.getLinkTargetURL(); 1375*cdf0e10cSrcweir if (!getType(*this, CommandId, srcUnqPath, &item, &type)) { 1376*cdf0e10cSrcweir return; 1377*cdf0e10cSrcweir } 1378*cdf0e10cSrcweir } else { 1379*cdf0e10cSrcweir rslvdSrcUnqPath = srcUnqPath; 1380*cdf0e10cSrcweir } 1381*cdf0e10cSrcweir 1382*cdf0e10cSrcweir sal_Bool isDocument 1383*cdf0e10cSrcweir = type != osl::FileStatus::Directory && type != osl::FileStatus::Volume; 1384*cdf0e10cSrcweir sal_Int32 IsWhat = isDocument ? -1 : 1; 1385*cdf0e10cSrcweir 1386*cdf0e10cSrcweir switch( NameClash ) 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir case NameClash::KEEP: 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); 1391*cdf0e10cSrcweir if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST ) 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir installError( CommandId, 1394*cdf0e10cSrcweir TASKHANDLING_KEEPERROR_FOR_COPY, 1395*cdf0e10cSrcweir nError ); 1396*cdf0e10cSrcweir return; 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir break; 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir case NameClash::OVERWRITE: 1401*cdf0e10cSrcweir { 1402*cdf0e10cSrcweir // remove (..., MustExist = sal_False). 1403*cdf0e10cSrcweir remove( CommandId, dstUnqPath, IsWhat, sal_False ); 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir // copy. 1406*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,false ); 1407*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1408*cdf0e10cSrcweir { 1409*cdf0e10cSrcweir installError( CommandId, 1410*cdf0e10cSrcweir TASKHANDLING_OVERWRITE_FOR_COPY, 1411*cdf0e10cSrcweir nError ); 1412*cdf0e10cSrcweir return; 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir break; 1415*cdf0e10cSrcweir } 1416*cdf0e10cSrcweir case NameClash::RENAME: 1417*cdf0e10cSrcweir { 1418*cdf0e10cSrcweir rtl::OUString newDstUnqPath; 1419*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); 1420*cdf0e10cSrcweir 1421*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1422*cdf0e10cSrcweir { 1423*cdf0e10cSrcweir // "invent" a new valid title. 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir sal_Int32 nPos = -1; 1426*cdf0e10cSrcweir sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' ); 1427*cdf0e10cSrcweir sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' ); 1428*cdf0e10cSrcweir if ( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment 1429*cdf0e10cSrcweir && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot 1430*cdf0e10cSrcweir nPos = nLastDot; 1431*cdf0e10cSrcweir else 1432*cdf0e10cSrcweir nPos = dstUnqPath.getLength(); 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir sal_Int32 nTry = 0; 1435*cdf0e10cSrcweir 1436*cdf0e10cSrcweir do 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir newDstUnqPath = dstUnqPath; 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir rtl::OUString aPostFix( rtl::OUString::createFromAscii( "_" ) ); 1441*cdf0e10cSrcweir aPostFix += rtl::OUString::valueOf( ++nTry ); 1442*cdf0e10cSrcweir 1443*cdf0e10cSrcweir newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostFix ); 1444*cdf0e10cSrcweir 1445*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,newDstUnqPath,IsWhat,true ); 1446*cdf0e10cSrcweir } 1447*cdf0e10cSrcweir while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) ); 1448*cdf0e10cSrcweir } 1449*cdf0e10cSrcweir 1450*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1451*cdf0e10cSrcweir { 1452*cdf0e10cSrcweir installError( CommandId, 1453*cdf0e10cSrcweir TASKHANDLING_RENAME_FOR_COPY ); 1454*cdf0e10cSrcweir return; 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir else if( nError != osl::FileBase::E_None ) 1457*cdf0e10cSrcweir { 1458*cdf0e10cSrcweir installError( CommandId, 1459*cdf0e10cSrcweir TASKHANDLING_RENAMEMOVE_FOR_COPY, 1460*cdf0e10cSrcweir nError ); 1461*cdf0e10cSrcweir return; 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir else 1464*cdf0e10cSrcweir dstUnqPath = newDstUnqPath; 1465*cdf0e10cSrcweir 1466*cdf0e10cSrcweir break; 1467*cdf0e10cSrcweir } 1468*cdf0e10cSrcweir case NameClash::ERROR: 1469*cdf0e10cSrcweir { 1470*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir installError( CommandId, 1475*cdf0e10cSrcweir TASKHANDLING_NAMECLASH_FOR_COPY ); 1476*cdf0e10cSrcweir return; 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir else if( nError != osl::FileBase::E_None ) 1479*cdf0e10cSrcweir { 1480*cdf0e10cSrcweir installError( CommandId, 1481*cdf0e10cSrcweir TASKHANDLING_NAMECLASHMOVE_FOR_COPY, 1482*cdf0e10cSrcweir nError ); 1483*cdf0e10cSrcweir return; 1484*cdf0e10cSrcweir } 1485*cdf0e10cSrcweir break; 1486*cdf0e10cSrcweir } 1487*cdf0e10cSrcweir case NameClash::ASK: 1488*cdf0e10cSrcweir default: 1489*cdf0e10cSrcweir { 1490*cdf0e10cSrcweir nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); 1491*cdf0e10cSrcweir 1492*cdf0e10cSrcweir if( nError == osl::FileBase::E_EXIST ) 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir installError( CommandId, 1495*cdf0e10cSrcweir TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY, 1496*cdf0e10cSrcweir NameClash); 1497*cdf0e10cSrcweir return; 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir break; 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir } 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir copyPersistentSet( srcUnqPath,dstUnqPath, !isDocument ); 1504*cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( dstUnqPath ) ),dstUnqPath ); 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir 1509*cdf0e10cSrcweir /********************************************************************************/ 1510*cdf0e10cSrcweir /* */ 1511*cdf0e10cSrcweir /* remove-implementation */ 1512*cdf0e10cSrcweir /* */ 1513*cdf0e10cSrcweir /********************************************************************************/ 1514*cdf0e10cSrcweir // 1515*cdf0e10cSrcweir // Deletes the content belonging to fileURL aUnqPath( recursively in case of directory ) 1516*cdf0e10cSrcweir // Return: success of operation 1517*cdf0e10cSrcweir // 1518*cdf0e10cSrcweir 1519*cdf0e10cSrcweir 1520*cdf0e10cSrcweir sal_Bool SAL_CALL 1521*cdf0e10cSrcweir shell::remove( sal_Int32 CommandId, 1522*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 1523*cdf0e10cSrcweir sal_Int32 IsWhat, 1524*cdf0e10cSrcweir sal_Bool MustExist ) 1525*cdf0e10cSrcweir throw() 1526*cdf0e10cSrcweir { 1527*cdf0e10cSrcweir sal_Int32 nMask = FileStatusMask_Type | FileStatusMask_FileURL; 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir osl::DirectoryItem aItem; 1530*cdf0e10cSrcweir osl::FileStatus aStatus( nMask ); 1531*cdf0e10cSrcweir osl::FileBase::RC nError; 1532*cdf0e10cSrcweir 1533*cdf0e10cSrcweir if( IsWhat == 0 ) // Determine whether we are removing a directory or a file 1534*cdf0e10cSrcweir { 1535*cdf0e10cSrcweir nError = osl::DirectoryItem::get( aUnqPath, aItem ); 1536*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1537*cdf0e10cSrcweir { 1538*cdf0e10cSrcweir if (MustExist) 1539*cdf0e10cSrcweir { 1540*cdf0e10cSrcweir installError( CommandId, 1541*cdf0e10cSrcweir TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE, 1542*cdf0e10cSrcweir nError ); 1543*cdf0e10cSrcweir } 1544*cdf0e10cSrcweir return (!MustExist); 1545*cdf0e10cSrcweir } 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus ); 1548*cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) ) 1549*cdf0e10cSrcweir { 1550*cdf0e10cSrcweir installError( CommandId, 1551*cdf0e10cSrcweir TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE, 1552*cdf0e10cSrcweir nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR ); 1553*cdf0e10cSrcweir return sal_False; 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir if( aStatus.getFileType() == osl::FileStatus::Regular || 1557*cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link ) 1558*cdf0e10cSrcweir IsWhat = -1; // RemoveFile 1559*cdf0e10cSrcweir else if( aStatus.getFileType() == osl::FileStatus::Directory || 1560*cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Volume ) 1561*cdf0e10cSrcweir IsWhat = +1; // RemoveDirectory 1562*cdf0e10cSrcweir } 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir if( IsWhat == -1 ) // Removing a file 1566*cdf0e10cSrcweir { 1567*cdf0e10cSrcweir nError = osl::File::remove( aUnqPath ); 1568*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1569*cdf0e10cSrcweir { 1570*cdf0e10cSrcweir if (MustExist) 1571*cdf0e10cSrcweir { 1572*cdf0e10cSrcweir installError( CommandId, 1573*cdf0e10cSrcweir TASKHANDLING_DELETEFILE_FOR_REMOVE, 1574*cdf0e10cSrcweir nError ); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir return (!MustExist); 1577*cdf0e10cSrcweir } 1578*cdf0e10cSrcweir else 1579*cdf0e10cSrcweir { 1580*cdf0e10cSrcweir notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) ); 1581*cdf0e10cSrcweir erasePersistentSet( aUnqPath ); // Removes from XPersistentPropertySet 1582*cdf0e10cSrcweir } 1583*cdf0e10cSrcweir } 1584*cdf0e10cSrcweir else if( IsWhat == +1 ) // Removing a directory 1585*cdf0e10cSrcweir { 1586*cdf0e10cSrcweir osl::Directory aDirectory( aUnqPath ); 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir nError = aDirectory.open(); 1589*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir if (MustExist) 1592*cdf0e10cSrcweir { 1593*cdf0e10cSrcweir installError( CommandId, 1594*cdf0e10cSrcweir TASKHANDLING_OPENDIRECTORY_FOR_REMOVE, 1595*cdf0e10cSrcweir nError ); 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir return (!MustExist); 1598*cdf0e10cSrcweir } 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir sal_Bool whileSuccess = sal_True; 1601*cdf0e10cSrcweir sal_Int32 recurse = 0; 1602*cdf0e10cSrcweir rtl::OUString name; 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir nError = aDirectory.getNextItem( aItem ); 1605*cdf0e10cSrcweir while( nError == osl::FileBase::E_None ) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir nError = aItem.getFileStatus( aStatus ); 1608*cdf0e10cSrcweir if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) ) 1609*cdf0e10cSrcweir { 1610*cdf0e10cSrcweir installError( CommandId, 1611*cdf0e10cSrcweir TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE, 1612*cdf0e10cSrcweir nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR ); 1613*cdf0e10cSrcweir whileSuccess = sal_False; 1614*cdf0e10cSrcweir break; 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir if( aStatus.getFileType() == osl::FileStatus::Regular || 1618*cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Link ) 1619*cdf0e10cSrcweir recurse = -1; 1620*cdf0e10cSrcweir else if( aStatus.getFileType() == osl::FileStatus::Directory || 1621*cdf0e10cSrcweir aStatus.getFileType() == osl::FileStatus::Volume ) 1622*cdf0e10cSrcweir recurse = +1; 1623*cdf0e10cSrcweir 1624*cdf0e10cSrcweir name = aStatus.getFileURL(); 1625*cdf0e10cSrcweir whileSuccess = remove( 1626*cdf0e10cSrcweir CommandId, name, recurse, MustExist ); 1627*cdf0e10cSrcweir if( !whileSuccess ) 1628*cdf0e10cSrcweir break; 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir nError = aDirectory.getNextItem( aItem ); 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir 1633*cdf0e10cSrcweir aDirectory.close(); 1634*cdf0e10cSrcweir 1635*cdf0e10cSrcweir if( ! whileSuccess ) 1636*cdf0e10cSrcweir return sal_False; // error code is installed 1637*cdf0e10cSrcweir 1638*cdf0e10cSrcweir if( nError != osl::FileBase::E_NOENT ) 1639*cdf0e10cSrcweir { 1640*cdf0e10cSrcweir installError( CommandId, 1641*cdf0e10cSrcweir TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE, 1642*cdf0e10cSrcweir nError ); 1643*cdf0e10cSrcweir return sal_False; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir nError = osl::Directory::remove( aUnqPath ); 1647*cdf0e10cSrcweir if( nError != osl::FileBase::E_None ) 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir if (MustExist) 1650*cdf0e10cSrcweir { 1651*cdf0e10cSrcweir installError( CommandId, 1652*cdf0e10cSrcweir TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE, 1653*cdf0e10cSrcweir nError ); 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir return (!MustExist); 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir else 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) ); 1660*cdf0e10cSrcweir erasePersistentSet( aUnqPath ); 1661*cdf0e10cSrcweir } 1662*cdf0e10cSrcweir } 1663*cdf0e10cSrcweir else // Don't know what to remove 1664*cdf0e10cSrcweir { 1665*cdf0e10cSrcweir installError( CommandId, 1666*cdf0e10cSrcweir TASKHANDLING_FILETYPE_FOR_REMOVE ); 1667*cdf0e10cSrcweir return sal_False; 1668*cdf0e10cSrcweir } 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir return sal_True; 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir /********************************************************************************/ 1675*cdf0e10cSrcweir /* */ 1676*cdf0e10cSrcweir /* mkdir-implementation */ 1677*cdf0e10cSrcweir /* */ 1678*cdf0e10cSrcweir /********************************************************************************/ 1679*cdf0e10cSrcweir // 1680*cdf0e10cSrcweir // Creates new directory with given URL, recursively if necessary 1681*cdf0e10cSrcweir // Return:: success of operation 1682*cdf0e10cSrcweir // 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir sal_Bool SAL_CALL 1685*cdf0e10cSrcweir shell::mkdir( sal_Int32 CommandId, 1686*cdf0e10cSrcweir const rtl::OUString& rUnqPath, 1687*cdf0e10cSrcweir sal_Bool OverWrite ) 1688*cdf0e10cSrcweir throw() 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir rtl::OUString aUnqPath; 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir // remove trailing slash 1693*cdf0e10cSrcweir if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) ) 1694*cdf0e10cSrcweir aUnqPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 ); 1695*cdf0e10cSrcweir else 1696*cdf0e10cSrcweir aUnqPath = rUnqPath; 1697*cdf0e10cSrcweir 1698*cdf0e10cSrcweir osl::FileBase::RC nError = osl::Directory::create( aUnqPath ); 1699*cdf0e10cSrcweir 1700*cdf0e10cSrcweir switch ( nError ) 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir case osl::FileBase::E_EXIST: // Directory cannot be overwritten 1703*cdf0e10cSrcweir { 1704*cdf0e10cSrcweir if( !OverWrite ) 1705*cdf0e10cSrcweir { 1706*cdf0e10cSrcweir installError( CommandId, 1707*cdf0e10cSrcweir TASKHANDLING_FOLDER_EXISTS_MKDIR ); 1708*cdf0e10cSrcweir return sal_False; 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir else 1711*cdf0e10cSrcweir return sal_True; 1712*cdf0e10cSrcweir } 1713*cdf0e10cSrcweir case osl::FileBase::E_INVAL: 1714*cdf0e10cSrcweir { 1715*cdf0e10cSrcweir installError(CommandId, 1716*cdf0e10cSrcweir TASKHANDLING_INVALID_NAME_MKDIR); 1717*cdf0e10cSrcweir return sal_False; 1718*cdf0e10cSrcweir } 1719*cdf0e10cSrcweir case osl::FileBase::E_None: 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir rtl::OUString aPrtPath = getParentName( aUnqPath ); 1722*cdf0e10cSrcweir notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath ); 1723*cdf0e10cSrcweir return sal_True; 1724*cdf0e10cSrcweir } 1725*cdf0e10cSrcweir default: 1726*cdf0e10cSrcweir return ensuredir( 1727*cdf0e10cSrcweir CommandId, 1728*cdf0e10cSrcweir aUnqPath, 1729*cdf0e10cSrcweir TASKHANDLING_CREATEDIRECTORY_MKDIR ); 1730*cdf0e10cSrcweir } 1731*cdf0e10cSrcweir } 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir 1734*cdf0e10cSrcweir /********************************************************************************/ 1735*cdf0e10cSrcweir /* */ 1736*cdf0e10cSrcweir /* mkfil-implementation */ 1737*cdf0e10cSrcweir /* */ 1738*cdf0e10cSrcweir /********************************************************************************/ 1739*cdf0e10cSrcweir // 1740*cdf0e10cSrcweir // Creates new file with given URL. 1741*cdf0e10cSrcweir // The content of aInputStream becomes the content of the file 1742*cdf0e10cSrcweir // Return:: success of operation 1743*cdf0e10cSrcweir // 1744*cdf0e10cSrcweir 1745*cdf0e10cSrcweir sal_Bool SAL_CALL 1746*cdf0e10cSrcweir shell::mkfil( sal_Int32 CommandId, 1747*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 1748*cdf0e10cSrcweir sal_Bool Overwrite, 1749*cdf0e10cSrcweir const uno::Reference< io::XInputStream >& aInputStream ) 1750*cdf0e10cSrcweir throw() 1751*cdf0e10cSrcweir { 1752*cdf0e10cSrcweir // return value unimportant 1753*cdf0e10cSrcweir sal_Bool bSuccess = write( CommandId, 1754*cdf0e10cSrcweir aUnqPath, 1755*cdf0e10cSrcweir Overwrite, 1756*cdf0e10cSrcweir aInputStream ); 1757*cdf0e10cSrcweir if ( bSuccess ) 1758*cdf0e10cSrcweir { 1759*cdf0e10cSrcweir rtl::OUString aPrtPath = getParentName( aUnqPath ); 1760*cdf0e10cSrcweir notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath ); 1761*cdf0e10cSrcweir } 1762*cdf0e10cSrcweir return bSuccess; 1763*cdf0e10cSrcweir } 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir 1766*cdf0e10cSrcweir /********************************************************************************/ 1767*cdf0e10cSrcweir /* */ 1768*cdf0e10cSrcweir /* write-implementation */ 1769*cdf0e10cSrcweir /* */ 1770*cdf0e10cSrcweir /********************************************************************************/ 1771*cdf0e10cSrcweir // 1772*cdf0e10cSrcweir // writes to the file with given URL. 1773*cdf0e10cSrcweir // The content of aInputStream becomes the content of the file 1774*cdf0e10cSrcweir // Return:: success of operation 1775*cdf0e10cSrcweir // 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir sal_Bool SAL_CALL 1778*cdf0e10cSrcweir shell::write( sal_Int32 CommandId, 1779*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 1780*cdf0e10cSrcweir sal_Bool OverWrite, 1781*cdf0e10cSrcweir const uno::Reference< io::XInputStream >& aInputStream ) 1782*cdf0e10cSrcweir throw() 1783*cdf0e10cSrcweir { 1784*cdf0e10cSrcweir if( ! aInputStream.is() ) 1785*cdf0e10cSrcweir { 1786*cdf0e10cSrcweir installError( CommandId, 1787*cdf0e10cSrcweir TASKHANDLING_INPUTSTREAM_FOR_WRITE ); 1788*cdf0e10cSrcweir return sal_False; 1789*cdf0e10cSrcweir } 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir // Create parent path, if necessary. 1792*cdf0e10cSrcweir if ( ! ensuredir( CommandId, 1793*cdf0e10cSrcweir getParentName( aUnqPath ), 1794*cdf0e10cSrcweir TASKHANDLING_ENSUREDIR_FOR_WRITE ) ) 1795*cdf0e10cSrcweir return sal_False; 1796*cdf0e10cSrcweir 1797*cdf0e10cSrcweir osl::FileBase::RC err; 1798*cdf0e10cSrcweir osl::File aFile( aUnqPath ); 1799*cdf0e10cSrcweir 1800*cdf0e10cSrcweir if( OverWrite ) 1801*cdf0e10cSrcweir { 1802*cdf0e10cSrcweir err = aFile.open( OpenFlag_Write | OpenFlag_Create ); 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1805*cdf0e10cSrcweir { 1806*cdf0e10cSrcweir aFile.close(); 1807*cdf0e10cSrcweir err = aFile.open( OpenFlag_Write ); 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1810*cdf0e10cSrcweir { 1811*cdf0e10cSrcweir installError( CommandId, 1812*cdf0e10cSrcweir TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE, 1813*cdf0e10cSrcweir err ); 1814*cdf0e10cSrcweir return sal_False; 1815*cdf0e10cSrcweir } 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir // the existing file was just opened and should be overwritten now, 1818*cdf0e10cSrcweir // truncate it first 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir err = aFile.setSize( 0 ); 1821*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1822*cdf0e10cSrcweir { 1823*cdf0e10cSrcweir installError( CommandId, 1824*cdf0e10cSrcweir TASKHANDLING_FILESIZE_FOR_WRITE, 1825*cdf0e10cSrcweir err ); 1826*cdf0e10cSrcweir return sal_False; 1827*cdf0e10cSrcweir } 1828*cdf0e10cSrcweir } 1829*cdf0e10cSrcweir } 1830*cdf0e10cSrcweir else 1831*cdf0e10cSrcweir { 1832*cdf0e10cSrcweir err = aFile.open( OpenFlag_Read | OpenFlag_NoLock ); 1833*cdf0e10cSrcweir if( err == osl::FileBase::E_None ) // The file exists and shall not be overwritten 1834*cdf0e10cSrcweir { 1835*cdf0e10cSrcweir installError( CommandId, 1836*cdf0e10cSrcweir TASKHANDLING_NOREPLACE_FOR_WRITE, // Now an exception 1837*cdf0e10cSrcweir err ); 1838*cdf0e10cSrcweir 1839*cdf0e10cSrcweir aFile.close(); 1840*cdf0e10cSrcweir return sal_False; 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir // as a temporary solution the creation does not lock the file at all 1844*cdf0e10cSrcweir // in future it should be possible to create the file without lock explicitly 1845*cdf0e10cSrcweir err = aFile.open( OpenFlag_Write | OpenFlag_Create | OpenFlag_NoLock ); 1846*cdf0e10cSrcweir 1847*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1848*cdf0e10cSrcweir { 1849*cdf0e10cSrcweir aFile.close(); 1850*cdf0e10cSrcweir installError( CommandId, 1851*cdf0e10cSrcweir TASKHANDLING_NO_OPEN_FILE_FOR_WRITE, 1852*cdf0e10cSrcweir err ); 1853*cdf0e10cSrcweir return sal_False; 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir } 1856*cdf0e10cSrcweir 1857*cdf0e10cSrcweir sal_Bool bSuccess = sal_True; 1858*cdf0e10cSrcweir 1859*cdf0e10cSrcweir sal_uInt64 nWrittenBytes; 1860*cdf0e10cSrcweir sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/; 1861*cdf0e10cSrcweir uno::Sequence< sal_Int8 > seq( nRequestedBytes ); 1862*cdf0e10cSrcweir 1863*cdf0e10cSrcweir do 1864*cdf0e10cSrcweir { 1865*cdf0e10cSrcweir try 1866*cdf0e10cSrcweir { 1867*cdf0e10cSrcweir nReadBytes = aInputStream->readBytes( seq, 1868*cdf0e10cSrcweir nRequestedBytes ); 1869*cdf0e10cSrcweir } 1870*cdf0e10cSrcweir catch( const io::NotConnectedException& ) 1871*cdf0e10cSrcweir { 1872*cdf0e10cSrcweir installError( CommandId, 1873*cdf0e10cSrcweir TASKHANDLING_NOTCONNECTED_FOR_WRITE ); 1874*cdf0e10cSrcweir bSuccess = sal_False; 1875*cdf0e10cSrcweir break; 1876*cdf0e10cSrcweir } 1877*cdf0e10cSrcweir catch( const io::BufferSizeExceededException& ) 1878*cdf0e10cSrcweir { 1879*cdf0e10cSrcweir installError( CommandId, 1880*cdf0e10cSrcweir TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE ); 1881*cdf0e10cSrcweir bSuccess = sal_False; 1882*cdf0e10cSrcweir break; 1883*cdf0e10cSrcweir } 1884*cdf0e10cSrcweir catch( const io::IOException& ) 1885*cdf0e10cSrcweir { 1886*cdf0e10cSrcweir installError( CommandId, 1887*cdf0e10cSrcweir TASKHANDLING_IOEXCEPTION_FOR_WRITE ); 1888*cdf0e10cSrcweir bSuccess = sal_False; 1889*cdf0e10cSrcweir break; 1890*cdf0e10cSrcweir } 1891*cdf0e10cSrcweir 1892*cdf0e10cSrcweir if( nReadBytes ) 1893*cdf0e10cSrcweir { 1894*cdf0e10cSrcweir const sal_Int8* p = seq.getConstArray(); 1895*cdf0e10cSrcweir 1896*cdf0e10cSrcweir err = aFile.write( ((void*)(p)), 1897*cdf0e10cSrcweir sal_uInt64( nReadBytes ), 1898*cdf0e10cSrcweir nWrittenBytes ); 1899*cdf0e10cSrcweir 1900*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1901*cdf0e10cSrcweir { 1902*cdf0e10cSrcweir installError( CommandId, 1903*cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_WRITE, 1904*cdf0e10cSrcweir err ); 1905*cdf0e10cSrcweir bSuccess = sal_False; 1906*cdf0e10cSrcweir break; 1907*cdf0e10cSrcweir } 1908*cdf0e10cSrcweir else if( nWrittenBytes != sal_uInt64( nReadBytes ) ) 1909*cdf0e10cSrcweir { 1910*cdf0e10cSrcweir installError( CommandId, 1911*cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_NO_SPACE ); 1912*cdf0e10cSrcweir bSuccess = sal_False; 1913*cdf0e10cSrcweir break; 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir } 1916*cdf0e10cSrcweir } while( nReadBytes == nRequestedBytes ); 1917*cdf0e10cSrcweir 1918*cdf0e10cSrcweir err = aFile.close(); 1919*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 1920*cdf0e10cSrcweir { 1921*cdf0e10cSrcweir installError( CommandId, 1922*cdf0e10cSrcweir TASKHANDLING_FILEIOERROR_FOR_WRITE, 1923*cdf0e10cSrcweir err ); 1924*cdf0e10cSrcweir bSuccess = sal_False; 1925*cdf0e10cSrcweir } 1926*cdf0e10cSrcweir 1927*cdf0e10cSrcweir return bSuccess; 1928*cdf0e10cSrcweir } 1929*cdf0e10cSrcweir 1930*cdf0e10cSrcweir 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir /*********************************************************************************/ 1933*cdf0e10cSrcweir /* */ 1934*cdf0e10cSrcweir /* insertDefaultProperties-Implementation */ 1935*cdf0e10cSrcweir /* */ 1936*cdf0e10cSrcweir /*********************************************************************************/ 1937*cdf0e10cSrcweir 1938*cdf0e10cSrcweir 1939*cdf0e10cSrcweir void SAL_CALL shell::insertDefaultProperties( const rtl::OUString& aUnqPath ) 1940*cdf0e10cSrcweir { 1941*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 1942*cdf0e10cSrcweir 1943*cdf0e10cSrcweir ContentMap::iterator it = 1944*cdf0e10cSrcweir m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; 1945*cdf0e10cSrcweir 1946*cdf0e10cSrcweir load( it,false ); 1947*cdf0e10cSrcweir 1948*cdf0e10cSrcweir MyProperty ContentTProperty( ContentType ); 1949*cdf0e10cSrcweir 1950*cdf0e10cSrcweir PropertySet& properties = *(it->second.properties); 1951*cdf0e10cSrcweir sal_Bool ContentNotDefau = properties.find( ContentTProperty ) != properties.end(); 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir shell::PropertySet::iterator it1 = m_aDefaultProperties.begin(); 1954*cdf0e10cSrcweir while( it1 != m_aDefaultProperties.end() ) 1955*cdf0e10cSrcweir { 1956*cdf0e10cSrcweir if( ContentNotDefau && it1->getPropertyName() == ContentType ) 1957*cdf0e10cSrcweir { 1958*cdf0e10cSrcweir // No insertion 1959*cdf0e10cSrcweir } 1960*cdf0e10cSrcweir else 1961*cdf0e10cSrcweir properties.insert( *it1 ); 1962*cdf0e10cSrcweir ++it1; 1963*cdf0e10cSrcweir } 1964*cdf0e10cSrcweir } 1965*cdf0e10cSrcweir 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir 1968*cdf0e10cSrcweir 1969*cdf0e10cSrcweir /******************************************************************************/ 1970*cdf0e10cSrcweir /* */ 1971*cdf0e10cSrcweir /* mapping of file urls */ 1972*cdf0e10cSrcweir /* to uncpath and vice versa */ 1973*cdf0e10cSrcweir /* */ 1974*cdf0e10cSrcweir /******************************************************************************/ 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir 1977*cdf0e10cSrcweir sal_Bool SAL_CALL shell::getUnqFromUrl( const rtl::OUString& Url,rtl::OUString& Unq ) 1978*cdf0e10cSrcweir { 1979*cdf0e10cSrcweir if( 0 == Url.compareToAscii( "file:///" ) || 1980*cdf0e10cSrcweir 0 == Url.compareToAscii( "file://localhost/" ) || 1981*cdf0e10cSrcweir 0 == Url.compareToAscii( "file://127.0.0.1/" ) ) 1982*cdf0e10cSrcweir { 1983*cdf0e10cSrcweir Unq = rtl::OUString::createFromAscii( "file:///" ); 1984*cdf0e10cSrcweir return false; 1985*cdf0e10cSrcweir } 1986*cdf0e10cSrcweir 1987*cdf0e10cSrcweir sal_Bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Url,Unq ); 1988*cdf0e10cSrcweir 1989*cdf0e10cSrcweir Unq = Url; 1990*cdf0e10cSrcweir 1991*cdf0e10cSrcweir sal_Int32 l = Unq.getLength()-1; 1992*cdf0e10cSrcweir if( ! err && Unq.getStr()[ l ] == '/' && 1993*cdf0e10cSrcweir Unq.indexOf( '/', RTL_CONSTASCII_LENGTH("//") ) < l ) 1994*cdf0e10cSrcweir Unq = Unq.copy(0, Unq.getLength() - 1); 1995*cdf0e10cSrcweir 1996*cdf0e10cSrcweir return err; 1997*cdf0e10cSrcweir } 1998*cdf0e10cSrcweir 1999*cdf0e10cSrcweir 2000*cdf0e10cSrcweir 2001*cdf0e10cSrcweir sal_Bool SAL_CALL shell::getUrlFromUnq( const rtl::OUString& Unq,rtl::OUString& Url ) 2002*cdf0e10cSrcweir { 2003*cdf0e10cSrcweir sal_Bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Unq,Url ); 2004*cdf0e10cSrcweir 2005*cdf0e10cSrcweir Url = Unq; 2006*cdf0e10cSrcweir 2007*cdf0e10cSrcweir return err; 2008*cdf0e10cSrcweir } 2009*cdf0e10cSrcweir 2010*cdf0e10cSrcweir 2011*cdf0e10cSrcweir 2012*cdf0e10cSrcweir // Helper function for public copy 2013*cdf0e10cSrcweir 2014*cdf0e10cSrcweir osl::FileBase::RC SAL_CALL 2015*cdf0e10cSrcweir shell::copy_recursive( const rtl::OUString& srcUnqPath, 2016*cdf0e10cSrcweir const rtl::OUString& dstUnqPath, 2017*cdf0e10cSrcweir sal_Int32 TypeToCopy, 2018*cdf0e10cSrcweir sal_Bool testExistBeforeCopy ) 2019*cdf0e10cSrcweir throw() 2020*cdf0e10cSrcweir { 2021*cdf0e10cSrcweir osl::FileBase::RC err = osl::FileBase::E_None; 2022*cdf0e10cSrcweir 2023*cdf0e10cSrcweir if( TypeToCopy == -1 ) // Document 2024*cdf0e10cSrcweir { 2025*cdf0e10cSrcweir err = osl_File_copy( srcUnqPath,dstUnqPath,testExistBeforeCopy ); 2026*cdf0e10cSrcweir } 2027*cdf0e10cSrcweir else if( TypeToCopy == +1 ) // Folder 2028*cdf0e10cSrcweir { 2029*cdf0e10cSrcweir osl::Directory aDir( srcUnqPath ); 2030*cdf0e10cSrcweir aDir.open(); 2031*cdf0e10cSrcweir 2032*cdf0e10cSrcweir err = osl::Directory::create( dstUnqPath ); 2033*cdf0e10cSrcweir osl::FileBase::RC next = err; 2034*cdf0e10cSrcweir if( err == osl::FileBase::E_None ) 2035*cdf0e10cSrcweir { 2036*cdf0e10cSrcweir sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type; 2037*cdf0e10cSrcweir 2038*cdf0e10cSrcweir osl::DirectoryItem aDirItem; 2039*cdf0e10cSrcweir 2040*cdf0e10cSrcweir while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None ) 2041*cdf0e10cSrcweir { 2042*cdf0e10cSrcweir sal_Bool IsDoc = false; 2043*cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask ); 2044*cdf0e10cSrcweir aDirItem.getFileStatus( aFileStatus ); 2045*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Type ) ) 2046*cdf0e10cSrcweir IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular; 2047*cdf0e10cSrcweir 2048*cdf0e10cSrcweir // Getting the information for the next recursive copy 2049*cdf0e10cSrcweir sal_Int32 newTypeToCopy = IsDoc ? -1 : +1; 2050*cdf0e10cSrcweir 2051*cdf0e10cSrcweir rtl::OUString newSrcUnqPath; 2052*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileURL ) ) 2053*cdf0e10cSrcweir newSrcUnqPath = aFileStatus.getFileURL(); 2054*cdf0e10cSrcweir 2055*cdf0e10cSrcweir rtl::OUString newDstUnqPath = dstUnqPath; 2056*cdf0e10cSrcweir rtl::OUString tit; 2057*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileName ) ) 2058*cdf0e10cSrcweir tit = rtl::Uri::encode( aFileStatus.getFileName(), 2059*cdf0e10cSrcweir rtl_UriCharClassPchar, 2060*cdf0e10cSrcweir rtl_UriEncodeIgnoreEscapes, 2061*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ); 2062*cdf0e10cSrcweir 2063*cdf0e10cSrcweir if( newDstUnqPath.lastIndexOf( sal_Unicode('/') ) != newDstUnqPath.getLength()-1 ) 2064*cdf0e10cSrcweir newDstUnqPath += rtl::OUString::createFromAscii( "/" ); 2065*cdf0e10cSrcweir 2066*cdf0e10cSrcweir newDstUnqPath += tit; 2067*cdf0e10cSrcweir 2068*cdf0e10cSrcweir if ( newSrcUnqPath != dstUnqPath ) 2069*cdf0e10cSrcweir err = copy_recursive( newSrcUnqPath,newDstUnqPath,newTypeToCopy,false ); 2070*cdf0e10cSrcweir } 2071*cdf0e10cSrcweir 2072*cdf0e10cSrcweir if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT ) 2073*cdf0e10cSrcweir err = next; 2074*cdf0e10cSrcweir } 2075*cdf0e10cSrcweir aDir.close(); 2076*cdf0e10cSrcweir } 2077*cdf0e10cSrcweir 2078*cdf0e10cSrcweir return err; 2079*cdf0e10cSrcweir } 2080*cdf0e10cSrcweir 2081*cdf0e10cSrcweir 2082*cdf0e10cSrcweir 2083*cdf0e10cSrcweir // Helper function for mkfil,mkdir and write 2084*cdf0e10cSrcweir // Creates whole path 2085*cdf0e10cSrcweir // returns success of the operation 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir 2088*cdf0e10cSrcweir sal_Bool SAL_CALL shell::ensuredir( sal_Int32 CommandId, 2089*cdf0e10cSrcweir const rtl::OUString& rUnqPath, 2090*cdf0e10cSrcweir sal_Int32 errorCode ) 2091*cdf0e10cSrcweir throw() 2092*cdf0e10cSrcweir { 2093*cdf0e10cSrcweir rtl::OUString aPath; 2094*cdf0e10cSrcweir 2095*cdf0e10cSrcweir if ( rUnqPath.getLength() < 1 ) 2096*cdf0e10cSrcweir return sal_False; 2097*cdf0e10cSrcweir 2098*cdf0e10cSrcweir if ( rUnqPath[ rUnqPath.getLength() - 1 ] == sal_Unicode( '/' ) ) 2099*cdf0e10cSrcweir aPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 ); 2100*cdf0e10cSrcweir else 2101*cdf0e10cSrcweir aPath = rUnqPath; 2102*cdf0e10cSrcweir 2103*cdf0e10cSrcweir 2104*cdf0e10cSrcweir // HACK: create directory on a mount point with nobrowse option 2105*cdf0e10cSrcweir // returns ENOSYS in any case !! 2106*cdf0e10cSrcweir osl::Directory aDirectory( aPath ); 2107*cdf0e10cSrcweir osl::FileBase::RC nError = aDirectory.open(); 2108*cdf0e10cSrcweir aDirectory.close(); 2109*cdf0e10cSrcweir 2110*cdf0e10cSrcweir if( nError == osl::File::E_None ) 2111*cdf0e10cSrcweir return sal_True; 2112*cdf0e10cSrcweir 2113*cdf0e10cSrcweir nError = osl::Directory::create( aPath ); 2114*cdf0e10cSrcweir 2115*cdf0e10cSrcweir if( nError == osl::File::E_None ) 2116*cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath ); 2117*cdf0e10cSrcweir 2118*cdf0e10cSrcweir sal_Bool bSuccess = ( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); 2119*cdf0e10cSrcweir 2120*cdf0e10cSrcweir if( ! bSuccess ) 2121*cdf0e10cSrcweir { 2122*cdf0e10cSrcweir rtl::OUString aParentDir = getParentName( aPath ); 2123*cdf0e10cSrcweir 2124*cdf0e10cSrcweir if ( aParentDir != aPath ) 2125*cdf0e10cSrcweir { // Create first the parent directory 2126*cdf0e10cSrcweir bSuccess = ensuredir( CommandId, 2127*cdf0e10cSrcweir getParentName( aPath ), 2128*cdf0e10cSrcweir errorCode ); 2129*cdf0e10cSrcweir 2130*cdf0e10cSrcweir // After parent directory structure exists try it one's more 2131*cdf0e10cSrcweir 2132*cdf0e10cSrcweir if ( bSuccess ) 2133*cdf0e10cSrcweir { // Parent directory exists, retry creation of directory 2134*cdf0e10cSrcweir nError = osl::Directory::create( aPath ); 2135*cdf0e10cSrcweir 2136*cdf0e10cSrcweir if( nError == osl::File::E_None ) 2137*cdf0e10cSrcweir notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath ); 2138*cdf0e10cSrcweir 2139*cdf0e10cSrcweir bSuccess =( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); 2140*cdf0e10cSrcweir } 2141*cdf0e10cSrcweir } 2142*cdf0e10cSrcweir } 2143*cdf0e10cSrcweir 2144*cdf0e10cSrcweir if( ! bSuccess ) 2145*cdf0e10cSrcweir installError( CommandId, 2146*cdf0e10cSrcweir errorCode, 2147*cdf0e10cSrcweir nError ); 2148*cdf0e10cSrcweir 2149*cdf0e10cSrcweir return bSuccess; 2150*cdf0e10cSrcweir } 2151*cdf0e10cSrcweir 2152*cdf0e10cSrcweir 2153*cdf0e10cSrcweir 2154*cdf0e10cSrcweir 2155*cdf0e10cSrcweir // 2156*cdf0e10cSrcweir // Given a sequence of properties seq, this method determines the mask 2157*cdf0e10cSrcweir // used to instantiate a osl::FileStatus, so that a call to 2158*cdf0e10cSrcweir // osl::DirectoryItem::getFileStatus fills the required fields. 2159*cdf0e10cSrcweir // 2160*cdf0e10cSrcweir 2161*cdf0e10cSrcweir 2162*cdf0e10cSrcweir void SAL_CALL 2163*cdf0e10cSrcweir shell::getMaskFromProperties( 2164*cdf0e10cSrcweir sal_Int32& n_Mask, 2165*cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq ) 2166*cdf0e10cSrcweir { 2167*cdf0e10cSrcweir n_Mask = 0; 2168*cdf0e10cSrcweir for(sal_Int32 j = 0; j < seq.getLength(); ++j) { 2169*cdf0e10cSrcweir if(seq[j].Name == Title) 2170*cdf0e10cSrcweir n_Mask |= FileStatusMask_FileName; 2171*cdf0e10cSrcweir else if(seq[j].Name == CasePreservingURL) 2172*cdf0e10cSrcweir n_Mask |= FileStatusMask_FileURL; 2173*cdf0e10cSrcweir else if(seq[j].Name == IsDocument || 2174*cdf0e10cSrcweir seq[j].Name == IsFolder || 2175*cdf0e10cSrcweir seq[j].Name == IsVolume || 2176*cdf0e10cSrcweir seq[j].Name == IsRemoveable || 2177*cdf0e10cSrcweir seq[j].Name == IsRemote || 2178*cdf0e10cSrcweir seq[j].Name == IsCompactDisc || 2179*cdf0e10cSrcweir seq[j].Name == IsFloppy || 2180*cdf0e10cSrcweir seq[j].Name == ContentType) 2181*cdf0e10cSrcweir n_Mask |= (FileStatusMask_Type | FileStatusMask_LinkTargetURL); 2182*cdf0e10cSrcweir else if(seq[j].Name == Size) 2183*cdf0e10cSrcweir n_Mask |= (FileStatusMask_FileSize | 2184*cdf0e10cSrcweir FileStatusMask_Type | 2185*cdf0e10cSrcweir FileStatusMask_LinkTargetURL); 2186*cdf0e10cSrcweir else if(seq[j].Name == IsHidden || 2187*cdf0e10cSrcweir seq[j].Name == IsReadOnly) 2188*cdf0e10cSrcweir n_Mask |= FileStatusMask_Attributes; 2189*cdf0e10cSrcweir else if(seq[j].Name == DateModified) 2190*cdf0e10cSrcweir n_Mask |= FileStatusMask_ModifyTime; 2191*cdf0e10cSrcweir // n_Mask = FileStatusMask_FileURL; 2192*cdf0e10cSrcweir // n_Mask |= FileStatusMask_LinkTargetURL; 2193*cdf0e10cSrcweir // n_Mask |= FileStatusMask_FileName; 2194*cdf0e10cSrcweir // n_Mask |= FileStatusMask_Type; 2195*cdf0e10cSrcweir // n_Mask |= FileStatusMask_ModifyTime; 2196*cdf0e10cSrcweir // n_Mask |= FileStatusMask_FileSize; 2197*cdf0e10cSrcweir // n_Mask |= FileStatusMask_Attributes; 2198*cdf0e10cSrcweir } 2199*cdf0e10cSrcweir } 2200*cdf0e10cSrcweir 2201*cdf0e10cSrcweir 2202*cdf0e10cSrcweir 2203*cdf0e10cSrcweir /*********************************************************************************/ 2204*cdf0e10cSrcweir /* */ 2205*cdf0e10cSrcweir /* load-Implementation */ 2206*cdf0e10cSrcweir /* */ 2207*cdf0e10cSrcweir /*********************************************************************************/ 2208*cdf0e10cSrcweir // 2209*cdf0e10cSrcweir // Load the properties from configuration, if create == true create them. 2210*cdf0e10cSrcweir // The Properties are stored under the url belonging to it->first. 2211*cdf0e10cSrcweir // 2212*cdf0e10cSrcweir 2213*cdf0e10cSrcweir void SAL_CALL 2214*cdf0e10cSrcweir shell::load( const ContentMap::iterator& it, sal_Bool create ) 2215*cdf0e10cSrcweir { 2216*cdf0e10cSrcweir if( ! it->second.properties ) 2217*cdf0e10cSrcweir it->second.properties = new PropertySet; 2218*cdf0e10cSrcweir 2219*cdf0e10cSrcweir if( ( ! it->second.xS.is() || 2220*cdf0e10cSrcweir ! it->second.xC.is() || 2221*cdf0e10cSrcweir ! it->second.xA.is() ) 2222*cdf0e10cSrcweir && m_xFileRegistry.is() ) 2223*cdf0e10cSrcweir { 2224*cdf0e10cSrcweir 2225*cdf0e10cSrcweir uno::Reference< ucb::XPersistentPropertySet > xS = m_xFileRegistry->openPropertySet( it->first,create ); 2226*cdf0e10cSrcweir if( xS.is() ) 2227*cdf0e10cSrcweir { 2228*cdf0e10cSrcweir uno::Reference< beans::XPropertyContainer > xC( xS,uno::UNO_QUERY ); 2229*cdf0e10cSrcweir uno::Reference< beans::XPropertyAccess > xA( xS,uno::UNO_QUERY ); 2230*cdf0e10cSrcweir 2231*cdf0e10cSrcweir it->second.xS = xS; 2232*cdf0e10cSrcweir it->second.xC = xC; 2233*cdf0e10cSrcweir it->second.xA = xA; 2234*cdf0e10cSrcweir 2235*cdf0e10cSrcweir // Now put in all values in the storage in the local hash; 2236*cdf0e10cSrcweir 2237*cdf0e10cSrcweir PropertySet& properties = *(it->second.properties); 2238*cdf0e10cSrcweir uno::Sequence< beans::Property > seq = xS->getPropertySetInfo()->getProperties(); 2239*cdf0e10cSrcweir 2240*cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i ) 2241*cdf0e10cSrcweir { 2242*cdf0e10cSrcweir MyProperty readProp( false, 2243*cdf0e10cSrcweir seq[i].Name, 2244*cdf0e10cSrcweir seq[i].Handle, 2245*cdf0e10cSrcweir seq[i].Type, 2246*cdf0e10cSrcweir xS->getPropertyValue( seq[i].Name ), 2247*cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE, 2248*cdf0e10cSrcweir seq[i].Attributes ); 2249*cdf0e10cSrcweir if( properties.find( readProp ) == properties.end() ) 2250*cdf0e10cSrcweir properties.insert( readProp ); 2251*cdf0e10cSrcweir } 2252*cdf0e10cSrcweir } 2253*cdf0e10cSrcweir else if( create ) 2254*cdf0e10cSrcweir { 2255*cdf0e10cSrcweir // Catastrophic error 2256*cdf0e10cSrcweir } 2257*cdf0e10cSrcweir } 2258*cdf0e10cSrcweir } 2259*cdf0e10cSrcweir 2260*cdf0e10cSrcweir 2261*cdf0e10cSrcweir 2262*cdf0e10cSrcweir 2263*cdf0e10cSrcweir /*********************************************************************************/ 2264*cdf0e10cSrcweir /* */ 2265*cdf0e10cSrcweir /* commit-Implementation */ 2266*cdf0e10cSrcweir /* */ 2267*cdf0e10cSrcweir /*********************************************************************************/ 2268*cdf0e10cSrcweir // Commit inserts the determined properties in the filestatus object into 2269*cdf0e10cSrcweir // the internal map, so that is possible to determine on a subsequent 2270*cdf0e10cSrcweir // setting of file properties which properties have changed without filestat 2271*cdf0e10cSrcweir 2272*cdf0e10cSrcweir 2273*cdf0e10cSrcweir void SAL_CALL 2274*cdf0e10cSrcweir shell::commit( const shell::ContentMap::iterator& it, 2275*cdf0e10cSrcweir const osl::FileStatus& aFileStatus ) 2276*cdf0e10cSrcweir { 2277*cdf0e10cSrcweir uno::Any aAny; 2278*cdf0e10cSrcweir uno::Any emptyAny; 2279*cdf0e10cSrcweir shell::PropertySet::iterator it1; 2280*cdf0e10cSrcweir 2281*cdf0e10cSrcweir if( it->second.properties == 0 ) 2282*cdf0e10cSrcweir { 2283*cdf0e10cSrcweir rtl::OUString aPath = it->first; 2284*cdf0e10cSrcweir insertDefaultProperties( aPath ); 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir 2287*cdf0e10cSrcweir PropertySet& properties = *( it->second.properties ); 2288*cdf0e10cSrcweir 2289*cdf0e10cSrcweir it1 = properties.find( MyProperty( Title ) ); 2290*cdf0e10cSrcweir if( it1 != properties.end() ) 2291*cdf0e10cSrcweir { 2292*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileName ) ) 2293*cdf0e10cSrcweir { 2294*cdf0e10cSrcweir aAny <<= aFileStatus.getFileName(); 2295*cdf0e10cSrcweir it1->setValue( aAny ); 2296*cdf0e10cSrcweir } 2297*cdf0e10cSrcweir } 2298*cdf0e10cSrcweir 2299*cdf0e10cSrcweir it1 = properties.find( MyProperty( CasePreservingURL ) ); 2300*cdf0e10cSrcweir if( it1 != properties.end() ) 2301*cdf0e10cSrcweir { 2302*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileURL ) ) 2303*cdf0e10cSrcweir { 2304*cdf0e10cSrcweir aAny <<= aFileStatus.getFileURL(); 2305*cdf0e10cSrcweir it1->setValue( aAny ); 2306*cdf0e10cSrcweir } 2307*cdf0e10cSrcweir } 2308*cdf0e10cSrcweir 2309*cdf0e10cSrcweir 2310*cdf0e10cSrcweir sal_Bool isDirectory,isFile,isVolume,isRemoveable,isRemote,isFloppy,isCompactDisc; 2311*cdf0e10cSrcweir 2312*cdf0e10cSrcweir sal_Int64 dirSize = 0; 2313*cdf0e10cSrcweir 2314*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_FileSize ) ) 2315*cdf0e10cSrcweir dirSize = aFileStatus.getFileSize(); 2316*cdf0e10cSrcweir 2317*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Type ) ) 2318*cdf0e10cSrcweir { 2319*cdf0e10cSrcweir if( osl::FileStatus::Link == aFileStatus.getFileType() && 2320*cdf0e10cSrcweir aFileStatus.isValid( FileStatusMask_LinkTargetURL ) ) 2321*cdf0e10cSrcweir { 2322*cdf0e10cSrcweir osl::DirectoryItem aDirItem; 2323*cdf0e10cSrcweir osl::FileStatus aFileStatus2( FileStatusMask_Type ); 2324*cdf0e10cSrcweir if( osl::FileBase::E_None == osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(),aDirItem ) && 2325*cdf0e10cSrcweir osl::FileBase::E_None == aDirItem.getFileStatus( aFileStatus2 ) && 2326*cdf0e10cSrcweir aFileStatus2.isValid( FileStatusMask_Type ) ) 2327*cdf0e10cSrcweir { 2328*cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus2.getFileType(); 2329*cdf0e10cSrcweir isDirectory = 2330*cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus2.getFileType() || 2331*cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus2.getFileType(); 2332*cdf0e10cSrcweir isFile = 2333*cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus2.getFileType(); 2334*cdf0e10cSrcweir 2335*cdf0e10cSrcweir if( aFileStatus2.isValid( FileStatusMask_FileSize ) ) 2336*cdf0e10cSrcweir dirSize = aFileStatus2.getFileSize(); 2337*cdf0e10cSrcweir } 2338*cdf0e10cSrcweir else 2339*cdf0e10cSrcweir { 2340*cdf0e10cSrcweir // extremly ugly, but otherwise default construction 2341*cdf0e10cSrcweir // of aDirItem and aFileStatus2 2342*cdf0e10cSrcweir // before the preciding if 2343*cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus.getFileType(); 2344*cdf0e10cSrcweir isDirectory = 2345*cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus.getFileType() || 2346*cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus.getFileType(); 2347*cdf0e10cSrcweir isFile = 2348*cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus.getFileType(); 2349*cdf0e10cSrcweir } 2350*cdf0e10cSrcweir } 2351*cdf0e10cSrcweir else 2352*cdf0e10cSrcweir { 2353*cdf0e10cSrcweir isVolume = osl::FileStatus::Volume == aFileStatus.getFileType(); 2354*cdf0e10cSrcweir isDirectory = 2355*cdf0e10cSrcweir osl::FileStatus::Volume == aFileStatus.getFileType() || 2356*cdf0e10cSrcweir osl::FileStatus::Directory == aFileStatus.getFileType(); 2357*cdf0e10cSrcweir isFile = 2358*cdf0e10cSrcweir osl::FileStatus::Regular == aFileStatus.getFileType(); 2359*cdf0e10cSrcweir } 2360*cdf0e10cSrcweir 2361*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsVolume ) ); 2362*cdf0e10cSrcweir if( it1 != properties.end() ) 2363*cdf0e10cSrcweir it1->setValue( uno::makeAny( isVolume ) ); 2364*cdf0e10cSrcweir 2365*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFolder ) ); 2366*cdf0e10cSrcweir if( it1 != properties.end() ) 2367*cdf0e10cSrcweir it1->setValue( uno::makeAny( isDirectory ) ); 2368*cdf0e10cSrcweir 2369*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsDocument ) ); 2370*cdf0e10cSrcweir if( it1 != properties.end() ) 2371*cdf0e10cSrcweir it1->setValue( uno::makeAny( isFile ) ); 2372*cdf0e10cSrcweir 2373*cdf0e10cSrcweir osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); 2374*cdf0e10cSrcweir if( isVolume && 2375*cdf0e10cSrcweir osl::FileBase::E_None == osl::Directory::getVolumeInfo( it->first,aVolumeInfo ) && 2376*cdf0e10cSrcweir aVolumeInfo.isValid( VolumeInfoMask_Attributes ) ) 2377*cdf0e10cSrcweir { 2378*cdf0e10cSrcweir // Retrieve the flags; 2379*cdf0e10cSrcweir isRemote = aVolumeInfo.getRemoteFlag(); 2380*cdf0e10cSrcweir isRemoveable = aVolumeInfo.getRemoveableFlag(); 2381*cdf0e10cSrcweir isCompactDisc = aVolumeInfo.getCompactDiscFlag(); 2382*cdf0e10cSrcweir isFloppy = aVolumeInfo.getFloppyDiskFlag(); 2383*cdf0e10cSrcweir 2384*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemote ) ); 2385*cdf0e10cSrcweir if( it1 != properties.end() ) 2386*cdf0e10cSrcweir it1->setValue( uno::makeAny( isRemote ) ); 2387*cdf0e10cSrcweir 2388*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemoveable ) ); 2389*cdf0e10cSrcweir if( it1 != properties.end() ) 2390*cdf0e10cSrcweir it1->setValue( uno::makeAny( isRemoveable ) ); 2391*cdf0e10cSrcweir 2392*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsCompactDisc ) ); 2393*cdf0e10cSrcweir if( it1 != properties.end() ) 2394*cdf0e10cSrcweir it1->setValue( uno::makeAny( isCompactDisc ) ); 2395*cdf0e10cSrcweir 2396*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFloppy ) ); 2397*cdf0e10cSrcweir if( it1 != properties.end() ) 2398*cdf0e10cSrcweir it1->setValue( uno::makeAny( isFloppy ) ); 2399*cdf0e10cSrcweir } 2400*cdf0e10cSrcweir else 2401*cdf0e10cSrcweir { 2402*cdf0e10cSrcweir sal_Bool dummy = false; 2403*cdf0e10cSrcweir aAny <<= dummy; 2404*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemote ) ); 2405*cdf0e10cSrcweir if( it1 != properties.end() ) 2406*cdf0e10cSrcweir it1->setValue( aAny ); 2407*cdf0e10cSrcweir 2408*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsRemoveable ) ); 2409*cdf0e10cSrcweir if( it1 != properties.end() ) 2410*cdf0e10cSrcweir it1->setValue( aAny ); 2411*cdf0e10cSrcweir 2412*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsCompactDisc ) ); 2413*cdf0e10cSrcweir if( it1 != properties.end() ) 2414*cdf0e10cSrcweir it1->setValue( aAny ); 2415*cdf0e10cSrcweir 2416*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsFloppy ) ); 2417*cdf0e10cSrcweir if( it1 != properties.end() ) 2418*cdf0e10cSrcweir it1->setValue( aAny ); 2419*cdf0e10cSrcweir } 2420*cdf0e10cSrcweir } 2421*cdf0e10cSrcweir else 2422*cdf0e10cSrcweir { 2423*cdf0e10cSrcweir isDirectory = sal_False; 2424*cdf0e10cSrcweir } 2425*cdf0e10cSrcweir 2426*cdf0e10cSrcweir it1 = properties.find( MyProperty( Size ) ); 2427*cdf0e10cSrcweir if( it1 != properties.end() ) 2428*cdf0e10cSrcweir it1->setValue( uno::makeAny( dirSize ) ); 2429*cdf0e10cSrcweir 2430*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsReadOnly ) ); 2431*cdf0e10cSrcweir if( it1 != properties.end() ) 2432*cdf0e10cSrcweir { 2433*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Attributes ) ) 2434*cdf0e10cSrcweir { 2435*cdf0e10cSrcweir sal_uInt64 Attr = aFileStatus.getAttributes(); 2436*cdf0e10cSrcweir sal_Bool readonly = ( Attr & Attribute_ReadOnly ) != 0; 2437*cdf0e10cSrcweir it1->setValue( uno::makeAny( readonly ) ); 2438*cdf0e10cSrcweir } 2439*cdf0e10cSrcweir } 2440*cdf0e10cSrcweir 2441*cdf0e10cSrcweir it1 = properties.find( MyProperty( IsHidden ) ); 2442*cdf0e10cSrcweir if( it1 != properties.end() ) 2443*cdf0e10cSrcweir { 2444*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_Attributes ) ) 2445*cdf0e10cSrcweir { 2446*cdf0e10cSrcweir sal_uInt64 Attr = aFileStatus.getAttributes(); 2447*cdf0e10cSrcweir sal_Bool ishidden = ( Attr & Attribute_Hidden ) != 0; 2448*cdf0e10cSrcweir it1->setValue( uno::makeAny( ishidden ) ); 2449*cdf0e10cSrcweir } 2450*cdf0e10cSrcweir } 2451*cdf0e10cSrcweir 2452*cdf0e10cSrcweir it1 = properties.find( MyProperty( DateModified ) ); 2453*cdf0e10cSrcweir if( it1 != properties.end() ) 2454*cdf0e10cSrcweir { 2455*cdf0e10cSrcweir if( aFileStatus.isValid( FileStatusMask_ModifyTime ) ) 2456*cdf0e10cSrcweir { 2457*cdf0e10cSrcweir TimeValue temp = aFileStatus.getModifyTime(); 2458*cdf0e10cSrcweir 2459*cdf0e10cSrcweir // Convert system time to local time (for EA) 2460*cdf0e10cSrcweir TimeValue myLocalTime; 2461*cdf0e10cSrcweir osl_getLocalTimeFromSystemTime( &temp, &myLocalTime ); 2462*cdf0e10cSrcweir 2463*cdf0e10cSrcweir oslDateTime myDateTime; 2464*cdf0e10cSrcweir osl_getDateTimeFromTimeValue( &myLocalTime, &myDateTime ); 2465*cdf0e10cSrcweir util::DateTime aDateTime; 2466*cdf0e10cSrcweir 2467*cdf0e10cSrcweir aDateTime.HundredthSeconds = (unsigned short)(myDateTime.NanoSeconds / 10000000); 2468*cdf0e10cSrcweir aDateTime.Seconds = myDateTime.Seconds; 2469*cdf0e10cSrcweir aDateTime.Minutes = myDateTime.Minutes; 2470*cdf0e10cSrcweir aDateTime.Hours = myDateTime.Hours; 2471*cdf0e10cSrcweir aDateTime.Day = myDateTime.Day; 2472*cdf0e10cSrcweir aDateTime.Month = myDateTime.Month; 2473*cdf0e10cSrcweir aDateTime.Year = myDateTime.Year; 2474*cdf0e10cSrcweir it1->setValue( uno::makeAny( aDateTime ) ); 2475*cdf0e10cSrcweir } 2476*cdf0e10cSrcweir } 2477*cdf0e10cSrcweir 2478*cdf0e10cSrcweir it1 = properties.find( MyProperty( CreatableContentsInfo ) ); 2479*cdf0e10cSrcweir if( it1 != properties.end() ) 2480*cdf0e10cSrcweir it1->setValue( uno::makeAny( 2481*cdf0e10cSrcweir isDirectory || !aFileStatus.isValid( FileStatusMask_Type ) 2482*cdf0e10cSrcweir ? queryCreatableContentsInfo() 2483*cdf0e10cSrcweir : uno::Sequence< ucb::ContentInfo >() ) ); 2484*cdf0e10cSrcweir } 2485*cdf0e10cSrcweir 2486*cdf0e10cSrcweir 2487*cdf0e10cSrcweir // Special optimized method for getting the properties of a 2488*cdf0e10cSrcweir // directoryitem, which is returned by osl::DirectoryItem::getNextItem() 2489*cdf0e10cSrcweir 2490*cdf0e10cSrcweir 2491*cdf0e10cSrcweir uno::Reference< sdbc::XRow > SAL_CALL 2492*cdf0e10cSrcweir shell::getv( 2493*cdf0e10cSrcweir Notifier* pNotifier, 2494*cdf0e10cSrcweir const uno::Sequence< beans::Property >& properties, 2495*cdf0e10cSrcweir osl::DirectoryItem& aDirItem, 2496*cdf0e10cSrcweir rtl::OUString& aUnqPath, 2497*cdf0e10cSrcweir sal_Bool& aIsRegular ) 2498*cdf0e10cSrcweir { 2499*cdf0e10cSrcweir uno::Sequence< uno::Any > seq( properties.getLength() ); 2500*cdf0e10cSrcweir 2501*cdf0e10cSrcweir sal_Int32 n_Mask; 2502*cdf0e10cSrcweir getMaskFromProperties( n_Mask,properties ); 2503*cdf0e10cSrcweir 2504*cdf0e10cSrcweir // Always retrieve the type and the target URL because item might be a link 2505*cdf0e10cSrcweir osl::FileStatus aFileStatus( n_Mask | 2506*cdf0e10cSrcweir FileStatusMask_FileURL | 2507*cdf0e10cSrcweir FileStatusMask_Type | 2508*cdf0e10cSrcweir FileStatusMask_LinkTargetURL ); 2509*cdf0e10cSrcweir aDirItem.getFileStatus( aFileStatus ); 2510*cdf0e10cSrcweir aUnqPath = aFileStatus.getFileURL(); 2511*cdf0e10cSrcweir 2512*cdf0e10cSrcweir // If the directory item type is a link retrieve the type of the target 2513*cdf0e10cSrcweir 2514*cdf0e10cSrcweir if ( aFileStatus.getFileType() == osl::FileStatus::Link ) 2515*cdf0e10cSrcweir { 2516*cdf0e10cSrcweir // Assume failure 2517*cdf0e10cSrcweir aIsRegular = false; 2518*cdf0e10cSrcweir osl::FileBase::RC result = osl::FileBase::E_INVAL; 2519*cdf0e10cSrcweir osl::DirectoryItem aTargetItem; 2520*cdf0e10cSrcweir osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(), aTargetItem ); 2521*cdf0e10cSrcweir if ( aTargetItem.is() ) 2522*cdf0e10cSrcweir { 2523*cdf0e10cSrcweir osl::FileStatus aTargetStatus( FileStatusMask_Type ); 2524*cdf0e10cSrcweir 2525*cdf0e10cSrcweir if ( osl::FileBase::E_None == 2526*cdf0e10cSrcweir ( result = aTargetItem.getFileStatus( aTargetStatus ) ) ) 2527*cdf0e10cSrcweir aIsRegular = 2528*cdf0e10cSrcweir aTargetStatus.getFileType() == osl::FileStatus::Regular; 2529*cdf0e10cSrcweir } 2530*cdf0e10cSrcweir } 2531*cdf0e10cSrcweir else 2532*cdf0e10cSrcweir aIsRegular = aFileStatus.getFileType() == osl::FileStatus::Regular; 2533*cdf0e10cSrcweir 2534*cdf0e10cSrcweir registerNotifier( aUnqPath,pNotifier ); 2535*cdf0e10cSrcweir insertDefaultProperties( aUnqPath ); 2536*cdf0e10cSrcweir { 2537*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2538*cdf0e10cSrcweir 2539*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aUnqPath ); 2540*cdf0e10cSrcweir commit( it,aFileStatus ); 2541*cdf0e10cSrcweir 2542*cdf0e10cSrcweir shell::PropertySet::iterator it1; 2543*cdf0e10cSrcweir PropertySet& propset = *(it->second.properties); 2544*cdf0e10cSrcweir 2545*cdf0e10cSrcweir for( sal_Int32 i = 0; i < seq.getLength(); ++i ) 2546*cdf0e10cSrcweir { 2547*cdf0e10cSrcweir MyProperty readProp( properties[i].Name ); 2548*cdf0e10cSrcweir it1 = propset.find( readProp ); 2549*cdf0e10cSrcweir if( it1 == propset.end() ) 2550*cdf0e10cSrcweir seq[i] = uno::Any(); 2551*cdf0e10cSrcweir else 2552*cdf0e10cSrcweir seq[i] = it1->getValue(); 2553*cdf0e10cSrcweir } 2554*cdf0e10cSrcweir } 2555*cdf0e10cSrcweir deregisterNotifier( aUnqPath,pNotifier ); 2556*cdf0e10cSrcweir 2557*cdf0e10cSrcweir XRow_impl* p = new XRow_impl( this,seq ); 2558*cdf0e10cSrcweir return uno::Reference< sdbc::XRow >( p ); 2559*cdf0e10cSrcweir } 2560*cdf0e10cSrcweir 2561*cdf0e10cSrcweir 2562*cdf0e10cSrcweir 2563*cdf0e10cSrcweir 2564*cdf0e10cSrcweir 2565*cdf0e10cSrcweir 2566*cdf0e10cSrcweir // EventListener 2567*cdf0e10cSrcweir 2568*cdf0e10cSrcweir 2569*cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL 2570*cdf0e10cSrcweir shell::getContentEventListeners( const rtl::OUString& aName ) 2571*cdf0e10cSrcweir { 2572*cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >; 2573*cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p; 2574*cdf0e10cSrcweir { 2575*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2576*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName ); 2577*cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier ) 2578*cdf0e10cSrcweir { 2579*cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier ); 2580*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin(); 2581*cdf0e10cSrcweir while( it1 != listOfNotifiers.end() ) 2582*cdf0e10cSrcweir { 2583*cdf0e10cSrcweir Notifier* pointer = *it1; 2584*cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cCEL(); 2585*cdf0e10cSrcweir if( notifier ) 2586*cdf0e10cSrcweir listeners.push_back( notifier ); 2587*cdf0e10cSrcweir ++it1; 2588*cdf0e10cSrcweir } 2589*cdf0e10cSrcweir } 2590*cdf0e10cSrcweir } 2591*cdf0e10cSrcweir return p; 2592*cdf0e10cSrcweir } 2593*cdf0e10cSrcweir 2594*cdf0e10cSrcweir 2595*cdf0e10cSrcweir 2596*cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL 2597*cdf0e10cSrcweir shell::getContentDeletedEventListeners( const rtl::OUString& aName ) 2598*cdf0e10cSrcweir { 2599*cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >; 2600*cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p; 2601*cdf0e10cSrcweir { 2602*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2603*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName ); 2604*cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier ) 2605*cdf0e10cSrcweir { 2606*cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier ); 2607*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin(); 2608*cdf0e10cSrcweir while( it1 != listOfNotifiers.end() ) 2609*cdf0e10cSrcweir { 2610*cdf0e10cSrcweir Notifier* pointer = *it1; 2611*cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cDEL(); 2612*cdf0e10cSrcweir if( notifier ) 2613*cdf0e10cSrcweir listeners.push_back( notifier ); 2614*cdf0e10cSrcweir ++it1; 2615*cdf0e10cSrcweir } 2616*cdf0e10cSrcweir } 2617*cdf0e10cSrcweir } 2618*cdf0e10cSrcweir return p; 2619*cdf0e10cSrcweir } 2620*cdf0e10cSrcweir 2621*cdf0e10cSrcweir 2622*cdf0e10cSrcweir void SAL_CALL 2623*cdf0e10cSrcweir shell::notifyInsert( std::list< ContentEventNotifier* >* listeners,const rtl::OUString& aChildName ) 2624*cdf0e10cSrcweir { 2625*cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin(); 2626*cdf0e10cSrcweir while( it != listeners->end() ) 2627*cdf0e10cSrcweir { 2628*cdf0e10cSrcweir (*it)->notifyChildInserted( aChildName ); 2629*cdf0e10cSrcweir delete (*it); 2630*cdf0e10cSrcweir ++it; 2631*cdf0e10cSrcweir } 2632*cdf0e10cSrcweir delete listeners; 2633*cdf0e10cSrcweir } 2634*cdf0e10cSrcweir 2635*cdf0e10cSrcweir 2636*cdf0e10cSrcweir void SAL_CALL 2637*cdf0e10cSrcweir shell::notifyContentDeleted( std::list< ContentEventNotifier* >* listeners ) 2638*cdf0e10cSrcweir { 2639*cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin(); 2640*cdf0e10cSrcweir while( it != listeners->end() ) 2641*cdf0e10cSrcweir { 2642*cdf0e10cSrcweir (*it)->notifyDeleted(); 2643*cdf0e10cSrcweir delete (*it); 2644*cdf0e10cSrcweir ++it; 2645*cdf0e10cSrcweir } 2646*cdf0e10cSrcweir delete listeners; 2647*cdf0e10cSrcweir } 2648*cdf0e10cSrcweir 2649*cdf0e10cSrcweir 2650*cdf0e10cSrcweir void SAL_CALL 2651*cdf0e10cSrcweir shell::notifyContentRemoved( std::list< ContentEventNotifier* >* listeners, 2652*cdf0e10cSrcweir const rtl::OUString& aChildName ) 2653*cdf0e10cSrcweir { 2654*cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin(); 2655*cdf0e10cSrcweir while( it != listeners->end() ) 2656*cdf0e10cSrcweir { 2657*cdf0e10cSrcweir (*it)->notifyRemoved( aChildName ); 2658*cdf0e10cSrcweir delete (*it); 2659*cdf0e10cSrcweir ++it; 2660*cdf0e10cSrcweir } 2661*cdf0e10cSrcweir delete listeners; 2662*cdf0e10cSrcweir } 2663*cdf0e10cSrcweir 2664*cdf0e10cSrcweir 2665*cdf0e10cSrcweir 2666*cdf0e10cSrcweir 2667*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* SAL_CALL 2668*cdf0e10cSrcweir shell::getPropertySetListeners( const rtl::OUString& aName ) 2669*cdf0e10cSrcweir { 2670*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* p = new std::list< PropertySetInfoChangeNotifier* >; 2671*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >& listeners = *p; 2672*cdf0e10cSrcweir { 2673*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2674*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName ); 2675*cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier ) 2676*cdf0e10cSrcweir { 2677*cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier ); 2678*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin(); 2679*cdf0e10cSrcweir while( it1 != listOfNotifiers.end() ) 2680*cdf0e10cSrcweir { 2681*cdf0e10cSrcweir Notifier* pointer = *it1; 2682*cdf0e10cSrcweir PropertySetInfoChangeNotifier* notifier = pointer->cPSL(); 2683*cdf0e10cSrcweir if( notifier ) 2684*cdf0e10cSrcweir listeners.push_back( notifier ); 2685*cdf0e10cSrcweir ++it1; 2686*cdf0e10cSrcweir } 2687*cdf0e10cSrcweir } 2688*cdf0e10cSrcweir } 2689*cdf0e10cSrcweir return p; 2690*cdf0e10cSrcweir } 2691*cdf0e10cSrcweir 2692*cdf0e10cSrcweir 2693*cdf0e10cSrcweir void SAL_CALL 2694*cdf0e10cSrcweir shell::notifyPropertyAdded( std::list< PropertySetInfoChangeNotifier* >* listeners, 2695*cdf0e10cSrcweir const rtl::OUString& aPropertyName ) 2696*cdf0e10cSrcweir { 2697*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >::iterator it = listeners->begin(); 2698*cdf0e10cSrcweir while( it != listeners->end() ) 2699*cdf0e10cSrcweir { 2700*cdf0e10cSrcweir (*it)->notifyPropertyAdded( aPropertyName ); 2701*cdf0e10cSrcweir delete (*it); 2702*cdf0e10cSrcweir ++it; 2703*cdf0e10cSrcweir } 2704*cdf0e10cSrcweir delete listeners; 2705*cdf0e10cSrcweir } 2706*cdf0e10cSrcweir 2707*cdf0e10cSrcweir 2708*cdf0e10cSrcweir void SAL_CALL 2709*cdf0e10cSrcweir shell::notifyPropertyRemoved( std::list< PropertySetInfoChangeNotifier* >* listeners, 2710*cdf0e10cSrcweir const rtl::OUString& aPropertyName ) 2711*cdf0e10cSrcweir { 2712*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >::iterator it = listeners->begin(); 2713*cdf0e10cSrcweir while( it != listeners->end() ) 2714*cdf0e10cSrcweir { 2715*cdf0e10cSrcweir (*it)->notifyPropertyRemoved( aPropertyName ); 2716*cdf0e10cSrcweir delete (*it); 2717*cdf0e10cSrcweir ++it; 2718*cdf0e10cSrcweir } 2719*cdf0e10cSrcweir delete listeners; 2720*cdf0e10cSrcweir } 2721*cdf0e10cSrcweir 2722*cdf0e10cSrcweir 2723*cdf0e10cSrcweir 2724*cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* SAL_CALL 2725*cdf0e10cSrcweir shell::getContentExchangedEventListeners( const rtl::OUString aOldPrefix, 2726*cdf0e10cSrcweir const rtl::OUString aNewPrefix, 2727*cdf0e10cSrcweir sal_Bool withChilds ) 2728*cdf0e10cSrcweir { 2729*cdf0e10cSrcweir 2730*cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* aVectorOnHeap = 2731*cdf0e10cSrcweir new std::vector< std::list< ContentEventNotifier* >* >; 2732*cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >& aVector = *aVectorOnHeap; 2733*cdf0e10cSrcweir 2734*cdf0e10cSrcweir sal_Int32 count; 2735*cdf0e10cSrcweir rtl::OUString aOldName; 2736*cdf0e10cSrcweir rtl::OUString aNewName; 2737*cdf0e10cSrcweir std::vector< rtl::OUString > oldChildList; 2738*cdf0e10cSrcweir 2739*cdf0e10cSrcweir { 2740*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2741*cdf0e10cSrcweir 2742*cdf0e10cSrcweir if( ! withChilds ) 2743*cdf0e10cSrcweir { 2744*cdf0e10cSrcweir aOldName = aOldPrefix; 2745*cdf0e10cSrcweir aNewName = aNewPrefix; 2746*cdf0e10cSrcweir count = 1; 2747*cdf0e10cSrcweir } 2748*cdf0e10cSrcweir else 2749*cdf0e10cSrcweir { 2750*cdf0e10cSrcweir ContentMap::iterator itnames = m_aContent.begin(); 2751*cdf0e10cSrcweir while( itnames != m_aContent.end() ) 2752*cdf0e10cSrcweir { 2753*cdf0e10cSrcweir if( isChild( aOldPrefix,itnames->first ) ) 2754*cdf0e10cSrcweir { 2755*cdf0e10cSrcweir oldChildList.push_back( itnames->first ); 2756*cdf0e10cSrcweir } 2757*cdf0e10cSrcweir ++itnames; 2758*cdf0e10cSrcweir } 2759*cdf0e10cSrcweir count = oldChildList.size(); 2760*cdf0e10cSrcweir } 2761*cdf0e10cSrcweir 2762*cdf0e10cSrcweir 2763*cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j ) 2764*cdf0e10cSrcweir { 2765*cdf0e10cSrcweir std::list< ContentEventNotifier* >* p = new std::list< ContentEventNotifier* >; 2766*cdf0e10cSrcweir std::list< ContentEventNotifier* >& listeners = *p; 2767*cdf0e10cSrcweir 2768*cdf0e10cSrcweir if( withChilds ) 2769*cdf0e10cSrcweir { 2770*cdf0e10cSrcweir aOldName = oldChildList[j]; 2771*cdf0e10cSrcweir aNewName = newName( aNewPrefix,aOldPrefix,aOldName ); 2772*cdf0e10cSrcweir } 2773*cdf0e10cSrcweir 2774*cdf0e10cSrcweir shell::ContentMap::iterator itold = m_aContent.find( aOldName ); 2775*cdf0e10cSrcweir if( itold != m_aContent.end() ) 2776*cdf0e10cSrcweir { 2777*cdf0e10cSrcweir shell::ContentMap::iterator itnew = m_aContent.insert( 2778*cdf0e10cSrcweir ContentMap::value_type( aNewName,UnqPathData() ) ).first; 2779*cdf0e10cSrcweir 2780*cdf0e10cSrcweir // copy Ownership also 2781*cdf0e10cSrcweir delete itnew->second.properties; 2782*cdf0e10cSrcweir itnew->second.properties = itold->second.properties; 2783*cdf0e10cSrcweir itold->second.properties = 0; 2784*cdf0e10cSrcweir 2785*cdf0e10cSrcweir // copy existing list 2786*cdf0e10cSrcweir std::list< Notifier* >* copyList = itnew->second.notifier; 2787*cdf0e10cSrcweir itnew->second.notifier = itold->second.notifier; 2788*cdf0e10cSrcweir itold->second.notifier = 0; 2789*cdf0e10cSrcweir 2790*cdf0e10cSrcweir m_aContent.erase( itold ); 2791*cdf0e10cSrcweir 2792*cdf0e10cSrcweir if( itnew != m_aContent.end() && itnew->second.notifier ) 2793*cdf0e10cSrcweir { 2794*cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( itnew->second.notifier ); 2795*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin(); 2796*cdf0e10cSrcweir while( it1 != listOfNotifiers.end() ) 2797*cdf0e10cSrcweir { 2798*cdf0e10cSrcweir Notifier* pointer = *it1; 2799*cdf0e10cSrcweir ContentEventNotifier* notifier = pointer->cEXC( aNewName ); 2800*cdf0e10cSrcweir if( notifier ) 2801*cdf0e10cSrcweir listeners.push_back( notifier ); 2802*cdf0e10cSrcweir ++it1; 2803*cdf0e10cSrcweir } 2804*cdf0e10cSrcweir } 2805*cdf0e10cSrcweir 2806*cdf0e10cSrcweir // Merge with preexisting notifiers 2807*cdf0e10cSrcweir // However, these may be in status BaseContent::Deleted 2808*cdf0e10cSrcweir if( copyList != 0 ) 2809*cdf0e10cSrcweir { 2810*cdf0e10cSrcweir std::list< Notifier* >::iterator copyIt = copyList->begin(); 2811*cdf0e10cSrcweir while( copyIt != copyList->end() ) 2812*cdf0e10cSrcweir { 2813*cdf0e10cSrcweir itnew->second.notifier->push_back( *copyIt ); 2814*cdf0e10cSrcweir ++copyIt; 2815*cdf0e10cSrcweir } 2816*cdf0e10cSrcweir } 2817*cdf0e10cSrcweir delete copyList; 2818*cdf0e10cSrcweir } 2819*cdf0e10cSrcweir aVector.push_back( p ); 2820*cdf0e10cSrcweir } 2821*cdf0e10cSrcweir } 2822*cdf0e10cSrcweir 2823*cdf0e10cSrcweir return aVectorOnHeap; 2824*cdf0e10cSrcweir } 2825*cdf0e10cSrcweir 2826*cdf0e10cSrcweir 2827*cdf0e10cSrcweir 2828*cdf0e10cSrcweir void SAL_CALL 2829*cdf0e10cSrcweir shell::notifyContentExchanged( std::vector< std::list< ContentEventNotifier* >* >* listeners_vec ) 2830*cdf0e10cSrcweir { 2831*cdf0e10cSrcweir std::list< ContentEventNotifier* >* listeners; 2832*cdf0e10cSrcweir for( sal_uInt32 i = 0; i < listeners_vec->size(); ++i ) 2833*cdf0e10cSrcweir { 2834*cdf0e10cSrcweir listeners = (*listeners_vec)[i]; 2835*cdf0e10cSrcweir std::list< ContentEventNotifier* >::iterator it = listeners->begin(); 2836*cdf0e10cSrcweir while( it != listeners->end() ) 2837*cdf0e10cSrcweir { 2838*cdf0e10cSrcweir (*it)->notifyExchanged(); 2839*cdf0e10cSrcweir delete (*it); 2840*cdf0e10cSrcweir ++it; 2841*cdf0e10cSrcweir } 2842*cdf0e10cSrcweir delete listeners; 2843*cdf0e10cSrcweir } 2844*cdf0e10cSrcweir delete listeners_vec; 2845*cdf0e10cSrcweir } 2846*cdf0e10cSrcweir 2847*cdf0e10cSrcweir 2848*cdf0e10cSrcweir 2849*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* SAL_CALL 2850*cdf0e10cSrcweir shell::getPropertyChangeNotifier( const rtl::OUString& aName ) 2851*cdf0e10cSrcweir { 2852*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* p = new std::list< PropertyChangeNotifier* >; 2853*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >& listeners = *p; 2854*cdf0e10cSrcweir { 2855*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2856*cdf0e10cSrcweir shell::ContentMap::iterator it = m_aContent.find( aName ); 2857*cdf0e10cSrcweir if( it != m_aContent.end() && it->second.notifier ) 2858*cdf0e10cSrcweir { 2859*cdf0e10cSrcweir std::list<Notifier*>& listOfNotifiers = *( it->second.notifier ); 2860*cdf0e10cSrcweir std::list<Notifier*>::iterator it1 = listOfNotifiers.begin(); 2861*cdf0e10cSrcweir while( it1 != listOfNotifiers.end() ) 2862*cdf0e10cSrcweir { 2863*cdf0e10cSrcweir Notifier* pointer = *it1; 2864*cdf0e10cSrcweir PropertyChangeNotifier* notifier = pointer->cPCL(); 2865*cdf0e10cSrcweir if( notifier ) 2866*cdf0e10cSrcweir listeners.push_back( notifier ); 2867*cdf0e10cSrcweir ++it1; 2868*cdf0e10cSrcweir } 2869*cdf0e10cSrcweir } 2870*cdf0e10cSrcweir } 2871*cdf0e10cSrcweir return p; 2872*cdf0e10cSrcweir } 2873*cdf0e10cSrcweir 2874*cdf0e10cSrcweir 2875*cdf0e10cSrcweir void SAL_CALL shell::notifyPropertyChanges( std::list< PropertyChangeNotifier* >* listeners, 2876*cdf0e10cSrcweir const uno::Sequence< beans::PropertyChangeEvent >& seqChanged ) 2877*cdf0e10cSrcweir { 2878*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >::iterator it = listeners->begin(); 2879*cdf0e10cSrcweir while( it != listeners->end() ) 2880*cdf0e10cSrcweir { 2881*cdf0e10cSrcweir (*it)->notifyPropertyChanged( seqChanged ); 2882*cdf0e10cSrcweir delete (*it); 2883*cdf0e10cSrcweir ++it; 2884*cdf0e10cSrcweir } 2885*cdf0e10cSrcweir delete listeners; 2886*cdf0e10cSrcweir } 2887*cdf0e10cSrcweir 2888*cdf0e10cSrcweir 2889*cdf0e10cSrcweir 2890*cdf0e10cSrcweir 2891*cdf0e10cSrcweir /********************************************************************************/ 2892*cdf0e10cSrcweir /* remove persistent propertyset */ 2893*cdf0e10cSrcweir /********************************************************************************/ 2894*cdf0e10cSrcweir 2895*cdf0e10cSrcweir void SAL_CALL 2896*cdf0e10cSrcweir shell::erasePersistentSet( const rtl::OUString& aUnqPath, 2897*cdf0e10cSrcweir sal_Bool withChilds ) 2898*cdf0e10cSrcweir { 2899*cdf0e10cSrcweir if( ! m_xFileRegistry.is() ) 2900*cdf0e10cSrcweir { 2901*cdf0e10cSrcweir OSL_ASSERT( m_xFileRegistry.is() ); 2902*cdf0e10cSrcweir return; 2903*cdf0e10cSrcweir } 2904*cdf0e10cSrcweir 2905*cdf0e10cSrcweir uno::Sequence< rtl::OUString > seqNames; 2906*cdf0e10cSrcweir 2907*cdf0e10cSrcweir if( withChilds ) 2908*cdf0e10cSrcweir { 2909*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xName( m_xFileRegistry,uno::UNO_QUERY ); 2910*cdf0e10cSrcweir seqNames = xName->getElementNames(); 2911*cdf0e10cSrcweir } 2912*cdf0e10cSrcweir 2913*cdf0e10cSrcweir sal_Int32 count = withChilds ? seqNames.getLength() : 1; 2914*cdf0e10cSrcweir 2915*cdf0e10cSrcweir rtl::OUString 2916*cdf0e10cSrcweir old_Name = aUnqPath; 2917*cdf0e10cSrcweir 2918*cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j ) 2919*cdf0e10cSrcweir { 2920*cdf0e10cSrcweir if( withChilds && ! ( isChild( old_Name,seqNames[j] ) ) ) 2921*cdf0e10cSrcweir continue; 2922*cdf0e10cSrcweir 2923*cdf0e10cSrcweir if( withChilds ) 2924*cdf0e10cSrcweir { 2925*cdf0e10cSrcweir old_Name = seqNames[j]; 2926*cdf0e10cSrcweir } 2927*cdf0e10cSrcweir 2928*cdf0e10cSrcweir { 2929*cdf0e10cSrcweir // Release possible references 2930*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 2931*cdf0e10cSrcweir ContentMap::iterator it = m_aContent.find( old_Name ); 2932*cdf0e10cSrcweir if( it != m_aContent.end() ) 2933*cdf0e10cSrcweir { 2934*cdf0e10cSrcweir it->second.xS = 0; 2935*cdf0e10cSrcweir it->second.xC = 0; 2936*cdf0e10cSrcweir it->second.xA = 0; 2937*cdf0e10cSrcweir 2938*cdf0e10cSrcweir delete it->second.properties; 2939*cdf0e10cSrcweir it->second.properties = 0; 2940*cdf0e10cSrcweir } 2941*cdf0e10cSrcweir } 2942*cdf0e10cSrcweir 2943*cdf0e10cSrcweir if( m_xFileRegistry.is() ) 2944*cdf0e10cSrcweir m_xFileRegistry->removePropertySet( old_Name ); 2945*cdf0e10cSrcweir } 2946*cdf0e10cSrcweir } 2947*cdf0e10cSrcweir 2948*cdf0e10cSrcweir 2949*cdf0e10cSrcweir 2950*cdf0e10cSrcweir 2951*cdf0e10cSrcweir /********************************************************************************/ 2952*cdf0e10cSrcweir /* copy persistent propertyset */ 2953*cdf0e10cSrcweir /* from srcUnqPath to dstUnqPath */ 2954*cdf0e10cSrcweir /********************************************************************************/ 2955*cdf0e10cSrcweir 2956*cdf0e10cSrcweir 2957*cdf0e10cSrcweir void SAL_CALL 2958*cdf0e10cSrcweir shell::copyPersistentSet( const rtl::OUString& srcUnqPath, 2959*cdf0e10cSrcweir const rtl::OUString& dstUnqPath, 2960*cdf0e10cSrcweir sal_Bool withChilds ) 2961*cdf0e10cSrcweir { 2962*cdf0e10cSrcweir if( ! m_xFileRegistry.is() ) 2963*cdf0e10cSrcweir { 2964*cdf0e10cSrcweir OSL_ASSERT( m_xFileRegistry.is() ); 2965*cdf0e10cSrcweir return; 2966*cdf0e10cSrcweir } 2967*cdf0e10cSrcweir 2968*cdf0e10cSrcweir uno::Sequence< rtl::OUString > seqNames; 2969*cdf0e10cSrcweir 2970*cdf0e10cSrcweir if( withChilds ) 2971*cdf0e10cSrcweir { 2972*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xName( m_xFileRegistry,uno::UNO_QUERY ); 2973*cdf0e10cSrcweir seqNames = xName->getElementNames(); 2974*cdf0e10cSrcweir } 2975*cdf0e10cSrcweir 2976*cdf0e10cSrcweir sal_Int32 count = withChilds ? seqNames.getLength() : 1; 2977*cdf0e10cSrcweir 2978*cdf0e10cSrcweir rtl::OUString 2979*cdf0e10cSrcweir old_Name = srcUnqPath, 2980*cdf0e10cSrcweir new_Name = dstUnqPath; 2981*cdf0e10cSrcweir 2982*cdf0e10cSrcweir for( sal_Int32 j = 0; j < count; ++j ) 2983*cdf0e10cSrcweir { 2984*cdf0e10cSrcweir if( withChilds && ! ( isChild( srcUnqPath,seqNames[j] ) ) ) 2985*cdf0e10cSrcweir continue; 2986*cdf0e10cSrcweir 2987*cdf0e10cSrcweir if( withChilds ) 2988*cdf0e10cSrcweir { 2989*cdf0e10cSrcweir old_Name = seqNames[j]; 2990*cdf0e10cSrcweir new_Name = newName( dstUnqPath,srcUnqPath,old_Name ); 2991*cdf0e10cSrcweir } 2992*cdf0e10cSrcweir 2993*cdf0e10cSrcweir uno::Reference< XPersistentPropertySet > x_src; 2994*cdf0e10cSrcweir 2995*cdf0e10cSrcweir if( m_xFileRegistry.is() ) 2996*cdf0e10cSrcweir { 2997*cdf0e10cSrcweir x_src = m_xFileRegistry->openPropertySet( old_Name,false ); 2998*cdf0e10cSrcweir m_xFileRegistry->removePropertySet( new_Name ); 2999*cdf0e10cSrcweir } 3000*cdf0e10cSrcweir 3001*cdf0e10cSrcweir if( x_src.is() ) 3002*cdf0e10cSrcweir { 3003*cdf0e10cSrcweir uno::Sequence< beans::Property > seqProperty = 3004*cdf0e10cSrcweir x_src->getPropertySetInfo()->getProperties(); 3005*cdf0e10cSrcweir 3006*cdf0e10cSrcweir if( seqProperty.getLength() ) 3007*cdf0e10cSrcweir { 3008*cdf0e10cSrcweir uno::Reference< XPersistentPropertySet > 3009*cdf0e10cSrcweir x_dstS = m_xFileRegistry->openPropertySet( new_Name,true ); 3010*cdf0e10cSrcweir uno::Reference< beans::XPropertyContainer > 3011*cdf0e10cSrcweir x_dstC( x_dstS,uno::UNO_QUERY ); 3012*cdf0e10cSrcweir 3013*cdf0e10cSrcweir for( sal_Int32 i = 0; i < seqProperty.getLength(); ++i ) 3014*cdf0e10cSrcweir { 3015*cdf0e10cSrcweir x_dstC->addProperty( seqProperty[i].Name, 3016*cdf0e10cSrcweir seqProperty[i].Attributes, 3017*cdf0e10cSrcweir x_src->getPropertyValue( seqProperty[i].Name ) ); 3018*cdf0e10cSrcweir } 3019*cdf0e10cSrcweir } 3020*cdf0e10cSrcweir } 3021*cdf0e10cSrcweir } // end for( sal_Int... 3022*cdf0e10cSrcweir } 3023*cdf0e10cSrcweir 3024*cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > shell::queryCreatableContentsInfo() 3025*cdf0e10cSrcweir { 3026*cdf0e10cSrcweir uno::Sequence< ucb::ContentInfo > seq(2); 3027*cdf0e10cSrcweir 3028*cdf0e10cSrcweir // file 3029*cdf0e10cSrcweir seq[0].Type = FileContentType; 3030*cdf0e10cSrcweir seq[0].Attributes = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM 3031*cdf0e10cSrcweir | ucb::ContentInfoAttribute::KIND_DOCUMENT; 3032*cdf0e10cSrcweir 3033*cdf0e10cSrcweir uno::Sequence< beans::Property > props( 1 ); 3034*cdf0e10cSrcweir props[0] = beans::Property( 3035*cdf0e10cSrcweir rtl::OUString::createFromAscii( "Title" ), 3036*cdf0e10cSrcweir -1, 3037*cdf0e10cSrcweir getCppuType( static_cast< rtl::OUString* >( 0 ) ), 3038*cdf0e10cSrcweir beans::PropertyAttribute::MAYBEVOID 3039*cdf0e10cSrcweir | beans::PropertyAttribute::BOUND ); 3040*cdf0e10cSrcweir seq[0].Properties = props; 3041*cdf0e10cSrcweir 3042*cdf0e10cSrcweir // folder 3043*cdf0e10cSrcweir seq[1].Type = FolderContentType; 3044*cdf0e10cSrcweir seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; 3045*cdf0e10cSrcweir seq[1].Properties = props; 3046*cdf0e10cSrcweir return seq; 3047*cdf0e10cSrcweir } 3048*cdf0e10cSrcweir 3049*cdf0e10cSrcweir /*******************************************************************************/ 3050*cdf0e10cSrcweir /* */ 3051*cdf0e10cSrcweir /* some misceancellous static functions */ 3052*cdf0e10cSrcweir /* */ 3053*cdf0e10cSrcweir /*******************************************************************************/ 3054*cdf0e10cSrcweir 3055*cdf0e10cSrcweir void SAL_CALL 3056*cdf0e10cSrcweir shell::getScheme( rtl::OUString& Scheme ) 3057*cdf0e10cSrcweir { 3058*cdf0e10cSrcweir Scheme = rtl::OUString::createFromAscii( "file" ); 3059*cdf0e10cSrcweir } 3060*cdf0e10cSrcweir 3061*cdf0e10cSrcweir rtl::OUString SAL_CALL 3062*cdf0e10cSrcweir shell::getImplementationName_static( void ) 3063*cdf0e10cSrcweir { 3064*cdf0e10cSrcweir return rtl::OUString::createFromAscii( "com.sun.star.comp.ucb.FileProvider" ); 3065*cdf0e10cSrcweir } 3066*cdf0e10cSrcweir 3067*cdf0e10cSrcweir 3068*cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL 3069*cdf0e10cSrcweir shell::getSupportedServiceNames_static( void ) 3070*cdf0e10cSrcweir { 3071*cdf0e10cSrcweir rtl::OUString Supported = rtl::OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" ) ; 3072*cdf0e10cSrcweir com::sun::star::uno::Sequence< rtl::OUString > Seq( &Supported,1 ); 3073*cdf0e10cSrcweir return Seq; 3074*cdf0e10cSrcweir } 3075