/************************************************************************* * * $RCSfile: DatabaseForm.cxx,v $ * * $Revision: 1.7 $ * * last change: $Author: fs $ $Date: 2000-10-31 16:03:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #include #include #ifndef _FRM_DATABASEFORM_HXX_ #include "DatabaseForm.hxx" #endif #ifndef _FRM_EVENT_THREAD_HXX_ #include "EventThread.hxx" #endif #ifndef _FORMS_LISTBOX_HXX_ #include "ListBox.hxx" #endif #ifndef _FRM_RESOURCE_HXX_ #include "frm_resource.hxx" #endif #ifndef _FRM_RESOURCE_HRC_ #include "frm_resource.hrc" #endif #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ #include #endif #ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ #include #endif #ifndef _COM_SUN_STAR_DATA_DATABASECURSORTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include #endif #ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_ #include #endif #ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ #include #endif #ifndef _COM_SUN_STAR_FORM_TABULATORCYCLE_HPP_ #include #endif #ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_ #include #endif #ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_ #include #endif #ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ #include #endif #ifndef _TOOLS_DEBUG_HXX #include #endif #ifndef _SV_TIMER_HXX #include #endif #ifndef _FRM_GROUPMANAGER_HXX_ #include "GroupManager.hxx" #endif #ifndef _FRM_PROPERTY_HRC_ #include "property.hrc" #endif #ifndef _FRM_PROPERTY_HXX_ #include "property.hxx" #endif #ifndef _FRM_SERVICES_HXX_ #include "services.hxx" #endif #ifndef _FRM_IDS_HXX_ #include "ids.hxx" #endif #ifndef _FSYS_HXX #include #endif #ifndef _TOOLS_INETMSG_HXX #include #endif #ifndef _INETSTRM_HXX //autogen #include #endif #ifndef _CPPUHELPER_IMPLBASE2_HXX_ #include #endif #ifndef _COMPHELPER_STLTYPES_HXX_ #include #endif #ifndef _COMPHELPER_SEQUENCE_HXX_ #include #endif #ifndef _COMPHELPER_STLTYPES_HXX_ #include #endif #ifndef _COMPHELPER_UNO3_HXX_ #include #endif #ifndef _COMPHELPER_ENUMHELPER_HXX_ #include #endif #ifndef _COMPHELPER_CONTAINER_HXX_ #include #endif #ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include #endif #ifndef _OSL_MUTEX_HXX_ #include #endif #ifndef _URLOBJ_HXX #include #endif #ifndef _TOOLS_SOLMATH_HXX #include #endif #ifndef _INETTYPE_HXX #include #endif #ifndef _CPPUHELPER_EXTRACT_HXX_ #include #endif #ifndef _VOS_MUTEX_HXX_ #include #endif #ifndef _SV_SVAPP_HXX // because of the solar mutex #include #endif #ifndef _RTL_TENCINFO_H #include #endif #ifndef _COMPHELPER_INTERACTION_HXX_ #include #endif #ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_ #include #endif #ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ #include #endif #define DATABASEFORM_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.form.component.ODatabaseForm") using namespace dbtools; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::task; //......................................................................... namespace frm { //......................................................................... namespace starframe = ::com::sun::star::frame; namespace stardata = ::com::sun::star::data; //------------------------------------------------------------------ staruno::Reference< starframe::XModel> getXModel(const staruno::Reference< staruno::XInterface>& xIface) { staruno::Reference< starframe::XModel> xModel(xIface, staruno::UNO_QUERY); if (xModel.is()) return xModel; else { staruno::Reference< starcontainer::XChild> xChild(xIface, staruno::UNO_QUERY); if (xChild.is()) { staruno::Reference< staruno::XInterface> xParent( xChild->getParent()); return getXModel(xParent); } else return NULL; } } //================================================================== // OParameterContinuation //================================================================== class OParameterContinuation : public OInteraction< XInteractionSupplyParameters > { Sequence< PropertyValue > m_aValues; public: OParameterContinuation() { } Sequence< PropertyValue > getValues() const { return m_aValues; } // XInteractionSupplyParameters virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException); }; //------------------------------------------------------------------ void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException) { m_aValues = _rValues; } //================================================================== //= OParameterWrapper //=----------------------------------------------------------------- //= wraps a parameter property set got from an starsdb::SQLQueryComposer //= so it has an additional property "Value", which is forwarded to //= an starsdbc::XParameters interface //================================================================== class OParameterWrapper :public ::cppu::OWeakObject ,public ::cppu::OPropertySetHelper ,public ::comphelper::OAggregationArrayUsageHelper { staruno::Any m_aValue; ::osl::Mutex m_aMutex; ::cppu::OBroadcastHelper m_aBroadcastHelper; OImplementationIdsRef m_aHoldIdHelper; staruno::Reference m_xPseudoAggregate; staruno::Reference m_xValueDestination; sal_Int32 m_nIndex; virtual ~OParameterWrapper(); public: OParameterWrapper(const staruno::Reference& _rxColumn, const staruno::Reference& _rxAllParameters, sal_Int32 _nIndex); // UNO DECLARE_UNO3_DEFAULTS(OParameterWrapper, OWeakObject); virtual staruno::Any SAL_CALL queryInterface(const staruno::Type& _rType) throw (staruno::RuntimeException); virtual staruno::Sequence SAL_CALL getImplementationId() throw(staruno::RuntimeException); virtual staruno::Sequence SAL_CALL getTypes() throw(staruno::RuntimeException); // starbeans::XPropertySet virtual staruno::Reference SAL_CALL getPropertySetInfo() throw( staruno::RuntimeException ); virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); // OPropertySetHelper virtual sal_Bool SAL_CALL convertFastPropertyValue( staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue) throw( starlang::IllegalArgumentException ); virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue ) throw( staruno::Exception ); virtual void SAL_CALL getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const; // OAggregationArrayUsageHelper virtual void fillProperties( staruno::Sequence< starbeans::Property >& /* [out] */ _rProps, staruno::Sequence< starbeans::Property >& /* [out] */ _rAggregateProps ) const; protected: ::rtl::OUString getPseudoAggregatePropertyName(sal_Int32 _nHandle) const; }; DBG_NAME(OParameterWrapper) //------------------------------------------------------------------------------ OParameterWrapper::OParameterWrapper(const staruno::Reference& _rxColumn, const staruno::Reference& _rxAllParameters, sal_Int32 _nIndex) :OPropertySetHelper(m_aBroadcastHelper) ,m_aBroadcastHelper(m_aMutex) ,m_xPseudoAggregate(_rxColumn) ,m_xValueDestination(_rxAllParameters) ,m_nIndex(_nIndex) { DBG_CTOR(OParameterWrapper, NULL); } //------------------------------------------------------------------------------ OParameterWrapper::~OParameterWrapper() { DBG_DTOR(OParameterWrapper, NULL); } //------------------------------------------------------------------------------ staruno::Any SAL_CALL OParameterWrapper::queryInterface(const staruno::Type& _rType) throw (staruno::RuntimeException) { staruno::Any aReturn; aReturn = OWeakObject::queryInterface(_rType); if (!aReturn.hasValue()) OPropertySetHelper::queryInterface(_rType); return aReturn; } //------------------------------------------------------------------------------ staruno::Sequence< staruno::Type > SAL_CALL OParameterWrapper::getTypes( ) throw(staruno::RuntimeException) { staruno::Sequence< staruno::Type > aWeakTypes(1); aWeakTypes.getArray()[0] = ::getCppuType(static_cast*>(NULL)); staruno::Sequence< staruno::Type > aPropertyTypes(3); aPropertyTypes.getArray()[0] = ::getCppuType(static_cast*>(NULL)); aPropertyTypes.getArray()[1] = ::getCppuType(static_cast*>(NULL)); aPropertyTypes.getArray()[2] = ::getCppuType(static_cast*>(NULL)); return concatSequences(aWeakTypes, aPropertyTypes); } //------------------------------------------------------------------------------ staruno::Sequence SAL_CALL OParameterWrapper::getImplementationId() throw(staruno::RuntimeException) { staruno::Reference xMyTpes; query_interface(static_cast(this), xMyTpes); return OImplementationIds::getImplementationId(xMyTpes); } //------------------------------------------------------------------------------ ::rtl::OUString OParameterWrapper::getPseudoAggregatePropertyName(sal_Int32 _nHandle) const { staruno::Reference xInfo = const_cast(this)->getPropertySetInfo(); staruno::Sequence aProperties = xInfo->getProperties(); const starbeans::Property* pProperties = aProperties.getConstArray(); for (sal_Int32 i=0; iHandle == _nHandle) return pProperties->Name; } DBG_ERROR("OParameterWrapper::getPseudoAggregatePropertyName : invalid argument !"); return ::rtl::OUString(); } //------------------------------------------------------------------------------ staruno::Reference OParameterWrapper::getPropertySetInfo() throw( staruno::RuntimeException ) { staruno::Reference xInfo( createPropertySetInfo( getInfoHelper() ) ); return xInfo; } //------------------------------------------------------------------------------ void OParameterWrapper::fillProperties( staruno::Sequence< starbeans::Property >& _rProps, staruno::Sequence< starbeans::Property >& _rAggregateProps ) const { BEGIN_AGGREGATION_PROPERTY_HELPER(1, m_xPseudoAggregate) DECL_PROP2(VALUE, ::rtl::OUString, TRANSIENT, MAYBEVOID); END_AGGREGATION_PROPERTY_HELPER(); } //------------------------------------------------------------------------------ ::cppu::IPropertyArrayHelper& OParameterWrapper::getInfoHelper() { return *const_cast(this)->getArrayHelper(); } //------------------------------------------------------------------------------ sal_Bool OParameterWrapper::convertFastPropertyValue(staruno::Any& rConvertedValue, staruno::Any& rOldValue, sal_Int32 nHandle, const staruno::Any& rValue) throw( starlang::IllegalArgumentException ) { DBG_ASSERT(PROPERTY_ID_VALUE == nHandle, "OParameterWrapper::convertFastPropertyValue : the only non-readonly prop should be our PROPERTY_VALUE"); // we're lazy here ... rOldValue = m_aValue; rConvertedValue = rValue; return sal_True; // assume "modified" ... } //------------------------------------------------------------------------------ void OParameterWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const staruno::Any& rValue ) throw( staruno::Exception ) { if (nHandle == PROPERTY_ID_VALUE) { // get the type of the param staruno::Any aParamType = m_xPseudoAggregate->getPropertyValue(PROPERTY_FIELDTYPE); DBG_ASSERT(aParamType.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !"); sal_Int32 nScale = 0; if (hasProperty(PROPERTY_SCALE, m_xPseudoAggregate)) { staruno::Any aScale = m_xPseudoAggregate->getPropertyValue(PROPERTY_SCALE); DBG_ASSERT(aScale.getValueType().getTypeClass() == staruno::TypeClass_LONG, "ODatabaseForm::setPropertyValue : invalid parameter field !"); nScale = getINT32(aScale); } // TODO : aParamType & nScale can be obtained within the constructor .... try { m_xValueDestination->setObjectWithInfo(m_nIndex + 1, rValue, getINT32(aParamType), nScale); // the index of the parameters is one-based m_aValue = rValue; } catch(starsdbc::SQLException& e) { starlang::WrappedTargetException aExceptionWrapper; aExceptionWrapper.Context = e.Context; aExceptionWrapper.Message = e.Message; aExceptionWrapper.TargetException <<= e; throw starlang::WrappedTargetException(aExceptionWrapper); } } else { ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle); m_xPseudoAggregate->setPropertyValue(aName, rValue); } } //------------------------------------------------------------------------------ void OParameterWrapper::getFastPropertyValue( staruno::Any& rValue, sal_Int32 nHandle ) const { if (nHandle == PROPERTY_ID_VALUE) { rValue = m_aValue; } else { ::rtl::OUString aName = getPseudoAggregatePropertyName(nHandle); rValue = m_xPseudoAggregate->getPropertyValue(aName); } } //================================================================== //= OParametersImpl //=----------------------------------------------------------------- //= class for the parameter event see approveParameter //================================================================== typedef ::cppu::WeakImplHelper2 OParametersImplBase; class OParametersImpl : public OParametersImplBase { public: typedef ::std::vector > Parameters; typedef Parameters::iterator ParametersIterator; private: Parameters m_aParameters; public: // UNO DECLARE_UNO3_AGG_DEFAULTS(OParametersImpl, OParametersImplBase); // XElementAccess virtual staruno::Type SAL_CALL getElementType() throw( staruno::RuntimeException ); virtual sal_Bool SAL_CALL hasElements() throw( staruno::RuntimeException ); // XEnumerationAccess virtual staruno::Reference SAL_CALL createEnumeration() throw( staruno::RuntimeException ); // XIndexAccess virtual sal_Int32 SAL_CALL getCount() throw( staruno::RuntimeException ); virtual staruno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw( starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException ); Parameters& getParameters() { return m_aParameters; } }; // starcontainer::XElementAccess //------------------------------------------------------------------------------ staruno::Type SAL_CALL OParametersImpl::getElementType() throw( staruno::RuntimeException ) { return ::getCppuType(static_cast*>(NULL)); } //------------------------------------------------------------------------------ sal_Bool SAL_CALL OParametersImpl::hasElements() throw( staruno::RuntimeException ) { return m_aParameters.size() != 0; } // starcontainer::XIndexAccess //------------------------------------------------------------------------------ sal_Int32 SAL_CALL OParametersImpl::getCount() throw( staruno::RuntimeException ) { return m_aParameters.size(); } //------------------------------------------------------------------------------ staruno::Any SAL_CALL OParametersImpl::getByIndex(sal_Int32 _nIndex) throw( starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException ) { if (_nIndex < 0 || _nIndex >= m_aParameters.size()) throw starlang::IndexOutOfBoundsException(); return staruno::makeAny(m_aParameters[_nIndex]); } // starcontainer::XEnumerationAccess //------------------------------------------------------------------------------ staruno::Reference OParametersImpl::createEnumeration() throw( staruno::RuntimeException ) { return new OEnumerationByIndex(reinterpret_cast(this)); } //================================================================== //= OParameterInfoImpl //=----------------------------------------------------------------- //= class which collects all information for parameter filling //================================================================== DECLARE_STL_USTRINGACCESS_MAP(sal_Int32, MapUString2INT32); struct OParameterInfoImpl { sal_Int32 nCount; // Number of Parameters staruno::Reference xComposer; staruno::Reference xParamsAsNames; OParametersImpl* pParameters; MapUString2INT32 aParamMapping; OParameterInfoImpl():nCount(0),pParameters(NULL){} ~OParameterInfoImpl() { if (pParameters) pParameters->release(); } }; //================================================================== //= OFormSubmitResetThread //=----------------------------------------------------------------- //= submitting and resetting html-forms asynchronously //================================================================== //------------------------------------------------------------------ class OFormSubmitResetThread: public OComponentEventThread { protected: // duplicate an event with respect to it's type virtual starlang::EventObject *cloneEvent( const starlang::EventObject *pEvt ) const; // process an event. while processing the mutex isn't locked, and pCompImpl // is made sure to remain valid virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl, const starlang::EventObject* _pEvt, const staruno::Reference& _rControl, sal_Bool _bSubmit); public: OFormSubmitResetThread(ODatabaseForm* pControl) : OComponentEventThread(pControl) { } }; //------------------------------------------------------------------ starlang::EventObject* OFormSubmitResetThread::cloneEvent( const starlang::EventObject *pEvt ) const { return new starawt::MouseEvent( *(starawt::MouseEvent *)pEvt ); } //------------------------------------------------------------------ void OFormSubmitResetThread::processEvent( ::cppu::OComponentHelper* pCompImpl, const starlang::EventObject *_pEvt, const staruno::Reference& _rControl, sal_Bool _bSubmit) { if (_bSubmit) ((ODatabaseForm *)pCompImpl)->submit_impl(_rControl, *reinterpret_cast(_pEvt), true); else ((ODatabaseForm *)pCompImpl)->reset_impl(true); } //================================================================== //= ODatabaseForm //================================================================== //------------------------------------------------------------------ InterfaceRef SAL_CALL ODatabaseForm_CreateInstance(const staruno::Reference& _rxFactory) { return *(new ODatabaseForm(_rxFactory)); } //------------------------------------------------------------------------------ staruno::Sequence SAL_CALL ODatabaseForm::getImplementationId() throw(staruno::RuntimeException) { return OImplementationIds::getImplementationId(getTypes()); } //------------------------------------------------------------------ staruno::Sequence SAL_CALL ODatabaseForm::getTypes() throw(staruno::RuntimeException) { // ask the aggregate staruno::Sequence aAggregateTypes; staruno::Reference xAggregateTypes; if (query_aggregation(m_xAggregate, xAggregateTypes)) aAggregateTypes = xAggregateTypes->getTypes(); staruno::Sequence aOwnTypes(23); aOwnTypes.getArray()[0] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[1] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[2] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[3] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[4] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[5] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[6] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[7] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[8] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[9] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[10] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[11] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[12] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[13] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[14] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[15] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[16] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[17] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[18] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[19] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[20] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[21] = ::getCppuType(static_cast*>(NULL)); aOwnTypes.getArray()[22] = ::getCppuType(static_cast*>(NULL)); return concatSequences(aAggregateTypes, aOwnTypes, OFormComponents::getTypes()); } //------------------------------------------------------------------ staruno::Any SAL_CALL ODatabaseForm::queryAggregation(const staruno::Type& _rType) throw(staruno::RuntimeException) { staruno::Any aReturn; // our own interfaces aReturn = ::cppu::queryInterface(_rType, static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this) ); if (!aReturn.hasValue()) aReturn = ::cppu::queryInterface(_rType, static_cast(this), static_cast(this), static_cast(static_cast(this)) ); // interfaces already present in the aggregate which we want to reroute // only available if we could create the aggregate if (!aReturn.hasValue() && m_xAggregateAsRowSet.is()) aReturn = ::cppu::queryInterface(_rType, static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this), static_cast(this) ); // property set related interfaces if (!aReturn.hasValue()) aReturn = OPropertySetAggregationHelper::queryInterface(_rType); // form component collection related interfaces if (!aReturn.hasValue()) aReturn = OFormComponents::queryAggregation(_rType); // aggregate interfaces // (ask the aggregated object _after_ the OComponentHelper (base of OFormComponents), // so calls to the starlang::XComponent interface reach us and not the aggreagtion) if (!aReturn.hasValue() && m_xAggregate.is()) aReturn = m_xAggregate->queryAggregation(_rType); return aReturn; } DBG_NAME(ODatabaseForm); //------------------------------------------------------------------ ODatabaseForm::ODatabaseForm(const staruno::Reference& _rxFactory) :OFormComponents(_rxFactory) ,OPropertySetAggregationHelper(OComponentHelper::rBHelper) ,OPropertyChangeListener(m_aMutex) ,m_aLoadListeners(m_aMutex) ,m_aRowSetApproveListeners(m_aMutex) ,m_aRowSetListeners(m_aMutex) ,m_aParameterListeners(m_aMutex) ,m_aResetListeners(m_aMutex) ,m_aSubmitListeners(m_aMutex) ,m_aErrorListeners(m_aMutex) ,m_bLoaded(sal_False) ,m_bSubForm(sal_False) ,m_eNavigation(starform::NavigationBarMode_CURRENT) ,m_nPrivileges(0) ,m_pParameterInfo(NULL) ,m_pThread(NULL) ,m_eSubmitMethod(starform::FormSubmitMethod_GET) ,m_eSubmitEncoding(starform::FormSubmitEncoding_URL) ,m_bAllowDelete(sal_True) ,m_bAllowUpdate(sal_True) ,m_bAllowInsert(sal_True) ,m_pLoadTimer(NULL) ,m_nResetsPending(0) { DBG_CTOR(ODatabaseForm,NULL); // aggregate a row set increment(m_refCount); { m_xAggregate = staruno::Reference(m_xServiceFactory->createInstance(SRV_SDB_ROWSET), staruno::UNO_QUERY); // m_xAggregate = staruno::Reference(m_xServiceFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.sdb.dbaccess.ORowSet")), staruno::UNO_QUERY); DBG_ASSERT(m_xAggregate.is(), "ODatabaseForm::ODatabaseForm : could not instantiate an SDB rowset !"); m_xAggregateAsRowSet = staruno::Reference (m_xAggregate,staruno::UNO_QUERY); setAggregation(m_xAggregate); } if (m_xAggregate.is()) { m_xAggregate->setDelegator(static_cast(this)); } // listen for the properties, important for Parameters if (m_xAggregateSet.is()) { OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer(this, m_xAggregateSet); pMultiplexer->addProperty(PROPERTY_COMMAND); pMultiplexer->addProperty(PROPERTY_FILTER_CRITERIA); pMultiplexer->addProperty(PROPERTY_APPLYFILTER); } decrement(m_refCount); m_pGroupManager = new OGroupManager(); m_pGroupManager->acquire(); addContainerListener(m_pGroupManager); } //------------------------------------------------------------------ ODatabaseForm::~ODatabaseForm() { DBG_DTOR(ODatabaseForm,NULL); m_pGroupManager->release(); if (m_xAggregate.is()) m_xAggregate->setDelegator(InterfaceRef()); } //============================================================================== // html tools //------------------------------------------------------------------------ ::rtl::OUString ODatabaseForm::GetDataURLEncoded(const staruno::Reference& SubmitButton, const starawt::MouseEvent& MouseEvt) { // Liste von successful Controls fuellen HtmlSuccessfulObjList aSuccObjList; FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt ); // Liste zu ::rtl::OUString zusammensetzen ::rtl::OUString aResult; ::rtl::OUString aName; ::rtl::OUString aValue; for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin(); pSuccObj < aSuccObjList.end(); ++pSuccObj ) { aName = pSuccObj->aName; aValue = pSuccObj->aValue; if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength() ) { // Bei File-URLs wird der Dateiname und keine starutil::URL uebertragen, // weil Netscape dies so macht. INetURLObject aURL; aURL.SetSmartProtocol(INET_PROT_FILE); aURL.SetSmartURL(aValue); if( INET_PROT_FILE == aURL.GetProtocol() ) aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS); } Encode( aName ); Encode( aValue ); aResult += aName; aResult += UniString('='); aResult += aValue; if (pSuccObj < aSuccObjList.end() - 1) aResult += UniString('&'); } aSuccObjList.clear(); return aResult; } //============================================================================== // html tools //------------------------------------------------------------------------ ::rtl::OUString ODatabaseForm::GetDataTextEncoded(const staruno::Reference& SubmitButton, const starawt::MouseEvent& MouseEvt) { // Liste von successful Controls fuellen HtmlSuccessfulObjList aSuccObjList; FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt ); // Liste zu ::rtl::OUString zusammensetzen ::rtl::OUString aResult; ::rtl::OUString aName; ::rtl::OUString aValue; for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin(); pSuccObj < aSuccObjList.end(); ++pSuccObj ) { aName = pSuccObj->aName; aValue = pSuccObj->aValue; if (pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE && aValue.getLength()) { // Bei File-URLs wird der Dateiname und keine starutil::URL uebertragen, // weil Netscape dies so macht. INetURLObject aURL; aURL.SetSmartProtocol(INET_PROT_FILE); aURL.SetSmartURL(aValue); if( INET_PROT_FILE == aURL.GetProtocol() ) aValue = INetURLObject::decode(aURL.PathToFileName(), '%', INetURLObject::DECODE_UNAMBIGUOUS); } Encode( aName ); Encode( aValue ); aResult += pSuccObj->aName; aResult += UniString('='); aResult += pSuccObj->aValue; if (pSuccObj < aSuccObjList.end() - 1) aResult += ::rtl::OUString::createFromAscii("\r\n"); } // Liste loeschen aSuccObjList.clear(); return aResult; } //------------------------------------------------------------------------ staruno::Sequence ODatabaseForm::GetDataMultiPartEncoded(const staruno::Reference& SubmitButton, const starawt::MouseEvent& MouseEvt, ::rtl::OUString& rContentType) { // Parent erzeugen INetMIMEMessage aParent; aParent.EnableAttachChild( INETMSG_MULTIPART_FORM_DATA ); // Liste von successful Controls fuellen HtmlSuccessfulObjList aSuccObjList; FillSuccessfulList( aSuccObjList, SubmitButton, MouseEvt ); // Liste zu ::rtl::OUString zusammensetzen ::rtl::OUString aResult; for ( HtmlSuccessfulObjListIterator pSuccObj = aSuccObjList.begin(); pSuccObj < aSuccObjList.end(); ++pSuccObj ) { if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_TEXT ) InsertTextPart( aParent, pSuccObj->aName, pSuccObj->aValue ); else if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE ) InsertFilePart( aParent, pSuccObj->aName, pSuccObj->aValue ); } // Liste loeschen aSuccObjList.clear(); // Fuer Parent MessageStream erzeugen INetMIMEMessageStream aMessStream; aMessStream.SetSourceMessage( &aParent ); aMessStream.GenerateHeader( sal_False ); // MessageStream in SvStream kopieren SvMemoryStream aMemStream; char* pBuf = new char[1025]; int nRead; while( (nRead = aMessStream.Read(pBuf, 1024)) > 0 ) aMemStream.Write( pBuf, nRead ); delete[] pBuf; aMemStream.Flush(); aMemStream.Seek( 0 ); void* pData = (void*)aMemStream.GetData(); sal_Int32 nLen = aMemStream.Seek(STREAM_SEEK_TO_END); rContentType = UniString(aParent.GetContentType()); return staruno::Sequence((sal_Int8*)pData, nLen); } //------------------------------------------------------------------------ void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const staruno::Reference& xComponentSet, const ::rtl::OUString& rNamePrefix, const staruno::Reference& rxSubmitButton, const starawt::MouseEvent& MouseEvt) { if (!xComponentSet.is()) return; // MIB 25.6.98: Geschachtelte Formulare abfangen ... oder muesste // man sie submitten? if (!hasProperty(PROPERTY_CLASSID, xComponentSet)) return; // Namen ermitteln if (!hasProperty(PROPERTY_NAME, xComponentSet)) return; sal_Int16 nClassId; xComponentSet->getPropertyValue(PROPERTY_CLASSID) >>= nClassId; ::rtl::OUString aName; xComponentSet->getPropertyValue( PROPERTY_NAME ) >>= aName; if( !aName.getLength() && nClassId != starform::FormComponentType::IMAGEBUTTON) return; else // Name um den Prefix erweitern aName = rNamePrefix + aName; switch( nClassId ) { // Buttons case starform::FormComponentType::COMMANDBUTTON: { // Es wird nur der gedrueckte Submit-Button ausgewertet // MIB: Sofern ueberhaupt einer uebergeben wurde if( rxSubmitButton.is() ) { staruno::Reference xSubmitButtonComponent(rxSubmitButton->getModel(), staruno::UNO_QUERY); if (xSubmitButtonComponent == xComponentSet && hasProperty(PROPERTY_LABEL, xComponentSet)) { // =