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 29*cdf0e10cSrcweir #ifndef _SHELL_HXX_ 30*cdf0e10cSrcweir #define _SHELL_HXX_ 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 34*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 35*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 36*cdf0e10cSrcweir #include <vector> 37*cdf0e10cSrcweir #include <hash_map> 38*cdf0e10cSrcweir #include <hash_set> 39*cdf0e10cSrcweir #include <list> 40*cdf0e10cSrcweir #include <osl/file.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include "osl/mutex.hxx" 43*cdf0e10cSrcweir #include <rtl/ustring.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 45*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/ucb/NumberedSortingInfo.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyAccess.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/ucb/ContentInfo.hpp> 66*cdf0e10cSrcweir #include "filtask.hxx" 67*cdf0e10cSrcweir #include "filnot.hxx" 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir namespace fileaccess { 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir class FileProvider; 72*cdf0e10cSrcweir class XPropertySetInfo_impl; 73*cdf0e10cSrcweir class XCommandInfo_impl; 74*cdf0e10cSrcweir class XResultSet_impl; 75*cdf0e10cSrcweir class BaseContent; 76*cdf0e10cSrcweir class shell; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir class shell 79*cdf0e10cSrcweir : public virtual TaskManager 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir friend class XPropertySetInfo_impl; 82*cdf0e10cSrcweir friend class XResultSet_impl; 83*cdf0e10cSrcweir friend class XCommandInfo_impl; 84*cdf0e10cSrcweir public: 85*cdf0e10cSrcweir // Type definitions 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir typedef rtl::OUString UniquePath; 88*cdf0e10cSrcweir typedef equalOUString eUniquePath; 89*cdf0e10cSrcweir typedef hashOUString hUniquePath; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir class MyProperty 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir private: 94*cdf0e10cSrcweir rtl::OUString PropertyName; 95*cdf0e10cSrcweir sal_Int32 Handle; 96*cdf0e10cSrcweir sal_Bool isNative; 97*cdf0e10cSrcweir com::sun::star::uno::Type Typ; // Duplicates information in Value 98*cdf0e10cSrcweir com::sun::star::uno::Any Value; 99*cdf0e10cSrcweir com::sun::star::beans::PropertyState State; 100*cdf0e10cSrcweir sal_Int16 Attributes; 101*cdf0e10cSrcweir public: 102*cdf0e10cSrcweir MyProperty(); 103*cdf0e10cSrcweir MyProperty( const rtl::OUString& __PropertyName ); 104*cdf0e10cSrcweir MyProperty( const sal_Bool& __isNative, 105*cdf0e10cSrcweir const rtl::OUString& __PropertyName, 106*cdf0e10cSrcweir const sal_Int32& __Handle, 107*cdf0e10cSrcweir const com::sun::star::uno::Type& __Typ, 108*cdf0e10cSrcweir const com::sun::star::uno::Any& __Value, 109*cdf0e10cSrcweir const com::sun::star::beans::PropertyState& __State, 110*cdf0e10cSrcweir const sal_Int16& __Attributes ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ~MyProperty(); 113*cdf0e10cSrcweir inline const sal_Bool& SAL_CALL IsNative() const; 114*cdf0e10cSrcweir inline const rtl::OUString& SAL_CALL getPropertyName() const { return PropertyName; } 115*cdf0e10cSrcweir inline const sal_Int32& SAL_CALL getHandle() const; 116*cdf0e10cSrcweir inline const com::sun::star::uno::Type& SAL_CALL getType() const; 117*cdf0e10cSrcweir inline const com::sun::star::uno::Any& SAL_CALL getValue() const; 118*cdf0e10cSrcweir inline const com::sun::star::beans::PropertyState& SAL_CALL getState() const; 119*cdf0e10cSrcweir inline const sal_Int16& SAL_CALL getAttributes() const; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // The set* functions are declared const, because the key of "this" stays intact 122*cdf0e10cSrcweir inline void SAL_CALL setHandle( const sal_Int32& __Handle ) const; 123*cdf0e10cSrcweir inline void SAL_CALL setType( const com::sun::star::uno::Type& __Type ) const; 124*cdf0e10cSrcweir inline void SAL_CALL setValue( const com::sun::star::uno::Any& __Value ) const; 125*cdf0e10cSrcweir inline void SAL_CALL setState( const com::sun::star::beans::PropertyState& __State ) const; 126*cdf0e10cSrcweir inline void SAL_CALL setAttributes( const sal_Int16& __Attributes ) const; 127*cdf0e10cSrcweir }; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir struct eMyProperty 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir bool operator()( const MyProperty& rKey1, const MyProperty& rKey2 ) const 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir return !!( rKey1.getPropertyName() == rKey2.getPropertyName() ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir }; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir struct hMyProperty 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir size_t operator()( const MyProperty& rName ) const 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir return rName.getPropertyName().hashCode(); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir }; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir typedef std::hash_set< MyProperty,hMyProperty,eMyProperty > PropertySet; 146*cdf0e10cSrcweir typedef std::list< Notifier* > NotifierList; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir class UnqPathData 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir public: 152*cdf0e10cSrcweir UnqPathData(); 153*cdf0e10cSrcweir ~UnqPathData(); 154*cdf0e10cSrcweir UnqPathData( const UnqPathData& ); 155*cdf0e10cSrcweir UnqPathData& operator=( UnqPathData& ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir PropertySet* properties; 158*cdf0e10cSrcweir NotifierList* notifier; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir // Three views on the PersistentPropertySet 161*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xS; 162*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertyContainer > xC; 163*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertyAccess > xA; 164*cdf0e10cSrcweir }; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir typedef std::hash_map< UniquePath,UnqPathData,hUniquePath,eUniquePath > ContentMap; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir public: 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // MethodenDefinitionen 171*cdf0e10cSrcweir shell( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMultiServiceFactory, 172*cdf0e10cSrcweir FileProvider* pProvider,sal_Bool bWithConfig ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir virtual ~shell(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir /** 179*cdf0e10cSrcweir * This two methods register and deregister a change listener for the content belonging 180*cdf0e10cSrcweir * to URL aUnqPath 181*cdf0e10cSrcweir */ 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void SAL_CALL registerNotifier( const rtl::OUString& aUnqPath,Notifier* pNotifier ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SAL_CALL deregisterNotifier( const rtl::OUString& aUnqPath,Notifier* pNotifier ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir /** 190*cdf0e10cSrcweir * Used to associate and deassociate a new property with 191*cdf0e10cSrcweir * the content belonging to URL UnqPath. 192*cdf0e10cSrcweir * The default value and the the attributes are input 193*cdf0e10cSrcweir */ 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir void SAL_CALL associate( const rtl::OUString& UnqPath, 196*cdf0e10cSrcweir const rtl::OUString& PropertyName, 197*cdf0e10cSrcweir const com::sun::star::uno::Any& DefaultValue, 198*cdf0e10cSrcweir const sal_Int16 Attributes ) 199*cdf0e10cSrcweir throw( com::sun::star::beans::PropertyExistException, 200*cdf0e10cSrcweir com::sun::star::beans::IllegalTypeException, 201*cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void SAL_CALL deassociate( const rtl::OUString& UnqPath, 205*cdf0e10cSrcweir const rtl::OUString& PropertyName ) 206*cdf0e10cSrcweir throw( com::sun::star::beans::UnknownPropertyException, 207*cdf0e10cSrcweir com::sun::star::beans::NotRemoveableException, 208*cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // 213*cdf0e10cSrcweir // Every method having a command id is not allowed to throw anything, 214*cdf0e10cSrcweir // but instead must install every error code in the task handler 215*cdf0e10cSrcweir // 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir /** 219*cdf0e10cSrcweir * Given an xOutputStream, this method writes the content of the file belonging to 220*cdf0e10cSrcweir * URL aUnqPath into the XOutputStream 221*cdf0e10cSrcweir */ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir void SAL_CALL page( sal_Int32 CommandId, 224*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 225*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream ) 226*cdf0e10cSrcweir throw(); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir /** 230*cdf0e10cSrcweir * Given a file URL aUnqPath, this methods returns a XInputStream which reads from the open file. 231*cdf0e10cSrcweir */ 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL 234*cdf0e10cSrcweir open( sal_Int32 CommandId, 235*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 236*cdf0e10cSrcweir sal_Bool bLock ) 237*cdf0e10cSrcweir throw(); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir /** 241*cdf0e10cSrcweir * Given a file URL aUnqPath, this methods returns a XStream which can be used 242*cdf0e10cSrcweir * to read and write from/to the file. 243*cdf0e10cSrcweir */ 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL 246*cdf0e10cSrcweir open_rw( sal_Int32 CommandId, 247*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 248*cdf0e10cSrcweir sal_Bool bLock ) 249*cdf0e10cSrcweir throw(); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir /** 253*cdf0e10cSrcweir * This method returns the result set containing the the children of the directory belonging 254*cdf0e10cSrcweir * to file URL aUnqPath 255*cdf0e10cSrcweir */ 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet > SAL_CALL 258*cdf0e10cSrcweir ls( sal_Int32 CommandId, 259*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 260*cdf0e10cSrcweir const sal_Int32 OpenMode, 261*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& sProperty, 262*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::ucb::NumberedSortingInfo > & sSortingInfo ) 263*cdf0e10cSrcweir throw(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir /** 267*cdf0e10cSrcweir * Info methods 268*cdf0e10cSrcweir */ 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // Info for commands 271*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > SAL_CALL 272*cdf0e10cSrcweir info_c() 273*cdf0e10cSrcweir throw(); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir // Info for the properties 276*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL 277*cdf0e10cSrcweir info_p( const rtl::OUString& aUnqPath ) 278*cdf0e10cSrcweir throw(); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir /** 282*cdf0e10cSrcweir * Sets the values of the properties belonging to fileURL aUnqPath 283*cdf0e10cSrcweir */ 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL 286*cdf0e10cSrcweir setv( const rtl::OUString& aUnqPath, 287*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& values ) 288*cdf0e10cSrcweir throw(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir /** 292*cdf0e10cSrcweir * Reads the values of the properties belonging to fileURL aUnqPath; 293*cdf0e10cSrcweir * Returns an XRow object containing the values in the requested order. 294*cdf0e10cSrcweir */ 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > SAL_CALL 297*cdf0e10cSrcweir getv( sal_Int32 CommandId, 298*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 299*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& properties ) 300*cdf0e10cSrcweir throw(); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir /********************************************************************************/ 304*cdf0e10cSrcweir /* transfer-commands */ 305*cdf0e10cSrcweir /********************************************************************************/ 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir /** 308*cdf0e10cSrcweir * Moves the content belonging to fileURL srcUnqPath to fileURL dstUnqPath( files and directories ) 309*cdf0e10cSrcweir */ 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir void SAL_CALL 312*cdf0e10cSrcweir move( sal_Int32 CommandId, 313*cdf0e10cSrcweir const rtl::OUString srcUnqPath, // Full file(folder)-path 314*cdf0e10cSrcweir const rtl::OUString dstUnqPath, // Path to the destination-directory 315*cdf0e10cSrcweir const sal_Int32 NameClash ) 316*cdf0e10cSrcweir throw(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir /** 319*cdf0e10cSrcweir * Copies the content belonging to fileURL srcUnqPath to fileURL dstUnqPath ( files and directories ) 320*cdf0e10cSrcweir */ 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir void SAL_CALL 323*cdf0e10cSrcweir copy( sal_Int32 CommandId, // See "move" 324*cdf0e10cSrcweir const rtl::OUString srcUnqPath, 325*cdf0e10cSrcweir const rtl::OUString dstUnqPath, 326*cdf0e10cSrcweir sal_Int32 NameClash ) 327*cdf0e10cSrcweir throw(); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir #define RemoveFolder 1 330*cdf0e10cSrcweir #define RemoveFile -1 331*cdf0e10cSrcweir #define RemoveUnknown 0 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir /** 334*cdf0e10cSrcweir * Deletes the content belonging to fileURL aUnqPath( recursively in case of directory ) 335*cdf0e10cSrcweir */ 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir sal_Bool SAL_CALL 338*cdf0e10cSrcweir remove( sal_Int32 CommandId, 339*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 340*cdf0e10cSrcweir sal_Int32 TypeToMove = RemoveUnknown, 341*cdf0e10cSrcweir sal_Bool MustExist = sal_True ) 342*cdf0e10cSrcweir throw(); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir #undef RemoveUnknown 345*cdf0e10cSrcweir #undef RemoveFile 346*cdf0e10cSrcweir #undef RemoveFolder 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir /********************************************************************************/ 350*cdf0e10cSrcweir /* write and create - commandos */ 351*cdf0e10cSrcweir /********************************************************************************/ 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir /** 354*cdf0e10cSrcweir * Creates new directory with given URL, recursively if necessary 355*cdf0e10cSrcweir * Return:: success of operation 356*cdf0e10cSrcweir */ 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir sal_Bool SAL_CALL 359*cdf0e10cSrcweir mkdir( sal_Int32 CommandId, 360*cdf0e10cSrcweir const rtl::OUString& aDirectoryName, 361*cdf0e10cSrcweir sal_Bool OverWrite ) 362*cdf0e10cSrcweir throw(); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir /** 366*cdf0e10cSrcweir * Creates new file with given URL. 367*cdf0e10cSrcweir * The content of aInputStream becomes the content of the file 368*cdf0e10cSrcweir * Return:: success of operation 369*cdf0e10cSrcweir */ 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir sal_Bool SAL_CALL 372*cdf0e10cSrcweir mkfil( sal_Int32 CommandId, 373*cdf0e10cSrcweir const rtl::OUString& aFileName, 374*cdf0e10cSrcweir sal_Bool OverWrite, 375*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& aInputStream ) 376*cdf0e10cSrcweir throw(); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir /** 380*cdf0e10cSrcweir * writes to the file with given URL. 381*cdf0e10cSrcweir * The content of aInputStream becomes the content of the file 382*cdf0e10cSrcweir * Return:: success of operation 383*cdf0e10cSrcweir */ 384*cdf0e10cSrcweir sal_Bool SAL_CALL 385*cdf0e10cSrcweir write( sal_Int32 CommandId, 386*cdf0e10cSrcweir const rtl::OUString& aUnqPath, 387*cdf0e10cSrcweir sal_Bool OverWrite, 388*cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::io::XInputStream >& aInputStream ) 389*cdf0e10cSrcweir throw(); 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir void SAL_CALL insertDefaultProperties( const rtl::OUString& aUnqPath ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 396*cdf0e10cSrcweir queryCreatableContentsInfo(); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir /******************************************************************************/ 400*cdf0e10cSrcweir /* */ 401*cdf0e10cSrcweir /* mapping of file urls */ 402*cdf0e10cSrcweir /* to uncpath and vice versa */ 403*cdf0e10cSrcweir /* */ 404*cdf0e10cSrcweir /******************************************************************************/ 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir sal_Bool SAL_CALL getUnqFromUrl( const rtl::OUString& Url, rtl::OUString& Unq ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir sal_Bool SAL_CALL getUrlFromUnq( const rtl::OUString& Unq, rtl::OUString& Url ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir sal_Bool m_bWithConfig; 412*cdf0e10cSrcweir FileProvider* m_pProvider; 413*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMultiServiceFactory; 414*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XPropertySetRegistry > m_xFileRegistry; 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir private: 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir /********************************************************************************/ 419*cdf0e10cSrcweir /* get eventListeners */ 420*cdf0e10cSrcweir /********************************************************************************/ 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL 423*cdf0e10cSrcweir getContentEventListeners( const rtl::OUString& aName ); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir std::list< ContentEventNotifier* >* SAL_CALL 426*cdf0e10cSrcweir getContentDeletedEventListeners( const rtl::OUString& aName ); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* SAL_CALL 429*cdf0e10cSrcweir getContentExchangedEventListeners( const rtl::OUString aOldPrefix, 430*cdf0e10cSrcweir const rtl::OUString aNewPrefix, 431*cdf0e10cSrcweir sal_Bool withChilds ); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* SAL_CALL 434*cdf0e10cSrcweir getPropertyChangeNotifier( const rtl::OUString& aName ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* SAL_CALL 437*cdf0e10cSrcweir getPropertySetListeners( const rtl::OUString& aName ); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir /********************************************************************************/ 441*cdf0e10cSrcweir /* notify eventListeners */ 442*cdf0e10cSrcweir /********************************************************************************/ 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir void SAL_CALL notifyPropertyChanges( 445*cdf0e10cSrcweir std::list< PropertyChangeNotifier* >* listeners, 446*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& seqChanged ); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir void SAL_CALL notifyContentExchanged( 449*cdf0e10cSrcweir std::vector< std::list< ContentEventNotifier* >* >* listeners_vec ); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir void SAL_CALL notifyInsert( 452*cdf0e10cSrcweir std::list< ContentEventNotifier* >* listeners,const rtl::OUString& aChildName ); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir void SAL_CALL notifyContentDeleted( 455*cdf0e10cSrcweir std::list< ContentEventNotifier* >* listeners ); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void SAL_CALL notifyContentRemoved( 458*cdf0e10cSrcweir std::list< ContentEventNotifier* >* listeners, 459*cdf0e10cSrcweir const rtl::OUString& aChildName ); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void SAL_CALL notifyPropertyAdded( 462*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* listeners, 463*cdf0e10cSrcweir const rtl::OUString& aPropertyName ); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir void SAL_CALL notifyPropertyRemoved( 466*cdf0e10cSrcweir std::list< PropertySetInfoChangeNotifier* >* listeners, 467*cdf0e10cSrcweir const rtl::OUString& aPropertyName ); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir /********************************************************************************/ 471*cdf0e10cSrcweir /* remove persistent propertyset */ 472*cdf0e10cSrcweir /********************************************************************************/ 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir void SAL_CALL erasePersistentSet( const rtl::OUString& aUnqPath, 475*cdf0e10cSrcweir sal_Bool withChilds = false ); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir /********************************************************************************/ 478*cdf0e10cSrcweir /* copy persistent propertyset */ 479*cdf0e10cSrcweir /* from srcUnqPath to dstUnqPath */ 480*cdf0e10cSrcweir /********************************************************************************/ 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir void SAL_CALL copyPersistentSet( const rtl::OUString& srcUnqPath, 483*cdf0e10cSrcweir const rtl::OUString& dstUnqPath, 484*cdf0e10cSrcweir sal_Bool withChilds = false ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir // Special optimized method for getting the properties of a directoryitem, which 488*cdf0e10cSrcweir // is returned by osl::DirectoryItem::getNextItem() 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > SAL_CALL 491*cdf0e10cSrcweir getv( Notifier* pNotifier, 492*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& properties, 493*cdf0e10cSrcweir osl::DirectoryItem& DirItem, 494*cdf0e10cSrcweir rtl::OUString& aUnqPath, 495*cdf0e10cSrcweir sal_Bool& bIsRegular ); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir /** 499*cdf0e10cSrcweir * Load the properties from configuration, if create == true create them. 500*cdf0e10cSrcweir * The Properties are stored under the url belonging to it->first. 501*cdf0e10cSrcweir */ 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir void SAL_CALL load( const shell::ContentMap::iterator& it, 504*cdf0e10cSrcweir sal_Bool create ); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir /** 507*cdf0e10cSrcweir * Commit inserts the determined properties in the filestatus object into 508*cdf0e10cSrcweir * the internal map, so that is possible to determine on a subsequent 509*cdf0e10cSrcweir * setting of file properties which properties have changed without filestat 510*cdf0e10cSrcweir */ 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir void SAL_CALL 513*cdf0e10cSrcweir commit( 514*cdf0e10cSrcweir const shell::ContentMap::iterator& it, 515*cdf0e10cSrcweir const osl::FileStatus& aFileStatus ); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir /** 518*cdf0e10cSrcweir * Given a Sequence of properties seq, this method determines the mask 519*cdf0e10cSrcweir * used to instantiate a osl::FileStatus, so that a call to 520*cdf0e10cSrcweir * osl::DirectoryItem::getFileStatus fills the required fields. 521*cdf0e10cSrcweir */ 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir void SAL_CALL 524*cdf0e10cSrcweir getMaskFromProperties( 525*cdf0e10cSrcweir sal_Int32& n_Mask, 526*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& seq ); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir void SAL_CALL 530*cdf0e10cSrcweir setFileProperties( 531*cdf0e10cSrcweir const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& values, 532*cdf0e10cSrcweir sal_Int32 numberOfValues ) 533*cdf0e10cSrcweir throw(); 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir // Helper function for public copy 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir osl::FileBase::RC SAL_CALL 539*cdf0e10cSrcweir copy_recursive( 540*cdf0e10cSrcweir const rtl::OUString& srcUnqPath, 541*cdf0e10cSrcweir const rtl::OUString& dstUnqPath, 542*cdf0e10cSrcweir sal_Int32 TypeToCopy, 543*cdf0e10cSrcweir sal_Bool testExistence ) 544*cdf0e10cSrcweir throw(); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir // Helper function for mkfil,mkdir and write 548*cdf0e10cSrcweir // Creates whole path 549*cdf0e10cSrcweir // returns success of the operation 550*cdf0e10cSrcweir // The calle determines the errorCode, which should be used to install 551*cdf0e10cSrcweir // any error 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir sal_Bool SAL_CALL 554*cdf0e10cSrcweir ensuredir( sal_Int32 CommandId, 555*cdf0e10cSrcweir const rtl::OUString& aDirectoryName, 556*cdf0e10cSrcweir sal_Int32 errorCode ) 557*cdf0e10cSrcweir throw(); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir // General 560*cdf0e10cSrcweir osl::Mutex m_aMutex; 561*cdf0e10cSrcweir ContentMap m_aContent; 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir // Default properties 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir const rtl::OUString Title; 566*cdf0e10cSrcweir const rtl::OUString CasePreservingURL; 567*cdf0e10cSrcweir const rtl::OUString IsDocument; 568*cdf0e10cSrcweir const rtl::OUString IsFolder; 569*cdf0e10cSrcweir const rtl::OUString DateModified; 570*cdf0e10cSrcweir const rtl::OUString Size; 571*cdf0e10cSrcweir const rtl::OUString IsVolume; 572*cdf0e10cSrcweir const rtl::OUString IsRemoveable; 573*cdf0e10cSrcweir const rtl::OUString IsRemote; 574*cdf0e10cSrcweir const rtl::OUString IsCompactDisc; 575*cdf0e10cSrcweir const rtl::OUString IsFloppy; 576*cdf0e10cSrcweir const rtl::OUString IsHidden; 577*cdf0e10cSrcweir const rtl::OUString ContentType; 578*cdf0e10cSrcweir const rtl::OUString IsReadOnly; 579*cdf0e10cSrcweir const rtl::OUString CreatableContentsInfo; 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir public: 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir const rtl::OUString FolderContentType; 584*cdf0e10cSrcweir const rtl::OUString FileContentType; 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir private: 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir PropertySet m_aDefaultProperties; 590*cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo > m_sCommandInfo; 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir public: 593*cdf0e10cSrcweir // Misceancellous: 594*cdf0e10cSrcweir // Methods for "writeComponentInfo" and "createComponentFactory" 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir static void SAL_CALL getScheme( rtl::OUString& Scheme ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir static rtl::OUString SAL_CALL getImplementationName_static( void ); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir static com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames_static( void ); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir }; // end class shell 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir } // end namespace fileaccess 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir #endif 607*cdf0e10cSrcweir 608