Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include <cassert>
23 :
24 : #include <osl/diagnose.h>
25 : #include <osl/mutex.hxx>
26 : #include <salhelper/simplereferenceobject.hxx>
27 : #include <cppuhelper/weak.hxx>
28 :
29 : #include <cppuhelper/implbase1.hxx>
30 : #include <com/sun/star/ucb/CheckinArgument.hpp>
31 : #include <com/sun/star/ucb/ContentCreationError.hpp>
32 : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
33 : #include <com/sun/star/ucb/XCommandInfo.hpp>
34 : #include <com/sun/star/ucb/XCommandProcessor.hpp>
35 : #include <com/sun/star/ucb/Command.hpp>
36 : #include <com/sun/star/ucb/CommandInfo.hpp>
37 : #include <com/sun/star/ucb/ContentAction.hpp>
38 : #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
39 : #include <com/sun/star/ucb/InsertCommandArgument.hpp>
40 : #include <com/sun/star/ucb/GlobalTransferCommandArgument2.hpp>
41 : #include <com/sun/star/ucb/NameClash.hpp>
42 : #include <com/sun/star/ucb/OpenMode.hpp>
43 : #include <com/sun/star/ucb/XContentCreator.hpp>
44 : #include <com/sun/star/ucb/XContentEventListener.hpp>
45 : #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
46 : #include <com/sun/star/ucb/XContentProvider.hpp>
47 : #include <com/sun/star/ucb/XContentProviderManager.hpp>
48 : #include <com/sun/star/ucb/XDynamicResultSet.hpp>
49 : #include <com/sun/star/ucb/SortedDynamicResultSetFactory.hpp>
50 : #include <com/sun/star/ucb/UniversalContentBroker.hpp>
51 : #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
52 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
53 : #include <com/sun/star/beans/Property.hpp>
54 : #include <com/sun/star/beans/PropertyValue.hpp>
55 : #include <com/sun/star/sdbc/XResultSet.hpp>
56 : #include <com/sun/star/sdbc/XRow.hpp>
57 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
58 : #include <com/sun/star/beans/UnknownPropertyException.hpp>
59 : #include <ucbhelper/macros.hxx>
60 : #include <ucbhelper/content.hxx>
61 : #include <ucbhelper/activedatasink.hxx>
62 : #include <ucbhelper/activedatastreamer.hxx>
63 : #include <ucbhelper/interactionrequest.hxx>
64 : #include <ucbhelper/cancelcommandexecution.hxx>
65 :
66 : using namespace com::sun::star::container;
67 : using namespace com::sun::star::beans;
68 : using namespace com::sun::star::io;
69 : using namespace com::sun::star::lang;
70 : using namespace com::sun::star::sdbc;
71 : using namespace com::sun::star::task;
72 : using namespace com::sun::star::ucb;
73 : using namespace com::sun::star::uno;
74 :
75 : namespace ucbhelper
76 : {
77 :
78 5457 : class EmptyInputStream : public ::cppu::WeakImplHelper1< XInputStream >
79 : {
80 : public:
81 : virtual sal_Int32 SAL_CALL readBytes(
82 : Sequence< sal_Int8 > & data, sal_Int32 nBytesToRead )
83 : throw (IOException, RuntimeException);
84 : virtual sal_Int32 SAL_CALL readSomeBytes(
85 : Sequence< sal_Int8 > & data, sal_Int32 nMaxBytesToRead )
86 : throw (IOException, RuntimeException);
87 : virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
88 : throw (IOException, RuntimeException);
89 : virtual sal_Int32 SAL_CALL available()
90 : throw (IOException, RuntimeException);
91 : virtual void SAL_CALL closeInput()
92 : throw (IOException, RuntimeException);
93 : };
94 :
95 0 : sal_Int32 EmptyInputStream::readBytes(
96 : Sequence< sal_Int8 > & data, sal_Int32 )
97 : throw (IOException, RuntimeException)
98 : {
99 0 : data.realloc( 0 );
100 0 : return 0;
101 : }
102 :
103 0 : sal_Int32 EmptyInputStream::readSomeBytes(
104 : Sequence< sal_Int8 > & data, sal_Int32 )
105 : throw (IOException, RuntimeException)
106 : {
107 0 : data.realloc( 0 );
108 0 : return 0;
109 : }
110 :
111 0 : void EmptyInputStream::skipBytes( sal_Int32 )
112 : throw (IOException, RuntimeException)
113 : {
114 0 : }
115 :
116 0 : sal_Int32 EmptyInputStream::available()
117 : throw (IOException, RuntimeException)
118 : {
119 0 : return 0;
120 : }
121 :
122 0 : void EmptyInputStream::closeInput()
123 : throw (IOException, RuntimeException)
124 : {
125 0 : }
126 :
127 :
128 : //=========================================================================
129 : //=========================================================================
130 : //
131 : // class ContentEventListener_Impl.
132 : //
133 : //=========================================================================
134 : //=========================================================================
135 :
136 127322 : class ContentEventListener_Impl : public cppu::OWeakObject,
137 : public XContentEventListener
138 : {
139 : Content_Impl& m_rContent;
140 :
141 : public:
142 63709 : ContentEventListener_Impl( Content_Impl& rContent )
143 63709 : : m_rContent( rContent ) {}
144 :
145 : // XInterface
146 : XINTERFACE_DECL()
147 :
148 : // XContentEventListener
149 : virtual void SAL_CALL contentEvent( const ContentEvent& evt )
150 : throw( RuntimeException );
151 :
152 : // XEventListener ( base of XContentEventListener )
153 : virtual void SAL_CALL disposing( const EventObject& Source )
154 : throw( RuntimeException );
155 : };
156 :
157 : //=========================================================================
158 : //=========================================================================
159 : //
160 : // class Content_Impl.
161 : //
162 : //=========================================================================
163 : //=========================================================================
164 :
165 : class Content_Impl : public salhelper::SimpleReferenceObject
166 : {
167 : friend class ContentEventListener_Impl;
168 :
169 : mutable OUString m_aURL;
170 : Reference< XComponentContext > m_xCtx;
171 : Reference< XContent > m_xContent;
172 : Reference< XCommandProcessor > m_xCommandProcessor;
173 : Reference< XCommandEnvironment > m_xEnv;
174 : Reference< XContentEventListener > m_xContentEventListener;
175 : mutable osl::Mutex m_aMutex;
176 :
177 : private:
178 : void reinit( const Reference< XContent >& xContent );
179 : void disposing(const EventObject& Source);
180 :
181 : public:
182 24906 : Content_Impl() {};
183 : Content_Impl( const Reference< XComponentContext >& rCtx,
184 : const Reference< XContent >& rContent,
185 : const Reference< XCommandEnvironment >& rEnv );
186 :
187 : virtual ~Content_Impl();
188 :
189 : const OUString& getURL() const;
190 : Reference< XContent > getContent();
191 : Reference< XCommandProcessor > getCommandProcessor();
192 2508 : Reference< XComponentContext > getComponentContext()
193 2508 : { assert(m_xCtx.is()); return m_xCtx; }
194 :
195 : Any executeCommand( const Command& rCommand );
196 :
197 : inline const Reference< XCommandEnvironment >& getEnvironment() const;
198 : inline void setEnvironment(
199 : const Reference< XCommandEnvironment >& xNewEnv );
200 :
201 : void inserted();
202 : };
203 :
204 : //=========================================================================
205 : // Helpers.
206 : //=========================================================================
207 :
208 1151 : static void ensureContentProviderForURL( const Reference< XUniversalContentBroker >& rBroker,
209 : const OUString & rURL )
210 : throw ( ContentCreationException, RuntimeException )
211 : {
212 : Reference< XContentProvider > xProv
213 1151 : = rBroker->queryContentProvider( rURL );
214 1151 : if ( !xProv.is() )
215 : {
216 : throw ContentCreationException(
217 2278 : "No Content Provider available for URL: " + rURL,
218 : Reference< XInterface >(),
219 3417 : ContentCreationError_NO_CONTENT_PROVIDER );
220 1151 : }
221 12 : }
222 :
223 : //=========================================================================
224 53166 : static Reference< XContentIdentifier > getContentIdentifier(
225 : const Reference< XUniversalContentBroker > & rBroker,
226 : const OUString & rURL,
227 : bool bThrow )
228 : throw ( ContentCreationException, RuntimeException )
229 : {
230 : Reference< XContentIdentifier > xId
231 53166 : = rBroker->createContentIdentifier( rURL );
232 :
233 53166 : if ( xId.is() )
234 53166 : return xId;
235 :
236 0 : if ( bThrow )
237 : {
238 0 : ensureContentProviderForURL( rBroker, rURL );
239 :
240 : throw ContentCreationException(
241 : "Unable to create Content Identifier!",
242 : Reference< XInterface >(),
243 0 : ContentCreationError_IDENTIFIER_CREATION_FAILED );
244 : }
245 :
246 0 : return Reference< XContentIdentifier >();
247 : }
248 :
249 : //=========================================================================
250 53166 : static Reference< XContent > getContent(
251 : const Reference< XUniversalContentBroker > & rBroker,
252 : const Reference< XContentIdentifier > & xId,
253 : bool bThrow )
254 : throw ( ContentCreationException, RuntimeException )
255 : {
256 53166 : Reference< XContent > xContent;
257 106332 : OUString msg;
258 : try
259 : {
260 53166 : xContent = rBroker->queryContent( xId );
261 : }
262 0 : catch ( IllegalIdentifierException const & e )
263 : {
264 0 : msg = e.Message;
265 : // handled below.
266 : }
267 :
268 53166 : if ( xContent.is() )
269 51965 : return xContent;
270 :
271 1201 : if ( bThrow )
272 : {
273 2290 : ensureContentProviderForURL( rBroker, xId->getContentIdentifier() );
274 :
275 : throw ContentCreationException(
276 24 : "Unable to create Content! " + msg,
277 : Reference< XInterface >(),
278 36 : ContentCreationError_CONTENT_CREATION_FAILED );
279 : }
280 :
281 53216 : return Reference< XContent >();
282 : }
283 :
284 : //=========================================================================
285 : //=========================================================================
286 : //
287 : // Content Implementation.
288 : //
289 : //=========================================================================
290 : //=========================================================================
291 :
292 24906 : Content::Content()
293 24906 : : m_xImpl( new Content_Impl )
294 : {
295 24906 : }
296 :
297 : //=========================================================================
298 45663 : Content::Content( const OUString& rURL,
299 : const Reference< XCommandEnvironment >& rEnv,
300 : const Reference< XComponentContext >& rCtx )
301 46814 : throw ( ContentCreationException, RuntimeException )
302 : {
303 : Reference< XUniversalContentBroker > pBroker(
304 45663 : UniversalContentBroker::create( rCtx ) );
305 :
306 : Reference< XContentIdentifier > xId
307 91326 : = getContentIdentifier( pBroker, rURL, true );
308 :
309 90175 : Reference< XContent > xContent = getContent( pBroker, xId, true );
310 :
311 90175 : m_xImpl = new Content_Impl( rCtx, xContent, rEnv );
312 44512 : }
313 :
314 : //=========================================================================
315 11744 : Content::Content( const Reference< XContent >& rContent,
316 : const Reference< XCommandEnvironment >& rEnv,
317 : const Reference< XComponentContext >& rCtx )
318 11744 : throw ( ContentCreationException, RuntimeException )
319 : {
320 11744 : m_xImpl = new Content_Impl( rCtx, rContent, rEnv );
321 11744 : }
322 :
323 : //=========================================================================
324 1220 : Content::Content( const Content& rOther )
325 : {
326 1220 : m_xImpl = rOther.m_xImpl;
327 1220 : }
328 :
329 : //=========================================================================
330 : // static
331 7503 : sal_Bool Content::create( const OUString& rURL,
332 : const Reference< XCommandEnvironment >& rEnv,
333 : const Reference< XComponentContext >& rCtx,
334 : Content& rContent )
335 : {
336 : Reference< XUniversalContentBroker > pBroker(
337 7503 : UniversalContentBroker::create( rCtx ) );
338 :
339 : Reference< XContentIdentifier > xId
340 15006 : = getContentIdentifier( pBroker, rURL, false );
341 7503 : if ( !xId.is() )
342 0 : return sal_False;
343 :
344 15006 : Reference< XContent > xContent = getContent( pBroker, xId, false );
345 7503 : if ( !xContent.is() )
346 50 : return sal_False;
347 :
348 : rContent.m_xImpl
349 7453 : = new Content_Impl( rCtx, xContent, rEnv );
350 :
351 14956 : return sal_True;
352 : }
353 :
354 : //=========================================================================
355 82237 : Content::~Content()
356 : {
357 82237 : }
358 :
359 : //=========================================================================
360 15356 : Content& Content::operator=( const Content& rOther )
361 : {
362 15356 : m_xImpl = rOther.m_xImpl;
363 15356 : return *this;
364 : }
365 :
366 : //=========================================================================
367 33940 : Reference< XContent > Content::get() const
368 : {
369 33940 : return m_xImpl->getContent();
370 : }
371 :
372 : //=========================================================================
373 2739 : const OUString& Content::getURL() const
374 : {
375 2739 : return m_xImpl->getURL();
376 : }
377 :
378 : //=========================================================================
379 6 : const Reference< XCommandEnvironment >& Content::getCommandEnvironment() const
380 : {
381 6 : return m_xImpl->getEnvironment();
382 : }
383 :
384 : //=========================================================================
385 2794 : void Content::setCommandEnvironment(
386 : const Reference< XCommandEnvironment >& xNewEnv )
387 : {
388 2794 : m_xImpl->setEnvironment( xNewEnv );
389 2794 : }
390 :
391 : //=========================================================================
392 0 : Reference< XCommandInfo > Content::getCommands()
393 : throw( CommandAbortedException, RuntimeException, Exception )
394 : {
395 0 : Command aCommand;
396 0 : aCommand.Name = OUString("getCommandInfo");
397 0 : aCommand.Handle = -1; // n/a
398 0 : aCommand.Argument = Any();
399 :
400 0 : Any aResult = m_xImpl->executeCommand( aCommand );
401 :
402 0 : Reference< XCommandInfo > xInfo;
403 0 : aResult >>= xInfo;
404 0 : return xInfo;
405 : }
406 :
407 : //=========================================================================
408 7093 : Reference< XPropertySetInfo > Content::getProperties()
409 : throw( CommandAbortedException, RuntimeException, Exception )
410 : {
411 7093 : Command aCommand;
412 7093 : aCommand.Name = OUString("getPropertySetInfo");
413 7093 : aCommand.Handle = -1; // n/a
414 7093 : aCommand.Argument = Any();
415 :
416 14186 : Any aResult = m_xImpl->executeCommand( aCommand );
417 :
418 7093 : Reference< XPropertySetInfo > xInfo;
419 7093 : aResult >>= xInfo;
420 14186 : return xInfo;
421 : }
422 :
423 : //=========================================================================
424 28805 : Any Content::getPropertyValue( const OUString& rPropertyName )
425 : throw( CommandAbortedException, RuntimeException, Exception )
426 : {
427 28805 : Sequence< OUString > aNames( 1 );
428 28805 : aNames.getArray()[ 0 ] = rPropertyName;
429 :
430 48033 : Sequence< Any > aRet = getPropertyValues( aNames );
431 38456 : return aRet.getConstArray()[ 0 ];
432 : }
433 :
434 : //=========================================================================
435 204 : Any Content::setPropertyValue( const OUString& rName,
436 : const Any& rValue )
437 : throw( CommandAbortedException, RuntimeException, Exception )
438 : {
439 204 : Sequence< OUString > aNames( 1 );
440 204 : aNames.getArray()[ 0 ] = rName;
441 :
442 408 : Sequence< Any > aValues( 1 );
443 204 : aValues.getArray()[ 0 ] = rValue;
444 :
445 408 : Sequence< Any > aErrors = setPropertyValues( aNames, aValues );
446 408 : return aErrors.getConstArray()[ 0 ];
447 : }
448 :
449 : //=========================================================================
450 28805 : Sequence< Any > Content::getPropertyValues(
451 : const Sequence< OUString >& rPropertyNames )
452 : throw( CommandAbortedException, RuntimeException, Exception )
453 : {
454 28805 : Reference< XRow > xRow = getPropertyValuesInterface( rPropertyNames );
455 :
456 19228 : sal_Int32 nCount = rPropertyNames.getLength();
457 19228 : Sequence< Any > aValues( nCount );
458 :
459 19228 : if ( xRow.is() )
460 : {
461 19228 : Any* pValues = aValues.getArray();
462 :
463 38456 : for ( sal_Int32 n = 0; n < nCount; ++n )
464 19228 : pValues[ n ] = xRow->getObject( n + 1, Reference< XNameAccess >() );
465 : }
466 :
467 19228 : return aValues;
468 : }
469 :
470 : //=========================================================================
471 28805 : Reference< XRow > Content::getPropertyValuesInterface(
472 : const Sequence< OUString >& rPropertyNames )
473 : throw( CommandAbortedException, RuntimeException, Exception )
474 : {
475 28805 : sal_Int32 nCount = rPropertyNames.getLength();
476 28805 : Sequence< Property > aProps( nCount );
477 28805 : Property* pProps = aProps.getArray();
478 :
479 28805 : const OUString* pNames = rPropertyNames.getConstArray();
480 :
481 57610 : for ( sal_Int32 n = 0; n< nCount; ++n )
482 : {
483 28805 : Property& rProp = pProps[ n ];
484 :
485 28805 : rProp.Name = pNames[ n ];
486 28805 : rProp.Handle = -1; // n/a
487 : // rProp.Type =
488 : // rProp.Attributes = ;
489 : }
490 :
491 57610 : Command aCommand;
492 28805 : aCommand.Name = OUString("getPropertyValues");
493 28805 : aCommand.Handle = -1; // n/a
494 28805 : aCommand.Argument <<= aProps;
495 :
496 48033 : Any aResult = m_xImpl->executeCommand( aCommand );
497 :
498 19228 : Reference< XRow > xRow;
499 19228 : aResult >>= xRow;
500 48033 : return xRow;
501 : }
502 :
503 : //=========================================================================
504 2023 : Sequence< Any > Content::setPropertyValues(
505 : const Sequence< OUString >& rPropertyNames,
506 : const Sequence< Any >& rValues )
507 : throw( CommandAbortedException, RuntimeException, Exception )
508 : {
509 2023 : if ( rPropertyNames.getLength() != rValues.getLength() )
510 : {
511 : ucbhelper::cancelCommandExecution(
512 : makeAny( IllegalArgumentException(
513 : OUString(
514 : "Length of property names sequence and value "
515 : "sequence are unequal!" ),
516 : get(),
517 0 : -1 ) ),
518 0 : m_xImpl->getEnvironment() );
519 : // Unreachable
520 : }
521 :
522 2023 : sal_Int32 nCount = rValues.getLength();
523 2023 : Sequence< PropertyValue > aProps( nCount );
524 2023 : PropertyValue* pProps = aProps.getArray();
525 :
526 2023 : const OUString* pNames = rPropertyNames.getConstArray();
527 2023 : const Any* pValues = rValues.getConstArray();
528 :
529 4068 : for ( sal_Int32 n = 0; n< nCount; ++n )
530 : {
531 2045 : PropertyValue& rProp = pProps[ n ];
532 :
533 2045 : rProp.Name = pNames[ n ];
534 2045 : rProp.Handle = -1; // n/a
535 2045 : rProp.Value = pValues[ n ];
536 : // rProp.State = ;
537 : }
538 :
539 4046 : Command aCommand;
540 2023 : aCommand.Name = OUString("setPropertyValues");
541 2023 : aCommand.Handle = -1; // n/a
542 2023 : aCommand.Argument <<= aProps;
543 :
544 4046 : Any aResult = m_xImpl->executeCommand( aCommand );
545 :
546 2023 : Sequence< Any > aErrors;
547 2023 : aResult >>= aErrors;
548 4046 : return aErrors;
549 : }
550 :
551 : //=========================================================================
552 12937 : Any Content::executeCommand( const OUString& rCommandName,
553 : const Any& rCommandArgument )
554 : throw( CommandAbortedException, RuntimeException, Exception )
555 : {
556 12937 : Command aCommand;
557 12937 : aCommand.Name = rCommandName;
558 12937 : aCommand.Handle = -1; // n/a
559 12937 : aCommand.Argument = rCommandArgument;
560 :
561 12937 : return m_xImpl->executeCommand( aCommand );
562 : }
563 :
564 : //=========================================================================
565 15917 : Any Content::createCursorAny( const Sequence< OUString >& rPropertyNames,
566 : ResultSetInclude eMode )
567 : throw( CommandAbortedException, RuntimeException, Exception )
568 : {
569 15917 : sal_Int32 nCount = rPropertyNames.getLength();
570 15917 : Sequence< Property > aProps( nCount );
571 15917 : Property* pProps = aProps.getArray();
572 15917 : const OUString* pNames = rPropertyNames.getConstArray();
573 31987 : for ( sal_Int32 n = 0; n < nCount; ++n )
574 : {
575 16070 : Property& rProp = pProps[ n ];
576 16070 : rProp.Name = pNames[ n ];
577 16070 : rProp.Handle = -1; // n/a
578 : }
579 :
580 31834 : OpenCommandArgument2 aArg;
581 : aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
582 : ? OpenMode::FOLDERS
583 : : ( eMode == INCLUDE_DOCUMENTS_ONLY )
584 15917 : ? OpenMode::DOCUMENTS : OpenMode::ALL;
585 15917 : aArg.Priority = 0; // unused
586 15917 : aArg.Sink.clear(); // unused
587 15917 : aArg.Properties = aProps;
588 :
589 31834 : Command aCommand;
590 15917 : aCommand.Name = OUString("open");
591 15917 : aCommand.Handle = -1; // n/a
592 15917 : aCommand.Argument <<= aArg;
593 :
594 31834 : return m_xImpl->executeCommand( aCommand );
595 : }
596 :
597 : //=========================================================================
598 15688 : Reference< XResultSet > Content::createCursor(
599 : const Sequence< OUString >& rPropertyNames,
600 : ResultSetInclude eMode )
601 : throw( CommandAbortedException, RuntimeException, Exception )
602 : {
603 15688 : Any aCursorAny = createCursorAny( rPropertyNames, eMode );
604 :
605 31236 : Reference< XDynamicResultSet > xDynSet;
606 15618 : Reference< XResultSet > aResult;
607 :
608 15618 : aCursorAny >>= xDynSet;
609 15618 : if ( xDynSet.is() )
610 15618 : aResult = xDynSet->getStaticResultSet();
611 :
612 : OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" );
613 :
614 15618 : if ( !aResult.is() )
615 : {
616 : // Former, the open command directly returned a XResultSet.
617 0 : aCursorAny >>= aResult;
618 :
619 : OSL_ENSURE( !aResult.is(),
620 : "Content::createCursor - open-Command must "
621 : "return a Reference< XDynnamicResultSet >!" );
622 : }
623 :
624 31236 : return aResult;
625 : }
626 :
627 : //=========================================================================
628 223 : Reference< XDynamicResultSet > Content::createDynamicCursor(
629 : const Sequence< OUString >& rPropertyNames,
630 : ResultSetInclude eMode )
631 : throw( CommandAbortedException, RuntimeException, Exception )
632 : {
633 223 : Reference< XDynamicResultSet > aResult;
634 223 : createCursorAny( rPropertyNames, eMode ) >>= aResult;
635 :
636 : OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" );
637 :
638 221 : return aResult;
639 : }
640 :
641 : //=========================================================================
642 6 : Reference< XResultSet > Content::createSortedCursor(
643 : const Sequence< OUString >& rPropertyNames,
644 : const Sequence< NumberedSortingInfo >& rSortInfo,
645 : Reference< XAnyCompareFactory > rAnyCompareFactory,
646 : ResultSetInclude eMode )
647 : throw( CommandAbortedException, RuntimeException, Exception )
648 : {
649 6 : Reference< XResultSet > aResult;
650 12 : Reference< XDynamicResultSet > aDynSet;
651 :
652 12 : Any aCursorAny = createCursorAny( rPropertyNames, eMode );
653 :
654 6 : aCursorAny >>= aDynSet;
655 :
656 6 : if( aDynSet.is() )
657 : {
658 6 : Reference< XDynamicResultSet > aDynResult;
659 :
660 6 : if( m_xImpl->getComponentContext().is() )
661 : {
662 : Reference< XSortedDynamicResultSetFactory > aSortFactory =
663 6 : SortedDynamicResultSetFactory::create( m_xImpl->getComponentContext());
664 :
665 18 : aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
666 : rSortInfo,
667 18 : rAnyCompareFactory );
668 : }
669 :
670 : OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" );
671 :
672 6 : if( aDynResult.is() )
673 6 : aResult = aDynResult->getStaticResultSet();
674 : else
675 0 : aResult = aDynSet->getStaticResultSet();
676 : }
677 :
678 : OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" );
679 :
680 6 : if ( !aResult.is() )
681 : {
682 : // Former, the open command directly returned a XResultSet.
683 0 : aCursorAny >>= aResult;
684 :
685 : OSL_ENSURE( !aResult.is(),
686 : "Content::createCursor - open-Command must "
687 : "return a Reference< XDynnamicResultSet >!" );
688 : }
689 :
690 12 : return aResult;
691 : }
692 :
693 : //=========================================================================
694 2161 : Reference< XInputStream > Content::openStream()
695 : throw( CommandAbortedException, RuntimeException, Exception )
696 : {
697 2161 : if ( !isDocument() )
698 0 : return Reference< XInputStream >();
699 :
700 2130 : Reference< XActiveDataSink > xSink = new ActiveDataSink;
701 :
702 4260 : OpenCommandArgument2 aArg;
703 2130 : aArg.Mode = OpenMode::DOCUMENT;
704 2130 : aArg.Priority = 0; // unused
705 2130 : aArg.Sink = xSink;
706 2130 : aArg.Properties = Sequence< Property >( 0 ); // unused
707 :
708 4260 : Command aCommand;
709 2130 : aCommand.Name = OUString("open");
710 2130 : aCommand.Handle = -1; // n/a
711 2130 : aCommand.Argument <<= aArg;
712 :
713 2130 : m_xImpl->executeCommand( aCommand );
714 :
715 4260 : return xSink->getInputStream();
716 : }
717 :
718 : //=========================================================================
719 480 : Reference< XInputStream > Content::openStreamNoLock()
720 : throw( CommandAbortedException, RuntimeException, Exception )
721 : {
722 480 : if ( !isDocument() )
723 0 : return Reference< XInputStream >();
724 :
725 456 : Reference< XActiveDataSink > xSink = new ActiveDataSink;
726 :
727 912 : OpenCommandArgument2 aArg;
728 456 : aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
729 456 : aArg.Priority = 0; // unused
730 456 : aArg.Sink = xSink;
731 456 : aArg.Properties = Sequence< Property >( 0 ); // unused
732 :
733 912 : Command aCommand;
734 456 : aCommand.Name = OUString("open");
735 456 : aCommand.Handle = -1; // n/a
736 456 : aCommand.Argument <<= aArg;
737 :
738 456 : m_xImpl->executeCommand( aCommand );
739 :
740 912 : return xSink->getInputStream();
741 : }
742 :
743 : //=========================================================================
744 675 : Reference< XStream > Content::openWriteableStream()
745 : throw( CommandAbortedException, RuntimeException, Exception )
746 : {
747 675 : if ( !isDocument() )
748 0 : return Reference< XStream >();
749 :
750 667 : Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
751 :
752 1334 : OpenCommandArgument2 aArg;
753 667 : aArg.Mode = OpenMode::DOCUMENT;
754 667 : aArg.Priority = 0; // unused
755 667 : aArg.Sink = xStreamer;
756 667 : aArg.Properties = Sequence< Property >( 0 ); // unused
757 :
758 1334 : Command aCommand;
759 667 : aCommand.Name = OUString("open");
760 667 : aCommand.Handle = -1; // n/a
761 667 : aCommand.Argument <<= aArg;
762 :
763 667 : m_xImpl->executeCommand( aCommand );
764 :
765 1334 : return xStreamer->getStream();
766 : }
767 :
768 : //=========================================================================
769 0 : Reference< XStream > Content::openWriteableStreamNoLock()
770 : throw( CommandAbortedException, RuntimeException, Exception )
771 : {
772 0 : if ( !isDocument() )
773 0 : return Reference< XStream >();
774 :
775 0 : Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
776 :
777 0 : OpenCommandArgument2 aArg;
778 0 : aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
779 0 : aArg.Priority = 0; // unused
780 0 : aArg.Sink = xStreamer;
781 0 : aArg.Properties = Sequence< Property >( 0 ); // unused
782 :
783 0 : Command aCommand;
784 0 : aCommand.Name = OUString("open");
785 0 : aCommand.Handle = -1; // n/a
786 0 : aCommand.Argument <<= aArg;
787 :
788 0 : m_xImpl->executeCommand( aCommand );
789 :
790 0 : return xStreamer->getStream();
791 : }
792 :
793 : //=========================================================================
794 3262 : sal_Bool Content::openStream( const Reference< XActiveDataSink >& rSink )
795 : throw( CommandAbortedException, RuntimeException, Exception )
796 : {
797 3262 : if ( !isDocument() )
798 0 : return sal_False;
799 :
800 1022 : OpenCommandArgument2 aArg;
801 1022 : aArg.Mode = OpenMode::DOCUMENT;
802 1022 : aArg.Priority = 0; // unused
803 1022 : aArg.Sink = rSink;
804 1022 : aArg.Properties = Sequence< Property >( 0 ); // unused
805 :
806 2044 : Command aCommand;
807 1022 : aCommand.Name = OUString("open");
808 1022 : aCommand.Handle = -1; // n/a
809 1022 : aCommand.Argument <<= aArg;
810 :
811 1022 : m_xImpl->executeCommand( aCommand );
812 :
813 2044 : return sal_True;
814 : }
815 :
816 : //=========================================================================
817 252 : sal_Bool Content::openStream( const Reference< XOutputStream >& rStream )
818 : throw( CommandAbortedException, RuntimeException, Exception )
819 : {
820 252 : if ( !isDocument() )
821 0 : return sal_False;
822 :
823 252 : OpenCommandArgument2 aArg;
824 252 : aArg.Mode = OpenMode::DOCUMENT;
825 252 : aArg.Priority = 0; // unused
826 252 : aArg.Sink = rStream;
827 252 : aArg.Properties = Sequence< Property >( 0 ); // unused
828 :
829 504 : Command aCommand;
830 252 : aCommand.Name = OUString("open");
831 252 : aCommand.Handle = -1; // n/a
832 252 : aCommand.Argument <<= aArg;
833 :
834 252 : m_xImpl->executeCommand( aCommand );
835 :
836 504 : return sal_True;
837 : }
838 :
839 : //=========================================================================
840 960 : void Content::writeStream( const Reference< XInputStream >& rStream,
841 : sal_Bool bReplaceExisting )
842 : throw( CommandAbortedException, RuntimeException, Exception )
843 : {
844 960 : InsertCommandArgument aArg;
845 960 : aArg.Data = rStream.is() ? rStream : new EmptyInputStream;
846 960 : aArg.ReplaceExisting = bReplaceExisting;
847 :
848 1920 : Command aCommand;
849 960 : aCommand.Name = OUString("insert");
850 960 : aCommand.Handle = -1; // n/a
851 960 : aCommand.Argument <<= aArg;
852 :
853 960 : m_xImpl->executeCommand( aCommand );
854 :
855 1920 : m_xImpl->inserted();
856 960 : }
857 :
858 : //=========================================================================
859 1810 : Sequence< ContentInfo > Content::queryCreatableContentsInfo()
860 : throw( CommandAbortedException, RuntimeException, Exception )
861 : {
862 : // First, try it using "CreatableContentsInfo" property -> the "new" way.
863 1810 : Sequence< ContentInfo > aInfo;
864 3612 : if ( getPropertyValue(
865 : OUString("CreatableContentsInfo") )
866 3616 : >>= aInfo )
867 1806 : return aInfo;
868 :
869 : // Second, try it using XContentCreator interface -> the "old" way (not
870 : // providing the chance to supply an XCommandEnvironment.
871 0 : Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
872 0 : if ( xCreator.is() )
873 0 : aInfo = xCreator->queryCreatableContentsInfo();
874 :
875 0 : return aInfo;
876 : }
877 :
878 : //=========================================================================
879 1819 : sal_Bool Content::insertNewContent( const OUString& rContentType,
880 : const Sequence< OUString >&
881 : rPropertyNames,
882 : const Sequence< Any >& rPropertyValues,
883 : Content& rNewContent )
884 : throw( CommandAbortedException, RuntimeException, Exception )
885 : {
886 : return insertNewContent( rContentType,
887 : rPropertyNames,
888 : rPropertyValues,
889 1819 : new EmptyInputStream,
890 3638 : rNewContent );
891 : }
892 :
893 : //=========================================================================
894 1819 : sal_Bool Content::insertNewContent( const OUString& rContentType,
895 : const Sequence< OUString >&
896 : rPropertyNames,
897 : const Sequence< Any >& rPropertyValues,
898 : const Reference< XInputStream >& rData,
899 : Content& rNewContent )
900 : throw( CommandAbortedException, RuntimeException, Exception )
901 : {
902 1819 : if ( rContentType.isEmpty() )
903 0 : return sal_False;
904 :
905 : // First, try it using "createNewContent" command -> the "new" way.
906 1819 : ContentInfo aInfo;
907 1819 : aInfo.Type = rContentType;
908 1819 : aInfo.Attributes = 0;
909 :
910 3638 : Command aCommand;
911 1819 : aCommand.Name = OUString("createNewContent");
912 1819 : aCommand.Handle = -1; // n/a
913 1819 : aCommand.Argument <<= aInfo;
914 :
915 3638 : Reference< XContent > xNew;
916 : try
917 : {
918 1819 : m_xImpl->executeCommand( aCommand ) >>= xNew;
919 : }
920 0 : catch ( RuntimeException const & )
921 : {
922 0 : throw;
923 : }
924 0 : catch ( Exception const & )
925 : {
926 : }
927 :
928 1819 : if ( !xNew.is() )
929 : {
930 : // Second, try it using XContentCreator interface -> the "old"
931 : // way (not providing the chance to supply an XCommandEnvironment.
932 0 : Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
933 :
934 0 : if ( !xCreator.is() )
935 0 : return sal_False;
936 :
937 0 : xNew = xCreator->createNewContent( aInfo );
938 :
939 0 : if ( !xNew.is() )
940 0 : return sal_False;
941 : }
942 :
943 : Content aNewContent(
944 3638 : xNew, m_xImpl->getEnvironment(), m_xImpl->getComponentContext() );
945 1819 : aNewContent.setPropertyValues( rPropertyNames, rPropertyValues );
946 : aNewContent.executeCommand( OUString("insert"),
947 : makeAny(
948 : InsertCommandArgument(
949 1819 : rData.is() ? rData : new EmptyInputStream,
950 3798 : sal_False /* ReplaceExisting */ ) ) );
951 1659 : aNewContent.m_xImpl->inserted();
952 :
953 1659 : rNewContent = aNewContent;
954 3478 : return sal_True;
955 : }
956 :
957 : //=========================================================================
958 675 : sal_Bool Content::transferContent( const Content& rSourceContent,
959 : InsertOperation eOperation,
960 : const OUString & rTitle,
961 : const sal_Int32 nNameClashAction,
962 : const OUString & rMimeType,
963 : bool bMajorVersion,
964 : const OUString & rVersionComment,
965 : OUString* pResultURL )
966 : throw( CommandAbortedException, RuntimeException, Exception )
967 : {
968 : Reference< XUniversalContentBroker > pBroker(
969 675 : UniversalContentBroker::create( m_xImpl->getComponentContext() ) );
970 :
971 : // Execute command "globalTransfer" at UCB.
972 :
973 675 : TransferCommandOperation eTransOp = TransferCommandOperation();
974 1350 : OUString sCommand( "globalTransfer" );
975 675 : bool bCheckIn = false;
976 675 : switch ( eOperation )
977 : {
978 : case InsertOperation_COPY:
979 675 : eTransOp = TransferCommandOperation_COPY;
980 675 : break;
981 :
982 : case InsertOperation_MOVE:
983 0 : eTransOp = TransferCommandOperation_MOVE;
984 0 : break;
985 :
986 : case InsertOperation_LINK:
987 0 : eTransOp = TransferCommandOperation_LINK;
988 0 : break;
989 :
990 : case InsertOperation_CHECKIN:
991 0 : eTransOp = TransferCommandOperation_COPY;
992 0 : sCommand = OUString( "checkin" );
993 0 : bCheckIn = true;
994 0 : break;
995 :
996 : default:
997 : ucbhelper::cancelCommandExecution(
998 : makeAny( IllegalArgumentException(
999 : OUString(
1000 : "Unknown transfer operation!" ),
1001 : get(),
1002 0 : -1 ) ),
1003 0 : m_xImpl->getEnvironment() );
1004 : // Unreachable
1005 : }
1006 675 : Command aCommand;
1007 675 : aCommand.Name = sCommand;
1008 675 : aCommand.Handle = -1; // n/a
1009 :
1010 675 : if ( !bCheckIn )
1011 : {
1012 : GlobalTransferCommandArgument2 aTransferArg(
1013 : eTransOp,
1014 675 : rSourceContent.getURL(), // SourceURL
1015 675 : getURL(), // TargetFolderURL,
1016 : rTitle,
1017 : nNameClashAction,
1018 675 : rMimeType );
1019 675 : aCommand.Argument <<= aTransferArg;
1020 : }
1021 : else
1022 : {
1023 : CheckinArgument aCheckinArg( bMajorVersion, rVersionComment,
1024 0 : rSourceContent.getURL(), getURL(), rTitle, rMimeType );
1025 0 : aCommand.Argument <<= aCheckinArg;
1026 : }
1027 :
1028 1348 : Any aRet = pBroker->execute( aCommand, 0, m_xImpl->getEnvironment() );
1029 673 : if ( pResultURL != NULL )
1030 0 : aRet >>= *pResultURL;
1031 2023 : return sal_True;
1032 : }
1033 :
1034 : //=========================================================================
1035 14498 : sal_Bool Content::isFolder()
1036 : throw( CommandAbortedException, RuntimeException, Exception )
1037 : {
1038 14498 : sal_Bool bFolder = sal_False;
1039 16182 : if ( getPropertyValue("IsFolder")
1040 28996 : >>= bFolder )
1041 8089 : return bFolder;
1042 :
1043 : ucbhelper::cancelCommandExecution(
1044 : makeAny( UnknownPropertyException(
1045 : OUString(
1046 : "Unable to retrieve value of property 'IsFolder'!" ),
1047 4 : get() ) ),
1048 6 : m_xImpl->getEnvironment() );
1049 :
1050 : // Unreachable - cancelCommandExecution always throws an exception.
1051 : // But some compilers complain...
1052 0 : return sal_False;
1053 : }
1054 :
1055 : //=========================================================================
1056 8780 : sal_Bool Content::isDocument()
1057 : throw( CommandAbortedException, RuntimeException, Exception )
1058 : {
1059 8780 : sal_Bool bDoc = sal_False;
1060 11498 : if ( getPropertyValue("IsDocument")
1061 17560 : >>= bDoc )
1062 5749 : return bDoc;
1063 :
1064 : ucbhelper::cancelCommandExecution(
1065 : makeAny( UnknownPropertyException(
1066 : OUString(
1067 : "Unable to retrieve value of property 'IsDocument'!" ),
1068 0 : get() ) ),
1069 0 : m_xImpl->getEnvironment() );
1070 :
1071 : // Unreachable - cancelCommandExecution always throws an exception,
1072 : // But some compilers complain...
1073 0 : return sal_False;
1074 : }
1075 :
1076 : //=========================================================================
1077 : //=========================================================================
1078 : //
1079 : // Content_Impl Implementation.
1080 : //
1081 : //=========================================================================
1082 : //=========================================================================
1083 :
1084 63709 : Content_Impl::Content_Impl( const Reference< XComponentContext >& rCtx,
1085 : const Reference< XContent >& rContent,
1086 : const Reference< XCommandEnvironment >& rEnv )
1087 : : m_xCtx( rCtx ),
1088 : m_xContent( rContent ),
1089 63709 : m_xEnv( rEnv )
1090 : {
1091 : assert(rCtx.is());
1092 63709 : if ( m_xContent.is() )
1093 : {
1094 63709 : m_xContentEventListener = new ContentEventListener_Impl( *this );
1095 63709 : m_xContent->addContentEventListener( m_xContentEventListener );
1096 :
1097 : #if OSL_DEBUG_LEVEL > 1
1098 : // Only done on demand in product version for performance reasons,
1099 : // but a nice debug helper.
1100 : getURL();
1101 : #endif
1102 : }
1103 63709 : }
1104 :
1105 : //=========================================================================
1106 390 : void Content_Impl::reinit( const Reference< XContent >& xContent )
1107 : {
1108 390 : osl::MutexGuard aGuard( m_aMutex );
1109 :
1110 390 : m_xCommandProcessor = 0;
1111 :
1112 : // #92581# - Don't reset m_aURL!!!
1113 :
1114 390 : if ( m_xContent.is() )
1115 : {
1116 : try
1117 : {
1118 390 : m_xContent->removeContentEventListener( m_xContentEventListener );
1119 : }
1120 0 : catch ( RuntimeException const & )
1121 : {
1122 : }
1123 : }
1124 :
1125 390 : if ( xContent.is() )
1126 : {
1127 0 : m_xContent = xContent;
1128 0 : m_xContent->addContentEventListener( m_xContentEventListener );
1129 :
1130 : #if OSL_DEBUG_LEVEL > 1
1131 : // Only done on demand in product version for performance reasons,
1132 : // but a nice debug helper.
1133 : getURL();
1134 : #endif
1135 : }
1136 : else
1137 : {
1138 : // We need m_xContent's URL in order to be able to create the
1139 : // content object again if demanded ( --> Content_Impl::getContent() )
1140 390 : getURL();
1141 :
1142 390 : m_xContent = 0;
1143 390 : }
1144 390 : }
1145 :
1146 : //=========================================================================
1147 : // virtual
1148 265410 : Content_Impl::~Content_Impl()
1149 : {
1150 88470 : if ( m_xContent.is() )
1151 : {
1152 : try
1153 : {
1154 63273 : m_xContent->removeContentEventListener( m_xContentEventListener );
1155 : }
1156 0 : catch ( RuntimeException const & )
1157 : {
1158 : }
1159 : }
1160 176940 : }
1161 :
1162 : //=========================================================================
1163 0 : void Content_Impl::disposing( const EventObject& Source )
1164 : {
1165 0 : Reference<XContent> xContent;
1166 :
1167 : {
1168 0 : osl::MutexGuard aGuard( m_aMutex );
1169 0 : if(Source.Source != m_xContent)
1170 0 : return;
1171 :
1172 0 : xContent = m_xContent;
1173 :
1174 0 : m_aURL = OUString();
1175 0 : m_xCommandProcessor = 0;
1176 0 : m_xContent = 0;
1177 : }
1178 :
1179 0 : if ( xContent.is() )
1180 : {
1181 : try
1182 : {
1183 0 : xContent->removeContentEventListener( m_xContentEventListener );
1184 : }
1185 0 : catch ( RuntimeException const & )
1186 : {
1187 : }
1188 0 : }
1189 : }
1190 :
1191 : //=========================================================================
1192 3129 : const OUString& Content_Impl::getURL() const
1193 : {
1194 3129 : if ( m_aURL.isEmpty() && m_xContent.is() )
1195 : {
1196 3121 : osl::MutexGuard aGuard( m_aMutex );
1197 :
1198 3121 : if ( m_aURL.isEmpty() && m_xContent.is() )
1199 : {
1200 3121 : Reference< XContentIdentifier > xId = m_xContent->getIdentifier();
1201 3121 : if ( xId.is() )
1202 3121 : m_aURL = xId->getContentIdentifier();
1203 3121 : }
1204 : }
1205 :
1206 3129 : return m_aURL;
1207 : }
1208 :
1209 : //=========================================================================
1210 80051 : Reference< XContent > Content_Impl::getContent()
1211 : {
1212 80051 : if ( !m_xContent.is() && !m_aURL.isEmpty() )
1213 : {
1214 2 : osl::MutexGuard aGuard( m_aMutex );
1215 :
1216 2 : if ( !m_xContent.is() && !m_aURL.isEmpty() )
1217 : {
1218 : Reference< XUniversalContentBroker > pBroker(
1219 2 : UniversalContentBroker::create( getComponentContext() ) );
1220 :
1221 : OSL_ENSURE( pBroker->queryContentProviders().getLength(),
1222 : "Content Broker not configured (no providers)!" );
1223 :
1224 : Reference< XContentIdentifier > xId
1225 4 : = pBroker->createContentIdentifier( m_aURL );
1226 :
1227 : OSL_ENSURE( xId.is(), "No Content Identifier!" );
1228 :
1229 2 : if ( xId.is() )
1230 : {
1231 : try
1232 : {
1233 2 : m_xContent = pBroker->queryContent( xId );
1234 : }
1235 0 : catch ( IllegalIdentifierException const & )
1236 : {
1237 : }
1238 :
1239 2 : if ( m_xContent.is() )
1240 2 : m_xContent->addContentEventListener(
1241 2 : m_xContentEventListener );
1242 2 : }
1243 2 : }
1244 : }
1245 :
1246 80051 : return m_xContent;
1247 : }
1248 :
1249 : //=========================================================================
1250 74081 : Reference< XCommandProcessor > Content_Impl::getCommandProcessor()
1251 : {
1252 74081 : if ( !m_xCommandProcessor.is() )
1253 : {
1254 46111 : osl::MutexGuard aGuard( m_aMutex );
1255 :
1256 46111 : if ( !m_xCommandProcessor.is() )
1257 : m_xCommandProcessor
1258 46111 : = Reference< XCommandProcessor >( getContent(), UNO_QUERY );
1259 : }
1260 :
1261 74081 : return m_xCommandProcessor;
1262 : }
1263 :
1264 : //=========================================================================
1265 74081 : Any Content_Impl::executeCommand( const Command& rCommand )
1266 : {
1267 74081 : Reference< XCommandProcessor > xProc = getCommandProcessor();
1268 74081 : if ( !xProc.is() )
1269 0 : return Any();
1270 :
1271 : // Execute command
1272 74081 : return xProc->execute( rCommand, 0, m_xEnv );
1273 : }
1274 :
1275 : //=========================================================================
1276 : inline const Reference< XCommandEnvironment >&
1277 2502 : Content_Impl::getEnvironment() const
1278 : {
1279 2502 : return m_xEnv;
1280 : }
1281 :
1282 : //=========================================================================
1283 2794 : inline void Content_Impl::setEnvironment(
1284 : const Reference< XCommandEnvironment >& xNewEnv )
1285 : {
1286 2794 : osl::MutexGuard aGuard( m_aMutex );
1287 2794 : m_xEnv = xNewEnv;
1288 2794 : }
1289 :
1290 : //=========================================================================
1291 2619 : void Content_Impl::inserted()
1292 : {
1293 : // URL might have changed during 'insert' => recalculate in next getURL()
1294 2619 : osl::MutexGuard aGuard( m_aMutex );
1295 2619 : m_aURL = OUString();
1296 2619 : }
1297 :
1298 : //=========================================================================
1299 : //=========================================================================
1300 : //
1301 : // ContentEventListener_Impl Implementation.
1302 : //
1303 : //=========================================================================
1304 : //=========================================================================
1305 :
1306 : //=========================================================================
1307 : //
1308 : // XInterface methods.
1309 : //
1310 : //=========================================================================
1311 :
1312 444074 : XINTERFACE_IMPL_2( ContentEventListener_Impl,
1313 : XContentEventListener,
1314 : XEventListener ); /* base of XContentEventListener */
1315 :
1316 : //=========================================================================
1317 : //
1318 : // XContentEventListener methods.
1319 : //
1320 : //=========================================================================
1321 :
1322 : // virtual
1323 3108 : void SAL_CALL ContentEventListener_Impl::contentEvent( const ContentEvent& evt )
1324 : throw( RuntimeException )
1325 : {
1326 3108 : if ( evt.Source == m_rContent.m_xContent )
1327 : {
1328 3108 : switch ( evt.Action )
1329 : {
1330 : case ContentAction::DELETED:
1331 390 : m_rContent.reinit( Reference< XContent >() );
1332 390 : break;
1333 :
1334 : case ContentAction::EXCHANGED:
1335 0 : m_rContent.reinit( evt.Content );
1336 0 : break;
1337 :
1338 : default:
1339 2718 : break;
1340 : }
1341 : }
1342 3108 : }
1343 :
1344 : //=========================================================================
1345 : //
1346 : // XEventListenr methods.
1347 : //
1348 : //=========================================================================
1349 :
1350 : // virtual
1351 0 : void SAL_CALL ContentEventListener_Impl::disposing( const EventObject& Source )
1352 : throw( RuntimeException )
1353 : {
1354 0 : m_rContent.disposing(Source);
1355 0 : }
1356 :
1357 : } /* namespace ucbhelper */
1358 :
1359 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|