diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-09-14 11:18:01 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-09-14 11:18:01 +0000 |
commit | ea35f2f06cbb9507218af9c224d2ebdcaa2bec10 (patch) | |
tree | 2e492090fd9daf7f2a20ec4d1598496db6f1520c /svx/source/fmcomp | |
parent | 8570f88531e1b206f3fa63e10b308df9c57bb9c9 (diff) |
CWS-TOOLING: integrate CWS dba32g
2009-09-09 07:53:55 +0200 oj r275964 : replace strlen with rtl_str_getLength
2009-09-07 20:59:10 +0200 fs r275913 : disable the CopyTableWizard test until issue 104869 is fixed
2009-09-07 12:17:31 +0200 oj r275885 : #i104810# remove de as lang
2009-09-05 22:26:21 +0200 fs r275857 : protect StateChanged against re-entrance
2009-09-05 22:25:52 +0200 fs r275856 : don't attempt to classify the parent of a form as control
2009-09-05 22:25:29 +0200 fs r275855 : protect against re-entrance
2009-09-05 00:11:40 +0200 fs r275835 : #i10000#
2009-09-04 23:25:50 +0200 fs r275834 : #i10000#
2009-09-04 23:23:47 +0200 fs r275833 : #i10000#
2009-09-04 21:49:37 +0200 fs r275830 : #i10000# correct wrong conflict resolution
2009-09-04 20:59:51 +0200 fs r275829 : CWS-TOOLING: rebase CWS dba32g to trunk@275801 (milestone: DEV300:m57)
2009-09-04 11:08:32 +0200 oj r275791 : #i104780# new version 1.2.0
2009-09-03 22:29:21 +0200 fs r275775 : OSL_TRACE doesn't need \n anymore
2009-09-03 08:33:21 +0200 fs r275743 : CWS-TOOLING: rebase CWS dba32g to trunk@275331 (milestone: DEV300:m56)
2009-09-02 13:48:12 +0200 fs r275708 : removed useless include
2009-09-02 13:45:43 +0200 fs r275707 : more since tags, which are used across offapi/udkapi
2009-09-02 13:23:04 +0200 fs r275705 : should *not* have the dtor, copy ctor, and assignment operator compiler-generated, else we run into trouble as soon as the compiler creates different versions of our singleton member's static data in different libraries
2009-09-02 12:32:45 +0200 fs r275704 : AutoIncrementIsPrimaryKey is a driver setting, not a data source setting
2009-09-02 11:42:49 +0200 fs r275701 : URL meta data are meta data which are valid for all connections of this type, not per-data-source properties. Settings them as data source properties is a hack.
2009-09-02 08:43:34 +0200 fs r275696 : 3.x.x is not a valid 'since' tag
2009-09-01 16:05:24 +0200 fs r275665 : #i104686# don't treat controls bound to read-only columns as required
2009-09-01 13:10:22 +0200 fs r275657 : #i104574# use PageUp/Down to scroll through the complete page
2009-09-01 07:04:48 +0200 oj r275641 : #i104104# correct line ends
2009-08-31 15:52:34 +0200 fs r275612 : #i104410#
2009-08-31 12:29:05 +0200 fs r275596 : #i104364#
2009-08-31 12:28:56 +0200 fs r275595 : #i104364#
2009-08-31 11:43:09 +0200 fs r275593 : #i104649# JavaDriverClassPath is also a known JDBC-bridge setting
2009-08-31 11:41:37 +0200 fs r275592 : #i104649#
2009-08-28 21:48:27 +0200 fs r275552 : during #i96862#: renamed the configuration data which controls availability of certain DBA-related UI
2009-08-28 21:48:17 +0200 fs r275551 : #i96862# do not show the 'Create a new database' option when a) no embedded/dBase driver is installed or b) the configuration requests to hide the option
2009-08-28 21:47:19 +0200 fs r275550 : during #i96862#: renamed the configuration data which controls availability of certain DBA-related UI
2009-08-28 21:46:41 +0200 fs r275549 : #i96862# renamed and extended the configuration data which controls availability of certain DBA-related UI
2009-08-28 15:10:19 +0200 fs r275535 : #i96862# if no embedded driver is installed, use dBase for creating new DBs. If no dBase driver is installed, too, do not offer the 'Create new database' option
2009-08-28 14:03:04 +0200 fs r275532 : #i104454# allow multiple fields to display the same column
2009-08-28 13:14:00 +0200 fs r275528 : #i104584# driver meta data do not belong into a data source's settings
2009-08-28 13:09:57 +0200 fs r275527 : properly chech the MySQL type buttons (else next/back in the wizard leads to state with two buttons checked)
2009-08-28 13:09:17 +0200 fs r275526 : #i104584# driver meta data do not belong into a data source's settings
2009-08-28 13:07:18 +0200 fs r275525 : BooleanComparisonMode is a property, or a feature - but not a driver meta data
2009-08-28 11:00:31 +0200 fs r275521 : #i104580#
2009-08-28 10:40:05 +0200 fs r275519 : #i104577# correct assertion: If the template node type is ANY, then any value type is allowed
2009-08-28 10:09:30 +0200 fs r275518 : #i104575# implement Named Pipe UI
2009-08-28 10:09:07 +0200 fs r275517 : pass the trigger-event to IWindowOperator::operateOn / work with VclWindowEvents, not VclSimpleEvents
2009-08-27 14:27:36 +0200 fs r275484 : ImplPosTabPage: respect mbEmptyViewMargin for WINDOWALIGN_LEFT
2009-08-27 13:43:56 +0200 fs r275480 : merging latest changes from CWS dba32f herein
2009-08-27 13:23:07 +0200 fs r275475 : #i103882#
2009-08-27 11:56:55 +0200 fs r275466 : #i104544# SetState: Do not call Update at the window which we just set text for. It should (sic\!) not be needed, but causes trouble
2009-08-27 11:55:34 +0200 fs r275465 : #i104544#
do not allow re-entrance for impl_ensureControl_nothrow
Actually, this is part of the fix only. I also removed the code which triggered this re-entrance (from
the grid control implementation), but to ensure it won't happen, again, I added some safety herein.
2009-08-27 10:14:11 +0200 fs r275459 : preparations for supporting a 'NamedPipe' parameter for the MySQL Connector/OOo
2009-08-27 10:13:21 +0200 fs r275458 : preparations for supporting a 'NamedPipe' setting for the MySQL Connector/OOo
2009-08-27 10:11:14 +0200 fs r275456 : outsourced the MySQLNative settings into a dedicated class, to not duplicate all the code in two tab page implementations
2009-08-26 14:18:13 +0200 fs r275422 : #i10000#
2009-08-26 13:26:36 +0200 fs r275419 : ignore output paths
2009-08-26 13:23:38 +0200 fs r275417 : support the LocalSocket property for the MySQL native driver
2009-08-26 13:17:05 +0200 fs r275416 : some re-factoring, to outsource the tab page for setting up the MySQLNative connection, into a dedicated class (needed later)
2009-08-26 13:15:15 +0200 fs r275415 : support a NoThousandSep property for NumericFormatters - I'm tired of correcting this at runtime, instead of controlling it in the resource
2009-08-26 11:45:08 +0200 fs r275410 : oops, 'flat' shouldn't have got lost
2009-08-26 09:38:57 +0200 fs r275398 : #i102631# when saving the document fails, ensure that the interaction handler really can handle/display the error
2009-08-26 09:37:05 +0200 fs r275397 : #i102631# don't let non-IO/RuntimeExceptions escape from DatabaseDocument::store*, wrap them into an IOException
2009-08-26 09:35:39 +0200 fs r275395 : let the default interaction handler implement XInteractionHandler2
2009-08-25 13:51:34 +0200 fs r275352 : #i102631# createTempFile: pass URL through FileHelper.getOOoCompatibleFileURL
2009-08-25 13:49:23 +0200 fs r275351 : #i102631# createTempFileURL: immediately delete the file implicitly created by createTempFile, we really only need the URL
2009-08-24 14:49:07 +0200 fs r275318 : #i10000#
2009-08-24 14:36:03 +0200 fs r275315 : properly terminate message with 0 character
2009-08-24 14:35:45 +0200 fs r275314 : trace method concepts in non-pro, if special flag is enabled
2009-08-24 14:24:17 +0200 fs r275312 : #i98973# filter some more events for grid control columns
2009-08-24 14:15:23 +0200 fs r275311 : #i98973# implement XComboBox for combo box cells
2009-08-24 13:39:24 +0200 fs r275308 : #i98973# do not display the 'actionPerformed' event for grid combo box columns
2009-08-24 12:52:03 +0200 fs r275303 : #i98973# implement XCheckBox and XButton for check box cells
2009-08-24 11:56:05 +0200 oj r275300 : #i104447# wrong default for orientation
2009-08-24 10:51:21 +0200 fs r275296 : in the script selector dialog, interpret a double click onto a function as OK
2009-08-24 10:50:56 +0200 fs r275295 : localize some to-be-displayed names, consolidate some code regarding form/control naming
2009-08-21 14:28:05 +0200 fs r275255 : #i98973# implement KeyListeners
2009-08-21 14:27:20 +0200 fs r275254 : #i98973# move the conversion VCL[Mouse|Key]Event->Awt[Mouse|Key]Event from vclxwindow.cxx to VCLUnoHelper
2009-08-21 14:08:50 +0200 fs r275248 : #i98973# implement Mouse- and MouseMotion-broadcasting
2009-08-21 13:31:08 +0200 fs r275244 : #i98973# implement text and change listeners at text cells
2009-08-21 12:47:38 +0200 fs r275234 : #i104399# some refactoring:
If the MySQL Connector/OOo is installed, it registers for the sdbc:mysqlc: protocol (now known as DST_MYSQL_NATIVE_DIRECT).
However, we do not want to display this in the UI, instead we display "MySQL" only, which collects DST_MYSQL_ODBC, DST_MYSQL_JDBC, and DST_MYSQL_NATIVE.
2009-08-21 12:45:18 +0200 fs r275232 : #i104399# also register for the sdbc:mysql:mysqlc protocol, decide at runtime (depending on the availability of sdbc:mysqlc:), whether it is really accepted. This prevents that the C/OOo extension needs to register *our* implementation name for the sdbc:mysql:mysqlc: protocol, which would be somewhat weird
2009-08-20 16:18:48 +0200 fs r275190 : merging the latest changes from CWS dba32f (which this CWS was created from)
2009-08-19 20:19:59 +0200 fs r275160 : add some spacing between the radios
2009-08-19 14:50:15 +0200 fs r275150 : #i98973# slightly refactoring the grid cell implementations, to prepare for proper events being fired. Implement focus events for the moment, more to come.
2009-08-19 10:53:38 +0200 fs r275142 : #i99936# initialize newly created models
2009-08-18 23:03:48 +0200 fs r275132 : merging latest changes from CWS dba32f
2009-08-18 15:14:08 +0200 fs r275110 : #i102819# SetColumnPos: SCROLL_CLIP is deadly here
Diffstat (limited to 'svx/source/fmcomp')
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 23 | ||||
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 855 |
2 files changed, 699 insertions, 179 deletions
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 20de4e139b9d..c210919bd09d 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -889,9 +889,6 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe break; case SID_FM_SHOWCOLS_MORE: { - //CHINA001 FmShowColsDialog dlg(NULL); - //CHINA001 dlg.SetColumns(xCols); - //CHINA001 dlg.Execute(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if(pFact) { @@ -960,24 +957,14 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe } else { - // Standardlabel setzen - ::rtl::OUString sLabelBase = String( SVX_RES( RID_STR_COLUMN ) ); - // disambiguate the name - Reference< XNameAccess > xColNames( xCols, UNO_QUERY ); - ::rtl::OUString sLabel; - for ( sal_Int32 i=1; i<65535; ++i ) - { - sLabel = sLabelBase; - sLabel += ::rtl::OUString::valueOf( (sal_Int32)i ); - if ( !xColNames->hasByName( sLabel ) ) - break; - } - // no fallback in case the name is not unique (which is rather improbable) .... + FormControlFactory factory( ::comphelper::getProcessServiceFactory() ); + + ::rtl::OUString sLabel = factory.getDefaultUniqueName_ByComponentType( + Reference< XNameAccess >( xCols, UNO_QUERY_THROW ), xNewCol ); xNewCol->setPropertyValue( FM_PROP_LABEL, makeAny( sLabel ) ); xNewCol->setPropertyValue( FM_PROP_NAME, makeAny( sLabel ) ); - FormControlFactory determine( ::comphelper::getProcessServiceFactory() ); - determine.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xNewCol ); + factory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xNewCol ); xCols->insertByIndex( nPos, makeAny( xNewCol ) ); } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 45a67a09e52d..96f11adfa6df 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -30,55 +30,52 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "gridcell.hxx" -#include "fmtools.hxx" -#include <stdio.h> -#ifndef _SVX_FMPROP_HRC + + #include "fmprop.hrc" -#endif +#include "fmresids.hrc" +#include "fmtools.hxx" +#include "gridcell.hxx" #include "gridcols.hxx" #include "sdbdatacolumn.hxx" + +#include <com/sun/star/awt/LineEndFormat.hpp> +#include <com/sun/star/awt/MouseWheelBehavior.hpp> #include <com/sun/star/awt/VisualEffect.hpp> -#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> -#ifndef _COM_SUN_STAR_SDDB_XCOLUMNSSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> -#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/form/XBoundComponent.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/form/FormComponentType.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/util/NumberFormat.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/awt/LineEndFormat.hpp> -#include <com/sun/star/awt/MouseWheelBehavior.hpp> -#ifndef _COM_SUN_STAR_SCRTIP_XEVENTATTACHERMANAGER_HPP_ -#include <com/sun/star/script/XEventAttacherManager.hpp> -#endif -#include <svtools/fmtfield.hxx> -#include <svtools/numuno.hxx> -#include <svtools/calendar.hxx> -#include <vcl/longcurr.hxx> -#include <svx/dialmgr.hxx> -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif -#include <tools/shl.hxx> -#include <tools/diagnose_ex.h> +#include <com/sun/star/util/XNumberFormatter.hpp> + +#include <comphelper/extract.hxx> #include <comphelper/numbers.hxx> #include <comphelper/property.hxx> -#include <comphelper/extract.hxx> +#include <connectivity/formattedcolumnvalue.hxx> #include <cppuhelper/typeprovider.hxx> #include <i18npool/lang.h> -#include <connectivity/formattedcolumnvalue.hxx> -#include <math.h> #include <rtl/math.hxx> +#include <svtools/calendar.hxx> +#include <svtools/fmtfield.hxx> +#include <svtools/numuno.hxx> #include <svtools/svmedit.hxx> +#include <svx/dialmgr.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/diagnose_ex.h> +#include <tools/shl.hxx> +#include <vcl/longcurr.hxx> + +#include <math.h> +#include <stdio.h> using namespace ::connectivity; using namespace ::connectivity::simple; @@ -228,13 +225,15 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< ::com::s { switch (nTypeId) { - case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell(this, pCellControl); break; - case TYPE_LISTBOX: m_pCell = new FmXListBoxCell(this, pCellControl); break; + case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, *pCellControl ); break; + case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, *pCellControl ); break; + case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, *pCellControl ); break; default: - m_pCell = new FmXEditCell(this, pCellControl); + m_pCell = new FmXEditCell( this, *pCellControl ); } } m_pCell->acquire(); + m_pCell->init(); impl_toggleScriptManager_nothrow( true ); @@ -3199,13 +3198,33 @@ TYPEINIT0(FmXGridCell); DBG_NAME(FmXGridCell); //----------------------------------------------------------------------------- -FmXGridCell::FmXGridCell(DbGridColumn* pColumn, DbCellControl* pControl) +FmXGridCell::FmXGridCell( DbGridColumn* pColumn, DbCellControl* _pControl ) :OComponentHelper(m_aMutex) ,m_pColumn(pColumn) - ,m_pCellControl(pControl) + ,m_pCellControl( _pControl ) + ,m_aWindowListeners( m_aMutex ) + ,m_aFocusListeners( m_aMutex ) + ,m_aKeyListeners( m_aMutex ) + ,m_aMouseListeners( m_aMutex ) + ,m_aMouseMotionListeners( m_aMutex ) { DBG_CTOR(FmXGridCell,NULL); +} + +//----------------------------------------------------------------------------- +void FmXGridCell::init() +{ + Window* pEventWindow( getEventWindow() ); + if ( pEventWindow ) + pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) ); +} +//----------------------------------------------------------------------------- +Window* FmXGridCell::getEventWindow() const +{ + if ( m_pCellControl ) + return &m_pCellControl->GetWindow(); + return NULL; } //----------------------------------------------------------------------------- @@ -3236,25 +3255,34 @@ void FmXGridCell::SetTextLineColor(const Color& _rColor) // XTypeProvider //------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXGridCell::getImplementationId() throw(RuntimeException) -{ - static ::cppu::OImplementationId* pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); +Sequence< Type > SAL_CALL FmXGridCell::getTypes( ) throw (RuntimeException) +{ + Sequence< uno::Type > aTypes = ::comphelper::concatSequences( + ::cppu::OComponentHelper::getTypes(), + FmXGridCell_Base::getTypes() + ); + if ( m_pCellControl ) + aTypes = ::comphelper::concatSequences( + aTypes, + FmXGridCell_WindowBase::getTypes() + ); + return aTypes; } +//------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXGridCell ) + // OComponentHelper //----------------------------------------------------------------------------- void FmXGridCell::disposing() { + lang::EventObject aEvent( *this ); + m_aWindowListeners.disposeAndClear( aEvent ); + m_aFocusListeners.disposeAndClear( aEvent ); + m_aKeyListeners.disposeAndClear( aEvent ); + m_aMouseListeners.disposeAndClear( aEvent ); + m_aMouseMotionListeners.disposeAndClear( aEvent ); + OComponentHelper::disposing(); m_pColumn = NULL; DELETEZ(m_pCellControl); @@ -3263,12 +3291,13 @@ void FmXGridCell::disposing() //------------------------------------------------------------------ Any SAL_CALL FmXGridCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) { - Any aReturn = OComponentHelper::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType, - static_cast< ::com::sun::star::awt::XControl* >(this), - static_cast< ::com::sun::star::form::XBoundControl* >(this) - ); + Any aReturn = OComponentHelper::queryAggregation( _rType ); + + if ( !aReturn.hasValue() ) + aReturn = FmXGridCell_Base::queryInterface( _rType ); + + if ( !aReturn.hasValue() && ( m_pCellControl != NULL ) ) + aReturn = FmXGridCell_WindowBase::queryInterface( _rType ); return aReturn; } @@ -3305,6 +3334,231 @@ void FmXGridCell::setLock(sal_Bool _bLock) throw( RuntimeException ) } } +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::setPosSize( ::sal_Int32 _X, ::sal_Int32 _Y, ::sal_Int32 _Width, ::sal_Int32 _Height, ::sal_Int16 _Flags ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::setPosSize: not implemented" ); + (void)_X; + (void)_Y; + (void)_Width; + (void)_Height; + (void)_Flags; + // not allowed to tamper with this for a grid cell +} + +//------------------------------------------------------------------ +awt::Rectangle SAL_CALL FmXGridCell::getPosSize( ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::getPosSize: not implemented" ); + return awt::Rectangle(); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::setVisible( ::sal_Bool _Visible ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::setVisible: not implemented" ); + (void)_Visible; + // not allowed to tamper with this for a grid cell +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::setEnable( ::sal_Bool _Enable ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::setEnable: not implemented" ); + (void)_Enable; + // not allowed to tamper with this for a grid cell +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::setFocus( ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::setFocus: not implemented" ); + // not allowed to tamper with this for a grid cell +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException) +{ + m_aWindowListeners.addInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removeWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException) +{ + m_aWindowListeners.removeInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException) +{ + m_aFocusListeners.addInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removeFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException) +{ + m_aFocusListeners.removeInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException) +{ + m_aKeyListeners.addInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removeKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException) +{ + m_aKeyListeners.removeInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException) +{ + m_aMouseListeners.addInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removeMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException) +{ + m_aMouseListeners.removeInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException) +{ + m_aMouseMotionListeners.addInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException) +{ + m_aMouseMotionListeners.removeInterface( _rxListener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::addPaintListener: not implemented" ); + (void)_rxListener; +} + +//------------------------------------------------------------------ +void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException) +{ + OSL_ENSURE( false, "FmXGridCell::removePaintListener: not implemented" ); + (void)_rxListener; +} + +//------------------------------------------------------------------ +IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent*, _pEvent ) +{ + ENSURE_OR_THROW( _pEvent, "illegal event pointer" ); + ENSURE_OR_THROW( _pEvent->GetWindow(), "illegal window" ); + onWindowEvent( _pEvent->GetId(), *_pEvent->GetWindow(), _pEvent->GetData() ); + return 1L; +} + +//------------------------------------------------------------------------------ +void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent ) +{ + m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent ); +} + +//------------------------------------------------------------------------------ +void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent ) +{ + m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent ); +} + +//------------------------------------------------------------------------------ +void FmXGridCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData ) +{ + switch ( _nEventId ) + { + case VCLEVENT_CONTROL_GETFOCUS: + case VCLEVENT_WINDOW_GETFOCUS: + case VCLEVENT_CONTROL_LOSEFOCUS: + case VCLEVENT_WINDOW_LOSEFOCUS: + { + if ( ( _rWindow.IsCompoundControl() + && ( _nEventId == VCLEVENT_CONTROL_GETFOCUS + || _nEventId == VCLEVENT_CONTROL_LOSEFOCUS + ) + ) + || ( !_rWindow.IsCompoundControl() + && ( _nEventId == VCLEVENT_WINDOW_GETFOCUS + || _nEventId == VCLEVENT_WINDOW_LOSEFOCUS + ) + ) + ) + { + if ( !m_aFocusListeners.getLength() ) + break; + + bool bFocusGained = ( _nEventId == VCLEVENT_CONTROL_GETFOCUS ) || ( _nEventId == VCLEVENT_WINDOW_GETFOCUS ); + + awt::FocusEvent aEvent; + aEvent.Source = *this; + aEvent.FocusFlags = _rWindow.GetGetFocusFlags(); + aEvent.Temporary = sal_False; + + if ( bFocusGained ) + onFocusGained( aEvent ); + else + onFocusLost( aEvent ); + } + } + break; + case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: + case VCLEVENT_WINDOW_MOUSEBUTTONUP: + { + if ( !m_aMouseListeners.getLength() ) + break; + + const bool bButtonDown = ( _nEventId == VCLEVENT_WINDOW_MOUSEBUTTONDOWN ); + + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent* >( _pEventData ), *this ) ); + m_aMouseListeners.notifyEach( bButtonDown ? &awt::XMouseListener::mousePressed : &awt::XMouseListener::mouseReleased, aEvent ); + } + break; + case VCLEVENT_WINDOW_MOUSEMOVE: + { + const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData ); + if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() ) + { + if ( m_aMouseListeners.getLength() != 0 ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); + m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent ); + } + } + else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() ) + { + if ( m_aMouseMotionListeners.getLength() != 0 ) + { + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); + aEvent.ClickCount = 0; + const bool bSimpleMove = ( ( rMouseEvent.GetMode() & MOUSE_SIMPLEMOVE ) != 0 ); + m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent ); + } + } + } + break; + case VCLEVENT_WINDOW_KEYINPUT: + case VCLEVENT_WINDOW_KEYUP: + { + if ( !m_aKeyListeners.getLength() ) + break; + + const bool bKeyPressed = ( _nEventId == VCLEVENT_WINDOW_KEYINPUT ); + awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent* >( _pEventData ), *this ) ); + m_aKeyListeners.notifyEach( bKeyPressed ? &awt::XKeyListener::keyPressed: &awt::XKeyListener::keyReleased, aEvent ); + } + break; + } +} + /*************************************************************************/ TYPEINIT1(FmXDataCell, FmXGridCell); //------------------------------------------------------------------------------ @@ -3326,6 +3580,12 @@ void FmXDataCell::UpdateFromColumn() /*************************************************************************/ TYPEINIT1(FmXTextCell, FmXDataCell); +FmXTextCell::FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl ) + :FmXDataCell( pColumn, _rControl ) + ,m_bFastPaint( sal_True ) +{ +} + //------------------------------------------------------------------------------ void FmXTextCell::PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect, @@ -3372,15 +3632,16 @@ void FmXTextCell::PaintFieldToCell(OutputDevice& rDev, DBG_NAME(FmXEditCell); //------------------------------------------------------------------------------ -FmXEditCell::FmXEditCell(DbGridColumn* pColumn, DbCellControl* pControl) - :FmXTextCell(pColumn, pControl) +FmXEditCell::FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl ) + :FmXTextCell( pColumn, _rControl ) ,m_aTextListeners(m_aMutex) + ,m_aChangeListeners( m_aMutex ) ,m_pEditImplementation( NULL ) ,m_bOwnEditImplementation( false ) { DBG_CTOR(FmXEditCell,NULL); - DbTextField* pTextField = PTR_CAST( DbTextField, pControl ); + DbTextField* pTextField = PTR_CAST( DbTextField, &_rControl ); if ( pTextField ) { @@ -3390,11 +3651,9 @@ FmXEditCell::FmXEditCell(DbGridColumn* pColumn, DbCellControl* pControl) } else { - m_pEditImplementation = new EditImplementation( *static_cast< Edit* >( pControl->GetControl() ) ); + m_pEditImplementation = new EditImplementation( static_cast< Edit& >( _rControl.GetWindow() ) ); m_bOwnEditImplementation = true; } - - m_pEditImplementation->SetModifyHdl( LINK( this, FmXEditCell, OnTextChanged ) ); } //------------------------------------------------------------------ @@ -3416,6 +3675,7 @@ void FmXEditCell::disposing() { ::com::sun::star::lang::EventObject aEvt(*this); m_aTextListeners.disposeAndClear(aEvt); + m_aChangeListeners.disposeAndClear(aEvt); m_pEditImplementation->SetModifyHdl( Link() ); if ( m_bOwnEditImplementation ) @@ -3428,27 +3688,26 @@ void FmXEditCell::disposing() //------------------------------------------------------------------ Any SAL_CALL FmXEditCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) { - Any aReturn = FmXDataCell::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType, - static_cast< ::com::sun::star::awt::XTextComponent* >(this) - ); + Any aReturn = FmXTextCell::queryAggregation( _rType ); + + if ( !aReturn.hasValue() ) + aReturn = FmXEditCell_Base::queryInterface( _rType ); + return aReturn; } //------------------------------------------------------------------------- Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXEditCell::getTypes( ) throw(RuntimeException) { - Sequence< ::com::sun::star::uno::Type > aTypes = OComponentHelper::getTypes(); - - sal_Int32 nLen = aTypes.getLength(); - aTypes.realloc(nLen + 2); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XControl >* >(NULL)); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XTextComponent >* >(NULL)); - - return aTypes; + return ::comphelper::concatSequences( + FmXTextCell::getTypes(), + FmXEditCell_Base::getTypes() + ); } +//------------------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXEditCell ) + // ::com::sun::star::awt::XTextComponent //------------------------------------------------------------------------------ void SAL_CALL FmXEditCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException ) @@ -3473,7 +3732,7 @@ void SAL_CALL FmXEditCell::setText( const ::rtl::OUString& aText ) throw( Runtim // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht. // ::com::sun::star::awt::Toolkit soll JAVA-komform sein... - OnTextChanged( NULL ); + onTextChanged(); } } @@ -3583,30 +3842,71 @@ void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen ) throw( RuntimeExcepti } //------------------------------------------------------------------------------ -IMPL_LINK( FmXEditCell, OnTextChanged, void*, EMPTYARG ) +void SAL_CALL FmXEditCell::addChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException) { - if ( m_pEditImplementation ) + m_aChangeListeners.addInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FmXEditCell::removeChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException) +{ + m_aChangeListeners.removeInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +void FmXEditCell::onTextChanged() +{ + ::com::sun::star::awt::TextEvent aEvent; + aEvent.Source = *this; + m_aTextListeners.notifyEach( &awt::XTextListener::textChanged, aEvent ); +} + +//------------------------------------------------------------------------------ +void FmXEditCell::onFocusGained( const awt::FocusEvent& _rEvent ) +{ + FmXTextCell::onFocusGained( _rEvent ); + m_sValueOnEnter = getText(); +} + +//------------------------------------------------------------------------------ +void FmXEditCell::onFocusLost( const awt::FocusEvent& _rEvent ) +{ + FmXTextCell::onFocusLost( _rEvent ); + + if ( getText() != m_sValueOnEnter ) { - ::cppu::OInterfaceIteratorHelper aIt( m_aTextListeners ); - ::com::sun::star::awt::TextEvent aEvt; - aEvt.Source = *this; - while( aIt.hasMoreElements() ) - ((::com::sun::star::awt::XTextListener *)aIt.next())->textChanged( aEvt ); + lang::EventObject aEvent( *this ); + m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvent ); } - return 1; +} + +//------------------------------------------------------------------------------ +void FmXEditCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData ) +{ + switch ( _nEventId ) + { + case VCLEVENT_EDIT_MODIFY: + { + if ( m_pEditImplementation && m_aTextListeners.getLength() ) + onTextChanged(); + return; + } + break; + } + + FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData ); } /*************************************************************************/ DBG_NAME(FmXCheckBoxCell); //------------------------------------------------------------------------------ -FmXCheckBoxCell::FmXCheckBoxCell(DbGridColumn* pColumn, DbCellControl* pControl) - :FmXDataCell(pColumn, pControl) +FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl ) + :FmXDataCell( pColumn, _rControl ) ,m_aItemListeners(m_aMutex) - ,m_pBox(&((CheckBoxControl*)pControl->GetControl())->GetBox()) + ,m_aActionListeners( m_aMutex ) + ,m_pBox( & static_cast< CheckBoxControl& >( _rControl.GetWindow() ).GetBox() ) { DBG_CTOR(FmXCheckBoxCell,NULL); - - ((CheckBoxControl*)pControl->GetControl())->SetClickHdl( LINK( this, FmXCheckBoxCell, OnClick ) ); } //------------------------------------------------------------------ @@ -3627,8 +3927,9 @@ void FmXCheckBoxCell::disposing() { ::com::sun::star::lang::EventObject aEvt(*this); m_aItemListeners.disposeAndClear(aEvt); + m_aActionListeners.disposeAndClear(aEvt); - ((CheckBoxControl*)m_pCellControl->GetControl())->SetClickHdl(Link()); + static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ).SetClickHdl(Link()); m_pBox = NULL; FmXDataCell::disposing(); @@ -3637,27 +3938,26 @@ void FmXCheckBoxCell::disposing() //------------------------------------------------------------------ Any SAL_CALL FmXCheckBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) { - Any aReturn = FmXDataCell::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType, - static_cast< ::com::sun::star::awt::XCheckBox* >(this) - ); + Any aReturn = FmXDataCell::queryAggregation( _rType ); + + if ( !aReturn.hasValue() ) + aReturn = FmXCheckBoxCell_Base::queryInterface( _rType ); + return aReturn; } //------------------------------------------------------------------------- Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXCheckBoxCell::getTypes( ) throw(RuntimeException) { - Sequence< ::com::sun::star::uno::Type > aTypes = OComponentHelper::getTypes(); - - sal_Int32 nLen = aTypes.getLength(); - aTypes.realloc(nLen + 2); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XControl >* >(NULL)); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XCheckBox >* >(NULL)); - - return aTypes; + return ::comphelper::concatSequences( + FmXDataCell::getTypes(), + FmXCheckBoxCell_Base::getTypes() + ); } +//------------------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXCheckBoxCell ) + //------------------------------------------------------------------ void SAL_CALL FmXCheckBoxCell::addItemListener( const Reference< ::com::sun::star::awt::XItemListener >& l ) throw( RuntimeException ) { @@ -3671,17 +3971,6 @@ void SAL_CALL FmXCheckBoxCell::removeItemListener( const Reference< ::com::sun:: } //------------------------------------------------------------------ -void SAL_CALL FmXCheckBoxCell::setLabel( const ::rtl::OUString& rLabel ) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (m_pBox) - { - UpdateFromColumn(); - m_pBox->SetText( rLabel ); - } -} - -//------------------------------------------------------------------ void SAL_CALL FmXCheckBoxCell::setState( short n ) throw( RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -3716,42 +4005,89 @@ void SAL_CALL FmXCheckBoxCell::enableTriState( sal_Bool b ) throw( RuntimeExcept } //------------------------------------------------------------------ -IMPL_LINK( FmXCheckBoxCell, OnClick, void*, EMPTYARG ) +void SAL_CALL FmXCheckBoxCell::addActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException) { - if (m_pBox) + m_aActionListeners.addInterface( _Listener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXCheckBoxCell::removeActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException) +{ + m_aActionListeners.removeInterface( _Listener ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXCheckBoxCell::setLabel( const ::rtl::OUString& _Label ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( m_pColumn ) + { + DbGridControl& rGrid( m_pColumn->GetParent() ); + rGrid.SetColumnTitle( rGrid.GetColumnId( m_pColumn->GetFieldPos() ), _Label ); + } +} + +//------------------------------------------------------------------ +void SAL_CALL FmXCheckBoxCell::setActionCommand( const ::rtl::OUString& _Command ) throw (RuntimeException) +{ + m_aActionCommand = _Command; +} + +//------------------------------------------------------------------ +Window* FmXCheckBoxCell::getEventWindow() const +{ + return m_pBox; +} + +//------------------------------------------------------------------ +void FmXCheckBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData ) +{ + switch ( _nEventId ) + { + case VCLEVENT_CHECKBOX_TOGGLE: { // check boxes are to be committed immediately (this holds for ordinary check box controls in // documents, and this must hold for check boxes in grid columns, too // 91210 - 22.08.2001 - frank.schoenheit@sun.com m_pCellControl->Commit(); - // notify our listeners - ::cppu::OInterfaceIteratorHelper aIt( m_aItemListeners ); - - ::com::sun::star::awt::ItemEvent aEvent; - aEvent.Source = *this; - aEvent.Highlighted = sal_False; - aEvent.Selected = m_pBox->GetState(); + Reference< XWindow > xKeepAlive( this ); + if ( m_aItemListeners.getLength() && m_pBox ) + { + awt::ItemEvent aEvent; + aEvent.Source = *this; + aEvent.Highlighted = sal_False; + aEvent.Selected = m_pBox->GetState(); + m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent ); + } + if ( m_aActionListeners.getLength() ) + { + awt::ActionEvent aEvent; + aEvent.Source = *this; + aEvent.ActionCommand = m_aActionCommand; + m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent ); + } + } + break; - while ( aIt.hasMoreElements() ) - static_cast< awt::XItemListener* >( aIt.next() )->itemStateChanged( aEvent ); + default: + FmXDataCell::onWindowEvent( _nEventId, _rWindow, _pEventData ); + break; } - return 1; } /*************************************************************************/ DBG_NAME(FmXListBoxCell); //------------------------------------------------------------------------------ -FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, DbCellControl* pControl) - :FmXTextCell(pColumn, pControl) +FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, DbCellControl& _rControl) + :FmXTextCell( pColumn, _rControl ) ,m_aItemListeners(m_aMutex) ,m_aActionListeners(m_aMutex) - ,m_pBox((ListBox*)pControl->GetControl()) + ,m_pBox( &static_cast< ListBox& >( _rControl.GetWindow() ) ) { DBG_CTOR(FmXListBoxCell,NULL); - m_pBox->AddEventListener( LINK( this, FmXListBoxCell, OnSelect ) ); m_pBox->SetDoubleClickHdl( LINK( this, FmXListBoxCell, OnDoubleClick ) ); } @@ -3786,26 +4122,25 @@ void FmXListBoxCell::disposing() Any SAL_CALL FmXListBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) { Any aReturn = FmXTextCell::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType, - static_cast< ::com::sun::star::awt::XListBox* >(this) - ); + + if ( !aReturn.hasValue() ) + aReturn = FmXListBoxCell_Base::queryInterface( _rType ); + return aReturn; } //------------------------------------------------------------------------- Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXListBoxCell::getTypes( ) throw(RuntimeException) { - Sequence< ::com::sun::star::uno::Type > aTypes = OComponentHelper::getTypes(); - - sal_Int32 nLen = aTypes.getLength(); - aTypes.realloc(nLen + 2); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XControl >* >(NULL)); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XListBox >* >(NULL)); - - return aTypes; + return ::comphelper::concatSequences( + FmXTextCell::getTypes(), + FmXListBoxCell_Base::getTypes() + ); } +//------------------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell ) + //------------------------------------------------------------------ void SAL_CALL FmXListBoxCell::addItemListener(const Reference< ::com::sun::star::awt::XItemListener >& l) throw( RuntimeException ) { @@ -4042,10 +4377,10 @@ void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 nEntry) throw( RuntimeExcept } //------------------------------------------------------------------ -IMPL_LINK(FmXListBoxCell, OnSelect, VclWindowEvent*, _pEvent ) +void FmXListBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData ) { - if ( ( _pEvent->GetWindow() == m_pBox ) - && ( _pEvent->GetId() == VCLEVENT_LISTBOX_SELECT ) + if ( ( &_rWindow == m_pBox ) + && ( _nEventId == VCLEVENT_LISTBOX_SELECT ) ) { OnDoubleClick( NULL ); @@ -4059,8 +4394,10 @@ IMPL_LINK(FmXListBoxCell, OnSelect, VclWindowEvent*, _pEvent ) ? m_pBox->GetSelectEntryPos() : 0xFFFF; m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent ); + return; } - return 1; + + FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData ); } @@ -4083,6 +4420,203 @@ IMPL_LINK( FmXListBoxCell, OnDoubleClick, void*, EMPTYARG ) /*************************************************************************/ + +DBG_NAME( FmXComboBoxCell ); + +//------------------------------------------------------------------------------ +FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl ) + :FmXTextCell( pColumn, _rControl ) + ,m_aItemListeners( m_aMutex ) + ,m_aActionListeners( m_aMutex ) + ,m_pComboBox( &static_cast< ComboBox& >( _rControl.GetWindow() ) ) +{ + DBG_CTOR( FmXComboBoxCell, NULL ); +} + +//------------------------------------------------------------------------------ +FmXComboBoxCell::~FmXComboBoxCell() +{ + if ( !OComponentHelper::rBHelper.bDisposed ) + { + acquire(); + dispose(); + } + + DBG_DTOR( FmXComboBoxCell, NULL ); +} + +//----------------------------------------------------------------------------- +void FmXComboBoxCell::disposing() +{ + ::com::sun::star::lang::EventObject aEvt(*this); + m_aItemListeners.disposeAndClear(aEvt); + m_aActionListeners.disposeAndClear(aEvt); + + FmXTextCell::disposing(); +} + +//------------------------------------------------------------------ +Any SAL_CALL FmXComboBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) +{ + Any aReturn = FmXTextCell::queryAggregation(_rType); + + if ( !aReturn.hasValue() ) + aReturn = FmXComboBoxCell_Base::queryInterface( _rType ); + + return aReturn; +} + +//------------------------------------------------------------------------- +Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes( ) throw(RuntimeException) +{ + return ::comphelper::concatSequences( + FmXTextCell::getTypes(), + FmXComboBoxCell_Base::getTypes() + ); +} + +//------------------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXComboBoxCell ) + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::addItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException ) +{ + m_aItemListeners.addInterface( l ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::removeItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException ) +{ + m_aItemListeners.removeInterface( l ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::addActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException ) +{ + m_aActionListeners.addInterface( l ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::removeActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException ) +{ + m_aActionListeners.removeInterface( l ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::addItem( const ::rtl::OUString& _Item, sal_Int16 _Pos ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( m_pComboBox ) + m_pComboBox->InsertEntry( _Item, _Pos ); +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::addItems( const Sequence< ::rtl::OUString >& _Items, sal_Int16 _Pos ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( m_pComboBox ) + { + sal_uInt16 nP = _Pos; + for ( sal_uInt16 n = 0; n < _Items.getLength(); n++ ) + { + m_pComboBox->InsertEntry( _Items.getConstArray()[n], nP ); + if ( _Pos != -1 ) + nP++; + } + } +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 _Pos, sal_Int16 _Count ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( m_pComboBox ) + { + for ( sal_uInt16 n = _Count; n; ) + m_pComboBox->RemoveEntry( _Pos + (--n) ); + } +} + +//------------------------------------------------------------------ +sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return m_pComboBox ? m_pComboBox->GetEntryCount() : 0; +} + +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 _Pos ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + String sItem; + if ( m_pComboBox ) + sItem = m_pComboBox->GetEntry( _Pos ); + return sItem; +} +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL FmXComboBoxCell::getItems() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Sequence< ::rtl::OUString > aItems; + if ( m_pComboBox ) + { + sal_uInt16 nEntries = m_pComboBox->GetEntryCount(); + aItems.realloc( nEntries ); + ::rtl::OUString* pItem = aItems.getArray(); + for ( sal_uInt16 n=0; n<nEntries; ++n, ++pItem ) + *pItem = m_pComboBox->GetEntry( n ); + } + return aItems; +} + +//------------------------------------------------------------------ +sal_Int16 SAL_CALL FmXComboBoxCell::getDropDownLineCount() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int16 nLines = 0; + if ( m_pComboBox ) + nLines = m_pComboBox->GetDropDownLineCount(); + + return nLines; +} + +//------------------------------------------------------------------ +void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( m_pComboBox ) + m_pComboBox->SetDropDownLineCount( nLines ); +} + +//------------------------------------------------------------------------------ +void FmXComboBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData ) +{ + + switch ( _nEventId ) + { + case VCLEVENT_COMBOBOX_SELECT: + { + awt::ItemEvent aEvent; + aEvent.Source = *this; + aEvent.Highlighted = sal_False; + + // Bei Mehrfachselektion 0xFFFF, sonst die ID + aEvent.Selected = ( m_pComboBox->GetSelectEntryCount() == 1 ) + ? m_pComboBox->GetSelectEntryPos() + : 0xFFFF; + m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent ); + } + break; + + default: + FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData ); + break; + } +} + +/*************************************************************************/ TYPEINIT1(FmXFilterCell, FmXGridCell); //------------------------------------------------------------------------------ @@ -4093,8 +4627,8 @@ Reference< XInterface > FmXFilterCell_CreateInstance(const Reference< ::com::su DBG_NAME(FmXFilterCell); //------------------------------------------------------------------------------ -FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, DbCellControl* pControl) - :FmXGridCell(pColumn, pControl) +FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, DbCellControl* pControl ) + :FmXGridCell( pColumn, pControl ) ,m_aTextListeners(m_aMutex) { DBG_CTOR(FmXFilterCell,NULL); @@ -4180,26 +4714,25 @@ void FmXFilterCell::disposing() Any SAL_CALL FmXFilterCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException) { Any aReturn = FmXGridCell::queryAggregation(_rType); - if (!aReturn.hasValue()) - aReturn = ::cppu::queryInterface(_rType, - static_cast< ::com::sun::star::awt::XTextComponent* >(this) - ); + + if ( !aReturn.hasValue() ) + aReturn = FmXFilterCell_Base::queryInterface( _rType ); + return aReturn; } //------------------------------------------------------------------------- Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXFilterCell::getTypes( ) throw(RuntimeException) { - Sequence< ::com::sun::star::uno::Type > aTypes = OComponentHelper::getTypes(); - - sal_Int32 nLen = aTypes.getLength(); - aTypes.realloc(nLen + 2); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XControl >* >(NULL)); - aTypes.getArray()[nLen++] = ::getCppuType(static_cast< Reference< ::com::sun::star::awt::XTextComponent >* >(NULL)); - - return aTypes; + return ::comphelper::concatSequences( + FmXGridCell::getTypes(), + FmXFilterCell_Base::getTypes() + ); } +//------------------------------------------------------------------------------ +IMPLEMENT_GET_IMPLEMENTATION_ID( FmXFilterCell ) + // ::com::sun::star::awt::XTextComponent //------------------------------------------------------------------------------ void SAL_CALL FmXFilterCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException ) |