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