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_UCBHELPER_RESULTSETHELPER_HXX
21 #define INCLUDED_UCBHELPER_RESULTSETHELPER_HXX
23 #include <osl/mutex.hxx>
24 #include <com/sun/star/lang/XTypeProvider.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
27 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
28 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
29 #include <cppuhelper/weak.hxx>
30 #include <ucbhelper/macros.hxx>
31 #include <ucbhelper/contenthelper.hxx>
32 #include <ucbhelper/ucbhelperdllapi.h>
35 class OInterfaceContainerHelper
;
42 #define DYNAMICRESULTSET_SERVICE_NAME "com.sun.star.ucb.DynamicResultSet"
47 * This is an abstract base class for implementations of the service
48 * com.sun.star.ucb.DynamicResultSet, which is the result of the command
49 * "open" executed at a UCB folder content.
51 * Features of the base class implementation:
52 * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo )
53 * - all required interfaces for service com::sun::star::ucb::DynamicResultSet
55 class UCBHELPER_DLLPUBLIC ResultSetImplHelper
:
56 public cppu::OWeakObject
,
57 public com::sun::star::lang::XTypeProvider
,
58 public com::sun::star::lang::XServiceInfo
,
59 public com::sun::star::ucb::XDynamicResultSet
61 cppu::OInterfaceContainerHelper
* m_pDisposeEventListeners
;
67 com::sun::star::ucb::OpenCommandArgument2 m_aCommand
;
68 com::sun::star::uno::Reference
<
69 com::sun::star::uno::XComponentContext
> m_xContext
;
71 com::sun::star::uno::Reference
<
72 com::sun::star::sdbc::XResultSet
> m_xResultSet1
;
74 com::sun::star::uno::Reference
<
75 com::sun::star::sdbc::XResultSet
> m_xResultSet2
;
76 // Resultset changes listener.
77 com::sun::star::uno::Reference
<
78 com::sun::star::ucb::XDynamicResultSetListener
> m_xListener
;
81 UCBHELPER_DLLPRIVATE
void init( bool bStatic
);
84 * Your implementation of this method has to fill the protected member
85 * m_xResultSet1. This resultset must implement a complete static
86 * resultset ( service com.sun.star.ucb.ContentResultSet ). This method
87 * will be called at most once in the life of your implementation object.
88 * After this method was called, the type of this resultset will be
89 * "static". There is no way to change the type afterwards.
90 * If this method gets called the client wants to use your resultset
91 * exclusively statically. You may deploy this factum to optimize your
92 * implementation (i.e. "switch off" all changes detection code in
93 * your implementation).
94 * Note that you may use the class ucb::ResultSet to implement the
95 * static resultset, that is required here.
97 UCBHELPER_DLLPRIVATE
virtual void initStatic() = 0;
100 * Your implementation of this method has to fill the protected members
101 * m_xResultSet1 and m_xResultSet2 of this base class. Each of these
102 * resultsets must implement a complete static resultset
103 * ( service com.sun.star.ucb.ContentResultSet ). This method will be
104 * called at most once in the life of your implementation object.
105 * After this method was called, the type of this resultset will be
106 * "dynamic". There is no way to change the type afterwards.
107 * If this method gets called the client wants to use your resultset
108 * exclusively dynamically. This means, it is interested in getting
109 * notifications on changes of data of the resultset contents. ( These
110 * changes are to propagate by your implementation throw the member
111 * m_xListener of this base class ).
112 * If your implementation cannot detect changes of relevant data, you
113 * may fill m_xResultSet1 and m_xResultSet2 with the same static resultset
114 * implementation object. This normally will be the same instance you put
115 * into m_xResultSet1 when initStatic() is called.
117 UCBHELPER_DLLPRIVATE
virtual void initDynamic() = 0;
123 * @param rxContext is a Service Manager.
124 * @param rCommand is the parameter for the open command that produces
128 const com::sun::star::uno::Reference
<
129 com::sun::star::uno::XComponentContext
>& rxContext
,
130 const com::sun::star::ucb::OpenCommandArgument2
& rCommand
);
135 virtual ~ResultSetImplHelper();
138 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
139 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
140 virtual void SAL_CALL
acquire()
141 throw() SAL_OVERRIDE
;
142 virtual void SAL_CALL
release()
143 throw() SAL_OVERRIDE
;
146 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
147 getImplementationId()
148 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 virtual com::sun::star::uno::Sequence
< com::sun::star::uno::Type
> SAL_CALL
151 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
154 virtual OUString SAL_CALL
getImplementationName()
155 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
157 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
159 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 static OUString
getImplementationName_Static();
162 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
164 // XComponent ( base class of XDynamicResultSet )
165 virtual void SAL_CALL
167 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
168 virtual void SAL_CALL
169 addEventListener( const com::sun::star::uno::Reference
<
170 com::sun::star::lang::XEventListener
>& Listener
)
171 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
172 virtual void SAL_CALL
173 removeEventListener( const com::sun::star::uno::Reference
<
174 com::sun::star::lang::XEventListener
>& Listener
)
175 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
178 virtual com::sun::star::uno::Reference
<
179 com::sun::star::sdbc::XResultSet
> SAL_CALL
181 throw( com::sun::star::ucb::ListenerAlreadySetException
,
182 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
183 virtual void SAL_CALL
184 setListener( const com::sun::star::uno::Reference
<
185 com::sun::star::ucb::XDynamicResultSetListener
>& Listener
)
186 throw( com::sun::star::ucb::ListenerAlreadySetException
,
187 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
188 virtual void SAL_CALL
189 connectToCache( const com::sun::star::uno::Reference
<
190 com::sun::star::ucb::XDynamicResultSet
> & xCache
)
191 throw( com::sun::star::ucb::ListenerAlreadySetException
,
192 com::sun::star::ucb::AlreadyInitializedException
,
193 com::sun::star::ucb::ServiceNotFoundException
,
194 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
197 * The implementation of this method always returns 0. Override this
198 * method, if necessary.
200 virtual sal_Int16 SAL_CALL
202 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
205 // Non-interface methods.
209 * This method returns, whether the resultset is static or dynamic.
210 * If neither getStatic() nor getDynamic() was called, the type
211 * of the resultset is "dynamic".
213 * @return true, if the resultset type is "static". False, otherwise.
215 bool isStatic() const { return m_bStatic
; }
220 #endif /* ! INCLUDED_UCBHELPER_RESULTSETHELPER_HXX */
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */