build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / ui / browser / formadapter.cxx
blobf66fb419840c3eedd3507a87c01b79470b0c487e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "formadapter.hxx"
21 #include <tools/debug.hxx>
22 #include <osl/diagnose.h>
23 #include <comphelper/types.hxx>
24 #include <comphelper/enumhelper.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include "dbu_brw.hrc"
27 #include "dbustrings.hrc"
28 #include <connectivity/dbexception.hxx>
29 #include <cppuhelper/typeprovider.hxx>
30 #include <comphelper/sequence.hxx>
32 using namespace dbaui;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::sdb;
35 using namespace ::com::sun::star::sdbcx;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::container;
39 // SbaXFormAdapter
41 SbaXFormAdapter::SbaXFormAdapter()
42 :m_aLoadListeners(*this, m_aMutex)
43 ,m_aRowSetListeners(*this, m_aMutex)
44 ,m_aRowSetApproveListeners(*this, m_aMutex)
45 ,m_aErrorListeners(*this, m_aMutex)
46 ,m_aParameterListeners(*this, m_aMutex)
47 ,m_aSubmitListeners(*this, m_aMutex)
48 ,m_aResetListeners(*this, m_aMutex)
49 ,m_aPropertyChangeListeners(*this, m_aMutex)
50 ,m_aVetoablePropertyChangeListeners(*this, m_aMutex)
51 ,m_aPropertiesChangeListeners(*this, m_aMutex)
52 ,m_aDisposeListeners(m_aMutex)
53 ,m_aContainerListeners(m_aMutex)
54 ,m_nNamePropHandle(-1)
59 SbaXFormAdapter::~SbaXFormAdapter()
64 Sequence< Type > SAL_CALL SbaXFormAdapter::getTypes( ) throw (RuntimeException, std::exception)
66 return ::comphelper::concatSequences(
67 SbaXFormAdapter_BASE1::getTypes(),
68 SbaXFormAdapter_BASE2::getTypes(),
69 SbaXFormAdapter_BASE3::getTypes()
73 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getImplementationId( ) throw (RuntimeException, std::exception)
75 return css::uno::Sequence<sal_Int8>();
78 Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) throw (RuntimeException, std::exception)
80 Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
82 if (!aReturn.hasValue())
83 aReturn = SbaXFormAdapter_BASE2::queryInterface( _rType );
85 if (!aReturn.hasValue())
86 aReturn = SbaXFormAdapter_BASE3::queryInterface( _rType );
88 return aReturn;
91 void SbaXFormAdapter::StopListening()
93 // log off all our multiplexers
94 STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, css::form::XLoadable, m_xMainForm);
95 STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, css::sdbc::XRowSet, m_xMainForm);
96 STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, css::sdb::XRowSetApproveBroadcaster, m_xMainForm);
97 STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, css::sdb::XSQLErrorBroadcaster, m_xMainForm);
98 STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, css::form::XSubmit, m_xMainForm);
99 STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, css::form::XReset, m_xMainForm);
101 if (m_aParameterListeners.getLength())
103 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
104 if (xBroadcaster.is())
105 xBroadcaster->removeParameterListener(&m_aParameterListeners);
108 STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
109 STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
110 if (m_aPropertiesChangeListeners.getLength())
112 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
113 if (xBroadcaster.is())
114 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
117 // log off ourself
118 Reference< css::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
119 if (xComp.is())
120 xComp->removeEventListener(static_cast<css::lang::XEventListener*>(static_cast<css::beans::XPropertyChangeListener*>(this)));
123 void SbaXFormAdapter::StartListening()
125 // log off all our multiplexers
126 START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, css::form::XLoadable, m_xMainForm);
127 START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, css::sdbc::XRowSet, m_xMainForm);
128 START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, css::sdb::XRowSetApproveBroadcaster, m_xMainForm);
129 START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, css::sdb::XSQLErrorBroadcaster, m_xMainForm);
130 START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, css::form::XSubmit, m_xMainForm);
131 START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, css::form::XReset, m_xMainForm);
133 if (m_aParameterListeners.getLength())
135 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
136 if (xBroadcaster.is())
137 xBroadcaster->addParameterListener(&m_aParameterListeners);
140 START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
141 START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
142 if (m_aPropertiesChangeListeners.getLength())
144 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
145 if (xBroadcaster.is())
146 xBroadcaster->addPropertiesChangeListener(css::uno::Sequence<OUString>{""}, &m_aPropertiesChangeListeners);
149 // log off ourself
150 Reference< css::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
151 if (xComp.is())
152 xComp->addEventListener(static_cast<css::lang::XEventListener*>(static_cast<css::beans::XPropertyChangeListener*>(this)));
155 void SbaXFormAdapter::AttachForm(const Reference< css::sdbc::XRowSet >& xNewMaster)
157 if (xNewMaster == m_xMainForm)
158 return;
160 OSL_ENSURE(xNewMaster.get() != static_cast< css::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
162 if (m_xMainForm.is())
164 StopListening();
166 // if our old master is loaded we have to send an 'unloaded' event
167 Reference< css::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
168 if (xLoadable->isLoaded())
170 css::lang::EventObject aEvt(*this);
171 ::comphelper::OInterfaceIteratorHelper2 aIt(m_aLoadListeners);
172 while (aIt.hasMoreElements())
173 static_cast< css::form::XLoadListener*>(aIt.next())->unloaded(aEvt);
177 m_xMainForm = xNewMaster;
179 if (m_xMainForm.is())
181 StartListening();
183 // if our new master is loaded we have to send an 'loaded' event
184 Reference< css::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
185 if (xLoadable->isLoaded())
187 css::lang::EventObject aEvt(*this);
188 ::comphelper::OInterfaceIteratorHelper2 aIt(m_aLoadListeners);
189 while (aIt.hasMoreElements())
190 static_cast< css::form::XLoadListener*>(aIt.next())->loaded(aEvt);
194 // TODO : perhaps _all_ of our listeners should be notified about our new state
195 // (nearly every aspect of us may have changed with new master form)
198 // css::sdbc::XCloseable
199 void SAL_CALL SbaXFormAdapter::close() throw( css::sdbc::SQLException, RuntimeException, std::exception )
201 Reference< css::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
202 if (xIface.is())
203 xIface->close();
206 // css::sdbc::XResultSetMetaDataSupplier
207 Reference< css::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( css::sdbc::SQLException, RuntimeException, std::exception )
209 Reference< css::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
210 if (xIface.is())
211 return xIface->getMetaData();
212 return Reference< css::sdbc::XResultSetMetaData > ();
215 // css::sdbc::XColumnLocate
216 sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const OUString& columnName) throw( css::sdbc::SQLException, RuntimeException, std::exception )
218 Reference< css::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
219 if (xIface.is())
220 return xIface->findColumn(columnName);
222 ::dbtools::throwInvalidColumnException( columnName, *this );
223 assert(false);
224 return 0; // Never reached
227 // css::sdbcx::XColumnsSupplier
228 Reference< css::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException, std::exception )
230 Reference< css::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
231 if (xIface.is())
232 return xIface->getColumns();
233 return Reference< css::container::XNameAccess > ();
236 // css::sdbc::XRow
237 sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( css::sdbc::SQLException, RuntimeException, std::exception )
239 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
240 if (xIface.is())
241 return xIface->wasNull();
242 return true;
245 OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
247 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
248 if (xIface.is())
249 return xIface->getString(columnIndex);
250 return OUString();
253 sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
255 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
256 if (xIface.is())
257 return xIface->getBoolean(columnIndex);
258 return false;
261 sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
264 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
265 if (xIface.is())
266 return xIface->getByte(columnIndex);
267 return 0;
270 sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
272 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
273 if (xIface.is())
274 return xIface->getShort(columnIndex);
275 return 0;
278 sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
280 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
281 if (xIface.is())
282 return xIface->getInt(columnIndex);
283 return 0;
286 sal_Int64 SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
288 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
289 if (xIface.is())
290 return xIface->getLong(columnIndex);
291 return 0;
294 float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
296 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
297 if (xIface.is())
298 return xIface->getFloat(columnIndex);
299 return 0.0;
302 double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
304 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
305 if (xIface.is())
306 return xIface->getDouble(columnIndex);
307 return 0.0;
310 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
312 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
313 if (xIface.is())
314 return xIface->getBytes(columnIndex);
315 return Sequence <sal_Int8> ();
318 css::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
320 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
321 if (xIface.is())
322 return xIface->getDate(columnIndex);
323 return css::util::Date();
326 css::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
328 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
329 if (xIface.is())
330 return xIface->getTime(columnIndex);
331 return css::util::Time();
334 css::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
336 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
337 if (xIface.is())
338 return xIface->getTimestamp(columnIndex);
339 return css::util::DateTime();
342 Reference< css::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
344 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
345 if (xIface.is())
346 return xIface->getBinaryStream(columnIndex);
347 return Reference< css::io::XInputStream > ();
350 Reference< css::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
352 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
353 if (xIface.is())
354 return xIface->getCharacterStream(columnIndex);
355 return Reference< css::io::XInputStream > ();
358 Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap) throw( css::sdbc::SQLException, RuntimeException, std::exception )
360 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
361 if (xIface.is())
362 return xIface->getObject(columnIndex, typeMap);
363 return Any();
366 Reference< css::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
368 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
369 if (xIface.is())
370 return xIface->getRef(columnIndex);
371 return Reference< css::sdbc::XRef > ();
374 Reference< css::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
376 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
377 if (xIface.is())
378 return xIface->getBlob(columnIndex);
379 return Reference< css::sdbc::XBlob > ();
382 Reference< css::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
384 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
385 if (xIface.is())
386 return xIface->getClob(columnIndex);
387 return Reference< css::sdbc::XClob > ();
390 Reference< css::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
392 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
393 if (xIface.is())
394 return xIface->getArray(columnIndex);
395 return Reference< css::sdbc::XArray > ();
398 // css::sdbcx::XRowLocate
399 Any SAL_CALL SbaXFormAdapter::getBookmark() throw( css::sdbc::SQLException, RuntimeException, std::exception )
401 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
402 if (xIface.is())
403 return xIface->getBookmark();
404 return Any();
407 sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( css::sdbc::SQLException, RuntimeException, std::exception )
409 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
410 if (xIface.is())
411 return xIface->moveToBookmark(bookmark);
412 return false;
415 sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( css::sdbc::SQLException, RuntimeException, std::exception )
417 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
418 if (xIface.is())
419 return xIface->moveRelativeToBookmark(bookmark,rows);
420 return false;
423 sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second) throw( css::sdbc::SQLException, RuntimeException, std::exception )
425 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
426 if (xIface.is())
427 return xIface->compareBookmarks(_first, _second);
428 return 0;
431 sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( css::sdbc::SQLException, RuntimeException, std::exception )
433 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
434 if (xIface.is())
435 return xIface->hasOrderedBookmarks();
436 return false;
439 sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( css::sdbc::SQLException, RuntimeException, std::exception )
441 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
442 if (xIface.is())
443 return xIface->hashBookmark(bookmark);
444 return 0;
447 // css::sdbc::XRowUpdate
448 void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( css::sdbc::SQLException, RuntimeException, std::exception )
450 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
451 if (xIface.is())
452 xIface->updateNull(columnIndex);
455 void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
457 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
458 if (xIface.is())
459 xIface->updateBoolean(columnIndex, x);
462 void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
464 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
465 if (xIface.is())
466 xIface->updateByte(columnIndex, x);
469 void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
471 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
472 if (xIface.is())
473 xIface->updateShort(columnIndex, x);
476 void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
478 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
479 if (xIface.is())
480 xIface->updateInt(columnIndex, x);
483 void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
485 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
486 if (xIface.is())
487 xIface->updateLong(columnIndex, x);
490 void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
492 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
493 if (xIface.is())
494 xIface->updateFloat(columnIndex, x);
497 void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
499 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
500 if (xIface.is())
501 xIface->updateDouble(columnIndex, x);
504 void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const OUString& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
506 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
507 if (xIface.is())
508 xIface->updateString(columnIndex, x);
511 void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
513 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
514 if (xIface.is())
515 xIface->updateBytes(columnIndex, x);
518 void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const css::util::Date& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
520 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
521 if (xIface.is())
522 xIface->updateDate(columnIndex, x);
525 void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const css::util::Time& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
527 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
528 if (xIface.is())
529 xIface->updateTime(columnIndex, x);
532 void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const css::util::DateTime& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
534 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
535 if (xIface.is())
536 xIface->updateTimestamp(columnIndex, x);
539 void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length) throw( css::sdbc::SQLException, RuntimeException, std::exception )
541 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
542 if (xIface.is())
543 xIface->updateBinaryStream(columnIndex, x, length);
546 void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length) throw( css::sdbc::SQLException, RuntimeException, std::exception )
548 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
549 if (xIface.is())
550 xIface->updateCharacterStream(columnIndex, x, length);
553 void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
555 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
556 if (xIface.is())
557 xIface->updateObject(columnIndex, x);
560 void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( css::sdbc::SQLException, RuntimeException, std::exception )
562 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
563 if (xIface.is())
564 xIface->updateNumericObject(columnIndex, x, scale);
567 // css::sdbc::XResultSet
568 sal_Bool SAL_CALL SbaXFormAdapter::next() throw( css::sdbc::SQLException, RuntimeException, std::exception )
570 if (m_xMainForm.is())
571 return m_xMainForm->next();
572 return false;
575 sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( css::sdbc::SQLException, RuntimeException, std::exception )
577 if (m_xMainForm.is())
578 return m_xMainForm->isBeforeFirst();
579 return false;
582 sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( css::sdbc::SQLException, RuntimeException, std::exception )
584 if (m_xMainForm.is())
585 return m_xMainForm->isAfterLast();
586 return false;
589 sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( css::sdbc::SQLException, RuntimeException, std::exception )
591 if (m_xMainForm.is())
592 return m_xMainForm->isFirst();
593 return false;
596 sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( css::sdbc::SQLException, RuntimeException, std::exception )
598 if (m_xMainForm.is())
599 return m_xMainForm->isLast();
600 return false;
603 void SAL_CALL SbaXFormAdapter::beforeFirst() throw( css::sdbc::SQLException, RuntimeException, std::exception )
605 if (m_xMainForm.is())
606 m_xMainForm->beforeFirst();
609 void SAL_CALL SbaXFormAdapter::afterLast() throw( css::sdbc::SQLException, RuntimeException, std::exception )
611 if (m_xMainForm.is())
612 m_xMainForm->afterLast();
615 sal_Bool SAL_CALL SbaXFormAdapter::first() throw( css::sdbc::SQLException, RuntimeException, std::exception )
617 if (m_xMainForm.is())
618 return m_xMainForm->first();
619 return false;
622 sal_Bool SAL_CALL SbaXFormAdapter::last() throw( css::sdbc::SQLException, RuntimeException, std::exception )
624 if (m_xMainForm.is())
625 return m_xMainForm->last();
626 return false;
629 sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
631 if (m_xMainForm.is())
632 return m_xMainForm->getRow();
633 return 0;
636 sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( css::sdbc::SQLException, RuntimeException, std::exception )
638 if (m_xMainForm.is())
639 return m_xMainForm->absolute(row);
640 return false;
643 sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( css::sdbc::SQLException, RuntimeException, std::exception )
645 if (m_xMainForm.is())
646 return m_xMainForm->relative(rows);
647 return false;
650 sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( css::sdbc::SQLException, RuntimeException, std::exception )
652 if (m_xMainForm.is())
653 return m_xMainForm->previous();
654 return false;
657 void SAL_CALL SbaXFormAdapter::refreshRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
659 if (m_xMainForm.is())
660 m_xMainForm->refreshRow();
663 sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( css::sdbc::SQLException, RuntimeException, std::exception )
665 if (m_xMainForm.is())
666 return m_xMainForm->rowUpdated();
667 return false;
670 sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( css::sdbc::SQLException, RuntimeException, std::exception )
672 if (m_xMainForm.is())
673 return m_xMainForm->rowInserted();
674 return false;
677 sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( css::sdbc::SQLException, RuntimeException, std::exception )
679 if (m_xMainForm.is())
680 return m_xMainForm->rowDeleted();
681 return false;
684 Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( css::sdbc::SQLException, RuntimeException, std::exception )
686 if (m_xMainForm.is())
687 return m_xMainForm->getStatement();
688 return nullptr;
691 // css::sdbc::XResultSetUpdate
692 void SAL_CALL SbaXFormAdapter::insertRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
694 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
695 if (xIface.is())
696 xIface->insertRow();
699 void SAL_CALL SbaXFormAdapter::updateRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
701 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
702 if (xIface.is())
703 xIface->updateRow();
706 void SAL_CALL SbaXFormAdapter::deleteRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
708 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
709 if (xIface.is())
710 xIface->deleteRow();
713 void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( css::sdbc::SQLException, RuntimeException, std::exception )
715 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
716 if (xIface.is())
717 xIface->cancelRowUpdates();
720 void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
722 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
723 if (xIface.is())
724 xIface->moveToInsertRow();
727 void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( css::sdbc::SQLException, RuntimeException, std::exception )
729 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
730 if (xIface.is())
731 xIface->moveToCurrentRow();
734 // css::sdbc::XRowSet
735 void SAL_CALL SbaXFormAdapter::execute() throw( css::sdbc::SQLException, RuntimeException, std::exception )
737 if (m_xMainForm.is())
738 m_xMainForm->execute();
741 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, css::sdbc::XRowSet, m_xMainForm)
743 // css::sdbcx::XDeleteRows
744 Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( css::sdbc::SQLException, RuntimeException, std::exception )
746 Reference< css::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
747 if (xIface.is())
748 return xIface->deleteRows(rows);
749 return Sequence<sal_Int32>();
752 // css::sdbc::XWarningsSupplier
753 Any SAL_CALL SbaXFormAdapter::getWarnings() throw( css::sdbc::SQLException, RuntimeException, std::exception )
755 Reference< css::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
756 if (xIface.is())
757 return xIface->getWarnings();
758 return Any();
761 void SAL_CALL SbaXFormAdapter::clearWarnings() throw( css::sdbc::SQLException, RuntimeException, std::exception )
763 Reference< css::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
764 if (xIface.is())
765 xIface->clearWarnings();
768 // css::sdb::XRowSetApproveBroadcaster
769 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, css::sdb::XRowSetApproveBroadcaster, m_xMainForm)
771 // css::sdbc::XSQLErrorBroadcaster
772 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, css::sdb::XSQLErrorBroadcaster, m_xMainForm)
774 // css::sdb::XResultSetAccess
775 Reference< css::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( css::sdbc::SQLException, RuntimeException, std::exception )
777 Reference< css::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
778 if (xIface.is())
779 return xIface->createResultSet();
780 return Reference< css::sdbc::XResultSet > ();
783 // css::form::XLoadable
784 void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException, std::exception )
786 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
787 if (xIface.is())
788 xIface->load();
791 void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException, std::exception )
793 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
794 if (xIface.is())
795 xIface->unload();
798 void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException, std::exception )
800 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
801 if (xIface.is())
802 xIface->reload();
805 sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException, std::exception )
807 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
808 if (xIface.is())
809 return xIface->isLoaded();
810 return false;
813 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, css::form::XLoadable, m_xMainForm)
815 // css::sdbc::XParameters
816 void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( css::sdbc::SQLException, RuntimeException, std::exception )
818 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
819 if (xIface.is())
820 xIface->setNull(parameterIndex, sqlType);
823 void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName) throw( css::sdbc::SQLException, RuntimeException, std::exception )
825 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
826 if (xIface.is())
827 xIface->setObjectNull(parameterIndex, sqlType, typeName);
830 void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
832 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
833 if (xIface.is())
834 xIface->setBoolean(parameterIndex, x);
837 void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
839 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
840 if (xIface.is())
841 xIface->setByte(parameterIndex, x);
844 void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
846 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
847 if (xIface.is())
848 xIface->setShort(parameterIndex, x);
851 void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
853 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
854 if (xIface.is())
855 xIface->setInt(parameterIndex, x);
858 void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
860 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
861 if (xIface.is())
862 xIface->setLong(parameterIndex, x);
865 void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
867 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
868 if (xIface.is())
869 xIface->setFloat(parameterIndex, x);
872 void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
874 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
875 if (xIface.is())
876 xIface->setDouble(parameterIndex, x);
879 void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const OUString& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
881 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
882 if (xIface.is())
883 xIface->setString(parameterIndex, x);
886 void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
888 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
889 if (xIface.is())
890 xIface->setBytes(parameterIndex, x);
893 void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const css::util::Date& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
895 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
896 if (xIface.is())
897 xIface->setDate(parameterIndex, x);
900 void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const css::util::Time& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
902 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
903 if (xIface.is())
904 xIface->setTime(parameterIndex, x);
907 void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
909 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
910 if (xIface.is())
911 xIface->setTimestamp(parameterIndex, x);
914 void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length) throw( css::sdbc::SQLException, RuntimeException, std::exception )
916 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
917 if (xIface.is())
918 xIface->setBinaryStream(parameterIndex, x, length);
921 void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length) throw( css::sdbc::SQLException, RuntimeException, std::exception )
923 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
924 if (xIface.is())
925 xIface->setCharacterStream(parameterIndex, x, length);
928 void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
930 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
931 if (xIface.is())
932 xIface->setObject(parameterIndex, x);
935 void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( css::sdbc::SQLException, RuntimeException, std::exception )
937 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
938 if (xIface.is())
939 xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
942 void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< css::sdbc::XRef >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
944 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
945 if (xIface.is())
946 xIface->setRef(parameterIndex, x);
949 void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< css::sdbc::XBlob >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
951 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
952 if (xIface.is())
953 xIface->setBlob(parameterIndex, x);
956 void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< css::sdbc::XClob >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
958 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
959 if (xIface.is())
960 xIface->setClob(parameterIndex, x);
963 void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< css::sdbc::XArray >& x) throw( css::sdbc::SQLException, RuntimeException, std::exception )
965 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
966 if (xIface.is())
967 xIface->setArray(parameterIndex, x);
970 void SAL_CALL SbaXFormAdapter::clearParameters() throw( css::sdbc::SQLException, RuntimeException, std::exception )
972 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
973 if (xIface.is())
974 xIface->clearParameters();
977 // css::form::XDatabaseParameterBroadcaster
978 void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< css::form::XDatabaseParameterListener >& aListener) throw( RuntimeException, std::exception )
980 m_aParameterListeners.addInterface(aListener);
981 if (m_aParameterListeners.getLength() == 1)
983 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
984 if (xBroadcaster.is())
985 xBroadcaster->addParameterListener(&m_aParameterListeners);
989 void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< css::form::XDatabaseParameterListener >& aListener) throw( RuntimeException, std::exception )
991 if (m_aParameterListeners.getLength() == 1)
993 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
994 if (xBroadcaster.is())
995 xBroadcaster->removeParameterListener(&m_aParameterListeners);
997 m_aParameterListeners.removeInterface(aListener);
1000 // css::container::XChild
1001 Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException, std::exception )
1003 return m_xParent;
1006 void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( css::lang::NoSupportException, RuntimeException, std::exception )
1008 m_xParent = Parent;
1011 // css::form::XSubmit
1012 void SAL_CALL SbaXFormAdapter::submit(const Reference< css::awt::XControl >& aControl, const css::awt::MouseEvent& aMouseEvt) throw( RuntimeException, std::exception )
1014 Reference< css::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
1015 if (xSubmit.is())
1016 xSubmit->submit(aControl, aMouseEvt);
1019 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, css::form::XSubmit, m_xMainForm)
1021 // css::awt::XTabControllerModel
1022 sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException, std::exception )
1024 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1025 return false;
1028 void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException, std::exception )
1030 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1033 void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< css::awt::XControlModel > >& /*Controls*/) throw( RuntimeException, std::exception )
1035 OSL_FAIL("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1038 Sequence< Reference< css::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException, std::exception )
1040 OSL_FAIL("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1041 return Sequence< Reference< css::awt::XControlModel > >();
1044 void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/, const OUString& /*GroupName*/) throw( RuntimeException, std::exception )
1046 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1049 sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException, std::exception )
1051 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1052 return 0;
1055 void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/, OUString& /*Name*/) throw( RuntimeException, std::exception )
1057 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1060 void SAL_CALL SbaXFormAdapter::getGroupByName(const OUString& /*Name*/, Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/) throw( RuntimeException, std::exception )
1062 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1065 // css::lang::XComponent
1066 void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException, std::exception )
1068 // log off all multiplexers
1069 if (m_xMainForm.is())
1070 StopListening();
1072 css::lang::EventObject aEvt(*this);
1073 m_aLoadListeners.disposeAndClear(aEvt);
1074 m_aRowSetListeners.disposeAndClear(aEvt);
1075 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1076 m_aErrorListeners.disposeAndClear(aEvt);
1077 m_aParameterListeners.disposeAndClear(aEvt);
1078 m_aSubmitListeners.disposeAndClear(aEvt);
1079 m_aResetListeners.disposeAndClear(aEvt);
1081 m_aVetoablePropertyChangeListeners.disposeAndClear();
1082 m_aPropertyChangeListeners.disposeAndClear();
1083 m_aPropertiesChangeListeners.disposeAndClear(aEvt);
1085 m_aDisposeListeners.disposeAndClear(aEvt);
1086 m_aContainerListeners.disposeAndClear(aEvt);
1088 // dispose all children
1089 for ( ::std::vector< Reference< css::form::XFormComponent > >::const_iterator aIter = m_aChildren.begin();
1090 aIter != m_aChildren.end();
1091 ++aIter
1094 Reference< css::beans::XPropertySet > xSet(*aIter, UNO_QUERY);
1095 if (xSet.is())
1096 xSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1098 Reference< css::container::XChild > xChild(*aIter, UNO_QUERY);
1099 if (xChild.is())
1100 xChild->setParent(Reference< XInterface > ());
1102 Reference< css::lang::XComponent > xComp(*aIter, UNO_QUERY);
1103 if (xComp.is())
1104 xComp->dispose();
1106 m_aChildren.clear();
1109 void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< css::lang::XEventListener >& xListener) throw( RuntimeException, std::exception )
1111 m_aDisposeListeners.addInterface(xListener);
1114 void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< css::lang::XEventListener >& aListener) throw( RuntimeException, std::exception )
1116 m_aDisposeListeners.removeInterface(aListener);
1119 // css::beans::XFastPropertySet
1120 void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue) throw( css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1122 Reference< css::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1123 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1125 if (m_nNamePropHandle == nHandle)
1127 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1129 throw css::lang::IllegalArgumentException();
1132 // for notifying property listeners
1133 css::beans::PropertyChangeEvent aEvt;
1134 aEvt.Source = *this;
1135 aEvt.PropertyName = PROPERTY_NAME;
1136 aEvt.PropertyHandle = m_nNamePropHandle;
1137 aEvt.OldValue <<= m_sName;
1138 aEvt.NewValue = aValue;
1140 aValue >>= m_sName;
1142 ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME));
1143 while (aIt.hasMoreElements())
1144 static_cast< css::beans::XPropertyChangeListener*>(aIt.next())->propertyChange(aEvt);
1146 return;
1149 xSet->setFastPropertyValue(nHandle, aValue);
1152 Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( css::beans::UnknownPropertyException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1154 Reference< css::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1155 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1157 if (m_nNamePropHandle == nHandle)
1158 return makeAny(m_sName);
1160 return xSet->getFastPropertyValue(nHandle);
1163 // css::container::XNamed
1164 OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException, std::exception )
1166 return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
1169 void SAL_CALL SbaXFormAdapter::setName(const OUString& aName) throw( RuntimeException, std::exception )
1171 setPropertyValue(PROPERTY_NAME, makeAny(aName));
1174 // css::io::XPersistObject
1175 OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException, std::exception )
1177 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1178 if (xPersist.is())
1179 return xPersist->getServiceName();
1180 return OUString();
1183 void SAL_CALL SbaXFormAdapter::write(const Reference< css::io::XObjectOutputStream >& _rxOutStream) throw( css::io::IOException, RuntimeException, std::exception )
1185 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1186 if (xPersist.is())
1187 xPersist->write(_rxOutStream);
1190 void SAL_CALL SbaXFormAdapter::read(const Reference< css::io::XObjectInputStream >& _rxInStream) throw( css::io::IOException, RuntimeException, std::exception )
1192 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1193 if (xPersist.is())
1194 xPersist->read(_rxInStream);
1197 // css::beans::XMultiPropertySet
1198 Reference< css::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException, std::exception )
1200 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1201 if (!xSet.is())
1202 return Reference< css::beans::XPropertySetInfo > ();
1204 Reference< css::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
1205 if (-1 == m_nNamePropHandle)
1207 // we need to determine the handle for the NAME property
1208 Sequence< css::beans::Property> aProps = xReturn->getProperties();
1209 const css::beans::Property* pProps = aProps.getConstArray();
1211 for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
1213 if (pProps->Name == PROPERTY_NAME)
1215 m_nNamePropHandle = pProps->Handle;
1216 break;
1220 return xReturn;
1223 void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< OUString >& PropertyNames, const Sequence< Any >& Values) throw( css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1225 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1226 if (xSet.is())
1227 xSet->setPropertyValues(PropertyNames, Values);
1230 Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< OUString >& aPropertyNames) throw( RuntimeException, std::exception )
1232 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1233 if (!xSet.is())
1234 return Sequence< Any>(aPropertyNames.getLength());
1236 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1238 // search for (and fake) the NAME property
1239 const OUString* pNames = aPropertyNames.getConstArray();
1240 Any* pValues = aReturn.getArray();
1241 OSL_ENSURE(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
1242 for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues)
1243 if (*pNames == PROPERTY_NAME)
1245 (*pValues) <<= m_sName;
1246 break;
1249 return aReturn;
1252 void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< OUString>& /*aPropertyNames*/, const Reference< css::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException, std::exception )
1254 // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
1255 m_aPropertiesChangeListeners.addInterface(xListener);
1256 if (m_aPropertiesChangeListeners.getLength() == 1)
1258 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1259 if (xBroadcaster.is())
1260 xBroadcaster->addPropertiesChangeListener(Sequence< OUString>{""}, &m_aPropertiesChangeListeners);
1264 void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< css::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException, std::exception )
1266 if (m_aPropertiesChangeListeners.getLength() == 1)
1268 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1269 if (xBroadcaster.is())
1270 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
1272 m_aPropertiesChangeListeners.removeInterface(Listener);
1275 void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< OUString >& aPropertyNames, const Reference< css::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException, std::exception )
1277 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1278 if (xSet.is())
1279 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1282 // css::beans::XPropertySet
1283 void SAL_CALL SbaXFormAdapter::setPropertyValue(const OUString& aPropertyName, const Any& aValue) throw( css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1285 Reference< css::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1286 if (!xSet.is())
1287 return;
1289 // special handling for the "name" property
1290 if (aPropertyName == PROPERTY_NAME)
1291 setFastPropertyValue(m_nNamePropHandle, aValue);
1293 xSet->setPropertyValue(aPropertyName, aValue);
1296 Any SAL_CALL SbaXFormAdapter::getPropertyValue(const OUString& PropertyName) throw( css::beans::UnknownPropertyException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1298 Reference< css::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1299 if (!xSet.is())
1300 return Any();
1302 // special handling for the "name" property
1303 if (PropertyName == PROPERTY_NAME)
1304 return getFastPropertyValue(m_nNamePropHandle);
1306 return xSet->getPropertyValue(PropertyName);
1309 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
1310 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, css::beans::XPropertySet, m_xMainForm);
1312 // css::util::XCancellable
1313 void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException, std::exception )
1315 Reference< css::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
1316 if (xCancel.is())
1317 return;
1318 xCancel->cancel();
1321 // css::beans::XPropertyState
1322 css::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const OUString& PropertyName) throw( css::beans::UnknownPropertyException, RuntimeException, std::exception )
1324 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1325 if (xState.is())
1326 return xState->getPropertyState(PropertyName);
1327 return css::beans::PropertyState_DEFAULT_VALUE;
1330 Sequence< css::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< OUString >& aPropertyName) throw( css::beans::UnknownPropertyException, RuntimeException, std::exception )
1332 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1333 if (xState.is())
1334 return xState->getPropertyStates(aPropertyName);
1336 // set them all to DEFAULT
1337 Sequence< css::beans::PropertyState> aReturn(aPropertyName.getLength());
1338 css::beans::PropertyState* pStates = aReturn.getArray();
1339 for (sal_Int32 i=0; i<aPropertyName.getLength(); ++i, ++pStates)
1340 *pStates = css::beans::PropertyState_DEFAULT_VALUE;
1341 return aReturn;
1344 void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const OUString& PropertyName) throw( css::beans::UnknownPropertyException, RuntimeException, std::exception )
1346 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1347 if (xState.is())
1348 xState->setPropertyToDefault(PropertyName);
1351 Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const OUString& aPropertyName) throw( css::beans::UnknownPropertyException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1353 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1354 if (xState.is())
1355 return xState->getPropertyDefault(aPropertyName);
1356 return Any();
1359 // css::form::XReset
1360 void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException, std::exception )
1362 Reference< css::form::XReset > xReset(m_xMainForm, UNO_QUERY);
1363 if (xReset.is())
1364 xReset->reset();
1367 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, css::form::XReset, m_xMainForm)
1369 // css::container::XNameContainer
1370 void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OUString* pNewElName) throw( css::lang::IllegalArgumentException )
1372 // extract the form component
1373 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1375 throw css::lang::IllegalArgumentException();
1378 Reference< css::form::XFormComponent > xElement(aElement, UNO_QUERY);
1379 if (!xElement.is())
1381 throw css::lang::IllegalArgumentException();
1384 // for the name we need the propset
1385 Reference< css::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1386 if (!xElementSet.is())
1388 throw css::lang::IllegalArgumentException();
1390 OUString sName;
1393 if (pNewElName)
1394 xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName));
1396 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1398 catch(Exception&)
1400 // the set didn't support the name prop
1401 throw css::lang::IllegalArgumentException();
1404 // check the index
1405 OSL_ASSERT(nIndex >= 0);
1406 if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
1407 nIndex = m_aChildren.size();
1409 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1410 m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
1411 m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
1413 // listen for a changes of the name
1414 xElementSet->addPropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1416 // we are now the parent of the new element
1417 xElement->setParent(static_cast<css::container::XContainer*>(this));
1419 // notify the container listeners
1420 css::container::ContainerEvent aEvt;
1421 aEvt.Source = *this;
1422 aEvt.Accessor <<= nIndex;
1423 aEvt.Element <<= xElement;
1424 ::comphelper::OInterfaceIteratorHelper2 aIt(m_aContainerListeners);
1425 while (aIt.hasMoreElements())
1426 static_cast< css::container::XContainerListener*>(aIt.next())->elementInserted(aEvt);
1429 sal_Int32 SbaXFormAdapter::implGetPos(const OUString& rName)
1431 ::std::vector< OUString>::const_iterator aIter = ::std::find_if( m_aChildNames.begin(),
1432 m_aChildNames.end(),
1433 ::std::bind2nd(::std::equal_to< OUString>(),rName));
1435 if(aIter != m_aChildNames.end())
1436 return aIter - m_aChildNames.begin();
1438 return -1;
1441 void SAL_CALL SbaXFormAdapter::insertByName(const OUString& aName, const Any& aElement) throw( css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1443 implInsert(aElement, m_aChildren.size(), &aName);
1446 void SAL_CALL SbaXFormAdapter::removeByName(const OUString& Name) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1448 sal_Int32 nPos = implGetPos(Name);
1449 if (-1 == nPos)
1451 throw css::container::NoSuchElementException();
1453 removeByIndex(nPos);
1456 // css::container::XNameReplace
1457 void SAL_CALL SbaXFormAdapter::replaceByName(const OUString& aName, const Any& aElement) throw( css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1459 sal_Int32 nPos = implGetPos(aName);
1460 if (-1 == nPos)
1462 throw css::container::NoSuchElementException();
1464 replaceByIndex(nPos, aElement);
1467 // css::container::XNameAccess
1468 Any SAL_CALL SbaXFormAdapter::getByName(const OUString& aName) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1470 sal_Int32 nPos = implGetPos(aName);
1471 if (-1 == nPos)
1473 throw css::container::NoSuchElementException();
1475 return makeAny(m_aChildren[nPos]);
1478 Sequence< OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException, std::exception )
1480 return Sequence< OUString >(m_aChildNames.data(), m_aChildNames.size());
1483 sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const OUString& aName) throw( RuntimeException, std::exception )
1485 return (-1 != implGetPos(aName));
1488 // css::container::XElementAccess
1489 Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException, std::exception)
1491 return cppu::UnoType<css::form::XFormComponent>::get();
1494 sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException, std::exception)
1496 return m_aChildren.size() > 0;
1499 // css::container::XIndexContainer
1500 void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element) throw( css::lang::IllegalArgumentException, css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1502 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1503 throw css::lang::IndexOutOfBoundsException();
1504 implInsert(Element, _rIndex);
1507 void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1509 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1510 throw css::lang::IndexOutOfBoundsException();
1512 Reference< css::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
1514 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1515 m_aChildren.erase(m_aChildren.begin() + _rIndex);
1516 m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
1518 // no need to listen anymore
1519 Reference< css::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
1520 xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1522 // we are no longer the parent
1523 xAffected->setParent(Reference< XInterface > ());
1525 // notify container listeners
1526 css::container::ContainerEvent aEvt;
1527 aEvt.Source = *this;
1528 aEvt.Element <<= xAffected;
1529 ::comphelper::OInterfaceIteratorHelper2 aIt(m_aContainerListeners);
1530 while (aIt.hasMoreElements())
1531 static_cast< css::container::XContainerListener*>(aIt.next())->elementRemoved(aEvt);
1535 // css::container::XIndexReplace
1536 void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element) throw( css::lang::IllegalArgumentException, css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1538 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1539 throw css::lang::IndexOutOfBoundsException();
1541 // extract the form component
1542 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1544 throw css::lang::IllegalArgumentException();
1547 Reference< css::form::XFormComponent > xElement(Element, UNO_QUERY);
1548 if (!xElement.is())
1550 throw css::lang::IllegalArgumentException();
1553 // for the name we need the propset
1554 Reference< css::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1555 if (!xElementSet.is())
1557 throw css::lang::IllegalArgumentException();
1559 OUString sName;
1562 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1564 catch(Exception&)
1566 // the set didn't support the name prop
1567 throw css::lang::IllegalArgumentException();
1570 Reference< css::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
1572 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1573 *(m_aChildren.begin() + _rIndex) = xElement;
1574 *(m_aChildNames.begin() + _rIndex) = sName;
1576 // correct property change listening
1577 Reference< css::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
1578 xOldSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1579 xElementSet->addPropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1581 // parent reset
1582 xOld->setParent(Reference< XInterface > ());
1583 xElement->setParent(static_cast<css::container::XContainer*>(this));
1585 // notify container listeners
1586 css::container::ContainerEvent aEvt;
1587 aEvt.Source = *this;
1588 aEvt.Accessor <<= (sal_Int32)_rIndex;
1589 aEvt.Element <<= xElement;
1590 aEvt.ReplacedElement <<= xOld;
1592 ::comphelper::OInterfaceIteratorHelper2 aIt(m_aContainerListeners);
1593 while (aIt.hasMoreElements())
1594 static_cast< css::container::XContainerListener*>(aIt.next())->elementReplaced(aEvt);
1597 // css::container::XIndexAccess
1598 sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException, std::exception )
1600 return m_aChildren.size();
1603 Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, RuntimeException, std::exception )
1605 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1606 throw css::lang::IndexOutOfBoundsException();
1608 Reference< css::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
1609 return makeAny(xElement);
1612 // css::container::XContainer
1613 void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< css::container::XContainerListener >& xListener) throw( RuntimeException, std::exception )
1615 m_aContainerListeners.addInterface(xListener);
1618 void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< css::container::XContainerListener >& xListener) throw( RuntimeException, std::exception )
1620 m_aContainerListeners.removeInterface(xListener);
1623 // css::container::XEnumerationAccess
1624 Reference< css::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException, std::exception )
1626 return new ::comphelper::OEnumerationByName(this);
1629 // css::beans::XPropertyChangeListener
1630 void SAL_CALL SbaXFormAdapter::propertyChange(const css::beans::PropertyChangeEvent& evt) throw( RuntimeException, std::exception )
1632 if (evt.PropertyName == PROPERTY_NAME)
1634 ::std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = ::std::find_if( m_aChildren.begin(),
1635 m_aChildren.end(),
1636 ::std::bind2nd(::std::equal_to< css::uno::Reference< css::uno::XInterface > >(),evt.Source));
1638 if(aIter != m_aChildren.end())
1640 sal_Int32 nPos = aIter - m_aChildren.begin();
1641 OSL_ENSURE(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1642 *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
1647 // css::lang::XEventListener
1648 void SAL_CALL SbaXFormAdapter::disposing(const css::lang::EventObject& Source) throw( RuntimeException, std::exception )
1650 // was it our main form ?
1651 if (Source.Source == m_xMainForm)
1652 dispose();
1654 ::std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = ::std::find_if( m_aChildren.begin(),
1655 m_aChildren.end(),
1656 ::std::bind2nd(::std::equal_to< css::uno::Reference< css::uno::XInterface > >(),Source.Source));
1657 if(aIter != m_aChildren.end())
1658 removeByIndex(aIter - m_aChildren.begin());
1661 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */