calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / dbaccess / source / ui / browser / formadapter.cxx
blob9f439acd20db2cf1e9dc0397a60a6ff69c553b56
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 <o3tl/safeint.hxx>
22 #include <osl/diagnose.h>
23 #include <comphelper/types.hxx>
24 #include <comphelper/enumhelper.hxx>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <strings.hxx>
27 #include <connectivity/dbexception.hxx>
28 #include <comphelper/sequence.hxx>
30 using namespace dbaui;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::sdb;
33 using namespace ::com::sun::star::sdbcx;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::container;
37 // SbaXFormAdapter
39 SbaXFormAdapter::SbaXFormAdapter()
40 :m_aLoadListeners(*this, m_aMutex)
41 ,m_aRowSetListeners(*this, m_aMutex)
42 ,m_aRowSetApproveListeners(*this, m_aMutex)
43 ,m_aErrorListeners(*this, m_aMutex)
44 ,m_aParameterListeners(*this, m_aMutex)
45 ,m_aSubmitListeners(*this, m_aMutex)
46 ,m_aResetListeners(*this, m_aMutex)
47 ,m_aPropertyChangeListeners(*this, m_aMutex)
48 ,m_aVetoablePropertyChangeListeners(*this, m_aMutex)
49 ,m_aPropertiesChangeListeners(*this, m_aMutex)
50 ,m_aDisposeListeners(m_aMutex)
51 ,m_aContainerListeners(m_aMutex)
52 ,m_nNamePropHandle(-1)
57 SbaXFormAdapter::~SbaXFormAdapter()
62 Sequence< Type > SAL_CALL SbaXFormAdapter::getTypes( )
64 return ::comphelper::concatSequences(
65 SbaXFormAdapter_BASE1::getTypes(),
66 SbaXFormAdapter_BASE2::getTypes(),
67 SbaXFormAdapter_BASE3::getTypes()
71 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getImplementationId( )
73 return css::uno::Sequence<sal_Int8>();
76 Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType)
78 Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
80 if (!aReturn.hasValue())
81 aReturn = SbaXFormAdapter_BASE2::queryInterface( _rType );
83 if (!aReturn.hasValue())
84 aReturn = SbaXFormAdapter_BASE3::queryInterface( _rType );
86 return aReturn;
89 void SbaXFormAdapter::StopListening()
91 // log off all our multiplexers
92 if (m_aLoadListeners.getLength())
94 css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
95 if (xBroadcaster.is())
96 xBroadcaster->removeLoadListener(&m_aLoadListeners);
98 if (m_aRowSetListeners.getLength())
100 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
101 if (xBroadcaster.is())
102 xBroadcaster->removeRowSetListener(&m_aRowSetListeners);
104 if (m_aRowSetApproveListeners.getLength())
106 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
107 if (xBroadcaster.is())
108 xBroadcaster->removeRowSetApproveListener(&m_aRowSetApproveListeners);
110 if (m_aErrorListeners.getLength())
112 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
113 if (xBroadcaster.is())
114 xBroadcaster->removeSQLErrorListener(&m_aErrorListeners);
116 if (m_aSubmitListeners.getLength())
118 css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
119 if (xBroadcaster.is())
120 xBroadcaster->removeSubmitListener(&m_aSubmitListeners);
122 if (m_aResetListeners.getLength())
124 css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
125 if (xBroadcaster.is())
126 xBroadcaster->removeResetListener(&m_aResetListeners);
128 if (m_aParameterListeners.getLength())
130 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
131 if (xBroadcaster.is())
132 xBroadcaster->removeParameterListener(&m_aParameterListeners);
135 if (m_aPropertyChangeListeners.getOverallLen())
137 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
138 if (xBroadcaster.is())
139 xBroadcaster->removePropertyChangeListener(OUString(), &m_aPropertyChangeListeners);
142 if (m_aVetoablePropertyChangeListeners.getOverallLen())
144 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
145 if (xBroadcaster.is())
146 xBroadcaster->removeVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners);
149 if (m_aPropertiesChangeListeners.getLength())
151 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
152 if (xBroadcaster.is())
153 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
156 // log off ourself
157 Reference< css::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
158 if (xComp.is())
159 xComp->removeEventListener(static_cast<css::lang::XEventListener*>(static_cast<css::beans::XPropertyChangeListener*>(this)));
162 void SbaXFormAdapter::StartListening()
164 // log off all our multiplexers
165 if (m_aLoadListeners.getLength())
167 css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
168 if (xBroadcaster.is())
169 xBroadcaster->addLoadListener(&m_aLoadListeners);
171 if (m_aRowSetListeners.getLength())
173 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
174 if (xBroadcaster.is())
175 xBroadcaster->addRowSetListener(&m_aRowSetListeners);
177 if (m_aRowSetApproveListeners.getLength())
179 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
180 if (xBroadcaster.is())
181 xBroadcaster->addRowSetApproveListener(&m_aRowSetApproveListeners);
183 if (m_aErrorListeners.getLength())
185 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
186 if (xBroadcaster.is())
187 xBroadcaster->addSQLErrorListener(&m_aErrorListeners);
189 if (m_aSubmitListeners.getLength())
191 css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
192 if (xBroadcaster.is())
193 xBroadcaster->addSubmitListener(&m_aSubmitListeners);
195 if (m_aResetListeners.getLength())
197 css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
198 if (xBroadcaster.is())
199 xBroadcaster->addResetListener(&m_aResetListeners);
202 if (m_aParameterListeners.getLength())
204 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
205 if (xBroadcaster.is())
206 xBroadcaster->addParameterListener(&m_aParameterListeners);
209 if (m_aPropertyChangeListeners.getOverallLen())
211 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
212 if (xBroadcaster.is())
213 xBroadcaster->addPropertyChangeListener(OUString(), &m_aPropertyChangeListeners);
216 if (m_aVetoablePropertyChangeListeners.getOverallLen())
218 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
219 if (xBroadcaster.is())
220 xBroadcaster->addVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners);
223 if (m_aPropertiesChangeListeners.getLength())
225 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
226 if (xBroadcaster.is())
227 xBroadcaster->addPropertiesChangeListener(css::uno::Sequence<OUString>{""}, &m_aPropertiesChangeListeners);
230 // log off ourself
231 Reference< css::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
232 if (xComp.is())
233 xComp->addEventListener(static_cast<css::lang::XEventListener*>(static_cast<css::beans::XPropertyChangeListener*>(this)));
236 void SbaXFormAdapter::AttachForm(const Reference< css::sdbc::XRowSet >& xNewMaster)
238 if (xNewMaster == m_xMainForm)
239 return;
241 OSL_ENSURE(xNewMaster.get() != static_cast< css::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
243 if (m_xMainForm.is())
245 StopListening();
247 // if our old master is loaded we have to send an 'unloaded' event
248 Reference< css::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
249 if (xLoadable->isLoaded())
251 css::lang::EventObject aEvt(*this);
252 m_aLoadListeners.notifyEach( &css::form::XLoadListener::unloaded, aEvt );
256 m_xMainForm = xNewMaster;
258 if (!m_xMainForm.is())
259 return;
261 StartListening();
263 // if our new master is loaded we have to send an 'loaded' event
264 Reference< css::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
265 if (xLoadable->isLoaded())
267 css::lang::EventObject aEvt(*this);
268 m_aLoadListeners.notifyEach( &css::form::XLoadListener::loaded, aEvt );
271 // TODO : perhaps _all_ of our listeners should be notified about our new state
272 // (nearly every aspect of us may have changed with new master form)
275 // css::sdbc::XCloseable
276 void SAL_CALL SbaXFormAdapter::close()
278 Reference< css::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
279 if (xIface.is())
280 xIface->close();
283 // css::sdbc::XResultSetMetaDataSupplier
284 Reference< css::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData()
286 Reference< css::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
287 if (xIface.is())
288 return xIface->getMetaData();
289 return Reference< css::sdbc::XResultSetMetaData > ();
292 // css::sdbc::XColumnLocate
293 sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const OUString& columnName)
295 Reference< css::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
296 if (xIface.is())
297 return xIface->findColumn(columnName);
299 ::dbtools::throwInvalidColumnException( columnName, *this );
300 assert(false);
301 return 0; // Never reached
304 // css::sdbcx::XColumnsSupplier
305 Reference< css::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns()
307 Reference< css::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
308 if (xIface.is())
309 return xIface->getColumns();
310 return Reference< css::container::XNameAccess > ();
313 // css::sdbc::XRow
314 sal_Bool SAL_CALL SbaXFormAdapter::wasNull()
316 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
317 if (xIface.is())
318 return xIface->wasNull();
319 return true;
322 OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex)
324 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
325 if (xIface.is())
326 return xIface->getString(columnIndex);
327 return OUString();
330 sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex)
332 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
333 if (xIface.is())
334 return xIface->getBoolean(columnIndex);
335 return false;
338 sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex)
341 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
342 if (xIface.is())
343 return xIface->getByte(columnIndex);
344 return 0;
347 sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex)
349 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
350 if (xIface.is())
351 return xIface->getShort(columnIndex);
352 return 0;
355 sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex)
357 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
358 if (xIface.is())
359 return xIface->getInt(columnIndex);
360 return 0;
363 sal_Int64 SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex)
365 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
366 if (xIface.is())
367 return xIface->getLong(columnIndex);
368 return 0;
371 float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex)
373 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
374 if (xIface.is())
375 return xIface->getFloat(columnIndex);
376 return 0.0;
379 double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex)
381 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
382 if (xIface.is())
383 return xIface->getDouble(columnIndex);
384 return 0.0;
387 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex)
389 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
390 if (xIface.is())
391 return xIface->getBytes(columnIndex);
392 return Sequence <sal_Int8> ();
395 css::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex)
397 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
398 if (xIface.is())
399 return xIface->getDate(columnIndex);
400 return css::util::Date();
403 css::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex)
405 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
406 if (xIface.is())
407 return xIface->getTime(columnIndex);
408 return css::util::Time();
411 css::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex)
413 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
414 if (xIface.is())
415 return xIface->getTimestamp(columnIndex);
416 return css::util::DateTime();
419 Reference< css::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex)
421 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
422 if (xIface.is())
423 return xIface->getBinaryStream(columnIndex);
424 return Reference< css::io::XInputStream > ();
427 Reference< css::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex)
429 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
430 if (xIface.is())
431 return xIface->getCharacterStream(columnIndex);
432 return Reference< css::io::XInputStream > ();
435 Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap)
437 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
438 if (xIface.is())
439 return xIface->getObject(columnIndex, typeMap);
440 return Any();
443 Reference< css::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex)
445 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
446 if (xIface.is())
447 return xIface->getRef(columnIndex);
448 return Reference< css::sdbc::XRef > ();
451 Reference< css::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex)
453 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
454 if (xIface.is())
455 return xIface->getBlob(columnIndex);
456 return Reference< css::sdbc::XBlob > ();
459 Reference< css::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex)
461 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
462 if (xIface.is())
463 return xIface->getClob(columnIndex);
464 return Reference< css::sdbc::XClob > ();
467 Reference< css::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex)
469 Reference< css::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
470 if (xIface.is())
471 return xIface->getArray(columnIndex);
472 return Reference< css::sdbc::XArray > ();
475 // css::sdbcx::XRowLocate
476 Any SAL_CALL SbaXFormAdapter::getBookmark()
478 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
479 if (xIface.is())
480 return xIface->getBookmark();
481 return Any();
484 sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark)
486 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
487 if (xIface.is())
488 return xIface->moveToBookmark(bookmark);
489 return false;
492 sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows)
494 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
495 if (xIface.is())
496 return xIface->moveRelativeToBookmark(bookmark,rows);
497 return false;
500 sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second)
502 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
503 if (xIface.is())
504 return xIface->compareBookmarks(_first, _second);
505 return 0;
508 sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks()
510 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
511 if (xIface.is())
512 return xIface->hasOrderedBookmarks();
513 return false;
516 sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark)
518 Reference< css::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
519 if (xIface.is())
520 return xIface->hashBookmark(bookmark);
521 return 0;
524 // css::sdbc::XRowUpdate
525 void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex)
527 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
528 if (xIface.is())
529 xIface->updateNull(columnIndex);
532 void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x)
534 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
535 if (xIface.is())
536 xIface->updateBoolean(columnIndex, x);
539 void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x)
541 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
542 if (xIface.is())
543 xIface->updateByte(columnIndex, x);
546 void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x)
548 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
549 if (xIface.is())
550 xIface->updateShort(columnIndex, x);
553 void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x)
555 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
556 if (xIface.is())
557 xIface->updateInt(columnIndex, x);
560 void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x)
562 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
563 if (xIface.is())
564 xIface->updateLong(columnIndex, x);
567 void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x)
569 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
570 if (xIface.is())
571 xIface->updateFloat(columnIndex, x);
574 void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x)
576 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
577 if (xIface.is())
578 xIface->updateDouble(columnIndex, x);
581 void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const OUString& x)
583 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
584 if (xIface.is())
585 xIface->updateString(columnIndex, x);
588 void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x)
590 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
591 if (xIface.is())
592 xIface->updateBytes(columnIndex, x);
595 void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const css::util::Date& x)
597 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
598 if (xIface.is())
599 xIface->updateDate(columnIndex, x);
602 void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const css::util::Time& x)
604 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
605 if (xIface.is())
606 xIface->updateTime(columnIndex, x);
609 void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const css::util::DateTime& x)
611 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
612 if (xIface.is())
613 xIface->updateTimestamp(columnIndex, x);
616 void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length)
618 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
619 if (xIface.is())
620 xIface->updateBinaryStream(columnIndex, x, length);
623 void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length)
625 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
626 if (xIface.is())
627 xIface->updateCharacterStream(columnIndex, x, length);
630 void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x)
632 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
633 if (xIface.is())
634 xIface->updateObject(columnIndex, x);
637 void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale)
639 Reference< css::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
640 if (xIface.is())
641 xIface->updateNumericObject(columnIndex, x, scale);
644 // css::sdbc::XResultSet
645 sal_Bool SAL_CALL SbaXFormAdapter::next()
647 if (m_xMainForm.is())
648 return m_xMainForm->next();
649 return false;
652 sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst()
654 if (m_xMainForm.is())
655 return m_xMainForm->isBeforeFirst();
656 return false;
659 sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast()
661 if (m_xMainForm.is())
662 return m_xMainForm->isAfterLast();
663 return false;
666 sal_Bool SAL_CALL SbaXFormAdapter::isFirst()
668 if (m_xMainForm.is())
669 return m_xMainForm->isFirst();
670 return false;
673 sal_Bool SAL_CALL SbaXFormAdapter::isLast()
675 if (m_xMainForm.is())
676 return m_xMainForm->isLast();
677 return false;
680 void SAL_CALL SbaXFormAdapter::beforeFirst()
682 if (m_xMainForm.is())
683 m_xMainForm->beforeFirst();
686 void SAL_CALL SbaXFormAdapter::afterLast()
688 if (m_xMainForm.is())
689 m_xMainForm->afterLast();
692 sal_Bool SAL_CALL SbaXFormAdapter::first()
694 if (m_xMainForm.is())
695 return m_xMainForm->first();
696 return false;
699 sal_Bool SAL_CALL SbaXFormAdapter::last()
701 if (m_xMainForm.is())
702 return m_xMainForm->last();
703 return false;
706 sal_Int32 SAL_CALL SbaXFormAdapter::getRow()
708 if (m_xMainForm.is())
709 return m_xMainForm->getRow();
710 return 0;
713 sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row)
715 if (m_xMainForm.is())
716 return m_xMainForm->absolute(row);
717 return false;
720 sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows)
722 if (m_xMainForm.is())
723 return m_xMainForm->relative(rows);
724 return false;
727 sal_Bool SAL_CALL SbaXFormAdapter::previous()
729 if (m_xMainForm.is())
730 return m_xMainForm->previous();
731 return false;
734 void SAL_CALL SbaXFormAdapter::refreshRow()
736 if (m_xMainForm.is())
737 m_xMainForm->refreshRow();
740 sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated()
742 if (m_xMainForm.is())
743 return m_xMainForm->rowUpdated();
744 return false;
747 sal_Bool SAL_CALL SbaXFormAdapter::rowInserted()
749 if (m_xMainForm.is())
750 return m_xMainForm->rowInserted();
751 return false;
754 sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted()
756 if (m_xMainForm.is())
757 return m_xMainForm->rowDeleted();
758 return false;
761 Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement()
763 if (m_xMainForm.is())
764 return m_xMainForm->getStatement();
765 return nullptr;
768 // css::sdbc::XResultSetUpdate
769 void SAL_CALL SbaXFormAdapter::insertRow()
771 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
772 if (xIface.is())
773 xIface->insertRow();
776 void SAL_CALL SbaXFormAdapter::updateRow()
778 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
779 if (xIface.is())
780 xIface->updateRow();
783 void SAL_CALL SbaXFormAdapter::deleteRow()
785 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
786 if (xIface.is())
787 xIface->deleteRow();
790 void SAL_CALL SbaXFormAdapter::cancelRowUpdates()
792 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
793 if (xIface.is())
794 xIface->cancelRowUpdates();
797 void SAL_CALL SbaXFormAdapter::moveToInsertRow()
799 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
800 if (xIface.is())
801 xIface->moveToInsertRow();
804 void SAL_CALL SbaXFormAdapter::moveToCurrentRow()
806 Reference< css::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
807 if (xIface.is())
808 xIface->moveToCurrentRow();
811 // css::sdbc::XRowSet
812 void SAL_CALL SbaXFormAdapter::execute()
814 if (m_xMainForm.is())
815 m_xMainForm->execute();
818 void SAL_CALL SbaXFormAdapter::addRowSetListener(const css::uno::Reference< css::sdbc::XRowSetListener >& l)
820 m_aRowSetListeners.addInterface(l);
821 if (m_aRowSetListeners.getLength() == 1)
823 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
824 if (xBroadcaster.is())
825 xBroadcaster->addRowSetListener(&m_aRowSetListeners);
828 void SAL_CALL SbaXFormAdapter::removeRowSetListener(const css::uno::Reference< css::sdbc::XRowSetListener >& l)
830 if (m_aRowSetListeners.getLength() == 1)
832 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
833 if (xBroadcaster.is())
834 xBroadcaster->removeRowSetListener(&m_aRowSetListeners);
836 m_aRowSetListeners.removeInterface(l);
839 // css::sdbcx::XDeleteRows
840 Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows)
842 Reference< css::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
843 if (xIface.is())
844 return xIface->deleteRows(rows);
845 return Sequence<sal_Int32>();
848 // css::sdbc::XWarningsSupplier
849 Any SAL_CALL SbaXFormAdapter::getWarnings()
851 Reference< css::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
852 if (xIface.is())
853 return xIface->getWarnings();
854 return Any();
857 void SAL_CALL SbaXFormAdapter::clearWarnings()
859 Reference< css::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
860 if (xIface.is())
861 xIface->clearWarnings();
864 // css::sdb::XRowSetApproveBroadcaster
865 void SAL_CALL SbaXFormAdapter::addRowSetApproveListener(const css::uno::Reference< css::sdb::XRowSetApproveListener >& l)
867 m_aRowSetApproveListeners.addInterface(l);
868 if (m_aRowSetApproveListeners.getLength() == 1)
870 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
871 if (xBroadcaster.is())
872 xBroadcaster->addRowSetApproveListener(&m_aRowSetApproveListeners);
875 void SAL_CALL SbaXFormAdapter::removeRowSetApproveListener(const css::uno::Reference< css::sdb::XRowSetApproveListener >& l)
877 if (m_aRowSetApproveListeners.getLength() == 1)
879 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
880 if (xBroadcaster.is())
881 xBroadcaster->removeRowSetApproveListener(&m_aRowSetApproveListeners);
883 m_aRowSetApproveListeners.removeInterface(l);
886 // css::sdbc::XSQLErrorBroadcaster
887 void SAL_CALL SbaXFormAdapter::addSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener >& l)
889 m_aErrorListeners.addInterface(l);
890 if (m_aErrorListeners.getLength() == 1)
892 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
893 if (xBroadcaster.is())
894 xBroadcaster->addSQLErrorListener(&m_aErrorListeners);
897 void SAL_CALL SbaXFormAdapter::removeSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener >& l)
899 if (m_aErrorListeners.getLength() == 1)
901 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
902 if (xBroadcaster.is())
903 xBroadcaster->removeSQLErrorListener(&m_aErrorListeners);
905 m_aErrorListeners.removeInterface(l);
908 // css::sdb::XResultSetAccess
909 Reference< css::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet()
911 Reference< css::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
912 if (xIface.is())
913 return xIface->createResultSet();
914 return Reference< css::sdbc::XResultSet > ();
917 // css::form::XLoadable
918 void SAL_CALL SbaXFormAdapter::load()
920 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
921 if (xIface.is())
922 xIface->load();
925 void SAL_CALL SbaXFormAdapter::unload()
927 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
928 if (xIface.is())
929 xIface->unload();
932 void SAL_CALL SbaXFormAdapter::reload()
934 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
935 if (xIface.is())
936 xIface->reload();
939 sal_Bool SAL_CALL SbaXFormAdapter::isLoaded()
941 Reference< css::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
942 if (xIface.is())
943 return xIface->isLoaded();
944 return false;
947 void SAL_CALL SbaXFormAdapter::addLoadListener(const css::uno::Reference< css::form::XLoadListener>& l)
949 m_aLoadListeners.addInterface(l);
950 if (m_aLoadListeners.getLength() == 1)
952 css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
953 if (xBroadcaster.is())
954 xBroadcaster->addLoadListener(&m_aLoadListeners);
957 void SAL_CALL SbaXFormAdapter::removeLoadListener(const css::uno::Reference< css::form::XLoadListener >& l)
959 if (m_aLoadListeners.getLength() == 1)
961 css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
962 if (xBroadcaster.is())
963 xBroadcaster->removeLoadListener(&m_aLoadListeners);
965 m_aLoadListeners.removeInterface(l);
968 // css::sdbc::XParameters
969 void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType)
971 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
972 if (xIface.is())
973 xIface->setNull(parameterIndex, sqlType);
976 void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName)
978 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
979 if (xIface.is())
980 xIface->setObjectNull(parameterIndex, sqlType, typeName);
983 void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x)
985 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
986 if (xIface.is())
987 xIface->setBoolean(parameterIndex, x);
990 void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x)
992 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
993 if (xIface.is())
994 xIface->setByte(parameterIndex, x);
997 void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x)
999 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1000 if (xIface.is())
1001 xIface->setShort(parameterIndex, x);
1004 void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x)
1006 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1007 if (xIface.is())
1008 xIface->setInt(parameterIndex, x);
1011 void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x)
1013 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1014 if (xIface.is())
1015 xIface->setLong(parameterIndex, x);
1018 void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x)
1020 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1021 if (xIface.is())
1022 xIface->setFloat(parameterIndex, x);
1025 void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x)
1027 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1028 if (xIface.is())
1029 xIface->setDouble(parameterIndex, x);
1032 void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const OUString& x)
1034 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1035 if (xIface.is())
1036 xIface->setString(parameterIndex, x);
1039 void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x)
1041 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1042 if (xIface.is())
1043 xIface->setBytes(parameterIndex, x);
1046 void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const css::util::Date& x)
1048 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1049 if (xIface.is())
1050 xIface->setDate(parameterIndex, x);
1053 void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const css::util::Time& x)
1055 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1056 if (xIface.is())
1057 xIface->setTime(parameterIndex, x);
1060 void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime& x)
1062 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1063 if (xIface.is())
1064 xIface->setTimestamp(parameterIndex, x);
1067 void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length)
1069 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1070 if (xIface.is())
1071 xIface->setBinaryStream(parameterIndex, x, length);
1074 void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length)
1076 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1077 if (xIface.is())
1078 xIface->setCharacterStream(parameterIndex, x, length);
1081 void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x)
1083 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1084 if (xIface.is())
1085 xIface->setObject(parameterIndex, x);
1088 void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale)
1090 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1091 if (xIface.is())
1092 xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
1095 void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< css::sdbc::XRef >& x)
1097 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1098 if (xIface.is())
1099 xIface->setRef(parameterIndex, x);
1102 void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< css::sdbc::XBlob >& x)
1104 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1105 if (xIface.is())
1106 xIface->setBlob(parameterIndex, x);
1109 void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< css::sdbc::XClob >& x)
1111 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1112 if (xIface.is())
1113 xIface->setClob(parameterIndex, x);
1116 void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< css::sdbc::XArray >& x)
1118 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1119 if (xIface.is())
1120 xIface->setArray(parameterIndex, x);
1123 void SAL_CALL SbaXFormAdapter::clearParameters()
1125 Reference< css::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
1126 if (xIface.is())
1127 xIface->clearParameters();
1130 // css::form::XDatabaseParameterBroadcaster
1131 void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< css::form::XDatabaseParameterListener >& aListener)
1133 m_aParameterListeners.addInterface(aListener);
1134 if (m_aParameterListeners.getLength() == 1)
1136 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1137 if (xBroadcaster.is())
1138 xBroadcaster->addParameterListener(&m_aParameterListeners);
1142 void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< css::form::XDatabaseParameterListener >& aListener)
1144 if (m_aParameterListeners.getLength() == 1)
1146 Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
1147 if (xBroadcaster.is())
1148 xBroadcaster->removeParameterListener(&m_aParameterListeners);
1150 m_aParameterListeners.removeInterface(aListener);
1153 // css::container::XChild
1154 Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent()
1156 return m_xParent;
1159 void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent)
1161 m_xParent = Parent;
1164 // css::form::XSubmit
1165 void SAL_CALL SbaXFormAdapter::submit(const Reference< css::awt::XControl >& aControl, const css::awt::MouseEvent& aMouseEvt)
1167 Reference< css::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
1168 if (xSubmit.is())
1169 xSubmit->submit(aControl, aMouseEvt);
1172 void SAL_CALL SbaXFormAdapter::addSubmitListener(const css::uno::Reference< css::form::XSubmitListener >& l)
1174 m_aSubmitListeners.addInterface(l);
1175 if (m_aSubmitListeners.getLength() == 1)
1177 css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1178 if (xBroadcaster.is())
1179 xBroadcaster->addSubmitListener(&m_aSubmitListeners);
1182 void SAL_CALL SbaXFormAdapter::removeSubmitListener(const css::uno::Reference< css::form::XSubmitListener >& l)
1184 if (m_aSubmitListeners.getLength() == 1)
1186 css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1187 if (xBroadcaster.is())
1188 xBroadcaster->removeSubmitListener(&m_aSubmitListeners);
1190 m_aSubmitListeners.removeInterface(l);
1193 // css::awt::XTabControllerModel
1194 sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl()
1196 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1197 return false;
1200 void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/)
1202 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1205 void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< css::awt::XControlModel > >& /*Controls*/)
1207 OSL_FAIL("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1210 Sequence< Reference< css::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels()
1212 OSL_FAIL("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1213 return Sequence< Reference< css::awt::XControlModel > >();
1216 void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/, const OUString& /*GroupName*/)
1218 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1221 sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount()
1223 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1224 return 0;
1227 void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/, OUString& /*Name*/)
1229 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1232 void SAL_CALL SbaXFormAdapter::getGroupByName(const OUString& /*Name*/, Sequence< Reference< css::awt::XControlModel > >& /*_rGroup*/)
1234 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1237 // css::lang::XComponent
1238 void SAL_CALL SbaXFormAdapter::dispose()
1240 // log off all multiplexers
1241 if (m_xMainForm.is())
1242 StopListening();
1244 css::lang::EventObject aEvt(*this);
1245 m_aLoadListeners.disposeAndClear(aEvt);
1246 m_aRowSetListeners.disposeAndClear(aEvt);
1247 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1248 m_aErrorListeners.disposeAndClear(aEvt);
1249 m_aParameterListeners.disposeAndClear(aEvt);
1250 m_aSubmitListeners.disposeAndClear(aEvt);
1251 m_aResetListeners.disposeAndClear(aEvt);
1253 m_aVetoablePropertyChangeListeners.disposeAndClear();
1254 m_aPropertyChangeListeners.disposeAndClear();
1255 m_aPropertiesChangeListeners.disposeAndClear(aEvt);
1257 m_aDisposeListeners.disposeAndClear(aEvt);
1258 m_aContainerListeners.disposeAndClear(aEvt);
1260 // dispose all children
1261 for (auto const& child : m_aChildren)
1263 Reference< css::beans::XPropertySet > xSet(child, UNO_QUERY);
1264 if (xSet.is())
1265 xSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1267 Reference< css::container::XChild > xChild(child, UNO_QUERY);
1268 if (xChild.is())
1269 xChild->setParent(Reference< XInterface > ());
1271 Reference< css::lang::XComponent > xComp(child, UNO_QUERY);
1272 if (xComp.is())
1273 xComp->dispose();
1275 m_aChildren.clear();
1278 void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< css::lang::XEventListener >& xListener)
1280 m_aDisposeListeners.addInterface(xListener);
1283 void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< css::lang::XEventListener >& aListener)
1285 m_aDisposeListeners.removeInterface(aListener);
1288 // css::beans::XFastPropertySet
1289 void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue)
1291 Reference< css::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1292 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1294 if (m_nNamePropHandle == nHandle)
1296 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1298 throw css::lang::IllegalArgumentException();
1301 // for notifying property listeners
1302 css::beans::PropertyChangeEvent aEvt;
1303 aEvt.Source = *this;
1304 aEvt.PropertyName = PROPERTY_NAME;
1305 aEvt.PropertyHandle = m_nNamePropHandle;
1306 aEvt.OldValue <<= m_sName;
1307 aEvt.NewValue = aValue;
1309 aValue >>= m_sName;
1311 m_aPropertyChangeListeners.getContainer(PROPERTY_NAME)->notifyEach(
1312 &XPropertyChangeListener::propertyChange, aEvt );
1314 return;
1317 xSet->setFastPropertyValue(nHandle, aValue);
1320 Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle)
1322 Reference< css::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1323 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1325 if (m_nNamePropHandle == nHandle)
1326 return Any(m_sName);
1328 return xSet->getFastPropertyValue(nHandle);
1331 // css::container::XNamed
1332 OUString SAL_CALL SbaXFormAdapter::getName()
1334 return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
1337 void SAL_CALL SbaXFormAdapter::setName(const OUString& aName)
1339 setPropertyValue(PROPERTY_NAME, Any(aName));
1342 // css::io::XPersistObject
1343 OUString SAL_CALL SbaXFormAdapter::getServiceName()
1345 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1346 if (xPersist.is())
1347 return xPersist->getServiceName();
1348 return OUString();
1351 void SAL_CALL SbaXFormAdapter::write(const Reference< css::io::XObjectOutputStream >& _rxOutStream)
1353 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1354 if (xPersist.is())
1355 xPersist->write(_rxOutStream);
1358 void SAL_CALL SbaXFormAdapter::read(const Reference< css::io::XObjectInputStream >& _rxInStream)
1360 Reference< css::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1361 if (xPersist.is())
1362 xPersist->read(_rxInStream);
1365 // css::beans::XMultiPropertySet
1366 Reference< css::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo()
1368 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1369 if (!xSet.is())
1370 return Reference< css::beans::XPropertySetInfo > ();
1372 Reference< css::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
1373 if (-1 == m_nNamePropHandle)
1375 // we need to determine the handle for the NAME property
1376 const Sequence<css::beans::Property> aProps = xReturn->getProperties();
1377 for (const css::beans::Property& rProp : aProps)
1379 if (rProp.Name == PROPERTY_NAME)
1381 m_nNamePropHandle = rProp.Handle;
1382 break;
1386 return xReturn;
1389 void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< OUString >& PropertyNames, const Sequence< Any >& Values)
1391 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1392 if (xSet.is())
1393 xSet->setPropertyValues(PropertyNames, Values);
1396 Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< OUString >& aPropertyNames)
1398 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1399 if (!xSet.is())
1400 return Sequence< Any>(aPropertyNames.getLength());
1402 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1403 auto aReturnRange = asNonConstRange(aReturn);
1405 // search for (and fake) the NAME property
1406 OSL_ENSURE(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
1407 for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i)
1408 if (aPropertyNames[i] == PROPERTY_NAME)
1410 aReturnRange[i] <<= m_sName;
1411 break;
1414 return aReturn;
1417 void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< OUString>& /*aPropertyNames*/, const Reference< css::beans::XPropertiesChangeListener >& xListener)
1419 // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
1420 m_aPropertiesChangeListeners.addInterface(xListener);
1421 if (m_aPropertiesChangeListeners.getLength() == 1)
1423 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1424 if (xBroadcaster.is())
1425 xBroadcaster->addPropertiesChangeListener(Sequence< OUString>{""}, &m_aPropertiesChangeListeners);
1429 void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< css::beans::XPropertiesChangeListener >& Listener)
1431 if (m_aPropertiesChangeListeners.getLength() == 1)
1433 Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1434 if (xBroadcaster.is())
1435 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
1437 m_aPropertiesChangeListeners.removeInterface(Listener);
1440 void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< OUString >& aPropertyNames, const Reference< css::beans::XPropertiesChangeListener >& xListener)
1442 Reference< css::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1443 if (xSet.is())
1444 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1447 // css::beans::XPropertySet
1448 void SAL_CALL SbaXFormAdapter::setPropertyValue(const OUString& aPropertyName, const Any& aValue)
1450 Reference< css::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1451 if (!xSet.is())
1452 return;
1454 // special handling for the "name" property
1455 if (aPropertyName == PROPERTY_NAME)
1456 setFastPropertyValue(m_nNamePropHandle, aValue);
1458 xSet->setPropertyValue(aPropertyName, aValue);
1461 Any SAL_CALL SbaXFormAdapter::getPropertyValue(const OUString& PropertyName)
1463 Reference< css::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1464 if (!xSet.is())
1465 return Any();
1467 // special handling for the "name" property
1468 if (PropertyName == PROPERTY_NAME)
1469 return getFastPropertyValue(m_nNamePropHandle);
1471 return xSet->getPropertyValue(PropertyName);
1474 void SAL_CALL SbaXFormAdapter::addPropertyChangeListener(const OUString& rName, const css::uno::Reference< css::beans::XPropertyChangeListener>& l )
1476 m_aPropertyChangeListeners.addInterface(rName, l);
1477 if (m_aPropertyChangeListeners.getOverallLen() == 1)
1479 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1480 if (xBroadcaster.is())
1481 xBroadcaster->addPropertyChangeListener(OUString(), &m_aPropertyChangeListeners);
1484 void SAL_CALL SbaXFormAdapter::removePropertyChangeListener(const OUString& rName, const css::uno::Reference< css::beans::XPropertyChangeListener>& l )
1486 if (m_aPropertyChangeListeners.getOverallLen() == 1)
1488 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1489 if (xBroadcaster.is())
1490 xBroadcaster->removePropertyChangeListener(OUString(), &m_aPropertyChangeListeners);
1492 m_aPropertyChangeListeners.removeInterface(rName, l);
1495 void SAL_CALL SbaXFormAdapter::addVetoableChangeListener(const OUString& rName, const css::uno::Reference< css::beans::XVetoableChangeListener>& l )
1497 m_aVetoablePropertyChangeListeners.addInterface(rName, l);
1498 if (m_aVetoablePropertyChangeListeners.getOverallLen() == 1)
1500 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1501 if (xBroadcaster.is())
1502 xBroadcaster->addVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners);
1505 void SAL_CALL SbaXFormAdapter::removeVetoableChangeListener(const OUString& rName, const css::uno::Reference< css::beans::XVetoableChangeListener>& l )
1507 if (m_aVetoablePropertyChangeListeners.getOverallLen() == 1)
1509 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1510 if (xBroadcaster.is())
1511 xBroadcaster->removeVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners);
1513 m_aVetoablePropertyChangeListeners.removeInterface(rName, l);
1517 // css::util::XCancellable
1518 void SAL_CALL SbaXFormAdapter::cancel()
1520 Reference< css::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
1521 if (!xCancel.is())
1522 return;
1523 xCancel->cancel();
1526 // css::beans::XPropertyState
1527 css::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const OUString& PropertyName)
1529 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1530 if (xState.is())
1531 return xState->getPropertyState(PropertyName);
1532 return css::beans::PropertyState_DEFAULT_VALUE;
1535 Sequence< css::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< OUString >& aPropertyName)
1537 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1538 if (xState.is())
1539 return xState->getPropertyStates(aPropertyName);
1541 // set them all to DEFAULT
1542 Sequence< css::beans::PropertyState> aReturn(aPropertyName.getLength());
1543 for (css::beans::PropertyState& rState : asNonConstRange(aReturn))
1544 rState = css::beans::PropertyState_DEFAULT_VALUE;
1545 return aReturn;
1548 void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const OUString& PropertyName)
1550 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1551 if (xState.is())
1552 xState->setPropertyToDefault(PropertyName);
1555 Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const OUString& aPropertyName)
1557 Reference< css::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1558 if (xState.is())
1559 return xState->getPropertyDefault(aPropertyName);
1560 return Any();
1563 // css::form::XReset
1564 void SAL_CALL SbaXFormAdapter::reset()
1566 Reference< css::form::XReset > xReset(m_xMainForm, UNO_QUERY);
1567 if (xReset.is())
1568 xReset->reset();
1571 void SAL_CALL SbaXFormAdapter::addResetListener(const css::uno::Reference< css::form::XResetListener >& l)
1573 m_aResetListeners.addInterface(l);
1574 if (m_aResetListeners.getLength() == 1)
1576 css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1577 if (xBroadcaster.is())
1578 xBroadcaster->addResetListener(&m_aResetListeners);
1581 void SAL_CALL SbaXFormAdapter::removeResetListener(const css::uno::Reference< css::form::XResetListener >& l)
1583 if (m_aResetListeners.getLength() == 1)
1585 css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY);
1586 if (xBroadcaster.is())
1587 xBroadcaster->removeResetListener(&m_aResetListeners);
1589 m_aResetListeners.removeInterface(l);
1592 // css::container::XNameContainer
1593 void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OUString* pNewElName)
1595 // extract the form component
1596 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1598 throw css::lang::IllegalArgumentException();
1601 Reference< css::form::XFormComponent > xElement(aElement, UNO_QUERY);
1602 if (!xElement.is())
1604 throw css::lang::IllegalArgumentException();
1607 // for the name we need the propset
1608 Reference< css::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1609 if (!xElementSet.is())
1611 throw css::lang::IllegalArgumentException();
1613 OUString sName;
1616 if (pNewElName)
1617 xElementSet->setPropertyValue(PROPERTY_NAME, Any(*pNewElName));
1619 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1621 catch(Exception&)
1623 // the set didn't support the name prop
1624 throw css::lang::IllegalArgumentException();
1627 // check the index
1628 OSL_ASSERT(nIndex >= 0);
1629 if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
1630 nIndex = m_aChildren.size();
1632 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1633 m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
1634 m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
1636 // listen for a change of the name
1637 xElementSet->addPropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1639 // we are now the parent of the new element
1640 xElement->setParent(static_cast<css::container::XContainer*>(this));
1642 // notify the container listeners
1643 css::container::ContainerEvent aEvt;
1644 aEvt.Source = *this;
1645 aEvt.Accessor <<= nIndex;
1646 aEvt.Element <<= xElement;
1647 m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt );
1650 sal_Int32 SbaXFormAdapter::implGetPos(const OUString& rName)
1652 std::vector< OUString>::const_iterator aIter = std::find( m_aChildNames.begin(),
1653 m_aChildNames.end(),
1654 rName);
1656 if(aIter != m_aChildNames.end())
1657 return aIter - m_aChildNames.begin();
1659 return -1;
1662 void SAL_CALL SbaXFormAdapter::insertByName(const OUString& aName, const Any& aElement)
1664 implInsert(aElement, m_aChildren.size(), &aName);
1667 void SAL_CALL SbaXFormAdapter::removeByName(const OUString& Name)
1669 sal_Int32 nPos = implGetPos(Name);
1670 if (-1 == nPos)
1672 throw css::container::NoSuchElementException();
1674 removeByIndex(nPos);
1677 // css::container::XNameReplace
1678 void SAL_CALL SbaXFormAdapter::replaceByName(const OUString& aName, const Any& aElement)
1680 sal_Int32 nPos = implGetPos(aName);
1681 if (-1 == nPos)
1683 throw css::container::NoSuchElementException();
1685 replaceByIndex(nPos, aElement);
1688 // css::container::XNameAccess
1689 Any SAL_CALL SbaXFormAdapter::getByName(const OUString& aName)
1691 sal_Int32 nPos = implGetPos(aName);
1692 if (-1 == nPos)
1694 throw css::container::NoSuchElementException();
1696 return Any(m_aChildren[nPos]);
1699 Sequence< OUString > SAL_CALL SbaXFormAdapter::getElementNames()
1701 return Sequence< OUString >(m_aChildNames.data(), m_aChildNames.size());
1704 sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const OUString& aName)
1706 return (-1 != implGetPos(aName));
1709 // css::container::XElementAccess
1710 Type SAL_CALL SbaXFormAdapter::getElementType()
1712 return cppu::UnoType<css::form::XFormComponent>::get();
1715 sal_Bool SAL_CALL SbaXFormAdapter::hasElements()
1717 return !m_aChildren.empty();
1720 // css::container::XIndexContainer
1721 void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element)
1723 if ( ( _rIndex < 0 ) || ( o3tl::make_unsigned(_rIndex) >= m_aChildren.size() ) )
1724 throw css::lang::IndexOutOfBoundsException();
1725 implInsert(Element, _rIndex);
1728 void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex)
1730 if ( ( _rIndex < 0 ) || ( o3tl::make_unsigned(_rIndex) >= m_aChildren.size() ) )
1731 throw css::lang::IndexOutOfBoundsException();
1733 Reference< css::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
1735 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1736 m_aChildren.erase(m_aChildren.begin() + _rIndex);
1737 m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
1739 // no need to listen anymore
1740 Reference< css::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
1741 xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1743 // we are no longer the parent
1744 xAffected->setParent(Reference< XInterface > ());
1746 // notify container listeners
1747 css::container::ContainerEvent aEvt;
1748 aEvt.Source = *this;
1749 aEvt.Element <<= xAffected;
1750 m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt );
1753 // css::container::XIndexReplace
1754 void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element)
1756 if ( ( _rIndex < 0 ) || ( o3tl::make_unsigned(_rIndex) >= m_aChildren.size() ) )
1757 throw css::lang::IndexOutOfBoundsException();
1759 // extract the form component
1760 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1762 throw css::lang::IllegalArgumentException();
1765 Reference< css::form::XFormComponent > xElement(Element, UNO_QUERY);
1766 if (!xElement.is())
1768 throw css::lang::IllegalArgumentException();
1771 // for the name we need the propset
1772 Reference< css::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1773 if (!xElementSet.is())
1775 throw css::lang::IllegalArgumentException();
1777 OUString sName;
1780 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1782 catch(Exception&)
1784 // the set didn't support the name prop
1785 throw css::lang::IllegalArgumentException();
1788 Reference< css::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
1790 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1791 *(m_aChildren.begin() + _rIndex) = xElement;
1792 *(m_aChildNames.begin() + _rIndex) = sName;
1794 // correct property change listening
1795 Reference< css::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
1796 xOldSet->removePropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1797 xElementSet->addPropertyChangeListener(PROPERTY_NAME, static_cast<css::beans::XPropertyChangeListener*>(this));
1799 // parent reset
1800 xOld->setParent(Reference< XInterface > ());
1801 xElement->setParent(static_cast<css::container::XContainer*>(this));
1803 // notify container listeners
1804 css::container::ContainerEvent aEvt;
1805 aEvt.Source = *this;
1806 aEvt.Accessor <<= _rIndex;
1807 aEvt.Element <<= xElement;
1808 aEvt.ReplacedElement <<= xOld;
1810 m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvt );
1813 // css::container::XIndexAccess
1814 sal_Int32 SAL_CALL SbaXFormAdapter::getCount()
1816 return m_aChildren.size();
1819 Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex)
1821 if ( ( _rIndex < 0 ) || ( o3tl::make_unsigned(_rIndex) >= m_aChildren.size() ) )
1822 throw css::lang::IndexOutOfBoundsException();
1824 Reference< css::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
1825 return Any(xElement);
1828 // css::container::XContainer
1829 void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< css::container::XContainerListener >& xListener)
1831 m_aContainerListeners.addInterface(xListener);
1834 void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< css::container::XContainerListener >& xListener)
1836 m_aContainerListeners.removeInterface(xListener);
1839 // css::container::XEnumerationAccess
1840 Reference< css::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration()
1842 return new ::comphelper::OEnumerationByName(this);
1845 // css::beans::XPropertyChangeListener
1846 void SAL_CALL SbaXFormAdapter::propertyChange(const css::beans::PropertyChangeEvent& evt)
1848 if (evt.PropertyName != PROPERTY_NAME)
1849 return;
1851 std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = std::find_if( m_aChildren.begin(),
1852 m_aChildren.end(),
1853 [&evt](css::uno::Reference< css::uno::XInterface > const & x) { return x == evt.Source; });
1855 if(aIter != m_aChildren.end())
1857 sal_Int32 nPos = aIter - m_aChildren.begin();
1858 OSL_ENSURE(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1859 *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
1863 // css::lang::XEventListener
1864 void SAL_CALL SbaXFormAdapter::disposing(const css::lang::EventObject& Source)
1866 // was it our main form ?
1867 if (Source.Source == m_xMainForm)
1868 dispose();
1870 std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = std::find_if( m_aChildren.begin(),
1871 m_aChildren.end(),
1872 [&Source](css::uno::Reference< css::uno::XInterface > const & x) { return x == Source.Source; });
1873 if(aIter != m_aChildren.end())
1874 removeByIndex(aIter - m_aChildren.begin());
1877 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */