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