Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
21 : #define INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
22 :
23 : #include <ucbhelper/providerhelper.hxx>
24 : #include <com/sun/star/lang/XInitialization.hpp>
25 : #include <unordered_map>
26 :
27 : namespace com { namespace sun { namespace star {
28 : namespace container {
29 : class XHierarchicalNameAccess;
30 : }
31 : namespace util {
32 : class XOfficeInstallationDirectories;
33 : }
34 : } } }
35 :
36 : namespace hierarchy_ucp {
37 :
38 :
39 :
40 : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
41 : "com.sun.star.ucb.HierarchyContentProvider"
42 :
43 : #define HIERARCHY_URL_SCHEME \
44 : "vnd.sun.star.hier"
45 : #define HIERARCHY_URL_SCHEME_LENGTH 17
46 :
47 : #define HIERARCHY_FOLDER_CONTENT_TYPE \
48 : "application/" HIERARCHY_URL_SCHEME "-folder"
49 : #define HIERARCHY_LINK_CONTENT_TYPE \
50 : "application/" HIERARCHY_URL_SCHEME "-link"
51 :
52 0 : struct ConfigProviderMapEntry
53 : {
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#
59 :
60 0 : ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
61 : };
62 :
63 : typedef std::unordered_map
64 : <
65 : OUString, // servcie specifier
66 : ConfigProviderMapEntry,
67 : OUStringHash
68 : >
69 : ConfigProviderMap;
70 :
71 : class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
72 : public com::sun::star::lang::XInitialization
73 : {
74 : ConfigProviderMap m_aConfigProviderMap;
75 : com::sun::star::uno::Reference<
76 : com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
77 :
78 : public:
79 : explicit HierarchyContentProvider(
80 : const com::sun::star::uno::Reference<
81 : com::sun::star::uno::XComponentContext >& rxContext );
82 : virtual ~HierarchyContentProvider();
83 :
84 : // XInterface
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()
88 : throw() SAL_OVERRIDE;
89 : virtual void SAL_CALL release()
90 : throw() SAL_OVERRIDE;
91 :
92 : // XTypeProvider
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;
97 :
98 : // XServiceInfo
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;
105 :
106 : static OUString getImplementationName_Static();
107 : static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
108 :
109 : static css::uno::Reference< css::lang::XSingleServiceFactory >
110 : createServiceFactory( const css::uno::Reference<
111 : css::lang::XMultiServiceFactory >& rxServiceMgr );
112 :
113 : // XContentProvider
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;
120 :
121 : // XInitialization
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;
127 :
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 );
135 :
136 : // Note: may retrun an empty reference.
137 : com::sun::star::uno::Reference<
138 : com::sun::star::util::XOfficeInstallationDirectories >
139 : getOfficeInstallationDirectories();
140 : };
141 :
142 : } // namespace hierarchy_ucp
143 :
144 : #endif // INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|