32#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
33#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
34#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
35#include <com/sun/star/uno/XComponentContext.hpp>
39#include <unordered_map>
52 public container::XHierarchicalNameAccess
57 uno::Reference< container::XHierarchicalNameAccess >
m_xNA;
62 uno::Reference< container::XHierarchicalNameAccess > xNA,
70 {
return m_xNA->queryInterface( aType ); }
72 acquire() noexcept
override
73 { OWeakObject::acquire(); }
75 release() noexcept
override
76 { OWeakObject::release(); }
80 getByHierarchicalName(
const OUString& aName )
override
81 {
return m_xNA->getByHierarchicalName( aName ); }
83 hasByHierarchicalName(
const OUString& aName )
override
84 {
return m_xNA->hasByHierarchicalName( aName ); }
89class Packages :
public std::unordered_map<OUString, Package*> {};
98 const uno::Reference< uno::XComponentContext >& rxContext )
99: ::
ucbhelper::ContentProviderImplHelper( rxContext )
113 OWeakObject::acquire();
119 OWeakObject::release();
125 static_cast< lang::XTypeProvider*
>(
this),
126 static_cast< lang::XServiceInfo*
>(
this),
127 static_cast< ucb::XContentProvider*
>(
this)
129 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
138 ucb::XContentProvider );
146 return "com.sun.star.comp.ucb.PackageContentProvider";
155css::uno::Sequence< OUString >
158 return {
"com.sun.star.ucb.PackageContentProvider" };
167 const uno::Reference< ucb::XContentIdentifier >& Identifier )
170 return uno::Reference< ucb::XContent >();
173 if ( !aUri.isValid() )
174 throw ucb::IllegalIdentifierException();
178 uno::Reference< ucb::XContentIdentifier > xId = new ::ucbhelper::ContentIdentifier( aUri.getUri() );
183 uno::Reference< ucb::XContent > xContent
193 if ( xContent.is() && !xContent->getIdentifier().is() )
194 throw ucb::IllegalIdentifierException();
203uno::Reference< container::XHierarchicalNameAccess >
212 Packages::const_iterator it =
m_pPackages->find( rURL );
216 return (*it).second->m_xNA;
224 uno::Reference< container::XHierarchicalNameAccess > xNameAccess;
228 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
229 "com.sun.star.packages.comp.ZipPackage",
231 css::uno::UNO_QUERY_THROW );
233 catch ( uno::RuntimeException
const & )
237 catch ( uno::Exception
const & e )
240 throw css::lang::WrappedTargetRuntimeException(
241 e.Message, e.Context, anyEx);
245 (*m_pPackages)[ rURL ] = xPackage.get();
256 Packages::iterator it =
m_pPackages->find( rName );
265extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
267 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
std::unique_ptr< Packages > m_pPackages
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::container::XHierarchicalNameAccess > createPackage(const PackageUri &rParam)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL acquire() noexcept override
void removePackage(const OUString &rName)
virtual ~ContentProvider() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier) override
static rtl::Reference< Content > create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
const OUString & getParam() const
const OUString & getPackage() const
rtl::Reference< ContentImplHelper > queryExistingContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
void registerNewContent(const css::uno::Reference< css::ucb::XContent > &xContent)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Sequence< PropertyValue > aArguments
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Any SAL_CALL getCaughtException()
uno::Reference< container::XHierarchicalNameAccess > m_xNA
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_package_ContentProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
ContentProvider * m_pOwner
XTYPEPROVIDER_IMPL_3(ContentProvider, lang::XTypeProvider, lang::XServiceInfo, ucb::XContentProvider)