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 <boost/unordered_map.hpp>
24 : #include <ucbhelper/providerhelper.hxx>
25 : #include <com/sun/star/lang/XInitialization.hpp>
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 : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 41
43 :
44 : #define HIERARCHY_URL_SCHEME \
45 : "vnd.sun.star.hier"
46 : #define HIERARCHY_URL_SCHEME_LENGTH 17
47 :
48 : #define HIERARCHY_FOLDER_CONTENT_TYPE \
49 : "application/" HIERARCHY_URL_SCHEME "-folder"
50 : #define HIERARCHY_LINK_CONTENT_TYPE \
51 : "application/" HIERARCHY_URL_SCHEME "-link"
52 :
53 :
54 :
55 6 : struct ConfigProviderMapEntry
56 : {
57 : com::sun::star::uno::Reference<
58 : com::sun::star::lang::XMultiServiceFactory > xConfigProvider;
59 : com::sun::star::uno::Reference<
60 : com::sun::star::container::XHierarchicalNameAccess > xRootReadAccess;
61 : bool bTriedToGetRootReadAccess; // #82494#
62 :
63 4 : ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
64 : };
65 :
66 : typedef boost::unordered_map
67 : <
68 : OUString, // servcie specifier
69 : ConfigProviderMapEntry,
70 : OUStringHash
71 : >
72 : ConfigProviderMap;
73 :
74 :
75 :
76 : class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
77 : public com::sun::star::lang::XInitialization
78 : {
79 : ConfigProviderMap m_aConfigProviderMap;
80 : com::sun::star::uno::Reference<
81 : com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
82 :
83 : public:
84 : HierarchyContentProvider(
85 : const com::sun::star::uno::Reference<
86 : com::sun::star::uno::XComponentContext >& rxContext );
87 : virtual ~HierarchyContentProvider();
88 :
89 : // XInterface
90 : virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
91 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
92 : virtual void SAL_CALL acquire()
93 : throw() SAL_OVERRIDE;
94 : virtual void SAL_CALL release()
95 : throw() SAL_OVERRIDE;
96 :
97 : // XTypeProvider
98 : virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
99 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
100 : virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
101 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
102 :
103 : // XServiceInfo
104 : virtual OUString SAL_CALL getImplementationName()
105 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
106 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
107 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
108 : virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
109 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
110 :
111 : static OUString getImplementationName_Static();
112 : static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
113 :
114 : static css::uno::Reference< css::lang::XSingleServiceFactory >
115 : createServiceFactory( const css::uno::Reference<
116 : css::lang::XMultiServiceFactory >& rxServiceMgr );
117 :
118 : // XContentProvider
119 : virtual com::sun::star::uno::Reference<
120 : com::sun::star::ucb::XContent > SAL_CALL
121 : queryContent( const com::sun::star::uno::Reference<
122 : com::sun::star::ucb::XContentIdentifier >& Identifier )
123 : throw( com::sun::star::ucb::IllegalIdentifierException,
124 : com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
125 :
126 : // XInitialization
127 : virtual void SAL_CALL
128 : initialize( const ::com::sun::star::uno::Sequence<
129 : ::com::sun::star::uno::Any >& aArguments )
130 : throw( ::com::sun::star::uno::Exception,
131 : ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
132 :
133 : // Non-Interface methods
134 : com::sun::star::uno::Reference<
135 : com::sun::star::lang::XMultiServiceFactory >
136 : getConfigProvider( const OUString & rServiceSpecifier );
137 : com::sun::star::uno::Reference<
138 : com::sun::star::container::XHierarchicalNameAccess >
139 : getRootConfigReadNameAccess( const OUString & rServiceSpecifier );
140 :
141 : // Note: may retrun an empty reference.
142 : com::sun::star::uno::Reference<
143 : com::sun::star::util::XOfficeInstallationDirectories >
144 : getOfficeInstallationDirectories();
145 : };
146 :
147 : } // namespace hierarchy_ucp
148 :
149 : #endif // INCLUDED_UCB_SOURCE_UCP_HIERARCHY_HIERARCHYPROVIDER_HXX
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|