1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: provider.hxx,v $
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 ************************************************************************/
34 #include <rtl/ustring.hxx>
35 #include <osl/mutex.hxx>
36 #include <ucbhelper/providerhelper.hxx>
37 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
38 #include <com/sun/star/container/XContainerListener.hpp>
39 #include <com/sun/star/container/XContainer.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
45 //=========================================================================
47 // UNO service name for the provider. This name will be used by the UCB to
48 // create instances of the provider.
50 //#define MYUCP_CONTENT_PROVIDER_SERVICE_NAME "com.sun.star.ucb.CHelpContentProvider"
51 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp"
52 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH1 25
54 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider"
55 #define MYUCP_CONTENT_PROVIDER_SERVICE_NAME_LENGTH2 36
57 // URL scheme. This is the scheme the provider will be able to create
58 // contents for. The UCB will select the provider ( i.e. in order to create
59 // contents ) according to this scheme.
61 #define MYUCP_URL_SCHEME "vnd.sun.star.help"
62 #define MYUCP_URL_SCHEME_LENGTH 18
63 #define MYUCP_CONTENT_TYPE "application/vnd.sun.star.xmlhelp" // UCB Content Type.
65 //=========================================================================
71 class ContentProvider
:
72 public ::ucbhelper::ContentProviderImplHelper
,
73 public ::com::sun::star::container::XContainerListener
,
74 public ::com::sun::star::lang::XComponent
78 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& rSMgr
);
80 virtual ~ContentProvider();
92 virtual ::com::sun::star::uno::Reference
<
93 ::com::sun::star::ucb::XContent
> SAL_CALL
94 queryContent( const ::com::sun::star::uno::Reference
<
95 ::com::sun::star::ucb::XContentIdentifier
>& Identifier
)
96 throw( ::com::sun::star::ucb::IllegalIdentifierException
,
97 ::com::sun::star::uno::RuntimeException
);
99 //////////////////////////////////////////////////////////////////////
100 // Additional interfaces
101 //////////////////////////////////////////////////////////////////////
105 virtual void SAL_CALL
107 throw (::com::sun::star::uno::RuntimeException
);
109 virtual void SAL_CALL
110 addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
)
111 throw (::com::sun::star::uno::RuntimeException
)
116 virtual void SAL_CALL
117 removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
)
118 throw (::com::sun::star::uno::RuntimeException
)
123 // XConainerListener ( deriver from XEventListener )
125 virtual void SAL_CALL
126 disposing( const ::com::sun::star::lang::EventObject
& Source
)
127 throw (::com::sun::star::uno::RuntimeException
)
130 m_xContainer
= com::sun::star::uno::Reference
<com::sun::star::container::XContainer
>(0);
133 virtual void SAL_CALL
134 elementInserted( const ::com::sun::star::container::ContainerEvent
& Event
)
135 throw (::com::sun::star::uno::RuntimeException
)
140 virtual void SAL_CALL
141 elementRemoved( const ::com::sun::star::container::ContainerEvent
& Event
)
142 throw (::com::sun::star::uno::RuntimeException
)
147 virtual void SAL_CALL
148 elementReplaced( const ::com::sun::star::container::ContainerEvent
& Event
)
149 throw (::com::sun::star::uno::RuntimeException
);
152 //////////////////////////////////////////////////////////////////////
153 // Non-interface methods.
154 //////////////////////////////////////////////////////////////////////
160 rtl::OUString m_aScheme
;
161 Databases
* m_pDatabases
;
162 com::sun::star::uno::Reference
<com::sun::star::container::XContainer
> m_xContainer
;
168 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
169 getConfiguration() const;
171 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>
172 getHierAccess( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& sProvider
,
173 const char* file
) const;
176 getKey( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& xHierAccess
,
177 const char* key
) const;
181 const ::com::sun::star::uno::Reference
<
182 ::com::sun::star::container::XHierarchicalNameAccess
>& xHierAccess
,
183 const char* key
) const;
185 void subst( rtl::OUString
& instpath
) const;