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

Generated by: LCOV version 1.11