diff options
Diffstat (limited to 'forms')
32 files changed, 1804 insertions, 361 deletions
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 4a4fd5c2acf8..05693f133338 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Button.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2002-12-02 12:57:24 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,9 @@ #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif +#ifndef _COMPHELPER_STREAMSECTION_HXX_ +#include <comphelper/streamsection.hxx> +#endif //......................................................................... namespace frm @@ -177,13 +180,20 @@ void OButtonModel::write(const Reference<XObjectOutputStream>& _rxOutStream) thr { OImageModel::write(_rxOutStream); - _rxOutStream->writeShort(0x0002); // Version - _rxOutStream->writeShort( (sal_uInt16)m_eButtonType ); + _rxOutStream->writeShort(0x0003); // Version + + { + OStreamSection aSection( _rxOutStream.get() ); + // this will allow readers to skip unknown bytes in their dtor + + _rxOutStream->writeShort( (sal_uInt16)m_eButtonType ); - ::rtl::OUString sTmp = INetURLObject::decode(INetURLObject::AbsToRel( m_sTargetURL ), '%', INetURLObject::DECODE_UNAMBIGUOUS); - _rxOutStream << sTmp; - _rxOutStream << m_sTargetFrame; - writeHelpTextCompatibly(_rxOutStream); + ::rtl::OUString sTmp = INetURLObject::decode(INetURLObject::AbsToRel( m_sTargetURL ), '%', INetURLObject::DECODE_UNAMBIGUOUS); + _rxOutStream << sTmp; + _rxOutStream << m_sTargetFrame; + writeHelpTextCompatibly(_rxOutStream); + _rxOutStream << isDispatchUrlInternal(); + } } //------------------------------------------------------------------------------ @@ -204,6 +214,7 @@ void OButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw _rxInStream >> m_sTargetFrame; } break; + case 0x0002: { m_eButtonType = (FormButtonType)_rxInStream->readShort(); @@ -215,7 +226,34 @@ void OButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw readHelpTextCompatibly(_rxInStream); } break; - default : + + case 0x0003: + { + OStreamSection aSection( _rxInStream.get() ); + // this will skip any unknown bytes in it's dtor + + // button type + m_eButtonType = (FormButtonType)_rxInStream->readShort(); + + // URL + ::rtl::OUString sTmp; + _rxInStream >> sTmp; + m_sTargetURL = INetURLObject::RelToAbs( sTmp ); + + // target frame + _rxInStream >> m_sTargetFrame; + + // help text + readHelpTextCompatibly(_rxInStream); + + // DispatchInternal + sal_Bool bDispath; + _rxInStream >> bDispath; + setDispatchUrlInternal(bDispath); + } + break; + + default: DBG_ERROR("OButtonModel::read : unknown version !"); m_eButtonType = FormButtonType_PUSH; m_sTargetURL = ::rtl::OUString(); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index c868c44654ee..e3b988bb1682 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DatabaseForm.cxx,v $ * - * $Revision: 1.49 $ + * $Revision: 1.50 $ * - * last change: $Author: fs $ $Date: 2002-10-09 14:53:54 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -218,8 +218,8 @@ #ifndef _URLOBJ_HXX #include <tools/urlobj.hxx> #endif -#ifndef _TOOLS_SOLMATH_HXX -#include <tools/solmath.hxx> +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> #endif #ifndef _INETTYPE_HXX #include <svtools/inettype.hxx> @@ -1161,9 +1161,7 @@ void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const Referenc { sal_Int16 nScale; xComponentSet->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) >>= nScale; - String aTempText = UniString(aText); - // TODO : remove this if SolarMath works with unicode strings - SolarMath::DoubleToString(aTempText, aDoubleVal, 'F', nScale, '.', sal_True); + aText = ::rtl::math::doubleToUString(aDoubleVal, rtl_math_StringFormat_F, nScale, '.', sal_True); } rList.push_back( HtmlSuccessfulObj(aName, aText) ); } @@ -1538,7 +1536,14 @@ void ODatabaseForm::createParameterInfo() m_pParameterInfo = new OParameterInfoImpl; // create and fill a composer - Reference<XSQLQueryComposer> xComposer = getCurrentSettingsComposer(m_xAggregateSet, m_xServiceFactory); + Reference<XSQLQueryComposer> xComposer; + try + { + xComposer = getCurrentSettingsComposer(m_xAggregateSet, m_xServiceFactory); + } + catch(SQLException&) + { + } Reference<XParametersSupplier> xSetParameters = Reference<XParametersSupplier> (xComposer, UNO_QUERY); // if there is no parsable statement return @@ -4169,7 +4174,7 @@ Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getCurrentServiceNames_Stati Sequence< ::rtl::OUString > aServices( 5 ); ::rtl::OUString* pServices = aServices.getArray(); - *pServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent"); + *pServices++ = FRM_SUN_FORMCOMPONENT; *pServices++ = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents"); *pServices++ = FRM_SUN_COMPONENT_FORM; *pServices++ = FRM_SUN_COMPONENT_HTMLFORM; @@ -4217,13 +4222,12 @@ Sequence< ::rtl::OUString > SAL_CALL ODatabaseForm::getSupportedServiceNames() t //------------------------------------------------------------------------------ sal_Bool SAL_CALL ODatabaseForm::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) { - Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); - const ::rtl::OUString* pSupported = aSupported.getConstArray(); - const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); - for (;pSupported != pEnd && !pSupported->equals(ServiceName); ++pSupported) - ; - - return pSupported != pEnd; + Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); + const ::rtl::OUString* pArray = aSupported.getConstArray(); + for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray ) + if( pArray->equals( ServiceName ) ) + return sal_True; + return sal_False; } //============================================================================== diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx index 5cc3f7ba10c7..e6be7d4210e8 100644 --- a/forms/source/component/DatabaseForm.hxx +++ b/forms/source/component/DatabaseForm.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DatabaseForm.hxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: fs $ $Date: 2002-10-04 08:14:15 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index 2754044db9fe..c095e0e493f4 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Edit.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: fs $ $Date: 2002-12-02 09:56:29 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -357,7 +357,7 @@ DBG_NAME(OEditModel); OEditModel::OEditModel(const Reference<XMultiServiceFactory>& _rxFactory) :OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_EDIT, FRM_CONTROL_EDIT ) // use the old control name for compytibility reasons - ,m_nMaxLen(0) + ,m_bMaxTextLenModified(sal_False) ,m_nKeyType(NumberFormat::UNDEFINED) ,m_aNullDate(DBTypeConversion::getStandardDate()) ,m_nFormatKey(0) @@ -376,7 +376,7 @@ OEditModel::OEditModel(const Reference<XMultiServiceFactory>& _rxFactory) //------------------------------------------------------------------ OEditModel::OEditModel( const OEditModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) :OEditBaseModel( _pOriginal, _rxFactory ) - ,m_nMaxLen(0) + ,m_bMaxTextLenModified(sal_False) ,m_nKeyType(NumberFormat::UNDEFINED) ,m_aNullDate(DBTypeConversion::getStandardDate()) ,m_nFormatKey(0) @@ -442,18 +442,34 @@ Reference<XPropertySetInfo> SAL_CALL OEditModel::getPropertySetInfo() throw(Runt Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); return xInfo; } +// ----------------------------------------------------------------------------- +void SAL_CALL OEditModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle ) const +{ + if ( PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH == nHandle ) + { + if ( m_bMaxTextLenModified ) + rValue <<= sal_Int16(0); + else if ( m_xAggregateSet.is() ) + rValue = m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN); + } + else + { + OEditBaseModel::getFastPropertyValue(rValue, nHandle ); + } +} //------------------------------------------------------------------------------ void OEditModel::fillProperties( Sequence< Property >& _rProps, Sequence< Property >& _rAggregateProps ) const { - FRM_BEGIN_PROP_HELPER(11) + FRM_BEGIN_PROP_HELPER(12) // Text auf transient setzen // ModifyPropertyAttributes(_rAggregateProps, PROPERTY_TEXT, PropertyAttribute::TRANSIENT, 0); DECL_PROP1(NAME, ::rtl::OUString, BOUND); DECL_PROP2(CLASSID, sal_Int16, READONLY, TRANSIENT); + DECL_PROP2(PERSISTENCE_MAXTEXTLENGTH,sal_Int16, READONLY, TRANSIENT); DECL_PROP2(DEFAULT_TEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT); DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND); DECL_PROP1(TAG, ::rtl::OUString, BOUND); @@ -476,22 +492,24 @@ void OEditModel::fillProperties( void OEditModel::write(const Reference<XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { Any aCurrentText; + sal_Int16 nOldTextLen = 0; // bin ich gerade loaded und habe dazu zeitweilig die MaxTextLen umgesetzt ? - if (m_nMaxLen) + if ( m_bMaxTextLenModified ) { // -> fuer die Dauer des Speicherns meinem aggregierten Model die alte TextLen einreden // before doing this we have to save the current text value of the aggregate, as this may be affected by resetting the text len // FS - 08.12.99 - 70606 aCurrentText = m_xAggregateSet->getPropertyValue(PROPERTY_TEXT); + m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN) >>= nOldTextLen; m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, makeAny((sal_Int16)0)); } OEditBaseModel::write(_rxOutStream); - if (m_nMaxLen) + if ( m_bMaxTextLenModified ) { // wieder zuruecksetzen - m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, makeAny((sal_Int16)m_nMaxLen)); + m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, makeAny(nOldTextLen)); // and reset the text // First we set it to an empty string : Without this the second setPropertyValue would not do anything as it thinks // we aren't changing the prop (it didn't notify the - implicite - change of the text prop while setting the max text len) @@ -584,8 +602,8 @@ void OEditModel::_loaded(const EventObject& rEvent) if (m_nKeyType != NumberFormat::SCIENTIFIC) { - m_nMaxLen = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)); - if (!m_nMaxLen) + m_bMaxTextLenModified = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)) != 0; + if ( !m_bMaxTextLenModified ) { sal_Int32 nFieldLen; m_xField->getPropertyValue(::rtl::OUString::createFromAscii("Precision")) >>= nFieldLen; @@ -596,11 +614,11 @@ void OEditModel::_loaded(const EventObject& rEvent) aVal <<= (sal_Int16)nFieldLen; m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal); - m_nMaxLen = static_cast<sal_Int16>(nFieldLen); // damit das Ganze beim _unloaded wieder zurueckgesetzt wird + m_bMaxTextLenModified = sal_True; } } else - m_nMaxLen = 0; + m_bMaxTextLenModified = sal_False; // to get sure that the text len won't be set in unloaded } } } @@ -611,12 +629,12 @@ void OEditModel::_unloaded() OEditBaseModel::_unloaded(); if (m_xField.is()) { - if (m_nMaxLen) + if ( m_bMaxTextLenModified ) { Any aVal; aVal <<= (sal_Int16)0; // nur wenn es 0 war, habe ich es in _loaded umgesetzt m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal); - m_nMaxLen = 0; + m_bMaxTextLenModified = sal_False; } m_xFormatter = 0; diff --git a/forms/source/component/Edit.hxx b/forms/source/component/Edit.hxx index 8b6d6ac98143..1010ed481273 100644 --- a/forms/source/component/Edit.hxx +++ b/forms/source/component/Edit.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Edit.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: fs $ $Date: 2002-12-02 09:56:29 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,11 +86,11 @@ class OEditModel ::com::sun::star::util::Date m_aNullDate; sal_Int32 m_nFieldType; sal_Int16 m_nKeyType; - sal_Int16 m_nMaxLen; + sal_Bool m_bMaxTextLenModified : 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate - sal_Bool m_bWritingFormattedFake : 1; + sal_Bool m_bWritingFormattedFake : 1; // are we writing something which should be interpreted as formatted upon reading? - sal_Bool m_bNumericField : 1; + sal_Bool m_bNumericField : 1; // are we bound to some kind of numeric field? static sal_Int32 nTextHandle; @@ -115,6 +115,8 @@ public: // ::com::sun::star::form::XBoundComponent virtual sal_Bool _commit(); + // XPropertySet + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; // ::com::sun::star::io::XPersistObject virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx new file mode 100644 index 000000000000..274967eb335d --- /dev/null +++ b/forms/source/component/Filter.cxx @@ -0,0 +1,1058 @@ +/************************************************************************* + * + * $RCSfile: Filter.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-25 18:01:15 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef FORMS_COMPONENT_FILTER_HXX +#include "Filter.hxx" +#endif + +#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ +#include <com/sun/star/form/FormComponentType.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCHECKBOX_HPP_ +#include <com/sun/star/awt/XCheckBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XRADIOBUTTON_HPP_ +#include <com/sun/star/awt/XRadioButton.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XLISTBOX_HPP_ +#include <com/sun/star/awt/XListBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XCOMBOBOX_HPP_ +#include <com/sun/star/awt/XComboBox.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_VCLWINDOWPEERATTRIBUTE_HPP_ +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XVCLWINDOWPEER_HPP_ +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include <com/sun/star/container/XChild.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDDB_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XCOLUMN_HPP_ +#include <com/sun/star/sdb/XColumn.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_ +#include <com/sun/star/beans/NamedValue.hpp> +#endif + +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/dbconversion.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif +#ifndef _COMPHELPER_NUMBERS_HXX_ +#include <comphelper/numbers.hxx> +#endif +#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX +#include <unotools/localedatawrapper.hxx> +#endif +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/helper/vclunohelper.hxx> +#endif +#ifndef _SV_WINTYPES_HXX +#include <vcl/wintypes.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _VCL_STDTEXT_HXX +#include <vcl/stdtext.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef _FRM_PROPERTY_HXX_ +#include "property.hxx" +#endif +#ifndef _FRM_PROPERTY_HRC_ +#include "property.hrc" +#endif +#ifndef _FRM_RESOURCE_HXX_ +#include "frm_resource.hxx" +#endif +#ifndef _FRM_RESOURCE_HRC_ +#include "frm_resource.hrc" +#endif +#ifndef FORMS_MODULE_HXX +#include "formsmodule.hxx" +#endif + +//-------------------------------------------------------------------------- +extern "C" void SAL_CALL createRegistryInfo_OFilterControl() +{ + static ::frm::OMultiInstanceAutoRegistration< ::frm::OFilterControl > aAutoRegistration; +} + +//......................................................................... +namespace frm +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::beans; + using namespace ::com::sun::star::sdb; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdbcx; + using namespace ::com::sun::star::util; + using namespace ::com::sun::star::form; + using namespace ::com::sun::star::container; + using namespace ::com::sun::star::ui::dialogs; + + using namespace ::connectivity; + + //===================================================================== + // OFilterControl + //===================================================================== + //--------------------------------------------------------------------- + OFilterControl::OFilterControl( const Reference< XMultiServiceFactory >& _rxORB ) + :m_aTextListeners( *this ) + ,m_bFilterList( sal_False ) + ,m_bMultiLine( sal_False ) + ,m_nControlClass( FormComponentType::TEXTFIELD ) + ,m_bFilterListFilled( sal_False ) + ,m_xORB( _rxORB ) + ,m_aParser( _rxORB ) + { + } + + //--------------------------------------------------------------------- + sal_Bool OFilterControl::ensureInitialized( ) + { + if ( !m_xField.is() ) + { + OSL_ENSURE( sal_False, "OFilterControl::ensureInitialized: improperly initialized: no field!" ); + return sal_False; + } + + if ( !m_xMetaData.is() ) + { + OSL_ENSURE( sal_False, "OFilterControl::ensureInitialized: improperly initialized: no database meta data!" ); + return sal_False; + } + + if ( !m_xFormatter.is() ) + { + // we can create one from the connection, if it's an SDB connection + Reference< XConnection > xConn( m_xMetaData->getConnection() ); + Reference< XNumberFormatsSupplier > xFormatSupplier = ::dbtools::getNumberFormats( xConn, sal_True, m_xORB ); + + if ( xFormatSupplier.is() ) + { + m_xFormatter = m_xFormatter.query( + m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) ) ) ); + if ( m_xFormatter.is() ) + m_xFormatter->attachNumberFormatsSupplier( xFormatSupplier ); + } + } + if ( !m_xFormatter.is() ) + { + OSL_ENSURE( sal_False, "OFilterControl::ensureInitialized: no number formatter!" ); + // no fallback anymore + return sal_False; + } + + return sal_True; + } + + //--------------------------------------------------------------------- + Any SAL_CALL OFilterControl::queryAggregation( const Type & rType ) throw(RuntimeException) + { + Any aRet = UnoControl::queryAggregation( rType); + if(!aRet.hasValue()) + aRet = OFilterControl_BASE::queryInterface(rType); + + return aRet; + } + //------------------------------------------------------------------ + // generate a uniqueId + const Sequence< sal_Int8 > & OFilterControl::getUnoTunnelId() + { + static Sequence< sal_Int8 > * pSeq = 0; + if( !pSeq ) + { + ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !pSeq ) + { + static Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0,sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; + } + // return implementation specific data + //------------------------------------------------------------------ + sal_Int64 OFilterControl::getSomething( const Sequence< sal_Int8 > & rId ) + { + if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; + } + + + //--------------------------------------------------------------------- + ::rtl::OUString OFilterControl::GetComponentServiceName() + { + ::rtl::OUString aServiceName; + switch (m_nControlClass) + { + case FormComponentType::RADIOBUTTON: + aServiceName = ::rtl::OUString::createFromAscii("radiobutton"); + break; + case FormComponentType::CHECKBOX: + aServiceName = ::rtl::OUString::createFromAscii("checkbox"); + break; + case FormComponentType::COMBOBOX: + aServiceName = ::rtl::OUString::createFromAscii("combobox"); + break; + case FormComponentType::LISTBOX: + aServiceName = ::rtl::OUString::createFromAscii("listbox"); + break; + default: + if (m_bMultiLine) + aServiceName = ::rtl::OUString::createFromAscii("MultiLineEdit"); + else + aServiceName = ::rtl::OUString::createFromAscii("Edit"); + } + return aServiceName; + } + + // XComponent + //--------------------------------------------------------------------- + void OFilterControl::dispose() throw( RuntimeException ) + { + EventObject aEvt(*this); + m_aTextListeners.disposeAndClear( aEvt ); + UnoControl::dispose(); + } + + //--------------------------------------------------------------------- + void OFilterControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException) + { + UnoControl::createPeer( rxToolkit, rParentPeer ); + + Reference< XVclWindowPeer > xVclWindow( getPeer(), UNO_QUERY ); + Any aValue; + if (xVclWindow.is()) + { + switch (m_nControlClass) + { + case FormComponentType::CHECKBOX: + { + // checkboxes always have a tristate-mode + sal_Bool bB(sal_True); + aValue.setValue(&bB,::getBooleanCppuType()); + xVclWindow->setProperty(PROPERTY_TRISTATE, aValue); + + aValue <<= (sal_Int32)STATE_DONTKNOW; + xVclWindow->setProperty(PROPERTY_STATE, aValue); + + Reference< XCheckBox > xBox( getPeer(), UNO_QUERY ); + xBox->addItemListener(this); + + } break; + case FormComponentType::RADIOBUTTON: + { + aValue <<= (sal_Int32)STATE_NOCHECK; + xVclWindow->setProperty(PROPERTY_STATE, aValue); + + Reference< XRadioButton > xRadio( getPeer(), UNO_QUERY ); + xRadio->addItemListener(this); + } break; + case FormComponentType::LISTBOX: + { + Reference< XListBox > xListBox( getPeer(), UNO_QUERY ); + xListBox->addItemListener(this); + } + case FormComponentType::COMBOBOX: // no break; + { + sal_Bool bB(sal_True); + aValue.setValue(&bB,::getBooleanCppuType()); + xVclWindow->setProperty(PROPERTY_AUTOCOMPLETE, aValue); + } + default: // no break; + { + Reference< XWindow > xWindow( getPeer(), UNO_QUERY ); + xWindow->addFocusListener(this); + + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + xText->setMaxTextLen(0); + } break; + } + } + + // filter controls are _never_ readonly + // #107013# - 2002-02-03 - fs@openoffice.org + Reference< XPropertySet > xModel( getModel(), UNO_QUERY ); + OSL_ENSURE( xModel.is(), "OFilterControl::createPeer: no model!" ); + Reference< XPropertySetInfo > xModelPSI; + if ( xModel.is() ) + xModelPSI = xModel->getPropertySetInfo(); + if ( xModelPSI.is() && xModelPSI->hasPropertyByName( PROPERTY_READONLY ) ) + xVclWindow->setProperty( PROPERTY_READONLY, makeAny( sal_False ) ); + + if (m_bFilterList) + m_bFilterListFilled = sal_False; + } + + //--------------------------------------------------------------------- + void OFilterControl::PrepareWindowDescriptor( WindowDescriptor& rDescr ) + { + if (m_bFilterList) + rDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN; + } + + //--------------------------------------------------------------------- + void OFilterControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal ) + { + // these properties are ignored + if (rPropName == PROPERTY_TEXT || + rPropName == PROPERTY_STATE) + return; + + UnoControl::ImplSetPeerProperty( rPropName, rVal ); + } + + // XEventListener + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::disposing(const EventObject& Source) throw( RuntimeException ) + { + UnoControl::disposing(Source); + } + + // XItemListener + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::itemStateChanged( const ItemEvent& rEvent ) throw(RuntimeException) + { + ::rtl::OUString aText; + switch (m_nControlClass) + { + case FormComponentType::CHECKBOX: + { + switch (rEvent.Selected) + { + case STATE_CHECK: + aText = ::rtl::OUString::createFromAscii("1"); + break; + case STATE_NOCHECK: + aText = ::rtl::OUString::createFromAscii("0"); + break; + } + } break; + case FormComponentType::LISTBOX: + { + Sequence< ::rtl::OUString> aValueSelection; + Reference< XPropertySet > aPropertyPointer(getModel(), UNO_QUERY); + aPropertyPointer->getPropertyValue(PROPERTY_VALUE_SEQ) >>= aValueSelection; + if (rEvent.Selected <= aValueSelection.getLength()) + aText = aValueSelection.getConstArray()[rEvent.Selected]; + } break; + case FormComponentType::RADIOBUTTON: + { + if (rEvent.Selected == STATE_CHECK) + aText = ::comphelper::getString(Reference< XPropertySet > (getModel(), UNO_QUERY)->getPropertyValue(PROPERTY_REFVALUE)); + } break; + } + + if (m_aText.compareTo(aText)) + { + m_aText = aText; + TextEvent aEvt; + aEvt.Source = *this; + ::cppu::OInterfaceIteratorHelper aIt( m_aTextListeners ); + while( aIt.hasMoreElements() ) + ((XTextListener *)aIt.next())->textChanged( aEvt ); + } + } + + //--------------------------------------------------------------------- + void OFilterControl::implInitFilterList() + { + if ( !ensureInitialized( ) ) + // already asserted in ensureInitialized + return; + + // declare here for later disposal + Reference< XResultSet > xListCursor; + Reference< XStatement > xStatement; + + try + { + m_bFilterListFilled = sal_True; + + Reference< XPropertySet > xSet(getModel(), UNO_QUERY); + if (xSet.is() && m_xField.is()) + { + ::rtl::OUString sName; + m_xField->getPropertyValue(PROPERTY_NAME) >>= sName; + + // here we need a table to which the field belongs to + Reference< XChild > xModelAsChild( xSet, UNO_QUERY ); + Reference< XRowSet > xForm( xModelAsChild->getParent(), UNO_QUERY ); + Reference< XPropertySet > xFormAsSet( xForm, UNO_QUERY ); + + // Connection holen + Reference< XConnection > xConnection; + if ( xForm.is() ) + xConnection = ::dbtools::getConnection( xForm ); + Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY ); + OSL_ENSURE( xFactory.is() && xFormAsSet.is(), "OFilterControl::implInitFilterList: invalid form or invalid connection!" ); + if ( !xFactory.is() || !xFormAsSet.is() ) + return; + + // create a query composer + Reference< XSQLQueryComposer > xComposer = xFactory->createQueryComposer(); + OSL_ENSURE( xComposer.is() , "OFilterControl::implInitFilterList: invalid query composer!" ); + if ( !xComposer.is() ) + return; + + // set the statement on the composer, ... + ::rtl::OUString sStatement; + xFormAsSet->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sStatement; + xComposer->setQuery( sStatement ); + + // ... and ask it for the involved tables and queries + Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY ); + Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY ); + + Reference< XNameAccess > xFieldNames; + if ( xSuppColumns.is() ) xFieldNames = xSuppColumns->getColumns(); + Reference< XNameAccess > xTablesNames; + if ( xSuppTables.is() ) xTablesNames = xSuppTables->getTables(); + + if ( !xFieldNames.is() || !xTablesNames.is() ) + { + OSL_ENSURE( sal_False, "OFilterControl::implInitFilterList: invalid query composer (no fields or no tables supplied)!" ); + return; + } + + // search the field + Reference< XPropertySet > xComposerFieldAsSet; + if ( xFieldNames->hasByName( sName ) ) + xFieldNames->getByName( sName ) >>= xComposerFieldAsSet; + + if ( xComposerFieldAsSet.is() + && ::comphelper::hasProperty( PROPERTY_TABLENAME, xComposerFieldAsSet ) + && ::comphelper::hasProperty( PROPERTY_REALNAME, xComposerFieldAsSet ) + ) + { + ::rtl::OUString sFieldName, sTableName; + xComposerFieldAsSet->getPropertyValue(PROPERTY_REALNAME) >>= sFieldName; + xComposerFieldAsSet->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName; + + // no possibility to create a select statement + // looking for the complete table name + if (!xTablesNames->hasByName(sTableName)) + return; + + // this is the tablename + Reference< XNamed > xName; + xTablesNames->getByName(sTableName) >>= xName; + OSL_ENSURE(xName.is(),"No XName interface!"); + sTableName = xName->getName(); + + // ein Statement aufbauen und abschicken als query + // Access to the connection + + Reference< XColumn > xDataField; + + Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData(); + ::rtl::OUString aQuote = xMeta->getIdentifierQuoteString(); + ::rtl::OUStringBuffer aStatement; + aStatement.appendAscii( "SELECT DISTINCT" ); + aStatement.append( ::dbtools::quoteName( aQuote, sName ) ); + + if ( sFieldName.getLength() && ( sName != sFieldName ) ) + { + aStatement.appendAscii(" AS "); + aStatement.append( ::dbtools::quoteName(aQuote, sFieldName) ); + } + + aStatement.appendAscii( " FROM " ); + aStatement.append( ::dbtools::quoteTableName( xMeta, sTableName, ::dbtools::eInDataManipulation ) ); + ::rtl::OUString sStatement( aStatement.makeStringAndClear( ) ); + + xStatement = xConnection->createStatement(); + xListCursor = xStatement->executeQuery( sStatement ); + + Reference< XColumnsSupplier > xSupplyCols(xListCursor, UNO_QUERY); + Reference< XIndexAccess > xFields; + if (xSupplyCols.is()) + xFields = Reference< XIndexAccess > (xSupplyCols->getColumns(), UNO_QUERY); + if (xFields.is()) + xFields->getByIndex(0) >>= xDataField; + if (!xDataField.is()) + return; + + + sal_Int16 i = 0; + vector< ::rtl::OUString> aStringList; + aStringList.reserve(16); + ::rtl::OUString aStr; + + ::com::sun::star::util::Date aNullDate( ::dbtools::DBTypeConversion::getStandardDate() ); + sal_Int32 nFormatKey = 0; + try + { + m_xFormatter->getNumberFormatsSupplier()->getNumberFormatSettings()->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) + >>= aNullDate; + nFormatKey = ::comphelper::getINT32(m_xField->getPropertyValue(PROPERTY_FORMATKEY)); + } + catch(const Exception&) + { + } + + + sal_Int16 nKeyType = ::comphelper::getNumberFormatType(m_xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey); + while (!xListCursor->isAfterLast() && i++ < SHRT_MAX) // max anzahl eintraege + { + aStr = ::dbtools::DBTypeConversion::getValue(xDataField, m_xFormatter, aNullDate, nFormatKey, nKeyType); + + aStringList.push_back(aStr); + xListCursor->next(); + } + + Sequence< ::rtl::OUString> aStringSeq(aStringList.size()); + ::rtl::OUString* pustrStrings = aStringSeq.getArray(); + for (i = 0; i < (sal_Int16)aStringList.size(); ++i) + pustrStrings[i] = aStringList[i]; + + Reference< XComboBox > xComboBox( getPeer(), UNO_QUERY); + if ( xComboBox.is() ) + { + xComboBox->addItems(aStringSeq, 0); + // set the drop down line count + sal_Int16 nLineCount = ::std::min( (sal_Int16)10, (sal_Int16)aStringSeq.getLength() ); + xComboBox->setDropDownLineCount( nLineCount ); + } + } + } + } + catch( const Exception& e ) + { + e; // make compiler happy + OSL_ENSURE( sal_False, "OFilterControl::implInitFilterList: caught an exception!" ); + } + + ::comphelper::disposeComponent( xListCursor ); + ::comphelper::disposeComponent( xStatement ); + } + + // XFocusListener + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::focusGained(const FocusEvent& e) throw( RuntimeException ) + { + // should we fill the combobox? + if (m_bFilterList && !m_bFilterListFilled) + implInitFilterList(); + } + + //--------------------------------------------------------------------- + sal_Bool SAL_CALL OFilterControl::commit() throw(RuntimeException) + { + if ( !ensureInitialized( ) ) + // already asserted in ensureInitialized + return sal_True; + + ::rtl::OUString aText; + switch (m_nControlClass) + { + case FormComponentType::TEXTFIELD: + case FormComponentType::COMBOBOX: + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + aText = xText->getText(); + } break; + default: + return sal_True; + } + if (m_aText.compareTo(aText)) + { + // check the text with the SQL-Parser + ::rtl::OUString aNewText(aText); + aNewText.trim(); + if (aNewText.getLength()) + { + ::rtl::OUString aErrorMsg; + Locale aAppLocale = Application::GetSettings().GetUILocale(); + OSQLParseNode* pParseNode = m_aParser.predicateTree(aErrorMsg, aNewText, m_xFormatter, m_xField); + + if ( !pParseNode ) + { // is it a text field ? + + // get the type + sal_Int32 nType = DataType::OTHER; + m_xField->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nType; + + if ( ( DataType::CHAR == nType ) + || ( DataType::VARCHAR == nType ) + || ( DataType::LONGVARCHAR == nType ) + ) + { // yes -> force a quoted text and try again + String sQuoted(aNewText); + if ( sQuoted.Len() + && ( ( sQuoted.GetChar( 0 ) != '\'' ) + || ( sQuoted.GetChar( sQuoted.Len() - 1 ) != '\'' ) + ) + ) + { + sQuoted.SearchAndReplaceAll( '\'', String::CreateFromAscii( "''" ) ); + String sTemp( '\'' ); + ( sTemp += sQuoted ) += '\''; + sQuoted = sTemp; + } + pParseNode = m_aParser.predicateTree( aErrorMsg, sQuoted, m_xFormatter, m_xField ); + } + } + + if ( pParseNode ) + { + ::rtl::OUString aPreparedText; + LocaleDataWrapper aLocaleWrapper(m_xORB,aAppLocale); + pParseNode->parseNodeToPredicateStr(aPreparedText, + m_xMetaData, + m_xFormatter, + m_xField, + aAppLocale, + (sal_Char)aLocaleWrapper.getNumDecimalSep().GetChar(0), + getParseContext()); + aNewText = aPreparedText; + } + else + { + // display the error and return sal_False + + SQLContext aError; + aError.Message = String( FRM_RES_STRING( RID_STR_SYNTAXERROR ) ); + aError.Details = aErrorMsg; + displayException( aError ); + + return sal_False; + } + } + + setText(aNewText); + TextEvent aEvt; + aEvt.Source = *this; + ::cppu::OInterfaceIteratorHelper aIt( m_aTextListeners ); + while( aIt.hasMoreElements() ) + static_cast< XTextListener* >( aIt.next() )->textChanged( aEvt ); + } + return sal_True; + } + + // XTextComponent + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::addTextListener(const Reference< XTextListener > & l) throw(RuntimeException) + { + m_aTextListeners.addInterface( l ); + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::removeTextListener(const Reference< XTextListener > & l) throw(RuntimeException) + { + m_aTextListeners.removeInterface( l ); + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::setText( const ::rtl::OUString& aText ) throw(RuntimeException) + { + if ( !ensureInitialized( ) ) + // already asserted in ensureInitialized + return; + + switch (m_nControlClass) + { + case FormComponentType::CHECKBOX: + { + Reference< XVclWindowPeer > xVclWindow( getPeer(), UNO_QUERY ); + if (xVclWindow.is()) + { + Any aValue; + if (aText.equals(::rtl::OUString::createFromAscii("1"))) + aValue <<= (sal_Int32)STATE_CHECK; + else if (aText.compareTo(::rtl::OUString::createFromAscii("0")) == 0) + aValue <<= (sal_Int32)STATE_NOCHECK; + else + aValue <<= (sal_Int32)STATE_DONTKNOW; + + m_aText = aText; + xVclWindow->setProperty(PROPERTY_STATE, aValue); + } + } break; + case FormComponentType::RADIOBUTTON: + { + Reference< XVclWindowPeer > xVclWindow( getPeer(), UNO_QUERY ); + if (xVclWindow.is()) + { + ::rtl::OUString aRefText = ::comphelper::getString(com::sun::star::uno::Reference< XPropertySet > (getModel(), UNO_QUERY)->getPropertyValue(PROPERTY_REFVALUE)); + Any aValue; + if (aText == aRefText) + aValue <<= (sal_Int32)STATE_CHECK; + else + aValue <<= (sal_Int32)STATE_NOCHECK; + m_aText = aText; + xVclWindow->setProperty(PROPERTY_STATE, aValue); + } + } break; + case FormComponentType::LISTBOX: + { + Reference< XListBox > xListBox( getPeer(), UNO_QUERY ); + if (xListBox.is()) + { + m_aText = aText; + xListBox->selectItem(m_aText, sal_True); + } + } break; + default: + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + { + m_aText = aText; + xText->setText(aText); + } + } + } + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + { + xText->insertText(rSel, aText); + m_aText = xText->getText(); + } + } + + //--------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OFilterControl::getText() throw(RuntimeException) + { + return m_aText; + } + + //--------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OFilterControl::getSelectedText( void ) throw(RuntimeException) + { + ::rtl::OUString aSelected; + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + aSelected = xText->getSelectedText(); + + return aSelected; + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + xText->setSelection( aSelection ); + } + + //--------------------------------------------------------------------- + ::com::sun::star::awt::Selection SAL_CALL OFilterControl::getSelection( void ) throw(::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::awt::Selection aSel; + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + aSel = xText->getSelection(); + return aSel; + } + + //--------------------------------------------------------------------- + sal_Bool SAL_CALL OFilterControl::isEditable( void ) throw(RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + return xText.is() && xText->isEditable(); + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::setEditable( sal_Bool bEditable ) throw(RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + xText->setEditable(bEditable); + } + + //--------------------------------------------------------------------- + sal_Int16 SAL_CALL OFilterControl::getMaxTextLen() throw(RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + return xText.is() ? xText->getMaxTextLen() : 0; + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::setMaxTextLen( sal_Int16 nLength ) throw(RuntimeException) + { + Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); + if (xText.is()) + xText->setMaxTextLen(nLength); + } + + //--------------------------------------------------------------------- + void OFilterControl::displayException( const ::com::sun::star::sdb::SQLContext& _rExcept ) + { + try + { + Sequence< Any > aArgs(2); + aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, makeAny( _rExcept ), PropertyState_DIRECT_VALUE); + aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny( m_xMessageParent ), PropertyState_DIRECT_VALUE); + + static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.sdb.ErrorMessageDialog" ); + Reference< XExecutableDialog > xErrorDialog( m_xORB->createInstanceWithArguments( s_sDialogServiceName, aArgs ), UNO_QUERY ); + if ( xErrorDialog.is() ) + xErrorDialog->execute(); + else + { + Window* pMessageParent = VCLUnoHelper::GetWindow( m_xMessageParent ); + ShowServiceNotAvailableError( pMessageParent, s_sDialogServiceName, sal_True ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "displayException: could not display the error message!" ); + } + } + + //--------------------------------------------------------------------- + void SAL_CALL OFilterControl::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) + { + const Any* pArguments = aArguments.getConstArray(); + const Any* pArgumentsEnd = pArguments + aArguments.getLength(); + + PropertyValue aProp; + NamedValue aValue; + const ::rtl::OUString* pName = NULL; + const Any* pValue = NULL; + + for ( ; pArguments != pArgumentsEnd; ++pArguments ) + { + // we recognize PropertyValues and NamedValues + if ( *pArguments >>= aProp ) + { + pName = &aProp.Name; + pValue = &aProp.Value; + } + else if ( *pArguments >>= aValue ) + { + pName = &aValue.Name; + pValue = &aValue.Value; + } + else + { + DBG_ERROR( "OFilterControl::initialize: unrecognized argument!" ); + continue; + } + + if ( 0 == pName->compareToAscii( "MessageParent" ) ) + { + // the message parent + *pValue >>= m_xMessageParent; + OSL_ENSURE( m_xMessageParent.is(), "OFilterControl::initialize: invalid MessageParent!" ); + } + else if ( 0 == pName->compareToAscii( "NumberFormatter" ) ) + { + // the number format. This argument is optional. + *pValue >>= m_xFormatter; + OSL_ENSURE( m_xFormatter.is(), "OFilterControl::initialize: invalid NumberFormatter!" ); + } + else if ( 0 == pName->compareToAscii( "ControlModel" ) ) + { + // the control model for which we act as filter control + Reference< XPropertySet > xControlModel; + if ( !(*pValue >>= xControlModel ) || !xControlModel.is() ) + { + OSL_ENSURE( sal_False, "OFilterControl::initialize: invalid control model argument!" ); + continue; + } + + // some properties which are "derived" from the control model we're working for + // ................................................... + // the field + m_xField.clear(); + OSL_ENSURE( ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ), "OFilterControl::initialize: control model needs a bound field property!" ); + xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= m_xField; + + // ................................................... + // filter list and control class + m_bFilterList = ::comphelper::hasProperty( PROPERTY_FILTERPROPOSAL, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_FILTERPROPOSAL ) ); + if ( m_bFilterList ) + m_nControlClass = FormComponentType::COMBOBOX; + else + { + sal_Int16 nClassId = ::comphelper::getINT16( xControlModel->getPropertyValue( PROPERTY_CLASSID ) ); + switch (nClassId) + { + case FormComponentType::CHECKBOX: + case FormComponentType::RADIOBUTTON: + case FormComponentType::LISTBOX: + case FormComponentType::COMBOBOX: + m_nControlClass = nClassId; + break; + default: + m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) ); + m_nControlClass = FormComponentType::TEXTFIELD; + break; + } + } + + // ................................................... + // the connection meta data for the form which we're working for + Reference< XChild > xModel( xControlModel, UNO_QUERY ); + Reference< XRowSet > xForm; + if ( xModel.is() ) + xForm = xForm.query( xModel->getParent() ); + Reference< XConnection > xConn = ::dbtools::getConnection( xForm ); + + m_xMetaData.clear(); + if ( xConn.is() ) + m_xMetaData = xConn->getMetaData(); + OSL_ENSURE( m_xMetaData.is(), "OFilterControl::initialize: unable to determine the database meta data for the form's connection!" ); + } + } + } + + //--------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OFilterControl::getImplementationName( ) throw (RuntimeException) + { + return getImplementationName_Static(); + } + + //--------------------------------------------------------------------- + sal_Bool SAL_CALL OFilterControl::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); + const ::rtl::OUString* pArray = aSupported.getConstArray(); + for( sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray ) + if( pArray->equals( ServiceName ) ) + return sal_True; + return sal_False; + } + + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL OFilterControl::getSupportedServiceNames( ) throw (RuntimeException) + { + return getSupportedServiceNames_Static(); + } + + //--------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OFilterControl::getImplementationName_Static() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.forms.OFilterControl" ) ); + } + + //--------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL OFilterControl::getSupportedServiceNames_Static() + { + Sequence< ::rtl::OUString > aNames( 2 ); + aNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.control.FilterControl" ) ); + aNames[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControl" ) ); + return aNames; + } + + //--------------------------------------------------------------------- + Reference< XInterface > SAL_CALL OFilterControl::Create( const Reference< XMultiServiceFactory >& _rxFactory ) + { + return static_cast< XServiceInfo* >( new OFilterControl( _rxFactory ) ); + } + +//......................................................................... +} // namespace frm +//......................................................................... diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx new file mode 100644 index 000000000000..37086f65abe9 --- /dev/null +++ b/forms/source/component/Filter.hxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * $RCSfile: Filter.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2003-03-25 18:01:15 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef FORMS_COMPONENT_FILTER_HXX +#define FORMS_COMPONENT_FILTER_HXX + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_FORM_XBOUNDCOMPONENT_HPP_ +#include <com/sun/star/form/XBoundComponent.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_ +#include <com/sun/star/awt/XTextComponent.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif + +#ifndef _TOOLKIT_CONTROLS_UNOCONTROL_HXX_ +#include <toolkit/controls/unocontrol.hxx> +#endif + +#ifndef _TOOLKIT_AWT_LISTENERMULTIPLEXER_HXX_ +#include <toolkit/helper/listenermultiplexer.hxx> +#endif + +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> +#endif + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#include <cppuhelper/implbase4.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif + +#ifndef SVX_QUERYDESIGNCONTEXT_HXX +#include <svx/ParseContext.hxx> +#endif + +class Window; + +//......................................................................... +namespace frm +{ +//......................................................................... + + //===================================================================== + // OFilterControl + //===================================================================== + typedef ::cppu::ImplHelper5 < ::com::sun::star::awt::XTextComponent + , ::com::sun::star::awt::XFocusListener + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::form::XBoundComponent + , ::com::sun::star::lang::XInitialization + > OFilterControl_BASE; + + class OFilterControl :public UnoControl + ,public OFilterControl_BASE + ,public ::svxform::OParseContextClient + { + TextListenerMultiplexer m_aTextListeners; + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMessageParent; + + ::rtl::OUString m_aText; + ::connectivity::OSQLParser m_aParser; + sal_Int16 m_nControlClass; // which kind of control do we use? + sal_Bool m_bFilterList : 1; + sal_Bool m_bMultiLine : 1; + sal_Bool m_bFilterListFilled : 1; + + private: +// OFilterControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + + void implInitFilterList(); + + public: + OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ); + + DECLARE_UNO3_AGG_DEFAULTS(OFilterControl,OWeakAggObject); + ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 > & rId ); + + virtual ::rtl::OUString GetComponentServiceName(); + virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & rxToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer ) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::awt::XTextComponent + virtual void SAL_CALL addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setText( const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL isEditable() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setEditable( sal_Bool bEditable ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setMaxTextLen( sal_Int16 nLength ) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Int16 SAL_CALL getMaxTextLen() throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::form::XBoundComponent + virtual void SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & l) throw( ::com::sun::star::uno::RuntimeException ) {} + virtual void SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & l) throw( ::com::sun::star::uno::RuntimeException ) {} + virtual sal_Bool SAL_CALL commit() throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::awt::XFocusListener + virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ){} + + // ::com::sun::star::awt::XItemListener + virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::util::XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + // com::sun::star::lang::XServiceInfo - static version + static ::rtl::OUString SAL_CALL getImplementationName_Static(); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static(); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCurrentServiceNames_Static(); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); + + protected: + virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc ); + virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); + + sal_Bool ensureInitialized( ); + + void displayException( const ::com::sun::star::sdb::SQLContext& _rExcept ); + }; +//......................................................................... +} // namespace frm +//......................................................................... + +#endif // FORMS_COMPONENT_FILTER_HXX diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index d1ed75fecc1e..aeadcf22b449 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FormComponent.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: fs $ $Date: 2002-12-12 16:13:48 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -187,7 +187,7 @@ OControl::~OControl() Any SAL_CALL OControl::queryAggregation( const Type& _rType ) throw(RuntimeException) { // ask the base class - Any aReturn = OComponentHelper::queryAggregation(_rType); + Any aReturn( OComponentHelper::queryAggregation(_rType) ); // ask our own interfaces if (!aReturn.hasValue()) { @@ -372,7 +372,7 @@ Sequence< Type> OBoundControl::_getTypes() Any SAL_CALL OBoundControl::queryAggregation(const Type& _rType) throw(RuntimeException) { // ask the base class - Any aReturn = OControl::queryAggregation(_rType); + Any aReturn(OControl::queryAggregation(_rType)); // ask our own interfaces if (!aReturn.hasValue()) aReturn = OBoundControl_BASE::queryInterface(_rType); @@ -454,17 +454,17 @@ Sequence<Type> OControlModel::_getTypes() Any SAL_CALL OControlModel::queryAggregation(const Type& _rType) throw (RuntimeException) { // base class 1 - Any aReturn = OComponentHelper::queryAggregation(_rType); + Any aReturn(OComponentHelper::queryAggregation(_rType)); // base class 2 if (!aReturn.hasValue()) { - aReturn = OPropertySetAggregationHelper::queryInterface(_rType); + aReturn = OControlModel_BASE::queryInterface(_rType); // our own interfaces if (!aReturn.hasValue()) { - aReturn = OControlModel_BASE::queryInterface(_rType); + aReturn = OPropertySetAggregationHelper::queryInterface(_rType); // our aggregate if (!aReturn.hasValue() && m_xAggregate.is() && !_rType.equals(::getCppuType(static_cast< Reference< XCloneable>* >(NULL)))) aReturn = m_xAggregate->queryAggregation(_rType); @@ -665,7 +665,7 @@ Sequence<rtl::OUString> SAL_CALL OControlModel::getSupportedServiceNames() throw aSupported.realloc(aSupported.getLength() + 2); ::rtl::OUString* pArray = aSupported.getArray(); - pArray[aSupported.getLength()-2] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponent"); + pArray[aSupported.getLength()-2] = FRM_SUN_FORMCOMPONENT; pArray[aSupported.getLength()-1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormControlModel"); return aSupported; @@ -923,9 +923,7 @@ DBG_NAME(frm_OBoundControlModel); //------------------------------------------------------------------ Any SAL_CALL OBoundControlModel::queryAggregation( const Type& _rType ) throw (RuntimeException) { - Any aReturn; - - aReturn = OControlModel::queryAggregation(_rType); + Any aReturn( OControlModel::queryAggregation(_rType) ); if (!aReturn.hasValue()) { aReturn = OBoundControlModel_BASE1::queryInterface(_rType); @@ -1052,7 +1050,7 @@ void SAL_CALL OBoundControlModel::disposing(const com::sun::star::lang::EventObj } else if (m_xLabelControl == _rEvent.Source) { - Reference<XPropertySet> xOldValue = m_xLabelControl; + Reference<XPropertySet> xOldValue = m_xLabelControl; m_xLabelControl = NULL; // fire a property change event @@ -1581,31 +1579,37 @@ void OBoundControlModel::reset() throw (RuntimeException) osl::ClearableMutexGuard aGuard(m_aMutex); m_bResetting = sal_True; - // gesondertes Verhalten bei Datenbankverbindung - if (m_xField.is()) + sal_Bool bSimpleReset = !m_xField.is() // no connection to a database field + || ( m_xCursor.is() // OR we have an improperly positioned cursor + && ( m_xCursor->isAfterLast() + || m_xCursor->isBeforeFirst() + ) + ); + + if ( !bSimpleReset ) { - // nur wenn der derzeitige Wert des Feldes auf NULL steht - // werden die Defaultwerte gesetzt - // ansonsten soll der aktuelle Werte nochmals aus dem Feld gesetzt werden - // dieses Verhalten ist noch nicht ganz ausgereift, was passiert wenn das Feld einen Defaultwert besitzt - // und das Control auch? + // The default values will be set if and only if the current value of the field which we're bound + // to is NULL. + // Else, the current field value should be refreshed + // This behaviour is not completely ... "matured": What should happen if the field as well as the + // control have a default value? sal_Bool bIsNull = sal_True; // we have to access the field content at least once to get a reliable result by XColumn::wasNull try { m_xColumn->getString(); + bIsNull = m_xColumn->wasNull(); } catch(Exception&) { - DBG_ERROR("OBoundControlModel::reset : XColumn::getString is expected to always succeed !"); + DBG_ERROR("OBoundControlModel::reset : XColumn::getString and wasNull are expected to always succeed !"); } - bIsNull = m_xColumn->wasNull(); if (bIsNull) { - Reference<XPropertySet> xSet(m_xCursor, UNO_QUERY); sal_Bool bIsNewRecord = sal_False; + Reference<XPropertySet> xSet(m_xCursor, UNO_QUERY); if (xSet.is()) xSet->getPropertyValue(PROPERTY_ISNEW) >>= bIsNewRecord; if (bIsNewRecord) diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx index e547de893bce..b407746ca38e 100644 --- a/forms/source/component/FormattedFieldWrapper.cxx +++ b/forms/source/component/FormattedFieldWrapper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FormattedFieldWrapper.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: fs $ $Date: 2001-07-20 13:13:32 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -156,6 +156,39 @@ OFormattedFieldWrapper::OFormattedFieldWrapper(const Reference<XMultiServiceFact } //------------------------------------------------------------------ +OFormattedFieldWrapper::OFormattedFieldWrapper( const OFormattedFieldWrapper* _pCloneSource ) + :m_xServiceFactory( _pCloneSource->m_xServiceFactory ) + ,m_pEditPart( NULL ) +{ + Reference< XCloneable > xCloneAccess; + query_aggregation( _pCloneSource->m_xAggregate, xCloneAccess ); + + // clone the aggregate + if ( xCloneAccess.is() ) + { + increment( m_refCount ); + { + Reference< XCloneable > xClone = xCloneAccess->createClone(); + m_xAggregate = Reference< XAggregation >( xClone, UNO_QUERY ); + DBG_ASSERT(m_xAggregate.is(), "OFormattedFieldWrapper::OFormattedFieldWrapper : invalid aggregate clone!"); + + query_interface( xClone, m_xFormattedPart ); + + if ( _pCloneSource->m_pEditPart ) + m_pEditPart = new OEditModel( _pCloneSource->m_pEditPart, _pCloneSource->m_xServiceFactory ); + } + if ( m_xAggregate.is() ) + { // has to be in it's own block because of the temporary variable created by *this + m_xAggregate->setDelegator( static_cast< XWeak* >( this ) ); + } + decrement( m_refCount ); + } + else + { // the clone source does not yet have an aggregate -> we don't yet need one, too + } +} + +//------------------------------------------------------------------ OFormattedFieldWrapper::~OFormattedFieldWrapper() { // release the aggregated object (if any) @@ -193,12 +226,16 @@ Any SAL_CALL OFormattedFieldWrapper::queryAggregation(const Type& _rType) throw if (!aReturn.hasValue()) { - aReturn = ::cppu::queryInterface(_rType,static_cast<XPersistObject*>(this)); + aReturn = ::cppu::queryInterface( _rType, + static_cast< XPersistObject* >( this ), + static_cast< XCloneable* >( this ) + ); if (!aReturn.hasValue()) { // somebody requests an interface other than the basics (XInterface) and other than - // the only one we can supply without an aggregate. So ensure the aggregate exists. + // the two we can supply without an aggregate. So ensure + // the aggregate exists. ensureAggregate(); if (m_xAggregate.is()) aReturn = m_xAggregate->queryAggregation(_rType); @@ -358,6 +395,14 @@ void SAL_CALL OFormattedFieldWrapper::read(const Reference<XObjectInputStream>& } //------------------------------------------------------------------ +Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone( ) throw (RuntimeException) +{ + ensureAggregate(); + + return new OFormattedFieldWrapper( this ); +} + +//------------------------------------------------------------------ void OFormattedFieldWrapper::ensureAggregate() { if (m_xAggregate.is()) diff --git a/forms/source/component/FormattedFieldWrapper.hxx b/forms/source/component/FormattedFieldWrapper.hxx index ac349dab7cb1..d4b29b3165b9 100644 --- a/forms/source/component/FormattedFieldWrapper.hxx +++ b/forms/source/component/FormattedFieldWrapper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FormattedFieldWrapper.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: fs $ $Date: 2001-04-11 14:21:58 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,12 +65,15 @@ #ifndef _FORMS_FORMCOMPONENT_HXX_ #include "FormComponent.hxx" #endif -#ifndef _CPPUHELPER_IMPLBASE2_HXX_ -#include <cppuhelper/implbase2.hxx> +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#include <cppuhelper/implbase3.hxx> #endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif +#ifndef _COM_SUN_STAR_UTIL_XCLONEABLE_HPP_ +#include <com/sun/star/util/XCloneable.hpp> +#endif //......................................................................... namespace frm @@ -80,8 +83,9 @@ class OEditModel; //================================================================== //= OFormattedFieldWrapper //================================================================== -typedef ::cppu::WeakAggImplHelper2 < ::com::sun::star::io::XPersistObject +typedef ::cppu::WeakAggImplHelper3 < ::com::sun::star::io::XPersistObject , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::util::XCloneable > OFormattedFieldWrapper_Base; class OFormattedFieldWrapper : public OFormattedFieldWrapper_Base @@ -100,6 +104,7 @@ protected: OFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, sal_Bool _bActAsFormatted); // if _bActAsFormatted is sal_False, the state is undetermined until somebody calls ::read or does // anything which requires a living aggregate + OFormattedFieldWrapper( const OFormattedFieldWrapper* _pCloneSource ); virtual ~OFormattedFieldWrapper(); friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); @@ -115,11 +120,14 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); - // ::com::sun::star::io::XPersistObject + // XPersistObject virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + protected: /// ensure we're in a defined state, which means a FormattedModel _OR_ an EditModel void ensureAggregate(); diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index c13202c1f95e..37567227051f 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Grid.cxx,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: fs $ $Date: 2002-12-02 09:56:31 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -289,9 +289,10 @@ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContain StringSequence OGridControlModel::getSupportedServiceNames() throw(RuntimeException) { StringSequence aSupported = OControlModel::getSupportedServiceNames(); - aSupported.realloc(aSupported.getLength() + 1); + aSupported.realloc(aSupported.getLength() + 2); ::rtl::OUString*pArray = aSupported.getArray(); + pArray[aSupported.getLength()-2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel")); pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GRIDCONTROL; return aSupported; } diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index 81732a569df2..5d35c9d048e4 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: GroupManager.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: fs $ $Date: 2002-10-02 14:41:04 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -148,6 +148,7 @@ OGroupComp::OGroupComp(const OGroupComp& _rSource) ,m_xComponent( _rSource.m_xComponent ) ,m_nTabIndex( _rSource.m_nTabIndex ) ,m_nPos( _rSource.m_nPos ) + ,m_xControlModel(_rSource.m_xControlModel) { } @@ -156,6 +157,7 @@ OGroupComp::OGroupComp(const Reference<XPropertySet>& rxSet, sal_Int32 nInsertPo :m_xComponent( rxSet ) ,m_nTabIndex(0) ,m_nPos( nInsertPos ) + ,m_xControlModel(rxSet,UNO_QUERY) { if (m_xComponent.is()) { @@ -293,7 +295,7 @@ Sequence< Reference<XControlModel> > OGroup::GetControlModels() const ConstOGroupCompArrIterator aGroupComps = m_aCompArray.begin(); for (sal_Int32 i = 0; i < nLen; ++i, ++pModels, ++aGroupComps) { - *pModels = Reference<XControlModel> ((*aGroupComps).GetComponent(), UNO_QUERY); + *pModels = aGroupComps->GetControlModel(); } return aControlModelSeq; } @@ -332,57 +334,51 @@ void OGroupManager::disposing(const EventObject& evt) throw( RuntimeException ) //////////////////////////////////////////////////////////////// // Gruppen loeschen - m_aGroupArr.erase(m_aGroupArr.begin(), m_aGroupArr.end()); + m_aGroupArr.clear(); m_xContainer.clear(); } } - -//------------------------------------------------------------------ -void SAL_CALL OGroupManager::propertyChange(const PropertyChangeEvent& evt) throw ( ::com::sun::star::uno::RuntimeException) +// ----------------------------------------------------------------------------- +void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const Reference<XPropertySet>& _xSet) { - Reference<XPropertySet> xSet(evt.Source, UNO_QUERY); - // Component aus CompGroup entfernen - m_pCompGroup->RemoveComponent( xSet ); + m_pCompGroup->RemoveComponent( _xSet ); - // Component aus Gruppe entfernen - sal_Int32 nGroupPos; - ::rtl::OUString sGroupName; - if (evt.PropertyName == PROPERTY_NAME) - evt.OldValue >>= sGroupName; - else - xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; - - OGroup aSearchGroup( sGroupName ); + OGroupArr::iterator aFind = m_aGroupArr.find(_sGroupName); - if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess())) + if ( aFind != m_aGroupArr.end() ) { // Gruppe vorhanden - OGroup& rFoundGroup = m_aGroupArr[nGroupPos]; - rFoundGroup.RemoveComponent( xSet ); + aFind->second.RemoveComponent( _xSet ); // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren - if( rFoundGroup.Count() == 1 ) + if ( aFind->second.Count() == 1 ) { - for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin(); - aMapSearch < m_aActiveGroupMap.end(); - ++aMapSearch - ) - { - if( *aMapSearch == nGroupPos ) - { - m_aActiveGroupMap.erase(aMapSearch); - break; - } - } + OActiveGroups::iterator aActiveFind = ::std::find(m_aActiveGroupMap.begin(),m_aActiveGroupMap.end(),aFind); + if ( aActiveFind != m_aActiveGroupMap.end() ) + m_aActiveGroupMap.erase(aActiveFind); } } // Bei Component als PropertyChangeListener abmelden - xSet->removePropertyChangeListener( PROPERTY_NAME, this ); - if (hasProperty(PROPERTY_TABINDEX, xSet)) - xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this ); + _xSet->removePropertyChangeListener( PROPERTY_NAME, this ); + if (hasProperty(PROPERTY_TABINDEX, _xSet)) + _xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this ); +} +//------------------------------------------------------------------ +void SAL_CALL OGroupManager::propertyChange(const PropertyChangeEvent& evt) throw ( ::com::sun::star::uno::RuntimeException) +{ + Reference<XPropertySet> xSet(evt.Source, UNO_QUERY); + + // Component aus Gruppe entfernen + ::rtl::OUString sGroupName; + if (evt.PropertyName == PROPERTY_NAME) + evt.OldValue >>= sGroupName; + else + xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; + + removeFromGroupMap(sGroupName,xSet); // Component neu einordnen InsertElement( xSet ); @@ -437,23 +433,18 @@ sal_Int32 OGroupManager::getGroupCount() //------------------------------------------------------------------ void OGroupManager::getGroup(sal_Int32 nGroup, Sequence< Reference<XControlModel> >& _rGroup, ::rtl::OUString& _rName) { - sal_uInt16 nGroupPos= m_aActiveGroupMap[nGroup]; - OGroup& rGroup = m_aGroupArr[nGroupPos]; - _rName = rGroup.GetGroupName(); - _rGroup = rGroup.GetControlModels(); + OSL_ENSURE(nGroup >= 0 && nGroup < m_aActiveGroupMap.size(),"OGroupManager::getGroup: Invalid group index!"); + OGroupArr::iterator aGroupPos = m_aActiveGroupMap[nGroup]; + _rName = aGroupPos->second.GetGroupName(); + _rGroup = aGroupPos->second.GetControlModels(); } //------------------------------------------------------------------ void OGroupManager::getGroupByName(const ::rtl::OUString& _rName, Sequence< Reference<XControlModel> >& _rGroup) { - sal_Int32 nGroupPos; - OGroup aSearchGroup( _rName ); - - if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess())) - { - OGroup& rGroup = m_aGroupArr[nGroupPos]; - _rGroup = rGroup.GetControlModels(); - } + OGroupArr::iterator aFind = m_aGroupArr.find(_rName); + if ( aFind != m_aGroupArr.end() ) + _rGroup = aFind->second.GetControlModels(); } //------------------------------------------------------------------ @@ -468,44 +459,23 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet ) m_pCompGroup->InsertComponent( xSet ); // Component in Gruppe aufnehmen - sal_Int32 nPos; ::rtl::OUString sGroupName; xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; - OGroup aNewGroup( sGroupName ); - if (seek_entry(m_aGroupArr, aNewGroup, nPos, OGroupLess())) - { - // Gruppe existiert schon ... - } - else - { - // Gruppe muss neu angelegt werden - nPos = insert_sorted(m_aGroupArr, aNewGroup, OGroupLess()); + OGroupArr::iterator aFind = m_aGroupArr.find(sGroupName); - // Indizes der ActiveGroupMap anpassen - if (seek_entry(m_aGroupArr, aNewGroup, nPos, OGroupLess())) - { - for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin(); - aMapSearch < m_aActiveGroupMap.end(); - ++aMapSearch - ) - { - if( (*aMapSearch) >= nPos ) - ++(*aMapSearch); - } - } - else - DBG_ERROR("OGroupManager::InsertElement : inserted the element but did not find it afterwards !"); + if ( aFind == m_aGroupArr.end() ) + { + aFind = m_aGroupArr.insert(OGroupArr::value_type(sGroupName,OGroup(sGroupName))).first; } - OGroup& rNewGroup = m_aGroupArr[nPos]; - rNewGroup.InsertComponent( xSet ); + aFind->second.InsertComponent( xSet ); // Wenn Anzahl der Gruppenelemente == 2 ist, Gruppe aktivieren - if( rNewGroup.Count() == 2 ) + if ( aFind->second.Count() == 2 ) { - m_aActiveGroupMap.insert( m_aActiveGroupMap.end(), nPos ); + m_aActiveGroupMap.push_back( aFind ); } @@ -526,43 +496,11 @@ void OGroupManager::RemoveElement( const Reference<XPropertySet>& xSet ) if (!xControl.is() ) return; - // Component aus CompGroup entfernen - m_pCompGroup->RemoveComponent( xSet ); - // Component aus Gruppe entfernen - sal_Int32 nGroupPos; ::rtl::OUString sGroupName; xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName; - OGroup aSearchGroup( sGroupName ); - - if (seek_entry(m_aGroupArr, aSearchGroup, nGroupPos, OGroupLess())) - { - // Gruppe vorhanden - OGroup& rGroup = m_aGroupArr[nGroupPos]; - rGroup.RemoveComponent( xSet ); - - - // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren - if( rGroup.Count() == 1 ) - { - for ( OUInt32ArrIterator aMapSearch = m_aActiveGroupMap.begin(); - aMapSearch < m_aActiveGroupMap.end(); - ++aMapSearch - ) - { - if( *aMapSearch == nGroupPos ) - { - m_aActiveGroupMap.erase(aMapSearch); - break; - } - } - } - } - // Bei Component als PropertyChangeListener abmelden - xSet->removePropertyChangeListener( PROPERTY_NAME, this ); - if (hasProperty(PROPERTY_TABINDEX, xSet)) - xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this ); + removeFromGroupMap(sGroupName,xSet); } //......................................................................... diff --git a/forms/source/component/GroupManager.hxx b/forms/source/component/GroupManager.hxx index b1cd9ca18562..0a8bbe7fa04c 100644 --- a/forms/source/component/GroupManager.hxx +++ b/forms/source/component/GroupManager.hxx @@ -2,9 +2,9 @@ * * $RCSfile: GroupManager.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: vg $ $Date: 2001-09-12 12:13:09 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,6 +161,7 @@ class OGroupComp { ::rtl::OUString m_aName; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xComponent; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xControlModel; sal_Int32 m_nPos; sal_Int16 m_nTabIndex; @@ -173,7 +174,9 @@ public: sal_Bool operator==( const OGroupComp& rComp ) const; - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& GetComponent() const { return m_xComponent; } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& GetComponent() const { return m_xComponent; } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& GetControlModel() const { return m_xControlModel; } + sal_Int32 GetPos() const { return m_nPos; } sal_Int16 GetTabIndex() const { return m_nTabIndex; } ::rtl::OUString GetName() const { return m_aName; } @@ -186,6 +189,7 @@ class OGroupComp; class OGroupCompAcc { ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xComponent; + OGroupComp m_aGroupComp; friend class OGroupCompAccLess; @@ -195,7 +199,7 @@ public: sal_Bool operator==( const OGroupCompAcc& rCompAcc ) const; - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& GetComponent() const { return m_xComponent; } + inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& GetComponent() const { return m_xComponent; } const OGroupComp& GetGroupComponent() const { return m_aGroupComp; } }; @@ -231,16 +235,16 @@ public: { return m_aCompArray[nP].GetComponent(); } }; -DECLARE_STL_VECTOR(OGroup, OGroupArr); -DECLARE_STL_VECTOR(sal_uInt32, OUInt32Arr); +DECLARE_STL_USTRINGACCESS_MAP(OGroup, OGroupArr); +DECLARE_STL_VECTOR(OGroupArr::iterator, OActiveGroups); //======================================================================== class OGroupManager : public ::cppu::WeakImplHelper2< ::com::sun::star::beans::XPropertyChangeListener, ::com::sun::star::container::XContainerListener> { - OGroup* m_pCompGroup; // Alle Components nach TabIndizes sortiert - OGroupArr m_aGroupArr; // Alle Components nach Gruppen sortiert - OUInt32Arr m_aActiveGroupMap; // In dieser Map werden die Indizes aller Gruppen gehalten, - // die mehr als 1 Element haben + OGroup* m_pCompGroup; // Alle Components nach TabIndizes sortiert + OGroupArr m_aGroupArr; // Alle Components nach Gruppen sortiert + OActiveGroups m_aActiveGroupMap; // In dieser Map werden die Indizes aller Gruppen gehalten, + // die mehr als 1 Element haben ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; @@ -248,6 +252,7 @@ class OGroupManager : public ::cppu::WeakImplHelper2< ::com::sun::star::beans::X // Helper functions void InsertElement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& rxElement ); void RemoveElement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& rxElement ); + void removeFromGroupMap(const ::rtl::OUString& _sGroupName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSet); public: OGroupManager(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _rxContainer); diff --git a/forms/source/component/Hidden.cxx b/forms/source/component/Hidden.cxx index ce6fb93e510b..1607de4c5d76 100644 --- a/forms/source/component/Hidden.cxx +++ b/forms/source/component/Hidden.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Hidden.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: fs $ $Date: 2002-12-02 09:56:32 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -196,11 +196,9 @@ void OHiddenModel::fillProperties( //------------------------------------------------------------------------------ StringSequence SAL_CALL OHiddenModel::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) { - StringSequence aSupported = OControlModel::getSupportedServiceNames(); - aSupported.realloc(aSupported.getLength() + 1); - - ::rtl::OUString* pArray = aSupported.getArray(); - pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_HIDDENCONTROL; + StringSequence aSupported( 2 ); + aSupported[ 0 ] = FRM_SUN_COMPONENT_HIDDENCONTROL; + aSupported[ 1 ] = FRM_SUN_FORMCOMPONENT; return aSupported; } diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index 8b19a6c75265..b00165ec0cf8 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -2,9 +2,9 @@ * * $RCSfile: RadioButton.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: fs $ $Date: 2002-12-02 09:56:35 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -132,9 +132,18 @@ void SAL_CALL ORadioButtonControl::createPeer(const Reference<starawt::XToolkit> // switch off the auto-toggle, we do this ourself .... // (formerly this switch-off was done in the toolkit - but the correct place is here ...) - Reference< XVclWindowPeer > xVclWindowPeer( getPeer(), UNO_QUERY ); - if (xVclWindowPeer.is()) - xVclWindowPeer->setProperty(::rtl::OUString::createFromAscii("AutoToggle"), ::cppu::bool2any(sal_False)); +// Reference< XVclWindowPeer > xVclWindowPeer( getPeer(), UNO_QUERY ); +// if (xVclWindowPeer.is()) +// xVclWindowPeer->setProperty(::rtl::OUString::createFromAscii("AutoToggle"), ::cppu::bool2any(sal_False)); + // new order: do _not_ switch off the auto toggle because: + // * today, it is not necessary anymore to handle the toggling ourself (everything works fine without it) + // * without auto toggle, the AccessibleEvents as fired by the radio buttons are + // a. newly checked button: "unchecked"->"checked" + // b. previously checked button: "checked"->"unchecked" + // This is deadly for AT-tools, which then get the "unchecked" event _immediately_ after the "checked" event, + // and only read the latter. This makes radio buttons pretty unusable in form documents. + // So we switched AutoToggle _on_, again, because then VCL can handle the notifications, and will send + // them in the proper order. } //================================================================== diff --git a/forms/source/component/cloneable.cxx b/forms/source/component/cloneable.cxx index 1a11afe767c8..f692586cc005 100644 --- a/forms/source/component/cloneable.cxx +++ b/forms/source/component/cloneable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cloneable.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: fs $ $Date: 2002-12-02 10:04:38 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,10 +106,3 @@ namespace frm } // namespace frm //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * - * Revision 1.0 29.11.2002 16:01:05 fs - ************************************************************************/ - diff --git a/forms/source/component/errorbroadcaster.cxx b/forms/source/component/errorbroadcaster.cxx index 816f592889a7..963c5f232e6c 100644 --- a/forms/source/component/errorbroadcaster.cxx +++ b/forms/source/component/errorbroadcaster.cxx @@ -2,9 +2,9 @@ * * $RCSfile: errorbroadcaster.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: fs $ $Date: 2001-08-28 14:33:58 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -149,10 +149,3 @@ namespace frm } // namespace frm //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * - * Revision 1.0 28.08.01 12:40:23 fs - ************************************************************************/ - diff --git a/forms/source/component/errorbroadcaster.hxx b/forms/source/component/errorbroadcaster.hxx index 2ea72bad77cc..7feeef117d68 100644 --- a/forms/source/component/errorbroadcaster.hxx +++ b/forms/source/component/errorbroadcaster.hxx @@ -2,9 +2,9 @@ * * $RCSfile: errorbroadcaster.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: fs $ $Date: 2001-08-28 14:34:05 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -116,10 +116,3 @@ namespace frm #endif // FORMS_ERRORBROADCASTER_HXX -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * - * Revision 1.0 28.08.01 12:18:36 fs - ************************************************************************/ - diff --git a/forms/source/component/makefile.mk b/forms/source/component/makefile.mk index 55e9b6a42336..f65dea701dca 100644 --- a/forms/source/component/makefile.mk +++ b/forms/source/component/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: fs $ $Date: 2002-12-02 09:52:09 $ +# last change: $Author: hr $ $Date: 2003-03-25 18:01:18 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -141,6 +141,7 @@ SLOFILES= $(SLO)$/Grid.obj \ $(SLO)$/ImageControl.obj \ $(SLO)$/errorbroadcaster.obj \ $(SLO)$/cloneable.obj \ + $(SLO)$/Filter.obj \ # --- Targets ---------------------------------- diff --git a/forms/source/inc/InterfaceContainer.hxx b/forms/source/inc/InterfaceContainer.hxx index 232c1dac0e5b..a41d43705670 100644 --- a/forms/source/inc/InterfaceContainer.hxx +++ b/forms/source/inc/InterfaceContainer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: InterfaceContainer.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: fs $ $Date: 2002-10-04 08:08:18 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -310,6 +310,35 @@ protected: void SAL_CALL writeEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream); void SAL_CALL readEvents(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream); + /** replace an element, specified by position + + @precond <arg>_nIndex</arg> is a valid index + @precond our mutex is locked exactly once, by the guard specified with <arg>_rClearBeforeNotify</arg> + + */ + void implReplaceByIndex( + const sal_Int32 _nIndex, + const ::com::sun::star::uno::Any& _rNewElement, + ::osl::ClearableMutexGuard& _rClearBeforeNotify + ); + + /** removes an element, specified by position + + @precond <arg>_nIndex</arg> is a valid index + @precond our mutex is locked exactly once, by the guard specified with <arg>_rClearBeforeNotify</arg> + + */ + void implRemoveByIndex( + const sal_Int32 _nIndex, + ::osl::ClearableMutexGuard& _rClearBeforeNotify + ); + + /** validates the given index + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index does not denote a valid position in our childs array + */ + void implCheckIndex( const sal_Int32 _nIndex ) SAL_THROW( ( ::com::sun::star::lang::IndexOutOfBoundsException ) ); + private: // the runtime event format has changed from version SO5.2 to OOo enum EventFormat diff --git a/forms/source/inc/frm_resource.hrc b/forms/source/inc/frm_resource.hrc index af082f7718a0..614bf3703365 100644 --- a/forms/source/inc/frm_resource.hrc +++ b/forms/source/inc/frm_resource.hrc @@ -2,9 +2,9 @@ * * $RCSfile: frm_resource.hrc,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: fs $ $Date: 2001-12-20 16:15:58 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,7 @@ #define RID_STR_OPEN_GRAPHICS ( RID_FRM_STRINGS_START + 13 ) #define RID_STR_CLEAR_GRAPHICS ( RID_FRM_STRINGS_START + 14 ) #define RID_STR_INVALIDSTREAM ( RID_FRM_STRINGS_START + 15 ) - +#define RID_STR_SYNTAXERROR ( RID_FRM_STRINGS_START + 16 ) #endif // _FRM_RESOURCE_HRC_ diff --git a/forms/source/inc/limitedformats.hxx b/forms/source/inc/limitedformats.hxx index 639660d2072b..5b05b6504763 100644 --- a/forms/source/inc/limitedformats.hxx +++ b/forms/source/inc/limitedformats.hxx @@ -2,9 +2,9 @@ * * $RCSfile: limitedformats.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2001-05-23 10:12:44 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -143,13 +143,3 @@ namespace frm #endif // _FORMS_LIMITED_FORMATS_HXX_ -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.1 2001/05/18 14:47:28 fs - * initial checkin - helper for control models with limited formatting capabilities - * - * - * Revision 1.0 18.05.01 10:38:19 fs - ************************************************************************/ - diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index 2a2010234807..0ec6c01ba2df 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -2,9 +2,9 @@ * * $RCSfile: property.hrc,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2002-12-02 12:58:12 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,18 +95,18 @@ namespace frm #define PROPERTY_ID_VALUE (PROPERTY_ID_START + 31) // INT32 #define PROPERTY_ID_FORMATKEY (PROPERTY_ID_START + 33) // UINT32 #define PROPERTY_ID_SIZE (PROPERTY_ID_START + 37) // UINT32 -#define PROPERTY_ID_HEIGHT (PROPERTY_ID_START + 41) // UINT16 + // free #define PROPERTY_ID_WIDTH (PROPERTY_ID_START + 42) // UINT16 #define PROPERTY_ID_DEFAULTCONTROL (PROPERTY_ID_START + 43) // string #define PROPERTY_ID_BOUNDCOLUMN (PROPERTY_ID_START + 44) // UINT16 may be null #define PROPERTY_ID_LISTSOURCETYPE (PROPERTY_ID_START + 45) // UINT16 #define PROPERTY_ID_LISTSOURCE (PROPERTY_ID_START + 46) // string -#define PROPERTY_ID_LISTINDEX (PROPERTY_ID_START + 47) // UINT32 + // free #define PROPERTY_ID_TEXT (PROPERTY_ID_START + 48) // string #define PROPERTY_ID_STRINGITEMLIST (PROPERTY_ID_START + 49) // wsstringsequence #define PROPERTY_ID_LABEL (PROPERTY_ID_START + 50) // string #define PROPERTY_ID_STATE (PROPERTY_ID_START + 52) // UINT16 -#define PROPERTY_ID_GROUPBOX (PROPERTY_ID_START + 53) // string + // free #define PROPERTY_ID_FONT (PROPERTY_ID_START + 54) // font #define PROPERTY_ID_HASNAVIGATION (PROPERTY_ID_START + 55) #define PROPERTY_ID_ROWHEIGHT (PROPERTY_ID_START + 57) // UINT16 @@ -251,6 +251,8 @@ namespace frm #define PROPERTY_ID_DISPATCHURLINTERNAL (PROPERTY_ID_START +212) // BOOL +#define PROPERTY_ID_PERSISTENCE_MAXTEXTLENGTH (PROPERTY_ID_START +213) // sal_Int16 + // start ID fuer aggregierte Properties #define PROPERTY_ID_AGGREGATE_ID (PROPERTY_ID_START + 10000) @@ -424,6 +426,8 @@ DECLARE_CONSTASCII_USTRING(PROPERTY_USER); DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD); DECLARE_CONSTASCII_USTRING(PROPERTY_DISPATCHURLINTERNAL); +DECLARE_CONSTASCII_USTRING(PROPERTY_PERSISTENCE_MAXTEXTLENGTH); + //......................................................................... } //......................................................................... diff --git a/forms/source/inc/services.hxx b/forms/source/inc/services.hxx index 6abb3ab74d90..c0659ef3d047 100644 --- a/forms/source/inc/services.hxx +++ b/forms/source/inc/services.hxx @@ -2,9 +2,9 @@ * * $RCSfile: services.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: fs $ $Date: 2002-03-04 14:49:43 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -235,6 +235,9 @@ DECLARE_CONSTASCII_USTRING(FRM_SUN_FORMS_COLLECTION); DECLARE_CONSTASCII_USTRING(FRM_SUN_INTERNATIONAL_INFO); +DECLARE_CONSTASCII_USTRING(FRM_SUN_FORMCOMPONENT); + + //......................................................................... } //... namespace frm ....................................................... diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 37431aa38d44..05eb9923d9e8 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: InterfaceContainer.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: rt $ $Date: 2002-10-09 13:48:09 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,6 +110,9 @@ #ifndef _COM_SUN_STAR_IO_WRONGFORMATEXCEPTION_HPP_ #include <com/sun/star/io/WrongFormatException.hpp> #endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> @@ -455,6 +458,33 @@ void SAL_CALL OInterfaceContainer::write( const Reference< XObjectOutputStream > } //------------------------------------------------------------------------------ +namespace +{ + Reference< XPersistObject > lcl_createPlaceHolder( const Reference< XMultiServiceFactory >& _rxORB ) + { + Reference< XPersistObject > xObject( _rxORB->createInstance( FRM_COMPONENT_HIDDENCONTROL ), UNO_QUERY ); + DBG_ASSERT( xObject.is(), "lcl_createPlaceHolder: could not create a substitute for the unknown object!" ); + if ( xObject.is() ) + { + // set some properties describing what we did + Reference< XPropertySet > xObjProps( xObject, UNO_QUERY ); + if ( xObject.is() ) + { + try + { + xObjProps->setPropertyValue( PROPERTY_NAME, makeAny( FRM_RES_STRING( RID_STR_CONTROL_SUBSTITUTED_NAME ) ) ); + xObjProps->setPropertyValue( PROPERTY_TAG, makeAny( FRM_RES_STRING( RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN ) ) ); + } + catch(Exception&) + { + } + } + } + return xObject; + } +} + +//------------------------------------------------------------------------------ void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& _rxInStream ) throw(IOException, RuntimeException) { ::osl::MutexGuard aGuard( m_rMutex ); @@ -485,27 +515,11 @@ void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& { e; // make compiler happy // the object could not be read - xObj = NULL; - // create a dummy starform (so the readEvents below will assign the events to the right controls) - xObj = Reference<XPersistObject> (m_xServiceFactory->createInstance(FRM_COMPONENT_HIDDENCONTROL), UNO_QUERY); - DBG_ASSERT(xObj.is(), "OInterfaceContainer::read : could not create a substitute for the unknown object !"); - if (!xObj.is()) - // couldn't handle it ... + // create a object (so the readEvents below will assign the events to the right controls) + xObj = lcl_createPlaceHolder( m_xServiceFactory ); + if ( !xObj.is() ) + // couldn't handle it throw; - - // set some properties describing what we did - Reference<XPropertySet> xObjProps(xObj, UNO_QUERY); - if (xObjProps.is()) - { - try - { - xObjProps->setPropertyValue(PROPERTY_NAME, makeAny(FRM_RES_STRING(RID_STR_CONTROL_SUBSTITUTED_NAME))); - xObjProps->setPropertyValue(PROPERTY_TAG, makeAny(FRM_RES_STRING(RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN))); - } - catch(Exception&) - { - } - } // 72133 - 09.02.00 - FS } catch(Exception&) @@ -518,13 +532,11 @@ void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& throw; } - if (xObj.is()) + if ( xObj.is() ) { - Any aElement = xObj->queryInterface(m_aElementType); - if (aElement.hasValue()) + Reference< XPropertySet > xElement( xObj, UNO_QUERY ); + try { - Reference< XPropertySet > xElement; - aElement >>= xElement; implInsert( m_aItems.size(), // position xElement, // element to insert @@ -533,8 +545,17 @@ void SAL_CALL OInterfaceContainer::read( const Reference< XObjectInputStream >& sal_True // fire the event ); } - else - ; // form konnte nicht gelesen werden; nyi + catch( const Exception& ) + { + DBG_ERROR( "OInterfaceContainerHelper::read: reading succeeded, but not inserting!" ); + // create a placeholder + xElement = xElement.query( lcl_createPlaceHolder( m_xServiceFactory ) ); + if ( !xElement.is() ) + // couldn't handle it + throw; + // insert the placeholder + implInsert( m_aItems.size(), xElement, sal_False, NULL, sal_True ); + } } } @@ -705,7 +726,21 @@ void OInterfaceContainer::approveNewElement( const Reference< XPropertySet >& _r // it has to be a child, and it must not have a parent already Reference< XChild > xChild( _rxObject, UNO_QUERY ); if ( !xChild.is() || xChild->getParent().is() ) + { +#ifdef FS_PRIV_DEBUG + ::rtl::OUString sChildName, sParentName; + Reference< XNamed > xNamed( xChild, UNO_QUERY ); + if ( xNamed.is() ) + sChildName = xNamed->getName(); + if ( xChild.is() ) + { + xNamed = xNamed.query( xChild->getParent() ); + if ( xNamed.is() ) + sParentName = xNamed->getName(); + } +#endif lcl_throwIllegalArgumentException(); + } // passed all tests. cache the information we have so far DBG_ASSERT( _pElement, "OInterfaceContainer::approveNewElement: invalid event descriptor!" ); @@ -779,13 +814,13 @@ void OInterfaceContainer::implInsert(sal_Int32 _nIndex, const Reference< XProper // fire the notification about the change if ( _bFire ) { - aGuard.clear(); - // notify listeners ContainerEvent aEvt; aEvt.Source = static_cast<XContainer*>(this); aEvt.Accessor <<= _nIndex; aEvt.Element = pElementMetaData->aElementTypeInterface; + + aGuard.clear(); NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementInserted, aEvt); } } @@ -821,26 +856,23 @@ void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any& } //------------------------------------------------------------------------------ -void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& Element) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any& _rNewElement, ::osl::ClearableMutexGuard& _rClearBeforeNotify ) { - if (_nIndex < 0 || _nIndex >= (sal_Int32)m_aItems.size()) - throw IndexOutOfBoundsException(); - - ::osl::ClearableMutexGuard aGuard( m_rMutex ); + OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < (sal_Int32)m_aItems.size() ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" ); // approve the new object ::std::auto_ptr< ElementDescription > aElementMetaData( createElementMetaData() ); - DBG_ASSERT( aElementMetaData.get(), "OInterfaceContainer::replaceByIndex: createElementMetaData returned nonsense!" ); + DBG_ASSERT( aElementMetaData.get(), "OInterfaceContainer::implReplaceByIndex: createElementMetaData returned nonsense!" ); { Reference< XPropertySet > xElementProps; - Element >>= xElementProps; + _rNewElement >>= xElementProps; approveNewElement( xElementProps, aElementMetaData.get() ); } // get the old element InterfaceRef xOldElement( m_aItems[ _nIndex ] ); DBG_ASSERT( xOldElement.get() == Reference< XInterface >( xOldElement, UNO_QUERY ).get(), - "OInterfaceContainer::replaceByIndex: elements should be held normalized!" ); + "OInterfaceContainer::implReplaceByIndex: elements should be held normalized!" ); // locate the old element in the map OInterfaceMap::iterator j = m_aMap.begin(); @@ -867,7 +899,7 @@ void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& // examine the new element ::rtl::OUString sName; - DBG_ASSERT( aElementMetaData.get()->xPropertySet.is(), "OInterfaceContainer::replaceByIndex: what did approveNewElement do?" ); + DBG_ASSERT( aElementMetaData.get()->xPropertySet.is(), "OInterfaceContainer::implReplaceByIndex: what did approveNewElement do?" ); aElementMetaData.get()->xPropertySet->getPropertyValue(PROPERTY_NAME) >>= sName; aElementMetaData.get()->xPropertySet->addPropertyChangeListener(PROPERTY_NAME, this); @@ -884,21 +916,37 @@ void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& implReplaced( xOldElement, aElementMetaData.get() ); // benachrichtigen - aGuard.clear(); ContainerEvent aEvt; aEvt.Source = static_cast<XContainer*>(this); aEvt.Accessor <<= _nIndex; aEvt.Element = aElementMetaData.get()->aElementTypeInterface; aEvt.ReplacedElement = xOldElement->queryInterface( m_aElementType ); + + _rClearBeforeNotify.clear(); NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementReplaced, aEvt); } //------------------------------------------------------------------------------ -void SAL_CALL OInterfaceContainer::removeByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +void OInterfaceContainer::implCheckIndex( const sal_Int32 _nIndex ) SAL_THROW( ( ::com::sun::star::lang::IndexOutOfBoundsException ) ) { - ::osl::MutexGuard aGuard( m_rMutex ); if (_nIndex < 0 || _nIndex >= (sal_Int32)m_aItems.size()) throw IndexOutOfBoundsException(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any& Element) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +{ + ::osl::ClearableMutexGuard aGuard( m_rMutex ); + // check the index + implCheckIndex( _nIndex ); + // do the replace + implReplaceByIndex( _nIndex, Element, aGuard ); +} + +//------------------------------------------------------------------------------ +void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::ClearableMutexGuard& _rClearBeforeNotify ) +{ + OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < (sal_Int32)m_aItems.size() ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" ); OInterfaceArray::iterator i = m_aItems.begin() + _nIndex; InterfaceRef xElement(*i); @@ -930,9 +978,21 @@ void SAL_CALL OInterfaceContainer::removeByIndex(sal_Int32 _nIndex) throw( Index aEvt.Source = static_cast<XContainer*>(this); aEvt.Element = xElement->queryInterface( m_aElementType ); aEvt.Accessor <<= _nIndex; + + _rClearBeforeNotify.clear(); NOTIFY_LISTENERS(m_aContainerListeners, XContainerListener, elementRemoved, aEvt); } +//------------------------------------------------------------------------------ +void SAL_CALL OInterfaceContainer::removeByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +{ + ::osl::ClearableMutexGuard aGuard( m_rMutex ); + // check the index + implCheckIndex( _nIndex ); + // do the removal + implRemoveByIndex( _nIndex, aGuard ); +} + //------------------------------------------------------------------------ ElementDescription* OInterfaceContainer::createElementMetaData( ) { @@ -973,7 +1033,7 @@ void SAL_CALL OInterfaceContainer::insertByName(const ::rtl::OUString& _rName, c //------------------------------------------------------------------------ void SAL_CALL OInterfaceContainer::replaceByName(const ::rtl::OUString& Name, const Any& Element) throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException ) { - ::osl::MutexGuard aGuard( m_rMutex ); + ::osl::ClearableMutexGuard aGuard( m_rMutex ); pair <OInterfaceMap::iterator, OInterfaceMap::iterator> aPair = m_aMap.equal_range(Name); if (aPair.first == aPair.second) @@ -994,7 +1054,8 @@ void SAL_CALL OInterfaceContainer::replaceByName(const ::rtl::OUString& Name, co // determine the element pos sal_Int32 nPos = find(m_aItems.begin(), m_aItems.end(), (*aPair.first).second) - m_aItems.begin(); - replaceByIndex(nPos, Element); + + implReplaceByIndex( nPos, Element, aGuard ); } //------------------------------------------------------------------------ diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx index b2e9b00148e9..5478106ca1af 100644 --- a/forms/source/misc/limitedformats.cxx +++ b/forms/source/misc/limitedformats.cxx @@ -2,9 +2,9 @@ * * $RCSfile: limitedformats.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: fs $ $Date: 2001-05-25 12:28:32 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -445,19 +445,3 @@ namespace frm } // namespace frm //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.3 2001/05/23 10:13:05 fs - * #86172# clear the format keys in the tables when releasing the number formats supplier - * - * Revision 1.2 2001/05/23 08:32:20 rt - * #65293# GCC does not like 'Locale ident(String(), String(), String())' - * - * Revision 1.1 2001/05/18 14:48:05 fs - * initial checkin - helper for control models with limited formatting capabilities - * - * - * Revision 1.0 18.05.01 10:39:57 fs - ************************************************************************/ - diff --git a/forms/source/misc/makefile.mk b/forms/source/misc/makefile.mk index 713c5d5697db..ec3bb93009de 100644 --- a/forms/source/misc/makefile.mk +++ b/forms/source/misc/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.4 $ +# $Revision: 1.5 $ # -# last change: $Author: fs $ $Date: 2002-03-04 13:57:23 $ +# last change: $Author: hr $ $Date: 2003-03-25 18:01:26 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses diff --git a/forms/source/misc/property.cxx b/forms/source/misc/property.cxx index a0732702360f..fa1d2c5303d8 100644 --- a/forms/source/misc/property.cxx +++ b/forms/source/misc/property.cxx @@ -2,9 +2,9 @@ * * $RCSfile: property.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2002-12-02 12:58:13 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -124,6 +124,8 @@ void PropertyInfoService::initialize() if (!s_AllKnownProperties.empty()) return; + s_AllKnownProperties.reserve(220); + ADD_PROP_ASSIGNMENT(NAME); ADD_PROP_ASSIGNMENT(TAG); ADD_PROP_ASSIGNMENT(TABINDEX); @@ -283,6 +285,7 @@ void PropertyInfoService::initialize() ADD_PROP_ASSIGNMENT(ACTIVE_CONNECTION); ADD_PROP_ASSIGNMENT(SCALE); ADD_PROP_ASSIGNMENT(SORT); + ADD_PROP_ASSIGNMENT(PERSISTENCE_MAXTEXTLENGTH); // now sort the array by name @@ -473,6 +476,8 @@ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USER, "User"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PASSWORD, "Password"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DISPATCHURLINTERNAL, "DispatchURLInternal"); +IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PERSISTENCE_MAXTEXTLENGTH, "PersistenceMaxTextLength"); + //......................................................................... } //... namespace frm ....................................................... diff --git a/forms/source/misc/services.cxx b/forms/source/misc/services.cxx index 4559af08795a..ae2e0d16742c 100644 --- a/forms/source/misc/services.cxx +++ b/forms/source/misc/services.cxx @@ -2,9 +2,9 @@ * * $RCSfile: services.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: hr $ $Date: 2002-03-05 17:07:16 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -226,6 +226,11 @@ IMPLEMENT_CONSTASCII_USTRING(SRV_SDBC_STATEMENT, "com.sun.star.sdbc.Statement"); IMPLEMENT_CONSTASCII_USTRING(SRV_AWT_POINTER, "com.sun.star.awt.Pointer"); +// ----------------------- +// common +// ----------------------- +IMPLEMENT_CONSTASCII_USTRING( FRM_SUN_FORMCOMPONENT, "com.sun.star.form.FormComponent" ); + //......................................................................... } //... namespace frm ....................................................... @@ -247,17 +252,11 @@ namespace starregistry = ::com::sun::star::registry; namespace staruno = ::com::sun::star::uno; namespace starlang = ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - //--------------------------------------------------------------------------------------- //....................................................................................... #define DECLARE_SERVICE_INFO(classImplName) \ namespace frm { \ - extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL \ - classImplName##_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) \ - throw (::com::sun::star::uno::RuntimeException); \ + extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL classImplName##_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory) throw (::com::sun::star::uno::RuntimeException); \ } //--------------------------------------------------------------------------------------- @@ -311,6 +310,10 @@ DECLARE_SERVICE_INFO(OFormsCollection) //--------------------------------------------------------------------------------------- +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + static Sequence< ::rtl::OUString > s_aClassImplementationNames; static Sequence<Sequence< ::rtl::OUString > > s_aClassServiceNames; static Sequence<sal_Int64> s_aFactories; @@ -500,6 +503,7 @@ extern "C" //--------------------------------------------------------------------------------------- void SAL_CALL createRegistryInfo_ODatabaseForm(); +void SAL_CALL createRegistryInfo_OFilterControl(); //--------------------------------------------------------------------------------------- void SAL_CALL createRegistryInfo_FORMS() @@ -508,6 +512,7 @@ void SAL_CALL createRegistryInfo_FORMS() if (!bInit) { createRegistryInfo_ODatabaseForm(); + createRegistryInfo_OFilterControl(); bInit = sal_True; } } diff --git a/forms/source/resource/strings.src b/forms/source/resource/strings.src index d2f4b71c8e88..3f917e194014 100644 --- a/forms/source/resource/strings.src +++ b/forms/source/resource/strings.src @@ -2,9 +2,9 @@ * * $RCSfile: strings.src,v $ * - * $Revision: 1.35 $ + * $Revision: 1.36 $ * - * last change: $Author: kz $ $Date: 2002-12-05 10:23:30 $ + * last change: $Author: hr $ $Date: 2003-03-25 18:01:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,14 +73,14 @@ String RID_BASELISTBOX_ERROR_FILLLIST Text[ greek ] = " "; Text[ dutch ] = "Inhoud combinatieveld of keuzelijst niet gevonden."; Text[ french ] = "Impossible de dterminer le contenu de la zone combine/zone de liste."; - Text[ spanish ] = "No se pudo determinar el contenido del campo combinado o del listado."; + Text[ spanish ] = "No se pudo determinar ni el contenido del cuadro combinado ni el del listado."; Text[ italian ] = "Non stato possibile determinare il contenuto di una casella combinata o di una casella di riepilogo."; Text[ danish ] = "Det var ikke muligt at bestemme indholdet for en kombinationsboks eller rulleliste."; Text[ swedish ] = "Innehllet i ett kombinationsflt eller en listruta kunde inte bestmmas."; Text[ polish ] = "Nie mona byo ustali zawartoci pola kombi lub pola listy."; Text[ portuguese_brazilian ] = "ComboBox/ListBox : determine the list contents"; Text[ japanese ] = "コンボボックスまたはリストボックスの内容が確認できませんでした。"; - Text[ korean ] = "콤보 상자 또는 목록 필드의 내용을 조사할 수 없었습니다."; + Text[ korean ] = "콤보 상자 또는 목록 필드의 내용을 확인하지 못했습니다."; Text[ chinese_simplified ] = "无法确定组合框或者列表框内的内容。"; Text[ chinese_traditional ] = "無法從資料庫內測定組合方塊或清單方塊的內容"; Text[ arabic ] = " ."; @@ -109,7 +109,7 @@ String RID_STR_IMPORT_GRAPHIC Text[ japanese ] = "図の挿入"; Text[ chinese_traditional ] = "插入圖形"; Text[ greek ] = " "; - Text[ korean ] = "그래픽 삽입"; + Text[ korean ] = "그림 삽입"; Text[ arabic ] = " "; Text[ turkish ] = "Insert graphics"; Text[ catalan ] = "Insereix grfics"; @@ -161,7 +161,7 @@ String RID_STR_CONTROL_SUBSTITUTED_EPXPLAIN Text[ polish ] = "Wystpi bd podczas adowania pola kontrolnego (control). Z tego powodu zamieniono je na symbol wieloznaczny."; Text[ portuguese_brazilian ] = "While loading this control an error occured. Thus it was replaced with a placeholder."; Text[ japanese ] = "このコントロールの読み込み中にエラーが発生しました。それが原因でワイルドカードに置換されました。"; - Text[ korean ] = "이 컨트롤 로드시에 오류가 발생하였습니다. 그러므로 플레이스홀더로 변경되었습니다."; + Text[ korean ] = "이 컨트롤 로드 중에 오류가 발생했습니다. 이 이유로 인해 플레이스홀더로 대체되었습니다."; Text[ chinese_simplified ] = "装入这个字段时出现了一个错误,因此用通配符代替字段。"; Text[ chinese_traditional ] = "載入這個控制項時發生一個錯誤。但已經用一個萬用字元替代它。"; Text[ arabic ] = " . ."; @@ -233,7 +233,7 @@ String RID_ERR_LOADING_FORM Text [ english ] = "The data content could not be loaded."; Text [ english_us ] = "The data content could not be loaded."; Text[ portuguese ] = "Foi impossvel carregar o contedo dos dados."; - Text[ russian ] = " ."; + Text[ russian ] = " ."; Text[ greek ] = " ."; Text[ dutch ] = "De gegevens kunnen niet worden geladen."; Text[ french ] = "Impossible de charger le contenu des donnes."; @@ -346,7 +346,7 @@ String RID_STR_ERR_DELETERECORD Text[ greek ] = " "; Text[ dutch ] = "Fout bij wissen van huidige record"; Text[ french ] = "Erreur lors de la suppression de l'enregistrement actif"; - Text[ spanish ] = "Error al eliminar el registro actual de datos."; + Text[ spanish ] = "Error al borrar el registro actual."; Text[ italian ] = "Errore nel cancellare il record di dati corrente."; Text[ danish ] = "Fejl ved sletning af den aktuelle datapost"; Text[ swedish ] = "Fel vid radering av den aktuella dataposten"; @@ -373,14 +373,14 @@ String RID_STR_ERR_DELETERECORDS Text[ greek ] = " "; Text[ dutch ] = "Fout bij wissen van opgegeven records"; Text[ french ] = "Erreur lors de la suppression des enregistrements spcifis"; - Text[ spanish ] = "Error al eliminar los registros de los datos indicados."; + Text[ spanish ] = "Error al borrar los registros indicados."; Text[ italian ] = "Errore nel cancellare i record di dati specificati."; Text[ danish ] = "Fejl ved sletning af de angivne dataposter"; Text[ swedish ] = "Fel vid radering av de angivna dataposterna"; Text[ polish ] = "Bd przy usuwaniu podanych rekordw"; Text[ portuguese_brazilian ] = "error deleting the specified records"; Text[ japanese ] = "指定したレコードを削除する時のエラー"; - Text[ korean ] = "지정된 레코드 삭제시에 오류"; + Text[ korean ] = "지정된 레코드 삭제 중 오류"; Text[ chinese_simplified ] = "在删除指定的数据条目时发生错误"; Text[ chinese_traditional ] = "在刪除指定資料條目時發生錯誤"; Text[ arabic ] = " "; @@ -408,7 +408,7 @@ String RID_STR_NEED_NON_NULL_OBJECT Text[ polish ] = "Obiekt nie moe by rwny ZERO."; Text[ portuguese_brazilian ] = "The object must not be NULL."; Text[ japanese ] = "オブジェクトが NULL ではいけません。"; - Text[ korean ] = "개체는 NULL이 아니어야 합니다."; + Text[ korean ] = "개체가 NULL이면 안됩니다."; Text[ chinese_simplified ] = "这个对象不可以是 NULL 。"; Text[ chinese_traditional ] = "這個物件不可以是 NULL 。"; Text[ turkish ] = "The object must not be NULL."; @@ -435,7 +435,7 @@ String RID_STR_OPEN_GRAPHICS Text[ polish ] = "Wstaw grafik z..."; Text[ portuguese_brazilian ] = "Insert graphics from..."; Text[ japanese ] = "図の挿入に開く..."; - Text[ korean ] = "...에서 그래픽 삭제"; + Text[ korean ] = "삽입할 그림... "; Text[ chinese_simplified ] = "插入图形从..."; Text[ chinese_traditional ] = "插入圖形從..."; Text[ turkish ] = "Insert graphics from..."; @@ -454,7 +454,7 @@ String RID_STR_CLEAR_GRAPHICS Text[ greek ] = "Remove graphics"; Text[ dutch ] = "Afbeelding verwijderen"; Text[ french ] = "Supprimer l'image"; - Text[ spanish ] = "Eliminar la imagen"; + Text[ spanish ] = "Borrar la imagen"; Text[ finnish ] = "Poista grafiikka"; Text[ italian ] = "Elimina l'immagine"; Text[ danish ] = "Fjern grafik"; @@ -462,7 +462,7 @@ String RID_STR_CLEAR_GRAPHICS Text[ polish ] = "Usu grafik"; Text[ portuguese_brazilian ] = "Remove graphics"; Text[ japanese ] = "図の削除"; - Text[ korean ] = "그래픽 삭제"; + Text[ korean ] = "그림 제거"; Text[ chinese_simplified ] = "删除图形"; Text[ chinese_traditional ] = "刪除圖形"; Text[ turkish ] = "Remove graphics"; @@ -476,3 +476,31 @@ String RID_STR_INVALIDSTREAM { Text = "Die bergebene Stream-Komponente ist ungltig."; }; + +String RID_STR_SYNTAXERROR +{ + Text = "Fehler bei der Analyse des Anfrageausdrucks" ; + Text [ english ] = "Syntax error in query expression" ; + Text [ english_us ] = "Syntax error in query expression" ; + Text [ portuguese ] = "Erro ao analisar a expresso de consulta." ; + Text [ portuguese_brazilian ] = "Fehler bei der Analyse des Anfrageausdrucks" ; + Text [ swedish ] = "Fel vid analys av frgeuttryck" ; + Text [ danish ] = "Fejl under analysen af foresprgseludtrykket" ; + Text [ italian ] = "Errore nell'analizzare dell'espressione di ricerca" ; + Text [ spanish ] = "Ha ocurrido un error al analizar la expresin de la consulta" ; + Text [ french ] = "Erreur dans l'analyse de l'expression de la requte" ; + Text [ dutch ] = "Fout bij de analyse van query-afdruk" ; + Text[ chinese_simplified ] = "查询语句出现语法错误。"; + Text[ russian ] = " "; + Text[ polish ] = "Bd przy ocenie wydruku kwerendy"; + Text[ japanese ] = "クエリー言語分析中でのエラー"; + Text[ chinese_traditional ] = "在分解查詢語句時發生一個錯誤。"; + Text[ arabic ] = " "; + Text[ greek ] = " "; + Text[ korean ] = "쿼리식을 분석하는 중 오류"; + Text[ turkish ] = "Sorgu ifadesinde szdizim hatas"; + Text[ catalan ] = "S'ha produt un error en analitzar l'expressi de consulta"; + Text[ finnish ] = "Syntaksivirhe kyselylausekkeessa"; + Text[ thai ] = "ไวยกรณ์ในคำอธิบายแบบสอบถามผิดพลาด"; +}; + diff --git a/forms/util/frm.xml b/forms/util/frm.xml index d180912534a6..26acdaa34c5e 100644 --- a/forms/util/frm.xml +++ b/forms/util/frm.xml @@ -53,8 +53,6 @@ <status value="final"/> <supported-service>com.sun.star.form.component.HiddenControl</supported-service> <supported-service>com.sun.star.form.FormComponent</supported-service> - <supported-service>com.sun.star.form.FormControlModel</supported-service> - <supported-service>com.sun.star.awt.UnoControlModel</supported-service> </component-description> <component-description> <author></author> diff --git a/forms/util/makefile.mk b/forms/util/makefile.mk index 000165bb3f67..11b37cb91c84 100644 --- a/forms/util/makefile.mk +++ b/forms/util/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: hr $ $Date: 2002-08-15 15:56:19 $ +# last change: $Author: hr $ $Date: 2003-03-25 18:01:28 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -101,7 +101,8 @@ SHL1STDLIBS= \ $(UNOTOOLSLIB) \ $(COMPHELPERLIB) \ $(DBTOOLSLIB) \ - $(TKLIB) + $(TKLIB) \ + $(SVXLIB) SHL1LIBS=$(LIB1TARGET) SHL1DEF=$(MISC)$/$(SHL1TARGET).def |