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 .
22 #include <ucbhelper/providerhelper.hxx>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <unordered_map>
27 namespace com::sun::star
{
29 class XHierarchicalNameAccess
;
32 class XOfficeInstallationDirectories
;
36 namespace hierarchy_ucp
{
39 #define HIERARCHY_URL_SCHEME \
41 #define HIERARCHY_URL_SCHEME_LENGTH 17
43 inline constexpr OUString HIERARCHY_FOLDER_CONTENT_TYPE
=
44 u
"application/" HIERARCHY_URL_SCHEME
"-folder"_ustr
;
45 inline constexpr OUString HIERARCHY_LINK_CONTENT_TYPE
=
46 u
"application/" HIERARCHY_URL_SCHEME
"-link"_ustr
;
48 struct ConfigProviderMapEntry
50 css::uno::Reference
< css::lang::XMultiServiceFactory
> xConfigProvider
;
51 css::uno::Reference
< css::container::XHierarchicalNameAccess
> xRootReadAccess
;
52 bool bTriedToGetRootReadAccess
;
54 ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
57 typedef std::unordered_map
59 OUString
, // service specifier
60 ConfigProviderMapEntry
64 typedef cppu::ImplInheritanceHelper
< ::ucbhelper::ContentProviderImplHelper
, css::lang::XInitialization
> HierarchyContentProvider_Base
;
65 class HierarchyContentProvider
: public HierarchyContentProvider_Base
67 ConfigProviderMap m_aConfigProviderMap
;
68 css::uno::Reference
< css::util::XOfficeInstallationDirectories
> m_xOfficeInstDirs
;
71 explicit HierarchyContentProvider(
72 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
73 virtual ~HierarchyContentProvider() override
;
76 virtual OUString SAL_CALL
getImplementationName() override
;
77 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
78 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
81 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
82 queryContent( const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
) override
;
86 initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
88 // Non-Interface methods
89 css::uno::Reference
< css::lang::XMultiServiceFactory
>
90 getConfigProvider( const OUString
& rServiceSpecifier
);
91 css::uno::Reference
< css::container::XHierarchicalNameAccess
>
92 getRootConfigReadNameAccess( const OUString
& rServiceSpecifier
);
94 // Note: may return an empty reference.
95 css::uno::Reference
< css::util::XOfficeInstallationDirectories
>
96 getOfficeInstallationDirectories();
99 } // namespace hierarchy_ucp
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */