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 
28 #include <cppuhelper/implbase.hxx>
29 #include <rtl/ref.hxx>
30 
31 #include <vector>
32 
33 
34 namespace 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;
71  class ControllerFeatures final
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(); }
115  FormControllerHelper* operator->() { return m_pImpl.get(); }
116  };
117 
118 
119  //= FormControllerHelper
120 
121  typedef ::cppu::WeakImplHelper < css::form::runtime::XFeatureInvalidation
122  , css::sdb::XSQLErrorListener
132  {
133  protected:
135  css::uno::Reference< css::form::runtime::XFormOperations >
137 
138  css::uno::Any m_aOperationError;
139 
140  public:
150  const css::uno::Reference< css::form::runtime::XFormController >& _rxController,
151  IControllerFeatureInvalidation* _pInvalidationCallback
152  );
153 
154  // forwards to the XFormOperations implementation
155  css::uno::Reference< css::sdbc::XRowSet >
156  getCursor() const;
157  void getState(
158  sal_Int32 _nSlotId,
159  css::form::runtime::FeatureState& _out_rState
160  ) const;
161  bool isEnabled( sal_Int32 _nSlotId ) const;
162  void execute( sal_Int32 _nSlotId ) const;
163  void execute( sal_Int32 _nSlotId, const OUString& _rParamName, const css::uno::Any& _rParamValue ) const;
164  bool commitCurrentRecord() const;
165  bool commitCurrentControl( ) const;
166  bool isInsertionRow() const;
167  bool isModifiedRow() const;
168 
169  bool canDoFormFilter() const;
170 
175  void dispose();
176 
177  protected:
179  virtual ~FormControllerHelper() override;
180 
181  // XFeatureInvalidation
182  virtual void SAL_CALL invalidateFeatures( const css::uno::Sequence< ::sal_Int16 >& Features ) override;
183  virtual void SAL_CALL invalidateAllFeatures() override;
184 
185  // XSQLErrorListener
186  virtual void SAL_CALL errorOccured( const css::sdb::SQLErrorEvent& Event ) override;
187 
188  // XEventListener
189  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
190 
191  private:
193 
195  const FormOperation _eWhat,
196  const sal_Int16 _nFeature, /* ignore for COMMIT_* */
197  const css::uno::Sequence< css::beans::NamedValue >& _rArguments /* ignore except for EXECUTE_ARGS */
198  ) const;
199  bool impl_operateForm_nothrow( const FormOperation _eWhat ) const
200  {
201  return impl_operateForm_nothrow( _eWhat, 0, css::uno::Sequence< css::beans::NamedValue >() );
202  }
203 
204  private:
205  FormControllerHelper( const FormControllerHelper& ) = delete;
207  };
208 
209 
210 }
211 
212 
213 #endif // INCLUDED_SVX_SOURCE_INC_FORMCONTROLLING_HXX
214 
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void invalidateFeatures(const ::std::vector< sal_Int32 > &_rFeatures)=0
invalidates the given features
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
FormControllerHelper & operator=(const FormControllerHelper &)=delete
easier access to a FormControllerHelper instance
bool isEnabled(sal_Int32 _nSlotId) const
void execute(sal_Int32 _nSlotId) const
virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent &Event) override
FormControllerHelper(const css::uno::Reference< css::form::runtime::XFormController > &_rxController, IControllerFeatureInvalidation *_pInvalidationCallback)
constructs the helper from a XFormController instance ...
rtl::Reference< FormControllerHelper > m_pImpl
IControllerFeatureInvalidation * m_pInvalidationCallback
::cppu::WeakImplHelper< css::form::runtime::XFeatureInvalidation, css::sdb::XSQLErrorListener > FormControllerHelper_Base
void dispose()
disposes this instance.
void assign(const css::uno::Reference< css::form::runtime::XFormController > &_rxController)
assign to a controller
virtual void SAL_CALL invalidateAllFeatures() override
css::uno::Reference< css::form::runtime::XFormOperations > m_xFormOperations
void dispose()
clears the instance so that it cannot be used afterwards
static sal_Int32 getControllerFeatureSlotIdForURL(const OUString &_rMainURL)
retrieves the feature id for a given feature URL
const FormControllerHelper * operator->() const
is a helper class which manages form controller functionality (such as moveNext etc.).
css::uno::Reference< css::sdbc::XRowSet > getCursor() const
IControllerFeatureInvalidation * m_pInvalidationCallback
ControllerFeatures(IControllerFeatureInvalidation *_pInvalidationCallback)
standard ctor
virtual void SAL_CALL invalidateFeatures(const css::uno::Sequence< ::sal_Int16 > &Features) override
bool impl_operateForm_nothrow(const FormOperation _eWhat) const
static sal_Int16 getFormFeatureForSlotId(sal_Int32 _nSlotId)
retrieves the css.form.runtime.FormFeature ID for a given slot ID
FormControllerHelper * operator->()
virtual ~FormControllerHelper() override
dtor
static sal_Int32 getSlotIdForFormFeature(sal_Int16 _nFormFeature)
retrieves the slot id for a given css.form.runtime.FormFeature ID
bool isAssigned() const
checks whether the instance is properly assigned to a form and/or controller
bool impl_operateForm_nothrow(const FormOperation _eWhat, const sal_Int16 _nFeature, const css::uno::Sequence< css::beans::NamedValue > &_rArguments) const
void getState(sal_Int32 _nSlotId, css::form::runtime::FeatureState &_out_rState) const