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 <rtl/uri.hxx>
30 : : #include <rtl/ustrbuf.hxx>
31 : : #include <osl/file.hxx>
32 : :
33 : : #include "osl/diagnose.h"
34 : : #include <com/sun/star/ucb/OpenMode.hpp>
35 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
36 : : #include <com/sun/star/ucb/XProgressHandler.hpp>
37 : : #include <com/sun/star/task/XInteractionHandler.hpp>
38 : : #include <com/sun/star/io/XActiveDataStreamer.hpp>
39 : : #include <com/sun/star/io/XOutputStream.hpp>
40 : : #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
41 : : #include <com/sun/star/io/XActiveDataSink.hpp>
42 : : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
43 : : #include <com/sun/star/beans/PropertySetInfoChange.hpp>
44 : : #include <com/sun/star/ucb/ContentAction.hpp>
45 : : #include <com/sun/star/ucb/NameClash.hpp>
46 : : #include "filglob.hxx"
47 : : #include "filid.hxx"
48 : : #include "filrow.hxx"
49 : : #include "bc.hxx"
50 : : #include "prov.hxx"
51 : : #include "filerror.hxx"
52 : : #include "filinsreq.hxx"
53 : :
54 : :
55 : : using namespace fileaccess;
56 : : using namespace com::sun::star;
57 : : using namespace com::sun::star::uno;
58 : : using namespace com::sun::star::ucb;
59 : :
60 : : // PropertyListeners
61 : :
62 : :
63 : : typedef cppu::OMultiTypeInterfaceContainerHelperVar< rtl::OUString,hashOUString,equalOUString >
64 : : PropertyListeners_impl;
65 : :
66 : 11864 : class fileaccess::PropertyListeners
67 : : : public PropertyListeners_impl
68 : : {
69 : : public:
70 : 11864 : PropertyListeners( ::osl::Mutex& aMutex )
71 : 11864 : : PropertyListeners_impl( aMutex )
72 : : {
73 : 11864 : }
74 : : };
75 : :
76 : :
77 : : /****************************************************************************************/
78 : : /* */
79 : : /* BaseContent */
80 : : /* */
81 : : /****************************************************************************************/
82 : :
83 : : ////////////////////////////////////////////////////////////////////////////////
84 : : // Private Constructor for just inserted Contents
85 : :
86 : 2313 : BaseContent::BaseContent( shell* pMyShell,
87 : : const rtl::OUString& parentName,
88 : : sal_Bool bFolder )
89 : : : m_pMyShell( pMyShell ),
90 : : m_xContentIdentifier( 0 ),
91 : : m_aUncPath( parentName ),
92 : : m_bFolder( bFolder ),
93 : : m_nState( JustInserted ),
94 : : m_pDisposeEventListeners( 0 ),
95 : : m_pContentEventListeners( 0 ),
96 : : m_pPropertySetInfoChangeListeners( 0 ),
97 [ + - ][ + - ]: 2313 : m_pPropertyListener( 0 )
[ + - ]
98 : : {
99 : 2313 : m_pMyShell->m_pProvider->acquire();
100 : : // No registering, since we have no name
101 : 2313 : }
102 : :
103 : :
104 : : ////////////////////////////////////////////////////////////////////////////////
105 : : // Constructor for full featured Contents
106 : :
107 : 93404 : BaseContent::BaseContent( shell* pMyShell,
108 : : const Reference< XContentIdentifier >& xContentIdentifier,
109 : : const rtl::OUString& aUncPath )
110 : : : m_pMyShell( pMyShell ),
111 : : m_xContentIdentifier( xContentIdentifier ),
112 : : m_aUncPath( aUncPath ),
113 : : m_bFolder( false ),
114 : : m_nState( FullFeatured ),
115 : : m_pDisposeEventListeners( 0 ),
116 : : m_pContentEventListeners( 0 ),
117 : : m_pPropertySetInfoChangeListeners( 0 ),
118 [ + - ][ + - ]: 93404 : m_pPropertyListener( 0 )
119 : : {
120 : 93404 : m_pMyShell->m_pProvider->acquire();
121 [ + - ]: 93404 : m_pMyShell->registerNotifier( m_aUncPath,this );
122 [ + - ]: 93404 : m_pMyShell->insertDefaultProperties( m_aUncPath );
123 : 93404 : }
124 : :
125 : :
126 [ + - ][ + - ]: 95488 : BaseContent::~BaseContent( )
127 : : {
128 [ + + ][ - + ]: 95488 : if( ( m_nState & FullFeatured ) || ( m_nState & Deleted ) )
129 : : {
130 [ + - ]: 95413 : m_pMyShell->deregisterNotifier( m_aUncPath,this );
131 : : }
132 : 95488 : m_pMyShell->m_pProvider->release();
133 : :
134 [ # # ][ - + ]: 95488 : delete m_pDisposeEventListeners;
135 [ + + ][ + - ]: 95488 : delete m_pContentEventListeners;
136 [ + + ][ + - ]: 95488 : delete m_pPropertyListener;
137 [ - + ][ # # ]: 95488 : delete m_pPropertySetInfoChangeListeners;
138 [ - + ]: 190976 : }
139 : :
140 : :
141 : : //////////////////////////////////////////////////////////////////////////
142 : : // XInterface
143 : : //////////////////////////////////////////////////////////////////////////
144 : :
145 : : void SAL_CALL
146 : 1337556 : BaseContent::acquire( void )
147 : : throw()
148 : : {
149 : 1337556 : OWeakObject::acquire();
150 : 1337556 : }
151 : :
152 : :
153 : : void SAL_CALL
154 : 1337073 : BaseContent::release( void )
155 : : throw()
156 : : {
157 : 1337073 : OWeakObject::release();
158 : 1337073 : }
159 : :
160 : :
161 : : Any SAL_CALL
162 : 118807 : BaseContent::queryInterface( const Type& rType )
163 : : throw( RuntimeException )
164 : : {
165 : : Any aRet = cppu::queryInterface( rType,
166 : : (static_cast< lang::XComponent* >(this)),
167 : : (static_cast< lang::XTypeProvider* >(this)),
168 : : (static_cast< lang::XServiceInfo* >(this)),
169 : : (static_cast< XCommandProcessor* >(this)),
170 : : (static_cast< container::XChild* >(this)),
171 : : (static_cast< beans::XPropertiesChangeNotifier* >(this)),
172 : : (static_cast< beans::XPropertyContainer* >(this)),
173 : : (static_cast< XContentCreator* >(this)),
174 : : (static_cast< beans::XPropertySetInfoChangeNotifier* >(this)),
175 [ + - ]: 118807 : (static_cast< XContent* >(this)) );
176 [ + + ][ + - ]: 118807 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
177 : : }
178 : :
179 : :
180 : :
181 : :
182 : : //////////////////////////////////////////////////////////////////////////////////////////
183 : : // XComponent
184 : : ////////////////////////////////////////////////////////////////////////////////////////
185 : :
186 : : void SAL_CALL
187 : 0 : BaseContent::addEventListener( const Reference< lang::XEventListener >& Listener )
188 : : throw( RuntimeException )
189 : : {
190 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
191 : :
192 [ # # ]: 0 : if ( ! m_pDisposeEventListeners )
193 : : m_pDisposeEventListeners =
194 [ # # ]: 0 : new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
195 : :
196 [ # # ][ # # ]: 0 : m_pDisposeEventListeners->addInterface( Listener );
197 : 0 : }
198 : :
199 : :
200 : : void SAL_CALL
201 : 0 : BaseContent::removeEventListener( const Reference< lang::XEventListener >& Listener )
202 : : throw( RuntimeException )
203 : : {
204 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
205 : :
206 [ # # ]: 0 : if ( m_pDisposeEventListeners )
207 [ # # ][ # # ]: 0 : m_pDisposeEventListeners->removeInterface( Listener );
208 : 0 : }
209 : :
210 : :
211 : : void SAL_CALL
212 : 0 : BaseContent::dispose()
213 : : throw( RuntimeException )
214 : : {
215 [ # # ]: 0 : lang::EventObject aEvt;
216 : : cppu::OInterfaceContainerHelper* pDisposeEventListeners;
217 : : cppu::OInterfaceContainerHelper* pContentEventListeners;
218 : : cppu::OInterfaceContainerHelper* pPropertySetInfoChangeListeners;
219 : : PropertyListeners* pPropertyListener;
220 : :
221 : : {
222 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
223 [ # # ]: 0 : aEvt.Source = static_cast< XContent* >( this );
224 : :
225 : :
226 : : pDisposeEventListeners =
227 : 0 : m_pDisposeEventListeners, m_pDisposeEventListeners = 0;
228 : :
229 : : pContentEventListeners =
230 : 0 : m_pContentEventListeners, m_pContentEventListeners = 0;
231 : :
232 : : pPropertySetInfoChangeListeners =
233 : : m_pPropertySetInfoChangeListeners,
234 : 0 : m_pPropertySetInfoChangeListeners = 0;
235 : :
236 : : pPropertyListener =
237 [ # # ]: 0 : m_pPropertyListener, m_pPropertyListener = 0;
238 : : }
239 : :
240 [ # # ][ # # ]: 0 : if ( pDisposeEventListeners && pDisposeEventListeners->getLength() )
[ # # ][ # # ]
241 [ # # ]: 0 : pDisposeEventListeners->disposeAndClear( aEvt );
242 : :
243 [ # # ][ # # ]: 0 : if ( pContentEventListeners && pContentEventListeners->getLength() )
[ # # ][ # # ]
244 [ # # ]: 0 : pContentEventListeners->disposeAndClear( aEvt );
245 : :
246 [ # # ]: 0 : if( pPropertyListener )
247 [ # # ]: 0 : pPropertyListener->disposeAndClear( aEvt );
248 : :
249 [ # # ]: 0 : if( pPropertySetInfoChangeListeners )
250 [ # # ]: 0 : pPropertySetInfoChangeListeners->disposeAndClear( aEvt );
251 : :
252 [ # # ][ # # ]: 0 : delete pDisposeEventListeners;
253 [ # # ][ # # ]: 0 : delete pContentEventListeners;
254 [ # # ][ # # ]: 0 : delete pPropertyListener;
255 [ # # ][ # # ]: 0 : delete pPropertySetInfoChangeListeners;
[ # # ]
256 : 0 : }
257 : :
258 : :
259 : :
260 : : //////////////////////////////////////////////////////////////////////////////////////////
261 : : // XServiceInfo
262 : : //////////////////////////////////////////////////////////////////////////////////////////
263 : :
264 : : rtl::OUString SAL_CALL
265 : 0 : BaseContent::getImplementationName()
266 : : throw( RuntimeException)
267 : : {
268 : 0 : return rtl::OUString("com.sun.star.comp.ucb.FileContent");
269 : : }
270 : :
271 : :
272 : :
273 : : sal_Bool SAL_CALL
274 : 0 : BaseContent::supportsService( const rtl::OUString& ServiceName )
275 : : throw( RuntimeException)
276 : : {
277 [ # # ]: 0 : if ( ServiceName == "com.sun.star.ucb.FileContent" )
278 : 0 : return true;
279 : : else
280 : 0 : return false;
281 : : }
282 : :
283 : :
284 : :
285 : : Sequence< rtl::OUString > SAL_CALL
286 : 0 : BaseContent::getSupportedServiceNames()
287 : : throw( RuntimeException )
288 : : {
289 : 0 : Sequence< rtl::OUString > ret( 1 );
290 [ # # ]: 0 : ret[0] = rtl::OUString("com.sun.star.ucb.FileContent");
291 : 0 : return ret;
292 : : }
293 : :
294 : :
295 : :
296 : : //////////////////////////////////////////////////////////////////////////////////////////
297 : : // XTypeProvider
298 : : //////////////////////////////////////////////////////////////////////////////////////////
299 : :
300 [ # # ][ # # ]: 0 : XTYPEPROVIDER_IMPL_10( BaseContent,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
301 : : lang::XComponent,
302 : : lang::XTypeProvider,
303 : : lang::XServiceInfo,
304 : : XCommandProcessor,
305 : : XContentCreator,
306 : : XContent,
307 : : container::XChild,
308 : : beans::XPropertiesChangeNotifier,
309 : : beans::XPropertyContainer,
310 : : beans::XPropertySetInfoChangeNotifier )
311 : :
312 : :
313 : : //////////////////////////////////////////////////////////////////////////////////////////
314 : : // XCommandProcessor
315 : : //////////////////////////////////////////////////////////////////////////////////////////
316 : :
317 : : sal_Int32 SAL_CALL
318 : 86190 : BaseContent::createCommandIdentifier( void )
319 : : throw( RuntimeException )
320 : : {
321 : 86190 : return m_pMyShell->getCommandId();
322 : : }
323 : :
324 : :
325 : : void SAL_CALL
326 : 0 : BaseContent::abort( sal_Int32 CommandId )
327 : : throw( RuntimeException )
328 : : {
329 : 0 : m_pMyShell->abort( CommandId );
330 : 0 : }
331 : :
332 : :
333 : : Any SAL_CALL
334 : 142277 : BaseContent::execute( const Command& aCommand,
335 : : sal_Int32 CommandId,
336 : : const Reference< XCommandEnvironment >& Environment )
337 : : throw( Exception,
338 : : CommandAbortedException,
339 : : RuntimeException )
340 : : {
341 [ + + ]: 142277 : if( ! CommandId )
342 : : // A Command with commandid zero cannot be aborted
343 : 1696 : CommandId = createCommandIdentifier();
344 : :
345 : : m_pMyShell->startTask( CommandId,
346 : 142277 : Environment );
347 : :
348 : 142277 : Any aAny;
349 : :
350 [ + + ]: 142277 : if (aCommand.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("getPropertySetInfo"))) // No exceptions
351 : : {
352 [ + - ][ + - ]: 2589 : aAny <<= getPropertySetInfo( CommandId );
353 : : }
354 [ + + ]: 139688 : else if (aCommand.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("getCommandInfo"))) // no exceptions
355 : : {
356 [ + - ][ + - ]: 16 : aAny <<= getCommandInfo();
357 : : }
358 [ + + ]: 139672 : else if ( aCommand.Name == "setPropertyValues" )
359 : : {
360 [ + - ]: 2617 : Sequence< beans::PropertyValue > sPropertyValues;
361 : :
362 [ + - ][ - + ]: 2617 : if( ! ( aCommand.Argument >>= sPropertyValues ) )
363 : : m_pMyShell->installError( CommandId,
364 [ # # ]: 0 : TASKHANDLING_WRONG_SETPROPERTYVALUES_ARGUMENT );
365 : : else
366 [ + - ][ + - ]: 2617 : aAny <<= setPropertyValues( CommandId,sPropertyValues ); // calls endTask by itself
[ + - ]
367 : : }
368 [ + + ]: 137055 : else if ( aCommand.Name == "getPropertyValues" )
369 : : {
370 [ + - ]: 66102 : Sequence< beans::Property > ListOfRequestedProperties;
371 : :
372 [ + - ][ - + ]: 66102 : if( ! ( aCommand.Argument >>= ListOfRequestedProperties ) )
373 : : m_pMyShell->installError( CommandId,
374 [ # # ]: 0 : TASKHANDLING_WRONG_GETPROPERTYVALUES_ARGUMENT );
375 : : else
376 : : aAny <<= getPropertyValues( CommandId,
377 [ + - ][ + - ]: 66102 : ListOfRequestedProperties );
[ + - ]
378 : : }
379 [ + + ]: 70953 : else if ( aCommand.Name == "open" )
380 : : {
381 [ + - ]: 55065 : OpenCommandArgument2 aOpenArgument;
382 [ + - ][ - + ]: 55065 : if( ! ( aCommand.Argument >>= aOpenArgument ) )
383 : : m_pMyShell->installError( CommandId,
384 [ # # ]: 0 : TASKHANDLING_WRONG_OPEN_ARGUMENT );
385 : : else
386 : : {
387 : 55065 : Reference< XDynamicResultSet > result = open( CommandId,aOpenArgument );
388 [ + + ]: 55065 : if( result.is() )
389 [ + - ]: 55065 : aAny <<= result;
390 [ + - ]: 55065 : }
391 : : }
392 [ + + ]: 15888 : else if ( aCommand.Name == "delete" )
393 : : {
394 [ + - ][ - + ]: 646 : if( ! aCommand.Argument.has< sal_Bool >() )
395 : : m_pMyShell->installError( CommandId,
396 [ # # ]: 0 : TASKHANDLING_WRONG_DELETE_ARGUMENT );
397 : : else
398 : 646 : deleteContent( CommandId );
399 : : }
400 [ + + ]: 15242 : else if ( aCommand.Name == "transfer" )
401 : : {
402 : 1186 : TransferInfo aTransferInfo;
403 [ - + ][ + - ]: 1186 : if( ! ( aCommand.Argument >>= aTransferInfo ) )
404 : : m_pMyShell->installError( CommandId,
405 [ # # ]: 0 : TASKHANDLING_WRONG_TRANSFER_ARGUMENT );
406 : : else
407 : 1186 : transfer( CommandId, aTransferInfo );
408 : : }
409 [ + + ]: 14056 : else if ( aCommand.Name == "insert" )
410 : : {
411 [ + - ]: 11743 : InsertCommandArgument aInsertArgument;
412 [ + - ][ - + ]: 11743 : if( ! ( aCommand.Argument >>= aInsertArgument ) )
413 : : m_pMyShell->installError( CommandId,
414 [ # # ]: 0 : TASKHANDLING_WRONG_INSERT_ARGUMENT );
415 : : else
416 [ + - ]: 11743 : insert( CommandId,aInsertArgument );
417 : : }
418 [ - + ]: 2313 : else if ( aCommand.Name == "getCasePreservingURL" )
419 : : {
420 [ # # ]: 0 : Sequence< beans::Property > seq(1);
421 [ # # ]: 0 : seq[0] = beans::Property(
422 : : rtl::OUString("CasePreservingURL"),
423 : : -1,
424 [ # # ]: 0 : getCppuType( static_cast< sal_Bool* >(0) ),
425 : 0 : 0 );
426 [ # # ]: 0 : Reference< sdbc::XRow > xRow = getPropertyValues( CommandId,seq );
427 [ # # ][ # # ]: 0 : rtl::OUString CasePreservingURL = xRow->getString(1);
428 [ # # ][ # # ]: 0 : if(!xRow->wasNull())
[ # # ]
429 [ # # ][ # # ]: 0 : aAny <<= CasePreservingURL;
430 : : }
431 [ + - ]: 2313 : else if ( aCommand.Name == "createNewContent" )
432 : : {
433 [ + - ]: 2313 : ucb::ContentInfo aArg;
434 [ + - ][ - + ]: 2313 : if ( !( aCommand.Argument >>= aArg ) )
435 : : m_pMyShell->installError( CommandId,
436 [ # # ]: 0 : TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT );
437 : : else
438 [ + - ][ + - ]: 2313 : aAny <<= createNewContent( aArg );
[ + - ]
439 : : }
440 : : else
441 : : m_pMyShell->installError( CommandId,
442 [ # # ]: 0 : TASKHANDLER_UNSUPPORTED_COMMAND );
443 : :
444 : :
445 : : // This is the only function allowed to throw an exception
446 [ + + ]: 142277 : endTask( CommandId );
447 : :
448 : 142277 : return aAny;
449 : : }
450 : :
451 : :
452 : :
453 : : void SAL_CALL
454 : 11864 : BaseContent::addPropertiesChangeListener(
455 : : const Sequence< rtl::OUString >& PropertyNames,
456 : : const Reference< beans::XPropertiesChangeListener >& Listener )
457 : : throw( RuntimeException )
458 : : {
459 [ + - ]: 11864 : if( ! Listener.is() )
460 : 11864 : return;
461 : :
462 [ + - ]: 11864 : osl::MutexGuard aGuard( m_aMutex );
463 : :
464 [ + - ]: 11864 : if( ! m_pPropertyListener )
465 [ + - ]: 11864 : m_pPropertyListener = new PropertyListeners( m_aEventListenerMutex );
466 : :
467 : :
468 [ + - ]: 11864 : if( PropertyNames.getLength() == 0 )
469 [ + - ]: 11864 : m_pPropertyListener->addInterface( rtl::OUString(),Listener );
470 : : else
471 : : {
472 : 0 : Reference< beans::XPropertySetInfo > xProp = m_pMyShell->info_p( m_aUncPath );
473 [ # # ]: 0 : for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i )
474 [ # # ][ # # ]: 0 : if( xProp->hasPropertyByName( PropertyNames[i] ) )
[ # # ]
475 [ # # ]: 0 : m_pPropertyListener->addInterface( PropertyNames[i],Listener );
476 [ + - ]: 11864 : }
477 : : }
478 : :
479 : :
480 : : void SAL_CALL
481 : 11864 : BaseContent::removePropertiesChangeListener( const Sequence< rtl::OUString >& PropertyNames,
482 : : const Reference< beans::XPropertiesChangeListener >& Listener )
483 : : throw( RuntimeException )
484 : : {
485 [ + - ]: 11864 : if( ! Listener.is() )
486 : : return;
487 : :
488 [ + - ]: 11864 : osl::MutexGuard aGuard( m_aMutex );
489 : :
490 [ - + ]: 11864 : if( ! m_pPropertyListener )
491 : : return;
492 : :
493 [ - + ]: 11864 : for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i )
494 [ # # ]: 0 : m_pPropertyListener->removeInterface( PropertyNames[i],Listener );
495 : :
496 [ + - ][ + - ]: 11864 : m_pPropertyListener->removeInterface( rtl::OUString(), Listener );
[ + - ]
497 : : }
498 : :
499 : :
500 : : /////////////////////////////////////////////////////////////////////////////////////////
501 : : // XContent
502 : : /////////////////////////////////////////////////////////////////////////////////////////
503 : :
504 : : Reference< ucb::XContentIdentifier > SAL_CALL
505 : 30746 : BaseContent::getIdentifier()
506 : : throw( RuntimeException )
507 : : {
508 : 30746 : return m_xContentIdentifier;
509 : : }
510 : :
511 : :
512 : : rtl::OUString SAL_CALL
513 : 0 : BaseContent::getContentType()
514 : : throw( RuntimeException )
515 : : {
516 [ # # ]: 0 : if( !( m_nState & Deleted ) )
517 : : {
518 [ # # ]: 0 : if( m_nState & JustInserted )
519 : : {
520 [ # # ]: 0 : if ( m_bFolder )
521 : 0 : return m_pMyShell->FolderContentType;
522 : : else
523 : 0 : return m_pMyShell->FileContentType;
524 : : }
525 : : else
526 : : {
527 : : try
528 : : {
529 : : // Who am I ?
530 [ # # ]: 0 : Sequence< beans::Property > seq(1);
531 [ # # ]: 0 : seq[0] = beans::Property( rtl::OUString("IsDocument"),
532 : : -1,
533 [ # # ]: 0 : getCppuType( static_cast< sal_Bool* >(0) ),
534 : 0 : 0 );
535 [ # # ]: 0 : Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq );
536 [ # # ][ # # ]: 0 : sal_Bool IsDocument = xRow->getBoolean( 1 );
537 : :
538 [ # # ][ # # ]: 0 : if ( !xRow->wasNull() )
[ # # ]
539 : : {
540 [ # # ]: 0 : if ( IsDocument )
541 : 0 : return m_pMyShell->FileContentType;
542 : : else
543 : 0 : return m_pMyShell->FolderContentType;
544 : : }
545 : : else
546 : : {
547 : : OSL_FAIL( "BaseContent::getContentType - Property value was null!" );
548 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
549 : : }
550 : 0 : catch (const sdbc::SQLException&)
551 : : {
552 : : OSL_FAIL( "BaseContent::getContentType - Caught SQLException!" );
553 : : }
554 : : }
555 : : }
556 : :
557 : 0 : return rtl::OUString();
558 : : }
559 : :
560 : :
561 : :
562 : : void SAL_CALL
563 : 128484 : BaseContent::addContentEventListener(
564 : : const Reference< XContentEventListener >& Listener )
565 : : throw( RuntimeException )
566 : : {
567 [ + - ]: 128484 : osl::MutexGuard aGuard( m_aMutex );
568 : :
569 [ + + ]: 128484 : if ( ! m_pContentEventListeners )
570 : : m_pContentEventListeners =
571 [ + - ]: 90649 : new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
572 : :
573 : :
574 [ + - ][ + - ]: 128484 : m_pContentEventListeners->addInterface( Listener );
575 : 128484 : }
576 : :
577 : :
578 : : void SAL_CALL
579 : 128255 : BaseContent::removeContentEventListener(
580 : : const Reference< XContentEventListener >& Listener )
581 : : throw( RuntimeException )
582 : : {
583 [ + - ]: 128255 : osl::MutexGuard aGuard( m_aMutex );
584 : :
585 [ + - ]: 128255 : if ( m_pContentEventListeners )
586 [ + - ][ + - ]: 128255 : m_pContentEventListeners->removeInterface( Listener );
587 : 128255 : }
588 : :
589 : :
590 : :
591 : : ////////////////////////////////////////////////////////////////////////////////
592 : : // XPropertyContainer
593 : : ////////////////////////////////////////////////////////////////////////////////
594 : :
595 : :
596 : : void SAL_CALL
597 : 0 : BaseContent::addProperty(
598 : : const rtl::OUString& Name,
599 : : sal_Int16 Attributes,
600 : : const Any& DefaultValue )
601 : : throw( beans::PropertyExistException,
602 : : beans::IllegalTypeException,
603 : : lang::IllegalArgumentException,
604 : : RuntimeException)
605 : : {
606 [ # # ][ # # ]: 0 : if( ( m_nState & JustInserted ) || ( m_nState & Deleted ) || Name.isEmpty() )
[ # # ][ # # ]
607 : : {
608 [ # # ]: 0 : throw lang::IllegalArgumentException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), 0 );
609 : : }
610 : :
611 : 0 : m_pMyShell->associate( m_aUncPath,Name,DefaultValue,Attributes );
612 : 0 : }
613 : :
614 : :
615 : : void SAL_CALL
616 : 0 : BaseContent::removeProperty(
617 : : const rtl::OUString& Name )
618 : : throw( beans::UnknownPropertyException,
619 : : beans::NotRemoveableException,
620 : : RuntimeException)
621 : : {
622 : :
623 [ # # ]: 0 : if( m_nState & Deleted )
624 [ # # ]: 0 : throw beans::UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
625 : :
626 : 0 : m_pMyShell->deassociate( m_aUncPath, Name );
627 : 0 : }
628 : :
629 : : ////////////////////////////////////////////////////////////////////////////////
630 : : // XContentCreator
631 : : ////////////////////////////////////////////////////////////////////////////////
632 : :
633 : : Sequence< ContentInfo > SAL_CALL
634 : 0 : BaseContent::queryCreatableContentsInfo(
635 : : void )
636 : : throw( RuntimeException )
637 : : {
638 : 0 : return m_pMyShell->queryCreatableContentsInfo();
639 : : }
640 : :
641 : :
642 : : Reference< XContent > SAL_CALL
643 : 2313 : BaseContent::createNewContent(
644 : : const ContentInfo& Info )
645 : : throw( RuntimeException )
646 : : {
647 : : // Check type.
648 [ - + ]: 2313 : if ( Info.Type.isEmpty() )
649 : 0 : return Reference< XContent >();
650 : :
651 : : sal_Bool bFolder
652 : 2313 : = ( Info.Type.compareTo( m_pMyShell->FolderContentType ) == 0 );
653 [ + + ]: 2313 : if ( !bFolder )
654 : : {
655 [ - + ]: 8 : if ( Info.Type.compareTo( m_pMyShell->FileContentType ) != 0 )
656 : : {
657 : : // Neither folder nor file to create!
658 : 0 : return Reference< XContent >();
659 : : }
660 : : }
661 : :
662 : : // Who am I ?
663 : 2313 : sal_Bool IsDocument = false;
664 : :
665 : : try
666 : : {
667 [ + - ]: 2313 : Sequence< beans::Property > seq(1);
668 [ + - ]: 2313 : seq[0] = beans::Property( rtl::OUString("IsDocument"),
669 : : -1,
670 [ + - ]: 2313 : getCppuType( static_cast< sal_Bool* >(0) ),
671 : 4626 : 0 );
672 [ + - ]: 2313 : Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq );
673 [ + - ][ + - ]: 2313 : IsDocument = xRow->getBoolean( 1 );
674 : :
675 [ + - ][ + - ]: 2313 : if ( xRow->wasNull() )
[ - + ]
676 : : {
677 : 0 : IsDocument = false;
678 : : // OSL_FAIL( // "BaseContent::createNewContent - Property value was null!" );
679 : : // return Reference< XContent >();
680 [ + - # # ]: 2313 : }
681 : : }
682 [ # # ]: 0 : catch (const sdbc::SQLException&)
683 : : {
684 : : OSL_FAIL( "BaseContent::createNewContent - Caught SQLException!" );
685 : 0 : return Reference< XContent >();
686 : : }
687 : :
688 : 2313 : rtl::OUString dstUncPath;
689 : :
690 [ - + ]: 2313 : if( IsDocument )
691 : : {
692 : : // KSO: Why is a document a XContentCreator? This is quite unusual.
693 [ # # ]: 0 : dstUncPath = getParentName( m_aUncPath );
694 : : }
695 : : else
696 : 2313 : dstUncPath = m_aUncPath;
697 : :
698 [ + - ]: 2313 : BaseContent* p = new BaseContent( m_pMyShell, dstUncPath, bFolder );
699 [ + - ][ + - ]: 2313 : return Reference< XContent >( p );
700 : : }
701 : :
702 : :
703 : : ////////////////////////////////////////////////////////////////////////////////
704 : : // XPropertySetInfoChangeNotifier
705 : : ////////////////////////////////////////////////////////////////////////////////
706 : :
707 : :
708 : : void SAL_CALL
709 : 0 : BaseContent::addPropertySetInfoChangeListener(
710 : : const Reference< beans::XPropertySetInfoChangeListener >& Listener )
711 : : throw( RuntimeException )
712 : : {
713 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
714 [ # # ]: 0 : if( ! m_pPropertySetInfoChangeListeners )
715 [ # # ]: 0 : m_pPropertySetInfoChangeListeners = new cppu::OInterfaceContainerHelper( m_aEventListenerMutex );
716 : :
717 [ # # ][ # # ]: 0 : m_pPropertySetInfoChangeListeners->addInterface( Listener );
718 : 0 : }
719 : :
720 : :
721 : : void SAL_CALL
722 : 0 : BaseContent::removePropertySetInfoChangeListener(
723 : : const Reference< beans::XPropertySetInfoChangeListener >& Listener )
724 : : throw( RuntimeException )
725 : : {
726 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
727 : :
728 [ # # ]: 0 : if( m_pPropertySetInfoChangeListeners )
729 [ # # ][ # # ]: 0 : m_pPropertySetInfoChangeListeners->removeInterface( Listener );
730 : 0 : }
731 : :
732 : :
733 : : ////////////////////////////////////////////////////////////////////////////////
734 : : // XChild
735 : : ////////////////////////////////////////////////////////////////////////////////
736 : :
737 : : Reference< XInterface > SAL_CALL
738 : 0 : BaseContent::getParent(
739 : : void )
740 : : throw( RuntimeException )
741 : : {
742 [ # # ]: 0 : rtl::OUString ParentUnq = getParentName( m_aUncPath );
743 : 0 : rtl::OUString ParentUrl;
744 : :
745 : :
746 [ # # ]: 0 : sal_Bool err = m_pMyShell->getUrlFromUnq( ParentUnq, ParentUrl );
747 [ # # ]: 0 : if( err )
748 [ # # ]: 0 : return Reference< XInterface >( 0 );
749 : :
750 [ # # ]: 0 : FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,ParentUnq );
751 [ # # ][ # # ]: 0 : Reference< XContentIdentifier > Identifier( p );
752 : :
753 : : try
754 : : {
755 [ # # ]: 0 : Reference< XContent > content = m_pMyShell->m_pProvider->queryContent( Identifier );
756 [ # # ][ # # ]: 0 : return Reference<XInterface>(content,UNO_QUERY);
757 : : }
758 [ # # ]: 0 : catch (const IllegalIdentifierException&)
759 : : {
760 : 0 : return Reference< XInterface >();
761 : 0 : }
762 : : }
763 : :
764 : :
765 : : void SAL_CALL
766 : 0 : BaseContent::setParent(
767 : : const Reference< XInterface >& )
768 : : throw( lang::NoSupportException,
769 : : RuntimeException)
770 : : {
771 [ # # ]: 0 : throw lang::NoSupportException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
772 : : }
773 : :
774 : :
775 : : //////////////////////////////////////////////////////////////////////////////////////////
776 : : // Private Methods
777 : : //////////////////////////////////////////////////////////////////////////////////////////
778 : :
779 : :
780 : : Reference< XCommandInfo > SAL_CALL
781 : 16 : BaseContent::getCommandInfo()
782 : : throw( RuntimeException )
783 : : {
784 [ - + ]: 16 : if( m_nState & Deleted )
785 : 0 : return Reference< XCommandInfo >();
786 : :
787 : 16 : return m_pMyShell->info_c();
788 : : }
789 : :
790 : :
791 : : Reference< beans::XPropertySetInfo > SAL_CALL
792 : 2589 : BaseContent::getPropertySetInfo(
793 : : sal_Int32 )
794 : : throw( RuntimeException )
795 : : {
796 [ - + ]: 2589 : if( m_nState & Deleted )
797 : 0 : return Reference< beans::XPropertySetInfo >();
798 : :
799 : 2589 : return m_pMyShell->info_p( m_aUncPath );
800 : : }
801 : :
802 : :
803 : :
804 : :
805 : : Reference< sdbc::XRow > SAL_CALL
806 : 71910 : BaseContent::getPropertyValues(
807 : : sal_Int32 nMyCommandIdentifier,
808 : : const Sequence< beans::Property >& PropertySet )
809 : : throw( RuntimeException )
810 : : {
811 : 71910 : sal_Int32 nProps = PropertySet.getLength();
812 [ - + ]: 71910 : if ( !nProps )
813 : 0 : return Reference< sdbc::XRow >();
814 : :
815 [ - + ]: 71910 : if( m_nState & Deleted )
816 : : {
817 [ # # ]: 0 : Sequence< Any > aValues( nProps );
818 [ # # ][ # # ]: 0 : return Reference< sdbc::XRow >( new XRow_impl( m_pMyShell, aValues ) );
[ # # ][ # # ]
819 : : }
820 : :
821 [ + + ]: 71910 : if( m_nState & JustInserted )
822 : : {
823 [ + - ]: 2313 : Sequence< Any > aValues( nProps );
824 [ + - ]: 2313 : Any* pValues = aValues.getArray();
825 : :
826 : 2313 : const beans::Property* pProps = PropertySet.getConstArray();
827 : :
828 [ + + ]: 4626 : for ( sal_Int32 n = 0; n < nProps; ++n )
829 : : {
830 : 2313 : const beans::Property& rProp = pProps[ n ];
831 : 2313 : Any& rValue = pValues[ n ];
832 : :
833 [ - + ]: 2313 : if ( rProp.Name == "ContentType" )
834 : : {
835 : : rValue <<= m_bFolder ? m_pMyShell->FolderContentType
836 [ # # ][ # # ]: 0 : : m_pMyShell->FileContentType;
837 : : }
838 [ - + ]: 2313 : else if ( rProp.Name == "IsFolder" )
839 : : {
840 [ # # ]: 0 : rValue <<= m_bFolder;
841 : : }
842 [ + - ]: 2313 : else if ( rProp.Name == "IsDocument" )
843 : : {
844 [ + - ]: 2313 : rValue <<= sal_Bool( !m_bFolder );
845 : : }
846 : : }
847 : :
848 : : return Reference< sdbc::XRow >(
849 [ + - ][ + - ]: 2313 : new XRow_impl( m_pMyShell, aValues ) );
[ + - ][ + - ]
850 : : }
851 : :
852 : : return m_pMyShell->getv( nMyCommandIdentifier,
853 : : m_aUncPath,
854 : 71910 : PropertySet );
855 : : }
856 : :
857 : :
858 : : Sequence< Any > SAL_CALL
859 : 2617 : BaseContent::setPropertyValues(
860 : : sal_Int32 nMyCommandIdentifier,
861 : : const Sequence< beans::PropertyValue >& Values )
862 : : throw()
863 : : {
864 [ - + ]: 2617 : if( m_nState & Deleted )
865 : : { // To do
866 [ # # ]: 0 : return Sequence< Any >( Values.getLength() );
867 : : }
868 : :
869 : 2617 : const rtl::OUString Title("Title");
870 : :
871 : : // Special handling for files which have to be inserted
872 [ + + ]: 2617 : if( m_nState & JustInserted )
873 : : {
874 [ + + ]: 4734 : for( sal_Int32 i = 0; i < Values.getLength(); ++i )
875 : : {
876 [ + + ]: 2421 : if( Values[i].Name == Title )
877 : : {
878 : 2313 : rtl::OUString NewTitle;
879 [ + - ]: 2313 : if( Values[i].Value >>= NewTitle )
880 : : {
881 [ - + ]: 2313 : if ( m_nState & NameForInsertionSet )
882 : : {
883 : : // User wants to set another Title before "insert".
884 : : // m_aUncPath contains previous own URI.
885 : :
886 : 0 : sal_Int32 nLastSlash = m_aUncPath.lastIndexOf( '/' );
887 : 0 : bool bTrailingSlash = false;
888 [ # # ]: 0 : if ( nLastSlash == m_aUncPath.getLength() - 1 )
889 : : {
890 : 0 : bTrailingSlash = true;
891 : : nLastSlash
892 : 0 : = m_aUncPath.lastIndexOf( '/', nLastSlash );
893 : : }
894 : :
895 : : OSL_ENSURE( nLastSlash != -1,
896 : : "BaseContent::setPropertyValues: "
897 : : "Invalid URL!" );
898 : :
899 : : rtl::OUStringBuffer aBuf(
900 [ # # ]: 0 : m_aUncPath.copy( 0, nLastSlash + 1 ) );
901 : :
902 [ # # ]: 0 : if ( !NewTitle.isEmpty() )
903 : : {
904 [ # # ]: 0 : aBuf.append( NewTitle );
905 [ # # ]: 0 : if ( bTrailingSlash )
906 [ # # ]: 0 : aBuf.append( sal_Unicode( '/' ) );
907 : : }
908 : : else
909 : : {
910 : 0 : m_nState &= ~NameForInsertionSet;
911 : : }
912 : :
913 [ # # ]: 0 : m_aUncPath = aBuf.makeStringAndClear();
914 : : }
915 : : else
916 : : {
917 [ + - ]: 2313 : if ( !NewTitle.isEmpty() )
918 : : {
919 : : // Initial Title before "insert".
920 : : // m_aUncPath contains parent's URI.
921 : :
922 [ + - ]: 2313 : if( m_aUncPath.lastIndexOf( sal_Unicode('/') ) != m_aUncPath.getLength() - 1 )
923 : 2313 : m_aUncPath += rtl::OUString("/");
924 : :
925 : : m_aUncPath += rtl::Uri::encode( NewTitle,
926 : : rtl_UriCharClassPchar,
927 : : rtl_UriEncodeIgnoreEscapes,
928 : 2313 : RTL_TEXTENCODING_UTF8 );
929 : 2313 : m_nState |= NameForInsertionSet;
930 : : }
931 : : }
932 : 2313 : }
933 : : }
934 : : }
935 : :
936 [ + - ]: 2313 : return Sequence< Any >( Values.getLength() );
937 : : }
938 : : else
939 : : {
940 : : Sequence< Any > ret = m_pMyShell->setv( m_aUncPath, // Does not handle Title
941 : 304 : Values );
942 : :
943 : : // Special handling Title: Setting Title is equivalent to a renaming of the underlying file
944 [ + + ]: 608 : for( sal_Int32 i = 0; i < Values.getLength(); ++i )
945 : : {
946 [ + - ]: 304 : if( Values[i].Name != Title )
947 : 304 : continue; // handled by setv
948 : :
949 : 0 : rtl::OUString NewTitle;
950 [ # # ]: 0 : if( !( Values[i].Value >>= NewTitle ) )
951 : : {
952 [ # # ][ # # ]: 0 : ret[i] <<= beans::IllegalTypeException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
[ # # ][ # # ]
953 : : break;
954 : : }
955 [ # # ]: 0 : else if( NewTitle.isEmpty() )
956 : : {
957 [ # # ][ # # ]: 0 : ret[i] <<= lang::IllegalArgumentException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >(), 0 );
[ # # ][ # # ]
958 : : break;
959 : : }
960 : :
961 : :
962 [ # # ]: 0 : rtl::OUString aDstName = getParentName( m_aUncPath );
963 [ # # ]: 0 : if( aDstName.lastIndexOf( sal_Unicode('/') ) != aDstName.getLength() - 1 )
964 : 0 : aDstName += rtl::OUString("/");
965 : :
966 : : aDstName += rtl::Uri::encode( NewTitle,
967 : : rtl_UriCharClassPchar,
968 : : rtl_UriEncodeIgnoreEscapes,
969 : 0 : RTL_TEXTENCODING_UTF8 );
970 : :
971 : : m_pMyShell->move( nMyCommandIdentifier, // move notifies the children also;
972 : : m_aUncPath,
973 : : aDstName,
974 : 0 : NameClash::KEEP );
975 : :
976 : : try
977 : : {
978 [ # # ]: 0 : endTask( nMyCommandIdentifier );
979 : : }
980 [ # # # # ]: 0 : catch(const Exception& e)
981 : : {
982 [ # # # # ]: 0 : ret[i] <<= e;
983 : : }
984 : :
985 : : // NameChanges come back trough a ContentEvent
986 : : break; // only handling Title
987 : 0 : } // end for
988 : :
989 [ + - ][ + - ]: 304 : return ret;
990 : 2617 : }
991 : : }
992 : :
993 : :
994 : :
995 : : Reference< XDynamicResultSet > SAL_CALL
996 : 55065 : BaseContent::open(
997 : : sal_Int32 nMyCommandIdentifier,
998 : : const OpenCommandArgument2& aCommandArgument )
999 : : throw()
1000 : : {
1001 : 55065 : Reference< XDynamicResultSet > retValue( 0 );
1002 : :
1003 [ - + ]: 55065 : if( ( m_nState & Deleted ) )
1004 : : {
1005 : : m_pMyShell->installError( nMyCommandIdentifier,
1006 [ # # ]: 0 : TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND );
1007 : : }
1008 [ - + ]: 55065 : else if( m_nState & JustInserted )
1009 : : {
1010 : : m_pMyShell->installError( nMyCommandIdentifier,
1011 [ # # ]: 0 : TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND );
1012 : : }
1013 : : else
1014 : : {
1015 [ + + ][ + + ]: 55065 : if( aCommandArgument.Mode == OpenMode::DOCUMENT ||
1016 : : aCommandArgument.Mode == OpenMode::DOCUMENT_SHARE_DENY_NONE )
1017 : :
1018 : : {
1019 [ + - ]: 30704 : Reference< io::XOutputStream > outputStream( aCommandArgument.Sink,UNO_QUERY );
1020 [ + + ]: 30704 : if( outputStream.is() )
1021 : : {
1022 : : m_pMyShell->page( nMyCommandIdentifier,
1023 : : m_aUncPath,
1024 : 2170 : outputStream );
1025 : : }
1026 : :
1027 : 30704 : sal_Bool bLock = ( aCommandArgument.Mode != OpenMode::DOCUMENT_SHARE_DENY_NONE );
1028 : :
1029 [ + - ]: 30704 : Reference< io::XActiveDataSink > activeDataSink( aCommandArgument.Sink,UNO_QUERY );
1030 [ + + ]: 30704 : if( activeDataSink.is() )
1031 : : {
1032 [ + - ]: 18511 : activeDataSink->setInputStream( m_pMyShell->open( nMyCommandIdentifier,
1033 : : m_aUncPath,
1034 [ + - ]: 18511 : bLock ) );
1035 : : }
1036 : :
1037 [ + - ]: 30704 : Reference< io::XActiveDataStreamer > activeDataStreamer( aCommandArgument.Sink,UNO_QUERY );
1038 [ + + ]: 30704 : if( activeDataStreamer.is() )
1039 : : {
1040 [ + - ]: 10023 : activeDataStreamer->setStream( m_pMyShell->open_rw( nMyCommandIdentifier,
1041 : : m_aUncPath,
1042 [ + - ]: 10023 : bLock ) );
1043 : 30704 : }
1044 : : }
1045 [ + + ][ + + ]: 24361 : else if ( aCommandArgument.Mode == OpenMode::ALL ||
[ + - ]
1046 : : aCommandArgument.Mode == OpenMode::FOLDERS ||
1047 : : aCommandArgument.Mode == OpenMode::DOCUMENTS )
1048 : : {
1049 : : retValue = m_pMyShell->ls( nMyCommandIdentifier,
1050 : : m_aUncPath,
1051 : : aCommandArgument.Mode,
1052 : : aCommandArgument.Properties,
1053 [ + - ]: 24361 : aCommandArgument.SortingInfo );
1054 : : }
1055 : : // else if( aCommandArgument.Mode ==
1056 : : // OpenMode::DOCUMENT_SHARE_DENY_NONE ||
1057 : : // aCommandArgument.Mode ==
1058 : : // OpenMode::DOCUMENT_SHARE_DENY_WRITE )
1059 : : // m_pMyShell->installError( nMyCommandIdentifier,
1060 : : // TASKHANDLING_UNSUPPORTED_OPEN_MODE,
1061 : : // aCommandArgument.Mode);
1062 : : else
1063 : : m_pMyShell->installError( nMyCommandIdentifier,
1064 : : TASKHANDLING_UNSUPPORTED_OPEN_MODE,
1065 [ # # ]: 0 : aCommandArgument.Mode);
1066 : : }
1067 : :
1068 : 55065 : return retValue;
1069 : : }
1070 : :
1071 : :
1072 : :
1073 : : void SAL_CALL
1074 : 646 : BaseContent::deleteContent( sal_Int32 nMyCommandIdentifier )
1075 : : throw()
1076 : : {
1077 [ - + ]: 646 : if( m_nState & Deleted )
1078 : 646 : return;
1079 : :
1080 [ + + ]: 646 : if( m_pMyShell->remove( nMyCommandIdentifier,m_aUncPath ) )
1081 : : {
1082 [ + - ]: 632 : osl::MutexGuard aGuard( m_aMutex );
1083 [ + - ]: 632 : m_nState |= Deleted;
1084 : : }
1085 : : }
1086 : :
1087 : :
1088 : :
1089 : : void SAL_CALL
1090 : 1186 : BaseContent::transfer( sal_Int32 nMyCommandIdentifier,
1091 : : const TransferInfo& aTransferInfo )
1092 : : throw()
1093 : : {
1094 [ + - ]: 1186 : if( m_nState & Deleted )
1095 : : return;
1096 : :
1097 [ + + ]: 1186 : if( aTransferInfo.SourceURL.compareToAscii( "file:",5 ) != 0 )
1098 : : {
1099 : : m_pMyShell->installError( nMyCommandIdentifier,
1100 [ + - ]: 4 : TASKHANDLING_TRANSFER_INVALIDSCHEME );
1101 : : return;
1102 : : }
1103 : :
1104 : 1182 : rtl::OUString srcUnc;
1105 [ - + ][ + - ]: 1182 : if( m_pMyShell->getUnqFromUrl( aTransferInfo.SourceURL,srcUnc ) )
1106 : : {
1107 : : m_pMyShell->installError( nMyCommandIdentifier,
1108 [ # # ]: 0 : TASKHANDLING_TRANSFER_INVALIDURL );
1109 : : return;
1110 : : }
1111 : :
1112 : 1182 : rtl::OUString srcUncPath = srcUnc;
1113 : :
1114 : : // Determine the new title !
1115 : 1182 : rtl::OUString NewTitle;
1116 [ + - ]: 1182 : if( !aTransferInfo.NewTitle.isEmpty() )
1117 : : NewTitle = rtl::Uri::encode( aTransferInfo.NewTitle,
1118 : : rtl_UriCharClassPchar,
1119 : : rtl_UriEncodeIgnoreEscapes,
1120 : 1182 : RTL_TEXTENCODING_UTF8 );
1121 : : else
1122 : 0 : NewTitle = srcUncPath.copy( 1 + srcUncPath.lastIndexOf( sal_Unicode('/') ) );
1123 : :
1124 : : // Is destination a document or a folder ?
1125 [ + - ]: 1182 : Sequence< beans::Property > seq(1);
1126 [ + - ]: 1182 : seq[0] = beans::Property( rtl::OUString("IsDocument"),
1127 : : -1,
1128 [ + - ]: 1182 : getCppuType( static_cast< sal_Bool* >(0) ),
1129 : 2364 : 0 );
1130 [ + - ]: 1182 : Reference< sdbc::XRow > xRow = getPropertyValues( nMyCommandIdentifier,seq );
1131 [ + - ][ + - ]: 1182 : sal_Bool IsDocument = xRow->getBoolean( 1 );
1132 [ + - ][ + - ]: 1182 : if( xRow->wasNull() )
[ + + ]
1133 : : { // Destination file type could not be determined
1134 : : m_pMyShell->installError( nMyCommandIdentifier,
1135 [ + - ]: 150 : TASKHANDLING_TRANSFER_DESTFILETYPE );
1136 : : return;
1137 : : }
1138 : :
1139 : 1032 : rtl::OUString dstUncPath;
1140 [ - + ]: 1032 : if( IsDocument )
1141 : : { // as sibling
1142 : 0 : sal_Int32 lastSlash = m_aUncPath.lastIndexOf( sal_Unicode('/') );
1143 : 0 : dstUncPath = m_aUncPath.copy(0,lastSlash );
1144 : : }
1145 : : else
1146 : : // as child
1147 : 1032 : dstUncPath = m_aUncPath;
1148 : :
1149 : 1032 : dstUncPath += ( rtl::OUString("/") + NewTitle );
1150 : :
1151 : 1032 : sal_Int32 NameClash = aTransferInfo.NameClash;
1152 : :
1153 [ + + ]: 1032 : if( aTransferInfo.MoveData )
1154 : 4 : m_pMyShell->move( nMyCommandIdentifier,srcUncPath,dstUncPath,NameClash );
1155 : : else
1156 [ + + ][ + - ]: 1186 : m_pMyShell->copy( nMyCommandIdentifier,srcUncPath,dstUncPath,NameClash );
[ + + ][ + + ]
[ + + ][ + + ]
1157 : : }
1158 : :
1159 : :
1160 : :
1161 : :
1162 : 11743 : void SAL_CALL BaseContent::insert( sal_Int32 nMyCommandIdentifier,
1163 : : const InsertCommandArgument& aInsertArgument )
1164 : : throw()
1165 : : {
1166 [ + + ]: 11743 : if( m_nState & FullFeatured )
1167 : : {
1168 : : m_pMyShell->write( nMyCommandIdentifier,
1169 : : m_aUncPath,
1170 : : aInsertArgument.ReplaceExisting,
1171 : 9430 : aInsertArgument.Data );
1172 : : return;
1173 : : }
1174 : :
1175 [ - + ]: 2313 : if( ! ( m_nState & JustInserted ) )
1176 : : {
1177 : : m_pMyShell->installError( nMyCommandIdentifier,
1178 [ # # ]: 0 : TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND );
1179 : : return;
1180 : : }
1181 : :
1182 : : // Inserts the content, which has the flag m_bIsFresh
1183 : :
1184 [ - + ]: 2313 : if( ! m_nState & NameForInsertionSet )
1185 : : {
1186 : : m_pMyShell->installError( nMyCommandIdentifier,
1187 [ # # ]: 0 : TASKHANDLING_NONAMESET_INSERT_COMMAND );
1188 : : return;
1189 : : }
1190 : :
1191 : : // Inserting a document or a file?
1192 : 2313 : sal_Bool bDocument = false;
1193 : :
1194 [ + - ]: 2313 : Sequence< beans::Property > seq(1);
1195 [ + - ]: 2313 : seq[0] = beans::Property( rtl::OUString("IsDocument"),
1196 : : -1,
1197 [ + - ]: 2313 : getCppuType( static_cast< sal_Bool* >(0) ),
1198 [ # # ]: 4626 : 0 );
1199 : :
1200 [ + - ]: 2313 : Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq );
1201 : :
1202 : 2313 : bool contentTypeSet = true; // is set to false, if contentType not set
1203 : : try
1204 : : {
1205 [ + - ][ + - ]: 2313 : bDocument = xRow->getBoolean( 1 );
1206 [ + - ][ + - ]: 2313 : if( xRow->wasNull() )
[ - + ]
1207 : 0 : contentTypeSet = false;
1208 : :
1209 : : }
1210 [ # # ]: 0 : catch (const sdbc::SQLException&)
1211 : : {
1212 : : OSL_FAIL( "BaseContent::insert - Caught SQLException!" );
1213 : 0 : contentTypeSet = false;
1214 : : }
1215 : :
1216 [ - + ]: 2313 : if( ! contentTypeSet )
1217 : : {
1218 : : m_pMyShell->installError( nMyCommandIdentifier,
1219 [ # # ]: 0 : TASKHANDLING_NOCONTENTTYPE_INSERT_COMMAND );
1220 : : return;
1221 : : }
1222 : :
1223 : :
1224 : 2313 : sal_Bool success = false;
1225 [ + + ]: 2313 : if( bDocument )
1226 : : success = m_pMyShell->mkfil( nMyCommandIdentifier,
1227 : : m_aUncPath,
1228 : : aInsertArgument.ReplaceExisting,
1229 : 8 : aInsertArgument.Data );
1230 : : else
1231 : : {
1232 [ + - ]: 2305 : while( ! success )
1233 : : {
1234 : : success = m_pMyShell->mkdir( nMyCommandIdentifier,
1235 : : m_aUncPath,
1236 : 2305 : aInsertArgument.ReplaceExisting );
1237 [ + + ]: 2305 : if( success )
1238 : : break;
1239 : :
1240 : : XInteractionRequestImpl *aRequestImpl =
1241 : : new XInteractionRequestImpl(
1242 : : rtl::Uri::decode(
1243 : : getTitle(m_aUncPath),
1244 : : rtl_UriDecodeWithCharset,
1245 : : RTL_TEXTENCODING_UTF8),
1246 : : (cppu::OWeakObject*)this,
1247 [ + - ][ + - ]: 75 : m_pMyShell,nMyCommandIdentifier);
[ + - ]
1248 [ + - ][ + - ]: 75 : uno::Reference< task::XInteractionRequest > aReq( aRequestImpl );
1249 : :
1250 [ + - ]: 75 : m_pMyShell->handleTask( nMyCommandIdentifier,aReq );
1251 [ + - + - ]: 225 : if( aRequestImpl->aborted() ||
[ + - ]
1252 [ + - ]: 150 : aRequestImpl->newName().isEmpty() )
1253 : : // means aborting
1254 : : break;
1255 : :
1256 : : // determine new uncpath
1257 [ # # ]: 0 : m_pMyShell->clearError( nMyCommandIdentifier );
1258 [ # # ]: 0 : m_aUncPath = getParentName( m_aUncPath );
1259 [ # # ]: 0 : if( m_aUncPath.lastIndexOf( sal_Unicode('/') ) != m_aUncPath.getLength() - 1 )
1260 : 0 : m_aUncPath += rtl::OUString("/");
1261 : :
1262 : : m_aUncPath += rtl::Uri::encode( aRequestImpl->newName(),
1263 : : rtl_UriCharClassPchar,
1264 : : rtl_UriEncodeIgnoreEscapes,
1265 [ - + ]: 2305 : RTL_TEXTENCODING_UTF8 );
1266 : 75 : }
1267 : : }
1268 : :
1269 [ + + ]: 2313 : if ( ! success )
1270 : : return;
1271 : :
1272 [ + - ]: 2238 : FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,m_aUncPath );
1273 [ + - ][ + - ]: 2238 : m_xContentIdentifier = Reference< XContentIdentifier >( p );
[ + - ]
1274 : :
1275 [ + - ]: 2238 : m_pMyShell->registerNotifier( m_aUncPath,this );
1276 [ + - ]: 2238 : m_pMyShell->insertDefaultProperties( m_aUncPath );
1277 : :
1278 [ + - ]: 2238 : osl::MutexGuard aGuard( m_aMutex );
1279 [ + - ][ + + ]: 11743 : m_nState = FullFeatured;
[ + - ][ + + ]
1280 : : }
1281 : :
1282 : :
1283 : :
1284 : 142277 : void SAL_CALL BaseContent::endTask( sal_Int32 CommandId )
1285 : : {
1286 : : // This is the only function allowed to throw an exception
1287 : 142277 : m_pMyShell->endTask( CommandId,m_aUncPath,this );
1288 : 125757 : }
1289 : :
1290 : :
1291 : :
1292 : : ContentEventNotifier*
1293 : 636 : BaseContent::cDEL( void )
1294 : : {
1295 [ + - ]: 636 : osl::MutexGuard aGuard( m_aMutex );
1296 : :
1297 : 636 : m_nState |= Deleted;
1298 : :
1299 : : ContentEventNotifier* p;
1300 [ + - ]: 636 : if( m_pContentEventListeners )
1301 : : p = new ContentEventNotifier( m_pMyShell,
1302 : : this,
1303 : : m_xContentIdentifier,
1304 [ + - ][ + - ]: 636 : m_pContentEventListeners->getElements() );
[ + - ][ + - ]
[ + - ]
1305 : : else
1306 : 0 : p = 0;
1307 : :
1308 [ + - ]: 636 : return p;
1309 : : }
1310 : :
1311 : :
1312 : : ContentEventNotifier*
1313 : 0 : BaseContent::cEXC( const rtl::OUString aNewName )
1314 : : {
1315 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
1316 : :
1317 : 0 : Reference< XContentIdentifier > xOldRef = m_xContentIdentifier;
1318 : 0 : m_aUncPath = aNewName;
1319 [ # # ]: 0 : FileContentIdentifier* pp = new FileContentIdentifier( m_pMyShell,aNewName );
1320 [ # # ][ # # ]: 0 : m_xContentIdentifier = Reference< XContentIdentifier >( pp );
[ # # ]
1321 : :
1322 : 0 : ContentEventNotifier* p = 0;
1323 [ # # ]: 0 : if( m_pContentEventListeners )
1324 : : p = new ContentEventNotifier( m_pMyShell,
1325 : : this,
1326 : : m_xContentIdentifier,
1327 : : xOldRef,
1328 [ # # ][ # # ]: 0 : m_pContentEventListeners->getElements() );
[ # # ][ # # ]
[ # # ]
1329 : :
1330 [ # # ]: 0 : return p;
1331 : : }
1332 : :
1333 : :
1334 : : ContentEventNotifier*
1335 : 4786 : BaseContent::cCEL( void )
1336 : : {
1337 [ + - ]: 4786 : osl::MutexGuard aGuard( m_aMutex );
1338 : 4786 : ContentEventNotifier* p = 0;
1339 [ + + ]: 4786 : if( m_pContentEventListeners )
1340 : : p = new ContentEventNotifier( m_pMyShell,
1341 : : this,
1342 : : m_xContentIdentifier,
1343 [ + - ][ + - ]: 3744 : m_pContentEventListeners->getElements() );
[ + - ][ + - ]
[ + - ]
1344 : :
1345 [ + - ]: 4786 : return p;
1346 : : }
1347 : :
1348 : : PropertySetInfoChangeNotifier*
1349 : 0 : BaseContent::cPSL( void )
1350 : : {
1351 [ # # ]: 0 : osl::MutexGuard aGuard( m_aMutex );
1352 : 0 : PropertySetInfoChangeNotifier* p = 0;
1353 [ # # ]: 0 : if( m_pPropertySetInfoChangeListeners )
1354 : : p = new PropertySetInfoChangeNotifier( this,
1355 : : m_xContentIdentifier,
1356 [ # # ][ # # ]: 0 : m_pPropertySetInfoChangeListeners->getElements() );
[ # # ][ # # ]
[ # # ]
1357 : :
1358 [ # # ]: 0 : return p;
1359 : : }
1360 : :
1361 : :
1362 : :
1363 : : PropertyChangeNotifier*
1364 : 4 : BaseContent::cPCL( void )
1365 : : {
1366 [ + - ]: 4 : osl::MutexGuard aGuard( m_aMutex );
1367 : :
1368 [ + - ]: 4 : Sequence< rtl::OUString > seqNames;
1369 : :
1370 [ - + ]: 4 : if( m_pPropertyListener )
1371 [ # # ][ # # ]: 0 : seqNames = m_pPropertyListener->getContainedTypes();
[ # # ]
1372 : :
1373 : 4 : PropertyChangeNotifier* p = 0;
1374 : :
1375 : 4 : sal_Int32 length = seqNames.getLength();
1376 : :
1377 [ - + ]: 4 : if( length )
1378 : : {
1379 [ # # ][ # # ]: 0 : ListenerMap* listener = new ListenerMap();
1380 [ # # ]: 0 : for( sal_Int32 i = 0; i < length; ++i )
1381 : : {
1382 [ # # ][ # # ]: 0 : (*listener)[seqNames[i]] = m_pPropertyListener->getContainer( seqNames[i] )->getElements();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1383 : : }
1384 : :
1385 : : p = new PropertyChangeNotifier( this,
1386 : : m_xContentIdentifier,
1387 [ # # ][ # # ]: 0 : listener );
[ # # ]
1388 : : }
1389 : :
1390 [ + - ][ + - ]: 4 : return p;
1391 : : }
1392 : :
1393 : :
1394 : 0 : rtl::OUString BaseContent::getKey( void )
1395 : : {
1396 : 0 : return m_aUncPath;
1397 : : }
1398 : :
1399 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|