diff options
Diffstat (limited to 'forms/source/inc')
-rw-r--r-- | forms/source/inc/FormComponent.hxx | 1206 | ||||
-rw-r--r-- | forms/source/inc/InterfaceContainer.hxx | 301 | ||||
-rw-r--r-- | forms/source/inc/cloneable.hxx | 41 | ||||
-rw-r--r-- | forms/source/inc/commandimageprovider.hxx | 53 | ||||
-rw-r--r-- | forms/source/inc/componenttools.hxx | 84 | ||||
-rw-r--r-- | forms/source/inc/controlfeatureinterception.hxx | 87 | ||||
-rw-r--r-- | forms/source/inc/featuredispatcher.hxx | 101 | ||||
-rw-r--r-- | forms/source/inc/formcontrolfont.hxx | 96 | ||||
-rw-r--r-- | forms/source/inc/formnavigation.hxx | 217 | ||||
-rw-r--r-- | forms/source/inc/frm_resource.hxx | 38 | ||||
-rw-r--r-- | forms/source/inc/frm_strings.hxx | 285 | ||||
-rw-r--r-- | forms/source/inc/limitedformats.hxx | 94 | ||||
-rw-r--r-- | forms/source/inc/property.hxx | 340 | ||||
-rw-r--r-- | forms/source/inc/propertybaghelper.hxx | 147 | ||||
-rw-r--r-- | forms/source/inc/resettable.hxx | 62 | ||||
-rw-r--r-- | forms/source/inc/services.hxx | 195 | ||||
-rw-r--r-- | forms/source/inc/togglestate.hxx | 33 | ||||
-rw-r--r-- | forms/source/inc/urltransformer.hxx | 70 | ||||
-rw-r--r-- | forms/source/inc/windowstateguard.hxx | 70 |
19 files changed, 3520 insertions, 0 deletions
diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx new file mode 100644 index 000000000..833cd90df --- /dev/null +++ b/forms/source/inc/FormComponent.hxx @@ -0,0 +1,1206 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "cloneable.hxx" +#include "propertybaghelper.hxx" +#include "resettable.hxx" +#include "windowstateguard.hxx" + +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> +#include <com/sun/star/form/validation/XValidityConstraintListener.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> +#include <com/sun/star/form/XBoundControl.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XLoadListener.hpp> +#include <com/sun/star/form/XReset.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdb/XColumn.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> +#include <com/sun/star/sdb/XRowSetChangeListener.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/form/XLoadable.hpp> + +#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/propagg.hxx> +#include <comphelper/propmultiplex.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/propshlp.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> + + +namespace frm +{ + + + // default tab index for components + const sal_Int16 FRM_DEFAULT_TABINDEX = 0; + + class OControlModel; + + + //= ControlModelLock + + /** class whose instances lock an OControlModel + + Locking here merely means locking the OControlModel's mutex. + + In addition to the locking facility, the class is also able to fire property + change notifications. This happens when the last ControlModelLock instance on a stack + dies. + */ + class ControlModelLock + { + public: + ControlModelLock( OControlModel& _rModel ) + :m_rModel( _rModel ) + ,m_bLocked( false ) + { + acquire(); + } + + ~ControlModelLock() + { + if ( m_bLocked ) + release(); + } + inline void acquire(); + inline void release(); + + OControlModel& getModel() const { return m_rModel; }; + + /** adds a property change notification, which is to be fired when the last lock on the model + (in the current thread) is released. + */ + void addPropertyNotification( + const sal_Int32 _nHandle, + const css::uno::Any& _rOldValue, + const css::uno::Any& _rNewValue + ); + + private: + void impl_notifyAll_nothrow(); + + OControlModel& m_rModel; + bool m_bLocked; + std::vector< sal_Int32 > m_aHandles; + std::vector< css::uno::Any > m_aOldValues; + std::vector< css::uno::Any > m_aNewValues; + + ControlModelLock( const ControlModelLock& ) = delete; + ControlModelLock& operator=( const ControlModelLock& ) = delete; + }; + + +//= OControl +//= base class for form layer controls + +typedef ::cppu::ImplHelper3 < css::awt::XControl + , css::lang::XEventListener + , css::lang::XServiceInfo + > OControl_BASE; + +class OControl :public ::cppu::OComponentHelper + ,public OControl_BASE +{ +protected: + ::osl::Mutex m_aMutex; + css::uno::Reference< css::awt::XControl > m_xControl; + css::uno::Reference< css::uno::XAggregation> + m_xAggregate; + + css::uno::Reference< css::uno::XComponentContext > + m_xContext; + WindowStateGuard m_aWindowStateGuard; + +public: + /** constructs a control + + @param _rFactory + the service factory for this control + @param _rAggregateService + the service name of the component to aggregate + @param _bSetDelegator + set this to <FALSE/> if you don't want the constructor to set the delegator at + the aggregate. In this case, you <em>have</em> to call doSetDelegator within your + own constructor. + + This is helpful, if your derived class wants to cache an interface of the aggregate. + In this case, the aggregate needs to be queried for this interface <b>before</b> the + <member scope="css::uno">XAggregation::setDelegator</member> call. + + In such a case, pass <FALSE/> to this parameter. Then, cache the aggregate's interface(s) + as needed. Afterwards, call <member>doSetDelegator</member>. + + In your destructor, you need to call <member>doResetDelegator</member> before + resetting the cached interfaces. This will reset the aggregates delegator to <NULL/>, + which will ensure that the <member scope="css::uno">XInterface::release</member> + calls on the cached interfaces are really applied to the aggregate, instead of + the <type>OControl</type> itself. + */ + OControl( + const css::uno::Reference< css::uno::XComponentContext >& _rFactory, + const OUString& _rAggregateService, + const bool _bSetDelegator = true + ); + +protected: + virtual ~OControl() override; + + /** sets the control as delegator at the aggregate + + This has to be called from within your derived class' constructor, if and only + if you passed <FALSE/> to the <arg>_bSetDelegator</arg> parameter of the + <type>OControl</type> constructor. + */ + void doSetDelegator(); + void doResetDelegator(); + +// UNO + DECLARE_UNO3_AGG_DEFAULTS(OControl, OComponentHelper) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + +// XTypeProvider + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; + virtual css::uno::Sequence< css::uno::Type> SAL_CALL getTypes() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// XComponent (as base of XControl) + virtual void SAL_CALL dispose( ) override + { OComponentHelper::dispose(); } + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener>& _rxListener) override + { OComponentHelper::addEventListener(_rxListener); } + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener>& _rxListener) override + { OComponentHelper::removeEventListener(_rxListener); } + +// XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +// XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + virtual OUString SAL_CALL getImplementationName() override = 0; + +// XControl + virtual void SAL_CALL setContext(const css::uno::Reference<css::uno::XInterface>& Context) override; + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL getContext() override; + virtual void SAL_CALL createPeer(const css::uno::Reference<css::awt::XToolkit>& Toolkit, const css::uno::Reference<css::awt::XWindowPeer>& Parent) override; + virtual css::uno::Reference<css::awt::XWindowPeer> SAL_CALL getPeer() override; + virtual sal_Bool SAL_CALL setModel(const css::uno::Reference<css::awt::XControlModel>& Model) override; + virtual css::uno::Reference<css::awt::XControlModel> SAL_CALL getModel() override; + virtual css::uno::Reference<css::awt::XView> SAL_CALL getView() override; + virtual void SAL_CALL setDesignMode(sal_Bool bOn) override; + virtual sal_Bool SAL_CALL isDesignMode() override; + virtual sal_Bool SAL_CALL isTransparent() override; + +protected: + virtual css::uno::Sequence< css::uno::Type> _getTypes(); + // overwrite this and call the base class if you have additional types + + css::uno::Sequence< OUString > getAggregateServiceNames() const; + +private: + void impl_resetStateGuard_nothrow(); +}; + +// a form control implementing the XBoundControl interface +typedef ::cppu::ImplHelper1 < css::form::XBoundControl + > OBoundControl_BASE; +class OBoundControl :public OControl + ,public OBoundControl_BASE +{ + bool m_bLocked : 1; + +public: + OBoundControl( + const css::uno::Reference< css::uno::XComponentContext >& _rxContext, + const OUString& _rAggregateService, + const bool _bSetDelegator = true + ); + + virtual ~OBoundControl() override; + + DECLARE_UNO3_AGG_DEFAULTS(OBoundControl, OControl) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + + // XBoundControl + virtual sal_Bool SAL_CALL getLock() override; + virtual void SAL_CALL setLock(sal_Bool _bLock) override; + // default implementation just disables the controls, overwrite _setLock to change this behaviour + + // XControl + virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel >& Model) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + +protected: + virtual css::uno::Sequence< css::uno::Type> _getTypes() override; + // implement the lock setting + void _setLock(bool _bLock); +}; + + +//= OControlModel +//= model of a form layer control + +//added for exporting OCX control +#define INVALID_OBJ_ID_IN_MSO 0xFFFF + +typedef ::cppu::ImplHelper7 < css::form::XFormComponent + , css::io::XPersistObject + , css::container::XNamed + , css::lang::XServiceInfo + , css::util::XCloneable + , css::beans::XPropertyContainer + , css::beans::XPropertyAccess + > OControlModel_BASE; + +class OControlModel :public ::cppu::OComponentHelper + ,public comphelper::OPropertySetAggregationHelper + ,public OControlModel_BASE + ,public OCloneableAggregation + ,public IPropertyBagHelperContext +{ + +protected: + css::uno::Reference<css::uno::XComponentContext> m_xContext; + + ::osl::Mutex m_aMutex; + oslInterlockedCount m_lockCount; + + css::uno::Reference<css::uno::XInterface> m_xParent; // ParentComponent + PropertyBagHelper m_aPropertyBagHelper; + + const css::uno::Reference<css::uno::XComponentContext>& + getContext() const { return m_xContext; } + +// <properties> + OUString m_aName; // name of the control + OUString m_aTag; // tag for additional data + sal_Int16 m_nTabIndex; // index within the taborder + sal_Int16 m_nClassId; // type of the control + bool m_bNativeLook; // should the control use the native platform look? + bool m_bGenerateVbEvents; // should the control generate fake vba events + //added for exporting OCX control + sal_Int16 m_nControlTypeinMSO; //keep the MS office control type for exporting to MS binary file + sal_uInt16 m_nObjIDinMSO; //keep the OCX control obj id for exporting to MS binary file +// </properties> + + +protected: + OControlModel( + const css::uno::Reference< css::uno::XComponentContext>& _rFactory, // factory to create the aggregate with + const OUString& _rUnoControlModelTypeName, // service name of te model to aggregate + const OUString& rDefault = OUString(), // service name of the default control + const bool _bSetDelegator = true // set to sal_False if you want to call setDelegator later (after returning from this ctor) + ); + OControlModel( + const OControlModel* _pOriginal, // the original object to clone + const css::uno::Reference< css::uno::XComponentContext>& _rFactory, // factory to create the aggregate with + const bool _bCloneAggregate = true, // should the aggregate of the original be cloned, too? + const bool _bSetDelegator = true // set to sal_False if you want to call setDelegator later (after returning from this ctor) + ); + virtual ~OControlModel() override; + + /** to be called after an OBoundControlModel (a derivee, respectively) has been cloned + + <p>This method contains late initializations which cannot be done in the + constructor of this base class, since the virtual method of derived classes do + not yet work there.</p> + */ + virtual void clonedFrom( const OControlModel* _pOriginal ); + + using OComponentHelper::rBHelper; + + virtual css::uno::Sequence< css::uno::Type> _getTypes(); + + void readHelpTextCompatibly(const css::uno::Reference< css::io::XObjectInputStream >& _rxInStream); + void writeHelpTextCompatibly(const css::uno::Reference< css::io::XObjectOutputStream >& _rxOutStream); + + void doSetDelegator(); + void doResetDelegator(); + + css::uno::Sequence< OUString > getAggregateServiceNames() const; + +public: + DECLARE_UNO3_AGG_DEFAULTS(OControl, OComponentHelper) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + +// XTypeProvider + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; + virtual css::uno::Sequence< css::uno::Type> SAL_CALL getTypes() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& aName) override; + +// XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + virtual OUString SAL_CALL getImplementationName() override = 0; + +// XServiceInfo - static version(s) + /// @throws css::uno::RuntimeException + static css::uno::Sequence<OUString> getSupportedServiceNames_Static(); + +// XPersistObject + virtual OUString SAL_CALL getServiceName() override = 0; + virtual void SAL_CALL + write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override; + virtual void SAL_CALL + read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override; + +// XChild (base of XFormComponent) + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL getParent() override; + virtual void SAL_CALL setParent(const css::uno::Reference<css::uno::XInterface>& Parent) override; + +// XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +// XPropertySet + virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + using ::cppu::OPropertySetHelper::getFastPropertyValue; + +// css::beans::XPropertyState + virtual css::beans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle) override; + virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle) override; + virtual css::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const override; + +// XCloneable + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override = 0; + +// XPropertyContainer + virtual void SAL_CALL addProperty( const OUString& Name, ::sal_Int16 Attributes, const css::uno::Any& DefaultValue ) override; + virtual void SAL_CALL removeProperty( const OUString& Name ) override; + +// XPropertyAccess + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues( ) override; + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override; + +protected: + using OPropertySetAggregationHelper::setPropertyValues; + using OPropertySetAggregationHelper::getPropertyValues; + +protected: + virtual void writeAggregate( const css::uno::Reference< css::io::XObjectOutputStream >& _rxOutStream ) const; + virtual void readAggregate( const css::uno::Reference< css::io::XObjectInputStream >& _rxInStream ); + +protected: + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + // OPropertySetHelper + virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + /** describes the properties provided by this class, or its respective + derived class + + Derived classes usually call the base class first, and then append own properties. + */ + virtual void describeFixedProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps + ) const; + + // IPropertyBagHelperContext + virtual ::osl::Mutex& getMutex() override; + virtual void describeFixedAndAggregateProperties( + css::uno::Sequence< css::beans::Property >& _out_rFixedProperties, + css::uno::Sequence< css::beans::Property >& _out_rAggregateProperties + ) const override; + virtual css::uno::Reference< css::beans::XMultiPropertySet > + getPropertiesInterface() override; + + /** describes the properties of our aggregate + + The default implementation simply asks m_xAggregateSet for its properties. + + You usually only need to override this method if you want to filter the + aggregate properties. + */ + virtual void describeAggregateProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps + ) const; + +public: + struct LockAccess { friend class ControlModelLock; private: LockAccess() { } }; + + void lockInstance( LockAccess ); + oslInterlockedCount unlockInstance( LockAccess ); + + void firePropertyChanges( + const std::vector< sal_Int32 >& _rHandles, + const std::vector< css::uno::Any >& _rOldValues, + const std::vector< css::uno::Any >& _rNewValues, + LockAccess + ); + + ::osl::Mutex& + getInstanceMutex() { return m_aMutex; } +}; + +//= OBoundControlModel +//= model of a form layer control which is bound to a data source field + +typedef ::cppu::ImplHelper4 < css::form::XLoadListener + , css::form::XReset + , css::beans::XPropertyChangeListener + , css::sdb::XRowSetChangeListener + > OBoundControlModel_BASE1; + +// separated into an own base class since derivees can disable the support for this +// interface, thus we want to easily exclude it in the queryInterface and getTypes +typedef ::cppu::ImplHelper1 < css::form::XBoundComponent + > OBoundControlModel_COMMITTING; + +// ditto +typedef ::cppu::ImplHelper2 < css::form::binding::XBindableValue + , css::util::XModifyListener + > OBoundControlModel_BINDING; + +// ditto +typedef ::cppu::ImplHelper2 < css::form::validation::XValidityConstraintListener + , css::form::validation::XValidatableFormComponent + > OBoundControlModel_VALIDATION; + +class OBoundControlModel :public OControlModel + ,public OBoundControlModel_BASE1 + ,public OBoundControlModel_COMMITTING + ,public OBoundControlModel_BINDING + ,public OBoundControlModel_VALIDATION + ,public ::comphelper::OPropertyChangeListener +{ +protected: + enum ValueChangeInstigator + { + eDbColumnBinding, + eExternalBinding, + eOther + }; + +private: + css::uno::Reference< css::beans::XPropertySet > + m_xField; + // the form which controls supplies the field we bind to. + css::uno::Reference< css::form::XLoadable > + m_xAmbientForm; + + OUString m_sValuePropertyName; + sal_Int32 m_nValuePropertyAggregateHandle; + sal_Int32 m_nFieldType; + css::uno::Type m_aValuePropertyType; + bool m_bValuePropertyMayBeVoid; + + ResetHelper m_aResetHelper; + ::comphelper::OInterfaceContainerHelper3<css::form::XUpdateListener> + m_aUpdateListeners; + ::comphelper::OInterfaceContainerHelper3<css::form::validation::XFormComponentValidityListener> + m_aFormComponentListeners; + + css::uno::Reference< css::form::binding::XValueBinding > + m_xExternalBinding; + css::uno::Reference< css::form::validation::XValidator > + m_xValidator; + css::uno::Type m_aExternalValueType; + +// <properties> + OUString m_aControlSource; // data source, name of the field + css::uno::Reference< css::beans::XPropertySet > + m_xLabelControl; // reference to a sibling control (model) which is our label + bool m_bInputRequired; +// </properties> + + rtl::Reference<::comphelper::OPropertyChangeMultiplexer> + m_pAggPropMultiplexer; + + bool m_bFormListening : 1; // are we currently a XLoadListener at our ambient form? + bool m_bLoaded : 1; + bool m_bRequired : 1; + const bool m_bCommitable : 1; // do we support XBoundComponent? + const bool m_bSupportsExternalBinding : 1; // do we support XBindableValue? + const bool m_bSupportsValidation : 1; // do we support XValidatable? + bool m_bForwardValueChanges : 1; // do we currently handle changes in the bound database field? + bool m_bTransferringValue : 1; // true if we're currently transferring our value to an external binding + bool m_bIsCurrentValueValid : 1; // flag specifying whether our current value is valid, relative to our external validator + bool m_bBindingControlsRO : 1; // is our ReadOnly property currently controlled by our external binding? + bool m_bBindingControlsEnable : 1; // is our Enabled property currently controlled by our external binding? + + ValueChangeInstigator m_eControlValueChangeInstigator; + +protected: + OUString m_aLabelServiceName; + // when setting the label for our control (property FM_PROP_CONTROLLABEL, member m_xLabelControl), + // we accept only objects supporting an XControlModel interface, an XServiceInfo interface and + // support for a service (XServiceInfo::supportsService) determined by this string. + // Any other arguments will throw an IllegalArgumentException. + // The default value is FM_COMPONENT_FIXEDTEXT. + + css::uno::Reference< css::sdbc::XRowSet > + m_xCursor; + css::uno::Reference< css::sdb::XColumnUpdate > + m_xColumnUpdate; + css::uno::Reference< css::sdb::XColumn > + m_xColumn; + +protected: + sal_Int32 getValuePropertyAggHandle( ) const { return m_nValuePropertyAggregateHandle; } + const OUString& getControlSource( ) const { return m_aControlSource; } + bool isRequired() const { return m_bRequired; } + bool isLoaded() const { return m_bLoaded; } + +protected: + + OBoundControlModel( + const css::uno::Reference< css::uno::XComponentContext>& _rxContext, + // factory to create the aggregate with + const OUString& _rUnoControlModelTypeName, // service name of te model to aggregate + const OUString& _rDefault, // service name of the default control + const bool _bCommitable, // is the control (model) committable? + const bool _bSupportExternalBinding, // set to sal_True if you want to support XBindableValue + const bool _bSupportsValidation // set to sal_True if you want to support XValidatable + ); + OBoundControlModel( + const OBoundControlModel* _pOriginal, // the original object to clone + const css::uno::Reference< css::uno::XComponentContext>& _rxContext + // factory to create the aggregate with + ); + virtual ~OBoundControlModel() override; + + /// late ctor after cloning + virtual void clonedFrom( const OControlModel* _pOriginal ) override; + + /** initializes the part of the class which is related to the control value. + + <p>Kind of late ctor, to be called for derivees which have a dedicated value property.<br/> + The value property is the property which's value is synced with either the database + column the object is bound to, or with the external value binding, if present.<br/> + E.g. for a text control model, this property will most probably be "Text".</p> + + <p>Derived classes are strongly recommended to call this method - at least the + "DataFieldProperty" (exposed in getFastPropertyValue) relies on the information + given herein, and needs to be supplied otherwise else.</p> + + <p>If this method has been called properly, then <member>setControlValue</member> + does not need to be overridden - it will simply set the property value at the + aggregate then.</p> + + @precond + The method has not be called before during the life time of the object. + + @param _rValuePropertyName + the name of the value property + @param _nValuePropertyExternalHandle + the handle of the property, as exposed to external components.<br/> + Normally, this information can be obtained dynamically (e.g. from describeFixedProperties), + but since this method is to be called from within the constructor of derived classes, + we prefer to be on the *really* safe side here... + + @see setControlValue + @see suspendValueListening + @see resumeValueListening + @see describeFixedProperties + */ + void initValueProperty( + const OUString& _rValuePropertyName, + sal_Int32 _nValuePropertyExternalHandle + ); + + /** initializes the part of the class which is related to the control value. + + <p>In opposite to ->initValueProperty, this method is to be used for value properties which are <em>not</em> + implemented by our aggregate, but by ourselves.</p> + + <p>Certain functionality is not available when using own value properties. This includes binding to an external + value and external validation. (This is not a conceptual limit, but simply missing implementation.)</p> + */ + void initOwnValueProperty( + const OUString& i_rValuePropertyName + ); + + /** suspends listening at the value property + + <p>As long as this listening is suspended, changes in the value property will not be + recognized and not be handled.</p> + + @see initValueProperty + @see resumeValueListening + */ + void suspendValueListening( ); + + /** resumes listening at the value property + + <p>As long as this listening is suspended, changes in the value property will not be + recognized and not be handled.</p> + + @precond + listening at the value property is currently suspended + + @see initValueProperty + @see resumeValueListening + */ + void resumeValueListening( ); + + /** (to be) called when the value property changed + + Normally, this is done automatically, since the value property is a property of our aggregate, and we're + a listener at this property. + However, in some cases the value property might not be an aggregate property, but a property of the + delegator instance. In this case, you'll need to call <code>onValuePropertyChange</code> whenever this + property changes. + */ + void onValuePropertyChange( ControlModelLock& i_rControLock ); + + /** starts listening at the aggregate, for changes in the given property + + <p>The OBoundControlModel automatically registers a multiplexer which listens for + changes in the aggregate property values. By default, only the control value property + is observed. You may add additional properties to be observed with this method.</p> + + @see initValueProperty + @see _propertyChanged + */ + void startAggregatePropertyListening( const OUString& _rPropertyName ); + + /** returns the default which should be used when resetting the control + + <p>The default implementation returns an empty Any.</p> + + @see resetNoBroadcast + */ + virtual css::uno::Any + getDefaultForReset() const; + + /** translates a db column value into a control value. + + <p>Must transform the very current value of the database column we're bound to + (<member>m_xColumn</member>) into a value which can be used as current value + for the control.</p> + + @see setControlValue + @pure + */ + virtual css::uno::Any + translateDbColumnToControlValue( ) = 0; + + /** returns the data types which the control could use to exchange data with + an external value binding + + The types returned here are completely independent from the concrete value binding, + they're just candidates which depend on the control type, and possible the concrete state + of the control (i.e. some property value). + + If a control implementation supports multiple types, the ordering in the returned + sequence indicates preference: Preferred types are mentioned first. + + The default implementation returns the type of our value property. + */ + virtual css::uno::Sequence< css::uno::Type > + getSupportedBindingTypes(); + + /** translates the given value, which was obtained from the current external value binding, + to a value which can be used in setControlValue + + <p>The default implementation returns the value itself, exception when it is VOID, and + our value property is not allowed to be void - in this case, the returned value is a + default-constructed value of the type required by our value property. + + @see hasExternalValueBinding + @see getExternalValueType + */ + virtual css::uno::Any + translateExternalValueToControlValue( const css::uno::Any& _rExternalValue ) const; + + /** commits the current control value to our external value binding + + <p>The default implementation simply calls getControlValue.</p> + + @see hasExternalValueBinding + @see initValueProperty + */ + virtual css::uno::Any + translateControlValueToExternalValue( ) const; + + /** commits the current control value to the database column we're bound to + @precond + we're properly bound to a database column, especially <member>m_xColumnUpdate</member> + is not <NULL/> + @param _bPostReset + <TRUE/> if and only if the current control value results from a reset (<member>getDefaultForReset</member>) + @pure + */ + virtual bool commitControlValueToDbColumn( + bool _bPostReset + ) = 0; + + /** sets the given value as new current value for the control + + Besides some administrative work (such as caring for <member>m_eControlValueChangeInstigator</member>), + this method simply calls <member>doSetControlValue</member>. + + @precond + Our own mutex is locked. + @param _rValue + The value to set. This value is guaranteed to be created by + <member>translateDbColumnToControlValue</member> or + <member>translateExternalValueToControlValue</member> + @param _eInstigator + the instigator of the value change + */ + void setControlValue( + const css::uno::Any& _rValue, + ValueChangeInstigator _eInstigator + ); + /** + <p>The default implementation will forward the given value to the aggregate, using + m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p> + + @precond + Our own mutex is locked. + @param _rValue + The value to set. This value is guaranteed to be created by + <member>translateDbColumnToControlValue</member> or + <member>translateExternalValueToControlValue</member> + */ + virtual void doSetControlValue( + const css::uno::Any& _rValue + ); + + /** retrieves the current value of the control + + <p>The default implementation will ask the aggregate for the property value + determined by either m_nValuePropertyAggregateHandle and/or m_sValuePropertyName.</p> + + @precond + Our own mutex is locked. + */ + virtual css::uno::Any + getControlValue( ) const; + + /** called whenever a connection to a database column has been established + */ + virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ); + /** called whenever a connection to a database column has been suspended + */ + virtual void onDisconnectedDbColumn(); + + /** called whenever a connection to an external supplier of values (XValueBinding) has been established + @see m_xExternalBinding + */ + virtual void onConnectedExternalValue( ); + + /** called whenever an external validator has been registered + */ + void onConnectedValidator( ); + /** called whenever an external validator has been revoked + */ + void onDisconnectedValidator( ); + + /** nFieldType is the type of the field, on which the model will be linked. + The linking happens when sal_True is returned. + The default-implementation allows everything but the three binary types + and FieldType_OTHER. + */ + virtual bool approveDbColumnType(sal_Int32 _nColumnType); + + /** retrieves the current value of the control, in a shape which can be used with our + external validator. + + The default implementation simply calls <member>>translateControlValueToExternalValue</member>. + + @precond + Our own mutex is locked. + */ + virtual css::uno::Any + translateControlValueToValidatableValue( ) const; + + /** retrieves the current value of the form component + + This is the implementation method for XValidatableFormComponent::getCurrentValue. The default implementation + calls translateControlValueToValidatableValue if a validator is present, otherwise getControlValue. + + @precond + our mutex is locked when this method is called + */ + virtual css::uno::Any + getCurrentFormComponentValue() const; + + /** We can't write (new) common properties in this base class, as the file format doesn't allow this + (unfortunately). So derived classes may use the following two methods. They secure the written + data with marks, so any new common properties in newer versions will be skipped by older ones. + */ + void writeCommonProperties(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream); + void readCommonProperties(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream); + // the next method may be used in derived classes's read when an unknown version is encountered + void defaultCommonProperties(); + + /** called to reset the control to some kind of default. + + <p>The semantics of "default" is finally defined by the derived class (in particular, + by <member>getDefaultForReset</member>).</p> + + <p>No listener notification needs to be done in the derived class.</p> + + <p>Normally, you won't override this method, but <member>getDefaultForReset</member> instead.</p> + + @see getDefaultForReset + */ + virtual void resetNoBroadcast(); + + virtual css::uno::Sequence< css::uno::Type> _getTypes() override; + + /// sets m_xField to the given new value, without notifying our listeners + void impl_setField_noNotify( + const css::uno::Reference< css::beans::XPropertySet>& _rxField + ); + bool hasField() const + { + return m_xField.is(); + } + sal_Int32 getFieldType() const + { + return m_nFieldType; + } + + // OControlModel's property handling + virtual void describeFixedProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps + ) const override; + +public: + const css::uno::Reference< css::beans::XPropertySet>& getField() const + { + return m_xField; + } + +public: + // UNO link + DECLARE_UNO3_AGG_DEFAULTS(OBoundControlModel, OControlModel) + virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XReset + virtual void SAL_CALL reset( ) override; + virtual void SAL_CALL addResetListener( const css::uno::Reference< css::form::XResetListener >& aListener ) override; + virtual void SAL_CALL removeResetListener( const css::uno::Reference< css::form::XResetListener >& aListener ) override; + + // XServiceInfo + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames( ) override; + + // XServiceInfo - static version + /// @throws css::uno::RuntimeException + static css::uno::Sequence<OUString> getSupportedServiceNames_Static(); + + // XChild + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + + // XPersistObject + virtual void SAL_CALL write( const css::uno::Reference< css::io::XObjectOutputStream >& OutStream ) override; + virtual void SAL_CALL read( const css::uno::Reference< css::io::XObjectInputStream >& InStream ) override; + + // XBoundComponent + virtual sal_Bool SAL_CALL commit() override; + + // XUpdateBroadcaster (base of XBoundComponent) + virtual void SAL_CALL addUpdateListener( const css::uno::Reference< css::form::XUpdateListener >& aListener ) override; + virtual void SAL_CALL removeUpdateListener( const css::uno::Reference< css::form::XUpdateListener >& aListener ) override; + + // XPropertySet + virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + using ::cppu::OPropertySetHelper::getFastPropertyValue; + +// css::beans::XPropertyState + virtual css::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const override; + +// XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +// XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + + // XRowSetChangeListener + virtual void SAL_CALL onRowSetChanged( const css::lang::EventObject& i_Event ) override; + +// XLoadListener + virtual void SAL_CALL loaded( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL unloading( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL unloaded( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL reloading( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL reloaded( const css::lang::EventObject& aEvent ) override; + +protected: + // XBindableValue + virtual void SAL_CALL setValueBinding( const css::uno::Reference< css::form::binding::XValueBinding >& _rxBinding ) override; + virtual css::uno::Reference< css::form::binding::XValueBinding > SAL_CALL getValueBinding( ) override; + + // XModifyListener + virtual void SAL_CALL modified( const css::lang::EventObject& _rEvent ) override; + + // XValidatable + virtual void SAL_CALL setValidator( const css::uno::Reference< css::form::validation::XValidator >& Validator ) override; + virtual css::uno::Reference< css::form::validation::XValidator > SAL_CALL getValidator( ) override; + + // XValidityConstraintListener + virtual void SAL_CALL validityConstraintChanged( const css::lang::EventObject& Source ) override; + + // XValidatableFormComponent + virtual sal_Bool SAL_CALL isValid( ) override; + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual void SAL_CALL addFormComponentValidityListener( const css::uno::Reference< css::form::validation::XFormComponentValidityListener >& Listener ) override; + virtual void SAL_CALL removeFormComponentValidityListener( const css::uno::Reference< css::form::validation::XFormComponentValidityListener >& Listener ) override; + +protected: + // OPropertyChangeListener + virtual void + _propertyChanged( const css::beans::PropertyChangeEvent& _rEvt ) override; + + /// checks whether we currently have an external value binding in place + bool hasExternalValueBinding() const { return m_xExternalBinding.is(); } + + // checks whether we currently have an external validator + bool hasValidator() const { return m_xValidator.is(); } + + /** transfers the very current value of the db column we're bound to the control + @precond + our own mutex is locked + @precond + we don't have an external binding in place + */ + void transferDbValueToControl( ); + + /** transfers the current value of the active external binding to the control + @precond + we do have an active external binding in place + */ + void transferExternalValueToControl( ControlModelLock& _rInstanceLock ); + + /** transfers the control value to the external binding + @precond + our own mutex is locked, and _rInstanceLock is the guard locking it + @precond + we do have an active external binding in place + */ + void transferControlValueToExternal( ControlModelLock& _rInstanceLock ); + + /** calculates the type which is to be used to communicate with the current external binding, + and stores it in m_aExternalValueType + + The method checks the possible type candidates as returned by getSupportedBindingTypes, + and the types supported by the current external binding, if any. + */ + void calculateExternalValueType(); + + /** returns the type which should be used to exchange data with our external value binding + + @see initValueProperty + */ + const css::uno::Type& + getExternalValueType() const { return m_aExternalValueType; } + + /** initializes the control from m_xField + + Basically, this method calls transferDbValueToControl - but only if our cursor is positioned + on a valid row. Otherwise, the control is reset. + + @precond + m_xField is not <NULL/> + */ + void initFromField( const css::uno::Reference< css::sdbc::XRowSet>& _rxForm ); + +private: + void connectToField( const css::uno::Reference< css::sdbc::XRowSet>& _rxForm ); + void resetField(); + + /** does a new validation of the control value + + If necessary, our <member>m_bIsCurrentValueValid</member> member will be adjusted, + and changes will be notified. + + Note that it's not necessary that we're connected to a validator. If we are not, + it's assumed that our value is valid, and this is handled appropriately. + + Use this method if there is a potential that <b>only</b> the validity flag changed. If + any of the other aspects (our current value, or our current text) changed, then + pass <TRUE/> for <member>_bForceNotification</member>. + + @param _bForceNotification + if <TRUE/>, then the validity listeners will be notified, not matter whether the validity + changed. + */ + void recheckValidity( bool _bForceNotification ); + + /// initializes m_pAggPropMultiplexer + void implInitAggMultiplexer( ); + + /// initializes listening at the value property + void implInitValuePropertyListening( ) const; + + /** adds or removes the component as load listener to/from our form, and (if necessary) as RowSetChange listener at + our parent. + + @precond there must no external value binding be in place + */ + void doFormListening( const bool _bStart ); + + bool isFormListening() const { return m_bFormListening; } + + /** determines the new value of m_xAmbientForm + */ + void impl_determineAmbientForm_nothrow(); + + /** connects to a value supplier which is a database column. + + The column is taken from our parent, which must be a database form respectively row set. + + @precond The control does not have an external value supplier + + @param _bFromReload + Determines whether the connection is made after the row set has been loaded (<FALSE/>) + or reloaded (<TRUE/>) + + @see impl_disconnectDatabaseColumn_noNotify + */ + void impl_connectDatabaseColumn_noNotify( + bool _bFromReload + ); + + /** disconnects from a value supplier which is a database column + + @precond The control does not have an external value supplier + @see impl_connectDatabaseColumn_noNotify + */ + void impl_disconnectDatabaseColumn_noNotify(); + + /** connects to an external value binding + + <p>Note that by definition, external data bindings supersede the SQL data binding which + is defined by our RowSet-column-related properties. This means that in case we're currently + connected to a database column when this is called, this connection is suspended.</p> + + @precond + the new external binding has already been approved (see <member>impl_approveValueBinding_nolock</member>) + @precond + there currently is no external binding in place + */ + void connectExternalValueBinding( + const css::uno::Reference< css::form::binding::XValueBinding >& _rxBinding, + ControlModelLock& _rInstanceLock + ); + + /** disconnects from an external value binding + + @precond + there currently is an external binding in place + */ + void disconnectExternalValueBinding( ); + + /** connects the component to an external validator + + @precond + there currently is no active validator + @precond + our mutex is currently locked exactly once + */ + void connectValidator( + const css::uno::Reference< css::form::validation::XValidator >& _rxValidator + ); + + /** disconnects the component from its current an external validator + + @precond + there currently is an active validator + @precond + our mutex is currently locked exactly once + */ + void disconnectValidator( ); + + /** called from within <member scope="css:::form::binding">XBindableValue::setValueBinding</member> + to approve the new binding + + The default implementation approves the binding if and only if it is not <NULL/>, and supports + the type returned by getExternalValueType. + + @param _rxBinding + the binding which applies for being responsible for our value, Must not be + <NULL/> + @return + <TRUE/> if and only if the given binding can supply values in the proper type + + @seealso getExternalValueType + */ + bool impl_approveValueBinding_nolock( + const css::uno::Reference< css::form::binding::XValueBinding >& _rxBinding + ); +}; + + + //= inlines + + inline void ControlModelLock::acquire() + { + m_rModel.lockInstance( OControlModel::LockAccess() ); + m_bLocked = true; + } + inline void ControlModelLock::release() + { + OSL_ENSURE( m_bLocked, "ControlModelLock::release: not locked!" ); + m_bLocked = false; + + if ( 0 == m_rModel.unlockInstance( OControlModel::LockAccess() ) ) + impl_notifyAll_nothrow(); + } + + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx new file mode 100644 index 000000000..66135a02e --- /dev/null +++ b/forms/source/inc/InterfaceContainer.hxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <comphelper/uno3.hxx> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/script/ScriptEventDescriptor.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <osl/mutex.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase8.hxx> +#include <unordered_map> + +namespace com::sun::star::uno { class XComponentContext; } + +using namespace comphelper; + + +namespace frm +{ + + + struct ElementDescription + { + public: + css::uno::Reference< css::uno::XInterface > xInterface; + css::uno::Reference< css::beans::XPropertySet > xPropertySet; + css::uno::Reference< css::container::XChild > xChild; + css::uno::Any aElementTypeInterface; + + public: + ElementDescription( ); + + private: + ElementDescription( const ElementDescription& ) = delete; + ElementDescription& operator=( const ElementDescription& ) = delete; + }; + +typedef std::vector<css::uno::Reference<css::uno::XInterface>> OInterfaceArray; +typedef std::unordered_multimap< OUString, css::uno::Reference<css::uno::XInterface> > OInterfaceMap; + + +// OInterfaceContainer +// implements a container for form components + +typedef ::cppu::ImplHelper8 < css::container::XNameContainer + , css::container::XIndexContainer + , css::container::XContainer + , css::container::XEnumerationAccess + , css::script::XEventAttacherManager + , css::beans::XPropertyChangeListener + , css::io::XPersistObject + , css::util::XCloneable + > OInterfaceContainer_BASE; + +class OInterfaceContainer : public OInterfaceContainer_BASE +{ +protected: + ::osl::Mutex& m_rMutex; + + OInterfaceArray m_aItems; + OInterfaceMap m_aMap; + ::comphelper::OInterfaceContainerHelper3<css::container::XContainerListener> m_aContainerListeners; + + const css::uno::Type m_aElementType; + + css::uno::Reference< css::uno::XComponentContext> m_xContext; + + + // EventManager + css::uno::Reference< css::script::XEventAttacherManager> m_xEventAttacher; + +public: + OInterfaceContainer( + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, + ::osl::Mutex& _rMutex, + const css::uno::Type& _rElementType); + + OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource ); + + // late constructor for cloning + /// @throws css::uno::RuntimeException + void clonedFrom(const OInterfaceContainer& _cloneSource); + +protected: + virtual ~OInterfaceContainer(); + +public: +// css::io::XPersistObject + virtual OUString SAL_CALL getServiceName( ) override = 0; + virtual void SAL_CALL write( const css::uno::Reference< css::io::XObjectOutputStream >& OutStream ) override; + virtual void SAL_CALL read( const css::uno::Reference< css::io::XObjectInputStream >& InStream ) override; + +// css::lang::XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override; + +// css::beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override; + +// css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override ; + virtual sal_Bool SAL_CALL hasElements() override; + +// css::container::XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration> SAL_CALL createEnumeration() override; + +// css::container::XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence<OUString> SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + +// css::container::XNameReplace + virtual void SAL_CALL replaceByName(const OUString& Name, const css::uno::Any& _rElement) override; + +// css::container::XNameContainer + virtual void SAL_CALL insertByName(const OUString& Name, const css::uno::Any& _rElement) override; + virtual void SAL_CALL removeByName(const OUString& Name) override; + +// css::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _nIndex) override; + +// css::container::XIndexReplace + virtual void SAL_CALL replaceByIndex(sal_Int32 _nIndex, const css::uno::Any& _rElement) override; + +// css::container::XIndexContainer + virtual void SAL_CALL insertByIndex(sal_Int32 _nIndex, const css::uno::Any& Element) override; + virtual void SAL_CALL removeByIndex(sal_Int32 _nIndex) override; + +// css::container::XContainer + virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener>& _rxListener) override; + virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener>& _rxListener) override; + +// css::script::XEventAttacherManager + virtual void SAL_CALL registerScriptEvent( sal_Int32 nIndex, const css::script::ScriptEventDescriptor& aScriptEvent ) override; + virtual void SAL_CALL registerScriptEvents( sal_Int32 nIndex, const css::uno::Sequence< css::script::ScriptEventDescriptor >& aScriptEvents ) override; + virtual void SAL_CALL revokeScriptEvent( sal_Int32 nIndex, const OUString& aListenerType, const OUString& aEventMethod, const OUString& aRemoveListenerParam ) override; + virtual void SAL_CALL revokeScriptEvents( sal_Int32 nIndex ) override; + virtual void SAL_CALL insertEntry( sal_Int32 nIndex ) override; + virtual void SAL_CALL removeEntry( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::script::ScriptEventDescriptor > SAL_CALL getScriptEvents( sal_Int32 Index ) override; + virtual void SAL_CALL attach( sal_Int32 nIndex, const css::uno::Reference< css::uno::XInterface >& xObject, const css::uno::Any& aHelper ) override; + virtual void SAL_CALL detach( sal_Int32 nIndex, const css::uno::Reference< css::uno::XInterface >& xObject ) override; + virtual void SAL_CALL addScriptListener( const css::uno::Reference< css::script::XScriptListener >& xListener ) override; + virtual void SAL_CALL removeScriptListener( const css::uno::Reference< css::script::XScriptListener >& Listener ) override; + +protected: + // helper + virtual void SAL_CALL disposing(); + void removeElementsNoEvents(); + + /** to be overridden if elements which are to be inserted into the container shall be checked + + <p>the ElementDescription given can be used to cache information about the object - it will be passed + later on to implInserted/implReplaced.</p> + */ + virtual void approveNewElement( + const css::uno::Reference< css::beans::XPropertySet >& _rxObject, + ElementDescription* _pElement + ); + + virtual ElementDescription* createElementMetaData( ); + + /** inserts an object into our internal structures + + @param _nIndex + the index at which position it should be inserted + @param _bEvents + if <TRUE/>, event knittings will be done + @param _pApprovalResult + must contain the result of an approveNewElement call. Can be <NULL/>, in this case, the approval + is done within implInsert. + @param _bFire + if <TRUE/>, a notification about the insertion will be fired + @throws css::lang::IllegalArgumentException + */ + void implInsert( + sal_Int32 _nIndex, + const css::uno::Reference< css::beans::XPropertySet >& _rxObject, + bool _bEvents /* = sal_True */, + ElementDescription* _pApprovalResult /* = NULL */ , + bool _bFire /* = sal_True */ + ); + + // called after the object is inserted, but before the "real listeners" are notified + virtual void implInserted( const ElementDescription* _pElement ); + // called after the object is removed, but before the "real listeners" are notified + virtual void implRemoved(const css::uno::Reference<css::uno::XInterface>& _rxObject); + + /** called after an object was replaced. The default implementation notifies our listeners, after releasing + the instance lock. + */ + virtual void impl_replacedElement( + const css::container::ContainerEvent& _rEvent, + ::osl::ClearableMutexGuard& _rInstanceLock + ); + + void SAL_CALL writeEvents(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream); + void SAL_CALL readEvents(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream); + + /** replace an element, specified by position + + @precond <arg>_nIndex</arg> is a valid index + @precond our mutex is locked exactly once, by the guard specified with <arg>_rClearBeforeNotify</arg> + + */ + void implReplaceByIndex( + const sal_Int32 _nIndex, + const css::uno::Any& _rNewElement, + ::osl::ClearableMutexGuard& _rClearBeforeNotify + ); + + /** removes an element, specified by position + + @precond <arg>_nIndex</arg> is a valid index + @precond our mutex is locked exactly once, by the guard specified with <arg>_rClearBeforeNotify</arg> + + */ + void implRemoveByIndex( + const sal_Int32 _nIndex, + ::osl::ClearableMutexGuard& _rClearBeforeNotify + ); + + /** validates the given index + @throws css::lang::IndexOutOfBoundsException + if the given index does not denote a valid position in our children array + */ + void implCheckIndex( const sal_Int32 _nIndex ); + +private: + // hack for Vba Events + void impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIndex ); + + void transformEvents(); + + void impl_createEventAttacher_nothrow(); +}; + +typedef ::cppu::ImplHelper1< css::form::XFormComponent> OFormComponents_BASE; +class OFormComponents :public ::cppu::OComponentHelper + ,public OInterfaceContainer + ,public OFormComponents_BASE +{ +protected: + ::osl::Mutex m_aMutex; + css::uno::Reference<css::uno::XInterface> m_xParent; + +public: + OFormComponents(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory); + OFormComponents( const OFormComponents& _cloneSource ); + virtual ~OFormComponents() override; + + DECLARE_UNO3_AGG_DEFAULTS(OFormComponents, ::cppu::OComponentHelper) + + virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::form::XFormComponent + virtual css::uno::Reference<css::uno::XInterface> SAL_CALL getParent() override; + virtual void SAL_CALL setParent(const css::uno::Reference<css::uno::XInterface>& Parent) override; + + // XEventListener + using OInterfaceContainer::disposing; +}; + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/cloneable.hxx b/forms/source/inc/cloneable.hxx new file mode 100644 index 000000000..e161ad8c0 --- /dev/null +++ b/forms/source/inc/cloneable.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/uno/XAggregation.hpp> + + +namespace frm +{ + + class OCloneableAggregation + { + protected: + css::uno::Reference< css::uno::XAggregation> m_xAggregate; + + protected: + static css::uno::Reference< css::uno::XAggregation > createAggregateClone( const OCloneableAggregation* _pOriginal ); + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/commandimageprovider.hxx b/forms/source/inc/commandimageprovider.hxx new file mode 100644 index 000000000..02742b5a9 --- /dev/null +++ b/forms/source/inc/commandimageprovider.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/XImageManager.hpp> + +#include <vcl/image.hxx> + +#include <memory> + + +namespace frm +{ + + class DocumentCommandImageProvider + { + public: + DocumentCommandImageProvider( const css::uno::Reference<css::uno::XComponentContext>& _rContext, const css::uno::Reference< css::frame::XModel >& _rxDocument ); + + std::vector<Image> getCommandImages( const css::uno::Sequence< OUString >& _rCommandURLs, bool _bLarge ) const; + + private: + css::uno::Reference< css::ui::XImageManager > m_xDocumentImageManager; + css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager; + }; + + + typedef std::shared_ptr< const DocumentCommandImageProvider > PCommandImageProvider; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/componenttools.hxx b/forms/source/inc/componenttools.hxx new file mode 100644 index 000000000..8c7fd8a8d --- /dev/null +++ b/forms/source/inc/componenttools.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/uno/Type.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/frame/XModel.hpp> + +#include <set> + + +namespace frm +{ + + + struct TypeCompareLess + { + bool operator()( const css::uno::Type& _rLHS, const css::uno::Type& _rRHS ) const + { + return _rLHS.getTypeName() < _rRHS.getTypeName(); + } + }; + + /** a helper class which merges sequences of <type scope="css::uno">Type</type>s, + so that the resulting sequence contains every type at most once + */ + class TypeBag + { + public: + typedef css::uno::Sequence< css::uno::Type > TypeSequence; + typedef ::std::set< css::uno::Type, TypeCompareLess > TypeSet; + + private: + TypeSet m_aTypes; + + public: + TypeBag( + const TypeSequence& _rTypes1 + ); + + TypeBag( + const TypeSequence& _rTypes1, + const TypeSequence& _rTypes2 + ); + TypeBag( + const TypeSequence& _rTypes1, + const TypeSequence& _rTypes2, + const TypeSequence& _rTypes3 + ); + + void addType( const css::uno::Type& i_rType ); + void addTypes( const TypeSequence& _rTypes ); + void removeType( const css::uno::Type& i_rType ); + + /** returns the types represented by this bag + */ + TypeSequence getTypes() const; + }; + + css::uno::Reference< css::frame::XModel > getXModel( + const css::uno::Reference< css::uno::XInterface >& _rxComponent ); + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/controlfeatureinterception.hxx b/forms/source/inc/controlfeatureinterception.hxx new file mode 100644 index 000000000..1e58ffb63 --- /dev/null +++ b/forms/source/inc/controlfeatureinterception.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> + +#include "urltransformer.hxx" + + +namespace frm +{ + + + class UrlTransformer; + + //= ControlFeatureInterception + + /** helper class for controls which allow some of their features to be intercepted + by external instances + + For using this class, instantiate it as member, derive yourself from + <type scope="css::frame">XDispatchProviderInterception</type>, and forward all + respective methods to this member. + + Additionally, don't forget to call <member>dispose</member> when your class is disposed itself. + */ + class ControlFeatureInterception + { + private: + css::uno::Reference< css::frame::XDispatchProviderInterceptor > + m_xFirstDispatchInterceptor; + ::std::unique_ptr< UrlTransformer > m_pUrlTransformer; + + public: + /** retrieves our URL transformer, so our clients may use it, too + */ + const UrlTransformer& getTransformer() const { return *m_pUrlTransformer; } + + public: + ControlFeatureInterception( const css::uno::Reference< css::uno::XComponentContext >& _rxORB ); + + // XDispatchProviderInterception + /// @throws css::uno::RuntimeException + void registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ); + /// @throws css::uno::RuntimeException + void releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ); + + // XComponent + void dispose(); + + /** queries the interceptor chain for the given dispatch, with a blank target frame and no frame search flags + */ + css::uno::Reference< css::frame::XDispatch > + queryDispatch( const css::util::URL& _rURL ); + + /** queries the interceptor chain for the URL given as ASCII string, + with a blank target frame and no frame search flags + */ + css::uno::Reference< css::frame::XDispatch > + queryDispatch( const char* _pAsciiURL ); + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/featuredispatcher.hxx b/forms/source/inc/featuredispatcher.hxx new file mode 100644 index 000000000..33f4610be --- /dev/null +++ b/forms/source/inc/featuredispatcher.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Any.hxx> + + +namespace frm +{ + + class IFeatureDispatcher + { + public: + /** dispatches a feature + + @param _nFeatureId + the id of the feature to dispatch + */ + virtual void dispatch( sal_Int16 _nFeatureId ) const = 0; + + /** dispatches a feature, with an additional named parameter + + @param _nFeatureId + the id of the feature to dispatch + + @param _pParamAsciiName + the Ascii name of the parameter of the dispatch call + + @param _rParamValue + the value of the parameter of the dispatch call + */ + virtual void dispatchWithArgument( + sal_Int16 _nFeatureId, + const char* _pParamName, + const css::uno::Any& _rParamValue + ) const = 0; + + /** checks whether a given feature is enabled + */ + virtual bool isEnabled( sal_Int16 _nFeatureId ) const = 0; + + /** returns the boolean state of a feature + + Certain features may support more status information than only the enabled/disabled + state. The type of such additional information is fixed relative to a given feature, but + may differ between different features. + + This method allows retrieving status information about features which have an additional + boolean information associated with it. + */ + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const = 0; + + /** returns the string state of a feature + + Certain features may support more status information than only the enabled/disabled + state. The type of such additional information is fixed relative to a given feature, but + may differ between different features. + + This method allows retrieving status information about features which have an additional + string information associated with it. + */ + virtual OUString getStringState( sal_Int16 _nFeatureId ) const = 0; + + /** returns the integer state of a feature + + Certain features may support more status information than only the enabled/disabled + state. The type of such additional information is fixed relative to a given feature, but + may differ between different features. + + This method allows retrieving status information about features which have an additional + integer information associated with it. + */ + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const = 0; + + protected: + ~IFeatureDispatcher() {} + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/formcontrolfont.hxx b/forms/source/inc/formcontrolfont.hxx new file mode 100644 index 000000000..2cb2a9201 --- /dev/null +++ b/forms/source/inc/formcontrolfont.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/beans/Property.hpp> +#include <tools/color.hxx> + +namespace cppu { + class OPropertySetHelper; +} + + +namespace frm +{ + + class FontControlModel + { + private: + // <properties> + css::awt::FontDescriptor m_aFont; + sal_Int16 m_nFontRelief; + sal_Int16 m_nFontEmphasis; + css::uno::Any m_aTextLineColor; + css::uno::Any m_aTextColor; + // </properties> + + bool m_bToolkitCompatibleDefaults; + + protected: + const css::awt::FontDescriptor& getFont() const { return m_aFont; } + void setFont( const css::awt::FontDescriptor& _rFont ) { m_aFont = _rFont; } + + void setTextColor( Color _nColor ) { m_aTextColor <<= _nColor; } + void clearTextColor( ) { m_aTextColor.clear(); } + bool hasTextColor( ) const { return m_aTextColor.hasValue(); } + Color getTextColor( ) const; + + void setTextLineColor( Color _nColor ) { m_aTextLineColor <<= _nColor; } + void clearTextLineColor( ) { m_aTextLineColor.clear(); } + bool hasTextLineColor( ) const { return m_aTextLineColor.hasValue(); } + Color getTextLineColor( ) const; + + protected: + FontControlModel( bool _bToolkitCompatibleDefaults ); + FontControlModel( const FontControlModel* _pOriginal ); + + protected: + static bool isFontRelatedProperty( sal_Int32 _nPropertyHandle ); + static bool isFontAggregateProperty( sal_Int32 _nPropertyHandle ); + + /// appends (!) the description of all font related properties to the given sequence + static void describeFontRelatedProperties( + css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps ); + + void getFastPropertyValue ( css::uno::Any& _rValue, sal_Int32 _nHandle ) const; + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + bool convertFastPropertyValue ( css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ); + /// @throws css::uno::Exception + void setFastPropertyValue_NoBroadcast_impl( + ::cppu::OPropertySetHelper & rBase, + void (::cppu::OPropertySetHelper::*pSet)( sal_Int32, css::uno::Any const&), + sal_Int32 nHandle, const css::uno::Any& rValue); + css::uno::Any + getPropertyDefaultByHandle ( sal_Int32 _nHandle ) const; + + private: + + private: + FontControlModel( const FontControlModel& ) = delete; + FontControlModel& operator=( const FontControlModel& ) = delete; + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/formnavigation.hxx b/forms/source/inc/formnavigation.hxx new file mode 100644 index 000000000..e18b99a1b --- /dev/null +++ b/forms/source/inc/formnavigation.hxx @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/implbase2.hxx> +#include "featuredispatcher.hxx" +#include <vector> +#include <map> +#include <memory> + + +namespace frm +{ + + + class UrlTransformer; + class ControlFeatureInterception; + + + //= OFormNavigationHelper + + typedef ::cppu::ImplHelper2 < css::frame::XDispatchProviderInterception + , css::frame::XStatusListener + > OFormNavigationHelper_Base; + + class OFormNavigationHelper + :public OFormNavigationHelper_Base + ,public IFeatureDispatcher + { + private: + struct FeatureInfo + { + css::util::URL aURL; + css::uno::Reference< css::frame::XDispatch > xDispatcher; + bool bCachedState; + css::uno::Any aCachedAdditionalState; + + FeatureInfo() : bCachedState( false ) { } + }; + typedef ::std::map< sal_Int16, FeatureInfo > FeatureMap; + + private: + css::uno::Reference< css::uno::XComponentContext > + m_xORB; + ::std::unique_ptr< ControlFeatureInterception > + m_pFeatureInterception; + + // all supported features + FeatureMap m_aSupportedFeatures; + // all features which we have an external dispatcher for + sal_Int32 m_nConnectedFeatures; + + protected: + OFormNavigationHelper( const css::uno::Reference< css::uno::XComponentContext >& _rxORB ); + virtual ~OFormNavigationHelper(); + + // XComponent + /// @throws css::uno::RuntimeException + void dispose( ); + + // XDispatchProviderInterception + virtual void SAL_CALL registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ) override; + virtual void SAL_CALL releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& State ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // IFeatureDispatcher + virtual void dispatch( sal_Int16 _nFeatureId ) const override; + virtual void dispatchWithArgument( sal_Int16 _nFeatureId, const char* _pParamName, const css::uno::Any& _rParamValue ) const override; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const override; + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const override; + virtual OUString getStringState( sal_Int16 _nFeatureId ) const override; + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const override; + + // own overridables + /** is called when the interceptors have. + <p>The default implementations simply calls <member>updateDispatches</member>, + derived classes can prevent this in certain cases, or do additional handling.</p> + */ + virtual void interceptorsChanged( ); + + /** called when the status of a feature changed + + <p>The default implementation does nothing.</p> + + <p>If the feature in question does support more state information that just the + enabled/disabled state, then this additional information is to be retrieved in + a separate call.</p> + + @param _nFeatureId + the id of the feature + @param _bEnabled + determines if the features is enabled or disabled + @see getBooleanState + */ + virtual void featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled ); + + /** notification for (potential) changes in the state of all features + <p>The base class implementation does nothing. Derived classes could force + their peer to update it's state, depending on the result of calls to + <member>IFeatureDispatcher::isEnabled</member>.</p> + */ + virtual void allFeatureStatesChanged( ); + + /** retrieves the list of supported features + <p>To be overridden by derived classes</p> + @param _rFeatureIds + the array of features to support. Out parameter to fill by the derivee's implementation + @pure + */ + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0; + + protected: + /** update all our dispatches which are controlled by our dispatch interceptors + */ + void updateDispatches(); + + /** connect to the dispatch interceptors + */ + void connectDispatchers(); + + /** disconnect from the dispatch interceptors + */ + void disconnectDispatchers(); + + /** queries the interceptor chain for a dispatcher for the given URL + */ + css::uno::Reference< css::frame::XDispatch > + queryDispatch( const css::util::URL& _rURL ); + + /** invalidates the set of supported features + + <p>This will invalidate all structures which are tied to the set of supported + features. All dispatches will be disconnected.<br/> + No automatic re-connection to potential external dispatchers is done, instead, + you have to call updateDispatches explicitly, if necessary.</p> + */ + void invalidateSupportedFeaturesSet(); + + private: + /** initialize m_aSupportedFeatures, if necessary + */ + void initializeSupportedFeatures(); + }; + + /** helper class mapping between feature ids and feature URLs + */ + class OFormNavigationMapper + { + private: + ::std::unique_ptr< UrlTransformer > m_pUrlTransformer; + + public: + OFormNavigationMapper( + const css::uno::Reference< css::uno::XComponentContext >& _rxORB + ); + ~OFormNavigationMapper( ); + + /** retrieves the ASCII representation of a feature URL belonging to an id + + @complexity O(log n) + @return NULL if the given id is not a known feature id (which is a valid usage) + */ + static const char* getFeatureURLAscii( sal_Int16 _nFeatureId ); + + /** retrieves the feature URL belonging to a feature id + + @complexity O(log n), with n being the number of all potentially known URLs + @return + <TRUE/> if and only if the given id is a known feature id + (which is a valid usage) + */ + bool getFeatureURL( sal_Int16 _nFeatureId, css::util::URL& /* [out] */ _rURL ); + + /** retrieves the feature id belonging to a feature URL + + @complexity O(n), with n being the number of all potentially known URLs + @return + the id of the feature URL, or -1 if the URl is not known + (which is a valid usage) + */ + static sal_Int16 getFeatureId( std::u16string_view _rCompleteURL ); + + private: + OFormNavigationMapper( const OFormNavigationMapper& ) = delete; + OFormNavigationMapper& operator=( const OFormNavigationMapper& ) = delete; + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/frm_resource.hxx b/forms/source/inc/frm_resource.hxx new file mode 100644 index 000000000..711018a15 --- /dev/null +++ b/forms/source/inc/frm_resource.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> + +namespace frm +{ + + // handling resources within the FormLayer library + namespace ResourceManager + { + /** loads the string with the specified resource id from the FormLayer mo file + */ + OUString loadString(TranslateId aResId); + }; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx new file mode 100644 index 000000000..35d9dab77 --- /dev/null +++ b/forms/source/inc/frm_strings.hxx @@ -0,0 +1,285 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ustring.hxx> + +//- properties + +inline constexpr OUStringLiteral PROPERTY_TABINDEX = u"TabIndex"; +inline constexpr OUStringLiteral PROPERTY_TAG = u"Tag"; +inline constexpr OUStringLiteral PROPERTY_NAME = u"Name"; +inline constexpr OUStringLiteral PROPERTY_GROUP_NAME = u"GroupName"; +inline constexpr OUStringLiteral PROPERTY_CLASSID = u"ClassId"; +inline constexpr OUStringLiteral PROPERTY_FETCHSIZE = u"FetchSize"; +inline constexpr OUStringLiteral PROPERTY_VALUE = u"Value"; +inline constexpr OUStringLiteral PROPERTY_TEXT = u"Text"; +inline constexpr OUStringLiteral PROPERTY_LABEL = u"Label"; +inline constexpr OUStringLiteral PROPERTY_NAVIGATION = u"NavigationBarMode"; +inline constexpr OUStringLiteral PROPERTY_HASNAVIGATION = u"HasNavigationBar"; +inline constexpr OUStringLiteral PROPERTY_CYCLE = u"Cycle"; +inline constexpr OUStringLiteral PROPERTY_CONTROLSOURCE = u"DataField"; +inline constexpr OUStringLiteral PROPERTY_ENABLED = u"Enabled"; +inline constexpr OUStringLiteral PROPERTY_ENABLEVISIBLE = u"EnableVisible"; +inline constexpr OUStringLiteral PROPERTY_READONLY = u"ReadOnly"; +inline constexpr OUStringLiteral PROPERTY_RELEVANT = u"Relevant"; +inline constexpr OUStringLiteral PROPERTY_ISREADONLY = u"IsReadOnly"; +inline constexpr OUStringLiteral PROPERTY_FILTER = u"Filter"; +inline constexpr OUStringLiteral PROPERTY_HAVINGCLAUSE = u"HavingClause"; +inline constexpr OUStringLiteral PROPERTY_WIDTH = u"Width"; +inline constexpr OUStringLiteral PROPERTY_SEARCHABLE = u"IsSearchable"; +inline constexpr OUStringLiteral PROPERTY_MULTILINE = u"MultiLine"; +inline constexpr OUStringLiteral PROPERTY_TARGET_URL = u"TargetURL"; +inline constexpr OUStringLiteral PROPERTY_TARGET_FRAME = u"TargetFrame"; +inline constexpr OUStringLiteral PROPERTY_DEFAULTCONTROL = u"DefaultControl"; +inline constexpr OUStringLiteral PROPERTY_MAXTEXTLEN = u"MaxTextLen"; +inline constexpr OUStringLiteral PROPERTY_EDITMASK = u"EditMask"; +inline constexpr OUStringLiteral PROPERTY_SIZE = u"Size"; +inline constexpr OUStringLiteral PROPERTY_SPIN = u"Spin"; +inline constexpr OUStringLiteral PROPERTY_DATE = u"Date"; +inline constexpr OUStringLiteral PROPERTY_TIME = u"Time"; +inline constexpr OUStringLiteral PROPERTY_STATE = u"State"; +inline constexpr OUStringLiteral PROPERTY_TRISTATE = u"TriState"; +inline constexpr OUStringLiteral PROPERTY_HIDDEN_VALUE = u"HiddenValue"; +inline constexpr OUStringLiteral PROPERTY_BUTTONTYPE = u"ButtonType"; +inline constexpr OUStringLiteral PROPERTY_STRINGITEMLIST = u"StringItemList"; +inline constexpr OUStringLiteral PROPERTY_TYPEDITEMLIST = u"TypedItemList"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_TEXT = u"DefaultText"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_STATE = u"DefaultState"; +inline constexpr OUStringLiteral PROPERTY_FORMATKEY = u"FormatKey"; +inline constexpr OUStringLiteral PROPERTY_FORMATSSUPPLIER = u"FormatsSupplier"; +inline constexpr OUStringLiteral PROPERTY_SUBMIT_ACTION = u"SubmitAction"; +inline constexpr OUStringLiteral PROPERTY_SUBMIT_TARGET = u"SubmitTarget"; +inline constexpr OUStringLiteral PROPERTY_SUBMIT_METHOD = u"SubmitMethod"; +inline constexpr OUStringLiteral PROPERTY_SUBMIT_ENCODING = u"SubmitEncoding"; +inline constexpr OUStringLiteral PROPERTY_IMAGE_URL = u"ImageURL"; +inline constexpr OUStringLiteral PROPERTY_GRAPHIC = u"Graphic"; +inline constexpr OUStringLiteral PROPERTY_IMAGE_POSITION = u"ImagePosition"; +inline constexpr OUStringLiteral PROPERTY_EMPTY_IS_NULL = u"ConvertEmptyToNull"; +inline constexpr OUStringLiteral PROPERTY_LISTSOURCETYPE = u"ListSourceType"; +inline constexpr OUStringLiteral PROPERTY_LISTSOURCE = u"ListSource"; +inline constexpr OUStringLiteral PROPERTY_SELECT_SEQ = u"SelectedItems"; +inline constexpr OUStringLiteral PROPERTY_VALUE_SEQ = u"ValueItemList"; +inline constexpr OUStringLiteral PROPERTY_SELECT_VALUE_SEQ = u"SelectedValues"; +inline constexpr OUStringLiteral PROPERTY_SELECT_VALUE = u"SelectedValue"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_SELECT_SEQ = u"DefaultSelection"; +inline constexpr OUStringLiteral PROPERTY_MULTISELECTION = u"MultiSelection"; +inline constexpr OUStringLiteral PROPERTY_ALIGN = u"Align"; +inline constexpr OUStringLiteral PROPERTY_VERTICAL_ALIGN = u"VerticalAlign"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_DATE = u"DefaultDate"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_TIME = u"DefaultTime"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_VALUE = u"DefaultValue"; +inline constexpr OUStringLiteral PROPERTY_DECIMAL_ACCURACY = u"DecimalAccuracy"; +inline constexpr OUStringLiteral PROPERTY_FIELDTYPE = u"Type"; +inline constexpr OUStringLiteral PROPERTY_DECIMALS = u"Decimals"; +inline constexpr OUStringLiteral PROPERTY_REFVALUE = u"RefValue"; +inline constexpr OUStringLiteral PROPERTY_UNCHECKED_REFVALUE = u"SecondaryRefValue"; +inline constexpr OUStringLiteral PROPERTY_VALUEMIN = u"ValueMin"; +inline constexpr OUStringLiteral PROPERTY_VALUEMAX = u"ValueMax"; +inline constexpr OUStringLiteral PROPERTY_STRICTFORMAT = u"StrictFormat"; +inline constexpr OUStringLiteral PROPERTY_ALLOWADDITIONS = u"AllowInserts"; +inline constexpr OUStringLiteral PROPERTY_ALLOWEDITS = u"AllowUpdates"; +inline constexpr OUStringLiteral PROPERTY_ALLOWDELETIONS = u"AllowDeletes"; +inline constexpr OUStringLiteral PROPERTY_MASTERFIELDS = u"MasterFields"; +inline constexpr OUStringLiteral PROPERTY_ISPASSTHROUGH = u"IsPassThrough"; +inline constexpr OUStringLiteral PROPERTY_QUERY = u"Query"; +inline constexpr OUStringLiteral PROPERTY_LITERALMASK = u"LiteralMask"; +inline constexpr OUStringLiteral PROPERTY_VALUESTEP = u"ValueStep"; +inline constexpr OUStringLiteral PROPERTY_SHOWTHOUSANDSEP = u"ShowThousandsSeparator"; +inline constexpr OUStringLiteral PROPERTY_CURRENCYSYMBOL = u"CurrencySymbol"; +inline constexpr OUStringLiteral PROPERTY_DATEFORMAT = u"DateFormat"; +inline constexpr OUStringLiteral PROPERTY_DATEMIN = u"DateMin"; +inline constexpr OUStringLiteral PROPERTY_DATEMAX = u"DateMax"; +inline constexpr OUStringLiteral PROPERTY_DATE_SHOW_CENTURY = u"DateShowCentury"; +inline constexpr OUStringLiteral PROPERTY_TIMEFORMAT = u"TimeFormat"; +inline constexpr OUStringLiteral PROPERTY_TIMEMIN = u"TimeMin"; +inline constexpr OUStringLiteral PROPERTY_TIMEMAX = u"TimeMax"; +inline constexpr OUStringLiteral PROPERTY_LINECOUNT = u"LineCount"; +inline constexpr OUStringLiteral PROPERTY_BOUNDCOLUMN = u"BoundColumn"; +inline constexpr OUStringLiteral PROPERTY_FONT = u"FontDescriptor"; +inline constexpr OUStringLiteral PROPERTY_FILLCOLOR = u"FillColor"; +inline constexpr OUStringLiteral PROPERTY_LINECOLOR = u"LineColor"; +inline constexpr OUStringLiteral PROPERTY_DROPDOWN = u"Dropdown"; +inline constexpr OUStringLiteral PROPERTY_HSCROLL = u"HScroll"; +inline constexpr OUStringLiteral PROPERTY_VSCROLL = u"VScroll"; +inline constexpr OUStringLiteral PROPERTY_TABSTOP = u"Tabstop"; +inline constexpr OUStringLiteral PROPERTY_AUTOCOMPLETE = u"Autocomplete"; +inline constexpr OUStringLiteral PROPERTY_HARDLINEBREAKS = u"HardLineBreaks"; +inline constexpr OUStringLiteral PROPERTY_PRINTABLE = u"Printable"; +inline constexpr OUStringLiteral PROPERTY_ECHO_CHAR = u"EchoChar"; +inline constexpr OUStringLiteral PROPERTY_ROWHEIGHT = u"RowHeight"; +inline constexpr OUStringLiteral PROPERTY_HELPTEXT = u"HelpText"; +inline constexpr OUStringLiteral PROPERTY_FONT_NAME = u"FontName"; +inline constexpr OUStringLiteral PROPERTY_FONT_STYLENAME = u"FontStyleName"; +inline constexpr OUStringLiteral PROPERTY_FONT_FAMILY = u"FontFamily"; +inline constexpr OUStringLiteral PROPERTY_FONT_CHARSET = u"FontCharset"; +inline constexpr OUStringLiteral PROPERTY_FONT_HEIGHT = u"FontHeight"; +inline constexpr OUStringLiteral PROPERTY_FONT_WEIGHT = u"FontWeight"; +inline constexpr OUStringLiteral PROPERTY_FONT_SLANT = u"FontSlant"; +inline constexpr OUStringLiteral PROPERTY_FONT_UNDERLINE = u"FontUnderline"; +inline constexpr OUStringLiteral PROPERTY_FONT_WORDLINEMODE = u"FontWordLineMode"; +inline constexpr OUStringLiteral PROPERTY_FONT_STRIKEOUT = u"FontStrikeout"; +inline constexpr OUStringLiteral PROPERTY_FONTEMPHASISMARK = u"FontEmphasisMark"; +inline constexpr OUStringLiteral PROPERTY_FONTRELIEF = u"FontRelief"; +inline constexpr OUStringLiteral PROPERTY_FONT_CHARWIDTH = u"FontCharWidth"; +inline constexpr OUStringLiteral PROPERTY_FONT_KERNING = u"FontKerning"; +inline constexpr OUStringLiteral PROPERTY_FONT_ORIENTATION = u"FontOrientation"; +inline constexpr OUStringLiteral PROPERTY_FONT_PITCH = u"FontPitch"; +inline constexpr OUStringLiteral PROPERTY_FONT_TYPE = u"FontType"; +inline constexpr OUStringLiteral PROPERTY_FONT_WIDTH = u"FontWidth"; +inline constexpr OUStringLiteral PROPERTY_HELPURL = u"HelpURL"; +inline constexpr OUStringLiteral PROPERTY_RECORDMARKER = u"HasRecordMarker"; +inline constexpr OUStringLiteral PROPERTY_BOUNDFIELD = u"BoundField"; +inline constexpr OUStringLiteral PROPERTY_INPUT_REQUIRED = u"InputRequired"; +inline constexpr OUStringLiteral PROPERTY_TREATASNUMERIC = u"TreatAsNumber"; +inline constexpr OUStringLiteral PROPERTY_EFFECTIVE_VALUE = u"EffectiveValue"; +inline constexpr OUStringLiteral PROPERTY_EFFECTIVE_DEFAULT = u"EffectiveDefault"; +inline constexpr OUStringLiteral PROPERTY_EFFECTIVE_MIN = u"EffectiveMin"; +inline constexpr OUStringLiteral PROPERTY_EFFECTIVE_MAX = u"EffectiveMax"; +inline constexpr OUStringLiteral PROPERTY_HIDDEN = u"Hidden"; +inline constexpr OUStringLiteral PROPERTY_FILTERPROPOSAL = u"UseFilterValueProposal"; +inline constexpr OUStringLiteral PROPERTY_FIELDSOURCE = u"FieldSource"; +inline constexpr OUStringLiteral PROPERTY_TABLENAME = u"TableName"; +inline constexpr OUStringLiteral PROPERTY_CONTROLLABEL = u"LabelControl"; +inline constexpr OUStringLiteral PROPERTY_CURRSYM_POSITION = u"PrependCurrencySymbol"; +inline constexpr OUStringLiteral PROPERTY_CURSORCOLOR = u"CursorColor"; +inline constexpr OUStringLiteral PROPERTY_ALWAYSSHOWCURSOR = u"AlwaysShowCursor"; +inline constexpr OUStringLiteral PROPERTY_DISPLAYSYNCHRON = u"DisplayIsSynchron"; +inline constexpr OUStringLiteral PROPERTY_TEXTCOLOR = u"TextColor"; +inline constexpr OUStringLiteral PROPERTY_DELAY = u"RepeatDelay"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_SCROLL_VALUE = u"DefaultScrollValue"; +inline constexpr OUStringLiteral PROPERTY_SCROLL_VALUE = u"ScrollValue"; +inline constexpr OUStringLiteral PROPERTY_DEFAULT_SPIN_VALUE = u"DefaultSpinValue"; +inline constexpr OUStringLiteral PROPERTY_SPIN_VALUE = u"SpinValue"; +inline constexpr OUStringLiteral PROPERTY_REFERENCE_DEVICE = u"ReferenceDevice"; +inline constexpr OUStringLiteral PROPERTY_ISMODIFIED = u"IsModified"; +inline constexpr OUStringLiteral PROPERTY_ISNEW = u"IsNew"; +inline constexpr OUStringLiteral PROPERTY_PRIVILEGES = u"Privileges"; +inline constexpr OUStringLiteral PROPERTY_COMMAND = u"Command"; +inline constexpr OUStringLiteral PROPERTY_COMMANDTYPE = u"CommandType"; +inline constexpr OUStringLiteral PROPERTY_RESULTSET_CONCURRENCY = u"ResultSetConcurrency"; +inline constexpr OUStringLiteral PROPERTY_INSERTONLY = u"IgnoreResult"; +inline constexpr OUStringLiteral PROPERTY_RESULTSET_TYPE = u"ResultSetType"; +inline constexpr OUStringLiteral PROPERTY_ESCAPE_PROCESSING = u"EscapeProcessing"; +inline constexpr OUStringLiteral PROPERTY_APPLYFILTER = u"ApplyFilter"; +inline constexpr OUStringLiteral PROPERTY_ROWCOUNT = u"RowCount"; +inline constexpr OUStringLiteral PROPERTY_ROWCOUNTFINAL = u"IsRowCountFinal"; + +inline constexpr OUStringLiteral PROPERTY_ISNULLABLE = u"IsNullable"; +inline constexpr OUStringLiteral PROPERTY_ACTIVECOMMAND = u"ActiveCommand"; +inline constexpr OUStringLiteral PROPERTY_ISCURRENCY = u"IsCurrency"; +inline constexpr OUStringLiteral PROPERTY_URL = u"URL"; +inline constexpr OUStringLiteral PROPERTY_TITLE = u"Title"; +inline constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION = u"ActiveConnection"; +inline constexpr OUStringLiteral PROPERTY_SCALE = u"Scale"; +inline constexpr OUStringLiteral PROPERTY_SORT = u"Order"; +inline constexpr OUStringLiteral PROPERTY_DATASOURCE = u"DataSourceName"; +inline constexpr OUStringLiteral PROPERTY_DETAILFIELDS = u"DetailFields"; + +inline constexpr OUStringLiteral PROPERTY_COLUMNSERVICENAME = u"ColumnServiceName"; +inline constexpr OUStringLiteral PROPERTY_REALNAME = u"RealName"; +inline constexpr OUStringLiteral PROPERTY_CONTROLSOURCEPROPERTY = u"DataFieldProperty"; +inline constexpr OUStringLiteral PROPERTY_USER = u"User"; +inline constexpr OUStringLiteral PROPERTY_PASSWORD = u"Password"; +inline constexpr OUStringLiteral PROPERTY_DISPATCHURLINTERNAL = u"DispatchURLInternal"; +inline constexpr OUStringLiteral PROPERTY_PERSISTENCE_MAXTEXTLENGTH = u"PersistenceMaxTextLength"; +inline constexpr OUStringLiteral PROPERTY_RICH_TEXT = u"RichText"; +inline constexpr OUStringLiteral PROPERTY_ENFORCE_FORMAT = u"EnforceFormat"; +inline constexpr OUStringLiteral PROPERTY_LINEEND_FORMAT = u"LineEndFormat"; +inline constexpr OUStringLiteral PROPERTY_WRITING_MODE = u"WritingMode"; +inline constexpr OUStringLiteral PROPERTY_CONTEXT_WRITING_MODE = u"ContextWritingMode"; + +inline constexpr OUStringLiteral PROPERTY_NATIVE_LOOK = u"NativeWidgetLook"; +inline constexpr OUStringLiteral PROPERTY_BORDER = u"Border"; +inline constexpr OUStringLiteral PROPERTY_BORDERCOLOR = u"BorderColor"; +inline constexpr OUStringLiteral PROPERTY_BACKGROUNDCOLOR = u"BackgroundColor"; +inline constexpr OUStringLiteral PROPERTY_ICONSIZE = u"IconSize"; +inline constexpr OUStringLiteral PROPERTY_TEXTLINECOLOR = u"TextLineColor"; +inline constexpr OUStringLiteral PROPERTY_HIDEINACTIVESELECTION = u"HideInactiveSelection"; + +inline constexpr OUStringLiteral PROPERTY_SHOW_POSITION = u"ShowPosition"; +inline constexpr OUStringLiteral PROPERTY_SHOW_NAVIGATION = u"ShowNavigation"; +inline constexpr OUStringLiteral PROPERTY_SHOW_RECORDACTIONS = u"ShowRecordActions"; +inline constexpr OUStringLiteral PROPERTY_SHOW_FILTERSORT = u"ShowFilterSort"; + +inline constexpr OUStringLiteral PROPERTY_XSD_WHITESPACE = u"WhiteSpace"; +inline constexpr OUStringLiteral PROPERTY_XSD_PATTERN = u"Pattern"; +inline constexpr OUStringLiteral PROPERTY_XSD_LENGTH = u"Length"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_LENGTH = u"MinLength"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_LENGTH = u"MaxLength"; +inline constexpr OUStringLiteral PROPERTY_XSD_TOTAL_DIGITS = u"TotalDigits"; +inline constexpr OUStringLiteral PROPERTY_XSD_FRACTION_DIGITS = u"FractionDigits"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_INCLUSIVE_INT = u"MaxInclusiveInt"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_EXCLUSIVE_INT = u"MaxExclusiveInt"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_INCLUSIVE_INT = u"MinInclusiveInt"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_EXCLUSIVE_INT = u"MinExclusiveInt"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE = u"MaxInclusiveDouble"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE = u"MaxExclusiveDouble"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE = u"MinInclusiveDouble"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE = u"MinExclusiveDouble"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_INCLUSIVE_DATE = u"MaxInclusiveDate"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_EXCLUSIVE_DATE = u"MaxExclusiveDate"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_INCLUSIVE_DATE = u"MinInclusiveDate"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_EXCLUSIVE_DATE = u"MinExclusiveDate"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_INCLUSIVE_TIME = u"MaxInclusiveTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_EXCLUSIVE_TIME = u"MaxExclusiveTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_INCLUSIVE_TIME = u"MinInclusiveTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_EXCLUSIVE_TIME = u"MinExclusiveTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME = u"MaxInclusiveDateTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME = u"MaxExclusiveDateTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME = u"MinInclusiveDateTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME = u"MinExclusiveDateTime"; +inline constexpr OUStringLiteral PROPERTY_XSD_IS_BASIC = u"IsBasic"; +inline constexpr OUStringLiteral PROPERTY_XSD_TYPE_CLASS = u"TypeClass"; + +inline constexpr OUStringLiteral PROPERTY_DYNAMIC_CONTROL_BORDER = u"DynamicControlBorder"; +inline constexpr OUStringLiteral PROPERTY_CONTROL_BORDER_COLOR_FOCUS = u"ControlBorderColorOnFocus"; +inline constexpr OUStringLiteral PROPERTY_CONTROL_BORDER_COLOR_MOUSE = u"ControlBorderColorOnHover"; +inline constexpr OUStringLiteral PROPERTY_CONTROL_BORDER_COLOR_INVALID = u"ControlBorderColorOnInvalid"; +inline constexpr OUStringLiteral PROPERTY_GENERATEVBAEVENTS = u"GenerateVbaEvents"; +inline constexpr OUStringLiteral PROPERTY_CONTROL_TYPE_IN_MSO = u"ControlTypeinMSO"; +inline constexpr OUStringLiteral PROPERTY_OBJ_ID_IN_MSO = u"ObjIDinMSO"; + + +//- URLs + +#define URL_FORM_POSITION ".uno:FormController/positionForm" +#define URL_FORM_RECORDCOUNT ".uno:FormController/RecordCount" +#define URL_RECORD_FIRST ".uno:FormController/moveToFirst" +#define URL_RECORD_PREV ".uno:FormController/moveToPrev" +#define URL_RECORD_NEXT ".uno:FormController/moveToNext" +#define URL_RECORD_LAST ".uno:FormController/moveToLast" +#define URL_RECORD_SAVE ".uno:FormController/saveRecord" +#define URL_RECORD_UNDO ".uno:FormController/undoRecord" +#define URL_RECORD_NEW ".uno:FormController/moveToNew" +#define URL_RECORD_DELETE ".uno:FormController/deleteRecord" +#define URL_FORM_REFRESH ".uno:FormController/refreshForm" +#define URL_FORM_REFRESH_CURRENT_CONTROL ".uno:FormController/refreshCurrentControl" + +#define URL_FORM_SORT_UP ".uno:FormController/sortUp" +#define URL_FORM_SORT_DOWN ".uno:FormController/sortDown" +#define URL_FORM_SORT ".uno:FormController/sort" +#define URL_FORM_AUTO_FILTER ".uno:FormController/autoFilter" +#define URL_FORM_FILTER ".uno:FormController/filter" +#define URL_FORM_APPLY_FILTER ".uno:FormController/applyFilter" +#define URL_FORM_REMOVE_FILTER ".uno:FormController/removeFilterOrder" + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/limitedformats.hxx b/forms/source/inc/limitedformats.hxx new file mode 100644 index 000000000..a176df06f --- /dev/null +++ b/forms/source/inc/limitedformats.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <osl/mutex.hxx> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> + + +namespace frm +{ + + + //= OLimitedFormats + + /** maintains translation tables format key <-> enum value + <p>Used for controls which provide a limited number for (standard) formats, which + should be available as format keys.</p> + */ + class OLimitedFormats + { + private: + static sal_Int32 s_nInstanceCount; + static ::osl::Mutex s_aMutex; + static css::uno::Reference< css::util::XNumberFormatsSupplier > + s_xStandardFormats; + + protected: + sal_Int32 m_nFormatEnumPropertyHandle; + const sal_Int16 m_nTableId; + css::uno::Reference< css::beans::XFastPropertySet > + m_xAggregate; + + protected: + /** ctor + <p>The class id is used to determine the translation table to use. All instances which + pass the same value here share one table.</p> + */ + OLimitedFormats( + const css::uno::Reference< css::uno::XComponentContext >& _rxContext, + const sal_Int16 _nClassId + ); + ~OLimitedFormats(); + + protected: + void setAggregateSet( + const css::uno::Reference< css::beans::XFastPropertySet >& _rxAggregate, + sal_Int32 _nOriginalPropertyHandle + ); + + protected: + void getFormatKeyPropertyValue( css::uno::Any& _rValue ) const; + bool convertFormatKeyPropertyValue( + css::uno::Any& _rConvertedValue, + css::uno::Any& _rOldValue, + const css::uno::Any& _rNewValue + ); + void setFormatKeyPropertyValue( const css::uno::Any& _rNewValue ); + // setFormatKeyPropertyValue should only be called with a value got from convertFormatKeyPropertyValue! + + const css::uno::Reference< css::util::XNumberFormatsSupplier >& + getFormatsSupplier() const { return s_xStandardFormats; } + + private: + void acquireSupplier(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); + void releaseSupplier(); + + static void ensureTableInitialized(const sal_Int16 _nTableId); + static void clearTable(const sal_Int16 _nTableId); + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/property.hxx b/forms/source/inc/property.hxx new file mode 100644 index 000000000..e6879950a --- /dev/null +++ b/forms/source/inc/property.hxx @@ -0,0 +1,340 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sal/config.h> + +#include <unordered_map> + +#include <comphelper/propagg.hxx> + +#include "frm_strings.hxx" + +using namespace comphelper; + +//= property helper classes + +namespace frm +{ + +// PropertyId's, who have a mapping to a PropertyName +#define PROPERTY_ID_START 0 + +#define PROPERTY_ID_NAME (PROPERTY_ID_START + 1) +#define PROPERTY_ID_TABINDEX (PROPERTY_ID_START + 2) +#define PROPERTY_ID_CONTROLSOURCE (PROPERTY_ID_START + 3) +#define PROPERTY_ID_MASTERFIELDS (PROPERTY_ID_START + 4) +#define PROPERTY_ID_DATASOURCE (PROPERTY_ID_START + 6) +#define PROPERTY_ID_CLASSID (PROPERTY_ID_START + 9) +#define PROPERTY_ID_CURSORTYPE (PROPERTY_ID_START + 10) +#define PROPERTY_ID_READONLY (PROPERTY_ID_START + 11) +#define PROPERTY_ID_NAVIGATION (PROPERTY_ID_START + 13) +#define PROPERTY_ID_CYCLE (PROPERTY_ID_START + 14) +#define PROPERTY_ID_ALLOWADDITIONS (PROPERTY_ID_START + 15) +#define PROPERTY_ID_ALLOWEDITS (PROPERTY_ID_START + 16) +#define PROPERTY_ID_ALLOWDELETIONS (PROPERTY_ID_START + 17) +#define PROPERTY_ID_NATIVE_LOOK (PROPERTY_ID_START + 18) +#define PROPERTY_ID_INPUT_REQUIRED (PROPERTY_ID_START + 19) +#define PROPERTY_ID_WRITING_MODE (PROPERTY_ID_START + 20) +#define PROPERTY_ID_CONTEXT_WRITING_MODE (PROPERTY_ID_START + 21) +#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) +#define PROPERTY_ID_GRAPHIC (PROPERTY_ID_START + 23) +#define PROPERTY_ID_GROUP_NAME (PROPERTY_ID_START + 24) + // free + // free + // free + // free + // free + // free +#define PROPERTY_ID_VALUE (PROPERTY_ID_START + 31) // INT32 + // free +#define PROPERTY_ID_FORMATKEY (PROPERTY_ID_START + 33) // UINT32 + // free + // free + // free +#define PROPERTY_ID_SIZE (PROPERTY_ID_START + 37) // UINT32 +#define PROPERTY_ID_REFERENCE_DEVICE (PROPERTY_ID_START + 38) // XDevice + // free + // free + // free +#define PROPERTY_ID_WIDTH (PROPERTY_ID_START + 42) // UINT16 +#define PROPERTY_ID_DEFAULTCONTROL (PROPERTY_ID_START + 43) // string +#define PROPERTY_ID_BOUNDCOLUMN (PROPERTY_ID_START + 44) // UINT16 may be null +#define PROPERTY_ID_LISTSOURCETYPE (PROPERTY_ID_START + 45) // UINT16 +#define PROPERTY_ID_LISTSOURCE (PROPERTY_ID_START + 46) // string + // FREE +#define PROPERTY_ID_TEXT (PROPERTY_ID_START + 48) // string +#define PROPERTY_ID_STRINGITEMLIST (PROPERTY_ID_START + 49) // wsstringsequence +#define PROPERTY_ID_LABEL (PROPERTY_ID_START + 50) // string +#define PROPERTY_ID_HIDEINACTIVESELECTION (PROPERTY_ID_START + 51) // sal_Bool +#define PROPERTY_ID_STATE (PROPERTY_ID_START + 52) // UINT16 +#define PROPERTY_ID_DELAY (PROPERTY_ID_START + 53) // sal_Int32 +#define PROPERTY_ID_FONT (PROPERTY_ID_START + 54) // font +#define PROPERTY_ID_HASNAVIGATION (PROPERTY_ID_START + 55) +#define PROPERTY_ID_BORDERCOLOR (PROPERTY_ID_START + 56) // sal_Int32 +#define PROPERTY_ID_ROWHEIGHT (PROPERTY_ID_START + 57) // UINT16 +#define PROPERTY_ID_BACKGROUNDCOLOR (PROPERTY_ID_START + 58) // sal_Int32 +#define PROPERTY_ID_FILLCOLOR (PROPERTY_ID_START + 59) // UINT32 +#define PROPERTY_ID_TEXTCOLOR (PROPERTY_ID_START + 60) // UINT32 +#define PROPERTY_ID_LINECOLOR (PROPERTY_ID_START + 61) // UINT32 +#define PROPERTY_ID_BORDER (PROPERTY_ID_START + 62) // UINT16 +#define PROPERTY_ID_ALIGN (PROPERTY_ID_START + 63) // UINT16 +#define PROPERTY_ID_DROPDOWN (PROPERTY_ID_START + 64) // BOOL +#define PROPERTY_ID_UNCHECKED_REFVALUE (PROPERTY_ID_START + 65) // OUString +#define PROPERTY_ID_HSCROLL (PROPERTY_ID_START + 66) // BOOL +#define PROPERTY_ID_VSCROLL (PROPERTY_ID_START + 67) // BOOL +#define PROPERTY_ID_TABSTOP (PROPERTY_ID_START + 68) // BOOL +#define PROPERTY_ID_REFVALUE (PROPERTY_ID_START + 69) // OUString +#define PROPERTY_ID_BUTTONTYPE (PROPERTY_ID_START + 70) // UINT16 +#define PROPERTY_ID_DEFAULT_TEXT (PROPERTY_ID_START + 71) // OUString +#define PROPERTY_ID_SUBMIT_ACTION (PROPERTY_ID_START + 72) // string +#define PROPERTY_ID_SUBMIT_METHOD (PROPERTY_ID_START + 73) // FmSubmitMethod +#define PROPERTY_ID_SUBMIT_ENCODING (PROPERTY_ID_START + 74) // FmSubmitEncoding +#define PROPERTY_ID_DEFAULT_VALUE (PROPERTY_ID_START + 75) // OUString +#define PROPERTY_ID_SUBMIT_TARGET (PROPERTY_ID_START + 76) // OUString +#define PROPERTY_ID_DEFAULT_STATE (PROPERTY_ID_START + 77) // UINT16 +#define PROPERTY_ID_VALUE_SEQ (PROPERTY_ID_START + 78) // StringSeq +#define PROPERTY_ID_IMAGE_URL (PROPERTY_ID_START + 79) // OUString +#define PROPERTY_ID_SELECT_VALUE (PROPERTY_ID_START + 80) // StringSeq +#define PROPERTY_ID_SELECT_VALUE_SEQ (PROPERTY_ID_START + 81) // StringSeq + // free + // free + // free + // free + // free + // free + // free + // free + // free +#define PROPERTY_ID_SELECT_SEQ (PROPERTY_ID_START + 91) // INT16Seq +#define PROPERTY_ID_DEFAULT_SELECT_SEQ (PROPERTY_ID_START + 92) // INT16Seq +#define PROPERTY_ID_MULTISELECTION (PROPERTY_ID_START + 93) // BOOL +#define PROPERTY_ID_MULTILINE (PROPERTY_ID_START + 94) // BOOL +#define PROPERTY_ID_DATE (PROPERTY_ID_START + 95) // UINT32 +#define PROPERTY_ID_DATEMIN (PROPERTY_ID_START + 96) // UINT32 +#define PROPERTY_ID_DATEMAX (PROPERTY_ID_START + 97) // UINT32 +#define PROPERTY_ID_DATEFORMAT (PROPERTY_ID_START + 98) // UINT16 +#define PROPERTY_ID_TIME (PROPERTY_ID_START + 99) // UINT32 +#define PROPERTY_ID_TIMEMIN (PROPERTY_ID_START +100) // UINT32 +#define PROPERTY_ID_TIMEMAX (PROPERTY_ID_START +101) // UINT32 +#define PROPERTY_ID_TIMEFORMAT (PROPERTY_ID_START +102) // UINT16 +#define PROPERTY_ID_VALUEMIN (PROPERTY_ID_START +103) // INT32 +#define PROPERTY_ID_VALUEMAX (PROPERTY_ID_START +104) // INT32 +#define PROPERTY_ID_VALUESTEP (PROPERTY_ID_START +105) // INT32 +#define PROPERTY_ID_CURRENCYSYMBOL (PROPERTY_ID_START +106) // OUString +#define PROPERTY_ID_EDITMASK (PROPERTY_ID_START +107) // OUString +#define PROPERTY_ID_LITERALMASK (PROPERTY_ID_START +108) // OUString +#define PROPERTY_ID_ENABLED (PROPERTY_ID_START +109) // BOOL +#define PROPERTY_ID_AUTOCOMPLETE (PROPERTY_ID_START +110) // BOOL +#define PROPERTY_ID_LINECOUNT (PROPERTY_ID_START +111) // UINT16 +#define PROPERTY_ID_MAXTEXTLEN (PROPERTY_ID_START +112) // UINT16 +#define PROPERTY_ID_SPIN (PROPERTY_ID_START +113) // BOOL +#define PROPERTY_ID_STRICTFORMAT (PROPERTY_ID_START +114) // BOOL +#define PROPERTY_ID_SHOWTHOUSANDSEP (PROPERTY_ID_START +115) // BOOL +#define PROPERTY_ID_HARDLINEBREAKS (PROPERTY_ID_START +116) // BOOL +#define PROPERTY_ID_PRINTABLE (PROPERTY_ID_START +117) // BOOL +#define PROPERTY_ID_TARGET_URL (PROPERTY_ID_START +118) // OUString +#define PROPERTY_ID_TARGET_FRAME (PROPERTY_ID_START +119) // OUString +#define PROPERTY_ID_TAG (PROPERTY_ID_START +120) // OUString +#define PROPERTY_ID_ECHO_CHAR (PROPERTY_ID_START +121) // UINT16 +#define PROPERTY_ID_SHOW_POSITION (PROPERTY_ID_START +122) // sal_Bool +#define PROPERTY_ID_SHOW_NAVIGATION (PROPERTY_ID_START +123) // sal_Bool +#define PROPERTY_ID_SHOW_RECORDACTIONS (PROPERTY_ID_START +124) // sal_Bool +#define PROPERTY_ID_SHOW_FILTERSORT (PROPERTY_ID_START +125) // sal_Bool +#define PROPERTY_ID_EMPTY_IS_NULL (PROPERTY_ID_START +126) // Bool +#define PROPERTY_ID_DECIMAL_ACCURACY (PROPERTY_ID_START +127) // UINT16 +#define PROPERTY_ID_DATE_SHOW_CENTURY (PROPERTY_ID_START +128) // Bool +#define PROPERTY_ID_TRISTATE (PROPERTY_ID_START +129) // Bool +#define PROPERTY_ID_DEFAULT_BUTTON (PROPERTY_ID_START +130) // Bool +#define PROPERTY_ID_HIDDEN_VALUE (PROPERTY_ID_START +131) // OUString +#define PROPERTY_ID_DECIMALS (PROPERTY_ID_START +132) // UINT16 +#define PROPERTY_ID_AUTOINCREMENT (PROPERTY_ID_START +133) // UINT16 + // free +#define PROPERTY_ID_FILTER (PROPERTY_ID_START +135) // OUString +#define PROPERTY_ID_HAVINGCLAUSE (PROPERTY_ID_START +136) // OUString +#define PROPERTY_ID_QUERY (PROPERTY_ID_START +137) // OUString +#define PROPERTY_ID_DEFAULT_LONG_VALUE (PROPERTY_ID_START +138) // Double +#define PROPERTY_ID_DEFAULT_DATE (PROPERTY_ID_START +139) // UINT32 +#define PROPERTY_ID_DEFAULT_TIME (PROPERTY_ID_START +140) +#define PROPERTY_ID_HELPTEXT (PROPERTY_ID_START +141) +#define PROPERTY_ID_FONT_NAME (PROPERTY_ID_START +142) +#define PROPERTY_ID_FONT_STYLENAME (PROPERTY_ID_START +143) +#define PROPERTY_ID_FONT_FAMILY (PROPERTY_ID_START +144) +#define PROPERTY_ID_FONT_CHARSET (PROPERTY_ID_START +145) +#define PROPERTY_ID_FONT_HEIGHT (PROPERTY_ID_START +146) +#define PROPERTY_ID_FONT_WEIGHT (PROPERTY_ID_START +147) +#define PROPERTY_ID_FONT_SLANT (PROPERTY_ID_START +148) +#define PROPERTY_ID_FONT_UNDERLINE (PROPERTY_ID_START +149) +#define PROPERTY_ID_FONT_STRIKEOUT (PROPERTY_ID_START +150) +#define PROPERTY_ID_ISPASSTHROUGH (PROPERTY_ID_START +151) +#define PROPERTY_ID_HELPURL (PROPERTY_ID_START +152) // OUString +#define PROPERTY_ID_RECORDMARKER (PROPERTY_ID_START +153) +#define PROPERTY_ID_BOUNDFIELD (PROPERTY_ID_START +154) +#define PROPERTY_ID_FORMATSSUPPLIER (PROPERTY_ID_START +155) // XNumberFormatsSupplier +#define PROPERTY_ID_TREATASNUMERIC (PROPERTY_ID_START +156) // BOOL +#define PROPERTY_ID_EFFECTIVE_VALUE (PROPERTY_ID_START +157) // ANY (string or double) +#define PROPERTY_ID_EFFECTIVE_DEFAULT (PROPERTY_ID_START +158) // ditto +#define PROPERTY_ID_EFFECTIVE_MIN (PROPERTY_ID_START +159) // ditto +#define PROPERTY_ID_EFFECTIVE_MAX (PROPERTY_ID_START +160) // ditto +#define PROPERTY_ID_HIDDEN (PROPERTY_ID_START +161) // BOOL +#define PROPERTY_ID_FILTERPROPOSAL (PROPERTY_ID_START +162) // BOOL +#define PROPERTY_ID_FIELDSOURCE (PROPERTY_ID_START +163) // String +#define PROPERTY_ID_TABLENAME (PROPERTY_ID_START +164) // String +#define PROPERTY_ID_ENABLEVISIBLE (PROPERTY_ID_START +165) // BOOL + // FREE + // FREE + // FREE + // FREE +#define PROPERTY_ID_CONTROLLABEL (PROPERTY_ID_START +171) // XPropertySet +#define PROPERTY_ID_CURRSYM_POSITION (PROPERTY_ID_START +172) // String + // FREE +#define PROPERTY_ID_CURSORCOLOR (PROPERTY_ID_START +174) // INT32 +#define PROPERTY_ID_ALWAYSSHOWCURSOR (PROPERTY_ID_START +175) // BOOL +#define PROPERTY_ID_DISPLAYSYNCHRON (PROPERTY_ID_START +176) // BOOL +#define PROPERTY_ID_ISMODIFIED (PROPERTY_ID_START +177) // BOOL +#define PROPERTY_ID_ISNEW (PROPERTY_ID_START +178) // BOOL +#define PROPERTY_ID_PRIVILEGES (PROPERTY_ID_START +179) // INT32 +#define PROPERTY_ID_DETAILFIELDS (PROPERTY_ID_START +180) // Sequence< OUString > +#define PROPERTY_ID_COMMAND (PROPERTY_ID_START +181) // String +#define PROPERTY_ID_COMMANDTYPE (PROPERTY_ID_START +182) // INT32 (css::sdb::CommandType) +#define PROPERTY_ID_RESULTSET_CONCURRENCY (PROPERTY_ID_START +183)// INT32 (css::sdbc::ResultSetConcurrency) +#define PROPERTY_ID_INSERTONLY (PROPERTY_ID_START +184) // BOOL +#define PROPERTY_ID_RESULTSET_TYPE (PROPERTY_ID_START +185) // INT32 (css::sdbc::ResultSetType) +#define PROPERTY_ID_ESCAPE_PROCESSING (PROPERTY_ID_START +186) // BOOL +#define PROPERTY_ID_APPLYFILTER (PROPERTY_ID_START +187) // BOOL + +#define PROPERTY_ID_ISNULLABLE (PROPERTY_ID_START +188) // BOOL +#define PROPERTY_ID_ACTIVECOMMAND (PROPERTY_ID_START +189) // String +#define PROPERTY_ID_ISCURRENCY (PROPERTY_ID_START +190) // BOOL +#define PROPERTY_ID_URL (PROPERTY_ID_START +192) // String +#define PROPERTY_ID_TITLE (PROPERTY_ID_START +193) // String +#define PROPERTY_ID_ACTIVE_CONNECTION (PROPERTY_ID_START +194) // css::sdbc::XConnection +#define PROPERTY_ID_SCALE (PROPERTY_ID_START +195) // INT32 +#define PROPERTY_ID_SORT (PROPERTY_ID_START +196) // String + + // free + // free +#define PROPERTY_ID_FETCHSIZE (PROPERTY_ID_START +199) + // free +#define PROPERTY_ID_SEARCHABLE (PROPERTY_ID_START +201) +#define PROPERTY_ID_ISREADONLY (PROPERTY_ID_START +202) + // free +#define PROPERTY_ID_FIELDTYPE (PROPERTY_ID_START +204) +#define PROPERTY_ID_COLUMNSERVICENAME (PROPERTY_ID_START +205) +#define PROPERTY_ID_CONTROLSOURCEPROPERTY (PROPERTY_ID_START +206) +#define PROPERTY_ID_REALNAME (PROPERTY_ID_START +207) +#define PROPERTY_ID_FONT_WORDLINEMODE (PROPERTY_ID_START +208) +#define PROPERTY_ID_TEXTLINECOLOR (PROPERTY_ID_START +209) +#define PROPERTY_ID_FONTEMPHASISMARK (PROPERTY_ID_START +210) +#define PROPERTY_ID_FONTRELIEF (PROPERTY_ID_START +211) + +#define PROPERTY_ID_DISPATCHURLINTERNAL ( PROPERTY_ID_START + 212 ) // sal_Bool +#define PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH ( PROPERTY_ID_START + 213 ) // sal_Int16 +#define PROPERTY_ID_DEFAULT_SCROLL_VALUE ( PROPERTY_ID_START + 214 ) // sal_Int32 +#define PROPERTY_ID_DEFAULT_SPIN_VALUE ( PROPERTY_ID_START + 215 ) // sal_Int32 +#define PROPERTY_ID_SCROLL_VALUE ( PROPERTY_ID_START + 216 ) // sal_Int32 +#define PROPERTY_ID_SPIN_VALUE ( PROPERTY_ID_START + 217 ) // sal_Int32 +#define PROPERTY_ID_ICONSIZE ( PROPERTY_ID_START + 218 ) // sal_Int16 + +#define PROPERTY_ID_FONT_CHARWIDTH ( PROPERTY_ID_START + 219 ) // float +#define PROPERTY_ID_FONT_KERNING ( PROPERTY_ID_START + 220 ) // sal_Bool +#define PROPERTY_ID_FONT_ORIENTATION ( PROPERTY_ID_START + 221 ) // float +#define PROPERTY_ID_FONT_PITCH ( PROPERTY_ID_START + 222 ) // sal_Int16 +#define PROPERTY_ID_FONT_TYPE ( PROPERTY_ID_START + 223 ) // sal_Int16 +#define PROPERTY_ID_FONT_WIDTH ( PROPERTY_ID_START + 224 ) // sal_Int16 +#define PROPERTY_ID_RICH_TEXT ( PROPERTY_ID_START + 225 ) // sal_Bool + +#define PROPERTY_ID_DYNAMIC_CONTROL_BORDER ( PROPERTY_ID_START + 226 ) // sal_Bool +#define PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS ( PROPERTY_ID_START + 227 ) // sal_Int32 +#define PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE ( PROPERTY_ID_START + 228 ) // sal_Int32 +#define PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID ( PROPERTY_ID_START + 229 ) // sal_Int32 + +#define PROPERTY_ID_XSD_PATTERN ( PROPERTY_ID_START + 230 ) +#define PROPERTY_ID_XSD_WHITESPACE ( PROPERTY_ID_START + 231 ) +#define PROPERTY_ID_XSD_LENGTH ( PROPERTY_ID_START + 232 ) +#define PROPERTY_ID_XSD_MIN_LENGTH ( PROPERTY_ID_START + 233 ) +#define PROPERTY_ID_XSD_MAX_LENGTH ( PROPERTY_ID_START + 234 ) +#define PROPERTY_ID_XSD_TOTAL_DIGITS ( PROPERTY_ID_START + 235 ) +#define PROPERTY_ID_XSD_FRACTION_DIGITS ( PROPERTY_ID_START + 236 ) +#define PROPERTY_ID_XSD_MAX_INCLUSIVE_INT ( PROPERTY_ID_START + 237 ) +#define PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT ( PROPERTY_ID_START + 238 ) +#define PROPERTY_ID_XSD_MIN_INCLUSIVE_INT ( PROPERTY_ID_START + 239 ) +#define PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT ( PROPERTY_ID_START + 240 ) +#define PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE ( PROPERTY_ID_START + 241 ) +#define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE ( PROPERTY_ID_START + 242 ) +#define PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE ( PROPERTY_ID_START + 243 ) +#define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE ( PROPERTY_ID_START + 244 ) +#define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE ( PROPERTY_ID_START + 245 ) +#define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE ( PROPERTY_ID_START + 246 ) +#define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE ( PROPERTY_ID_START + 247 ) +#define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE ( PROPERTY_ID_START + 248 ) +#define PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME ( PROPERTY_ID_START + 249 ) +#define PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME ( PROPERTY_ID_START + 250 ) +#define PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME ( PROPERTY_ID_START + 251 ) +#define PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME ( PROPERTY_ID_START + 252 ) +#define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME ( PROPERTY_ID_START + 253 ) +#define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME ( PROPERTY_ID_START + 254 ) +#define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME ( PROPERTY_ID_START + 255 ) +#define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME ( PROPERTY_ID_START + 256 ) +#define PROPERTY_ID_XSD_IS_BASIC ( PROPERTY_ID_START + 257 ) +#define PROPERTY_ID_XSD_TYPE_CLASS ( PROPERTY_ID_START + 258 ) + +#define PROPERTY_ID_LINEEND_FORMAT ( PROPERTY_ID_START + 259 ) // css.awt.LineEndFormat +#define PROPERTY_ID_GENERATEVBAEVENTS ( PROPERTY_ID_START + 260 ) +#define PROPERTY_ID_CONTROL_TYPE_IN_MSO ( PROPERTY_ID_START + 261 ) +#define PROPERTY_ID_OBJ_ID_IN_MSO ( PROPERTY_ID_START + 262 ) + +#define PROPERTY_ID_TYPEDITEMLIST ( PROPERTY_ID_START + 263 ) // Sequence<Any> + +// start ID for aggregated properties +#define PROPERTY_ID_AGGREGATE_ID (PROPERTY_ID_START + 10000) + +//= assignment property handle <-> property name +//= used by the PropertySetAggregationHelper + + +class PropertyInfoService +{ + typedef std::unordered_map<OUString, sal_Int32> PropertyMap; + static PropertyMap s_AllKnownProperties; + +public: + PropertyInfoService() = delete; + + static sal_Int32 getPropertyId(const OUString& _rName); + +private: + static void initialize(); +}; + + +// a class implementing the comphelper::IPropertyInfoService +class ConcreteInfoService : public ::comphelper::IPropertyInfoService +{ +public: + virtual ~ConcreteInfoService() {} + + virtual sal_Int32 getPreferredPropertyId(const OUString& _rName) override; +}; + +} +//... namespace frm ....................................................... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/propertybaghelper.hxx b/forms/source/inc/propertybaghelper.hxx new file mode 100644 index 000000000..542cef9a6 --- /dev/null +++ b/forms/source/inc/propertybaghelper.hxx @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <comphelper/propertybag.hxx> +#include <comphelper/propagg.hxx> +#include <memory> + + +namespace frm +{ + + + //= class IPropertyBagHelperContext + + class SAL_NO_VTABLE IPropertyBagHelperContext + { + public: + virtual ::osl::Mutex& getMutex() = 0; + + virtual void describeFixedAndAggregateProperties( + css::uno::Sequence< css::beans::Property >& _out_rFixedProperties, + css::uno::Sequence< css::beans::Property >& _out_rAggregateProperties + ) const = 0; + + virtual css::uno::Reference< css::beans::XMultiPropertySet > + getPropertiesInterface() = 0; + + protected: + ~IPropertyBagHelperContext() {} + }; + + class PropertyBagHelper + { + private: + IPropertyBagHelperContext& m_rContext; + std::unique_ptr<::comphelper::OPropertyArrayAggregationHelper> + m_pPropertyArrayHelper; + ::comphelper::PropertyBag m_aDynamicProperties; + bool m_bDisposed; + + public: + PropertyBagHelper( IPropertyBagHelperContext& _rContext ); + ~PropertyBagHelper(); + PropertyBagHelper(const PropertyBagHelper&) = delete; + PropertyBagHelper& operator=(const PropertyBagHelper&) = delete; + + // XComponent equivalent + void dispose(); + + // OPropertySetHelper equivalent + inline ::comphelper::OPropertyArrayAggregationHelper& getInfoHelper() const; + + // XPropertyContainer equivalent + void addProperty( const OUString& _rName, ::sal_Int16 _nAttributes, const css::uno::Any& _rInitialValue ); + void removeProperty( const OUString& _rName ); + + // XPropertyAccess equivalent + css::uno::Sequence< css::beans::PropertyValue > getPropertyValues(); + void setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& _rProps ); + + // forwards to m_aDynamicProperties + inline void getDynamicFastPropertyValue( sal_Int32 _nHandle, css::uno::Any& _out_rValue ) const; + inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle, const css::uno::Any& _rNewValue, css::uno::Any& _out_rConvertedValue, css::uno::Any& _out_rCurrentValue ) const; + inline void setDynamicFastPropertyValue( sal_Int32 _nHandle, const css::uno::Any& _rValue ); + inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, css::uno::Any& _out_rValue ) const; + inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const; + + private: + void impl_nts_checkDisposed_throw() const; + + /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus + getInfoHelper will return a newly created instance + */ + void impl_nts_invalidatePropertySetInfo(); + + /** returns the IPropertyArrayHelper instance used by |this| + */ + ::comphelper::OPropertyArrayAggregationHelper& impl_ts_getArrayHelper() const; + + /** finds a free property handle + @param _rPropertyName + the name of the property to find a handle for. If possible, the handle as determined by + our ConcreteInfoService instance will be used + */ + sal_Int32 impl_findFreeHandle( const OUString& _rPropertyName ); + }; + + + inline ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::getInfoHelper() const + { + return impl_ts_getArrayHelper(); + } + + + inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle, css::uno::Any& _out_rValue ) const + { + m_aDynamicProperties.getFastPropertyValue( _nHandle, _out_rValue ); + } + + + inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle, const css::uno::Any& _rNewValue, css::uno::Any& _out_rConvertedValue, css::uno::Any& _out_rCurrentValue ) const + { + return m_aDynamicProperties.convertFastPropertyValue( _nHandle, _rNewValue, _out_rConvertedValue, _out_rCurrentValue ); + } + + + inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle, const css::uno::Any& _rValue ) + { + m_aDynamicProperties.setFastPropertyValue( _nHandle, _rValue ); + } + + + inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, css::uno::Any& _out_rValue ) const + { + m_aDynamicProperties.getPropertyDefaultByHandle( _nHandle, _out_rValue ); + } + + inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const + { + return m_aDynamicProperties.hasPropertyByHandle( _nHandle ); + } + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/resettable.hxx b/forms/source/inc/resettable.hxx new file mode 100644 index 000000000..cbbc13e50 --- /dev/null +++ b/forms/source/inc/resettable.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/form/XResetListener.hpp> + +#include <comphelper/interfacecontainer3.hxx> + +namespace cppu +{ + class OWeakObject; +} + + +namespace frm +{ + + class ResetHelper + { + public: + ResetHelper( ::cppu::OWeakObject& _parent, ::osl::Mutex& _mutex ) + :m_rParent( _parent ) + ,m_aResetListeners( _mutex ) + { + } + + // XReset equivalents + void addResetListener( const css::uno::Reference< css::form::XResetListener >& _listener ); + void removeResetListener( const css::uno::Reference< css::form::XResetListener >& _listener ); + + // calling listeners + bool approveReset(); + void notifyResetted(); + void disposing(); + + private: + ::cppu::OWeakObject& m_rParent; + ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners; + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/services.hxx b/forms/source/inc/services.hxx new file mode 100644 index 000000000..82a18ad6f --- /dev/null +++ b/forms/source/inc/services.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUStringLiteral VCL_CONTROL_LISTBOX = u"stardiv.vcl.control.ListBox"; +inline constexpr OUStringLiteral VCL_CONTROL_COMBOBOX = u"stardiv.vcl.control.ComboBox"; +inline constexpr OUStringLiteral VCL_CONTROL_RADIOBUTTON = u"stardiv.vcl.control.RadioButton"; +inline constexpr OUStringLiteral VCL_CONTROL_GROUPBOX = u"stardiv.vcl.control.GroupBox"; +inline constexpr OUStringLiteral VCL_CONTROL_COMMANDBUTTON = u"stardiv.vcl.control.Button"; +inline constexpr OUStringLiteral VCL_CONTROL_CHECKBOX = u"stardiv.vcl.control.CheckBox"; +inline constexpr OUStringLiteral VCL_CONTROL_IMAGEBUTTON = u"stardiv.vcl.control.ImageButton"; +inline constexpr OUStringLiteral VCL_CONTROL_TIMEFIELD = u"stardiv.vcl.control.TimeField"; +inline constexpr OUStringLiteral VCL_CONTROL_DATEFIELD = u"stardiv.vcl.control.DateField"; +inline constexpr OUStringLiteral VCL_CONTROL_NUMERICFIELD = u"stardiv.vcl.control.NumericField"; +inline constexpr OUStringLiteral VCL_CONTROL_CURRENCYFIELD = u"stardiv.vcl.control.CurrencyField"; +inline constexpr OUStringLiteral VCL_CONTROL_PATTERNFIELD = u"stardiv.vcl.control.PatternField"; +inline constexpr OUStringLiteral VCL_CONTROL_FORMATTEDFIELD = u"stardiv.vcl.control.FormattedField"; +inline constexpr OUStringLiteral VCL_CONTROL_IMAGECONTROL = u"stardiv.vcl.control.ImageControl"; + +inline constexpr OUStringLiteral VCL_CONTROLMODEL_EDIT = u"stardiv.vcl.controlmodel.Edit"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_LISTBOX = u"stardiv.vcl.controlmodel.ListBox"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_COMBOBOX = u"stardiv.vcl.controlmodel.ComboBox"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_RADIOBUTTON = u"stardiv.vcl.controlmodel.RadioButton"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_GROUPBOX = u"stardiv.vcl.controlmodel.GroupBox"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_FIXEDTEXT = u"stardiv.vcl.controlmodel.FixedText"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_COMMANDBUTTON = u"stardiv.vcl.controlmodel.Button"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_CHECKBOX = u"stardiv.vcl.controlmodel.CheckBox"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_IMAGEBUTTON = u"stardiv.vcl.controlmodel.ImageButton"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_FILECONTROL = u"stardiv.vcl.controlmodel.FileControl"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_TIMEFIELD = u"stardiv.vcl.controlmodel.TimeField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_DATEFIELD = u"stardiv.vcl.controlmodel.DateField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_NUMERICFIELD = u"stardiv.vcl.controlmodel.NumericField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_CURRENCYFIELD = u"stardiv.vcl.controlmodel.CurrencyField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_PATTERNFIELD = u"stardiv.vcl.controlmodel.PatternField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_FORMATTEDFIELD = u"stardiv.vcl.controlmodel.FormattedField"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_IMAGECONTROL = u"stardiv.vcl.controlmodel.ImageControl"; + +inline constexpr OUStringLiteral VCL_CONTROLMODEL_SCROLLBAR = u"com.sun.star.awt.UnoControlScrollBarModel"; +inline constexpr OUStringLiteral VCL_CONTROL_SCROLLBAR = u"com.sun.star.awt.UnoControlScrollBar"; +inline constexpr OUStringLiteral VCL_CONTROLMODEL_SPINBUTTON = u"com.sun.star.awt.UnoControlSpinButtonModel"; +inline constexpr OUStringLiteral VCL_CONTROL_SPINBUTTON = u"com.sun.star.awt.UnoControlSpinButton"; + +// service names for compatibility + +inline constexpr OUStringLiteral FRM_COMPONENT_FORM = u"stardiv.one.form.component.Form"; +inline constexpr OUStringLiteral FRM_COMPONENT_EDIT = u"stardiv.one.form.component.Edit"; // compatibility +inline constexpr OUStringLiteral FRM_COMPONENT_TEXTFIELD = u"stardiv.one.form.component.TextField"; +inline constexpr OUStringLiteral FRM_COMPONENT_LISTBOX = u"stardiv.one.form.component.ListBox"; +inline constexpr OUStringLiteral FRM_COMPONENT_COMBOBOX = u"stardiv.one.form.component.ComboBox"; +inline constexpr OUStringLiteral FRM_COMPONENT_RADIOBUTTON = u"stardiv.one.form.component.RadioButton"; +inline constexpr OUStringLiteral FRM_COMPONENT_GROUPBOX = u"stardiv.one.form.component.GroupBox"; // compatibility +inline constexpr OUStringLiteral FRM_COMPONENT_FIXEDTEXT = u"stardiv.one.form.component.FixedText"; // compatibility +inline constexpr OUStringLiteral FRM_COMPONENT_COMMANDBUTTON = u"stardiv.one.form.component.CommandButton"; +inline constexpr OUStringLiteral FRM_COMPONENT_CHECKBOX = u"stardiv.one.form.component.CheckBox"; +inline constexpr OUStringLiteral FRM_COMPONENT_GRID = u"stardiv.one.form.component.Grid"; // compatibility +inline constexpr OUStringLiteral FRM_COMPONENT_GRIDCONTROL = u"stardiv.one.form.component.GridControl"; +inline constexpr OUStringLiteral FRM_COMPONENT_IMAGEBUTTON = u"stardiv.one.form.component.ImageButton"; +inline constexpr OUStringLiteral FRM_COMPONENT_FILECONTROL = u"stardiv.one.form.component.FileControl"; +inline constexpr OUStringLiteral FRM_COMPONENT_TIMEFIELD = u"stardiv.one.form.component.TimeField"; +inline constexpr OUStringLiteral FRM_COMPONENT_DATEFIELD = u"stardiv.one.form.component.DateField"; +inline constexpr OUStringLiteral FRM_COMPONENT_NUMERICFIELD = u"stardiv.one.form.component.NumericField"; +inline constexpr OUStringLiteral FRM_COMPONENT_CURRENCYFIELD = u"stardiv.one.form.component.CurrencyField"; +inline constexpr OUStringLiteral FRM_COMPONENT_PATTERNFIELD = u"stardiv.one.form.component.PatternField"; +inline constexpr OUStringLiteral FRM_COMPONENT_HIDDEN = u"stardiv.one.form.component.Hidden"; +inline constexpr OUStringLiteral FRM_COMPONENT_HIDDENCONTROL = u"stardiv.one.form.component.HiddenControl"; +inline constexpr OUStringLiteral FRM_COMPONENT_IMAGECONTROL = u"stardiv.one.form.component.ImageControl"; +inline constexpr OUStringLiteral FRM_COMPONENT_FORMATTEDFIELD = u"stardiv.one.form.component.FormattedField"; + +// <compatibility_I> +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_COMMANDBUTTON = u"stardiv.one.form.control.CommandButton"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_RADIOBUTTON = u"stardiv.one.form.control.RadioButton"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_CHECKBOX = u"stardiv.one.form.control.CheckBox"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_EDIT = u"stardiv.one.form.control.Edit"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_LISTBOX = u"stardiv.one.form.control.ListBox"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_COMBOBOX = u"stardiv.one.form.control.ComboBox"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_GROUPBOX = u"stardiv.one.form.control.GroupBox"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_TEXTFIELD = u"stardiv.one.form.control.TextField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_GRID = u"stardiv.one.form.control.Grid"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_IMAGEBUTTON = u"stardiv.one.form.control.ImageButton"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_TIMEFIELD = u"stardiv.one.form.control.TimeField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_DATEFIELD = u"stardiv.one.form.control.DateField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_NUMERICFIELD = u"stardiv.one.form.control.NumericField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_CURRENCYFIELD = u"stardiv.one.form.control.CurrencyField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_PATTERNFIELD = u"stardiv.one.form.control.PatternField"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_IMAGECONTROL = u"stardiv.one.form.control.ImageControl"; +inline constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_FORMATTEDFIELD = u"stardiv.one.form.control.FormattedField"; +// </compatibility_I> + +// new (sun) service names + +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_FORM = u"com.sun.star.form.component.Form"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_HTMLFORM = u"com.sun.star.form.component.HTMLForm"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATAFORM = u"com.sun.star.form.component.DataForm"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_TEXTFIELD = u"com.sun.star.form.component.TextField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_LISTBOX = u"com.sun.star.form.component.ListBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_COMBOBOX = u"com.sun.star.form.component.ComboBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_RADIOBUTTON = u"com.sun.star.form.component.RadioButton"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_GROUPBOX = u"com.sun.star.form.component.GroupBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_FIXEDTEXT = u"com.sun.star.form.component.FixedText"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_COMMANDBUTTON = u"com.sun.star.form.component.CommandButton"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_CHECKBOX = u"com.sun.star.form.component.CheckBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_GRIDCONTROL = u"com.sun.star.form.component.GridControl"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_IMAGEBUTTON = u"com.sun.star.form.component.ImageButton"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_FILECONTROL = u"com.sun.star.form.component.FileControl"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_TIMEFIELD = u"com.sun.star.form.component.TimeField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATEFIELD = u"com.sun.star.form.component.DateField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_NUMERICFIELD = u"com.sun.star.form.component.NumericField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_CURRENCYFIELD = u"com.sun.star.form.component.CurrencyField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_PATTERNFIELD = u"com.sun.star.form.component.PatternField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_HIDDENCONTROL = u"com.sun.star.form.component.HiddenControl"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_FORMATTEDFIELD = u"com.sun.star.form.component.FormattedField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_SCROLLBAR = u"com.sun.star.form.component.ScrollBar"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_SPINBUTTON = u"com.sun.star.form.component.SpinButton"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_RICHTEXTCONTROL = u"com.sun.star.form.component.RichTextControl"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_NAVTOOLBAR = u"com.sun.star.form.component.NavigationToolBar"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_SUBMITBUTTON = u"com.sun.star.form.component.SubmitButton"; + +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_IMAGECONTROL = u"com.sun.star.form.component.DatabaseImageControl"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_RADIOBUTTON = u"com.sun.star.form.component.DatabaseRadioButton"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_CHECKBOX = u"com.sun.star.form.component.DatabaseCheckBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_LISTBOX = u"com.sun.star.form.component.DatabaseListBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_COMBOBOX = u"com.sun.star.form.component.DatabaseComboBox"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD = u"com.sun.star.form.component.DatabaseFormattedField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_TEXTFIELD = u"com.sun.star.form.component.DatabaseTextField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_DATEFIELD = u"com.sun.star.form.component.DatabaseDateField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_TIMEFIELD = u"com.sun.star.form.component.DatabaseTimeField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD = u"com.sun.star.form.component.DatabaseNumericField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_CURRENCYFIELD = u"com.sun.star.form.component.DatabaseCurrencyField"; +inline constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD = u"com.sun.star.form.component.DatabasePatternField"; + +inline constexpr OUStringLiteral FRM_SUN_CONTROL_TEXTFIELD = u"com.sun.star.form.control.TextField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_LISTBOX = u"com.sun.star.form.control.ListBox"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_COMBOBOX = u"com.sun.star.form.control.ComboBox"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_RADIOBUTTON = u"com.sun.star.form.control.RadioButton"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_GROUPBOX = u"com.sun.star.form.control.GroupBox"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_COMMANDBUTTON = u"com.sun.star.form.control.CommandButton"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_CHECKBOX = u"com.sun.star.form.control.CheckBox"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_GRIDCONTROL = u"com.sun.star.form.control.GridControl"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_IMAGEBUTTON = u"com.sun.star.form.control.ImageButton"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_TIMEFIELD = u"com.sun.star.form.control.TimeField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_DATEFIELD = u"com.sun.star.form.control.DateField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_NUMERICFIELD = u"com.sun.star.form.control.NumericField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_CURRENCYFIELD = u"com.sun.star.form.control.CurrencyField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_PATTERNFIELD = u"com.sun.star.form.control.PatternField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_IMAGECONTROL = u"com.sun.star.form.control.ImageControl"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_FORMATTEDFIELD = u"com.sun.star.form.control.FormattedField"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_RICHTEXTCONTROL = u"com.sun.star.form.control.RichTextControl"; +inline constexpr OUStringLiteral FRM_SUN_CONTROL_SUBMITBUTTON = u"com.sun.star.form.control.SubmitButton"; + +inline constexpr OUStringLiteral BINDABLE_DATABASE_CHECK_BOX = u"com.sun.star.form.binding.BindableDatabaseCheckBox"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_COMBO_BOX = u"com.sun.star.form.binding.BindableDatabaseComboBox"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_FORMATTED_FIELD = u"com.sun.star.form.binding.BindableDatabaseFormattedField"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_LIST_BOX = u"com.sun.star.form.binding.BindableDatabaseListBox"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_NUMERIC_FIELD = u"com.sun.star.form.binding.BindableDatabaseNumericField"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_RADIO_BUTTON = u"com.sun.star.form.binding.BindableDatabaseRadioButton"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_TEXT_FIELD = u"com.sun.star.form.binding.BindableDatabaseTextField"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_DATE_FIELD = u"com.sun.star.form.binding.BindableDatabaseDateField"; +inline constexpr OUStringLiteral BINDABLE_DATABASE_TIME_FIELD = u"com.sun.star.form.binding.BindableDatabaseTimeField"; + +inline constexpr OUStringLiteral BINDABLE_CONTROL_MODEL = u"com.sun.star.form.binding.BindableControlModel"; +inline constexpr OUStringLiteral BINDABLE_INTEGER_VALUE_RANGE = u"com.sun.star.form.binding.BindableIntegerValueRange"; +inline constexpr OUStringLiteral BINDABLE_DATA_AWARE_CONTROL_MODEL = u"com.sun.star.form.binding.BindableDataAwareControlModel"; +inline constexpr OUStringLiteral DATA_AWARE_CONTROL_MODEL = u"com.sun.star.form.binding.DataAwareControlModel"; +inline constexpr OUStringLiteral VALIDATABLE_CONTROL_MODEL = u"com.sun.star.form.binding.ValidatableControlModel"; +inline constexpr OUStringLiteral VALIDATABLE_BINDABLE_CONTROL_MODEL = u"com.sun.star.form.binding.ValidatableBindableControlModel"; + +// common + +inline constexpr OUStringLiteral FRM_SUN_FORMCOMPONENT = u"com.sun.star.form.FormComponent"; + +// misc + +inline constexpr OUStringLiteral SRV_SDB_ROWSET = u"com.sun.star.sdb.RowSet"; +inline constexpr OUStringLiteral SRV_SDB_CONNECTION = u"com.sun.star.sdb.Connection"; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/togglestate.hxx b/forms/source/inc/togglestate.hxx new file mode 100644 index 000000000..aeacabc51 --- /dev/null +++ b/forms/source/inc/togglestate.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +namespace frm +{ + + + enum ToggleState { TRISTATE_FALSE = 0, TRISTATE_TRUE = 1, TRISTATE_INDET = 2 }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/urltransformer.hxx b/forms/source/inc/urltransformer.hxx new file mode 100644 index 000000000..3cfe22594 --- /dev/null +++ b/forms/source/inc/urltransformer.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/URL.hpp> + + +namespace frm +{ + + class UrlTransformer + { + private: + css::uno::Reference< css::uno::XComponentContext > + m_xORB; + mutable css::uno::Reference< css::util::XURLTransformer > + m_xTransformer; + mutable bool m_bTriedToCreateTransformer; + + public: + UrlTransformer( const css::uno::Reference< css::uno::XComponentContext >& _rxORB ); + + /** returns a URL object for the given URL string + */ + css::util::URL + getStrictURL( const OUString& _rURL ) const; + + /** returns a URL object for the given URL ASCII string + */ + css::util::URL + getStrictURLFromAscii( const char* _pAsciiURL ) const; + + /** parses a given URL smartly, with a given protocol + */ + void + parseSmartWithProtocol( css::util::URL& _rURL, const OUString& _rProtocol ) const; + + private: + /** ensures that we have a URLTransformer instance in <member>m_xTransformer</member> + + @return + <TRUE/> if and only if m_xTransformer is not <NULL/> + */ + bool implEnsureTransformer() const; + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/windowstateguard.hxx b/forms/source/inc/windowstateguard.hxx new file mode 100644 index 000000000..f1a449c39 --- /dev/null +++ b/forms/source/inc/windowstateguard.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <rtl/ref.hxx> + + +namespace frm +{ + + + //= WindowStateGuard + + class WindowStateGuard_Impl; + + /** a helper class which monitors certain states of an XWindow2, and ensures + that they're consistent with respective properties at an XModel. + + For form controls, window states - such as "Enabled" - can be set by various + means. You can set the respective control model property, you can directly manipulate + the XWindow2, or the state can change implicitly due to VCL actions. In any case, + we need to ensure that the state does not contradict the model property "too much". + + As an example, consider a form control which, according to its model's property, is disabled. + Now when the parent VCL window of the control's VCL window is enabled, then the control's + window is enabled, too - which contradicts the model property. + + A WindowStateGuard helps you preventing such inconsistent states. + + The class is not threadsafe. + */ + class WindowStateGuard + { + private: + ::rtl::Reference< WindowStateGuard_Impl > m_pImpl; + + public: + WindowStateGuard(); + ~WindowStateGuard(); + + void attach( + const css::uno::Reference< css::awt::XWindow2 >& _rxWindow, + const css::uno::Reference< css::awt::XControlModel >& _rxModel + ); + }; + + +} // namespace frm + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |