fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / browser / formadapter.cxx
blob5b2fbb54c2e96ace71d66bf77bada996c8347df0
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, ::com::sun::star::form::XLoadable, m_xMainForm);
95 STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
96 STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
97 STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
98 STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
99 STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
101 if (m_aParameterListeners.getLength())
103 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
104 if (xBroadcaster.is())
105 xBroadcaster->removeParameterListener(&m_aParameterListeners);
108 STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
109 STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
110 if (m_aPropertiesChangeListeners.getLength())
112 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
113 if (xBroadcaster.is())
114 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
117 // log off ourself
118 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
119 if (xComp.is())
120 xComp->removeEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
123 void SbaXFormAdapter::StartListening()
125 // log off all our multiplexers
126 START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
127 START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
128 START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
129 START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
130 START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
131 START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
133 if (m_aParameterListeners.getLength())
135 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
136 if (xBroadcaster.is())
137 xBroadcaster->addParameterListener(&m_aParameterListeners);
140 START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
141 START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
142 if (m_aPropertiesChangeListeners.getLength())
144 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
145 OUString sEmpty;
146 if (xBroadcaster.is())
147 xBroadcaster->addPropertiesChangeListener(::comphelper::StringSequence(&sEmpty, 1), &m_aPropertiesChangeListeners);
150 // log off ourself
151 Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
152 if (xComp.is())
153 xComp->addEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
156 void SbaXFormAdapter::AttachForm(const Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster)
158 if (xNewMaster == m_xMainForm)
159 return;
161 OSL_ENSURE(xNewMaster.get() != static_cast< ::com::sun::star::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
163 if (m_xMainForm.is())
165 StopListening();
167 // if our old master is loaded we have to send an 'unloaded' event
168 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
169 if (xLoadable->isLoaded())
171 ::com::sun::star::lang::EventObject aEvt(*this);
172 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
173 while (aIt.hasMoreElements())
174 static_cast< ::com::sun::star::form::XLoadListener*>(aIt.next())->unloaded(aEvt);
178 m_xMainForm = xNewMaster;
180 if (m_xMainForm.is())
182 StartListening();
184 // if our new master is loaded we have to send an 'loaded' event
185 Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
186 if (xLoadable->isLoaded())
188 ::com::sun::star::lang::EventObject aEvt(*this);
189 ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
190 while (aIt.hasMoreElements())
191 static_cast< ::com::sun::star::form::XLoadListener*>(aIt.next())->loaded(aEvt);
195 // TODO : perhaps _all_ of our listeners should be notified about our new state
196 // (nearly every aspect of us may have changed with new master form)
199 // ::com::sun::star::sdbc::XCloseable
200 void SAL_CALL SbaXFormAdapter::close() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
202 Reference< ::com::sun::star::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
203 if (xIface.is())
204 xIface->close();
207 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
208 Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
210 Reference< ::com::sun::star::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
211 if (xIface.is())
212 return xIface->getMetaData();
213 return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ();
216 // ::com::sun::star::sdbc::XColumnLocate
217 sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const OUString& columnName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
219 Reference< ::com::sun::star::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
220 if (xIface.is())
221 return xIface->findColumn(columnName);
223 ::dbtools::throwInvalidColumnException( columnName, *this );
224 assert(false);
225 return 0; // Never reached
228 // ::com::sun::star::sdbcx::XColumnsSupplier
229 Reference< ::com::sun::star::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException, std::exception )
231 Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
232 if (xIface.is())
233 return xIface->getColumns();
234 return Reference< ::com::sun::star::container::XNameAccess > ();
237 // ::com::sun::star::sdbc::XRow
238 sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
240 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
241 if (xIface.is())
242 return xIface->wasNull();
243 return sal_True;
246 OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
248 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
249 if (xIface.is())
250 return xIface->getString(columnIndex);
251 return OUString();
254 sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
256 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
257 if (xIface.is())
258 return xIface->getBoolean(columnIndex);
259 return sal_False;
262 sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
265 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
266 if (xIface.is())
267 return xIface->getByte(columnIndex);
268 return 0;
271 sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
273 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
274 if (xIface.is())
275 return xIface->getShort(columnIndex);
276 return 0;
279 sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
281 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
282 if (xIface.is())
283 return xIface->getInt(columnIndex);
284 return 0;
287 sal_Int64 SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
289 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
290 if (xIface.is())
291 return xIface->getLong(columnIndex);
292 return 0;
295 float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
297 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
298 if (xIface.is())
299 return xIface->getFloat(columnIndex);
300 return 0.0;
303 double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
305 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
306 if (xIface.is())
307 return xIface->getDouble(columnIndex);
308 return 0.0;
311 Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
313 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
314 if (xIface.is())
315 return xIface->getBytes(columnIndex);
316 return Sequence <sal_Int8> ();
319 ::com::sun::star::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
321 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
322 if (xIface.is())
323 return xIface->getDate(columnIndex);
324 return ::com::sun::star::util::Date();
327 ::com::sun::star::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
329 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
330 if (xIface.is())
331 return xIface->getTime(columnIndex);
332 return ::com::sun::star::util::Time();
335 ::com::sun::star::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
337 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
338 if (xIface.is())
339 return xIface->getTimestamp(columnIndex);
340 return ::com::sun::star::util::DateTime();
343 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
345 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
346 if (xIface.is())
347 return xIface->getBinaryStream(columnIndex);
348 return Reference< ::com::sun::star::io::XInputStream > ();
351 Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
353 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
354 if (xIface.is())
355 return xIface->getCharacterStream(columnIndex);
356 return Reference< ::com::sun::star::io::XInputStream > ();
359 Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
361 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
362 if (xIface.is())
363 return xIface->getObject(columnIndex, typeMap);
364 return Any();
367 Reference< ::com::sun::star::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
369 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
370 if (xIface.is())
371 return xIface->getRef(columnIndex);
372 return Reference< ::com::sun::star::sdbc::XRef > ();
375 Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
377 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
378 if (xIface.is())
379 return xIface->getBlob(columnIndex);
380 return Reference< ::com::sun::star::sdbc::XBlob > ();
383 Reference< ::com::sun::star::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
385 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
386 if (xIface.is())
387 return xIface->getClob(columnIndex);
388 return Reference< ::com::sun::star::sdbc::XClob > ();
391 Reference< ::com::sun::star::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
393 Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
394 if (xIface.is())
395 return xIface->getArray(columnIndex);
396 return Reference< ::com::sun::star::sdbc::XArray > ();
399 // ::com::sun::star::sdbcx::XRowLocate
400 Any SAL_CALL SbaXFormAdapter::getBookmark() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
402 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
403 if (xIface.is())
404 return xIface->getBookmark();
405 return Any();
408 sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
410 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
411 if (xIface.is())
412 return xIface->moveToBookmark(bookmark);
413 return sal_False;
416 sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
418 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
419 if (xIface.is())
420 return xIface->moveRelativeToBookmark(bookmark,rows);
421 return sal_False;
424 sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
426 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
427 if (xIface.is())
428 return xIface->compareBookmarks(_first, _second);
429 return 0;
432 sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
434 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
435 if (xIface.is())
436 return xIface->hasOrderedBookmarks();
437 return sal_False;
440 sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
442 Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
443 if (xIface.is())
444 return xIface->hashBookmark(bookmark);
445 return 0;
448 // ::com::sun::star::sdbc::XRowUpdate
449 void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
451 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
452 if (xIface.is())
453 xIface->updateNull(columnIndex);
456 void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
458 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
459 if (xIface.is())
460 xIface->updateBoolean(columnIndex, x);
463 void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
465 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
466 if (xIface.is())
467 xIface->updateByte(columnIndex, x);
470 void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
472 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
473 if (xIface.is())
474 xIface->updateShort(columnIndex, x);
477 void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
479 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
480 if (xIface.is())
481 xIface->updateInt(columnIndex, x);
484 void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
486 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
487 if (xIface.is())
488 xIface->updateLong(columnIndex, x);
491 void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
493 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
494 if (xIface.is())
495 xIface->updateFloat(columnIndex, x);
498 void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
500 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
501 if (xIface.is())
502 xIface->updateDouble(columnIndex, x);
505 void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
507 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
508 if (xIface.is())
509 xIface->updateString(columnIndex, x);
512 void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
514 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
515 if (xIface.is())
516 xIface->updateBytes(columnIndex, x);
519 void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
521 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
522 if (xIface.is())
523 xIface->updateDate(columnIndex, x);
526 void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
528 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
529 if (xIface.is())
530 xIface->updateTime(columnIndex, x);
533 void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
535 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
536 if (xIface.is())
537 xIface->updateTimestamp(columnIndex, x);
540 void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
542 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
543 if (xIface.is())
544 xIface->updateBinaryStream(columnIndex, x, length);
547 void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
549 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
550 if (xIface.is())
551 xIface->updateCharacterStream(columnIndex, x, length);
554 void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
556 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
557 if (xIface.is())
558 xIface->updateObject(columnIndex, x);
561 void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
563 Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
564 if (xIface.is())
565 xIface->updateNumericObject(columnIndex, x, scale);
568 // ::com::sun::star::sdbc::XResultSet
569 sal_Bool SAL_CALL SbaXFormAdapter::next() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
571 if (m_xMainForm.is())
572 return m_xMainForm->next();
573 return sal_False;
576 sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
578 if (m_xMainForm.is())
579 return m_xMainForm->isBeforeFirst();
580 return sal_False;
583 sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
585 if (m_xMainForm.is())
586 return m_xMainForm->isAfterLast();
587 return sal_False;
590 sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
592 if (m_xMainForm.is())
593 return m_xMainForm->isFirst();
594 return sal_False;
597 sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
599 if (m_xMainForm.is())
600 return m_xMainForm->isLast();
601 return sal_False;
604 void SAL_CALL SbaXFormAdapter::beforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
606 if (m_xMainForm.is())
607 m_xMainForm->beforeFirst();
610 void SAL_CALL SbaXFormAdapter::afterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
612 if (m_xMainForm.is())
613 m_xMainForm->afterLast();
616 sal_Bool SAL_CALL SbaXFormAdapter::first() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
618 if (m_xMainForm.is())
619 return m_xMainForm->first();
620 return sal_False;
623 sal_Bool SAL_CALL SbaXFormAdapter::last() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
625 if (m_xMainForm.is())
626 return m_xMainForm->last();
627 return sal_False;
630 sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
632 if (m_xMainForm.is())
633 return m_xMainForm->getRow();
634 return 0;
637 sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
639 if (m_xMainForm.is())
640 return m_xMainForm->absolute(row);
641 return sal_False;
644 sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
646 if (m_xMainForm.is())
647 return m_xMainForm->relative(rows);
648 return sal_False;
651 sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
653 if (m_xMainForm.is())
654 return m_xMainForm->previous();
655 return sal_False;
658 void SAL_CALL SbaXFormAdapter::refreshRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
660 if (m_xMainForm.is())
661 m_xMainForm->refreshRow();
664 sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
666 if (m_xMainForm.is())
667 return m_xMainForm->rowUpdated();
668 return sal_False;
671 sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
673 if (m_xMainForm.is())
674 return m_xMainForm->rowInserted();
675 return sal_False;
678 sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
680 if (m_xMainForm.is())
681 return m_xMainForm->rowDeleted();
682 return sal_False;
685 Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
687 if (m_xMainForm.is())
688 return m_xMainForm->getStatement();
689 return NULL;
692 // ::com::sun::star::sdbc::XResultSetUpdate
693 void SAL_CALL SbaXFormAdapter::insertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
695 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
696 if (xIface.is())
697 xIface->insertRow();
700 void SAL_CALL SbaXFormAdapter::updateRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
702 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
703 if (xIface.is())
704 xIface->updateRow();
707 void SAL_CALL SbaXFormAdapter::deleteRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
709 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
710 if (xIface.is())
711 xIface->deleteRow();
714 void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
716 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
717 if (xIface.is())
718 xIface->cancelRowUpdates();
721 void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
723 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
724 if (xIface.is())
725 xIface->moveToInsertRow();
728 void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
730 Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
731 if (xIface.is())
732 xIface->moveToCurrentRow();
735 // ::com::sun::star::sdbc::XRowSet
736 void SAL_CALL SbaXFormAdapter::execute() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
738 if (m_xMainForm.is())
739 m_xMainForm->execute();
742 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm)
744 // ::com::sun::star::sdbcx::XDeleteRows
745 Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
747 Reference< ::com::sun::star::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
748 if (xIface.is())
749 return xIface->deleteRows(rows);
750 return Sequence<sal_Int32>();
753 // ::com::sun::star::sdbc::XWarningsSupplier
754 Any SAL_CALL SbaXFormAdapter::getWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
756 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
757 if (xIface.is())
758 return xIface->getWarnings();
759 return Any();
762 void SAL_CALL SbaXFormAdapter::clearWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
764 Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
765 if (xIface.is())
766 xIface->clearWarnings();
769 // ::com::sun::star::sdb::XRowSetApproveBroadcaster
770 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm)
772 // com::sun::star::sdbc::XSQLErrorBroadcaster
773 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm)
775 // ::com::sun::star::sdb::XResultSetAccess
776 Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
778 Reference< ::com::sun::star::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
779 if (xIface.is())
780 return xIface->createResultSet();
781 return Reference< ::com::sun::star::sdbc::XResultSet > ();
784 // com::sun::star::form::XLoadable
785 void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException, std::exception )
787 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
788 if (xIface.is())
789 xIface->load();
792 void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException, std::exception )
794 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
795 if (xIface.is())
796 xIface->unload();
799 void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException, std::exception )
801 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
802 if (xIface.is())
803 xIface->reload();
806 sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException, std::exception )
808 Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
809 if (xIface.is())
810 return xIface->isLoaded();
811 return sal_False;
814 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm)
816 // ::com::sun::star::sdbc::XParameters
817 void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
819 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
820 if (xIface.is())
821 xIface->setNull(parameterIndex, sqlType);
824 void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
826 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
827 if (xIface.is())
828 xIface->setObjectNull(parameterIndex, sqlType, typeName);
831 void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
833 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
834 if (xIface.is())
835 xIface->setBoolean(parameterIndex, x);
838 void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
840 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
841 if (xIface.is())
842 xIface->setByte(parameterIndex, x);
845 void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
847 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
848 if (xIface.is())
849 xIface->setShort(parameterIndex, x);
852 void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
854 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
855 if (xIface.is())
856 xIface->setInt(parameterIndex, x);
859 void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
861 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
862 if (xIface.is())
863 xIface->setLong(parameterIndex, x);
866 void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
868 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
869 if (xIface.is())
870 xIface->setFloat(parameterIndex, x);
873 void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
875 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
876 if (xIface.is())
877 xIface->setDouble(parameterIndex, x);
880 void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
882 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
883 if (xIface.is())
884 xIface->setString(parameterIndex, x);
887 void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
889 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
890 if (xIface.is())
891 xIface->setBytes(parameterIndex, x);
894 void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
896 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
897 if (xIface.is())
898 xIface->setDate(parameterIndex, x);
901 void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
903 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
904 if (xIface.is())
905 xIface->setTime(parameterIndex, x);
908 void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
910 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
911 if (xIface.is())
912 xIface->setTimestamp(parameterIndex, x);
915 void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
917 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
918 if (xIface.is())
919 xIface->setBinaryStream(parameterIndex, x, length);
922 void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
924 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
925 if (xIface.is())
926 xIface->setCharacterStream(parameterIndex, x, length);
929 void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
931 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
932 if (xIface.is())
933 xIface->setObject(parameterIndex, x);
936 void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
938 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
939 if (xIface.is())
940 xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
943 void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XRef >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
945 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
946 if (xIface.is())
947 xIface->setRef(parameterIndex, x);
950 void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XBlob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
952 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
953 if (xIface.is())
954 xIface->setBlob(parameterIndex, x);
957 void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XClob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
959 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
960 if (xIface.is())
961 xIface->setClob(parameterIndex, x);
964 void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XArray >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
966 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
967 if (xIface.is())
968 xIface->setArray(parameterIndex, x);
971 void SAL_CALL SbaXFormAdapter::clearParameters() throw( ::com::sun::star::sdbc::SQLException, RuntimeException, std::exception )
973 Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
974 if (xIface.is())
975 xIface->clearParameters();
978 // ::com::sun::star::form::XDatabaseParameterBroadcaster
979 void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException, std::exception )
981 m_aParameterListeners.addInterface(aListener);
982 if (m_aParameterListeners.getLength() == 1)
984 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
985 if (xBroadcaster.is())
986 xBroadcaster->addParameterListener(&m_aParameterListeners);
990 void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException, std::exception )
992 if (m_aParameterListeners.getLength() == 1)
994 Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
995 if (xBroadcaster.is())
996 xBroadcaster->removeParameterListener(&m_aParameterListeners);
998 m_aParameterListeners.removeInterface(aListener);
1001 // ::com::sun::star::container::XChild
1002 Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException, std::exception )
1004 return m_xParent;
1007 void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( ::com::sun::star::lang::NoSupportException, RuntimeException, std::exception )
1009 m_xParent = Parent;
1012 // ::com::sun::star::form::XSubmit
1013 void SAL_CALL SbaXFormAdapter::submit(const Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw( RuntimeException, std::exception )
1015 Reference< ::com::sun::star::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
1016 if (xSubmit.is())
1017 xSubmit->submit(aControl, aMouseEvt);
1020 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm)
1022 // ::com::sun::star::awt::XTabControllerModel
1023 sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException, std::exception )
1025 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1026 return sal_False;
1029 void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException, std::exception )
1031 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1034 void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*Controls*/) throw( RuntimeException, std::exception )
1036 OSL_FAIL("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1039 Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException, std::exception )
1041 OSL_FAIL("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1042 return Sequence< Reference< ::com::sun::star::awt::XControlModel > >();
1045 void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, const OUString& /*GroupName*/) throw( RuntimeException, std::exception )
1047 OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1050 sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException, std::exception )
1052 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1053 return 0;
1056 void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, OUString& /*Name*/) throw( RuntimeException, std::exception )
1058 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1061 void SAL_CALL SbaXFormAdapter::getGroupByName(const OUString& /*Name*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/) throw( RuntimeException, std::exception )
1063 OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1066 // ::com::sun::star::lang::XComponent
1067 void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException, std::exception )
1069 // log off all multiplexers
1070 if (m_xMainForm.is())
1071 StopListening();
1073 ::com::sun::star::lang::EventObject aEvt(*this);
1074 m_aLoadListeners.disposeAndClear(aEvt);
1075 m_aRowSetListeners.disposeAndClear(aEvt);
1076 m_aRowSetApproveListeners.disposeAndClear(aEvt);
1077 m_aErrorListeners.disposeAndClear(aEvt);
1078 m_aParameterListeners.disposeAndClear(aEvt);
1079 m_aSubmitListeners.disposeAndClear(aEvt);
1080 m_aResetListeners.disposeAndClear(aEvt);
1082 m_aVetoablePropertyChangeListeners.disposeAndClear();
1083 m_aPropertyChangeListeners.disposeAndClear();
1084 m_aPropertiesChangeListeners.disposeAndClear(aEvt);
1086 m_aDisposeListeners.disposeAndClear(aEvt);
1087 m_aContainerListeners.disposeAndClear(aEvt);
1089 // dispose all children
1090 for ( ::std::vector< Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = m_aChildren.begin();
1091 aIter != m_aChildren.end();
1092 ++aIter
1095 Reference< ::com::sun::star::beans::XPropertySet > xSet(*aIter, UNO_QUERY);
1096 if (xSet.is())
1097 xSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1099 Reference< ::com::sun::star::container::XChild > xChild(*aIter, UNO_QUERY);
1100 if (xChild.is())
1101 xChild->setParent(Reference< XInterface > ());
1103 Reference< ::com::sun::star::lang::XComponent > xComp(*aIter, UNO_QUERY);
1104 if (xComp.is())
1105 xComp->dispose();
1107 m_aChildren.clear();
1110 void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< ::com::sun::star::lang::XEventListener >& xListener) throw( RuntimeException, std::exception )
1112 m_aDisposeListeners.addInterface(xListener);
1115 void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener >& aListener) throw( RuntimeException, std::exception )
1117 m_aDisposeListeners.removeInterface(aListener);
1120 // ::com::sun::star::beans::XFastPropertySet
1121 void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1123 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1124 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1126 if (m_nNamePropHandle == nHandle)
1128 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1130 throw ::com::sun::star::lang::IllegalArgumentException();
1133 // for notifying property listeners
1134 ::com::sun::star::beans::PropertyChangeEvent aEvt;
1135 aEvt.Source = *this;
1136 aEvt.PropertyName = PROPERTY_NAME;
1137 aEvt.PropertyHandle = m_nNamePropHandle;
1138 aEvt.OldValue <<= m_sName;
1139 aEvt.NewValue = aValue;
1141 aValue >>= m_sName;
1143 ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME));
1144 while (aIt.hasMoreElements())
1145 static_cast< ::com::sun::star::beans::XPropertyChangeListener*>(aIt.next())->propertyChange(aEvt);
1147 return;
1150 xSet->setFastPropertyValue(nHandle, aValue);
1153 Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1155 Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
1156 OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1158 if (m_nNamePropHandle == nHandle)
1159 return makeAny(m_sName);
1161 return xSet->getFastPropertyValue(nHandle);
1164 // ::com::sun::star::container::XNamed
1165 OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException, std::exception )
1167 return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
1170 void SAL_CALL SbaXFormAdapter::setName(const OUString& aName) throw( RuntimeException, std::exception )
1172 setPropertyValue(PROPERTY_NAME, makeAny(aName));
1175 // ::com::sun::star::io::XPersistObject
1176 OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException, std::exception )
1178 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1179 if (xPersist.is())
1180 return xPersist->getServiceName();
1181 return OUString();
1184 void SAL_CALL SbaXFormAdapter::write(const Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw( ::com::sun::star::io::IOException, RuntimeException, std::exception )
1186 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1187 if (xPersist.is())
1188 xPersist->write(_rxOutStream);
1191 void SAL_CALL SbaXFormAdapter::read(const Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw( ::com::sun::star::io::IOException, RuntimeException, std::exception )
1193 Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
1194 if (xPersist.is())
1195 xPersist->read(_rxInStream);
1198 // ::com::sun::star::beans::XMultiPropertySet
1199 Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException, std::exception )
1201 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1202 if (!xSet.is())
1203 return Reference< ::com::sun::star::beans::XPropertySetInfo > ();
1205 Reference< ::com::sun::star::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
1206 if (-1 == m_nNamePropHandle)
1208 // we need to determine the handle for the NAME property
1209 Sequence< ::com::sun::star::beans::Property> aProps = xReturn->getProperties();
1210 const ::com::sun::star::beans::Property* pProps = aProps.getConstArray();
1212 for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
1214 if (pProps->Name == PROPERTY_NAME)
1216 m_nNamePropHandle = pProps->Handle;
1217 break;
1221 return xReturn;
1224 void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< OUString >& PropertyNames, const Sequence< Any >& Values) throw( ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1226 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1227 if (xSet.is())
1228 xSet->setPropertyValues(PropertyNames, Values);
1231 Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< OUString >& aPropertyNames) throw( RuntimeException, std::exception )
1233 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1234 if (!xSet.is())
1235 return Sequence< Any>(aPropertyNames.getLength());
1237 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1239 // search for (and fake) the NAME property
1240 const OUString* pNames = aPropertyNames.getConstArray();
1241 Any* pValues = aReturn.getArray();
1242 OSL_ENSURE(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
1243 for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues)
1244 if (*pNames == PROPERTY_NAME)
1246 (*pValues) <<= m_sName;
1247 break;
1250 return aReturn;
1253 void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< OUString>& /*aPropertyNames*/, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException, std::exception )
1255 // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
1256 m_aPropertiesChangeListeners.addInterface(xListener);
1257 if (m_aPropertiesChangeListeners.getLength() == 1)
1259 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1260 OUString sEmpty;
1261 if (xBroadcaster.is())
1262 xBroadcaster->addPropertiesChangeListener(Sequence< OUString>(&sEmpty, 1), &m_aPropertiesChangeListeners);
1266 void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException, std::exception )
1268 if (m_aPropertiesChangeListeners.getLength() == 1)
1270 Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
1271 if (xBroadcaster.is())
1272 xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
1274 m_aPropertiesChangeListeners.removeInterface(Listener);
1277 void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< OUString >& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException, std::exception )
1279 Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
1280 if (xSet.is())
1281 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1284 // ::com::sun::star::beans::XPropertySet
1285 void SAL_CALL SbaXFormAdapter::setPropertyValue(const OUString& aPropertyName, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1287 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1288 if (!xSet.is())
1289 return;
1291 // special handling for the "name" property
1292 if (aPropertyName == PROPERTY_NAME)
1293 setFastPropertyValue(m_nNamePropHandle, aValue);
1295 xSet->setPropertyValue(aPropertyName, aValue);
1298 Any SAL_CALL SbaXFormAdapter::getPropertyValue(const OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1300 Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
1301 if (!xSet.is())
1302 return Any();
1304 // special handling for the "name" property
1305 if (PropertyName == PROPERTY_NAME)
1306 return getFastPropertyValue(m_nNamePropHandle);
1308 return xSet->getPropertyValue(PropertyName);
1311 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1312 IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
1314 // ::com::sun::star::util::XCancellable
1315 void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException, std::exception )
1317 Reference< ::com::sun::star::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
1318 if (xCancel.is())
1319 return;
1320 xCancel->cancel();
1323 // ::com::sun::star::beans::XPropertyState
1324 ::com::sun::star::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException, std::exception )
1326 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1327 if (xState.is())
1328 return xState->getPropertyState(PropertyName);
1329 return ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1332 Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< OUString >& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException, std::exception )
1334 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1335 if (xState.is())
1336 return xState->getPropertyStates(aPropertyName);
1338 // set them all to DEFAULT
1339 Sequence< ::com::sun::star::beans::PropertyState> aReturn(aPropertyName.getLength());
1340 ::com::sun::star::beans::PropertyState* pStates = aReturn.getArray();
1341 for (sal_uInt16 i=0; i<aPropertyName.getLength(); ++i, ++pStates)
1342 *pStates = ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
1343 return aReturn;
1346 void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException, std::exception )
1348 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1349 if (xState.is())
1350 xState->setPropertyToDefault(PropertyName);
1353 Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const OUString& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1355 Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
1356 if (xState.is())
1357 return xState->getPropertyDefault(aPropertyName);
1358 return Any();
1361 // ::com::sun::star::form::XReset
1362 void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException, std::exception )
1364 Reference< ::com::sun::star::form::XReset > xReset(m_xMainForm, UNO_QUERY);
1365 if (xReset.is())
1366 xReset->reset();
1369 IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm)
1371 // ::com::sun::star::container::XNameContainer
1372 void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OUString* pNewElName) throw( ::com::sun::star::lang::IllegalArgumentException )
1374 // extract the form component
1375 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1377 throw ::com::sun::star::lang::IllegalArgumentException();
1380 Reference< ::com::sun::star::form::XFormComponent > xElement(*static_cast<Reference< XInterface > const *>(aElement.getValue()), UNO_QUERY);
1381 if (!xElement.is())
1383 throw ::com::sun::star::lang::IllegalArgumentException();
1386 // for the name we need the propset
1387 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1388 if (!xElementSet.is())
1390 throw ::com::sun::star::lang::IllegalArgumentException();
1392 OUString sName;
1395 if (pNewElName)
1396 xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName));
1398 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1400 catch(Exception&)
1402 // the set didn't support the name prop
1403 throw ::com::sun::star::lang::IllegalArgumentException();
1406 // check the index
1407 OSL_ASSERT(nIndex >= 0);
1408 if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
1409 nIndex = m_aChildren.size();
1411 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1412 m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
1413 m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
1415 // listen for a changes of the name
1416 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1418 // we are now the parent of the new element
1419 xElement->setParent((::com::sun::star::container::XContainer*)this);
1421 // notify the container listeners
1422 ::com::sun::star::container::ContainerEvent aEvt;
1423 aEvt.Source = *this;
1424 aEvt.Accessor <<= nIndex;
1425 aEvt.Element <<= xElement;
1426 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1427 while (aIt.hasMoreElements())
1428 static_cast< ::com::sun::star::container::XContainerListener*>(aIt.next())->elementInserted(aEvt);
1431 sal_Int32 SbaXFormAdapter::implGetPos(const OUString& rName)
1433 ::std::vector< OUString>::iterator aIter = ::std::find_if( m_aChildNames.begin(),
1434 m_aChildNames.end(),
1435 ::std::bind2nd(::std::equal_to< OUString>(),rName));
1437 if(aIter != m_aChildNames.end())
1438 return aIter - m_aChildNames.begin();
1440 return -1;
1443 void SAL_CALL SbaXFormAdapter::insertByName(const OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1445 implInsert(aElement, m_aChildren.size(), &aName);
1448 void SAL_CALL SbaXFormAdapter::removeByName(const OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1450 sal_Int32 nPos = implGetPos(Name);
1451 if (-1 == nPos)
1453 throw ::com::sun::star::container::NoSuchElementException();
1455 removeByIndex(nPos);
1458 // ::com::sun::star::container::XNameReplace
1459 void SAL_CALL SbaXFormAdapter::replaceByName(const OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1461 sal_Int32 nPos = implGetPos(aName);
1462 if (-1 == nPos)
1464 throw ::com::sun::star::container::NoSuchElementException();
1466 replaceByIndex(nPos, aElement);
1469 // ::com::sun::star::container::XNameAccess
1470 Any SAL_CALL SbaXFormAdapter::getByName(const OUString& aName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1472 sal_Int32 nPos = implGetPos(aName);
1473 if (-1 == nPos)
1475 throw ::com::sun::star::container::NoSuchElementException();
1477 return makeAny(m_aChildren[nPos]);
1480 Sequence< OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException, std::exception )
1482 return Sequence< OUString >(m_aChildNames.data(), m_aChildNames.size());
1485 sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const OUString& aName) throw( RuntimeException, std::exception )
1487 return (-1 != implGetPos(aName));
1490 // ::com::sun::star::container::XElementAccess
1491 Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException, std::exception)
1493 return cppu::UnoType<com::sun::star::form::XFormComponent>::get();
1496 sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException, std::exception)
1498 return m_aChildren.size() > 0;
1501 // ::com::sun::star::container::XIndexContainer
1502 void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1504 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1505 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1506 implInsert(Element, _rIndex);
1509 void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1511 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1512 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1514 Reference< ::com::sun::star::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
1516 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1517 m_aChildren.erase(m_aChildren.begin() + _rIndex);
1518 m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
1520 // no need to listen anymore
1521 Reference< ::com::sun::star::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
1522 xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1524 // we are no longer the parent
1525 xAffected->setParent(Reference< XInterface > ());
1527 // notify container listeners
1528 ::com::sun::star::container::ContainerEvent aEvt;
1529 aEvt.Source = *this;
1530 aEvt.Element <<= xAffected;
1531 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1532 while (aIt.hasMoreElements())
1533 static_cast< ::com::sun::star::container::XContainerListener*>(aIt.next())->elementRemoved(aEvt);
1537 // ::com::sun::star::container::XIndexReplace
1538 void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1540 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1541 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1543 // extract the form component
1544 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1546 throw ::com::sun::star::lang::IllegalArgumentException();
1549 Reference< ::com::sun::star::form::XFormComponent > xElement(*static_cast<Reference< XInterface > const *>(Element.getValue()), UNO_QUERY);
1550 if (!xElement.is())
1552 throw ::com::sun::star::lang::IllegalArgumentException();
1555 // for the name we need the propset
1556 Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
1557 if (!xElementSet.is())
1559 throw ::com::sun::star::lang::IllegalArgumentException();
1561 OUString sName;
1564 xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
1566 catch(Exception&)
1568 // the set didn't support the name prop
1569 throw ::com::sun::star::lang::IllegalArgumentException();
1572 Reference< ::com::sun::star::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
1574 OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1575 *(m_aChildren.begin() + _rIndex) = xElement;
1576 *(m_aChildNames.begin() + _rIndex) = sName;
1578 // correct property change listening
1579 Reference< ::com::sun::star::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
1580 xOldSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1581 xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
1583 // parent reset
1584 xOld->setParent(Reference< XInterface > ());
1585 xElement->setParent((::com::sun::star::container::XContainer*)this);
1587 // notify container listeners
1588 ::com::sun::star::container::ContainerEvent aEvt;
1589 aEvt.Source = *this;
1590 aEvt.Accessor <<= (sal_Int32)_rIndex;
1591 aEvt.Element <<= xElement;
1592 aEvt.ReplacedElement <<= xOld;
1594 ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
1595 while (aIt.hasMoreElements())
1596 static_cast< ::com::sun::star::container::XContainerListener*>(aIt.next())->elementReplaced(aEvt);
1599 // ::com::sun::star::container::XIndexAccess
1600 sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException, std::exception )
1602 return m_aChildren.size();
1605 Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException, std::exception )
1607 if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
1608 throw ::com::sun::star::lang::IndexOutOfBoundsException();
1610 Reference< ::com::sun::star::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
1611 return makeAny(xElement);
1614 // ::com::sun::star::container::XContainer
1615 void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException, std::exception )
1617 m_aContainerListeners.addInterface(xListener);
1620 void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException, std::exception )
1622 m_aContainerListeners.removeInterface(xListener);
1625 // ::com::sun::star::container::XEnumerationAccess
1626 Reference< ::com::sun::star::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException, std::exception )
1628 return new ::comphelper::OEnumerationByName(this);
1631 // ::com::sun::star::beans::XPropertyChangeListener
1632 void SAL_CALL SbaXFormAdapter::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( RuntimeException, std::exception )
1634 if (evt.PropertyName == PROPERTY_NAME)
1636 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1637 m_aChildren.end(),
1638 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),evt.Source));
1640 if(aIter != m_aChildren.end())
1642 sal_Int32 nPos = aIter - m_aChildren.begin();
1643 OSL_ENSURE(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1644 *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
1649 // ::com::sun::star::lang::XEventListener
1650 void SAL_CALL SbaXFormAdapter::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException, std::exception )
1652 // was it our main form ?
1653 if (Source.Source == m_xMainForm)
1654 dispose();
1656 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
1657 m_aChildren.end(),
1658 ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),Source.Source));
1659 if(aIter != m_aChildren.end())
1660 removeByIndex(aIter - m_aChildren.begin());
1663 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */