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
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/lang/XTypeProvider.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
28 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
29 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <ucbhelper/macros.hxx>
32 #include <ucbhelper/contenthelper.hxx>
33 #include <ucbhelper/ucbhelperdllapi.h>
36 class OInterfaceContainerHelper
;
42 #define DYNAMICRESULTSET_SERVICE_NAME "com.sun.star.ucb.DynamicResultSet"
46 * This is an abstract base class for implementations of the service
47 * com.sun.star.ucb.DynamicResultSet, which is the result of the command
48 * "open" executed at a UCB folder content.
50 * Features of the base class implementation:
51 * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo )
52 * - all required interfaces for service css::ucb::DynamicResultSet
54 class UCBHELPER_DLLPUBLIC ResultSetImplHelper
:
55 public cppu::OWeakObject
,
56 public css::lang::XTypeProvider
,
57 public css::lang::XServiceInfo
,
58 public css::ucb::XDynamicResultSet
60 std::unique_ptr
<cppu::OInterfaceContainerHelper
> m_pDisposeEventListeners
;
66 css::ucb::OpenCommandArgument2 m_aCommand
;
67 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
69 css::uno::Reference
< css::sdbc::XResultSet
> m_xResultSet1
;
71 css::uno::Reference
< css::sdbc::XResultSet
> m_xResultSet2
;
72 // Resultset changes listener.
73 css::uno::Reference
< css::ucb::XDynamicResultSetListener
> m_xListener
;
76 UCBHELPER_DLLPRIVATE
void init( bool bStatic
);
79 * Your implementation of this method has to fill the protected member
80 * m_xResultSet1. This resultset must implement a complete static
81 * resultset ( service com.sun.star.ucb.ContentResultSet ). This method
82 * will be called at most once in the life of your implementation object.
83 * After this method was called, the type of this resultset will be
84 * "static". There is no way to change the type afterwards.
85 * If this method gets called the client wants to use your resultset
86 * exclusively statically. You may deploy this factum to optimize your
87 * implementation (i.e. "switch off" all changes detection code in
88 * your implementation).
89 * Note that you may use the class ucb::ResultSet to implement the
90 * static resultset, that is required here.
92 UCBHELPER_DLLPRIVATE
virtual void initStatic() = 0;
95 * Your implementation of this method has to fill the protected members
96 * m_xResultSet1 and m_xResultSet2 of this base class. Each of these
97 * resultsets must implement a complete static resultset
98 * ( service com.sun.star.ucb.ContentResultSet ). This method will be
99 * called at most once in the life of your implementation object.
100 * After this method was called, the type of this resultset will be
101 * "dynamic". There is no way to change the type afterwards.
102 * If this method gets called the client wants to use your resultset
103 * exclusively dynamically. This means, it is interested in getting
104 * notifications on changes of data of the resultset contents. ( These
105 * changes are to propagate by your implementation throw the member
106 * m_xListener of this base class ).
107 * If your implementation cannot detect changes of relevant data, you
108 * may fill m_xResultSet1 and m_xResultSet2 with the same static resultset
109 * implementation object. This normally will be the same instance you put
110 * into m_xResultSet1 when initStatic() is called.
112 UCBHELPER_DLLPRIVATE
virtual void initDynamic() = 0;
118 * @param rxContext is a Service Manager.
119 * @param rCommand is the parameter for the open command that produces
123 const css::uno::Reference
<
124 css::uno::XComponentContext
>& rxContext
,
125 const css::ucb::OpenCommandArgument2
& rCommand
);
130 virtual ~ResultSetImplHelper() override
;
133 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
134 virtual void SAL_CALL
acquire()
136 virtual void SAL_CALL
release()
140 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
141 getImplementationId() override
;
142 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
146 virtual OUString SAL_CALL
getImplementationName() override
;
147 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
148 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
150 // XComponent ( base class of XDynamicResultSet )
151 virtual void SAL_CALL
153 virtual void SAL_CALL
154 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
155 virtual void SAL_CALL
156 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
159 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
160 getStaticResultSet() override
;
161 virtual void SAL_CALL
162 setListener( const css::uno::Reference
< css::ucb::XDynamicResultSetListener
>& Listener
) override
;
163 virtual void SAL_CALL
164 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
167 * The implementation of this method always returns 0. Override this
168 * method, if necessary.
170 virtual sal_Int16 SAL_CALL
171 getCapabilities() override
;
177 #endif /* ! INCLUDED_UCBHELPER_RESULTSETHELPER_HXX */
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */