diff options
68 files changed, 2605 insertions, 1319 deletions
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index ad607469937d..4d7c09563b5d 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -40,6 +40,7 @@ #include "modulepcr.hxx" #include "pcrcommon.hxx" #include "pcrstrings.hxx" +#include "propertycontrolextender.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/XTabControllerModel.hpp> @@ -59,6 +60,8 @@ #include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/script/XScriptEventsSupplier.hpp> #include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp> /** === end UNO includes === **/ #include <comphelper/namedvaluecollection.hxx> @@ -136,6 +139,10 @@ namespace pcr using ::com::sun::star::frame::XModel; using ::com::sun::star::frame::XController; using ::com::sun::star::uno::UNO_SET_THROW; + using com::sun::star::uri::UriReferenceFactory; + using com::sun::star::uri::XUriReferenceFactory; + using com::sun::star::uri::XVndSunStarScriptUrlReference; + using ::com::sun::star::lang::XEventListener; /** === end UNO using === **/ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType; namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -676,9 +683,8 @@ namespace pcr { ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( false, "EventHandler::convertToPropertyValue: why calling this for read-only controls?" ); - // since currently, the controls to display the script events are readonly, this method should normally - // not be called. + ::rtl::OUString sNewScriptCode; + OSL_VERIFY( _rControlValue >>= sNewScriptCode ); Sequence< ScriptEventDescriptor > aAllAssignedEvents; impl_getComponentScriptEvents_nothrow( aAllAssignedEvents ); @@ -686,14 +692,17 @@ namespace pcr const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName ); ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( rEvent, aAllAssignedEvents ); -#if OSL_DEBUG_LEVEL > 0 - ::rtl::OUString sControlValue; - OSL_VERIFY( _rControlValue >>= sControlValue ); - OSL_ENSURE( sControlValue == aAssignedScript.ScriptCode, "EventHandler::convertToPropertyValue: somebody really managed to enter a new value in the control?" ); -#else - (void)_rControlValue; -#endif + OSL_ENSURE( !sNewScriptCode.getLength(), "EventHandler::convertToPropertyValue: cannot convert a non-empty display name!" ); + // Usually, there is no possibility for the user to change the content of an event binding directly in the + // input field, this instead is done with the macro assignment dialog. + // The only exception is the user pressing "DEL" while the control has the focus, in this case, we reset the + // control content to an empty string. So this is the only scenario where this method is allowed to be called. + // Striclty, we would be able to convert the display value to a property value, + // using the "name (location, language)" format we used in convertToControlValue. However, + // there is no need for this code ... + + aAssignedScript.ScriptCode = sNewScriptCode; return makeAny( aAssignedScript ); } @@ -708,7 +717,58 @@ namespace pcr OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING, "EventHandler::convertToControlValue: unexpected ControlValue type class!" ); (void)_rControlValueType; - return makeAny( aScriptEvent.ScriptCode ); + + ::rtl::OUString sScript( aScriptEvent.ScriptCode ); + if ( sScript.getLength() ) + { + // format is: "name (location, language)" + try + { + // parse + Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_aContext.getUNOContext() ); + Reference< XVndSunStarScriptUrlReference > xScriptUri( xUriRefFac->parse( sScript ), UNO_QUERY_THROW ); + + ::rtl::OUStringBuffer aComposeBuffer; + + // name + aComposeBuffer.append( xScriptUri->getName() ); + + // location + const ::rtl::OUString sLocationParamName( RTL_CONSTASCII_USTRINGPARAM( "location" ) ); + const ::rtl::OUString sLocation = xScriptUri->getParameter( sLocationParamName ); + const ::rtl::OUString sLangParamName( RTL_CONSTASCII_USTRINGPARAM( "language" ) ); + const ::rtl::OUString sLanguage = xScriptUri->getParameter( sLangParamName ); + + if ( sLocation.getLength() || sLanguage.getLength() ) + { + aComposeBuffer.appendAscii( " (" ); + + // location + OSL_ENSURE( sLocation.getLength(), "EventHandler::convertToControlValue: unexpected: no location!" ); + if ( sLocation.getLength() ) + { + aComposeBuffer.append( sLocation ); + aComposeBuffer.appendAscii( ", " ); + } + + // language + if ( sLanguage.getLength() ) + { + aComposeBuffer.append( sLanguage ); + } + + aComposeBuffer.append( sal_Unicode( ')' ) ); + } + + sScript = aComposeBuffer.makeStringAndClear(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + return makeAny( sScript ); } //-------------------------------------------------------------------- @@ -829,7 +889,10 @@ namespace pcr ::osl::MutexGuard aGuard( m_aMutex ); LineDescriptor aDescriptor; + aDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::TextField, sal_True ); + Reference< XEventListener > xControlExtender = new PropertyControlExtender( aDescriptor.Control ); + const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName ); aDescriptor.DisplayName = rEvent.sDisplayName; aDescriptor.HelpURL = HelpIdUrl::getHelpURL( rEvent.nHelpId ); diff --git a/extensions/source/propctrlr/formres.src b/extensions/source/propctrlr/formres.src index 3700667dd0e9..084825dfd05c 100644 --- a/extensions/source/propctrlr/formres.src +++ b/extensions/source/propctrlr/formres.src @@ -77,7 +77,7 @@ String RID_STR_SHOWTHOUSANDSEP }; String RID_STR_PRINTABLE { - Text [ en-US ] = "Print" ; + Text [ en-US ] = "Printable" ; }; String RID_STR_TARGET_URL { @@ -744,7 +744,7 @@ String RID_STR_EVT_APPROVEPARAMETER }; String RID_STR_EVT_ACTIONPERFORMED { - Text [ en-US ] = "When initiating" ; + Text [ en-US ] = "Execute action" ; }; String RID_STR_EVT_AFTERUPDATE { @@ -844,7 +844,7 @@ String RID_STR_EVT_APPROVERESETTED }; String RID_STR_EVT_APPROVEACTIONPERFORMED { - Text [ en-US ] = "Before commencing" ; + Text [ en-US ] = "Approve action" ; }; String RID_STR_EVT_SUBMITTED { diff --git a/extensions/source/propctrlr/makefile.mk b/extensions/source/propctrlr/makefile.mk index 62ca941f3751..47e0c995a49b 100644 --- a/extensions/source/propctrlr/makefile.mk +++ b/extensions/source/propctrlr/makefile.mk @@ -97,7 +97,8 @@ SLOFILES= $(SLO)$/controlfontdialog.obj \ $(SLO)$/inspectorhelpwindow.obj \ $(SLO)$/defaulthelpprovider.obj \ $(SLO)$/MasterDetailLinkDialog.obj \ - $(SLO)$/inspectormodelbase.obj + $(SLO)$/inspectormodelbase.obj \ + $(SLO)$/propertycontrolextender.obj SRS1NAME=$(TARGET) SRC1FILES= propres.src \ diff --git a/extensions/source/propctrlr/propertycontrolextender.cxx b/extensions/source/propctrlr/propertycontrolextender.cxx new file mode 100644 index 000000000000..205f7c423025 --- /dev/null +++ b/extensions/source/propctrlr/propertycontrolextender.cxx @@ -0,0 +1,148 @@ +/************************************************************************* +* 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: code,v $ +* +* $Revision: 1.3 $ +* +* 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_extensions.hxx" + +#ifndef EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX +#include "propertycontrolextender.hxx" +#endif + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/KeyFunction.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace pcr +{ +//........................................................................ + + /** === 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::awt::XWindow; + using ::com::sun::star::awt::KeyEvent; + using ::com::sun::star::inspection::XPropertyControl; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::inspection::XPropertyControlContext; + /** === end UNO using === **/ + namespace KeyFunction = ::com::sun::star::awt::KeyFunction; + + //==================================================================== + //= PropertyControlExtender_Data + //==================================================================== + struct PropertyControlExtender_Data + { + Reference< XPropertyControl > xControl; + Reference< XWindow > xControlWindow; + }; + + //==================================================================== + //= PropertyControlExtender + //==================================================================== + //-------------------------------------------------------------------- + PropertyControlExtender::PropertyControlExtender( const Reference< XPropertyControl >& _rxObservedControl ) + :m_pData( new PropertyControlExtender_Data ) + { + try + { + m_pData->xControl.set( _rxObservedControl, UNO_SET_THROW ); + m_pData->xControlWindow.set( m_pData->xControl->getControlWindow(), UNO_SET_THROW ); + m_pData->xControlWindow->addKeyListener( this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + PropertyControlExtender::~PropertyControlExtender() + { + } + + //-------------------------------------------------------------------- + void SAL_CALL PropertyControlExtender::keyPressed( const KeyEvent& _event ) throw (RuntimeException) + { + OSL_ENSURE( _event.Source == m_pData->xControlWindow, "PropertyControlExtender::keyPressed: where does this come from?" ); + if ( ( _event.KeyFunc == KeyFunction::DELETE ) + && ( _event.Modifiers == 0 ) + ) + { + try + { + Reference< XPropertyControl > xControl( m_pData->xControl, UNO_SET_THROW ); + + // reset the value + xControl->setValue( Any() ); + + // and notify the change + // don't use XPropertyControl::notifyModifiedValue. It only notifies when the control content + // is recognized as being modified by the user, which is not the case, since we just modified + // it programmatically. + Reference< XPropertyControlContext > xControlContext( xControl->getControlContext(), UNO_SET_THROW ); + xControlContext->valueChanged( xControl ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + //-------------------------------------------------------------------- + void SAL_CALL PropertyControlExtender::keyReleased( const KeyEvent& /*_event*/ ) throw (RuntimeException) + { + // not interested in + } + + //-------------------------------------------------------------------- + void SAL_CALL PropertyControlExtender::disposing( const EventObject& Source ) throw (RuntimeException) + { + OSL_ENSURE( Source.Source == m_pData->xControlWindow, "PropertyControlExtender::disposing: where does this come from?" ); + (void)Source.Source; + m_pData->xControlWindow.clear(); + m_pData->xControl.clear(); + } + + +//........................................................................ +} // namespace pcr +//........................................................................ diff --git a/extensions/source/propctrlr/propertycontrolextender.hxx b/extensions/source/propctrlr/propertycontrolextender.hxx new file mode 100644 index 000000000000..591df0be6de7 --- /dev/null +++ b/extensions/source/propctrlr/propertycontrolextender.hxx @@ -0,0 +1,77 @@ +/************************************************************************* +* 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: code,v $ +* +* $Revision: 1.3 $ +* +* 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 EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX +#define EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/inspection/XPropertyControl.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> + +#include <memory> + +//........................................................................ +namespace pcr +{ +//........................................................................ + + //==================================================================== + //= PropertyControlExtender + //==================================================================== + struct PropertyControlExtender_Data; + typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XKeyListener + > PropertyControlExtender_Base; + class PropertyControlExtender : public PropertyControlExtender_Base + { + public: + PropertyControlExtender( + const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxObservedControl + ); + + // XKeyListener + virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + protected: + virtual ~PropertyControlExtender(); + + private: + ::std::auto_ptr< PropertyControlExtender_Data > m_pData; + }; + +//........................................................................ +} // namespace pcr +//........................................................................ + +#endif // EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index 4f5560462f86..6bd78ec7d09d 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -917,6 +917,7 @@ namespace pcr :OComboboxControl_Base( PropertyControlType::ComboBox, pParent, nWinStyle ) { getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); + getTypedControlWindow()->SetSelectHdl( LINK( this, OComboboxControl, OnEntrySelected ) ); } //------------------------------------------------------------------ @@ -968,6 +969,15 @@ namespace pcr return aRet; } + //------------------------------------------------------------------ + IMPL_LINK( OComboboxControl, OnEntrySelected, void*, /*_pNothing*/ ) + { + if ( !getTypedControlWindow()->IsTravelSelect() ) + // fire a commit + m_aImplControl.notifyModifiedValue(); + return 0L; + } + //================================================================== //= OMultilineFloatingEdit //================================================================== diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx index 0e64f2c65c42..ebe5b7c4ed48 100644 --- a/extensions/source/propctrlr/standardcontrol.hxx +++ b/extensions/source/propctrlr/standardcontrol.hxx @@ -337,6 +337,8 @@ namespace pcr virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException); + protected: + DECL_LINK( OnEntrySelected, void* ); }; //======================================================================== diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx index 9ce48b313e82..dc57f133e323 100644 --- a/extensions/source/propctrlr/taborder.cxx +++ b/extensions/source/propctrlr/taborder.cxx @@ -340,6 +340,14 @@ namespace pcr } //------------------------------------------------------------------------ + void TabOrderListBox::ModelHasMoved( SvListEntry* _pSource ) + { + SvTreeListBox::ModelHasMoved( _pSource ); + + ((TabOrderDialog*)Window::GetParent())->SetModified(); + } + + //------------------------------------------------------------------------ void TabOrderListBox::MoveSelection( long nRelPos ) { UniString aSelEntryPrevText,aSelEntryNextText; diff --git a/extensions/source/propctrlr/taborder.hxx b/extensions/source/propctrlr/taborder.hxx index e47954fd2a22..b8dae415a1dc 100644 --- a/extensions/source/propctrlr/taborder.hxx +++ b/extensions/source/propctrlr/taborder.hxx @@ -69,6 +69,10 @@ namespace pcr virtual ~TabOrderListBox(); void MoveSelection( long nRelPos ); + + protected: + virtual void ModelHasMoved(SvListEntry* pSource ); + private: using SvTreeListBox::MoveSelection; }; diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 5b41b825ff9c..38b1a0376a76 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -555,7 +555,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/Columns.cxx b/forms/source/component/Columns.cxx index fae95b36f180..b9b2b6cb5936 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 ()); } //------------------------------------------------------------------------------ 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..3491c2142449 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& ) { @@ -853,7 +853,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..bba5b48ffe28 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -31,72 +31,71 @@ // 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 <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 +114,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; @@ -261,51 +258,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 +411,9 @@ ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory) m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_ACTIVE_CONNECTION); } - if (m_xAggregate.is()) + if ( m_xAggregate.is() ) { - m_xAggregate->setDelegator(static_cast<XWeak*>(this)); + m_xAggregate->setDelegator( static_cast< XWeak* >( this ) ); } { @@ -324,10 +422,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 +434,10 @@ ODatabaseForm::~ODatabaseForm() DBG_DTOR(ODatabaseForm,NULL); m_pGroupManager->release(); + m_pGroupManager = NULL; if (m_xAggregate.is()) - m_xAggregate->setDelegator(InterfaceRef()); + m_xAggregate->setDelegator( NULL ); if (m_pAggregatePropertyMultiplexer) { @@ -1368,6 +1466,16 @@ void SAL_CALL ODatabaseForm::setPropertyValues( const Sequence< PropertyValue >& } //------------------------------------------------------------------------------ +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 @@ -3694,7 +3802,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..3cbbbcec2bbd 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -228,6 +228,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 +441,9 @@ 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; + // 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: @@ -538,6 +542,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..5b00c5fbb9a2 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 "FormComponent.hxx" -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <cppuhelper/queryinterface.hxx> -#include <com/sun/star/awt/XTextComponent.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/sdbc/ColumnValue.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> -#include <comphelper/guarding.hxx> -#include <connectivity/dbtools.hxx> -#ifndef _FRM_PROPERTY_HRC_ -#include "property.hrc" -#endif -#include "services.hxx" -#include "componenttools.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 "componenttools.hxx"
+#include "FormComponent.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/form/XForm.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>
+/** === end UNO includes === **/
+
+#include <comphelper/basicio.hxx>
+#include <comphelper/guarding.hxx>
+#include <comphelper/listenernotification.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <rtl/logfile.hxx>
+#include <toolkit/helper/emptyfontdescriptor.hxx>
+#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 @@ -554,7 +610,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) @@ -599,7 +655,7 @@ 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 ) @@ -685,14 +741,11 @@ void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(com: 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 @@ -1131,6 +1184,35 @@ void SAL_CALL OControlModel::setPropertyValues( const Sequence< PropertyValue >& 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 //================================================================== @@ -1163,6 +1245,8 @@ 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 ) @@ -1171,7 +1255,7 @@ OBoundControlModel::OBoundControlModel( ,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,6 +1280,8 @@ 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 ) @@ -1205,7 +1291,7 @@ OBoundControlModel::OBoundControlModel( ,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 ) @@ -1395,7 +1481,7 @@ void OBoundControlModel::disposing() m_aUpdateListeners.disposeAndClear( aEvt ); // 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 +1507,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 +1521,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 +1551,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 ); + + // a new parent means a new ambient form + impl_determineAmbientForm_nothrow(); + + if ( !hasExternalValueBinding() ) + { + // log on new listeners + doFormListening( true ); - // log on new listeners - only in case we do not have an external value binding - if ( m_xParent.is() && !hasExternalValueBinding() ) - startLoadListening( ); + // 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 +1625,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 @@ -1884,6 +1982,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 +2023,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 +2034,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 +2049,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 +2071,7 @@ sal_Bool SAL_CALL OBoundControlModel::commit() throw(RuntimeException) if ( bSuccess ) { - aGuard.clear(); + aLock.release(); m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvent ); } @@ -1997,24 +2120,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 +2186,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 +2227,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 +2257,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 +2291,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 ); } //------------------------------------------------------------------------------ @@ -2310,7 +2454,7 @@ void OBoundControlModel::reset() throw (RuntimeException) if (!bContinue) return; - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + ControlModelLock aLock( *this ); // on a new record? sal_Bool bIsNewRecord = sal_False; @@ -2414,17 +2558,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 ); } + +// ----------------------------------------------------------------------------- +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 +2585,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 +2605,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 +2704,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 +2731,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 +2743,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 +2760,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 +2776,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 +2793,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 +2809,7 @@ void OBoundControlModel::transferControlValueToExternal( ::osl::ResettableMutexG Any aExternalValue( translateControlValueToExternalValue() ); m_bTransferingValue = sal_True; - _rInstanceLock.clear(); + _rInstanceLock.release(); // >>>>>>>> ----- UNSAFE ----- >>>>>>>> try { @@ -2663,7 +2820,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..9ca5a1b02ef3 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -99,6 +99,7 @@ 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 ) @@ -123,6 +124,7 @@ OGridControlModel::OGridControlModel( const OGridControlModel* _pOriginal, const ,FontControlModel( _pOriginal ) ,m_aSelectListeners( m_aMutex ) ,m_aResetListeners( m_aMutex ) + ,m_aRowSetChangeListeners( m_aMutex ) { DBG_CTOR(OGridControlModel,NULL); @@ -157,7 +159,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 +246,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 +313,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 +328,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 +346,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 +388,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; @@ -735,72 +777,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 +789,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 +822,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..56981f54349b 100644 --- a/forms/source/component/Grid.hxx +++ b/forms/source/component/Grid.hxx @@ -28,16 +28,22 @@ * ************************************************************************/ -#include "FormComponent.hxx" -#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 <comphelper/proparrhlp.hxx> -#include <cppuhelper/implbase6.hxx> -#include "errorbroadcaster.hxx" -#include "formcontrolfont.hxx" +#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/form/XLoadable.hpp>
+#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/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,7 +95,6 @@ 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 @@ -128,13 +135,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 +168,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 +203,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..f7bc39fa1b89 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -124,7 +124,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,7 +141,7 @@ 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 ) @@ -297,8 +297,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 @@ -459,7 +459,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 +467,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& ) { @@ -1329,7 +1329,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..9aeca0e851e2 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -164,7 +164,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(); 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/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index d396cbd2df6a..9329ca92ba14 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -31,57 +31,60 @@ #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 "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 +107,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 +178,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 +186,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 +360,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 +519,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 +590,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 +599,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,6 +636,12 @@ 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; @@ -585,15 +662,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 +985,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 +1004,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 +1060,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 +1114,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 +1122,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 +1177,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 +1226,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 +1275,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 9bdbf3bdc402..f9939d17623b 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); @@ -267,6 +282,8 @@ private: efVersionSO6x }; void transformEvents( const EventFormat _eTargetFormat ); + + void impl_createEventAttacher_nothrow(); }; //================================================================== @@ -275,9 +292,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; @@ -285,6 +302,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/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 55fec77ffb11..f1b59d77af7e 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>
//......................................................................... namespace frm @@ -71,6 +71,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 { @@ -102,15 +103,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& ) { @@ -118,7 +160,10 @@ OInterfaceContainer::OInterfaceContainer( } } -OInterfaceContainer::~OInterfaceContainer() {} +//------------------------------------------------------------------------------ +OInterfaceContainer::~OInterfaceContainer() +{ +} //------------------------------------------------------------------------------ void OInterfaceContainer::disposing() @@ -783,6 +828,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) @@ -856,17 +920,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 ); } //------------------------------------------------------------------------------ @@ -1124,8 +1184,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/wizards/com/sun/star/wizards/db/CommandMetaData.java b/wizards/com/sun/star/wizards/db/CommandMetaData.java index adaeacb1a965..ba6c5972801a 100644 --- a/wizards/com/sun/star/wizards/db/CommandMetaData.java +++ b/wizards/com/sun/star/wizards/db/CommandMetaData.java @@ -54,7 +54,7 @@ import com.sun.star.frame.*; public class CommandMetaData extends DBMetaData { public Map FieldTitleSet = new HashMap(); - public String[] AllFieldNames = new String[]{}; + public String[] m_aAllFieldNames = new String[]{}; public FieldColumn[] FieldColumns = new FieldColumn[]{}; // public String[] FieldNames = new String[] {}; public String[] GroupFieldNames = new String[] {}; @@ -63,7 +63,7 @@ public class CommandMetaData extends DBMetaData public String[][] AggregateFieldNames = new String[][] {}; public String[] NumericFieldNames = new String[] {}; public String[] NonAggregateFieldNames; - public int[] FieldTypes; + private int[] FieldTypes; private int CommandType; private String Command; boolean bCatalogAtStart = true; @@ -297,7 +297,7 @@ public class CommandMetaData extends DBMetaData { try { - Object oField; + // Object oField; java.util.Vector ResultFieldNames = new java.util.Vector(10); String[] FieldNames; CommandObject oCommand = this.getCommandByName(_commandname, _commandtype); @@ -306,7 +306,7 @@ public class CommandMetaData extends DBMetaData { for (int n = 0; n < FieldNames.length; n++) { - oField = oCommand.xColumns.getByName(FieldNames[n]); + Object oField = oCommand.xColumns.getByName(FieldNames[n]); int iType = AnyConverter.toInt(Helper.getUnoPropertyValue(oField, "Type")); // BinaryFieldTypes are not included in the WidthList if (JavaTools.FieldInIntTable(WidthList, iType) >= 0) @@ -316,11 +316,15 @@ public class CommandMetaData extends DBMetaData // else ResultFieldNames.addElement(FieldNames[n]); } + else if (JavaTools.FieldInIntTable(BinaryTypes, iType) >= 0) + { + ResultFieldNames.addElement(FieldNames[n]); + } } - FieldNames = new String[FieldNames.length]; + // FieldNames = new String[FieldNames.length]; FieldTypes = new int[FieldNames.length]; - AllFieldNames = new String[ResultFieldNames.size()]; - ResultFieldNames.copyInto(AllFieldNames); + m_aAllFieldNames = new String[ResultFieldNames.size()]; + ResultFieldNames.copyInto(m_aAllFieldNames); return true; } } @@ -367,7 +371,7 @@ public class CommandMetaData extends DBMetaData return Command; } /** - * @param command The command to set. + * @param _command The command to set. */ public void setCommandName(String _command) { @@ -383,7 +387,7 @@ public class CommandMetaData extends DBMetaData } /** - * @param commandType The commandType to set. + * @param _commandType The commandType to set. */ public void setCommandType(int _commandType) { @@ -504,7 +508,7 @@ public class CommandMetaData extends DBMetaData /** * the fieldnames passed over are not necessarily the ones that are defined in the class - * @param FieldNames + * @param _DisplayFieldNames * @return */ public boolean hasNumericalFields(String[] _DisplayFieldNames) @@ -659,7 +663,9 @@ public class CommandMetaData extends DBMetaData XComponentLoader xLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xFac.createInstanceWithArguments(args)); ret[0] = xLoader.loadComponentFromURL(surl, "_self", 0, _rArgs); if ( ret[0] != null) + { ret[0] = (XComponent)UnoRuntime.queryInterface(XComponent.class,xLoader); + } } catch (Exception exception) { @@ -683,7 +689,7 @@ public class CommandMetaData extends DBMetaData if (xDBMetaData.supportsIntegrityEnhancementFacility()) { java.util.Vector TableVector = new java.util.Vector(); - Object oTable = xTableNames.getByName(_stablename); + Object oTable = getTableNamesAsNameAccess().getByName(_stablename); XKeysSupplier xKeysSupplier = (XKeysSupplier) UnoRuntime.queryInterface(XKeysSupplier.class, oTable); xIndexKeys = xKeysSupplier.getKeys(); for (int i = 0; i < xIndexKeys.getCount(); i++) @@ -694,7 +700,7 @@ public class CommandMetaData extends DBMetaData { // getImportedKeys (RelationController.cxx /source/ui/relationdesign) /Zeile 475 String sreftablename = AnyConverter.toString(xPropertySet.getPropertyValue("ReferencedTable")); - if (xTableNames.hasByName(sreftablename)) + if (getTableNamesAsNameAccess().hasByName(sreftablename)) { TableVector.addElement(sreftablename); } @@ -732,7 +738,7 @@ public class CommandMetaData extends DBMetaData if (curtype == KeyType.FOREIGN) { String scurreftablename = AnyConverter.toString(xPropertySet.getPropertyValue("ReferencedTable")); - if (xTableNames.hasByName(scurreftablename)) + if (getTableNamesAsNameAccess().hasByName(scurreftablename)) { if (scurreftablename.equals(_sreferencedtablename)) { diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index af9605cb99c6..31a5db521008 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -90,7 +90,7 @@ import com.sun.star.sdbcx.XTablesSupplier; public class DBMetaData { - public XNameAccess xTableNames; + private XNameAccess m_xTableNames; public XNameAccess xQueryNames; private XInteractionHandler oInteractionHandler; private XNameAccess xNameAccess; @@ -104,16 +104,16 @@ public class DBMetaData private XWindowPeer xWindowPeer; public String[] DataSourceNames; public String[] CommandNames; - public String[] TableNames = new String[] + private String[] TableNames = new String[] { }; - public String[] QueryNames = new String[] + private String[] QueryNames = new String[] { }; public java.util.Vector CommandObjects = new Vector(1); - public int[][] WidthList; - public int[] NumericTypes; - public int[] BinaryTypes; + protected int[][] WidthList; + protected int[] NumericTypes; + protected int[] BinaryTypes; public Locale aLocale; public int[] CommandTypes; public String DataSourceName; @@ -231,8 +231,8 @@ public class DBMetaData public boolean hasTableByName(String _stablename) { - getTableNames(); - return xTableNames.hasByName(_stablename); + // getTableNames(); + return getTableNamesAsNameAccess().hasByName(_stablename); } public void setTableByName(String _tableName) @@ -291,17 +291,17 @@ public class DBMetaData Object oCommand; this.Name = _CommandName; this.CommandType = _CommandType; - if (xTableNames == null) - { - setCommandNames(); - } + // if (getTableNamesAsNameAccess() == null) + // { + // initCommandNames(); + // } if (CommandType == com.sun.star.sdb.CommandType.TABLE) { - oCommand = xTableNames.getByName(Name); + oCommand = getTableNamesAsNameAccess().getByName(Name); } else { - oCommand = xQueryNames.getByName(Name); + oCommand = getQueryNamesAsNameAccess().getByName(Name); } XColumnsSupplier xCommandCols = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, oCommand); xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oCommand); @@ -331,13 +331,36 @@ public class DBMetaData return bHasEscapeProcessing; } - public void setCommandNames() + // public void initCommandNames() + // { + // getTableNames(); + // } + + public XNameAccess getQueryNamesAsNameAccess() { - getTableNames(); XQueriesSupplier xDBQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, DBConnection); xQueryNames = (XNameAccess) xDBQueries.getQueries(); - QueryNames = xQueryNames.getElementNames(); + return xQueryNames; + } + + public XNameAccess getTableNamesAsNameAccess() + { + XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); + XNameAccess xTableNames = xDBTables.getTables(); + return xTableNames; + } + public String[] getQueryNames() + { + if (QueryNames != null) + { + if (QueryNames.length > 0) + { + return QueryNames; + } + } + QueryNames = getQueryNamesAsNameAccess().getElementNames(); + return QueryNames; } public String[] getTableNames() @@ -349,9 +372,7 @@ public class DBMetaData return TableNames; } } - XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); - xTableNames = (XNameAccess) xDBTables.getTables(); - TableNames = (String[]) xTableNames.getElementNames(); + TableNames = (String[]) getTableNamesAsNameAccess().getElementNames(); return TableNames; } @@ -1078,7 +1099,6 @@ public class DBMetaData public void finish() { - xTableNames = null; xQueryNames = null; oInteractionHandler = null; xNameAccess = null; diff --git a/wizards/com/sun/star/wizards/db/TableDescriptor.java b/wizards/com/sun/star/wizards/db/TableDescriptor.java index 35cf52373921..ee7ed3dd38e2 100644 --- a/wizards/com/sun/star/wizards/db/TableDescriptor.java +++ b/wizards/com/sun/star/wizards/db/TableDescriptor.java @@ -34,9 +34,9 @@ import com.sun.star.beans.PropertyVetoException; import com.sun.star.beans.UnknownPropertyException; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; -import com.sun.star.lang.XInitialization; +// import com.sun.star.lang.XInitialization; import com.sun.star.sdbc.SQLException; -import com.sun.star.ui.dialogs.XExecutableDialog; +// import com.sun.star.ui.dialogs.XExecutableDialog; import com.sun.star.wizards.common.JavaTools; import com.sun.star.wizards.ui.WizardDialog; import java.util.Vector; @@ -59,7 +59,7 @@ import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.sdbcx.XDataDescriptorFactory; import com.sun.star.sdbcx.XDrop; import com.sun.star.sdbcx.XKeysSupplier; -import com.sun.star.sdbcx.XTablesSupplier; +// import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.wizards.common.Desktop; @@ -89,7 +89,7 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen private boolean bIDFieldisInserted = false; private String IDFieldName = ""; private String sColumnAlreadyExistsMessage = ""; - private WizardDialog oUnoDialog; +// private WizardDialog oUnoDialog; private XWindow xWindow; /** @@ -121,11 +121,11 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen { if (super.getConnection(_curPropertyValue)) { - XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); - xTableNames = xDBTables.getTables(); - xTableAppend = (XAppend) UnoRuntime.queryInterface(XAppend.class, xTableNames); - xTableDrop = (XDrop) UnoRuntime.queryInterface(XDrop.class, xTableNames); - xTableDataDescriptorFactory = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, xTableNames); + // XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); + // xTableNames = xDBTables.getTables(); + xTableAppend = (XAppend) UnoRuntime.queryInterface(XAppend.class, getTableNamesAsNameAccess()); + xTableDrop = (XDrop) UnoRuntime.queryInterface(XDrop.class, getTableNamesAsNameAccess()); + xTableDataDescriptorFactory = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, getTableNamesAsNameAccess()); xPropTableDataDescriptor = xTableDataDescriptorFactory.createDataDescriptor(); XColumnsSupplier xColumnsSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xPropTableDataDescriptor); xNameAccessColumns = xColumnsSupplier.getColumns(); @@ -246,7 +246,10 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen /** * creates the table under the passed name + * @param _catalogname + * @param _schemaname * @param _tablename is made unique if necessary + * @param _fieldnames * @return true or false to indicate successful creation or not */ public boolean createTable(String _catalogname, String _schemaname, String _tablename, String[] _fieldnames) @@ -272,7 +275,7 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen assignTableProperty("Name", _tablename); assignTableProperty("CatalogName", _catalogname); assignTableProperty("SchemaName", _schemaname); - xTableContainer = (XContainer) UnoRuntime.queryInterface(XContainer.class, xTableNames); + xTableContainer = (XContainer) UnoRuntime.queryInterface(XContainer.class, getTableNamesAsNameAccess()); xTableContainer.addContainerListener(this); if (keycolumncontainer.size() > 0) { @@ -295,6 +298,7 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen } if (breturn) { + // TODO: LLA: describe what is he doing here. xTableAppend.appendByDescriptor(xPropTableDataDescriptor); } } @@ -340,7 +344,7 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen } if (xTableDrop != null) { - if (xTableNames.hasByName(_tablename)) + if (getTableNamesAsNameAccess().hasByName(_tablename)) { xTableDrop.dropByName(_tablename); } diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java index c5f2ed8ff403..c5380083db30 100644 --- a/wizards/com/sun/star/wizards/document/Control.java +++ b/wizards/com/sun/star/wizards/document/Control.java @@ -65,9 +65,9 @@ public class Control extends Shape String sServiceName; XNamed xNamed; final int SOMAXTEXTSIZE = 50; - int icontroltype; + private int icontroltype; protected XNameContainer xFormName; - protected final int IIMGFIELDWIDTH = 2000; + protected final int IIMGFIELDWIDTH = 3000; public Control() { @@ -102,8 +102,8 @@ public class Control extends Shape { try { - this.icontroltype = _icontroltype; - this.sServiceName = oFormHandler.sModelServices[icontroltype]; + icontroltype = _icontroltype; + sServiceName = oFormHandler.sModelServices[getControlType()]; Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName); xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oControlModel); xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oControlModel); @@ -194,7 +194,7 @@ public class Control extends Shape public int getPreferredHeight(String sText) { Size aPeerSize = getPreferredSize(sText); - if (icontroltype == FormHandler.SOCHECKBOX) + if (getControlType() == FormHandler.SOCHECKBOX) { return (aPeerSize.Height * oFormHandler.getXPixelFactor()); } @@ -206,7 +206,7 @@ public class Control extends Shape public int getPreferredWidth() { - if (icontroltype == FormHandler.SOIMAGECONTROL) + if (getControlType() == FormHandler.SOIMAGECONTROL) { return IIMGFIELDWIDTH; } @@ -215,7 +215,7 @@ public class Control extends Shape Size aPeerSize = getPeerSize(); // We increase the preferred Width a bit so that the control does not become too small // when we change the border from "3D" to "Flat" - if (icontroltype == FormHandler.SOCHECKBOX) + if (getControlType() == FormHandler.SOCHECKBOX) { return ((aPeerSize.Width * oFormHandler.getXPixelFactor())); } @@ -228,7 +228,7 @@ public class Control extends Shape public int getPreferredHeight() { - if (this.icontroltype == FormHandler.SOIMAGECONTROL) + if (getControlType() == FormHandler.SOIMAGECONTROL) { return 2000; } @@ -310,17 +310,17 @@ public class Control extends Shape aPreferredSize = getPeer().getPreferredSize(); xPropertySet.setPropertyValue("EffectiveValue", com.sun.star.uno.Any.VOID); } - else if (this.icontroltype == FormHandler.SOCHECKBOX) + else if (getControlType() == FormHandler.SOCHECKBOX) { aPreferredSize = getPeer().getPreferredSize(); } - else if (this.icontroltype == FormHandler.SODATECONTROL) + else if (getControlType() == FormHandler.SODATECONTROL) { xPropertySet.setPropertyValue("Date", new Integer(4711)); //TODO find a better date aPreferredSize = getPeer().getPreferredSize(); xPropertySet.setPropertyValue("Date", com.sun.star.uno.Any.VOID); } - else if (this.icontroltype == FormHandler.SOTIMECONTROL) + else if (getControlType() == FormHandler.SOTIMECONTROL) { xPropertySet.setPropertyValue("Time", new Integer(47114)); //TODO find a better time aPreferredSize = getPeer().getPreferredSize(); diff --git a/wizards/com/sun/star/wizards/document/DatabaseControl.java b/wizards/com/sun/star/wizards/document/DatabaseControl.java index f809ef479f05..0cbc1cd13aec 100644 --- a/wizards/com/sun/star/wizards/document/DatabaseControl.java +++ b/wizards/com/sun/star/wizards/document/DatabaseControl.java @@ -31,17 +31,17 @@ package com.sun.star.wizards.document; import com.sun.star.awt.Point; -import com.sun.star.awt.Size; +// import com.sun.star.awt.Size; import com.sun.star.beans.XPropertySet; -import com.sun.star.container.ElementExistException; -import com.sun.star.container.XNameAccess; +//import com.sun.star.container.ElementExistException; +//import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.drawing.XShapes; -import com.sun.star.lang.IllegalArgumentException; -import com.sun.star.lang.WrappedTargetException; +//import com.sun.star.lang.IllegalArgumentException; +//import com.sun.star.lang.WrappedTargetException; import com.sun.star.sdbc.DataType; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.UnoRuntime; +//import com.sun.star.uno.AnyConverter; +//import com.sun.star.uno.UnoRuntime; import com.sun.star.wizards.common.Desktop; import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.db.FieldColumn; @@ -55,15 +55,15 @@ import com.sun.star.wizards.db.FieldColumn; public class DatabaseControl extends Control { - protected int ifieldtype; - private int iMemofieldwidth = IIMGFIELDWIDTH; - private int iMemofieldheight = -1; - private FieldColumn m_FieldColumn; + private int m_nFieldType; + // private int iMemofieldwidth = IIMGFIELDWIDTH; + // private int iMemofieldheight = -1; + // private FieldColumn m_FieldColumn; public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn) { super(); - m_FieldColumn = _curfieldcolumn; + // m_FieldColumn = _curfieldcolumn; if (_curfieldcolumn.FieldType != DataType.TIMESTAMP) { createGridColumn(_oGridControl, _curfieldcolumn, _curfieldcolumn.FieldType, _curfieldcolumn.getFieldTitle()); @@ -73,24 +73,37 @@ public class DatabaseControl extends Control public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle) { super(); - m_FieldColumn = _curfieldcolumn; + // m_FieldColumn = _curfieldcolumn; createGridColumn(_oGridControl, _curfieldcolumn, _fieldtype, _columntitle); } + protected int getFieldType() + { + return m_nFieldType; + } + private void createGridColumn(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle) { try { - ifieldtype = _fieldtype; - String suniqueName = Desktop.getUniqueName(_oGridControl.xNameAccess, _curfieldcolumn.m_sFieldName); - XPropertySet xPropColumn = _oGridControl.xGridColumnFactory.createColumn(getGridColumnName()); - xPropColumn.setPropertyValue("Name", suniqueName); - xPropColumn.setPropertyValue("Hidden", new Boolean(_fieldtype == DataType.LONGVARBINARY)); //TODO CONTROLType abfragen!!!!!! - xPropColumn.setPropertyValue("DataField", _curfieldcolumn.m_sFieldName); + m_nFieldType = _fieldtype; + String sFieldName = _curfieldcolumn.m_sFieldName; + String sUniqueName = Desktop.getUniqueName(_oGridControl.xNameAccess, sFieldName); + + String sGridColumnName = getGridColumnName(); + XPropertySet xPropColumn = _oGridControl.xGridColumnFactory.createColumn(sGridColumnName); + xPropColumn.setPropertyValue("Name", sUniqueName); + boolean bHidden = false; + if (_fieldtype == DataType.LONGVARBINARY) //TODO CONTROLType abfragen!!!!!! + { + bHidden = true; + } + xPropColumn.setPropertyValue("Hidden", new Boolean(bHidden)); + xPropColumn.setPropertyValue("DataField", sFieldName); xPropColumn.setPropertyValue("Label", _columntitle); xPropColumn.setPropertyValue("Width", new Integer(0)); // Width of column is adjusted to Columname - setNumerics(); - _oGridControl.xNameContainer.insertByName(_curfieldcolumn.m_sFieldName, xPropColumn); + setNumericLimits(); + _oGridControl.xNameContainer.insertByName(sFieldName, xPropColumn); } catch (Exception e) { @@ -108,9 +121,9 @@ public class DatabaseControl extends Control super(_oFormHandler, _xFormName, _oFormHandler.getControlType(_fieldtype), _curFieldName, _aPoint, null); try { - this.ifieldtype = _fieldtype; + m_nFieldType = _fieldtype; Helper.setUnoPropertyValue(xControlModel, "DataField", _curFieldName); - setNumerics(); + setNumericLimits(); } catch (Exception e) { @@ -123,9 +136,9 @@ public class DatabaseControl extends Control super(_oFormHandler, _xGroupShapes, _xFormName, _oFormHandler.getControlType(_fieldtype), _aPoint, null); try { - this.ifieldtype = _fieldtype; + m_nFieldType = _fieldtype; Helper.setUnoPropertyValue(xControlModel, "DataField", _curFieldName); - setNumerics(); + setNumericLimits(); } catch (Exception e) { @@ -137,7 +150,7 @@ public class DatabaseControl extends Control { for (int i = 0; i < FormHandler.oControlData.length; i++) { - if (FormHandler.oControlData[i].DataType == this.ifieldtype) + if (FormHandler.oControlData[i].DataType == getFieldType()) { return FormHandler.oControlData[i].GridColumnName; } @@ -145,39 +158,39 @@ public class DatabaseControl extends Control return ""; } - public int getDBHeight() + public int getControlHeight() { - if (this.icontroltype == FormHandler.SOIMAGECONTROL) + if (getControlType() == FormHandler.SOIMAGECONTROL) { - return oFormHandler.getImageControlHeight(); + // return oFormHandler.getImageControlHeight(); + final int nMemofieldheight = oFormHandler.getControlReferenceHeight() * 4; + return nMemofieldheight; } else { - if (this.ifieldtype == DataType.LONGVARCHAR) + if (getFieldType() == DataType.LONGVARCHAR) { - if (iMemofieldheight == -1) - { - Helper.setUnoPropertyValue(xControlModel, "MultiLine", Boolean.TRUE); - iMemofieldheight = oFormHandler.getDBRefHeight() * 4; - } - return iMemofieldheight; + // Helper.setUnoPropertyValue(xControlModel, "MultiLine", Boolean.TRUE); + final int nMemofieldheight = oFormHandler.getControlReferenceHeight() * 4; + return nMemofieldheight; } - else if (this.icontroltype == FormHandler.SOCHECKBOX) + else if (getControlType() == FormHandler.SOCHECKBOX) { return super.getPreferredHeight(); } - else - { - return oFormHandler.getDBRefHeight(); - } } + return oFormHandler.getControlReferenceHeight(); } - public int getDBWidth() + public int getControlWidth() { - if (this.ifieldtype == DataType.LONGVARCHAR) + if (getControlType() == FormHandler.SOIMAGECONTROL) { - return 2 * getDBHeight(); + return 2 * getControlHeight(); + } + if (getFieldType() == DataType.LONGVARCHAR) + { + return 2 * getControlHeight(); } else { @@ -185,26 +198,49 @@ public class DatabaseControl extends Control } } - public void setNumerics() + private static long m_nLongMax = 0; + public static long getLongMax() + { + if (m_nLongMax == 0) + { + } + return m_nLongMax; + } + public void setNumericLimits() { try { - if (this.icontroltype == FormHandler.SONUMERICCONTROL) + if (getControlType() == FormHandler.SONUMERICCONTROL) { xPropertySet.setPropertyValue("TreatAsNumber", Boolean.TRUE); - switch (ifieldtype) + // Math. + // 2^63 - 1 = 9223372036854775807 + // int nIntMax = 0x7fffffff; + // int nIntMin = -0x80000000; + // long nLongMax = nIntMax; + // nLongMax <<= (4*4); + // nLongMax |= 0xffff; + // nLongMax <<= (4*4); + // nLongMax |= 0xffff; + + // long nLongMin = nIntMin; + // nLongMin <<= (8*4); + + // long nLong2 = (long)9223372036854775807; + + switch (getFieldType()) { case DataType.BIGINT: - xPropertySet.setPropertyValue("EffectiveMax", new Double(2147483647 * 2147483647)); - xPropertySet.setPropertyValue("EffectiveMin", new Double(-(-2147483648 * -2147483648))); + xPropertySet.setPropertyValue("EffectiveMax", new Double(Long.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", new Double(Long.MIN_VALUE)); break; case DataType.INTEGER: - xPropertySet.setPropertyValue("EffectiveMax", new Double(2147483647)); - xPropertySet.setPropertyValue("EffectiveMin", new Double(-2147483648)); + xPropertySet.setPropertyValue("EffectiveMax", new Double(Integer.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", new Double(Integer.MIN_VALUE)); break; case DataType.SMALLINT: - xPropertySet.setPropertyValue("EffectiveMax", new Double(32767)); - xPropertySet.setPropertyValue("EffectiveMin", new Double(-32768)); + xPropertySet.setPropertyValue("EffectiveMax", new Double(Short.MAX_VALUE)); + xPropertySet.setPropertyValue("EffectiveMin", new Double(Short.MIN_VALUE)); break; case DataType.TINYINT: xPropertySet.setPropertyValue("EffectiveMax", new Double(127)); @@ -218,11 +254,12 @@ public class DatabaseControl extends Control break; } } - else if (icontroltype == FormHandler.SOTEXTBOX) - { // com.sun.star.sdbc.DataType.CHAR, com.sun.star.sdbc.DataType.VARCHAR, com.sun.star.sdbc.DataType.LONGVARCHAR - } - else if (icontroltype == FormHandler.SOCHECKBOX) + // else if (getControlType() == FormHandler.SOTEXTBOX) + // { // com.sun.star.sdbc.DataType.CHAR, com.sun.star.sdbc.DataType.VARCHAR, com.sun.star.sdbc.DataType.LONGVARCHAR + // } + else if (getControlType() == FormHandler.SOIMAGECONTROL) { + xPropertySet.setPropertyValue("ScaleMode", com.sun.star.awt.ImageScaleMode.Isotropic); } } catch (Exception e) diff --git a/wizards/com/sun/star/wizards/document/FormHandler.java b/wizards/com/sun/star/wizards/document/FormHandler.java index 1c8f18844101..bc8b87b26334 100644 --- a/wizards/com/sun/star/wizards/document/FormHandler.java +++ b/wizards/com/sun/star/wizards/document/FormHandler.java @@ -34,17 +34,17 @@ import com.sun.star.awt.Size; import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XControlModel; import com.sun.star.awt.XDevice; -import com.sun.star.beans.PropertyVetoException; -import com.sun.star.beans.UnknownPropertyException; +// import com.sun.star.beans.PropertyVetoException; +// import com.sun.star.beans.UnknownPropertyException; import com.sun.star.beans.XPropertySet; -import com.sun.star.container.NoSuchElementException; +// import com.sun.star.container.NoSuchElementException; import com.sun.star.container.XChild; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.view.XControlAccess; import com.sun.star.wizards.common.*; -import com.sun.star.sdbc.*; +import com.sun.star.sdbc.DataType; import com.sun.star.text.XTextDocument; import com.sun.star.uno.Exception; import com.sun.star.uno.Type; @@ -60,8 +60,8 @@ import com.sun.star.drawing.XShapeGrouper; import com.sun.star.drawing.XShapes; import com.sun.star.form.XFormsSupplier; import com.sun.star.lang.IllegalArgumentException; -import com.sun.star.lang.IndexOutOfBoundsException; -import com.sun.star.lang.WrappedTargetException; +// import com.sun.star.lang.IndexOutOfBoundsException; +// import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XServiceInfo; @@ -78,6 +78,8 @@ public class FormHandler public String[] sModelServices = new String[8]; public XNameContainer xNamedForm; public static ControlData[] oControlData; + // ControlData[] oImageControlData; + public final static int SOLABEL = 0; public final static int SOTEXTBOX = 1; public final static int SOCHECKBOX = 2; @@ -129,29 +131,30 @@ public class FormHandler sModelServices[SONUMERICCONTROL] = "com.sun.star.form.component.FormattedField"; sModelServices[SOGRIDCONTROL] = "com.sun.star.form.component.GridControl"; sModelServices[SOIMAGECONTROL] = "com.sun.star.form.component.DatabaseImageControl"; - oControlData = new ControlData[17]; - oControlData[0] = createControlData(DataType.BIT, SOCHECKBOX, "CheckBox", "CheckBox", false); - oControlData[1] = createControlData(DataType.BOOLEAN, SOCHECKBOX, "CheckBox", "CheckBox", false); - oControlData[2] = createControlData(DataType.TINYINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[3] = createControlData(DataType.SMALLINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[4] = createControlData(DataType.INTEGER, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[5] = createControlData(DataType.BIGINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[6] = createControlData(DataType.FLOAT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[7] = createControlData(DataType.REAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[8] = createControlData(DataType.DOUBLE, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[9] = createControlData(DataType.NUMERIC, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[10] = createControlData(DataType.DECIMAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false); - oControlData[11] = createControlData(DataType.CHAR, SOTEXTBOX, "TextField", "TextField", false); - oControlData[12] = createControlData(DataType.VARCHAR, SOTEXTBOX, "TextField", "TextField", true); + + oControlData = new ControlData[21]; + oControlData[0] = createControlData(DataType.BIT, SOCHECKBOX, "CheckBox", "CheckBox", false); + oControlData[1] = createControlData(DataType.BOOLEAN, SOCHECKBOX, "CheckBox", "CheckBox", false); + oControlData[2] = createControlData(DataType.TINYINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[3] = createControlData(DataType.SMALLINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[4] = createControlData(DataType.INTEGER, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[5] = createControlData(DataType.BIGINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[6] = createControlData(DataType.FLOAT, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[7] = createControlData(DataType.REAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[8] = createControlData(DataType.DOUBLE, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[9] = createControlData(DataType.NUMERIC, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[10] = createControlData(DataType.DECIMAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false); + oControlData[11] = createControlData(DataType.CHAR, SOTEXTBOX, "TextField", "TextField", false); + oControlData[12] = createControlData(DataType.VARCHAR, SOTEXTBOX, "TextField", "TextField", true); oControlData[13] = createControlData(DataType.LONGVARCHAR, SOTEXTBOX, "TextField", "TextField", true); - oControlData[14] = createControlData(DataType.DATE, SODATECONTROL, "DateField", "DateField", false); - oControlData[15] = createControlData(DataType.TIME, SOTIMECONTROL, "TimeField", "TimeField", false); - oControlData[16] = createControlData(DataType.TIMESTAMP, SODATECONTROL, "DateField", "TextField", false); - ControlData[] oImageControlData = new ControlData[4]; - oImageControlData[0] = createControlData(DataType.BINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); - oImageControlData[1] = createControlData(DataType.VARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); - oImageControlData[2] = createControlData(DataType.LONGVARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); - oImageControlData[3] = createControlData(DataType.BLOB, SOIMAGECONTROL, "ImageControl", "TextField", false); + oControlData[14] = createControlData(DataType.DATE, SODATECONTROL, "DateField", "DateField", false); + oControlData[15] = createControlData(DataType.TIME, SOTIMECONTROL, "TimeField", "TimeField", false); + oControlData[16] = createControlData(DataType.TIMESTAMP, SODATECONTROL, "DateField", "TextField", false); + // oImageControlData = new ControlData[4]; + oControlData[17] = createControlData(DataType.BINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); + oControlData[18] = createControlData(DataType.VARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); + oControlData[19] = createControlData(DataType.LONGVARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false); + oControlData[20] = createControlData(DataType.BLOB, SOIMAGECONTROL, "ImageControl", "TextField", false); } public int getControlType(int _fieldtype) @@ -160,7 +163,8 @@ public class FormHandler { if (oControlData[i].DataType == _fieldtype) { - return oControlData[i].ControlType; + final int nType = oControlData[i].ControlType; + return nType; } } return -1; @@ -190,6 +194,7 @@ public class FormHandler XDevice xDevice = (XDevice) UnoRuntime.queryInterface(XDevice.class, oLabelControl.xWindowPeer); iXPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterX); iYPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterY); + nLabelHeight = (oLabelControl.getPreferredHeight("The quick brown fox...") + 1); Control oTextControl = new Control(this, SOTEXTBOX, new Point(), new Size()); nDBRefHeight = (oTextControl.getPreferredHeight("The quick brown fox...") + 1); @@ -543,7 +548,7 @@ public class FormHandler /** * @return */ - public int getDBRefHeight() + public int getControlReferenceHeight() { if (this.nDBRefHeight == -1) { diff --git a/wizards/com/sun/star/wizards/document/TimeStampControl.java b/wizards/com/sun/star/wizards/document/TimeStampControl.java index 343aad8de747..f9417323af8d 100644 --- a/wizards/com/sun/star/wizards/document/TimeStampControl.java +++ b/wizards/com/sun/star/wizards/document/TimeStampControl.java @@ -69,7 +69,7 @@ public class TimeStampControl extends DatabaseControl oResource = _oResource; // xGroupShape = xShape; oDateControl = new DatabaseControl(oFormHandler, _xFormName, _curFieldName, DataType.DATE, aPoint); - int nDBHeight = oDateControl.getDBHeight(); + int nDBHeight = oDateControl.getControlHeight(); nDateWidth = oDateControl.getPreferredWidth(); oDateControl.setSize(new Size(nDateWidth, nDBHeight)); Point aTimePoint = new Point(aPoint.X + 10 + nDateWidth, aPoint.Y); diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java index 73bad73b5fb1..5e54d5e8bc69 100644 --- a/wizards/com/sun/star/wizards/form/FormControlArranger.java +++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java @@ -31,15 +31,16 @@ package com.sun.star.wizards.form; import com.sun.star.awt.Point; import com.sun.star.awt.Size; -import com.sun.star.beans.UnknownPropertyException; +// import com.sun.star.beans.UnknownPropertyException; import com.sun.star.container.XNameContainer; -import com.sun.star.lang.IllegalArgumentException; -import com.sun.star.lang.WrappedTargetException; +// import com.sun.star.lang.IllegalArgumentException; +// import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdbc.DataType; import com.sun.star.task.XStatusIndicator; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.Resource; import com.sun.star.wizards.db.*; import com.sun.star.wizards.document.Control; @@ -54,11 +55,11 @@ public class FormControlArranger XNameContainer xFormName; XMultiServiceFactory xMSF; public DatabaseControl[] DBControlList = null; - public Control[] LabelControlList = null; + private Control[] LabelControlList = null; private XStatusIndicator xProgressBar; private FieldColumn[] FieldColumns; DatabaseControl curDBControl; - Control curLabelControl; + // Control curLabelControl; int icurArrangement; boolean bIsFirstRun; boolean bIsVeryFirstRun; @@ -122,13 +123,18 @@ public class FormControlArranger NBorderType = new Short(_nBorderType); } + public Control[] getLabelControlList() + { + return LabelControlList; + } + private int getCheckBoxDiffHeight(int LastIndex) { if ((LastIndex < DBControlList.length)) { if (DBControlList[LastIndex].getControlType() == FormHandler.SOCHECKBOX) { - return (int) ((oFormHandler.getDBRefHeight() - DBControlList[LastIndex].getDBHeight()) / 2); + return (int) ((oFormHandler.getControlReferenceHeight() - DBControlList[LastIndex].getControlHeight()) / 2); } } return 0; @@ -277,7 +283,7 @@ public class FormControlArranger { int nControlBaseWidth = 0; curDBControl = this.DBControlList[i]; - curLabelControl = this.LabelControlList[i]; + Control curLabelControl = this.LabelControlList[i]; if (i != StartIndex) { curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y)); @@ -380,12 +386,19 @@ public class FormControlArranger xProgressBar.start("", FieldColumns.length); for (int i = 0; i < FieldColumns.length; i++) { - insertLabel(i, _iAlign); - insertDBControl(i); - bIsVeryFirstRun = false; - DBControlList[i].setPropertyValue("LabelControl", curLabelControl.xPropertySet); - resetPosSizes(i); - xProgressBar.setValue(i + 1); + try + { + insertLabel(i, _iAlign); + insertDBControl(i); + bIsVeryFirstRun = false; + DBControlList[i].setPropertyValue("LabelControl", LabelControlList[i].xPropertySet); + resetPosSizes(i); + xProgressBar.setValue(i + 1); + } + catch (RuntimeException e) + { + int dummy = 0; + } } xProgressBar.end(); bControlsareCreated = true; @@ -523,7 +536,7 @@ public class FormControlArranger nXTCPos = cXOffset; nTCWidth = 2000; nDBWidth = 2000; - nDBHeight = oFormHandler.getDBRefHeight(); + nDBHeight = oFormHandler.getControlReferenceHeight(); nTCHeight = oFormHandler.getLabelHeight(); iReduceWidth = 0; if (icurArrangement == FormWizard.SOCOLUMNARLEFT) @@ -560,7 +573,8 @@ public class FormControlArranger { Point aPoint = new Point(nXTCPos, nYTCPos); Size aSize = new Size(nTCWidth, nTCHeight); - this.LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, FieldColumns[i].m_sFieldName, aPoint, aSize); + final String sFieldName = FieldColumns[i].m_sFieldName; + this.LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, sFieldName, aPoint, aSize); if (bIsVeryFirstRun) { if (icurArrangement == FormWizard.SOCOLUMNARTOP) @@ -568,9 +582,10 @@ public class FormControlArranger nYDBPos = nYTCPos + nTCHeight; } } - nTCWidth = LabelControlList[i].getPreferredWidth(FieldColumns[i].getFieldTitle()); + String sTitle = FieldColumns[i].getFieldTitle(); + nTCWidth = LabelControlList[i].getPreferredWidth(sTitle); } - curLabelControl = LabelControlList[i]; + Control curLabelControl = LabelControlList[i]; if (icurArrangement == FormWizard.SOCOLUMNARLEFT) { // Note This If Sequence must be called before retrieving the outer Points @@ -613,6 +628,9 @@ public class FormControlArranger { try { + String sFieldName = FieldColumns[i].m_sFieldName; + int nFieldType = FieldColumns[i].FieldType; + Point aPoint = new Point(nXDBPos, nYDBPos); if (bControlsareCreated) { @@ -620,34 +638,40 @@ public class FormControlArranger } else { - if (FieldColumns[i].FieldType == DataType.TIMESTAMP) + if (nFieldType == DataType.TIMESTAMP) { - DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, FieldColumns[i].m_sFieldName, aPoint); + DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, sFieldName, aPoint); } else { - DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, FieldColumns[i].m_sFieldName, FieldColumns[i].FieldType, aPoint); + DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, sFieldName, nFieldType, aPoint); if (DBControlList[i].getControlType() == FormHandler.SOCHECKBOX) { + // Checkboxes have no Label near by DBControlList[i].setPropertyValue("Label", ""); } } } - this.curDBControl = DBControlList[i]; - nDBHeight = curDBControl.getDBHeight(); - nDBWidth = curDBControl.getDBWidth(); - if (FieldColumns[i].FieldType != DataType.TIMESTAMP) + DatabaseControl aDBControl = DBControlList[i]; + nDBHeight = aDBControl.getControlHeight(); + nDBWidth = aDBControl.getControlWidth(); + if (nFieldType != DataType.TIMESTAMP) { - curDBControl.setSize(new Size(nDBWidth, nDBHeight)); + aDBControl.setSize(new Size(nDBWidth, nDBHeight)); } - if (curDBControl.getControlType() == FormHandler.SOCHECKBOX) + if (aDBControl.getControlType() == FormHandler.SOCHECKBOX) { - nYDBPos = nYDBPos + /*(int)*/ ((oFormHandler.getDBRefHeight() - nDBHeight) / 2); + nYDBPos = nYDBPos + /*(int)*/ ((oFormHandler.getControlReferenceHeight() - nDBHeight) / 2); aPoint = new Point(nXDBPos, nYDBPos); - curDBControl.setPosition(aPoint); + aDBControl.setPosition(aPoint); + } + if (nFieldType == DataType.LONGVARCHAR) /* memo */ + { + LabelControlList[i].setPropertyValue("MultiLine", Boolean.TRUE); + // Helper.setUnoPropertyValue(LabelControlList[i], "MultiLine", Boolean.TRUE); } checkOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, true); - curDBControl.setPropertyValue("Border", NBorderType); + aDBControl.setPropertyValue("Border", NBorderType); } catch (Exception e) { diff --git a/wizards/com/sun/star/wizards/form/FormDocument.java b/wizards/com/sun/star/wizards/form/FormDocument.java index 5e07324d3182..7938b139decc 100644 --- a/wizards/com/sun/star/wizards/form/FormDocument.java +++ b/wizards/com/sun/star/wizards/form/FormDocument.java @@ -442,7 +442,7 @@ public class FormDocument extends TextDocument { if (oFormController != null) { - return oFormController.LabelControlList; + return oFormController.getLabelControlList(); } else { diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java index 2330832a45a3..7631a1315594 100644 --- a/wizards/com/sun/star/wizards/form/FormWizard.java +++ b/wizards/com/sun/star/wizards/form/FormWizard.java @@ -348,7 +348,7 @@ public class FormWizard extends WizardDialog return ret; } - public boolean getFormResources() + private boolean getFormResources() { sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_FORM); sShowBinaryFields = m_oResource.getResText(UIConsts.RID_FORM + 2); diff --git a/wizards/com/sun/star/wizards/query/QuerySummary.java b/wizards/com/sun/star/wizards/query/QuerySummary.java index 07e66d0a7e1c..b382553d68c8 100644 --- a/wizards/com/sun/star/wizards/query/QuerySummary.java +++ b/wizards/com/sun/star/wizards/query/QuerySummary.java @@ -54,8 +54,8 @@ public class QuerySummary extends QueryMetaData super(_xMSF); this.oResource = _oResource; // this.xMSF = _xMSF; - sAnd = oResource.getResText(RID_QUERY + 33); - sOr = oResource.getResText(RID_QUERY + 34); + sAnd = oResource.getResText(RID_QUERY + 38); + sOr = oResource.getResText(RID_QUERY + 39); sSeparator = oResource.getResText(RID_QUERY + 91); sReturnChar = String.valueOf((char) 13) + String.valueOf((char) 13); } diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java index 778faeb08903..14df991ba04c 100644 --- a/wizards/com/sun/star/wizards/query/QueryWizard.java +++ b/wizards/com/sun/star/wizards/query/QueryWizard.java @@ -523,7 +523,7 @@ public class QueryWizard extends WizardDialog if (JavaTools.FieldInList(CurDBMetaData.NonAggregateFieldNames, CurDisplayFieldName) > -1) { showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, resmsgNonNumericAsGroupBy); - CurGroupFieldSelection.xSelFieldsListBox.addItems(SelItems, CurGroupFieldSelection.xSelFieldsListBox.getItemCount()); + CurGroupFieldSelection.xSelectedFieldsListBox.addItems(SelItems, CurGroupFieldSelection.xSelectedFieldsListBox.getItemCount()); String FieldList[] = CurGroupFieldSelection.xFieldsListBox.getItems(); int index = JavaTools.FieldInList(FieldList, CurDisplayFieldName); if (index > -1) diff --git a/wizards/com/sun/star/wizards/report/GroupFieldHandler.java b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java index 5d4f1199e41b..a1250e8f86b7 100644 --- a/wizards/com/sun/star/wizards/report/GroupFieldHandler.java +++ b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java @@ -128,7 +128,7 @@ public class GroupFieldHandler extends FieldSelection protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex) { super.toggleListboxButtons(iFieldsSelIndex, iSelFieldsSelIndex); - int iSelCount = xSelFieldsListBox.getItemCount(); + int iSelCount = xSelectedFieldsListBox.getItemCount(); if (iSelCount >= MAXSELFIELDS) { CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, "Enabled", Boolean.FALSE); @@ -137,7 +137,7 @@ public class GroupFieldHandler extends FieldSelection public void selectFields(boolean bMoveAll) { - int iSelCount = xSelFieldsListBox.getItemCount(); + int iSelCount = xSelectedFieldsListBox.getItemCount(); if (iSelCount < MAXSELFIELDS) { super.selectFields(bMoveAll); @@ -150,18 +150,18 @@ public class GroupFieldHandler extends FieldSelection public void moveItemDown(String Selitem) { - CurReportDocument.refreshGroupFields(xSelFieldsListBox.getItems()); + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); } public void moveItemUp(String item) { - CurReportDocument.refreshGroupFields(xSelFieldsListBox.getItems()); + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); } public void shiftFromLeftToRight(String[] Selitems, String[] Newitems) { String CurGroupTitle = Selitems[0]; - int iSelCount = xSelFieldsListBox.getItemCount(); + int iSelCount = xSelectedFieldsListBox.getItemCount(); String[] CurGroupNames = xFieldsListBox.getItems(); CurReportDocument.liveupdate_addGroupNametoDocument(CurGroupNames, CurGroupTitle, GroupFieldVector, CurReportDocument.getReportPath(), iSelCount); CurUnoDialog.setControlProperty("lblBlindTextNote_1", "Enabled", new Boolean(true)); @@ -177,12 +177,12 @@ public class GroupFieldHandler extends FieldSelection if (iSelPos > 0) { String OldGroupTitle = OldSelitems[0]; - String[] NewSelList = xSelFieldsListBox.getItems(); + String[] NewSelList = xSelectedFieldsListBox.getItems(); CurReportDocument.liveupdate_removeGroupName(NewSelList, OldGroupTitle, GroupFieldVector); - String[] NewSelGroupNames = xSelFieldsListBox.getItems(); + String[] NewSelGroupNames = xSelectedFieldsListBox.getItems(); CurUnoDialog.setControlProperty("lblBlindTextNote_1", "Enabled", new Boolean(NewSelGroupNames.length == 0)); - // CurReportDocument.refreshGroupFields(xSelFieldsListBox.getItems()); + // CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); } } diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index 65ec553f6183..d3abec37c593 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -473,15 +473,18 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple // CurReportDocument.getDoc().xProgressBar.setValue(30); CurDBCommandFieldSelection = new CommandFieldSelection(this, CurReportDocument.getRecordParser(), 100, slblFields, slblSelFields, slblTables, true, 34330); CurDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); - insertLabel("lblBinaryFields", - new String[] - { - "Height", "Label", "PositionX", "PositionY", "Step", "Width" - }, - new Object[] - { - new Integer(16), sShowBinaryFields, new Integer(95), new Integer(162), new Integer(1), new Integer(210) - }); + if ( !isReportBuilderInstalled() ) + { + insertLabel("lblBinaryFields", + new String[] + { + "Height", "Label", "PositionX", "PositionY", "Step", "Width" + }, + new Object[] + { + new Integer(16), sShowBinaryFields, new Integer(95), new Integer(162), new Integer(1), new Integer(210) + }); + } // CurReportDocument.getDoc().xProgressBar.setValue(40); CurTitlesComponent = new TitlesComponent(this, SOTITLEPAGE, 97, 37, 210, 7, slblColumnNames, slblColumnTitles, 34381); CurTitlesComponent.addTextListener(this); diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java index 515d0c635ed0..3c2ffc7954bb 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java +++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java @@ -59,8 +59,7 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XURLTransformer; import com.sun.star.wizards.common.Resource; import com.sun.star.wizards.db.FieldColumn; -// import java.io.File; -import java.io.File; +//import java.io.File; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Iterator; @@ -182,6 +181,7 @@ public class ReportBuilderImplementation extends ReportImplementationHelper aConnection.Value = _xConnection; args[1] = aConnection; + XReportDefinition xReportDefinition = null; final XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, /* getRecordParser().getReportDocuments() */ _aDoc); try @@ -195,7 +195,20 @@ public class ReportBuilderImplementation extends ReportImplementationHelper aCommand.Name = "openDesign"; final com.sun.star.ucb.OpenCommandArgument2 aOpenCommand = new com.sun.star.ucb.OpenCommandArgument2(); aOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT; - aCommand.Argument = aOpenCommand; + + PropertyValue args2[] = new PropertyValue[2]; + + PropertyValue aPropOpenCommand = new PropertyValue(); + aPropOpenCommand.Name = ""; + aPropOpenCommand.Value = aOpenCommand; + args2[0] = aPropOpenCommand; + + PropertyValue aAddField = new PropertyValue(); + aAddField.Name = "Mode"; + aAddField.Value = "remote"; + args2[1] = aAddField; + + aCommand.Argument = args2; // com.sun.star.usb.XCommandEnvironment xEnv = new com.sun.star.ucb.XCommandEnvironment(); final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); xReportDefinition = (XReportDefinition) UnoRuntime.queryInterface(XReportDefinition.class, aObj2); diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java index 1488a9ca32a5..8ab20bb35e81 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java @@ -94,9 +94,10 @@ public class ColumnarSingleColumn extends ReportBuilderLayouter aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel); final String sFieldName = convertToFieldName(aFieldNames[i]); aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField); - aRect.Y += aSOLabel.getHeight(500); + int nHeight = aRect.Height; + aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), nHeight); } - aRect.Y += aSOLabel.getHeight(500); // one empty line + aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line xSection.setHeight(aRect.Y); doNotBreakInTable(xSection); } diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java index 98147e93c095..372e8b596f2f 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java @@ -108,6 +108,7 @@ public class ColumnarTwoColumns extends ReportBuilderLayouter final SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); aSOLabel.setFontToBold(); final SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + int nMaxHeight = 0; for (int x = 0; x < _nColumns; x++) { aRect.Y = 0; @@ -120,13 +121,15 @@ public class ColumnarTwoColumns extends ReportBuilderLayouter aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel); final String sFieldName = convertToFieldName(aFieldNames[i]); aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField); - aRect.Y += aSOLabel.getHeight(500); + + aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), aRect.Height); ++i; } } + nMaxHeight = Math.max(aRect.Y, nMaxHeight); } - aRect.Y = aSOLabel.getHeight(500) * nRows; - aRect.Y += aSOLabel.getHeight(500); // one empty line + aRect.Y = Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight) * nRows, nMaxHeight); + aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line xSection.setHeight(aRect.Y); doNotBreakInTable(xSection); } diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java index df5228e18e4d..9d56cc8fc31c 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java @@ -91,7 +91,7 @@ public class InBlocksLabelsAbove extends ColumnarTwoColumns aRectLabels.Y = 0; aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); - aRectFields.Y = 500; + aRectFields.Y = LayoutConstants.LabelHeight; aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); // first run only calculates the width. @@ -129,10 +129,11 @@ public class InBlocksLabelsAbove extends ColumnarTwoColumns aSOLabel.setFontToBold(); final SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); - aRectFields.Y = aSOLabel.getHeight(500); + aRectFields.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight); aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); i = 0; nCount = aFieldTitleNames.length; + int nLastHeight = 0; while (nCount > 0) { final String sLabel = aFieldTitleNames[i]; @@ -141,21 +142,23 @@ public class InBlocksLabelsAbove extends ColumnarTwoColumns final String sFieldName = convertToFieldName(aFieldNames[i]); nFieldWidth = 3000 + nDelta; aRectFields = insertFormattedField(xSection, sFieldName, aRectFields, nFieldWidth, aSOTextField); - + nLastHeight = Math.max(nLastHeight, aRectFields.Height); int nNextX = aRectFields.X + nFieldWidth; if (nNextX > (getPageWidth() - getRightPageIndent()) & nCount > 1) { - aRectLabels.Y += (2 * aSOLabel.getHeight(500)); // 2 * label height + int nHeight = (aSOLabel.getHeight(LayoutConstants.LabelHeight) + Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight)); + nLastHeight = 0; + aRectLabels.Y += nHeight; // 2 * label height aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); - aRectFields.Y += (2 * aSOTextField.getHeight(500)); + aRectFields.Y += nHeight; aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); } ++i; --nCount; } - aRectFields.Y += aSOTextField.getHeight(500); - aRectFields.Y += aSOTextField.getHeight(500); // one empty line + aRectFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight); + aRectFields.Y += aSOTextField.getHeight(LayoutConstants.EmptyLineHeight); // one empty line xSection.setHeight(aRectFields.Y); doNotBreakInTable(xSection); } diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java index f6f93e11e574..6a3d8602668c 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java @@ -104,6 +104,7 @@ public class InBlocksLabelsLeft extends ColumnarTwoColumns SectionObject aSOLabel = getDesignTemplate().getDetailLabel(); aSOLabel.setFontToBold(); SectionObject aSOTextField = getDesignTemplate().getDetailTextField(); + int nLastHeight = 0; while (nCount > 0) { final String sLabel = aFieldTitleNames[i]; @@ -112,18 +113,19 @@ public class InBlocksLabelsLeft extends ColumnarTwoColumns final String sFieldName = convertToFieldName(aFieldNames[i]); nFieldWidth = 3000 + nDelta; aRectLabelFields = insertFormattedField(xSection, sFieldName, aRectLabelFields, nFieldWidth, aSOTextField); - + nLastHeight = Math.max(aRectLabelFields.Height, nLastHeight); final int nNextX = aRectLabelFields.X + nLabelWidth + nFieldWidth; if (nNextX > (getPageWidth() - getRightPageIndent())) { // TODO: label height is fix - aRectLabelFields.Y += aSOTextField.getHeight(500); + aRectLabelFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight); + nLastHeight = 0; aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); } ++i; --nCount; } - aRectLabelFields.Y += aSOLabel.getHeight(500); // one empty line + aRectLabelFields.Y += Math.max(aSOLabel.getHeight(LayoutConstants.EmptyLineHeight), nLastHeight); // one empty line xSection.setHeight(aRectLabelFields.Y); doNotBreakInTable(xSection); } diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java new file mode 100644 index 000000000000..127f26e02a78 --- /dev/null +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java @@ -0,0 +1,56 @@ +/* + * *********************************************************************** + * + * 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: InBlocksLabelsLeft.java,v $ + * + * $Revision: 1.2.36.1 $ + * + * 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 com.sun.star.wizards.reportbuilder.layout; + +/** + * + * @author ll93751 + */ +public class LayoutConstants +{ + public static final int LabelHeight = 500; + public static final int FormattedFieldHeight = 500; + public static final int EmptyLineHeight = 500; + + public static final int BinaryHeight = 4000; + public static final int MemoFieldHeight = 4000; + + public static final int LineHeight = 250; + + /** + * Groups will indent + * This is the factor (5mm) which will multiply with the current indent + */ + public static final int IndentFactorWidth = 500; +} diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java index 7b0c69c51115..891a57b30fb4 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java @@ -42,6 +42,7 @@ import com.sun.star.awt.XWindow; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.Property; import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.UnknownPropertyException; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySetInfo; import com.sun.star.container.XEnumeration; @@ -53,10 +54,13 @@ import com.sun.star.report.XFixedText; import com.sun.star.report.XFormattedField; import com.sun.star.report.XGroup; import com.sun.star.report.XGroups; +import com.sun.star.report.XImageControl; import com.sun.star.report.XReportComponent; +import com.sun.star.report.XReportControlModel; import com.sun.star.report.XReportDefinition; import com.sun.star.report.XSection; import com.sun.star.drawing.XShape; +import com.sun.star.sdbc.DataType; import com.sun.star.style.XStyle; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.XNumberFormatTypes; @@ -238,11 +242,11 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter final int MAX_INDENT = 2; if (_nGroupCount <= MAX_INDENT) { - nIndent = _nGroupCount * 500; + nIndent = _nGroupCount * LayoutConstants.IndentFactorWidth; } else { - nIndent = MAX_INDENT * 500; + nIndent = MAX_INDENT * LayoutConstants.IndentFactorWidth; } return nIndent; } @@ -434,7 +438,7 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter int nLabelHeight = 0; // if (aSO != null) // { - nLabelHeight = aSO.getHeight(500); + nLabelHeight = aSO.getHeight(LayoutConstants.LabelHeight); aRect = insertLabel(xGroupSection, getTitleFromFieldName(m_aGroupNames[i]), aRect, nLabelWidth, aSO); // } // else @@ -450,7 +454,7 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter aRect.X = nLeftPageIndent + getLeftGroupIndent(i); aRect.Y = nLabelHeight; final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; - final int nLineHeight = 250; + final int nLineHeight = LayoutConstants.LineHeight; insertHorizontalLine(xGroupSection, aRect, nLineWidth, nLineHeight); xGroupSection.setHeight(nLabelHeight + nLineHeight); } @@ -490,6 +494,18 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter return ""; } + protected int getTypeFromFieldName(String _sField) + { + for (int i = 0; i < m_aFieldNames.length; i++) + { + if (m_aFieldNames[i].equals(_sField)) + { + return m_aFieldTypes[i]; + } + } + return 0; + } + protected boolean listContains(String[] _aList, String _aValue) { for (int i = 0; i < _aList.length; i++) @@ -631,7 +647,7 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter final XFixedText xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, aFixedText); - int nHeight = 500; // default height of label is fixed. + int nHeight = LayoutConstants.LabelHeight; // default height of label is fixed. if (_aSO != null) { if (_aSO instanceof SectionEmptyObject) @@ -651,7 +667,7 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter xFixedText.setFontDescriptor(aFD); copyProperties(_aSO.getParent(), xFixedText); } - nHeight = _aSO.getHeight(500); + nHeight = _aSO.getHeight(LayoutConstants.LabelHeight); } } xFixedText.setLabel(_sLabel); @@ -682,6 +698,16 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter return aDataField.toString(); } + protected String convertFromFieldName(String _sName) + { + if (_sName.startsWith("field:[")) + { + int nCloseBrace = _sName.lastIndexOf("]"); + final String sName = _sName.substring(7, nCloseBrace).trim(); + return sName; + } + return _sName; + } // ------------------------------------------------------------------------- /** * Insert a already formatted field name into a given section @@ -706,45 +732,96 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter { try { - final Object aFormattedField = getMSFofReportDefinition().createInstance("com.sun.star.report.FormattedField"); - final XFormattedField xFormattedField = (XFormattedField) UnoRuntime.queryInterface(XFormattedField.class, aFormattedField); - // #i86907# not documented right in idl description. - xFormattedField.setDataField(_sFormattedfield); - int nHeight = 500; - if (_aSO != null) + Object aField; + int nHeight = LayoutConstants.FormattedFieldHeight; + + int nType = getTypeFromFieldName(convertFromFieldName(_sFormattedfield)); + if (nType == DataType.BINARY || + nType == DataType.VARBINARY || + nType == DataType.LONGVARBINARY) { -// TODO: there seems to be some problems with copy all properties from the design template to the current design - final FontDescriptor aFD = _aSO.getFontDescriptor(); - if (aFD != null) + aField = getMSFofReportDefinition().createInstance("com.sun.star.report.ImageControl"); + nHeight = LayoutConstants.BinaryHeight; + } + else + { + aField = getMSFofReportDefinition().createInstance("com.sun.star.report.FormattedField"); + nHeight = LayoutConstants.FormattedFieldHeight; + if (nType == DataType.LONGVARCHAR) /* memo */ { - xFormattedField.setFontDescriptor(aFD); - copyProperties(_aSO.getParent(), xFormattedField); + nHeight = LayoutConstants.MemoFieldHeight; // special case for memo } - nHeight = _aSO.getHeight(500); } - xFormattedField.setPositionX(_aRect.X); - xFormattedField.setPositionY(_aRect.Y); - xFormattedField.setWidth(_nWidth); - _aRect.X += _nWidth; - xFormattedField.setHeight(nHeight); - - xFormattedField.setParaAdjust(_nAlignment); + _aRect.Height = nHeight; - // spezial case rpt:now() (default date format) - if (_sFormattedfield.equals("rpt:now()")) + final XReportControlModel xReportControlModel = (XReportControlModel) UnoRuntime.queryInterface(XReportControlModel.class, aField); + if (xReportControlModel != null) { - XNumberFormatsSupplier x = xFormattedField.getFormatsSupplier(); - XNumberFormats xFormats = x.getNumberFormats(); - XNumberFormatTypes x3 = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xFormats); - Locale.getDefault(); - com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale(); - aLocale.Country = Locale.getDefault().getCountry(); - aLocale.Language = Locale.getDefault().getLanguage(); - - int nFormat = x3.getStandardFormat(com.sun.star.util.NumberFormat.DATE, aLocale); - xFormattedField.setFormatKey(nFormat); + // #i86907# not documented right in idl description. + xReportControlModel.setDataField(_sFormattedfield); + if (_aSO != null) + { + // TODO: there seems to be some problems with copy all properties from the design template to the current design + final FontDescriptor aFD = _aSO.getFontDescriptor(); + if (aFD != null) + { + xReportControlModel.setFontDescriptor(aFD); + copyProperties(_aSO.getParent(), xReportControlModel); + } + nHeight = _aSO.getHeight(nHeight); + } + xReportControlModel.setPositionX(_aRect.X); + xReportControlModel.setPositionY(_aRect.Y); + xReportControlModel.setWidth(_nWidth); + _aRect.X += _nWidth; + xReportControlModel.setHeight(nHeight); + + if (nType == DataType.BINARY || + nType == DataType.VARBINARY || + nType == DataType.LONGVARBINARY) + { + // aField = getMSFofReportDefinition().createInstance("com.sun.star.report.ImageControl"); + final XImageControl xImageControl = (XImageControl) UnoRuntime.queryInterface(XImageControl.class, xReportControlModel); + if (xImageControl != null) + { + // xImageControl.setScaleImage(true); + + xImageControl.setScaleMode(com.sun.star.awt.ImageScaleMode.Isotropic); + } + } + else + { + try + { + xReportControlModel.setParaAdjust(_nAlignment); + // if (nType == DataType.LONGVARCHAR) + // { + // xReportControlModel.??? + // } + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + // seems we not able to set ParaAdjust + } + } + // spezial case rpt:now() (default date format) + if (_sFormattedfield.equals("rpt:now()")) + { + final XFormattedField xFormattedField = (XFormattedField) UnoRuntime.queryInterface(XFormattedField.class, xReportControlModel); + + XNumberFormatsSupplier x = xFormattedField.getFormatsSupplier(); + XNumberFormats xFormats = x.getNumberFormats(); + XNumberFormatTypes x3 = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xFormats); + Locale.getDefault(); + com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale(); + aLocale.Country = Locale.getDefault().getCountry(); + aLocale.Language = Locale.getDefault().getLanguage(); + + int nFormat = x3.getStandardFormat(com.sun.star.util.NumberFormat.DATE, aLocale); + xFormattedField.setFormatKey(nFormat); + } + _xSection.add(xReportControlModel); } - _xSection.add(xFormattedField); } catch (com.sun.star.uno.Exception e) { @@ -1253,7 +1330,7 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter aRect.X = getLeftPageIndent(); SectionObject aSOLabel = SectionEmptyObject.create(); aSOLabel.setFontToBold(); - aRect.Y = aSOLabel.getHeight(500); + aRect.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight); final int nWidth = 3000; @@ -1263,26 +1340,26 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter // aRect = insertFormattedField(xSection, "rpt:Title()", aRect, nTitleWidth); aRect = insertLabel(xSection, sTitle, aRect, nTitleWidth, aSOLabel); - aRect.Y += aSOLabel.getHeight(500) + 250; + aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight; aRect.X = getLeftPageIndent(); aRect = insertLabel(xSection, sAuthorTitle, aRect, nWidth, aSOLabel); // aRect = insertFormattedField(xSection, "rpt:Author()", aRect, nWidth); aRect = insertLabel(xSection, sAuthor, aRect, nTitleWidth, aSOLabel); - aRect.Y += aSOLabel.getHeight(500); + aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight); aRect.X = getLeftPageIndent(); aRect = insertLabel(xSection, sDateTitle, aRect, nWidth, aSOLabel); // aRect = insertFormattedField(xSection, "rpt:Date()", aRect, nWidth); aRect = insertFormattedField(xSection, sDate, aRect, nTitleWidth, aSOLabel); - aRect.Y += aSOLabel.getHeight(500) + 250; + aRect.Y += aSOLabel.getHeight(LayoutConstants.FormattedFieldHeight) + LayoutConstants.LineHeight; // draw a line under the label/formattedfield aRect.X = getLeftPageIndent(); final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; - final int nLineHeight = 250; + final int nLineHeight = LayoutConstants.LineHeight; insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight); aRect.Y += nLineHeight; @@ -1366,18 +1443,18 @@ abstract public class ReportBuilderLayouter implements IReportBuilderLayouter // draw a line over the label/formattedfield final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X; - final int nLineHeight = 250; + final int nLineHeight = LayoutConstants.LineHeight; insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight); aRect.Y += nLineHeight; - aRect.Y += 500; + aRect.Y += LayoutConstants.LabelHeight; final int nWidth = nUsablePageWidth; aRect.X = getLeftPageIndent(); aRect = insertFormattedField(xSection, "rpt:" + sNoFirstUnusedQuotes, aRect, nWidth, null, (short) com.sun.star.awt.TextAlign.CENTER); - aRect.Y += 500 + 250; + aRect.Y += LayoutConstants.FormattedFieldHeight + LayoutConstants.LineHeight; xSection.setHeight(aRect.Y); } catch (Exception e) diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java index 2bdc2cf8c929..caae8481ef10 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java @@ -68,7 +68,7 @@ abstract public class SectionObject public int getHeight(int _nDefault) { - final int nHeight = getPropertySetHelper().getPropertyValueAsInteger("Height", 500); + final int nHeight = getPropertySetHelper().getPropertyValueAsInteger("Height", _nDefault); return nHeight; } diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java index b5ebc38a0453..e0dadcb3d567 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java @@ -85,13 +85,14 @@ public class Tabular extends ReportBuilderLayouter final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldNames.length); final SectionObject aSO = getDesignTemplate().getDetailTextField(); - + int nHeight = LayoutConstants.FormattedFieldHeight; for (int i = 0; i < aFieldNames.length; i++) { final String sFieldName = convertToFieldName(aFieldNames[i]); aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSO); + nHeight = Math.max(aRect.Height, nHeight); } - int nHeight = aSO.getHeight(500); + nHeight = Math.max(aSO.getHeight(nHeight), nHeight); xSection.setHeight(nHeight); } @@ -141,14 +142,14 @@ public class Tabular extends ReportBuilderLayouter // TODO: getCountOfGroups() == nGroups??? aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()); // TODO: group line is fix - aRect.Y = aSO.getHeight(500) + 250; // group height + a little empty line + aRect.Y = aSO.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight; // group height + a little empty line final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldTitleNames.length); for (int i = 0; i < aFieldTitleNames.length; i++) { aRect = insertLabel(xSection, aFieldTitleNames[i], aRect, nWidth, aSO); } - xSection.setHeight(aSO.getHeight(500) + 250 + aSO.getHeight(500)); + xSection.setHeight(aSO.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight + aSO.getHeight(LayoutConstants.LabelHeight)); } catch (com.sun.star.uno.Exception e) { diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk b/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk index 5961467b2dcc..0bf60e0ba3d7 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk +++ b/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk @@ -53,6 +53,7 @@ JARCLASSDIRS = \ # --- Files -------------------------------------------------------- JAVAFILES= \ + LayoutConstants.java \ ReportBuilderLayouter.java \ Tabular.java \ ColumnarSingleColumn.java \ diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java index dec58408d2fc..b78394585cd0 100644 --- a/wizards/com/sun/star/wizards/table/Finalizer.java +++ b/wizards/com/sun/star/wizards/table/Finalizer.java @@ -148,7 +148,7 @@ public class Finalizer }, new Object[] { - Boolean.TRUE, new Integer(12), "HID:41244", new Short("7"), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sCatalogNames, new Short(curtabindex++), new Integer(80) + Boolean.TRUE, new Integer(12), "HID:41244", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sCatalogNames, new Short(curtabindex++), new Integer(80) }); int isel = JavaTools.FieldInList(sCatalogNames, sCatalog); if (isel < 0) @@ -203,7 +203,7 @@ public class Finalizer }, new Object[] { - Boolean.TRUE, new Integer(12), "HID:41245", new Short("7"), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sSchemaNames, new Short(curtabindex++), new Integer(80) + Boolean.TRUE, new Integer(12), "HID:41245", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sSchemaNames, new Short(curtabindex++), new Integer(80) }); int isel = JavaTools.FieldInList(sSchemaNames, sSchema); if (isel < 0) @@ -321,7 +321,7 @@ public class Finalizer { if (txtTableName.getText().equals("")) { - String ssuffix = Desktop.getIncrementSuffix(curtabledescriptor.xTableNames, getComposedTableName(_tablename)); + String ssuffix = Desktop.getIncrementSuffix(curtabledescriptor.getTableNamesAsNameAccess(), getComposedTableName(_tablename)); txtTableName.setText(_tablename + ssuffix); setCompletionFlag(); } diff --git a/wizards/com/sun/star/wizards/table/ScenarioSelector.java b/wizards/com/sun/star/wizards/table/ScenarioSelector.java index 90702e74c65d..1bce7ad83aa8 100644 --- a/wizards/com/sun/star/wizards/table/ScenarioSelector.java +++ b/wizards/com/sun/star/wizards/table/ScenarioSelector.java @@ -29,24 +29,24 @@ ************************************************************************/ package com.sun.star.wizards.table; -import java.util.Hashtable; +// import java.util.Hashtable; import java.util.Vector; import com.sun.star.awt.ItemEvent; -import com.sun.star.awt.XButton; +// import com.sun.star.awt.XButton; import com.sun.star.awt.XFixedText; import com.sun.star.awt.XItemListener; import com.sun.star.awt.XListBox; import com.sun.star.awt.XRadioButton; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; +// import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.lang.EventObject; import com.sun.star.lang.Locale; import com.sun.star.lang.XMultiServiceFactory; //import com.sun.star.uno.Exception; -import com.sun.star.sdbc.SQLException; -import com.sun.star.uno.UnoRuntime; +// import com.sun.star.sdbc.SQLException; +// import com.sun.star.uno.UnoRuntime; import com.sun.star.wizards.common.Configuration; import com.sun.star.wizards.common.Desktop; import com.sun.star.wizards.common.Helper; @@ -55,7 +55,7 @@ import com.sun.star.wizards.db.TableDescriptor; import com.sun.star.wizards.ui.FieldSelection; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.UnoDialog; -import com.sun.star.wizards.ui.WizardDialog; +// import com.sun.star.wizards.ui.WizardDialog; import com.sun.star.wizards.ui.XFieldSelectionListener; /** @@ -80,7 +80,6 @@ public class ScenarioSelector extends FieldSelection implements XItemListener, X private int curcategory; public boolean bcolumnnameislimited; private int imaxcolumnchars; - private String[] fieldnames; String smytable; Locale aLocale; XMultiServiceFactory xMSF; @@ -164,7 +163,7 @@ public class ScenarioSelector extends FieldSelection implements XItemListener, X }, new Object[] { - Boolean.TRUE, new Integer(12), "HID:41208", new Short("7"), new Integer(91), new Integer(92), IMAINSTEP, new Short(pretabindex++), getListboxWidth() + Boolean.TRUE, new Integer(12), "HID:41208", new Short(UnoDialog.getListBoxLineCount()), new Integer(91), new Integer(92), IMAINSTEP, new Short(pretabindex++), getListboxWidth() }); } catch (Exception e) @@ -245,7 +244,7 @@ public class ScenarioSelector extends FieldSelection implements XItemListener, X e.printStackTrace(System.out); } } - fieldnames = new String[a]; + String[] fieldnames = new String[a]; afieldnameVector.toArray(fieldnames); return fieldnames; } @@ -349,7 +348,7 @@ public class ScenarioSelector extends FieldSelection implements XItemListener, X for (int i = 0; i < SelItems.length; i++) { int selindex = JavaTools.FieldInList(NewItems, SelItems[i]); - super.xSelFieldsListBox.removeItems((short) selindex, (short) 1); + super.xSelectedFieldsListBox.removeItems((short) selindex, (short) 1); /**TODO In this context the items should be better placed at their original position. * but how is this position retrieved? */ diff --git a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java index d5d787744fd5..471a18c2365f 100644 --- a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java +++ b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java @@ -54,7 +54,7 @@ public class CommandFieldSelection extends FieldSelection implements Comparator String sTableLabelName; String sQueryPrefix; String sTablePrefix; - short iSelPos = -1; + private short m_iSelPos = -1; short iOldSelPos = -1; boolean bpreselectCommand = true; boolean bgetQueries; @@ -70,9 +70,9 @@ public class CommandFieldSelection extends FieldSelection implements Comparator short[] SelItems = (short[]) CurUnoDialog.getControlProperty(sTableListBoxName, "SelectedItems"); if (SelItems.length > 0) { - iOldSelPos = iSelPos; - iSelPos = SelItems[0]; - if ((iSelPos > -1) && (iSelPos != iOldSelPos)) + iOldSelPos = m_iSelPos; + m_iSelPos = SelItems[0]; + if ((m_iSelPos > -1) && (m_iSelPos != iOldSelPos)) { if (!AppendMode) { @@ -154,9 +154,9 @@ public class CommandFieldSelection extends FieldSelection implements Comparator }, new Object[] { - Boolean.TRUE, Boolean.FALSE, new Integer(12), "HID:" + (super.FirstHelpIndex - 1), new Short("7"), new Integer(95), new Integer(37), IStep, new Short((short) 4), getListboxWidth() + Boolean.TRUE, Boolean.FALSE, new Integer(12), "HID:" + (super.FirstHelpIndex - 1), new Short(UnoDialog.getListBoxLineCount()), new Integer(95), new Integer(37), IStep, new Short((short) 4), getListboxWidth() }); - XWindow xTableListBoxWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xTableListBox); + // XWindow xTableListBoxWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xTableListBox); fillupCommandListBox(); } catch (Exception exception) @@ -261,11 +261,11 @@ public class CommandFieldSelection extends FieldSelection implements Comparator if (binitialize) { CurDBMetaData.setCommandName(curCommandName); - if (CurDBMetaData.AllFieldNames != null) + if (CurDBMetaData.m_aAllFieldNames != null) { - if (CurDBMetaData.AllFieldNames.length > 0) + if (CurDBMetaData.m_aAllFieldNames.length > 0) { - initialize(CurDBMetaData.AllFieldNames, AppendMode, CurDBMetaData.getMaxColumnsInSelect()); + initialize(CurDBMetaData.m_aAllFieldNames, AppendMode, CurDBMetaData.getMaxColumnsInSelect()); return; } } @@ -288,21 +288,21 @@ public class CommandFieldSelection extends FieldSelection implements Comparator short[] iSelArray = new short[0]; boolean bgetFields = false; String[] ContentList = new String[0]; - CurDBMetaData.setCommandNames(); + // CurDBMetaData.initCommandNames(); if (bgetQueries) { - ContentList = new String[CurDBMetaData.TableNames.length + CurDBMetaData.QueryNames.length]; - System.arraycopy(CurDBMetaData.QueryNames, 0, ContentList, CurDBMetaData.TableNames.length, CurDBMetaData.QueryNames.length); - ContentList = setPrefixinArray(ContentList, sQueryPrefix, CurDBMetaData.TableNames.length, CurDBMetaData.QueryNames.length); + ContentList = new String[CurDBMetaData.getTableNames().length + CurDBMetaData.getQueryNames().length]; + System.arraycopy(CurDBMetaData.getQueryNames(), 0, ContentList, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length); + ContentList = setPrefixinArray(ContentList, sQueryPrefix, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length); } else { - ContentList = new String[CurDBMetaData.TableNames.length]; + ContentList = new String[CurDBMetaData.getTableNames().length]; } - System.arraycopy(CurDBMetaData.TableNames, 0, ContentList, 0, CurDBMetaData.TableNames.length); + System.arraycopy(CurDBMetaData.getTableNames(), 0, ContentList, 0, CurDBMetaData.getTableNames().length); if (bgetQueries) { - ContentList = setPrefixinArray(ContentList, sTablePrefix, 0, CurDBMetaData.TableNames.length); + ContentList = setPrefixinArray(ContentList, sTablePrefix, 0, CurDBMetaData.getTableNames().length); } java.util.Arrays.sort(ContentList, this); Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "StringItemList", ContentList); @@ -321,10 +321,7 @@ public class CommandFieldSelection extends FieldSelection implements Comparator else { emptyFieldsListBoxes(); - iSelArray = new short[] - { - (short) iSelPos - }; + iSelArray = new short[] { (short) iSelPos }; } Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", iSelArray); toggleCommandListBox(true); diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.java b/wizards/com/sun/star/wizards/ui/ControlScroller.java index 38fdca98edd7..176fd62f109b 100644 --- a/wizards/com/sun/star/wizards/ui/ControlScroller.java +++ b/wizards/com/sun/star/wizards/ui/ControlScroller.java @@ -120,7 +120,7 @@ public abstract class ControlScroller iStartPosY = iCompPosY + SORELFIRSTPOSY; int ScrollHeight = iCompHeight - 2; nlineincrement = 1; - sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.xDlgNameAccess, "imgBackground"); + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "imgBackground"); oImgControl = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgBackground" + sIncSuffix, new String[] { @@ -236,7 +236,7 @@ public abstract class ControlScroller PropertyValue[] valueProps = (PropertyValue[]) scrollfields.get(guiRow + nscrollvalue); for (int n = 0; n < nameProps.length; n++) { - if (CurUnoDialog.xDlgNameAccess.hasByName(nameProps[n].Name)) + if (CurUnoDialog.getDlgNameAccess().hasByName(nameProps[n].Name)) { setControlData(nameProps[n].Name, valueProps[n].Value); } @@ -418,7 +418,7 @@ public abstract class ControlScroller protected PropertyValue fieldInfo(PropertyValue valueProp, PropertyValue nameProp) { - if (CurUnoDialog.xDlgNameAccess.hasByName(nameProp.Name)) + if (CurUnoDialog.getDlgNameAccess().hasByName(nameProp.Name)) { valueProp.Value = getControlData(nameProp.Name); } diff --git a/wizards/com/sun/star/wizards/ui/FieldSelection.java b/wizards/com/sun/star/wizards/ui/FieldSelection.java index 652eb5f44392..e66a2e58af65 100644 --- a/wizards/com/sun/star/wizards/ui/FieldSelection.java +++ b/wizards/com/sun/star/wizards/ui/FieldSelection.java @@ -45,18 +45,19 @@ public class FieldSelection public UnoDialog CurUnoDialog; public XListBox xFieldsListBox; - public XListBox xSelFieldsListBox; + public XListBox xSelectedFieldsListBox; public XFieldSelectionListener xFieldSelection; public int maxfieldcount = 10000000; public String sIncSuffix; protected Integer IStep; protected int FirstHelpIndex; protected short curtabindex; - String[] AllFieldNames; - public Integer ListBoxWidth; + private String[] AllFieldNames; + private Integer ListBoxWidth; public Integer SelListBoxPosX; boolean bisModified = false; boolean AppendMode = false; + final int SOCMDMOVESEL = 1; final int SOCMDMOVEALL = 2; final int SOCMDREMOVESEL = 3; @@ -71,6 +72,7 @@ public class FieldSelection final int cmdButtonVertiDist = 2; final int lblHeight = 8; final int lblVertiDist = 2; + int CompPosX; int CompPosY; int CompHeight; @@ -217,7 +219,7 @@ public class FieldSelection Integer CmdButtonWidth = new Integer(cmdButtonWidth); - sIncSuffix = "_" + com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.xDlgNameAccess, "lblFields_"); + sIncSuffix = "_" + com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "lblFields_"); CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblFields" + sIncSuffix, new String[] @@ -297,7 +299,7 @@ public class FieldSelection new Integer(8), slblSelFields, SelListBoxPosX, new Integer(CompPosY), IStep, new Short(curtabindex++), ListBoxWidth }); - xSelFieldsListBox = CurUnoDialog.insertListBox("lstSelFields" + sIncSuffix, SOSELFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(), + xSelectedFieldsListBox = CurUnoDialog.insertListBox("lstSelFields" + sIncSuffix, SOSELFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(), new String[] { "Height", "HelpURL", "MultiSelection", "PositionX", "PositionY", "Step", "TabIndex", "Width" @@ -330,7 +332,7 @@ public class FieldSelection CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveselected, AccessTextMoveSelected); CurUnoDialog.getPeerConfiguration().setAccessibleName(btnremoveselected, AccessTextRemoveSelected); CurUnoDialog.getPeerConfiguration().setAccessibleName(xFieldsListBox, JavaTools.replaceSubString(slblFields, "", "~")); - CurUnoDialog.getPeerConfiguration().setAccessibleName(xSelFieldsListBox, JavaTools.replaceSubString(slblSelFields, "", "~")); + CurUnoDialog.getPeerConfiguration().setAccessibleName(xSelectedFieldsListBox, JavaTools.replaceSubString(slblSelFields, "", "~")); if (btnmoveall != null) { CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveall, AccessTextMoveAll); @@ -382,18 +384,18 @@ public class FieldSelection private void changeSelectionOrder(int iNeighbor) { - short[] iSelIndices = xSelFieldsListBox.getSelectedItemsPos(); + short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos(); // Todo: we are assuming that the array starts with the lowest index. Verfy this assumption!!!!! if (iSelIndices.length == 1) { short iSelIndex = iSelIndices[0]; - String[] NewItemList = xSelFieldsListBox.getItems(); + String[] NewItemList = xSelectedFieldsListBox.getItems(); String CurItem = NewItemList[iSelIndex]; String NeighborItem = NewItemList[iSelIndex + iNeighbor]; NewItemList[iSelIndex + iNeighbor] = CurItem; NewItemList[iSelIndex] = NeighborItem; CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "StringItemList", NewItemList); - xSelFieldsListBox.selectItem(CurItem, true); + xSelectedFieldsListBox.selectItem(CurItem, true); if (xFieldSelection != null) { if (iNeighbor < 0) @@ -443,16 +445,16 @@ public class FieldSelection boolean bmoveUpenabled = false; boolean bmoveDownenabled = false; CurUnoDialog.selectListBoxItem(xFieldsListBox, iFieldsSelIndex); - CurUnoDialog.selectListBoxItem(xSelFieldsListBox, iSelFieldsSelIndex); - int SelListBoxSelLength = xSelFieldsListBox.getSelectedItems().length; + CurUnoDialog.selectListBoxItem(xSelectedFieldsListBox, iSelFieldsSelIndex); + int SelListBoxSelLength = xSelectedFieldsListBox.getSelectedItems().length; int ListBoxSelLength = xFieldsListBox.getSelectedItems().length; boolean bIsFieldSelected = (ListBoxSelLength > 0); int FieldCount = xFieldsListBox.getItemCount(); boolean bSelectSelected = (SelListBoxSelLength > 0); - int SelectCount = xSelFieldsListBox.getItemCount(); + int SelectCount = xSelectedFieldsListBox.getItemCount(); if (bSelectSelected) { - short[] iSelIndices = xSelFieldsListBox.getSelectedItemsPos(); + short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos(); bmoveUpenabled = ((iSelIndices[0] > 0) && (iSelIndices.length == 1)); bmoveDownenabled = (((iSelIndices[SelListBoxSelLength - 1]) < (short) (SelectCount - 1)) && (iSelIndices.length == 1)); } @@ -470,8 +472,8 @@ public class FieldSelection protected void toggleMoveButtons(boolean _btoggleMoveAll, boolean _btoggleMoveSelected) { - boolean btoggleMoveAll = (((xFieldsListBox.getItemCount() + xSelFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveAll)); - boolean btoggleMoveSelected = (((xFieldsListBox.getSelectedItems().length + xSelFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveSelected)); + boolean btoggleMoveAll = (((xFieldsListBox.getItemCount() + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveAll)); + boolean btoggleMoveSelected = (((xFieldsListBox.getSelectedItems().length + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveSelected)); CurUnoDialog.setControlProperty("cmdMoveAll" + sIncSuffix, "Enabled", new Boolean(btoggleMoveAll)); CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, "Enabled", new Boolean(btoggleMoveSelected)); } @@ -479,7 +481,7 @@ public class FieldSelection public void setMultipleMode(boolean _bisMultiple) { xFieldsListBox.setMultipleMode(_bisMultiple); - xSelFieldsListBox.setMultipleMode(_bisMultiple); + xSelectedFieldsListBox.setMultipleMode(_bisMultiple); } public void emptyFieldsListBoxes() @@ -502,25 +504,31 @@ public class FieldSelection public void mergeList(String[] AllFieldNames, String[] SecondList) { - int MaxIndex = SecondList.length; + // int MaxIndex = SecondList.length; xFieldsListBox.addItems(AllFieldNames, (short) 0); toggleListboxButtons((short) - 1, (short) - 1); } public void intializeSelectedFields(String[] _SelectedFieldNames) { - xSelFieldsListBox.addItems(_SelectedFieldNames, xSelFieldsListBox.getItemCount()); + xSelectedFieldsListBox.addItems(_SelectedFieldNames, xSelectedFieldsListBox.getItemCount()); + } + + private void removeAllItems(XListBox _xListBox) + { + _xListBox.removeItems((short) 0, _xListBox.getItemCount()); } + // Note Boolean Parameter public void initialize(String[] _AllFieldNames, boolean _AppendMode) { AppendMode = _AppendMode; - xFieldsListBox.removeItems((short) 0, xFieldsListBox.getItemCount()); + removeAllItems(xFieldsListBox); xFieldsListBox.addItems(_AllFieldNames, (short) 0); - this.AllFieldNames = xFieldsListBox.getItems(); - if ((xSelFieldsListBox.getItemCount() > 0) && (!AppendMode)) + AllFieldNames = xFieldsListBox.getItems(); + if ((xSelectedFieldsListBox.getItemCount() > 0) && (!AppendMode)) { - xSelFieldsListBox.removeItems((short) 0, xSelFieldsListBox.getItemCount()); + removeAllItems(xSelectedFieldsListBox); } toggleListboxControls(Boolean.TRUE); } @@ -543,8 +551,8 @@ public class FieldSelection public void initialize(String[] _AllFieldNames, String[] _SelFieldNames, boolean _AppendMode) { - xSelFieldsListBox.removeItems((short) 0, xSelFieldsListBox.getItemCount()); - xSelFieldsListBox.addItems(_SelFieldNames, (short) 0); + removeAllItems(xSelectedFieldsListBox); + xSelectedFieldsListBox.addItems(_SelFieldNames, (short) 0); initialize(_AllFieldNames, _AppendMode); } @@ -553,20 +561,20 @@ public class FieldSelection // int CurIndex; short iFieldSelected = (short) - 1; short iSelFieldSelected = (short) - 1; - // int MaxCurTarget = xSelFieldsListBox.getItemCount(); + // int MaxCurTarget = xSelectedFieldsListBox.getItemCount(); String[] SelFieldItems; if (bMoveAll) { SelFieldItems = xFieldsListBox.getItems(); - xFieldsListBox.removeItems((short) 0, xFieldsListBox.getItemCount()); + removeAllItems(xFieldsListBox); if (!AppendMode) { - xSelFieldsListBox.removeItems((short) 0, xSelFieldsListBox.getItemCount()); - xSelFieldsListBox.addItems(AllFieldNames, (short) 0); + removeAllItems(xSelectedFieldsListBox); + xSelectedFieldsListBox.addItems(AllFieldNames, (short) 0); } else { - xSelFieldsListBox.addItems(SelFieldItems, xSelFieldsListBox.getItemCount()); + xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount()); } } else @@ -576,18 +584,18 @@ public class FieldSelection if (MaxSourceSelected > 0) { iFieldSelected = xFieldsListBox.getSelectedItemPos(); - iSelFieldSelected = xSelFieldsListBox.getSelectedItemPos(); + iSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos(); short[] SourceSelList = new short[xFieldsListBox.getSelectedItemsPos().length]; SourceSelList = xFieldsListBox.getSelectedItemsPos(); - xSelFieldsListBox.addItems(SelFieldItems, xSelFieldsListBox.getItemCount()); + xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount()); CurUnoDialog.removeSelectedItems(xFieldsListBox); - xSelFieldsListBox.selectItemPos((short) 0, xSelFieldsListBox.getSelectedItems().length > 0); + xSelectedFieldsListBox.selectItemPos((short) 0, xSelectedFieldsListBox.getSelectedItems().length > 0); } } toggleListboxButtons(iFieldSelected, iSelFieldSelected); if (xFieldSelection != null) { - xFieldSelection.shiftFromLeftToRight(SelFieldItems, xSelFieldsListBox.getItems()); + xFieldSelection.shiftFromLeftToRight(SelFieldItems, xSelectedFieldsListBox.getItems()); } } @@ -596,14 +604,14 @@ public class FieldSelection // int m = 0; String SearchString; short iOldFieldSelected = xFieldsListBox.getSelectedItemPos(); - short iOldSelFieldSelected = xSelFieldsListBox.getSelectedItemPos(); - String[] OldSelFieldItems = xSelFieldsListBox.getSelectedItems(); + short iOldSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos(); + String[] OldSelFieldItems = xSelectedFieldsListBox.getSelectedItems(); if (bMoveAll) { - OldSelFieldItems = xSelFieldsListBox.getItems(); - xFieldsListBox.removeItems((short) 0, xFieldsListBox.getItemCount()); + OldSelFieldItems = xSelectedFieldsListBox.getItems(); + removeAllItems(xFieldsListBox); xFieldsListBox.addItems(AllFieldNames, (short) 0); - xSelFieldsListBox.removeItems((short) 0, xSelFieldsListBox.getItemCount()); + removeAllItems(xSelectedFieldsListBox); } else { @@ -630,10 +638,10 @@ public class FieldSelection NewSourceVector.toArray(NewSourceList); xFieldsListBox.addItems(NewSourceList, (short) 0); } - CurUnoDialog.removeSelectedItems(xSelFieldsListBox); + CurUnoDialog.removeSelectedItems(xSelectedFieldsListBox); } toggleListboxButtons(iOldFieldSelected, iOldSelFieldSelected); - String[] NewSelFieldItems = xSelFieldsListBox.getItems(); + String[] NewSelFieldItems = xSelectedFieldsListBox.getItems(); if (xFieldSelection != null) { xFieldSelection.shiftFromRightToLeft(OldSelFieldItems, NewSelFieldItems); diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java index e1ae043db571..c84db4674c96 100644 --- a/wizards/com/sun/star/wizards/ui/FilterComponent.java +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -56,12 +56,13 @@ public class FilterComponent { private Integer IStep; - private int iStartPosX; - private int iStartPosY; + // private int iStartPosX; + // private int iStartPosY; // int Count; private int RowCount; // private int FilterCount; private static String[] sLogicOperators; + private static String[] sBooleanValues; // private /* public */ String[] FieldNames; private XRadioButton optMatchAll; private XRadioButton optMatchAny; @@ -77,9 +78,6 @@ public class FilterComponent private ControlRow[] oControlRows; // private Vector FilterNames; private String sDuplicateCondition; - final int SOLSTFIELDNAME = 3; - final int SOLSTOPERATOR = 4; - final int SOTXTVALUE = 5; final int SOOPTORMODE = 100; final int SOOPTANDMODE = 101; QueryMetaData oQueryMetaData; @@ -113,6 +111,14 @@ public class FilterComponent { SO_FIRSTTEXTFIELD, SO_SECONDTEXTFIELD, SO_THIRDTEXTFIELD, SO_FOURTHTEXTFIELD }; + final int SO_FIRSTBOOLFIELDNAME = 256 + 1; + final int SO_SECONDBOOLFIELDNAME = 256 + 2; + final int SO_THIRDBOOLFIELDNAME = 256 + 3; + final int SO_FOURTHBOOLFIELDNAME = 256 + 4; + int SO_BOOLEANLIST[] = { + SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME + }; + final int SO_OPTQUERYMODE = 5; int SOI_MATCHALL = 0; int SOI_MATCHANY = 1; @@ -127,7 +133,7 @@ public class FilterComponent try { int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); - String scontrolname = ""; + String sControlName = ""; switch (iKey) { // case SOOPTQUERYMODE: @@ -136,31 +142,55 @@ public class FilterComponent case SO_SECONDFIELDNAME: case SO_THIRDFIELDNAME: case SO_FOURTHFIELDNAME: - scontrolname = getControlName(EventObject.Source); - String scontrolnameSuffix = sIncSuffix + "_" + scontrolname.substring(scontrolname.length() - 1, scontrolname.length()); - XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(scontrolname)); + sControlName = getControlName(EventObject.Source); + String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName); + XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName)); String CurDisplayFieldName = xCurFieldListBox.getSelectedItem(); FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName); - XControl xValueControl = CurUnoDialog.xDlgContainer.getControl("txtValue" + scontrolnameSuffix); - XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); - Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", new Boolean(CurFieldColumn.bIsNumberFormat)); - final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); - aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.DBFormatKey, aNumberFormatter); + + String sControlNameTextValue = "txtValue" + sControlNameSuffix; +// String sControlNameBooleanList = "lstBoolean" + sControlNameSuffix; +// if (aFieldColumn.FieldType == DataType.BOOLEAN) +// { +// // scheint aufgrund eines Fehlers in Toolkit nicht zu funktionieren +// CurUnoDialog.setControlVisible(sControlNameTextValue, false); +// CurUnoDialog.setControlVisible(sControlNameBooleanList, true); +// } +// else +// { +// CurUnoDialog.setControlVisible(sControlNameTextValue, true); +// CurUnoDialog.setControlVisible(sControlNameBooleanList, false); + + XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue); + XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl); + Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", new Boolean(CurFieldColumn.bIsNumberFormat)); + final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter(); + aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.DBFormatKey, aNumberFormatter); +// } + break; case SO_FIRSTCONDITION: case SO_SECONDCONDITION: case SO_THIRDCONDITION: case SO_FOURTHCONDITION: - scontrolname = getControlName(EventObject.Source); + sControlName = getControlName(EventObject.Source); break; case SOOPTORMODE: case SOOPTANDMODE: // getfilterstate(); return; + + case SO_FIRSTBOOLFIELDNAME: + case SO_SECONDBOOLFIELDNAME: + case SO_THIRDBOOLFIELDNAME: + case SO_FOURTHBOOLFIELDNAME: + sControlName = getControlName(EventObject.Source); + break; + default: break; } - togglefollowingControlRow(scontrolname); + togglefollowingControlRow(sControlName); } catch (Exception exception) { @@ -217,13 +247,25 @@ public class FilterComponent } } + public static String getIndexNumber(String _sStr) + { + String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length()); + return sLastNumber; + } + + /** + * Enable the next ControlRow if the Condition is complete in the current line + * + * @param _scurName every control name ends with something like _1, _2, _3 this is the index number + * we try to interpret to check which line we currently use. (number - 1) + */ private void togglefollowingControlRow(String _scurName) { // String sNameSuffix = sIncSuffix + "_" + _scurName.substring(_scurName.length() - 1, _scurName.length()); - int Index = Integer.valueOf(_scurName.substring(_scurName.length() - 1, _scurName.length())).intValue(); + int Index = Integer.valueOf(getIndexNumber(_scurName)).intValue(); if (Index < oControlRows.length) { - boolean bValue = oControlRows[Index - 1].isComplete(); + boolean bValue = oControlRows[Index - 1].isConditionComplete(); oControlRows[Index].setEnabled(bValue); } } @@ -246,80 +288,84 @@ public class FilterComponent public PropertyValue[][] getFilterConditions() { - ControlRow CurControlRow; - Object curValue; + // ControlRow CurControlRow; // getfilterstate(); - int filtercount = getFilterCount(); - if (filtercount > 0) + int nFilterCount = getFilterCount(); + if (nFilterCount > 0) { if (this.getfilterstate() == this.SOI_MATCHALL) { - filterconditions = new PropertyValue[1][filtercount]; + filterconditions = new PropertyValue[1][nFilterCount]; } else { - filterconditions = new PropertyValue[filtercount][1]; + filterconditions = new PropertyValue[nFilterCount][1]; } int a = 0; for (int i = 0; i < RowCount; i++) { - CurControlRow = oControlRows[i]; + ControlRow CurControlRow = oControlRows[i]; if (CurControlRow.isEnabled()) { - if (CurControlRow.isComplete()) + if (CurControlRow.isConditionComplete()) { - String curFieldName = CurControlRow.getSelectedFieldName(); - int curOperator = (int) CurControlRow.getSelectedOperator() + 1; - FieldColumn CurFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(curFieldName); - if (CurFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getTextFormatKey()) + Object aValue; + String sFieldName = CurControlRow.getSelectedFieldName(); + int nOperator = (int) CurControlRow.getSelectedOperator(); + FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); + if (aFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getTextFormatKey()) { - curValue = "'" + CurControlRow.getValue() + "'"; + aValue = "'" + CurControlRow.getValue() + "'"; } //// TODO the following code is bound to be deprecated as soon as the query composer is able to handle date/time values as numbers - else if ((CurFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getDateFormatKey()) || - (CurFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getDateTimeFormatKey())) + else if ((aFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getDateFormatKey()) || + (aFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getDateTimeFormatKey())) { String sDate = CurControlRow.getDateTimeString(true); - curValue = "{D '" + sDate + "' }"; // FormatsSupplier + aValue = "{D '" + sDate + "' }"; // FormatsSupplier } - else if (CurFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getTimeFormatKey()) + else if (aFieldColumn.StandardFormatKey == oQueryMetaData.getNumberFormatter().getTimeFormatKey()) { String sTime = CurControlRow.getDateTimeString(true); - curValue = "'{T '" + sTime + "' }"; + aValue = "'{T '" + sTime + "' }"; } else { - curValue = CurControlRow.getValue(); - switch (CurFieldColumn.FieldType) + aValue = CurControlRow.getValue(); + // if void + if (! AnyConverter.isVoid(aValue)) { - case DataType.TINYINT: - case DataType.BIGINT: - case DataType.INTEGER: - case DataType.SMALLINT: - curValue = String.valueOf(((Double) curValue).intValue()); - break; - case DataType.BIT: - case DataType.BOOLEAN: - // curValue = CurControlRow.getText(); // wrong! (creates something like 'WAHR'/'FALSCH' if german locale is used. - - // double dblvalue = ((Double) curValue).doubleValue(); - //curValue = new Boolean(dblvalue == 1.0); // wrong! we need a string, not a boolean value - - // converts the '1.0'/'0.0' (EffectiveValue) to a 'boolean' String like 'true'/'false' - curValue = String.valueOf(((Double) curValue).intValue() == 1); - break; - default: - curValue = String.valueOf(curValue); - break; + switch (aFieldColumn.FieldType) + { + case DataType.TINYINT: + case DataType.BIGINT: + case DataType.INTEGER: + case DataType.SMALLINT: + aValue = String.valueOf(((Double) aValue).intValue()); + break; + case DataType.BIT: + case DataType.BOOLEAN: + // curValue = CurControlRow.getText(); // wrong! (creates something like 'WAHR'/'FALSCH' if german locale is used. + + // double dblvalue = ((Double) curValue).doubleValue(); + //curValue = new Boolean(dblvalue == 1.0); // wrong! we need a string, not a boolean value + + // converts the '1.0'/'0.0' (EffectiveValue) to a 'boolean' String like 'true'/'false' + aValue = String.valueOf(((Double) aValue).intValue() == 1); + break; + default: + aValue = String.valueOf(aValue); + break; + } } } - PropertyValue oPropertyValue = Properties.createProperty(curFieldName, curValue, curOperator); + PropertyValue oPropertyValue = Properties.createProperty(sFieldName, aValue, nOperator); if (getfilterstate()/*this.ifilterstate*/ == this.SOI_MATCHALL) { if (i == 0) { - filterconditions[0] = new PropertyValue[filtercount]; + filterconditions[0] = new PropertyValue[nFilterCount]; } filterconditions[0][a] = oPropertyValue; } @@ -422,7 +468,7 @@ public class FilterComponent int a = 0; for (int i = 0; i < RowCount; i++) { - if (oControlRows[i].isEnabled() && oControlRows[i].isComplete()) + if (oControlRows[i].isEnabled() && oControlRows[i].isConditionComplete()) { a++; } @@ -456,44 +502,79 @@ public class FilterComponent this.RowCount = FilterCount; this.oQueryMetaData = _oQueryMetaData; boolean bEnabled; - sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.xDlgNameAccess, "optMatchAll"); - iStartPosX = iPosX; - iStartPosY = iPosY; + sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll"); + // iStartPosX = iPosX; + // iStartPosY = iPosY; String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9); String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10); slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17); slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24); slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25); - sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 7); + sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null + sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89); + // create Radiobuttons + // * match all + // * match one optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), new String[] { - "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width" + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "State", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Integer(9), "HID:" + curHelpID++, soptMatchAll, new Integer(iPosX), new Integer(iStartPosY), new Short((short) 1), IStep, new Short(curtabindex++), new Integer(203) + new Integer(9), + "HID:" + curHelpID++, + soptMatchAll, + new Integer(iPosX), + new Integer(iPosY), + new Short((short) 1), + IStep, + new Short(curtabindex++), + new Integer(203) }); optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), new String[] { - "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Height", + "HelpURL", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Integer(9), "HID:" + curHelpID++, soptMatchAny, new Integer(iPosX), new Integer(iStartPosY + 12), IStep, new Short(curtabindex++), new Integer(203) + new Integer(9), + "HID:" + curHelpID++, + soptMatchAny, + new Integer(iPosX), + new Integer(iPosY + 12), + IStep, + new Short(curtabindex++), + new Integer(203) }); getfilterstate(); + oControlRows = new ControlRow[FilterCount]; for (int i = 0; i < FilterCount; i++) { bEnabled = (i == 0); - oControlRows[i] = new ControlRow(iStartPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); - iStartPosY += 43; + oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3))); + iPosY += 43; } } catch (Exception exception) @@ -504,42 +585,51 @@ public class FilterComponent public void initialize(PropertyValue[][] _filterconditions, String[] _fieldnames) { - for (int i = 0; i < RowCount; i++) + // String aFieldNamesWithAdditionalEmpty[] = new String[_fieldnames.length + 1]; + // for (int i = 0; i < _fieldnames.length; i++) + // { + // aFieldNamesWithAdditionalEmpty[i] = _fieldnames[i]; + // } + // aFieldNamesWithAdditionalEmpty[_fieldnames.length] = ""; + + int i; + for (i = 0; i < RowCount; i++) { oControlRows[i].setFieldNames(_fieldnames); + // oControlRows[i].setFieldNames(aFieldNamesWithAdditionalEmpty); } this.filterconditions = _filterconditions; PropertyValue[] curfilterconditions; - int a; + // int a; if (_filterconditions.length == 1) { curfilterconditions = filterconditions[0]; - for (a = 0; a < curfilterconditions.length; a++) + for (i = 0; i < curfilterconditions.length; i++) { - oControlRows[a].setCondition(filterconditions[0][a]); + oControlRows[i].setCondition(filterconditions[0][i]); } } else { - for (a = 0; a < filterconditions.length; a++) + for (i = 0; i < filterconditions.length; i++) { - oControlRows[a].setCondition(filterconditions[a][0]); + oControlRows[i].setCondition(filterconditions[i][0]); } } - while (a < oControlRows.length) + while (i < oControlRows.length) { - oControlRows[a].settovoid(); + oControlRows[i].settovoid(); boolean bdoenable; - if (a > 0) + if (i > 0) { - bdoenable = oControlRows[a - 1].isComplete(); + bdoenable = oControlRows[i - 1].isConditionComplete(); } else { bdoenable = true; } - oControlRows[a].setEnabled(bdoenable); - a++; + oControlRows[i].setEnabled(bdoenable); + i++; } } @@ -557,73 +647,216 @@ public class FilterComponent } } + // ------------------------------------------------------------------------- + // + // + // ------------------------------------------------------------------------- + class ControlRow { + private final static int SOLSTFIELDNAME = 3; + private final static int SOLSTOPERATOR = 4; + private final static int SOTXTVALUE = 5; protected XInterface[] ControlElements = new XInterface[6]; - private boolean bEnabled; + private boolean m_bEnabled; String[] FieldNames; - protected ControlRow(int iCompPosY, int Index, boolean _bEnabled, int _firstRowHelpID) + protected ControlRow(int iCompPosX, int iCompPosY, int Index, boolean _bEnabled, int _firstRowHelpID) { + int nFieldWidth = 71; + int nOperatorWidth = 70; + int nValueWidth = 44; + + int nPosX1 = iCompPosX + 10; + int nPosX2 = iCompPosX + 10 + nFieldWidth + 6; // 87 + int nPosX3 = iCompPosX + 10 + nFieldWidth + 6 + nOperatorWidth + 6; + + try { String sCompSuffix = sIncSuffix + "_" + String.valueOf(Index + 1); - this.bEnabled = _bEnabled; + m_bEnabled = _bEnabled; + + // Label Field ControlElements[0] = (XInterface) CurUnoDialog.insertLabel("lblFieldNames" + sCompSuffix, new String[] { - "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Enabled", + "Height", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), new Integer(9), slblFieldNames, new Integer(iStartPosX + 10), new Integer(iCompPosY + 13), IStep, new Short(curtabindex++), new Integer(55) + new Boolean(isEnabled()), + new Integer(9), + slblFieldNames, + new Integer(nPosX1), + new Integer(iCompPosY + 13), + IStep, + new Short(curtabindex++), + new Integer(nFieldWidth) }); + + // Label Operator ControlElements[1] = (XInterface) CurUnoDialog.insertLabel("lblOperators" + sCompSuffix, new String[] { - "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Enabled", + "Height", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), new Integer(9), slblOperators, new Integer(iStartPosX + 87), new Integer(iCompPosY + 13), IStep, new Short(curtabindex++), new Integer(52) + new Boolean(isEnabled()), + new Integer(9), + slblOperators, + new Integer(nPosX2), + new Integer(iCompPosY + 13), + IStep, + new Short(curtabindex++), + new Integer(nOperatorWidth) }); + + // Label Value ControlElements[2] = (XInterface) CurUnoDialog.insertLabel("lblValue" + sCompSuffix, new String[] { - "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Enabled", + "Height", + "Label", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), new Integer(9), slblValue, new Integer(iStartPosX + 162), new Integer(iCompPosY + 13), IStep, new Short(curtabindex++), new Integer(44) + new Boolean(isEnabled()), + new Integer(9), + slblValue, + new Integer(nPosX3), + new Integer(iCompPosY + 13), + IStep, + new Short(curtabindex++), + new Integer(nValueWidth) }); - ControlElements[3] = (XInterface) CurUnoDialog.insertListBox("lstFieldName" + sCompSuffix, SO_FIELDNAMELIST[Index], null, new ItemListenerImpl(), + + // Listbox Fields + ControlElements[SOLSTFIELDNAME] = (XInterface) CurUnoDialog.insertListBox("lstFieldName" + sCompSuffix, SO_FIELDNAMELIST[Index], null, new ItemListenerImpl(), new String[] { - "Enabled", "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Enabled", + "Dropdown", + "Height", + "HelpURL", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), Boolean.TRUE, new Integer(13), "HID:" + _firstRowHelpID++, new Integer(iStartPosX + 10), new Integer(iCompPosY + 23), IStep, new Short(curtabindex++), new Integer(71) + new Boolean(isEnabled()), + Boolean.TRUE, + new Integer(13), + "HID:" + _firstRowHelpID++, + new Integer(nPosX1), + new Integer(iCompPosY + 23), + IStep, + new Short(curtabindex++), + new Integer(nFieldWidth) }); - ControlElements[4] = (XInterface) CurUnoDialog.insertListBox("lstOperator" + sCompSuffix, SO_CONDITIONLIST[Index], null, new ItemListenerImpl(), + + // Listbox Operators + ControlElements[SOLSTOPERATOR] = (XInterface) CurUnoDialog.insertListBox("lstOperator" + sCompSuffix, SO_CONDITIONLIST[Index], null, new ItemListenerImpl(), new String[] { - "Enabled", "Dropdown", "Height", "HelpURL", "LineCount", "PositionX", "PositionY", "Step", "StringItemList", "TabIndex", "Width" + "Enabled", + "Dropdown", + "Height", + "HelpURL", + "LineCount", + "PositionX", + "PositionY", + "Step", + "StringItemList", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), Boolean.TRUE, new Integer(13), "HID:" + _firstRowHelpID++, new Short((short) 7), new Integer(iStartPosX + 87), new Integer(iCompPosY + 23), IStep, sLogicOperators, new Short(curtabindex++), new Integer(70) + new Boolean(isEnabled()), + Boolean.TRUE, + new Integer(13), + "HID:" + _firstRowHelpID++, + new Short((short) sLogicOperators.length /* 7 */ ), + new Integer(nPosX2), + new Integer(iCompPosY + 23), + IStep, + sLogicOperators, + new Short(curtabindex++), + new Integer(nOperatorWidth) }); - ControlElements[5] = (XInterface) CurUnoDialog.insertFormattedField("txtValue" + sCompSuffix, SO_TEXTFIELDLIST[Index], new TextListenerImpl(), + ControlElements[SOTXTVALUE] = (XInterface) CurUnoDialog.insertFormattedField("txtValue" + sCompSuffix, SO_TEXTFIELDLIST[Index], new TextListenerImpl(), new String[] { - "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width" + "Enabled", + "Height", + "HelpURL", + "PositionX", + "PositionY", + "Step", + "TabIndex", + "Width" }, new Object[] { - new Boolean(bEnabled), new Integer(13), "HID:" + _firstRowHelpID++, new Integer(iStartPosX + 162), new Integer(iCompPosY + 23), IStep, new Short(curtabindex++), new Integer(44) + new Boolean(isEnabled()), + new Integer(13), + "HID:" + _firstRowHelpID++, + new Integer(nPosX3), + new Integer(iCompPosY + 23), + IStep, + new Short(curtabindex++), + new Integer(nValueWidth) }); + +// ControlElements[6] = CurUnoDialog.insertListBox((new StringBuilder()).append("lstBoolean").append(sCompSuffix).toString(), SO_BOOLEANLIST[Index], null, new ItemListenerImpl(), new String[] { +// "Enabled", +// "Dropdown", +// "Height", +// "HelpURL", +// "LineCount", +// "PositionX", "PositionY", +// "Step", +// "StringItemList", +// "TabIndex", +// "Width" +// }, new Object[] { +// new Boolean(bEnabled), +// Boolean.TRUE, +// new Integer(13), +// "HID:" + _firstRowHelpID++, +// new Short((short) 2), +// new Integer(nPosX3 + 44), new Integer(iCompPosY + 23), +// IStep, +// FilterComponent.sBooleanValues, +// new Short(curtabindex++), +// new Integer(nValueWidth) +// }); } catch (Exception exception) { @@ -631,15 +864,35 @@ public class FilterComponent } } - boolean isComplete() + /** + * @returns true if the current condition is complete, all needed fields are filled with values. + * So we can enable the next. + */ + boolean isConditionComplete() { try { short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), "SelectedItems")); if (SelFields.length > 0) { - short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); - if (SelOperator.length > 0) + int nSelOperator = getSelectedOperator(); + // short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); + if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL || /* is null */ + nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */ + { + // disable value field + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.FALSE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.FALSE); + + return true; + } + else + { + // enable value field + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.TRUE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.TRUE); + } + if (nSelOperator != -1) { Object oValue = Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue"); if (!AnyConverter.isVoid(oValue)) @@ -647,6 +900,13 @@ public class FilterComponent String sValue = (String.valueOf(oValue)); return (!sValue.equals("")); } +// String sBoolValue=""; +// short aSelectedBoolValue[] = (short[])Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[6]), "SelectedItems"); +// if (aSelectedBoolValue.length > 0) +// { +// sBoolValue = String.valueOf(aSelectedBoolValue[0] == 1); +// return !sBoolValue.equals(""); +// } } } return false; @@ -658,7 +918,7 @@ public class FilterComponent } } - public void fieldnamechanged(ItemEvent EventObject) + private void fieldnamechanged(ItemEvent EventObject) { int i = 0; } @@ -718,28 +978,27 @@ public class FilterComponent protected boolean isEnabled() { - return bEnabled; + return m_bEnabled; } - protected void settovoid() + private void settovoid() { CurUnoDialog.deselectListBox(ControlElements[SOLSTFIELDNAME]); CurUnoDialog.deselectListBox(ControlElements[SOLSTOPERATOR]); Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", com.sun.star.uno.Any.VOID); } - protected void setEnabled(boolean _bEnabled) + private void setEnabled(boolean _bEnabled) { + // enable all Controls Fieldname, operator, value for (int i = 0; i < ControlElements.length; i++) { Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[i]), "Enabled", new Boolean(_bEnabled)); } - bEnabled = _bEnabled; - if (bEnabled) + m_bEnabled = _bEnabled; + if (isEnabled()) { - short[] iselected = new short[] - { - }; + short[] iselected = new short[] {}; try { iselected = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); @@ -750,13 +1009,10 @@ public class FilterComponent } if ((iselected.length) == 0) { - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] - { - 0 - }); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[] { 0 }); } } - else if (!isComplete()) + else if (!isConditionComplete()) { CurUnoDialog.deselectListBox(ControlElements[SOLSTOPERATOR]); } @@ -777,12 +1033,37 @@ public class FilterComponent } // TODO: check if it is really useful to match the indices of the listbox the API constants + // =, <>, <, >, <=, >=, like, !like, is null, !is null protected short getSelectedOperator() { try { short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems")); - return SelFields[0]; + switch (SelFields[0]) + { + case 0: + return com.sun.star.sdb.SQLFilterOperator.EQUAL; + case 1: + return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL; + case 2: + return com.sun.star.sdb.SQLFilterOperator.LESS; + case 3: + return com.sun.star.sdb.SQLFilterOperator.GREATER; + case 4: + return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL; + case 5: + return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL; + case 6: + return com.sun.star.sdb.SQLFilterOperator.LIKE; + case 7: + return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE; + case 8: + return com.sun.star.sdb.SQLFilterOperator.SQLNULL; + case 9: + return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL; + default: + return -1; + } } catch (Exception exception) { @@ -833,7 +1114,8 @@ public class FilterComponent } } } -}// com.sun.star.sdb.SQLFilterOperator.EQUAL +} +// com.sun.star.sdb.SQLFilterOperator.EQUAL // com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL // com.sun.star.sdb.SQLFilterOperator.LESS // com.sun.star.sdb.SQLFilterOperator.GREATER diff --git a/wizards/com/sun/star/wizards/ui/SortingComponent.java b/wizards/com/sun/star/wizards/ui/SortingComponent.java index e3091d6c9599..f7fd075d6b4c 100644 --- a/wizards/com/sun/star/wizards/ui/SortingComponent.java +++ b/wizards/com/sun/star/wizards/ui/SortingComponent.java @@ -114,7 +114,7 @@ public class SortingComponent "Dropdown", "Enabled", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width" }, new Object[] { - new Boolean(true), new Boolean(bDoEnable), new Integer(12), HIDString, new Short("7"), "lstSort" + new Integer(i + 1), IListBoxPosX, new Integer(iCurPosY + 14), IStep, new Short(curtabindex++), IListBoxWidth + new Boolean(true), new Boolean(bDoEnable), new Integer(12), HIDString, new Short(UnoDialog.getListBoxLineCount()), "lstSort" + new Integer(i + 1), IListBoxPosX, new Integer(iCurPosY + 14), IStep, new Short(curtabindex++), IListBoxWidth }); //new Short((short) (17+i*4)) HIDString = "HID:" + Integer.toString(FirstHelpIndex + 1); diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java index 1425c3eadb53..256a28eff6b6 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.java +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java @@ -57,7 +57,7 @@ public class UnoDialog implements EventNames public XMultiServiceFactory MSFDialogModel; public XNameContainer xDlgNames; public XControlContainer xDlgContainer; - public XNameAccess xDlgNameAccess; + private XNameAccess m_xDlgNameAccess; public XControl xControl; public XDialog xDialog; public XReschedule xReschedule; @@ -95,7 +95,7 @@ public class UnoDialog implements EventNames xPSetDlg = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDialogModel); xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, xUnoDialog); xDlgNames = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xDialogModel); - xDlgNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDialogModel); + // xDlgNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDialogModel); xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xUnoDialog); xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xUnoDialog); @@ -141,17 +141,25 @@ public class UnoDialog implements EventNames return m_oPeerConfig; } + XNameAccess getDlgNameAccess() + { + if (m_xDlgNameAccess == null) + { + m_xDlgNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDialogModel); + } + return m_xDlgNameAccess; + } public void setControlProperty(String ControlName, String PropertyName, Object PropertyValue) { try { if (PropertyValue != null) { - if (xDlgNameAccess.hasByName(ControlName) == false) + if (getDlgNameAccess().hasByName(ControlName) == false) { return; } - Object xControlModel = xDlgNameAccess.getByName(ControlName); + Object xControlModel = getDlgNameAccess().getByName(ControlName); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); if (AnyConverter.isArray(PropertyValue)) { @@ -182,11 +190,11 @@ public class UnoDialog implements EventNames { if (PropertyValues != null) { - if (xDlgNameAccess.hasByName(ControlName) == false) + if (getDlgNameAccess().hasByName(ControlName) == false) { return; } - Object xControlModel = xDlgNameAccess.getByName(ControlName); + Object xControlModel = getDlgNameAccess().getByName(ControlName); XMultiPropertySet xMultiPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, xControlModel); xMultiPSet.setPropertyValues(PropertyNames, PropertyValues); } @@ -201,7 +209,7 @@ public class UnoDialog implements EventNames { try { - Object xControlModel = xDlgNameAccess.getByName(ControlName); + Object xControlModel = getDlgNameAccess().getByName(ControlName); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); Object oPropValue = xPSet.getPropertyValue(PropertyName); // if (AnyConverter.isArray(oPropValue)) @@ -220,7 +228,7 @@ public class UnoDialog implements EventNames { try { - Object xControlModel = xDlgNameAccess.getByName(ControlName); + Object xControlModel = getDlgNameAccess().getByName(ControlName); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); Property[] allProps = xPSet.getPropertySetInfo().getProperties(); for (int i = 0; i < allProps.length; i++) @@ -685,7 +693,7 @@ public class UnoDialog implements EventNames * * @param _xBasisListBox */ - public void deselectListBox(XInterface _xBasisListBox) + public static void deselectListBox(XInterface _xBasisListBox) { Object oListBoxModel = getModel(_xBasisListBox); Object sList = Helper.getUnoPropertyValue(oListBoxModel, "StringItemList"); @@ -1128,4 +1136,9 @@ public class UnoDialog implements EventNames return _surl; } } + + public static short getListBoxLineCount() + { + return (short)20; + } } diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java index d8194c085626..94c6117486c6 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog2.java +++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java @@ -190,7 +190,7 @@ public class UnoDialog2 extends UnoDialog implements EventNames public XControl insertInfoImage(int _posx, int _posy, int _iStep) { - XControl xImgControl = insertImage(Desktop.getUniqueName(xDlgNameAccess, "imgHint"), + XControl xImgControl = insertImage(Desktop.getUniqueName(getDlgNameAccess(), "imgHint"), new String[] { "Border", "Height", "ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "Width" diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java index 4fe94c5e3456..42cca588a5ce 100644 --- a/wizards/com/sun/star/wizards/ui/WizardDialog.java +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java @@ -645,8 +645,12 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL public abstract void finishWizard(); + /** + * This function will call if the finish button is pressed on the UI. + */ public void finishWizard_1() { + enableFinishButton(false); finishWizard(); removeTerminateListener(); } diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialog.java b/wizards/com/sun/star/wizards/web/WebWizardDialog.java index 089122bea457..18e0f2d01ace 100644 --- a/wizards/com/sun/star/wizards/web/WebWizardDialog.java +++ b/wizards/com/sun/star/wizards/web/WebWizardDialog.java @@ -290,7 +290,7 @@ public abstract class WebWizardDialog extends WizardDialog implements WebWizardC }, new Object[] { - Boolean.TRUE, INTEGER_12, "HID:" + HID1_LST_SESSIONS, new Short((short) 7), "lstLoadSettings", new Integer(97), new Integer(165), INTEGERS[1], new Short(tabIndex++), new Integer(173) + Boolean.TRUE, INTEGER_12, "HID:" + HID1_LST_SESSIONS, new Short((short) 14), "lstLoadSettings", new Integer(97), new Integer(165), INTEGERS[1], new Short(tabIndex++), new Integer(173) }); btnDelSession = insertButton("btnDelSession", BTNDELSESSION_ACTION_PERFORMED, new String[] @@ -372,7 +372,7 @@ public abstract class WebWizardDialog extends WizardDialog implements WebWizardC }, new Object[] { - Boolean.TRUE, INTEGER_12, "HID:" + HID2_LST_DOC_EXPORT, new Short((short) 7), "lstDocTargetType", new Integer(235), new Integer(38), INTEGERS[2], new Short(tabIndex++), new Integer(89) + Boolean.TRUE, INTEGER_12, "HID:" + HID2_LST_DOC_EXPORT, new Short((short) 14), "lstDocTargetType", new Integer(235), new Integer(38), INTEGERS[2], new Short(tabIndex++), new Integer(89) }); @@ -561,7 +561,7 @@ public abstract class WebWizardDialog extends WizardDialog implements WebWizardC }, new Object[] { - Boolean.TRUE, INTEGER_12, "HID:" + HID5_LST_STYLES, new Short((short) 7), "lstStyles", new Integer(179), new Integer(26), INTEGERS[5], new Short((short) 52), new Integer(145) + Boolean.TRUE, INTEGER_12, "HID:" + HID5_LST_STYLES, new Short((short) 14), "lstStyles", new Integer(179), new Integer(26), INTEGERS[5], new Short((short) 52), new Integer(145) }); insertLabel("lblBackground", PROPNAMES_LBL, @@ -876,7 +876,7 @@ public abstract class WebWizardDialog extends WizardDialog implements WebWizardC }, new Object[] { - Boolean.TRUE, Boolean.TRUE, INTEGER_12, "HID:" + HID7_TXT_SAVE, new Short((short) 7), "txtSaveSettings", new Integer(179), new Integer(167), INTEGERS[7], new Short(tabIndex++), new Integer(145) + Boolean.TRUE, Boolean.TRUE, INTEGER_12, "HID:" + HID7_TXT_SAVE, new Short((short) 14), "txtSaveSettings", new Integer(179), new Integer(167), INTEGERS[7], new Short(tabIndex++), new Integer(145) }); } diff --git a/wizards/source/formwizard/dbwizres.src b/wizards/source/formwizard/dbwizres.src index e0a563f81db2..d3b04cd8593d 100644 --- a/wizards/source/formwizard/dbwizres.src +++ b/wizards/source/formwizard/dbwizres.src @@ -777,7 +777,9 @@ String RID_DB_QUERY_WIZARD_START + 25 Text [ en-US] = "Value"; }; - +// -------------------------------------- +// don't change anything to the next 10 values +// they are list elements and need to be as follows String RID_DB_QUERY_WIZARD_START + 26 { Text [ en-US] = "is equal to"; @@ -799,7 +801,6 @@ String RID_DB_QUERY_WIZARD_START + 29 Text [ en-US] = "is greater than"; }; - String RID_DB_QUERY_WIZARD_START + 30 { Text [ en-US] = "is equal or less than "; @@ -817,11 +818,37 @@ String RID_DB_QUERY_WIZARD_START + 32 String RID_DB_QUERY_WIZARD_START + 33 { - Text [ en-US] = "and"; + Text [ en-US] = "not like"; }; String RID_DB_QUERY_WIZARD_START + 34 { + Text [ en-US] = "is null"; +}; + +String RID_DB_QUERY_WIZARD_START + 35 +{ + Text [ en-US] = "is not null"; +}; +// -------------------------------------- + +String RID_DB_QUERY_WIZARD_START + 36 +{ + Text [ en-US] = "true"; +}; + +String RID_DB_QUERY_WIZARD_START + 37 +{ + Text [ en-US] = "false"; +}; + +String RID_DB_QUERY_WIZARD_START + 38 +{ + Text [ en-US] = "and"; +}; + +String RID_DB_QUERY_WIZARD_START + 39 +{ Text [ en-US] = "or"; }; |