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
;
229 // UniversalContentBroker Implementation.
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" );
246 UniversalContentBroker::~UniversalContentBroker()
248 delete m_pDisposeEventListeners
;
253 // XInterface methods.
254 void SAL_CALL
UniversalContentBroker::acquire()
257 OWeakObject::acquire();
260 void SAL_CALL
UniversalContentBroker::release()
263 OWeakObject::release();
266 css::uno::Any SAL_CALL
UniversalContentBroker::queryInterface( const css::uno::Type
& rType
)
267 throw( css::uno::RuntimeException
, std::exception
)
269 css::uno::Any aRet
= cppu::queryInterface( rType
,
270 (static_cast< XUniversalContentBroker
* >(this)),
271 (static_cast< XTypeProvider
* >(this)),
272 (static_cast< XComponent
* >(this)),
273 (static_cast< XServiceInfo
* >(this)),
274 (static_cast< XInitialization
* >(this)),
275 (static_cast< XContentProviderManager
* >(this)),
276 (static_cast< XContentProvider
* >(this)),
277 (static_cast< XContentIdentifierFactory
* >(this)),
278 (static_cast< XCommandProcessor
* >(this))
280 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
283 // XTypeProvider methods.
287 XTYPEPROVIDER_IMPL_9( UniversalContentBroker
,
288 XUniversalContentBroker
,
293 XContentProviderManager
,
295 XContentIdentifierFactory
,
300 // XComponent methods.
305 void SAL_CALL
UniversalContentBroker::dispose()
306 throw( com::sun::star::uno::RuntimeException
, std::exception
)
308 if ( m_pDisposeEventListeners
&& m_pDisposeEventListeners
->getLength() )
311 aEvt
.Source
= (static_cast< XComponent
* >(this));
312 m_pDisposeEventListeners
->disposeAndClear( aEvt
);
315 if ( m_xNotifier
.is() )
316 m_xNotifier
->removeChangesListener( this );
321 void SAL_CALL
UniversalContentBroker::addEventListener(
322 const Reference
< XEventListener
>& Listener
)
323 throw( com::sun::star::uno::RuntimeException
, std::exception
)
325 if ( !m_pDisposeEventListeners
)
326 m_pDisposeEventListeners
= new OInterfaceContainerHelper( m_aMutex
);
328 m_pDisposeEventListeners
->addInterface( Listener
);
333 void SAL_CALL
UniversalContentBroker::removeEventListener(
334 const Reference
< XEventListener
>& Listener
)
335 throw( com::sun::star::uno::RuntimeException
, std::exception
)
337 if ( m_pDisposeEventListeners
)
338 m_pDisposeEventListeners
->removeInterface( Listener
);
340 // Note: Don't want to delete empty container here -> performance.
345 // XServiceInfo methods.
349 XSERVICEINFO_IMPL_1_CTX( UniversalContentBroker
,
350 OUString( "com.sun.star.comp.ucb.UniversalContentBroker" ),
351 OUString( UCB_SERVICE_NAME
) );
355 // Service factory implementation.
359 ONE_INSTANCE_SERVICE_FACTORY_IMPL( UniversalContentBroker
);
363 // XInitialization methods.
368 void SAL_CALL
UniversalContentBroker::initialize(
369 const com::sun::star::uno::Sequence
< Any
>& aArguments
)
370 throw( com::sun::star::uno::Exception
,
371 com::sun::star::uno::RuntimeException
, std::exception
)
374 osl::MutexGuard
aGuard(m_aMutex
);
375 if (m_aArguments
.getLength() != 0)
377 if (aArguments
.getLength() != 0
378 && !(m_aArguments
.getLength() == 2
379 && aArguments
.getLength() == 2
380 && m_aArguments
[0] == aArguments
[0]
381 && m_aArguments
[1] == aArguments
[1]))
383 throw IllegalArgumentException(
384 "UCB reinitialized with different arguments",
385 static_cast< cppu::OWeakObject
* >(this), 0);
389 if (aArguments
.getLength() == 0)
391 m_aArguments
.realloc(2);
392 m_aArguments
[0] <<= OUString("Local");
393 m_aArguments
[1] <<= OUString("Office");
397 m_aArguments
= aArguments
;
405 // XContentProviderManager methods.
410 Reference
< XContentProvider
> SAL_CALL
411 UniversalContentBroker::registerContentProvider(
412 const Reference
< XContentProvider
>& Provider
,
413 const OUString
& Scheme
,
414 sal_Bool ReplaceExisting
)
415 throw( DuplicateProviderException
, com::sun::star::uno::RuntimeException
, std::exception
)
417 osl::MutexGuard
aGuard(m_aMutex
);
419 ProviderMap_Impl::iterator aIt
;
422 aIt
= m_aProviders
.find(Scheme
);
424 catch (const IllegalArgumentException
&)
429 Reference
< XContentProvider
> xPrevious
;
430 if (aIt
== m_aProviders
.end())
432 ProviderList_Impl aList
;
433 aList
.push_front(Provider
);
436 m_aProviders
.add(Scheme
, aList
, false);
438 catch (const IllegalArgumentException
&)
445 if (!ReplaceExisting
)
446 throw DuplicateProviderException();
448 ProviderList_Impl
& rList
= aIt
->getValue();
449 xPrevious
= rList
.front().getProvider();
450 rList
.push_front(Provider
);
458 void SAL_CALL
UniversalContentBroker::deregisterContentProvider(
459 const Reference
< XContentProvider
>& Provider
,
460 const OUString
& Scheme
)
461 throw( com::sun::star::uno::RuntimeException
, std::exception
)
463 osl::MutexGuard
aGuard(m_aMutex
);
465 ProviderMap_Impl::iterator aMapIt
;
468 aMapIt
= m_aProviders
.find(Scheme
);
470 catch (const IllegalArgumentException
&)
475 if (aMapIt
!= m_aProviders
.end())
477 ProviderList_Impl
& rList
= aMapIt
->getValue();
479 ProviderList_Impl::iterator
aListEnd(rList
.end());
480 for (ProviderList_Impl::iterator
aListIt(rList
.begin());
481 aListIt
!= aListEnd
; ++aListIt
)
483 if ((*aListIt
).getProvider() == Provider
)
485 rList
.erase(aListIt
);
491 m_aProviders
.erase(aMapIt
);
497 com::sun::star::uno::Sequence
< ContentProviderInfo
> SAL_CALL
498 UniversalContentBroker::queryContentProviders()
499 throw( com::sun::star::uno::RuntimeException
, std::exception
)
501 // Return a list with information about active(!) content providers.
503 osl::MutexGuard
aGuard(m_aMutex
);
505 com::sun::star::uno::Sequence
< ContentProviderInfo
> aSeq(
506 m_aProviders
.size() );
507 ContentProviderInfo
* pInfo
= aSeq
.getArray();
509 ProviderMap_Impl::const_iterator end
= m_aProviders
.end();
510 for (ProviderMap_Impl::const_iterator
it(m_aProviders
.begin()); it
!= end
;
513 // Note: Active provider is always the first list element.
514 pInfo
->ContentProvider
= it
->getValue().front().getProvider();
515 pInfo
->Scheme
= it
->getRegexp();
524 Reference
< XContentProvider
> SAL_CALL
525 UniversalContentBroker::queryContentProvider( const OUString
&
527 throw( com::sun::star::uno::RuntimeException
, std::exception
)
529 return queryContentProvider( Identifier
, false );
534 // XContentProvider methods.
539 Reference
< XContent
> SAL_CALL
UniversalContentBroker::queryContent(
540 const Reference
< XContentIdentifier
>& Identifier
)
541 throw( IllegalIdentifierException
, com::sun::star::uno::RuntimeException
, std::exception
)
544 // Let the content provider for the scheme given with the content
545 // identifier create the XContent instance.
548 if ( !Identifier
.is() )
549 return Reference
< XContent
>();
551 Reference
< XContentProvider
> xProv
=
552 queryContentProvider( Identifier
->getContentIdentifier(), true );
554 return xProv
->queryContent( Identifier
);
556 return Reference
< XContent
>();
561 sal_Int32 SAL_CALL
UniversalContentBroker::compareContentIds(
562 const Reference
< XContentIdentifier
>& Id1
,
563 const Reference
< XContentIdentifier
>& Id2
)
564 throw( com::sun::star::uno::RuntimeException
, std::exception
)
566 OUString
aURI1( Id1
->getContentIdentifier() );
567 OUString
aURI2( Id2
->getContentIdentifier() );
569 Reference
< XContentProvider
> xProv1
570 = queryContentProvider( aURI1
, true );
571 Reference
< XContentProvider
> xProv2
572 = queryContentProvider( aURI2
, true );
574 // When both identifiers belong to the same provider, let that provider
575 // compare them; otherwise, simply compare the URI strings (which must
577 if ( xProv1
.is() && ( xProv1
== xProv2
) )
578 return xProv1
->compareContentIds( Id1
, Id2
);
580 return aURI1
.compareTo( aURI2
);
585 // XContentIdentifierFactory methods.
590 Reference
< XContentIdentifier
> SAL_CALL
591 UniversalContentBroker::createContentIdentifier(
592 const OUString
& ContentId
)
593 throw( com::sun::star::uno::RuntimeException
, std::exception
)
596 // Let the content provider for the scheme given with content
597 // identifier create the XContentIdentifier instance, if he supports
598 // the XContentIdentifierFactory interface. Otherwise create standard
599 // implementation object for XContentIdentifier.
602 Reference
< XContentIdentifier
> xIdentifier
;
604 Reference
< XContentProvider
> xProv
605 = queryContentProvider( ContentId
, true );
608 Reference
< XContentIdentifierFactory
> xFac( xProv
, UNO_QUERY
);
610 xIdentifier
= xFac
->createContentIdentifier( ContentId
);
613 if ( !xIdentifier
.is() )
614 xIdentifier
= new ContentIdentifier( ContentId
);
621 // XCommandProcessor methods.
626 sal_Int32 SAL_CALL
UniversalContentBroker::createCommandIdentifier()
627 throw( RuntimeException
, std::exception
)
629 osl::MutexGuard
aGuard( m_aMutex
);
631 // Just increase counter on every call to generate an identifier.
632 return ++m_nCommandId
;
637 Any SAL_CALL
UniversalContentBroker::execute(
638 const Command
& aCommand
,
640 const Reference
< XCommandEnvironment
>& Environment
)
641 throw( Exception
, CommandAbortedException
, RuntimeException
, std::exception
)
646 // Note: Don't forget to adapt ucb_commands::CommandProcessorInfo
647 // ctor in ucbcmds.cxx when adding new commands!
650 if ( ( aCommand
.Handle
== GETCOMMANDINFO_HANDLE
) || aCommand
.Name
== GETCOMMANDINFO_NAME
)
656 aRet
<<= getCommandInfo();
658 else if ( ( aCommand
.Handle
== GLOBALTRANSFER_HANDLE
) || aCommand
.Name
== GLOBALTRANSFER_NAME
)
664 GlobalTransferCommandArgument2 aTransferArg
;
665 if ( !( aCommand
.Argument
>>= aTransferArg
) )
667 GlobalTransferCommandArgument aArg
;
668 if ( !( aCommand
.Argument
>>= aArg
) )
670 ucbhelper::cancelCommandExecution(
671 makeAny( IllegalArgumentException(
672 OUString( "Wrong argument type!" ),
673 static_cast< cppu::OWeakObject
* >( this ),
679 // Copy infos into the new stucture
680 aTransferArg
.Operation
= aArg
.Operation
;
681 aTransferArg
.SourceURL
= aArg
.SourceURL
;
682 aTransferArg
.TargetURL
= aArg
.TargetURL
;
683 aTransferArg
.NewTitle
= aArg
.NewTitle
;
684 aTransferArg
.NameClash
= aArg
.NameClash
;
687 globalTransfer( aTransferArg
, Environment
);
689 else if ( ( aCommand
.Handle
== CHECKIN_HANDLE
) || aCommand
.Name
== CHECKIN_NAME
)
691 ucb::CheckinArgument aCheckinArg
;
692 if ( !( aCommand
.Argument
>>= aCheckinArg
) )
694 ucbhelper::cancelCommandExecution(
695 makeAny( IllegalArgumentException(
696 OUString( "Wrong argument type!" ),
697 static_cast< cppu::OWeakObject
* >( this ),
702 aRet
<<= checkIn( aCheckinArg
, Environment
);
710 ucbhelper::cancelCommandExecution(
711 makeAny( UnsupportedCommandException(
713 static_cast< cppu::OWeakObject
* >( this ) ) ),
723 // XCommandProcessor2 methods.
728 void SAL_CALL
UniversalContentBroker::releaseCommandIdentifier(sal_Int32
/*aCommandId*/)
729 throw( RuntimeException
, std::exception
)
731 // @@@ Not implemeted ( yet).
736 void SAL_CALL
UniversalContentBroker::abort( sal_Int32
)
737 throw( RuntimeException
, std::exception
)
739 // @@@ Not implemeted ( yet).
744 // XChangesListener methods
748 void SAL_CALL
UniversalContentBroker::changesOccurred( const util::ChangesEvent
& Event
)
749 throw( uno::RuntimeException
, std::exception
)
751 sal_Int32 nCount
= Event
.Changes
.getLength();
754 uno::Reference
< container::XHierarchicalNameAccess
> xHierNameAccess
;
755 Event
.Base
>>= xHierNameAccess
;
757 OSL_ASSERT( xHierNameAccess
.is() );
759 const util::ElementChange
* pElementChanges
760 = Event
.Changes
.getConstArray();
762 ContentProviderDataList aData
;
763 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
765 const util::ElementChange
& rElem
= pElementChanges
[ n
];
767 rElem
.Accessor
>>= aKey
;
769 ContentProviderData aInfo
;
771 // Removal of UCPs from the configuration leads to changesOccurred
772 // notifications, too, but it is hard to tell for a given
773 // ElementChange whether it is an addition or a removal, so as a
774 // heuristic consider as removals those that cause a
775 // NoSuchElementException in createContentProviderData.
777 // For now, removal of UCPs from the configuration is simply ignored
778 // (and not reflected in the UCB's data structures):
779 if (createContentProviderData(aKey
, xHierNameAccess
, aInfo
))
781 aData
.push_back(aInfo
);
785 prepareAndRegister(aData
);
791 // XEventListener methods
795 void SAL_CALL
UniversalContentBroker::disposing(const lang::EventObject
&)
796 throw( uno::RuntimeException
, std::exception
)
798 if ( m_xNotifier
.is() )
800 osl::Guard
< osl::Mutex
> aGuard( m_aMutex
);
802 if ( m_xNotifier
.is() )
809 // Non-interface methods
813 Reference
< XContentProvider
> UniversalContentBroker::queryContentProvider(
814 const OUString
& Identifier
,
817 osl::MutexGuard
aGuard( m_aMutex
);
819 ProviderList_Impl
const * pList
= m_aProviders
.map( Identifier
);
820 return pList
? bResolved
? pList
->front().getResolvedProvider()
821 : pList
->front().getProvider()
822 : Reference
< XContentProvider
>();
825 bool UniversalContentBroker::configureUcb()
826 throw (uno::RuntimeException
)
830 if (m_aArguments
.getLength() < 2
831 || !(m_aArguments
[0] >>= aKey1
) || !(m_aArguments
[1] >>= aKey2
))
833 OSL_FAIL("UniversalContentBroker::configureUcb(): Bad arguments");
837 ContentProviderDataList aData
;
838 if (!getContentProviderData(aKey1
, aKey2
, aData
))
840 OSL_TRACE("UniversalContentBroker::configureUcb(): No configuration");
844 prepareAndRegister(aData
);
849 void UniversalContentBroker::prepareAndRegister(
850 const ContentProviderDataList
& rData
)
852 ContentProviderDataList::const_iterator
aEnd(rData
.end());
853 for (ContentProviderDataList::const_iterator
aIt(rData
.begin());
856 OUString aProviderArguments
;
857 if (fillPlaceholders(aIt
->Arguments
,
859 &aProviderArguments
))
869 OSL_FAIL("UniversalContentBroker::prepareAndRegister(): Bad argument placeholders");
874 bool UniversalContentBroker::getContentProviderData(
875 const OUString
& rKey1
,
876 const OUString
& rKey2
,
877 ContentProviderDataList
& rListToFill
)
879 if ( !m_xContext
.is() || rKey1
.isEmpty() || rKey2
.isEmpty() )
881 OSL_FAIL( "UniversalContentBroker::getContentProviderData - Invalid argument!" );
887 uno::Reference
< lang::XMultiServiceFactory
> xConfigProv
=
888 configuration::theDefaultProvider::get( m_xContext
);
890 OUStringBuffer aFullPath
;
891 aFullPath
.appendAscii( CONFIG_CONTENTPROVIDERS_KEY
"/['" );
892 makeAndAppendXMLName( aFullPath
, rKey1
);
893 aFullPath
.appendAscii( "']/SecondaryKeys/['" );
894 makeAndAppendXMLName( aFullPath
, rKey2
);
895 aFullPath
.appendAscii( "']/ProviderData" );
897 uno::Sequence
< uno::Any
> aArguments( 1 );
898 beans::PropertyValue aProperty
;
899 aProperty
.Name
= "nodepath";
900 aProperty
.Value
<<= aFullPath
.makeStringAndClear();
901 aArguments
[ 0 ] <<= aProperty
;
903 uno::Reference
< uno::XInterface
> xInterface(
904 xConfigProv
->createInstanceWithArguments(
905 OUString( "com.sun.star.configuration.ConfigurationAccess" ),
908 if ( !m_xNotifier
.is() )
910 m_xNotifier
= uno::Reference
< util::XChangesNotifier
>(
911 xInterface
, uno::UNO_QUERY_THROW
);
913 m_xNotifier
->addChangesListener( this );
916 uno::Reference
< container::XNameAccess
> xNameAccess(
917 xInterface
, uno::UNO_QUERY_THROW
);
919 uno::Sequence
< OUString
> aElems
= xNameAccess
->getElementNames();
920 const OUString
* pElems
= aElems
.getConstArray();
921 sal_Int32 nCount
= aElems
.getLength();
925 uno::Reference
< container::XHierarchicalNameAccess
>
926 xHierNameAccess( xInterface
, uno::UNO_QUERY_THROW
);
928 // Iterate over children.
929 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
935 ContentProviderData aInfo
;
937 OUStringBuffer aElemBuffer
;
938 aElemBuffer
.appendAscii( "['" );
939 makeAndAppendXMLName( aElemBuffer
, pElems
[ n
] );
940 aElemBuffer
.appendAscii( "']" );
943 createContentProviderData(
944 aElemBuffer
.makeStringAndClear(), xHierNameAccess
,
947 rListToFill
.push_back( aInfo
);
949 catch (const container::NoSuchElementException
&)
951 // getByHierarchicalName
952 OSL_FAIL( "UniversalContentBroker::getContentProviderData - "
953 "caught NoSuchElementException!" );
958 catch (const uno::RuntimeException
&)
960 OSL_TRACE( "UniversalContentBroker::getContentProviderData - caught RuntimeException!" );
963 catch (const uno::Exception
&)
965 // createInstance, createInstanceWithArguments
967 OSL_TRACE( "UniversalContentBroker::getContentProviderData - caught Exception!" );
976 // ProviderListEntry_Impl implementation.
980 Reference
< XContentProvider
> ProviderListEntry_Impl::resolveProvider() const
982 if ( !m_xResolvedProvider
.is() )
984 Reference
< XContentProviderSupplier
> xSupplier(
985 m_xProvider
, UNO_QUERY
);
986 if ( xSupplier
.is() )
987 m_xResolvedProvider
= xSupplier
->getContentProvider();
989 if ( !m_xResolvedProvider
.is() )
990 m_xResolvedProvider
= m_xProvider
;
993 return m_xResolvedProvider
;
996 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */