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 _UCBHELPER_RESULTSETHELPER_HXX
21 #define _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
;
40 //=========================================================================
42 #define DYNAMICRESULTSET_SERVICE_NAME "com.sun.star.ucb.DynamicResultSet"
44 //=========================================================================
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( sal_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 paramter 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();
144 XSERVICEINFO_NOFACTORY_DECL()
146 // XComponent ( base class of XDynamicResultSet )
147 virtual void SAL_CALL
149 throw( com::sun::star::uno::RuntimeException
);
150 virtual void SAL_CALL
151 addEventListener( const com::sun::star::uno::Reference
<
152 com::sun::star::lang::XEventListener
>& Listener
)
153 throw( com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
155 removeEventListener( const com::sun::star::uno::Reference
<
156 com::sun::star::lang::XEventListener
>& Listener
)
157 throw( com::sun::star::uno::RuntimeException
);
160 virtual com::sun::star::uno::Reference
<
161 com::sun::star::sdbc::XResultSet
> SAL_CALL
163 throw( com::sun::star::ucb::ListenerAlreadySetException
,
164 com::sun::star::uno::RuntimeException
);
165 virtual void SAL_CALL
166 setListener( const com::sun::star::uno::Reference
<
167 com::sun::star::ucb::XDynamicResultSetListener
>& Listener
)
168 throw( com::sun::star::ucb::ListenerAlreadySetException
,
169 com::sun::star::uno::RuntimeException
);
170 virtual void SAL_CALL
171 connectToCache( const com::sun::star::uno::Reference
<
172 com::sun::star::ucb::XDynamicResultSet
> & xCache
)
173 throw( com::sun::star::ucb::ListenerAlreadySetException
,
174 com::sun::star::ucb::AlreadyInitializedException
,
175 com::sun::star::ucb::ServiceNotFoundException
,
176 com::sun::star::uno::RuntimeException
);
179 * The implemetation of this method always returns 0. Override this
180 * method, if necessary.
182 virtual sal_Int16 SAL_CALL
184 throw( com::sun::star::uno::RuntimeException
);
186 //////////////////////////////////////////////////////////////////////
187 // Non-interface methods.
188 //////////////////////////////////////////////////////////////////////
191 * This method returns, whether the resultset is static or dynamic.
192 * If neither getStatic() nor getDynamic() was called, the type
193 * of the resultset is "dynamic".
195 * @return true, if the resultset type is "static". False, otherwise.
197 sal_Bool
isStatic() const { return m_bStatic
; }
202 #endif /* !_UCBHELPER_RESULTSETHELPER_HXX */
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */