1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 /**************************************************************************
23 **************************************************************************
25 *************************************************************************/
26 #include <osl/diagnose.h>
27 #include <comphelper/processfactory.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <com/sun/star/lang/IllegalArgumentException.hpp>
30 #include <com/sun/star/ucb/GlobalTransferCommandArgument2.hpp>
31 #include <com/sun/star/ucb/XCommandInfo.hpp>
32 #include <com/sun/star/ucb/XContentProvider.hpp>
33 #include <com/sun/star/ucb/XContentProviderSupplier.hpp>
34 #include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
35 #include <com/sun/star/ucb/XContentProviderFactory.hpp>
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #include <com/sun/star/configuration/theDefaultProvider.hpp>
38 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <ucbhelper/cancelcommandexecution.hxx>
42 #include "identify.hxx"
43 #include "ucbcmds.hxx"
48 using namespace com::sun::star::uno
;
49 using namespace com::sun::star::lang
;
50 using namespace com::sun::star::ucb
;
51 using namespace ucb_impl
;
52 using namespace com::sun::star
;
53 using namespace ucbhelper
;
56 #define CONFIG_CONTENTPROVIDERS_KEY \
57 "/org.openoffice.ucb.Configuration/ContentProviders"
62 bool fillPlaceholders(OUString
const & rInput
,
63 uno::Sequence
< uno::Any
> const & rReplacements
,
66 sal_Unicode
const * p
= rInput
.getStr();
67 sal_Unicode
const * pEnd
= p
+ rInput
.getLength();
68 sal_Unicode
const * pCopy
= p
;
69 OUStringBuffer aBuffer
;
75 && p
[0] == 'a' && p
[1] == 'm' && p
[2] == 'p'
78 aBuffer
.append(pCopy
, p
- 1 - pCopy
);
83 else if (pEnd
- p
>= 3
84 && p
[0] == 'l' && p
[1] == 't' && p
[2] == ';')
86 aBuffer
.append(pCopy
, p
- 1 - pCopy
);
91 else if (pEnd
- p
>= 3
92 && p
[0] == 'g' && p
[1] == 't' && p
[2] == ';')
94 aBuffer
.append(pCopy
, p
- 1 - pCopy
);
102 sal_Unicode
const * q
= p
;
103 while (q
!= pEnd
&& *q
!= '>')
107 OUString
aKey(p
, q
- p
);
110 for (sal_Int32 i
= 2; i
+ 1 < rReplacements
.getLength();
113 OUString aReplaceKey
;
114 if ((rReplacements
[i
] >>= aReplaceKey
)
115 && aReplaceKey
== aKey
116 && (rReplacements
[i
+ 1] >>= aValue
))
124 aBuffer
.append(pCopy
, p
- 1 - pCopy
);
125 aBuffer
.append(aValue
);
130 aBuffer
.append(pCopy
, pEnd
- pCopy
);
131 *pOutput
= aBuffer
.makeStringAndClear();
135 void makeAndAppendXMLName(
136 OUStringBuffer
& rBuffer
, const OUString
& rIn
)
138 sal_Int32 nCount
= rIn
.getLength();
139 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
141 const sal_Unicode c
= rIn
[ n
];
145 rBuffer
.appendAscii( "&" );
149 rBuffer
.appendAscii( """ );
153 rBuffer
.appendAscii( "'" );
157 rBuffer
.appendAscii( "<" );
161 rBuffer
.appendAscii( ">" );
171 bool createContentProviderData(
172 const OUString
& rProvider
,
173 const uno::Reference
< container::XHierarchicalNameAccess
>& rxHierNameAccess
,
174 ContentProviderData
& rInfo
)
176 // Obtain service name.
177 OUStringBuffer
aKeyBuffer (rProvider
);
178 aKeyBuffer
.appendAscii( "/ServiceName" );
183 if ( !( rxHierNameAccess
->getByHierarchicalName(
184 aKeyBuffer
.makeStringAndClear() ) >>= aValue
) )
186 OSL_FAIL( "UniversalContentBroker::getContentProviderData - "
187 "Error getting item value!" );
190 catch (const container::NoSuchElementException
&)
195 rInfo
.ServiceName
= aValue
;
197 // Obtain URL Template.
198 aKeyBuffer
.append(rProvider
);
199 aKeyBuffer
.appendAscii( "/URLTemplate" );
201 if ( !( rxHierNameAccess
->getByHierarchicalName(
202 aKeyBuffer
.makeStringAndClear() ) >>= aValue
) )
204 OSL_FAIL( "UniversalContentBroker::getContentProviderData - "
205 "Error getting item value!" );
208 rInfo
.URLTemplate
= aValue
;
211 aKeyBuffer
.append(rProvider
);
212 aKeyBuffer
.appendAscii( "/Arguments" );
214 if ( !( rxHierNameAccess
->getByHierarchicalName(
215 aKeyBuffer
.makeStringAndClear() ) >>= aValue
) )
217 OSL_FAIL( "UniversalContentBroker::getContentProviderData - "
218 "Error getting item value!" );
221 rInfo
.Arguments
= aValue
;
227 //=========================================================================
229 // UniversalContentBroker Implementation.
231 //=========================================================================
233 UniversalContentBroker::UniversalContentBroker(
234 const Reference
< com::sun::star::uno::XComponentContext
>& xContext
)
235 : m_xContext( xContext
),
236 m_pDisposeEventListeners( NULL
),
237 m_nInitCount( 0 ), //@@@ see initialize() method
240 OSL_ENSURE( m_xContext
.is(),
241 "UniversalContentBroker ctor: No service manager" );
244 //=========================================================================
246 UniversalContentBroker::~UniversalContentBroker()
248 delete m_pDisposeEventListeners
;
251 //=========================================================================
253 // XInterface methods.
255 //=========================================================================
257 XINTERFACE_IMPL_9( UniversalContentBroker
,
258 XUniversalContentBroker
,
263 XContentProviderManager
,
265 XContentIdentifierFactory
,
268 //=========================================================================
270 // XTypeProvider methods.
272 //=========================================================================
274 XTYPEPROVIDER_IMPL_9( UniversalContentBroker
,
275 XUniversalContentBroker
,
280 XContentProviderManager
,
282 XContentIdentifierFactory
,
285 //=========================================================================
287 // XComponent methods.
289 //=========================================================================
292 void SAL_CALL
UniversalContentBroker::dispose()
293 throw( com::sun::star::uno::RuntimeException
)
295 if ( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
298 aEvt
.Source
= (static_cast< XComponent
* >(this));
299 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
302 if ( m_xNotifier
.is() )
303 m_xNotifier
->removeChangesListener( this );
306 //=========================================================================
308 void SAL_CALL
UniversalContentBroker::addEventListener(
309 const Reference
< XEventListener
>& Listener
)
310 throw( com::sun::star::uno::RuntimeException
)
312 if ( !m_pDisposeEventListeners
)
313 m_pDisposeEventListeners
= new OInterfaceContainerHelper( m_aMutex
);
315 m_pDisposeEventListeners
->addInterface( Listener
);
318 //=========================================================================
320 void SAL_CALL
UniversalContentBroker::removeEventListener(
321 const Reference
< XEventListener
>& Listener
)
322 throw( com::sun::star::uno::RuntimeException
)
324 if ( m_pDisposeEventListeners
)
325 m_pDisposeEventListeners
->removeInterface( Listener
);
327 // Note: Don't want to delete empty container here -> performance.
330 //=========================================================================
332 // XServiceInfo methods.
334 //=========================================================================
336 XSERVICEINFO_IMPL_1_CTX( UniversalContentBroker
,
337 OUString( "com.sun.star.comp.ucb.UniversalContentBroker" ),
338 OUString( UCB_SERVICE_NAME
) );
340 //=========================================================================
342 // Service factory implementation.
344 //=========================================================================
346 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UniversalContentBroker
);
348 //=========================================================================
350 // XInitialization methods.
352 //=========================================================================
355 void SAL_CALL
UniversalContentBroker::initialize(
356 const com::sun::star::uno::Sequence
< Any
>& aArguments
)
357 throw( com::sun::star::uno::Exception
,
358 com::sun::star::uno::RuntimeException
)
361 osl::MutexGuard
aGuard(m_aMutex
);
362 if (m_aArguments
.getLength() != 0)
364 if (aArguments
.getLength() != 0
365 && !(m_aArguments
.getLength() == 2
366 && aArguments
.getLength() == 2
367 && m_aArguments
[0] == aArguments
[0]
368 && m_aArguments
[1] == aArguments
[1]))
370 throw IllegalArgumentException(
371 "UCB reinitialized with different arguments",
372 static_cast< cppu::OWeakObject
* >(this), 0);
376 if (aArguments
.getLength() == 0)
378 m_aArguments
.realloc(2);
379 m_aArguments
[0] <<= OUString("Local");
380 m_aArguments
[1] <<= OUString("Office");
384 m_aArguments
= aArguments
;
390 //=========================================================================
392 // XContentProviderManager methods.
394 //=========================================================================
397 Reference
< XContentProvider
> SAL_CALL
398 UniversalContentBroker::registerContentProvider(
399 const Reference
< XContentProvider
>& Provider
,
400 const OUString
& Scheme
,
401 sal_Bool ReplaceExisting
)
402 throw( DuplicateProviderException
, com::sun::star::uno::RuntimeException
)
404 osl::MutexGuard
aGuard(m_aMutex
);
406 ProviderMap_Impl::iterator aIt
;
409 aIt
= m_aProviders
.find(Scheme
);
411 catch (const IllegalArgumentException
&)
416 Reference
< XContentProvider
> xPrevious
;
417 if (aIt
== m_aProviders
.end())
419 ProviderList_Impl aList
;
420 aList
.push_front(Provider
);
423 m_aProviders
.add(Scheme
, aList
, false);
425 catch (const IllegalArgumentException
&)
432 if (!ReplaceExisting
)
433 throw DuplicateProviderException();
435 ProviderList_Impl
& rList
= aIt
->getValue();
436 xPrevious
= rList
.front().getProvider();
437 rList
.push_front(Provider
);
443 //=========================================================================
445 void SAL_CALL
UniversalContentBroker::deregisterContentProvider(
446 const Reference
< XContentProvider
>& Provider
,
447 const OUString
& Scheme
)
448 throw( com::sun::star::uno::RuntimeException
)
450 osl::MutexGuard
aGuard(m_aMutex
);
452 ProviderMap_Impl::iterator aMapIt
;
455 aMapIt
= m_aProviders
.find(Scheme
);
457 catch (const IllegalArgumentException
&)
462 if (aMapIt
!= m_aProviders
.end())
464 ProviderList_Impl
& rList
= aMapIt
->getValue();
466 ProviderList_Impl::iterator
aListEnd(rList
.end());
467 for (ProviderList_Impl::iterator
aListIt(rList
.begin());
468 aListIt
!= aListEnd
; ++aListIt
)
470 if ((*aListIt
).getProvider() == Provider
)
472 rList
.erase(aListIt
);
478 m_aProviders
.erase(aMapIt
);
482 //=========================================================================
484 com::sun::star::uno::Sequence
< ContentProviderInfo
> SAL_CALL
485 UniversalContentBroker::queryContentProviders()
486 throw( com::sun::star::uno::RuntimeException
)
488 // Return a list with information about active(!) content providers.
490 osl::MutexGuard
aGuard(m_aMutex
);
492 com::sun::star::uno::Sequence
< ContentProviderInfo
> aSeq(
493 m_aProviders
.size() );
494 ContentProviderInfo
* pInfo
= aSeq
.getArray();
496 ProviderMap_Impl::const_iterator end
= m_aProviders
.end();
497 for (ProviderMap_Impl::const_iterator
it(m_aProviders
.begin()); it
!= end
;
500 // Note: Active provider is always the first list element.
501 pInfo
->ContentProvider
= it
->getValue().front().getProvider();
502 pInfo
->Scheme
= it
->getRegexp();
509 //=========================================================================
511 Reference
< XContentProvider
> SAL_CALL
512 UniversalContentBroker::queryContentProvider( const OUString
&
514 throw( com::sun::star::uno::RuntimeException
)
516 return queryContentProvider( Identifier
, sal_False
);
519 //=========================================================================
521 // XContentProvider methods.
523 //=========================================================================
526 Reference
< XContent
> SAL_CALL
UniversalContentBroker::queryContent(
527 const Reference
< XContentIdentifier
>& Identifier
)
528 throw( IllegalIdentifierException
, com::sun::star::uno::RuntimeException
)
530 //////////////////////////////////////////////////////////////////////
531 // Let the content provider for the scheme given with the content
532 // identifier create the XContent instance.
533 //////////////////////////////////////////////////////////////////////
535 if ( !Identifier
.is() )
536 return Reference
< XContent
>();
538 Reference
< XContentProvider
> xProv
=
539 queryContentProvider( Identifier
->getContentIdentifier(), sal_True
);
541 return xProv
->queryContent( Identifier
);
543 return Reference
< XContent
>();
546 //=========================================================================
548 sal_Int32 SAL_CALL
UniversalContentBroker::compareContentIds(
549 const Reference
< XContentIdentifier
>& Id1
,
550 const Reference
< XContentIdentifier
>& Id2
)
551 throw( com::sun::star::uno::RuntimeException
)
553 OUString
aURI1( Id1
->getContentIdentifier() );
554 OUString
aURI2( Id2
->getContentIdentifier() );
556 Reference
< XContentProvider
> xProv1
557 = queryContentProvider( aURI1
, sal_True
);
558 Reference
< XContentProvider
> xProv2
559 = queryContentProvider( aURI2
, sal_True
);
561 // When both identifiers belong to the same provider, let that provider
562 // compare them; otherwise, simply compare the URI strings (which must
564 if ( xProv1
.is() && ( xProv1
== xProv2
) )
565 return xProv1
->compareContentIds( Id1
, Id2
);
567 return aURI1
.compareTo( aURI2
);
570 //=========================================================================
572 // XContentIdentifierFactory methods.
574 //=========================================================================
577 Reference
< XContentIdentifier
> SAL_CALL
578 UniversalContentBroker::createContentIdentifier(
579 const OUString
& ContentId
)
580 throw( com::sun::star::uno::RuntimeException
)
582 //////////////////////////////////////////////////////////////////////
583 // Let the content provider for the scheme given with content
584 // identifier create the XContentIdentifier instance, if he supports
585 // the XContentIdentifierFactory interface. Otherwise create standard
586 // implementation object for XContentIdentifier.
587 //////////////////////////////////////////////////////////////////////
589 Reference
< XContentIdentifier
> xIdentifier
;
591 Reference
< XContentProvider
> xProv
592 = queryContentProvider( ContentId
, sal_True
);
595 Reference
< XContentIdentifierFactory
> xFac( xProv
, UNO_QUERY
);
597 xIdentifier
= xFac
->createContentIdentifier( ContentId
);
600 if ( !xIdentifier
.is() )
601 xIdentifier
= new ContentIdentifier( ContentId
);
606 //=========================================================================
608 // XCommandProcessor methods.
610 //=========================================================================
613 sal_Int32 SAL_CALL
UniversalContentBroker::createCommandIdentifier()
614 throw( RuntimeException
)
616 osl::MutexGuard
aGuard( m_aMutex
);
618 // Just increase counter on every call to generate an identifier.
619 return ++m_nCommandId
;
622 //=========================================================================
624 Any SAL_CALL
UniversalContentBroker::execute(
625 const Command
& aCommand
,
627 const Reference
< XCommandEnvironment
>& Environment
)
628 throw( Exception
, CommandAbortedException
, RuntimeException
)
632 //////////////////////////////////////////////////////////////////////
633 // Note: Don't forget to adapt ucb_commands::CommandProcessorInfo
634 // ctor in ucbcmds.cxx when adding new commands!
635 //////////////////////////////////////////////////////////////////////
637 if ( ( aCommand
.Handle
== GETCOMMANDINFO_HANDLE
) || aCommand
.Name
== GETCOMMANDINFO_NAME
)
639 //////////////////////////////////////////////////////////////////
641 //////////////////////////////////////////////////////////////////
643 aRet
<<= getCommandInfo();
645 else if ( ( aCommand
.Handle
== GLOBALTRANSFER_HANDLE
) || aCommand
.Name
== GLOBALTRANSFER_NAME
)
647 //////////////////////////////////////////////////////////////////
649 //////////////////////////////////////////////////////////////////
651 GlobalTransferCommandArgument2 aTransferArg
;
652 if ( !( aCommand
.Argument
>>= aTransferArg
) )
654 GlobalTransferCommandArgument aArg
;
655 if ( !( aCommand
.Argument
>>= aArg
) )
657 ucbhelper::cancelCommandExecution(
658 makeAny( IllegalArgumentException(
659 OUString( "Wrong argument type!" ),
660 static_cast< cppu::OWeakObject
* >( this ),
666 // Copy infos into the new stucture
667 aTransferArg
.Operation
= aArg
.Operation
;
668 aTransferArg
.SourceURL
= aArg
.SourceURL
;
669 aTransferArg
.TargetURL
= aArg
.TargetURL
;
670 aTransferArg
.NewTitle
= aArg
.NewTitle
;
671 aTransferArg
.NameClash
= aArg
.NameClash
;
674 globalTransfer( aTransferArg
, Environment
);
676 else if ( ( aCommand
.Handle
== CHECKIN_HANDLE
) || aCommand
.Name
== CHECKIN_NAME
)
678 ucb::CheckinArgument aCheckinArg
;
679 if ( !( aCommand
.Argument
>>= aCheckinArg
) )
681 ucbhelper::cancelCommandExecution(
682 makeAny( IllegalArgumentException(
683 OUString( "Wrong argument type!" ),
684 static_cast< cppu::OWeakObject
* >( this ),
689 aRet
<<= checkIn( aCheckinArg
, Environment
);
693 //////////////////////////////////////////////////////////////////
695 //////////////////////////////////////////////////////////////////
697 ucbhelper::cancelCommandExecution(
698 makeAny( UnsupportedCommandException(
700 static_cast< cppu::OWeakObject
* >( this ) ) ),
708 //=========================================================================
710 // XCommandProcessor2 methods.
712 //=========================================================================
715 void SAL_CALL
UniversalContentBroker::releaseCommandIdentifier(sal_Int32
/*aCommandId*/)
716 throw( RuntimeException
)
718 // @@@ Not implemeted ( yet).
721 //=========================================================================
723 void SAL_CALL
UniversalContentBroker::abort( sal_Int32
)
724 throw( RuntimeException
)
726 // @@@ Not implemeted ( yet).
729 //=========================================================================
731 // XChangesListener methods
733 //=========================================================================
735 void SAL_CALL
UniversalContentBroker::changesOccurred( const util::ChangesEvent
& Event
)
736 throw( uno::RuntimeException
)
738 sal_Int32 nCount
= Event
.Changes
.getLength();
741 uno::Reference
< container::XHierarchicalNameAccess
> xHierNameAccess
;
742 Event
.Base
>>= xHierNameAccess
;
744 OSL_ASSERT( xHierNameAccess
.is() );
746 const util::ElementChange
* pElementChanges
747 = Event
.Changes
.getConstArray();
749 ContentProviderDataList aData
;
750 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
752 const util::ElementChange
& rElem
= pElementChanges
[ n
];
754 rElem
.Accessor
>>= aKey
;
756 ContentProviderData aInfo
;
758 // Removal of UCPs from the configuration leads to changesOccurred
759 // notifications, too, but it is hard to tell for a given
760 // ElementChange whether it is an addition or a removal, so as a
761 // heuristic consider as removals those that cause a
762 // NoSuchElementException in createContentProviderData.
764 // For now, removal of UCPs from the configuration is simply ignored
765 // (and not reflected in the UCB's data structures):
766 if (createContentProviderData(aKey
, xHierNameAccess
, aInfo
))
768 aData
.push_back(aInfo
);
772 prepareAndRegister(aData
);
776 //=========================================================================
778 // XEventListener methods
780 //=========================================================================
782 void SAL_CALL
UniversalContentBroker::disposing(const lang::EventObject
&)
783 throw( uno::RuntimeException
)
785 if ( m_xNotifier
.is() )
787 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
789 if ( m_xNotifier
.is() )
794 //=========================================================================
796 // Non-interface methods
798 //=========================================================================
800 Reference
< XContentProvider
> UniversalContentBroker::queryContentProvider(
801 const OUString
& Identifier
,
804 osl::MutexGuard
aGuard( m_aMutex
);
806 ProviderList_Impl
const * pList
= m_aProviders
.map( Identifier
);
807 return pList
? bResolved
? pList
->front().getResolvedProvider()
808 : pList
->front().getProvider()
809 : Reference
< XContentProvider
>();
812 bool UniversalContentBroker::configureUcb()
813 throw (uno::RuntimeException
)
817 if (m_aArguments
.getLength() < 2
818 || !(m_aArguments
[0] >>= aKey1
) || !(m_aArguments
[1] >>= aKey2
))
820 OSL_FAIL("UniversalContentBroker::configureUcb(): Bad arguments");
824 ContentProviderDataList aData
;
825 if (!getContentProviderData(aKey1
, aKey2
, aData
))
827 OSL_TRACE("UniversalContentBroker::configureUcb(): No configuration");
831 prepareAndRegister(aData
);
836 void UniversalContentBroker::prepareAndRegister(
837 const ContentProviderDataList
& rData
)
839 ContentProviderDataList::const_iterator
aEnd(rData
.end());
840 for (ContentProviderDataList::const_iterator
aIt(rData
.begin());
843 OUString aProviderArguments
;
844 if (fillPlaceholders(aIt
->Arguments
,
846 &aProviderArguments
))
856 OSL_FAIL("UniversalContentBroker::prepareAndRegister(): Bad argument placeholders");
860 //=========================================================================
861 bool UniversalContentBroker::getContentProviderData(
862 const OUString
& rKey1
,
863 const OUString
& rKey2
,
864 ContentProviderDataList
& rListToFill
)
866 if ( !m_xContext
.is() || rKey1
.isEmpty() || rKey2
.isEmpty() )
868 OSL_FAIL( "UniversalContentBroker::getContentProviderData - Invalid argument!" );
874 uno::Reference
< lang::XMultiServiceFactory
> xConfigProv
=
875 configuration::theDefaultProvider::get( m_xContext
);
877 OUStringBuffer aFullPath
;
878 aFullPath
.appendAscii( CONFIG_CONTENTPROVIDERS_KEY
"/['" );
879 makeAndAppendXMLName( aFullPath
, rKey1
);
880 aFullPath
.appendAscii( "']/SecondaryKeys/['" );
881 makeAndAppendXMLName( aFullPath
, rKey2
);
882 aFullPath
.appendAscii( "']/ProviderData" );
884 uno::Sequence
< uno::Any
> aArguments( 1 );
885 beans::PropertyValue aProperty
;
886 aProperty
.Name
= "nodepath";
887 aProperty
.Value
<<= aFullPath
.makeStringAndClear();
888 aArguments
[ 0 ] <<= aProperty
;
890 uno::Reference
< uno::XInterface
> xInterface(
891 xConfigProv
->createInstanceWithArguments(
892 OUString( "com.sun.star.configuration.ConfigurationAccess" ),
895 if ( !m_xNotifier
.is() )
897 m_xNotifier
= uno::Reference
< util::XChangesNotifier
>(
898 xInterface
, uno::UNO_QUERY_THROW
);
900 m_xNotifier
->addChangesListener( this );
903 uno::Reference
< container::XNameAccess
> xNameAccess(
904 xInterface
, uno::UNO_QUERY_THROW
);
906 uno::Sequence
< OUString
> aElems
= xNameAccess
->getElementNames();
907 const OUString
* pElems
= aElems
.getConstArray();
908 sal_Int32 nCount
= aElems
.getLength();
912 uno::Reference
< container::XHierarchicalNameAccess
>
913 xHierNameAccess( xInterface
, uno::UNO_QUERY_THROW
);
915 // Iterate over children.
916 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
922 ContentProviderData aInfo
;
924 OUStringBuffer aElemBuffer
;
925 aElemBuffer
.appendAscii( "['" );
926 makeAndAppendXMLName( aElemBuffer
, pElems
[ n
] );
927 aElemBuffer
.appendAscii( "']" );
930 createContentProviderData(
931 aElemBuffer
.makeStringAndClear(), xHierNameAccess
,
934 rListToFill
.push_back( aInfo
);
936 catch (const container::NoSuchElementException
&)
938 // getByHierarchicalName
939 OSL_FAIL( "UniversalContentBroker::getContentProviderData - "
940 "caught NoSuchElementException!" );
945 catch (const uno::RuntimeException
&)
947 OSL_TRACE( "UniversalContentBroker::getContentProviderData - caught RuntimeException!" );
950 catch (const uno::Exception
&)
952 // createInstance, createInstanceWithArguments
954 OSL_TRACE( "UniversalContentBroker::getContentProviderData - caught Exception!" );
961 //=========================================================================
963 // ProviderListEntry_Impl implementation.
965 //=========================================================================
967 Reference
< XContentProvider
> ProviderListEntry_Impl::resolveProvider() const
969 if ( !m_xResolvedProvider
.is() )
971 Reference
< XContentProviderSupplier
> xSupplier(
972 m_xProvider
, UNO_QUERY
);
973 if ( xSupplier
.is() )
974 m_xResolvedProvider
= xSupplier
->getContentProvider();
976 if ( !m_xResolvedProvider
.is() )
977 m_xResolvedProvider
= m_xProvider
;
980 return m_xResolvedProvider
;
983 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */