diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-25 17:05:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-25 17:05:07 +0000 |
commit | 6ae4167f33c43b1d4a1bcd2d170f68abc71aa426 (patch) | |
tree | 1373e15f70e8c5d023dd00e017c0ab342f186ac9 /forms/source/component | |
parent | bac8976cffc32c82288a03fc690d70d1b392dccb (diff) |
MWS_SRX644: migrate branch mws_srx644 -> HEAD
Diffstat (limited to 'forms/source/component')
-rw-r--r-- | forms/source/component/Button.cxx | 56 | ||||
-rw-r--r-- | forms/source/component/DatabaseForm.cxx | 36 | ||||
-rw-r--r-- | forms/source/component/DatabaseForm.hxx | 4 | ||||
-rw-r--r-- | forms/source/component/Edit.cxx | 46 | ||||
-rw-r--r-- | forms/source/component/Edit.hxx | 12 | ||||
-rw-r--r-- | forms/source/component/Filter.cxx | 1058 | ||||
-rw-r--r-- | forms/source/component/Filter.hxx | 227 | ||||
-rw-r--r-- | forms/source/component/FormComponent.cxx | 48 | ||||
-rw-r--r-- | forms/source/component/FormattedFieldWrapper.cxx | 53 | ||||
-rw-r--r-- | forms/source/component/FormattedFieldWrapper.hxx | 20 | ||||
-rw-r--r-- | forms/source/component/Grid.cxx | 7 | ||||
-rw-r--r-- | forms/source/component/GroupManager.cxx | 158 | ||||
-rw-r--r-- | forms/source/component/GroupManager.hxx | 25 | ||||
-rw-r--r-- | forms/source/component/Hidden.cxx | 12 | ||||
-rw-r--r-- | forms/source/component/RadioButton.cxx | 19 | ||||
-rw-r--r-- | forms/source/component/cloneable.cxx | 11 | ||||
-rw-r--r-- | forms/source/component/errorbroadcaster.cxx | 11 | ||||
-rw-r--r-- | forms/source/component/errorbroadcaster.hxx | 11 | ||||
-rw-r--r-- | forms/source/component/makefile.mk | 5 |
19 files changed, 1577 insertions, 242 deletions
diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 1b1e82c91..98d53d6b0 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 86508820b..97910b461 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 448c81624..b082286d2 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 bccf5231f..9bd3f5460 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 a794c85bd..b6bb77df2 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 000000000..9d38793e2 --- /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 000000000..4cf553bca --- /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 914f1f4b7..fde9b18ad 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 798b34e1a..ca36b9559 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 a8adb47d2..a9456be92 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 bb767c2d5..df110869c 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 0efd60f7a..411bddf4d 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 ad8709261..63ada40b0 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 059aa01ca..bbbd52633 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 464fd6031..593b7f9e1 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 d220f91bf..e31a2c2ef 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 060005a26..440722ea1 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 43ab488a2..dfc5ebcbe 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 55e9b6a42..f65dea701 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 ---------------------------------- |