Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / browser / formadapter.cxx
blob3fa5d94a586b5f940eda0920dd72c13eb73efc28
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "formadapter.hxx"
31 #include <tools/debug.hxx>
32 #include <osl/diagnose.h>
33 #include <comphelper/types.hxx>
34 #include <comphelper/enumhelper.hxx>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include "dbu_brw.hrc"
37 #include "dbustrings.hrc"
38 #include <cppuhelper/typeprovider.hxx>
39 #include <comphelper/sequence.hxx>
41 using namespace dbaui;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::sdb;
44 using namespace ::com::sun::star::sdbcx;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::container;
48 //==================================================================
49 // SbaXFormAdapter
50 //==================================================================
52 DBG_NAME(SbaXFormAdapter)
53 // -------------------------------------------------------------------------
54 SbaXFormAdapter::SbaXFormAdapter()
55 :m_aLoadListeners(*this, m_aMutex)
56 ,m_aRowSetListeners(*this, m_aMutex)
57 ,m_aRowSetApproveListeners(*this, m_aMutex)
58 ,m_aErrorListeners(*this, m_aMutex)
59 ,m_aParameterListeners(*this, m_aMutex)
60 ,m_aSubmitListeners(*this, m_aMutex)
61 ,m_aResetListeners(*this, m_aMutex)
62 ,m_aPropertyChangeListeners(*this, m_aMutex)
63 ,m_aVetoablePropertyChangeListeners(*this, m_aMutex)
64 ,m_aPropertiesChangeListeners(*this, m_aMutex)
65 ,m_aDisposeListeners(m_aMutex)
66 ,m_aContainerListeners(m_aMutex)
67 ,m_nNamePropHandle(-1)
69 DBG_CTOR(SbaXFormAdapter,NULL);
73 // -------------------------------------------------------------------------
74 SbaXFormAdapter::~SbaXFormAdapter()
77 DBG_DTOR(SbaXFormAdapter,NULL);
80 // -------------------------------------------------------------------------
81 Sequence< Type > SAL_CALL SbaXFormAdapter::getTypes( ) throw (RuntimeException)
83 return ::comphelper::concatSequences(
84 SbaXFormAdapter_BASE1::getTypes(),
85 SbaXFormAdapter_BASE2::getTypes(),
86 SbaXFormAdapter_BASE3::getTypes()
90 // -------------------------------------------------------------------------
91 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getImplementationId( ) throw (RuntimeException)
93 static ::cppu::OImplementationId * pId = 0;
94 if (! pId)
96 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
97 if (! pId)
99 static ::cppu::OImplementationId aId;
100 pId = &aId;
103 return pId->getImplementationId();
106 // -------------------------------------------------------------------------
107 Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) throw (RuntimeException)
109 Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
111 if (!aReturn.hasValue())
112 aReturn = SbaXFormAdapter_BASE2::queryInterface( _rType );
114 if (!aReturn.hasValue())
115 aReturn = SbaXFormAdapter_BASE3::queryInterface( _rType );
117 return aReturn;
120 // -------------------------------------------------------------------------
121 void SbaXFormAdapter::StopListening()
123 // log off all our multiplexers
124 STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
125 STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
126 STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
127 STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
128 STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
129 STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
131 if (m_aParameterListeners.getLength())
133 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
134 if (xBroadcaster.is())
135 xBroadcaster->removeParameterListener(&m_aParameterListeners);
138 STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
139 STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
140 if (m_aPropertiesChangeListeners.getLength())
142 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
143 if (xBroadcaster.is())
144 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
147 // log off ourself
148 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
149 if (xComp.is())
150 xComp->removeEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
153 // -------------------------------------------------------------------------
154 void SbaXFormAdapter::StartListening()
156 // log off all our multiplexers
157 START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
158 START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
159 START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
160 START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
161 START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
162 START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
164 if (m_aParameterListeners.getLength())
166 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
167 if (xBroadcaster.is())
168 xBroadcaster->addParameterListener(&m_aParameterListeners);
171 START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
172 START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
173 if (m_aPropertiesChangeListeners.getLength())
175 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
176 ::rtl::OUString sEmpty;
177 if (xBroadcaster.is())
178 xBroadcaster->addPropertiesChangeListener(::comphelper::StringSequence(&sEmpty, 1), &m_aPropertiesChangeListeners);
181 // log off ourself
182 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
183 if (xComp.is())
184 xComp->addEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
187 // -------------------------------------------------------------------------
188 void SbaXFormAdapter::AttachForm(const Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster)
190 if (xNewMaster == m_xMainForm)
191 return;
193 OSL_ENSURE(xNewMaster.get() != static_cast< ::com::sun::star::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
195 if (m_xMainForm.is())
197 StopListening();
199 // if our old master is loaded we have to send an 'unloaded' event
200 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
201 if (xLoadable->isLoaded())
203 ::com::sun::star::lang::EventObject aEvt(*this);
204 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
205 while (aIt.hasMoreElements())
206 ((::com::sun::star::form::XLoadListener*)aIt.next())->unloaded(aEvt);
210 m_xMainForm = xNewMaster;
212 if (m_xMainForm.is())
214 StartListening();
216 // if our new master is loaded we have to send an 'loaded' event
217 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
218 if (xLoadable->isLoaded())
220 ::com::sun::star::lang::EventObject aEvt(*this);
221 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
222 while (aIt.hasMoreElements())
223 ((::com::sun::star::form::XLoadListener*)aIt.next())->loaded(aEvt);
227 // TODO : perhaps _all_ of our listeners should be notified about our new state
228 // (nearly every aspect of us may have changed with new master form)
231 // ::com::sun::star::sdbc::XCloseable
232 // -------------------------------------------------------------------------
233 void SAL_CALL SbaXFormAdapter::close() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
235 Reference< ::com::sun::star::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
236 if (xIface.is())
237 xIface->close();
240 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
241 // -------------------------------------------------------------------------
242 Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
244 Reference< ::com::sun::star::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
245 if (xIface.is())
246 return xIface->getMetaData();
247 return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ();
250 // ::com::sun::star::sdbc::XColumnLocate
251 // -------------------------------------------------------------------------
252 sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const ::rtl::OUString& columnName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
254 Reference< ::com::sun::star::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
255 if (xIface.is())
256 return xIface->findColumn(columnName);
257 return 0;
260 // ::com::sun::star::sdbcx::XColumnsSupplier
261 // -------------------------------------------------------------------------
262 Reference< ::com::sun::star::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException )
264 Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
265 if (xIface.is())
266 return xIface->getColumns();
267 return Reference< ::com::sun::star::container::XNameAccess > ();
270 // ::com::sun::star::sdbc::XRow
271 // -------------------------------------------------------------------------
272 sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
274 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
275 if (xIface.is())
276 return xIface->wasNull();
277 return sal_True;
279 // -------------------------------------------------------------------------
280 ::rtl::OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
282 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
283 if (xIface.is())
284 return xIface->getString(columnIndex);
285 return ::rtl::OUString();
287 // -------------------------------------------------------------------------
288 sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
290 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
291 if (xIface.is())
292 return xIface->getBoolean(columnIndex);
293 return sal_False;
295 // -------------------------------------------------------------------------
296 sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) 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->getByte(columnIndex);
301 return 0;
303 // -------------------------------------------------------------------------
304 sal_Int16 SAL_CALL SbaXFormAdapter::getShort(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->getShort(columnIndex);
309 return 0;
311 // -------------------------------------------------------------------------
312 sal_Int32 SAL_CALL SbaXFormAdapter::getInt(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->getInt(columnIndex);
317 return 0;
319 // -------------------------------------------------------------------------
320 sal_Int64 SAL_CALL SbaXFormAdapter::getLong(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->getLong(columnIndex);
325 return 0;
327 // -------------------------------------------------------------------------
328 float SAL_CALL SbaXFormAdapter::getFloat(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->getFloat(columnIndex);
333 return 0.0;
335 // -------------------------------------------------------------------------
336 double SAL_CALL SbaXFormAdapter::getDouble(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->getDouble(columnIndex);
341 return 0.0;
343 // -------------------------------------------------------------------------
344 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(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->getBytes(columnIndex);
349 return Sequence <sal_Int8> ();
351 // -------------------------------------------------------------------------
352 ::com::sun::star::util::Date SAL_CALL SbaXFormAdapter::getDate(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->getDate(columnIndex);
357 return ::com::sun::star::util::Date();
359 // -------------------------------------------------------------------------
360 ::com::sun::star::util::Time SAL_CALL SbaXFormAdapter::getTime(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->getTime(columnIndex);
365 return ::com::sun::star::util::Time();
367 // -------------------------------------------------------------------------
368 ::com::sun::star::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(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->getTimestamp(columnIndex);
373 return ::com::sun::star::util::DateTime();
375 // -------------------------------------------------------------------------
376 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(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->getBinaryStream(columnIndex);
381 return Reference< ::com::sun::star::io::XInputStream > ();
383 // -------------------------------------------------------------------------
384 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(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->getCharacterStream(columnIndex);
389 return Reference< ::com::sun::star::io::XInputStream > ();
391 // -------------------------------------------------------------------------
392 Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap) 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->getObject(columnIndex, typeMap);
397 return Any();
399 // -------------------------------------------------------------------------
400 Reference< ::com::sun::star::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(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->getRef(columnIndex);
405 return Reference< ::com::sun::star::sdbc::XRef > ();
407 // -------------------------------------------------------------------------
408 Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(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->getBlob(columnIndex);
413 return Reference< ::com::sun::star::sdbc::XBlob > ();
415 // -------------------------------------------------------------------------
416 Reference< ::com::sun::star::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) 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->getClob(columnIndex);
421 return Reference< ::com::sun::star::sdbc::XClob > ();
423 // -------------------------------------------------------------------------
424 Reference< ::com::sun::star::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(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->getArray(columnIndex);
429 return Reference< ::com::sun::star::sdbc::XArray > ();
432 // ::com::sun::star::sdbcx::XRowLocate
433 // -------------------------------------------------------------------------
434 Any SAL_CALL SbaXFormAdapter::getBookmark() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
436 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
437 if (xIface.is())
438 return xIface->getBookmark();
439 return Any();
441 // -------------------------------------------------------------------------
442 sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
444 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
445 if (xIface.is())
446 return xIface->moveToBookmark(bookmark);
447 return sal_False;
449 // -------------------------------------------------------------------------
450 sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
452 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
453 if (xIface.is())
454 return xIface->moveRelativeToBookmark(bookmark,rows);
455 return sal_False;
457 // -------------------------------------------------------------------------
458 sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second) 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->compareBookmarks(_first, _second);
463 return 0;
466 // -------------------------------------------------------------------------
467 sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
469 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
470 if (xIface.is())
471 return xIface->hasOrderedBookmarks();
472 return sal_False;
475 // -------------------------------------------------------------------------
476 sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
478 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
479 if (xIface.is())
480 return xIface->hashBookmark(bookmark);
481 return 0;
484 // ::com::sun::star::sdbc::XRowUpdate
485 // -------------------------------------------------------------------------
486 void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
488 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
489 if (xIface.is())
490 xIface->updateNull(columnIndex);
492 // -------------------------------------------------------------------------
493 void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
495 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
496 if (xIface.is())
497 xIface->updateBoolean(columnIndex, x);
499 // -------------------------------------------------------------------------
500 void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
502 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
503 if (xIface.is())
504 xIface->updateByte(columnIndex, x);
506 // -------------------------------------------------------------------------
507 void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
509 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
510 if (xIface.is())
511 xIface->updateShort(columnIndex, x);
513 // -------------------------------------------------------------------------
514 void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
516 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
517 if (xIface.is())
518 xIface->updateInt(columnIndex, x);
520 // -------------------------------------------------------------------------
521 void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
523 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
524 if (xIface.is())
525 xIface->updateLong(columnIndex, x);
527 // -------------------------------------------------------------------------
528 void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
530 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
531 if (xIface.is())
532 xIface->updateFloat(columnIndex, x);
534 // -------------------------------------------------------------------------
535 void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
537 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
538 if (xIface.is())
539 xIface->updateDouble(columnIndex, x);
541 // -------------------------------------------------------------------------
542 void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
544 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
545 if (xIface.is())
546 xIface->updateString(columnIndex, x);
548 // -------------------------------------------------------------------------
549 void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
551 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
552 if (xIface.is())
553 xIface->updateBytes(columnIndex, x);
555 // -------------------------------------------------------------------------
556 void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
558 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
559 if (xIface.is())
560 xIface->updateDate(columnIndex, x);
562 // -------------------------------------------------------------------------
563 void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
565 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
566 if (xIface.is())
567 xIface->updateTime(columnIndex, x);
569 // -------------------------------------------------------------------------
570 void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
572 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
573 if (xIface.is())
574 xIface->updateTimestamp(columnIndex, x);
576 // -------------------------------------------------------------------------
577 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 )
579 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
580 if (xIface.is())
581 xIface->updateBinaryStream(columnIndex, x, length);
583 // -------------------------------------------------------------------------
584 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 )
586 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
587 if (xIface.is())
588 xIface->updateCharacterStream(columnIndex, x, length);
590 // -------------------------------------------------------------------------
591 void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
593 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
594 if (xIface.is())
595 xIface->updateObject(columnIndex, x);
597 // -------------------------------------------------------------------------
598 void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
600 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
601 if (xIface.is())
602 xIface->updateNumericObject(columnIndex, x, scale);
605 // ::com::sun::star::sdbc::XResultSet
606 // -------------------------------------------------------------------------
607 sal_Bool SAL_CALL SbaXFormAdapter::next() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
609 if (m_xMainForm.is())
610 return m_xMainForm->next();
611 return sal_False;
613 // -------------------------------------------------------------------------
614 sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
616 if (m_xMainForm.is())
617 return m_xMainForm->isBeforeFirst();
618 return sal_False;
620 // -------------------------------------------------------------------------
621 sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
623 if (m_xMainForm.is())
624 return m_xMainForm->isAfterLast();
625 return sal_False;
627 // -------------------------------------------------------------------------
628 sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
630 if (m_xMainForm.is())
631 return m_xMainForm->isFirst();
632 return sal_False;
634 // -------------------------------------------------------------------------
635 sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
637 if (m_xMainForm.is())
638 return m_xMainForm->isLast();
639 return sal_False;
641 // -------------------------------------------------------------------------
642 void SAL_CALL SbaXFormAdapter::beforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
644 if (m_xMainForm.is())
645 m_xMainForm->beforeFirst();
647 // -------------------------------------------------------------------------
648 void SAL_CALL SbaXFormAdapter::afterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
650 if (m_xMainForm.is())
651 m_xMainForm->afterLast();
653 // -------------------------------------------------------------------------
654 sal_Bool SAL_CALL SbaXFormAdapter::first() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
656 if (m_xMainForm.is())
657 return m_xMainForm->first();
658 return sal_False;
660 // -------------------------------------------------------------------------
661 sal_Bool SAL_CALL SbaXFormAdapter::last() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
663 if (m_xMainForm.is())
664 return m_xMainForm->last();
665 return sal_False;
667 // -------------------------------------------------------------------------
668 sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
670 if (m_xMainForm.is())
671 return m_xMainForm->getRow();
672 return sal_False;
674 // -------------------------------------------------------------------------
675 sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
677 if (m_xMainForm.is())
678 return m_xMainForm->absolute(row);
679 return sal_False;
681 // -------------------------------------------------------------------------
682 sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
684 if (m_xMainForm.is())
685 return m_xMainForm->relative(rows);
686 return sal_False;
688 // -------------------------------------------------------------------------
689 sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
691 if (m_xMainForm.is())
692 return m_xMainForm->previous();
693 return sal_False;
695 // -------------------------------------------------------------------------
696 void SAL_CALL SbaXFormAdapter::refreshRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
698 if (m_xMainForm.is())
699 m_xMainForm->refreshRow();
702 // -------------------------------------------------------------------------
703 sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
705 if (m_xMainForm.is())
706 return m_xMainForm->rowUpdated();
707 return sal_False;
709 // -------------------------------------------------------------------------
710 sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
712 if (m_xMainForm.is())
713 return m_xMainForm->rowInserted();
714 return sal_False;
716 // -------------------------------------------------------------------------
717 sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
719 if (m_xMainForm.is())
720 return m_xMainForm->rowDeleted();
721 return sal_False;
723 // -------------------------------------------------------------------------
724 Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
726 if (m_xMainForm.is())
727 return m_xMainForm->getStatement();
728 return NULL;
731 // ::com::sun::star::sdbc::XResultSetUpdate
732 // -------------------------------------------------------------------------
733 void SAL_CALL SbaXFormAdapter::insertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
735 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
736 if (xIface.is())
737 xIface->insertRow();
739 // -------------------------------------------------------------------------
740 void SAL_CALL SbaXFormAdapter::updateRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
742 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
743 if (xIface.is())
744 xIface->updateRow();
746 // -------------------------------------------------------------------------
747 void SAL_CALL SbaXFormAdapter::deleteRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
749 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
750 if (xIface.is())
751 xIface->deleteRow();
753 // -------------------------------------------------------------------------
754 void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
756 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
757 if (xIface.is())
758 xIface->cancelRowUpdates();
760 // -------------------------------------------------------------------------
761 void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
763 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
764 if (xIface.is())
765 xIface->moveToInsertRow();
767 // -------------------------------------------------------------------------
768 void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
770 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
771 if (xIface.is())
772 xIface->moveToCurrentRow();
775 // ::com::sun::star::sdbc::XRowSet
776 // -------------------------------------------------------------------------
777 void SAL_CALL SbaXFormAdapter::execute() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
779 if (m_xMainForm.is())
780 m_xMainForm->execute();
782 // -------------------------------------------------------------------------
783 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm)
785 // ::com::sun::star::sdbcx::XDeleteRows
786 // -------------------------------------------------------------------------
787 Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
789 Reference< ::com::sun::star::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
790 if (xIface.is())
791 return xIface->deleteRows(rows);
792 return Sequence<sal_Int32>();
795 // ::com::sun::star::sdbc::XWarningsSupplier
796 // -------------------------------------------------------------------------
797 Any SAL_CALL SbaXFormAdapter::getWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
799 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
800 if (xIface.is())
801 return xIface->getWarnings();
802 return Any();
804 // -------------------------------------------------------------------------
805 void SAL_CALL SbaXFormAdapter::clearWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
807 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
808 if (xIface.is())
809 xIface->clearWarnings();
812 // ::com::sun::star::sdb::XRowSetApproveBroadcaster
813 // -------------------------------------------------------------------------
814 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm)
816 // com::sun::star::sdbc::XSQLErrorBroadcaster
817 // -------------------------------------------------------------------------
818 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm)
820 // ::com::sun::star::sdb::XResultSetAccess
821 // -------------------------------------------------------------------------
822 Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
824 Reference< ::com::sun::star::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
825 if (xIface.is())
826 return xIface->createResultSet();
827 return Reference< ::com::sun::star::sdbc::XResultSet > ();
830 // com::sun::star::form::XLoadable
831 // -------------------------------------------------------------------------
832 void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException )
834 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
835 if (xIface.is())
836 xIface->load();
838 // -------------------------------------------------------------------------
839 void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException )
841 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
842 if (xIface.is())
843 xIface->unload();
845 // -------------------------------------------------------------------------
846 void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException )
848 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
849 if (xIface.is())
850 xIface->reload();
852 // -------------------------------------------------------------------------
853 sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException )
855 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
856 if (xIface.is())
857 return xIface->isLoaded();
858 return sal_False;
860 // -------------------------------------------------------------------------
861 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm)
863 // ::com::sun::star::sdbc::XParameters
864 // -------------------------------------------------------------------------
865 void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
867 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
868 if (xIface.is())
869 xIface->setNull(parameterIndex, sqlType);
871 // -------------------------------------------------------------------------
872 void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
874 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
875 if (xIface.is())
876 xIface->setObjectNull(parameterIndex, sqlType, typeName);
878 // -------------------------------------------------------------------------
879 void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
881 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
882 if (xIface.is())
883 xIface->setBoolean(parameterIndex, x);
885 // -------------------------------------------------------------------------
886 void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
888 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
889 if (xIface.is())
890 xIface->setByte(parameterIndex, x);
892 // -------------------------------------------------------------------------
893 void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
895 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
896 if (xIface.is())
897 xIface->setShort(parameterIndex, x);
899 // -------------------------------------------------------------------------
900 void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
902 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
903 if (xIface.is())
904 xIface->setInt(parameterIndex, x);
906 // -------------------------------------------------------------------------
907 void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
909 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
910 if (xIface.is())
911 xIface->setLong(parameterIndex, x);
913 // -------------------------------------------------------------------------
914 void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
916 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
917 if (xIface.is())
918 xIface->setFloat(parameterIndex, x);
920 // -------------------------------------------------------------------------
921 void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
923 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
924 if (xIface.is())
925 xIface->setDouble(parameterIndex, x);
927 // -------------------------------------------------------------------------
928 void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
930 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
931 if (xIface.is())
932 xIface->setString(parameterIndex, x);
934 // -------------------------------------------------------------------------
935 void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
937 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
938 if (xIface.is())
939 xIface->setBytes(parameterIndex, x);
941 // -------------------------------------------------------------------------
942 void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
944 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
945 if (xIface.is())
946 xIface->setDate(parameterIndex, x);
948 // -------------------------------------------------------------------------
949 void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
951 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
952 if (xIface.is())
953 xIface->setTime(parameterIndex, x);
955 // -------------------------------------------------------------------------
956 void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
958 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
959 if (xIface.is())
960 xIface->setTimestamp(parameterIndex, x);
962 // -------------------------------------------------------------------------
963 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 )
965 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
966 if (xIface.is())
967 xIface->setBinaryStream(parameterIndex, x, length);
969 // -------------------------------------------------------------------------
970 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 )
972 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
973 if (xIface.is())
974 xIface->setCharacterStream(parameterIndex, x, length);
976 // -------------------------------------------------------------------------
977 void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
979 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
980 if (xIface.is())
981 xIface->setObject(parameterIndex, x);
983 // -------------------------------------------------------------------------
984 void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
986 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
987 if (xIface.is())
988 xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
990 // -------------------------------------------------------------------------
991 void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XRef >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
993 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
994 if (xIface.is())
995 xIface->setRef(parameterIndex, x);
997 // -------------------------------------------------------------------------
998 void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XBlob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1000 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1001 if (xIface.is())
1002 xIface->setBlob(parameterIndex, x);
1004 // -------------------------------------------------------------------------
1005 void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XClob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1007 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1008 if (xIface.is())
1009 xIface->setClob(parameterIndex, x);
1011 // -------------------------------------------------------------------------
1012 void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XArray >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1014 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1015 if (xIface.is())
1016 xIface->setArray(parameterIndex, x);
1018 // -------------------------------------------------------------------------
1019 void SAL_CALL SbaXFormAdapter::clearParameters() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
1021 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1022 if (xIface.is())
1023 xIface->clearParameters();
1026 // ::com::sun::star::form::XDatabaseParameterBroadcaster
1027 // -------------------------------------------------------------------------
1028 void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
1030 m_aParameterListeners.addInterface(aListener);
1031 if (m_aParameterListeners.getLength() == 1)
1033 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1034 if (xBroadcaster.is())
1035 xBroadcaster->addParameterListener(&m_aParameterListeners);
1039 // -------------------------------------------------------------------------
1040 void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
1042 if (m_aParameterListeners.getLength() == 1)
1044 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1045 if (xBroadcaster.is())
1046 xBroadcaster->removeParameterListener(&m_aParameterListeners);
1048 m_aParameterListeners.removeInterface(aListener);
1051 // ::com::sun::star::container::XChild
1052 // -------------------------------------------------------------------------
1053 Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException )
1055 return m_xParent;
1058 // -------------------------------------------------------------------------
1059 void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( ::com::sun::star::lang::NoSupportException, RuntimeException )
1061 m_xParent = Parent;
1064 // ::com::sun::star::form::XSubmit
1065 // -------------------------------------------------------------------------
1066 void SAL_CALL SbaXFormAdapter::submit(const Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw( RuntimeException )
1068 Reference< ::com::sun::star::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
1069 if (xSubmit.is())
1070 xSubmit->submit(aControl, aMouseEvt);
1073 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm)
1075 // ::com::sun::star::awt::XTabControllerModel
1076 // -------------------------------------------------------------------------
1077 sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException )
1079 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1080 return sal_False;
1083 // -------------------------------------------------------------------------
1084 void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException )
1086 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1089 // -------------------------------------------------------------------------
1090 void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*Controls*/) throw( RuntimeException )
1092 OSL_FAIL("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1095 // -------------------------------------------------------------------------
1096 Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException )
1098 OSL_FAIL("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1099 return Sequence< Reference< ::com::sun::star::awt::XControlModel > >();
1102 // -------------------------------------------------------------------------
1103 void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, const ::rtl::OUString& /*GroupName*/) throw( RuntimeException )
1105 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1108 // -------------------------------------------------------------------------
1109 sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException )
1111 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1112 return 0;
1115 // -------------------------------------------------------------------------
1116 void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, ::rtl::OUString& /*Name*/) throw( RuntimeException )
1118 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1121 // -------------------------------------------------------------------------
1122 void SAL_CALL SbaXFormAdapter::getGroupByName(const ::rtl::OUString& /*Name*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/) throw( RuntimeException )
1124 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1127 // ::com::sun::star::lang::XComponent
1128 // -------------------------------------------------------------------------
1129 void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException )
1131 // log off all multiplexers
1132 if (m_xMainForm.is())
1133 StopListening();
1135 ::com::sun::star::lang::EventObject aEvt(*this);
1136 m_aLoadListeners.disposeAndClear(aEvt);
1137 m_aRowSetListeners.disposeAndClear(aEvt);
1138 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1139 m_aErrorListeners.disposeAndClear(aEvt);
1140 m_aParameterListeners.disposeAndClear(aEvt);
1141 m_aSubmitListeners.disposeAndClear(aEvt);
1142 m_aResetListeners.disposeAndClear(aEvt);
1144 m_aVetoablePropertyChangeListeners.disposeAndClear();
1145 m_aPropertyChangeListeners.disposeAndClear();
1146 m_aPropertiesChangeListeners.disposeAndClear(aEvt);
1148 m_aDisposeListeners.disposeAndClear(aEvt);
1149 m_aContainerListeners.disposeAndClear(aEvt);
1151 // dispose all children
1152 for ( ::std::vector< Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = m_aChildren.begin();
1153 aIter != m_aChildren.end();
1154 ++aIter
1157 Reference< ::com::sun::star::beans::XPropertySet > xSet(*aIter, UNO_QUERY);
1158 if (xSet.is())
1159 xSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1161 Reference< ::com::sun::star::container::XChild > xChild(*aIter, UNO_QUERY);
1162 if (xChild.is())
1163 xChild->setParent(Reference< XInterface > ());
1165 Reference< ::com::sun::star::lang::XComponent > xComp(*aIter, UNO_QUERY);
1166 if (xComp.is())
1167 xComp->dispose();
1169 m_aChildren.clear();
1172 // -------------------------------------------------------------------------
1173 void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< ::com::sun::star::lang::XEventListener >& xListener) throw( RuntimeException )
1175 m_aDisposeListeners.addInterface(xListener);
1178 // -------------------------------------------------------------------------
1179 void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener >& aListener) throw( RuntimeException )
1181 m_aDisposeListeners.removeInterface(aListener);
1184 // ::com::sun::star::beans::XFastPropertySet
1185 // -------------------------------------------------------------------------
1186 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 )
1188 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1189 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1191 if (m_nNamePropHandle == nHandle)
1193 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1195 throw ::com::sun::star::lang::IllegalArgumentException();
1198 // for notifying property listeners
1199 ::com::sun::star::beans::PropertyChangeEvent aEvt;
1200 aEvt.Source = *this;
1201 aEvt.PropertyName = PROPERTY_NAME;
1202 aEvt.PropertyHandle = m_nNamePropHandle;
1203 aEvt.OldValue <<= m_sName;
1204 aEvt.NewValue = aValue;
1206 aValue >>= m_sName;
1208 ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME));
1209 while (aIt.hasMoreElements())
1210 ((::com::sun::star::beans::XPropertyChangeListener*)aIt.next())->propertyChange(aEvt);
1212 return;
1215 xSet->setFastPropertyValue(nHandle, aValue);
1218 // -------------------------------------------------------------------------
1219 Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1221 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1222 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1224 if (m_nNamePropHandle == nHandle)
1225 return makeAny(m_sName);
1227 return xSet->getFastPropertyValue(nHandle);
1230 // ::com::sun::star::container::XNamed
1231 // -------------------------------------------------------------------------
1232 ::rtl::OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException )
1234 return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
1237 // -------------------------------------------------------------------------
1238 void SAL_CALL SbaXFormAdapter::setName(const ::rtl::OUString& aName) throw( RuntimeException )
1240 setPropertyValue(PROPERTY_NAME, makeAny(aName));
1243 // ::com::sun::star::io::XPersistObject
1244 // -------------------------------------------------------------------------
1245 ::rtl::OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException )
1247 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1248 if (xPersist.is())
1249 return xPersist->getServiceName();
1250 return ::rtl::OUString();
1253 // -------------------------------------------------------------------------
1254 void SAL_CALL SbaXFormAdapter::write(const Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw( ::com::sun::star::io::IOException, RuntimeException )
1256 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1257 if (xPersist.is())
1258 xPersist->write(_rxOutStream);
1261 // -------------------------------------------------------------------------
1262 void SAL_CALL SbaXFormAdapter::read(const Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw( ::com::sun::star::io::IOException, RuntimeException )
1264 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1265 if (xPersist.is())
1266 xPersist->read(_rxInStream);
1269 // ::com::sun::star::beans::XMultiPropertySet
1270 // -------------------------------------------------------------------------
1271 Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException )
1273 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1274 if (!xSet.is())
1275 return Reference< ::com::sun::star::beans::XPropertySetInfo > ();
1277 Reference< ::com::sun::star::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
1278 if (-1 == m_nNamePropHandle)
1280 // we need to determine the handle for the NAME property
1281 Sequence< ::com::sun::star::beans::Property> aProps = xReturn->getProperties();
1282 const ::com::sun::star::beans::Property* pProps = aProps.getConstArray();
1284 for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
1286 if (pProps->Name.equals(PROPERTY_NAME))
1288 ((SbaXFormAdapter*)this)->m_nNamePropHandle = pProps->Handle;
1289 break;
1293 return xReturn;
1296 // -------------------------------------------------------------------------
1297 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 )
1299 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1300 if (xSet.is())
1301 xSet->setPropertyValues(PropertyNames, Values);
1304 // -------------------------------------------------------------------------
1305 Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< ::rtl::OUString >& aPropertyNames) throw( RuntimeException )
1307 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1308 if (!xSet.is())
1309 return Sequence< Any>(aPropertyNames.getLength());
1311 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1313 // search for (and fake) the NAME property
1314 const ::rtl::OUString* pNames = aPropertyNames.getConstArray();
1315 Any* pValues = aReturn.getArray();
1316 OSL_ENSURE(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
1317 for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues)
1318 if (pNames->equals(PROPERTY_NAME))
1320 (*pValues) <<= m_sName;
1321 break;
1324 return aReturn;
1327 // -------------------------------------------------------------------------
1328 void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< ::rtl::OUString>& /*aPropertyNames*/, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
1330 // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
1331 m_aPropertiesChangeListeners.addInterface(xListener);
1332 if (m_aPropertiesChangeListeners.getLength() == 1)
1334 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1335 ::rtl::OUString sEmpty;
1336 if (xBroadcaster.is())
1337 xBroadcaster->addPropertiesChangeListener(Sequence< ::rtl::OUString>(&sEmpty, 1), &m_aPropertiesChangeListeners);
1341 // -------------------------------------------------------------------------
1342 void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException )
1344 if (m_aPropertiesChangeListeners.getLength() == 1)
1346 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1347 if (xBroadcaster.is())
1348 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
1350 m_aPropertiesChangeListeners.removeInterface(Listener);
1353 // -------------------------------------------------------------------------
1354 void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< ::rtl::OUString >& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
1356 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1357 if (xSet.is())
1358 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1362 // ::com::sun::star::beans::XPropertySet
1363 // -------------------------------------------------------------------------
1364 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 )
1366 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1367 if (!xSet.is())
1368 return;
1370 // special handling for the "name" property
1371 if (aPropertyName.equals(PROPERTY_NAME))
1372 setFastPropertyValue(m_nNamePropHandle, aValue);
1374 xSet->setPropertyValue(aPropertyName, aValue);
1377 // -------------------------------------------------------------------------
1378 Any SAL_CALL SbaXFormAdapter::getPropertyValue(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1380 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1381 if (!xSet.is())
1382 return Any();
1384 // special handling for the "name" property
1385 if (PropertyName.equals(PROPERTY_NAME))
1386 return getFastPropertyValue(m_nNamePropHandle);
1388 return xSet->getPropertyValue(PropertyName);
1391 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1392 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1394 // ::com::sun::star::util::XCancellable
1395 // -------------------------------------------------------------------------
1396 void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException )
1398 Reference< ::com::sun::star::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
1399 if (xCancel.is())
1400 return;
1401 xCancel->cancel();
1404 // ::com::sun::star::beans::XPropertyState
1405 // -------------------------------------------------------------------------
1406 ::com::sun::star::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
1408 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1409 if (xState.is())
1410 return xState->getPropertyState(PropertyName);
1411 return ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1414 // -------------------------------------------------------------------------
1415 Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< ::rtl::OUString >& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
1417 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1418 if (xState.is())
1419 return xState->getPropertyStates(aPropertyName);
1421 // set them all to DEFAULT
1422 Sequence< ::com::sun::star::beans::PropertyState> aReturn(aPropertyName.getLength());
1423 ::com::sun::star::beans::PropertyState* pStates = aReturn.getArray();
1424 for (sal_uInt16 i=0; i<aPropertyName.getLength(); ++i, ++pStates)
1425 *pStates = ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1426 return aReturn;
1429 // -------------------------------------------------------------------------
1430 void SAL_CALL SbaXFormAdapter::setPropertyToDefault(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 xState->setPropertyToDefault(PropertyName);
1437 // -------------------------------------------------------------------------
1438 Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const ::rtl::OUString& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1440 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1441 if (xState.is())
1442 return xState->getPropertyDefault(aPropertyName);
1443 return Any();
1446 // ::com::sun::star::form::XReset
1447 // -------------------------------------------------------------------------
1448 void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException )
1450 Reference< ::com::sun::star::form::XReset > xReset(m_xMainForm, UNO_QUERY);
1451 if (xReset.is())
1452 xReset->reset();
1455 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm)
1457 // ::com::sun::star::container::XNameContainer
1458 // -------------------------------------------------------------------------
1459 void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const ::rtl::OUString* pNewElName) throw( ::com::sun::star::lang::IllegalArgumentException )
1461 // extract the form component
1462 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1464 throw ::com::sun::star::lang::IllegalArgumentException();
1467 Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)aElement.getValue(), UNO_QUERY);
1468 if (!xElement.is())
1470 throw ::com::sun::star::lang::IllegalArgumentException();
1473 // for the name we need the propset
1474 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1475 if (!xElementSet.is())
1477 throw ::com::sun::star::lang::IllegalArgumentException();
1479 ::rtl::OUString sName;
1482 if (pNewElName)
1483 xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName));
1485 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1487 catch(Exception&)
1489 // the set didn't support the name prop
1490 throw ::com::sun::star::lang::IllegalArgumentException();
1493 // check the index
1494 OSL_ASSERT(nIndex >= 0);
1495 if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
1496 nIndex = m_aChildren.size();
1498 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1499 m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
1500 m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
1502 // listen for a changes of the name
1503 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1505 // we are now the parent of the new element
1506 xElement->setParent((::com::sun::star::container::XContainer*)this);
1508 // notify the container listeners
1509 ::com::sun::star::container::ContainerEvent aEvt;
1510 aEvt.Source = *this;
1511 aEvt.Accessor <<= nIndex;
1512 aEvt.Element <<= xElement;
1513 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1514 while (aIt.hasMoreElements())
1515 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementInserted(aEvt);
1518 // -------------------------------------------------------------------------
1519 sal_Int32 SbaXFormAdapter::implGetPos(const ::rtl::OUString& rName)
1521 ::std::vector< ::rtl::OUString>::iterator aIter = ::std::find_if( m_aChildNames.begin(),
1522 m_aChildNames.end(),
1523 ::std::bind2nd(::std::equal_to< rtl::OUString>(),rName));
1525 if(aIter != m_aChildNames.end())
1526 return aIter - m_aChildNames.begin();
1528 return -1;
1531 // -------------------------------------------------------------------------
1532 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 )
1534 implInsert(aElement, m_aChildren.size(), &aName);
1537 // -------------------------------------------------------------------------
1538 void SAL_CALL SbaXFormAdapter::removeByName(const ::rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1540 sal_Int32 nPos = implGetPos(Name);
1541 if (-1 == nPos)
1543 throw ::com::sun::star::container::NoSuchElementException();
1545 removeByIndex(nPos);
1548 // ::com::sun::star::container::XNameReplace
1549 // -------------------------------------------------------------------------
1550 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 )
1552 sal_Int32 nPos = implGetPos(aName);
1553 if (-1 == nPos)
1555 throw ::com::sun::star::container::NoSuchElementException();
1557 replaceByIndex(nPos, aElement);
1560 // ::com::sun::star::container::XNameAccess
1561 // -------------------------------------------------------------------------
1562 Any SAL_CALL SbaXFormAdapter::getByName(const ::rtl::OUString& aName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1564 sal_Int32 nPos = implGetPos(aName);
1565 if (-1 == nPos)
1567 throw ::com::sun::star::container::NoSuchElementException();
1569 return makeAny(m_aChildren[nPos]);
1572 // -------------------------------------------------------------------------
1573 Sequence< ::rtl::OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException )
1575 ::rtl::OUString *pChildNames = m_aChildNames.empty() ? 0 : &m_aChildNames[0];
1576 return Sequence< ::rtl::OUString >(pChildNames, m_aChildNames.size());
1579 // -------------------------------------------------------------------------
1580 sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const ::rtl::OUString& aName) throw( RuntimeException )
1582 return (-1 != implGetPos(aName));
1585 // ::com::sun::star::container::XElementAccess
1586 // -------------------------------------------------------------------------
1587 Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException)
1589 return ::getCppuType(
1590 static_cast< Reference< ::com::sun::star::form::XFormComponent >* >(NULL));
1593 // -------------------------------------------------------------------------
1594 sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException)
1596 return m_aChildren.size() > 0;
1600 // ::com::sun::star::container::XIndexContainer
1601 // -------------------------------------------------------------------------
1602 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 )
1604 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1605 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1606 implInsert(Element, _rIndex);
1609 // -------------------------------------------------------------------------
1610 void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1612 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1613 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1615 Reference< ::com::sun::star::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
1617 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1618 m_aChildren.erase(m_aChildren.begin() + _rIndex);
1619 m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
1621 // no need to listen anymore
1622 Reference< ::com::sun::star::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
1623 xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1625 // we are no longer the parent
1626 xAffected->setParent(Reference< XInterface > ());
1628 // notify container listeners
1629 ::com::sun::star::container::ContainerEvent aEvt;
1630 aEvt.Source = *this;
1631 aEvt.Element <<= xAffected;
1632 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1633 while (aIt.hasMoreElements())
1634 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementRemoved(aEvt);
1638 // ::com::sun::star::container::XIndexReplace
1639 // -------------------------------------------------------------------------
1640 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 )
1642 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1643 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1645 // extract the form component
1646 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1648 throw ::com::sun::star::lang::IllegalArgumentException();
1651 Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)Element.getValue(), UNO_QUERY);
1652 if (!xElement.is())
1654 throw ::com::sun::star::lang::IllegalArgumentException();
1657 // for the name we need the propset
1658 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1659 if (!xElementSet.is())
1661 throw ::com::sun::star::lang::IllegalArgumentException();
1663 ::rtl::OUString sName;
1666 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1668 catch(Exception&)
1670 // the set didn't support the name prop
1671 throw ::com::sun::star::lang::IllegalArgumentException();
1674 Reference< ::com::sun::star::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
1676 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1677 *(m_aChildren.begin() + _rIndex) = xElement;
1678 *(m_aChildNames.begin() + _rIndex) = sName;
1680 // correct property change listening
1681 Reference< ::com::sun::star::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
1682 xOldSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1683 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1685 // parent reset
1686 xOld->setParent(Reference< XInterface > ());
1687 xElement->setParent((::com::sun::star::container::XContainer*)this);
1689 // notify container listeners
1690 ::com::sun::star::container::ContainerEvent aEvt;
1691 aEvt.Source = *this;
1692 aEvt.Accessor <<= (sal_Int32)_rIndex;
1693 aEvt.Element <<= xElement;
1694 aEvt.ReplacedElement <<= xOld;
1696 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1697 while (aIt.hasMoreElements())
1698 ((::com::sun::star::container::XContainerListener*)aIt.next())->elementReplaced(aEvt);
1701 // ::com::sun::star::container::XIndexAccess
1702 // -------------------------------------------------------------------------
1703 sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException )
1705 return m_aChildren.size();
1708 // -------------------------------------------------------------------------
1709 Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1711 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1712 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1714 Reference< ::com::sun::star::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
1715 return makeAny(xElement);
1718 // ::com::sun::star::container::XContainer
1719 // -------------------------------------------------------------------------
1720 void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
1722 m_aContainerListeners.addInterface(xListener);
1725 // -------------------------------------------------------------------------
1726 void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
1728 m_aContainerListeners.removeInterface(xListener);
1731 // ::com::sun::star::container::XEnumerationAccess
1732 // -------------------------------------------------------------------------
1733 Reference< ::com::sun::star::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException )
1735 return new ::comphelper::OEnumerationByName(this);
1738 // ::com::sun::star::beans::XPropertyChangeListener
1739 // -------------------------------------------------------------------------
1740 void SAL_CALL SbaXFormAdapter::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( RuntimeException )
1742 if (evt.PropertyName.equals(PROPERTY_NAME))
1744 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1745 m_aChildren.end(),
1746 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),evt.Source));
1748 if(aIter != m_aChildren.end())
1750 sal_Int32 nPos = aIter - m_aChildren.begin();
1751 OSL_ENSURE(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1752 *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
1757 // ::com::sun::star::lang::XEventListener
1758 // -------------------------------------------------------------------------
1759 void SAL_CALL SbaXFormAdapter::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException )
1761 // was it our main form ?
1762 if (Source.Source == m_xMainForm)
1763 dispose();
1765 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1766 m_aChildren.end(),
1767 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),Source.Source));
1768 if(aIter != m_aChildren.end())
1769 removeByIndex(aIter - m_aChildren.begin());
1771 // -----------------------------------------------------------------------------
1774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */