tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / inc / formcontrolling.hxx
blobc9bd8f23f8a60a7e1d569e5af4c34268a5360c1c
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_SVX_SOURCE_INC_FORMCONTROLLING_HXX
21 #define INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
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>
28 #include <cppuhelper/implbase.hxx>
29 #include <rtl/ref.hxx>
31 #include <vector>
34 namespace svx
37 class FeatureSlotTranslation
39 public:
40 /// retrieves the feature id for a given feature URL
41 static sal_Int32 getControllerFeatureSlotIdForURL( const OUString& _rMainURL );
43 /// retrieves the css.form.runtime.FormFeature ID for a given slot ID
44 static sal_Int16 getFormFeatureForSlotId( sal_Int32 _nSlotId );
46 /// retrieves the slot id for a given css.form.runtime.FormFeature ID
47 static sal_Int32 getSlotIdForFormFeature( sal_Int16 _nFormFeature );
50 class IControllerFeatureInvalidation
52 public:
53 /** invalidates the given features
55 Invalidation means that any user interface representation (such as toolbox buttons), or
56 any dispatches associated with the features in question are potentially out-of-date, and
57 need to be updated
59 @param _rFeatures
60 Ids of the features to be invalidated.
62 virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) = 0;
64 protected:
65 ~IControllerFeatureInvalidation() {}
68 class FormControllerHelper;
69 /** easier access to a FormControllerHelper instance
71 class ControllerFeatures final
73 IControllerFeatureInvalidation* m_pInvalidationCallback; // necessary as long as m_pImpl is not yet constructed
74 rtl::Reference<FormControllerHelper> m_pImpl;
76 public:
77 /** standard ctor
79 The instance is not functional until <method>assign</method> is used.
81 @param _pInvalidationCallback
82 the callback for invalidating feature states
84 ControllerFeatures(
85 IControllerFeatureInvalidation* _pInvalidationCallback
88 /** constructs the instance from a <type scope="css::form::runtime">XFormController<type> instance
90 @param _rxController
91 The form controller which the helper should be responsible for. Must not
92 be <NULL/>, and must have a valid model (form).
94 ControllerFeatures(
95 const css::uno::Reference< css::form::runtime::XFormController >& _rxController
98 /// dtor
99 ~ControllerFeatures();
101 /// checks whether the instance is properly assigned to a form and/or controller
102 bool isAssigned( ) const { return m_pImpl != nullptr; }
104 /** assign to a controller
106 void assign(
107 const css::uno::Reference< css::form::runtime::XFormController >& _rxController
110 /// clears the instance so that it cannot be used afterwards
111 void dispose();
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(); }
115 FormControllerHelper* operator->() { return m_pImpl.get(); }
119 //= FormControllerHelper
121 typedef ::cppu::WeakImplHelper < css::form::runtime::XFeatureInvalidation
122 , css::sdb::XSQLErrorListener
123 > FormControllerHelper_Base;
124 /** is a helper class which manages form controller functionality (such as moveNext etc.).
126 <p>The class helps implementing form controller functionality, by providing
127 methods to determine the state of, and execute, various common form features.<br/>
128 A <em>feature</em> is for instance moving the form associated with the controller
129 to a certain position, or reloading the form, and so on.</p>
131 class FormControllerHelper final : public FormControllerHelper_Base
133 IControllerFeatureInvalidation* m_pInvalidationCallback;
134 css::uno::Reference< css::form::runtime::XFormOperations >
135 m_xFormOperations;
137 css::uno::Any m_aOperationError;
139 public:
140 /** constructs the helper from a <type scope="css::form::runtime">XFormController<type> instance
142 @param _rxController
143 The form controller which the helper should be responsible for. Must not
144 be <NULL/>, and must have a valid model (form).
145 @param _pInvalidationCallback
146 the callback for invalidating feature states
148 FormControllerHelper(
149 const css::uno::Reference< css::form::runtime::XFormController >& _rxController,
150 IControllerFeatureInvalidation* _pInvalidationCallback
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;
168 bool canDoFormFilter() const;
170 /** disposes this instance.
172 After this method has been called, the instance is not functional anymore
174 void dispose();
176 private:
177 /// dtor
178 virtual ~FormControllerHelper() override;
180 // XFeatureInvalidation
181 virtual void SAL_CALL invalidateFeatures( const css::uno::Sequence< ::sal_Int16 >& Features ) override;
182 virtual void SAL_CALL invalidateAllFeatures() override;
184 // XSQLErrorListener
185 virtual void SAL_CALL errorOccured( const css::sdb::SQLErrorEvent& Event ) override;
187 // XEventListener
188 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
190 enum FormOperation { EXECUTE, EXECUTE_ARGS, COMMIT_CONTROL, COMMIT_RECORD };
192 bool impl_operateForm_nothrow(
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
199 return impl_operateForm_nothrow( _eWhat, 0, css::uno::Sequence< css::beans::NamedValue >() );
202 private:
203 FormControllerHelper( const FormControllerHelper& ) = delete;
204 FormControllerHelper& operator=( const FormControllerHelper& ) = delete;
211 #endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */