merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / browser / formadapter.cxx
blob826b982becbf1bb131e842e9c0344f586e016efa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formadapter.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _SBA_FORMADAPTER_HXX
35 #include "formadapter.hxx"
36 #endif
37 #ifndef _TOOLS_DEBUG_HXX //autogen
38 #include <tools/debug.hxx>
39 #endif
40 #ifndef _COMPHELPER_TYPES_HXX_
41 #include <comphelper/types.hxx>
42 #endif
43 #ifndef _COMPHELPER_ENUMHELPER_HXX_
44 #include <comphelper/enumhelper.hxx>
45 #endif
46 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #endif
49 #ifndef _STRING_HXX
50 #include <tools/string.hxx>
51 #endif
52 #ifndef _DBU_BRW_HRC_
53 #include "dbu_brw.hrc"
54 #endif
55 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
56 #include "dbustrings.hrc"
57 #endif
58 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
59 #include <cppuhelper/typeprovider.hxx>
60 #endif
61 #ifndef _COMPHELPER_SEQUENCE_HXX_
62 #include <comphelper/sequence.hxx>
63 #endif
65 using namespace dbaui;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::sdb;
68 using namespace ::com::sun::star::sdbcx;
69 using namespace ::com::sun::star::beans;
70 using namespace ::com::sun::star::container;
72 //==================================================================
73 // SbaXFormAdapter
74 //==================================================================
76 DBG_NAME(SbaXFormAdapter)
77 // -------------------------------------------------------------------------
78 SbaXFormAdapter::SbaXFormAdapter()
79 :m_aLoadListeners(*this, m_aMutex)
80 ,m_aRowSetListeners(*this, m_aMutex)
81 ,m_aRowSetApproveListeners(*this, m_aMutex)
82 ,m_aErrorListeners(*this, m_aMutex)
83 ,m_aParameterListeners(*this, m_aMutex)
84 ,m_aSubmitListeners(*this, m_aMutex)
85 ,m_aResetListeners(*this, m_aMutex)
86 ,m_aPropertyChangeListeners(*this, m_aMutex)
87 ,m_aVetoablePropertyChangeListeners(*this, m_aMutex)
88 ,m_aPropertiesChangeListeners(*this, m_aMutex)
89 ,m_aDisposeListeners(m_aMutex)
90 ,m_aContainerListeners(m_aMutex)
91 ,m_nNamePropHandle(-1)
93 DBG_CTOR(SbaXFormAdapter,NULL);
97 // -------------------------------------------------------------------------
98 SbaXFormAdapter::~SbaXFormAdapter()
101 DBG_DTOR(SbaXFormAdapter,NULL);
104 // -------------------------------------------------------------------------
105 Sequence< Type > SAL_CALL SbaXFormAdapter::getTypes( ) throw (RuntimeException)
107 return ::comphelper::concatSequences(
108 SbaXFormAdapter_BASE1::getTypes(),
109 SbaXFormAdapter_BASE2::getTypes(),
110 SbaXFormAdapter_BASE3::getTypes()
114 // -------------------------------------------------------------------------
115 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getImplementationId( ) throw (RuntimeException)
117 static ::cppu::OImplementationId * pId = 0;
118 if (! pId)
120 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
121 if (! pId)
123 static ::cppu::OImplementationId aId;
124 pId = &aId;
127 return pId->getImplementationId();
130 // -------------------------------------------------------------------------
131 Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) throw (RuntimeException)
133 Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
135 if (!aReturn.hasValue())
136 aReturn = SbaXFormAdapter_BASE2::queryInterface( _rType );
138 if (!aReturn.hasValue())
139 aReturn = SbaXFormAdapter_BASE3::queryInterface( _rType );
141 return aReturn;
144 // -------------------------------------------------------------------------
145 void SbaXFormAdapter::StopListening()
147 // log off all our multiplexers
148 STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
149 STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
150 STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
151 STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
152 STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
153 STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
155 if (m_aParameterListeners.getLength())
157 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
158 if (xBroadcaster.is())
159 xBroadcaster->removeParameterListener(&m_aParameterListeners);
162 STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
163 STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
164 if (m_aPropertiesChangeListeners.getLength())
166 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
167 if (xBroadcaster.is())
168 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
171 // log off ourself
172 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
173 if (xComp.is())
174 xComp->removeEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
177 // -------------------------------------------------------------------------
178 void SbaXFormAdapter::StartListening()
180 // log off all our multiplexers
181 START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
182 START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
183 START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
184 START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
185 START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
186 START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
188 if (m_aParameterListeners.getLength())
190 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
191 if (xBroadcaster.is())
192 xBroadcaster->addParameterListener(&m_aParameterListeners);
195 START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
196 START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
197 if (m_aPropertiesChangeListeners.getLength())
199 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
200 ::rtl::OUString sEmpty;
201 if (xBroadcaster.is())
202 xBroadcaster->addPropertiesChangeListener(::comphelper::StringSequence(&sEmpty, 1), &m_aPropertiesChangeListeners);
205 // log off ourself
206 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
207 if (xComp.is())
208 xComp->addEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
211 // -------------------------------------------------------------------------
212 void SbaXFormAdapter::AttachForm(const Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster)
214 if (xNewMaster == m_xMainForm)
215 return;
217 DBG_ASSERT(xNewMaster.get() != static_cast< ::com::sun::star::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
219 if (m_xMainForm.is())
221 StopListening();
223 // if our old master is loaded we have to send an 'unloaded' event
224 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
225 if (xLoadable->isLoaded())
227 ::com::sun::star::lang::EventObject aEvt(*this);
228 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
229 while (aIt.hasMoreElements())
230 ((::com::sun::star::form::XLoadListener*)aIt.next())->unloaded(aEvt);
234 m_xMainForm = xNewMaster;
236 if (m_xMainForm.is())
238 StartListening();
240 // if our new master is loaded we have to send an 'loaded' event
241 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
242 if (xLoadable->isLoaded())
244 ::com::sun::star::lang::EventObject aEvt(*this);
245 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
246 while (aIt.hasMoreElements())
247 ((::com::sun::star::form::XLoadListener*)aIt.next())->loaded(aEvt);
251 // TODO : perhaps _all_ of our listeners should be notified about our new state
252 // (nearly every aspect of us may have changed with new master form)
255 // ::com::sun::star::sdbc::XCloseable
256 // -------------------------------------------------------------------------
257 void SAL_CALL SbaXFormAdapter::close() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
259 Reference< ::com::sun::star::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
260 if (xIface.is())
261 xIface->close();
264 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
265 // -------------------------------------------------------------------------
266 Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
268 Reference< ::com::sun::star::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
269 if (xIface.is())
270 return xIface->getMetaData();
271 return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ();
274 // ::com::sun::star::sdbc::XColumnLocate
275 // -------------------------------------------------------------------------
276 sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const ::rtl::OUString& columnName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
278 Reference< ::com::sun::star::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
279 if (xIface.is())
280 return xIface->findColumn(columnName);
281 return 0;
284 // ::com::sun::star::sdbcx::XColumnsSupplier
285 // -------------------------------------------------------------------------
286 Reference< ::com::sun::star::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException )
288 Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
289 if (xIface.is())
290 return xIface->getColumns();
291 return Reference< ::com::sun::star::container::XNameAccess > ();
294 // ::com::sun::star::sdbc::XRow
295 // -------------------------------------------------------------------------
296 sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
298 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
299 if (xIface.is())
300 return xIface->wasNull();
301 return sal_True;
303 // -------------------------------------------------------------------------
304 ::rtl::OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
306 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
307 if (xIface.is())
308 return xIface->getString(columnIndex);
309 return ::rtl::OUString();
311 // -------------------------------------------------------------------------
312 sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
314 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
315 if (xIface.is())
316 return xIface->getBoolean(columnIndex);
317 return sal_False;
319 // -------------------------------------------------------------------------
320 sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
322 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
323 if (xIface.is())
324 return xIface->getByte(columnIndex);
325 return 0;
327 // -------------------------------------------------------------------------
328 sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
330 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
331 if (xIface.is())
332 return xIface->getShort(columnIndex);
333 return 0;
335 // -------------------------------------------------------------------------
336 sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
338 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
339 if (xIface.is())
340 return xIface->getInt(columnIndex);
341 return 0;
343 // -------------------------------------------------------------------------
344 sal_Int64 SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
346 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
347 if (xIface.is())
348 return xIface->getLong(columnIndex);
349 return 0;
351 // -------------------------------------------------------------------------
352 float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
354 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
355 if (xIface.is())
356 return xIface->getFloat(columnIndex);
357 return 0.0;
359 // -------------------------------------------------------------------------
360 double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
362 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
363 if (xIface.is())
364 return xIface->getDouble(columnIndex);
365 return 0.0;
367 // -------------------------------------------------------------------------
368 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
370 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
371 if (xIface.is())
372 return xIface->getBytes(columnIndex);
373 return Sequence <sal_Int8> ();
375 // -------------------------------------------------------------------------
376 ::com::sun::star::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
378 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
379 if (xIface.is())
380 return xIface->getDate(columnIndex);
381 return ::com::sun::star::util::Date();
383 // -------------------------------------------------------------------------
384 ::com::sun::star::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
386 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
387 if (xIface.is())
388 return xIface->getTime(columnIndex);
389 return ::com::sun::star::util::Time();
391 // -------------------------------------------------------------------------
392 ::com::sun::star::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
394 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
395 if (xIface.is())
396 return xIface->getTimestamp(columnIndex);
397 return ::com::sun::star::util::DateTime();
399 // -------------------------------------------------------------------------
400 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
402 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
403 if (xIface.is())
404 return xIface->getBinaryStream(columnIndex);
405 return Reference< ::com::sun::star::io::XInputStream > ();
407 // -------------------------------------------------------------------------
408 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
410 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
411 if (xIface.is())
412 return xIface->getCharacterStream(columnIndex);
413 return Reference< ::com::sun::star::io::XInputStream > ();
415 // -------------------------------------------------------------------------
416 Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
418 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
419 if (xIface.is())
420 return xIface->getObject(columnIndex, typeMap);
421 return Any();
423 // -------------------------------------------------------------------------
424 Reference< ::com::sun::star::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
426 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
427 if (xIface.is())
428 return xIface->getRef(columnIndex);
429 return Reference< ::com::sun::star::sdbc::XRef > ();
431 // -------------------------------------------------------------------------
432 Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
434 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
435 if (xIface.is())
436 return xIface->getBlob(columnIndex);
437 return Reference< ::com::sun::star::sdbc::XBlob > ();
439 // -------------------------------------------------------------------------
440 Reference< ::com::sun::star::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
442 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
443 if (xIface.is())
444 return xIface->getClob(columnIndex);
445 return Reference< ::com::sun::star::sdbc::XClob > ();
447 // -------------------------------------------------------------------------
448 Reference< ::com::sun::star::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
450 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
451 if (xIface.is())
452 return xIface->getArray(columnIndex);
453 return Reference< ::com::sun::star::sdbc::XArray > ();
456 // ::com::sun::star::sdbcx::XRowLocate
457 // -------------------------------------------------------------------------
458 Any SAL_CALL SbaXFormAdapter::getBookmark() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
460 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
461 if (xIface.is())
462 return xIface->getBookmark();
463 return Any();
465 // -------------------------------------------------------------------------
466 sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
468 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
469 if (xIface.is())
470 return xIface->moveToBookmark(bookmark);
471 return sal_False;
473 // -------------------------------------------------------------------------
474 sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
476 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
477 if (xIface.is())
478 return xIface->moveRelativeToBookmark(bookmark,rows);
479 return sal_False;
481 // -------------------------------------------------------------------------
482 sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
484 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
485 if (xIface.is())
486 return xIface->compareBookmarks(_first, _second);
487 return 0;
490 // -------------------------------------------------------------------------
491 sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
493 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
494 if (xIface.is())
495 return xIface->hasOrderedBookmarks();
496 return sal_False;
499 // -------------------------------------------------------------------------
500 sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
502 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
503 if (xIface.is())
504 return xIface->hashBookmark(bookmark);
505 return 0;
508 // ::com::sun::star::sdbc::XRowUpdate
509 // -------------------------------------------------------------------------
510 void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
512 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
513 if (xIface.is())
514 xIface->updateNull(columnIndex);
516 // -------------------------------------------------------------------------
517 void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
519 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
520 if (xIface.is())
521 xIface->updateBoolean(columnIndex, x);
523 // -------------------------------------------------------------------------
524 void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
526 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
527 if (xIface.is())
528 xIface->updateByte(columnIndex, x);
530 // -------------------------------------------------------------------------
531 void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
533 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
534 if (xIface.is())
535 xIface->updateShort(columnIndex, x);
537 // -------------------------------------------------------------------------
538 void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
540 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
541 if (xIface.is())
542 xIface->updateInt(columnIndex, x);
544 // -------------------------------------------------------------------------
545 void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
547 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
548 if (xIface.is())
549 xIface->updateLong(columnIndex, x);
551 // -------------------------------------------------------------------------
552 void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
554 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
555 if (xIface.is())
556 xIface->updateFloat(columnIndex, x);
558 // -------------------------------------------------------------------------
559 void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
561 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
562 if (xIface.is())
563 xIface->updateDouble(columnIndex, x);
565 // -------------------------------------------------------------------------
566 void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
568 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
569 if (xIface.is())
570 xIface->updateString(columnIndex, x);
572 // -------------------------------------------------------------------------
573 void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
575 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
576 if (xIface.is())
577 xIface->updateBytes(columnIndex, x);
579 // -------------------------------------------------------------------------
580 void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
582 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
583 if (xIface.is())
584 xIface->updateDate(columnIndex, x);
586 // -------------------------------------------------------------------------
587 void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
589 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
590 if (xIface.is())
591 xIface->updateTime(columnIndex, x);
593 // -------------------------------------------------------------------------
594 void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
596 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
597 if (xIface.is())
598 xIface->updateTimestamp(columnIndex, x);
600 // -------------------------------------------------------------------------
601 void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
603 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
604 if (xIface.is())
605 xIface->updateBinaryStream(columnIndex, x, length);
607 // -------------------------------------------------------------------------
608 void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
610 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
611 if (xIface.is())
612 xIface->updateCharacterStream(columnIndex, x, length);
614 // -------------------------------------------------------------------------
615 void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
617 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
618 if (xIface.is())
619 xIface->updateObject(columnIndex, x);
621 // -------------------------------------------------------------------------
622 void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
624 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
625 if (xIface.is())
626 xIface->updateNumericObject(columnIndex, x, scale);
629 // ::com::sun::star::sdbc::XResultSet
630 // -------------------------------------------------------------------------
631 sal_Bool SAL_CALL SbaXFormAdapter::next() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
633 if (m_xMainForm.is())
634 return m_xMainForm->next();
635 return sal_False;
637 // -------------------------------------------------------------------------
638 sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
640 if (m_xMainForm.is())
641 return m_xMainForm->isBeforeFirst();
642 return sal_False;
644 // -------------------------------------------------------------------------
645 sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
647 if (m_xMainForm.is())
648 return m_xMainForm->isAfterLast();
649 return sal_False;
651 // -------------------------------------------------------------------------
652 sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
654 if (m_xMainForm.is())
655 return m_xMainForm->isFirst();
656 return sal_False;
658 // -------------------------------------------------------------------------
659 sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
661 if (m_xMainForm.is())
662 return m_xMainForm->isLast();
663 return sal_False;
665 // -------------------------------------------------------------------------
666 void SAL_CALL SbaXFormAdapter::beforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
668 if (m_xMainForm.is())
669 m_xMainForm->beforeFirst();
671 // -------------------------------------------------------------------------
672 void SAL_CALL SbaXFormAdapter::afterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
674 if (m_xMainForm.is())
675 m_xMainForm->afterLast();
677 // -------------------------------------------------------------------------
678 sal_Bool SAL_CALL SbaXFormAdapter::first() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
680 if (m_xMainForm.is())
681 return m_xMainForm->first();
682 return sal_False;
684 // -------------------------------------------------------------------------
685 sal_Bool SAL_CALL SbaXFormAdapter::last() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
687 if (m_xMainForm.is())
688 return m_xMainForm->last();
689 return sal_False;
691 // -------------------------------------------------------------------------
692 sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
694 if (m_xMainForm.is())
695 return m_xMainForm->getRow();
696 return sal_False;
698 // -------------------------------------------------------------------------
699 sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
701 if (m_xMainForm.is())
702 return m_xMainForm->absolute(row);
703 return sal_False;
705 // -------------------------------------------------------------------------
706 sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
708 if (m_xMainForm.is())
709 return m_xMainForm->relative(rows);
710 return sal_False;
712 // -------------------------------------------------------------------------
713 sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
715 if (m_xMainForm.is())
716 return m_xMainForm->previous();
717 return sal_False;
719 // -------------------------------------------------------------------------
720 void SAL_CALL SbaXFormAdapter::refreshRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
722 if (m_xMainForm.is())
723 m_xMainForm->refreshRow();
726 // -------------------------------------------------------------------------
727 sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
729 if (m_xMainForm.is())
730 return m_xMainForm->rowUpdated();
731 return sal_False;
733 // -------------------------------------------------------------------------
734 sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
736 if (m_xMainForm.is())
737 return m_xMainForm->rowInserted();
738 return sal_False;
740 // -------------------------------------------------------------------------
741 sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
743 if (m_xMainForm.is())
744 return m_xMainForm->rowDeleted();
745 return sal_False;
747 // -------------------------------------------------------------------------
748 Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
750 if (m_xMainForm.is())
751 return m_xMainForm->getStatement();
752 return NULL;
755 // ::com::sun::star::sdbc::XResultSetUpdate
756 // -------------------------------------------------------------------------
757 void SAL_CALL SbaXFormAdapter::insertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
759 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
760 if (xIface.is())
761 xIface->insertRow();
763 // -------------------------------------------------------------------------
764 void SAL_CALL SbaXFormAdapter::updateRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
766 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
767 if (xIface.is())
768 xIface->updateRow();
770 // -------------------------------------------------------------------------
771 void SAL_CALL SbaXFormAdapter::deleteRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
773 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
774 if (xIface.is())
775 xIface->deleteRow();
777 // -------------------------------------------------------------------------
778 void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
780 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
781 if (xIface.is())
782 xIface->cancelRowUpdates();
784 // -------------------------------------------------------------------------
785 void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
787 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
788 if (xIface.is())
789 xIface->moveToInsertRow();
791 // -------------------------------------------------------------------------
792 void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
794 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
795 if (xIface.is())
796 xIface->moveToCurrentRow();
799 // ::com::sun::star::sdbc::XRowSet
800 // -------------------------------------------------------------------------
801 void SAL_CALL SbaXFormAdapter::execute() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
803 if (m_xMainForm.is())
804 m_xMainForm->execute();
806 // -------------------------------------------------------------------------
807 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm)
809 // ::com::sun::star::sdbcx::XDeleteRows
810 // -------------------------------------------------------------------------
811 Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
813 Reference< ::com::sun::star::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
814 if (xIface.is())
815 return xIface->deleteRows(rows);
816 return Sequence<sal_Int32>();
819 // ::com::sun::star::sdbc::XWarningsSupplier
820 // -------------------------------------------------------------------------
821 Any SAL_CALL SbaXFormAdapter::getWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
823 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
824 if (xIface.is())
825 return xIface->getWarnings();
826 return Any();
828 // -------------------------------------------------------------------------
829 void SAL_CALL SbaXFormAdapter::clearWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
831 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
832 if (xIface.is())
833 xIface->clearWarnings();
836 // ::com::sun::star::sdb::XRowSetApproveBroadcaster
837 // -------------------------------------------------------------------------
838 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm)
840 // com::sun::star::sdbc::XSQLErrorBroadcaster
841 // -------------------------------------------------------------------------
842 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm)
844 // ::com::sun::star::sdb::XResultSetAccess
845 // -------------------------------------------------------------------------
846 Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
848 Reference< ::com::sun::star::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
849 if (xIface.is())
850 return xIface->createResultSet();
851 return Reference< ::com::sun::star::sdbc::XResultSet > ();
854 // com::sun::star::form::XLoadable
855 // -------------------------------------------------------------------------
856 void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException )
858 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
859 if (xIface.is())
860 xIface->load();
862 // -------------------------------------------------------------------------
863 void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException )
865 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
866 if (xIface.is())
867 xIface->unload();
869 // -------------------------------------------------------------------------
870 void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException )
872 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
873 if (xIface.is())
874 xIface->reload();
876 // -------------------------------------------------------------------------
877 sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException )
879 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
880 if (xIface.is())
881 return xIface->isLoaded();
882 return sal_False;
884 // -------------------------------------------------------------------------
885 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm)
887 // ::com::sun::star::sdbc::XParameters
888 // -------------------------------------------------------------------------
889 void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
891 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
892 if (xIface.is())
893 xIface->setNull(parameterIndex, sqlType);
895 // -------------------------------------------------------------------------
896 void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
898 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
899 if (xIface.is())
900 xIface->setObjectNull(parameterIndex, sqlType, typeName);
902 // -------------------------------------------------------------------------
903 void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
905 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
906 if (xIface.is())
907 xIface->setBoolean(parameterIndex, x);
909 // -------------------------------------------------------------------------
910 void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
912 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
913 if (xIface.is())
914 xIface->setByte(parameterIndex, x);
916 // -------------------------------------------------------------------------
917 void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
919 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
920 if (xIface.is())
921 xIface->setShort(parameterIndex, x);
923 // -------------------------------------------------------------------------
924 void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
926 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
927 if (xIface.is())
928 xIface->setInt(parameterIndex, x);
930 // -------------------------------------------------------------------------
931 void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
933 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
934 if (xIface.is())
935 xIface->setLong(parameterIndex, x);
937 // -------------------------------------------------------------------------
938 void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
940 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
941 if (xIface.is())
942 xIface->setFloat(parameterIndex, x);
944 // -------------------------------------------------------------------------
945 void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
947 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
948 if (xIface.is())
949 xIface->setDouble(parameterIndex, x);
951 // -------------------------------------------------------------------------
952 void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
954 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
955 if (xIface.is())
956 xIface->setString(parameterIndex, x);
958 // -------------------------------------------------------------------------
959 void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
961 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
962 if (xIface.is())
963 xIface->setBytes(parameterIndex, x);
965 // -------------------------------------------------------------------------
966 void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
968 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
969 if (xIface.is())
970 xIface->setDate(parameterIndex, x);
972 // -------------------------------------------------------------------------
973 void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
975 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
976 if (xIface.is())
977 xIface->setTime(parameterIndex, x);
979 // -------------------------------------------------------------------------
980 void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
982 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
983 if (xIface.is())
984 xIface->setTimestamp(parameterIndex, x);
986 // -------------------------------------------------------------------------
987 void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
989 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
990 if (xIface.is())
991 xIface->setBinaryStream(parameterIndex, x, length);
993 // -------------------------------------------------------------------------
994 void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
996 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
997 if (xIface.is())
998 xIface->setCharacterStream(parameterIndex, x, length);
1000 // -------------------------------------------------------------------------
1001 void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1003 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1004 if (xIface.is())
1005 xIface->setObject(parameterIndex, x);
1007 // -------------------------------------------------------------------------
1008 void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1010 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1011 if (xIface.is())
1012 xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
1014 // -------------------------------------------------------------------------
1015 void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XRef >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1017 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1018 if (xIface.is())
1019 xIface->setRef(parameterIndex, x);
1021 // -------------------------------------------------------------------------
1022 void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XBlob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1024 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1025 if (xIface.is())
1026 xIface->setBlob(parameterIndex, x);
1028 // -------------------------------------------------------------------------
1029 void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XClob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1031 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1032 if (xIface.is())
1033 xIface->setClob(parameterIndex, x);
1035 // -------------------------------------------------------------------------
1036 void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XArray >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1038 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1039 if (xIface.is())
1040 xIface->setArray(parameterIndex, x);
1042 // -------------------------------------------------------------------------
1043 void SAL_CALL SbaXFormAdapter::clearParameters() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1045 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1046 if (xIface.is())
1047 xIface->clearParameters();
1050 // ::com::sun::star::form::XDatabaseParameterBroadcaster
1051 // -------------------------------------------------------------------------
1052 void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
1054 m_aParameterListeners.addInterface(aListener);
1055 if (m_aParameterListeners.getLength() == 1)
1057 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1058 if (xBroadcaster.is())
1059 xBroadcaster->addParameterListener(&m_aParameterListeners);
1063 // -------------------------------------------------------------------------
1064 void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
1066 if (m_aParameterListeners.getLength() == 1)
1068 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1069 if (xBroadcaster.is())
1070 xBroadcaster->removeParameterListener(&m_aParameterListeners);
1072 m_aParameterListeners.removeInterface(aListener);
1075 // ::com::sun::star::container::XChild
1076 // -------------------------------------------------------------------------
1077 Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException )
1079 return m_xParent;
1082 // -------------------------------------------------------------------------
1083 void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( ::com::sun::star::lang::NoSupportException, RuntimeException )
1085 m_xParent = Parent;
1088 // ::com::sun::star::form::XSubmit
1089 // -------------------------------------------------------------------------
1090 void SAL_CALL SbaXFormAdapter::submit(const Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw( RuntimeException )
1092 Reference< ::com::sun::star::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
1093 if (xSubmit.is())
1094 xSubmit->submit(aControl, aMouseEvt);
1097 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm)
1099 // ::com::sun::star::awt::XTabControllerModel
1100 // -------------------------------------------------------------------------
1101 sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException )
1103 DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1104 return sal_False;
1107 // -------------------------------------------------------------------------
1108 void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException )
1110 DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1113 // -------------------------------------------------------------------------
1114 void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*Controls*/) throw( RuntimeException )
1116 DBG_ERROR("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1119 // -------------------------------------------------------------------------
1120 Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException )
1122 DBG_ERROR("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1123 return Sequence< Reference< ::com::sun::star::awt::XControlModel > >();
1126 // -------------------------------------------------------------------------
1127 void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, const ::rtl::OUString& /*GroupName*/) throw( RuntimeException )
1129 DBG_ERROR("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1132 // -------------------------------------------------------------------------
1133 sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException )
1135 DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1136 return 0;
1139 // -------------------------------------------------------------------------
1140 void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, ::rtl::OUString& /*Name*/) throw( RuntimeException )
1142 DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1145 // -------------------------------------------------------------------------
1146 void SAL_CALL SbaXFormAdapter::getGroupByName(const ::rtl::OUString& /*Name*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/) throw( RuntimeException )
1148 DBG_ERROR("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1151 // ::com::sun::star::lang::XComponent
1152 // -------------------------------------------------------------------------
1153 void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException )
1155 // log off all multiplexers
1156 if (m_xMainForm.is())
1157 StopListening();
1159 ::com::sun::star::lang::EventObject aEvt(*this);
1160 m_aLoadListeners.disposeAndClear(aEvt);
1161 m_aRowSetListeners.disposeAndClear(aEvt);
1162 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1163 m_aErrorListeners.disposeAndClear(aEvt);
1164 m_aParameterListeners.disposeAndClear(aEvt);
1165 m_aSubmitListeners.disposeAndClear(aEvt);
1166 m_aResetListeners.disposeAndClear(aEvt);
1168 m_aVetoablePropertyChangeListeners.disposeAndClear();
1169 m_aPropertyChangeListeners.disposeAndClear();
1170 m_aPropertiesChangeListeners.disposeAndClear(aEvt);
1172 m_aDisposeListeners.disposeAndClear(aEvt);
1173 m_aContainerListeners.disposeAndClear(aEvt);
1175 // dispose all childs
1176 for ( ::std::vector< Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = m_aChildren.begin();
1177 aIter != m_aChildren.end();
1178 ++aIter
1181 Reference< ::com::sun::star::beans::XPropertySet > xSet(*aIter, UNO_QUERY);
1182 if (xSet.is())
1183 xSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1185 Reference< ::com::sun::star::container::XChild > xChild(*aIter, UNO_QUERY);
1186 if (xChild.is())
1187 xChild->setParent(Reference< XInterface > ());
1189 Reference< ::com::sun::star::lang::XComponent > xComp(*aIter, UNO_QUERY);
1190 if (xComp.is())
1191 xComp->dispose();
1193 m_aChildren.clear();
1196 // -------------------------------------------------------------------------
1197 void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< ::com::sun::star::lang::XEventListener >& xListener) throw( RuntimeException )
1199 m_aDisposeListeners.addInterface(xListener);
1202 // -------------------------------------------------------------------------
1203 void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener >& aListener) throw( RuntimeException )
1205 m_aDisposeListeners.removeInterface(aListener);
1208 // ::com::sun::star::beans::XFastPropertySet
1209 // -------------------------------------------------------------------------
1210 void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1212 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1213 DBG_ASSERT(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1215 if (m_nNamePropHandle == nHandle)
1217 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1219 throw ::com::sun::star::lang::IllegalArgumentException();
1222 // for notifying property listeners
1223 ::com::sun::star::beans::PropertyChangeEvent aEvt;
1224 aEvt.Source = *this;
1225 aEvt.PropertyName = PROPERTY_NAME;
1226 aEvt.PropertyHandle = m_nNamePropHandle;
1227 aEvt.OldValue <<= m_sName;
1228 aEvt.NewValue = aValue;
1230 aValue >>= m_sName;
1232 ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME));
1233 while (aIt.hasMoreElements())
1234 ((::com::sun::star::beans::XPropertyChangeListener*)aIt.next())->propertyChange(aEvt);
1236 return;
1239 xSet->setFastPropertyValue(nHandle, aValue);
1242 // -------------------------------------------------------------------------
1243 Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1245 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1246 DBG_ASSERT(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1248 if (m_nNamePropHandle == nHandle)
1249 return makeAny(m_sName);
1251 return xSet->getFastPropertyValue(nHandle);
1254 // ::com::sun::star::container::XNamed
1255 // -------------------------------------------------------------------------
1256 ::rtl::OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException )
1258 return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
1261 // -------------------------------------------------------------------------
1262 void SAL_CALL SbaXFormAdapter::setName(const ::rtl::OUString& aName) throw( RuntimeException )
1264 setPropertyValue(PROPERTY_NAME, makeAny(aName));
1267 // ::com::sun::star::io::XPersistObject
1268 // -------------------------------------------------------------------------
1269 ::rtl::OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException )
1271 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1272 if (xPersist.is())
1273 return xPersist->getServiceName();
1274 return ::rtl::OUString();
1277 // -------------------------------------------------------------------------
1278 void SAL_CALL SbaXFormAdapter::write(const Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw( ::com::sun::star::io::IOException, RuntimeException )
1280 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1281 if (xPersist.is())
1282 xPersist->write(_rxOutStream);
1285 // -------------------------------------------------------------------------
1286 void SAL_CALL SbaXFormAdapter::read(const Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw( ::com::sun::star::io::IOException, RuntimeException )
1288 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1289 if (xPersist.is())
1290 xPersist->read(_rxInStream);
1293 // ::com::sun::star::beans::XMultiPropertySet
1294 // -------------------------------------------------------------------------
1295 Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException )
1297 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1298 if (!xSet.is())
1299 return Reference< ::com::sun::star::beans::XPropertySetInfo > ();
1301 Reference< ::com::sun::star::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
1302 if (-1 == m_nNamePropHandle)
1304 // we need to determine the handle for the NAME property
1305 Sequence< ::com::sun::star::beans::Property> aProps = xReturn->getProperties();
1306 const ::com::sun::star::beans::Property* pProps = aProps.getConstArray();
1308 for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
1310 if (pProps->Name.equals(PROPERTY_NAME))
1312 ((SbaXFormAdapter*)this)->m_nNamePropHandle = pProps->Handle;
1313 break;
1317 return xReturn;
1320 // -------------------------------------------------------------------------
1321 void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< ::rtl::OUString >& PropertyNames, const Sequence< Any >& Values) throw( ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1323 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1324 if (xSet.is())
1325 xSet->setPropertyValues(PropertyNames, Values);
1328 // -------------------------------------------------------------------------
1329 Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< ::rtl::OUString >& aPropertyNames) throw( RuntimeException )
1331 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1332 if (!xSet.is())
1333 return Sequence< Any>(aPropertyNames.getLength());
1335 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1337 // search for (and fake) the NAME property
1338 const ::rtl::OUString* pNames = aPropertyNames.getConstArray();
1339 Any* pValues = aReturn.getArray();
1340 DBG_ASSERT(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
1341 for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues)
1342 if (pNames->equals(PROPERTY_NAME))
1344 (*pValues) <<= m_sName;
1345 break;
1348 return aReturn;
1351 // -------------------------------------------------------------------------
1352 void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< ::rtl::OUString>& /*aPropertyNames*/, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
1354 // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
1355 m_aPropertiesChangeListeners.addInterface(xListener);
1356 if (m_aPropertiesChangeListeners.getLength() == 1)
1358 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1359 ::rtl::OUString sEmpty;
1360 if (xBroadcaster.is())
1361 xBroadcaster->addPropertiesChangeListener(Sequence< ::rtl::OUString>(&sEmpty, 1), &m_aPropertiesChangeListeners);
1365 // -------------------------------------------------------------------------
1366 void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException )
1368 if (m_aPropertiesChangeListeners.getLength() == 1)
1370 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1371 if (xBroadcaster.is())
1372 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
1374 m_aPropertiesChangeListeners.removeInterface(Listener);
1377 // -------------------------------------------------------------------------
1378 void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< ::rtl::OUString >& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
1380 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1381 if (xSet.is())
1382 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1386 // ::com::sun::star::beans::XPropertySet
1387 // -------------------------------------------------------------------------
1388 void SAL_CALL SbaXFormAdapter::setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1390 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1391 if (!xSet.is())
1392 return;
1394 // special handling for the "name" property
1395 if (aPropertyName.equals(PROPERTY_NAME))
1396 setFastPropertyValue(m_nNamePropHandle, aValue);
1398 xSet->setPropertyValue(aPropertyName, aValue);
1401 // -------------------------------------------------------------------------
1402 Any SAL_CALL SbaXFormAdapter::getPropertyValue(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1404 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1405 if (!xSet.is())
1406 return Any();
1408 // special handling for the "name" property
1409 if (PropertyName.equals(PROPERTY_NAME))
1410 return getFastPropertyValue(m_nNamePropHandle);
1412 return xSet->getPropertyValue(PropertyName);
1415 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1416 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1418 // ::com::sun::star::util::XCancellable
1419 // -------------------------------------------------------------------------
1420 void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException )
1422 Reference< ::com::sun::star::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
1423 if (xCancel.is())
1424 return;
1425 xCancel->cancel();
1428 // ::com::sun::star::beans::XPropertyState
1429 // -------------------------------------------------------------------------
1430 ::com::sun::star::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
1432 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1433 if (xState.is())
1434 return xState->getPropertyState(PropertyName);
1435 return ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1438 // -------------------------------------------------------------------------
1439 Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< ::rtl::OUString >& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
1441 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1442 if (xState.is())
1443 return xState->getPropertyStates(aPropertyName);
1445 // set them all to DEFAULT
1446 Sequence< ::com::sun::star::beans::PropertyState> aReturn(aPropertyName.getLength());
1447 ::com::sun::star::beans::PropertyState* pStates = aReturn.getArray();
1448 for (sal_uInt16 i=0; i<aPropertyName.getLength(); ++i, ++pStates)
1449 *pStates = ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1450 return aReturn;
1453 // -------------------------------------------------------------------------
1454 void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
1456 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1457 if (xState.is())
1458 xState->setPropertyToDefault(PropertyName);
1461 // -------------------------------------------------------------------------
1462 Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const ::rtl::OUString& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1464 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1465 if (xState.is())
1466 return xState->getPropertyDefault(aPropertyName);
1467 return Any();
1470 // ::com::sun::star::form::XReset
1471 // -------------------------------------------------------------------------
1472 void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException )
1474 Reference< ::com::sun::star::form::XReset > xReset(m_xMainForm, UNO_QUERY);
1475 if (xReset.is())
1476 xReset->reset();
1479 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm)
1481 // ::com::sun::star::container::XNameContainer
1482 // -------------------------------------------------------------------------
1483 void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const ::rtl::OUString* pNewElName) throw( ::com::sun::star::lang::IllegalArgumentException )
1485 // extract the form component
1486 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1488 throw ::com::sun::star::lang::IllegalArgumentException();
1491 Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)aElement.getValue(), UNO_QUERY);
1492 if (!xElement.is())
1494 throw ::com::sun::star::lang::IllegalArgumentException();
1497 // for the name we need the propset
1498 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1499 if (!xElementSet.is())
1501 throw ::com::sun::star::lang::IllegalArgumentException();
1503 ::rtl::OUString sName;
1506 if (pNewElName)
1507 xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName));
1509 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1511 catch(Exception&)
1513 // the set didn't support the name prop
1514 throw ::com::sun::star::lang::IllegalArgumentException();
1517 // check the index
1518 OSL_ASSERT(nIndex >= 0);
1519 if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
1520 nIndex = m_aChildren.size();
1522 DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1523 m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
1524 m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
1526 // listen for a changes of the name
1527 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1529 // we are now the parent of the new element
1530 xElement->setParent((::com::sun::star::container::XContainer*)this);
1532 // notify the container listeners
1533 ::com::sun::star::container::ContainerEvent aEvt;
1534 aEvt.Source = *this;
1535 aEvt.Accessor <<= nIndex;
1536 aEvt.Element <<= xElement;
1537 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1538 while (aIt.hasMoreElements())
1539 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementInserted(aEvt);
1542 // -------------------------------------------------------------------------
1543 sal_Int32 SbaXFormAdapter::implGetPos(const ::rtl::OUString& rName)
1545 ::std::vector< ::rtl::OUString>::iterator aIter = ::std::find_if( m_aChildNames.begin(),
1546 m_aChildNames.end(),
1547 ::std::bind2nd(::std::equal_to< rtl::OUString>(),rName));
1549 if(aIter != m_aChildNames.end())
1550 return aIter - m_aChildNames.begin();
1552 return -1;
1555 // -------------------------------------------------------------------------
1556 void SAL_CALL SbaXFormAdapter::insertByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1558 implInsert(aElement, m_aChildren.size(), &aName);
1561 // -------------------------------------------------------------------------
1562 void SAL_CALL SbaXFormAdapter::removeByName(const ::rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1564 sal_Int32 nPos = implGetPos(Name);
1565 if (-1 == nPos)
1567 throw ::com::sun::star::container::NoSuchElementException();
1569 removeByIndex(nPos);
1572 // ::com::sun::star::container::XNameReplace
1573 // -------------------------------------------------------------------------
1574 void SAL_CALL SbaXFormAdapter::replaceByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1576 sal_Int32 nPos = implGetPos(aName);
1577 if (-1 == nPos)
1579 throw ::com::sun::star::container::NoSuchElementException();
1581 replaceByIndex(nPos, aElement);
1584 // ::com::sun::star::container::XNameAccess
1585 // -------------------------------------------------------------------------
1586 Any SAL_CALL SbaXFormAdapter::getByName(const ::rtl::OUString& aName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1588 sal_Int32 nPos = implGetPos(aName);
1589 if (-1 == nPos)
1591 throw ::com::sun::star::container::NoSuchElementException();
1593 return makeAny(m_aChildren[nPos]);
1596 // -------------------------------------------------------------------------
1597 Sequence< ::rtl::OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException )
1599 ::rtl::OUString *pChildNames = m_aChildNames.empty() ? 0 : &m_aChildNames[0];
1600 return Sequence< ::rtl::OUString >(pChildNames, m_aChildNames.size());
1603 // -------------------------------------------------------------------------
1604 sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const ::rtl::OUString& aName) throw( RuntimeException )
1606 return (-1 != implGetPos(aName));
1609 // ::com::sun::star::container::XElementAccess
1610 // -------------------------------------------------------------------------
1611 Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException)
1613 return ::getCppuType(
1614 static_cast< Reference< ::com::sun::star::form::XFormComponent >* >(NULL));
1617 // -------------------------------------------------------------------------
1618 sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException)
1620 return m_aChildren.size() > 0;
1624 // ::com::sun::star::container::XIndexContainer
1625 // -------------------------------------------------------------------------
1626 void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1628 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1629 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1630 implInsert(Element, _rIndex);
1633 // -------------------------------------------------------------------------
1634 void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1636 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1637 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1639 Reference< ::com::sun::star::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
1641 DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1642 m_aChildren.erase(m_aChildren.begin() + _rIndex);
1643 m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
1645 // no need to listen anymore
1646 Reference< ::com::sun::star::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
1647 xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1649 // we are no longer the parent
1650 xAffected->setParent(Reference< XInterface > ());
1652 // notify container listeners
1653 ::com::sun::star::container::ContainerEvent aEvt;
1654 aEvt.Source = *this;
1655 aEvt.Element <<= xAffected;
1656 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1657 while (aIt.hasMoreElements())
1658 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementRemoved(aEvt);
1662 // ::com::sun::star::container::XIndexReplace
1663 // -------------------------------------------------------------------------
1664 void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1666 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1667 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1669 // extract the form component
1670 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1672 throw ::com::sun::star::lang::IllegalArgumentException();
1675 Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)Element.getValue(), UNO_QUERY);
1676 if (!xElement.is())
1678 throw ::com::sun::star::lang::IllegalArgumentException();
1681 // for the name we need the propset
1682 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1683 if (!xElementSet.is())
1685 throw ::com::sun::star::lang::IllegalArgumentException();
1687 ::rtl::OUString sName;
1690 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1692 catch(Exception&)
1694 // the set didn't support the name prop
1695 throw ::com::sun::star::lang::IllegalArgumentException();
1698 Reference< ::com::sun::star::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
1700 DBG_ASSERT(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1701 *(m_aChildren.begin() + _rIndex) = xElement;
1702 *(m_aChildNames.begin() + _rIndex) = sName;
1704 // correct property change listening
1705 Reference< ::com::sun::star::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
1706 xOldSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1707 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1709 // parent reset
1710 xOld->setParent(Reference< XInterface > ());
1711 xElement->setParent((::com::sun::star::container::XContainer*)this);
1713 // notify container listeners
1714 ::com::sun::star::container::ContainerEvent aEvt;
1715 aEvt.Source = *this;
1716 aEvt.Accessor <<= (sal_Int32)_rIndex;
1717 aEvt.Element <<= xElement;
1718 aEvt.ReplacedElement <<= xOld;
1720 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1721 while (aIt.hasMoreElements())
1722 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementReplaced(aEvt);
1725 // ::com::sun::star::container::XIndexAccess
1726 // -------------------------------------------------------------------------
1727 sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException )
1729 return m_aChildren.size();
1732 // -------------------------------------------------------------------------
1733 Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1735 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1736 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1738 Reference< ::com::sun::star::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
1739 return makeAny(xElement);
1742 // ::com::sun::star::container::XContainer
1743 // -------------------------------------------------------------------------
1744 void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
1746 m_aContainerListeners.addInterface(xListener);
1749 // -------------------------------------------------------------------------
1750 void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
1752 m_aContainerListeners.removeInterface(xListener);
1755 // ::com::sun::star::container::XEnumerationAccess
1756 // -------------------------------------------------------------------------
1757 Reference< ::com::sun::star::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException )
1759 return new ::comphelper::OEnumerationByName(this);
1762 // ::com::sun::star::beans::XPropertyChangeListener
1763 // -------------------------------------------------------------------------
1764 void SAL_CALL SbaXFormAdapter::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( RuntimeException )
1766 if (evt.PropertyName.equals(PROPERTY_NAME))
1768 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1769 m_aChildren.end(),
1770 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),evt.Source));
1772 if(aIter != m_aChildren.end())
1774 sal_Int32 nPos = aIter - m_aChildren.begin();
1775 DBG_ASSERT(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1776 *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
1781 // ::com::sun::star::lang::XEventListener
1782 // -------------------------------------------------------------------------
1783 void SAL_CALL SbaXFormAdapter::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException )
1785 // was it our main form ?
1786 if (Source.Source == m_xMainForm)
1787 dispose();
1789 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1790 m_aChildren.end(),
1791 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),Source.Source));
1792 if(aIter != m_aChildren.end())
1793 removeByIndex(aIter - m_aChildren.begin());
1795 // -----------------------------------------------------------------------------