merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / ucp / hierarchy / hierarchyprovider.hxx
blob4d2f09142a5438ad545882b143bdd480a7d5b98a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hierarchyprovider.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _HIERARCHYPROVIDER_HXX
32 #define _HIERARCHYPROVIDER_HXX
34 #include <hash_map>
35 #include <ucbhelper/providerhelper.hxx>
36 #include <com/sun/star/lang/XInitialization.hpp>
38 namespace com { namespace sun { namespace star {
39 namespace container {
40 class XHierarchicalNameAccess;
42 namespace util {
43 class XOfficeInstallationDirectories;
45 } } }
47 namespace hierarchy_ucp {
49 //=========================================================================
51 #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
52 "com.sun.star.ucb.HierarchyContentProvider"
53 #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 41
55 #define HIERARCHY_URL_SCHEME \
56 "vnd.sun.star.hier"
57 #define HIERARCHY_URL_SCHEME_LENGTH 17
59 #define HIERARCHY_FOLDER_CONTENT_TYPE \
60 "application/" HIERARCHY_URL_SCHEME "-folder"
61 #define HIERARCHY_LINK_CONTENT_TYPE \
62 "application/" HIERARCHY_URL_SCHEME "-link"
64 //=========================================================================
66 struct ConfigProviderMapEntry
68 com::sun::star::uno::Reference<
69 com::sun::star::lang::XMultiServiceFactory > xConfigProvider;
70 com::sun::star::uno::Reference<
71 com::sun::star::container::XHierarchicalNameAccess > xRootReadAccess;
72 bool bTriedToGetRootReadAccess; // #82494#
74 ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
77 struct equalString
79 bool operator()(
80 const rtl::OUString& rKey1, const rtl::OUString& rKey2 ) const
82 return !!( rKey1 == rKey2 );
86 struct hashString
88 size_t operator()( const rtl::OUString & rName ) const
90 return rName.hashCode();
94 typedef std::hash_map
96 rtl::OUString, // servcie specifier
97 ConfigProviderMapEntry,
98 hashString,
99 equalString
101 ConfigProviderMap;
103 //=========================================================================
105 class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
106 public com::sun::star::lang::XInitialization
108 ConfigProviderMap m_aConfigProviderMap;
109 com::sun::star::uno::Reference<
110 com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
112 public:
113 HierarchyContentProvider(
114 const com::sun::star::uno::Reference<
115 com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
116 virtual ~HierarchyContentProvider();
118 // XInterface
119 XINTERFACE_DECL()
121 // XTypeProvider
122 XTYPEPROVIDER_DECL()
124 // XServiceInfo
125 XSERVICEINFO_DECL()
127 // XContentProvider
128 virtual com::sun::star::uno::Reference<
129 com::sun::star::ucb::XContent > SAL_CALL
130 queryContent( const com::sun::star::uno::Reference<
131 com::sun::star::ucb::XContentIdentifier >& Identifier )
132 throw( com::sun::star::ucb::IllegalIdentifierException,
133 com::sun::star::uno::RuntimeException );
135 // XInitialization
136 virtual void SAL_CALL
137 initialize( const ::com::sun::star::uno::Sequence<
138 ::com::sun::star::uno::Any >& aArguments )
139 throw( ::com::sun::star::uno::Exception,
140 ::com::sun::star::uno::RuntimeException );
142 // Non-Interface methods
143 com::sun::star::uno::Reference<
144 com::sun::star::lang::XMultiServiceFactory >
145 getConfigProvider( const rtl::OUString & rServiceSpecifier );
146 com::sun::star::uno::Reference<
147 com::sun::star::container::XHierarchicalNameAccess >
148 getRootConfigReadNameAccess( const rtl::OUString & rServiceSpecifier );
150 // Note: may retrun an empty reference.
151 com::sun::star::uno::Reference<
152 com::sun::star::util::XOfficeInstallationDirectories >
153 getOfficeInstallationDirectories();
156 } // namespace hierarchy_ucp
158 #endif /* !_HIERARCHYPROVIDER_HXX */