LCOV - code coverage report
Current view: top level - libreoffice/forms/source/component - DatabaseForm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 272 1900 14.3 %
Date: 2012-12-27 Functions: 42 185 22.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "componenttools.hxx"
      22             : #include "DatabaseForm.hxx"
      23             : #include "EventThread.hxx"
      24             : #include "frm_module.hxx"
      25             : #include "frm_resource.hrc"
      26             : #include "frm_resource.hxx"
      27             : #include "GroupManager.hxx"
      28             : #include "property.hrc"
      29             : #include "property.hxx"
      30             : #include "services.hxx"
      31             : 
      32             : #include <com/sun/star/awt/XControlContainer.hpp>
      33             : #include <com/sun/star/awt/XTextComponent.hpp>
      34             : #include <com/sun/star/form/DataSelectionType.hpp>
      35             : #include <com/sun/star/form/FormComponentType.hpp>
      36             : #include <com/sun/star/form/TabulatorCycle.hpp>
      37             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      38             : #include <com/sun/star/frame/XDispatch.hpp>
      39             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      40             : #include <com/sun/star/frame/XModel.hpp>
      41             : #include <com/sun/star/io/XObjectInputStream.hpp>
      42             : #include <com/sun/star/io/XObjectOutputStream.hpp>
      43             : #include <com/sun/star/sdb/CommandType.hpp>
      44             : #include <com/sun/star/sdb/RowSetVetoException.hpp>
      45             : #include <com/sun/star/sdb/SQLContext.hpp>
      46             : #include <com/sun/star/sdb/XColumnUpdate.hpp>
      47             : #include <com/sun/star/sdbc/DataType.hpp>
      48             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      49             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      50             : #include <com/sun/star/sdbc/XRowSet.hpp>
      51             : #include <com/sun/star/sdbcx/Privilege.hpp>
      52             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      53             : #include <com/sun/star/util/XCancellable.hpp>
      54             : #include <com/sun/star/util/URLTransformer.hpp>
      55             : #include <com/sun/star/util/XURLTransformer.hpp>
      56             : #include <com/sun/star/util/XModifiable2.hpp>
      57             : 
      58             : #include <comphelper/basicio.hxx>
      59             : #include <comphelper/container.hxx>
      60             : #include <comphelper/enumhelper.hxx>
      61             : #include <comphelper/extract.hxx>
      62             : #include <comphelper/processfactory.hxx>
      63             : #include <comphelper/seqstream.hxx>
      64             : #include <comphelper/sequence.hxx>
      65             : #include <comphelper/stl_types.hxx>
      66             : #include <comphelper/uno3.hxx>
      67             : #include <connectivity/dbtools.hxx>
      68             : #include <cppuhelper/exc_hlp.hxx>
      69             : #include <cppuhelper/implbase2.hxx>
      70             : #include <rtl/math.hxx>
      71             : #include <rtl/tencinfo.h>
      72             : #include <svl/inetstrm.hxx>
      73             : #include <svl/inettype.hxx>
      74             : #include <tools/debug.hxx>
      75             : #include <tools/diagnose_ex.h>
      76             : #include <tools/fsys.hxx>
      77             : #include <tools/inetmsg.hxx>
      78             : #include <tools/urlobj.hxx>
      79             : #include <unotools/ucblockbytes.hxx>
      80             : #include <unotools/ucbstreamhelper.hxx>
      81             : #include <vcl/svapp.hxx>
      82             : #include <vcl/timer.hxx>
      83             : #include <osl/mutex.hxx>
      84             : 
      85             : #include <ctype.h>
      86             : #include <boost/unordered_map.hpp>
      87             : 
      88             : // compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ...
      89             : namespace com {
      90             : namespace sun {
      91             : namespace star {
      92             : namespace data {
      93             : 
      94             : enum DatabaseCursorType
      95             : {
      96             :     DatabaseCursorType_FORWARD = 0,
      97             :     DatabaseCursorType_SNAPSHOT = 1,
      98             :     DatabaseCursorType_KEYSET = 2,
      99             :     DatabaseCursorType_DYNAMIC = 3,
     100             :     DatabaseCursorType_MAKE_FIXED_SIZE = SAL_MAX_ENUM
     101             : };
     102             : 
     103             : } } } }
     104             : 
     105             : using namespace ::dbtools;
     106             : using namespace ::comphelper;
     107             : using namespace ::com::sun::star::uno;
     108             : using namespace ::com::sun::star::sdb;
     109             : using namespace ::com::sun::star::sdbc;
     110             : using namespace ::com::sun::star::sdbcx;
     111             : using namespace ::com::sun::star::beans;
     112             : using namespace ::com::sun::star::container;
     113             : using namespace ::com::sun::star::task;
     114             : using namespace ::com::sun::star::frame;
     115             : using namespace ::com::sun::star::form;
     116             : using namespace ::com::sun::star::awt;
     117             : using namespace ::com::sun::star::io;
     118             : using namespace ::com::sun::star::lang;
     119             : using namespace ::com::sun::star::data;
     120             : using namespace ::com::sun::star::util;
     121             : 
     122             : //--------------------------------------------------------------------------
     123           3 : extern "C" void SAL_CALL createRegistryInfo_ODatabaseForm()
     124             : {
     125           3 :     static ::frm::OMultiInstanceAutoRegistration< ::frm::ODatabaseForm > aAutoRegistration;
     126           3 : }
     127             : 
     128             : //.........................................................................
     129             : namespace frm
     130             : {
     131             : //.........................................................................
     132             : 
     133             : //==================================================================
     134             : //= DocumentModifyGuard
     135             : //==================================================================
     136             : class DocumentModifyGuard
     137             : {
     138             : public:
     139           0 :     DocumentModifyGuard( const Reference< XInterface >& _rxFormComponent )
     140           0 :         :m_xDocumentModify( getXModel( _rxFormComponent ), UNO_QUERY )
     141             :     {
     142           0 :         impl_changeModifiableFlag_nothrow( false );
     143           0 :     }
     144           0 :     ~DocumentModifyGuard()
     145           0 :     {
     146           0 :         impl_changeModifiableFlag_nothrow( true );
     147           0 :     }
     148             : 
     149             : private:
     150           0 :     void    impl_changeModifiableFlag_nothrow( const bool _enable )
     151             :     {
     152             :         try
     153             :         {
     154           0 :             if ( m_xDocumentModify.is() )
     155           0 :                 _enable ? m_xDocumentModify->enableSetModified() : m_xDocumentModify->disableSetModified();
     156             :         }
     157           0 :         catch(const Exception&)
     158             :         {
     159             :             DBG_UNHANDLED_EXCEPTION();
     160             :         }
     161           0 :     }
     162             : 
     163             : private:
     164             :     Reference< XModifiable2 >   m_xDocumentModify;
     165             : };
     166             : 
     167             : //==================================================================
     168             : //= OFormSubmitResetThread
     169             : //=-----------------------------------------------------------------
     170             : //= submitting and resetting html-forms asynchronously
     171             : //==================================================================
     172             : 
     173             : //------------------------------------------------------------------
     174           0 : class OFormSubmitResetThread: public OComponentEventThread
     175             : {
     176             : protected:
     177             : 
     178             :     // duplicate an event with respect to it's type
     179             :     virtual EventObject *cloneEvent( const EventObject *pEvt ) const;
     180             : 
     181             :     // process an event. while processing the mutex isn't locked, and pCompImpl
     182             :     // is made sure to remain valid
     183             :     virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl,
     184             :                                const EventObject* _pEvt,
     185             :                                const Reference<XControl>& _rControl,
     186             :                                sal_Bool _bSubmit);
     187             : 
     188             : public:
     189             : 
     190           0 :     OFormSubmitResetThread(ODatabaseForm* pControl) : OComponentEventThread(pControl) { }
     191             : };
     192             : 
     193             : //------------------------------------------------------------------
     194           0 : EventObject* OFormSubmitResetThread::cloneEvent(
     195             :         const EventObject *pEvt ) const
     196             : {
     197           0 :     return new ::com::sun::star::awt::MouseEvent( *(::com::sun::star::awt::MouseEvent *)pEvt );
     198             : }
     199             : 
     200             : //------------------------------------------------------------------
     201           0 : void OFormSubmitResetThread::processEvent(
     202             :         ::cppu::OComponentHelper* pCompImpl,
     203             :         const EventObject *_pEvt,
     204             :         const Reference<XControl>& _rControl,
     205             :         sal_Bool _bSubmit)
     206             : {
     207           0 :     if (_bSubmit)
     208           0 :         ((ODatabaseForm *)pCompImpl)->submit_impl(_rControl, *static_cast<const ::com::sun::star::awt::MouseEvent*>(_pEvt), true);
     209             :     else
     210           0 :         ((ODatabaseForm *)pCompImpl)->reset_impl(true);
     211           0 : }
     212             : 
     213             : //==================================================================
     214             : //= ODatabaseForm
     215             : //==================================================================
     216             : 
     217             : //------------------------------------------------------------------
     218           4 : Reference< XInterface > SAL_CALL ODatabaseForm::Create( const Reference< XMultiServiceFactory >& _rxFactory )
     219             : {
     220           4 :     return *( new ODatabaseForm( _rxFactory ) );
     221             : }
     222             : 
     223             : //------------------------------------------------------------------------------
     224           0 : Sequence<sal_Int8> SAL_CALL ODatabaseForm::getImplementationId() throw(RuntimeException)
     225             : {
     226           0 :     return OImplementationIds::getImplementationId(getTypes());
     227             : }
     228             : 
     229             : //------------------------------------------------------------------
     230           0 : Sequence<Type> SAL_CALL ODatabaseForm::getTypes() throw(RuntimeException)
     231             : {
     232             :     // ask the aggregate
     233           0 :     Sequence<Type> aAggregateTypes;
     234           0 :     Reference<XTypeProvider> xAggregateTypes;
     235           0 :     if (query_aggregation(m_xAggregate, xAggregateTypes))
     236           0 :         aAggregateTypes = xAggregateTypes->getTypes();
     237             : 
     238             :     Sequence< Type > aRet = concatSequences(
     239             :         aAggregateTypes, ODatabaseForm_BASE1::getTypes(), OFormComponents::getTypes()
     240           0 :     );
     241           0 :     aRet = concatSequences( aRet, ODatabaseForm_BASE2::getTypes(), ODatabaseForm_BASE3::getTypes() );
     242           0 :     return concatSequences( aRet, OPropertySetAggregationHelper::getTypes() );
     243             : }
     244             : 
     245             : //------------------------------------------------------------------
     246         295 : Any SAL_CALL ODatabaseForm::queryAggregation(const Type& _rType) throw(RuntimeException)
     247             : {
     248         295 :     Any aReturn = ODatabaseForm_BASE1::queryInterface(_rType);
     249             :     // our own interfaces
     250         295 :     if (!aReturn.hasValue())
     251             :     {
     252         132 :         aReturn = ODatabaseForm_BASE2::queryInterface(_rType);
     253             :         // property set related interfaces
     254         132 :         if (!aReturn.hasValue())
     255             :         {
     256         131 :             aReturn = OPropertySetAggregationHelper::queryInterface(_rType);
     257             : 
     258             :             // form component collection related interfaces
     259         131 :             if (!aReturn.hasValue())
     260             :             {
     261         101 :                 aReturn = OFormComponents::queryAggregation(_rType);
     262             : 
     263             :                 // interfaces already present in the aggregate which we want to reroute
     264             :                 // only available if we could create the aggregate
     265         101 :                 if (!aReturn.hasValue() && m_xAggregateAsRowSet.is())
     266          22 :                     aReturn = ODatabaseForm_BASE3::queryInterface(_rType);
     267             : 
     268             :                 // aggregate interfaces
     269             :                 // (ask the aggregated object _after_ the OComponentHelper (base of OFormComponents),
     270             :                 // so calls to the XComponent interface reach us and not the aggreagtion)
     271         101 :                 if (!aReturn.hasValue() && m_xAggregate.is())
     272          17 :                     aReturn = m_xAggregate->queryAggregation(_rType);
     273             :             }
     274             :         }
     275             :     }
     276             : 
     277         295 :     return aReturn;
     278             : }
     279             : 
     280             : DBG_NAME(ODatabaseForm);
     281             : //------------------------------------------------------------------
     282           4 : ODatabaseForm::ODatabaseForm(const Reference<XMultiServiceFactory>& _rxFactory)
     283             :     :OFormComponents(_rxFactory)
     284             :     ,OPropertySetAggregationHelper(OComponentHelper::rBHelper)
     285             :     ,OPropertyChangeListener(m_aMutex)
     286             :     ,m_aLoadListeners(m_aMutex)
     287             :     ,m_aRowSetApproveListeners(m_aMutex)
     288             :     ,m_aRowSetListeners(m_aMutex)
     289             :     ,m_aSubmitListeners(m_aMutex)
     290             :     ,m_aErrorListeners(m_aMutex)
     291             :     ,m_aResetListeners( *this, m_aMutex )
     292             :     ,m_aPropertyBagHelper( *this )
     293             :     ,m_pAggregatePropertyMultiplexer(NULL)
     294             :     ,m_pGroupManager( NULL )
     295             :     ,m_aParameterManager( m_aMutex, comphelper::getComponentContext(_rxFactory) )
     296             :     ,m_aFilterManager( _rxFactory )
     297             :     ,m_pLoadTimer(NULL)
     298             :     ,m_pThread(NULL)
     299             :     ,m_nResetsPending(0)
     300             :     ,m_nPrivileges(0)
     301             :     ,m_bInsertOnly( sal_False )
     302             :     ,m_eSubmitMethod(FormSubmitMethod_GET)
     303             :     ,m_eSubmitEncoding(FormSubmitEncoding_URL)
     304             :     ,m_eNavigation(NavigationBarMode_CURRENT)
     305             :     ,m_bAllowInsert(sal_True)
     306             :     ,m_bAllowUpdate(sal_True)
     307             :     ,m_bAllowDelete(sal_True)
     308             :     ,m_bLoaded(sal_False)
     309             :     ,m_bSubForm(sal_False)
     310             :     ,m_bForwardingConnection(sal_False)
     311           4 :     ,m_bSharingConnection( sal_False )
     312             : {
     313             :     DBG_CTOR( ODatabaseForm, NULL );
     314           4 :     impl_construct();
     315           4 : }
     316             : 
     317             : //------------------------------------------------------------------
     318           0 : ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource )
     319             :     :OFormComponents( _cloneSource )
     320             :     ,OPropertySetAggregationHelper( OComponentHelper::rBHelper )
     321             :     ,OPropertyChangeListener( m_aMutex )
     322             :     ,ODatabaseForm_BASE1()
     323             :     ,ODatabaseForm_BASE2()
     324             :     ,ODatabaseForm_BASE3()
     325             :     ,IPropertyBagHelperContext()
     326             :     ,m_aLoadListeners( m_aMutex )
     327             :     ,m_aRowSetApproveListeners( m_aMutex )
     328             :     ,m_aRowSetListeners( m_aMutex )
     329             :     ,m_aSubmitListeners( m_aMutex )
     330             :     ,m_aErrorListeners( m_aMutex )
     331             :     ,m_aResetListeners( *this, m_aMutex )
     332             :     ,m_aPropertyBagHelper( *this )
     333             :     ,m_pAggregatePropertyMultiplexer( NULL )
     334             :     ,m_pGroupManager( NULL )
     335             :     ,m_aParameterManager( m_aMutex, comphelper::getComponentContext(_cloneSource.m_xServiceFactory) )
     336             :     ,m_aFilterManager( _cloneSource.m_xServiceFactory )
     337             :     ,m_pLoadTimer( NULL )
     338             :     ,m_pThread( NULL )
     339             :     ,m_nResetsPending( 0 )
     340             :     ,m_nPrivileges( 0 )
     341             :     ,m_bInsertOnly( _cloneSource.m_bInsertOnly )
     342             :     ,m_aControlBorderColorFocus( _cloneSource.m_aControlBorderColorFocus )
     343             :     ,m_aControlBorderColorMouse( _cloneSource.m_aControlBorderColorMouse )
     344             :     ,m_aControlBorderColorInvalid( _cloneSource.m_aControlBorderColorInvalid )
     345             :     ,m_aDynamicControlBorder( _cloneSource.m_aDynamicControlBorder )
     346             :     ,m_sName( _cloneSource.m_sName )
     347             :     ,m_aTargetURL( _cloneSource.m_aTargetURL )
     348             :     ,m_aTargetFrame( _cloneSource.m_aTargetFrame )
     349             :     ,m_eSubmitMethod( _cloneSource.m_eSubmitMethod )
     350             :     ,m_eSubmitEncoding( _cloneSource.m_eSubmitEncoding )
     351             :     ,m_eNavigation( _cloneSource.m_eNavigation )
     352             :     ,m_bAllowInsert( _cloneSource.m_bAllowInsert )
     353             :     ,m_bAllowUpdate( _cloneSource.m_bAllowUpdate )
     354             :     ,m_bAllowDelete( _cloneSource.m_bAllowDelete )
     355             :     ,m_bLoaded( sal_False )
     356             :     ,m_bSubForm( sal_False )
     357             :     ,m_bForwardingConnection( sal_False )
     358           0 :     ,m_bSharingConnection( sal_False )
     359             : {
     360             :     DBG_CTOR( ODatabaseForm, NULL );
     361             : 
     362           0 :     impl_construct();
     363             : 
     364           0 :     osl_atomic_increment( &m_refCount );
     365             :     {
     366             :         // our aggregated rowset itself is not cloneable, so simply copy the properties
     367           0 :         ::comphelper::copyProperties( _cloneSource.m_xAggregateSet, m_xAggregateSet );
     368             : 
     369             :         // also care for the dynamic properties: If the clone source has properties which we do not have,
     370             :         // then add them
     371             :         try
     372             :         {
     373             :             Reference< XPropertySet > xSourceProps( const_cast< ODatabaseForm& >( _cloneSource ).queryAggregation(
     374           0 :                 XPropertySet::static_type() ), UNO_QUERY_THROW );
     375           0 :             Reference< XPropertySetInfo > xSourcePSI( xSourceProps->getPropertySetInfo(), UNO_SET_THROW );
     376           0 :             Reference< XPropertyState > xSourcePropState( xSourceProps, UNO_QUERY );
     377             : 
     378           0 :             Reference< XPropertySetInfo > xDestPSI( getPropertySetInfo(), UNO_QUERY_THROW );
     379             : 
     380           0 :             Sequence< Property > aSourceProperties( xSourcePSI->getProperties() );
     381           0 :             for (   const Property* pSourceProperty = aSourceProperties.getConstArray();
     382           0 :                     pSourceProperty != aSourceProperties.getConstArray() + aSourceProperties.getLength();
     383             :                     ++pSourceProperty
     384             :                 )
     385             :             {
     386           0 :                 if ( xDestPSI->hasPropertyByName( pSourceProperty->Name ) )
     387           0 :                     continue;
     388             : 
     389             :                 // the initial value passed to XPropertyContainer is also used as default, usually. So, try
     390             :                 // to retrieve the default of the source property
     391           0 :                 Any aInitialValue;
     392           0 :                 if ( xSourcePropState.is() )
     393             :                 {
     394           0 :                     aInitialValue = xSourcePropState->getPropertyDefault( pSourceProperty->Name );
     395             :                 }
     396             :                 else
     397             :                 {
     398           0 :                     aInitialValue = xSourceProps->getPropertyValue( pSourceProperty->Name );
     399             :                 }
     400           0 :                 addProperty( pSourceProperty->Name, pSourceProperty->Attributes, aInitialValue );
     401           0 :                 setPropertyValue( pSourceProperty->Name, xSourceProps->getPropertyValue( pSourceProperty->Name ) );
     402           0 :             }
     403             :         }
     404           0 :         catch(const Exception&)
     405             :         {
     406             :             throw WrappedTargetException(
     407             :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not clone the given database form." ) ),
     408             :                 *const_cast< ODatabaseForm* >( &_cloneSource ),
     409             :                 ::cppu::getCaughtException()
     410           0 :             );
     411             :         }
     412             :     }
     413           0 :     osl_atomic_decrement( &m_refCount );
     414           0 : }
     415             : 
     416             : //------------------------------------------------------------------
     417           4 : void ODatabaseForm::impl_construct()
     418             : {
     419             :     // aggregate a row set
     420           4 :     increment(m_refCount);
     421             :     {
     422           4 :         m_xAggregate = Reference< XAggregation >( m_xServiceFactory->createInstance( SRV_SDB_ROWSET ), UNO_QUERY_THROW );
     423           4 :         m_xAggregateAsRowSet.set( m_xAggregate, UNO_QUERY_THROW );
     424           4 :         setAggregation( m_xAggregate );
     425             :     }
     426             : 
     427             :     // listen for the properties, important for Parameters
     428           4 :     if ( m_xAggregateSet.is() )
     429             :     {
     430           4 :         m_pAggregatePropertyMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet, sal_False);
     431           4 :         m_pAggregatePropertyMultiplexer->acquire();
     432           4 :         m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_COMMAND);
     433           4 :         m_pAggregatePropertyMultiplexer->addProperty(PROPERTY_ACTIVE_CONNECTION);
     434             :     }
     435             : 
     436             :     {
     437           4 :         Reference< XWarningsSupplier > xRowSetWarnings( m_xAggregate, UNO_QUERY );
     438           4 :         m_aWarnings.setExternalWarnings( xRowSetWarnings );
     439             :     }
     440             : 
     441           4 :     if ( m_xAggregate.is() )
     442             :     {
     443           4 :         m_xAggregate->setDelegator( static_cast< XWeak* >( this ) );
     444             :     }
     445             : 
     446             :     {
     447           4 :         m_aFilterManager.initialize( m_xAggregateSet );
     448           4 :         m_aParameterManager.initialize( this, m_xAggregate );
     449             : 
     450           4 :         declareForwardedProperty( PROPERTY_ID_ACTIVE_CONNECTION );
     451             :     }
     452           4 :     decrement( m_refCount );
     453             : 
     454           4 :     m_pGroupManager = new OGroupManager( this );
     455           4 :     m_pGroupManager->acquire();
     456           4 : }
     457             : 
     458             : //------------------------------------------------------------------
     459           6 : ODatabaseForm::~ODatabaseForm()
     460             : {
     461             :     DBG_DTOR(ODatabaseForm,NULL);
     462             : 
     463           2 :     m_pGroupManager->release();
     464           2 :     m_pGroupManager = NULL;
     465             : 
     466           2 :     if (m_xAggregate.is())
     467           2 :         m_xAggregate->setDelegator( NULL );
     468             : 
     469           2 :     m_aWarnings.setExternalWarnings( NULL );
     470             : 
     471           2 :     if (m_pAggregatePropertyMultiplexer)
     472             :     {
     473           2 :         m_pAggregatePropertyMultiplexer->dispose();
     474           2 :         m_pAggregatePropertyMultiplexer->release();
     475           2 :         m_pAggregatePropertyMultiplexer = NULL;
     476             :     }
     477           4 : }
     478             : 
     479             : //==============================================================================
     480             : // html tools
     481             : //------------------------------------------------------------------------
     482           0 : ::rtl::OUString ODatabaseForm::GetDataURLEncoded(const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt)
     483             : {
     484           0 :     return GetDataEncoded(true,SubmitButton,MouseEvt);
     485             : }
     486             : // -----------------------------------------------------------------------------
     487           0 : ::rtl::OUString ODatabaseForm::GetDataEncoded(bool _bURLEncoded,const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt)
     488             : {
     489             :     // Fill List of successful Controls
     490           0 :     HtmlSuccessfulObjList aSuccObjList;
     491           0 :     FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
     492             : 
     493             : 
     494             :     // Aggregate Liste to ::rtl::OUString
     495           0 :     ::rtl::OUStringBuffer aResult;
     496           0 :     ::rtl::OUString aName;
     497           0 :     ::rtl::OUString aValue;
     498             : 
     499           0 :     for (   HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
     500           0 :             pSuccObj < aSuccObjList.end();
     501             :             ++pSuccObj
     502             :         )
     503             :     {
     504           0 :         aName = pSuccObj->aName;
     505           0 :         aValue = pSuccObj->aValue;
     506           0 :         if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && !aValue.isEmpty() )
     507             :         {
     508             :             // For File URLs we transfer the file name and not a URL, because Netscape does it like that
     509           0 :             INetURLObject aURL;
     510           0 :             aURL.SetSmartProtocol(INET_PROT_FILE);
     511           0 :             aURL.SetSmartURL(aValue);
     512           0 :             if( INET_PROT_FILE == aURL.GetProtocol() )
     513           0 :                 aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
     514             :         }
     515           0 :         Encode( aName );
     516           0 :         Encode( aValue );
     517             : 
     518           0 :         aResult.append(aName);
     519           0 :         aResult.append(sal_Unicode('='));
     520           0 :         aResult.append(aValue);
     521             : 
     522           0 :         if (pSuccObj < aSuccObjList.end() - 1)
     523             :         {
     524           0 :             if ( _bURLEncoded )
     525           0 :                 aResult.append(sal_Unicode('&'));
     526             :             else
     527           0 :                 aResult.appendAscii("\r\n");
     528             :         }
     529             :     }
     530             : 
     531             : 
     532           0 :     aSuccObjList.clear();
     533             : 
     534           0 :     return aResult.makeStringAndClear();
     535             : }
     536             : 
     537             : //==============================================================================
     538             : // html tools
     539             : //------------------------------------------------------------------------
     540           0 : ::rtl::OUString ODatabaseForm::GetDataTextEncoded(const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt)
     541             : {
     542           0 :     return GetDataEncoded(false,SubmitButton,MouseEvt);
     543             : }
     544             : 
     545             : //------------------------------------------------------------------------
     546           0 : Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XControl>& SubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt, ::rtl::OUString& rContentType)
     547             : {
     548             : 
     549             :     // Create Parent
     550           0 :     INetMIMEMessage aParent;
     551           0 :     aParent.EnableAttachChild( INETMSG_MULTIPART_FORM_DATA );
     552             : 
     553             : 
     554             :     // Fill List of successful Controls
     555           0 :     HtmlSuccessfulObjList aSuccObjList;
     556           0 :     FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt );
     557             : 
     558             : 
     559             :     // Aggregate Liste to ::rtl::OUString
     560           0 :     ::rtl::OUString aResult;
     561           0 :     for (   HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin();
     562           0 :             pSuccObj < aSuccObjList.end();
     563             :             ++pSuccObj
     564             :         )
     565             :     {
     566           0 :         if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_TEXT )
     567           0 :             InsertTextPart( aParent, pSuccObj->aName, pSuccObj->aValue );
     568           0 :         else if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE )
     569           0 :             InsertFilePart( aParent, pSuccObj->aName, pSuccObj->aValue );
     570             :     }
     571             : 
     572             : 
     573             :     // Delete List
     574           0 :     aSuccObjList.clear();
     575             : 
     576             :     // Create MessageStream for parent
     577           0 :     INetMIMEMessageStream aMessStream;
     578           0 :     aMessStream.SetSourceMessage( &aParent );
     579           0 :     aMessStream.GenerateHeader( sal_False );
     580             : 
     581             :     // Copy MessageStream to SvStream
     582           0 :     SvMemoryStream aMemStream;
     583           0 :     char* pBuf = new char[1025];
     584             :     int nRead;
     585           0 :     while( (nRead = aMessStream.Read(pBuf, 1024)) > 0 )
     586           0 :         aMemStream.Write( pBuf, nRead );
     587           0 :     delete[] pBuf;
     588             : 
     589           0 :     aMemStream.Flush();
     590           0 :     aMemStream.Seek( 0 );
     591           0 :     void* pData = (void*)aMemStream.GetData();
     592           0 :     sal_Int32 nLen = aMemStream.Seek(STREAM_SEEK_TO_END);
     593             : 
     594           0 :     rContentType = aParent.GetContentType();
     595           0 :     return Sequence<sal_Int8>((sal_Int8*)pData, nLen);
     596             : }
     597             : 
     598             : //------------------------------------------------------------------------
     599             : namespace
     600             : {
     601           0 :     static void appendDigits( sal_Int32 _nNumber, sal_Int8 nDigits, ::rtl::OUStringBuffer& _rOut )
     602             :     {
     603           0 :         sal_Int32 nCurLen = _rOut.getLength();
     604           0 :         _rOut.append( _nNumber );
     605           0 :         while ( _rOut.getLength() - nCurLen < nDigits )
     606           0 :             _rOut.insert( nCurLen, (sal_Unicode)'0' );
     607           0 :     }
     608             : }
     609             : 
     610             : //------------------------------------------------------------------------
     611           0 : void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const Reference<XPropertySet>& xComponentSet, const ::rtl::OUString& rNamePrefix,
     612             :                      const Reference<XControl>& rxSubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt)
     613             : {
     614           0 :     if (!xComponentSet.is())
     615             :         return;
     616             : 
     617             :     // MIB 25.6.98: Catch nested Forms; or would we need to submit them?
     618           0 :     if (!hasProperty(PROPERTY_CLASSID, xComponentSet))
     619             :         return;
     620             : 
     621             :     // Get names
     622           0 :     if (!hasProperty(PROPERTY_NAME, xComponentSet))
     623             :         return;
     624             : 
     625           0 :     sal_Int16 nClassId = 0;
     626           0 :     xComponentSet->getPropertyValue(PROPERTY_CLASSID) >>= nClassId;
     627           0 :     ::rtl::OUString aName;
     628           0 :     xComponentSet->getPropertyValue( PROPERTY_NAME ) >>= aName;
     629           0 :     if( aName.isEmpty() && nClassId != FormComponentType::IMAGEBUTTON)
     630             :         return;
     631             :     else    // Extend name with the prefix
     632           0 :         aName = rNamePrefix + aName;
     633             : 
     634           0 :     switch( nClassId )
     635             :     {
     636             :         // Buttons
     637             :         case FormComponentType::COMMANDBUTTON:
     638             :         {
     639             :             // We only evaluate the pressed Submit button
     640             :             // MIB: If one is passed at all
     641           0 :             if( rxSubmitButton.is() )
     642             :             {
     643           0 :                 Reference<XPropertySet>  xSubmitButtonComponent(rxSubmitButton->getModel(), UNO_QUERY);
     644           0 :                 if (xSubmitButtonComponent == xComponentSet && hasProperty(PROPERTY_LABEL, xComponentSet))
     645             :                 {
     646             :                     // <name>=<label>
     647           0 :                     ::rtl::OUString aLabel;
     648           0 :                     xComponentSet->getPropertyValue( PROPERTY_LABEL ) >>= aLabel;
     649           0 :                     rList.push_back( HtmlSuccessfulObj(aName, aLabel) );
     650           0 :                 }
     651             :             }
     652           0 :         } break;
     653             : 
     654             :         // ImageButtons
     655             :         case FormComponentType::IMAGEBUTTON:
     656             :         {
     657             :             // We only evaluate the pressed Submit button
     658             :             // MIB: If one is passed at all
     659           0 :             if( rxSubmitButton.is() )
     660             :             {
     661           0 :                 Reference<XPropertySet>  xSubmitButtonComponent(rxSubmitButton->getModel(), UNO_QUERY);
     662           0 :                 if (xSubmitButtonComponent == xComponentSet)
     663             :                 {
     664             :                     // <name>.x=<pos.X>&<name>.y=<pos.Y>
     665           0 :                     ::rtl::OUString aRhs = ::rtl::OUString::valueOf( MouseEvt.X );
     666             : 
     667             :                     // Only if a name is available we have a name.x
     668           0 :                     rtl::OUStringBuffer aLhs(aName);
     669           0 :                     if (!aName.isEmpty())
     670           0 :                         aLhs.append(".x");
     671             :                     else
     672           0 :                         aLhs.append("x");
     673           0 :                     rList.push_back( HtmlSuccessfulObj(aLhs.makeStringAndClear(), aRhs) );
     674             : 
     675           0 :                     aLhs.append(aName);
     676           0 :                     aRhs = ::rtl::OUString::valueOf( MouseEvt.Y );
     677           0 :                     if (!aName.isEmpty())
     678           0 :                         aLhs.append(".y");
     679             :                     else
     680           0 :                         aLhs.append("y");
     681           0 :                     rList.push_back( HtmlSuccessfulObj(aLhs.makeStringAndClear(), aRhs) );
     682           0 :                 }
     683             :             }
     684           0 :         } break;
     685             : 
     686             :         // CheckBoxen / RadioButtons
     687             :         case FormComponentType::CHECKBOX:
     688             :         case FormComponentType::RADIOBUTTON:
     689             :         {
     690             :             // <name>=<refValue>
     691           0 :             if( !hasProperty(PROPERTY_STATE, xComponentSet) )
     692             :                 break;
     693           0 :             sal_Int16 nChecked = 0;
     694           0 :             xComponentSet->getPropertyValue( PROPERTY_STATE ) >>= nChecked;
     695           0 :             if( nChecked != 1 )
     696             :                 break;
     697             : 
     698           0 :             ::rtl::OUString aStrValue;
     699           0 :             if( hasProperty(PROPERTY_REFVALUE, xComponentSet) )
     700           0 :                 xComponentSet->getPropertyValue( PROPERTY_REFVALUE ) >>= aStrValue;
     701             : 
     702           0 :             rList.push_back( HtmlSuccessfulObj(aName, aStrValue) );
     703           0 :         } break;
     704             : 
     705             :         // Edit
     706             :         case FormComponentType::TEXTFIELD:
     707             :         {
     708             :             // <name>=<text>
     709           0 :             if( !hasProperty(PROPERTY_TEXT, xComponentSet) )
     710             :                 break;
     711             : 
     712             :             // MIB: Special treatment for multiline edit only if we have a control for it
     713           0 :             Any aTmp = xComponentSet->getPropertyValue( PROPERTY_MULTILINE );
     714           0 :             sal_Bool bMulti =   rxSubmitButton.is()
     715           0 :                             && (aTmp.getValueType().getTypeClass() == TypeClass_BOOLEAN)
     716           0 :                             && getBOOL(aTmp);
     717           0 :             ::rtl::OUString sText;
     718           0 :             if ( bMulti )   // For multiline edit, get the text at the control
     719             :             {
     720             : 
     721           0 :                 Reference<XControlContainer>  xControlContainer(rxSubmitButton->getContext(), UNO_QUERY);
     722           0 :                 if( !xControlContainer.is() ) break;
     723             : 
     724           0 :                 Sequence<Reference<XControl> > aControlSeq = xControlContainer->getControls();
     725           0 :                 Reference<XControl>  xControl;
     726           0 :                 Reference<XFormComponent>  xControlComponent;
     727             : 
     728             :                 // Find the right control
     729             :                 sal_Int32 i;
     730           0 :                 for( i=0; i<aControlSeq.getLength(); i++ )
     731             :                 {
     732           0 :                     xControl = aControlSeq.getConstArray()[i];
     733           0 :                     Reference<XPropertySet>  xModel(xControl->getModel(), UNO_QUERY);
     734           0 :                     if (xModel == xComponentSet)
     735             :                     {
     736           0 :                         Reference<XTextComponent>  xTextComponent(xControl, UNO_QUERY);
     737           0 :                         if( xTextComponent.is() )
     738           0 :                             sText = xTextComponent->getText();
     739           0 :                         break;
     740             :                     }
     741           0 :                 }
     742             :                 // Couldn't find control or it does not exist (edit in the grid)
     743           0 :                 if (i == aControlSeq.getLength())
     744           0 :                     xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;
     745             :             }
     746             :             else
     747           0 :                 xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText;
     748             : 
     749           0 :             rList.push_back( HtmlSuccessfulObj(aName, sText) );
     750           0 :         } break;
     751             : 
     752             :         // ComboBox, Patternfield
     753             :         case FormComponentType::COMBOBOX:
     754             :         case FormComponentType::PATTERNFIELD:
     755             :         {
     756             :             // <name>=<text>
     757           0 :             if( hasProperty(PROPERTY_TEXT, xComponentSet) )
     758             :             {
     759           0 :                 ::rtl::OUString aText;
     760           0 :                 xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
     761           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText) );
     762             :             }
     763           0 :         } break;
     764             :         case FormComponentType::CURRENCYFIELD:
     765             :         case FormComponentType::NUMERICFIELD:
     766             :         {
     767             :             // <name>=<wert> // Value is a double with dot as decimal delimiter
     768             :                              // no value (NULL) means empty value
     769           0 :             if( hasProperty(PROPERTY_VALUE, xComponentSet) )
     770             :             {
     771           0 :                 ::rtl::OUString aText;
     772           0 :                 Any aVal  = xComponentSet->getPropertyValue( PROPERTY_VALUE );
     773             : 
     774           0 :                 double aDoubleVal = 0;
     775           0 :                 if (aVal >>= aDoubleVal)
     776             :                 {
     777           0 :                     sal_Int16 nScale = 0;
     778           0 :                     xComponentSet->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) >>= nScale;
     779           0 :                     aText = ::rtl::math::doubleToUString(aDoubleVal, rtl_math_StringFormat_F, nScale, '.', sal_True);
     780             :                 }
     781           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText) );
     782             :             }
     783           0 :         }   break;
     784             :         case FormComponentType::DATEFIELD:
     785             :         {
     786             :             // <name>=<wert> // Value is a Date with the format MM-DD-YYYY
     787             :                              // no value (NULL) means empty value
     788           0 :             if( hasProperty(PROPERTY_DATE, xComponentSet) )
     789             :             {
     790           0 :                 ::rtl::OUString aText;
     791           0 :                 Any aVal  = xComponentSet->getPropertyValue( PROPERTY_DATE );
     792           0 :                 sal_Int32 nInt32Val = 0;
     793           0 :                 if (aVal >>= nInt32Val)
     794             :                 {
     795           0 :                     ::Date aDate( nInt32Val );
     796           0 :                     ::rtl::OUStringBuffer aBuffer;
     797           0 :                     appendDigits( aDate.GetMonth(), 2, aBuffer );
     798           0 :                     aBuffer.append( (sal_Unicode)'-' );
     799           0 :                     appendDigits( aDate.GetDay(), 2, aBuffer );
     800           0 :                     aBuffer.append( (sal_Unicode)'-' );
     801           0 :                     appendDigits( aDate.GetYear(), 4, aBuffer );
     802           0 :                     aText = aBuffer.makeStringAndClear();
     803             :                 }
     804           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText) );
     805             :             }
     806           0 :         }   break;
     807             :         case FormComponentType::TIMEFIELD:
     808             :         {
     809             :             // <name>=<wert> // Value is a Time with the format HH:MM:SS
     810             :                              // no value (NULL) means empty value
     811           0 :             if( hasProperty(PROPERTY_TIME, xComponentSet) )
     812             :             {
     813           0 :                 ::rtl::OUString aText;
     814           0 :                 Any aVal  = xComponentSet->getPropertyValue( PROPERTY_TIME );
     815           0 :                 sal_Int32 nInt32Val = 0;
     816           0 :                 if (aVal >>= nInt32Val)
     817             :                 {
     818           0 :                     ::Time aTime(nInt32Val);
     819           0 :                     ::rtl::OUStringBuffer aBuffer;
     820           0 :                     appendDigits( aTime.GetHour(), 2, aBuffer );
     821           0 :                     aBuffer.append( (sal_Unicode)'-' );
     822           0 :                     appendDigits( aTime.GetMin(), 2, aBuffer );
     823           0 :                     aBuffer.append( (sal_Unicode)'-' );
     824           0 :                     appendDigits( aTime.GetSec(), 2, aBuffer );
     825           0 :                     aText = aBuffer.makeStringAndClear();
     826             :                 }
     827           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText) );
     828             :             }
     829           0 :         }   break;
     830             : 
     831             :         // starform
     832             :         case FormComponentType::HIDDENCONTROL:
     833             :         {
     834             : 
     835             :             // <name>=<value>
     836           0 :             if( hasProperty(PROPERTY_HIDDEN_VALUE, xComponentSet) )
     837             :             {
     838           0 :                 ::rtl::OUString aText;
     839           0 :                 xComponentSet->getPropertyValue( PROPERTY_HIDDEN_VALUE ) >>= aText;
     840           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText) );
     841             :             }
     842           0 :         } break;
     843             : 
     844             :         // starform
     845             :         case FormComponentType::FILECONTROL:
     846             :         {
     847             :             // <name>=<text>
     848           0 :             if( hasProperty(PROPERTY_TEXT, xComponentSet) )
     849             :             {
     850             : 
     851           0 :                 ::rtl::OUString aText;
     852           0 :                 xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= aText;
     853           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aText, SUCCESSFUL_REPRESENT_FILE) );
     854             :             }
     855           0 :         } break;
     856             : 
     857             :         // starform
     858             :         case FormComponentType::LISTBOX:
     859             :         {
     860             : 
     861             :             // <name>=<Token0>&<name>=<Token1>&...&<name>=<TokenN> (multiple selection)
     862           0 :             if (!hasProperty(PROPERTY_SELECT_SEQ, xComponentSet) ||
     863           0 :                 !hasProperty(PROPERTY_STRINGITEMLIST, xComponentSet))
     864             :                 break;
     865             : 
     866             :             // Displayed values
     867           0 :             Sequence< ::rtl::OUString > aVisibleList;
     868           0 :             xComponentSet->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aVisibleList;
     869           0 :             sal_Int32 nStringCnt = aVisibleList.getLength();
     870           0 :             const ::rtl::OUString* pStrings = aVisibleList.getConstArray();
     871             : 
     872             :             // Value list
     873           0 :             Sequence< ::rtl::OUString > aValueList;
     874           0 :             xComponentSet->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueList;
     875           0 :             sal_Int32 nValCnt = aValueList.getLength();
     876           0 :             const ::rtl::OUString* pVals = aValueList.getConstArray();
     877             : 
     878             :             // Selection
     879           0 :             Sequence<sal_Int16> aSelectList;
     880           0 :             xComponentSet->getPropertyValue( PROPERTY_SELECT_SEQ ) >>= aSelectList;
     881           0 :             sal_Int32 nSelCount = aSelectList.getLength();
     882           0 :             const sal_Int16* pSels = aSelectList.getConstArray();
     883             : 
     884             :             // Simple or multiple selection
     885             :             // For simple selections MT only accounts for the list's first entry.
     886           0 :             if (nSelCount > 1 && !getBOOL(xComponentSet->getPropertyValue(PROPERTY_MULTISELECTION)))
     887           0 :                 nSelCount = 1;
     888             : 
     889             :             // The indices in the selection list can also be invalid, so we first have to
     890             :             // find the valid ones to determine the length of the new list.
     891           0 :             sal_Int32 nCurCnt = 0;
     892             :             sal_Int32 i;
     893           0 :             for( i=0; i<nSelCount; ++i )
     894             :             {
     895           0 :                 if( pSels[i] < nStringCnt )
     896           0 :                     ++nCurCnt;
     897             :             }
     898             : 
     899           0 :             ::rtl::OUString aSubValue;
     900           0 :             for(i=0; i<nCurCnt; ++i )
     901             :             {
     902           0 :                 sal_Int16  nSelPos = pSels[i];
     903           0 :                 if (nSelPos < nValCnt && !pVals[nSelPos].isEmpty())
     904             :                 {
     905           0 :                     aSubValue = pVals[nSelPos];
     906             :                 }
     907             :                 else
     908             :                 {
     909           0 :                     aSubValue = pStrings[nSelPos];
     910             :                 }
     911           0 :                 rList.push_back( HtmlSuccessfulObj(aName, aSubValue) );
     912           0 :             }
     913           0 :         } break;
     914             :         case FormComponentType::GRIDCONTROL:
     915             :         {
     916             :             // Each of the column values is sent;
     917             :             // the name is extended by the grid's prefix.
     918           0 :             Reference<XIndexAccess>  xContainer(xComponentSet, UNO_QUERY);
     919           0 :             if (!xContainer.is())
     920             :                 break;
     921             : 
     922           0 :             aName += rtl::OUString(static_cast<sal_Unicode>('.'));
     923             : 
     924           0 :             Reference<XPropertySet>  xSet;
     925           0 :             sal_Int32 nCount = xContainer->getCount();
     926             :             // we know already how many objects should be appended,
     927             :             // so why not allocate the space for them
     928           0 :             rList.reserve( nCount + rList.capacity() ); // not size()
     929           0 :             for (sal_Int32 i = 0; i < nCount; ++i)
     930             :             {
     931           0 :                 xContainer->getByIndex(i) >>= xSet;
     932           0 :                 if (xSet.is())
     933           0 :                     AppendComponent(rList, xSet, aName, rxSubmitButton, MouseEvt);
     934           0 :             }
     935             :         }
     936           0 :     }
     937             : }
     938             : 
     939             : //------------------------------------------------------------------------
     940           0 : void ODatabaseForm::FillSuccessfulList( HtmlSuccessfulObjList& rList,
     941             :     const Reference<XControl>& rxSubmitButton, const ::com::sun::star::awt::MouseEvent& MouseEvt )
     942             : {
     943             :     // Delete list
     944           0 :     rList.clear();
     945             :     // Iterate over Components
     946           0 :     Reference<XPropertySet>         xComponentSet;
     947           0 :     ::rtl::OUString aPrefix;
     948             : 
     949             :     // we know already how many objects should be appended,
     950             :     // so why not allocate the space for them
     951           0 :     rList.reserve( getCount() );
     952           0 :     for( sal_Int32 nIndex=0; nIndex < getCount(); nIndex++ )
     953             :     {
     954           0 :         getByIndex( nIndex ) >>= xComponentSet;
     955           0 :         AppendComponent(rList, xComponentSet, aPrefix, rxSubmitButton, MouseEvt);
     956           0 :     }
     957           0 : }
     958             : 
     959             : //------------------------------------------------------------------------
     960           0 : void ODatabaseForm::Encode( ::rtl::OUString& rString ) const
     961             : {
     962           0 :     ::rtl::OUStringBuffer aResult;
     963             : 
     964             :     // Line endings are represented as CR
     965           0 :     rString = convertLineEnd(rString, LINEEND_CR);
     966             : 
     967             :     // Check each character
     968           0 :     sal_Int32 nStrLen = rString.getLength();
     969             :     sal_Unicode nCharCode;
     970           0 :     for( sal_Int32 nCurPos=0; nCurPos < nStrLen; ++nCurPos )
     971             :     {
     972           0 :         nCharCode = rString[nCurPos];
     973             : 
     974             :         // Handle chars, which are not an alphanumeric character and character codes > 127
     975           0 :         if( (!isalnum(nCharCode) && nCharCode != (sal_Unicode)' ') || nCharCode > 127 )
     976             :         {
     977           0 :             switch( nCharCode )
     978             :             {
     979             :                 case 13:    // CR
     980           0 :                     aResult.append("%0D%0A"); // CR LF in hex
     981           0 :                     break;
     982             : 
     983             : 
     984             :                 // Special treatment for Netscape
     985             :                 case 42:    // '*'
     986             :                 case 45:    // '-'
     987             :                 case 46:    // '.'
     988             :                 case 64:    // '@'
     989             :                 case 95:    // '_'
     990           0 :                     aResult.append(nCharCode);
     991           0 :                     break;
     992             : 
     993             :                 default:
     994             :                 {
     995             :                     // Convert to hex
     996           0 :                     short nHi = ((sal_Int16)nCharCode) / 16;
     997           0 :                     short nLo = ((sal_Int16)nCharCode) - (nHi*16);
     998           0 :                     if( nHi > 9 ) nHi += (int)'A'-10; else nHi += (int)'0';
     999           0 :                     if( nLo > 9 ) nLo += (int)'A'-10; else nLo += (int)'0';
    1000           0 :                     aResult.append('%');
    1001           0 :                     aResult.append((sal_Unicode)nHi);
    1002           0 :                     aResult.append((sal_Unicode)nLo);
    1003             :                 }
    1004           0 :             }
    1005             :         }
    1006             :         else
    1007           0 :             aResult.append(nCharCode);
    1008             :     }
    1009             : 
    1010             :     // Replace spaces with '+'
    1011           0 :     rString = aResult.makeStringAndClear().replace(' ', '+');
    1012           0 : }
    1013             : 
    1014             : //------------------------------------------------------------------------
    1015           0 : void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
    1016             :     const ::rtl::OUString& rData )
    1017             : {
    1018             : 
    1019             :     // Create part as MessageChild
    1020           0 :     INetMIMEMessage* pChild = new INetMIMEMessage();
    1021             : 
    1022             : 
    1023             :     // Header
    1024           0 :     ::rtl::OUStringBuffer aContentDisp;
    1025           0 :     aContentDisp.append("form-data; name=\"");
    1026           0 :     aContentDisp.append(rName);
    1027           0 :     aContentDisp.append('\"');
    1028           0 :     pChild->SetContentDisposition(aContentDisp.makeStringAndClear());
    1029           0 :     pChild->SetContentType(::rtl::OUString("text/plain"));
    1030             : 
    1031           0 :     rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding();
    1032           0 :     const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding );
    1033           0 :     rtl::OUString aBestMatchingEncoding = rtl::OUString::createFromAscii(pBestMatchingEncoding);
    1034           0 :     pChild->SetContentTransferEncoding(aBestMatchingEncoding);
    1035             : 
    1036             :     // Body
    1037           0 :     SvMemoryStream* pStream = new SvMemoryStream;
    1038           0 :     pStream->WriteLine( rtl::OUStringToOString(rData, rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding)) );
    1039           0 :     pStream->Flush();
    1040           0 :     pStream->Seek( 0 );
    1041           0 :     pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
    1042           0 :     rParent.AttachChild( *pChild );
    1043           0 : }
    1044             : 
    1045             : //------------------------------------------------------------------------
    1046           0 : sal_Bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const ::rtl::OUString& rName,
    1047             :     const ::rtl::OUString& rFileName )
    1048             : {
    1049           0 :     rtl::OUString aFileName(rFileName);
    1050           0 :     rtl::OUString aContentType(CONTENT_TYPE_STR_TEXT_PLAIN);
    1051           0 :     SvStream *pStream = 0;
    1052             : 
    1053           0 :     if (!aFileName.isEmpty())
    1054             :     {
    1055             :         // We can only process File URLs yet
    1056           0 :         INetURLObject aURL;
    1057           0 :         aURL.SetSmartProtocol(INET_PROT_FILE);
    1058           0 :         aURL.SetSmartURL(rFileName);
    1059           0 :         if( INET_PROT_FILE == aURL.GetProtocol() )
    1060             :         {
    1061           0 :             aFileName = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
    1062           0 :             DirEntry aDirEntry( aFileName );
    1063           0 :             if( aDirEntry.Exists() )
    1064             :             {
    1065           0 :                 pStream = ::utl::UcbStreamHelper::CreateStream(aFileName, STREAM_READ);
    1066           0 :                 if (!pStream || (pStream->GetError() != ERRCODE_NONE))
    1067             :                 {
    1068           0 :                     delete pStream;
    1069           0 :                     pStream = 0;
    1070             :                 }
    1071             :             }
    1072             :             INetContentType eContentType = INetContentTypes::GetContentType4Extension(
    1073           0 :                                                                 aDirEntry.GetExtension() );
    1074           0 :             if (eContentType != CONTENT_TYPE_UNKNOWN)
    1075           0 :                 aContentType = INetContentTypes::GetContentType(eContentType);
    1076           0 :         }
    1077             :     }
    1078             : 
    1079             :     // If something didn't work, we create an empty MemoryStream
    1080           0 :     if( !pStream )
    1081           0 :         pStream = new SvMemoryStream;
    1082             : 
    1083             : 
    1084             :     // Create part as MessageChild
    1085           0 :     INetMIMEMessage* pChild = new INetMIMEMessage;
    1086             : 
    1087             : 
    1088             :     // Header
    1089           0 :     ::rtl::OUStringBuffer aContentDisp;
    1090           0 :     aContentDisp.append("form-data; name=\"");
    1091           0 :     aContentDisp.append(rName);
    1092           0 :     aContentDisp.append('\"');
    1093           0 :     aContentDisp.append("; filename=\"");
    1094           0 :     aContentDisp.append(aFileName);
    1095           0 :     aContentDisp.append('\"');
    1096           0 :     pChild->SetContentDisposition(aContentDisp.makeStringAndClear());
    1097           0 :     pChild->SetContentType( aContentType );
    1098           0 :     pChild->SetContentTransferEncoding(::rtl::OUString("8bit"));
    1099             : 
    1100             : 
    1101             :     // Body
    1102           0 :     pChild->SetDocumentLB( new SvLockBytes(pStream, sal_True) );
    1103           0 :     rParent.AttachChild( *pChild );
    1104             : 
    1105           0 :     return sal_True;
    1106             : }
    1107             : 
    1108             : //==============================================================================
    1109             : // internals
    1110             : //------------------------------------------------------------------------------
    1111           0 : void ODatabaseForm::onError( const SQLErrorEvent& _rEvent )
    1112             : {
    1113           0 :     m_aErrorListeners.notifyEach( &XSQLErrorListener::errorOccured, _rEvent );
    1114           0 : }
    1115             : 
    1116             : //------------------------------------------------------------------------------
    1117           0 : void ODatabaseForm::onError( const SQLException& _rException, const ::rtl::OUString& _rContextDescription )
    1118             : {
    1119           0 :     if ( !m_aErrorListeners.getLength() )
    1120           0 :         return;
    1121             : 
    1122           0 :     SQLErrorEvent aEvent( *this, makeAny( prependErrorInfo( _rException, *this, _rContextDescription ) ) );
    1123           0 :     onError( aEvent );
    1124             : }
    1125             : 
    1126             : //------------------------------------------------------------------------------
    1127           0 : void ODatabaseForm::updateParameterInfo()
    1128             : {
    1129           0 :     m_aParameterManager.updateParameterInfo( m_aFilterManager );
    1130           0 : }
    1131             : 
    1132             : //------------------------------------------------------------------------------
    1133           0 : bool ODatabaseForm::hasValidParent() const
    1134             : {
    1135             :     // do we have to fill the parameters again?
    1136           0 :     if (m_bSubForm)
    1137             :     {
    1138           0 :         Reference<XResultSet>  xResultSet(m_xParent, UNO_QUERY);
    1139           0 :         if (!xResultSet.is())
    1140             :         {
    1141             :             OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !");
    1142           0 :             return false;
    1143             :         }
    1144             :         try
    1145             :         {
    1146           0 :             Reference< XPropertySet >  xSet( m_xParent, UNO_QUERY );
    1147           0 :             Reference< XLoadable > xLoad( m_xParent, UNO_QUERY );
    1148           0 :             if  (   xLoad->isLoaded()
    1149           0 :                 &&  (   xResultSet->isBeforeFirst()
    1150           0 :                     ||  xResultSet->isAfterLast()
    1151           0 :                     ||  getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) )
    1152             :                     )
    1153             :                 )
    1154             :                 // the parent form is loaded and on a "virtual" row -> not valid
    1155           0 :                 return false;
    1156             :         }
    1157           0 :         catch(const Exception&)
    1158             :         {
    1159             :             // parent could be forwardonly?
    1160           0 :             return false;
    1161           0 :         }
    1162             :     }
    1163           0 :     return true;
    1164             : }
    1165             : 
    1166             : //------------------------------------------------------------------------------
    1167           0 : bool ODatabaseForm::fillParameters( ::osl::ResettableMutexGuard& _rClearForNotifies, const Reference< XInteractionHandler >& _rxCompletionHandler )
    1168             : {
    1169             :     // do we have to fill the parameters again?
    1170           0 :     if ( !m_aParameterManager.isUpToDate() )
    1171           0 :         updateParameterInfo();
    1172             : 
    1173             :     // is there a valid parent?
    1174           0 :     if ( m_bSubForm && !hasValidParent() )
    1175           0 :         return true;
    1176             : 
    1177             :     // ensure we're connected
    1178           0 :     if ( !implEnsureConnection() )
    1179           0 :         return false;
    1180             : 
    1181           0 :     if ( m_aParameterManager.isUpToDate() )
    1182           0 :         return m_aParameterManager.fillParameterValues( _rxCompletionHandler, _rClearForNotifies );
    1183             : 
    1184           0 :     return true;
    1185             : }
    1186             : 
    1187             : //------------------------------------------------------------------------------
    1188           0 : void ODatabaseForm::saveInsertOnlyState( )
    1189             : {
    1190             :     OSL_ENSURE( !m_aIgnoreResult.hasValue(), "ODatabaseForm::saveInsertOnlyState: overriding old value!" );
    1191           0 :     m_aIgnoreResult = m_xAggregateSet->getPropertyValue( PROPERTY_INSERTONLY );
    1192           0 : }
    1193             : 
    1194             : //------------------------------------------------------------------------------
    1195           0 : void ODatabaseForm::restoreInsertOnlyState( )
    1196             : {
    1197           0 :     if ( m_aIgnoreResult.hasValue() )
    1198             :     {
    1199           0 :         m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, m_aIgnoreResult );
    1200           0 :         m_aIgnoreResult = Any();
    1201             :     }
    1202           0 : }
    1203             : 
    1204             : //------------------------------------------------------------------------------
    1205           0 : sal_Bool ODatabaseForm::executeRowSet(::osl::ResettableMutexGuard& _rClearForNotifies, sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler)
    1206             : {
    1207           0 :     if (!m_xAggregateAsRowSet.is())
    1208           0 :         return sal_False;
    1209             : 
    1210           0 :     if (!fillParameters(_rClearForNotifies, _rxCompletionHandler))
    1211           0 :         return sal_False;
    1212             : 
    1213           0 :     restoreInsertOnlyState( );
    1214             : 
    1215             :     // ensure the aggregated row set has the correct properties
    1216           0 :     sal_Int32 nConcurrency = ResultSetConcurrency::READ_ONLY;
    1217             : 
    1218             :     // if we have a parent, who is not positioned on a valid row
    1219             :     // we can't be updatable!
    1220           0 :     if (m_bSubForm && !hasValidParent())
    1221             :     {
    1222           0 :         nConcurrency = ResultSetConcurrency::READ_ONLY;
    1223             : 
    1224             :         // don't use any parameters if we don't have a valid parent
    1225           0 :         m_aParameterManager.setAllParametersNull();
    1226             : 
    1227             :         // switch to "insert only" mode
    1228           0 :         saveInsertOnlyState( );
    1229           0 :         m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( sal_True ) );
    1230             :     }
    1231           0 :     else if (m_bAllowInsert || m_bAllowUpdate || m_bAllowDelete)
    1232           0 :         nConcurrency = ResultSetConcurrency::UPDATABLE;
    1233             :     else
    1234           0 :         nConcurrency = ResultSetConcurrency::READ_ONLY;
    1235             : 
    1236           0 :     m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_CONCURRENCY, makeAny( (sal_Int32)nConcurrency ) );
    1237           0 :     m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_TYPE, makeAny( (sal_Int32)ResultSetType::SCROLL_SENSITIVE ) );
    1238             : 
    1239           0 :     sal_Bool bSuccess = sal_False;
    1240             :     try
    1241             :     {
    1242           0 :         m_xAggregateAsRowSet->execute();
    1243           0 :         bSuccess = sal_True;
    1244             :     }
    1245           0 :     catch(const RowSetVetoException&)
    1246             :     {
    1247             :     }
    1248           0 :     catch(const SQLException& eDb)
    1249             :     {
    1250           0 :         _rClearForNotifies.clear();
    1251           0 :         if (!m_sCurrentErrorContext.isEmpty())
    1252           0 :             onError(eDb, m_sCurrentErrorContext);
    1253             :         else
    1254           0 :             onError(eDb, FRM_RES_STRING(RID_STR_READERROR));
    1255           0 :         _rClearForNotifies.reset();
    1256             : 
    1257           0 :         restoreInsertOnlyState( );
    1258             :     }
    1259             : 
    1260           0 :     if (bSuccess)
    1261             :     {
    1262             :         // adjust the privilege property
    1263             :         //  m_nPrivileges;
    1264           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
    1265           0 :         if (!m_bAllowInsert)
    1266           0 :             m_nPrivileges &= ~Privilege::INSERT;
    1267           0 :         if (!m_bAllowUpdate)
    1268           0 :             m_nPrivileges &= ~Privilege::UPDATE;
    1269           0 :         if (!m_bAllowDelete)
    1270           0 :             m_nPrivileges &= ~Privilege::DELETE;
    1271             : 
    1272           0 :         if (bMoveToFirst)
    1273             :         {
    1274             :             // the row set is positioned _before_ the first row (per definitionem), so move the set ...
    1275             :             try
    1276             :             {
    1277             :                 // if we have an insert only rowset we move to the insert row
    1278           0 :                 next();
    1279           0 :                 if (((m_nPrivileges & Privilege::INSERT) == Privilege::INSERT)
    1280           0 :                     && isAfterLast())
    1281             :                 {
    1282             :                     // move on the insert row of set
    1283             :                     // resetting must be done later, after the load events have been posted
    1284             :                     // see :moveToInsertRow and load , reload
    1285           0 :                     Reference<XResultSetUpdate>  xUpdate;
    1286           0 :                     if (query_aggregation( m_xAggregate, xUpdate))
    1287           0 :                         xUpdate->moveToInsertRow();
    1288             :                 }
    1289             :             }
    1290           0 :             catch(const SQLException& eDB)
    1291             :             {
    1292           0 :                 _rClearForNotifies.clear();
    1293           0 :                 if (!m_sCurrentErrorContext.isEmpty())
    1294           0 :                     onError(eDB, m_sCurrentErrorContext);
    1295             :                 else
    1296           0 :                     onError(eDB, FRM_RES_STRING(RID_STR_READERROR));
    1297           0 :                 _rClearForNotifies.reset();
    1298           0 :                 bSuccess = sal_False;
    1299             :             }
    1300             :         }
    1301             :     }
    1302           0 :     return bSuccess;
    1303             : }
    1304             : 
    1305             : //------------------------------------------------------------------
    1306           3 : void ODatabaseForm::disposing()
    1307             : {
    1308           3 :     if (m_pAggregatePropertyMultiplexer)
    1309           3 :         m_pAggregatePropertyMultiplexer->dispose();
    1310             : 
    1311           3 :     if (m_bLoaded)
    1312           0 :         unload();
    1313             : 
    1314             :     // cancel the submit/reset-thread
    1315             :     {
    1316           3 :         ::osl::MutexGuard aGuard( m_aMutex );
    1317           3 :         if (m_pThread)
    1318             :         {
    1319           0 :             m_pThread->release();
    1320           0 :             m_pThread = NULL;
    1321           3 :         }
    1322             :     }
    1323             : 
    1324           3 :     EventObject aEvt(static_cast<XWeak*>(this));
    1325           3 :     m_aLoadListeners.disposeAndClear(aEvt);
    1326           3 :     m_aRowSetApproveListeners.disposeAndClear(aEvt);
    1327           3 :     m_aParameterManager.disposing( aEvt );
    1328           3 :     m_aResetListeners.disposing();
    1329           3 :     m_aSubmitListeners.disposeAndClear(aEvt);
    1330           3 :     m_aErrorListeners.disposeAndClear(aEvt);
    1331             : 
    1332           3 :     m_aParameterManager.dispose();   // (to free any references it may have to me)
    1333           3 :     m_aFilterManager.dispose();      // (dito)
    1334             : 
    1335           3 :     OFormComponents::disposing();
    1336           3 :     OPropertySetAggregationHelper::disposing();
    1337             : 
    1338             :     // stop listening on the aggregate
    1339           3 :     if (m_xAggregateAsRowSet.is())
    1340           3 :         m_xAggregateAsRowSet->removeRowSetListener(this);
    1341             : 
    1342             :     // dispose the active connection
    1343           3 :     Reference<XComponent>  xAggregationComponent;
    1344           3 :     if (query_aggregation(m_xAggregate, xAggregationComponent))
    1345           3 :         xAggregationComponent->dispose();
    1346             : 
    1347           3 :     m_aPropertyBagHelper.dispose();
    1348           3 : }
    1349             : 
    1350             : //------------------------------------------------------------------------------
    1351           0 : Reference< XConnection > ODatabaseForm::getConnection()
    1352             : {
    1353           0 :     Reference< XConnection > xConn;
    1354           0 :     m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConn;
    1355           0 :     return xConn;
    1356             : }
    1357             : 
    1358             : //------------------------------------------------------------------------------
    1359           4 : ::osl::Mutex& ODatabaseForm::getMutex()
    1360             : {
    1361           4 :     return m_aMutex;
    1362             : }
    1363             : 
    1364             : //==============================================================================
    1365             : // property handling
    1366             : //------------------------------------------------------------------------------
    1367           4 : void ODatabaseForm::describeFixedAndAggregateProperties(
    1368             :         Sequence< Property >& _rProps,
    1369             :         Sequence< Property >& _rAggregateProps ) const
    1370             : {
    1371           4 :     BEGIN_DESCRIBE_AGGREGATION_PROPERTIES(22, m_xAggregateSet)
    1372             :         // we want to "override" the privileges, since we have additional "AllowInsert" etc. properties
    1373           4 :         RemoveProperty( _rAggregateProps, PROPERTY_PRIVILEGES );
    1374             : 
    1375             :         // InsertOnly is also to be overridden, since we sometimes change it ourself
    1376           4 :         RemoveProperty( _rAggregateProps, PROPERTY_INSERTONLY );
    1377             : 
    1378             :         // we remove and re-declare the DataSourceName property, 'cause we want it to be constrained, and the
    1379             :         // original property of our aggregate isn't
    1380           4 :         RemoveProperty( _rAggregateProps, PROPERTY_DATASOURCE );
    1381             : 
    1382             :         // for connection sharing, we need to override the ActiveConnection property, too
    1383           4 :         RemoveProperty( _rAggregateProps, PROPERTY_ACTIVE_CONNECTION );
    1384             : 
    1385             :         // the Filter property is also overwritten, since we have some implicit filters
    1386             :         // (e.g. the ones which result from linking master fields to detail fields
    1387             :         // via column names instead of parameters)
    1388           4 :         RemoveProperty( _rAggregateProps, PROPERTY_FILTER );
    1389           4 :         RemoveProperty( _rAggregateProps, PROPERTY_APPLYFILTER );
    1390             : 
    1391           4 :         DECL_IFACE_PROP4(ACTIVE_CONNECTION, XConnection,                    BOUND, TRANSIENT, MAYBEVOID, CONSTRAINED);
    1392           4 :         DECL_BOOL_PROP2 ( APPLYFILTER,                                      BOUND, MAYBEDEFAULT            );
    1393           4 :         DECL_PROP1      ( NAME,             ::rtl::OUString,                BOUND                          );
    1394           4 :         DECL_PROP1      ( MASTERFIELDS,     Sequence< ::rtl::OUString >,    BOUND                          );
    1395           4 :         DECL_PROP1      ( DETAILFIELDS,     Sequence< ::rtl::OUString >,    BOUND                          );
    1396           4 :         DECL_PROP2      ( DATASOURCE,       ::rtl::OUString,                BOUND, CONSTRAINED             );
    1397           4 :         DECL_PROP3      ( CYCLE,            TabulatorCycle,                 BOUND, MAYBEVOID, MAYBEDEFAULT );
    1398           4 :         DECL_PROP2      ( FILTER,           ::rtl::OUString,                BOUND, MAYBEDEFAULT            );
    1399           4 :         DECL_BOOL_PROP2 ( INSERTONLY,                                       BOUND, MAYBEDEFAULT            );
    1400           4 :         DECL_PROP1      ( NAVIGATION,       NavigationBarMode,              BOUND                          );
    1401           4 :         DECL_BOOL_PROP1 ( ALLOWADDITIONS,                                   BOUND                          );
    1402           4 :         DECL_BOOL_PROP1 ( ALLOWEDITS,                                       BOUND                          );
    1403           4 :         DECL_BOOL_PROP1 ( ALLOWDELETIONS,                                   BOUND                          );
    1404           4 :         DECL_PROP2      ( PRIVILEGES,       sal_Int32,                      TRANSIENT, READONLY            );
    1405           4 :         DECL_PROP1      ( TARGET_URL,       ::rtl::OUString,                BOUND                          );
    1406           4 :         DECL_PROP1      ( TARGET_FRAME,     ::rtl::OUString,                BOUND                          );
    1407           4 :         DECL_PROP1      ( SUBMIT_METHOD,    FormSubmitMethod,               BOUND                          );
    1408           4 :         DECL_PROP1      ( SUBMIT_ENCODING,  FormSubmitEncoding,             BOUND                          );
    1409           4 :         DECL_BOOL_PROP3 ( DYNAMIC_CONTROL_BORDER,                           BOUND, MAYBEVOID, MAYBEDEFAULT );
    1410           4 :         DECL_PROP3      ( CONTROL_BORDER_COLOR_FOCUS,   sal_Int32,          BOUND, MAYBEVOID, MAYBEDEFAULT );
    1411           4 :         DECL_PROP3      ( CONTROL_BORDER_COLOR_MOUSE,   sal_Int32,          BOUND, MAYBEVOID, MAYBEDEFAULT );
    1412           4 :         DECL_PROP3      ( CONTROL_BORDER_COLOR_INVALID, sal_Int32,          BOUND, MAYBEVOID, MAYBEDEFAULT );
    1413             :     END_DESCRIBE_PROPERTIES();
    1414           4 : }
    1415             : 
    1416             : //------------------------------------------------------------------------------
    1417           0 : Reference< XMultiPropertySet > ODatabaseForm::getPropertiesInterface()
    1418             : {
    1419           0 :     return Reference< XMultiPropertySet >( *this, UNO_QUERY );
    1420             : }
    1421             : 
    1422             : //------------------------------------------------------------------------------
    1423         113 : ::cppu::IPropertyArrayHelper& ODatabaseForm::getInfoHelper()
    1424             : {
    1425         113 :     return m_aPropertyBagHelper.getInfoHelper();
    1426             : }
    1427             : 
    1428             : //------------------------------------------------------------------------------
    1429           7 : Reference< XPropertySetInfo > ODatabaseForm::getPropertySetInfo() throw( RuntimeException )
    1430             : {
    1431           7 :     return createPropertySetInfo( getInfoHelper() );
    1432             : }
    1433             : 
    1434             : //--------------------------------------------------------------------
    1435           0 : void SAL_CALL ODatabaseForm::addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException)
    1436             : {
    1437           0 :     m_aPropertyBagHelper.addProperty( _rName, _nAttributes, _rInitialValue );
    1438           0 : }
    1439             : 
    1440             : //--------------------------------------------------------------------
    1441           0 : void SAL_CALL ODatabaseForm::removeProperty( const ::rtl::OUString& _rName ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException)
    1442             : {
    1443           0 :     m_aPropertyBagHelper.removeProperty( _rName );
    1444           0 : }
    1445             : 
    1446             : //--------------------------------------------------------------------
    1447           0 : Sequence< PropertyValue > SAL_CALL ODatabaseForm::getPropertyValues() throw (RuntimeException)
    1448             : {
    1449           0 :     return m_aPropertyBagHelper.getPropertyValues();
    1450             : }
    1451             : 
    1452             : //--------------------------------------------------------------------
    1453           0 : void SAL_CALL ODatabaseForm::setPropertyValues( const Sequence< PropertyValue >& _rProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1454             : {
    1455           0 :     m_aPropertyBagHelper.setPropertyValues( _rProps );
    1456           0 : }
    1457             : 
    1458             : //------------------------------------------------------------------------------
    1459           0 : Any SAL_CALL ODatabaseForm::getWarnings(  ) throw (SQLException, RuntimeException)
    1460             : {
    1461           0 :     return m_aWarnings.getWarnings();
    1462             : }
    1463             : 
    1464             : //------------------------------------------------------------------------------
    1465           0 : void SAL_CALL ODatabaseForm::clearWarnings(  ) throw (SQLException, RuntimeException)
    1466             : {
    1467           0 :     m_aWarnings.clearWarnings();
    1468           0 : }
    1469             : 
    1470             : //------------------------------------------------------------------------------
    1471           0 : Reference< XCloneable > SAL_CALL ODatabaseForm::createClone(  ) throw (RuntimeException)
    1472             : {
    1473           0 :     ODatabaseForm* pClone = new ODatabaseForm( *this );
    1474           0 :     osl_atomic_increment( &pClone->m_refCount );
    1475           0 :     pClone->clonedFrom( *this );
    1476           0 :     osl_atomic_decrement( &pClone->m_refCount );
    1477           0 :     return pClone;
    1478             : }
    1479             : 
    1480             : //------------------------------------------------------------------------------
    1481           0 : void ODatabaseForm::fire( sal_Int32* pnHandles, const Any* pNewValues, const Any* pOldValues, sal_Int32 nCount, sal_Bool bVetoable )
    1482             : {
    1483             :     // same as in getFastPropertyValue(sal_Int32) : if we're resetting currently don't fire any changes of the
    1484             :     // IsModified property from sal_False to sal_True, as this is only temporary 'til the reset is done
    1485           0 :     if (m_nResetsPending > 0)
    1486             :     {
    1487             :         // look for the PROPERTY_ID_ISMODIFIED
    1488           0 :         sal_Int32 nPos = 0;
    1489           0 :         for (nPos=0; nPos<nCount; ++nPos)
    1490           0 :             if (pnHandles[nPos] == PROPERTY_ID_ISMODIFIED)
    1491           0 :                 break;
    1492             : 
    1493           0 :         if ((nPos < nCount) && (pNewValues[nPos].getValueType().getTypeClass() == TypeClass_BOOLEAN) && getBOOL(pNewValues[nPos]))
    1494             :         {   // yeah, we found it, and it changed to TRUE
    1495           0 :             if (nPos == 0)
    1496             :             {   // just cut the first element
    1497           0 :                 ++pnHandles;
    1498           0 :                 ++pNewValues;
    1499           0 :                 ++pOldValues;
    1500           0 :                 --nCount;
    1501             :             }
    1502           0 :             else if (nPos == nCount - 1)
    1503             :                 // just cut the last element
    1504           0 :                 --nCount;
    1505             :             else
    1506             :             {   // split into two base class calls
    1507           0 :                 OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nPos, bVetoable);
    1508           0 :                 ++nPos;
    1509           0 :                 OPropertySetAggregationHelper::fire(pnHandles + nPos, pNewValues + nPos, pOldValues + nPos, nCount - nPos, bVetoable);
    1510           0 :                 return;
    1511             :             }
    1512             :         }
    1513             :     }
    1514             : 
    1515           0 :     OPropertySetAggregationHelper::fire(pnHandles, pNewValues, pOldValues, nCount, bVetoable);
    1516             : }
    1517             : 
    1518             : //------------------------------------------------------------------------------
    1519          20 : Any SAL_CALL ODatabaseForm::getFastPropertyValue( sal_Int32 nHandle )
    1520             :        throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1521             : {
    1522          20 :     if ((nHandle == PROPERTY_ID_ISMODIFIED) && (m_nResetsPending > 0))
    1523           0 :         return ::cppu::bool2any((sal_False));
    1524             :         // don't allow the aggregate which is currently being reset to return a (temporary) "yes"
    1525             :     else
    1526          20 :         return OPropertySetAggregationHelper::getFastPropertyValue(nHandle);
    1527             : }
    1528             : 
    1529             : //------------------------------------------------------------------------------
    1530          16 : void ODatabaseForm::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
    1531             : {
    1532          16 :     switch (nHandle)
    1533             :     {
    1534             :         case PROPERTY_ID_INSERTONLY:
    1535           0 :             rValue <<= m_bInsertOnly;
    1536           0 :             break;
    1537             : 
    1538             :         case PROPERTY_ID_FILTER:
    1539           0 :             rValue <<= m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter );
    1540           0 :             break;
    1541             : 
    1542             :         case PROPERTY_ID_APPLYFILTER:
    1543           0 :             rValue <<= m_aFilterManager.isApplyPublicFilter();
    1544           0 :             break;
    1545             : 
    1546             :         case PROPERTY_ID_DATASOURCE:
    1547           1 :             rValue = m_xAggregateSet->getPropertyValue( PROPERTY_DATASOURCE );
    1548           1 :             break;
    1549             : 
    1550             :         case PROPERTY_ID_TARGET_URL:
    1551           0 :             rValue <<= m_aTargetURL;
    1552           0 :             break;
    1553             :         case PROPERTY_ID_TARGET_FRAME:
    1554           0 :             rValue <<= m_aTargetFrame;
    1555           0 :             break;
    1556             :         case PROPERTY_ID_SUBMIT_METHOD:
    1557           0 :             rValue <<= m_eSubmitMethod;
    1558           0 :             break;
    1559             :         case PROPERTY_ID_SUBMIT_ENCODING:
    1560           0 :             rValue <<= m_eSubmitEncoding;
    1561           0 :             break;
    1562             :         case PROPERTY_ID_NAME:
    1563           4 :             rValue <<= m_sName;
    1564           4 :             break;
    1565             :         case PROPERTY_ID_MASTERFIELDS:
    1566           0 :             rValue <<= m_aMasterFields;
    1567           0 :             break;
    1568             :         case PROPERTY_ID_DETAILFIELDS:
    1569           0 :             rValue <<= m_aDetailFields;
    1570           0 :             break;
    1571             :         case PROPERTY_ID_CYCLE:
    1572           0 :             rValue = m_aCycle;
    1573           0 :             break;
    1574             :         case PROPERTY_ID_NAVIGATION:
    1575           0 :             rValue <<= m_eNavigation;
    1576           0 :             break;
    1577             :         case PROPERTY_ID_ALLOWADDITIONS:
    1578           0 :             rValue <<= (sal_Bool)m_bAllowInsert;
    1579           0 :             break;
    1580             :         case PROPERTY_ID_ALLOWEDITS:
    1581           0 :             rValue <<= (sal_Bool)m_bAllowUpdate;
    1582           0 :             break;
    1583             :         case PROPERTY_ID_ALLOWDELETIONS:
    1584           0 :             rValue <<= (sal_Bool)m_bAllowDelete;
    1585           0 :             break;
    1586             :         case PROPERTY_ID_PRIVILEGES:
    1587           0 :             rValue <<= (sal_Int32)m_nPrivileges;
    1588           0 :             break;
    1589             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1590           2 :             rValue = m_aDynamicControlBorder;
    1591           2 :             break;
    1592             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1593           2 :             rValue = m_aControlBorderColorFocus;
    1594           2 :             break;
    1595             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1596           2 :             rValue = m_aControlBorderColorMouse;
    1597           2 :             break;
    1598             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1599           2 :             rValue = m_aControlBorderColorInvalid;
    1600           2 :             break;
    1601             :         default:
    1602           3 :             if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( nHandle ) )
    1603           0 :                 m_aPropertyBagHelper.getDynamicFastPropertyValue( nHandle, rValue );
    1604             :             else
    1605           3 :                 OPropertySetAggregationHelper::getFastPropertyValue( rValue, nHandle );
    1606           3 :             break;
    1607             :     }
    1608          16 : }
    1609             : 
    1610             : //------------------------------------------------------------------------------
    1611           8 : sal_Bool ODatabaseForm::convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue,
    1612             :                                                 sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
    1613             : {
    1614           8 :     sal_Bool bModified(sal_False);
    1615           8 :     switch (nHandle)
    1616             :     {
    1617             :         case PROPERTY_ID_INSERTONLY:
    1618           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_bInsertOnly );
    1619           0 :             break;
    1620             : 
    1621             :         case PROPERTY_ID_FILTER:
    1622           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter ) );
    1623           0 :             break;
    1624             : 
    1625             :         case PROPERTY_ID_APPLYFILTER:
    1626           1 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.isApplyPublicFilter() );
    1627           1 :             break;
    1628             : 
    1629             :         case PROPERTY_ID_DATASOURCE:
    1630             :         {
    1631           0 :             Any aAggregateProperty;
    1632           0 :             getFastPropertyValue(aAggregateProperty, PROPERTY_ID_DATASOURCE);
    1633           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, aAggregateProperty, ::getCppuType(static_cast<const ::rtl::OUString*>(NULL)));
    1634             :         }
    1635           0 :         break;
    1636             :         case PROPERTY_ID_TARGET_URL:
    1637           1 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetURL);
    1638           1 :             break;
    1639             :         case PROPERTY_ID_TARGET_FRAME:
    1640           1 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aTargetFrame);
    1641           1 :             break;
    1642             :         case PROPERTY_ID_SUBMIT_METHOD:
    1643           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitMethod);
    1644           0 :             break;
    1645             :         case PROPERTY_ID_SUBMIT_ENCODING:
    1646           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eSubmitEncoding);
    1647           0 :             break;
    1648             :         case PROPERTY_ID_NAME:
    1649           4 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_sName);
    1650           4 :             break;
    1651             :         case PROPERTY_ID_MASTERFIELDS:
    1652           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aMasterFields);
    1653           0 :             break;
    1654             :         case PROPERTY_ID_DETAILFIELDS:
    1655           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDetailFields);
    1656           0 :             break;
    1657             :         case PROPERTY_ID_CYCLE:
    1658           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
    1659           0 :             break;
    1660             :         case PROPERTY_ID_NAVIGATION:
    1661           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_eNavigation);
    1662           0 :             break;
    1663             :         case PROPERTY_ID_ALLOWADDITIONS:
    1664           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowInsert);
    1665           0 :             break;
    1666             :         case PROPERTY_ID_ALLOWEDITS:
    1667           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowUpdate);
    1668           0 :             break;
    1669             :         case PROPERTY_ID_ALLOWDELETIONS:
    1670           0 :             bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAllowDelete);
    1671           0 :             break;
    1672             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1673           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aDynamicControlBorder, ::getBooleanCppuType() );
    1674           0 :             break;
    1675             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1676           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aControlBorderColorFocus, getCppuType( static_cast< sal_Int32* >( NULL ) ) );
    1677           0 :             break;
    1678             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1679           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aControlBorderColorMouse, getCppuType( static_cast< sal_Int32* >( NULL ) ) );
    1680           0 :             break;
    1681             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1682           0 :             bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aControlBorderColorInvalid, getCppuType( static_cast< sal_Int32* >( NULL ) ) );
    1683           0 :             break;
    1684             :         default:
    1685           1 :             if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle ( nHandle ) )
    1686           0 :                 bModified = m_aPropertyBagHelper.convertDynamicFastPropertyValue( nHandle, rValue, rConvertedValue, rOldValue );
    1687             :             else
    1688           1 :                 bModified = OPropertySetAggregationHelper::convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
    1689           1 :             break;
    1690             :     }
    1691           8 :     return bModified;
    1692             : }
    1693             : 
    1694             : //------------------------------------------------------------------------------
    1695           5 : void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception )
    1696             : {
    1697           5 :     switch (nHandle)
    1698             :     {
    1699             :         case PROPERTY_ID_INSERTONLY:
    1700           0 :             rValue >>= m_bInsertOnly;
    1701           0 :             if ( m_aIgnoreResult.hasValue() )
    1702           0 :                 m_aIgnoreResult <<= m_bInsertOnly;
    1703             :             else
    1704           0 :                 m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( m_bInsertOnly ) );
    1705           0 :             break;
    1706             : 
    1707             :         case PROPERTY_ID_FILTER:
    1708             :         {
    1709           0 :             ::rtl::OUString sNewFilter;
    1710           0 :             rValue >>= sNewFilter;
    1711           0 :             m_aFilterManager.setFilterComponent( FilterManager::fcPublicFilter, sNewFilter );
    1712             :         }
    1713           0 :         break;
    1714             : 
    1715             :         case PROPERTY_ID_APPLYFILTER:
    1716             :         {
    1717           0 :             sal_Bool bApply = sal_True;
    1718           0 :             rValue >>= bApply;
    1719           0 :             m_aFilterManager.setApplyPublicFilter( bApply );
    1720             :         }
    1721           0 :         break;
    1722             : 
    1723             :         case PROPERTY_ID_DATASOURCE:
    1724             :         {
    1725           0 :             Reference< XConnection > xSomeConnection;
    1726           0 :             if ( ::dbtools::isEmbeddedInDatabase( getParent(), xSomeConnection ) )
    1727           0 :                 throw PropertyVetoException();
    1728             : 
    1729             :             try
    1730             :             {
    1731           0 :                 m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, rValue);
    1732             :             }
    1733           0 :             catch(const Exception&)
    1734             :             {
    1735           0 :             }
    1736             :         }
    1737           0 :         break;
    1738             :         case PROPERTY_ID_TARGET_URL:
    1739           0 :             rValue >>= m_aTargetURL;
    1740           0 :             break;
    1741             :         case PROPERTY_ID_TARGET_FRAME:
    1742           0 :             rValue >>= m_aTargetFrame;
    1743           0 :             break;
    1744             :         case PROPERTY_ID_SUBMIT_METHOD:
    1745           0 :             rValue >>= m_eSubmitMethod;
    1746           0 :             break;
    1747             :         case PROPERTY_ID_SUBMIT_ENCODING:
    1748           0 :             rValue >>= m_eSubmitEncoding;
    1749           0 :             break;
    1750             :         case PROPERTY_ID_NAME:
    1751           4 :             rValue >>= m_sName;
    1752           4 :             break;
    1753             :         case PROPERTY_ID_MASTERFIELDS:
    1754           0 :             rValue >>= m_aMasterFields;
    1755           0 :             invlidateParameters();
    1756           0 :             break;
    1757             :         case PROPERTY_ID_DETAILFIELDS:
    1758           0 :             rValue >>= m_aDetailFields;
    1759           0 :             invlidateParameters();
    1760           0 :             break;
    1761             :         case PROPERTY_ID_CYCLE:
    1762           0 :             m_aCycle = rValue;
    1763           0 :             break;
    1764             :         case PROPERTY_ID_NAVIGATION:
    1765           0 :             rValue >>= m_eNavigation;
    1766           0 :             break;
    1767             :         case PROPERTY_ID_ALLOWADDITIONS:
    1768           0 :             m_bAllowInsert = getBOOL(rValue);
    1769           0 :             break;
    1770             :         case PROPERTY_ID_ALLOWEDITS:
    1771           0 :             m_bAllowUpdate = getBOOL(rValue);
    1772           0 :             break;
    1773             :         case PROPERTY_ID_ALLOWDELETIONS:
    1774           0 :             m_bAllowDelete = getBOOL(rValue);
    1775           0 :             break;
    1776             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1777           0 :             m_aDynamicControlBorder = rValue;
    1778           0 :             break;
    1779             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1780           0 :             m_aControlBorderColorFocus = rValue;
    1781           0 :             break;
    1782             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1783           0 :             m_aControlBorderColorMouse = rValue;
    1784           0 :             break;
    1785             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1786           0 :             m_aControlBorderColorInvalid = rValue;
    1787           0 :             break;
    1788             : 
    1789             :         case PROPERTY_ID_ACTIVE_CONNECTION:
    1790             :         {
    1791           1 :             Reference< XConnection > xOuterConnection;
    1792           1 :             if ( ::dbtools::isEmbeddedInDatabase( getParent(), xOuterConnection ) )
    1793             :             {
    1794           0 :                 if ( xOuterConnection != Reference< XConnection >( rValue, UNO_QUERY ) )
    1795             :                     // somebody's trying to set a connection which is not equal the connection
    1796             :                     // implied by the database we're embedded in
    1797           0 :                     throw PropertyVetoException();
    1798             :             }
    1799           1 :             OPropertySetAggregationHelper::setFastPropertyValue_NoBroadcast( nHandle, rValue );
    1800           1 :             break;
    1801             :         }
    1802             : 
    1803             :         default:
    1804           0 :             if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( nHandle ) )
    1805           0 :                 m_aPropertyBagHelper.setDynamicFastPropertyValue( nHandle, rValue );
    1806             :             else
    1807           0 :                 OPropertySetAggregationHelper::setFastPropertyValue_NoBroadcast( nHandle, rValue );
    1808           0 :             break;
    1809             :     }
    1810           5 : }
    1811             : 
    1812             : //------------------------------------------------------------------
    1813           1 : void SAL_CALL ODatabaseForm::forwardingPropertyValue( sal_Int32 _nHandle )
    1814             : {
    1815             :     OSL_ENSURE( _nHandle == PROPERTY_ID_ACTIVE_CONNECTION, "ODatabaseForm::forwardingPropertyValue: unexpected property!" );
    1816           1 :     if ( _nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
    1817             :     {
    1818           1 :         if ( m_bSharingConnection )
    1819           0 :             stopSharingConnection( );
    1820           1 :         m_bForwardingConnection = sal_True;
    1821             :     }
    1822           1 : }
    1823             : 
    1824             : //------------------------------------------------------------------
    1825           1 : void SAL_CALL ODatabaseForm::forwardedPropertyValue( sal_Int32 _nHandle, bool /*_bSuccess*/ )
    1826             : {
    1827             :     OSL_ENSURE( _nHandle == PROPERTY_ID_ACTIVE_CONNECTION, "ODatabaseForm::forwardedPropertyValue: unexpected property!" );
    1828           1 :     if ( _nHandle == PROPERTY_ID_ACTIVE_CONNECTION )
    1829             :     {
    1830           1 :         m_bForwardingConnection = sal_False;
    1831             :     }
    1832           1 : }
    1833             : 
    1834             : //==============================================================================
    1835             : // com::sun::star::beans::XPropertyState
    1836             : //------------------------------------------------------------------
    1837           0 : PropertyState ODatabaseForm::getPropertyStateByHandle(sal_Int32 nHandle)
    1838             : {
    1839             :     PropertyState eState;
    1840           0 :     switch (nHandle)
    1841             :     {
    1842             :         case PROPERTY_ID_NAVIGATION:
    1843           0 :             return (NavigationBarMode_CURRENT == m_eNavigation) ? PropertyState_DEFAULT_VALUE : PropertyState_DIRECT_VALUE;
    1844             : 
    1845             :         case PROPERTY_ID_CYCLE:
    1846           0 :             eState = m_aCycle.hasValue() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1847           0 :             break;
    1848             : 
    1849             :         case PROPERTY_ID_INSERTONLY:
    1850           0 :             eState = m_bInsertOnly ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1851           0 :             break;
    1852             : 
    1853             :         case PROPERTY_ID_FILTER:
    1854           0 :             if ( m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter ).isEmpty() )
    1855           0 :                 eState = PropertyState_DEFAULT_VALUE;
    1856             :             else
    1857           0 :                 eState = PropertyState_DIRECT_VALUE;
    1858           0 :             break;
    1859             : 
    1860             :         case PROPERTY_ID_APPLYFILTER:
    1861           0 :             eState = m_aFilterManager.isApplyPublicFilter() ? PropertyState_DEFAULT_VALUE : PropertyState_DIRECT_VALUE;
    1862           0 :             break;
    1863             : 
    1864             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1865           0 :             eState = m_aDynamicControlBorder.hasValue() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1866           0 :             break;
    1867             : 
    1868             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1869           0 :             eState = m_aControlBorderColorFocus.hasValue() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1870           0 :             break;
    1871             : 
    1872             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1873           0 :             eState = m_aControlBorderColorMouse.hasValue() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1874           0 :             break;
    1875             : 
    1876             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1877           0 :             eState = m_aControlBorderColorInvalid.hasValue() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1878           0 :             break;
    1879             : 
    1880             :         default:
    1881           0 :             eState = OPropertySetAggregationHelper::getPropertyStateByHandle(nHandle);
    1882             :     }
    1883           0 :     return eState;
    1884             : }
    1885             : 
    1886             : //------------------------------------------------------------------
    1887           0 : void ODatabaseForm::setPropertyToDefaultByHandle(sal_Int32 nHandle)
    1888             : {
    1889           0 :     switch (nHandle)
    1890             :     {
    1891             :         case PROPERTY_ID_INSERTONLY:
    1892             :         case PROPERTY_ID_FILTER:
    1893             :         case PROPERTY_ID_APPLYFILTER:
    1894             :         case PROPERTY_ID_NAVIGATION:
    1895             :         case PROPERTY_ID_CYCLE:
    1896             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1897             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1898             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1899             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1900           0 :             setFastPropertyValue( nHandle, getPropertyDefaultByHandle( nHandle ) );
    1901           0 :             break;
    1902             : 
    1903             :         default:
    1904           0 :             OPropertySetAggregationHelper::setPropertyToDefaultByHandle(nHandle);
    1905             :     }
    1906           0 : }
    1907             : 
    1908             : //------------------------------------------------------------------
    1909           0 : Any ODatabaseForm::getPropertyDefaultByHandle( sal_Int32 nHandle ) const
    1910             : {
    1911           0 :     Any aReturn;
    1912           0 :     switch (nHandle)
    1913             :     {
    1914             :         case PROPERTY_ID_INSERTONLY:
    1915             :         case PROPERTY_ID_DYNAMIC_CONTROL_BORDER:
    1916           0 :             aReturn <<= sal_False;
    1917           0 :             break;
    1918             : 
    1919             :         case PROPERTY_ID_FILTER:
    1920           0 :             aReturn <<= ::rtl::OUString();
    1921           0 :             break;
    1922             : 
    1923             :         case PROPERTY_ID_APPLYFILTER:
    1924           0 :             aReturn <<= sal_True;
    1925           0 :             break;
    1926             : 
    1927             :         case PROPERTY_ID_NAVIGATION:
    1928           0 :             aReturn = makeAny(NavigationBarMode_CURRENT);
    1929           0 :             break;
    1930             : 
    1931             :         case PROPERTY_ID_CYCLE:
    1932             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_FOCUS:
    1933             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_MOUSE:
    1934             :         case PROPERTY_ID_CONTROL_BORDER_COLOR_INVALID:
    1935           0 :             break;
    1936             : 
    1937             :         default:
    1938           0 :             if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( nHandle ) )
    1939           0 :                 m_aPropertyBagHelper.getDynamicPropertyDefaultByHandle( nHandle, aReturn );
    1940             :             else
    1941           0 :                 aReturn = OPropertySetAggregationHelper::getPropertyDefaultByHandle( nHandle );
    1942           0 :             break;
    1943             :     }
    1944           0 :     return aReturn;
    1945             : }
    1946             : 
    1947             : //==============================================================================
    1948             : // com::sun::star::form::XReset
    1949             : //------------------------------------------------------------------------------
    1950           0 : void SAL_CALL ODatabaseForm::reset() throw( RuntimeException )
    1951             : {
    1952           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    1953             : 
    1954           0 :     if (isLoaded())
    1955             :     {
    1956           0 :         ::osl::MutexGuard aResetGuard(m_aResetSafety);
    1957           0 :         ++m_nResetsPending;
    1958           0 :         reset_impl(true);
    1959           0 :         return;
    1960             :     }
    1961             : 
    1962           0 :     if ( !m_aResetListeners.empty() )
    1963             :     {
    1964           0 :         ::osl::MutexGuard aResetGuard(m_aResetSafety);
    1965           0 :         ++m_nResetsPending;
    1966             :         // create an own thread if we have (approve-)reset-listeners (so the listeners can't do that much damage
    1967             :         // to this thread which is probably the main one)
    1968           0 :         if (!m_pThread)
    1969             :         {
    1970           0 :             m_pThread = new OFormSubmitResetThread(this);
    1971           0 :             m_pThread->acquire();
    1972           0 :             m_pThread->create();
    1973             :         }
    1974           0 :         EventObject aEvt;
    1975           0 :         m_pThread->addEvent(&aEvt, sal_False);
    1976             :     }
    1977             :     else
    1978             :     {
    1979             :         // direct call without any approving by the listeners
    1980           0 :         aGuard.clear();
    1981             : 
    1982           0 :         ::osl::MutexGuard aResetGuard(m_aResetSafety);
    1983           0 :         ++m_nResetsPending;
    1984           0 :         reset_impl(false);
    1985           0 :     }
    1986             : }
    1987             : 
    1988             : //-----------------------------------------------------------------------------
    1989           0 : void ODatabaseForm::reset_impl(bool _bAproveByListeners)
    1990             : {
    1991           0 :     if ( _bAproveByListeners )
    1992           0 :         if ( !m_aResetListeners.approveReset() )
    1993           0 :             return;
    1994             : 
    1995           0 :     ::osl::ResettableMutexGuard aResetGuard(m_aResetSafety);
    1996             :     // do we have a database connected form and stay on the insert row
    1997           0 :     sal_Bool bInsertRow = sal_False;
    1998           0 :     if (m_xAggregateSet.is())
    1999           0 :         bInsertRow = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW));
    2000           0 :     if (bInsertRow)
    2001             :     {
    2002             :         try
    2003             :         {
    2004             :             // Iterate through all columns and set the default value
    2005           0 :             Reference< XColumnsSupplier > xColsSuppl( m_xAggregateSet, UNO_QUERY );
    2006           0 :             Reference< XIndexAccess > xIndexCols( xColsSuppl->getColumns(), UNO_QUERY );
    2007           0 :             for (sal_Int32 i = 0; i < xIndexCols->getCount(); ++i)
    2008             :             {
    2009           0 :                 Reference< XPropertySet > xColProps;
    2010           0 :                 xIndexCols->getByIndex(i) >>= xColProps;
    2011             : 
    2012           0 :                 Reference< XColumnUpdate > xColUpdate( xColProps, UNO_QUERY );
    2013           0 :                 if ( !xColUpdate.is() )
    2014           0 :                     continue;
    2015             : 
    2016           0 :                 Reference< XPropertySetInfo > xPSI;
    2017           0 :                 if ( xColProps.is() )
    2018           0 :                     xPSI = xColProps->getPropertySetInfo( );
    2019             : 
    2020           0 :                 static const ::rtl::OUString PROPERTY_CONTROLDEFAULT( RTL_CONSTASCII_USTRINGPARAM( "ControlDefault" ) );
    2021           0 :                 if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) )
    2022             :                 {
    2023           0 :                     Any aDefault = xColProps->getPropertyValue( PROPERTY_CONTROLDEFAULT );
    2024             : 
    2025           0 :                     sal_Bool bReadOnly = sal_False;
    2026           0 :                     if ( xPSI->hasPropertyByName( PROPERTY_ISREADONLY ) )
    2027           0 :                         xColProps->getPropertyValue( PROPERTY_ISREADONLY ) >>= bReadOnly;
    2028             : 
    2029           0 :                     if ( !bReadOnly )
    2030             :                     {
    2031             :                         try
    2032             :                         {
    2033           0 :                             if ( aDefault.hasValue() )
    2034           0 :                                 xColUpdate->updateObject( aDefault );
    2035             :                         }
    2036           0 :                         catch(const Exception&)
    2037             :                         {
    2038             :                             DBG_UNHANDLED_EXCEPTION();
    2039             :                         }
    2040           0 :                     }
    2041             :                 }
    2042           0 :             }
    2043             :         }
    2044           0 :         catch(const Exception&)
    2045             :         {
    2046             :         }
    2047             : 
    2048           0 :         if (m_bSubForm)
    2049             :         {
    2050           0 :             Reference< XColumnsSupplier > xParentColSupp( m_xParent, UNO_QUERY );
    2051           0 :             Reference< XNameAccess >      xParentCols;
    2052           0 :             if ( xParentColSupp.is() )
    2053           0 :                 xParentCols = xParentColSupp->getColumns();
    2054             : 
    2055           0 :             if ( xParentCols.is() && xParentCols->hasElements() && m_aMasterFields.getLength() )
    2056             :             {
    2057             :                 try
    2058             :                 {
    2059             :                     // analyze our parameters
    2060           0 :                     if ( !m_aParameterManager.isUpToDate() )
    2061           0 :                         updateParameterInfo();
    2062             : 
    2063           0 :                     m_aParameterManager.resetParameterValues( );
    2064             :                 }
    2065           0 :                 catch(const Exception&)
    2066             :                 {
    2067             :                     OSL_FAIL("ODatabaseForm::reset_impl: could not initialize the master-detail-driven parameters!");
    2068             :                 }
    2069           0 :             }
    2070             :         }
    2071             :     }
    2072             : 
    2073           0 :     aResetGuard.clear();
    2074             :     // iterate through all components. don't use an XIndexAccess as this will cause massive
    2075             :     // problems with the count.
    2076           0 :     Reference<XEnumeration>  xIter = createEnumeration();
    2077           0 :     while (xIter->hasMoreElements())
    2078             :     {
    2079           0 :         Reference<XReset> xReset;
    2080           0 :         xIter->nextElement() >>= xReset;
    2081           0 :         if (xReset.is())
    2082             :         {
    2083             :             // TODO : all reset-methods have to be thread-safe
    2084           0 :             xReset->reset();
    2085             :         }
    2086           0 :     }
    2087             : 
    2088           0 :     aResetGuard.reset();
    2089             :     // ensure that the row isn't modified
    2090             :     // (do this _before_ the listeners are notified ! their reaction (maybe asynchronous) may depend
    2091             :     // on the modified state of the row)
    2092           0 :     if (bInsertRow)
    2093           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, ::cppu::bool2any(sal_Bool(sal_False)));
    2094             : 
    2095           0 :     aResetGuard.clear();
    2096             :     {
    2097           0 :         m_aResetListeners.resetted();
    2098             :     }
    2099             : 
    2100           0 :     aResetGuard.reset();
    2101             :     // and again : ensure the row isn't modified
    2102             :     // we already did this after we (and maybe our dependents) resetted the values, but the listeners may have changed the row, too
    2103           0 :     if (bInsertRow)
    2104           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_ISMODIFIED, ::cppu::bool2any((sal_False)));
    2105             : 
    2106           0 :     --m_nResetsPending;
    2107             : }
    2108             : 
    2109             : //-----------------------------------------------------------------------------
    2110           0 : void SAL_CALL ODatabaseForm::addResetListener(const Reference<XResetListener>& _rListener) throw( RuntimeException )
    2111             : {
    2112           0 :     m_aResetListeners.addTypedListener( _rListener );
    2113           0 : }
    2114             : 
    2115             : //-----------------------------------------------------------------------------
    2116           0 : void SAL_CALL ODatabaseForm::removeResetListener(const Reference<XResetListener>& _rListener) throw( RuntimeException )
    2117             : {
    2118           0 :     m_aResetListeners.removeTypedListener( _rListener );
    2119           0 : }
    2120             : 
    2121             : //==============================================================================
    2122             : // com::sun::star::form::XSubmit
    2123             : //------------------------------------------------------------------------------
    2124           0 : void SAL_CALL ODatabaseForm::submit( const Reference<XControl>& Control,
    2125             :                               const ::com::sun::star::awt::MouseEvent& MouseEvt ) throw( RuntimeException )
    2126             : {
    2127             :     {
    2128           0 :         ::osl::MutexGuard aGuard(m_aMutex);
    2129             :         // Do we have controls and a Submit URL?
    2130           0 :         if( !getCount() || m_aTargetURL.isEmpty() )
    2131           0 :             return;
    2132             :     }
    2133             : 
    2134           0 :     ::osl::ClearableMutexGuard aGuard(m_aMutex);
    2135           0 :     if (m_aSubmitListeners.getLength())
    2136             :     {
    2137             :         // create an own thread if we have (approve-)submit-listeners (so the listeners can't do that much damage
    2138             :         // to this thread which is probably the main one)
    2139           0 :         if (!m_pThread)
    2140             :         {
    2141           0 :             m_pThread = new OFormSubmitResetThread(this);
    2142           0 :             m_pThread->acquire();
    2143           0 :             m_pThread->create();
    2144             :         }
    2145           0 :         m_pThread->addEvent(&MouseEvt, Control, sal_True);
    2146             :     }
    2147             :     else
    2148             :     {
    2149             :         // direct call without any approving by the listeners
    2150           0 :         aGuard.clear();
    2151           0 :         submit_impl( Control, MouseEvt, true );
    2152           0 :     }
    2153             : }
    2154             : // -----------------------------------------------------------------------------
    2155           0 : void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLTransformer>& xTransformer,const ::rtl::OUString& aURLStr,const ::rtl::OUString& aReferer,const ::rtl::OUString& aTargetName
    2156             :                   ,const ::rtl::OUString& aData,rtl_TextEncoding _eEncoding)
    2157             : {
    2158           0 :     URL aURL;
    2159           0 :     aURL.Complete = aURLStr;
    2160           0 :     xTransformer->parseStrict(aURL);
    2161             : 
    2162           0 :     Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
    2163             :         FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
    2164           0 :         FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
    2165             : 
    2166           0 :     if (xDisp.is())
    2167             :     {
    2168           0 :         Sequence<PropertyValue> aArgs(2);
    2169           0 :         aArgs.getArray()[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer") );
    2170           0 :         aArgs.getArray()[0].Value <<= aReferer;
    2171             : 
    2172             :         // build a sequence from the to-be-submitted string
    2173           0 :         rtl::OString a8BitData(rtl::OUStringToOString(aData, _eEncoding));
    2174             :         // always ANSI #58641
    2175           0 :         Sequence< sal_Int8 > aPostData((const sal_Int8*)a8BitData.getStr(), a8BitData.getLength());
    2176           0 :         Reference< XInputStream > xPostData = new SequenceInputStream(aPostData);
    2177             : 
    2178           0 :         aArgs.getArray()[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PostData") );
    2179           0 :         aArgs.getArray()[1].Value <<= xPostData;
    2180             : 
    2181           0 :         xDisp->dispatch(aURL, aArgs);
    2182           0 :     } // if (xDisp.is())
    2183           0 : }
    2184             : //------------------------------------------------------------------------------
    2185           0 : void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const ::com::sun::star::awt::MouseEvent& MouseEvt, bool _bAproveByListeners)
    2186             : {
    2187             : 
    2188           0 :     if (_bAproveByListeners)
    2189             :     {
    2190           0 :         ::cppu::OInterfaceIteratorHelper aIter(m_aSubmitListeners);
    2191           0 :         EventObject aEvt(static_cast<XWeak*>(this));
    2192           0 :         sal_Bool bCanceled = sal_False;
    2193           0 :         while (aIter.hasMoreElements() && !bCanceled)
    2194             :         {
    2195           0 :             if (!((XSubmitListener*)aIter.next())->approveSubmit(aEvt))
    2196           0 :                 bCanceled = sal_True;
    2197             :         }
    2198             : 
    2199           0 :         if (bCanceled)
    2200           0 :             return;
    2201             :     }
    2202             : 
    2203             :     FormSubmitEncoding eSubmitEncoding;
    2204             :     FormSubmitMethod eSubmitMethod;
    2205           0 :     ::rtl::OUString aURLStr;
    2206           0 :     ::rtl::OUString aReferer;
    2207           0 :     ::rtl::OUString aTargetName;
    2208           0 :     Reference< XModel >  xModel;
    2209             :     {
    2210           0 :         SolarMutexGuard aGuard;
    2211             :         // starform->Forms
    2212             : 
    2213           0 :         Reference<XChild>  xParent(m_xParent, UNO_QUERY);
    2214             : 
    2215           0 :         if (xParent.is())
    2216           0 :             xModel = getXModel(xParent->getParent());
    2217             : 
    2218           0 :         if (xModel.is())
    2219           0 :             aReferer = xModel->getURL();
    2220             : 
    2221             :         // TargetItem
    2222           0 :         aTargetName = m_aTargetFrame;
    2223             : 
    2224           0 :         eSubmitEncoding = m_eSubmitEncoding;
    2225           0 :         eSubmitMethod = m_eSubmitMethod;
    2226           0 :         aURLStr = m_aTargetURL;
    2227             :     }
    2228             : 
    2229           0 :     if (!xModel.is())
    2230             :         return;
    2231           0 :     Reference< XFrame >  xFrame = xModel->getCurrentController()->getFrame();
    2232           0 :     if (!xFrame.is())
    2233             :         return;
    2234             : 
    2235           0 :     Reference<XURLTransformer> xTransformer(URLTransformer::create(comphelper::getComponentContext(m_xServiceFactory)));
    2236             : 
    2237             :     // URL encoding
    2238           0 :     if( eSubmitEncoding == FormSubmitEncoding_URL )
    2239             :     {
    2240           0 :         ::rtl::OUString aData;
    2241             :         {
    2242           0 :             SolarMutexGuard aGuard;
    2243           0 :             aData = GetDataURLEncoded( Control, MouseEvt );
    2244             :         }
    2245             : 
    2246           0 :         URL aURL;
    2247             :         // FormMethod GET
    2248           0 :         if( eSubmitMethod == FormSubmitMethod_GET )
    2249             :         {
    2250           0 :             INetURLObject aUrlObj( aURLStr, INetURLObject::WAS_ENCODED );
    2251           0 :             aUrlObj.SetParam( aData, INetURLObject::ENCODE_ALL );
    2252           0 :             aURL.Complete = aUrlObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
    2253           0 :             if (xTransformer.is())
    2254           0 :                 xTransformer->parseStrict(aURL);
    2255             : 
    2256           0 :             Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
    2257             :                     FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
    2258           0 :                     FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
    2259             : 
    2260           0 :             if (xDisp.is())
    2261             :             {
    2262           0 :                 Sequence<PropertyValue> aArgs(1);
    2263           0 :                 aArgs.getArray()->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer") );
    2264           0 :                 aArgs.getArray()->Value <<= aReferer;
    2265           0 :                 xDisp->dispatch(aURL, aArgs);
    2266           0 :             }
    2267             :         }
    2268             :         // FormMethod POST
    2269           0 :         else if( eSubmitMethod == FormSubmitMethod_POST )
    2270             :         {
    2271           0 :             lcl_dispatch(xFrame,xTransformer,aURLStr,aReferer,aTargetName,aData,RTL_TEXTENCODING_MS_1252);
    2272           0 :         }
    2273             :     }
    2274           0 :     else if( eSubmitEncoding == FormSubmitEncoding_MULTIPART )
    2275             :     {
    2276           0 :         URL aURL;
    2277           0 :         aURL.Complete = aURLStr;
    2278           0 :         xTransformer->parseStrict(aURL);
    2279             : 
    2280           0 :         Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
    2281             :                 FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
    2282           0 :                 FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
    2283             : 
    2284           0 :         if (xDisp.is())
    2285             :         {
    2286           0 :             ::rtl::OUString aContentType;
    2287           0 :             Sequence<sal_Int8> aData;
    2288             :             {
    2289           0 :                 SolarMutexGuard aGuard;
    2290           0 :                 aData = GetDataMultiPartEncoded(Control, MouseEvt, aContentType);
    2291             :             }
    2292           0 :             if (!aData.getLength())
    2293             :                 return;
    2294             : 
    2295           0 :             Sequence<PropertyValue> aArgs(3);
    2296           0 :             aArgs.getArray()[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer") );
    2297           0 :             aArgs.getArray()[0].Value <<= aReferer;
    2298           0 :             aArgs.getArray()[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContentType") );
    2299           0 :             aArgs.getArray()[1].Value <<= aContentType;
    2300             : 
    2301             :             // build a sequence from the to-be-submitted string
    2302           0 :             Reference< XInputStream > xPostData = new SequenceInputStream(aData);
    2303             : 
    2304           0 :             aArgs.getArray()[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PostData") );
    2305           0 :             aArgs.getArray()[2].Value <<= xPostData;
    2306             : 
    2307           0 :             xDisp->dispatch(aURL, aArgs);
    2308           0 :         }
    2309             :     }
    2310           0 :     else if( eSubmitEncoding == FormSubmitEncoding_TEXT )
    2311             :     {
    2312           0 :         ::rtl::OUString aData;
    2313             :         {
    2314           0 :             SolarMutexGuard aGuard;
    2315           0 :             aData = GetDataTextEncoded( Reference<XControl> (), MouseEvt );
    2316             :         }
    2317             : 
    2318           0 :         lcl_dispatch(xFrame,xTransformer,aURLStr,aReferer,aTargetName,aData,osl_getThreadTextEncoding());
    2319             :     }
    2320             :     else {
    2321             :         OSL_FAIL("ODatabaseForm::submit_Impl : wrong encoding !");
    2322           0 :     }
    2323             : 
    2324             : }
    2325             : 
    2326             : // XSubmit
    2327             : //------------------------------------------------------------------------------
    2328           0 : void SAL_CALL ODatabaseForm::addSubmitListener(const Reference<XSubmitListener>& _rListener) throw( RuntimeException )
    2329             : {
    2330           0 :     m_aSubmitListeners.addInterface(_rListener);
    2331           0 : }
    2332             : 
    2333             : //------------------------------------------------------------------------------
    2334           0 : void SAL_CALL ODatabaseForm::removeSubmitListener(const Reference<XSubmitListener>& _rListener) throw( RuntimeException )
    2335             : {
    2336           0 :     m_aSubmitListeners.removeInterface(_rListener);
    2337           0 : }
    2338             : 
    2339             : //==============================================================================
    2340             : // com::sun::star::sdbc::XSQLErrorBroadcaster
    2341             : //------------------------------------------------------------------------------
    2342           2 : void SAL_CALL ODatabaseForm::addSQLErrorListener(const Reference<XSQLErrorListener>& _rListener) throw( RuntimeException )
    2343             : {
    2344           2 :     m_aErrorListeners.addInterface(_rListener);
    2345           2 : }
    2346             : 
    2347             : //------------------------------------------------------------------------------
    2348           1 : void SAL_CALL ODatabaseForm::removeSQLErrorListener(const Reference<XSQLErrorListener>& _rListener) throw( RuntimeException )
    2349             : {
    2350           1 :     m_aErrorListeners.removeInterface(_rListener);
    2351           1 : }
    2352             : 
    2353             : //------------------------------------------------------------------------------
    2354           1 : void ODatabaseForm::invlidateParameters()
    2355             : {
    2356           1 :     ::osl::MutexGuard aGuard(m_aMutex);
    2357           1 :     m_aParameterManager.clearAllParameterInformation();
    2358           1 : }
    2359             : 
    2360             : //==============================================================================
    2361             : // OChangeListener
    2362             : //------------------------------------------------------------------------------
    2363           1 : void ODatabaseForm::_propertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException )
    2364             : {
    2365           1 :     if ((evt.PropertyName.equalsAsciiL(PROPERTY_ACTIVE_CONNECTION.ascii, PROPERTY_ACTIVE_CONNECTION.length)) && !m_bForwardingConnection)
    2366             :     {
    2367             :         // the rowset changed its active connection itself (without interaction from our side), so
    2368             :         // we need to fire this event, too
    2369           0 :         sal_Int32 nHandle = PROPERTY_ID_ACTIVE_CONNECTION;
    2370           0 :         fire(&nHandle, &evt.NewValue, &evt.OldValue, 1, sal_False);
    2371             :     }
    2372             :     else    // it was one of the statement relevant props
    2373             :     {
    2374             :         // if the statement has changed we have to delete the parameter info
    2375           1 :         invlidateParameters();
    2376             :     }
    2377           1 : }
    2378             : 
    2379             : //==============================================================================
    2380             : // smartXChild
    2381             : //------------------------------------------------------------------------------
    2382           4 : void SAL_CALL ODatabaseForm::setParent(const InterfaceRef& Parent) throw ( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException)
    2383             : {
    2384             :     // SYNCHRONIZED ----->
    2385           4 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2386             : 
    2387           4 :     Reference<XForm>  xParentForm(getParent(), UNO_QUERY);
    2388           4 :     if (xParentForm.is())
    2389             :     {
    2390             :         try
    2391             :         {
    2392           0 :             Reference< XRowSetApproveBroadcaster > xParentApprBroadcast( xParentForm, UNO_QUERY_THROW );
    2393           0 :             xParentApprBroadcast->removeRowSetApproveListener( this );
    2394             : 
    2395           0 :             Reference< XLoadable > xParentLoadable( xParentForm, UNO_QUERY_THROW );
    2396           0 :             xParentLoadable->removeLoadListener( this );
    2397             : 
    2398           0 :             Reference< XPropertySet > xParentProperties( xParentForm, UNO_QUERY_THROW );
    2399           0 :             xParentProperties->removePropertyChangeListener( PROPERTY_ISNEW, this );
    2400             :         }
    2401           0 :         catch(const Exception&)
    2402             :         {
    2403             :             DBG_UNHANDLED_EXCEPTION();
    2404             :         }
    2405             :     }
    2406             : 
    2407           4 :     OFormComponents::setParent(Parent);
    2408             : 
    2409           4 :     xParentForm.set(getParent(), UNO_QUERY);
    2410           4 :     if ( xParentForm.is() )
    2411             :     {
    2412             :         try
    2413             :         {
    2414           0 :             Reference< XRowSetApproveBroadcaster > xParentApprBroadcast( xParentForm, UNO_QUERY_THROW );
    2415           0 :             xParentApprBroadcast->addRowSetApproveListener( this );
    2416             : 
    2417           0 :             Reference< XLoadable > xParentLoadable( xParentForm, UNO_QUERY_THROW );
    2418           0 :             xParentLoadable->addLoadListener( this );
    2419             : 
    2420           0 :             Reference< XPropertySet > xParentProperties( xParentForm, UNO_QUERY_THROW );
    2421           0 :             xParentProperties->addPropertyChangeListener( PROPERTY_ISNEW, this );
    2422             :         }
    2423           0 :         catch(const Exception&)
    2424             :         {
    2425             :             DBG_UNHANDLED_EXCEPTION();
    2426             :         }
    2427             :     }
    2428             : 
    2429           4 :     Reference< XPropertySet > xAggregateProperties( m_xAggregateSet );
    2430           4 :     aGuard.clear();
    2431             :     // <----- SYNCHRONIZED
    2432             : 
    2433           4 :     Reference< XConnection > xOuterConnection;
    2434           4 :     sal_Bool bIsEmbedded = ::dbtools::isEmbeddedInDatabase( Parent, xOuterConnection );
    2435             : 
    2436           4 :     if ( bIsEmbedded )
    2437           0 :         xAggregateProperties->setPropertyValue( PROPERTY_DATASOURCE, makeAny( ::rtl::OUString() ) );
    2438           4 : }
    2439             : 
    2440             : //==============================================================================
    2441             : // smartXTabControllerModel
    2442             : //------------------------------------------------------------------------------
    2443           5 : sal_Bool SAL_CALL ODatabaseForm::getGroupControl() throw(com::sun::star::uno::RuntimeException)
    2444             : {
    2445           5 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2446             : 
    2447             :     // Should controls be combined into a TabOrder group?
    2448           5 :     if (m_aCycle.hasValue())
    2449             :     {
    2450           0 :         sal_Int32 nCycle = 0;
    2451           0 :         ::cppu::enum2int(nCycle, m_aCycle);
    2452           0 :         return nCycle != TabulatorCycle_PAGE;
    2453             :     }
    2454             : 
    2455           5 :     if (isLoaded() && getConnection().is())
    2456           0 :         return sal_True;
    2457             : 
    2458           5 :     return sal_False;
    2459             : }
    2460             : 
    2461             : //------------------------------------------------------------------------------
    2462           0 : void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlModel> >& rControls) throw( RuntimeException )
    2463             : {
    2464           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2465             : 
    2466             :     // Set TabIndex in the order of the sequence
    2467           0 :     const Reference<XControlModel>* pControls = rControls.getConstArray();
    2468           0 :     sal_Int32 nCount = getCount();
    2469           0 :     sal_Int32 nNewCount = rControls.getLength();
    2470             : 
    2471             :     // HiddenControls and forms are not listed
    2472           0 :     if (nNewCount <= nCount)
    2473             :     {
    2474           0 :         Any aElement;
    2475           0 :         sal_Int16 nTabIndex = 1;
    2476           0 :         for (sal_Int32 i=0; i < nNewCount; ++i, ++pControls)
    2477             :         {
    2478           0 :             Reference<XFormComponent>  xComp(*pControls, UNO_QUERY);
    2479           0 :             if (xComp.is())
    2480             :             {
    2481             :                 // Find component in the list
    2482           0 :                 for (sal_Int32 j = 0; j < nCount; ++j)
    2483             :                 {
    2484           0 :                     Reference<XFormComponent> xElement;
    2485           0 :                     ::cppu::extractInterface(xElement, getByIndex(j));
    2486           0 :                     if (xComp == xElement)
    2487             :                     {
    2488           0 :                         Reference<XPropertySet>  xSet(xComp, UNO_QUERY);
    2489           0 :                         if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet))
    2490           0 :                             xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) );
    2491           0 :                         break;
    2492             :                     }
    2493           0 :                 }
    2494             :             }
    2495           0 :         }
    2496           0 :     }
    2497           0 : }
    2498             : 
    2499             : //------------------------------------------------------------------------------
    2500           9 : Sequence<Reference<XControlModel> > SAL_CALL ODatabaseForm::getControlModels() throw( RuntimeException )
    2501             : {
    2502           9 :     ::osl::MutexGuard aGuard(m_aMutex);
    2503           9 :     return m_pGroupManager->getControlModels();
    2504             : }
    2505             : 
    2506             : //------------------------------------------------------------------------------
    2507           0 : void SAL_CALL ODatabaseForm::setGroup( const Sequence<Reference<XControlModel> >& _rGroup, const ::rtl::OUString& Name ) throw( RuntimeException )
    2508             : {
    2509           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2510             : 
    2511             :     // The controls are grouped by adjusting their names to the name of the
    2512             :     // first control of the sequence
    2513           0 :     const Reference<XControlModel>* pControls = _rGroup.getConstArray();
    2514           0 :     Reference< XPropertySet > xSet;
    2515           0 :     ::rtl::OUString sGroupName( Name );
    2516             : 
    2517           0 :     for( sal_Int32 i=0; i<_rGroup.getLength(); ++i, ++pControls )
    2518             :     {
    2519           0 :         xSet = xSet.query( *pControls );
    2520           0 :         if ( !xSet.is() )
    2521             :         {
    2522             :             // can't throw an exception other than a RuntimeException (which would not be appropriate),
    2523             :             // so we ignore (and only assert) this
    2524             :             OSL_FAIL( "ODatabaseForm::setGroup: invalid arguments!" );
    2525           0 :             continue;
    2526             :         }
    2527             : 
    2528           0 :         if (sGroupName.isEmpty())
    2529           0 :             xSet->getPropertyValue(PROPERTY_NAME) >>= sGroupName;
    2530             :         else
    2531           0 :             xSet->setPropertyValue(PROPERTY_NAME, makeAny(sGroupName));
    2532           0 :     }
    2533           0 : }
    2534             : 
    2535             : //------------------------------------------------------------------------------
    2536           5 : sal_Int32 SAL_CALL ODatabaseForm::getGroupCount() throw( RuntimeException )
    2537             : {
    2538           5 :     ::osl::MutexGuard aGuard(m_aMutex);
    2539           5 :     return m_pGroupManager->getGroupCount();
    2540             : }
    2541             : 
    2542             : //------------------------------------------------------------------------------
    2543           0 : void SAL_CALL ODatabaseForm::getGroup( sal_Int32 nGroup, Sequence<Reference<XControlModel> >& _rGroup, ::rtl::OUString& _rName ) throw( RuntimeException )
    2544             : {
    2545           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2546           0 :     _rGroup.realloc(0);
    2547           0 :     _rName = ::rtl::OUString();
    2548             : 
    2549           0 :     if ((nGroup < 0) || (nGroup >= m_pGroupManager->getGroupCount()))
    2550           0 :         return;
    2551           0 :     m_pGroupManager->getGroup( nGroup, _rGroup, _rName  );
    2552             : }
    2553             : 
    2554             : //------------------------------------------------------------------------------
    2555           0 : void SAL_CALL ODatabaseForm::getGroupByName(const ::rtl::OUString& Name, Sequence< Reference<XControlModel>  >& _rGroup) throw( RuntimeException )
    2556             : {
    2557           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2558           0 :     _rGroup.realloc(0);
    2559           0 :     m_pGroupManager->getGroupByName( Name, _rGroup );
    2560           0 : }
    2561             : 
    2562             : //==============================================================================
    2563             : // com::sun::star::lang::XEventListener
    2564             : //------------------------------------------------------------------------------
    2565           0 : void SAL_CALL ODatabaseForm::disposing(const EventObject& Source) throw( RuntimeException )
    2566             : {
    2567             :     // does the call come from the connection which we are sharing with our parent?
    2568           0 :     if ( isSharingConnection() )
    2569             :     {
    2570           0 :         Reference< XConnection > xConnSource( Source.Source, UNO_QUERY );
    2571           0 :         if ( xConnSource.is() )
    2572             :         {
    2573             : #if OSL_DEBUG_LEVEL > 0
    2574             :             Reference< XConnection > xActiveConn;
    2575             :             m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xActiveConn;
    2576             :             OSL_ENSURE( xActiveConn.get() == xConnSource.get(), "ODatabaseForm::disposing: where did this come from?" );
    2577             :                 // there should be exactly one XConnection object we're listening at - our aggregate connection
    2578             : #endif
    2579           0 :             disposingSharedConnection( xConnSource );
    2580           0 :         }
    2581             :     }
    2582             : 
    2583           0 :     OInterfaceContainer::disposing(Source);
    2584             : 
    2585             :     // does the disposing come from the aggregate ?
    2586           0 :     if (m_xAggregate.is())
    2587             :     {   // no -> forward it
    2588           0 :         com::sun::star::uno::Reference<com::sun::star::lang::XEventListener> xListener;
    2589           0 :         if (query_aggregation(m_xAggregate, xListener))
    2590           0 :             xListener->disposing(Source);
    2591             :     }
    2592           0 : }
    2593             : 
    2594             : //------------------------------------------------------------------------------
    2595           0 : void ODatabaseForm::impl_createLoadTimer()
    2596             : {
    2597             :     OSL_PRECOND( m_pLoadTimer == NULL, "ODatabaseForm::impl_createLoadTimer: timer already exists!" );
    2598           0 :     m_pLoadTimer = new Timer();
    2599           0 :     m_pLoadTimer->SetTimeout(100);
    2600           0 :     m_pLoadTimer->SetTimeoutHdl(LINK(this,ODatabaseForm,OnTimeout));
    2601           0 : }
    2602             : 
    2603             : //==============================================================================
    2604             : // com::sun::star::form::XLoadListener
    2605             : //------------------------------------------------------------------------------
    2606           0 : void SAL_CALL ODatabaseForm::loaded(const EventObject& /*aEvent*/) throw( RuntimeException )
    2607             : {
    2608             :     {
    2609           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    2610           0 :         Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW );
    2611           0 :         xParentRowSet->addRowSetListener( this );
    2612             : 
    2613           0 :         impl_createLoadTimer();
    2614             :     }
    2615             : 
    2616           0 :     load_impl( sal_True );
    2617           0 : }
    2618             : 
    2619             : //------------------------------------------------------------------------------
    2620           0 : void SAL_CALL ODatabaseForm::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
    2621             : {
    2622             :     {
    2623             :         // now stop the rowset listening if we are a subform
    2624           0 :         ::osl::MutexGuard aGuard( m_aMutex );
    2625             : 
    2626           0 :         if ( m_pLoadTimer && m_pLoadTimer->IsActive() )
    2627           0 :             m_pLoadTimer->Stop();
    2628           0 :         DELETEZ( m_pLoadTimer );
    2629             : 
    2630           0 :         Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW );
    2631           0 :         xParentRowSet->removeRowSetListener( this );
    2632             :     }
    2633             : 
    2634           0 :     unload();
    2635           0 : }
    2636             : 
    2637             : //------------------------------------------------------------------------------
    2638           0 : void SAL_CALL ODatabaseForm::unloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
    2639             : {
    2640             :     // nothing to do
    2641           0 : }
    2642             : 
    2643             : //------------------------------------------------------------------------------
    2644           0 : void SAL_CALL ODatabaseForm::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
    2645             : {
    2646             :     // now stop the rowset listening if we are a subform
    2647           0 :     ::osl::MutexGuard aGuard(m_aMutex);
    2648           0 :     Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
    2649           0 :     if (xParentRowSet.is())
    2650           0 :         xParentRowSet->removeRowSetListener(this);
    2651             : 
    2652           0 :     if (m_pLoadTimer && m_pLoadTimer->IsActive())
    2653           0 :         m_pLoadTimer->Stop();
    2654           0 : }
    2655             : 
    2656             : //------------------------------------------------------------------------------
    2657           0 : void SAL_CALL ODatabaseForm::reloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
    2658             : {
    2659           0 :     reload_impl(sal_True);
    2660             :     {
    2661           0 :         ::osl::MutexGuard aGuard(m_aMutex);
    2662           0 :         Reference<XRowSet>  xParentRowSet(m_xParent, UNO_QUERY);
    2663           0 :         if (xParentRowSet.is())
    2664           0 :             xParentRowSet->addRowSetListener(this);
    2665             :     }
    2666           0 : }
    2667             : 
    2668             : //------------------------------------------------------------------------------
    2669           0 : IMPL_LINK_NOARG(ODatabaseForm, OnTimeout)
    2670             : {
    2671           0 :     reload_impl(sal_True);
    2672           0 :     return 1;
    2673             : }
    2674             : 
    2675             : //==============================================================================
    2676             : // com::sun::star::form::XLoadable
    2677             : //------------------------------------------------------------------------------
    2678           0 : void SAL_CALL ODatabaseForm::load() throw( RuntimeException )
    2679             : {
    2680           0 :     load_impl(sal_False);
    2681           0 : }
    2682             : 
    2683             : //------------------------------------------------------------------------------
    2684           0 : sal_Bool ODatabaseForm::canShareConnection( const Reference< XPropertySet >& _rxParentProps )
    2685             : {
    2686             :     // our own data source
    2687           0 :     ::rtl::OUString sOwnDatasource;
    2688           0 :     m_xAggregateSet->getPropertyValue( PROPERTY_DATASOURCE ) >>= sOwnDatasource;
    2689             : 
    2690             :     // our parents data source
    2691           0 :     ::rtl::OUString sParentDataSource;
    2692             :     OSL_ENSURE( _rxParentProps.is() && _rxParentProps->getPropertySetInfo().is() && _rxParentProps->getPropertySetInfo()->hasPropertyByName( PROPERTY_DATASOURCE ),
    2693             :         "ODatabaseForm::doShareConnection: invalid parent form!" );
    2694           0 :     if ( _rxParentProps.is() )
    2695           0 :         _rxParentProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sParentDataSource;
    2696             : 
    2697           0 :     sal_Bool bCanShareConnection = sal_False;
    2698             : 
    2699             :     // both rowsets share are connected to the same data source
    2700           0 :     if ( sParentDataSource == sOwnDatasource )
    2701             :     {
    2702           0 :         if ( !sParentDataSource.isEmpty() )
    2703             :             // and it's really a data source name (not empty)
    2704           0 :             bCanShareConnection = sal_True;
    2705             :         else
    2706             :         {   // the data source name is empty
    2707             :             // -> ook for the URL
    2708           0 :             ::rtl::OUString sParentURL;
    2709           0 :             ::rtl::OUString sMyURL;
    2710           0 :             _rxParentProps->getPropertyValue( PROPERTY_URL ) >>= sParentURL;
    2711           0 :             m_xAggregateSet->getPropertyValue( PROPERTY_URL ) >>= sMyURL;
    2712             : 
    2713           0 :             bCanShareConnection = (sParentURL == sMyURL);
    2714             :         }
    2715             :     }
    2716             : 
    2717           0 :     if ( bCanShareConnection )
    2718             :     {
    2719             :         // check for the user/password
    2720             : 
    2721             :         // take the user property on the rowset (if any) into account
    2722           0 :         ::rtl::OUString sParentUser, sParentPwd;
    2723           0 :         _rxParentProps->getPropertyValue( PROPERTY_USER ) >>= sParentUser;
    2724           0 :         _rxParentProps->getPropertyValue( PROPERTY_PASSWORD ) >>= sParentPwd;
    2725             : 
    2726           0 :         ::rtl::OUString sMyUser, sMyPwd;
    2727           0 :         m_xAggregateSet->getPropertyValue( PROPERTY_USER ) >>= sMyUser;
    2728           0 :         m_xAggregateSet->getPropertyValue( PROPERTY_PASSWORD ) >>= sMyPwd;
    2729             : 
    2730             :         bCanShareConnection =
    2731           0 :                 ( sParentUser == sMyUser )
    2732           0 :             &&  ( sParentPwd == sMyPwd );
    2733             :     }
    2734             : 
    2735           0 :     return bCanShareConnection;
    2736             : }
    2737             : 
    2738             : //------------------------------------------------------------------------------
    2739           0 : void ODatabaseForm::doShareConnection( const Reference< XPropertySet >& _rxParentProps )
    2740             : {
    2741             :     // get the conneciton of the parent
    2742           0 :     Reference< XConnection > xParentConn;
    2743           0 :     _rxParentProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xParentConn;
    2744             :     OSL_ENSURE( xParentConn.is(), "ODatabaseForm::doShareConnection: we're a valid sub-form, but the parent has no connection?!" );
    2745             : 
    2746           0 :     if ( xParentConn.is() )
    2747             :     {
    2748             :         // add as dispose listener to the connection
    2749           0 :         Reference< XComponent > xParentConnComp( xParentConn, UNO_QUERY );
    2750             :         OSL_ENSURE( xParentConnComp.is(), "ODatabaseForm::doShareConnection: invalid connection!" );
    2751           0 :         xParentConnComp->addEventListener( static_cast< XLoadListener* >( this ) );
    2752             : 
    2753             :         // forward the connection to our own aggreagte
    2754           0 :         m_bForwardingConnection = sal_True;
    2755           0 :         m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xParentConn ) );
    2756           0 :         m_bForwardingConnection = sal_False;
    2757             : 
    2758           0 :         m_bSharingConnection = sal_True;
    2759             :     }
    2760             :     else
    2761           0 :         m_bSharingConnection = sal_False;
    2762           0 : }
    2763             : 
    2764             : //------------------------------------------------------------------------------
    2765           0 : void ODatabaseForm::disposingSharedConnection( const Reference< XConnection >& /*_rxConn*/ )
    2766             : {
    2767           0 :     stopSharingConnection();
    2768             : 
    2769             :     // TODO: we could think about whether or not to re-connect.
    2770           0 :     unload( );
    2771           0 : }
    2772             : 
    2773             : //------------------------------------------------------------------------------
    2774           0 : void ODatabaseForm::stopSharingConnection( )
    2775             : {
    2776             :     OSL_ENSURE( m_bSharingConnection, "ODatabaseForm::stopSharingConnection: invalid call!" );
    2777             : 
    2778           0 :     if ( m_bSharingConnection )
    2779             :     {
    2780             :         // get the connection
    2781           0 :         Reference< XConnection > xSharedConn;
    2782           0 :         m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xSharedConn;
    2783             :         OSL_ENSURE( xSharedConn.is(), "ODatabaseForm::stopSharingConnection: there's no conn!" );
    2784             : 
    2785             :         // remove ourself as event listener
    2786           0 :         Reference< XComponent > xSharedConnComp( xSharedConn, UNO_QUERY );
    2787           0 :         if ( xSharedConnComp.is() )
    2788           0 :             xSharedConnComp->removeEventListener( static_cast< XLoadListener* >( this ) );
    2789             : 
    2790             :         // no need to dispose the conn: we're not the owner, this is our parent
    2791             :         // (in addition, this method may be called if the connection is beeing disposed while we use it)
    2792             : 
    2793             :         // reset the property
    2794           0 :         xSharedConn.clear();
    2795           0 :         m_bForwardingConnection = sal_True;
    2796           0 :         m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) );
    2797           0 :         m_bForwardingConnection = sal_False;
    2798             : 
    2799             :         // reset the flag
    2800           0 :         m_bSharingConnection = sal_False;
    2801             :     }
    2802           0 : }
    2803             : 
    2804             : //------------------------------------------------------------------------------
    2805           0 : sal_Bool ODatabaseForm::implEnsureConnection()
    2806             : {
    2807             :     try
    2808             :     {
    2809           0 :         if ( getConnection( ).is() )
    2810             :             // if our aggregate already has a connection, nothing needs to be done about it
    2811           0 :             return sal_True;
    2812             : 
    2813             :         // see whether we're an embedded form
    2814           0 :         Reference< XConnection > xOuterConnection;
    2815           0 :         if ( ::dbtools::isEmbeddedInDatabase( getParent(), xOuterConnection ) )
    2816             :         {
    2817           0 :             m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xOuterConnection ) );
    2818           0 :             return xOuterConnection.is();
    2819             :         }
    2820             : 
    2821           0 :         m_bSharingConnection = sal_False;
    2822             : 
    2823             :         // if we're a sub form, we try to re-use the connection of our parent
    2824           0 :         if (m_bSubForm)
    2825             :         {
    2826             :             OSL_ENSURE( Reference< XForm >( getParent(), UNO_QUERY ).is(),
    2827             :                 "ODatabaseForm::implEnsureConnection: m_bSubForm is TRUE, but the parent is no form?" );
    2828             : 
    2829           0 :             Reference< XPropertySet > xParentProps( getParent(), UNO_QUERY );
    2830             : 
    2831             :             // can we re-use (aka share) the connection of the parent?
    2832           0 :             if ( canShareConnection( xParentProps ) )
    2833             :             {
    2834             :                 // yep -> do it
    2835           0 :                 doShareConnection( xParentProps );
    2836             :                 // success?
    2837           0 :                 if ( m_bSharingConnection )
    2838             :                     // yes -> outta here
    2839           0 :                     return sal_True;
    2840           0 :             }
    2841             :         }
    2842             : 
    2843           0 :         if (m_xAggregateSet.is())
    2844             :         {
    2845             :             Reference< XConnection >  xConnection = connectRowset(
    2846             :                 Reference<XRowSet> (m_xAggregate, UNO_QUERY),
    2847             :                 comphelper::getComponentContext(m_xServiceFactory),
    2848             :                 sal_True    // set a calculated connection as ActiveConnection
    2849           0 :             );
    2850           0 :             return xConnection.is();
    2851           0 :         }
    2852             :     }
    2853           0 :     catch(const SQLException& eDB)
    2854             :     {
    2855           0 :         onError(eDB, FRM_RES_STRING(RID_STR_CONNECTERROR));
    2856             :     }
    2857           0 :     catch(const Exception&)
    2858             :     {
    2859             :         DBG_UNHANDLED_EXCEPTION();
    2860             :     }
    2861             : 
    2862           0 :     return sal_False;
    2863             : }
    2864             : 
    2865             : //------------------------------------------------------------------------------
    2866           0 : void ODatabaseForm::load_impl(sal_Bool bCausedByParentForm, sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler ) throw( RuntimeException )
    2867             : {
    2868           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2869             : 
    2870             :     // are we already loaded?
    2871           0 :     if (isLoaded())
    2872           0 :         return;
    2873             : 
    2874           0 :     m_bSubForm = bCausedByParentForm;
    2875             : 
    2876             :     // if we don't have a connection, we are not intended to be a database form or the aggregate was not able
    2877             :     // to establish a connection
    2878           0 :     sal_Bool bConnected = implEnsureConnection();
    2879             : 
    2880             :     // we don't have to execute if we do not have a command to execute
    2881           0 :     sal_Bool bExecute = bConnected && m_xAggregateSet.is() && !getString(m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND)).isEmpty();
    2882             : 
    2883             :     // a database form always uses caching
    2884             :     // we use starting fetchsize with at least 10 rows
    2885           0 :     if (bConnected)
    2886           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, makeAny((sal_Int32)40));
    2887             : 
    2888             :     // if we're loaded as sub form we got a "rowSetChanged" from the parent rowset _before_ we got the "loaded"
    2889             :     // so we don't need to execute the statement again, this was already done
    2890             :     // (and there were no relevant changes between these two listener calls, the "load" of a form is quite an
    2891             :     // atomar operation.)
    2892             : 
    2893           0 :     sal_Bool bSuccess = sal_False;
    2894           0 :     if (bExecute)
    2895             :     {
    2896           0 :         m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_LOADING_FORM);
    2897           0 :         bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler);
    2898             :     }
    2899             : 
    2900           0 :     if (bSuccess)
    2901             :     {
    2902           0 :         m_bLoaded = sal_True;
    2903           0 :         aGuard.clear();
    2904           0 :         EventObject aEvt(static_cast<XWeak*>(this));
    2905           0 :         m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt );
    2906             : 
    2907             :         // if we are on the insert row, we have to reset all controls
    2908             :         // to set the default values
    2909           0 :         if (bExecute && getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
    2910           0 :             reset();
    2911           0 :     }
    2912             : }
    2913             : 
    2914             : //------------------------------------------------------------------------------
    2915           0 : void SAL_CALL ODatabaseForm::unload() throw( RuntimeException )
    2916             : {
    2917           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2918           0 :     if (!isLoaded())
    2919           0 :         return;
    2920             : 
    2921           0 :     DELETEZ(m_pLoadTimer);
    2922             : 
    2923           0 :     aGuard.clear();
    2924           0 :     EventObject aEvt(static_cast<XWeak*>(this));
    2925           0 :     m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );
    2926             : 
    2927           0 :     if (m_xAggregateAsRowSet.is())
    2928             :     {
    2929             :         // we may have reset the InsertOnly property on the aggregate - restore it
    2930           0 :         restoreInsertOnlyState( );
    2931             : 
    2932             :         // clear the parameters if there are any
    2933           0 :         invlidateParameters();
    2934             : 
    2935             :         try
    2936             :         {
    2937             :             // close the aggregate
    2938           0 :             Reference<XCloseable>  xCloseable;
    2939           0 :             query_aggregation( m_xAggregate, xCloseable);
    2940           0 :             aGuard.clear();
    2941           0 :             if (xCloseable.is())
    2942           0 :                 xCloseable->close();
    2943             :         }
    2944           0 :         catch(const SQLException&)
    2945             :         {
    2946             :         }
    2947           0 :         aGuard.reset();
    2948             :     }
    2949             : 
    2950           0 :     m_bLoaded = sal_False;
    2951             : 
    2952             :     // if the connection we used while we were loaded is only shared with our parent, we
    2953             :     // reset it
    2954           0 :     if ( isSharingConnection() )
    2955           0 :         stopSharingConnection();
    2956             : 
    2957           0 :     aGuard.clear();
    2958           0 :     m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt );
    2959             : }
    2960             : 
    2961             : //------------------------------------------------------------------------------
    2962           0 : void SAL_CALL ODatabaseForm::reload() throw( RuntimeException )
    2963             : {
    2964           0 :     reload_impl(sal_True);
    2965           0 : }
    2966             : 
    2967             : //------------------------------------------------------------------------------
    2968           0 : void ODatabaseForm::reload_impl(sal_Bool bMoveToFirst, const Reference< XInteractionHandler >& _rxCompletionHandler ) throw( RuntimeException )
    2969             : {
    2970           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    2971           0 :     if (!isLoaded())
    2972           0 :         return;
    2973             : 
    2974           0 :     DocumentModifyGuard aModifyGuard( *this );
    2975             :         // ensures the document is not marked as "modified" just because we change some control's content during
    2976             :         // reloading ...
    2977             : 
    2978           0 :     EventObject aEvent(static_cast<XWeak*>(this));
    2979             :     {
    2980             :         // only if there is no approve listener we can post the event at this time
    2981             :         // otherwise see approveRowsetChange
    2982             :         // the aprrovement is done by the aggregate
    2983           0 :         if (!m_aRowSetApproveListeners.getLength())
    2984             :         {
    2985           0 :             ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
    2986           0 :             aGuard.clear();
    2987             : 
    2988           0 :             while (aIter.hasMoreElements())
    2989           0 :                 ((XLoadListener*)aIter.next())->reloading(aEvent);
    2990             : 
    2991           0 :             aGuard.reset();
    2992             :         }
    2993             :     }
    2994             : 
    2995           0 :     sal_Bool bSuccess = sal_True;
    2996             :     try
    2997             :     {
    2998           0 :         m_sCurrentErrorContext = FRM_RES_STRING(RID_ERR_REFRESHING_FORM);
    2999           0 :         bSuccess = executeRowSet(aGuard, bMoveToFirst, _rxCompletionHandler);
    3000             :     }
    3001           0 :     catch(const SQLException&)
    3002             :     {
    3003             :         OSL_FAIL("ODatabaseForm::reload_impl : shouldn't executeRowSet catch this exception?");
    3004             :     }
    3005             : 
    3006           0 :     if (bSuccess)
    3007             :     {
    3008           0 :         ::cppu::OInterfaceIteratorHelper aIter(m_aLoadListeners);
    3009           0 :         aGuard.clear();
    3010           0 :         while (aIter.hasMoreElements())
    3011           0 :             ((XLoadListener*)aIter.next())->reloaded(aEvent);
    3012             : 
    3013             :         // if we are on the insert row, we have to reset all controls
    3014             :         // to set the default values
    3015           0 :         if (getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ISNEW)))
    3016           0 :             reset();
    3017             :     }
    3018             :     else
    3019           0 :         m_bLoaded = sal_False;
    3020             : }
    3021             : 
    3022             : //------------------------------------------------------------------------------
    3023          18 : sal_Bool SAL_CALL ODatabaseForm::isLoaded() throw( RuntimeException )
    3024             : {
    3025          18 :     return m_bLoaded;
    3026             : }
    3027             : 
    3028             : //------------------------------------------------------------------------------
    3029          13 : void SAL_CALL ODatabaseForm::addLoadListener(const Reference<XLoadListener>& aListener) throw( RuntimeException )
    3030             : {
    3031          13 :     m_aLoadListeners.addInterface(aListener);
    3032          13 : }
    3033             : 
    3034             : //------------------------------------------------------------------------------
    3035           6 : void SAL_CALL ODatabaseForm::removeLoadListener(const Reference<XLoadListener>& aListener) throw( RuntimeException )
    3036             : {
    3037           6 :     m_aLoadListeners.removeInterface(aListener);
    3038           6 : }
    3039             : 
    3040             : //==============================================================================
    3041             : // com::sun::star::sdbc::XCloseable
    3042             : //==============================================================================
    3043           0 : void SAL_CALL ODatabaseForm::close() throw( SQLException, RuntimeException )
    3044             : {
    3045             :     // unload will close the aggregate
    3046           0 :     unload();
    3047           0 : }
    3048             : 
    3049             : //==============================================================================
    3050             : // com::sun::star::sdbc::XRowSetListener
    3051             : //------------------------------------------------------------------------------
    3052           0 : void SAL_CALL ODatabaseForm::cursorMoved(const EventObject& /*event*/) throw( RuntimeException )
    3053             : {
    3054             :     // reload the subform with the new parameters of the parent
    3055             :     // do this handling delayed to provide of execute too many SQL Statements
    3056           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    3057             : 
    3058             :     DBG_ASSERT( m_pLoadTimer, "ODatabaseForm::cursorMoved: how can this happen?!" );
    3059           0 :     if ( !m_pLoadTimer )
    3060           0 :         impl_createLoadTimer();
    3061             : 
    3062           0 :     if ( m_pLoadTimer->IsActive() )
    3063           0 :         m_pLoadTimer->Stop();
    3064             : 
    3065             :     // and start the timer again
    3066           0 :     m_pLoadTimer->Start();
    3067           0 : }
    3068             : 
    3069             : //------------------------------------------------------------------------------
    3070           0 : void SAL_CALL ODatabaseForm::rowChanged(const EventObject& /*event*/) throw( RuntimeException )
    3071             : {
    3072             :     // ignore it
    3073           0 : }
    3074             : 
    3075             : //------------------------------------------------------------------------------
    3076           0 : void SAL_CALL ODatabaseForm::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException )
    3077             : {
    3078             :     // not interested in :
    3079             :     // if our parent is an ODatabaseForm, too, then after this rowSetChanged we'll get a "reloaded"
    3080             :     // or a "loaded" event.
    3081             :     // If somebody gave us another parent which is an XRowSet but doesn't handle an execute as
    3082             :     // "load" respectivly "reload" ... can't do anything ....
    3083           0 : }
    3084             : 
    3085             : //------------------------------------------------------------------------------
    3086           0 : bool ODatabaseForm::impl_approveRowChange_throw( const EventObject& _rEvent, const bool _bAllowSQLException,
    3087             :     ::osl::ClearableMutexGuard& _rGuard )
    3088             : {
    3089           0 :     ::cppu::OInterfaceIteratorHelper aIter( m_aRowSetApproveListeners );
    3090           0 :     _rGuard.clear();
    3091           0 :     while ( aIter.hasMoreElements() )
    3092             :     {
    3093           0 :         Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) );
    3094           0 :         if ( !xListener.is() )
    3095           0 :             continue;
    3096             : 
    3097             :         try
    3098             :         {
    3099           0 :             if ( !xListener->approveRowSetChange( _rEvent ) )
    3100           0 :                 return false;
    3101             :         }
    3102           0 :         catch (const DisposedException& e)
    3103             :         {
    3104           0 :             if ( e.Context == xListener )
    3105           0 :                 aIter.remove();
    3106             :         }
    3107           0 :         catch (const RuntimeException&)
    3108             :         {
    3109           0 :             throw;
    3110             :         }
    3111           0 :         catch (const SQLException&)
    3112             :         {
    3113           0 :             if ( _bAllowSQLException )
    3114           0 :                 throw;
    3115             :             DBG_UNHANDLED_EXCEPTION();
    3116             :         }
    3117           0 :         catch (const Exception&)
    3118             :         {
    3119             :             DBG_UNHANDLED_EXCEPTION();
    3120             :         }
    3121           0 :     }
    3122           0 :     return true;
    3123             : }
    3124             : 
    3125             : //------------------------------------------------------------------------------
    3126           0 : sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event) throw( RuntimeException )
    3127             : {
    3128             :     // is our aggregate calling?
    3129           0 :     if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))
    3130             :     {
    3131             :         // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
    3132             :         // for XRowSetApproveBroadcaster-interface.
    3133             :         // So we have to multiplex this approve request.
    3134           0 :         ::cppu::OInterfaceIteratorHelper aIter( m_aRowSetApproveListeners );
    3135           0 :         while ( aIter.hasMoreElements() )
    3136             :         {
    3137           0 :             Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) );
    3138           0 :             if ( !xListener.is() )
    3139           0 :                 continue;
    3140             : 
    3141             :             try
    3142             :             {
    3143           0 :                 if ( !xListener->approveCursorMove( event ) )
    3144           0 :                     return sal_False;
    3145             :             }
    3146           0 :             catch (const DisposedException& e)
    3147             :             {
    3148           0 :                 if ( e.Context == xListener )
    3149           0 :                     aIter.remove();
    3150             :             }
    3151           0 :             catch (const RuntimeException&)
    3152             :             {
    3153           0 :                 throw;
    3154             :             }
    3155           0 :             catch (const Exception&)
    3156             :             {
    3157             :                 DBG_UNHANDLED_EXCEPTION();
    3158             :             }
    3159           0 :         }
    3160           0 :         return true;
    3161             :     }
    3162             :     else
    3163             :     {
    3164             :         // this is a call from our parent ...
    3165             :         // a parent's cursor move will result in a re-execute of our own row-set, so we have to
    3166             :         // ask our own RowSetChangesListeners, too
    3167           0 :         ::osl::ClearableMutexGuard aGuard( m_aMutex );
    3168           0 :         if ( !impl_approveRowChange_throw( event, false, aGuard ) )
    3169           0 :             return sal_False;
    3170             :     }
    3171           0 :     return sal_True;
    3172             : }
    3173             : 
    3174             : //------------------------------------------------------------------------------
    3175           0 : sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const RowChangeEvent& event) throw( RuntimeException )
    3176             : {
    3177             :     // is our aggregate calling?
    3178           0 :     if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))
    3179             :     {
    3180             :         // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
    3181             :         // for XRowSetApproveBroadcaster-interface.
    3182             :         // So we have to multiplex this approve request.
    3183           0 :         ::cppu::OInterfaceIteratorHelper aIter( m_aRowSetApproveListeners );
    3184           0 :         while ( aIter.hasMoreElements() )
    3185             :         {
    3186           0 :             Reference< XRowSetApproveListener > xListener( static_cast< XRowSetApproveListener* >( aIter.next() ) );
    3187           0 :             if ( !xListener.is() )
    3188           0 :                 continue;
    3189             : 
    3190             :             try
    3191             :             {
    3192           0 :                 if ( !xListener->approveRowChange( event ) )
    3193           0 :                     return false;
    3194             :             }
    3195           0 :             catch (const DisposedException& e)
    3196             :             {
    3197           0 :                 if ( e.Context == xListener )
    3198           0 :                     aIter.remove();
    3199             :             }
    3200           0 :             catch (const RuntimeException&)
    3201             :             {
    3202           0 :                 throw;
    3203             :             }
    3204           0 :             catch (const Exception&)
    3205             :             {
    3206             :                 DBG_UNHANDLED_EXCEPTION();
    3207             :             }
    3208           0 :         }
    3209           0 :         return true;
    3210             :     }
    3211           0 :     return sal_True;
    3212             : }
    3213             : 
    3214             : //------------------------------------------------------------------------------
    3215           0 : sal_Bool SAL_CALL ODatabaseForm::approveRowSetChange(const EventObject& event) throw( RuntimeException )
    3216             : {
    3217           0 :     if (event.Source == InterfaceRef(static_cast<XWeak*>(this)))    // ignore our aggregate as we handle this approve ourself
    3218             :     {
    3219           0 :         ::osl::ClearableMutexGuard aGuard( m_aMutex );
    3220           0 :         bool bWasLoaded = isLoaded();
    3221           0 :         if ( !impl_approveRowChange_throw( event, false, aGuard ) )
    3222           0 :             return sal_False;
    3223             : 
    3224           0 :         if ( bWasLoaded )
    3225             :         {
    3226           0 :             m_aLoadListeners.notifyEach( &XLoadListener::reloading, event );
    3227           0 :         }
    3228             :     }
    3229             :     else
    3230             :     {
    3231             :         // this is a call from our parent ...
    3232             :         // a parent's cursor move will result in a re-execute of our own row-set, so we have to
    3233             :         // ask our own RowSetChangesListeners, too
    3234           0 :         ::osl::ClearableMutexGuard aGuard( m_aMutex );
    3235           0 :         if ( !impl_approveRowChange_throw( event, false, aGuard ) )
    3236           0 :             return sal_False;
    3237             :     }
    3238           0 :     return sal_True;
    3239             : }
    3240             : 
    3241             : //==============================================================================
    3242             : // com::sun::star::sdb::XRowSetApproveBroadcaster
    3243             : //------------------------------------------------------------------------------
    3244           0 : void SAL_CALL ODatabaseForm::addRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) throw( RuntimeException )
    3245             : {
    3246           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    3247           0 :     m_aRowSetApproveListeners.addInterface(_rListener);
    3248             : 
    3249             :     // do we have to multiplex ?
    3250           0 :     if (m_aRowSetApproveListeners.getLength() == 1)
    3251             :     {
    3252           0 :         Reference<XRowSetApproveBroadcaster>  xBroadcaster;
    3253           0 :         if (query_aggregation( m_xAggregate, xBroadcaster))
    3254             :         {
    3255           0 :             Reference<XRowSetApproveListener>  xListener((XRowSetApproveListener*)this);
    3256           0 :             xBroadcaster->addRowSetApproveListener(xListener);
    3257           0 :         }
    3258           0 :     }
    3259           0 : }
    3260             : 
    3261             : //------------------------------------------------------------------------------
    3262           0 : void SAL_CALL ODatabaseForm::removeRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) throw( RuntimeException )
    3263             : {
    3264           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    3265             :     // do we have to remove the multiplex ?
    3266           0 :     m_aRowSetApproveListeners.removeInterface(_rListener);
    3267           0 :     if ( m_aRowSetApproveListeners.getLength() == 0 )
    3268             :     {
    3269           0 :         Reference<XRowSetApproveBroadcaster>  xBroadcaster;
    3270           0 :         if (query_aggregation( m_xAggregate, xBroadcaster))
    3271             :         {
    3272           0 :             Reference<XRowSetApproveListener>  xListener((XRowSetApproveListener*)this);
    3273           0 :             xBroadcaster->removeRowSetApproveListener(xListener);
    3274           0 :         }
    3275           0 :     }
    3276           0 : }
    3277             : 
    3278             : //==============================================================================
    3279             : // com::sun:star::form::XDatabaseParameterBroadcaster
    3280             : //------------------------------------------------------------------------------
    3281           2 : void SAL_CALL ODatabaseForm::addDatabaseParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
    3282             : {
    3283           2 :     m_aParameterManager.addParameterListener( _rListener );
    3284           2 : }
    3285             : //------------------------------------------------------------------------------
    3286           1 : void SAL_CALL ODatabaseForm::removeDatabaseParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
    3287             : {
    3288           1 :     m_aParameterManager.removeParameterListener( _rListener );
    3289           1 : }
    3290             : 
    3291             : //------------------------------------------------------------------------------
    3292           2 : void SAL_CALL ODatabaseForm::addParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
    3293             : {
    3294           2 :     ODatabaseForm::addDatabaseParameterListener( _rListener );
    3295           2 : }
    3296             : 
    3297             : //------------------------------------------------------------------------------
    3298           1 : void SAL_CALL ODatabaseForm::removeParameterListener(const Reference<XDatabaseParameterListener>& _rListener) throw( RuntimeException )
    3299             : {
    3300           1 :     ODatabaseForm::removeDatabaseParameterListener( _rListener );
    3301           1 : }
    3302             : 
    3303             : //==============================================================================
    3304             : // com::sun::star::sdb::XCompletedExecution
    3305             : //------------------------------------------------------------------------------
    3306           0 : void SAL_CALL ODatabaseForm::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException)
    3307             : {
    3308           0 :     ::osl::ClearableMutexGuard aGuard(m_aMutex);
    3309             :     // the difference between execute and load is, that we position on the first row in case of load
    3310             :     // after execute we remain before the first row
    3311           0 :     if (!isLoaded())
    3312             :     {
    3313           0 :         aGuard.clear();
    3314           0 :         load_impl(sal_False, sal_False, _rxHandler);
    3315             :     }
    3316             :     else
    3317             :     {
    3318           0 :         EventObject event(static_cast< XWeak* >(this));
    3319           0 :         if ( !impl_approveRowChange_throw( event, true, aGuard ) )
    3320           0 :             return;
    3321             : 
    3322             :         // we're loaded and somebody want's to execute ourself -> this means a reload
    3323           0 :         reload_impl(sal_False, _rxHandler);
    3324           0 :     }
    3325             : }
    3326             : 
    3327             : //==============================================================================
    3328             : // com::sun::star::sdbc::XRowSet
    3329             : //------------------------------------------------------------------------------
    3330           0 : void SAL_CALL ODatabaseForm::execute() throw( SQLException, RuntimeException )
    3331             : {
    3332           0 :     ::osl::ResettableMutexGuard aGuard(m_aMutex);
    3333             :     // if somebody calls an execute and we're not loaded we reroute this call to our load method.
    3334             : 
    3335             :     // the difference between execute and load is, that we position on the first row in case of load
    3336             :     // after execute we remain before the first row
    3337           0 :     if (!isLoaded())
    3338             :     {
    3339           0 :         aGuard.clear();
    3340           0 :         load_impl(sal_False, sal_False);
    3341             :     }
    3342             :     else
    3343             :     {
    3344           0 :         EventObject event(static_cast< XWeak* >(this));
    3345           0 :         if ( !impl_approveRowChange_throw( event, true, aGuard ) )
    3346           0 :             return;
    3347             : 
    3348             :         // we're loaded and somebody want's to execute ourself -> this means a reload
    3349           0 :         reload_impl(sal_False);
    3350           0 :     }
    3351             : }
    3352             : 
    3353             : //------------------------------------------------------------------------------
    3354           2 : void SAL_CALL ODatabaseForm::addRowSetListener(const Reference<XRowSetListener>& _rListener) throw( RuntimeException )
    3355             : {
    3356           2 :     if (m_xAggregateAsRowSet.is())
    3357           2 :         m_xAggregateAsRowSet->addRowSetListener(_rListener);
    3358           2 : }
    3359             : 
    3360             : //------------------------------------------------------------------------------
    3361           1 : void SAL_CALL ODatabaseForm::removeRowSetListener(const Reference<XRowSetListener>& _rListener) throw( RuntimeException )
    3362             : {
    3363           1 :     if (m_xAggregateAsRowSet.is())
    3364           1 :         m_xAggregateAsRowSet->removeRowSetListener(_rListener);
    3365           1 : }
    3366             : 
    3367             : //==============================================================================
    3368             : // com::sun::star::sdbc::XResultSet
    3369             : //------------------------------------------------------------------------------
    3370           0 : sal_Bool SAL_CALL ODatabaseForm::next() throw( SQLException, RuntimeException )
    3371             : {
    3372           0 :     return m_xAggregateAsRowSet->next();
    3373             : }
    3374             : 
    3375             : //------------------------------------------------------------------------------
    3376           0 : sal_Bool SAL_CALL ODatabaseForm::isBeforeFirst() throw( SQLException, RuntimeException )
    3377             : {
    3378           0 :     return m_xAggregateAsRowSet->isBeforeFirst();
    3379             : }
    3380             : 
    3381             : //------------------------------------------------------------------------------
    3382           0 : sal_Bool SAL_CALL ODatabaseForm::isAfterLast() throw( SQLException, RuntimeException )
    3383             : {
    3384           0 :     return m_xAggregateAsRowSet->isAfterLast();
    3385             : }
    3386             : 
    3387             : //------------------------------------------------------------------------------
    3388           0 : sal_Bool SAL_CALL ODatabaseForm::isFirst() throw( SQLException, RuntimeException )
    3389             : {
    3390           0 :     return m_xAggregateAsRowSet->isFirst();
    3391             : }
    3392             : 
    3393             : //------------------------------------------------------------------------------
    3394           0 : sal_Bool SAL_CALL ODatabaseForm::isLast() throw( SQLException, RuntimeException )
    3395             : {
    3396           0 :     return m_xAggregateAsRowSet->isLast();
    3397             : }
    3398             : 
    3399             : //------------------------------------------------------------------------------
    3400           0 : void SAL_CALL ODatabaseForm::beforeFirst() throw( SQLException, RuntimeException )
    3401             : {
    3402           0 :     m_xAggregateAsRowSet->beforeFirst();
    3403           0 : }
    3404             : 
    3405             : //------------------------------------------------------------------------------
    3406           0 : void SAL_CALL ODatabaseForm::afterLast() throw( SQLException, RuntimeException )
    3407             : {
    3408           0 :     m_xAggregateAsRowSet->afterLast();
    3409           0 : }
    3410             : 
    3411             : //------------------------------------------------------------------------------
    3412           0 : sal_Bool SAL_CALL ODatabaseForm::first() throw( SQLException, RuntimeException )
    3413             : {
    3414           0 :     return m_xAggregateAsRowSet->first();
    3415             : }
    3416             : 
    3417             : //------------------------------------------------------------------------------
    3418           0 : sal_Bool SAL_CALL ODatabaseForm::last() throw( SQLException, RuntimeException )
    3419             : {
    3420           0 :     return m_xAggregateAsRowSet->last();
    3421             : }
    3422             : 
    3423             : //------------------------------------------------------------------------------
    3424           0 : sal_Int32 SAL_CALL ODatabaseForm::getRow() throw( SQLException, RuntimeException )
    3425             : {
    3426           0 :     return m_xAggregateAsRowSet->getRow();
    3427             : }
    3428             : 
    3429             : //------------------------------------------------------------------------------
    3430           0 : sal_Bool SAL_CALL ODatabaseForm::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
    3431             : {
    3432           0 :     return m_xAggregateAsRowSet->absolute(row);
    3433             : }
    3434             : 
    3435             : //------------------------------------------------------------------------------
    3436           0 : sal_Bool SAL_CALL ODatabaseForm::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
    3437             : {
    3438           0 :     return m_xAggregateAsRowSet->relative(rows);
    3439             : }
    3440             : 
    3441             : //------------------------------------------------------------------------------
    3442           0 : sal_Bool SAL_CALL ODatabaseForm::previous() throw( SQLException, RuntimeException )
    3443             : {
    3444           0 :     return m_xAggregateAsRowSet->previous();
    3445             : }
    3446             : 
    3447             : //------------------------------------------------------------------------------
    3448           0 : void SAL_CALL ODatabaseForm::refreshRow() throw( SQLException, RuntimeException )
    3449             : {
    3450           0 :     m_xAggregateAsRowSet->refreshRow();
    3451           0 : }
    3452             : 
    3453             : //------------------------------------------------------------------------------
    3454           0 : sal_Bool SAL_CALL ODatabaseForm::rowUpdated() throw( SQLException, RuntimeException )
    3455             : {
    3456           0 :     return m_xAggregateAsRowSet->rowUpdated();
    3457             : }
    3458             : 
    3459             : //------------------------------------------------------------------------------
    3460           0 : sal_Bool SAL_CALL ODatabaseForm::rowInserted() throw( SQLException, RuntimeException )
    3461             : {
    3462           0 :     return m_xAggregateAsRowSet->rowInserted();
    3463             : }
    3464             : 
    3465             : //------------------------------------------------------------------------------
    3466           0 : sal_Bool SAL_CALL ODatabaseForm::rowDeleted() throw( SQLException, RuntimeException )
    3467             : {
    3468           0 :     return m_xAggregateAsRowSet->rowDeleted();
    3469             : }
    3470             : 
    3471             : //------------------------------------------------------------------------------
    3472           0 : InterfaceRef SAL_CALL ODatabaseForm::getStatement() throw( SQLException, RuntimeException )
    3473             : {
    3474           0 :     return m_xAggregateAsRowSet->getStatement();
    3475             : }
    3476             : 
    3477             : // com::sun::star::sdbc::XResultSetUpdate
    3478             : // exceptions during insert update and delete will be forwarded to the errorlistener
    3479             : //------------------------------------------------------------------------------
    3480           0 : void SAL_CALL ODatabaseForm::insertRow() throw( SQLException, RuntimeException )
    3481             : {
    3482             :     try
    3483             :     {
    3484           0 :         Reference<XResultSetUpdate>  xUpdate;
    3485           0 :         if (query_aggregation( m_xAggregate, xUpdate))
    3486           0 :             xUpdate->insertRow();
    3487             :     }
    3488           0 :     catch(const RowSetVetoException&)
    3489             :     {
    3490           0 :         throw;
    3491             :     }
    3492           0 :     catch(const SQLException& eDb)
    3493             :     {
    3494           0 :         onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD));
    3495           0 :         throw;
    3496             :     }
    3497           0 : }
    3498             : 
    3499             : //------------------------------------------------------------------------------
    3500           0 : void SAL_CALL ODatabaseForm::updateRow() throw( SQLException, RuntimeException )
    3501             : {
    3502             :     try
    3503             :     {
    3504           0 :         Reference<XResultSetUpdate>  xUpdate;
    3505           0 :         if (query_aggregation( m_xAggregate, xUpdate))
    3506           0 :             xUpdate->updateRow();
    3507             :     }
    3508           0 :     catch(const RowSetVetoException&)
    3509             :     {
    3510           0 :         throw;
    3511             :     }
    3512           0 :     catch(const SQLException& eDb)
    3513             :     {
    3514           0 :         onError(eDb, FRM_RES_STRING(RID_STR_ERR_UPDATERECORD));
    3515           0 :         throw;
    3516             :     }
    3517           0 : }
    3518             : 
    3519             : //------------------------------------------------------------------------------
    3520           0 : void SAL_CALL ODatabaseForm::deleteRow() throw( SQLException, RuntimeException )
    3521             : {
    3522             :     try
    3523             :     {
    3524           0 :         Reference<XResultSetUpdate>  xUpdate;
    3525           0 :         if (query_aggregation( m_xAggregate, xUpdate))
    3526           0 :             xUpdate->deleteRow();
    3527             :     }
    3528           0 :     catch(const RowSetVetoException&)
    3529             :     {
    3530           0 :         throw;
    3531             :     }
    3532           0 :     catch(const SQLException& eDb)
    3533             :     {
    3534           0 :         onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORD));
    3535           0 :         throw;
    3536             :     }
    3537           0 : }
    3538             : 
    3539             : //------------------------------------------------------------------------------
    3540           0 : void SAL_CALL ODatabaseForm::cancelRowUpdates() throw( SQLException, RuntimeException )
    3541             : {
    3542             :     try
    3543             :     {
    3544           0 :         Reference<XResultSetUpdate>  xUpdate;
    3545           0 :         if (query_aggregation( m_xAggregate, xUpdate))
    3546           0 :             xUpdate->cancelRowUpdates();
    3547             :     }
    3548           0 :     catch(const RowSetVetoException&)
    3549             :     {
    3550           0 :         throw;
    3551             :     }
    3552           0 :     catch(const SQLException& eDb)
    3553             :     {
    3554           0 :         onError(eDb, FRM_RES_STRING(RID_STR_ERR_INSERTRECORD));
    3555           0 :         throw;
    3556             :     }
    3557           0 : }
    3558             : 
    3559             : //------------------------------------------------------------------------------
    3560           0 : void SAL_CALL ODatabaseForm::moveToInsertRow() throw( SQLException, RuntimeException )
    3561             : {
    3562           0 :     Reference<XResultSetUpdate>  xUpdate;
    3563           0 :     if (query_aggregation( m_xAggregate, xUpdate))
    3564             :     {
    3565             :         // _always_ move to the insert row
    3566             :         //
    3567             :         // Formerly, the following line was conditioned with a "not is new", means we did not move the aggregate
    3568             :         // to the insert row if it was already positioned there.
    3569             :         //
    3570             :         // This prevented the RowSet implementation from resetting it's column values. We, ourself, formerly
    3571             :         // did this reset of columns in reset_impl, where we set every column to the ControlDefault, or, if this
    3572             :         // was not present, to NULL. However, the problem with setting to NULL was #88888#, the problem with
    3573             :         // _not_ setting to NULL (which was the original fix for #88888#) was #97955#.
    3574             :         //
    3575             :         // So now we
    3576             :         // * move our aggregate to the insert row
    3577             :         // * in reset_impl
    3578             :         //   - set the control defaults into the columns if not void
    3579             :         //   - do _not_ set the columns to NULL if no control default is set
    3580             :         //
    3581             :         // Still, there is #72756#. During fixing this bug, DG introduced not calling the aggregate here. So
    3582             :         // in theory, we re-introduced #72756#. But the bug described therein does not happen anymore, as the
    3583             :         // preliminaries for it changed (no display of guessed values for new records with autoinc fields)
    3584             :         //
    3585             :         // BTW: the public Issuezilla bug is #i2815#
    3586             :         //
    3587           0 :         xUpdate->moveToInsertRow();
    3588             : 
    3589             :         // then set the default values and the parameters given from the parent
    3590           0 :         reset();
    3591           0 :     }
    3592           0 : }
    3593             : 
    3594             : //------------------------------------------------------------------------------
    3595           0 : void SAL_CALL ODatabaseForm::moveToCurrentRow() throw( SQLException, RuntimeException )
    3596             : {
    3597           0 :     Reference<XResultSetUpdate>  xUpdate;
    3598           0 :     if (query_aggregation( m_xAggregate, xUpdate))
    3599           0 :         xUpdate->moveToCurrentRow();
    3600           0 : }
    3601             : 
    3602             : // com::sun::star::sdbcx::XDeleteRows
    3603             : //------------------------------------------------------------------------------
    3604           0 : Sequence<sal_Int32> SAL_CALL ODatabaseForm::deleteRows(const Sequence<Any>& rows) throw( SQLException, RuntimeException )
    3605             : {
    3606             :     try
    3607             :     {
    3608           0 :         Reference<XDeleteRows>  xDelete;
    3609           0 :         if (query_aggregation( m_xAggregate, xDelete))
    3610           0 :             return xDelete->deleteRows(rows);
    3611             :     }
    3612           0 :     catch(const RowSetVetoException&)
    3613             :     {
    3614           0 :         throw;
    3615             :     }
    3616           0 :     catch(const SQLException& eDb)
    3617             :     {
    3618           0 :         onError(eDb, FRM_RES_STRING(RID_STR_ERR_DELETERECORDS));
    3619           0 :         throw;
    3620             :     }
    3621             : 
    3622           0 :     return Sequence< sal_Int32 >();
    3623             : }
    3624             : 
    3625             : // com::sun::star::sdbc::XParameters
    3626             : //------------------------------------------------------------------------------
    3627           0 : void SAL_CALL ODatabaseForm::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( SQLException, RuntimeException )
    3628             : {
    3629           0 :     m_aParameterManager.setNull(parameterIndex, sqlType);
    3630           0 : }
    3631             : 
    3632             : //------------------------------------------------------------------------------
    3633           0 : void SAL_CALL ODatabaseForm::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( SQLException, RuntimeException )
    3634             : {
    3635           0 :     m_aParameterManager.setObjectNull(parameterIndex, sqlType, typeName);
    3636           0 : }
    3637             : 
    3638             : //------------------------------------------------------------------------------
    3639           0 : void SAL_CALL ODatabaseForm::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( SQLException, RuntimeException )
    3640             : {
    3641           0 :     m_aParameterManager.setBoolean(parameterIndex, x);
    3642           0 : }
    3643             : 
    3644             : //------------------------------------------------------------------------------
    3645           0 : void SAL_CALL ODatabaseForm::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( SQLException, RuntimeException )
    3646             : {
    3647           0 :     m_aParameterManager.setByte(parameterIndex, x);
    3648           0 : }
    3649             : 
    3650             : //------------------------------------------------------------------------------
    3651           0 : void SAL_CALL ODatabaseForm::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( SQLException, RuntimeException )
    3652             : {
    3653           0 :     m_aParameterManager.setShort(parameterIndex, x);
    3654           0 : }
    3655             : 
    3656             : //------------------------------------------------------------------------------
    3657           0 : void SAL_CALL ODatabaseForm::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( SQLException, RuntimeException )
    3658             : {
    3659           0 :     m_aParameterManager.setInt(parameterIndex, x);
    3660           0 : }
    3661             : 
    3662             : //------------------------------------------------------------------------------
    3663           0 : void SAL_CALL ODatabaseForm::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( SQLException, RuntimeException )
    3664             : {
    3665           0 :     m_aParameterManager.setLong(parameterIndex, x);
    3666           0 : }
    3667             : 
    3668             : //------------------------------------------------------------------------------
    3669           0 : void SAL_CALL ODatabaseForm::setFloat(sal_Int32 parameterIndex, float x) throw( SQLException, RuntimeException )
    3670             : {
    3671           0 :     m_aParameterManager.setFloat(parameterIndex, x);
    3672           0 : }
    3673             : 
    3674             : //------------------------------------------------------------------------------
    3675           0 : void SAL_CALL ODatabaseForm::setDouble(sal_Int32 parameterIndex, double x) throw( SQLException, RuntimeException )
    3676             : {
    3677           0 :     m_aParameterManager.setDouble(parameterIndex, x);
    3678           0 : }
    3679             : 
    3680             : //------------------------------------------------------------------------------
    3681           0 : void SAL_CALL ODatabaseForm::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( SQLException, RuntimeException )
    3682             : {
    3683           0 :     m_aParameterManager.setString(parameterIndex, x);
    3684           0 : }
    3685             : 
    3686             : //------------------------------------------------------------------------------
    3687           0 : void SAL_CALL ODatabaseForm::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
    3688             : {
    3689           0 :     m_aParameterManager.setBytes(parameterIndex, x);
    3690           0 : }
    3691             : 
    3692             : //------------------------------------------------------------------------------
    3693           0 : void SAL_CALL ODatabaseForm::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
    3694             : {
    3695           0 :     m_aParameterManager.setDate(parameterIndex, x);
    3696           0 : }
    3697             : 
    3698             : //------------------------------------------------------------------------------
    3699           0 : void SAL_CALL ODatabaseForm::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
    3700             : {
    3701           0 :     m_aParameterManager.setTime(parameterIndex, x);
    3702           0 : }
    3703             : 
    3704             : //------------------------------------------------------------------------------
    3705           0 : void SAL_CALL ODatabaseForm::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
    3706             : {
    3707           0 :     m_aParameterManager.setTimestamp(parameterIndex, x);
    3708           0 : }
    3709             : 
    3710             : //------------------------------------------------------------------------------
    3711           0 : void SAL_CALL ODatabaseForm::setBinaryStream(sal_Int32 parameterIndex, const Reference<XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
    3712             : {
    3713           0 :     m_aParameterManager.setBinaryStream(parameterIndex, x, length);
    3714           0 : }
    3715             : 
    3716             : //------------------------------------------------------------------------------
    3717           0 : void SAL_CALL ODatabaseForm::setCharacterStream(sal_Int32 parameterIndex, const Reference<XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
    3718             : {
    3719           0 :     m_aParameterManager.setCharacterStream(parameterIndex, x, length);
    3720           0 : }
    3721             : 
    3722             : //------------------------------------------------------------------------------
    3723           0 : void SAL_CALL ODatabaseForm::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( SQLException, RuntimeException )
    3724             : {
    3725           0 :     m_aParameterManager.setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
    3726           0 : }
    3727             : 
    3728             : //------------------------------------------------------------------------------
    3729           0 : void SAL_CALL ODatabaseForm::setObject(sal_Int32 parameterIndex, const Any& x) throw( SQLException, RuntimeException )
    3730             : {
    3731           0 :     m_aParameterManager.setObject(parameterIndex, x);
    3732           0 : }
    3733             : 
    3734             : //------------------------------------------------------------------------------
    3735           0 : void SAL_CALL ODatabaseForm::setRef(sal_Int32 parameterIndex, const Reference<XRef>& x) throw( SQLException, RuntimeException )
    3736             : {
    3737           0 :     m_aParameterManager.setRef(parameterIndex, x);
    3738           0 : }
    3739             : 
    3740             : //------------------------------------------------------------------------------
    3741           0 : void SAL_CALL ODatabaseForm::setBlob(sal_Int32 parameterIndex, const Reference<XBlob>& x) throw( SQLException, RuntimeException )
    3742             : {
    3743           0 :     m_aParameterManager.setBlob(parameterIndex, x);
    3744           0 : }
    3745             : 
    3746             : //------------------------------------------------------------------------------
    3747           0 : void SAL_CALL ODatabaseForm::setClob(sal_Int32 parameterIndex, const Reference<XClob>& x) throw( SQLException, RuntimeException )
    3748             : {
    3749           0 :     m_aParameterManager.setClob(parameterIndex, x);
    3750           0 : }
    3751             : 
    3752             : //------------------------------------------------------------------------------
    3753           0 : void SAL_CALL ODatabaseForm::setArray(sal_Int32 parameterIndex, const Reference<XArray>& x) throw( SQLException, RuntimeException )
    3754             : {
    3755           0 :     m_aParameterManager.setArray(parameterIndex, x);
    3756           0 : }
    3757             : 
    3758             : //------------------------------------------------------------------------------
    3759           0 : void SAL_CALL ODatabaseForm::clearParameters() throw( SQLException, RuntimeException )
    3760             : {
    3761           0 :     m_aParameterManager.clearParameters();
    3762           0 : }
    3763             : 
    3764             : //------------------------------------------------------------------------------
    3765           1 : void SAL_CALL ODatabaseForm::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
    3766             : {
    3767           1 :     if ( evt.Source == m_xParent )
    3768             :     {
    3769           0 :         if ( evt.PropertyName == PROPERTY_ISNEW )
    3770             :         {
    3771           0 :             sal_Bool bCurrentIsNew( sal_False );
    3772           0 :             OSL_VERIFY( evt.NewValue >>= bCurrentIsNew );
    3773           0 :             if ( !bCurrentIsNew )
    3774           0 :                 reload_impl( sal_True );
    3775             :         }
    3776           1 :         return;
    3777             :     }
    3778           1 :     OFormComponents::propertyChange( evt );
    3779             : }
    3780             : 
    3781             : // com::sun::star::lang::XServiceInfo
    3782             : //------------------------------------------------------------------------------
    3783           6 : ::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName_Static()
    3784             : {
    3785           6 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.forms.ODatabaseForm" ) );
    3786             : }
    3787             : 
    3788             : //------------------------------------------------------------------------------
    3789           3 : Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getCompatibleServiceNames_Static()
    3790             : {
    3791           3 :     Sequence< ::rtl::OUString > aServices( 1 );
    3792           3 :     ::rtl::OUString* pServices = aServices.getArray();
    3793             : 
    3794           3 :     *pServices++ = FRM_COMPONENT_FORM;
    3795             : 
    3796           3 :     return aServices;
    3797             : }
    3798             : 
    3799             : //------------------------------------------------------------------------------
    3800           3 : Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getCurrentServiceNames_Static()
    3801             : {
    3802           3 :     Sequence< ::rtl::OUString > aServices( 5 );
    3803           3 :     ::rtl::OUString* pServices = aServices.getArray();
    3804             : 
    3805           3 :     *pServices++ = FRM_SUN_FORMCOMPONENT;
    3806           3 :     *pServices++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.FormComponents") );
    3807           3 :     *pServices++ = FRM_SUN_COMPONENT_FORM;
    3808           3 :     *pServices++ = FRM_SUN_COMPONENT_HTMLFORM;
    3809           3 :     *pServices++ = FRM_SUN_COMPONENT_DATAFORM;
    3810             : 
    3811           3 :     return aServices;
    3812             : }
    3813             : 
    3814             : //------------------------------------------------------------------------------
    3815           3 : Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames_Static()
    3816             : {
    3817             :     return ::comphelper::concatSequences(
    3818             :         getCurrentServiceNames_Static(),
    3819             :         getCompatibleServiceNames_Static()
    3820           3 :     );
    3821             : }
    3822             : 
    3823             : //------------------------------------------------------------------------------
    3824           0 : ::rtl::OUString SAL_CALL ODatabaseForm::getImplementationName() throw( RuntimeException )
    3825             : {
    3826           0 :     return getImplementationName_Static();
    3827             : }
    3828             : 
    3829             : //------------------------------------------------------------------------------
    3830           0 : Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames() throw( RuntimeException )
    3831             : {
    3832             :     // the services of our aggregate
    3833           0 :     Sequence< ::rtl::OUString > aServices;
    3834           0 :     Reference< XServiceInfo > xInfo;
    3835           0 :     if (query_aggregation(m_xAggregate, xInfo))
    3836           0 :         aServices = xInfo->getSupportedServiceNames();
    3837             : 
    3838             :     // concat with out own services
    3839             :     return ::comphelper::concatSequences(
    3840             :         getCurrentServiceNames_Static(),
    3841             :         aServices
    3842           0 :     );
    3843             :     // use getCurrentXXX instead of getSupportedXXX, because at runtime, we do not want to have
    3844             :     // the compatible names
    3845             :     // This is maily to be consistent with the implementation before fixing #97083#, though the
    3846             :     // better solution _may_ be to return the compatible names at runtime, too
    3847             : }
    3848             : 
    3849             : //------------------------------------------------------------------------------
    3850           0 : sal_Bool SAL_CALL ODatabaseForm::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException )
    3851             : {
    3852           0 :     Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
    3853           0 :     const ::rtl::OUString* pArray = aSupported.getConstArray();
    3854           0 :     for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray )
    3855           0 :         if( pArray->equals( ServiceName ) )
    3856           0 :             return sal_True;
    3857           0 :     return sal_False;
    3858             : }
    3859             : 
    3860             : //==============================================================================
    3861             : // com::sun::star::io::XPersistObject
    3862             : //------------------------------------------------------------------------------
    3863             : 
    3864             : const sal_uInt16 CYCLE              = 0x0001;
    3865             : const sal_uInt16 DONTAPPLYFILTER    = 0x0002;
    3866             : 
    3867             : //------------------------------------------------------------------------------
    3868           0 : ::rtl::OUString ODatabaseForm::getServiceName() throw( RuntimeException )
    3869             : {
    3870           0 :     return FRM_COMPONENT_FORM;  // old (non-sun) name for compatibility !
    3871             : }
    3872             : 
    3873             : //------------------------------------------------------------------------------
    3874           0 : void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutStream) throw( IOException, RuntimeException )
    3875             : {
    3876             :     DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::write : only to be called if the aggregate exists !");
    3877             : 
    3878             :     // all children
    3879           0 :     OFormComponents::write(_rxOutStream);
    3880             : 
    3881             :     // version
    3882           0 :     _rxOutStream->writeShort(0x0003);
    3883             : 
    3884             :     // Name
    3885           0 :     _rxOutStream << m_sName;
    3886             : 
    3887           0 :     ::rtl::OUString sDataSource;
    3888           0 :     if (m_xAggregateSet.is())
    3889           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_DATASOURCE) >>= sDataSource;
    3890           0 :     _rxOutStream << sDataSource;
    3891             : 
    3892             :     // former CursorSource
    3893           0 :     ::rtl::OUString sCommand;
    3894           0 :     if (m_xAggregateSet.is())
    3895           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
    3896           0 :     _rxOutStream << sCommand;
    3897             : 
    3898             :     // former MasterFields
    3899           0 :     _rxOutStream << m_aMasterFields;
    3900             :     // former DetailFields
    3901           0 :     _rxOutStream << m_aDetailFields;
    3902             : 
    3903             :     // former DataSelectionType
    3904           0 :     DataSelectionType eTranslated = DataSelectionType_TABLE;
    3905           0 :     if (m_xAggregateSet.is())
    3906             :     {
    3907           0 :         sal_Int32 nCommandType = 0;
    3908           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_COMMANDTYPE) >>= nCommandType;
    3909           0 :         switch (nCommandType)
    3910             :         {
    3911           0 :             case CommandType::TABLE : eTranslated = DataSelectionType_TABLE; break;
    3912           0 :             case CommandType::QUERY : eTranslated = DataSelectionType_QUERY; break;
    3913             :             case CommandType::COMMAND:
    3914             :             {
    3915           0 :                 sal_Bool bEscapeProcessing = getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING));
    3916           0 :                 eTranslated = bEscapeProcessing ? DataSelectionType_SQL : DataSelectionType_SQLPASSTHROUGH;
    3917             :             }
    3918           0 :             break;
    3919             :             default : OSL_FAIL("ODatabaseForm::write : wrong CommandType !");
    3920             :         }
    3921             :     }
    3922           0 :     _rxOutStream->writeShort((sal_Int16)eTranslated);           // former DataSelectionType
    3923             : 
    3924             :     // very old versions expect a CursorType here
    3925           0 :     _rxOutStream->writeShort(DatabaseCursorType_KEYSET);
    3926             : 
    3927           0 :     _rxOutStream->writeBoolean(m_eNavigation != NavigationBarMode_NONE);
    3928             : 
    3929             :     // former DataEntry
    3930           0 :     if (m_xAggregateSet.is())
    3931           0 :         _rxOutStream->writeBoolean(getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_INSERTONLY)));
    3932             :     else
    3933           0 :         _rxOutStream->writeBoolean(sal_False);
    3934             : 
    3935           0 :     _rxOutStream->writeBoolean(m_bAllowInsert);
    3936           0 :     _rxOutStream->writeBoolean(m_bAllowUpdate);
    3937           0 :     _rxOutStream->writeBoolean(m_bAllowDelete);
    3938             : 
    3939             :     // html form stuff
    3940           0 :     ::rtl::OUString sTmp = INetURLObject::decode( m_aTargetURL, '%', INetURLObject::DECODE_UNAMBIGUOUS);
    3941           0 :     _rxOutStream << sTmp;
    3942           0 :     _rxOutStream->writeShort( (sal_Int16)m_eSubmitMethod );
    3943           0 :     _rxOutStream->writeShort( (sal_Int16)m_eSubmitEncoding );
    3944           0 :     _rxOutStream << m_aTargetFrame;
    3945             : 
    3946             :     // version 2 didn't know some options and the "default" state
    3947           0 :     sal_Int32 nCycle = TabulatorCycle_RECORDS;
    3948           0 :     if (m_aCycle.hasValue())
    3949             :     {
    3950           0 :         ::cppu::enum2int(nCycle, m_aCycle);
    3951           0 :         if (m_aCycle == TabulatorCycle_PAGE)
    3952             :                 // unknown in earlier versions
    3953           0 :             nCycle = TabulatorCycle_RECORDS;
    3954             :     }
    3955           0 :     _rxOutStream->writeShort((sal_Int16) nCycle);
    3956             : 
    3957           0 :     _rxOutStream->writeShort((sal_Int16)m_eNavigation);
    3958             : 
    3959           0 :     ::rtl::OUString sFilter;
    3960           0 :     ::rtl::OUString sOrder;
    3961           0 :     if (m_xAggregateSet.is())
    3962             :     {
    3963           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_FILTER) >>= sFilter;
    3964           0 :         m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sOrder;
    3965             :     }
    3966           0 :     _rxOutStream << sFilter;
    3967           0 :     _rxOutStream << sOrder;
    3968             : 
    3969             : 
    3970             :     // version 3
    3971           0 :     sal_uInt16 nAnyMask = 0;
    3972           0 :     if (m_aCycle.hasValue())
    3973           0 :         nAnyMask |= CYCLE;
    3974             : 
    3975           0 :     if (m_xAggregateSet.is() && !getBOOL(m_xAggregateSet->getPropertyValue(PROPERTY_APPLYFILTER)))
    3976           0 :         nAnyMask |= DONTAPPLYFILTER;
    3977             : 
    3978           0 :     _rxOutStream->writeShort(nAnyMask);
    3979             : 
    3980           0 :     if (nAnyMask & CYCLE)
    3981             :     {
    3982           0 :         sal_Int32 nRealCycle = 0;
    3983           0 :         ::cppu::enum2int(nRealCycle, m_aCycle);
    3984           0 :         _rxOutStream->writeShort((sal_Int16)nRealCycle);
    3985           0 :     }
    3986           0 : }
    3987             : 
    3988             : //------------------------------------------------------------------------------
    3989           0 : void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStream) throw( IOException, RuntimeException )
    3990             : {
    3991             :     DBG_ASSERT(m_xAggregateSet.is(), "ODatabaseForm::read : only to be called if the aggregate exists !");
    3992             : 
    3993           0 :     OFormComponents::read(_rxInStream);
    3994             : 
    3995             :     // version
    3996           0 :     sal_uInt16 nVersion = _rxInStream->readShort();
    3997             : 
    3998           0 :     _rxInStream >> m_sName;
    3999             : 
    4000           0 :     ::rtl::OUString sAggregateProp;
    4001           0 :     _rxInStream >> sAggregateProp;
    4002           0 :     if (m_xAggregateSet.is())
    4003           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, makeAny(sAggregateProp));
    4004           0 :     _rxInStream >> sAggregateProp;
    4005           0 :     if (m_xAggregateSet.is())
    4006           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, makeAny(sAggregateProp));
    4007             : 
    4008           0 :     _rxInStream >> m_aMasterFields;
    4009           0 :     _rxInStream >> m_aDetailFields;
    4010             : 
    4011           0 :     sal_Int16 nCursorSourceType = _rxInStream->readShort();
    4012           0 :     sal_Int32 nCommandType = 0;
    4013           0 :     switch ((DataSelectionType)nCursorSourceType)
    4014             :     {
    4015           0 :         case DataSelectionType_TABLE : nCommandType = CommandType::TABLE; break;
    4016           0 :         case DataSelectionType_QUERY : nCommandType = CommandType::QUERY; break;
    4017             :         case DataSelectionType_SQL:
    4018             :         case DataSelectionType_SQLPASSTHROUGH:
    4019             :         {
    4020           0 :             nCommandType = CommandType::COMMAND;
    4021           0 :             sal_Bool bEscapeProcessing = ((DataSelectionType)nCursorSourceType) != DataSelectionType_SQLPASSTHROUGH;
    4022           0 :             m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, makeAny((sal_Bool)bEscapeProcessing));
    4023             :         }
    4024           0 :         break;
    4025             :         default : OSL_FAIL("ODatabaseForm::read : wrong CommandType !");
    4026             :     }
    4027           0 :     if (m_xAggregateSet.is())
    4028           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, makeAny(nCommandType));
    4029             : 
    4030             :     // obsolete
    4031           0 :     _rxInStream->readShort();
    4032             : 
    4033             :     // navigation mode was a boolean in version 1
    4034             :     // was a sal_Bool in version 1
    4035           0 :     sal_Bool bNavigation = _rxInStream->readBoolean();
    4036           0 :     if (nVersion == 1)
    4037           0 :         m_eNavigation = bNavigation ? NavigationBarMode_CURRENT : NavigationBarMode_NONE;
    4038             : 
    4039           0 :     sal_Bool bInsertOnly = _rxInStream->readBoolean();
    4040           0 :     if (m_xAggregateSet.is())
    4041           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, makeAny(bInsertOnly));
    4042             : 
    4043           0 :     m_bAllowInsert      = _rxInStream->readBoolean();
    4044           0 :     m_bAllowUpdate      = _rxInStream->readBoolean();
    4045           0 :     m_bAllowDelete      = _rxInStream->readBoolean();
    4046             : 
    4047             :     // html stuff
    4048           0 :     ::rtl::OUString sTmp;
    4049           0 :     _rxInStream >> sTmp;
    4050           0 :     m_aTargetURL = INetURLObject::decode( sTmp, '%', INetURLObject::DECODE_UNAMBIGUOUS);
    4051           0 :     m_eSubmitMethod     = (FormSubmitMethod)_rxInStream->readShort();
    4052           0 :     m_eSubmitEncoding       = (FormSubmitEncoding)_rxInStream->readShort();
    4053           0 :     _rxInStream >> m_aTargetFrame;
    4054             : 
    4055           0 :     if (nVersion > 1)
    4056             :     {
    4057           0 :         sal_Int32 nCycle = _rxInStream->readShort();
    4058           0 :         m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
    4059           0 :         m_eNavigation = (NavigationBarMode)_rxInStream->readShort();
    4060             : 
    4061           0 :         _rxInStream >> sAggregateProp;
    4062           0 :         setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp));
    4063             : 
    4064           0 :         _rxInStream >> sAggregateProp;
    4065           0 :         if (m_xAggregateSet.is())
    4066           0 :             m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp));
    4067             :     }
    4068             : 
    4069           0 :     sal_uInt16 nAnyMask = 0;
    4070           0 :     if (nVersion > 2)
    4071             :     {
    4072           0 :         nAnyMask = _rxInStream->readShort();
    4073           0 :         if (nAnyMask & CYCLE)
    4074             :         {
    4075           0 :             sal_Int32 nCycle = _rxInStream->readShort();
    4076           0 :             m_aCycle = ::cppu::int2enum(nCycle, ::getCppuType(static_cast<const TabulatorCycle*>(NULL)));
    4077             :         }
    4078             :         else
    4079           0 :             m_aCycle.clear();
    4080             :     }
    4081           0 :     if (m_xAggregateSet.is())
    4082           0 :         m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny((sal_Bool)((nAnyMask & DONTAPPLYFILTER) == 0)));
    4083           0 : }
    4084             : 
    4085             : //------------------------------------------------------------------------------
    4086          11 : void ODatabaseForm::implInserted( const ElementDescription* _pElement )
    4087             : {
    4088          11 :     OFormComponents::implInserted( _pElement );
    4089             : 
    4090          11 :     Reference< XSQLErrorBroadcaster >   xBroadcaster( _pElement->xInterface, UNO_QUERY );
    4091          11 :     Reference< XForm >                  xForm       ( _pElement->xInterface, UNO_QUERY );
    4092             : 
    4093          11 :     if ( xBroadcaster.is() && !xForm.is() )
    4094             :     {   // the object is an error broadcaster, but no form itself -> add ourself as listener
    4095           0 :         xBroadcaster->addSQLErrorListener( this );
    4096          11 :     }
    4097          11 : }
    4098             : 
    4099             : //------------------------------------------------------------------------------
    4100           1 : void ODatabaseForm::implRemoved(const InterfaceRef& _rxObject)
    4101             : {
    4102           1 :     OFormComponents::implRemoved( _rxObject );
    4103             : 
    4104           1 :     Reference<XSQLErrorBroadcaster>  xBroadcaster(_rxObject, UNO_QUERY);
    4105           1 :     Reference<XForm>  xForm(_rxObject, UNO_QUERY);
    4106           1 :     if (xBroadcaster.is() && !xForm.is())
    4107             :     {   // the object is an error broadcaster, but no form itself -> remove ourself as listener
    4108           0 :         xBroadcaster->removeSQLErrorListener(this);
    4109           1 :     }
    4110           1 : }
    4111             : 
    4112             : //------------------------------------------------------------------------------
    4113           0 : void SAL_CALL ODatabaseForm::errorOccured(const SQLErrorEvent& _rEvent) throw( RuntimeException )
    4114             : {
    4115             :     // give it to my own error listener
    4116           0 :     onError(_rEvent);
    4117             :     // TODO : think about extending the chain with an SQLContext object saying
    4118             :     // "this was an error of one of my children"
    4119           0 : }
    4120             : 
    4121             : // com::sun::star::container::XNamed
    4122             : //------------------------------------------------------------------------------
    4123           0 : ::rtl::OUString SAL_CALL ODatabaseForm::getName() throw( RuntimeException )
    4124             : {
    4125           0 :     ::rtl::OUString sReturn;
    4126           0 :     OPropertySetHelper::getFastPropertyValue(PROPERTY_ID_NAME) >>= sReturn;
    4127           0 :     return sReturn;
    4128             : }
    4129             : 
    4130             : //------------------------------------------------------------------------------
    4131           0 : void SAL_CALL ODatabaseForm::setName(const ::rtl::OUString& aName) throw( RuntimeException )
    4132             : {
    4133           0 :     setFastPropertyValue(PROPERTY_ID_NAME, makeAny(aName));
    4134           0 : }
    4135             : 
    4136             : //.........................................................................
    4137             : }   // namespace frm
    4138             : //.........................................................................
    4139             : 
    4140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10