Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / ucbhelper / resultsethelper.hxx
blob31f96790581a927cb270599a5a4a60e109fa8e63
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
24 #include <mutex>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
27 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
28 #include <comphelper/interfacecontainer4.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <ucbhelper/ucbhelperdllapi.h>
32 namespace com::sun::star::uno { class XComponentContext; }
34 namespace cppu {
35 class OInterfaceContainerHelper;
38 namespace ucbhelper {
41 inline constexpr OUStringLiteral DYNAMICRESULTSET_SERVICE_NAME = u"com.sun.star.ucb.DynamicResultSet";
44 /**
45 * This is an abstract base class for implementations of the service
46 * com.sun.star.ucb.DynamicResultSet, which is the result of the command
47 * "open" executed at a UCB folder content.
49 * Features of the base class implementation:
50 * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo )
51 * - all required interfaces for service css::ucb::DynamicResultSet
53 class UCBHELPER_DLLPUBLIC ResultSetImplHelper :
54 public cppu::WeakImplHelper<
55 css::lang::XServiceInfo,
56 css::ucb::XDynamicResultSet>
58 comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aDisposeEventListeners;
59 bool m_bStatic;
60 bool m_bInitDone;
62 protected:
63 std::mutex m_aMutex;
64 css::ucb::OpenCommandArgument2 m_aCommand;
65 css::uno::Reference< css::uno::XComponentContext > m_xContext;
66 // Resultset #1
67 css::uno::Reference< css::sdbc::XResultSet > m_xResultSet1;
68 // Resultset #2
69 css::uno::Reference< css::sdbc::XResultSet > m_xResultSet2;
70 // Resultset changes listener.
71 css::uno::Reference< css::ucb::XDynamicResultSetListener > m_xListener;
73 private:
74 UCBHELPER_DLLPRIVATE void init( bool bStatic );
76 /**
77 * Your implementation of this method has to fill the protected member
78 * m_xResultSet1. This resultset must implement a complete static
79 * resultset ( service com.sun.star.ucb.ContentResultSet ). This method
80 * will be called at most once in the life of your implementation object.
81 * After this method was called, the type of this resultset will be
82 * "static". There is no way to change the type afterwards.
83 * If this method gets called the client wants to use your resultset
84 * exclusively statically. You may deploy this factum to optimize your
85 * implementation (i.e. "switch off" all changes detection code in
86 * your implementation).
87 * Note that you may use the class ucb::ResultSet to implement the
88 * static resultset, that is required here.
90 UCBHELPER_DLLPRIVATE virtual void initStatic() = 0;
92 /**
93 * Your implementation of this method has to fill the protected members
94 * m_xResultSet1 and m_xResultSet2 of this base class. Each of these
95 * resultsets must implement a complete static resultset
96 * ( service com.sun.star.ucb.ContentResultSet ). This method will be
97 * called at most once in the life of your implementation object.
98 * After this method was called, the type of this resultset will be
99 * "dynamic". There is no way to change the type afterwards.
100 * If this method gets called the client wants to use your resultset
101 * exclusively dynamically. This means, it is interested in getting
102 * notifications on changes of data of the resultset contents. ( These
103 * changes are to propagate by your implementation throw the member
104 * m_xListener of this base class ).
105 * If your implementation cannot detect changes of relevant data, you
106 * may fill m_xResultSet1 and m_xResultSet2 with the same static resultset
107 * implementation object. This normally will be the same instance you put
108 * into m_xResultSet1 when initStatic() is called.
110 UCBHELPER_DLLPRIVATE virtual void initDynamic() = 0;
112 public:
114 * Constructor.
116 * @param rxContext is a Service Manager.
117 * @param rCommand is the parameter for the open command that produces
118 * this resultset.
120 ResultSetImplHelper(
121 css::uno::Reference<
122 css::uno::XComponentContext > xContext,
123 css::ucb::OpenCommandArgument2 aCommand );
126 * Destructor.
128 virtual ~ResultSetImplHelper() override;
130 // XServiceInfo
131 virtual OUString SAL_CALL getImplementationName() override;
132 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
133 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
135 // XComponent ( base class of XDynamicResultSet )
136 virtual void SAL_CALL
137 dispose() override;
138 virtual void SAL_CALL
139 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
140 virtual void SAL_CALL
141 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
143 // XDynamicResultSet
144 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
145 getStaticResultSet() override;
146 virtual void SAL_CALL
147 setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener >& Listener ) override;
148 virtual void SAL_CALL
149 connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
152 * The implementation of this method always returns 0. Override this
153 * method, if necessary.
155 virtual sal_Int16 SAL_CALL
156 getCapabilities() override;
162 #endif /* ! INCLUDED_UCBHELPER_RESULTSETHELPER_HXX */
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */