diff options
Diffstat (limited to 'forms/source/inc')
-rw-r--r-- | forms/source/inc/FormComponent.hxx | 1240 | ||||
-rw-r--r-- | forms/source/inc/InterfaceContainer.hxx | 304 | ||||
-rw-r--r-- | forms/source/inc/cloneable.hxx | 44 | ||||
-rw-r--r-- | forms/source/inc/commandimageprovider.hxx | 56 | ||||
-rw-r--r-- | forms/source/inc/componenttools.hxx | 87 | ||||
-rw-r--r-- | forms/source/inc/controlfeatureinterception.hxx | 90 | ||||
-rw-r--r-- | forms/source/inc/featuredispatcher.hxx | 104 | ||||
-rw-r--r-- | forms/source/inc/formcontrolfont.hxx | 99 | ||||
-rw-r--r-- | forms/source/inc/formnavigation.hxx | 220 | ||||
-rw-r--r-- | forms/source/inc/frm_resource.hxx | 42 | ||||
-rw-r--r-- | forms/source/inc/frm_strings.hxx | 300 | ||||
-rw-r--r-- | forms/source/inc/limitedformats.hxx | 97 | ||||
-rw-r--r-- | forms/source/inc/listenercontainers.hxx | 113 | ||||
-rw-r--r-- | forms/source/inc/property.hxx | 435 | ||||
-rw-r--r-- | forms/source/inc/propertybaghelper.hxx | 150 | ||||
-rw-r--r-- | forms/source/inc/resettable.hxx | 65 | ||||
-rw-r--r-- | forms/source/inc/services.hxx | 204 | ||||
-rw-r--r-- | forms/source/inc/togglestate.hxx | 36 | ||||
-rw-r--r-- | forms/source/inc/urltransformer.hxx | 73 | ||||
-rw-r--r-- | forms/source/inc/windowstateguard.hxx | 73 |
20 files changed, 3832 insertions, 0 deletions
diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx new file mode 100644 index 000000000..09fdb0658 --- /dev/null +++ b/forms/source/inc/FormComponent.hxx @@ -0,0 +1,1240 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FORMCOMPONENT_HXX +#define INCLUDED_FORMS_SOURCE_INC_FORMCOMPONENT_HXX + +#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/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; + + // macros for quickly declaring/implementing XServiceInfo + #define DECLARE_XPERSISTOBJECT() \ + virtual OUString SAL_CALL getServiceName() override; \ + 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; + + 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 binarary file + sal_uInt16 m_nObjIDinMSO; //keep the OCX control obj id for exporting to MS binarary 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; } +}; + +// constructor for cloning a class +#define DECLARE_DEFAULT_CLONE_CTOR( classname ) \ + classname( \ + const classname* _pOriginal, \ + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ + ); \ + +// all xtors for a leaf class of the object hierarchy +#define DECLARE_DEFAULT_LEAF_XTOR( classname ) \ + classname( \ + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ + ); \ + classname( \ + const classname* _pOriginal, \ + const css::uno::Reference< css::uno::XComponentContext>& _rxFactory \ + ); \ + virtual ~classname() override \ + + +#define IMPLEMENT_DEFAULT_CLONING( classname ) \ + css::uno::Reference< css::util::XCloneable > SAL_CALL classname::createClone( ) \ + { \ + classname* pClone = new classname( this, getContext() ); \ + pClone->clonedFrom( this ); \ + return pClone; \ + } + + +//= 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; + +// dito +typedef ::cppu::ImplHelper2 < css::form::binding::XBindableValue + , css::util::XModifyListener + > OBoundControlModel_BINDING; + +// dito +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::OInterfaceContainerHelper2 m_aUpdateListeners; + ::comphelper::OInterfaceContainerHelper2 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> + + ::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_bTransferingValue : 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(); + } + + +} + + +#endif // INCLUDED_FORMS_SOURCE_INC_FORMCOMPONENT_HXX + +/* 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..690b93d49 --- /dev/null +++ b/forms/source/inc/InterfaceContainer.hxx @@ -0,0 +1,304 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_INTERFACECONTAINER_HXX +#define INCLUDED_FORMS_SOURCE_INC_INTERFACECONTAINER_HXX + +#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/interfacecontainer2.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::OInterfaceContainerHelper2 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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_INTERFACECONTAINER_HXX + +/* 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..e920650a5 --- /dev/null +++ b/forms/source/inc/cloneable.hxx @@ -0,0 +1,44 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_CLONEABLE_HXX +#define INCLUDED_FORMS_SOURCE_INC_CLONEABLE_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_CLONEABLE_HXX + +/* 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..3a67df022 --- /dev/null +++ b/forms/source/inc/commandimageprovider.hxx @@ -0,0 +1,56 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_COMMANDIMAGEPROVIDER_HXX +#define INCLUDED_FORMS_SOURCE_INC_COMMANDIMAGEPROVIDER_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_COMMANDIMAGEPROVIDER_HXX + +/* 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..f684ec572 --- /dev/null +++ b/forms/source/inc/componenttools.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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_COMPONENTTOOLS_HXX +#define INCLUDED_FORMS_SOURCE_INC_COMPONENTTOOLS_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_COMPONENTTOOLS_HXX + +/* 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..294d777dc --- /dev/null +++ b/forms/source/inc/controlfeatureinterception.hxx @@ -0,0 +1,90 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX +#define INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX + +/* 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..12fbe44ff --- /dev/null +++ b/forms/source/inc/featuredispatcher.hxx @@ -0,0 +1,104 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FEATUREDISPATCHER_HXX +#define INCLUDED_FORMS_SOURCE_INC_FEATUREDISPATCHER_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_FEATUREDISPATCHER_HXX + +/* 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..b6d9ea55d --- /dev/null +++ b/forms/source/inc/formcontrolfont.hxx @@ -0,0 +1,99 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FORMCONTROLFONT_HXX +#define INCLUDED_FORMS_SOURCE_INC_FORMCONTROLFONT_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_FORMCONTROLFONT_HXX + +/* 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..5a25dd896 --- /dev/null +++ b/forms/source/inc/formnavigation.hxx @@ -0,0 +1,220 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX +#define INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX + +#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( const OUString& _rCompleteURL ); + + private: + OFormNavigationMapper( const OFormNavigationMapper& ) = delete; + OFormNavigationMapper& operator=( const OFormNavigationMapper& ) = delete; + }; + + +} // namespace frm + + +#endif // INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX + +/* 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..529d0f43b --- /dev/null +++ b/forms/source/inc/frm_resource.hxx @@ -0,0 +1,42 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FRM_RESOURCE_HXX +#define INCLUDED_FORMS_SOURCE_INC_FRM_RESOURCE_HXX + +#include <rtl/ustring.hxx> + +namespace frm +{ + +#define FRM_RES_STRING(id) ResourceManager::loadString(id) + + // handling resources within the FormLayer library + namespace ResourceManager + { + /** loads the string with the specified resource id from the FormLayer mo file + */ + OUString loadString(const char* pResId); + }; +} + + +#endif // INCLUDED_FORMS_SOURCE_INC_FRM_RESOURCE_HXX + +/* 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..9e20636fc --- /dev/null +++ b/forms/source/inc/frm_strings.hxx @@ -0,0 +1,300 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_FRM_STRINGS_HXX +#define INCLUDED_FORMS_SOURCE_INC_FRM_STRINGS_HXX + + +namespace frm +{ + + + //- properties + + #define PROPERTY_TABINDEX "TabIndex" + #define PROPERTY_TAG "Tag" + #define PROPERTY_NAME "Name" + #define PROPERTY_GROUP_NAME "GroupName" + #define PROPERTY_CLASSID "ClassId" + #define PROPERTY_FETCHSIZE "FetchSize" + #define PROPERTY_VALUE "Value" + #define PROPERTY_TEXT "Text" + #define PROPERTY_LABEL "Label" + #define PROPERTY_CANINSERT "CanInsert" + #define PROPERTY_CANUPDATE "CanUpdate" + #define PROPERTY_CANDELETE "CanDelete" + #define PROPERTY_NAVIGATION "NavigationBarMode" + #define PROPERTY_HASNAVIGATION "HasNavigationBar" + #define PROPERTY_CYCLE "Cycle" + #define PROPERTY_CONTROLSOURCE "DataField" + #define PROPERTY_ENABLED "Enabled" + #define PROPERTY_ENABLEVISIBLE "EnableVisible" + #define PROPERTY_READONLY "ReadOnly" + #define PROPERTY_RELEVANT "Relevant" + #define PROPERTY_ISREADONLY "IsReadOnly" + #define PROPERTY_FILTER "Filter" + #define PROPERTY_HAVINGCLAUSE "HavingClause" + #define PROPERTY_WIDTH "Width" + #define PROPERTY_SEARCHABLE "IsSearchable" + #define PROPERTY_MULTILINE "MultiLine" + #define PROPERTY_TARGET_URL "TargetURL" + #define PROPERTY_TARGET_FRAME "TargetFrame" + #define PROPERTY_DEFAULTCONTROL "DefaultControl" + #define PROPERTY_MAXTEXTLEN "MaxTextLen" + #define PROPERTY_EDITMASK "EditMask" + #define PROPERTY_SIZE "Size" + #define PROPERTY_SPIN "Spin" + #define PROPERTY_DATE "Date" + #define PROPERTY_TIME "Time" + #define PROPERTY_STATE "State" + #define PROPERTY_TRISTATE "TriState" + #define PROPERTY_HIDDEN_VALUE "HiddenValue" + #define PROPERTY_BUTTONTYPE "ButtonType" + #define PROPERTY_STRINGITEMLIST "StringItemList" + #define PROPERTY_TYPEDITEMLIST "TypedItemList" + #define PROPERTY_DEFAULT_TEXT "DefaultText" + #define PROPERTY_DEFAULT_STATE "DefaultState" + #define PROPERTY_FORMATKEY "FormatKey" + #define PROPERTY_FORMATSSUPPLIER "FormatsSupplier" + #define PROPERTY_SUBMIT_ACTION "SubmitAction" + #define PROPERTY_SUBMIT_TARGET "SubmitTarget" + #define PROPERTY_SUBMIT_METHOD "SubmitMethod" + #define PROPERTY_SUBMIT_ENCODING "SubmitEncoding" + #define PROPERTY_IMAGE_URL "ImageURL" + #define PROPERTY_GRAPHIC "Graphic" + #define PROPERTY_IMAGE_POSITION "ImagePosition" + #define PROPERTY_EMPTY_IS_NULL "ConvertEmptyToNull" + #define PROPERTY_LISTSOURCETYPE "ListSourceType" + #define PROPERTY_LISTSOURCE "ListSource" + #define PROPERTY_SELECT_SEQ "SelectedItems" + #define PROPERTY_VALUE_SEQ "ValueItemList" + #define PROPERTY_SELECT_VALUE_SEQ "SelectedValues" + #define PROPERTY_SELECT_VALUE "SelectedValue" + #define PROPERTY_DEFAULT_SELECT_SEQ "DefaultSelection" + #define PROPERTY_MULTISELECTION "MultiSelection" + #define PROPERTY_ALIGN "Align" + #define PROPERTY_VERTICAL_ALIGN "VerticalAlign" + #define PROPERTY_DEFAULT_DATE "DefaultDate" + #define PROPERTY_DEFAULT_TIME "DefaultTime" + #define PROPERTY_DEFAULT_VALUE "DefaultValue" + #define PROPERTY_DECIMAL_ACCURACY "DecimalAccuracy" + #define PROPERTY_CURSORSOURCE "DataSelection" + #define PROPERTY_CURSORSOURCETYPE "DataSelectionType" + #define PROPERTY_FIELDTYPE "Type" + #define PROPERTY_DECIMALS "Decimals" + #define PROPERTY_REFVALUE "RefValue" + #define PROPERTY_UNCHECKED_REFVALUE "SecondaryRefValue" + #define PROPERTY_VALUEMIN "ValueMin" + #define PROPERTY_VALUEMAX "ValueMax" + #define PROPERTY_STRICTFORMAT "StrictFormat" + #define PROPERTY_ALLOWADDITIONS "AllowInserts" + #define PROPERTY_ALLOWEDITS "AllowUpdates" + #define PROPERTY_ALLOWDELETIONS "AllowDeletes" + #define PROPERTY_MASTERFIELDS "MasterFields" + #define PROPERTY_ISPASSTHROUGH "IsPassThrough" + #define PROPERTY_QUERY "Query" + #define PROPERTY_LITERALMASK "LiteralMask" + #define PROPERTY_VALUESTEP "ValueStep" + #define PROPERTY_SHOWTHOUSANDSEP "ShowThousandsSeparator" + #define PROPERTY_CURRENCYSYMBOL "CurrencySymbol" + #define PROPERTY_DATEFORMAT "DateFormat" + #define PROPERTY_DATEMIN "DateMin" + #define PROPERTY_DATEMAX "DateMax" + #define PROPERTY_DATE_SHOW_CENTURY "DateShowCentury" + #define PROPERTY_TIMEFORMAT "TimeFormat" + #define PROPERTY_TIMEMIN "TimeMin" + #define PROPERTY_TIMEMAX "TimeMax" + #define PROPERTY_LINECOUNT "LineCount" + #define PROPERTY_BOUNDCOLUMN "BoundColumn" + #define PROPERTY_FONT "FontDescriptor" + #define PROPERTY_FILLCOLOR "FillColor" + #define PROPERTY_LINECOLOR "LineColor" + #define PROPERTY_DROPDOWN "Dropdown" + #define PROPERTY_HSCROLL "HScroll" + #define PROPERTY_VSCROLL "VScroll" + #define PROPERTY_TABSTOP "Tabstop" + #define PROPERTY_AUTOCOMPLETE "Autocomplete" + #define PROPERTY_HARDLINEBREAKS "HardLineBreaks" + #define PROPERTY_PRINTABLE "Printable" + #define PROPERTY_ECHO_CHAR "EchoChar" + #define PROPERTY_ROWHEIGHT "RowHeight" + #define PROPERTY_HELPTEXT "HelpText" + #define PROPERTY_FONT_NAME "FontName" + #define PROPERTY_FONT_STYLENAME "FontStyleName" + #define PROPERTY_FONT_FAMILY "FontFamily" + #define PROPERTY_FONT_CHARSET "FontCharset" + #define PROPERTY_FONT_HEIGHT "FontHeight" + #define PROPERTY_FONT_WEIGHT "FontWeight" + #define PROPERTY_FONT_SLANT "FontSlant" + #define PROPERTY_FONT_UNDERLINE "FontUnderline" + #define PROPERTY_FONT_WORDLINEMODE "FontWordLineMode" + #define PROPERTY_FONT_STRIKEOUT "FontStrikeout" + #define PROPERTY_FONTEMPHASISMARK "FontEmphasisMark" + #define PROPERTY_FONTRELIEF "FontRelief" + #define PROPERTY_FONT_CHARWIDTH "FontCharWidth" + #define PROPERTY_FONT_KERNING "FontKerning" + #define PROPERTY_FONT_ORIENTATION "FontOrientation" + #define PROPERTY_FONT_PITCH "FontPitch" + #define PROPERTY_FONT_TYPE "FontType" + #define PROPERTY_FONT_WIDTH "FontWidth" + #define PROPERTY_HELPURL "HelpURL" + #define PROPERTY_RECORDMARKER "HasRecordMarker" + #define PROPERTY_BOUNDFIELD "BoundField" + #define PROPERTY_INPUT_REQUIRED "InputRequired" + #define PROPERTY_TREATASNUMERIC "TreatAsNumber" + #define PROPERTY_EFFECTIVE_VALUE "EffectiveValue" + #define PROPERTY_EFFECTIVE_DEFAULT "EffectiveDefault" + #define PROPERTY_EFFECTIVE_MIN "EffectiveMin" + #define PROPERTY_EFFECTIVE_MAX "EffectiveMax" + #define PROPERTY_HIDDEN "Hidden" + #define PROPERTY_FILTERPROPOSAL "UseFilterValueProposal" + #define PROPERTY_FIELDSOURCE "FieldSource" + #define PROPERTY_TABLENAME "TableName" + #define PROPERTY_ISFILTERAPPLIED "IsFilterApplied" + #define PROPERTY_CONTROLLABEL "LabelControl" + #define PROPERTY_CURRSYM_POSITION "PrependCurrencySymbol" + #define PROPERTY_CURSORCOLOR "CursorColor" + #define PROPERTY_ALWAYSSHOWCURSOR "AlwaysShowCursor" + #define PROPERTY_DISPLAYSYNCHRON "DisplayIsSynchron" + #define PROPERTY_TEXTCOLOR "TextColor" + #define PROPERTY_DELAY "RepeatDelay" + #define PROPERTY_DEFAULT_SCROLL_VALUE "DefaultScrollValue" + #define PROPERTY_SCROLL_VALUE "ScrollValue" + #define PROPERTY_DEFAULT_SPIN_VALUE "DefaultSpinValue" + #define PROPERTY_SPIN_VALUE "SpinValue" + #define PROPERTY_REFERENCE_DEVICE "ReferenceDevice" + #define PROPERTY_ISMODIFIED "IsModified" + #define PROPERTY_ISNEW "IsNew" + #define PROPERTY_PRIVILEGES "Privileges" + #define PROPERTY_COMMAND "Command" + #define PROPERTY_COMMANDTYPE "CommandType" + #define PROPERTY_RESULTSET_CONCURRENCY "ResultSetConcurrency" + #define PROPERTY_INSERTONLY "IgnoreResult" + #define PROPERTY_RESULTSET_TYPE "ResultSetType" + #define PROPERTY_ESCAPE_PROCESSING "EscapeProcessing" + #define PROPERTY_APPLYFILTER "ApplyFilter" + #define PROPERTY_ROWCOUNT "RowCount" + #define PROPERTY_ROWCOUNTFINAL "IsRowCountFinal" + + #define PROPERTY_ISNULLABLE "IsNullable" + #define PROPERTY_ACTIVECOMMAND "ActiveCommand" + #define PROPERTY_ISCURRENCY "IsCurrency" + #define PROPERTY_URL "URL" + #define PROPERTY_TITLE "Title" + #define PROPERTY_ACTIVE_CONNECTION "ActiveConnection" + #define PROPERTY_SCALE "Scale" + #define PROPERTY_SORT "Order" + #define PROPERTY_DATASOURCE "DataSourceName" + #define PROPERTY_DETAILFIELDS "DetailFields" + + #define PROPERTY_COLUMNSERVICENAME "ColumnServiceName" + #define PROPERTY_REALNAME "RealName" + #define PROPERTY_CONTROLSOURCEPROPERTY "DataFieldProperty" + #define PROPERTY_USER "User" + #define PROPERTY_PASSWORD "Password" + #define PROPERTY_DISPATCHURLINTERNAL "DispatchURLInternal" + #define PROPERTY_PERSISTENCE_MAXTEXTLENGTH "PersistenceMaxTextLength" + #define PROPERTY_RICH_TEXT "RichText" + #define PROPERTY_ENFORCE_FORMAT "EnforceFormat" + #define PROPERTY_LINEEND_FORMAT "LineEndFormat" + #define PROPERTY_WRITING_MODE "WritingMode" + #define PROPERTY_CONTEXT_WRITING_MODE "ContextWritingMode" + + #define PROPERTY_NATIVE_LOOK "NativeWidgetLook" + #define PROPERTY_BORDER "Border" + #define PROPERTY_BORDERCOLOR "BorderColor" + #define PROPERTY_BACKGROUNDCOLOR "BackgroundColor" + #define PROPERTY_ICONSIZE "IconSize" + #define PROPERTY_TEXTLINECOLOR "TextLineColor" + #define PROPERTY_HIDEINACTIVESELECTION "HideInactiveSelection" + + #define PROPERTY_SHOW_POSITION "ShowPosition" + #define PROPERTY_SHOW_NAVIGATION "ShowNavigation" + #define PROPERTY_SHOW_RECORDACTIONS "ShowRecordActions" + #define PROPERTY_SHOW_FILTERSORT "ShowFilterSort" + + #define PROPERTY_XSD_WHITESPACE "WhiteSpace" + #define PROPERTY_XSD_PATTERN "Pattern" + #define PROPERTY_XSD_LENGTH "Length" + #define PROPERTY_XSD_MIN_LENGTH "MinLength" + #define PROPERTY_XSD_MAX_LENGTH "MaxLength" + #define PROPERTY_XSD_TOTAL_DIGITS "TotalDigits" + #define PROPERTY_XSD_FRACTION_DIGITS "FractionDigits" + #define PROPERTY_XSD_MAX_INCLUSIVE_INT "MaxInclusiveInt" + #define PROPERTY_XSD_MAX_EXCLUSIVE_INT "MaxExclusiveInt" + #define PROPERTY_XSD_MIN_INCLUSIVE_INT "MinInclusiveInt" + #define PROPERTY_XSD_MIN_EXCLUSIVE_INT "MinExclusiveInt" + #define PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE "MaxInclusiveDouble" + #define PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE "MaxExclusiveDouble" + #define PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE "MinInclusiveDouble" + #define PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE "MinExclusiveDouble" + #define PROPERTY_XSD_MAX_INCLUSIVE_DATE "MaxInclusiveDate" + #define PROPERTY_XSD_MAX_EXCLUSIVE_DATE "MaxExclusiveDate" + #define PROPERTY_XSD_MIN_INCLUSIVE_DATE "MinInclusiveDate" + #define PROPERTY_XSD_MIN_EXCLUSIVE_DATE "MinExclusiveDate" + #define PROPERTY_XSD_MAX_INCLUSIVE_TIME "MaxInclusiveTime" + #define PROPERTY_XSD_MAX_EXCLUSIVE_TIME "MaxExclusiveTime" + #define PROPERTY_XSD_MIN_INCLUSIVE_TIME "MinInclusiveTime" + #define PROPERTY_XSD_MIN_EXCLUSIVE_TIME "MinExclusiveTime" + #define PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME "MaxInclusiveDateTime" + #define PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME "MaxExclusiveDateTime" + #define PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME "MinInclusiveDateTime" + #define PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME "MinExclusiveDateTime" + #define PROPERTY_XSD_IS_BASIC "IsBasic" + #define PROPERTY_XSD_TYPE_CLASS "TypeClass" + + #define PROPERTY_DYNAMIC_CONTROL_BORDER "DynamicControlBorder" + #define PROPERTY_CONTROL_BORDER_COLOR_FOCUS "ControlBorderColorOnFocus" + #define PROPERTY_CONTROL_BORDER_COLOR_MOUSE "ControlBorderColorOnHover" + #define PROPERTY_CONTROL_BORDER_COLOR_INVALID "ControlBorderColorOnInvalid" + #define PROPERTY_GENERATEVBAEVENTS "GenerateVbaEvents" + #define PROPERTY_CONTROL_TYPE_IN_MSO "ControlTypeinMSO" + #define PROPERTY_OBJ_ID_IN_MSO "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" + + +} // namespace frm + + +#endif // INCLUDED_FORMS_SOURCE_INC_FRM_STRINGS_HXX + +/* 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..5922fd6db --- /dev/null +++ b/forms/source/inc/limitedformats.hxx @@ -0,0 +1,97 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX +#define INCLUDED_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_LIMITEDFORMATS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/inc/listenercontainers.hxx b/forms/source/inc/listenercontainers.hxx new file mode 100644 index 000000000..7e67fa0c7 --- /dev/null +++ b/forms/source/inc/listenercontainers.hxx @@ -0,0 +1,113 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX +#define INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX + +#include <com/sun/star/form/XResetListener.hpp> +#include <comphelper/listenernotification.hxx> +#include <cppuhelper/weak.hxx> + + +namespace frm +{ + + template < class LISTENER > + class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject > + { + public: + typedef ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject > + EventListeners_Base; + + private: + ::cppu::OWeakObject& m_rInstigator; + + protected: + EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex ) + :EventListeners_Base( _rMutex ) + ,m_rInstigator( _rInstigator ) + { + } + + public: + bool notify() + { + css::lang::EventObject aEvent( m_rInstigator ); + return EventListeners_Base::notify( aEvent ); + } + + void disposing() + { + css::lang::EventObject aEvent( m_rInstigator ); + EventListeners_Base::disposing( aEvent ); + } + protected: + using EventListeners_Base::notify; + using EventListeners_Base::disposing; + }; + + typedef EventListeners < css::form::XResetListener + > ResetListeners_Base; + class ResetListeners : public ResetListeners_Base + { + private: + enum NotificationType + { + eApproval, + eFinal + }; + NotificationType m_eCurrentNotificationType; + + public: + ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex ) + :ResetListeners_Base( _rInstigator, _rMutex ) + ,m_eCurrentNotificationType( eApproval ) + { + } + + /** see whether all our listeners approve the reset + */ + bool approveReset() + { + m_eCurrentNotificationType = eApproval; + return notify(); + } + + /** tell all our listeners that the reset happened + */ + void resetted() + { + m_eCurrentNotificationType = eFinal; + notify(); + } + + protected: + virtual bool implTypedNotify( + const css::uno::Reference< css::form::XResetListener >& _rxListener, + const css::lang::EventObject& _rEvent + ) override; + }; + + +} // namespace frm + + +#endif // INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX + +/* 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..d4d3aecd2 --- /dev/null +++ b/forms/source/inc/property.hxx @@ -0,0 +1,435 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_PROPERTY_HXX +#define INCLUDED_FORMS_SOURCE_INC_PROPERTY_HXX + +#include <sal/config.h> + +#include <unordered_map> + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <comphelper/propagg.hxx> +#include <tools/debug.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) // dito +#define PROPERTY_ID_EFFECTIVE_MIN (PROPERTY_ID_START +159) // dito +#define PROPERTY_ID_EFFECTIVE_MAX (PROPERTY_ID_START +160) // dito +#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; +}; + + +#define DECL_PROP_IMPL(varname, type) \ + *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(), + + +#define DECL_BOOL_PROP_IMPL(varname) \ + *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<bool>::get(), + + +#define DECL_IFACE_PROP_IMPL(varname, type) \ + *pProperties++ = css::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cppu::UnoType<type>::get(), + + +#define BEGIN_DESCRIBE_PROPERTIES( count, baseclass ) \ + baseclass::describeFixedProperties( _rProps ); \ + sal_Int32 nOldCount = _rProps.getLength(); \ + _rProps.realloc( nOldCount + ( count ) ); \ + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; \ + + +#define BEGIN_DESCRIBE_BASE_PROPERTIES( count ) \ + _rProps.realloc( count ); \ + css::beans::Property* pProperties = _rProps.getArray(); \ + + +#define DECL_PROP0(varname, type) \ + DECL_PROP_IMPL(varname, type) 0) + + +#define DECL_PROP1(varname, type, attrib1) \ + DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1) + + +#define DECL_PROP2(varname, type, attrib1, attrib2) \ + DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) + + +#define DECL_PROP3(varname, type, attrib1, attrib2, attrib3) \ + DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3) + + +#define DECL_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ + DECL_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 | css::beans::PropertyAttribute::attrib4) + +// === some property types require special handling +// === such as interfaces + +#define DECL_IFACE_PROP2(varname, type, attrib1, attrib2) \ + DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) + + +#define DECL_IFACE_PROP3(varname, type, attrib1, attrib2, attrib3) \ + DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3) + + +#define DECL_IFACE_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ + DECL_IFACE_PROP_IMPL(varname, type) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 | PropertyAttribute::attrib4) + +// === or Boolean properties + +#define DECL_BOOL_PROP1(varname, attrib1) \ + DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1) + + +#define DECL_BOOL_PROP2(varname, attrib1, attrib2) \ + DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2) + + +#define DECL_BOOL_PROP3( varname, attrib1, attrib2, attrib3 ) \ + DECL_BOOL_PROP_IMPL(varname) css::beans::PropertyAttribute::attrib1 | css::beans::PropertyAttribute::attrib2 | css::beans::PropertyAttribute::attrib3 ) + + +#define END_DESCRIBE_PROPERTIES() \ + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); \ + + +#define REGISTER_PROP_2( prop, member, attrib1, attrib2 ) \ + registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ + &member, cppu::UnoType<decltype(member)>::get() ); + +#define REGISTER_PROP_3( prop, member, attrib1, attrib2, attrib3 ) \ + registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2 | PropertyAttribute::attrib3, \ + &member, cppu::UnoType<decltype(member)>::get() ); + + +#define REGISTER_VOID_PROP_2( prop, memberAny, type, attrib1, attrib2 ) \ + registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ + &memberAny, cppu::UnoType<type>::get() ); + + +} +//... namespace frm ....................................................... + +#endif // INCLUDED_FORMS_SOURCE_INC_PROPERTY_HXX + +/* 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..0e93500ad --- /dev/null +++ b/forms/source/inc/propertybaghelper.hxx @@ -0,0 +1,150 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX +#define INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX + +/* 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..11a2db897 --- /dev/null +++ b/forms/source/inc/resettable.hxx @@ -0,0 +1,65 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_RESETTABLE_HXX +#define INCLUDED_FORMS_SOURCE_INC_RESETTABLE_HXX + +#include <com/sun/star/form/XResetListener.hpp> + +#include <comphelper/interfacecontainer2.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::OInterfaceContainerHelper2 m_aResetListeners; + }; + + +} // namespace frm + + +#endif // INCLUDED_FORMS_SOURCE_INC_RESETTABLE_HXX + +/* 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..8a3312b30 --- /dev/null +++ b/forms/source/inc/services.hxx @@ -0,0 +1,204 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_SERVICES_HXX +#define INCLUDED_FORMS_SOURCE_INC_SERVICES_HXX + +#define AWT_CONTROL_TEXTFIELD "com.sun.star.awt.TextField" + +#define VCL_CONTROL_EDIT "stardiv.vcl.control.Edit" +#define VCL_CONTROL_LISTBOX "stardiv.vcl.control.ListBox" +#define VCL_CONTROL_COMBOBOX "stardiv.vcl.control.ComboBox" +#define VCL_CONTROL_RADIOBUTTON "stardiv.vcl.control.RadioButton" +#define VCL_CONTROL_GROUPBOX "stardiv.vcl.control.GroupBox" +#define VCL_CONTROL_FIXEDTEXT "stardiv.vcl.control.FixedText" +#define VCL_CONTROL_COMMANDBUTTON "stardiv.vcl.control.Button" +#define VCL_CONTROL_CHECKBOX "stardiv.vcl.control.CheckBox" +#define VCL_CONTROL_IMAGEBUTTON "stardiv.vcl.control.ImageButton" +#define VCL_CONTROL_FILECONTROL "stardiv.vcl.control.FileControl" +#define VCL_CONTROL_TIMEFIELD "stardiv.vcl.control.TimeField" +#define VCL_CONTROL_DATEFIELD "stardiv.vcl.control.DateField" +#define VCL_CONTROL_NUMERICFIELD "stardiv.vcl.control.NumericField" +#define VCL_CONTROL_CURRENCYFIELD "stardiv.vcl.control.CurrencyField" +#define VCL_CONTROL_PATTERNFIELD "stardiv.vcl.control.PatternField" +#define VCL_CONTROL_FORMATTEDFIELD "stardiv.vcl.control.FormattedField" +#define VCL_CONTROL_IMAGECONTROL "stardiv.vcl.control.ImageControl" + +#define VCL_CONTROLMODEL_EDIT "stardiv.vcl.controlmodel.Edit" +#define VCL_CONTROLMODEL_LISTBOX "stardiv.vcl.controlmodel.ListBox" +#define VCL_CONTROLMODEL_COMBOBOX "stardiv.vcl.controlmodel.ComboBox" +#define VCL_CONTROLMODEL_RADIOBUTTON "stardiv.vcl.controlmodel.RadioButton" +#define VCL_CONTROLMODEL_GROUPBOX "stardiv.vcl.controlmodel.GroupBox" +#define VCL_CONTROLMODEL_FIXEDTEXT "stardiv.vcl.controlmodel.FixedText" +#define VCL_CONTROLMODEL_COMMANDBUTTON "stardiv.vcl.controlmodel.Button" +#define VCL_CONTROLMODEL_CHECKBOX "stardiv.vcl.controlmodel.CheckBox" +#define VCL_CONTROLMODEL_IMAGEBUTTON "stardiv.vcl.controlmodel.ImageButton" +#define VCL_CONTROLMODEL_FILECONTROL "stardiv.vcl.controlmodel.FileControl" +#define VCL_CONTROLMODEL_TIMEFIELD "stardiv.vcl.controlmodel.TimeField" +#define VCL_CONTROLMODEL_DATEFIELD "stardiv.vcl.controlmodel.DateField" +#define VCL_CONTROLMODEL_NUMERICFIELD "stardiv.vcl.controlmodel.NumericField" +#define VCL_CONTROLMODEL_CURRENCYFIELD "stardiv.vcl.controlmodel.CurrencyField" +#define VCL_CONTROLMODEL_PATTERNFIELD "stardiv.vcl.controlmodel.PatternField" +#define VCL_CONTROLMODEL_FORMATTEDFIELD "stardiv.vcl.controlmodel.FormattedField" +#define VCL_CONTROLMODEL_IMAGECONTROL "stardiv.vcl.controlmodel.ImageControl" + +#define VCL_CONTROLMODEL_SCROLLBAR "com.sun.star.awt.UnoControlScrollBarModel" +#define VCL_CONTROL_SCROLLBAR "com.sun.star.awt.UnoControlScrollBar" +#define VCL_CONTROLMODEL_SPINBUTTON "com.sun.star.awt.UnoControlSpinButtonModel" +#define VCL_CONTROL_SPINBUTTON "com.sun.star.awt.UnoControlSpinButton" + +// service names for compatibility + +#define FRM_COMPONENT_FORM "stardiv.one.form.component.Form" +#define FRM_COMPONENT_EDIT "stardiv.one.form.component.Edit" // compatibility +#define FRM_COMPONENT_TEXTFIELD "stardiv.one.form.component.TextField" +#define FRM_COMPONENT_LISTBOX "stardiv.one.form.component.ListBox" +#define FRM_COMPONENT_COMBOBOX "stardiv.one.form.component.ComboBox" +#define FRM_COMPONENT_RADIOBUTTON "stardiv.one.form.component.RadioButton" +#define FRM_COMPONENT_GROUPBOX "stardiv.one.form.component.GroupBox" // compatibility +#define FRM_COMPONENT_FIXEDTEXT "stardiv.one.form.component.FixedText" // compatibility +#define FRM_COMPONENT_COMMANDBUTTON "stardiv.one.form.component.CommandButton" +#define FRM_COMPONENT_CHECKBOX "stardiv.one.form.component.CheckBox" +#define FRM_COMPONENT_GRID "stardiv.one.form.component.Grid" // compatibility +#define FRM_COMPONENT_GRIDCONTROL "stardiv.one.form.component.GridControl" +#define FRM_COMPONENT_IMAGEBUTTON "stardiv.one.form.component.ImageButton" +#define FRM_COMPONENT_FILECONTROL "stardiv.one.form.component.FileControl" +#define FRM_COMPONENT_TIMEFIELD "stardiv.one.form.component.TimeField" +#define FRM_COMPONENT_DATEFIELD "stardiv.one.form.component.DateField" +#define FRM_COMPONENT_NUMERICFIELD "stardiv.one.form.component.NumericField" +#define FRM_COMPONENT_CURRENCYFIELD "stardiv.one.form.component.CurrencyField" +#define FRM_COMPONENT_PATTERNFIELD "stardiv.one.form.component.PatternField" +#define FRM_COMPONENT_HIDDEN "stardiv.one.form.component.Hidden" +#define FRM_COMPONENT_HIDDENCONTROL "stardiv.one.form.component.HiddenControl" +#define FRM_COMPONENT_IMAGECONTROL "stardiv.one.form.component.ImageControl" +#define FRM_COMPONENT_FORMATTEDFIELD "stardiv.one.form.component.FormattedField" + +// <compatibility_I> +#define STARDIV_ONE_FORM_CONTROL_COMMANDBUTTON "stardiv.one.form.control.CommandButton" +#define STARDIV_ONE_FORM_CONTROL_RADIOBUTTON "stardiv.one.form.control.RadioButton" +#define STARDIV_ONE_FORM_CONTROL_CHECKBOX "stardiv.one.form.control.CheckBox" +#define STARDIV_ONE_FORM_CONTROL_EDIT "stardiv.one.form.control.Edit" +#define STARDIV_ONE_FORM_CONTROL_LISTBOX "stardiv.one.form.control.ListBox" +#define STARDIV_ONE_FORM_CONTROL_COMBOBOX "stardiv.one.form.control.ComboBox" +#define STARDIV_ONE_FORM_CONTROL_GROUPBOX "stardiv.one.form.control.GroupBox" +#define STARDIV_ONE_FORM_CONTROL_TEXTFIELD "stardiv.one.form.control.TextField" +#define STARDIV_ONE_FORM_CONTROL_GRID "stardiv.one.form.control.Grid" +#define STARDIV_ONE_FORM_CONTROL_IMAGEBUTTON "stardiv.one.form.control.ImageButton" +#define STARDIV_ONE_FORM_CONTROL_TIMEFIELD "stardiv.one.form.control.TimeField" +#define STARDIV_ONE_FORM_CONTROL_DATEFIELD "stardiv.one.form.control.DateField" +#define STARDIV_ONE_FORM_CONTROL_NUMERICFIELD "stardiv.one.form.control.NumericField" +#define STARDIV_ONE_FORM_CONTROL_CURRENCYFIELD "stardiv.one.form.control.CurrencyField" +#define STARDIV_ONE_FORM_CONTROL_PATTERNFIELD "stardiv.one.form.control.PatternField" +#define STARDIV_ONE_FORM_CONTROL_IMAGECONTROL "stardiv.one.form.control.ImageControl" +#define STARDIV_ONE_FORM_CONTROL_FORMATTEDFIELD "stardiv.one.form.control.FormattedField" +// </compatibility_I> + +// new (sun) service names + +#define FRM_SUN_COMPONENT_FORM "com.sun.star.form.component.Form" +#define FRM_SUN_COMPONENT_HTMLFORM "com.sun.star.form.component.HTMLForm" +#define FRM_SUN_COMPONENT_DATAFORM "com.sun.star.form.component.DataForm" +#define FRM_SUN_COMPONENT_TEXTFIELD "com.sun.star.form.component.TextField" +#define FRM_SUN_COMPONENT_LISTBOX "com.sun.star.form.component.ListBox" +#define FRM_SUN_COMPONENT_COMBOBOX "com.sun.star.form.component.ComboBox" +#define FRM_SUN_COMPONENT_RADIOBUTTON "com.sun.star.form.component.RadioButton" +#define FRM_SUN_COMPONENT_GROUPBOX "com.sun.star.form.component.GroupBox" +#define FRM_SUN_COMPONENT_FIXEDTEXT "com.sun.star.form.component.FixedText" +#define FRM_SUN_COMPONENT_COMMANDBUTTON "com.sun.star.form.component.CommandButton" +#define FRM_SUN_COMPONENT_CHECKBOX "com.sun.star.form.component.CheckBox" +#define FRM_SUN_COMPONENT_GRIDCONTROL "com.sun.star.form.component.GridControl" +#define FRM_SUN_COMPONENT_IMAGEBUTTON "com.sun.star.form.component.ImageButton" +#define FRM_SUN_COMPONENT_FILECONTROL "com.sun.star.form.component.FileControl" +#define FRM_SUN_COMPONENT_TIMEFIELD "com.sun.star.form.component.TimeField" +#define FRM_SUN_COMPONENT_DATEFIELD "com.sun.star.form.component.DateField" +#define FRM_SUN_COMPONENT_NUMERICFIELD "com.sun.star.form.component.NumericField" +#define FRM_SUN_COMPONENT_CURRENCYFIELD "com.sun.star.form.component.CurrencyField" +#define FRM_SUN_COMPONENT_PATTERNFIELD "com.sun.star.form.component.PatternField" +#define FRM_SUN_COMPONENT_HIDDENCONTROL "com.sun.star.form.component.HiddenControl" +#define FRM_SUN_COMPONENT_FORMATTEDFIELD "com.sun.star.form.component.FormattedField" +#define FRM_SUN_COMPONENT_SCROLLBAR "com.sun.star.form.component.ScrollBar" +#define FRM_SUN_COMPONENT_SPINBUTTON "com.sun.star.form.component.SpinButton" +#define FRM_SUN_COMPONENT_RICHTEXTCONTROL "com.sun.star.form.component.RichTextControl" +#define FRM_SUN_COMPONENT_NAVTOOLBAR "com.sun.star.form.component.NavigationToolBar" +#define FRM_SUN_COMPONENT_SUBMITBUTTON "com.sun.star.form.component.SubmitButton" + +#define FRM_SUN_COMPONENT_IMAGECONTROL "com.sun.star.form.component.DatabaseImageControl" +#define FRM_SUN_COMPONENT_DATABASE_RADIOBUTTON "com.sun.star.form.component.DatabaseRadioButton" +#define FRM_SUN_COMPONENT_DATABASE_CHECKBOX "com.sun.star.form.component.DatabaseCheckBox" +#define FRM_SUN_COMPONENT_DATABASE_LISTBOX "com.sun.star.form.component.DatabaseListBox" +#define FRM_SUN_COMPONENT_DATABASE_COMBOBOX "com.sun.star.form.component.DatabaseComboBox" +#define FRM_SUN_COMPONENT_DATABASE_FORMATTEDFIELD "com.sun.star.form.component.DatabaseFormattedField" +#define FRM_SUN_COMPONENT_DATABASE_TEXTFIELD "com.sun.star.form.component.DatabaseTextField" +#define FRM_SUN_COMPONENT_DATABASE_DATEFIELD "com.sun.star.form.component.DatabaseDateField" +#define FRM_SUN_COMPONENT_DATABASE_TIMEFIELD "com.sun.star.form.component.DatabaseTimeField" +#define FRM_SUN_COMPONENT_DATABASE_NUMERICFIELD "com.sun.star.form.component.DatabaseNumericField" +#define FRM_SUN_COMPONENT_DATABASE_CURRENCYFIELD "com.sun.star.form.component.DatabaseCurrencyField" +#define FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD "com.sun.star.form.component.DatabasePatternField" + +#define FRM_SUN_CONTROL_TEXTFIELD "com.sun.star.form.control.TextField" +#define FRM_SUN_CONTROL_LISTBOX "com.sun.star.form.control.ListBox" +#define FRM_SUN_CONTROL_COMBOBOX "com.sun.star.form.control.ComboBox" +#define FRM_SUN_CONTROL_RADIOBUTTON "com.sun.star.form.control.RadioButton" +#define FRM_SUN_CONTROL_GROUPBOX "com.sun.star.form.control.GroupBox" +#define FRM_SUN_CONTROL_FIXEDTEXT "com.sun.star.form.control.FixedText" +#define FRM_SUN_CONTROL_COMMANDBUTTON "com.sun.star.form.control.CommandButton" +#define FRM_SUN_CONTROL_CHECKBOX "com.sun.star.form.control.CheckBox" +#define FRM_SUN_CONTROL_GRIDCONTROL "com.sun.star.form.control.GridControl" +#define FRM_SUN_CONTROL_IMAGEBUTTON "com.sun.star.form.control.ImageButton" +#define FRM_SUN_CONTROL_TIMEFIELD "com.sun.star.form.control.TimeField" +#define FRM_SUN_CONTROL_DATEFIELD "com.sun.star.form.control.DateField" +#define FRM_SUN_CONTROL_NUMERICFIELD "com.sun.star.form.control.NumericField" +#define FRM_SUN_CONTROL_CURRENCYFIELD "com.sun.star.form.control.CurrencyField" +#define FRM_SUN_CONTROL_PATTERNFIELD "com.sun.star.form.control.PatternField" +#define FRM_SUN_CONTROL_IMAGECONTROL "com.sun.star.form.control.ImageControl" +#define FRM_SUN_CONTROL_FORMATTEDFIELD "com.sun.star.form.control.FormattedField" +#define FRM_SUN_CONTROL_RICHTEXTCONTROL "com.sun.star.form.control.RichTextControl" +#define FRM_SUN_CONTROL_SUBMITBUTTON "com.sun.star.form.control.SubmitButton" + +#define BINDABLE_DATABASE_CHECK_BOX "com.sun.star.form.binding.BindableDatabaseCheckBox" +#define BINDABLE_DATABASE_COMBO_BOX "com.sun.star.form.binding.BindableDatabaseComboBox" +#define BINDABLE_DATABASE_FORMATTED_FIELD "com.sun.star.form.binding.BindableDatabaseFormattedField" +#define BINDABLE_DATABASE_LIST_BOX "com.sun.star.form.binding.BindableDatabaseListBox" +#define BINDABLE_DATABASE_NUMERIC_FIELD "com.sun.star.form.binding.BindableDatabaseNumericField" +#define BINDABLE_DATABASE_RADIO_BUTTON "com.sun.star.form.binding.BindableDatabaseRadioButton" +#define BINDABLE_DATABASE_TEXT_FIELD "com.sun.star.form.binding.BindableDatabaseTextField" +#define BINDABLE_DATABASE_DATE_FIELD "com.sun.star.form.binding.BindableDatabaseDateField" +#define BINDABLE_DATABASE_TIME_FIELD "com.sun.star.form.binding.BindableDatabaseTimeField" + +#define BINDABLE_CONTROL_MODEL "com.sun.star.form.binding.BindableControlModel" +#define BINDABLE_INTEGER_VALUE_RANGE "com.sun.star.form.binding.BindableIntegerValueRange" +#define BINDABLE_DATA_AWARE_CONTROL_MODEL "com.sun.star.form.binding.BindableDataAwareControlModel" +#define DATA_AWARE_CONTROL_MODEL "com.sun.star.form.binding.DataAwareControlModel" +#define VALIDATABLE_CONTROL_MODEL "com.sun.star.form.binding.ValidatableControlModel" +#define VALIDATABLE_BINDABLE_CONTROL_MODEL "com.sun.star.form.binding.ValidatableBindableControlModel" + +// common + +#define FRM_SUN_FORMCOMPONENT "com.sun.star.form.FormComponent" + +// misc + +#define SRV_AWT_IMAGEPRODUCER "com.sun.star.awt.ImageProducer" + +#define SRV_SDB_ROWSET "com.sun.star.sdb.RowSet" +#define SRV_SDB_CONNECTION "com.sun.star.sdb.Connection" + +#endif // INCLUDED_FORMS_SOURCE_INC_SERVICES_HXX + +/* 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..d02032ea8 --- /dev/null +++ b/forms/source/inc/togglestate.hxx @@ -0,0 +1,36 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_TOGGLESTATE_HXX +#define INCLUDED_FORMS_SOURCE_INC_TOGGLESTATE_HXX + + +namespace frm +{ + + + enum ToggleState { TRISTATE_FALSE = 0, TRISTATE_TRUE = 1, TRISTATE_INDET = 2 }; + + +} // namespace frm + + +#endif // INCLUDED_FORMS_SOURCE_INC_TOGGLESTATE_HXX + +/* 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..3db4d79ca --- /dev/null +++ b/forms/source/inc/urltransformer.hxx @@ -0,0 +1,73 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_URLTRANSFORMER_HXX +#define INCLUDED_FORMS_SOURCE_INC_URLTRANSFORMER_HXX + +#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 protocol given by ASCII string + */ + void + parseSmartWithAsciiProtocol( css::util::URL& _rURL, const char* _pAsciiURL ) 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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_URLTRANSFORMER_HXX + +/* 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..6d1f94554 --- /dev/null +++ b/forms/source/inc/windowstateguard.hxx @@ -0,0 +1,73 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_FORMS_SOURCE_INC_WINDOWSTATEGUARD_HXX +#define INCLUDED_FORMS_SOURCE_INC_WINDOWSTATEGUARD_HXX + +#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 + + +#endif // INCLUDED_FORMS_SOURCE_INC_WINDOWSTATEGUARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |