22#include <osl/diagnose.h>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
39SbaXFormAdapter::SbaXFormAdapter()
42 ,m_aRowSetApproveListeners(*this,
m_aMutex)
44 ,m_aParameterListeners(*this,
m_aMutex)
47 ,m_aPropertyChangeListeners(*this,
m_aMutex)
48 ,m_aVetoablePropertyChangeListeners(*this,
m_aMutex)
49 ,m_aPropertiesChangeListeners(*this,
m_aMutex)
52 ,m_nNamePropHandle(-1)
64 return ::comphelper::concatSequences(
65 SbaXFormAdapter_BASE1::getTypes(),
73 return css::uno::Sequence<sal_Int8>();
78 Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
80 if (!aReturn.hasValue())
83 if (!aReturn.hasValue())
94 css::uno::Reference< css::form::XLoadable > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
95 if (xBroadcaster.is())
100 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
101 if (xBroadcaster.is())
106 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
107 if (xBroadcaster.is())
112 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
113 if (xBroadcaster.is())
118 css::uno::Reference< css::form::XSubmit > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
119 if (xBroadcaster.is())
124 css::uno::Reference< css::form::XReset > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
125 if (xBroadcaster.is())
131 if (xBroadcaster.is())
137 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
138 if (xBroadcaster.is())
144 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
145 if (xBroadcaster.is())
152 if (xBroadcaster.is())
159 xComp->removeEventListener(
static_cast<css::lang::XEventListener*
>(
static_cast<css::beans::XPropertyChangeListener*
>(
this)));
167 css::uno::Reference< css::form::XLoadable > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
168 if (xBroadcaster.is())
173 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
174 if (xBroadcaster.is())
179 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
180 if (xBroadcaster.is())
185 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
186 if (xBroadcaster.is())
191 css::uno::Reference< css::form::XSubmit > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
192 if (xBroadcaster.is())
197 css::uno::Reference< css::form::XReset > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
198 if (xBroadcaster.is())
205 if (xBroadcaster.is())
211 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
212 if (xBroadcaster.is())
218 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
219 if (xBroadcaster.is())
226 if (xBroadcaster.is())
233 xComp->addEventListener(
static_cast<css::lang::XEventListener*
>(
static_cast<css::beans::XPropertyChangeListener*
>(
this)));
241 OSL_ENSURE(xNewMaster.get() !=
static_cast< css::sdbc::XRowSet*
>(
this),
"SbaXFormAdapter::AttachForm : invalid argument !");
249 if (xLoadable->isLoaded())
251 css::lang::EventObject aEvt(*
this);
265 if (xLoadable->isLoaded())
267 css::lang::EventObject aEvt(*
this);
288 return xIface->getMetaData();
299 ::dbtools::throwInvalidColumnException(
columnName, *
this );
309 return xIface->getColumns();
318 return xIface->wasNull();
326 return xIface->getString(columnIndex);
334 return xIface->getBoolean(columnIndex);
343 return xIface->getByte(columnIndex);
351 return xIface->getShort(columnIndex);
359 return xIface->getInt(columnIndex);
367 return xIface->getLong(columnIndex);
375 return xIface->getFloat(columnIndex);
383 return xIface->getDouble(columnIndex);
391 return xIface->getBytes(columnIndex);
399 return xIface->getDate(columnIndex);
400 return css::util::Date();
407 return xIface->getTime(columnIndex);
408 return css::util::Time();
415 return xIface->getTimestamp(columnIndex);
416 return css::util::DateTime();
423 return xIface->getBinaryStream(columnIndex);
431 return xIface->getCharacterStream(columnIndex);
439 return xIface->getObject(columnIndex, typeMap);
447 return xIface->getRef(columnIndex);
455 return xIface->getBlob(columnIndex);
463 return xIface->getClob(columnIndex);
471 return xIface->getArray(columnIndex);
480 return xIface->getBookmark();
488 return xIface->moveToBookmark(bookmark);
496 return xIface->moveRelativeToBookmark(bookmark,rows);
504 return xIface->compareBookmarks(_first, _second);
512 return xIface->hasOrderedBookmarks();
520 return xIface->hashBookmark(bookmark);
529 xIface->updateNull(columnIndex);
536 xIface->updateBoolean(columnIndex,
x);
543 xIface->updateByte(columnIndex,
x);
550 xIface->updateShort(columnIndex,
x);
557 xIface->updateInt(columnIndex,
x);
564 xIface->updateLong(columnIndex,
x);
571 xIface->updateFloat(columnIndex,
x);
578 xIface->updateDouble(columnIndex,
x);
585 xIface->updateString(columnIndex,
x);
592 xIface->updateBytes(columnIndex,
x);
599 xIface->updateDate(columnIndex,
x);
606 xIface->updateTime(columnIndex,
x);
613 xIface->updateTimestamp(columnIndex,
x);
620 xIface->updateBinaryStream(columnIndex,
x,
length);
627 xIface->updateCharacterStream(columnIndex,
x,
length);
634 xIface->updateObject(columnIndex,
x);
641 xIface->updateNumericObject(columnIndex,
x,
scale);
794 xIface->cancelRowUpdates();
801 xIface->moveToInsertRow();
808 xIface->moveToCurrentRow();
823 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
824 if (xBroadcaster.is())
832 css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
833 if (xBroadcaster.is())
844 return xIface->deleteRows(rows);
853 return xIface->getWarnings();
861 xIface->clearWarnings();
870 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
871 if (xBroadcaster.is())
879 css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
880 if (xBroadcaster.is())
892 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
893 if (xBroadcaster.is())
901 css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
902 if (xBroadcaster.is())
913 return xIface->createResultSet();
943 return xIface->isLoaded();
952 css::uno::Reference< css::form::XLoadable > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
953 if (xBroadcaster.is())
961 css::uno::Reference< css::form::XLoadable > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
962 if (xBroadcaster.is())
973 xIface->setNull(parameterIndex, sqlType);
980 xIface->setObjectNull(parameterIndex, sqlType,
typeName);
987 xIface->setBoolean(parameterIndex,
x);
994 xIface->setByte(parameterIndex,
x);
1001 xIface->setShort(parameterIndex,
x);
1008 xIface->setInt(parameterIndex,
x);
1015 xIface->setLong(parameterIndex,
x);
1022 xIface->setFloat(parameterIndex,
x);
1029 xIface->setDouble(parameterIndex,
x);
1036 xIface->setString(parameterIndex,
x);
1043 xIface->setBytes(parameterIndex,
x);
1050 xIface->setDate(parameterIndex,
x);
1057 xIface->setTime(parameterIndex,
x);
1064 xIface->setTimestamp(parameterIndex,
x);
1071 xIface->setBinaryStream(parameterIndex,
x,
length);
1078 xIface->setCharacterStream(parameterIndex,
x,
length);
1085 xIface->setObject(parameterIndex,
x);
1092 xIface->setObjectWithInfo(parameterIndex,
x, targetSqlType,
scale);
1099 xIface->setRef(parameterIndex,
x);
1106 xIface->setBlob(parameterIndex,
x);
1113 xIface->setClob(parameterIndex,
x);
1120 xIface->setArray(parameterIndex,
x);
1127 xIface->clearParameters();
1137 if (xBroadcaster.is())
1147 if (xBroadcaster.is())
1169 xSubmit->submit(aControl, aMouseEvt);
1177 css::uno::Reference< css::form::XSubmit > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1178 if (xBroadcaster.is())
1186 css::uno::Reference< css::form::XSubmit > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1187 if (xBroadcaster.is())
1196 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
1202 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
1207 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
1212 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
1218 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::setGroup : not supported !");
1223 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
1229 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::getGroup : not supported !");
1234 OSL_FAIL(
"SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
1244 css::lang::EventObject aEvt(*
this);
1265 xSet->removePropertyChangeListener(
PROPERTY_NAME,
static_cast<css::beans::XPropertyChangeListener*
>(
this));
1292 OSL_ENSURE(xSet.is(),
"SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
1296 if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
1298 throw css::lang::IllegalArgumentException();
1302 css::beans::PropertyChangeEvent aEvt;
1303 aEvt.Source = *
this;
1307 aEvt.NewValue = aValue;
1312 &XPropertyChangeListener::propertyChange, aEvt );
1317 xSet->setFastPropertyValue(
nHandle, aValue);
1323 OSL_ENSURE(xSet.is(),
"SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
1328 return xSet->getFastPropertyValue(
nHandle);
1347 return xPersist->getServiceName();
1355 xPersist->write(_rxOutStream);
1362 xPersist->read(_rxInStream);
1377 for (
const css::beans::Property& rProp : aProps)
1393 xSet->setPropertyValues(PropertyNames,
Values);
1402 Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
1403 auto aReturnRange = asNonConstRange(aReturn);
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)
1424 if (xBroadcaster.is())
1434 if (xBroadcaster.is())
1444 xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
1458 xSet->setPropertyValue(aPropertyName, aValue);
1471 return xSet->getPropertyValue(PropertyName);
1479 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1480 if (xBroadcaster.is())
1488 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1489 if (xBroadcaster.is())
1500 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1501 if (xBroadcaster.is())
1509 css::uno::Reference< css::beans::XPropertySet > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1510 if (xBroadcaster.is())
1531 return xState->getPropertyState(PropertyName);
1532 return css::beans::PropertyState_DEFAULT_VALUE;
1539 return xState->getPropertyStates(aPropertyName);
1543 for (css::beans::PropertyState& rState : asNonConstRange(aReturn))
1544 rState = css::beans::PropertyState_DEFAULT_VALUE;
1552 xState->setPropertyToDefault(PropertyName);
1559 return xState->getPropertyDefault(aPropertyName);
1576 css::uno::Reference< css::form::XReset > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1577 if (xBroadcaster.is())
1585 css::uno::Reference< css::form::XReset > xBroadcaster(
m_xMainForm, css::uno::UNO_QUERY);
1586 if (xBroadcaster.is())
1596 if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
1598 throw css::lang::IllegalArgumentException();
1604 throw css::lang::IllegalArgumentException();
1609 if (!xElementSet.is())
1611 throw css::lang::IllegalArgumentException();
1624 throw css::lang::IllegalArgumentException();
1632 OSL_ENSURE(
m_aChildren.size() ==
m_aChildNames.size(),
"SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
1637 xElementSet->addPropertyChangeListener(
PROPERTY_NAME,
static_cast<css::beans::XPropertyChangeListener*
>(
this));
1640 xElement->setParent(
static_cast<css::container::XContainer*
>(
this));
1643 css::container::ContainerEvent aEvt;
1644 aEvt.Source = *
this;
1645 aEvt.Accessor <<=
nIndex;
1646 aEvt.Element <<= xElement;
1652 std::vector< OUString>::const_iterator aIter = std::find(
m_aChildNames.begin(),
1672 throw css::container::NoSuchElementException();
1683 throw css::container::NoSuchElementException();
1694 throw css::container::NoSuchElementException();
1724 throw css::lang::IndexOutOfBoundsException();
1731 throw css::lang::IndexOutOfBoundsException();
1735 OSL_ENSURE(
m_aChildren.size() ==
m_aChildNames.size(),
"SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
1741 xAffectedSet->removePropertyChangeListener(
PROPERTY_NAME,
static_cast<css::beans::XPropertyChangeListener*
>(
this));
1747 css::container::ContainerEvent aEvt;
1748 aEvt.Source = *
this;
1749 aEvt.Element <<= xAffected;
1757 throw css::lang::IndexOutOfBoundsException();
1760 if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
1762 throw css::lang::IllegalArgumentException();
1768 throw css::lang::IllegalArgumentException();
1773 if (!xElementSet.is())
1775 throw css::lang::IllegalArgumentException();
1785 throw css::lang::IllegalArgumentException();
1790 OSL_ENSURE(
m_aChildren.size() ==
m_aChildNames.size(),
"SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
1796 xOldSet->removePropertyChangeListener(
PROPERTY_NAME,
static_cast<css::beans::XPropertyChangeListener*
>(
this));
1797 xElementSet->addPropertyChangeListener(
PROPERTY_NAME,
static_cast<css::beans::XPropertyChangeListener*
>(
this));
1801 xElement->setParent(
static_cast<css::container::XContainer*
>(
this));
1804 css::container::ContainerEvent aEvt;
1805 aEvt.Source = *
this;
1806 aEvt.Accessor <<= _rIndex;
1807 aEvt.Element <<= xElement;
1808 aEvt.ReplacedElement <<= xOld;
1822 throw css::lang::IndexOutOfBoundsException();
1825 return Any(xElement);
1842 return new ::comphelper::OEnumerationByName(
this);
1851 std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = std::find_if(
m_aChildren.begin(),
1853 [&evt](css::uno::Reference< css::uno::XInterface >
const &
x) { return x == evt.Source; });
1858 OSL_ENSURE(*(
m_aChildNames.begin() +
nPos) == ::comphelper::getString(evt.OldValue),
"SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
1870 std::vector< css::uno::Reference< css::form::XFormComponent > >::const_iterator aIter = std::find_if(
m_aChildren.begin(),
1872 [&
Source](css::uno::Reference< css::uno::XInterface >
const &
x) { return x == Source.Source; });
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 getLength() const
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
css::uno::Type const & get()
::comphelper::OInterfaceContainerHelper3< css::beans::XPropertyChangeListener > * getContainer(const OUString &rName)
void removeInterface(const OUString &rName, const css::uno::Reference< css::beans::XPropertyChangeListener > &rListener)
sal_Int32 getOverallLen() const
void addInterface(const OUString &rName, const css::uno::Reference< css::beans::XPropertyChangeListener > &rListener)
void removeInterface(const OUString &rName, const css::uno::Reference< css::beans::XVetoableChangeListener > &rListener)
sal_Int32 getOverallLen() const
void addInterface(const OUString &rName, const css::uno::Reference< css::beans::XVetoableChangeListener > &rListener)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr OUStringLiteral PROPERTY_NAME(u"Name")