LibreOffice Module extensions (master) 1
eformshelper.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#pragma once
21
22#include "pcrcommon.hxx"
23
24#include <com/sun/star/frame/XModel.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/xforms/XModel.hpp>
27#include <com/sun/star/xforms/XFormsSupplier.hpp>
28#include <com/sun/star/form/binding/XBindableValue.hpp>
29#include <com/sun/star/form/binding/XListEntrySource.hpp>
30#include <osl/mutex.hxx>
31#include <rtl/ustring.hxx>
32
33#include <vector>
34#include <set>
35#include <map>
36
37
38namespace pcr
39{
40
41
42 typedef std::map< OUString, css::uno::Reference< css::beans::XPropertySet >, std::less< OUString > >
44
45
46 //= EFormsHelper
47
49 {
50 protected:
51 css::uno::Reference< css::beans::XPropertySet >
53 css::uno::Reference< css::form::binding::XBindableValue >
55 css::uno::Reference< css::xforms::XFormsSupplier >
60 m_aSubmissionUINames; // only filled upon request
62 m_aBindingUINames; // only filled upon request
63
64 public:
66 ::osl::Mutex& _rMutex,
67 const css::uno::Reference< css::beans::XPropertySet >& _rxControlModel,
68 const css::uno::Reference< css::frame::XModel >& _rxContextDocument
69 );
70
76 static bool
77 isEForm(
78 const css::uno::Reference< css::frame::XModel >& _rxContextDocument
79 );
80
90 const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxBindingListener
91 );
92
97 const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxBindingListener
98 );
99
106 bool canBindToDataType( sal_Int32 _nDataType = -1 ) const;
107
110 bool canBindToAnyDataType() const { return canBindToDataType(); }
111
114 bool isListEntrySink() const;
115
118 void getFormModelNames( std::vector< OUString >& /* [out] */ _rModelNames ) const;
119
123 void getBindingNames( const OUString& _rModelName, std::vector< OUString >& /* [out] */ _rBindingNames ) const;
124
126 css::uno::Reference< css::xforms::XModel >
127 getFormModelByName( const OUString& _rModelName ) const;
128
131 css::uno::Reference< css::xforms::XModel >
132 getCurrentFormModel() const;
133
136 OUString
138
141 css::uno::Reference< css::beans::XPropertySet >
142 getCurrentBinding() const;
143
146 OUString
147 getCurrentBindingName() const;
148
151 void setBinding( const css::uno::Reference< css::beans::XPropertySet >& _rxBinding );
152
156 css::uno::Reference< css::form::binding::XListEntrySource >
158
162 void setListSourceBinding( const css::uno::Reference< css::form::binding::XListEntrySource >& _rxListSource );
163
172 css::uno::Reference< css::beans::XPropertySet >
173 getOrCreateBindingForModel( const OUString& _rTargetModel, const OUString& _rBindingName ) const;
174
178 {
180 Binding
181 };
182
187 static OUString
189 const ModelElementType _eType,
190 const css::uno::Reference< css::beans::XPropertySet >& _rxElement
191 );
192
200 css::uno::Reference< css::beans::XPropertySet >
202 const ModelElementType _eType,
203 const OUString& _rUIName
204 ) const;
205
215 const ModelElementType _eType,
216 std::vector< OUString >& /* [out] */ _rElementNames,
217 bool _bPrepentEmptyEntry
218 );
219
220 protected:
222 const css::uno::Reference< css::beans::XPropertySet >& _rxOldProps,
223 const css::uno::Reference< css::beans::XPropertySet >& _rxNewProps,
224 std::set< OUString >& _rFilter
225 ) const;
226
231 const OUString& _rName,
232 const css::uno::Any& _rOldValue,
233 const css::uno::Any& _rNewValue
234 ) const;
235
236 private:
237 void impl_switchBindingListening_throw( bool _bDoListening, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
238
240 css::uno::Reference< css::beans::XPropertySet >
241 implGetOrCreateBinding( const OUString& _rTargetModel, const OUString& _rBindingName ) const;
242
243 void
244 impl_toggleBindingPropertyListening_throw( bool _bDoListen, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxConcreteListenerOrNull );
245
246 private:
247 EFormsHelper( const EFormsHelper& ) = delete;
249 };
250
251
252} // namespace pcr
253
254
255/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::beans::XPropertySet > m_xControlModel
void getBindingNames(const OUString &_rModelName, std::vector< OUString > &_rBindingNames) const
retrieves the names of all bindings for a given model
bool isListEntrySink() const
checks whether the control model is a source for list entries, as supplied by XML data bindings
void getFormModelNames(std::vector< OUString > &_rModelNames) const
retrieves the names of all XForms models in the document the control lives in
EFormsHelper(const EFormsHelper &)=delete
PropertyChangeListeners m_aPropertyListeners
void firePropertyChange(const OUString &_rName, const css::uno::Any &_rOldValue, const css::uno::Any &_rNewValue) const
fires a change in a single property, if the property value changed, and if we have a listener interes...
void setListSourceBinding(const css::uno::Reference< css::form::binding::XListEntrySource > &_rxListSource)
sets a new list source at the control model
void setBinding(const css::uno::Reference< css::beans::XPropertySet > &_rxBinding)
sets a new binding at the control model
bool canBindToAnyDataType() const
checks whether the control model can be bound to any XSD data type
css::uno::Reference< css::form::binding::XListEntrySource > getCurrentListSourceBinding() const
retrieves the binding instance which is currently used as list source for the control model
void registerBindingListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxBindingListener)
registers a listener to be notified when any aspect of the binding changes.
void impl_toggleBindingPropertyListening_throw(bool _bDoListen, const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxConcreteListenerOrNull)
void revokeBindingListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxBindingListener)
revokes the binding listener which has previously been registered
ModelElementType
types of sub-elements of a model
css::uno::Reference< css::xforms::XFormsSupplier > m_xDocument
css::uno::Reference< css::xforms::XModel > getCurrentFormModel() const
retrieves the model which the active binding of the control model belongs to
OUString getCurrentFormModelName() const
retrieves the name of the model which the active binding of the control model belongs to
css::uno::Reference< css::beans::XPropertySet > getModelElementFromUIName(const ModelElementType _eType, const OUString &_rUIName) const
retrieves the submission object for an UI name
OUString getCurrentBindingName() const
retrieves the name of the binding instance which is currently attached to the control model
MapStringToPropertySet m_aSubmissionUINames
static OUString getModelElementUIName(const ModelElementType _eType, const css::uno::Reference< css::beans::XPropertySet > &_rxElement)
retrieves the name of a model's sub-element, as to be shown in the UI
bool canBindToDataType(sal_Int32 _nDataType=-1) const
checks whether it's possible to bind the control model to a given XSD data type
css::uno::Reference< css::beans::XPropertySet > implGetOrCreateBinding(const OUString &_rTargetModel, const OUString &_rBindingName) const
implementation for both <member>getOrCreateBindingForModel</member>
EFormsHelper & operator=(const EFormsHelper &)=delete
EFormsHelper(::osl::Mutex &_rMutex, const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const css::uno::Reference< css::frame::XModel > &_rxContextDocument)
css::uno::Reference< css::xforms::XModel > getFormModelByName(const OUString &_rModelName) const
retrieves the XForms model (within the control model's document) with the given name
css::uno::Reference< css::beans::XPropertySet > getCurrentBinding() const
retrieves the binding instance which is currently attached to the control model
void firePropertyChanges(const css::uno::Reference< css::beans::XPropertySet > &_rxOldProps, const css::uno::Reference< css::beans::XPropertySet > &_rxNewProps, std::set< OUString > &_rFilter) const
void impl_switchBindingListening_throw(bool _bDoListening, const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener)
MapStringToPropertySet m_aBindingUINames
css::uno::Reference< css::form::binding::XBindableValue > m_xBindableControl
css::uno::Reference< css::beans::XPropertySet > getOrCreateBindingForModel(const OUString &_rTargetModel, const OUString &_rBindingName) const
retrieves a given binding for a given model, or creates a new one
static bool isEForm(const css::uno::Reference< css::frame::XModel > &_rxContextDocument)
determines whether the given document is an eForm
void getAllElementUINames(const ModelElementType _eType, std::vector< OUString > &_rElementNames, bool _bPrepentEmptyEntry)
retrieves the UI names of all elements of all models in our document
a property handler for any virtual string properties
Definition: browserline.cxx:39
std::map< OUString, css::uno::Reference< css::beans::XPropertySet >, std::less< OUString > > MapStringToPropertySet