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