LibreOffice Module svx (master) 1
formcontrolling.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
21#define INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
22
23#include <com/sun/star/form/runtime/XFormController.hpp>
24#include <com/sun/star/form/runtime/FeatureState.hpp>
25#include <com/sun/star/form/runtime/XFormOperations.hpp>
26#include <com/sun/star/sdb/XSQLErrorListener.hpp>
27
29#include <rtl/ref.hxx>
30
31#include <vector>
32
33
34namespace svx
35{
36
38 {
39 public:
41 static sal_Int32 getControllerFeatureSlotIdForURL( const OUString& _rMainURL );
42
44 static sal_Int16 getFormFeatureForSlotId( sal_Int32 _nSlotId );
45
47 static sal_Int32 getSlotIdForFormFeature( sal_Int16 _nFormFeature );
48 };
49
51 {
52 public:
62 virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) = 0;
63
64 protected:
66 };
67
68 class FormControllerHelper;
72 {
73 IControllerFeatureInvalidation* m_pInvalidationCallback; // necessary as long as m_pImpl is not yet constructed
75
76 public:
85 IControllerFeatureInvalidation* _pInvalidationCallback
86 );
87
95 const css::uno::Reference< css::form::runtime::XFormController >& _rxController
96 );
97
100
102 bool isAssigned( ) const { return m_pImpl != nullptr; }
103
106 void assign(
107 const css::uno::Reference< css::form::runtime::XFormController >& _rxController
108 );
109
111 void dispose();
112
113 // access to the instance which implements the functionality. Not to be used when not assigned
114 const FormControllerHelper* operator->() const { return m_pImpl.get(); }
116 };
117
118
119 //= FormControllerHelper
120
121 typedef ::cppu::WeakImplHelper < css::form::runtime::XFeatureInvalidation
122 , css::sdb::XSQLErrorListener
132 {
134 css::uno::Reference< css::form::runtime::XFormOperations >
136
137 css::uno::Any m_aOperationError;
138
139 public:
149 const css::uno::Reference< css::form::runtime::XFormController >& _rxController,
150 IControllerFeatureInvalidation* _pInvalidationCallback
151 );
152
153 // forwards to the XFormOperations implementation
154 css::uno::Reference< css::sdbc::XRowSet >
155 getCursor() const;
156 void getState(
157 sal_Int32 _nSlotId,
158 css::form::runtime::FeatureState& _out_rState
159 ) const;
160 bool isEnabled( sal_Int32 _nSlotId ) const;
161 void execute( sal_Int32 _nSlotId ) const;
162 void execute( sal_Int32 _nSlotId, const OUString& _rParamName, const css::uno::Any& _rParamValue ) const;
163 bool commitCurrentRecord() const;
164 bool commitCurrentControl( ) const;
165 bool isInsertionRow() const;
166 bool isModifiedRow() const;
167
168 bool canDoFormFilter() const;
169
174 void dispose();
175
176 private:
178 virtual ~FormControllerHelper() override;
179
180 // XFeatureInvalidation
181 virtual void SAL_CALL invalidateFeatures( const css::uno::Sequence< ::sal_Int16 >& Features ) override;
182 virtual void SAL_CALL invalidateAllFeatures() override;
183
184 // XSQLErrorListener
185 virtual void SAL_CALL errorOccured( const css::sdb::SQLErrorEvent& Event ) override;
186
187 // XEventListener
188 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
189
191
193 const FormOperation _eWhat,
194 const sal_Int16 _nFeature, /* ignore for COMMIT_* */
195 const css::uno::Sequence< css::beans::NamedValue >& _rArguments /* ignore except for EXECUTE_ARGS */
196 ) const;
197 bool impl_operateForm_nothrow( const FormOperation _eWhat ) const
198 {
199 return impl_operateForm_nothrow( _eWhat, 0, css::uno::Sequence< css::beans::NamedValue >() );
200 }
201
202 private:
205 };
206
207
208}
209
210
211#endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
212
213/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
easier access to a FormControllerHelper instance
rtl::Reference< FormControllerHelper > m_pImpl
void assign(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
assign to a controller
void dispose()
clears the instance so that it cannot be used afterwards
FormControllerHelper * operator->()
ControllerFeatures(IControllerFeatureInvalidation *_pInvalidationCallback)
standard ctor
IControllerFeatureInvalidation * m_pInvalidationCallback
ControllerFeatures(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
constructs the instance from a <type scope="css::form::runtime">XFormController<type> instance
const FormControllerHelper * operator->() const
bool isAssigned() const
checks whether the instance is properly assigned to a form and/or controller
static sal_Int32 getControllerFeatureSlotIdForURL(const OUString &_rMainURL)
retrieves the feature id for a given feature URL
static sal_Int16 getFormFeatureForSlotId(sal_Int32 _nSlotId)
retrieves the css.form.runtime.FormFeature ID for a given slot ID
static sal_Int32 getSlotIdForFormFeature(sal_Int16 _nFormFeature)
retrieves the slot id for a given css.form.runtime.FormFeature ID
is a helper class which manages form controller functionality (such as moveNext etc....
FormControllerHelper(const css::uno::Reference< css::form::runtime::XFormController > &_rxController, IControllerFeatureInvalidation *_pInvalidationCallback)
constructs the helper from a <type scope="css::form::runtime">XFormController<type> instance
virtual void SAL_CALL invalidateFeatures(const css::uno::Sequence< ::sal_Int16 > &Features) override
void dispose()
disposes this instance.
css::uno::Reference< css::sdbc::XRowSet > getCursor() const
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void execute(sal_Int32 _nSlotId, const OUString &_rParamName, const css::uno::Any &_rParamValue) const
bool impl_operateForm_nothrow(const FormOperation _eWhat, const sal_Int16 _nFeature, const css::uno::Sequence< css::beans::NamedValue > &_rArguments) const
virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent &Event) override
virtual void SAL_CALL invalidateAllFeatures() override
bool isEnabled(sal_Int32 _nSlotId) const
void getState(sal_Int32 _nSlotId, css::form::runtime::FeatureState &_out_rState) const
css::uno::Reference< css::form::runtime::XFormOperations > m_xFormOperations
virtual ~FormControllerHelper() override
dtor
FormControllerHelper & operator=(const FormControllerHelper &)=delete
bool impl_operateForm_nothrow(const FormOperation _eWhat) const
void execute(sal_Int32 _nSlotId) const
FormControllerHelper(const FormControllerHelper &)=delete
IControllerFeatureInvalidation * m_pInvalidationCallback
virtual void invalidateFeatures(const ::std::vector< sal_Int32 > &_rFeatures)=0
invalidates the given features
::cppu::WeakImplHelper< css::form::runtime::XFeatureInvalidation, css::sdb::XSQLErrorListener > FormControllerHelper_Base