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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
23 #include <ucbhelper/providerhelper.hxx>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <unordered_map>
27 namespace com
{ namespace sun
{ namespace star
{
29 class XHierarchicalNameAccess
;
32 class XOfficeInstallationDirectories
;
36 namespace hierarchy_ucp
{
40 #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
41 "com.sun.star.ucb.HierarchyContentProvider"
43 #define HIERARCHY_URL_SCHEME \
45 #define HIERARCHY_URL_SCHEME_LENGTH 17
47 #define HIERARCHY_FOLDER_CONTENT_TYPE \
48 "application/" HIERARCHY_URL_SCHEME "-folder"
49 #define HIERARCHY_LINK_CONTENT_TYPE \
50 "application/" HIERARCHY_URL_SCHEME "-link"
52 struct ConfigProviderMapEntry
54 com::sun::star::uno::Reference
<
55 com::sun::star::lang::XMultiServiceFactory
> xConfigProvider
;
56 com::sun::star::uno::Reference
<
57 com::sun::star::container::XHierarchicalNameAccess
> xRootReadAccess
;
58 bool bTriedToGetRootReadAccess
; // #82494#
60 ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
63 typedef std::unordered_map
65 OUString
, // servcie specifier
66 ConfigProviderMapEntry
,
71 class HierarchyContentProvider
: public ::ucbhelper::ContentProviderImplHelper
,
72 public com::sun::star::lang::XInitialization
74 ConfigProviderMap m_aConfigProviderMap
;
75 com::sun::star::uno::Reference
<
76 com::sun::star::util::XOfficeInstallationDirectories
> m_xOfficeInstDirs
;
79 HierarchyContentProvider(
80 const com::sun::star::uno::Reference
<
81 com::sun::star::uno::XComponentContext
>& rxContext
);
82 virtual ~HierarchyContentProvider();
85 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
86 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual void SAL_CALL
acquire()
89 virtual void SAL_CALL
release()
93 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
94 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
96 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 virtual OUString SAL_CALL
getImplementationName()
100 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
102 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
103 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
104 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
106 static OUString
getImplementationName_Static();
107 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
109 static css::uno::Reference
< css::lang::XSingleServiceFactory
>
110 createServiceFactory( const css::uno::Reference
<
111 css::lang::XMultiServiceFactory
>& rxServiceMgr
);
114 virtual com::sun::star::uno::Reference
<
115 com::sun::star::ucb::XContent
> SAL_CALL
116 queryContent( const com::sun::star::uno::Reference
<
117 com::sun::star::ucb::XContentIdentifier
>& Identifier
)
118 throw( com::sun::star::ucb::IllegalIdentifierException
,
119 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 virtual void SAL_CALL
123 initialize( const ::com::sun::star::uno::Sequence
<
124 ::com::sun::star::uno::Any
>& aArguments
)
125 throw( ::com::sun::star::uno::Exception
,
126 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 // Non-Interface methods
129 com::sun::star::uno::Reference
<
130 com::sun::star::lang::XMultiServiceFactory
>
131 getConfigProvider( const OUString
& rServiceSpecifier
);
132 com::sun::star::uno::Reference
<
133 com::sun::star::container::XHierarchicalNameAccess
>
134 getRootConfigReadNameAccess( const OUString
& rServiceSpecifier
);
136 // Note: may retrun an empty reference.
137 com::sun::star::uno::Reference
<
138 com::sun::star::util::XOfficeInstallationDirectories
>
139 getOfficeInstallationDirectories();
142 } // namespace hierarchy_ucp
144 #endif // INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */