diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-29 15:26:37 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-29 15:26:37 +0000 |
commit | fb9f2b25462585f6c18087b681f0b5d029b01113 (patch) | |
tree | 3a0eaf9e40aa247387d666998aaf7411f0225308 /forms | |
parent | 51a09373ea2bccf70994cc48449d18fb5a9b7820 (diff) | |
parent | 3e2f5ba7b8f50e009ea6e457b97447af2e090a80 (diff) |
ab71: merge with DEV300_m54
Diffstat (limited to 'forms')
52 files changed, 2161 insertions, 1343 deletions
diff --git a/forms/prj/build.lst b/forms/prj/build.lst index 4393408051d7..3a4182b82c99 100644 --- a/forms/prj/build.lst +++ b/forms/prj/build.lst @@ -1,4 +1,4 @@ -fm forms : svx sfx2 ucb configmgr fileaccess QADEVOOO:qadevOOo NULL +fm forms : l10n svx sfx2 ucb configmgr fileaccess QADEVOOO:qadevOOo NULL fm forms usr1 - all fm_mkofrm NULL fm forms\inc nmake - all fm_inc NULL fm forms\source\inc get - all fm_sinc NULL diff --git a/forms/qa/integration/forms/ShowTargets.java b/forms/qa/integration/forms/ShowTargets.java deleted file mode 100644 index 3c747adfb2bc..000000000000 --- a/forms/qa/integration/forms/ShowTargets.java +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ShowTargets.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package integration.forms; - -/** - * - * @author fs93730 - */ -public class ShowTargets -{ - /** Creates a new instance of ShowTargets */ - public ShowTargets() - { - } - - public static void main( String[] args ) - { - System.out.println( "possible targets (* denotes a test case which requires user interaction):" ); - System.out.println( " run" ); - - for ( int i = 0; i < args.length; ++i ) - { - // filter - if ( args[i].equals( "TestCase" ) ) - continue; - if ( args[i].equals( "TestSkeleton" ) ) - continue; - - String completePotentialClassName = args[i].replace( '/', '.' ); - - // get the class - Class potentialTestClass = null; - try { potentialTestClass = Class.forName( completePotentialClassName ); } - catch( java.lang.ClassNotFoundException e ) - { - continue; - } - - // see if it is derived from complexlib.ComplexTestCase - Class superClass = potentialTestClass.getSuperclass(); - while ( superClass != null ) - { - if ( superClass.getName().equals( "complexlib.ComplexTestCase" ) ) - { - if ( isInteractiveTest( potentialTestClass ) ) - System.out.print( "* " ); - else - System.out.print( " " ); - System.out.println( "run_" + args[i] ); - } - superClass = superClass.getSuperclass(); - } - } - } - - /** determines if the test denoted by a given Class is an interactive test - */ - static private boolean isInteractiveTest( Class testClass ) - { - java.lang.reflect.Method interactiveTestMethod = null; - try { interactiveTestMethod = testClass.getMethod( "isInteractiveTest", new Class[]{} ); } - catch( Exception e ) { } - - if ( interactiveTestMethod != null ) - { - try - { - Boolean result = (Boolean)interactiveTestMethod.invoke( null, new Object[]{} ); - return result.booleanValue(); - } - catch( Exception e ) { } - } - return false; - } -} diff --git a/forms/qa/makefile.mk b/forms/qa/makefile.mk index 7be518dc063b..822f67e1bb46 100644 --- a/forms/qa/makefile.mk +++ b/forms/qa/makefile.mk @@ -56,7 +56,7 @@ JARCOMPRESS = TRUE # --- Runner Settings ---------------------------------------------- # classpath and argument list -RUNNER_CLASSPATH = -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar$(PATH_SEPERATOR)$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/ConnectivityTools.jar +RUNNER_CLASSPATH = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar$(PATH_SEPERATOR)$(SOLARBINDIR)$/ConnectivityTools.jar" RUNNER_ARGS = org.openoffice.Runner -TestBase java_complex .END @@ -75,7 +75,7 @@ ALL: ALLDEP .IF "$(BUILD_QADEVOOO)" == "YES" show_targets: - +@java $(RUNNER_CLASSPATH) integration.forms.ShowTargets $(foreach,i,$(JAVAFILES) $(i:s/.\$///:s/.java//)) + +@java $(RUNNER_CLASSPATH) complexlib.ShowTargets $(foreach,i,$(JAVAFILES) $(i:s/.\$///:s/.java//)) run: +$(COPY) integration$/forms$/*.props $(CLASSDIR)$/$(PACKAGE) && java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce forms_all.sce diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 5b41b825ff9c..8907dcd82712 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -30,14 +30,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" + #include "Button.hxx" + +#include <com/sun/star/awt/XVclWindowPeer.hpp> + +#include <comphelper/streamsection.hxx> +#include <comphelper/basicio.hxx> +#include <tools/diagnose_ex.h> #include <tools/debug.hxx> #include <tools/urlobj.hxx> -#include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <comphelper/streamsection.hxx> -#include <comphelper/basicio.hxx> -#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <vos/mutex.hxx> //......................................................................... namespace frm @@ -71,16 +75,40 @@ InterfaceRef SAL_CALL OButtonModel_CreateInstance(const Reference<XMultiServiceF OButtonModel::OButtonModel(const Reference<XMultiServiceFactory>& _rxFactory) :OClickableImageBaseModel( _rxFactory, VCL_CONTROLMODEL_COMMANDBUTTON, FRM_SUN_CONTROL_COMMANDBUTTON ) // use the old control name for compatibility reasons + ,m_aResetHelper( *this, m_aMutex ) + ,m_eDefaultState( STATE_NOCHECK ) { DBG_CTOR( OButtonModel, NULL ); m_nClassId = FormComponentType::COMMANDBUTTON; } //------------------------------------------------------------------ +Any SAL_CALL OButtonModel::queryAggregation( const Type& _type ) throw(RuntimeException) +{ + Any aReturn = OClickableImageBaseModel::queryAggregation( _type ); + if ( !aReturn.hasValue() ) + aReturn = OButtonModel_Base::queryInterface( _type ); + return aReturn; +} + +//------------------------------------------------------------------ +Sequence< Type > OButtonModel::_getTypes() +{ + return ::comphelper::concatSequences( + OClickableImageBaseModel::_getTypes(), + OButtonModel_Base::getTypes() + ); +} + +//------------------------------------------------------------------ OButtonModel::OButtonModel( const OButtonModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OClickableImageBaseModel( _pOriginal, _rxFactory ) + ,m_aResetHelper( *this, m_aMutex ) + ,m_eDefaultState( _pOriginal->m_eDefaultState ) { DBG_CTOR( OButtonModel, NULL ); + m_nClassId = FormComponentType::COMMANDBUTTON; + implInitializeImageURL(); } @@ -93,12 +121,13 @@ OButtonModel::~OButtonModel() //------------------------------------------------------------------------------ void OButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 5, OClickableImageBaseModel ) - DECL_PROP1(BUTTONTYPE, FormButtonType, BOUND); - DECL_PROP1(DISPATCHURLINTERNAL, sal_Bool, BOUND); - DECL_PROP1(TARGET_URL, ::rtl::OUString, BOUND); - DECL_PROP1(TARGET_FRAME, ::rtl::OUString, BOUND); - DECL_PROP1(TABINDEX, sal_Int16, BOUND); + BEGIN_DESCRIBE_PROPERTIES( 6, OClickableImageBaseModel ) + DECL_PROP1( BUTTONTYPE, FormButtonType, BOUND ); + DECL_PROP1( DEFAULT_STATE, sal_Int16, BOUND ); + DECL_PROP1( DISPATCHURLINTERNAL, sal_Bool, BOUND ); + DECL_PROP1( TARGET_URL, ::rtl::OUString, BOUND ); + DECL_PROP1( TARGET_FRAME, ::rtl::OUString, BOUND ); + DECL_PROP1( TABINDEX, sal_Int16, BOUND ); END_DESCRIBE_PROPERTIES(); } @@ -205,6 +234,118 @@ void OButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw } } +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::disposing() +{ + m_aResetHelper.disposing(); + OClickableImageBaseModel::disposing(); +} + +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::reset() throw (RuntimeException) +{ + if ( !m_aResetHelper.approveReset() ) + return; + + impl_resetNoBroadcast_nothrow(); + + m_aResetHelper.notifyResetted(); +} + +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::addResetListener( const Reference< XResetListener >& _listener ) throw (RuntimeException) +{ + m_aResetHelper.addResetListener( _listener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::removeResetListener( const Reference< XResetListener >& _listener ) throw (RuntimeException) +{ + m_aResetHelper.removeResetListener( _listener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const +{ + switch ( _nHandle ) + { + case PROPERTY_ID_DEFAULT_STATE: + _rValue <<= (sal_Int16)m_eDefaultState; + break; + + default: + OClickableImageBaseModel::getFastPropertyValue( _rValue, _nHandle ); + break; + } +} + +//-------------------------------------------------------------------- +void SAL_CALL OButtonModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw (Exception) +{ + switch ( _nHandle ) + { + case PROPERTY_ID_DEFAULT_STATE: + { + sal_Int16 nDefaultState( (sal_Int16)STATE_NOCHECK ); + OSL_VERIFY( _rValue >>= nDefaultState ); + m_eDefaultState = (ToggleState)nDefaultState; + impl_resetNoBroadcast_nothrow(); + } + break; + + default: + OClickableImageBaseModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + break; + } +} + +//-------------------------------------------------------------------- +sal_Bool SAL_CALL OButtonModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) throw (IllegalArgumentException) +{ + sal_Bool bModified = sal_False; + switch ( _nHandle ) + { + case PROPERTY_ID_DEFAULT_STATE: + bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_eDefaultState ); + break; + + default: + bModified = OClickableImageBaseModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue ); + break; + } + return bModified; +} + +//-------------------------------------------------------------------- +Any OButtonModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const +{ + Any aDefault; + switch ( _nHandle ) + { + case PROPERTY_ID_DEFAULT_STATE: + aDefault <<= (sal_Int16)STATE_NOCHECK; + break; + + default: + aDefault = OClickableImageBaseModel::getPropertyDefaultByHandle( _nHandle ); + break; + } + return aDefault; +} + +//-------------------------------------------------------------------- +void OButtonModel::impl_resetNoBroadcast_nothrow() +{ + try + { + setPropertyValue( PROPERTY_STATE, getPropertyValue( PROPERTY_DEFAULT_STATE ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + //================================================================== // OButtonControl //================================================================== @@ -555,7 +696,7 @@ sal_Int32 OButtonControl::getModelUrlFeatureId( ) const // is it a feature URL? if ( isFormControllerURL( sUrl ) ) { - OFormNavigationMapper aMapper( getORB() ); + OFormNavigationMapper aMapper( m_aContext.getLegacyServiceFactory() ); nFeatureId = aMapper.getFeatureId( sUrl ); } } diff --git a/forms/source/component/Button.hxx b/forms/source/component/Button.hxx index 038f5b1e8aec..5bbb7f387f85 100644 --- a/forms/source/component/Button.hxx +++ b/forms/source/component/Button.hxx @@ -32,13 +32,19 @@ #define _FRM_BUTTON_HXX_ #include "clickableimage.hxx" +#include "togglestate.hxx" +#include "formnavigation.hxx" +#include "resettable.hxx" + #include <com/sun/star/awt/MouseEvent.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/awt/ActionEvent.hpp> #include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/awt/XButton.hpp> +#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/beans/PropertyChangeEvent.hpp> -#include "formnavigation.hxx" + +#include <cppuhelper/implbase1.hxx> //......................................................................... namespace frm @@ -48,12 +54,20 @@ namespace frm //================================================================== // OButtonModel //================================================================== -class OButtonModel - :public OClickableImageBaseModel +typedef ::cppu::ImplHelper1 < ::com::sun::star::form::XReset + > OButtonModel_Base; +class OButtonModel :public OClickableImageBaseModel + ,public OButtonModel_Base { public: DECLARE_DEFAULT_LEAF_XTOR( OButtonModel ); + // UNO + DECLARE_UNO3_AGG_DEFAULTS( OButtonModel, OClickableImageBaseModel ); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); + // ::com::sun::star::lang::XServiceInfo IMPLEMENTATION_NAME(OButtonModel); virtual StringSequence SAL_CALL getSupportedServiceNames() throw(); @@ -63,13 +77,44 @@ public: virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + // XReset + virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + // OControlModel's property handling virtual void describeFixedProperties( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps ) const; + // XPropertySet and friends + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const; + + // OComponentHelper + virtual void SAL_CALL disposing(); + protected: DECLARE_XCLONEABLE(); + +private: + void impl_resetNoBroadcast_nothrow(); + + using ::cppu::OPropertySetHelper::getFastPropertyValue; + +private: + ResetHelper m_aResetHelper; + + // <properties> + ToggleState m_eDefaultState; // the default check state + // </properties> +protected: + using OClickableImageBaseModel::disposing; }; //================================================================== diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx index a8086d39b597..8e66ebc60ab6 100644 --- a/forms/source/component/CheckBox.cxx +++ b/forms/source/component/CheckBox.cxx @@ -209,7 +209,7 @@ void SAL_CALL OCheckBoxModel::read(const Reference<stario::XObjectInputStream>& break; } setReferenceValue( sReferenceValue ); - setDefaultChecked( static_cast< CheckState >( nDefaultChecked ) ); + setDefaultChecked( static_cast< ToggleState >( nDefaultChecked ) ); // Nach dem Lesen die Defaultwerte anzeigen if ( getControlSource().getLength() ) diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index fae95b36f180..c307783f179b 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -204,11 +204,11 @@ Any SAL_CALL OGridColumn::queryAggregation( const Type& _rType ) throw (RuntimeE DBG_NAME(OGridColumn); //------------------------------------------------------------------------------ -OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName) +OGridColumn::OGridColumn( const comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName ) :OGridColumn_BASE(m_aMutex) ,OPropertySetAggregationHelper(OGridColumn_BASE::rBHelper) ,m_aHidden( makeAny( sal_False ) ) - ,m_xORB( _rxFactory ) + ,m_aContext( _rContext ) ,m_aModelName(_sModelName) { DBG_CTOR(OGridColumn,NULL); @@ -218,15 +218,13 @@ OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, cons { increment( m_refCount ); - // Muss im eigenen Block, - // da xAgg vor dem delegator setzen wieder freigesetzt sein muss! { - m_xAggregate = Reference< XAggregation >( _rxFactory->createInstance( m_aModelName ), UNO_QUERY ); + m_xAggregate.set( m_aContext.createComponent( m_aModelName ), UNO_QUERY ); setAggregation( m_xAggregate ); } - if (m_xAggregate.is()) - { // don't omit this brackets - they ensure that the following temporary is properly deleted + if ( m_xAggregate.is() ) + { // don't omit those brackets - they ensure that the following temporary is properly deleted m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) ); } @@ -239,7 +237,7 @@ OGridColumn::OGridColumn(const Reference<XMultiServiceFactory>& _rxFactory, cons OGridColumn::OGridColumn( const OGridColumn* _pOriginal ) :OGridColumn_BASE( m_aMutex ) ,OPropertySetAggregationHelper( OGridColumn_BASE::rBHelper ) - ,m_xORB( _pOriginal->m_xORB ) + ,m_aContext( _pOriginal->m_aContext ) { DBG_CTOR(OGridColumn,NULL); @@ -283,13 +281,6 @@ OGridColumn::~OGridColumn() DBG_DTOR(OGridColumn,NULL); } -// XChild -//------------------------------------------------------------------------------ -void SAL_CALL OGridColumn::setParent(const InterfaceRef& Parent) throw(NoSupportException, RuntimeException) -{ - m_xParent = Parent; -} - // XEventListener //------------------------------------------------------------------------------ void SAL_CALL OGridColumn::disposing(const EventObject& _rSource) throw(RuntimeException) @@ -311,8 +302,6 @@ void OGridColumn::disposing() Reference<XComponent> xComp; if (query_aggregation(m_xAggregate, xComp)) xComp->dispose(); - - setParent(InterfaceRef ()); } //------------------------------------------------------------------------------ @@ -356,6 +345,7 @@ void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, sal_B aForbiddenProperties.insert( PROPERTY_VERTICALALIGN ); aForbiddenProperties.insert( PROPERTY_IMAGE_URL ); aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION ); + aForbiddenProperties.insert( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) ); if ( !bAllowDropDown ) aForbiddenProperties.insert( PROPERTY_DROPDOWN ); diff --git a/forms/source/component/Columns.hxx b/forms/source/component/Columns.hxx index 0e5c7a570c62..f1aafd47cb5d 100644 --- a/forms/source/component/Columns.hxx +++ b/forms/source/component/Columns.hxx @@ -31,19 +31,23 @@ #ifndef _FRM_COLUMNS_HXX #define _FRM_COLUMNS_HXX -#include <cppuhelper/component.hxx> -#include <comphelper/proparrhlp.hxx> -#include <comphelper/propagg.hxx> -#include <comphelper/uno3.hxx> -#include "frm_strings.hxx" -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/compbase3.hxx> -#include <comphelper/broadcasthelper.hxx> -#include "cloneable.hxx" +#include "cloneable.hxx"
+#include "frm_strings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/component.hxx>
using namespace comphelper; @@ -55,8 +59,7 @@ namespace frm //================================================================== // OGridColumn //================================================================== -typedef ::cppu::WeakAggComponentImplHelper3 < ::com::sun::star::container::XChild - , ::com::sun::star::lang::XUnoTunnel +typedef ::cppu::WeakAggComponentImplHelper2 < ::com::sun::star::lang::XUnoTunnel , ::com::sun::star::util::XCloneable > OGridColumn_BASE; class OGridColumn :public ::comphelper::OBaseMutex ,public OGridColumn_BASE @@ -70,17 +73,15 @@ protected: ::com::sun::star::uno::Any m_aHidden; // column hidden? // [properties] - InterfaceRef m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> - m_xORB; - ::rtl::OUString m_aModelName; + ::comphelper::ComponentContext m_aContext; + ::rtl::OUString m_aModelName; // [properties] ::rtl::OUString m_aLabel; // Name der Spalte // [properties] public: - OGridColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, const ::rtl::OUString& _sModelName = ::rtl::OUString()); + OGridColumn(const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _sModelName = ::rtl::OUString()); OGridColumn(const OGridColumn* _pOriginal ); virtual ~OGridColumn(); @@ -102,10 +103,6 @@ public: // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); - // XChild - virtual InterfaceRef SAL_CALL getParent() throw(::com::sun::star::uno::RuntimeException){return m_xParent;} - virtual void SAL_CALL setParent(const InterfaceRef& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); - // XPersistObject virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); @@ -135,30 +132,30 @@ protected: virtual OGridColumn* createCloneColumn() const = 0; }; -#define DECL_COLUMN(ClassName) \ -class ClassName \ - :public OGridColumn \ - ,public OAggregationArrayUsageHelper< ClassName > \ -{ \ -public: \ - ClassName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);\ - ClassName(const ClassName* _pCloneFrom);\ - \ +#define DECL_COLUMN(ClassName) \ +class ClassName \ + :public OGridColumn \ + ,public OAggregationArrayUsageHelper< ClassName > \ +{ \ +public: \ + ClassName(const ::comphelper::ComponentContext& _rContext ); \ + ClassName(const ClassName* _pCloneFrom); \ + \ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); \ - virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \ - \ - virtual void fillProperties( \ - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \ + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \ + \ + virtual void fillProperties( \ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, \ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps \ - ) const; \ - \ - virtual OGridColumn* createCloneColumn() const; \ + ) const; \ + \ + virtual OGridColumn* createCloneColumn() const; \ }; #define IMPL_COLUMN(ClassName, Model, bAllowDropDown) \ -ClassName::ClassName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory) \ - :OGridColumn(_rxFactory, Model) \ + ClassName::ClassName( const ::comphelper::ComponentContext& _rContext ) \ + :OGridColumn(_rContext, Model) \ { \ } \ ClassName::ClassName( const ClassName* _pCloneFrom ) \ diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index fc8cd78fdfde..1d6d204ea977 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -143,7 +143,7 @@ DBG_NAME( OComboBoxModel ) OComboBoxModel::OComboBoxModel(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_COMBOBOX, FRM_SUN_CONTROL_COMBOBOX, sal_True, sal_True, sal_True ) // use the old control name for compytibility reasons - ,OEntryListHelper( m_aMutex ) + ,OEntryListHelper( (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_eListSourceType(ListSourceType_TABLE) @@ -158,7 +158,7 @@ OComboBoxModel::OComboBoxModel(const Reference<XMultiServiceFactory>& _rxFactory //------------------------------------------------------------------ OComboBoxModel::OComboBoxModel( const OComboBoxModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - ,OEntryListHelper( *_pOriginal, m_aMutex ) + ,OEntryListHelper( *_pOriginal, (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_aListSource( _pOriginal->m_aListSource ) @@ -265,8 +265,8 @@ void OComboBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const case PROPERTY_ID_STRINGITEMLIST: { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); - setNewStringItemList( _rValue, aGuard ); + ControlModelLock aLock( *this ); + setNewStringItemList( _rValue, aLock ); // TODO: this is bogus. setNewStringItemList expects a guard which has the *only* // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with // a lock - so we effectively has two locks here, of which setNewStringItemList can @@ -384,7 +384,7 @@ void SAL_CALL OComboBoxModel::write(const Reference<stario::XObjectOutputStream> void SAL_CALL OComboBoxModel::read(const Reference<stario::XObjectInputStream>& _rxInStream) throw(stario::IOException, RuntimeException) { OBoundControlModel::read(_rxInStream); - ::osl::ResettableMutexGuard aGuard(m_aMutex); + ControlModelLock aLock( *this ); // since we are "overwriting" the StringItemList of our aggregate (means we have // an own place to store the value, instead of relying on our aggregate storing it), @@ -392,7 +392,7 @@ void SAL_CALL OComboBoxModel::read(const Reference<stario::XObjectInputStream>& try { if ( m_xAggregateSet.is() ) - setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aGuard ); + setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock ); } catch( const Exception& ) { @@ -733,6 +733,8 @@ void OComboBoxModel::onDisconnectedDbColumn() // reset the string item list if ( !hasExternalListSource() ) setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( m_aDesignModeStringItems ) ); + + m_aListRowSet.dispose(); } //------------------------------------------------------------------------------ @@ -853,7 +855,7 @@ Any OComboBoxModel::getDefaultForReset() const } //-------------------------------------------------------------------- -void OComboBoxModel::stringItemListChanged( ::osl::ResettableMutexGuard& /*_rInstanceLock*/ ) +void OComboBoxModel::stringItemListChanged( ControlModelLock& /*_rInstanceLock*/ ) { if ( m_xAggregateSet.is() ) m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( getStringItemList() ) ); diff --git a/forms/source/component/ComboBox.hxx b/forms/source/component/ComboBox.hxx index 28e17ebe9f42..835099a7637c 100644 --- a/forms/source/component/ComboBox.hxx +++ b/forms/source/component/ComboBox.hxx @@ -146,7 +146,7 @@ protected: getDefaultForReset() const; // OEntryListHelper overriables - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ); + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); virtual void connectedExternalListSource( ); virtual void disconnectedExternalListSource( ); virtual void refreshInternalEntryList(); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index f524142865e5..96412feed10a 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -31,72 +31,72 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include <stdio.h> -#include <ctype.h> -#include <hash_map> - -#include "DatabaseForm.hxx" -#include "EventThread.hxx" -#include "frm_resource.hxx" -#include "frm_resource.hrc" -#include "GroupManager.hxx" -#include "property.hrc" -#include "property.hxx" -#include "services.hxx" -#include "frm_module.hxx" -#include "componenttools.hxx" -#include <com/sun/star/sdb/XColumnUpdate.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/form/DataSelectionType.hpp> -#include <com/sun/star/sdb/SQLContext.hpp> -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/sdb/CommandType.hpp> -#include <com/sun/star/sdb/RowSetVetoException.hpp> -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/sdbcx/Privilege.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/form/TabulatorCycle.hpp> -#include <com/sun/star/awt/XControlContainer.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> - -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <vcl/timer.hxx> -#include <tools/fsys.hxx> -#include <tools/inetmsg.hxx> -#ifndef _INETSTRM_HXX //autogen -#include <svtools/inetstrm.hxx> -#endif -#include <cppuhelper/implbase2.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/sequence.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/uno3.hxx> -#include <comphelper/seqstream.hxx> -#include <comphelper/enumhelper.hxx> -#include <comphelper/container.hxx> -#include <comphelper/basicio.hxx> -#include <connectivity/dbtools.hxx> -#include <osl/mutex.hxx> -#include <tools/urlobj.hxx> -#include <rtl/math.hxx> -#include <svtools/inettype.hxx> -#include <comphelper/extract.hxx> -#include <vos/mutex.hxx> -#include <vcl/svapp.hxx> -#include <rtl/tencinfo.h> -#include <unotools/ucblockbytes.hxx> -#include <unotools/ucbstreamhelper.hxx> +#include "componenttools.hxx"
+#include "DatabaseForm.hxx"
+#include "EventThread.hxx"
+#include "frm_module.hxx"
+#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "GroupManager.hxx"
+#include "property.hrc"
+#include "property.hxx"
+#include "services.hxx"
+
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/form/DataSelectionType.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/TabulatorCycle.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/RowSetVetoException.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/util/XModifiable2.hpp> +
+#include <comphelper/basicio.hxx>
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/math.hxx>
+#include <rtl/tencinfo.h>
+#include <svtools/inetstrm.hxx>
+#include <svtools/inettype.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/fsys.hxx>
+#include <tools/inetmsg.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/ucblockbytes.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/timer.hxx>
+#include <vos/mutex.hxx>
+ +#include <ctype.h>
+#include <hash_map>
+//#include <stdio.h>
// compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ... namespace com { @@ -115,8 +115,6 @@ enum DatabaseCursorType } } } } -#define DATABASEFORM_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.ODatabaseForm") - using namespace ::dbtools; using namespace ::comphelper; using namespace ::com::sun::star::uno; @@ -146,6 +144,41 @@ namespace frm //......................................................................... //================================================================== +//= DocumentModifyGuard +//================================================================== +class DocumentModifyGuard +{ +public: + DocumentModifyGuard( const Reference< XInterface >& _rxFormComponent ) + :m_xDocumentModify( getXModel( _rxFormComponent ), UNO_QUERY ) + { + OSL_ENSURE( m_xDocumentModify.is(), "DocumentModifyGuard::DocumentModifyGuard: no document, or no XModifiable2!" ); + impl_changeModifiableFlag_nothrow( false ); + } + ~DocumentModifyGuard() + { + impl_changeModifiableFlag_nothrow( true ); + } + +private: + void impl_changeModifiableFlag_nothrow( const bool _enable ) + { + try + { + if ( m_xDocumentModify.is() ) + _enable ? m_xDocumentModify->enableSetModified() : m_xDocumentModify->disableSetModified(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + +private: + Reference< XModifiable2 > m_xDocumentModify; +}; + +//================================================================== //= OFormSubmitResetThread //=----------------------------------------------------------------- //= submitting and resetting html-forms asynchronously @@ -261,51 +294,152 @@ Any SAL_CALL ODatabaseForm::queryAggregation(const Type& _rType) throw(RuntimeEx DBG_NAME(ODatabaseForm); //------------------------------------------------------------------ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) - :OFormComponents(_rxFactory) - ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) - ,OPropertyChangeListener(m_aMutex) - ,m_aLoadListeners(m_aMutex) - ,m_aRowSetApproveListeners(m_aMutex) - ,m_aRowSetListeners(m_aMutex) - ,m_aSubmitListeners(m_aMutex) - ,m_aErrorListeners(m_aMutex) - ,m_aResetListeners( *this, m_aMutex ) - ,m_aPropertyBagHelper( *this ) - ,m_pAggregatePropertyMultiplexer(NULL) - ,m_pGroupManager( NULL ) - ,m_aParameterManager( m_aMutex, _rxFactory ) - ,m_aFilterManager( _rxFactory ) - ,m_pLoadTimer(NULL) - ,m_pThread(NULL) - ,m_nResetsPending(0) - ,m_nPrivileges(0) - ,m_bInsertOnly( sal_False ) - ,m_eSubmitMethod(FormSubmitMethod_GET) - ,m_eSubmitEncoding(FormSubmitEncoding_URL) - ,m_eNavigation(NavigationBarMode_CURRENT) - ,m_bAllowInsert(sal_True) - ,m_bAllowUpdate(sal_True) - ,m_bAllowDelete(sal_True) - ,m_bLoaded(sal_False) - ,m_bSubForm(sal_False) - ,m_bForwardingConnection(sal_False) - ,m_bSharingConnection( sal_False ) -{ - DBG_CTOR(ODatabaseForm,NULL); + :OFormComponents(_rxFactory) + ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) + ,OPropertyChangeListener(m_aMutex) + ,m_aLoadListeners(m_aMutex) + ,m_aRowSetApproveListeners(m_aMutex) + ,m_aRowSetListeners(m_aMutex) + ,m_aSubmitListeners(m_aMutex) + ,m_aErrorListeners(m_aMutex) + ,m_aResetListeners( *this, m_aMutex ) + ,m_aPropertyBagHelper( *this ) + ,m_pAggregatePropertyMultiplexer(NULL) + ,m_pGroupManager( NULL ) + ,m_aParameterManager( m_aMutex, _rxFactory ) + ,m_aFilterManager( _rxFactory ) + ,m_pLoadTimer(NULL) + ,m_pThread(NULL) + ,m_nResetsPending(0) + ,m_nPrivileges(0) + ,m_bInsertOnly( sal_False ) + ,m_eSubmitMethod(FormSubmitMethod_GET) + ,m_eSubmitEncoding(FormSubmitEncoding_URL) + ,m_eNavigation(NavigationBarMode_CURRENT) + ,m_bAllowInsert(sal_True) + ,m_bAllowUpdate(sal_True) + ,m_bAllowDelete(sal_True) + ,m_bLoaded(sal_False) + ,m_bSubForm(sal_False) + ,m_bForwardingConnection(sal_False) + ,m_bSharingConnection( sal_False ) +{ + DBG_CTOR( ODatabaseForm, NULL ); + impl_construct(); +} + +//------------------------------------------------------------------ +ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource ) + :OFormComponents( _cloneSource ) + ,OPropertySetAggregationHelper( OComponentHelper::rBHelper ) + ,OPropertyChangeListener( m_aMutex ) + ,ODatabaseForm_BASE1() + ,ODatabaseForm_BASE2() + ,ODatabaseForm_BASE3() + ,IPropertyBagHelperContext() + ,m_aLoadListeners( m_aMutex ) + ,m_aRowSetApproveListeners( m_aMutex ) + ,m_aRowSetListeners( m_aMutex ) + ,m_aSubmitListeners( m_aMutex ) + ,m_aErrorListeners( m_aMutex ) + ,m_aResetListeners( *this, m_aMutex ) + ,m_aPropertyBagHelper( *this ) + ,m_pAggregatePropertyMultiplexer( NULL ) + ,m_pGroupManager( NULL ) + ,m_aParameterManager( m_aMutex, _cloneSource.m_xServiceFactory ) + ,m_aFilterManager( _cloneSource.m_xServiceFactory ) + ,m_pLoadTimer( NULL ) + ,m_pThread( NULL ) + ,m_nResetsPending( 0 ) + ,m_nPrivileges( 0 ) + ,m_bInsertOnly( _cloneSource.m_bInsertOnly ) + ,m_aControlBorderColorFocus( _cloneSource.m_aControlBorderColorFocus ) + ,m_aControlBorderColorMouse( _cloneSource.m_aControlBorderColorMouse ) + ,m_aControlBorderColorInvalid( _cloneSource.m_aControlBorderColorInvalid ) + ,m_aDynamicControlBorder( _cloneSource.m_aDynamicControlBorder ) + ,m_sName( _cloneSource.m_sName ) + ,m_aTargetURL( _cloneSource.m_aTargetURL ) + ,m_aTargetFrame( _cloneSource.m_aTargetFrame ) + ,m_eSubmitMethod( _cloneSource.m_eSubmitMethod ) + ,m_eSubmitEncoding( _cloneSource.m_eSubmitEncoding ) + ,m_eNavigation( _cloneSource.m_eNavigation ) + ,m_bAllowInsert( _cloneSource.m_bAllowInsert ) + ,m_bAllowUpdate( _cloneSource.m_bAllowUpdate ) + ,m_bAllowDelete( _cloneSource.m_bAllowDelete ) + ,m_bLoaded( sal_False ) + ,m_bSubForm( sal_False ) + ,m_bForwardingConnection( sal_False ) + ,m_bSharingConnection( sal_False ) +{ + DBG_CTOR( ODatabaseForm, NULL ); + + impl_construct(); + + osl_incrementInterlockedCount( &m_refCount ); + { + // our aggregated rowset itself is not cloneable, so simply copy the properties + ::comphelper::copyProperties( _cloneSource.m_xAggregateSet, m_xAggregateSet ); + + // also care for the dynamic properties: If the clone source has properties which we do not have, + // then add them + try + { + Reference< XPropertySet > xSourceProps( const_cast< ODatabaseForm& >( _cloneSource ).queryAggregation( + XPropertySet::static_type() ), UNO_QUERY_THROW ); + Reference< XPropertySetInfo > xSourcePSI( xSourceProps->getPropertySetInfo(), UNO_SET_THROW ); + Reference< XPropertyState > xSourcePropState( xSourceProps, UNO_QUERY ); + Reference< XPropertySetInfo > xDestPSI( getPropertySetInfo(), UNO_QUERY_THROW ); + + Sequence< Property > aSourceProperties( xSourcePSI->getProperties() ); + for ( const Property* pSourceProperty = aSourceProperties.getConstArray(); + pSourceProperty != aSourceProperties.getConstArray() + aSourceProperties.getLength(); + ++pSourceProperty + ) + { + if ( xDestPSI->hasPropertyByName( pSourceProperty->Name ) ) + continue; + + // the initial value passed to XPropertyContainer is also used as default, usually. So, try + // to retrieve the default of the source property + Any aInitialValue; + if ( xSourcePropState.is() ) + { + aInitialValue = xSourcePropState->getPropertyDefault( pSourceProperty->Name ); + } + else + { + aInitialValue = xSourceProps->getPropertyValue( pSourceProperty->Name ); + } + addProperty( pSourceProperty->Name, pSourceProperty->Attributes, aInitialValue ); + setPropertyValue( pSourceProperty->Name, xSourceProps->getPropertyValue( pSourceProperty->Name ) ); + } + } + catch( const Exception& ) + { + throw WrappedTargetException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not clone the given database form." ) ), + *const_cast< ODatabaseForm* >( &_cloneSource ), + ::cppu::getCaughtException() + ); + } + } + osl_decrementInterlockedCount( &m_refCount ); +} + +//------------------------------------------------------------------ +void ODatabaseForm::impl_construct() +{ // aggregate a row set increment(m_refCount); - { - m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(SRV_SDB_ROWSET), UNO_QUERY); - // m_xAggregate = Reference<XAggregation>(m_xServiceFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.sdb.dbaccess.ORowSet")), UNO_QUERY); - DBG_ASSERT(m_xAggregate.is(), "ODatabaseForm::ODatabaseForm : could not instantiate an SDB rowset !"); - m_xAggregateAsRowSet = Reference<XRowSet> (m_xAggregate,UNO_QUERY); - setAggregation(m_xAggregate); + m_xAggregate = Reference< XAggregation >( m_xServiceFactory->createInstance( SRV_SDB_ROWSET ), UNO_QUERY_THROW ); + m_xAggregateAsRowSet.set( m_xAggregate, UNO_QUERY_THROW ); + setAggregation( m_xAggregate ); } // listen for the properties, important for Parameters - if (m_xAggregateSet.is()) + if ( m_xAggregateSet.is() ) { m_pAggregatePropertyMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet, sal_False); m_pAggregatePropertyMultiplexer->acquire(); @@ -313,9 +447,14 @@ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_ACTIVE_CONNECTION); } - if (m_xAggregate.is()) { - m_xAggregate->setDelegator(static_cast<XWeak*>(this)); + Reference< XWarningsSupplier > xRowSetWarnings( m_xAggregate, UNO_QUERY ); + m_aWarnings.setExternalWarnings( xRowSetWarnings ); + } + + if ( m_xAggregate.is() ) + { + m_xAggregate->setDelegator( static_cast< XWeak* >( this ) ); } { @@ -324,10 +463,9 @@ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) declareForwardedProperty( PROPERTY_ID_ACTIVE_CONNECTION ); } + decrement( m_refCount ); - decrement(m_refCount); - - m_pGroupManager = new OGroupManager(this); + m_pGroupManager = new OGroupManager( this ); m_pGroupManager->acquire(); } @@ -337,9 +475,12 @@ ODatabaseForm::~ODatabaseForm() DBG_DTOR(ODatabaseForm,NULL); m_pGroupManager->release(); + m_pGroupManager = NULL; if (m_xAggregate.is()) - m_xAggregate->setDelegator(InterfaceRef()); + m_xAggregate->setDelegator( NULL ); + + m_aWarnings.setExternalWarnings( NULL ); if (m_pAggregatePropertyMultiplexer) { @@ -354,14 +495,18 @@ ODatabaseForm::~ODatabaseForm() //------------------------------------------------------------------------ ::rtl::OUString ODatabaseForm::GetDataURLEncoded(const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt) { - + return GetDataEncoded(true,SubmitButton,MouseEvt); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ODatabaseForm::GetDataEncoded(bool _bURLEncoded,const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt) +{ // Liste von successful Controls fuellen HtmlSuccessfulObjList aSuccObjList; FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt ); // Liste zu ::rtl::OUString zusammensetzen - ::rtl::OUString aResult; + ::rtl::OUStringBuffer aResult; ::rtl::OUString aName; ::rtl::OUString aValue; @@ -384,17 +529,24 @@ ODatabaseForm::~ODatabaseForm() } Encode( aName ); Encode( aValue ); - aResult += aName; - aResult += UniString('='); - aResult += aValue; + + aResult.append(aName); + aResult.append(sal_Unicode('=')); + aResult.append(aValue); + if (pSuccObj < aSuccObjList.end() - 1) - aResult += UniString('&'); + { + if ( _bURLEncoded ) + aResult.append(sal_Unicode('&')); + else + aResult.appendAscii("\r\n"); + } } aSuccObjList.clear(); - return aResult; + return aResult.makeStringAndClear(); } //============================================================================== @@ -402,46 +554,7 @@ ODatabaseForm::~ODatabaseForm() //------------------------------------------------------------------------ ::rtl::OUString ODatabaseForm::GetDataTextEncoded(const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt) { - - // Liste von successful Controls fuellen - HtmlSuccessfulObjList aSuccObjList; - FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt ); - // Liste zu ::rtl::OUString zusammensetzen - ::rtl::OUString aResult; - ::rtl::OUString aName; - ::rtl::OUString aValue; - - for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin(); - pSuccObj < aSuccObjList.end(); - ++pSuccObj - ) - { - aName = pSuccObj->aName; - aValue = pSuccObj->aValue; - if (pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength()) - { - // Bei File-URLs wird der Dateiname und keine URL uebertragen, - // weil Netscape dies so macht. - INetURLObject aURL; - aURL.SetSmartProtocol(INET_PROT_FILE); - aURL.SetSmartURL(aValue); - if( INET_PROT_FILE == aURL.GetProtocol() ) - aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS); - } - Encode( aName ); - Encode( aValue ); - aResult += pSuccObj->aName; - aResult += UniString('='); - aResult += pSuccObj->aValue; - if (pSuccObj < aSuccObjList.end() - 1) - aResult += ::rtl::OUString::createFromAscii("\r\n"); - } - - - // Liste loeschen - aSuccObjList.clear(); - - return aResult; + return GetDataEncoded(false,SubmitButton,MouseEvt); } //------------------------------------------------------------------------ @@ -1368,6 +1481,28 @@ void SAL_CALL ODatabaseForm::setPropertyValues( const Sequence< PropertyValue >& } //------------------------------------------------------------------------------ +Any SAL_CALL ODatabaseForm::getWarnings( ) throw (SQLException, RuntimeException) +{ + return m_aWarnings.getWarnings(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL ODatabaseForm::clearWarnings( ) throw (SQLException, RuntimeException) +{ + m_aWarnings.clearWarnings(); +} + +//------------------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL ODatabaseForm::createClone( ) throw (RuntimeException) +{ + ODatabaseForm* pClone = new ODatabaseForm( *this ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return pClone; +} + +//------------------------------------------------------------------------------ void ODatabaseForm::fire( sal_Int32* pnHandles, const Any* pNewValues, const Any* pOldValues, sal_Int32 nCount, sal_Bool bVetoable ) { // same as in getFastPropertyValue(INT32) : if we're resetting currently don't fire any changes of the @@ -2040,7 +2175,36 @@ void SAL_CALL ODatabaseForm::submit( const Reference<XControl>& Control, submit_impl( Control, MouseEvt, true ); } } +// ----------------------------------------------------------------------------- +void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLTransformer>& xTransformer,const ::rtl::OUString& aURLStr,const ::rtl::OUString& aReferer,const ::rtl::OUString& aTargetName + ,const ::rtl::OUString& aData,rtl_TextEncoding _eEncoding) +{ + URL aURL; + aURL.Complete = aURLStr; + xTransformer->parseStrict(aURL); + + Reference< XDispatch > xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName, + FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN | + FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS); + + if (xDisp.is()) + { + Sequence<PropertyValue> aArgs(2); + aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer"); + aArgs.getArray()[0].Value <<= aReferer; + + // build a sequence from the to-be-submitted string + ByteString a8BitData(aData.getStr(), (sal_uInt16)aData.getLength(), _eEncoding); + // always ANSI #58641 + Sequence< sal_Int8 > aPostData((sal_Int8*)a8BitData.GetBuffer(), a8BitData.Len()); + Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); + aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostData"); + aArgs.getArray()[1].Value <<= xPostData; + + xDisp->dispatch(aURL, aArgs); + } // if (xDisp.is()) +} //------------------------------------------------------------------------------ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com::sun::star::awt::MouseEvent& MouseEvt, bool _bAproveByListeners) { @@ -2088,6 +2252,9 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com: if (!xModel.is()) return; + Reference< XFrame > xFrame = xModel->getCurrentController()->getFrame(); + if (!xFrame.is()) + return; Reference<XURLTransformer> xTransformer(m_xServiceFactory->createInstance( @@ -2103,10 +2270,6 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com: aData = GetDataURLEncoded( Control, MouseEvt ); } - Reference< XFrame > xFrame = xModel->getCurrentController()->getFrame(); - if (!xFrame.is()) - return; - URL aURL; // FormMethod GET if( eSubmitMethod == FormSubmitMethod_GET ) @@ -2132,38 +2295,11 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com: // FormMethod POST else if( eSubmitMethod == FormSubmitMethod_POST ) { - aURL.Complete = aURLStr; - xTransformer->parseStrict(aURL); - - Reference< XDispatch > xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName, - FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN | - FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS); - - if (xDisp.is()) - { - Sequence<PropertyValue> aArgs(2); - aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer"); - aArgs.getArray()[0].Value <<= aReferer; - - // build a sequence from the to-be-submitted string - ByteString a8BitData(aData.getStr(), (sal_uInt16)aData.getLength(), RTL_TEXTENCODING_MS_1252); - // always ANSI #58641 - Sequence< sal_Int8 > aPostData((sal_Int8*)a8BitData.GetBuffer(), a8BitData.Len()); - Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); - - aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostData"); - aArgs.getArray()[1].Value <<= xPostData; - - xDisp->dispatch(aURL, aArgs); - } + lcl_dispatch(xFrame,xTransformer,aURLStr,aReferer,aTargetName,aData,RTL_TEXTENCODING_MS_1252); } } else if( eSubmitEncoding == FormSubmitEncoding_MULTIPART ) { - Reference< XFrame > xFrame = xModel->getCurrentController()->getFrame(); - if (!xFrame.is()) - return; - URL aURL; aURL.Complete = aURLStr; xTransformer->parseStrict(aURL); @@ -2206,35 +2342,7 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com: aData = GetDataTextEncoded( Reference<XControl> (), MouseEvt ); } - Reference< XFrame > xFrame = xModel->getCurrentController()->getFrame(); - if (!xFrame.is()) - return; - - URL aURL; - - aURL.Complete = aURLStr; - xTransformer->parseStrict(aURL); - - Reference< XDispatch > xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName, - FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN | - FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS); - - if (xDisp.is()) - { - Sequence<PropertyValue> aArgs(2); - aArgs.getArray()[0].Name = ::rtl::OUString::createFromAscii("Referer"); - aArgs.getArray()[0].Value <<= aReferer; - - // build a sequence from the to-be-submitted string - ByteString aSystemEncodedData(aData.getStr(), (sal_uInt16)aData.getLength(), osl_getThreadTextEncoding()); - Sequence< sal_Int8 > aPostData((sal_Int8*)aSystemEncodedData.GetBuffer(), aSystemEncodedData.Len()); - Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); - - aArgs.getArray()[1].Name = ::rtl::OUString::createFromAscii("PostData"); - aArgs.getArray()[1].Value <<= xPostData; - - xDisp->dispatch(aURL, aArgs); - } + lcl_dispatch(xFrame,xTransformer,aURLStr,aReferer,aTargetName,aData,osl_getThreadTextEncoding()); } else { DBG_ERROR("ODatabaseForm::submit_Impl : wrong encoding !"); @@ -2888,6 +2996,10 @@ void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst, const Reference< XInterac if (!isLoaded()) return; + DocumentModifyGuard aModifyGuard( *this ); + // ensures the document is not marked as "modified" just because we change some control's content during + // reloading ... + EventObject aEvent(static_cast<XWeak*>(this)); { // only if there is no approve listener we can post the event at this time @@ -3694,7 +3806,7 @@ void SAL_CALL ODatabaseForm::propertyChange( const PropertyChangeEvent& evt ) th //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName_Static() { - return DATABASEFORM_IMPLEMENTATION_NAME; + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.forms.ODatabaseForm" ) ); } //------------------------------------------------------------------------------ diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx index 47b43fb53f03..a19d20930538 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -63,13 +63,15 @@ #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <tools/link.hxx> #include "InterfaceContainer.hxx" -#include "connectivity/parameters.hxx" -#include "connectivity/filtermanager.hxx" +#include <connectivity/parameters.hxx> +#include <connectivity/filtermanager.hxx> +#include <connectivity/warningscontainer.hxx> #ifndef FORMS_SOURCE_MISC_LISTENERCONTAINERS_HXX #include "listenercontainers.hxx" @@ -79,7 +81,7 @@ #include <comphelper/uno3.hxx> #include <comphelper/proparrhlp.hxx> #include <cppuhelper/implbase12.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase7.hxx> namespace com { namespace sun { namespace star { namespace sdbc { @@ -143,9 +145,10 @@ typedef ::cppu::ImplHelper12 < ::com::sun::star::form::XForm > ODatabaseForm_BASE1; -typedef ::cppu::ImplHelper3 < ::com::sun::star::lang::XServiceInfo +typedef ::cppu::ImplHelper4 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::beans::XPropertyContainer , ::com::sun::star::beans::XPropertyAccess + , ::com::sun::star::sdbc::XWarningsSupplier > ODatabaseForm_BASE2; typedef ::cppu::ImplHelper7< ::com::sun::star::sdbc::XCloseable, @@ -188,6 +191,7 @@ class ODatabaseForm :public OFormComponents ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet> m_xAggregateAsRowSet; PropertyBagHelper m_aPropertyBagHelper; + ::dbtools::WarningsContainer m_aWarnings; OPropertyChangeMultiplexer* m_pAggregatePropertyMultiplexer; // Verwaltung der ControlGruppen OGroupManager* m_pGroupManager; @@ -228,6 +232,7 @@ class ODatabaseForm :public OFormComponents public: ODatabaseForm(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + ODatabaseForm( const ODatabaseForm& _cloneSource ); ~ODatabaseForm(); // UNO binding @@ -440,6 +445,13 @@ public: virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); using OPropertySetAggregationHelper::setPropertyValues; + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + inline void submitNBC( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& Control, const ::com::sun::star::awt::MouseEvent& MouseEvt ); protected: @@ -520,6 +532,7 @@ private: void onError(const ::com::sun::star::sdbc::SQLException&, const ::rtl::OUString& _rContextDescription); // html tools + ::rtl::OUString GetDataEncoded(bool _bURLEncoded,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt); ::rtl::OUString GetDataURLEncoded(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt); ::rtl::OUString GetDataTextEncoded(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt); ::com::sun::star::uno::Sequence<sal_Int8> GetDataMultiPartEncoded(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt, @@ -538,6 +551,8 @@ private: void impl_createLoadTimer(); + void impl_construct(); + DECL_LINK( OnTimeout, void* ); protected: using OPropertySetHelper::getPropertyValues; diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index 4ada0ca85861..0f4abd687d65 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -519,7 +519,8 @@ void OEditModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutS // but for compatibility, we need to use an "old" aggregate for writing and reading Reference< XPropertySet > xFakedAggregate( - getORB()->createInstance( VCL_CONTROLMODEL_EDIT ), UNO_QUERY + getContext().createComponent( (rtl::OUString)VCL_CONTROLMODEL_EDIT ), + UNO_QUERY ); OSL_ENSURE( xFakedAggregate.is(), "OEditModel::writeAggregate: could not create an old EditControlModel!" ); if ( !xFakedAggregate.is() ) @@ -540,7 +541,8 @@ void OEditModel::readAggregate( const Reference< XObjectInputStream >& _rxInStre // but for compatibility, we need to use an "old" aggregate for writing and reading Reference< XPropertySet > xFakedAggregate( - getORB()->createInstance( VCL_CONTROLMODEL_EDIT ), UNO_QUERY + getContext().createComponent( (rtl::OUString)VCL_CONTROLMODEL_EDIT ), + UNO_QUERY ); Reference< XPersistObject > xFakedPersist( xFakedAggregate, UNO_QUERY ); OSL_ENSURE( xFakedPersist.is(), "OEditModel::readAggregate: no XPersistObject, or no faked aggregate at all!" ); diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 4b1bc5515836..ed3e85a905ec 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -30,35 +30,39 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" + +#include "componenttools.hxx" #include "FormComponent.hxx" -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <cppuhelper/queryinterface.hxx> +#include "frm_resource.hrc" +#include "frm_resource.hxx" +#include "property.hrc" +#include "services.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> #include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/form/XLoadable.hpp> #include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/io/XMarkableStream.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp> +#include <com/sun/star/sdb/XRowSetSupplier.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/awt/XVclWindowPeer.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <comphelper/property.hxx> +/** === end UNO includes === **/ + +#include <comphelper/basicio.hxx> #include <comphelper/guarding.hxx> +#include <comphelper/listenernotification.hxx> +#include <comphelper/property.hxx> #include <connectivity/dbtools.hxx> -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "services.hxx" -#include "componenttools.hxx" +#include <cppuhelper/queryinterface.hxx> #include <rtl/logfile.hxx> -#include <comphelper/basicio.hxx> -#include <comphelper/listenernotification.hxx> #include <toolkit/helper/emptyfontdescriptor.hxx> - -#include "frm_resource.hxx" -#include "frm_resource.hrc" +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> #include <functional> #include <algorithm> @@ -88,15 +92,67 @@ namespace frm using namespace ::dbtools; using namespace ::comphelper; -//========================================================================= + //========================================================================= + //= FieldChangeNotifier + //========================================================================= + //------------------------------------------------------------------------- + void ControlModelLock::impl_notifyAll_nothrow() + { + m_rModel.firePropertyChanges( m_aHandles, m_aOldValues, m_aNewValues, OControlModel::LockAccess() ); + } + + //------------------------------------------------------------------------- + void ControlModelLock::addPropertyNotification( const sal_Int32 _nHandle, const Any& _rOldValue, const Any& _rNewValue ) + { + sal_Int32 nOldLength = m_aHandles.getLength(); + if ( ( nOldLength != m_aOldValues.getLength() ) + || ( nOldLength != m_aNewValues.getLength() ) + ) + throw RuntimeException( ::rtl::OUString(), m_rModel ); + + m_aHandles.realloc( nOldLength + 1 ); + m_aHandles[ nOldLength ] = _nHandle; + m_aOldValues.realloc( nOldLength + 1 ); + m_aOldValues[ nOldLength ] = _rOldValue; + m_aNewValues.realloc( nOldLength + 1 ); + m_aNewValues[ nOldLength ] = _rNewValue; + } + + //========================================================================= + //= FieldChangeNotifier + //========================================================================= + //------------------------------------------------------------------------- + class FieldChangeNotifier + { + public: + FieldChangeNotifier( ControlModelLock& _rLock ) + :m_rLock( _rLock ) + ,m_rModel( dynamic_cast< OBoundControlModel& >( _rLock.getModel() ) ) + { + m_xOldField = m_rModel.getField(); + } + + ~FieldChangeNotifier() + { + Reference< XPropertySet > xNewField( m_rModel.getField() ); + if ( m_xOldField != xNewField ) + m_rLock.addPropertyNotification( PROPERTY_ID_BOUNDFIELD, makeAny( m_xOldField ), makeAny( xNewField ) ); + } + + private: + ControlModelLock& m_rLock; + OBoundControlModel& m_rModel; + Reference< XPropertySet > m_xOldField; + }; + +//============================================================================= //= base class for form layer controls -//========================================================================= +//============================================================================= DBG_NAME(frm_OControl) //------------------------------------------------------------------------------ OControl::OControl( const Reference< XMultiServiceFactory >& _rxFactory, const rtl::OUString& _rAggregateService, const sal_Bool _bSetDelegator ) :OComponentHelper(m_aMutex) ,m_aContext( _rxFactory ) - ,m_xServiceFactory(_rxFactory) { DBG_CTOR(frm_OControl, NULL); // VCL-Control aggregieren @@ -183,22 +239,9 @@ Sequence<Type> OControl::_getTypes() } //------------------------------------------------------------------------------ -void OControl::initFormControlPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _rxPeer ) +void OControl::initFormControlPeer( const Reference< XWindowPeer >& /*_rxPeer*/ ) { - try - { - Reference< XVclWindowPeer > xVclWindowPeer( _rxPeer, UNO_QUERY_THROW ); - - // #i63103# - form controls should only react on the mouse wheel when they're focused - xVclWindowPeer->setProperty( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WheelWithoutFocus" ) ), - makeAny( sal_Bool( sal_False ) ) - ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + // nothing to do here } // OComponentHelper @@ -467,12 +510,14 @@ DBG_NAME(OControlModel) //------------------------------------------------------------------ Sequence<sal_Int8> SAL_CALL OControlModel::getImplementationId() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getImplementationId" ); return OImplementationIds::getImplementationId(getTypes()); } //------------------------------------------------------------------ Sequence<Type> SAL_CALL OControlModel::getTypes() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getTypes" ); TypeBag aTypes( _getTypes() ); Reference< XTypeProvider > xProv; @@ -485,6 +530,7 @@ Sequence<Type> SAL_CALL OControlModel::getTypes() throw(RuntimeException) //------------------------------------------------------------------------------ Sequence<Type> OControlModel::_getTypes() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::_getTypes" ); return TypeBag( OComponentHelper::getTypes(), OPropertySetAggregationHelper::getTypes(), OControlModel_BASE::getTypes() @@ -494,6 +540,7 @@ Sequence<Type> OControlModel::_getTypes() //------------------------------------------------------------------ Any SAL_CALL OControlModel::queryAggregation(const Type& _rType) throw (RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::queryAggregation" ); // base class 1 Any aReturn(OComponentHelper::queryAggregation(_rType)); @@ -517,6 +564,7 @@ Any SAL_CALL OControlModel::queryAggregation(const Type& _rType) throw (RuntimeE //------------------------------------------------------------------------------ void OControlModel::readHelpTextCompatibly(const staruno::Reference< stario::XObjectInputStream >& _rxInStream) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::readHelpTextCompatibly" ); ::rtl::OUString sHelpText; ::comphelper::operator>>( _rxInStream, sHelpText); try @@ -533,6 +581,7 @@ void OControlModel::readHelpTextCompatibly(const staruno::Reference< stario::XOb //------------------------------------------------------------------------------ void OControlModel::writeHelpTextCompatibly(const staruno::Reference< stario::XObjectOutputStream >& _rxOutStream) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::writeHelpTextCompatibly" ); ::rtl::OUString sHelpText; try { @@ -554,7 +603,7 @@ OControlModel::OControlModel( :OComponentHelper(m_aMutex) ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) ,m_aContext( _rxFactory ) - ,m_xServiceFactory(_rxFactory) + ,m_lockCount( 0 ) ,m_aPropertyBagHelper( *this ) ,m_nTabIndex(FRM_DEFAULT_TABINDEX) ,m_nClassId(FormComponentType::CONTROL) @@ -563,6 +612,7 @@ OControlModel::OControlModel( // the native look is ugly .... // #i37342# / 2004-11-19 / frank.schoenheit@sun.com { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::OControlModel" ); DBG_CTOR(OControlModel, NULL); if (_rUnoControlModelTypeName.getLength()) // the is a model we have to aggregate { @@ -599,11 +649,12 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< :OComponentHelper( m_aMutex ) ,OPropertySetAggregationHelper( OComponentHelper::rBHelper ) ,m_aContext( _rxFactory ) - ,m_xServiceFactory( _rxFactory ) + ,m_lockCount( 0 ) ,m_aPropertyBagHelper( *this ) ,m_nTabIndex( FRM_DEFAULT_TABINDEX ) ,m_nClassId( FormComponentType::CONTROL ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::OControlModel(copy)" ); DBG_CTOR( OControlModel, NULL ); DBG_ASSERT( _pOriginal, "OControlModel::OControlModel: invalid original!" ); @@ -648,12 +699,14 @@ OControlModel::~OControlModel() //------------------------------------------------------------------ void OControlModel::clonedFrom( const OControlModel* /*_pOriginal*/ ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::clonedFrom" ); // nothing to do in this base class } //------------------------------------------------------------------------------ void OControlModel::doResetDelegator() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::doResetDelegator" ); if (m_xAggregate.is()) m_xAggregate->setDelegator(NULL); } @@ -661,6 +714,7 @@ void OControlModel::doResetDelegator() //------------------------------------------------------------------------------ void OControlModel::doSetDelegator() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::doSetDelegator" ); increment(m_refCount); if (m_xAggregate.is()) { @@ -673,32 +727,32 @@ void OControlModel::doSetDelegator() //------------------------------------------------------------------------------ InterfaceRef SAL_CALL OControlModel::getParent() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getParent" ); return m_xParent; } //------------------------------------------------------------------------------ void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(com::sun::star::lang::NoSupportException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setParent" ); osl::MutexGuard aGuard(m_aMutex); Reference<XComponent> xComp(m_xParent, UNO_QUERY); if (xComp.is()) xComp->removeEventListener(static_cast<XPropertiesChangeListener*>(this)); - { - xComp = xComp.query( _rxParent ); - RTL_LOGFILE_CONTEXT( aLogger, "OControlModel::setParent::logOnEventListener" ); - if ( xComp.is() ) - xComp->addEventListener(static_cast<XPropertiesChangeListener*>(this)); - } - m_xParent = _rxParent; + xComp = xComp.query( m_xParent ); + + if ( xComp.is() ) + xComp->addEventListener(static_cast<XPropertiesChangeListener*>(this)); } // XNamed //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL OControlModel::getName() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getName" ); ::rtl::OUString aReturn; OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= aReturn; return aReturn; @@ -707,6 +761,7 @@ void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(com: //------------------------------------------------------------------------------ void SAL_CALL OControlModel::setName(const ::rtl::OUString& _rName) throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setName" ); setFastPropertyValue(PROPERTY_ID_NAME, makeAny(_rName)); } @@ -714,6 +769,7 @@ void SAL_CALL OControlModel::setName(const ::rtl::OUString& _rName) throw(Runtim //------------------------------------------------------------------------------ sal_Bool SAL_CALL OControlModel::supportsService(const rtl::OUString& _rServiceName) throw ( RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::supportsService" ); Sequence<rtl::OUString> aSupported = getSupportedServiceNames(); const rtl::OUString* pSupported = aSupported.getConstArray(); for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) @@ -725,6 +781,7 @@ sal_Bool SAL_CALL OControlModel::supportsService(const rtl::OUString& _rServiceN //------------------------------------------------------------------------------ Sequence< ::rtl::OUString > OControlModel::getAggregateServiceNames() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getAggregateServiceNames" ); Sequence< ::rtl::OUString > aAggServices; Reference< XServiceInfo > xInfo; if ( query_aggregation( m_xAggregate, xInfo ) ) @@ -735,6 +792,7 @@ Sequence< ::rtl::OUString > OControlModel::getAggregateServiceNames() //------------------------------------------------------------------------------ Sequence<rtl::OUString> SAL_CALL OControlModel::getSupportedServiceNames() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getSupportedServiceNames" ); return ::comphelper::concatSequences( getAggregateServiceNames(), getSupportedServiceNames_Static() @@ -744,6 +802,7 @@ Sequence<rtl::OUString> SAL_CALL OControlModel::getSupportedServiceNames() throw //------------------------------------------------------------------------------ Sequence< ::rtl::OUString > SAL_CALL OControlModel::getSupportedServiceNames_Static() throw( RuntimeException ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getSupportedServiceNames_Static" ); Sequence< ::rtl::OUString > aServiceNames( 2 ); aServiceNames[ 0 ] = FRM_SUN_FORMCOMPONENT; aServiceNames[ 1 ] = ::rtl::OUString::createFromAscii( "com.sun.star.form.FormControlModel" ); @@ -754,6 +813,7 @@ Sequence< ::rtl::OUString > SAL_CALL OControlModel::getSupportedServiceNames_Sta //------------------------------------------------------------------------------ void SAL_CALL OControlModel::disposing(const com::sun::star::lang::EventObject& _rSource) throw (RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::disposing" ); // release the parent if (_rSource.Source == m_xParent) { @@ -775,6 +835,7 @@ void SAL_CALL OControlModel::disposing(const com::sun::star::lang::EventObject& //----------------------------------------------------------------------------- void OControlModel::disposing() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::disposing" ); OPropertySetAggregationHelper::disposing(); Reference<com::sun::star::lang::XComponent> xComp; @@ -789,6 +850,7 @@ void OControlModel::disposing() //------------------------------------------------------------------------------ void OControlModel::writeAggregate( const Reference< XObjectOutputStream >& _rxOutStream ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::writeAggregate" ); Reference< XPersistObject > xPersist; if ( query_aggregation( m_xAggregate, xPersist ) ) xPersist->write( _rxOutStream ); @@ -797,6 +859,7 @@ void OControlModel::writeAggregate( const Reference< XObjectOutputStream >& _rxO //------------------------------------------------------------------------------ void OControlModel::readAggregate( const Reference< XObjectInputStream >& _rxInStream ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::readAggregate" ); Reference< XPersistObject > xPersist; if ( query_aggregation( m_xAggregate, xPersist ) ) xPersist->read( _rxInStream ); @@ -806,6 +869,7 @@ void OControlModel::readAggregate( const Reference< XObjectInputStream >& _rxInS void SAL_CALL OControlModel::write(const Reference<stario::XObjectOutputStream>& _rxOutStream) throw(stario::IOException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::write" ); osl::MutexGuard aGuard(m_aMutex); // 1. Schreiben des UnoControls @@ -851,6 +915,7 @@ void SAL_CALL OControlModel::write(const Reference<stario::XObjectOutputStream>& //------------------------------------------------------------------------------ void OControlModel::read(const Reference<stario::XObjectInputStream>& InStream) throw (::com::sun::star::io::IOException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::read" ); osl::MutexGuard aGuard(m_aMutex); Reference<stario::XMarkableStream> xMark(InStream, UNO_QUERY); @@ -904,6 +969,7 @@ void OControlModel::read(const Reference<stario::XObjectInputStream>& InStream) //------------------------------------------------------------------------------ PropertyState OControlModel::getPropertyStateByHandle( sal_Int32 _nHandle ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getPropertyStateByHandle" ); // simply compare the current and the default value Any aCurrentValue = getPropertyDefaultByHandle( _nHandle ); Any aDefaultValue; getFastPropertyValue( aDefaultValue, _nHandle ); @@ -920,6 +986,7 @@ PropertyState OControlModel::getPropertyStateByHandle( sal_Int32 _nHandle ) //------------------------------------------------------------------------------ void OControlModel::setPropertyToDefaultByHandle( sal_Int32 _nHandle) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setPropertyToDefaultByHandle" ); Any aDefault = getPropertyDefaultByHandle( _nHandle ); Any aConvertedValue, aOldValue; @@ -933,6 +1000,7 @@ void OControlModel::setPropertyToDefaultByHandle( sal_Int32 _nHandle) //------------------------------------------------------------------------------ Any OControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getPropertyDefaultByHandle" ); Any aReturn; switch ( _nHandle ) { @@ -965,6 +1033,7 @@ Any OControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const //------------------------------------------------------------------------------ void OControlModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getFastPropertyValue" ); switch ( _nHandle ) { case PROPERTY_ID_NAME: @@ -996,6 +1065,7 @@ sal_Bool OControlModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw (com::sun::star::lang::IllegalArgumentException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::convertFastPropertyValue" ); sal_Bool bModified(sal_False); switch (_nHandle) { @@ -1025,6 +1095,7 @@ sal_Bool OControlModel::convertFastPropertyValue( void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setFastPropertyValue_NoBroadcast" ); switch (_nHandle) { case PROPERTY_ID_NAME: @@ -1057,6 +1128,7 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A //------------------------------------------------------------------------------ void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::describeFixedProperties" ); BEGIN_DESCRIBE_BASE_PROPERTIES( 4 ) DECL_PROP2 (CLASSID, sal_Int16, READONLY, TRANSIENT); DECL_PROP1 (NAME, ::rtl::OUString, BOUND); @@ -1068,6 +1140,7 @@ void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) con //------------------------------------------------------------------------------ void OControlModel::describeAggregateProperties( Sequence< Property >& /* [out] */ _rAggregateProps ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::describeAggregateProperties" ); if ( m_xAggregateSet.is() ) { Reference< XPropertySetInfo > xPSI( m_xAggregateSet->getPropertySetInfo() ); @@ -1079,12 +1152,14 @@ void OControlModel::describeAggregateProperties( Sequence< Property >& /* [out] //------------------------------------------------------------------------------ ::osl::Mutex& OControlModel::getMutex() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getMutex" ); return m_aMutex; } //------------------------------------------------------------------------------ void OControlModel::describeFixedAndAggregateProperties( Sequence< Property >& _out_rFixedProperties, Sequence< Property >& _out_rAggregateProperties ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::describeFixedAndAggregateProperties" ); describeFixedProperties( _out_rFixedProperties ); describeAggregateProperties( _out_rAggregateProperties ); } @@ -1092,45 +1167,81 @@ void OControlModel::describeFixedAndAggregateProperties( Sequence< Property >& _ //------------------------------------------------------------------------------ Reference< XMultiPropertySet > OControlModel::getPropertiesInterface() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getPropertiesInterface" ); return Reference< XMultiPropertySet >( *this, UNO_QUERY ); } //------------------------------------------------------------------------------ Reference< XPropertySetInfo> SAL_CALL OControlModel::getPropertySetInfo() throw( RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getPropertySetInfo" ); return createPropertySetInfo( getInfoHelper() ); } //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper& OControlModel::getInfoHelper() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getInfoHelper" ); return m_aPropertyBagHelper.getInfoHelper(); } //-------------------------------------------------------------------- void SAL_CALL OControlModel::addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::addProperty" ); m_aPropertyBagHelper.addProperty( _rName, _nAttributes, _rInitialValue ); } //-------------------------------------------------------------------- void SAL_CALL OControlModel::removeProperty( const ::rtl::OUString& _rName ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::removeProperty" ); m_aPropertyBagHelper.removeProperty( _rName ); } //-------------------------------------------------------------------- Sequence< PropertyValue > SAL_CALL OControlModel::getPropertyValues() throw (RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getPropertyValues" ); return m_aPropertyBagHelper.getPropertyValues(); } //-------------------------------------------------------------------- void SAL_CALL OControlModel::setPropertyValues( const Sequence< PropertyValue >& _rProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setPropertyValues" ); m_aPropertyBagHelper.setPropertyValues( _rProps ); } +//-------------------------------------------------------------------- +void OControlModel::lockInstance( LockAccess ) +{ + m_aMutex.acquire(); + osl_incrementInterlockedCount( &m_lockCount ); +} + +//-------------------------------------------------------------------- +oslInterlockedCount OControlModel::unlockInstance( LockAccess ) +{ + OSL_ENSURE( m_lockCount > 0, "OControlModel::unlockInstance: not locked!" ); + oslInterlockedCount lockCount = osl_decrementInterlockedCount( &m_lockCount ); + m_aMutex.release(); + return lockCount; +} + +//-------------------------------------------------------------------- +void OControlModel::firePropertyChanges( const Sequence< sal_Int32 >& _rHandles, const Sequence< Any >& _rOldValues, + const Sequence< Any >& _rNewValues, LockAccess ) +{ + OPropertySetHelper::fire( + const_cast< Sequence< sal_Int32 >& >( _rHandles ).getArray(), + _rNewValues.getConstArray(), + _rOldValues.getConstArray(), + _rHandles.getLength(), + sal_False + ); +} + //================================================================== //= OBoundControlModel //================================================================== @@ -1141,6 +1252,7 @@ Any SAL_CALL OBoundControlModel::queryAggregation( const Type& _rType ) throw (R Any aReturn( OControlModel::queryAggregation(_rType) ); if (!aReturn.hasValue()) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::queryAggregation" ); aReturn = OBoundControlModel_BASE1::queryInterface(_rType); if ( !aReturn.hasValue() && m_bCommitable ) @@ -1163,15 +1275,17 @@ OBoundControlModel::OBoundControlModel( const sal_Bool _bCommitable, const sal_Bool _bSupportExternalBinding, const sal_Bool _bSupportsValidation ) :OControlModel( _rxFactory, _rUnoControlModelTypeName, _rDefault, sal_False ) ,OPropertyChangeListener( m_aMutex ) + ,m_xField() + ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( -1 ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( false ) + ,m_aResetHelper( *this, m_aMutex ) ,m_aUpdateListeners(m_aMutex) - ,m_aResetListeners(m_aMutex) ,m_aFormComponentListeners( m_aMutex ) ,m_bInputRequired( sal_True ) ,m_pAggPropMultiplexer( NULL ) - ,m_bLoadListening( sal_False ) + ,m_bFormListening( false ) ,m_bLoaded(sal_False) ,m_bRequired(sal_False) ,m_bCommitable(_bCommitable) @@ -1196,16 +1310,18 @@ OBoundControlModel::OBoundControlModel( const OBoundControlModel* _pOriginal, const Reference< XMultiServiceFactory>& _rxFactory ) :OControlModel( _pOriginal, _rxFactory, sal_True, sal_False ) ,OPropertyChangeListener( m_aMutex ) + ,m_xField() + ,m_xAmbientForm() ,m_nValuePropertyAggregateHandle( _pOriginal->m_nValuePropertyAggregateHandle ) ,m_nFieldType( DataType::OTHER ) ,m_bValuePropertyMayBeVoid( _pOriginal->m_bValuePropertyMayBeVoid ) + ,m_aResetHelper( *this, m_aMutex ) ,m_aUpdateListeners( m_aMutex ) - ,m_aResetListeners( m_aMutex ) ,m_aFormComponentListeners( m_aMutex ) ,m_xValidator( _pOriginal->m_xValidator ) ,m_bInputRequired( sal_True ) ,m_pAggPropMultiplexer( NULL ) - ,m_bLoadListening( sal_False ) + ,m_bFormListening( false ) ,m_bLoaded( sal_False ) ,m_bRequired( sal_False ) ,m_bCommitable( _pOriginal->m_bCommitable ) @@ -1382,6 +1498,7 @@ Sequence< Type > OBoundControlModel::_getTypes() //----------------------------------------------------------------------------- void OBoundControlModel::disposing() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::_getTypes" ); OControlModel::disposing(); ::osl::ClearableMutexGuard aGuard(m_aMutex); @@ -1391,11 +1508,11 @@ void OBoundControlModel::disposing() // notify all our listeners com::sun::star::lang::EventObject aEvt( static_cast< XWeak* >( this ) ); - m_aResetListeners.disposeAndClear( aEvt ); m_aUpdateListeners.disposeAndClear( aEvt ); + m_aResetHelper.disposing(); // disconnect from our database column - // TODO: could we replace the following 5 lines with a call to disconnectDatabaseColumn? + // TODO: could we replace the following 5 lines with a call to impl_disconnectDatabaseColumn_noNotify? // The only more thing which it does is calling onDisconnectedDbColumn - could this // cause trouble? At least when we continue to call OControlModel::disposing before, it *may*. if ( hasField() ) @@ -1421,7 +1538,7 @@ void OBoundControlModel::disposing() //------------------------------------------------------------------------------ void OBoundControlModel::_propertyChanged( const PropertyChangeEvent& _rEvt ) throw ( RuntimeException ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_ENSURE( _rEvt.PropertyName == m_sValuePropertyName, "OBoundControlModel::_propertyChanged: where did this come from (1)?" ); @@ -1435,7 +1552,7 @@ void OBoundControlModel::_propertyChanged( const PropertyChangeEvent& _rEvt ) th { // the control value changed, while we have an external value binding // -> forward the value to it if ( m_eControlValueChangeInstigator != eExternalBinding ) - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); } else if ( !m_bCommitable && m_xColumnUpdate.is() ) { // the control value changed, while we are bound to a database column, @@ -1465,56 +1582,71 @@ void OBoundControlModel::startAggregatePropertyListening( const ::rtl::OUString& } //------------------------------------------------------------------------------ -void OBoundControlModel::startLoadListening( ) +void OBoundControlModel::doFormListening( const bool _bStart ) { - OSL_PRECOND( !isLoadListening(), "OBoundControlModel::startLoadListening: already listening!" ); - OSL_PRECOND( m_xParent.is(), "OBoundControlModel::startLoadListening: no parent to listen at!" ); - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::startLoadListening: external value binding should overrule the database binding!" ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::doFormListening: external value binding should overrule the database binding!" ); - Reference< XLoadable > xLoadable( m_xParent, UNO_QUERY ); - if ( xLoadable.is() ) - { - RTL_LOGFILE_CONTEXT( aLogger, "forms::OBoundControlModel::startLoadListening" ); - xLoadable->addLoadListener( this ); - m_bLoadListening = sal_True; - } -} + if ( isFormListening() == _bStart ) + return; -//------------------------------------------------------------------------------ -void OBoundControlModel::stopLoadListening( ) -{ - OSL_PRECOND( isLoadListening(), "OBoundControlModel::stopLoadListening: not listening!" ); + if ( m_xAmbientForm.is() ) + _bStart ? m_xAmbientForm->addLoadListener( this ) : m_xAmbientForm->removeLoadListener( this ); - Reference< XLoadable > xLoadable( m_xParent, UNO_QUERY ); - if ( xLoadable.is() && isLoadListening() ) + Reference< XLoadable > xParentLoadable( getParent(), UNO_QUERY ); + if ( getParent().is() && !xParentLoadable.is() ) { - xLoadable->removeLoadListener( this ); - m_bLoadListening = sal_False; + // if our parent does not directly support the XLoadable interface, then it might support the + // XRowSetSupplier/XRowSetChangeBroadcaster interfaces. In this case we have to listen for changes + // broadcasted by the latter. + Reference< XRowSetChangeBroadcaster > xRowSetBroadcaster( getParent(), UNO_QUERY ); + if ( xRowSetBroadcaster.is() ) + _bStart ? xRowSetBroadcaster->addRowSetChangeListener( this ) : xRowSetBroadcaster->removeRowSetChangeListener( this ); } + + m_bFormListening = _bStart && m_xAmbientForm.is(); } // XChild //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::setParent(const Reference<XInterface>& _rxParent) throw(com::sun::star::lang::NoSupportException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + if ( getParent() == _rxParent ) + return; + + // disconnect from database column (which is controlled by parent, directly or indirectly) + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); // log off old listeners - if ( isLoadListening() ) - stopLoadListening( ); + if ( isFormListening() ) + doFormListening( false ); - OControlModel::setParent(_rxParent); + // actually set the new parent + OControlModel::setParent( _rxParent ); - // log on new listeners - only in case we do not have an external value binding - if ( m_xParent.is() && !hasExternalValueBinding() ) - startLoadListening( ); + // a new parent means a new ambient form + impl_determineAmbientForm_nothrow(); + + if ( !hasExternalValueBinding() ) + { + // log on new listeners + doFormListening( true ); + + // re-connect to database column of the new parent + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); + } } // XEventListener //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObject& _rEvent) throw (RuntimeException) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + if ( _rEvent.Source == getField() ) { resetField(); @@ -1524,11 +1656,8 @@ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObj Reference<XPropertySet> xOldValue = m_xLabelControl; m_xLabelControl = NULL; - // fire a property change event - Any aOldValue; aOldValue <<= xOldValue; - Any aNewValue; aNewValue <<= m_xLabelControl; - sal_Int32 nHandle = PROPERTY_ID_CONTROLLABEL; - OPropertySetHelper::fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False ); + // fire a propertyChanged (when we leave aLock's scope) + aLock.addPropertyNotification( PROPERTY_ID_CONTROLLABEL, makeAny( xOldValue ), makeAny( m_xLabelControl ) ); } else if ( _rEvent.Source == m_xExternalBinding ) { // *first* check for the external binding @@ -1547,6 +1676,7 @@ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObj //------------------------------------------------------------------------------ StringSequence SAL_CALL OBoundControlModel::getSupportedServiceNames() throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::disposing" ); return ::comphelper::concatSequences( getAggregateServiceNames(), getSupportedServiceNames_Static() @@ -1569,6 +1699,7 @@ Sequence< ::rtl::OUString > SAL_CALL OBoundControlModel::getSupportedServiceName //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::write( const Reference<stario::XObjectOutputStream>& _rxOutStream ) throw(stario::IOException, RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::getSupportedServiceNames_Static" ); OControlModel::write(_rxOutStream); osl::MutexGuard aGuard(m_aMutex); @@ -1669,6 +1800,7 @@ void SAL_CALL OBoundControlModel::read( const Reference< stario::XObjectInputStr //------------------------------------------------------------------------------ void OBoundControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OBoundControlModel::getFastPropertyValue" ); switch (nHandle) { case PROPERTY_ID_INPUT_REQUIRED: @@ -1737,6 +1869,7 @@ sal_Bool OBoundControlModel::convertFastPropertyValue( //------------------------------------------------------------------------------ Any OBoundControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::convertFastPropertyValue" ); Any aDefault; switch ( _nHandle ) { @@ -1844,6 +1977,7 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "OControlModel::setFastPropertyValue_NoBroadcast" ); // if the DBColumn value changed, transfer it to the control if ( evt.PropertyName.equals( PROPERTY_VALUE ) ) { @@ -1884,6 +2018,31 @@ void SAL_CALL OBoundControlModel::propertyChange( const PropertyChangeEvent& evt } } +//------------------------------------------------------------------------------ +void SAL_CALL OBoundControlModel::onRowSetChanged( const EventObject& /*i_Event*/ ) throw (RuntimeException) +{ + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + // disconnect from database column (which is controlled by parent, directly or indirectly) + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); + + // log off old listeners + if ( isFormListening() ) + doFormListening( false ); + + // determine the new ambient form + impl_determineAmbientForm_nothrow(); + + // log on new listeners + doFormListening( true ); + + // re-connect to database column if needed and possible + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); +} + // XBoundComponent //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::addUpdateListener(const Reference<XUpdateListener>& _rxListener) throw(RuntimeException) @@ -1900,7 +2059,7 @@ void SAL_CALL OBoundControlModel::removeUpdateListener(const Reference< XUpdateL //------------------------------------------------------------------------------ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_PRECOND( m_bCommitable, "OBoundControlModel::commit: invalid call (I'm not commitable !) " ); if ( hasExternalValueBinding() ) @@ -1911,7 +2070,7 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) if ( !m_sValuePropertyName.getLength() ) // but for those derivees which did not use this feature, we need an // explicit transfer - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); return sal_True; } @@ -1926,12 +2085,12 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) aEvent.Source = static_cast< XWeak* >( this ); sal_Bool bSuccess = sal_True; - aGuard.clear(); + aLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> while (aIter.hasMoreElements() && bSuccess) bSuccess = static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aEvent ); // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - aGuard.reset(); + aLock.acquire(); if ( bSuccess ) { @@ -1948,7 +2107,7 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) if ( bSuccess ) { - aGuard.clear(); + aLock.release(); m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvent ); } @@ -1997,24 +2156,31 @@ sal_Bool OBoundControlModel::connectToField(const Reference<XRowSet>& rForm) sal_Int32 nFieldType = 0; xFieldCandidate->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType; if ( approveDbColumnType( nFieldType ) ) + impl_setField_noNotify( xFieldCandidate ); + } + else + impl_setField_noNotify( NULL ); + + if ( m_xField.is() ) + { + if( m_xField->getPropertySetInfo()->hasPropertyByName( PROPERTY_VALUE ) ) { - m_xField = xFieldCandidate; + // an wertaenderungen horchen m_xField->addPropertyChangeListener( PROPERTY_VALUE, this ); - m_nFieldType = nFieldType; - - // listen to value changes m_xColumnUpdate = Reference< XColumnUpdate >( m_xField, UNO_QUERY ); m_xColumn = Reference< XColumn >( m_xField, UNO_QUERY ); INT32 nNullableFlag = ColumnValue::NO_NULLS; - m_xField->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullableFlag; - m_bRequired = ( ColumnValue::NO_NULLS == nNullableFlag ); + m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag; + m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); // we're optimistic : in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability .... } + else + { + OSL_ENSURE(sal_False, "OBoundControlModel::connectToField: property NAME not supported!"); + impl_setField_noNotify( NULL ); + } } - else - resetField(); - } catch( const Exception& ) { @@ -2056,25 +2222,39 @@ sal_Bool OBoundControlModel::approveDbColumnType(sal_Int32 _nColumnType) return sal_True; } -//============================================================================== -// value binding handling +//------------------------------------------------------------------------------ +void OBoundControlModel::impl_determineAmbientForm_nothrow() +{ + Reference< XInterface > xParent( const_cast< OBoundControlModel* >( this )->getParent() ); + + m_xAmbientForm.set( xParent, UNO_QUERY ); + if ( !m_xAmbientForm.is() ) + { + Reference< XRowSetSupplier > xSupRowSet( xParent, UNO_QUERY ); + if ( xSupRowSet.is() ) + m_xAmbientForm.set( xSupRowSet->getRowSet(), UNO_QUERY ); + } +} //------------------------------------------------------------------------------ -void OBoundControlModel::connectDatabaseColumn( const Reference< XRowSet >& _rxRowSet, bool _bFromReload ) +void OBoundControlModel::impl_connectDatabaseColumn_noNotify( bool _bFromReload ) { - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::connectDatabaseColumn: not to be called with an external value binding!" ); - ::osl::MutexGuard aGuard( m_aMutex ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::impl_connectDatabaseColumn_noNotify: not to be called with an external value binding!" ); // consistency checks DBG_ASSERT( !( hasField() && !_bFromReload ), - "OBoundControlModel::connectDatabaseColumn: the form is just *loaded*, but we already have a field!" ); + "OBoundControlModel::impl_connectDatabaseColumn_noNotify: the form is just *loaded*, but we already have a field!" ); (void)_bFromReload; - Reference< XPropertySet > xOldField = getField(); + Reference< XRowSet > xRowSet( m_xAmbientForm, UNO_QUERY ); + OSL_ENSURE( xRowSet.is(), "OBoundControlModel::impl_connectDatabaseColumn_noNotify: no row set!" ); + if ( !xRowSet.is() ) + return; + if ( !hasField() ) { // connect to the column - connectToField( _rxRowSet ); + connectToField( xRowSet ); } // now that we're connected (more or less, even if we did not find a column), @@ -2083,26 +2263,17 @@ void OBoundControlModel::connectDatabaseColumn( const Reference< XRowSet >& _rxR // let derived classes react on this new connection m_bLoaded = sal_True; - onConnectedDbColumn( _rxRowSet ); + onConnectedDbColumn( xRowSet ); // initially transfer the db column value to the control, if we successfully connected to a database column if ( hasField() ) - initFromField( _rxRowSet ); - - if ( xOldField != getField() ) - { - Any aNewValue; aNewValue <<= getField(); - Any aOldValue; aOldValue <<= xOldField; - sal_Int32 nHandle = PROPERTY_ID_BOUNDFIELD; - OPropertySetHelper::fire(&nHandle, &aNewValue, &aOldValue, 1, sal_False); - } + initFromField( xRowSet ); } //------------------------------------------------------------------------------ -void OBoundControlModel::disconnectDatabaseColumn( ) +void OBoundControlModel::impl_disconnectDatabaseColumn_noNotify() { - OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::disconnectDatabaseColumn: not to be called with an external value binding!" ); - ::osl::MutexGuard aGuard( m_aMutex ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::impl_disconnectDatabaseColumn_noNotify: not to be called with an external value binding!" ); // let derived classes react on this onDisconnectedDbColumn(); @@ -2122,14 +2293,17 @@ void OBoundControlModel::disconnectDatabaseColumn( ) //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::loaded( const EventObject& _rEvent ) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + OSL_ENSURE( _rEvent.Source == m_xAmbientForm, "OBoundControlModel::loaded: where does this come from?" ); + (void)_rEvent; + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::loaded: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - // connect to the database column described by our SQL-binding-related properties - Reference< XRowSet > xRowSet( _rEvent.Source, UNO_QUERY ); - DBG_ASSERT( xRowSet.is(), "OBoundControlModel::loaded: event source is no RowSet?!" ); - connectDatabaseColumn( xRowSet, false ); + impl_connectDatabaseColumn_noNotify( false ); } @@ -2153,24 +2327,30 @@ void SAL_CALL OBoundControlModel::reloading( const com::sun::star::lang::EventOb //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::unloading(const com::sun::star::lang::EventObject& /*aEvent*/) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::unloading: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - // disconnect from the database column described by our SQL-binding-related properties - disconnectDatabaseColumn(); + impl_disconnectDatabaseColumn_noNotify(); } //------------------------------------------------------------------------------ void SAL_CALL OBoundControlModel::reloaded( const EventObject& _rEvent ) throw(RuntimeException) { + ControlModelLock aLock( *this ); + FieldChangeNotifier aBoundFieldNotifier( aLock ); + + OSL_ENSURE( _rEvent.Source == m_xAmbientForm, "OBoundControlModel::reloaded: where does this come from?" ); + (void)_rEvent; + OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::reloaded: we should never reach this with an external value binding!" ); if ( hasExternalValueBinding() ) return; - Reference< XRowSet > xRowSet( _rEvent.Source, UNO_QUERY ); - DBG_ASSERT( xRowSet.is(), "OBoundControlModel::reloaded: event source is no RowSet?!" ); - connectDatabaseColumn( xRowSet, true ); + impl_connectDatabaseColumn_noNotify( true ); } //------------------------------------------------------------------------------ @@ -2289,28 +2469,22 @@ void OBoundControlModel::resetNoBroadcast() //----------------------------------------------------------------------------- void OBoundControlModel::addResetListener(const Reference<XResetListener>& l) throw (RuntimeException) { - m_aResetListeners.addInterface(l); + m_aResetHelper.addResetListener( l ); } //----------------------------------------------------------------------------- void OBoundControlModel::removeResetListener(const Reference<XResetListener>& l) throw (RuntimeException) { - m_aResetListeners.removeInterface(l); + m_aResetHelper.removeResetListener( l ); } //----------------------------------------------------------------------------- void OBoundControlModel::reset() throw (RuntimeException) { - cppu::OInterfaceIteratorHelper aIter(m_aResetListeners); - EventObject aResetEvent(static_cast<XWeak*>(this)); - sal_Bool bContinue = sal_True; - while ( aIter.hasMoreElements() && bContinue ) - bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent ); + if ( !m_aResetHelper.approveReset() ) + return; - if (!bContinue) - return; - - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); // on a new record? sal_Bool bIsNewRecord = sal_False; @@ -2414,17 +2588,25 @@ void OBoundControlModel::reset() throw (RuntimeException) // transfer to the external binding, if necessary if ( hasExternalValueBinding() ) - transferControlValueToExternal( aGuard ); + transferControlValueToExternal( aLock ); } // revalidate, if necessary if ( hasValidator() ) recheckValidity( true ); - aGuard.clear(); + aLock.release(); - m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent ); + m_aResetHelper.notifyResetted(); } + +// ----------------------------------------------------------------------------- +void OBoundControlModel::impl_setField_noNotify( const Reference< XPropertySet>& _rxField ) +{ + DBG_ASSERT( !hasExternalValueBinding(), "OBoundControlModel::impl_setField_noNotify: We have an external value binding!" ); + m_xField = _rxField; +} + //-------------------------------------------------------------------- sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< XValueBinding >& _rxBinding ) { @@ -2433,10 +2615,10 @@ sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< X Sequence< Type > aTypeCandidates; { - // >>>>>>>> ----- SAFE ----- >>>>>>>> + // SYNCHRONIZED --> ::osl::MutexGuard aGuard( m_aMutex ); aTypeCandidates = getSupportedBindingTypes(); - // <<<<<<<< ----- SAFE ----- <<<<<<<< + // <-- SYNCHRONIZED } for ( const Type* pType = aTypeCandidates.getConstArray(); @@ -2453,18 +2635,19 @@ sal_Bool OBoundControlModel::impl_approveValueBinding_nolock( const Reference< X //-------------------------------------------------------------------- void OBoundControlModel::connectExternalValueBinding( - const Reference< XValueBinding >& _rxBinding, ::osl::ResettableMutexGuard& _rInstanceLock ) + const Reference< XValueBinding >& _rxBinding, ControlModelLock& _rInstanceLock ) { OSL_PRECOND( _rxBinding.is(), "OBoundControlModel::connectExternalValueBinding: invalid binding instance!" ); OSL_PRECOND( !hasExternalValueBinding( ), "OBoundControlModel::connectExternalValueBinding: precond not met (currently have a binding)!" ); - // Suspend being a load listener at our parent form. This is because - // an external value binding overrules a possible database binding - if ( isLoadListening() ) - stopLoadListening( ); + // if we're connected to a database column, suspend this + if ( hasField() ) + impl_disconnectDatabaseColumn_noNotify(); - // TODO: if we're already connected to a db column, we should disconnect from it here, - // shouldn't we? + // suspend listening for load-related events at out ambient form. + // This is because an external value binding overrules a possible database binding. + if ( isFormListening() ) + doFormListening( false ); // remember this new binding m_xExternalBinding = _rxBinding; @@ -2551,13 +2734,13 @@ void OBoundControlModel::disconnectExternalValueBinding( ) // no binding anymore m_xExternalBinding.clear(); - // be a load listener at our parent, again. This was suspended while we had + // be a load listener at our form, again. This was suspended while we had // an external value binding in place. - if ( m_xParent.is() ) - startLoadListening( ); + doFormListening( true ); - // TODO: anything to care for here? Changing values? Falling back to a - // database binding if appropriate? + // re-connect to database column of the new parent + if ( m_xAmbientForm.is() && m_xAmbientForm->isLoaded() ) + impl_connectDatabaseColumn_noNotify( false ); // tell the derivee onDisconnectedExternalValue(); @@ -2578,7 +2761,11 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin ); } - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); + + // since a ValueBinding overrules any potentially active database binding, the change in a ValueBinding + // might trigger a change in our BoundField. + FieldChangeNotifier aBoundFieldNotifier( aLock ); // disconnect from the old binding if ( hasExternalValueBinding() ) @@ -2586,7 +2773,7 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin // connect to the new binding if ( _rxBinding.is() ) - connectExternalValueBinding( _rxBinding, aGuard ); + connectExternalValueBinding( _rxBinding, aLock ); } //-------------------------------------------------------------------- @@ -2603,12 +2790,12 @@ Reference< XValueBinding > SAL_CALL OBoundControlModel::getValueBinding( ) thro //-------------------------------------------------------------------- void SAL_CALL OBoundControlModel::modified( const EventObject& _rEvent ) throw ( RuntimeException ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); OSL_PRECOND( hasExternalValueBinding(), "OBoundControlModel::modified: Where did this come from?" ); if ( !m_bTransferingValue && ( m_xExternalBinding == _rEvent.Source ) && m_xExternalBinding.is() ) { - transferExternalValueToControl( aGuard ); + transferExternalValueToControl( aLock ); } } @@ -2619,12 +2806,12 @@ void OBoundControlModel::transferDbValueToControl( ) } //------------------------------------------------------------------------------ -void OBoundControlModel::transferExternalValueToControl( ::osl::ResettableMutexGuard& _rInstanceLock ) +void OBoundControlModel::transferExternalValueToControl( ControlModelLock& _rInstanceLock ) { Reference< XValueBinding > xExternalBinding( m_xExternalBinding ); Type aValueExchangeType( getExternalValueType() ); - _rInstanceLock.clear(); + _rInstanceLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> Any aExternalValue; try @@ -2636,13 +2823,13 @@ void OBoundControlModel::transferExternalValueToControl( ::osl::ResettableMutexG DBG_UNHANDLED_EXCEPTION(); } // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - _rInstanceLock.reset(); + _rInstanceLock.acquire(); setControlValue( translateExternalValueToControlValue( aExternalValue ), eExternalBinding ); } //------------------------------------------------------------------------------ -void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexGuard& _rInstanceLock ) +void OBoundControlModel::transferControlValueToExternal( ControlModelLock& _rInstanceLock ) { OSL_PRECOND( m_bSupportsExternalBinding && hasExternalValueBinding(), "OBoundControlModel::transferControlValueToExternal: precondition not met!" ); @@ -2652,7 +2839,7 @@ void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexG Any aExternalValue( translateControlValueToExternalValue() ); m_bTransferingValue = sal_True; - _rInstanceLock.clear(); + _rInstanceLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> try { @@ -2663,7 +2850,7 @@ void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexG DBG_UNHANDLED_EXCEPTION(); } // <<<<<<<< ----- UNSAFE ----- <<<<<<<< - _rInstanceLock.reset(); + _rInstanceLock.acquire(); m_bTransferingValue = sal_False; } diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 00a8de08a5ef..bc0e952f1735 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -671,14 +671,14 @@ Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() co Reference< XRowSet > xRowSet( xNextParentForm, UNO_QUERY ); Reference< XNumberFormatsSupplier > xSupplier; if (xRowSet.is()) - xSupplier = getNumberFormats(getConnection(xRowSet), sal_True, m_xServiceFactory); + xSupplier = getNumberFormats( getConnection(xRowSet), sal_True, getContext().getLegacyServiceFactory() ); return xSupplier; } //------------------------------------------------------------------------------ Reference< XNumberFormatsSupplier > OFormattedModel::calcDefaultFormatsSupplier() const { - return StandardFormatsSupplier::get( m_xServiceFactory ); + return StandardFormatsSupplier::get( getContext().getLegacyServiceFactory() ); } // XBoundComponent diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx index 81419eca6c77..ff4e0185826c 100644 --- a/forms/source/component/FormsCollection.cxx +++ b/forms/source/component/FormsCollection.cxx @@ -46,6 +46,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::form; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::util; + //------------------------------------------------------------------ DBG_NAME(OFormsCollection) //------------------------------------------------------------------ @@ -74,13 +76,23 @@ Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException) //------------------------------------------------------------------ OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory) - :FormsCollectionComponentBase(m_aMutex) - ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XForm>*>(NULL))) + :FormsCollectionComponentBase( m_aMutex ) + ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() ) + ,OFormsCollection_BASE() { DBG_CTOR(OFormsCollection, NULL); } //------------------------------------------------------------------------------ +OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource ) + :FormsCollectionComponentBase( m_aMutex ) + ,OInterfaceContainer( m_aMutex, _cloneSource ) + ,OFormsCollection_BASE() +{ + DBG_CTOR( OFormsCollection, NULL ); +} + +//------------------------------------------------------------------------------ OFormsCollection::~OFormsCollection() { DBG_DTOR(OFormsCollection, NULL); @@ -134,6 +146,17 @@ StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(Runti return aReturn; } +// XCloneable +//------------------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) throw (RuntimeException) +{ + OFormsCollection* pClone = new OFormsCollection( *this ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return pClone; +} + // OComponentHelper //------------------------------------------------------------------------------ void OFormsCollection::disposing() diff --git a/forms/source/component/FormsCollection.hxx b/forms/source/component/FormsCollection.hxx index c93256d399fd..0ef86327dc52 100644 --- a/forms/source/component/FormsCollection.hxx +++ b/forms/source/component/FormsCollection.hxx @@ -63,6 +63,7 @@ class OFormsCollection public: OFormsCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + OFormsCollection( const OFormsCollection& _cloneSource ); virtual ~OFormsCollection(); public: @@ -82,6 +83,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); virtual StringSequence SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + // OComponentHelper virtual void SAL_CALL disposing(); diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index 270fa2c9547e..ef0abf146632 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -99,10 +99,12 @@ OGridControlModel::OGridControlModel(const Reference<XMultiServiceFactory>& _rxF ,FontControlModel( false ) ,m_aSelectListeners(m_aMutex) ,m_aResetListeners(m_aMutex) + ,m_aRowSetChangeListeners(m_aMutex) ,m_aDefaultControl( FRM_SUN_CONTROL_GRIDCONTROL ) ,m_nBorder(1) ,m_nWritingMode( WritingMode2::CONTEXT ) ,m_nContextWritingMode( WritingMode2::CONTEXT ) + ,m_bEnableVisible(sal_True) ,m_bEnable(sal_True) ,m_bNavigation(sal_True) ,m_bRecordMarker(sal_True) @@ -123,11 +125,13 @@ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const ,FontControlModel( _pOriginal ) ,m_aSelectListeners( m_aMutex ) ,m_aResetListeners( m_aMutex ) + ,m_aRowSetChangeListeners( m_aMutex ) { DBG_CTOR(OGridControlModel,NULL); m_aDefaultControl = _pOriginal->m_aDefaultControl; m_bEnable = _pOriginal->m_bEnable; + m_bEnableVisible = _pOriginal->m_bEnableVisible; m_bNavigation = _pOriginal->m_bNavigation; m_nBorder = _pOriginal->m_nBorder; m_nWritingMode = _pOriginal->m_nWritingMode; @@ -157,7 +161,17 @@ OGridControlModel::~OGridControlModel() // XCloneable //------------------------------------------------------------------------------ -IMPLEMENT_DEFAULT_CLONING( OGridControlModel ) +Reference< XCloneable > SAL_CALL OGridControlModel::createClone( ) throw (RuntimeException) +{ + OGridControlModel* pClone = new OGridControlModel( this, getContext().getLegacyServiceFactory() ); + osl_incrementInterlockedCount( &pClone->m_refCount ); + pClone->OControlModel::clonedFrom( this ); + // do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is + // already done in the ctor + //pClone->OInterfaceContainer::clonedFrom( *this ); + osl_decrementInterlockedCount( &pClone->m_refCount ); + return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) ); +} //------------------------------------------------------------------------------ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer ) @@ -234,20 +248,47 @@ void SAL_CALL OGridControlModel::errorOccured( const SQLErrorEvent& _rEvent ) th onError( _rEvent ); } +// XRowSetSupplier +//------------------------------------------------------------------------------ +Reference< XRowSet > SAL_CALL OGridControlModel::getRowSet( ) throw (RuntimeException) +{ + return Reference< XRowSet >( getParent(), UNO_QUERY ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OGridControlModel::setRowSet( const Reference< XRowSet >& /*_rxDataSource*/ ) throw (RuntimeException) +{ + OSL_ENSURE( false, "OGridControlModel::setRowSet: not supported!" ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OGridControlModel::addRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException) +{ + if ( i_Listener.is() ) + m_aRowSetChangeListeners.addInterface( i_Listener ); +} + +//-------------------------------------------------------------------- +void SAL_CALL OGridControlModel::removeRowSetChangeListener( const Reference< XRowSetChangeListener >& i_Listener ) throw (RuntimeException) +{ + m_aRowSetChangeListeners.removeInterface( i_Listener ); +} + // XChild //------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::setParent(const InterfaceRef& Parent) throw(NoSupportException, RuntimeException) +void SAL_CALL OGridControlModel::setParent( const InterfaceRef& i_Parent ) throw(NoSupportException, RuntimeException) { - if (m_xParentFormLoadable.is()) - m_xParentFormLoadable->removeLoadListener(this); + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + if ( i_Parent == getParent() ) + return; - OControlModel::setParent(Parent); + OControlModel::setParent( i_Parent ); - Reference< XForm > xForm(m_xParent, UNO_QUERY); - m_xParentFormLoadable = Reference< XLoadable > (xForm, UNO_QUERY); - if (m_xParentFormLoadable.is()) - m_xParentFormLoadable->addLoadListener(this); + EventObject aEvent( *this ); + aGuard.clear(); + m_aRowSetChangeListeners.notifyEach( &XRowSetChangeListener::onRowSetChanged, aEvent ); } + //------------------------------------------------------------------------------ Sequence< Type > SAL_CALL OGridControlModel::getTypes( ) throw(RuntimeException) { @@ -274,6 +315,7 @@ void OGridControlModel::disposing() EventObject aEvt(static_cast<XWeak*>(this)); m_aSelectListeners.disposeAndClear(aEvt); m_aResetListeners.disposeAndClear(aEvt); + m_aRowSetChangeListeners.disposeAndClear(aEvt); } // XEventListener @@ -288,6 +330,8 @@ void OGridControlModel::disposing(const EventObject& _rEvent) throw( RuntimeExce //----------------------------------------------------------------------------- sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalArgumentException, RuntimeException) { + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + Reference<XPropertySet> xSel; if (rElement.hasValue() && !::cppu::extractInterface(xSel, rElement)) { @@ -304,11 +348,11 @@ sal_Bool SAL_CALL OGridControlModel::select(const Any& rElement) throw(IllegalAr } } - if (xSel != m_xSelection) + if ( xSel != m_xSelection ) { m_xSelection = xSel; - EventObject aEvt(xMe); - m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt ); + aGuard.clear(); + m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) ); return sal_True; } return sal_False; @@ -346,16 +390,16 @@ Reference<XPropertySet> OGridControlModel::createColumn(sal_Int32 nTypeId) cons Reference<XPropertySet> xReturn; switch (nTypeId) { - case TYPE_CHECKBOX: xReturn = new CheckBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_COMBOBOX: xReturn = new ComboBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_DATEFIELD: xReturn = new DateFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_LISTBOX: xReturn = new ListBoxColumn(OControlModel::m_xServiceFactory); break; - case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_TEXTFIELD: xReturn = new TextFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn(OControlModel::m_xServiceFactory); break; - case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn(OControlModel::m_xServiceFactory); break; + case TYPE_CHECKBOX: xReturn = new CheckBoxColumn( getContext() ); break; + case TYPE_COMBOBOX: xReturn = new ComboBoxColumn( getContext() ); break; + case TYPE_CURRENCYFIELD: xReturn = new CurrencyFieldColumn( getContext() ); break; + case TYPE_DATEFIELD: xReturn = new DateFieldColumn( getContext() ); break; + case TYPE_LISTBOX: xReturn = new ListBoxColumn( getContext() ); break; + case TYPE_NUMERICFIELD: xReturn = new NumericFieldColumn( getContext() ); break; + case TYPE_PATTERNFIELD: xReturn = new PatternFieldColumn( getContext() ); break; + case TYPE_TEXTFIELD: xReturn = new TextFieldColumn( getContext() ); break; + case TYPE_TIMEFIELD: xReturn = new TimeFieldColumn( getContext() ); break; + case TYPE_FORMATTEDFIELD: xReturn = new FormattedFieldColumn( getContext() ); break; default: DBG_ERROR("OGridControlModel::createColumn: Unknown Column"); break; @@ -415,7 +459,7 @@ void OGridControlModel::_reset() //------------------------------------------------------------------------------ void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES( 36 ) + BEGIN_DESCRIBE_BASE_PROPERTIES( 37 ) DECL_PROP1(NAME, ::rtl::OUString, BOUND); DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT); DECL_PROP1(TAG, ::rtl::OUString, BOUND); @@ -423,6 +467,7 @@ void OGridControlModel::describeFixedProperties( Sequence< Property >& _rProps ) DECL_PROP3(TABSTOP, sal_Bool, BOUND, MAYBEDEFAULT, MAYBEVOID); DECL_PROP2(HASNAVIGATION, sal_Bool, BOUND, MAYBEDEFAULT); DECL_PROP1(ENABLED, sal_Bool, BOUND); + DECL_PROP2(ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT); DECL_PROP1(BORDER, sal_Int16, BOUND); DECL_PROP2(BORDERCOLOR, sal_Int16, BOUND, MAYBEVOID); DECL_PROP1(DEFAULTCONTROL, ::rtl::OUString, BOUND); @@ -496,6 +541,9 @@ void OGridControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) co case PROPERTY_ID_ENABLED: setBOOL(rValue, m_bEnable); break; + case PROPERTY_ID_ENABLEVISIBLE: + setBOOL(rValue, m_bEnableVisible); + break; case PROPERTY_ID_BORDER: rValue <<= (sal_Int16)m_nBorder; break; @@ -574,6 +622,9 @@ sal_Bool OGridControlModel::convertFastPropertyValue( Any& rConvertedValue, Any& case PROPERTY_ID_ENABLED: bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnable); break; + case PROPERTY_ID_ENABLEVISIBLE: + bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEnableVisible); + break; case PROPERTY_ID_BORDER: bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_nBorder); break; @@ -645,6 +696,9 @@ void OGridControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, con case PROPERTY_ID_ENABLED: m_bEnable = getBOOL(rValue); break; + case PROPERTY_ID_ENABLEVISIBLE: + m_bEnableVisible = getBOOL(rValue); + break; case PROPERTY_ID_RECORDMARKER: m_bRecordMarker = getBOOL(rValue); break; @@ -702,6 +756,7 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const case PROPERTY_ID_RECORDMARKER: case PROPERTY_ID_DISPLAYSYNCHRON: case PROPERTY_ID_ENABLED: + case PROPERTY_ID_ENABLEVISIBLE: aReturn = makeBoolAny(sal_True); break; @@ -735,72 +790,6 @@ Any OGridControlModel::getPropertyDefaultByHandle( sal_Int32 nHandle ) const return aReturn; } -// XLoadListener -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::loaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; ++nIndex) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->loaded(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::unloaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->unloaded(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::reloading(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->reloading(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::unloading(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->unloading(rEvent); - } -} - -//------------------------------------------------------------------------------ -void SAL_CALL OGridControlModel::reloaded(const EventObject& rEvent) throw(RuntimeException) -{ - Reference<XLoadListener> xListener; - sal_Int32 nCount = getCount(); - for (sal_Int32 nIndex=0; nIndex < nCount; nIndex++) - { - getByIndex(nIndex) >>= xListener; - if (xListener.is()) - xListener->reloaded(rEvent); - } -} - //------------------------------------------------------------------------------ OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxIFace) const { @@ -813,42 +802,32 @@ OGridColumn* OGridControlModel::getColumnImplementation(const InterfaceRef& _rxI } //------------------------------------------------------------------------------ -void OGridControlModel::gotColumn(const Reference< XInterface >& _rxColumn) +void OGridControlModel::gotColumn( const Reference< XInterface >& _rxColumn ) { - // if our form is already loaded, tell the column - // 18.05.2001 - 86558 - frank.schoenheit@germany.sun.com - if (m_xParentFormLoadable.is() && m_xParentFormLoadable->isLoaded()) - { - Reference< XLoadListener > xColumnLoadListener(_rxColumn, UNO_QUERY); - if (xColumnLoadListener.is()) - { // it's kind of a fake ... - EventObject aFakedLoadEvent; - aFakedLoadEvent.Source = m_xParentFormLoadable; - xColumnLoadListener->loaded(aFakedLoadEvent); - } - } + Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY ); + if ( xBroadcaster.is() ) + xBroadcaster->addSQLErrorListener( this ); } //------------------------------------------------------------------------------ void OGridControlModel::lostColumn(const Reference< XInterface >& _rxColumn) { - if (Reference<XInterface>(m_xSelection, UNO_QUERY).get() == Reference<XInterface>(_rxColumn, UNO_QUERY).get()) + if ( m_xSelection == _rxColumn ) { // the currently selected element was replaced m_xSelection.clear(); - EventObject aEvt(static_cast<XWeak*>(this)); + EventObject aEvt( static_cast< XWeak* >( this ) ); m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvt ); } + + Reference< XSQLErrorBroadcaster > xBroadcaster( _rxColumn, UNO_QUERY ); + if ( xBroadcaster.is() ) + xBroadcaster->removeSQLErrorListener( this ); } //------------------------------------------------------------------------------ void OGridControlModel::implRemoved(const InterfaceRef& _rxObject) { OInterfaceContainer::implRemoved(_rxObject); - - Reference< XSQLErrorBroadcaster > xBroadcaster( _rxObject, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->removeSQLErrorListener( this ); - lostColumn(_rxObject); } @@ -856,20 +835,30 @@ void OGridControlModel::implRemoved(const InterfaceRef& _rxObject) void OGridControlModel::implInserted( const ElementDescription* _pElement ) { OInterfaceContainer::implInserted( _pElement ); - - Reference< XSQLErrorBroadcaster > xBroadcaster( _pElement->xInterface, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->addSQLErrorListener( this ); - gotColumn( _pElement->xInterface ); } //------------------------------------------------------------------------------ -void OGridControlModel::implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ) +void OGridControlModel::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock ) { - OInterfaceContainer::implReplaced( _rxReplacedObject, _pElement ); - lostColumn( _rxReplacedObject ); - gotColumn( _pElement->xInterface ); + Reference< XInterface > xOldColumn( _rEvent.ReplacedElement, UNO_QUERY ); + Reference< XInterface > xNewColumn( _rEvent.Element, UNO_QUERY ); + + bool bNewSelection = ( xOldColumn == m_xSelection ); + + lostColumn( xOldColumn ); + gotColumn( xNewColumn ); + + if ( bNewSelection ) + m_xSelection.set( xNewColumn, UNO_QUERY ); + + OInterfaceContainer::impl_replacedElement( _rEvent, _rInstanceLock ); + // <<---- SYNCHRONIZED + + if ( bNewSelection ) + { + m_aSelectListeners.notifyEach( &XSelectionChangeListener::selectionChanged, EventObject( *this ) ); + } } //------------------------------------------------------------------------------ diff --git a/forms/source/component/Grid.hxx b/forms/source/component/Grid.hxx index 716f1a4ca739..f5bb60489e45 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -28,16 +28,22 @@ * ************************************************************************/ +#include "errorbroadcaster.hxx" #include "FormComponent.hxx" +#include "formcontrolfont.hxx" +#include "InterfaceContainer.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/form/XGridColumnFactory.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/form/XLoadable.hpp> -#include <tools/link.hxx> -#include "InterfaceContainer.hxx" +#include <com/sun/star/sdb/XRowSetSupplier.hpp> +#include <com/sun/star/sdb/XRowSetChangeBroadcaster.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +/** === end UNO includes === **/ + #include <comphelper/proparrhlp.hxx> -#include <cppuhelper/implbase6.hxx> -#include "errorbroadcaster.hxx" -#include "formcontrolfont.hxx" +#include <cppuhelper/implbase7.hxx> +#include <tools/link.hxx> //......................................................................... namespace frm @@ -59,12 +65,13 @@ class OGridColumn; //================================================================== // OGridControlModel //================================================================== -typedef ::cppu::ImplHelper6 < ::com::sun::star::awt::XControlModel +typedef ::cppu::ImplHelper7 < ::com::sun::star::awt::XControlModel , ::com::sun::star::form::XGridColumnFactory - , ::com::sun::star::form::XLoadListener , ::com::sun::star::form::XReset , ::com::sun::star::view::XSelectionSupplier , ::com::sun::star::sdb::XSQLErrorListener + , ::com::sun::star::sdb::XRowSetSupplier + , ::com::sun::star::sdb::XRowSetChangeBroadcaster > OGridControlModel_BASE; class OGridControlModel :public OControlModel @@ -74,7 +81,8 @@ class OGridControlModel :public OControlModel ,public OGridControlModel_BASE { ::cppu::OInterfaceContainerHelper m_aSelectListeners, - m_aResetListeners; + m_aResetListeners, + m_aRowSetChangeListeners; // [properties] ::com::sun::star::uno::Any m_aRowHeight; // Zeilenhoehe @@ -87,13 +95,13 @@ class OGridControlModel :public OControlModel // [properties] ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSelection; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xParentFormLoadable; // [properties] ::rtl::OUString m_sHelpURL; // URL sal_Int16 m_nBorder; sal_Int16 m_nWritingMode; sal_Int16 m_nContextWritingMode; + sal_Bool m_bEnableVisible : 1; sal_Bool m_bEnable : 1; sal_Bool m_bNavigation : 1; sal_Bool m_bRecordMarker : 1; @@ -128,13 +136,6 @@ public: // XEventListener virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); - // XLoadListener - virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); - // XReset virtual void SAL_CALL reset() throw ( ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException); @@ -168,6 +169,14 @@ public: // XSQLErrorListener virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + // XRowSetSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getRowSet( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowSet( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xDataSource ) throw (::com::sun::star::uno::RuntimeException); + + // XRowSetChangeBroadcaster + virtual void SAL_CALL addRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRowSetChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetChangeListener >& i_Listener ) throw (::com::sun::star::uno::RuntimeException); + // OControlModel's property handling virtual void describeFixedProperties( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps @@ -195,7 +204,10 @@ protected: protected: virtual void implRemoved(const InterfaceRef& _rxObject); virtual void implInserted( const ElementDescription* _pElement ); - virtual void implReplaced( const InterfaceRef& _rxReplacedObject, const ElementDescription* _pElement ); + virtual void impl_replacedElement( + const ::com::sun::star::container::ContainerEvent& _rEvent, + ::osl::ClearableMutexGuard& _rInstanceLock + ); void gotColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); void lostColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxColumn); diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 6376f0401a6e..5d30c2776659 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -378,7 +378,7 @@ sal_Bool OImageControlModel::impl_updateStreamForURL_lck( const ::rtl::OUString& if ( ::svt::GraphicAccess::isSupportedURL( _rURL ) ) { - xImageStream = ::svt::GraphicAccess::getImageXStream( getORB(), _rURL ); + xImageStream = ::svt::GraphicAccess::getImageXStream( getContext().getLegacyServiceFactory(), _rURL ); } else { @@ -591,7 +591,7 @@ void OImageControlModel::doSetControlValue( const Any& _rValue ) // OComponentHelper //------------------------------------------------------------------ -void OImageControlModel::disposing() +void SAL_CALL OImageControlModel::disposing() { OBoundControlModel::disposing(); @@ -646,25 +646,16 @@ InterfaceRef SAL_CALL OImageControlControl_CreateInstance(const Reference<XMulti //------------------------------------------------------------------------------ Sequence<Type> OImageControlControl::_getTypes() { - static Sequence<Type> aTypes; - if (!aTypes.getLength()) - { - // my base class - Sequence<Type> aBaseClassTypes = OBoundControl::_getTypes(); - - Sequence<Type> aOwnTypes(1); - Type* pOwnTypes = aOwnTypes.getArray(); - pOwnTypes[0] = getCppuType((Reference<XMouseListener>*)NULL); - - aTypes = concatSequences(aBaseClassTypes, aOwnTypes); - } - return aTypes; + return concatSequences( + OBoundControl::_getTypes(), + OImageControlControl_Base::getTypes() + ); } //------------------------------------------------------------------------------ OImageControlControl::OImageControlControl(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControl(_rxFactory, VCL_CONTROL_IMAGECONTROL) - ,m_pImageIndicator( new OImageIndicator ) + ,m_aModifyListeners( m_aMutex ) { increment(m_refCount); { @@ -677,14 +668,15 @@ OImageControlControl::OImageControlControl(const Reference<XMultiServiceFactory> decrement(m_refCount); } -// UNO Anbindung //------------------------------------------------------------------------------ Any SAL_CALL OImageControlControl::queryAggregation(const Type& _rType) throw (RuntimeException) { - Any aReturn = OBoundControl::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType - ,static_cast<XMouseListener*>(this) + Any aReturn = OBoundControl::queryAggregation( _rType ); + if ( !aReturn.hasValue() ) + aReturn = ::cppu::queryInterface( + _rType, + static_cast< XMouseListener* >( this ), + static_cast< XModifyBroadcaster* >( this ) ); return aReturn; @@ -701,23 +693,31 @@ StringSequence OImageControlControl::getSupportedServiceNames() throw() return aSupported; } -//-------------------------------------------------------------------- -sal_Bool SAL_CALL OImageControlControl::setModel(const Reference<starawt::XControlModel>& _rxModel ) throw (RuntimeException) +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::addModifyListener( const Reference< XModifyListener >& _Listener ) throw (RuntimeException) { - Reference< XImageProducer > xProducer( getModel(), UNO_QUERY ); - if ( xProducer.is() ) - xProducer->removeConsumer( m_pImageIndicator.getRef() ); + m_aModifyListeners.addInterface( _Listener ); +} - sal_Bool bReturn = OBoundControl::setModel( _rxModel ); +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::removeModifyListener( const Reference< XModifyListener >& _Listener ) throw (RuntimeException) +{ + m_aModifyListeners.removeInterface( _Listener ); +} - xProducer = xProducer.query( getModel() ); - if ( xProducer.is() ) - { - m_pImageIndicator->reset(); - xProducer->addConsumer( m_pImageIndicator.getRef() ); - } +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::disposing() +{ + EventObject aEvent( *this ); + m_aModifyListeners.disposeAndClear( aEvent ); - return bReturn; + OBoundControl::disposing(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OImageControlControl::disposing( const EventObject& _Event ) throw(RuntimeException) +{ + OBoundControl::disposing( _Event ); } //------------------------------------------------------------------------------ @@ -744,11 +744,11 @@ void OImageControlControl::implClearGraphics( sal_Bool _bForce ) } //------------------------------------------------------------------------------ -void OImageControlControl::implInsertGraphics() +bool OImageControlControl::implInsertGraphics() { Reference< XPropertySet > xSet( getModel(), UNO_QUERY ); if ( !xSet.is() ) - return; + return false; ::rtl::OUString sTitle = FRM_RES_STRING(RID_STR_IMPORT_GRAPHIC); // build some arguments for the upcoming dialog @@ -757,30 +757,26 @@ void OImageControlControl::implInsertGraphics() ::sfx2::FileDialogHelper aDialog( TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC ); aDialog.SetTitle( sTitle ); - Reference< XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY); - DBG_ASSERT( xController.is(), "OImageControlControl::implInsertGraphics: invalid file picker!" ); - if ( xController.is() ) - { - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True)); + Reference< XFilePickerControlAccess > xController( aDialog.GetFilePicker(), UNO_QUERY_THROW ); + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True)); - Reference<XPropertySet> xBoundField; - if ( hasProperty( PROPERTY_BOUNDFIELD, xSet ) ) - xSet->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= xBoundField; - sal_Bool bHasField = xBoundField.is(); + Reference<XPropertySet> xBoundField; + if ( hasProperty( PROPERTY_BOUNDFIELD, xSet ) ) + xSet->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= xBoundField; + sal_Bool bHasField = xBoundField.is(); - // if the control is bound to a DB field, then it's not possible to decide whether or not to link - xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, !bHasField ); + // if the control is bound to a DB field, then it's not possible to decide whether or not to link + xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, !bHasField ); - // if the control is bound to a DB field, then linking of the image depends on the type of the field - sal_Bool bImageIsLinked = sal_True; - if ( bHasField ) - { - sal_Int32 nFieldType = DataType::OTHER; - OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); - bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); - } - xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); + // if the control is bound to a DB field, then linking of the image depends on the type of the field + sal_Bool bImageIsLinked = sal_True; + if ( bHasField ) + { + sal_Int32 nFieldType = DataType::OTHER; + OSL_VERIFY( xBoundField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType ); + bImageIsLinked = ( lcl_getImageStoreType( nFieldType ) == ImageStoreLink ); } + xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny( bImageIsLinked ) ); if ( ERRCODE_NONE == aDialog.Execute() ) { @@ -802,12 +798,15 @@ void OImageControlControl::implInsertGraphics() } else xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( ::rtl::OUString( aDialog.GetPath() ) ) ); + + return true; } } catch(Exception&) { DBG_ERROR("OImageControlControl::implInsertGraphics: caught an exception while attempting to execute the FilePicker!"); } + return false; } //------------------------------------------------------------------------------ @@ -839,10 +838,11 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& if (e.Buttons != MouseButton::LEFT) return; + bool bModified = false; // is this a request for a context menu? if ( e.PopupTrigger ) { - Reference< XPopupMenu > xMenu( m_xServiceFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.PopupMenu" ) ), UNO_QUERY ); + Reference< XPopupMenu > xMenu( m_aContext.createComponent( "com.sun.star.awt.PopupMenu" ), UNO_QUERY ); DBG_ASSERT( xMenu.is(), "OImageControlControl::mousePressed: could not create a popup menu!" ); Reference< XWindowPeer > xWindowPeer = getPeer(); @@ -878,10 +878,12 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& { case ID_OPEN_GRAPHICS: implInsertGraphics(); + bModified = true; break; case ID_CLEAR_GRAPHICS: implClearGraphics( sal_True ); + bModified = true; break; } } @@ -916,9 +918,16 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& if (bReadOnly) return; - implInsertGraphics(); + if ( implInsertGraphics() ) + bModified = true; } } + + if ( bModified ) + { + EventObject aEvent( *this ); + m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent ); + } } //------------------------------------------------------------------------------ @@ -936,62 +945,6 @@ void SAL_CALL OImageControlControl::mouseExited(const awt::MouseEvent& /*e*/) th { } - -//============================================================================== -//= OImageIndicator -//============================================================================== -DBG_NAME( OImageIndicator ) -//------------------------------------------------------------------------------ -OImageIndicator::OImageIndicator( ) - :m_bIsProducing( sal_False ) - ,m_bIsEmptyImage( sal_True ) -{ - DBG_CTOR( OImageIndicator, NULL ); -} - -//------------------------------------------------------------------------------ -OImageIndicator::~OImageIndicator( ) -{ - DBG_DTOR( OImageIndicator, NULL ); -} - -//-------------------------------------------------------------------- -void OImageIndicator::reset() -{ - OSL_ENSURE( !m_bIsProducing, "OImageIndicator::reset: sure you know what you're doing? The producer is currently producing!" ); - m_bIsProducing = sal_True; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::init( sal_Int32 /*Width*/, sal_Int32 /*Height*/ ) throw (RuntimeException) -{ - m_bIsProducing = sal_True; - m_bIsEmptyImage = sal_True; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setColorModel( sal_Int16 /*BitCount*/, const Sequence< sal_Int32 >& /*RGBAPal*/, sal_Int32 /*RedMask*/, sal_Int32 /*GreenMask*/, sal_Int32 /*BlueMask*/, sal_Int32 /*AlphaMask*/ ) throw (RuntimeException) -{ -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setPixelsByBytes( sal_Int32 /*nX*/, sal_Int32 /*nY*/, sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/, const Sequence< sal_Int8 >& /*aProducerData*/, sal_Int32 /*nOffset*/, sal_Int32 /*nScanSize*/ ) throw (RuntimeException) -{ - m_bIsEmptyImage = sal_False; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::setPixelsByLongs( sal_Int32 /*nX*/, sal_Int32 /*nY*/, sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/, const Sequence< sal_Int32 >& /*aProducerData*/, sal_Int32 /*nOffset*/, sal_Int32 /*nScanSize*/ ) throw (RuntimeException) -{ - m_bIsEmptyImage = sal_False; -} - -//-------------------------------------------------------------------- -void SAL_CALL OImageIndicator::complete( sal_Int32 /*Status*/, const Reference< XImageProducer >& /*xProducer*/ ) throw (RuntimeException) -{ - m_bIsProducing = sal_False; -} - //......................................................................... } // namespace frm //......................................................................... diff --git a/forms/source/component/ImageControl.hxx b/forms/source/component/ImageControl.hxx index 9c43484006c3..49ae9ff81964 100644 --- a/forms/source/component/ImageControl.hxx +++ b/forms/source/component/ImageControl.hxx @@ -35,6 +35,7 @@ #include "imgprod.hxx" #include <com/sun/star/form/XImageProducerSupplier.hpp> #include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <comphelper/propmultiplex.hxx> #include <comphelper/implementationreference.hxx> #include <cppuhelper/implbase2.hxx> @@ -145,49 +146,17 @@ protected: }; //================================================================== -//= OImageIndicator (helper class for OImageControlControl) -//================================================================== -typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XImageConsumer - > OImageIndicator_Base; - -class OImageIndicator : public OImageIndicator_Base -{ -private: - sal_Bool m_bIsProducing : 1; - sal_Bool m_bIsEmptyImage : 1; - -public: - OImageIndicator( ); - - void reset(); - inline sal_Bool isEmptyImage() const { return m_bIsEmptyImage; } - -protected: - ~OImageIndicator( ); - // XImageProducer - virtual void SAL_CALL init( sal_Int32 Width, sal_Int32 Height ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setColorModel( sal_Int16 BitCount, const ::com::sun::star::uno::Sequence< sal_Int32 >& RGBAPal, sal_Int32 RedMask, sal_Int32 GreenMask, sal_Int32 BlueMask, sal_Int32 AlphaMask ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPixelsByBytes( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int8 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPixelsByLongs( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, const ::com::sun::star::uno::Sequence< sal_Int32 >& aProducerData, sal_Int32 nOffset, sal_Int32 nScanSize ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL complete( sal_Int32 Status, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer >& xProducer ) throw (::com::sun::star::uno::RuntimeException); - -private: - OImageIndicator( const OImageIndicator& ); // never implemented - OImageIndicator& operator=( const OImageIndicator& ); // never implemented -}; - -//================================================================== //= OImageControlControl //================================================================== -class OImageControlControl :public ::com::sun::star::awt::XMouseListener - ,public OBoundControl +typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XMouseListener + , ::com::sun::star::util::XModifyBroadcaster + > OImageControlControl_Base; +class OImageControlControl : public OBoundControl + , public OImageControlControl_Base { private: - typedef ::comphelper::ImplementationReference< OImageIndicator, ::com::sun::star::awt::XImageConsumer > - ImageIndicatorReference; - ImageIndicatorReference m_pImageIndicator; + ::cppu::OInterfaceContainerHelper m_aModifyListeners; -protected: // XTypeProvider virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); @@ -195,12 +164,11 @@ public: OImageControlControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); // UNO - DECLARE_UNO3_AGG_DEFAULTS(OImageControlControl, OBoundControl); - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); + DECLARE_UNO3_AGG_DEFAULTS( OImageControlControl, OBoundControl ); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException); // XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException) - { OBoundControl::disposing(_rSource); } + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException); // XServiceInfo IMPLEMENTATION_NAME(OImageControlControl); @@ -212,15 +180,16 @@ public: virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw ( ::com::sun::star::uno::RuntimeException); - // XControl - virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference<starawt::XControlModel>& _rxModel ) throw (::com::sun::star::uno::RuntimeException); + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); - // prevent method hiding - using OBoundControl::disposing; + // OComponentHelper + virtual void SAL_CALL disposing(); private: void implClearGraphics( sal_Bool _bForce ); - void implInsertGraphics(); + bool implInsertGraphics(); /** determines whether the control does currently have an empty grahic set */ diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index a2de412fa3a4..ec953f66c6f6 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -54,27 +54,22 @@ #include <com/sun/star/sdb/CommandType.hpp> /** === end UNO includes === **/ -#include <connectivity/dbtools.hxx> -#include <connectivity/formattedcolumnvalue.hxx> -#include <connectivity/dbconversion.hxx> - -#include <vcl/svapp.hxx> - -#include <unotools/sharedunocomponent.hxx> - -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> - #include <comphelper/basicio.hxx> #include <comphelper/container.hxx> #include <comphelper/numbers.hxx> #include <comphelper/listenernotification.hxx> - +#include <connectivity/dbtools.hxx> +#include <connectivity/formattedcolumnvalue.hxx> +#include <connectivity/dbconversion.hxx> #include <cppuhelper/queryinterface.hxx> - #include <rtl/logfile.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/sharedunocomponent.hxx> +#include <vcl/svapp.hxx> #include <algorithm> +#include <functional> //......................................................................... @@ -94,14 +89,61 @@ namespace frm using namespace ::com::sun::star::form::binding; using namespace ::dbtools; - //================================================================== - //= ItemEvent - //================================================================== + using ::connectivity::ORowSetValue; + + //============================================================================== + //= helper + //============================================================================== + namespace + { + //-------------------------------------------------------------------------- + struct RowSetValueToString : public ::std::unary_function< ORowSetValue, ::rtl::OUString > + { + ::rtl::OUString operator()( const ORowSetValue& _value ) const + { + return _value.getString(); + } + }; + + //-------------------------------------------------------------------------- + struct AppendRowSetValueString : public ::std::unary_function< ::rtl::OUString, void > + { + AppendRowSetValueString( ::rtl::OUString& _string ) + :m_string( _string ) + { + } + + void operator()( const ::rtl::OUString _append ) + { + m_string += _append; + } + + private: + ::rtl::OUString& m_string; + }; + + //-------------------------------------------------------------------------- + Sequence< ::rtl::OUString > lcl_convertToStringSequence( const ValueList& _values ) + { + Sequence< ::rtl::OUString > aStrings( _values.size() ); + ::std::transform( + _values.begin(), + _values.end(), + aStrings.getArray(), + RowSetValueToString() + ); + return aStrings; + } + } + + //============================================================================== + //= ItemEventDescription + //============================================================================== typedef ::comphelper::EventHolder< ItemEvent > ItemEventDescription; - //================================================================== + //============================================================================== //= OListBoxModel - //================================================================== + //============================================================================== //------------------------------------------------------------------ InterfaceRef SAL_CALL OListBoxModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException) { @@ -124,7 +166,7 @@ namespace frm OListBoxModel::OListBoxModel(const Reference<XMultiServiceFactory>& _rxFactory) :OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_LISTBOX, FRM_SUN_CONTROL_LISTBOX, sal_True, sal_True, sal_True ) // use the old control name for compytibility reasons - ,OEntryListHelper( m_aMutex ) + ,OEntryListHelper( (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_nNULLPos(-1) @@ -141,13 +183,13 @@ namespace frm //------------------------------------------------------------------ OListBoxModel::OListBoxModel( const OListBoxModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OBoundControlModel( _pOriginal, _rxFactory ) - ,OEntryListHelper( *_pOriginal, m_aMutex ) + ,OEntryListHelper( *_pOriginal, (OControlModel&)*this ) ,OErrorBroadcaster( OComponentHelper::rBHelper ) ,m_aListRowSet( getContext() ) ,m_eListSourceType( _pOriginal->m_eListSourceType ) ,m_aBoundColumn( _pOriginal->m_aBoundColumn ) - ,m_aListSourceSeq( _pOriginal->m_aListSourceSeq ) - ,m_aValueSeq( _pOriginal->m_aValueSeq ) + ,m_aListSourceValues( _pOriginal->m_aListSourceValues ) + ,m_aBoundValues( _pOriginal->m_aBoundValues ) ,m_aDefaultSelectSeq( _pOriginal->m_aDefaultSelectSeq ) ,m_nNULLPos(-1) ,m_bBoundComponent(sal_False) @@ -229,11 +271,11 @@ namespace frm break; case PROPERTY_ID_LISTSOURCE: - _rValue <<= m_aListSourceSeq; + _rValue <<= lcl_convertToStringSequence( m_aListSourceValues ); break; case PROPERTY_ID_VALUE_SEQ: - _rValue <<= m_aValueSeq; + _rValue <<= lcl_convertToStringSequence( m_aBoundValues ); break; case PROPERTY_ID_DEFAULT_SELECT_SEQ: @@ -266,24 +308,38 @@ namespace frm _rValue >>= m_eListSourceType; break; - case PROPERTY_ID_LISTSOURCE : - DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<StringSequence*>(NULL))), - "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" ); - _rValue >>= m_aListSourceSeq; - - if (m_eListSourceType == ListSourceType_VALUELIST) - m_aValueSeq = m_aListSourceSeq; - else if ( m_xCursor.is() && !hasField() && !hasExternalListSource() ) - // listbox is already connected to a database, and no external list source - // data source changed -> refresh - loadData( false ); - break; + case PROPERTY_ID_LISTSOURCE: + { + // extract + Sequence< ::rtl::OUString > aListSource; + OSL_VERIFY( _rValue >>= aListSource ); + + // copy to member + ValueList().swap(m_aListSourceValues); + ::std::copy( + aListSource.getConstArray(), + aListSource.getConstArray() + aListSource.getLength(), + ::std::insert_iterator< ValueList >( m_aListSourceValues, m_aListSourceValues.end() ) + ); + + // propagate + if ( m_eListSourceType == ListSourceType_VALUELIST ) + { + m_aBoundValues = m_aListSourceValues; + } + else + { + if ( m_xCursor.is() && !hasField() && !hasExternalListSource() ) + // listbox is already connected to a database, and no external list source + // data source changed -> refresh + loadData( false ); + } + } + break; case PROPERTY_ID_VALUE_SEQ : - DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast<StringSequence*>(NULL))), - "OListBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" ); - _rValue >>= m_aValueSeq; - break; + OSL_ENSURE( false, "ValueItemList is read-only!" ); + throw PropertyVetoException(); case PROPERTY_ID_DEFAULT_SELECT_SEQ : DBG_ASSERT(_rValue.getValueType().equals(::getCppuType(reinterpret_cast< Sequence<sal_Int16>*>(NULL))), @@ -297,8 +353,8 @@ namespace frm case PROPERTY_ID_STRINGITEMLIST: { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); - setNewStringItemList( _rValue, aGuard ); + ControlModelLock aLock( *this ); + setNewStringItemList( _rValue, aLock ); // TODO: this is bogus. setNewStringItemList expects a guard which has the *only* // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with // a lock - so we effectively has two locks here, of which setNewStringItemList can @@ -329,12 +385,12 @@ namespace frm break; case PROPERTY_ID_LISTSOURCE: - bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aListSourceSeq); + bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, lcl_convertToStringSequence( m_aListSourceValues ) ); break; case PROPERTY_ID_VALUE_SEQ : - bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aValueSeq); - break; + OSL_ENSURE( false, "ValueItemList is read-only!" ); + throw PropertyVetoException(); case PROPERTY_ID_DEFAULT_SELECT_SEQ : bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_aDefaultSelectSeq); @@ -435,7 +491,7 @@ namespace frm _rxOutStream << nAnyMask; - _rxOutStream << m_aListSourceSeq; + _rxOutStream << lcl_convertToStringSequence( m_aListSourceValues ); _rxOutStream << (sal_Int16)m_eListSourceType; _rxOutStream << aDummySeq; _rxOutStream << m_aDefaultSelectSeq; @@ -459,7 +515,7 @@ namespace frm // Deshalb muessen sie explizit ueber setPropertyValue() gesetzt werden. OBoundControlModel::read(_rxInStream); - ::osl::ResettableMutexGuard aGuard(m_aMutex); + ControlModelLock aLock( *this ); // since we are "overwriting" the StringItemList of our aggregate (means we have // an own place to store the value, instead of relying on our aggregate storing it), @@ -467,7 +523,7 @@ namespace frm try { if ( m_xAggregateSet.is() ) - setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aGuard ); + setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock ); } catch( const Exception& ) { @@ -481,9 +537,9 @@ namespace frm if (nVersion > 0x0004) { DBG_ERROR("OListBoxModel::read : invalid (means unknown) version !"); - m_aListSourceSeq.realloc(0); + ValueList().swap(m_aListSourceValues); m_aBoundColumn <<= (sal_Int16)0; - m_aValueSeq.realloc(0); + ValueList().swap(m_aBoundValues); m_eListSourceType = ListSourceType_VALUELIST; m_aDefaultSelectSeq.realloc(0); defaultCommonProperties(); @@ -588,17 +644,18 @@ namespace frm // PRE2: list source ::rtl::OUString sListSource; - // if our list source type is no value list, we need to concatenete + // if our list source type is no value list, we need to concatenate // the single list source elements - const ::rtl::OUString* pListSourceItem = m_aListSourceSeq.getConstArray(); - sal_Int32 i(0); - for ( i=0; i<m_aListSourceSeq.getLength(); ++i, ++pListSourceItem ) - sListSource = sListSource + *pListSourceItem; + ::std::for_each( + m_aListSourceValues.begin(), + m_aListSourceValues.end(), + AppendRowSetValueString( sListSource ) + ); // outta here if we don't have all pre-requisites if ( !xConnection.is() || !sListSource.getLength() ) { - m_aValueSeq = StringSequence(); + ValueList().swap(m_aBoundValues); return; } @@ -742,9 +799,7 @@ namespace frm } // Anzeige- und Werteliste fuellen - ::std::vector< ::rtl::OUString > aValueList, aStringList; - aValueList.reserve(16); - aStringList.reserve(16); + ValueList aDisplayList, aValueList; sal_Bool bUseNULL = hasField() && !isRequired(); try @@ -780,23 +835,20 @@ namespace frm ::dbtools::FormattedColumnValue aValueFormatter( getContext(), m_xCursor, xDataField ); // Feld der BoundColumn des ResultSets holen - Reference< XPropertySet > xBoundField; - if ((nBoundColumn > 0) && m_xColumn.is()) + sal_Int32 nBoundColumnType = DataType::SQLNULL; + if ( ( nBoundColumn > 0 ) && m_xColumn.is() ) { // don't look for a bound column if we're not connected to a field try { - xColumns->getByIndex(nBoundColumn) >>= xBoundField; + Reference< XPropertySet > xBoundField( xColumns->getByIndex( nBoundColumn ), UNO_QUERY_THROW ); + OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nBoundColumnType ); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } } - m_bBoundComponent = xBoundField.is(); - - ::std::auto_ptr< ::dbtools::FormattedColumnValue > pBoundFieldFormatter; - if ( xBoundField.is() ) - pBoundFieldFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), m_xCursor, xBoundField ) ); + m_bBoundComponent = ( nBoundColumnType != DataType::SQLNULL ); // Ist die LB an ein Feld gebunden und sind Leereintraege zulaessig // dann wird die Position fuer einen Leereintrag gemerkt @@ -804,20 +856,21 @@ namespace frm RTL_LOGFILE_CONTEXT( aLogContext, "OListBoxModel::loadData: string collection" ); ::rtl::OUString aStr; sal_Int16 entryPos = 0; - // per definitionem the list cursor is positioned _before_ the first row at the moment + ORowSetValue aBoundValue; + Reference< XRow > xCursorRow( xListCursor, UNO_QUERY_THROW ); while ( xListCursor->next() && ( entryPos++ < SHRT_MAX ) ) // SHRT_MAX is the maximum number of entries { aStr = aValueFormatter.getFormattedValue(); - aStringList.push_back(aStr); + aDisplayList.push_back( aStr ); - if ( pBoundFieldFormatter.get() ) + if ( m_bBoundComponent ) { - aStr = pBoundFieldFormatter->getFormattedValue(); - aValueList.push_back( aStr ); + aBoundValue.fill( nBoundColumn + 1, nBoundColumnType, xCursorRow ); + aValueList.push_back( aBoundValue ); } - if (bUseNULL && (m_nNULLPos == -1) && !aStr.getLength()) - m_nNULLPos = (sal_Int16)aStringList.size() - 1; + if ( bUseNULL && ( m_nNULLPos == -1 ) && !aStr.getLength() ) + m_nNULLPos = sal_Int16( aDisplayList.size() - 1 ); } } break; @@ -828,11 +881,11 @@ namespace frm if (xFieldNames.is()) { StringSequence seqNames = xFieldNames->getElementNames(); - sal_Int32 nFieldsCount = seqNames.getLength(); - const ::rtl::OUString* pustrNames = seqNames.getConstArray(); - - for (sal_Int32 k=0; k<nFieldsCount; ++k, ++pustrNames) - aStringList.push_back(*pustrNames); + ::std::copy( + seqNames.getConstArray(), + seqNames.getConstArray() + seqNames.getLength(), + ::std::insert_iterator< ValueList >( aDisplayList, aDisplayList.end() ) + ); } } break; @@ -857,25 +910,16 @@ namespace frm // NULL eintrag hinzufuegen if (bUseNULL && m_nNULLPos == -1) { - if (m_bBoundComponent) - aValueList.insert(aValueList.begin(), ::rtl::OUString()); + if ( m_bBoundComponent ) + aValueList.insert( aValueList.begin(), ORowSetValue() ); - aStringList.insert(aStringList.begin(), ::rtl::OUString()); + aDisplayList.insert( aDisplayList.begin(), ORowSetValue( ::rtl::OUString() ) ); m_nNULLPos = 0; } - m_aValueSeq.realloc(aValueList.size()); - ::rtl::OUString* pValues = m_aValueSeq.getArray(); - for ( i = 0; i < (sal_Int32)aValueList.size(); ++i, ++pValues) - *pValues = aValueList[i]; - - // String-Sequence fuer ListBox erzeugen - StringSequence aStringSeq(aStringList.size()); - ::rtl::OUString* pStrings = aStringSeq.getArray(); - for ( i = 0; i < (sal_Int32)aStringList.size(); ++i, ++pStrings ) - *pStrings = aStringList[i]; + m_aBoundValues = aValueList; - setFastPropertyValue(PROPERTY_ID_STRINGITEMLIST, makeAny(aStringSeq)); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( lcl_convertToStringSequence( aDisplayList ) ) ); } //------------------------------------------------------------------------------ @@ -890,19 +934,14 @@ namespace frm if ( !hasExternalListSource() ) impl_refreshDbEntryList( false ); - - if ( hasField() ) - m_pBoundFieldFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), m_xCursor, getField() ) ); } //------------------------------------------------------------------------------ void OListBoxModel::onDisconnectedDbColumn() { - m_pBoundFieldFormatter.reset( NULL ); - - if (m_eListSourceType != ListSourceType_VALUELIST) + if ( m_eListSourceType != ListSourceType_VALUELIST ) { - m_aValueSeq = StringSequence(); + ValueList().swap(m_aBoundValues); m_nNULLPos = -1; m_bBoundComponent = sal_False; @@ -914,81 +953,73 @@ namespace frm } //------------------------------------------------------------------------------ - StringSequence OListBoxModel::GetCurValueSeq() const + ValueList OListBoxModel::impl_getValues() const { - StringSequence aCurValues; + if ( !m_aBoundValues.empty() ) + return m_aBoundValues; - // Aus den selektierten Indizes Werte-Sequence aufbauen - DBG_ASSERT(m_xAggregateFastSet.is(), "OListBoxModel::GetCurValueSeq : invalid aggregate !"); - if (!m_xAggregateFastSet.is()) - return aCurValues; - - Any aTmp = m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ); - - Sequence<sal_Int16> aSelectSeq; aTmp >>= aSelectSeq; - const sal_Int16 *pSels = aSelectSeq.getConstArray(); - sal_uInt32 nSelCount = aSelectSeq.getLength(); + Sequence< ::rtl::OUString > aStringItems( getStringItemList() ); + ValueList aValues( aStringItems.getLength() ); + ::std::copy( + aStringItems.getConstArray(), + aStringItems.getConstArray() + aStringItems.getLength(), + aValues.begin() + ); - if (nSelCount) - { - StringSequence aValues( impl_getValues() ); + return aValues; + } + //------------------------------------------------------------------------------ + ORowSetValue OListBoxModel::getFirstSelectedValue() const + { + static const ORowSetValue s_aEmptyVaue; - const ::rtl::OUString *pVals = aValues.getConstArray(); - sal_Int32 nValCnt = aValues.getLength(); + DBG_ASSERT( m_xAggregateFastSet.is(), "OListBoxModel::getFirstSelectedValue: invalid aggregate!" ); + if ( !m_xAggregateFastSet.is() ) + return s_aEmptyVaue; - if (nSelCount > 1) - { - // Einfach- oder Mehrfach-Selektion - sal_Bool bMultiSel = false; - const_cast<OListBoxModel*>(this)->OPropertySetAggregationHelper::getFastPropertyValue(PROPERTY_ID_MULTISELECTION) >>= bMultiSel; - if (bMultiSel) - nSelCount = 1; - } + Sequence< sal_Int16 > aSelectedIndices; + OSL_VERIFY( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) >>= aSelectedIndices ); + if ( !aSelectedIndices.getLength() ) + // nothing selected at all + return s_aEmptyVaue; - // ist der Eintrag fuer NULL selektiert ? - // dann leere Selektion liefern - if (m_nNULLPos != -1 && nSelCount == 1 && pSels[0] == m_nNULLPos) - nSelCount = 0; + if ( ( m_nNULLPos != -1 ) && ( aSelectedIndices[0] == m_nNULLPos ) ) + // the dedicated "NULL" entry is selected + return s_aEmptyVaue; - aCurValues.realloc(nSelCount); - ::rtl::OUString *pCurVals = aCurValues.getArray(); + ValueList aValues( impl_getValues() ); - for (sal_uInt16 i = 0; i < nSelCount; i++) - { - if (pSels[i] < nValCnt) - pCurVals[i] = pVals[pSels[i]]; - } + size_t selectedValue = aSelectedIndices[0]; + if ( selectedValue >= aValues.size() ) + { + OSL_ENSURE( false, "OListBoxModel::getFirstSelectedValue: inconsistent selection/valuelist!" ); + return s_aEmptyVaue; } - return aCurValues; + + return aValues[ selectedValue ]; } //------------------------------------------------------------------------------ sal_Bool OListBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { // current selektion list - Any aCurrentValue; - StringSequence aCurValueSeq = GetCurValueSeq(); - if ( aCurValueSeq.getLength() ) - aCurrentValue <<= aCurValueSeq.getConstArray()[0]; - - if ( !compare( aCurrentValue, m_aSaveValue ) ) + const ORowSetValue rCurrentValue( getFirstSelectedValue() ); + if ( rCurrentValue != m_aSaveValue ) { - if ( !aCurrentValue.hasValue() ) + if ( rCurrentValue.isNull() ) m_xColumnUpdate->updateNull(); else { try { - ::rtl::OUString sNewValue; - aCurrentValue >>= sNewValue; - m_xColumnUpdate->updateString( sNewValue ); + m_xColumnUpdate->updateObject( rCurrentValue.makeAny() ); } - catch(Exception&) + catch ( const Exception& ) { return sal_False; } } - m_aSaveValue = aCurrentValue; + m_aSaveValue = rCurrentValue; } return sal_True; } @@ -997,37 +1028,41 @@ namespace frm //------------------------------------------------------------------------------ Any OListBoxModel::translateDbColumnToControlValue() { - DBG_ASSERT( m_xAggregateFastSet.is() && m_xAggregateSet.is(), "OListBoxModel::translateDbColumnToControlValue: invalid aggregate !" ); - if ( !m_xAggregateFastSet.is() || !m_xAggregateSet.is() ) - return Any(); - - OSL_ENSURE( m_pBoundFieldFormatter.get(), "OListBoxModel::translateDbColumnToControlValue: illegal call!" ); - if ( !m_pBoundFieldFormatter.get() ) + Reference< XPropertySet > xBoundField( getField() ); + if ( !xBoundField.is() ) + { + OSL_ENSURE( false, "OListBoxModel::translateDbColumnToControlValue: no field? How could that happen?!" ); return Any(); + } - Sequence<sal_Int16> aSelSeq; + Sequence< sal_Int16 > aSelectionIndicies; // Bei NULL-Eintraegen Selektion aufheben! - ::rtl::OUString sValue = m_pBoundFieldFormatter->getFormattedValue(); - OSL_PRECOND( getField() == m_xColumn, "OListBoxModel::translateDbColumnToControlValue: inconsistency!" ); - // m_pBoundFieldFormatter is based on m_xField, and we use m_xColumn to check for wasNull - // => both should better be the same object ... - if ( m_xColumn->wasNull() ) + ORowSetValue aCurrentValue; + aCurrentValue.fill( xBoundField->getPropertyValue( PROPERTY_VALUE ) ); + + if ( aCurrentValue.isNull() ) { - m_aSaveValue.clear(); - if (m_nNULLPos != -1) + if ( m_nNULLPos != -1 ) { - aSelSeq.realloc(1); - aSelSeq.getArray()[0] = m_nNULLPos; + aSelectionIndicies.realloc(1); + aSelectionIndicies[0] = m_nNULLPos; } } else { - m_aSaveValue <<= sValue; - - aSelSeq = findValue( impl_getValues(), sValue, m_bBoundComponent ); + ValueList aValues( impl_getValues() ); + ValueList::const_iterator curValuePos = ::std::find( aValues.begin(), aValues.end(), aCurrentValue ); + if ( curValuePos != aValues.end() ) + { + aSelectionIndicies.realloc( 1 ); + aSelectionIndicies[0] = curValuePos - aValues.begin(); + } } - return makeAny( aSelSeq ); + + m_aSaveValue = aCurrentValue; + + return makeAny( aSelectionIndicies ); } // XReset @@ -1158,7 +1193,7 @@ namespace frm aThisEntryIndexes.getConstArray(), aThisEntryIndexes.getConstArray() + aThisEntryIndexes.getLength(), ::std::insert_iterator< ::std::set< sal_Int16 > >( aSelectionSet, aSelectionSet.begin() ) - ); + ); } // copy the indexes to the sequence @@ -1329,7 +1364,7 @@ namespace frm } //-------------------------------------------------------------------- - void OListBoxModel::stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ) + void OListBoxModel::stringItemListChanged( ControlModelLock& _rInstanceLock ) { if ( !m_xAggregateSet.is() ) return; diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index 16fe8cd4482b..60bd63b3712d 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -46,14 +46,13 @@ #include <com/sun/star/form/XChangeBroadcaster.hpp> /** === end UNO includes === **/ -#include <vcl/timer.hxx> - #include <comphelper/asyncnotification.hxx> - +#include <connectivity/FValue.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/implbase1.hxx> +#include <vcl/timer.hxx> -#include <memory> +#include <vector> namespace dbtools { @@ -67,21 +66,21 @@ namespace frm //================================================================== //= OListBoxModel //================================================================== +typedef ::std::vector< ::connectivity::ORowSetValue > ValueList; + class OListBoxModel :public OBoundControlModel ,public OEntryListHelper ,public OErrorBroadcaster { - CachedRowSet m_aListRowSet; // the row set to fill the list - ::std::auto_ptr< ::dbtools::FormattedColumnValue > - m_pBoundFieldFormatter; - ::com::sun::star::uno::Any m_aSaveValue; + CachedRowSet m_aListRowSet; // the row set to fill the list + ::connectivity::ORowSetValue m_aSaveValue; // <properties> ::com::sun::star::form::ListSourceType m_eListSourceType; // type der list source ::com::sun::star::uno::Any m_aBoundColumn; - StringSequence m_aListSourceSeq; // - StringSequence m_aValueSeq; // alle Werte, readonly + ValueList m_aListSourceValues; + ValueList m_aBoundValues; ::com::sun::star::uno::Sequence<sal_Int16> m_aDefaultSelectSeq; // DefaultSelected // </properties> @@ -89,8 +88,7 @@ class OListBoxModel :public OBoundControlModel sal_Bool m_bBoundComponent : 1; private: - // Helper functions - StringSequence GetCurValueSeq() const; + ::connectivity::ORowSetValue getFirstSelectedValue() const; virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); @@ -164,7 +162,7 @@ protected: getCurrentFormComponentValue() const; // OEntryListHelper overriables - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ); + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); virtual void connectedExternalListSource( ); virtual void disconnectedExternalListSource( ); virtual void refreshInternalEntryList(); @@ -180,8 +178,7 @@ private: */ void impl_refreshDbEntryList( bool _bForce ); - StringSequence - impl_getValues() const { return m_aValueSeq.getLength() ? m_aValueSeq : getStringItemList(); } + ValueList impl_getValues() const; }; //================================================================== diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index 78841aa89ecf..cd70d200f376 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -259,7 +259,7 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons } } - if (nHandle == PROPERTY_ID_DEFAULTCHECKED) + if (nHandle == PROPERTY_ID_DEFAULT_STATE) { sal_Int16 nValue; rValue >>= nValue; @@ -269,7 +269,7 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons Any aZero; nValue = 0; aZero <<= nValue; - SetSiblingPropsTo(PROPERTY_DEFAULTCHECKED, aZero); + SetSiblingPropsTo(PROPERTY_DEFAULT_STATE, aZero); } } } @@ -341,7 +341,7 @@ void SAL_CALL ORadioButtonModel::read(const Reference<XObjectInputStream>& _rxIn } setReferenceValue( sReferenceValue ); - setDefaultChecked( (CheckState)nDefaultChecked ); + setDefaultChecked( (ToggleState)nDefaultChecked ); // Nach dem Lesen die Defaultwerte anzeigen if ( getControlSource().getLength() ) diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx index 81a9346ae6e7..3d7217cc162c 100644 --- a/forms/source/component/entrylisthelper.cxx +++ b/forms/source/component/entrylisthelper.cxx @@ -31,6 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" #include "entrylisthelper.hxx" +#include "FormComponent.hxx" + #include <osl/diagnose.h> #include <comphelper/sequence.hxx> #include <comphelper/property.hxx> @@ -50,18 +52,18 @@ namespace frm //= OEntryListHelper //===================================================================== //--------------------------------------------------------------------- - OEntryListHelper::OEntryListHelper( ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) - ,m_aRefreshListeners( _rMutex ) + OEntryListHelper::OEntryListHelper( OControlModel& _rControlModel ) + :m_rControlModel( _rControlModel ) + ,m_aRefreshListeners( _rControlModel.getInstanceMutex() ) { } //--------------------------------------------------------------------- - OEntryListHelper::OEntryListHelper( const OEntryListHelper& _rSource, ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) + OEntryListHelper::OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ) + :m_rControlModel( _rControlModel ) ,m_xListSource ( _rSource.m_xListSource ) ,m_aStringItems( _rSource.m_aStringItems ) - ,m_aRefreshListeners( _rMutex ) + ,m_aRefreshListeners( _rControlModel.getInstanceMutex() ) { } @@ -73,14 +75,14 @@ namespace frm //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::setListEntrySource( const Reference< XListEntrySource >& _rxSource ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); // disconnect from the current external list source disconnectExternalListSource(); // and connect to the new one if ( _rxSource.is() ) - connectExternalListSource( _rxSource, aGuard ); + connectExternalListSource( _rxSource, aLock ); } //--------------------------------------------------------------------- @@ -93,7 +95,8 @@ namespace frm //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryChanged( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryChanged: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( _rEvent.Position < m_aStringItems.getLength() ), @@ -107,14 +110,15 @@ namespace frm ) { m_aStringItems[ _rEvent.Position ] = _rEvent.Entries[ 0 ]; - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryRangeInserted( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryRangeInserted: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Position < m_aStringItems.getLength() ) && ( _rEvent.Entries.getLength() > 0 ), @@ -143,14 +147,15 @@ namespace frm aMovedEntries ); - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::entryRangeRemoved( const ListEntryEvent& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::entryRangeRemoved: where did this come from?" ); OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Count > 0 ) && ( _rEvent.Position + _rEvent.Count <= m_aStringItems.getLength() ), @@ -170,21 +175,22 @@ namespace frm // shrink the array m_aStringItems.realloc( m_aStringItems.getLength() - _rEvent.Count ); - stringItemListChanged( aGuard ); + stringItemListChanged( aLock ); } } //--------------------------------------------------------------------- void SAL_CALL OEntryListHelper::allEntriesChanged( const EventObject& _rEvent ) throw (RuntimeException) { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); + ControlModelLock aLock( m_rControlModel ); + OSL_ENSURE( _rEvent.Source == m_xListSource, "OEntryListHelper::allEntriesChanged: where did this come from?" ); Reference< XListEntrySource > xSource( _rEvent.Source, UNO_QUERY ); if ( _rEvent.Source == m_xListSource ) { - impl_lock_refreshList( aGuard ); + impl_lock_refreshList( aLock ); } } @@ -207,8 +213,8 @@ namespace frm void SAL_CALL OEntryListHelper::refresh() throw(RuntimeException) { { - ::osl::ResettableMutexGuard aGuard( m_rMutex ); - impl_lock_refreshList( aGuard ); + ControlModelLock aLock( m_rControlModel ); + impl_lock_refreshList( aLock ); } EventObject aEvt( static_cast< XRefreshable* >( this ) ); @@ -216,7 +222,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::impl_lock_refreshList( ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::impl_lock_refreshList( ControlModelLock& _rInstanceLock ) { if ( hasExternalListSource() ) { @@ -272,7 +278,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::connectExternalListSource( const Reference< XListEntrySource >& _rxSource, ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::connectExternalListSource( const Reference< XListEntrySource >& _rxSource, ControlModelLock& _rInstanceLock ) { OSL_ENSURE( !hasExternalListSource(), "OEntryListHelper::connectExternalListSource: only to be called if no external source is active!" ); OSL_ENSURE( _rxSource.is(), "OEntryListHelper::connectExternalListSource: invalid list source!" ); @@ -306,7 +312,7 @@ namespace frm } //--------------------------------------------------------------------- - void OEntryListHelper::setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ::osl::ResettableMutexGuard& _rInstanceLock ) + void OEntryListHelper::setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ) { OSL_PRECOND( !hasExternalListSource(), "OEntryListHelper::setNewStringItemList: this should never have survived convertNewListSourceProperty!" ); OSL_VERIFY( _rValue >>= m_aStringItems ); diff --git a/forms/source/component/entrylisthelper.hxx b/forms/source/component/entrylisthelper.hxx index 5b5b0ca46610..3d0f1de784b6 100644 --- a/forms/source/component/entrylisthelper.hxx +++ b/forms/source/component/entrylisthelper.hxx @@ -46,6 +46,9 @@ namespace frm { //......................................................................... + class OControlModel; + class ControlModelLock; + //===================================================================== //= OEntryListHelper //===================================================================== @@ -57,19 +60,19 @@ namespace frm class OEntryListHelper : public OEntryListHelper_BASE { private: - ::osl::Mutex& m_rMutex; + OControlModel& m_rControlModel; ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > m_xListSource; /// our external list source ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aStringItems; /// "overridden" StringItemList property value - ::cppu::OInterfaceContainerHelper + ::cppu::OInterfaceContainerHelper m_aRefreshListeners; protected: - OEntryListHelper( ::osl::Mutex& _rMutex ); - OEntryListHelper( const OEntryListHelper& _rSource, ::osl::Mutex& _rMutex ); + OEntryListHelper( OControlModel& _rControlModel ); + OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ); virtual ~OEntryListHelper( ); /// returns the current string item list @@ -117,7 +120,7 @@ namespace frm not to be called when we have an external list source @see hasExternalListSource */ - void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ::osl::ResettableMutexGuard& _rInstanceLock ); + void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ); /** announces that the list of entries has changed. @@ -127,7 +130,7 @@ namespace frm @pure @see getStringItemList */ - virtual void stringItemListChanged( ::osl::ResettableMutexGuard& _rInstanceLock ) = 0; + virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0; /** called whenever a connection to a new external list source has been established */ @@ -171,7 +174,7 @@ namespace frm */ void connectExternalListSource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource, - ::osl::ResettableMutexGuard& _rInstanceLock + ControlModelLock& _rInstanceLock ); /** refreshes our list entries @@ -182,7 +185,7 @@ namespace frm In case we do not have an external list source, refreshInternalEntryList is called. */ - void impl_lock_refreshList( ::osl::ResettableMutexGuard& _rInstanceLock ); + void impl_lock_refreshList( ControlModelLock& _rInstanceLock ); private: OEntryListHelper(); // never implemented diff --git a/forms/source/component/navigationbar.cxx b/forms/source/component/navigationbar.cxx index 236f64f762a8..abe5b5c45488 100644 --- a/forms/source/component/navigationbar.cxx +++ b/forms/source/component/navigationbar.cxx @@ -84,6 +84,7 @@ namespace frm getPropertyDefaultByHandle( PROPERTY_ID_BORDER ) >>= m_nBorder; getPropertyDefaultByHandle( PROPERTY_ID_DELAY ) >>= m_nDelay; getPropertyDefaultByHandle( PROPERTY_ID_ENABLED ) >>= m_bEnabled; + getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE ) >>= m_bEnableVisible; getPropertyDefaultByHandle( PROPERTY_ID_SHOW_POSITION ) >>= m_bShowPosition; getPropertyDefaultByHandle( PROPERTY_ID_SHOW_NAVIGATION ) >>= m_bShowNavigation; getPropertyDefaultByHandle( PROPERTY_ID_SHOW_RECORDACTIONS ) >>= m_bShowActions; @@ -107,6 +108,7 @@ namespace frm m_sHelpText = _pOriginal->m_sHelpText; m_sHelpURL = _pOriginal->m_sHelpURL; m_bEnabled = _pOriginal->m_bEnabled; + m_bEnableVisible = _pOriginal->m_bEnableVisible; m_nIconSize = _pOriginal->m_nIconSize; m_nBorder = _pOriginal->m_nBorder; m_nDelay = _pOriginal->m_nDelay; @@ -125,6 +127,7 @@ namespace frm REGISTER_PROP_2( HELPTEXT, m_sHelpText, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HELPURL, m_sHelpURL, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( ENABLED, m_bEnabled, BOUND, MAYBEDEFAULT ); + REGISTER_PROP_2( ENABLEVISIBLE, m_bEnableVisible, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( ICONSIZE, m_nIconSize, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( BORDER, m_nBorder, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( DELAY, m_nDelay, BOUND, MAYBEDEFAULT ); @@ -444,6 +447,7 @@ namespace frm break; case PROPERTY_ID_ENABLED: + case PROPERTY_ID_ENABLEVISIBLE: case PROPERTY_ID_SHOW_POSITION: case PROPERTY_ID_SHOW_NAVIGATION: case PROPERTY_ID_SHOW_RECORDACTIONS: diff --git a/forms/source/component/navigationbar.hxx b/forms/source/component/navigationbar.hxx index a1f525e61980..1dd94eff2bbc 100644 --- a/forms/source/component/navigationbar.hxx +++ b/forms/source/component/navigationbar.hxx @@ -70,6 +70,7 @@ namespace frm sal_Int16 m_nBorder; sal_Int32 m_nDelay; sal_Bool m_bEnabled; + sal_Bool m_bEnableVisible; sal_Bool m_bShowPosition; sal_Bool m_bShowNavigation; sal_Bool m_bShowActions; diff --git a/forms/source/component/propertybaghelper.cxx b/forms/source/component/propertybaghelper.cxx index 796f683ac1aa..a14aaf6d3ed3 100644 --- a/forms/source/component/propertybaghelper.cxx +++ b/forms/source/component/propertybaghelper.cxx @@ -45,6 +45,9 @@ #include <tools/diagnose_ex.h> #include <comphelper/sequence.hxx> +#include <rtl/logfile.hxx> +#include "rtl/instance.hxx" + #define NEW_HANDLE_BASE 10000 @@ -93,6 +96,7 @@ namespace frm ,m_pPropertyArrayHelper( NULL ) ,m_bDisposed( false ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::PropertyBagHelper" ); } //-------------------------------------------------------------------- @@ -104,12 +108,14 @@ namespace frm //-------------------------------------------------------------------- void PropertyBagHelper::dispose() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::dispose" ); m_bDisposed = true; } //-------------------------------------------------------------------- void PropertyBagHelper::impl_nts_checkDisposed_throw() const { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::impl_nts_checkDisposed_throw" ); if ( m_bDisposed ) throw DisposedException(); } @@ -117,12 +123,14 @@ namespace frm //-------------------------------------------------------------------- void PropertyBagHelper::impl_nts_invalidatePropertySetInfo() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::impl_nts_invalidatePropertySetInfo" ); delete m_pPropertyArrayHelper, m_pPropertyArrayHelper = NULL; } //-------------------------------------------------------------------- sal_Int32 PropertyBagHelper::impl_findFreeHandle( const ::rtl::OUString& _rPropertyName ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::impl_findFreeHandle" ); ::comphelper::OPropertyArrayAggregationHelper& rPropInfo( impl_ts_getArrayHelper() ); // check the preferred handle @@ -162,29 +170,43 @@ namespace frm //-------------------------------------------------------------------- ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::impl_ts_getArrayHelper() const { - ::osl::MutexGuard aGuard( m_rContext.getMutex() ); - if ( !m_pPropertyArrayHelper ) + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::impl_ts_getArrayHelper" ); + //::osl::MutexGuard aGuard( m_rContext.getMutex() ); + OPropertyArrayAggregationHelper* p = m_pPropertyArrayHelper; + if ( !p ) { - // our own fixed and our aggregate's properties - Sequence< Property > aFixedProps; - Sequence< Property > aAggregateProps; - m_rContext.describeFixedAndAggregateProperties( aFixedProps, aAggregateProps ); + ::osl::MutexGuard aGuard( m_rContext.getMutex() ); + p = m_pPropertyArrayHelper; + if ( !p ) + { + // our own fixed and our aggregate's properties + Sequence< Property > aFixedProps; + Sequence< Property > aAggregateProps; + m_rContext.describeFixedAndAggregateProperties( aFixedProps, aAggregateProps ); - // our dynamic properties - Sequence< Property > aDynamicProps; - m_aDynamicProperties.describeProperties( aDynamicProps ); + // our dynamic properties + Sequence< Property > aDynamicProps; + m_aDynamicProperties.describeProperties( aDynamicProps ); - Sequence< Property > aOwnProps( - ::comphelper::concatSequences( aFixedProps, aDynamicProps ) ); + Sequence< Property > aOwnProps( + ::comphelper::concatSequences( aFixedProps, aDynamicProps ) ); - const_cast< PropertyBagHelper* >( this )->m_pPropertyArrayHelper = new OPropertyArrayAggregationHelper( aOwnProps, aAggregateProps, &lcl_getPropertyInfos(), NEW_HANDLE_BASE ); + p = new OPropertyArrayAggregationHelper( aOwnProps, aAggregateProps, &lcl_getPropertyInfos(), NEW_HANDLE_BASE ); + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + const_cast< PropertyBagHelper* >( this )->m_pPropertyArrayHelper = p; + } + } // if ( !p ) + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); } - return *m_pPropertyArrayHelper; + return *p; } //-------------------------------------------------------------------- void PropertyBagHelper::addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::addProperty" ); ::osl::MutexGuard aGuard( m_rContext.getMutex() ); impl_nts_checkDisposed_throw(); @@ -212,6 +234,7 @@ namespace frm //-------------------------------------------------------------------- void PropertyBagHelper::removeProperty( const ::rtl::OUString& _rName ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::removeProperty" ); ::osl::MutexGuard aGuard( m_rContext.getMutex() ); impl_nts_checkDisposed_throw(); @@ -260,6 +283,7 @@ namespace frm //-------------------------------------------------------------------- Sequence< PropertyValue > PropertyBagHelper::getPropertyValues() { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::getPropertyValues" ); ::osl::MutexGuard aGuard( m_rContext.getMutex() ); impl_nts_checkDisposed_throw(); @@ -302,6 +326,7 @@ namespace frm //-------------------------------------------------------------------- void PropertyBagHelper::setPropertyValues( const Sequence< PropertyValue >& _rProps ) { + // RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "forms", "dev@dba.openoffice.org", "PropertyBagHelper::setPropertyValues" ); ::osl::ClearableMutexGuard aGuard( m_rContext.getMutex() ); impl_nts_checkDisposed_throw(); diff --git a/forms/source/component/refvaluecomponent.cxx b/forms/source/component/refvaluecomponent.cxx index 7a9f71475229..cd6fd6eba04e 100644 --- a/forms/source/component/refvaluecomponent.cxx +++ b/forms/source/component/refvaluecomponent.cxx @@ -90,7 +90,7 @@ namespace frm switch ( _nHandle ) { case PROPERTY_ID_REFVALUE: _rValue <<= m_sReferenceValue; break; - case PROPERTY_ID_DEFAULTCHECKED: _rValue <<= (sal_Int16)m_eDefaultChecked; break; + case PROPERTY_ID_DEFAULT_STATE: _rValue <<= (sal_Int16)m_eDefaultChecked; break; case PROPERTY_ID_UNCHECKED_REFVALUE: OSL_ENSURE( m_bSupportSecondRefValue, "OReferenceValueComponent::getFastPropertyValue: not supported!" ); @@ -117,11 +117,11 @@ namespace frm OSL_VERIFY( _rValue >>= m_sNoCheckReferenceValue ); break; - case PROPERTY_ID_DEFAULTCHECKED: + case PROPERTY_ID_DEFAULT_STATE: { sal_Int16 nDefaultChecked( (sal_Int16)STATE_NOCHECK ); OSL_VERIFY( _rValue >>= nDefaultChecked ); - m_eDefaultChecked = (CheckState)nDefaultChecked; + m_eDefaultChecked = (ToggleState)nDefaultChecked; resetNoBroadcast(); } break; @@ -146,7 +146,7 @@ namespace frm bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_sNoCheckReferenceValue ); break; - case PROPERTY_ID_DEFAULTCHECKED: + case PROPERTY_ID_DEFAULT_STATE: bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_eDefaultChecked ); break; @@ -168,7 +168,7 @@ namespace frm { BEGIN_DESCRIBE_PROPERTIES( m_bSupportSecondRefValue ? 3 : 2, OBoundControlModel ) DECL_PROP1( REFVALUE, ::rtl::OUString, BOUND ); - DECL_PROP1( DEFAULTCHECKED, sal_Int16, BOUND ); + DECL_PROP1( DEFAULT_STATE, sal_Int16, BOUND ); if ( m_bSupportSecondRefValue ) { DECL_PROP1( UNCHECKED_REFVALUE, ::rtl::OUString, BOUND ); diff --git a/forms/source/component/refvaluecomponent.hxx b/forms/source/component/refvaluecomponent.hxx index 856c53572432..40745b22764d 100644 --- a/forms/source/component/refvaluecomponent.hxx +++ b/forms/source/component/refvaluecomponent.hxx @@ -28,10 +28,11 @@ * ************************************************************************/ -#ifndef EFORMS2_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX -#define EFORMS2_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX +#ifndef FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX +#define FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX #include "FormComponent.hxx" +#include "togglestate.hxx" /** === begin UNO includes === **/ /** === end UNO includes === **/ @@ -41,8 +42,6 @@ namespace frm { //........................................................................ - enum CheckState { STATE_NOCHECK = 0, STATE_CHECK = 1, STATE_DONTKNOW = 2 }; - //==================================================================== //= OReferenceValueComponent //==================================================================== @@ -54,7 +53,7 @@ namespace frm // <properties> ::rtl::OUString m_sReferenceValue; // the reference value to use for data exchange ::rtl::OUString m_sNoCheckReferenceValue; // the reference value to be exchanged when the control is not checked - CheckState m_eDefaultChecked; // the default check state + ToggleState m_eDefaultChecked; // the default check state // </properties> sal_Bool m_bSupportSecondRefValue; // do we support the SecondaryRefValue property? @@ -65,8 +64,8 @@ namespace frm const ::rtl::OUString& getNoCheckReferenceValue() const { return m_sNoCheckReferenceValue; } - CheckState getDefaultChecked() const { return m_eDefaultChecked; } - void setDefaultChecked( CheckState _eChecked ) { m_eDefaultChecked = _eChecked; } + ToggleState getDefaultChecked() const { return m_eDefaultChecked; } + void setDefaultChecked( ToggleState _eChecked ) { m_eDefaultChecked = _eChecked; } protected: OReferenceValueComponent( @@ -109,5 +108,5 @@ namespace frm } // namespace frm //........................................................................ -#endif // EFORMS2_FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX +#endif // FORMS_SOURCE_COMPONENT_REFVALUECOMPONENT_HXX diff --git a/forms/source/helper/makefile.mk b/forms/source/helper/makefile.mk index 4c2d68fd639e..5739d1fcb6d0 100644 --- a/forms/source/helper/makefile.mk +++ b/forms/source/helper/makefile.mk @@ -1,3 +1,4 @@ + #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,7 +51,8 @@ INCPRE+=$(SOLARINCDIR)$/offuh SLOFILES= $(SLO)$/formnavigation.obj \ $(SLO)$/controlfeatureinterception.obj \ $(SLO)$/urltransformer.obj \ - $(SLO)$/windowstateguard.obj + $(SLO)$/windowstateguard.obj \ + $(SLO)$/resettable.obj \ # --- Targets ---------------------------------- diff --git a/forms/source/helper/resettable.cxx b/forms/source/helper/resettable.cxx new file mode 100644 index 000000000000..3c67dfa5e46e --- /dev/null +++ b/forms/source/helper/resettable.cxx @@ -0,0 +1,101 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_forms.hxx" + +#include "resettable.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <cppuhelper/weak.hxx> + +//........................................................................ +namespace frm +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::form::XResetListener; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //==================================================================== + //= ResetHelper + //==================================================================== + //-------------------------------------------------------------------- + void ResetHelper::addResetListener( const Reference< XResetListener >& _listener ) + { + m_aResetListeners.addInterface( _listener ); + } + + //-------------------------------------------------------------------- + void ResetHelper::removeResetListener( const Reference< XResetListener >& _listener ) + { + m_aResetListeners.removeInterface( _listener ); + } + + //-------------------------------------------------------------------- + bool ResetHelper::approveReset() + { + ::cppu::OInterfaceIteratorHelper aIter( m_aResetListeners ); + EventObject aResetEvent( m_rParent ); + + sal_Bool bContinue = sal_True; + while ( aIter.hasMoreElements() && bContinue ) + bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent ); + + return bContinue; + } + + //-------------------------------------------------------------------- + void ResetHelper::notifyResetted() + { + EventObject aResetEvent( m_rParent ); + m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent ); + } + + //-------------------------------------------------------------------- + void ResetHelper::disposing() + { + EventObject aEvent( m_rParent ); + m_aResetListeners.disposeAndClear( aEvent ); + } + +//........................................................................ +} // namespace frm +//........................................................................ diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index d396cbd2df6a..05c8ad587902 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -31,57 +31,61 @@ #ifndef _FORMS_FORMCOMPONENT_HXX_ #define _FORMS_FORMCOMPONENT_HXX_ -#include <osl/mutex.hxx> -#include <rtl/ustring.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 <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/uno/XAggregation.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/form/XBoundControl.hpp> -#include <com/sun/star/io/XPersistObject.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/form/XFormComponent.hpp> -#include <com/sun/star/form/XBoundComponent.hpp> -#include <com/sun/star/form/XLoadListener.hpp> -#include <com/sun/star/form/XReset.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/sdb/XColumn.hpp> -#include <com/sun/star/sdb/XColumnUpdate.hpp> -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/form/binding/XBindableValue.hpp> -#include <com/sun/star/lang/DisposedException.hpp> +#include "cloneable.hxx"
+#include "ids.hxx"
+#include "property.hrc"
+#include "property.hxx"
+#include "propertybaghelper.hxx"
+#include "resettable.hxx" +#include "services.hxx"
+#include "windowstateguard.hxx"
+
+/** === begin UNO includes === **/
+#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/XChild.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/FormComponentType.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/XMarkableStream.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.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/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/form/validation/XValidityConstraintListener.hpp> -#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> - -#include <comphelper/propagg.hxx> -#include <comphelper/propertybag.hxx> -#include <comphelper/uno3.hxx> -#include <comphelper/sequence.hxx> -#include <comphelper/componentcontext.hxx> -#include "services.hxx" -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "property.hxx" -#include "cloneable.hxx" -#include "ids.hxx" -#include "windowstateguard.hxx" -#include "propertybaghelper.hxx" -#include <comphelper/propmultiplex.hxx> +#include <com/sun/star/form/XLoadable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/propertybag.hxx>
+#include <comphelper/propmultiplex.hxx>
+#include <comphelper/sequence.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 <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
#include <memory> @@ -104,6 +108,64 @@ namespace frm virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) \ { return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.") + ::rtl::OUString::createFromAscii(#ImplName); } + class OControlModel; + + //========================================================================= + //= ControlModelLock + //========================================================================= + /** class whose instances lock a 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(); + + inline 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 ::com::sun::star::uno::Any& _rOldValue, + const ::com::sun::star::uno::Any& _rNewValue + ); + + private: + void impl_notifyAll_nothrow(); + + private: + OControlModel& m_rModel; + bool m_bLocked; + ::com::sun::star::uno::Sequence< sal_Int32 > m_aHandles; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOldValues; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aNewValues; + + private: + ControlModelLock(); // never implemented + ControlModelLock( const ControlModelLock& ); // never implemented + ControlModelLock& operator=( const ControlModelLock& ); // never implemented + }; + //========================================================================= //= OControl //= base class for form layer controls @@ -117,7 +179,7 @@ class OControl :public ::cppu::OComponentHelper ,public OControl_BASE { protected: - osl::Mutex m_aMutex; + ::osl::Mutex m_aMutex; OImplementationIdsRef m_aHoldIdHelper; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xControl; @@ -125,8 +187,6 @@ protected: m_xAggregate; ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xServiceFactory; // legacy only, use m_aContext instead WindowStateGuard m_aWindowStateGuard; public: @@ -301,19 +361,14 @@ class OControlModel :public ::cppu::OComponentHelper protected: ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xServiceFactory; // legacy only, use m_aContext instead - ::osl::Mutex m_aMutex; + ::osl::Mutex m_aMutex; + oslInterlockedCount m_lockCount; InterfaceRef m_xParent; // ParentComponent OImplementationIdsRef m_aHoldIdHelper; PropertyBagHelper m_aPropertyBagHelper; - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& - getORB( ) const { return m_xServiceFactory; } - // legacy only, use getContext instead! - const ::comphelper::ComponentContext& getContext() const { return m_aContext; } @@ -465,6 +520,22 @@ protected: virtual void describeAggregateProperties( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps ) const; + +public: + struct LockAccess { friend class ControlModelLock; private: LockAccess() { } }; + + void lockInstance( LockAccess ); + oslInterlockedCount unlockInstance( LockAccess ); + + void firePropertyChanges( + const ::com::sun::star::uno::Sequence< sal_Int32 >& _rHandles, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rOldValues, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rNewValues, + LockAccess + ); + + inline ::osl::Mutex& + getInstanceMutex() { return m_aMutex; } }; //================================================================== @@ -520,7 +591,7 @@ protected: #define IMPLEMENT_DEFAULT_CLONING( classname ) \ ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL classname::createClone( ) throw (::com::sun::star::uno::RuntimeException) \ { \ - classname* pClone = new classname( this, getORB() ); \ + classname* pClone = new classname( this, getContext().getLegacyServiceFactory() ); \ pClone->clonedFrom( this ); \ return pClone; \ } @@ -529,9 +600,10 @@ protected: //= OBoundControlModel //= model of a form layer control which is bound to a data source field //================================================================== -typedef ::cppu::ImplHelper3 < ::com::sun::star::form::XLoadListener +typedef ::cppu::ImplHelper4 < ::com::sun::star::form::XLoadListener , ::com::sun::star::form::XReset , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::sdb::XRowSetChangeListener > OBoundControlModel_BASE1; // separated into an own base class since derivees can disable the support for this @@ -565,14 +637,20 @@ protected: }; private: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xField; + // the form which controls supplies the field we bind to. + ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > + m_xAmbientForm; + ::rtl::OUString m_sValuePropertyName; sal_Int32 m_nValuePropertyAggregateHandle; sal_Int32 m_nFieldType; ::com::sun::star::uno::Type m_aValuePropertyType; bool m_bValuePropertyMayBeVoid; + ResetHelper m_aResetHelper; ::cppu::OInterfaceContainerHelper m_aUpdateListeners; - ::cppu::OInterfaceContainerHelper m_aResetListeners; ::cppu::OInterfaceContainerHelper m_aFormComponentListeners; ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding > @@ -585,15 +663,13 @@ private: ::rtl::OUString m_aControlSource; // Datenquelle, Name des Feldes ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLabelControl; // reference to a sibling control (model) which is our label - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - m_xField; sal_Bool m_bInputRequired; // </properties> ::comphelper::OPropertyChangeMultiplexer* m_pAggPropMultiplexer; - sal_Bool m_bLoadListening : 1; // are we currently a load listener at our parent form? + bool m_bFormListening : 1; // are we currently a XLoadListener at our ambient form? sal_Bool m_bLoaded : 1; sal_Bool m_bRequired : 1; const sal_Bool m_bCommitable : 1; // do we support XBoundComponent? @@ -910,10 +986,10 @@ protected: virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); - inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getField() const - { - return m_xField; - } + /// sets m_xField to the given new value, without notifying our listeners + void impl_setField_noNotify( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxField + ); inline bool hasField() const { return m_xField.is(); @@ -929,6 +1005,12 @@ protected: ) const; public: + inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getField() const + { + return m_xField; + } + +public: // UNO Anbindung DECLARE_UNO3_AGG_DEFAULTS(OBoundControlModel, OControlModel); virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); @@ -979,6 +1061,9 @@ public: // XPropertyChangeListener virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); + // XRowSetChangeListener + virtual void SAL_CALL onRowSetChanged( const ::com::sun::star::lang::EventObject& i_Event ) throw (::com::sun::star::uno::RuntimeException); + // XLoadListener virtual void SAL_CALL loaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL unloading( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); @@ -1030,7 +1115,7 @@ protected: @precond we do have an active external binding in place */ - void transferExternalValueToControl( ::osl::ResettableMutexGuard& _rInstanceLock ); + void transferExternalValueToControl( ControlModelLock& _rInstanceLock ); /** transfers the control value to the external binding @precond @@ -1038,7 +1123,7 @@ protected: @precond we do have an active external binding in place */ - void transferControlValueToExternal( ::osl::ResettableMutexGuard& _rInstanceLock ); + 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 @@ -1093,46 +1178,41 @@ private: /// initializes listening at the value property void implInitValuePropertyListening( ) const; - /** adds the component as load listener to the parent form + /** adds or removes the component as load listener to/from our form, and (if necessary) as RowSetChange listener at + our parent. - @precond there is a valid (non-NULL) parent form @precond there must no external value binding be in place - @precond We are currently *not* listening at the parent form. */ - void startLoadListening( ); + void doFormListening( const bool _bStart ); - /** removes the component as load listener from the parent form - @precond We currently *are* listening at the parent form. + inline bool isFormListening() const { return m_bFormListening; } + + /** determines the new value of m_xAmbientForm */ - void stopLoadListening( ); + void impl_determineAmbientForm_nothrow(); - inline sal_Bool isLoadListening() const { return m_bLoadListening; } + /** connects to a value supplier which is an database column. - /** connects to a value supplier which is an database column + The column is take from our parent, which must be a database form respectively row set. @precond The control does not have an external value supplier - @precond Our mutex is not locked - @param _rxRowSet - The row set which contains the column which we should connect to @param _bFromReload Determines whether the connection is made after the row set has been loaded (<FALSE/>) or reloaded (<TRUE/>) - @see disconnectDatabaseColumn + @see impl_disconnectDatabaseColumn_noNotify */ - void connectDatabaseColumn( - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet, + void impl_connectDatabaseColumn_noNotify( bool _bFromReload ); /** disconnects from a value supplier which is an database column @precond The control does not have an external value supplier - @precond Our mutex is not locked - @see connectDatabaseColumn + @see impl_connectDatabaseColumn_noNotify */ - void disconnectDatabaseColumn( ); + void impl_disconnectDatabaseColumn_noNotify(); /** connects to an external value binding @@ -1147,7 +1227,7 @@ private: */ void connectExternalValueBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding, - ::osl::ResettableMutexGuard& _rInstanceLock + ControlModelLock& _rInstanceLock ); /** disconnects from an external value binding @@ -1196,6 +1276,23 @@ private: ); }; + //========================================================================= + //= 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(); + } + //......................................................................... } //......................................................................... diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx index 6d7c6d422efe..ec237fc0aa1b 100644 --- a/forms/source/inc/InterfaceContainer.hxx +++ b/forms/source/inc/InterfaceContainer.hxx @@ -53,10 +53,11 @@ #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/util/XCloneable.hpp> #include <osl/mutex.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/component.hxx> -#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/implbase8.hxx> using namespace comphelper; @@ -91,13 +92,15 @@ typedef ::std::hash_multimap< ::rtl::OUString, InterfaceRef, ::comphelper::UStri // OInterfaceContainer // implements a container for form components //================================================================== -typedef ::cppu::ImplHelper7< ::com::sun::star::container::XNameContainer, - ::com::sun::star::container::XIndexContainer, - ::com::sun::star::container::XContainer, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::script::XEventAttacherManager, - ::com::sun::star::beans::XPropertyChangeListener, - ::com::sun::star::io::XPersistObject > OInterfaceContainer_BASE; +typedef ::cppu::ImplHelper8 < ::com::sun::star::container::XNameContainer + , ::com::sun::star::container::XIndexContainer + , ::com::sun::star::container::XContainer + , ::com::sun::star::container::XEnumerationAccess + , ::com::sun::star::script::XEventAttacherManager + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::io::XPersistObject + , ::com::sun::star::util::XCloneable + > OInterfaceContainer_BASE; class OInterfaceContainer : public OInterfaceContainer_BASE { @@ -108,7 +111,7 @@ protected: OInterfaceMap m_aMap; ::cppu::OInterfaceContainerHelper m_aContainerListeners; - ::com::sun::star::uno::Type m_aElementType; + const ::com::sun::star::uno::Type m_aElementType; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xServiceFactory; @@ -122,6 +125,12 @@ public: ::osl::Mutex& _rMutex, const ::com::sun::star::uno::Type& _rElementType); + OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource ); + + // late constructor for cloning + void clonedFrom( const OInterfaceContainer& _cloneSource ); + +protected: virtual ~OInterfaceContainer(); public: @@ -221,11 +230,17 @@ protected: ) throw(::com::sun::star::lang::IllegalArgumentException); // called after the object is inserted, but before the "real listeners" are notified - virtual void implInserted( const ElementDescription* /*_pElement*/ ) { } + virtual void implInserted( const ElementDescription* _pElement ); // called after the object is removed, but before the "real listeners" are notified - virtual void implRemoved(const InterfaceRef& /*_rxObject*/) { } - // called after an object was replaced, but before the "real listeners" are notified - virtual void implReplaced( const InterfaceRef& /*_rxReplacedObject*/, const ElementDescription* /*_pElement*/ ) { } + virtual void implRemoved(const InterfaceRef& _rxObject); + + /** called after an object was replaced. The default implementation notifies our listeners, after releasing + the instance lock. + */ + virtual void impl_replacedElement( + const ::com::sun::star::container::ContainerEvent& _rEvent, + ::osl::ClearableMutexGuard& _rInstanceLock + ); void SAL_CALL writeEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); void SAL_CALL readEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); @@ -270,6 +285,8 @@ private: efVersionSO6x }; void transformEvents( const EventFormat _eTargetFormat ); + + void impl_createEventAttacher_nothrow(); }; //================================================================== @@ -278,9 +295,9 @@ private: typedef ::cppu::ImplHelper1< ::com::sun::star::form::XFormComponent> OFormComponents_BASE; typedef ::cppu::OComponentHelper FormComponentsBase; // else MSVC kills itself on some statements -class OFormComponents : public FormComponentsBase, - public OInterfaceContainer, - public OFormComponents_BASE +class OFormComponents :public FormComponentsBase + ,public OInterfaceContainer + ,public OFormComponents_BASE { protected: ::osl::Mutex m_aMutex; @@ -288,6 +305,7 @@ protected: public: OFormComponents(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); + OFormComponents( const OFormComponents& _cloneSource ); virtual ~OFormComponents(); DECLARE_UNO3_AGG_DEFAULTS(OFormComponents, FormComponentsBase); diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index 13fbf9723eeb..bf2d5d4d7446 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -113,6 +113,7 @@ namespace frm FORMS_CONSTASCII_STRING( PROPERTY_CYCLE, "Cycle" ); FORMS_CONSTASCII_STRING( PROPERTY_CONTROLSOURCE, "DataField" ); FORMS_CONSTASCII_STRING( PROPERTY_ENABLED, "Enabled" ); + FORMS_CONSTASCII_STRING( PROPERTY_ENABLEVISIBLE, "EnableVisible" ); FORMS_CONSTASCII_STRING( PROPERTY_READONLY, "ReadOnly" ); FORMS_CONSTASCII_STRING( PROPERTY_RELEVANT, "Relevant" ); FORMS_CONSTASCII_STRING( PROPERTY_ISREADONLY, "IsReadOnly" ); @@ -135,7 +136,7 @@ namespace frm FORMS_CONSTASCII_STRING( PROPERTY_BUTTONTYPE, "ButtonType" ); FORMS_CONSTASCII_STRING( PROPERTY_STRINGITEMLIST, "StringItemList" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_TEXT, "DefaultText" ); - FORMS_CONSTASCII_STRING( PROPERTY_DEFAULTCHECKED, "DefaultState" ); + FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_STATE, "DefaultState" ); FORMS_CONSTASCII_STRING( PROPERTY_FORMATKEY, "FormatKey" ); FORMS_CONSTASCII_STRING( PROPERTY_FORMATSSUPPLIER, "FormatsSupplier" ); FORMS_CONSTASCII_STRING( PROPERTY_SUBMIT_ACTION, "SubmitAction" ); diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index 065a46eb5b8c..df94d1575a5a 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -118,7 +118,7 @@ namespace frm #define PROPERTY_ID_SUBMIT_ENCODING (PROPERTY_ID_START + 74) // FmSubmitEncoding #define PROPERTY_ID_DEFAULT_VALUE (PROPERTY_ID_START + 75) // ::rtl::OUString #define PROPERTY_ID_SUBMIT_TARGET (PROPERTY_ID_START + 76) // ::rtl::OUString -#define PROPERTY_ID_DEFAULTCHECKED (PROPERTY_ID_START + 77) // UINT16 +#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) // ::rtl::OUString // free @@ -206,7 +206,7 @@ namespace frm #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 - // FREE +#define PROPERTY_ID_ENABLEVISIBLE (PROPERTY_ID_START +165) // BOOL // FREE // FREE // FREE diff --git a/forms/source/inc/resettable.hxx b/forms/source/inc/resettable.hxx new file mode 100644 index 000000000000..f8815d5e3eb3 --- /dev/null +++ b/forms/source/inc/resettable.hxx @@ -0,0 +1,75 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+#ifndef FORMS_RESETTABLE_HXX +#define FORMS_RESETTABLE_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/form/XResetListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/interfacecontainer.hxx> + +namespace cppu +{ + class OWeakObject; +} + +//........................................................................ +namespace frm +{ +//........................................................................ + + //==================================================================== + //= ResetHelper + //==================================================================== + class ResetHelper + { + public: + ResetHelper( ::cppu::OWeakObject& _parent, ::osl::Mutex& _mutex ) + :m_rParent( _parent ) + ,m_aResetListeners( _mutex ) + { + } + + // XReset equivalents + void addResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _listener ); + void removeResetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _listener ); + + // calling listeners + bool approveReset(); + void notifyResetted(); + void disposing(); + + private: + ::cppu::OWeakObject& m_rParent; + ::cppu::OInterfaceContainerHelper m_aResetListeners; + }; + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // FORMS_RESETTABLE_HXX diff --git a/forms/source/inc/togglestate.hxx b/forms/source/inc/togglestate.hxx new file mode 100644 index 000000000000..04755000db19 --- /dev/null +++ b/forms/source/inc/togglestate.hxx @@ -0,0 +1,43 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+#ifndef FORMS_TOGGLESTATE_HXX +#define FORMS_TOGGLESTATE_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//........................................................................ +namespace frm +{ +//........................................................................ + + enum ToggleState { STATE_NOCHECK = 0, STATE_CHECK = 1, STATE_DONTKNOW = 2 }; + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // FORMS_TOGGLESTATE_HXX diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 7cb608334d30..813b1873b786 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -30,34 +30,34 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include "InterfaceContainer.hxx" -#include <cppuhelper/queryinterface.hxx> -#include <comphelper/eventattachermgr.hxx> -#include <comphelper/types.hxx> -#include <comphelper/enumhelper.hxx> -#include <comphelper/property.hxx> -#include <comphelper/container.hxx> -#include <comphelper/sequence.hxx> - -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "services.hxx" -#ifndef _FRM_RESOURCE_HRC_ -#include "frm_resource.hrc" -#endif -#include "frm_resource.hxx" -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/io/XMarkableStream.hpp> -#include <com/sun/star/io/WrongFormatException.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> - -#include <algorithm> -#include <memory> -#include <rtl/logfile.hxx> + +#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "InterfaceContainer.hxx"
+#include "property.hrc"
+#include "services.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/io/XMarkableStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/eventattachermgr.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <rtl/logfile.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+ +#include <algorithm>
+#include <memory>
//......................................................................... #include <com/sun/star/frame/XModel.hpp> @@ -78,6 +78,7 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::script; using namespace ::com::sun::star::io; using namespace ::com::sun::star::form; +using namespace ::com::sun::star::util; namespace { @@ -193,15 +194,56 @@ OInterfaceContainer::OInterfaceContainer( const Reference<XMultiServiceFactory>& _rxFactory, ::osl::Mutex& _rMutex, const Type& _rElementType) - :m_rMutex(_rMutex) - ,m_aContainerListeners(_rMutex) - ,m_aElementType(_rElementType) - ,m_xServiceFactory(_rxFactory) + :OInterfaceContainer_BASE() + ,m_rMutex(_rMutex) + ,m_aContainerListeners(_rMutex) + ,m_aElementType(_rElementType) + ,m_xServiceFactory(_rxFactory) +{ + impl_createEventAttacher_nothrow(); +} + +//------------------------------------------------------------------------------ +OInterfaceContainer::OInterfaceContainer( ::osl::Mutex& _rMutex, const OInterfaceContainer& _cloneSource ) + :OInterfaceContainer_BASE() + ,m_rMutex( _rMutex ) + ,m_aContainerListeners( _rMutex ) + ,m_aElementType( _cloneSource.m_aElementType ) + ,m_xServiceFactory( _cloneSource.m_xServiceFactory ) +{ + impl_createEventAttacher_nothrow(); +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::clonedFrom( const OInterfaceContainer& _cloneSource ) +{ + try + { + const Reference< XIndexAccess > xSourceHierarchy( const_cast< OInterfaceContainer* >( &_cloneSource ) ); + const sal_Int32 nCount = xSourceHierarchy->getCount(); + for ( sal_Int32 i=0; i<nCount; ++i ) + { + Reference< XCloneable > xCloneable( xSourceHierarchy->getByIndex( i ), UNO_QUERY_THROW ); + Reference< XInterface > xClone( xCloneable->createClone() ); + insertByIndex( i, makeAny( xClone ) ); + } + } + catch( const Exception& ) + { + throw WrappedTargetException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not clone the given interface hierarchy." ) ), + static_cast< XIndexContainer* >( const_cast< OInterfaceContainer* >( &_cloneSource ) ), + ::cppu::getCaughtException() + ); + } +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::impl_createEventAttacher_nothrow() { try { - m_xEventAttacher = ::comphelper::createEventAttacherManager(m_xServiceFactory); - OSL_ENSURE( m_xEventAttacher.is(), "OInterfaceContainer::OInterfaceContainer: no event attacher manager!" ); + m_xEventAttacher.set( ::comphelper::createEventAttacherManager( m_xServiceFactory ), UNO_SET_THROW ); } catch( const Exception& ) { @@ -209,7 +251,10 @@ OInterfaceContainer::OInterfaceContainer( } } -OInterfaceContainer::~OInterfaceContainer() {} +//------------------------------------------------------------------------------ +OInterfaceContainer::~OInterfaceContainer() +{ +} //------------------------------------------------------------------------------ void OInterfaceContainer::disposing() @@ -891,6 +936,25 @@ void OInterfaceContainer::removeElementsNoEvents(sal_Int32 nIndex) xChild->setParent(InterfaceRef ()); } +//------------------------------------------------------------------------------ +void OInterfaceContainer::implInserted( const ElementDescription* /*_pElement*/ ) +{ + // not inrerested in +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::implRemoved( const InterfaceRef& /*_rxObject*/ ) +{ + // not inrerested in +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::impl_replacedElement( const ContainerEvent& _rEvent, ::osl::ClearableMutexGuard& _rInstanceLock ) +{ + _rInstanceLock.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, _rEvent ); +} + // XIndexContainer //------------------------------------------------------------------------------ void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any& _rElement ) throw(IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) @@ -964,17 +1028,13 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any m_xEventAttacher->attach( _nIndex, aElementMetaData.get()->xInterface, makeAny( aElementMetaData.get()->xPropertySet ) ); } - implReplaced( xOldElement, aElementMetaData.get() ); - - // benachrichtigen - ContainerEvent aEvt; - aEvt.Source = static_cast<XContainer*>(this); - aEvt.Accessor <<= _nIndex; - aEvt.Element = aElementMetaData.get()->aElementTypeInterface; - aEvt.ReplacedElement = xOldElement->queryInterface( m_aElementType ); + ContainerEvent aReplaceEvent; + aReplaceEvent.Source = static_cast< XContainer* >( this ); + aReplaceEvent.Accessor <<= _nIndex; + aReplaceEvent.Element = aElementMetaData.get()->xInterface->queryInterface( m_aElementType ); + aReplaceEvent.ReplacedElement = xOldElement->queryInterface( m_aElementType ); - _rClearBeforeNotify.clear(); - m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvt ); + impl_replacedElement( aReplaceEvent, _rClearBeforeNotify ); } //------------------------------------------------------------------------------ @@ -1248,8 +1308,17 @@ Sequence<Type> SAL_CALL OFormComponents::getTypes() throw(RuntimeException) //------------------------------------------------------------------------------ OFormComponents::OFormComponents(const Reference<XMultiServiceFactory>& _rxFactory) - :FormComponentsBase(m_aMutex) - ,OInterfaceContainer(_rxFactory, m_aMutex, ::getCppuType(static_cast<Reference<XFormComponent>*>(NULL))) + :FormComponentsBase( m_aMutex ) + ,OInterfaceContainer( _rxFactory, m_aMutex, XFormComponent::static_type() ) + ,OFormComponents_BASE() +{ +} + +//------------------------------------------------------------------------------ +OFormComponents::OFormComponents( const OFormComponents& _cloneSource ) + :FormComponentsBase( m_aMutex ) + ,OInterfaceContainer( m_aMutex, _cloneSource ) + ,OFormComponents_BASE() { } diff --git a/forms/source/misc/property.cxx b/forms/source/misc/property.cxx index a47b7b73b706..12cc73e10264 100644 --- a/forms/source/misc/property.cxx +++ b/forms/source/misc/property.cxx @@ -106,6 +106,7 @@ void PropertyInfoService::initialize() ADD_PROP_ASSIGNMENT(CYCLE); ADD_PROP_ASSIGNMENT(CONTROLSOURCE); ADD_PROP_ASSIGNMENT(ENABLED); + ADD_PROP_ASSIGNMENT(ENABLEVISIBLE); ADD_PROP_ASSIGNMENT(SPIN); ADD_PROP_ASSIGNMENT(READONLY); ADD_PROP_ASSIGNMENT(FILTER); @@ -125,7 +126,7 @@ void PropertyInfoService::initialize() ADD_PROP_ASSIGNMENT(BUTTONTYPE); ADD_PROP_ASSIGNMENT(STRINGITEMLIST); ADD_PROP_ASSIGNMENT(DEFAULT_TEXT); - ADD_PROP_ASSIGNMENT(DEFAULTCHECKED); + ADD_PROP_ASSIGNMENT(DEFAULT_STATE); ADD_PROP_ASSIGNMENT(DEFAULT_DATE); ADD_PROP_ASSIGNMENT(DEFAULT_TIME); ADD_PROP_ASSIGNMENT(DEFAULT_VALUE); diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index ca2bf688a92d..d38b350ada32 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -88,6 +88,7 @@ namespace frm getPropertyDefaultByHandle( PROPERTY_ID_DEFAULTCONTROL ) >>= m_sDefaultControl; getPropertyDefaultByHandle( PROPERTY_ID_BORDER ) >>= m_nBorder; getPropertyDefaultByHandle( PROPERTY_ID_ENABLED ) >>= m_bEnabled; + getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE ) >>= m_bEnableVisible; getPropertyDefaultByHandle( PROPERTY_ID_HARDLINEBREAKS ) >>= m_bHardLineBreaks; getPropertyDefaultByHandle( PROPERTY_ID_HSCROLL ) >>= m_bHScroll; getPropertyDefaultByHandle( PROPERTY_ID_VSCROLL ) >>= m_bVScroll; @@ -124,6 +125,7 @@ namespace frm m_sHelpURL = _pOriginal->m_sHelpURL; m_nBorder = _pOriginal->m_nBorder; m_bEnabled = _pOriginal->m_bEnabled; + m_bEnableVisible = _pOriginal->m_bEnableVisible; m_bHardLineBreaks = _pOriginal->m_bHardLineBreaks; m_bHScroll = _pOriginal->m_bHScroll; m_bVScroll = _pOriginal->m_bVScroll; @@ -188,6 +190,7 @@ namespace frm REGISTER_PROP_2( HELPTEXT, m_sHelpText, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HELPURL, m_sHelpURL, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( ENABLED, m_bEnabled, BOUND, MAYBEDEFAULT ); + REGISTER_PROP_2( ENABLEVISIBLE, m_bEnableVisible, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( BORDER, m_nBorder, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HARDLINEBREAKS, m_bHardLineBreaks, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HSCROLL, m_bHScroll, BOUND, MAYBEDEFAULT ); @@ -456,6 +459,7 @@ namespace frm break; case PROPERTY_ID_ENABLED: + case PROPERTY_ID_ENABLEVISIBLE: case PROPERTY_ID_PRINTABLE: case PROPERTY_ID_HIDEINACTIVESELECTION: aDefault <<= (sal_Bool)sal_True; diff --git a/forms/source/richtext/richtextmodel.hxx b/forms/source/richtext/richtextmodel.hxx index b124f76c4237..5e905e2873ad 100644 --- a/forms/source/richtext/richtextmodel.hxx +++ b/forms/source/richtext/richtextmodel.hxx @@ -83,6 +83,7 @@ namespace frm sal_Int16 m_nContextWritingMode; sal_Int16 m_nBorder; sal_Bool m_bEnabled; + sal_Bool m_bEnableVisible; sal_Bool m_bHardLineBreaks; sal_Bool m_bHScroll; sal_Bool m_bVScroll; diff --git a/forms/source/richtext/richtextunowrapper.cxx b/forms/source/richtext/richtextunowrapper.cxx index 13da356d0ad3..f5a9d178d32c 100644 --- a/forms/source/richtext/richtextunowrapper.cxx +++ b/forms/source/richtext/richtextunowrapper.cxx @@ -37,6 +37,7 @@ /** === end UNO includes === **/ #include <svx/unofored.hxx> #include <svx/editview.hxx> +#include <svx/unoipset.hxx> //........................................................................ namespace frm @@ -51,10 +52,10 @@ namespace frm //==================================================================== namespace { - const SfxItemPropertyMap* getTextEnginePropertyMap() + const SvxItemPropertySet* getTextEnginePropertySet() { // Propertymap fuer einen Outliner Text - static const SfxItemPropertyMap aTextEnginePropertyMap[] = + static const SfxItemPropertyMapEntry aTextEnginePropertyMap[] = { SVX_UNOEDIT_CHAR_PROPERTIES, SVX_UNOEDIT_FONT_PROPERTIES, @@ -63,8 +64,8 @@ namespace frm { MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 }, { NULL, 0, 0, NULL, 0, 0 } }; - - return aTextEnginePropertyMap; + static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap ); + return &aTextEnginePropertySet; } } @@ -73,7 +74,7 @@ namespace frm //==================================================================== //-------------------------------------------------------------------- ORichTextUnoWrapper::ORichTextUnoWrapper( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener ) - :SvxUnoText( getTextEnginePropertyMap() ) + :SvxUnoText( getTextEnginePropertySet() ) { SetEditSource( new RichTextEditSource( _rEngine, _pTextChangeListener ) ); } diff --git a/forms/source/richtext/richtextvclcontrol.cxx b/forms/source/richtext/richtextvclcontrol.cxx index 7c5505d1d87d..f3c56cc6cd88 100644 --- a/forms/source/richtext/richtextvclcontrol.cxx +++ b/forms/source/richtext/richtextvclcontrol.cxx @@ -233,7 +233,7 @@ namespace frm { // Ctrl-Tab is used to step out of the control // -> build a new key event without the Ctrl-key, and let the very base class handle it - KeyCode aNewCode( KEY_TAB, bShift, sal_False, sal_False ); + KeyCode aNewCode( KEY_TAB, bShift, sal_False, sal_False, sal_False ); ::KeyEvent aNewEvent( pKeyEvent->GetCharCode(), aNewCode ); Control::KeyInput( aNewEvent ); return 1; // handled diff --git a/forms/source/xforms/submission/replace.cxx b/forms/source/xforms/submission/replace.cxx index e0504973f7ac..9c54d6e7164a 100644 --- a/forms/source/xforms/submission/replace.cxx +++ b/forms/source/xforms/submission/replace.cxx @@ -30,8 +30,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" - +#include <memory> #include "submission.hxx" +#include "serialization_app_xml.hxx" #include <rtl/ustring.hxx> #include <rtl/string.hxx> @@ -44,11 +45,14 @@ #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <ucbhelper/content.hxx> using namespace com::sun::star::uno; +using namespace com::sun::star::ucb; using namespace com::sun::star::frame; using namespace com::sun::star::lang; using namespace com::sun::star::beans; +using namespace com::sun::star::task; using namespace com::sun::star::xml::dom; CSubmission::SubmissionResult CSubmission::replace(const ::rtl::OUString& aReplace, const Reference<XDocument>& aDocument, const Reference<XFrame>& aFrame) @@ -116,5 +120,29 @@ CSubmission::SubmissionResult CSubmission::replace(const ::rtl::OUString& aRepla } return CSubmission::UNKNOWN_ERROR; } +::std::auto_ptr< CSerialization > CSubmission::createSerialization(const Reference< XInteractionHandler >& _xHandler,Reference<XCommandEnvironment>& _rOutEnv) +{ + // PUT always uses application/xml + ::std::auto_ptr< CSerialization > apSerialization(new CSerializationAppXML()); + apSerialization->setSource(m_aFragment); + apSerialization->serialize(); + + // create a commandEnvironment and use the default interaction handler + CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper; + if( _xHandler.is() ) + pHelper->m_aInteractionHandler = _xHandler; + else + pHelper->m_aInteractionHandler = CSS::uno::Reference< XInteractionHandler >(m_aFactory->createInstance( + ::rtl::OUString::createFromAscii("com.sun.star.task.InteractionHandler")), UNO_QUERY); + OSL_ENSURE(pHelper->m_aInteractionHandler.is(), "failed to create IntreractionHandler"); + + CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper; + pHelper->m_aProgressHandler = Reference< XProgressHandler >(pProgressHelper); + + // UCB has ownership of environment... + _rOutEnv = pHelper; + return apSerialization; +} + diff --git a/forms/source/xforms/submission/submission.hxx b/forms/source/xforms/submission/submission.hxx index a435d7c7fc15..c146282903c4 100644 --- a/forms/source/xforms/submission/submission.hxx +++ b/forms/source/xforms/submission/submission.hxx @@ -35,12 +35,14 @@ #include <rtl/ustring.h> #include <osl/conditn.hxx> #include <osl/mutex.hxx> +#include <unotools/processfactory.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/xml/xpath/XXPathObject.hpp> #include <com/sun/star/xml/dom/XDocumentFragment.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XProgressHandler.hpp> @@ -66,10 +68,12 @@ class CCommandEnvironmentHelper : public cppu::WeakImplHelper1< CSS::ucb::XComma friend class CSubmissionPut; friend class CSubmissionPost; friend class CSubmissionGet; + friend class CSubmission; protected: - CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler; - CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler; + CSS::uno::Reference< CSS::task::XInteractionHandler > m_aInteractionHandler; + CSS::uno::Reference< CSS::ucb::XProgressHandler > m_aProgressHandler; + public: virtual CSS::uno::Reference< CSS::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (CSS::uno::RuntimeException) { @@ -118,11 +122,15 @@ class CSubmission protected: INetURLObject m_aURLObj; - CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject; + CSS::uno::Reference< CSS::xml::xpath::XXPathObject > m_aXPathObject; CSS::uno::Reference< CSS::xml::dom::XDocumentFragment > m_aFragment; - CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream; + CSS::uno::Reference< CSS::io::XInputStream > m_aResultStream; + CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory; rtl::OUString m_aEncoding; + ::std::auto_ptr< CSerialization > createSerialization(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& aHandler + ,com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment>& _rOutEnv); + public: enum SubmissionResult { SUCCESS, @@ -136,6 +144,7 @@ public: CSubmission(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) : m_aURLObj(aURL) , m_aFragment(aFragment) + , m_aFactory(::utl::getProcessServiceFactory()) {} virtual ~CSubmission() {} diff --git a/forms/source/xforms/submission/submission_get.cxx b/forms/source/xforms/submission/submission_get.cxx index 9ca195be946f..c310be9fc82f 100644 --- a/forms/source/xforms/submission/submission_get.cxx +++ b/forms/source/xforms/submission/submission_get.cxx @@ -55,7 +55,6 @@ using namespace std; CSubmissionGet::CSubmissionGet(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) - , m_aFactory(utl::getProcessServiceFactory()) { } diff --git a/forms/source/xforms/submission/submission_post.cxx b/forms/source/xforms/submission/submission_post.cxx index 53047c7036e9..8142fec3df05 100644 --- a/forms/source/xforms/submission/submission_post.cxx +++ b/forms/source/xforms/submission/submission_post.cxx @@ -55,29 +55,14 @@ using namespace std; CSubmissionPost::CSubmissionPost(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) - , m_aFactory(utl::getProcessServiceFactory()) { } CSubmission::SubmissionResult CSubmissionPost::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler) { // PUT always uses application/xml - auto_ptr< CSerialization > apSerialization(new CSerializationAppXML()); - apSerialization->setSource(m_aFragment); - apSerialization->serialize(); - - // create a commandEnvironment and use the default interaction handler - CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper; - if( aInteractionHandler.is() ) - pHelper->m_aInteractionHandler = aInteractionHandler; - else - pHelper->m_aInteractionHandler = CSS::uno::Reference< XInteractionHandler >(m_aFactory->createInstance( - OUString::createFromAscii("com.sun.star.task.InteractionHandler")), UNO_QUERY); - OSL_ENSURE(pHelper->m_aInteractionHandler.is(), "failed to create IntreractionHandler"); - CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper; - pHelper->m_aProgressHandler = CSS::uno::Reference< XProgressHandler >(pProgressHelper); - // UCB has ownership of environment... - CSS::uno::Reference< XCommandEnvironment > aEnvironment(pHelper); + CSS::uno::Reference< XCommandEnvironment > aEnvironment; + auto_ptr< CSerialization > apSerialization(createSerialization(aInteractionHandler,aEnvironment)); try { ucbhelper::Content aContent(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE), aEnvironment); diff --git a/forms/source/xforms/submission/submission_post.hxx b/forms/source/xforms/submission/submission_post.hxx index d812c0bec858..a3c109033664 100644 --- a/forms/source/xforms/submission/submission_post.hxx +++ b/forms/source/xforms/submission/submission_post.hxx @@ -31,14 +31,10 @@ #ifndef __SUBMISSION_POST_HXX #define __SUBMISSION_POST_HXX -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - #include "submission.hxx" class CSubmissionPost : public CSubmission { -private: - CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory; public: CSubmissionPost(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment); virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler); diff --git a/forms/source/xforms/submission/submission_put.cxx b/forms/source/xforms/submission/submission_put.cxx index 50d80880b07a..10bc0e2b0896 100644 --- a/forms/source/xforms/submission/submission_put.cxx +++ b/forms/source/xforms/submission/submission_put.cxx @@ -53,31 +53,13 @@ using namespace std; CSubmissionPut::CSubmissionPut(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) : CSubmission(aURL, aFragment) - , m_aFactory(utl::getProcessServiceFactory()) { } CSubmission::SubmissionResult CSubmissionPut::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler) { - // PUT always uses application/xml - auto_ptr< CSerialization > apSerialization(new CSerializationAppXML()); - apSerialization->setSource(m_aFragment); - apSerialization->serialize(); - - // create a commandEnvironment and use the default interaction handler - CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper; - if( aInteractionHandler.is() ) - pHelper->m_aInteractionHandler = aInteractionHandler; - else - pHelper->m_aInteractionHandler = CSS::uno::Reference< XInteractionHandler >(m_aFactory->createInstance( - OUString::createFromAscii("com.sun.star.task.InteractionHandler")), UNO_QUERY); - OSL_ENSURE(pHelper->m_aInteractionHandler.is(), "failed to create IntreractionHandler"); - - CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper; - pHelper->m_aProgressHandler = CSS::uno::Reference< XProgressHandler >(pProgressHelper); - - // UCB has ownership of environment... - CSS::uno::Reference< XCommandEnvironment > aEnvironment(pHelper); + CSS::uno::Reference< XCommandEnvironment > aEnvironment; + auto_ptr< CSerialization > apSerialization(createSerialization(aInteractionHandler,aEnvironment)); try { ucbhelper::Content aContent(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE), aEnvironment); diff --git a/forms/source/xforms/submission/submission_put.hxx b/forms/source/xforms/submission/submission_put.hxx index da95f926ebaf..3bf3d2fd92a1 100644 --- a/forms/source/xforms/submission/submission_put.hxx +++ b/forms/source/xforms/submission/submission_put.hxx @@ -38,8 +38,6 @@ class CSubmissionPut : public CSubmission { -private: - CSS::uno::Reference< CSS::lang::XMultiServiceFactory > m_aFactory; public: CSubmissionPut(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment); virtual SubmissionResult submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler); |