1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sal/macros.h>
23 #include "svx/fmresids.hrc"
24 #include "svx/fmtools.hxx"
25 #include "gridcell.hxx"
26 #include "gridcols.hxx"
27 #include "sdbdatacolumn.hxx"
29 #include <com/sun/star/awt/LineEndFormat.hpp>
30 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
31 #include <com/sun/star/awt/VisualEffect.hpp>
32 #include <com/sun/star/container/XChild.hpp>
33 #include <com/sun/star/container/XNamed.hpp>
34 #include <com/sun/star/form/FormComponentType.hpp>
35 #include <com/sun/star/form/XBoundComponent.hpp>
36 #include <com/sun/star/script/XEventAttacherManager.hpp>
37 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
38 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
39 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
40 #include <com/sun/star/sdbc/ColumnValue.hpp>
41 #include <com/sun/star/sdbc/DataType.hpp>
42 #include <com/sun/star/sdbc/XStatement.hpp>
43 #include <com/sun/star/util/NumberFormat.hpp>
44 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
45 #include <com/sun/star/util/Time.hpp>
46 #include <com/sun/star/util/Date.hpp>
48 #include <comphelper/numbers.hxx>
49 #include <comphelper/property.hxx>
50 #include <comphelper/servicehelper.hxx>
51 #include <comphelper/string.hxx>
52 #include <connectivity/formattedcolumnvalue.hxx>
53 #include <cppuhelper/typeprovider.hxx>
54 #include <i18nlangtag/lang.h>
56 #include <rtl/math.hxx>
57 #include <svtools/calendar.hxx>
58 #include <svtools/fmtfield.hxx>
59 #include <svl/numuno.hxx>
60 #include <svtools/svmedit.hxx>
61 #include <svx/dialmgr.hxx>
62 #include <toolkit/helper/vclunohelper.hxx>
63 #include <tools/diagnose_ex.h>
64 #include <tools/shl.hxx>
65 #include <vcl/longcurr.hxx>
66 #include <vcl/settings.hxx>
71 using namespace ::connectivity
;
72 using namespace ::connectivity::simple
;
73 using namespace ::svxform
;
74 using namespace ::comphelper
;
75 using namespace ::svt
;
76 using namespace ::com::sun::star
;
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::sdbc
;
79 using namespace ::com::sun::star::sdbcx
;
80 using namespace ::com::sun::star::sdb
;
81 using namespace ::com::sun::star::beans
;
82 using namespace ::com::sun::star::form
;
84 using ::com::sun::star::util::XNumberFormatter
;
85 namespace MouseWheelBehavior
= ::com::sun::star::awt::MouseWheelBehavior
;
87 const char INVALIDTEXT
[] = "###";
88 const char OBJECTTEXT
[] = "<OBJECT>";
95 static LineEnd
getModelLineEndSetting( const Reference
< XPropertySet
>& _rxModel
)
97 LineEnd eFormat
= LINEEND_LF
;
101 sal_Int16 nLineEndFormat
= awt::LineEndFormat::LINE_FEED
;
103 Reference
< XPropertySetInfo
> xPSI
;
105 xPSI
= _rxModel
->getPropertySetInfo();
107 OSL_ENSURE( xPSI
.is(), "getModelLineEndSetting: invalid column model!" );
108 if ( xPSI
.is() && xPSI
->hasPropertyByName( FM_PROP_LINEENDFORMAT
) )
110 OSL_VERIFY( _rxModel
->getPropertyValue( FM_PROP_LINEENDFORMAT
) >>= nLineEndFormat
);
112 switch ( nLineEndFormat
)
114 case awt::LineEndFormat::CARRIAGE_RETURN
: eFormat
= LINEEND_CR
; break;
115 case awt::LineEndFormat::LINE_FEED
: eFormat
= LINEEND_LF
; break;
116 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
: eFormat
= LINEEND_CRLF
; break;
118 OSL_FAIL( "getModelLineEndSetting: what's this?" );
122 catch( const Exception
& )
124 OSL_FAIL( "getModelLineEndSetting: caught an exception!" );
125 DBG_UNHANDLED_EXCEPTION();
135 CellControllerRef
DbGridColumn::s_xEmptyController
;
138 void DbGridColumn::CreateControl(sal_Int32 _nFieldPos
, const Reference
< ::com::sun::star::beans::XPropertySet
>& xField
, sal_Int32 nTypeId
)
142 m_nTypeId
= (sal_Int16
)nTypeId
;
143 if (xField
!= m_xField
)
147 xField
->getPropertyValue(FM_PROP_FORMATKEY
) >>= m_nFormatKey
;
148 m_nFieldPos
= (sal_Int16
)_nFieldPos
;
149 m_bReadOnly
= ::comphelper::getBOOL(xField
->getPropertyValue(FM_PROP_ISREADONLY
));
150 m_bAutoValue
= ::comphelper::getBOOL(xField
->getPropertyValue(FM_PROP_AUTOINCREMENT
));
151 m_nFieldType
= (sal_Int16
)::comphelper::getINT32(xField
->getPropertyValue(FM_PROP_FIELDTYPE
));
153 switch (m_nFieldType
)
157 case DataType::TIMESTAMP
:
161 case DataType::BOOLEAN
:
162 case DataType::TINYINT
:
163 case DataType::SMALLINT
:
164 case DataType::INTEGER
:
165 case DataType::BIGINT
:
166 case DataType::FLOAT
:
168 case DataType::DOUBLE
:
169 case DataType::NUMERIC
:
170 case DataType::DECIMAL
:
171 m_nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
175 m_nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
180 DbCellControl
* pCellControl
= NULL
;
181 if (m_rParent
.IsFilterMode())
183 pCellControl
= new DbFilterField(m_rParent
.getContext(),*this);
190 case TYPE_CHECKBOX
: pCellControl
= new DbCheckBox(*this); break;
191 case TYPE_COMBOBOX
: pCellControl
= new DbComboBox(*this); break;
192 case TYPE_CURRENCYFIELD
: pCellControl
= new DbCurrencyField(*this); break;
193 case TYPE_DATEFIELD
: pCellControl
= new DbDateField(*this); break;
194 case TYPE_LISTBOX
: pCellControl
= new DbListBox(*this); break;
195 case TYPE_NUMERICFIELD
: pCellControl
= new DbNumericField(*this); break;
196 case TYPE_PATTERNFIELD
: pCellControl
= new DbPatternField( *this, m_rParent
.getContext() ); break;
197 case TYPE_TEXTFIELD
: pCellControl
= new DbTextField(*this); break;
198 case TYPE_TIMEFIELD
: pCellControl
= new DbTimeField(*this); break;
199 case TYPE_FORMATTEDFIELD
: pCellControl
= new DbFormattedField(*this); break;
201 OSL_FAIL("DbGridColumn::CreateControl: Unknown Column");
206 Reference
< XRowSet
> xCur
;
207 if (m_rParent
.getDataSource())
208 xCur
= Reference
< XRowSet
> ((Reference
< XInterface
>)*m_rParent
.getDataSource(), UNO_QUERY
);
209 // TODO : the cursor wrapper should use an XRowSet interface, too
211 pCellControl
->Init( m_rParent
.GetDataWindow(), xCur
);
213 // now create the control wrapper
214 if (m_rParent
.IsFilterMode())
215 m_pCell
= new FmXFilterCell(this, pCellControl
);
220 case TYPE_CHECKBOX
: m_pCell
= new FmXCheckBoxCell( this, *pCellControl
); break;
221 case TYPE_LISTBOX
: m_pCell
= new FmXListBoxCell( this, *pCellControl
); break;
222 case TYPE_COMBOBOX
: m_pCell
= new FmXComboBoxCell( this, *pCellControl
); break;
224 m_pCell
= new FmXEditCell( this, *pCellControl
);
230 impl_toggleScriptManager_nothrow( true );
232 // only if we use have a bound field, we use a a controller for displaying the
233 // window in the grid
235 m_xController
= pCellControl
->CreateController();
239 void DbGridColumn::impl_toggleScriptManager_nothrow( bool _bAttach
)
243 Reference
< container::XChild
> xChild( m_xModel
, UNO_QUERY_THROW
);
244 Reference
< script::XEventAttacherManager
> xManager( xChild
->getParent(), UNO_QUERY_THROW
);
245 Reference
< container::XIndexAccess
> xContainer( xChild
->getParent(), UNO_QUERY_THROW
);
247 sal_Int32
nIndexInParent( getElementPos( xContainer
, m_xModel
) );
249 Reference
< XInterface
> xCellInterface( *m_pCell
, UNO_QUERY
);
251 xManager
->attach( nIndexInParent
, xCellInterface
, makeAny( xCellInterface
) );
253 xManager
->detach( nIndexInParent
, xCellInterface
);
255 catch( const Exception
& )
257 DBG_UNHANDLED_EXCEPTION();
262 void DbGridColumn::UpdateFromField(const DbGridRow
* pRow
, const Reference
< XNumberFormatter
>& xFormatter
)
264 if (m_pCell
&& m_pCell
->ISA(FmXFilterCell
))
265 PTR_CAST(FmXFilterCell
, m_pCell
)->Update();
266 else if (pRow
&& pRow
->IsValid() && m_nFieldPos
>= 0 && m_pCell
&& pRow
->HasField(m_nFieldPos
))
268 PTR_CAST(FmXDataCell
, m_pCell
)->UpdateFromField( pRow
->GetField( m_nFieldPos
).getColumn(), xFormatter
);
273 bool DbGridColumn::Commit()
276 if (!m_bInSave
&& m_pCell
)
279 bResult
= m_pCell
->Commit();
281 // store the data into the model
282 FmXDataCell
* pDataCell
= PTR_CAST(FmXDataCell
, m_pCell
);
283 if (bResult
&& pDataCell
)
285 Reference
< ::com::sun::star::form::XBoundComponent
> xComp(m_xModel
, UNO_QUERY
);
287 bResult
= xComp
->commit();
295 DbGridColumn::~DbGridColumn()
301 void DbGridColumn::setModel(::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> _xModel
)
304 impl_toggleScriptManager_nothrow( false );
309 impl_toggleScriptManager_nothrow( true );
313 void DbGridColumn::Clear()
317 impl_toggleScriptManager_nothrow( false );
324 m_xController
= NULL
;
330 m_bAutoValue
= false;
331 m_nFieldType
= DataType::OTHER
;
335 sal_Int16
DbGridColumn::SetAlignment(sal_Int16 _nAlign
)
342 m_xField
->getPropertyValue(FM_PROP_FIELDTYPE
) >>= nType
;
346 case DataType::NUMERIC
:
347 case DataType::DECIMAL
:
348 case DataType::DOUBLE
:
350 case DataType::BIGINT
:
351 case DataType::INTEGER
:
352 case DataType::SMALLINT
:
353 case DataType::TINYINT
:
356 case DataType::TIMESTAMP
:
357 _nAlign
= ::com::sun::star::awt::TextAlign::RIGHT
;
360 case DataType::BOOLEAN
:
361 _nAlign
= ::com::sun::star::awt::TextAlign::CENTER
;
364 _nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
369 _nAlign
= ::com::sun::star::awt::TextAlign::LEFT
;
373 if (m_pCell
&& m_pCell
->isAlignedController())
374 m_pCell
->AlignControl(m_nAlign
);
380 sal_Int16
DbGridColumn::SetAlignmentFromModel(sal_Int16 nStandardAlign
)
382 Any
aAlign( m_xModel
->getPropertyValue(FM_PROP_ALIGN
));
383 if (aAlign
.hasValue())
385 sal_Int16 nTest
= sal_Int16();
386 if (aAlign
>>= nTest
)
387 nStandardAlign
= nTest
;
389 return SetAlignment(nStandardAlign
);
393 void DbGridColumn::setLock(bool _bLock
)
395 if (m_bLocked
== _bLock
)
399 // is the column we represent active ?
401 return; // no, it isn't (or at least it shouldn't be ...)
403 if (m_rParent
.GetCurColumnId() == m_nId
)
405 m_rParent
.DeactivateCell();
406 m_rParent
.ActivateCell(m_rParent
.GetCurRow(), m_rParent
.GetCurColumnId());
411 OUString
DbGridColumn::GetCellText(const DbGridRow
* pRow
, const Reference
< XNumberFormatter
>& xFormatter
) const
414 if (m_pCell
&& m_pCell
->ISA(FmXFilterCell
))
417 if (!pRow
|| !pRow
->IsValid())
418 aText
= OUString(INVALIDTEXT
);
419 else if (pRow
->HasField(m_nFieldPos
))
421 aText
= GetCellText( pRow
->GetField( m_nFieldPos
).getColumn(), xFormatter
);
427 OUString
DbGridColumn::GetCellText(const Reference
< ::com::sun::star::sdb::XColumn
>& xField
, const Reference
< XNumberFormatter
>& xFormatter
) const
432 FmXTextCell
* pTextCell
= PTR_CAST(FmXTextCell
, m_pCell
);
434 aText
= pTextCell
->GetText(xField
, xFormatter
);
436 aText
= OUString(OBJECTTEXT
);
442 Reference
< ::com::sun::star::sdb::XColumn
> DbGridColumn::GetCurrentFieldValue() const
444 Reference
< ::com::sun::star::sdb::XColumn
> xField
;
445 const DbGridRowRef xRow
= m_rParent
.GetCurrentRow();
446 if (xRow
.Is() && xRow
->HasField(m_nFieldPos
))
448 xField
= xRow
->GetField(m_nFieldPos
).getColumn();
454 void DbGridColumn::Paint(OutputDevice
& rDev
,
455 const Rectangle
& rRect
,
456 const DbGridRow
* pRow
,
457 const Reference
< XNumberFormatter
>& xFormatter
)
459 bool bEnabled
= ( rDev
.GetOutDevType() != OUTDEV_WINDOW
)
460 || ( static_cast< Window
& >( rDev
).IsEnabled() );
462 FmXDataCell
* pDataCell
= PTR_CAST(FmXDataCell
, m_pCell
);
465 if (!pRow
|| !pRow
->IsValid())
467 sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_CENTER
;
469 nStyle
|= TEXT_DRAW_DISABLE
;
471 rDev
.DrawText(rRect
, OUString(INVALIDTEXT
), nStyle
);
473 else if (m_bAutoValue
&& pRow
->IsNew())
475 sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_VCENTER
;
477 nStyle
|= TEXT_DRAW_DISABLE
;
479 switch (GetAlignment())
481 case ::com::sun::star::awt::TextAlign::RIGHT
:
482 nStyle
|= TEXT_DRAW_RIGHT
;
484 case ::com::sun::star::awt::TextAlign::CENTER
:
485 nStyle
|= TEXT_DRAW_CENTER
;
488 nStyle
|= TEXT_DRAW_LEFT
;
491 rDev
.DrawText(rRect
, SVX_RESSTR(RID_STR_AUTOFIELD
), nStyle
);
493 else if (pRow
->HasField(m_nFieldPos
))
495 pDataCell
->PaintFieldToCell(rDev
, rRect
, pRow
->GetField( m_nFieldPos
).getColumn(), xFormatter
);
500 if (!pRow
|| !pRow
->IsValid())
502 sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_CENTER
;
504 nStyle
|= TEXT_DRAW_DISABLE
;
506 rDev
.DrawText(rRect
, OUString(INVALIDTEXT
), nStyle
);
508 else if (pRow
->HasField(m_nFieldPos
) && m_bObject
)
510 sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_CENTER
;
512 nStyle
|= TEXT_DRAW_DISABLE
;
513 rDev
.DrawText(rRect
, OUString(OBJECTTEXT
), nStyle
);
516 else if ( m_pCell
->ISA( FmXFilterCell
) )
517 static_cast< FmXFilterCell
* >( m_pCell
)->PaintCell( rDev
, rRect
);
521 void DbGridColumn::ImplInitWindow( Window
& rParent
, const InitWindowFacet _eInitWhat
)
524 m_pCell
->ImplInitWindow( rParent
, _eInitWhat
);
530 TYPEINIT0( DbCellControl
)
531 TYPEINIT1( DbLimitedLengthField
, DbCellControl
)
532 TYPEINIT1( DbTextField
, DbLimitedLengthField
)
533 TYPEINIT1( DbFormattedField
, DbLimitedLengthField
)
534 TYPEINIT1( DbCheckBox
, DbCellControl
)
535 TYPEINIT1( DbComboBox
, DbCellControl
)
536 TYPEINIT1( DbListBox
, DbCellControl
)
537 TYPEINIT1( DbPatternField
, DbCellControl
)
538 TYPEINIT1( DbSpinField
, DbCellControl
)
539 TYPEINIT1( DbDateField
, DbSpinField
)
540 TYPEINIT1( DbTimeField
, DbSpinField
)
541 TYPEINIT1( DbCurrencyField
, DbSpinField
)
542 TYPEINIT1( DbNumericField
, DbSpinField
)
543 TYPEINIT1( DbFilterField
, DbCellControl
)
546 DbCellControl::DbCellControl( DbGridColumn
& _rColumn
, bool /*_bText*/ )
547 :OPropertyChangeListener(m_aMutex
)
548 ,m_pModelChangeBroadcaster(NULL
)
549 ,m_pFieldChangeBroadcaster(NULL
)
550 ,m_bTransparent( false )
551 ,m_bAlignedController( true )
552 ,m_bAccessingValueProperty( false )
553 ,m_rColumn( _rColumn
)
557 Reference
< XPropertySet
> xColModelProps( _rColumn
.getModel(), UNO_QUERY
);
558 if ( xColModelProps
.is() )
560 // if our model's format key changes we want to propagate the new value to our windows
561 m_pModelChangeBroadcaster
= new ::comphelper::OPropertyChangeMultiplexer(this, Reference
< ::com::sun::star::beans::XPropertySet
> (_rColumn
.getModel(), UNO_QUERY
));
562 m_pModelChangeBroadcaster
->acquire();
564 // be listener for some common properties
565 implDoPropertyListening( FM_PROP_READONLY
, false );
566 implDoPropertyListening( FM_PROP_ENABLED
, false );
568 // add as listener for all know "value" properties
569 implDoPropertyListening( FM_PROP_VALUE
, false );
570 implDoPropertyListening( FM_PROP_STATE
, false );
571 implDoPropertyListening( FM_PROP_TEXT
, false );
572 implDoPropertyListening( FM_PROP_EFFECTIVE_VALUE
, false );
574 // be listener at the bound field as well
577 Reference
< XPropertySetInfo
> xPSI( xColModelProps
->getPropertySetInfo(), UNO_SET_THROW
);
578 if ( xPSI
->hasPropertyByName( FM_PROP_BOUNDFIELD
) )
580 Reference
< XPropertySet
> xField
;
581 xColModelProps
->getPropertyValue( FM_PROP_BOUNDFIELD
) >>= xField
;
584 m_pFieldChangeBroadcaster
= new ::comphelper::OPropertyChangeMultiplexer(this, xField
);
585 m_pFieldChangeBroadcaster
->acquire();
586 m_pFieldChangeBroadcaster
->addProperty( FM_PROP_ISREADONLY
);
590 catch( const Exception
& )
592 OSL_FAIL( "DbCellControl::doPropertyListening: caught an exception!" );
593 DBG_UNHANDLED_EXCEPTION();
599 void DbCellControl::implDoPropertyListening(const OUString
& _rPropertyName
, bool _bWarnIfNotExistent
)
603 Reference
< XPropertySet
> xColModelProps( m_rColumn
.getModel(), UNO_QUERY
);
604 Reference
< XPropertySetInfo
> xPSI
;
605 if ( xColModelProps
.is() )
606 xPSI
= xColModelProps
->getPropertySetInfo();
608 DBG_ASSERT( !_bWarnIfNotExistent
|| ( xPSI
.is() && xPSI
->hasPropertyByName( _rPropertyName
) ),
609 "DbCellControl::doPropertyListening: no property set info or non-existent property!" );
610 (void)_bWarnIfNotExistent
;
612 if ( xPSI
.is() && xPSI
->hasPropertyByName( _rPropertyName
) )
613 m_pModelChangeBroadcaster
->addProperty( _rPropertyName
);
615 catch( const Exception
& )
617 OSL_FAIL( "DbCellControl::doPropertyListening: caught an exception!" );
618 DBG_UNHANDLED_EXCEPTION();
623 void DbCellControl::doPropertyListening(const OUString
& _rPropertyName
)
625 implDoPropertyListening( _rPropertyName
);
628 static void lcl_clearBroadCaster(::comphelper::OPropertyChangeMultiplexer
*& _pBroadcaster
)
632 _pBroadcaster
->dispose();
633 _pBroadcaster
->release();
634 _pBroadcaster
= NULL
;
635 // no delete, this is done implicitly
639 DbCellControl::~DbCellControl()
641 lcl_clearBroadCaster(m_pModelChangeBroadcaster
);
642 lcl_clearBroadCaster(m_pFieldChangeBroadcaster
);
649 void DbCellControl::implValuePropertyChanged( )
651 OSL_ENSURE( !isValuePropertyLocked(),
652 "DbCellControl::implValuePropertyChanged: not to be called with the value property locked!" );
656 if ( m_rColumn
.getModel().is() )
657 updateFromModel( m_rColumn
.getModel() );
662 void DbCellControl::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& /*_rxModel*/ )
664 // nothing to to here
668 void DbCellControl::_propertyChanged(const PropertyChangeEvent
& _rEvent
) throw(RuntimeException
)
670 SolarMutexGuard aGuard
;
672 Reference
< XPropertySet
> xSourceProps( _rEvent
.Source
, UNO_QUERY
);
674 if ( _rEvent
.PropertyName
.equals( FM_PROP_VALUE
)
675 || _rEvent
.PropertyName
.equals( FM_PROP_STATE
)
676 || _rEvent
.PropertyName
.equals( FM_PROP_TEXT
)
677 || _rEvent
.PropertyName
.equals( FM_PROP_EFFECTIVE_VALUE
)
679 { // it was one of the known "value" properties
680 if ( !isValuePropertyLocked() )
682 implValuePropertyChanged( );
685 else if ( _rEvent
.PropertyName
.equals( FM_PROP_READONLY
) )
687 implAdjustReadOnly( xSourceProps
, true);
689 else if ( _rEvent
.PropertyName
.equals( FM_PROP_ISREADONLY
) )
691 bool bReadOnly
= true;
692 _rEvent
.NewValue
>>= bReadOnly
;
693 m_rColumn
.SetReadOnly(bReadOnly
);
694 implAdjustReadOnly( xSourceProps
, false);
696 else if ( _rEvent
.PropertyName
.equals( FM_PROP_ENABLED
) )
698 implAdjustEnabled( xSourceProps
);
701 implAdjustGenericFieldSetting( xSourceProps
);
705 bool DbCellControl::Commit()
707 // lock the listening for value property changes
709 // commit the content of the control into the model's value property
710 bool bReturn
= false;
713 bReturn
= commitControl();
715 catch( const Exception
& )
717 DBG_UNHANDLED_EXCEPTION();
719 // unlock the listening for value property changes
720 unlockValueProperty();
726 void DbCellControl::ImplInitWindow( Window
& rParent
, const InitWindowFacet _eInitWhat
)
728 Window
* pWindows
[] = { m_pPainter
, m_pWindow
};
730 if ( ( _eInitWhat
& InitWritingMode
) != 0 )
732 for ( size_t i
=0; i
< sizeof( pWindows
) / sizeof( pWindows
[0] ); ++i
)
735 pWindows
[i
]->EnableRTL( rParent
.IsRTLEnabled() );
739 if ( ( _eInitWhat
& InitFontFacet
) != 0 )
741 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
746 pWindows
[i
]->SetZoom( rParent
.GetZoom() );
748 const StyleSettings
& rStyleSettings
= pWindows
[i
]->GetSettings().GetStyleSettings();
749 Font aFont
= rStyleSettings
.GetFieldFont();
750 aFont
.SetTransparent( isTransparent() );
752 if ( rParent
.IsControlFont() )
754 pWindows
[i
]->SetControlFont( rParent
.GetControlFont() );
755 aFont
.Merge( rParent
.GetControlFont() );
758 pWindows
[i
]->SetControlFont();
760 pWindows
[i
]->SetZoomedPointFont( aFont
);
764 if ( ( ( _eInitWhat
& InitFontFacet
) != 0 )
765 || ( ( _eInitWhat
& InitForeground
) != 0 )
768 Color
aTextColor( rParent
.IsControlForeground() ? rParent
.GetControlForeground() : rParent
.GetTextColor() );
770 bool bTextLineColor
= rParent
.IsTextLineColor();
771 Color
aTextLineColor( rParent
.GetTextLineColor() );
773 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
777 pWindows
[i
]->SetTextColor(aTextColor
);
778 if (rParent
.IsControlForeground())
779 pWindows
[i
]->SetControlForeground(aTextColor
);
782 pWindows
[i
]->SetTextLineColor();
784 pWindows
[i
]->SetTextLineColor(aTextLineColor
);
789 if ( ( _eInitWhat
& InitBackground
) != 0 )
791 if (rParent
.IsControlBackground())
793 Color
aColor( rParent
.GetControlBackground());
794 for (size_t i
=0; i
< sizeof(pWindows
)/sizeof(pWindows
[0]); ++i
)
798 if ( isTransparent() )
799 pWindows
[i
]->SetBackground();
802 pWindows
[i
]->SetBackground(aColor
);
803 pWindows
[i
]->SetControlBackground(aColor
);
805 pWindows
[i
]->SetFillColor(aColor
);
813 if ( isTransparent() )
814 m_pPainter
->SetBackground();
816 m_pPainter
->SetBackground(rParent
.GetBackground());
817 m_pPainter
->SetFillColor(rParent
.GetFillColor());
822 if ( isTransparent() )
823 m_pWindow
->SetBackground(rParent
.GetBackground());
825 m_pWindow
->SetFillColor(rParent
.GetFillColor());
832 void DbCellControl::implAdjustReadOnly( const Reference
< XPropertySet
>& _rxModel
,bool i_bReadOnly
)
834 DBG_ASSERT( m_pWindow
, "DbCellControl::implAdjustReadOnly: not to be called without window!" );
835 DBG_ASSERT( _rxModel
.is(), "DbCellControl::implAdjustReadOnly: invalid model!" );
836 if ( m_pWindow
&& _rxModel
.is() )
838 Edit
* pEditWindow
= dynamic_cast< Edit
* >( m_pWindow
);
841 bool bReadOnly
= m_rColumn
.IsReadOnly();
844 _rxModel
->getPropertyValue( i_bReadOnly
? OUString(FM_PROP_READONLY
) : OUString(FM_PROP_ISREADONLY
)) >>= bReadOnly
;
846 static_cast< Edit
* >( m_pWindow
)->SetReadOnly( bReadOnly
);
852 void DbCellControl::implAdjustEnabled( const Reference
< XPropertySet
>& _rxModel
)
854 DBG_ASSERT( m_pWindow
, "DbCellControl::implAdjustEnabled: not to be called without window!" );
855 DBG_ASSERT( _rxModel
.is(), "DbCellControl::implAdjustEnabled: invalid model!" );
856 if ( m_pWindow
&& _rxModel
.is() )
859 _rxModel
->getPropertyValue( FM_PROP_ENABLED
) >>= bEnable
;
860 m_pWindow
->Enable( bEnable
);
865 void DbCellControl::Init( Window
& rParent
, const Reference
< XRowSet
>& _rxCursor
)
867 ImplInitWindow( rParent
, InitAll
);
872 if ( isAlignedController() )
873 AlignControl( m_rColumn
.GetAlignment() );
877 // some other common properties
878 Reference
< XPropertySet
> xModel( m_rColumn
.getModel(), UNO_SET_THROW
);
879 Reference
< XPropertySetInfo
> xModelPSI( xModel
->getPropertySetInfo(), UNO_SET_THROW
);
881 if ( xModelPSI
->hasPropertyByName( FM_PROP_READONLY
) )
883 implAdjustReadOnly( xModel
,true );
886 if ( xModelPSI
->hasPropertyByName( FM_PROP_ENABLED
) )
888 implAdjustEnabled( xModel
);
891 if ( xModelPSI
->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR
) )
893 sal_Int16 nWheelBehavior
= MouseWheelBehavior::SCROLL_FOCUS_ONLY
;
894 OSL_VERIFY( xModel
->getPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR
) >>= nWheelBehavior
);
895 sal_uInt16 nVclSetting
= MOUSE_WHEEL_FOCUS_ONLY
;
896 switch ( nWheelBehavior
)
898 case MouseWheelBehavior::SCROLL_DISABLED
: nVclSetting
= MOUSE_WHEEL_DISABLE
; break;
899 case MouseWheelBehavior::SCROLL_FOCUS_ONLY
: nVclSetting
= MOUSE_WHEEL_FOCUS_ONLY
; break;
900 case MouseWheelBehavior::SCROLL_ALWAYS
: nVclSetting
= MOUSE_WHEEL_ALWAYS
; break;
902 OSL_FAIL( "DbCellControl::Init: invalid MouseWheelBehavior!" );
906 AllSettings aSettings
= m_pWindow
->GetSettings();
907 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
908 aMouseSettings
.SetWheelBehavior( nVclSetting
);
909 aSettings
.SetMouseSettings( aMouseSettings
);
910 m_pWindow
->SetSettings( aSettings
, true );
913 catch( const Exception
& )
915 DBG_UNHANDLED_EXCEPTION();
918 m_xCursor
= _rxCursor
;
922 void DbCellControl::SetTextLineColor()
925 m_pWindow
->SetTextLineColor();
927 m_pPainter
->SetTextLineColor();
931 void DbCellControl::SetTextLineColor(const Color
& _rColor
)
934 m_pWindow
->SetTextLineColor(_rColor
);
936 m_pPainter
->SetTextLineColor(_rColor
);
941 static void lcl_implAlign( Window
* _pWindow
, WinBits _nAlignmentBit
)
943 WinBits nStyle
= _pWindow
->GetStyle();
944 nStyle
&= ~(WB_LEFT
| WB_RIGHT
| WB_CENTER
);
945 _pWindow
->SetStyle( nStyle
| _nAlignmentBit
);
950 void DbCellControl::AlignControl(sal_Int16 nAlignment
)
952 WinBits nAlignmentBit
= 0;
955 case ::com::sun::star::awt::TextAlign::RIGHT
:
956 nAlignmentBit
= WB_RIGHT
;
958 case ::com::sun::star::awt::TextAlign::CENTER
:
959 nAlignmentBit
= WB_CENTER
;
962 nAlignmentBit
= WB_LEFT
;
965 lcl_implAlign( m_pWindow
, nAlignmentBit
);
967 lcl_implAlign( m_pPainter
, nAlignmentBit
);
971 void DbCellControl::PaintCell( OutputDevice
& _rDev
, const Rectangle
& _rRect
)
973 if ( m_pPainter
->GetParent() == &_rDev
)
975 m_pPainter
->SetPaintTransparent( true );
976 m_pPainter
->SetBackground( );
977 m_pPainter
->SetControlBackground( _rDev
.GetFillColor() );
978 m_pPainter
->SetControlForeground( _rDev
.GetTextColor() );
979 m_pPainter
->SetTextColor( _rDev
.GetTextColor() );
980 m_pPainter
->SetTextFillColor( _rDev
.GetTextColor() );
982 Font
aFont( _rDev
.GetFont() );
983 aFont
.SetTransparent( true );
984 m_pPainter
->SetFont( aFont
);
986 m_pPainter
->SetPosSizePixel( _rRect
.TopLeft(), _rRect
.GetSize() );
988 m_pPainter
->Update();
989 m_pPainter
->SetParentUpdateMode( false );
991 m_pPainter
->SetParentUpdateMode( true );
994 m_pPainter
->Draw( &_rDev
, _rRect
.TopLeft(), _rRect
.GetSize(), 0 );
998 void DbCellControl::PaintFieldToCell( OutputDevice
& _rDev
, const Rectangle
& _rRect
, const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& _rxFormatter
)
1000 m_pPainter
->SetText( GetFormatText( _rxField
, _rxFormatter
) );
1001 PaintCell( _rDev
, _rRect
);
1005 double DbCellControl::GetValue(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
) const
1008 if (m_rColumn
.IsNumeric())
1012 fValue
= _rxField
->getDouble();
1014 catch(const Exception
&) { }
1018 bool bSuccess
= false;
1021 fValue
= _rxField
->getDouble();
1024 catch(const Exception
&) { }
1029 fValue
= xFormatter
->convertStringToNumber(m_rColumn
.GetKey(), _rxField
->getString());
1031 catch(const Exception
&) { }
1038 void DbCellControl::invalidatedController()
1040 m_rColumn
.GetParent().refreshController(m_rColumn
.GetId(), DbGridControl::GrantControlAccess());
1043 /*************************************************************************/
1045 /*************************************************************************/
1048 //= DbLimitedLengthField
1051 DbLimitedLengthField::DbLimitedLengthField( DbGridColumn
& _rColumn
)
1052 :DbCellControl( _rColumn
)
1054 doPropertyListening( FM_PROP_MAXTEXTLEN
);
1058 void DbLimitedLengthField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
1060 DBG_ASSERT( m_pWindow
, "DbLimitedLengthField::implAdjustGenericFieldSetting: not to be called without window!" );
1061 DBG_ASSERT( _rxModel
.is(), "DbLimitedLengthField::implAdjustGenericFieldSetting: invalid model!" );
1062 if ( m_pWindow
&& _rxModel
.is() )
1064 sal_Int16 nMaxLen
= 0;
1065 _rxModel
->getPropertyValue( FM_PROP_MAXTEXTLEN
) >>= nMaxLen
;
1066 implSetMaxTextLen( nMaxLen
);
1071 void DbLimitedLengthField::implSetEffectiveMaxTextLen( sal_Int32 _nMaxLen
)
1073 dynamic_cast< Edit
* >( m_pWindow
)->SetMaxTextLen( _nMaxLen
);
1075 dynamic_cast< Edit
* >( m_pPainter
)->SetMaxTextLen( _nMaxLen
);
1082 DbTextField::DbTextField(DbGridColumn
& _rColumn
)
1083 :DbLimitedLengthField(_rColumn
)
1085 ,m_pPainterImplementation( NULL
)
1086 ,m_nKeyType(::com::sun::star::util::NumberFormat::TEXT
)
1087 ,m_bIsSimpleEdit( true )
1092 DbTextField::~DbTextField( )
1094 DELETEZ( m_pPainterImplementation
);
1099 void DbTextField::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
1101 sal_Int16 nAlignment
= m_rColumn
.SetAlignmentFromModel(-1);
1103 Reference
< XPropertySet
> xModel( m_rColumn
.getModel() );
1105 WinBits nStyle
= WB_LEFT
;
1108 case awt::TextAlign::RIGHT
:
1112 case awt::TextAlign::CENTER
:
1117 // is this a multi-line field?
1118 bool bIsMultiLine
= false;
1123 OSL_VERIFY( xModel
->getPropertyValue( FM_PROP_MULTILINE
) >>= bIsMultiLine
);
1126 catch( const Exception
& )
1128 OSL_FAIL( "DbTextField::Init: caught an exception while determining the multi-line capabilities!" );
1129 DBG_UNHANDLED_EXCEPTION();
1132 m_bIsSimpleEdit
= !bIsMultiLine
;
1135 m_pWindow
= new MultiLineTextCell( &rParent
, nStyle
);
1136 m_pEdit
= new MultiLineEditImplementation( *static_cast< MultiLineTextCell
* >( m_pWindow
) );
1138 m_pPainter
= new MultiLineTextCell( &rParent
, nStyle
);
1139 m_pPainterImplementation
= new MultiLineEditImplementation( *static_cast< MultiLineTextCell
* >( m_pPainter
) );
1143 m_pWindow
= new Edit( &rParent
, nStyle
);
1144 m_pEdit
= new EditImplementation( *static_cast< Edit
* >( m_pWindow
) );
1146 m_pPainter
= new Edit( &rParent
, nStyle
);
1147 m_pPainterImplementation
= new EditImplementation( *static_cast< Edit
* >( m_pPainter
) );
1150 if ( WB_LEFT
== nStyle
)
1152 // this is so that when getting the focus, the selection is oriented left-to-right
1153 AllSettings aSettings
= m_pWindow
->GetSettings();
1154 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1155 aStyleSettings
.SetSelectionOptions(
1156 aStyleSettings
.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST
);
1157 aSettings
.SetStyleSettings(aStyleSettings
);
1158 m_pWindow
->SetSettings(aSettings
);
1161 implAdjustGenericFieldSetting( xModel
);
1163 if (m_rColumn
.GetParent().getNumberFormatter().is() && m_rColumn
.GetKey())
1164 m_nKeyType
= comphelper::getNumberFormatType(m_rColumn
.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn
.GetKey());
1166 DbLimitedLengthField::Init( rParent
, xCursor
);
1170 CellControllerRef
DbTextField::CreateController() const
1172 return new EditCellController( m_pEdit
);
1176 void DbTextField::PaintFieldToCell( OutputDevice
& _rDev
, const Rectangle
& _rRect
, const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& _rxFormatter
)
1178 if ( m_pPainterImplementation
)
1179 m_pPainterImplementation
->SetText( GetFormatText( _rxField
, _rxFormatter
, NULL
) );
1181 DbLimitedLengthField::PaintFieldToCell( _rDev
, _rRect
, _rxField
, _rxFormatter
);
1185 OUString
DbTextField::GetFormatText(const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
, Color
** /*ppColor*/)
1188 if ( _rxField
.is() )
1191 aString
= getFormattedValue( _rxField
, xFormatter
, m_rColumn
.GetParent().getNullDate(), m_rColumn
.GetKey(), m_nKeyType
);
1193 catch( const Exception
& )
1195 DBG_UNHANDLED_EXCEPTION();
1202 void DbTextField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
)
1204 m_pEdit
->SetText( GetFormatText( _rxField
, xFormatter
) );
1205 m_pEdit
->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1209 void DbTextField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
1211 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbTextField::updateFromModel: invalid call!" );
1214 _rxModel
->getPropertyValue( FM_PROP_TEXT
) >>= sText
;
1216 sal_Int32 nMaxTextLen
= m_pEdit
->GetMaxTextLen();
1217 if ( EDIT_NOLIMIT
!= nMaxTextLen
&& sText
.getLength() > nMaxTextLen
)
1219 sal_Int32 nDiff
= sText
.getLength() - nMaxTextLen
;
1220 sText
= sText
.replaceAt(sText
.getLength() - nDiff
,nDiff
, OUString());
1224 m_pEdit
->SetText( sText
);
1225 m_pEdit
->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1229 bool DbTextField::commitControl()
1231 OUString
aText( m_pEdit
->GetText( getModelLineEndSetting( m_rColumn
.getModel() ) ) );
1232 // we have to check if the length before we can decide if the value was modified
1233 sal_Int32 nMaxTextLen
= m_pEdit
->GetMaxTextLen();
1234 if ( EDIT_NOLIMIT
!= nMaxTextLen
)
1237 m_rColumn
.getModel()->getPropertyValue( FM_PROP_TEXT
) >>= sOldValue
;
1238 // if the new value didn't change we must set the old long value again
1239 if ( sOldValue
.getLength() > nMaxTextLen
&& sOldValue
.compareTo(aText
,nMaxTextLen
) == 0 )
1242 m_rColumn
.getModel()->setPropertyValue( FM_PROP_TEXT
, makeAny( aText
) );
1247 void DbTextField::implSetEffectiveMaxTextLen( sal_Int32 _nMaxLen
)
1250 m_pEdit
->SetMaxTextLen( _nMaxLen
);
1251 if ( m_pPainterImplementation
)
1252 m_pPainterImplementation
->SetMaxTextLen( _nMaxLen
);
1256 //= DbFormattedField
1259 DbFormattedField::DbFormattedField(DbGridColumn
& _rColumn
)
1260 :DbLimitedLengthField(_rColumn
)
1261 ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED
)
1264 // if our model's format key changes we want to propagate the new value to our windows
1265 doPropertyListening( FM_PROP_FORMATKEY
);
1269 DbFormattedField::~DbFormattedField()
1274 void DbFormattedField::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
1276 sal_Int16 nAlignment
= m_rColumn
.SetAlignmentFromModel(-1);
1278 Reference
< ::com::sun::star::beans::XPropertySet
> xUnoModel
= m_rColumn
.getModel();
1282 case ::com::sun::star::awt::TextAlign::RIGHT
:
1283 m_pWindow
= new FormattedField( &rParent
, WB_RIGHT
);
1284 m_pPainter
= new FormattedField( &rParent
, WB_RIGHT
);
1287 case ::com::sun::star::awt::TextAlign::CENTER
:
1288 m_pWindow
= new FormattedField( &rParent
, WB_CENTER
);
1289 m_pPainter
= new FormattedField( &rParent
, WB_CENTER
);
1292 m_pWindow
= new FormattedField( &rParent
, WB_LEFT
);
1293 m_pPainter
= new FormattedField( &rParent
, WB_LEFT
);
1295 // Alles nur damit die Selektion bei Focuserhalt von rechts nach links geht
1296 AllSettings aSettings
= m_pWindow
->GetSettings();
1297 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1298 aStyleSettings
.SetSelectionOptions(
1299 aStyleSettings
.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST
);
1300 aSettings
.SetStyleSettings(aStyleSettings
);
1301 m_pWindow
->SetSettings(aSettings
);
1304 implAdjustGenericFieldSetting( xUnoModel
);
1306 static_cast< FormattedField
* >( m_pWindow
)->SetStrictFormat( false );
1307 static_cast< FormattedField
* >( m_pPainter
)->SetStrictFormat( false );
1308 // wenn man _irgendeine_ Formatierung zulaesst, kann man da sowieso keine Eingabe-Ueberpruefung
1309 // machen (das FormattedField unterstuetzt das sowieso nicht, nur abgeleitete Klassen)
1311 // von dem Uno-Model den Formatter besorgen
1312 // (Ich koennte theoretisch auch ueber den ::com::sun::star::util::NumberFormatter gehen, den mir der Cursor bestimmt
1313 // liefern wuerde. Das Problem dabei ist, dass ich mich eigentlich nicht darauf verlassen
1314 // kann, dass die beiden Formatter die selben sind, sauber ist das Ganze, wenn ich ueber das
1316 sal_Int32 nFormatKey
= -1;
1318 // mal sehen, ob das Model einen hat ...
1319 DBG_ASSERT(::comphelper::hasProperty(FM_PROP_FORMATSSUPPLIER
, xUnoModel
), "DbFormattedField::Init : invalid UNO model !");
1320 Any
aSupplier( xUnoModel
->getPropertyValue(FM_PROP_FORMATSSUPPLIER
));
1321 if (aSupplier
.hasValue())
1323 m_xSupplier
.set(aSupplier
, css::uno::UNO_QUERY
);
1324 if (m_xSupplier
.is())
1326 // wenn wir den Supplier vom Model nehmen, dann auch den Key
1327 Any
aFmtKey( xUnoModel
->getPropertyValue(FM_PROP_FORMATKEY
));
1328 if (aFmtKey
.hasValue())
1330 DBG_ASSERT(aFmtKey
.getValueType().getTypeClass() == TypeClass_LONG
, "DbFormattedField::Init : invalid format key property (no sal_Int32) !");
1331 nFormatKey
= ::comphelper::getINT32(aFmtKey
);
1335 DBG_WARNING("DbFormattedField::Init : my uno-model has no format-key, but a formats supplier !");
1336 // the OFormattedModel which we usually are working with ensures that the model has a format key
1337 // as soon as the form is loaded. Unfortunally this method here is called from within loaded, too.
1338 // So if our LoadListener is called before the LoadListener of the model, this "else case" is
1340 // Of course our property listener for the FormatKey property will notify us if the prop is changed,
1341 // so this here isn't really bad ....
1347 // nein ? vielleicht die ::com::sun::star::form::component::Form hinter dem Cursor ?
1348 if (!m_xSupplier
.is())
1350 Reference
< XRowSet
> xCursorForm(xCursor
, UNO_QUERY
);
1351 if (xCursorForm
.is())
1352 { // wenn wir vom Cursor den Formatter nehmen, dann auch den Key vom Feld, an das wir gebunden sind
1353 m_xSupplier
= getNumberFormats(getRowSetConnection(xCursorForm
), false);
1355 if (m_rColumn
.GetField().is())
1356 nFormatKey
= ::comphelper::getINT32(m_rColumn
.GetField()->getPropertyValue(FM_PROP_FORMATKEY
));
1360 SvNumberFormatter
* pFormatterUsed
= NULL
;
1361 if (m_xSupplier
.is())
1363 SvNumberFormatsSupplierObj
* pImplmentation
= SvNumberFormatsSupplierObj::getImplementation(m_xSupplier
);
1365 pFormatterUsed
= pImplmentation
->GetNumberFormatter();
1367 // alles hingfaellig : der Supplier ist vom falschen Typ, dann koennen wir uns auch nicht darauf verlassen, dass
1368 // ein Standard-Formatter den (eventuell nicht-Standard-)Key kennt.
1372 // einen Standard-Formatter ...
1373 if (pFormatterUsed
== NULL
)
1375 pFormatterUsed
= ((FormattedField
*)m_pWindow
)->StandardFormatter();
1376 DBG_ASSERT(pFormatterUsed
!= NULL
, "DbFormattedField::Init : no standard formatter given by the numeric field !");
1378 // ... und einen Standard-Key
1379 if (nFormatKey
== -1)
1382 m_nKeyType
= comphelper::getNumberFormatType(m_xSupplier
->getNumberFormats(), nFormatKey
);
1384 ((FormattedField
*)m_pWindow
)->SetFormatter(pFormatterUsed
);
1385 ((FormattedField
*)m_pPainter
)->SetFormatter(pFormatterUsed
);
1387 ((FormattedField
*)m_pWindow
)->SetFormatKey(nFormatKey
);
1388 ((FormattedField
*)m_pPainter
)->SetFormatKey(nFormatKey
);
1390 ((FormattedField
*)m_pWindow
)->TreatAsNumber(m_rColumn
.IsNumeric());
1391 ((FormattedField
*)m_pPainter
)->TreatAsNumber(m_rColumn
.IsNumeric());
1393 // Min- und Max-Werte
1394 if (m_rColumn
.IsNumeric())
1396 bool bClearMin
= true;
1397 if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MIN
, xUnoModel
))
1399 Any
aMin( xUnoModel
->getPropertyValue(FM_PROP_EFFECTIVE_MIN
));
1400 if (aMin
.getValueType().getTypeClass() != TypeClass_VOID
)
1402 DBG_ASSERT(aMin
.getValueType().getTypeClass() == TypeClass_DOUBLE
, "DbFormattedField::Init : the model has an invalid min value !");
1403 double dMin
= ::comphelper::getDouble(aMin
);
1404 ((FormattedField
*)m_pWindow
)->SetMinValue(dMin
);
1405 ((FormattedField
*)m_pPainter
)->SetMinValue(dMin
);
1411 ((FormattedField
*)m_pWindow
)->ClearMinValue();
1412 ((FormattedField
*)m_pPainter
)->ClearMinValue();
1414 bool bClearMax
= true;
1415 if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MAX
, xUnoModel
))
1417 Any
aMin( xUnoModel
->getPropertyValue(FM_PROP_EFFECTIVE_MAX
));
1418 if (aMin
.getValueType().getTypeClass() != TypeClass_VOID
)
1420 DBG_ASSERT(aMin
.getValueType().getTypeClass() == TypeClass_DOUBLE
, "DbFormattedField::Init : the model has an invalid max value !");
1421 double dMin
= ::comphelper::getDouble(aMin
);
1422 ((FormattedField
*)m_pWindow
)->SetMaxValue(dMin
);
1423 ((FormattedField
*)m_pPainter
)->SetMaxValue(dMin
);
1429 ((FormattedField
*)m_pWindow
)->ClearMaxValue();
1430 ((FormattedField
*)m_pPainter
)->ClearMaxValue();
1435 Any
aDefault( xUnoModel
->getPropertyValue(FM_PROP_EFFECTIVE_DEFAULT
));
1436 if (aDefault
.hasValue())
1437 { // das Ding kann ein double oder ein String sein
1438 switch (aDefault
.getValueType().getTypeClass())
1440 case TypeClass_DOUBLE
:
1441 if (m_rColumn
.IsNumeric())
1443 ((FormattedField
*)m_pWindow
)->SetDefaultValue(::comphelper::getDouble(aDefault
));
1444 ((FormattedField
*)m_pPainter
)->SetDefaultValue(::comphelper::getDouble(aDefault
));
1448 OUString sConverted
;
1450 pFormatterUsed
->GetOutputString(::comphelper::getDouble(aDefault
), 0, sConverted
, &pDummy
);
1451 ((FormattedField
*)m_pWindow
)->SetDefaultText(sConverted
);
1452 ((FormattedField
*)m_pPainter
)->SetDefaultText(sConverted
);
1455 case TypeClass_STRING
:
1457 OUString
sDefault( ::comphelper::getString(aDefault
) );
1458 if (m_rColumn
.IsNumeric())
1461 sal_uInt32
nTestFormat(0);
1462 if (pFormatterUsed
->IsNumberFormat(sDefault
, nTestFormat
, dVal
))
1464 ((FormattedField
*)m_pWindow
)->SetDefaultValue(dVal
);
1465 ((FormattedField
*)m_pPainter
)->SetDefaultValue(dVal
);
1470 ((FormattedField
*)m_pWindow
)->SetDefaultText(sDefault
);
1471 ((FormattedField
*)m_pPainter
)->SetDefaultText(sDefault
);
1476 OSL_FAIL( "DbFormattedField::Init: unexpected value type!" );
1480 DbLimitedLengthField::Init( rParent
, xCursor
);
1484 CellControllerRef
DbFormattedField::CreateController() const
1486 return new ::svt::FormattedFieldCellController( static_cast< FormattedField
* >( m_pWindow
) );
1490 void DbFormattedField::_propertyChanged( const PropertyChangeEvent
& _rEvent
) throw( RuntimeException
)
1492 if (_rEvent
.PropertyName
== FM_PROP_FORMATKEY
)
1494 sal_Int32 nNewKey
= _rEvent
.NewValue
.hasValue() ? ::comphelper::getINT32(_rEvent
.NewValue
) : 0;
1495 m_nKeyType
= comphelper::getNumberFormatType(m_xSupplier
->getNumberFormats(), nNewKey
);
1497 DBG_ASSERT(m_pWindow
&& m_pPainter
, "DbFormattedField::_propertyChanged : where are my windows ?");
1499 static_cast< FormattedField
* >( m_pWindow
)->SetFormatKey( nNewKey
);
1501 static_cast< FormattedField
* >( m_pPainter
)->SetFormatKey( nNewKey
);
1505 DbLimitedLengthField::_propertyChanged( _rEvent
);
1510 OUString
DbFormattedField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/, Color
** ppColor
)
1512 // defaultmaessig keine Farb-Angabe
1513 if (ppColor
!= NULL
)
1516 // NULL-Wert -> leerer Text
1523 if (m_rColumn
.IsNumeric())
1525 // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
1526 // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
1527 // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
1528 // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
1529 // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
1530 double dValue
= getValue( _rxField
, m_rColumn
.GetParent().getNullDate() );
1531 if (_rxField
->wasNull())
1533 ((FormattedField
*)m_pPainter
)->SetValue(dValue
);
1537 // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
1538 // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
1539 aText
= _rxField
->getString();
1540 if (_rxField
->wasNull())
1542 ((FormattedField
*)m_pPainter
)->SetTextFormatted(aText
);
1545 catch( const Exception
& )
1547 DBG_UNHANDLED_EXCEPTION();
1550 aText
= m_pPainter
->GetText();
1551 if (ppColor
!= NULL
)
1552 *ppColor
= ((FormattedField
*)m_pPainter
)->GetLastOutputColor();
1558 void DbFormattedField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/)
1562 FormattedField
* pFormattedWindow
= static_cast<FormattedField
*>(m_pWindow
);
1564 { // NULL-Wert -> leerer Text
1565 m_pWindow
->SetText(OUString());
1567 else if (m_rColumn
.IsNumeric())
1569 // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
1570 // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
1571 // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
1572 // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
1573 // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
1574 double dValue
= getValue( _rxField
, m_rColumn
.GetParent().getNullDate() );
1575 if (_rxField
->wasNull())
1576 m_pWindow
->SetText(OUString());
1578 pFormattedWindow
->SetValue(dValue
);
1582 // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
1583 // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
1584 OUString
sText( _rxField
->getString());
1586 pFormattedWindow
->SetTextFormatted( sText
);
1587 pFormattedWindow
->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1590 catch( const Exception
& )
1592 DBG_UNHANDLED_EXCEPTION();
1597 void DbFormattedField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
1599 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbFormattedField::updateFromModel: invalid call!" );
1601 FormattedField
* pFormattedWindow
= static_cast< FormattedField
* >( m_pWindow
);
1604 Any aValue
= _rxModel
->getPropertyValue( FM_PROP_EFFECTIVE_VALUE
);
1605 if ( aValue
>>= sText
)
1606 { // our effective value is transferred as string
1607 pFormattedWindow
->SetTextFormatted( sText
);
1608 pFormattedWindow
->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1614 pFormattedWindow
->SetValue(dValue
);
1619 bool DbFormattedField::commitControl()
1622 FormattedField
& rField
= *(FormattedField
*)m_pWindow
;
1623 DBG_ASSERT(&rField
== m_pWindow
, "DbFormattedField::commitControl : can't work with a window other than my own !");
1624 if (m_rColumn
.IsNumeric())
1626 if (!rField
.GetText().isEmpty())
1627 aNewVal
<<= rField
.GetValue();
1628 // ein LeerString wird erst mal standardmaessig als void weitergereicht
1631 aNewVal
<<= OUString(rField
.GetTextValue());
1633 m_rColumn
.getModel()->setPropertyValue(FM_PROP_EFFECTIVE_VALUE
, aNewVal
);
1641 DbCheckBox::DbCheckBox( DbGridColumn
& _rColumn
)
1642 :DbCellControl( _rColumn
, true )
1644 setAlignedController( false );
1649 void setCheckBoxStyle( Window
* _pWindow
, bool bMono
)
1651 AllSettings aSettings
= _pWindow
->GetSettings();
1652 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1654 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() | STYLE_OPTION_MONO
);
1656 aStyleSettings
.SetOptions( aStyleSettings
.GetOptions() & (~STYLE_OPTION_MONO
) );
1657 aSettings
.SetStyleSettings( aStyleSettings
);
1658 _pWindow
->SetSettings( aSettings
);
1663 void DbCheckBox::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
1665 setTransparent( true );
1667 m_pWindow
= new CheckBoxControl( &rParent
);
1668 m_pPainter
= new CheckBoxControl( &rParent
);
1670 m_pWindow
->SetPaintTransparent( true );
1671 m_pPainter
->SetPaintTransparent( true );
1673 m_pPainter
->SetBackground();
1677 Reference
< XPropertySet
> xModel( m_rColumn
.getModel(), UNO_SET_THROW
);
1679 sal_Int16 nStyle
= awt::VisualEffect::LOOK3D
;
1680 OSL_VERIFY( xModel
->getPropertyValue( FM_PROP_VISUALEFFECT
) >>= nStyle
);
1682 setCheckBoxStyle( m_pWindow
, nStyle
== awt::VisualEffect::FLAT
);
1683 setCheckBoxStyle( m_pPainter
, nStyle
== awt::VisualEffect::FLAT
);
1685 bool bTristate
= true;
1686 OSL_VERIFY( xModel
->getPropertyValue( FM_PROP_TRISTATE
) >>= bTristate
);
1687 static_cast< CheckBoxControl
* >( m_pWindow
)->GetBox().EnableTriState( bTristate
);
1688 static_cast< CheckBoxControl
* >( m_pPainter
)->GetBox().EnableTriState( bTristate
);
1690 catch( const Exception
& )
1692 DBG_UNHANDLED_EXCEPTION();
1695 DbCellControl::Init( rParent
, xCursor
);
1699 CellControllerRef
DbCheckBox::CreateController() const
1701 return new CheckBoxCellController((CheckBoxControl
*)m_pWindow
);
1704 static void lcl_setCheckBoxState( const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
,
1705 CheckBoxControl
* _pCheckBoxControl
)
1707 TriState eState
= TRISTATE_INDET
;
1712 bool bValue
= _rxField
->getBoolean();
1713 if (!_rxField
->wasNull())
1714 eState
= bValue
? TRISTATE_TRUE
: TRISTATE_FALSE
;
1716 catch( const Exception
& )
1718 DBG_UNHANDLED_EXCEPTION();
1721 _pCheckBoxControl
->GetBox().SetState(eState
);
1725 void DbCheckBox::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/)
1727 lcl_setCheckBoxState( _rxField
, static_cast<CheckBoxControl
*>(m_pWindow
) );
1731 void DbCheckBox::PaintFieldToCell(OutputDevice
& rDev
, const Rectangle
& rRect
,
1732 const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
,
1733 const Reference
< XNumberFormatter
>& xFormatter
)
1735 lcl_setCheckBoxState( _rxField
, static_cast<CheckBoxControl
*>(m_pPainter
) );
1736 DbCellControl::PaintFieldToCell( rDev
, rRect
, _rxField
, xFormatter
);
1740 void DbCheckBox::updateFromModel( Reference
< XPropertySet
> _rxModel
)
1742 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbCheckBox::updateFromModel: invalid call!" );
1744 sal_Int16 nState
= TRISTATE_INDET
;
1745 _rxModel
->getPropertyValue( FM_PROP_STATE
) >>= nState
;
1746 static_cast< CheckBoxControl
* >( m_pWindow
)->GetBox().SetState( static_cast< TriState
>( nState
) );
1750 bool DbCheckBox::commitControl()
1752 m_rColumn
.getModel()->setPropertyValue( FM_PROP_STATE
,
1753 makeAny( (sal_Int16
)( static_cast< CheckBoxControl
* >( m_pWindow
)->GetBox().GetState() ) ) );
1758 OUString
DbCheckBox::GetFormatText(const Reference
< XColumn
>& /*_rxField*/, const Reference
< XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
1766 DbPatternField::DbPatternField( DbGridColumn
& _rColumn
, const Reference
<XComponentContext
>& _rContext
)
1767 :DbCellControl( _rColumn
)
1768 ,m_xContext( _rContext
)
1770 doPropertyListening( FM_PROP_LITERALMASK
);
1771 doPropertyListening( FM_PROP_EDITMASK
);
1772 doPropertyListening( FM_PROP_STRICTFORMAT
);
1776 void DbPatternField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
1778 DBG_ASSERT( m_pWindow
, "DbPatternField::implAdjustGenericFieldSetting: not to be called without window!" );
1779 DBG_ASSERT( _rxModel
.is(), "DbPatternField::implAdjustGenericFieldSetting: invalid model!" );
1780 if ( m_pWindow
&& _rxModel
.is() )
1784 bool bStrict
= false;
1786 _rxModel
->getPropertyValue( FM_PROP_LITERALMASK
) >>= aLitMask
;
1787 _rxModel
->getPropertyValue( FM_PROP_EDITMASK
) >>= aEditMask
;
1788 _rxModel
->getPropertyValue( FM_PROP_STRICTFORMAT
) >>= bStrict
;
1790 OString
aAsciiEditMask(OUStringToOString(aEditMask
, RTL_TEXTENCODING_ASCII_US
));
1792 static_cast< PatternField
* >( m_pWindow
)->SetMask( aAsciiEditMask
, aLitMask
);
1793 static_cast< PatternField
* >( m_pPainter
)->SetMask( aAsciiEditMask
, aLitMask
);
1794 static_cast< PatternField
* >( m_pWindow
)->SetStrictFormat( bStrict
);
1795 static_cast< PatternField
* >( m_pPainter
)->SetStrictFormat( bStrict
);
1800 void DbPatternField::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
1802 m_rColumn
.SetAlignmentFromModel(-1);
1804 m_pWindow
= new PatternField( &rParent
, 0 );
1805 m_pPainter
= new PatternField( &rParent
, 0 );
1807 Reference
< XPropertySet
> xModel( m_rColumn
.getModel() );
1808 implAdjustGenericFieldSetting( xModel
);
1810 DbCellControl::Init( rParent
, xCursor
);
1814 CellControllerRef
DbPatternField::CreateController() const
1816 return new SpinCellController( static_cast< PatternField
* >( m_pWindow
) );
1820 OUString
DbPatternField::impl_formatText( const OUString
& _rText
)
1822 m_pPainter
->SetText( _rText
);
1823 static_cast< PatternField
* >( m_pPainter
)->ReformatAll();
1824 return m_pPainter
->GetText();
1828 OUString
DbPatternField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
1830 bool bIsForPaint
= _rxField
!= m_rColumn
.GetField();
1831 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1832 ::std::auto_ptr
< ::dbtools::FormattedColumnValue
>& rpFormatter
= bIsForPaint
? m_pPaintFormatter
: m_pValueFormatter
;
1833 SAL_WNODEPRECATED_DECLARATIONS_POP
1835 if ( !rpFormatter
.get() )
1837 DBToolsObjectFactory aFactory
;
1838 rpFormatter
= aFactory
.createFormattedColumnValue(
1839 m_xContext
, getCursor(), Reference
< XPropertySet
>( _rxField
, UNO_QUERY
) );
1840 OSL_ENSURE( rpFormatter
.get(), "DbPatternField::Init: no value formatter!" );
1843 OSL_ENSURE( rpFormatter
->getColumn() == _rxField
, "DbPatternField::GetFormatText: my value formatter is working for another field ...!" );
1844 // re-creating the value formatter here every time would be quite expensive ...
1847 if ( rpFormatter
.get() )
1848 sText
= rpFormatter
->getFormattedValue();
1850 return impl_formatText( sText
);
1854 void DbPatternField::UpdateFromField( const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& _rxFormatter
)
1856 static_cast< Edit
* >( m_pWindow
)->SetText( GetFormatText( _rxField
, _rxFormatter
) );
1857 static_cast< Edit
* >( m_pWindow
)->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1861 void DbPatternField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
1863 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbPatternField::updateFromModel: invalid call!" );
1866 _rxModel
->getPropertyValue( FM_PROP_TEXT
) >>= sText
;
1868 static_cast< Edit
* >( m_pWindow
)->SetText( impl_formatText( sText
) );
1869 static_cast< Edit
* >( m_pWindow
)->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
1873 bool DbPatternField::commitControl()
1875 OUString
aText(m_pWindow
->GetText());
1876 m_rColumn
.getModel()->setPropertyValue(FM_PROP_TEXT
, makeAny(aText
));
1884 DbSpinField::DbSpinField( DbGridColumn
& _rColumn
, sal_Int16 _nStandardAlign
)
1885 :DbCellControl( _rColumn
)
1886 ,m_nStandardAlign( _nStandardAlign
)
1891 void DbSpinField::Init( Window
& _rParent
, const Reference
< XRowSet
>& _rxCursor
)
1893 m_rColumn
.SetAlignmentFromModel( m_nStandardAlign
);
1895 Reference
< XPropertySet
> xModel( m_rColumn
.getModel() );
1897 // determine the WinBits for the field
1898 WinBits nFieldStyle
= 0;
1899 if ( ::comphelper::getBOOL( xModel
->getPropertyValue( FM_PROP_SPIN
) ) )
1900 nFieldStyle
= WB_REPEAT
| WB_SPIN
;
1901 // create the fields
1902 m_pWindow
= createField( &_rParent
, nFieldStyle
, xModel
);
1903 m_pPainter
= createField( &_rParent
, nFieldStyle
, xModel
);
1905 // adjust all other settings which depend on the property values
1906 implAdjustGenericFieldSetting( xModel
);
1908 // call the base class
1909 DbCellControl::Init( _rParent
, _rxCursor
);
1913 CellControllerRef
DbSpinField::CreateController() const
1915 return new SpinCellController( static_cast< SpinField
* >( m_pWindow
) );
1922 DbNumericField::DbNumericField( DbGridColumn
& _rColumn
)
1923 :DbSpinField( _rColumn
)
1925 doPropertyListening( FM_PROP_DECIMAL_ACCURACY
);
1926 doPropertyListening( FM_PROP_VALUEMIN
);
1927 doPropertyListening( FM_PROP_VALUEMAX
);
1928 doPropertyListening( FM_PROP_VALUESTEP
);
1929 doPropertyListening( FM_PROP_STRICTFORMAT
);
1930 doPropertyListening( FM_PROP_SHOWTHOUSANDSEP
);
1934 void DbNumericField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
1936 DBG_ASSERT( m_pWindow
, "DbNumericField::implAdjustGenericFieldSetting: not to be called without window!" );
1937 DBG_ASSERT( _rxModel
.is(), "DbNumericField::implAdjustGenericFieldSetting: invalid model!" );
1938 if ( m_pWindow
&& _rxModel
.is() )
1940 sal_Int32 nMin
= (sal_Int32
)getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUEMIN
) );
1941 sal_Int32 nMax
= (sal_Int32
)getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUEMAX
) );
1942 sal_Int32 nStep
= (sal_Int32
)getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUESTEP
) );
1943 bool bStrict
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_STRICTFORMAT
) );
1944 sal_Int16 nScale
= getINT16( _rxModel
->getPropertyValue( FM_PROP_DECIMAL_ACCURACY
) );
1945 bool bThousand
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP
) );
1947 static_cast< DoubleNumericField
* >( m_pWindow
)->SetMinValue(nMin
);
1948 static_cast< DoubleNumericField
* >( m_pWindow
)->SetMaxValue(nMax
);
1949 static_cast< DoubleNumericField
* >( m_pWindow
)->SetSpinSize(nStep
);
1950 static_cast< DoubleNumericField
* >( m_pWindow
)->SetStrictFormat(bStrict
);
1952 static_cast< DoubleNumericField
* >( m_pPainter
)->SetMinValue(nMin
);
1953 static_cast< DoubleNumericField
* >( m_pPainter
)->SetMaxValue(nMax
);
1954 static_cast< DoubleNumericField
* >( m_pPainter
)->SetStrictFormat(bStrict
);
1957 // dem Field und dem Painter einen Formatter spendieren
1958 // zuerst testen, ob ich von dem Service hinter einer Connection bekommen kann
1959 Reference
< ::com::sun::star::util::XNumberFormatsSupplier
> xSupplier
;
1960 Reference
< XRowSet
> xForm
;
1961 if ( m_rColumn
.GetParent().getDataSource() )
1962 xForm
= Reference
< XRowSet
>( ( Reference
< XInterface
> )*m_rColumn
.GetParent().getDataSource(), UNO_QUERY
);
1964 xSupplier
= getNumberFormats( getRowSetConnection( xForm
), true );
1965 SvNumberFormatter
* pFormatterUsed
= NULL
;
1966 if ( xSupplier
.is() )
1968 SvNumberFormatsSupplierObj
* pImplmentation
= SvNumberFormatsSupplierObj::getImplementation( xSupplier
);
1969 pFormatterUsed
= pImplmentation
? pImplmentation
->GetNumberFormatter() : NULL
;
1971 if ( NULL
== pFormatterUsed
)
1972 { // der Cursor fuehrte nicht zum Erfolg -> Standard
1973 pFormatterUsed
= static_cast< DoubleNumericField
* >( m_pWindow
)->StandardFormatter();
1974 DBG_ASSERT( pFormatterUsed
!= NULL
, "DbNumericField::implAdjustGenericFieldSetting: no standard formatter given by the numeric field !" );
1976 static_cast< DoubleNumericField
* >( m_pWindow
)->SetFormatter( pFormatterUsed
);
1977 static_cast< DoubleNumericField
* >( m_pPainter
)->SetFormatter( pFormatterUsed
);
1979 // und dann ein Format generieren, dass die gewuenschten Nachkommastellen usw. hat
1980 LanguageType aAppLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
1981 OUString sFormatString
= pFormatterUsed
->GenerateFormat(0, aAppLanguage
, bThousand
, false, nScale
);
1983 static_cast< DoubleNumericField
* >( m_pWindow
)->SetFormat( sFormatString
, aAppLanguage
);
1984 static_cast< DoubleNumericField
* >( m_pPainter
)->SetFormat( sFormatString
, aAppLanguage
);
1989 SpinField
* DbNumericField::createField( Window
* _pParent
, WinBits _nFieldStyle
, const Reference
< XPropertySet
>& /*_rxModel*/ )
1991 return new DoubleNumericField( _pParent
, _nFieldStyle
);
1997 static OUString
lcl_setFormattedNumeric_nothrow( DoubleNumericField
& _rField
, const DbCellControl
& _rControl
,
1998 const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& _rxFormatter
)
2001 if ( _rxField
.is() )
2005 double fValue
= _rControl
.GetValue( _rxField
, _rxFormatter
);
2006 if ( !_rxField
->wasNull() )
2008 _rField
.SetValue( fValue
);
2009 sValue
= _rField
.GetText();
2012 catch( const Exception
& )
2014 DBG_UNHANDLED_EXCEPTION();
2022 OUString
DbNumericField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
, Color
** /*ppColor*/)
2024 return lcl_setFormattedNumeric_nothrow(dynamic_cast<DoubleNumericField
&>(*m_pPainter
), *this, _rxField
, _rxFormatter
);
2028 void DbNumericField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
)
2030 lcl_setFormattedNumeric_nothrow(dynamic_cast<DoubleNumericField
&>(*m_pWindow
), *this, _rxField
, _rxFormatter
);
2034 void DbNumericField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2036 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbNumericField::updateFromModel: invalid call!" );
2039 if ( _rxModel
->getPropertyValue( FM_PROP_VALUE
) >>= dValue
)
2040 static_cast< DoubleNumericField
* >( m_pWindow
)->SetValue( dValue
);
2042 m_pWindow
->SetText( OUString() );
2046 bool DbNumericField::commitControl()
2048 OUString
aText( m_pWindow
->GetText());
2051 if (!aText
.isEmpty()) // not empty
2053 double fValue
= ((DoubleNumericField
*)m_pWindow
)->GetValue();
2054 aVal
<<= (double)fValue
;
2056 m_rColumn
.getModel()->setPropertyValue(FM_PROP_VALUE
, aVal
);
2064 DbCurrencyField::DbCurrencyField(DbGridColumn
& _rColumn
)
2065 :DbSpinField( _rColumn
)
2068 doPropertyListening( FM_PROP_DECIMAL_ACCURACY
);
2069 doPropertyListening( FM_PROP_VALUEMIN
);
2070 doPropertyListening( FM_PROP_VALUEMAX
);
2071 doPropertyListening( FM_PROP_VALUESTEP
);
2072 doPropertyListening( FM_PROP_STRICTFORMAT
);
2073 doPropertyListening( FM_PROP_SHOWTHOUSANDSEP
);
2074 doPropertyListening( FM_PROP_CURRENCYSYMBOL
);
2078 void DbCurrencyField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
2080 DBG_ASSERT( m_pWindow
, "DbCurrencyField::implAdjustGenericFieldSetting: not to be called without window!" );
2081 DBG_ASSERT( _rxModel
.is(), "DbCurrencyField::implAdjustGenericFieldSetting: invalid model!" );
2082 if ( m_pWindow
&& _rxModel
.is() )
2084 m_nScale
= getINT16( _rxModel
->getPropertyValue( FM_PROP_DECIMAL_ACCURACY
) );
2085 double nMin
= getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUEMIN
) );
2086 double nMax
= getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUEMAX
) );
2087 double nStep
= getDouble( _rxModel
->getPropertyValue( FM_PROP_VALUESTEP
) );
2088 bool bStrict
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_STRICTFORMAT
) );
2089 bool bThousand
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP
) );
2090 OUString
aStr( getString( _rxModel
->getPropertyValue(FM_PROP_CURRENCYSYMBOL
) ) );
2092 static_cast< LongCurrencyField
* >( m_pWindow
)->SetUseThousandSep( bThousand
);
2093 static_cast< LongCurrencyField
* >( m_pWindow
)->SetDecimalDigits( m_nScale
);
2094 static_cast< LongCurrencyField
* >( m_pWindow
)->SetCurrencySymbol( aStr
);
2095 static_cast< LongCurrencyField
* >( m_pWindow
)->SetFirst( nMin
);
2096 static_cast< LongCurrencyField
* >( m_pWindow
)->SetLast( nMax
);
2097 static_cast< LongCurrencyField
* >( m_pWindow
)->SetMin( nMin
);
2098 static_cast< LongCurrencyField
* >( m_pWindow
)->SetMax( nMax
);
2099 static_cast< LongCurrencyField
* >( m_pWindow
)->SetSpinSize( nStep
);
2100 static_cast< LongCurrencyField
* >( m_pWindow
)->SetStrictFormat( bStrict
);
2102 static_cast< LongCurrencyField
* >( m_pPainter
)->SetUseThousandSep( bThousand
);
2103 static_cast< LongCurrencyField
* >( m_pPainter
)->SetDecimalDigits( m_nScale
);
2104 static_cast< LongCurrencyField
* >( m_pPainter
)->SetCurrencySymbol( aStr
);
2105 static_cast< LongCurrencyField
* >( m_pPainter
)->SetFirst( nMin
);
2106 static_cast< LongCurrencyField
* >( m_pPainter
)->SetLast( nMax
);
2107 static_cast< LongCurrencyField
* >( m_pPainter
)->SetMin( nMin
);
2108 static_cast< LongCurrencyField
* >( m_pPainter
)->SetMax( nMax
);
2109 static_cast< LongCurrencyField
* >( m_pPainter
)->SetStrictFormat( bStrict
);
2114 SpinField
* DbCurrencyField::createField( Window
* _pParent
, WinBits _nFieldStyle
, const Reference
< XPropertySet
>& /*_rxModel*/ )
2116 return new LongCurrencyField( _pParent
, _nFieldStyle
);
2120 double DbCurrencyField::GetCurrency(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
) const
2122 double fValue
= GetValue(_rxField
, xFormatter
);
2125 // OSL_TRACE("double = %.64f ",fValue);
2126 fValue
= ::rtl::math::pow10Exp(fValue
, m_nScale
);
2127 fValue
= ::rtl::math::round(fValue
, 0);
2135 static OUString
lcl_setFormattedCurrency_nothrow( LongCurrencyField
& _rField
, const DbCurrencyField
& _rControl
,
2136 const Reference
< XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& _rxFormatter
)
2139 if ( _rxField
.is() )
2143 double fValue
= _rControl
.GetCurrency( _rxField
, _rxFormatter
);
2144 if ( !_rxField
->wasNull() )
2146 _rField
.SetValue( fValue
);
2147 sValue
= _rField
.GetText();
2150 catch( const Exception
& )
2152 DBG_UNHANDLED_EXCEPTION();
2160 OUString
DbCurrencyField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
, Color
** /*ppColor*/)
2162 return lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField
& >( *m_pPainter
), *this, _rxField
, _rxFormatter
);
2166 void DbCurrencyField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& _rxFormatter
)
2168 lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField
& >( *m_pWindow
), *this, _rxField
, _rxFormatter
);
2172 void DbCurrencyField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2174 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbCurrencyField::updateFromModel: invalid call!" );
2177 if ( _rxModel
->getPropertyValue( FM_PROP_VALUE
) >>= dValue
)
2181 dValue
= ::rtl::math::pow10Exp( dValue
, m_nScale
);
2182 dValue
= ::rtl::math::round(dValue
, 0);
2185 static_cast< LongCurrencyField
* >( m_pWindow
)->SetValue( dValue
);
2188 m_pWindow
->SetText( OUString() );
2192 bool DbCurrencyField::commitControl()
2194 OUString
aText(m_pWindow
->GetText());
2196 if (!aText
.isEmpty()) // not empty
2198 double fValue
= ((LongCurrencyField
*)m_pWindow
)->GetValue();
2201 fValue
/= ::rtl::math::pow10Exp(1.0, m_nScale
);
2203 aVal
<<= (double)fValue
;
2205 m_rColumn
.getModel()->setPropertyValue(FM_PROP_VALUE
, aVal
);
2213 DbDateField::DbDateField( DbGridColumn
& _rColumn
)
2214 :DbSpinField( _rColumn
)
2216 doPropertyListening( FM_PROP_DATEFORMAT
);
2217 doPropertyListening( FM_PROP_DATEMIN
);
2218 doPropertyListening( FM_PROP_DATEMAX
);
2219 doPropertyListening( FM_PROP_STRICTFORMAT
);
2220 doPropertyListening( FM_PROP_DATE_SHOW_CENTURY
);
2224 SpinField
* DbDateField::createField( Window
* _pParent
, WinBits _nFieldStyle
, const Reference
< XPropertySet
>& _rxModel
)
2226 // check if there is a DropDown property set to TRUE
2227 bool bDropDown
= !hasProperty( FM_PROP_DROPDOWN
, _rxModel
)
2228 || getBOOL( _rxModel
->getPropertyValue( FM_PROP_DROPDOWN
) );
2230 _nFieldStyle
|= WB_DROPDOWN
;
2232 CalendarField
* pField
= new CalendarField( _pParent
, _nFieldStyle
);
2234 pField
->EnableToday();
2235 pField
->EnableNone();
2241 void DbDateField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
2243 DBG_ASSERT( m_pWindow
, "DbDateField::implAdjustGenericFieldSetting: not to be called without window!" );
2244 DBG_ASSERT( _rxModel
.is(), "DbDateField::implAdjustGenericFieldSetting: invalid model!" );
2245 if ( m_pWindow
&& _rxModel
.is() )
2247 sal_Int16 nFormat
= getINT16( _rxModel
->getPropertyValue( FM_PROP_DATEFORMAT
) );
2249 OSL_VERIFY( _rxModel
->getPropertyValue( FM_PROP_DATEMIN
) >>= aMin
);
2251 OSL_VERIFY( _rxModel
->getPropertyValue( FM_PROP_DATEMAX
) >>= aMax
);
2252 bool bStrict
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_STRICTFORMAT
) );
2254 Any aCentury
= _rxModel
->getPropertyValue( FM_PROP_DATE_SHOW_CENTURY
);
2255 if ( aCentury
.getValueType().getTypeClass() != TypeClass_VOID
)
2257 bool bShowDateCentury
= getBOOL( aCentury
);
2259 static_cast<DateField
*>( m_pWindow
)->SetShowDateCentury( bShowDateCentury
);
2260 static_cast<DateField
*>( m_pPainter
)->SetShowDateCentury( bShowDateCentury
);
2263 static_cast< DateField
* >( m_pWindow
)->SetExtDateFormat( (ExtDateFieldFormat
)nFormat
);
2264 static_cast< DateField
* >( m_pWindow
)->SetMin( aMin
);
2265 static_cast< DateField
* >( m_pWindow
)->SetMax( aMax
);
2266 static_cast< DateField
* >( m_pWindow
)->SetStrictFormat( bStrict
);
2267 static_cast< DateField
* >( m_pWindow
)->EnableEmptyFieldValue( true );
2269 static_cast< DateField
* >( m_pPainter
)->SetExtDateFormat( (ExtDateFieldFormat
)nFormat
);
2270 static_cast< DateField
* >( m_pPainter
)->SetMin( aMin
);
2271 static_cast< DateField
* >( m_pPainter
)->SetMax( aMax
);
2272 static_cast< DateField
* >( m_pPainter
)->SetStrictFormat( bStrict
);
2273 static_cast< DateField
* >( m_pPainter
)->EnableEmptyFieldValue( true );
2280 static OUString
lcl_setFormattedDate_nothrow( DateField
& _rField
, const Reference
< XColumn
>& _rxField
)
2283 if ( _rxField
.is() )
2287 ::com::sun::star::util::Date aValue
= _rxField
->getDate();
2288 if ( _rxField
->wasNull() )
2289 _rField
.SetText( sDate
);
2292 _rField
.SetDate( ::Date( aValue
.Day
, aValue
.Month
, aValue
.Year
) );
2293 sDate
= _rField
.GetText();
2296 catch( const Exception
& )
2298 DBG_UNHANDLED_EXCEPTION();
2305 OUString
DbDateField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
2307 return lcl_setFormattedDate_nothrow(dynamic_cast<DateField
&>(*m_pPainter
), _rxField
);
2311 void DbDateField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/)
2313 lcl_setFormattedDate_nothrow(dynamic_cast<DateField
&>(*m_pWindow
), _rxField
);
2317 void DbDateField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2319 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbDateField::updateFromModel: invalid call!" );
2322 if ( _rxModel
->getPropertyValue( FM_PROP_DATE
) >>= aDate
)
2323 static_cast< DateField
* >( m_pWindow
)->SetDate( ::Date( aDate
) );
2325 static_cast< DateField
* >( m_pWindow
)->SetText( OUString() );
2329 bool DbDateField::commitControl()
2331 OUString
aText(m_pWindow
->GetText());
2333 if (!aText
.isEmpty())
2334 aVal
<<= static_cast<DateField
*>(m_pWindow
)->GetDate().GetUNODate();
2338 m_rColumn
.getModel()->setPropertyValue(FM_PROP_DATE
, aVal
);
2346 DbTimeField::DbTimeField( DbGridColumn
& _rColumn
)
2347 :DbSpinField( _rColumn
, ::com::sun::star::awt::TextAlign::LEFT
)
2349 doPropertyListening( FM_PROP_TIMEFORMAT
);
2350 doPropertyListening( FM_PROP_TIMEMIN
);
2351 doPropertyListening( FM_PROP_TIMEMAX
);
2352 doPropertyListening( FM_PROP_STRICTFORMAT
);
2356 SpinField
* DbTimeField::createField( Window
* _pParent
, WinBits _nFieldStyle
, const Reference
< XPropertySet
>& /*_rxModel*/ )
2358 return new TimeField( _pParent
, _nFieldStyle
);
2362 void DbTimeField::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
2364 DBG_ASSERT( m_pWindow
, "DbTimeField::implAdjustGenericFieldSetting: not to be called without window!" );
2365 DBG_ASSERT( _rxModel
.is(), "DbTimeField::implAdjustGenericFieldSetting: invalid model!" );
2366 if ( m_pWindow
&& _rxModel
.is() )
2368 sal_Int16 nFormat
= getINT16( _rxModel
->getPropertyValue( FM_PROP_TIMEFORMAT
) );
2370 OSL_VERIFY( _rxModel
->getPropertyValue( FM_PROP_TIMEMIN
) >>= aMin
);
2372 OSL_VERIFY( _rxModel
->getPropertyValue( FM_PROP_TIMEMAX
) >>= aMax
);
2373 bool bStrict
= getBOOL( _rxModel
->getPropertyValue( FM_PROP_STRICTFORMAT
) );
2375 static_cast< TimeField
* >( m_pWindow
)->SetExtFormat( (ExtTimeFieldFormat
)nFormat
);
2376 static_cast< TimeField
* >( m_pWindow
)->SetMin( aMin
);
2377 static_cast< TimeField
* >( m_pWindow
)->SetMax( aMax
);
2378 static_cast< TimeField
* >( m_pWindow
)->SetStrictFormat( bStrict
);
2379 static_cast< TimeField
* >( m_pWindow
)->EnableEmptyFieldValue( true );
2381 static_cast< TimeField
* >( m_pPainter
)->SetExtFormat( (ExtTimeFieldFormat
)nFormat
);
2382 static_cast< TimeField
* >( m_pPainter
)->SetMin( aMin
);
2383 static_cast< TimeField
* >( m_pPainter
)->SetMax( aMax
);
2384 static_cast< TimeField
* >( m_pPainter
)->SetStrictFormat( bStrict
);
2385 static_cast< TimeField
* >( m_pPainter
)->EnableEmptyFieldValue( true );
2392 static OUString
lcl_setFormattedTime_nothrow( TimeField
& _rField
, const Reference
< XColumn
>& _rxField
)
2395 if ( _rxField
.is() )
2399 ::com::sun::star::util::Time aValue
= _rxField
->getTime();
2400 if ( _rxField
->wasNull() )
2401 _rField
.SetText( sTime
);
2404 _rField
.SetTime( ::Time( aValue
.Hours
, aValue
.Minutes
, aValue
.Seconds
, aValue
.NanoSeconds
) );
2405 sTime
= _rField
.GetText();
2408 catch( const Exception
& )
2410 DBG_UNHANDLED_EXCEPTION();
2417 OUString
DbTimeField::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< ::com::sun::star::util::XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
2419 return lcl_setFormattedTime_nothrow( *static_cast< TimeField
* >( m_pPainter
), _rxField
);
2423 void DbTimeField::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/)
2425 lcl_setFormattedTime_nothrow( *static_cast< TimeField
* >( m_pWindow
), _rxField
);
2429 void DbTimeField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2431 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbTimeField::updateFromModel: invalid call!" );
2434 if ( _rxModel
->getPropertyValue( FM_PROP_DATE
) >>= aTime
)
2435 static_cast< TimeField
* >( m_pWindow
)->SetTime( ::Time( aTime
) );
2437 static_cast< TimeField
* >( m_pWindow
)->SetText( OUString() );
2441 bool DbTimeField::commitControl()
2443 OUString
aText(m_pWindow
->GetText());
2445 if (!aText
.isEmpty())
2446 aVal
<<= static_cast<TimeField
*>(m_pWindow
)->GetTime().GetUNOTime();
2450 m_rColumn
.getModel()->setPropertyValue(FM_PROP_TIME
, aVal
);
2458 DbComboBox::DbComboBox(DbGridColumn
& _rColumn
)
2459 :DbCellControl(_rColumn
)
2460 ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED
)
2462 setAlignedController( false );
2464 doPropertyListening( FM_PROP_STRINGITEMLIST
);
2465 doPropertyListening( FM_PROP_LINECOUNT
);
2469 void DbComboBox::_propertyChanged( const PropertyChangeEvent
& _rEvent
) throw( RuntimeException
)
2471 if ( _rEvent
.PropertyName
.equals( FM_PROP_STRINGITEMLIST
) )
2473 SetList(_rEvent
.NewValue
);
2477 DbCellControl::_propertyChanged( _rEvent
) ;
2482 void DbComboBox::SetList(const Any
& rItems
)
2484 ComboBoxControl
* pField
= (ComboBoxControl
*)m_pWindow
;
2487 ::comphelper::StringSequence aTest
;
2488 if (rItems
>>= aTest
)
2490 const OUString
* pStrings
= aTest
.getConstArray();
2491 sal_Int32 nItems
= aTest
.getLength();
2492 for (sal_Int32 i
= 0; i
< nItems
; ++i
, ++pStrings
)
2493 pField
->InsertEntry(*pStrings
, LISTBOX_APPEND
);
2495 // tell the grid control that this controller is invalid and has to be re-initialized
2496 invalidatedController();
2501 void DbComboBox::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
2503 DBG_ASSERT( m_pWindow
, "DbComboBox::implAdjustGenericFieldSetting: not to be called without window!" );
2504 DBG_ASSERT( _rxModel
.is(), "DbComboBox::implAdjustGenericFieldSetting: invalid model!" );
2505 if ( m_pWindow
&& _rxModel
.is() )
2507 sal_Int16 nLines
= getINT16( _rxModel
->getPropertyValue( FM_PROP_LINECOUNT
) );
2508 static_cast< ComboBoxControl
* >( m_pWindow
)->SetDropDownLineCount( nLines
);
2513 void DbComboBox::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
2515 m_rColumn
.SetAlignmentFromModel(::com::sun::star::awt::TextAlign::LEFT
);
2517 m_pWindow
= new ComboBoxControl( &rParent
);
2519 // selection von rechts nach links
2520 AllSettings aSettings
= m_pWindow
->GetSettings();
2521 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
2522 aStyleSettings
.SetSelectionOptions(
2523 aStyleSettings
.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST
);
2524 aSettings
.SetStyleSettings(aStyleSettings
);
2525 m_pWindow
->SetSettings(aSettings
, true);
2527 // some initial properties
2528 Reference
< XPropertySet
> xModel(m_rColumn
.getModel());
2529 SetList( xModel
->getPropertyValue( FM_PROP_STRINGITEMLIST
) );
2530 implAdjustGenericFieldSetting( xModel
);
2532 if (m_rColumn
.GetParent().getNumberFormatter().is())
2533 m_nKeyType
= comphelper::getNumberFormatType(m_rColumn
.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn
.GetKey());
2535 DbCellControl::Init( rParent
, xCursor
);
2539 CellControllerRef
DbComboBox::CreateController() const
2541 return new ComboBoxCellController((ComboBoxControl
*)m_pWindow
);
2545 OUString
DbComboBox::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
, Color
** /*ppColor*/)
2551 aString
= getFormattedValue( _rxField
, xFormatter
, m_rColumn
.GetParent().getNullDate(), m_rColumn
.GetKey(), m_nKeyType
);
2553 catch( const Exception
& )
2555 DBG_UNHANDLED_EXCEPTION();
2561 void DbComboBox::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
)
2563 m_pWindow
->SetText(GetFormatText(_rxField
, xFormatter
));
2567 void DbComboBox::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2569 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbComboBox::updateFromModel: invalid call!" );
2572 _rxModel
->getPropertyValue( FM_PROP_TEXT
) >>= sText
;
2574 static_cast< ComboBox
* >( m_pWindow
)->SetText( sText
);
2575 static_cast< ComboBox
* >( m_pWindow
)->SetSelection( Selection( SELECTION_MAX
, SELECTION_MIN
) );
2579 bool DbComboBox::commitControl()
2581 OUString
aText( m_pWindow
->GetText());
2582 m_rColumn
.getModel()->setPropertyValue(FM_PROP_TEXT
, makeAny(aText
));
2587 DbListBox::DbListBox(DbGridColumn
& _rColumn
)
2588 :DbCellControl(_rColumn
)
2591 setAlignedController( false );
2593 doPropertyListening( FM_PROP_STRINGITEMLIST
);
2594 doPropertyListening( FM_PROP_LINECOUNT
);
2598 void DbListBox::_propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw( RuntimeException
)
2600 if ( _rEvent
.PropertyName
.equals( FM_PROP_STRINGITEMLIST
) )
2602 SetList(_rEvent
.NewValue
);
2606 DbCellControl::_propertyChanged( _rEvent
) ;
2611 void DbListBox::SetList(const Any
& rItems
)
2613 ListBoxControl
* pField
= (ListBoxControl
*)m_pWindow
;
2618 ::comphelper::StringSequence aTest
;
2619 if (rItems
>>= aTest
)
2621 const OUString
* pStrings
= aTest
.getConstArray();
2622 sal_Int32 nItems
= aTest
.getLength();
2625 for (sal_Int32 i
= 0; i
< nItems
; ++i
, ++pStrings
)
2626 pField
->InsertEntry(*pStrings
, LISTBOX_APPEND
);
2628 m_rColumn
.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ
) >>= m_aValueList
;
2629 m_bBound
= m_aValueList
.getLength() > 0;
2631 // tell the grid control that this controller is invalid and has to be re-initialized
2632 invalidatedController();
2638 void DbListBox::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
2640 m_rColumn
.SetAlignment(::com::sun::star::awt::TextAlign::LEFT
);
2642 m_pWindow
= new ListBoxControl( &rParent
);
2644 // some initial properties
2645 Reference
< XPropertySet
> xModel( m_rColumn
.getModel() );
2646 SetList( xModel
->getPropertyValue( FM_PROP_STRINGITEMLIST
) );
2647 implAdjustGenericFieldSetting( xModel
);
2649 DbCellControl::Init( rParent
, xCursor
);
2653 void DbListBox::implAdjustGenericFieldSetting( const Reference
< XPropertySet
>& _rxModel
)
2655 DBG_ASSERT( m_pWindow
, "DbListBox::implAdjustGenericFieldSetting: not to be called without window!" );
2656 DBG_ASSERT( _rxModel
.is(), "DbListBox::implAdjustGenericFieldSetting: invalid model!" );
2657 if ( m_pWindow
&& _rxModel
.is() )
2659 sal_Int16 nLines
= getINT16( _rxModel
->getPropertyValue( FM_PROP_LINECOUNT
) );
2660 static_cast< ListBoxControl
* >( m_pWindow
)->SetDropDownLineCount( nLines
);
2665 CellControllerRef
DbListBox::CreateController() const
2667 return new ListBoxCellController((ListBoxControl
*)m_pWindow
);
2671 OUString
DbListBox::GetFormatText(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
2674 if ( _rxField
.is() )
2678 sText
= _rxField
->getString();
2681 Sequence
< sal_Int16
> aPosSeq
= ::comphelper::findValue( m_aValueList
, sText
, true );
2682 if ( aPosSeq
.getLength() )
2683 sText
= static_cast<ListBox
*>(m_pWindow
)->GetEntry(aPosSeq
.getConstArray()[0]);
2688 catch( const Exception
& )
2690 DBG_UNHANDLED_EXCEPTION();
2697 void DbListBox::UpdateFromField(const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
, const Reference
< XNumberFormatter
>& xFormatter
)
2699 OUString
sFormattedText( GetFormatText( _rxField
, xFormatter
) );
2700 if (!sFormattedText
.isEmpty())
2701 static_cast< ListBox
* >( m_pWindow
)->SelectEntry( sFormattedText
);
2703 static_cast< ListBox
* >( m_pWindow
)->SetNoSelection();
2707 void DbListBox::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2709 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbListBox::updateFromModel: invalid call!" );
2711 Sequence
< sal_Int16
> aSelection
;
2712 _rxModel
->getPropertyValue( FM_PROP_SELECT_SEQ
);
2714 sal_Int16 nSelection
= -1;
2715 if ( aSelection
.getLength() > 0 )
2716 nSelection
= aSelection
[ 0 ];
2718 ListBox
* pListBox
= static_cast< ListBox
* >( m_pWindow
);
2720 if ( ( nSelection
>= 0 ) && ( nSelection
< pListBox
->GetEntryCount() ) )
2721 pListBox
->SelectEntryPos( nSelection
);
2723 pListBox
->SetNoSelection( );
2727 bool DbListBox::commitControl()
2730 Sequence
<sal_Int16
> aSelectSeq
;
2731 if (static_cast<ListBox
*>(m_pWindow
)->GetSelectEntryCount())
2733 aSelectSeq
.realloc(1);
2734 *(sal_Int16
*)aSelectSeq
.getArray() = (sal_Int16
)static_cast<ListBox
*>(m_pWindow
)->GetSelectEntryPos();
2736 aVal
<<= aSelectSeq
;
2737 m_rColumn
.getModel()->setPropertyValue(FM_PROP_SELECT_SEQ
, aVal
);
2742 /*************************************************************************/
2743 DbFilterField::DbFilterField(const Reference
< XComponentContext
>& rxContext
,DbGridColumn
& _rColumn
)
2744 :DbCellControl(_rColumn
)
2745 ,OSQLParserClient(rxContext
)
2746 ,m_nControlClass(::com::sun::star::form::FormComponentType::TEXTFIELD
)
2747 ,m_bFilterList(false)
2748 ,m_bFilterListFilled(false)
2752 setAlignedController( false );
2756 DbFilterField::~DbFilterField()
2758 if (m_nControlClass
== ::com::sun::star::form::FormComponentType::CHECKBOX
)
2759 ((CheckBoxControl
*)m_pWindow
)->SetClickHdl( Link() );
2764 void DbFilterField::PaintCell(OutputDevice
& rDev
, const Rectangle
& rRect
)
2766 static sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_VCENTER
| TEXT_DRAW_LEFT
;
2767 switch (m_nControlClass
)
2769 case FormComponentType::CHECKBOX
:
2770 DbCellControl::PaintCell( rDev
, rRect
);
2772 case FormComponentType::LISTBOX
:
2773 rDev
.DrawText(rRect
, static_cast<ListBox
*>(m_pWindow
)->GetSelectEntry(), nStyle
);
2776 rDev
.DrawText(rRect
, m_aText
, nStyle
);
2781 void DbFilterField::SetList(const Any
& rItems
, bool bComboBox
)
2783 ::comphelper::StringSequence aTest
;
2785 const OUString
* pStrings
= aTest
.getConstArray();
2786 sal_Int32 nItems
= aTest
.getLength();
2791 ComboBox
* pField
= (ComboBox
*)m_pWindow
;
2792 for (sal_Int32 i
= 0; i
< nItems
; ++i
, ++pStrings
)
2793 pField
->InsertEntry(*pStrings
, LISTBOX_APPEND
);
2797 ListBox
* pField
= (ListBox
*)m_pWindow
;
2798 for (sal_Int32 i
= 0; i
< nItems
; ++i
, ++pStrings
)
2799 pField
->InsertEntry(*pStrings
, LISTBOX_APPEND
);
2801 m_rColumn
.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ
) >>= m_aValueList
;
2802 m_bBound
= m_aValueList
.getLength() > 0;
2808 void DbFilterField::CreateControl(Window
* pParent
, const Reference
< ::com::sun::star::beans::XPropertySet
>& xModel
)
2810 switch (m_nControlClass
)
2812 case ::com::sun::star::form::FormComponentType::CHECKBOX
:
2813 m_pWindow
= new CheckBoxControl(pParent
);
2814 m_pWindow
->SetPaintTransparent( true );
2815 ((CheckBoxControl
*)m_pWindow
)->SetClickHdl( LINK( this, DbFilterField
, OnClick
) );
2817 m_pPainter
= new CheckBoxControl(pParent
);
2818 m_pPainter
->SetPaintTransparent( true );
2819 m_pPainter
->SetBackground();
2821 case ::com::sun::star::form::FormComponentType::LISTBOX
:
2823 m_pWindow
= new ListBoxControl(pParent
);
2824 sal_Int16 nLines
= ::comphelper::getINT16(xModel
->getPropertyValue(FM_PROP_LINECOUNT
));
2825 Any aItems
= xModel
->getPropertyValue(FM_PROP_STRINGITEMLIST
);
2826 SetList(aItems
, m_nControlClass
== ::com::sun::star::form::FormComponentType::COMBOBOX
);
2827 static_cast<ListBox
*>(m_pWindow
)->SetDropDownLineCount(nLines
);
2829 case ::com::sun::star::form::FormComponentType::COMBOBOX
:
2831 m_pWindow
= new ComboBoxControl(pParent
);
2833 AllSettings aSettings
= m_pWindow
->GetSettings();
2834 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
2835 aStyleSettings
.SetSelectionOptions(
2836 aStyleSettings
.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST
);
2837 aSettings
.SetStyleSettings(aStyleSettings
);
2838 m_pWindow
->SetSettings(aSettings
, true);
2842 sal_Int16 nLines
= ::comphelper::getINT16(xModel
->getPropertyValue(FM_PROP_LINECOUNT
));
2843 Any aItems
= xModel
->getPropertyValue(FM_PROP_STRINGITEMLIST
);
2844 SetList(aItems
, m_nControlClass
== ::com::sun::star::form::FormComponentType::COMBOBOX
);
2845 ((ComboBox
*)m_pWindow
)->SetDropDownLineCount(nLines
);
2848 ((ComboBox
*)m_pWindow
)->SetDropDownLineCount(5);
2853 m_pWindow
= new Edit(pParent
, WB_LEFT
);
2854 AllSettings aSettings
= m_pWindow
->GetSettings();
2855 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
2856 aStyleSettings
.SetSelectionOptions(
2857 aStyleSettings
.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST
);
2858 aSettings
.SetStyleSettings(aStyleSettings
);
2859 m_pWindow
->SetSettings(aSettings
, true);
2865 void DbFilterField::Init( Window
& rParent
, const Reference
< XRowSet
>& xCursor
)
2867 Reference
< ::com::sun::star::beans::XPropertySet
> xModel(m_rColumn
.getModel());
2868 m_rColumn
.SetAlignment(::com::sun::star::awt::TextAlign::LEFT
);
2872 m_bFilterList
= ::comphelper::hasProperty(FM_PROP_FILTERPROPOSAL
, xModel
) && ::comphelper::getBOOL(xModel
->getPropertyValue(FM_PROP_FILTERPROPOSAL
));
2874 m_nControlClass
= ::com::sun::star::form::FormComponentType::COMBOBOX
;
2877 sal_Int16 nClassId
= ::comphelper::getINT16(xModel
->getPropertyValue(FM_PROP_CLASSID
));
2880 case FormComponentType::CHECKBOX
:
2881 case FormComponentType::LISTBOX
:
2882 case FormComponentType::COMBOBOX
:
2883 m_nControlClass
= nClassId
;
2887 m_nControlClass
= FormComponentType::COMBOBOX
;
2889 m_nControlClass
= FormComponentType::TEXTFIELD
;
2894 CreateControl( &rParent
, xModel
);
2895 DbCellControl::Init( rParent
, xCursor
);
2897 // filter cells are never readonly
2898 Edit
* pAsEdit
= dynamic_cast< Edit
* >( m_pWindow
);
2900 pAsEdit
->SetReadOnly( false );
2904 CellControllerRef
DbFilterField::CreateController() const
2906 CellControllerRef xController
;
2907 switch (m_nControlClass
)
2909 case ::com::sun::star::form::FormComponentType::CHECKBOX
:
2910 xController
= new CheckBoxCellController((CheckBoxControl
*)m_pWindow
);
2912 case ::com::sun::star::form::FormComponentType::LISTBOX
:
2913 xController
= new ListBoxCellController((ListBoxControl
*)m_pWindow
);
2915 case ::com::sun::star::form::FormComponentType::COMBOBOX
:
2916 xController
= new ComboBoxCellController((ComboBoxControl
*)m_pWindow
);
2920 xController
= new ComboBoxCellController((ComboBoxControl
*)m_pWindow
);
2922 xController
= new EditCellController((Edit
*)m_pWindow
);
2928 void DbFilterField::updateFromModel( Reference
< XPropertySet
> _rxModel
)
2930 OSL_ENSURE( _rxModel
.is() && m_pWindow
, "DbFilterField::updateFromModel: invalid call!" );
2933 OSL_FAIL( "DbListBox::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
2934 // TODO: implement this.
2935 // remember: updateFromModel should be some kind of opposite of commitControl
2939 bool DbFilterField::commitControl()
2941 OUString
aText(m_aText
);
2942 switch (m_nControlClass
)
2944 case ::com::sun::star::form::FormComponentType::CHECKBOX
:
2946 case ::com::sun::star::form::FormComponentType::LISTBOX
:
2948 if (static_cast<ListBox
*>(m_pWindow
)->GetSelectEntryCount())
2950 sal_Int16 nPos
= (sal_Int16
)static_cast<ListBox
*>(m_pWindow
)->GetSelectEntryPos();
2951 if ( ( nPos
>= 0 ) && ( nPos
< m_aValueList
.getLength() ) )
2952 aText
= m_aValueList
.getConstArray()[nPos
];
2955 if (m_aText
!= aText
)
2958 m_aCommitLink
.Call(this);
2962 aText
= m_pWindow
->GetText();
2965 if (m_aText
!= aText
)
2967 // check the text with the SQL-Parser
2968 OUString
aNewText(comphelper::string::stripEnd(aText
, ' '));
2969 if (!aNewText
.isEmpty())
2972 Reference
< XNumberFormatter
> xNumberFormatter(m_rColumn
.GetParent().getNumberFormatter());
2974 ::rtl::Reference
< ISQLParseNode
> xParseNode
= predicateTree(aErrorMsg
, aNewText
,xNumberFormatter
, m_rColumn
.GetField());
2975 if (xParseNode
.is())
2977 OUString aPreparedText
;
2979 ::com::sun::star::lang::Locale aAppLocale
= Application::GetSettings().GetUILanguageTag().getLocale();
2981 Reference
< XRowSet
> xDataSourceRowSet(
2982 (Reference
< XInterface
>)*m_rColumn
.GetParent().getDataSource(), UNO_QUERY
);
2983 Reference
< XConnection
> xConnection(getRowSetConnection(xDataSourceRowSet
));
2985 xParseNode
->parseNodeToPredicateStr(aPreparedText
,
2988 m_rColumn
.GetField(),
2993 m_aText
= aPreparedText
;
2998 SQLException aError
;
2999 aError
.Message
= aErrorMsg
;
3000 displayException(aError
, m_pWindow
->GetParent());
3001 // TODO: transport the title
3009 m_pWindow
->SetText(m_aText
);
3010 m_aCommitLink
.Call(this);
3016 void DbFilterField::SetText(const OUString
& rText
)
3019 switch (m_nControlClass
)
3021 case ::com::sun::star::form::FormComponentType::CHECKBOX
:
3025 eState
= TRISTATE_TRUE
;
3026 else if (rText
== "0")
3027 eState
= TRISTATE_FALSE
;
3029 eState
= TRISTATE_INDET
;
3031 ((CheckBoxControl
*)m_pWindow
)->GetBox().SetState(eState
);
3032 ((CheckBoxControl
*)m_pPainter
)->GetBox().SetState(eState
);
3034 case ::com::sun::star::form::FormComponentType::LISTBOX
:
3036 Sequence
<sal_Int16
> aPosSeq
= ::comphelper::findValue(m_aValueList
, m_aText
, true);
3037 if (aPosSeq
.getLength())
3038 static_cast<ListBox
*>(m_pWindow
)->SelectEntryPos(aPosSeq
.getConstArray()[0], true);
3040 static_cast<ListBox
*>(m_pWindow
)->SetNoSelection();
3043 m_pWindow
->SetText(m_aText
);
3046 // now force a repaint on the window
3047 m_rColumn
.GetParent().RowModified(0,m_rColumn
.GetId());
3051 void DbFilterField::Update()
3053 // should we fill the combobox with a filter proposal?
3054 if (m_bFilterList
&& !m_bFilterListFilled
)
3056 m_bFilterListFilled
= true;
3057 Reference
< ::com::sun::star::beans::XPropertySet
> xField
= m_rColumn
.GetField();
3062 xField
->getPropertyValue(FM_PROP_NAME
) >>= aName
;
3065 Reference
< ::com::sun::star::container::XChild
> xModelAsChild(m_rColumn
.getModel(), UNO_QUERY
);
3067 xModelAsChild
= Reference
< ::com::sun::star::container::XChild
> (xModelAsChild
->getParent(),UNO_QUERY
);
3068 Reference
< XRowSet
> xForm(xModelAsChild
->getParent(), UNO_QUERY
);
3072 Reference
<XPropertySet
> xFormProp(xForm
,UNO_QUERY
);
3073 Reference
< XTablesSupplier
> xSupTab
;
3074 xFormProp
->getPropertyValue("SingleSelectQueryComposer") >>= xSupTab
;
3076 Reference
< XConnection
> xConnection(getRowSetConnection(xForm
));
3081 Reference
< XColumnsSupplier
> xSupCol(xSupTab
,UNO_QUERY
);
3082 Reference
< ::com::sun::star::container::XNameAccess
> xFieldNames
= xSupCol
->getColumns();
3083 if (!xFieldNames
->hasByName(aName
))
3086 Reference
< ::com::sun::star::container::XNameAccess
> xTablesNames
= xSupTab
->getTables();
3087 Reference
< ::com::sun::star::beans::XPropertySet
> xComposerFieldAsSet(xFieldNames
->getByName(aName
),UNO_QUERY
);
3089 if (xComposerFieldAsSet
.is() && ::comphelper::hasProperty(FM_PROP_TABLENAME
, xComposerFieldAsSet
) &&
3090 ::comphelper::hasProperty(FM_PROP_FIELDSOURCE
, xComposerFieldAsSet
))
3092 OUString aFieldName
;
3093 OUString aTableName
;
3094 xComposerFieldAsSet
->getPropertyValue(FM_PROP_FIELDSOURCE
) >>= aFieldName
;
3095 xComposerFieldAsSet
->getPropertyValue(FM_PROP_TABLENAME
) >>= aTableName
;
3097 // no possibility to create a select statement
3098 // looking for the complete table name
3099 if (!xTablesNames
->hasByName(aTableName
))
3102 // ein Statement aufbauen und abschicken als query
3103 // Access to the connection
3104 Reference
< XStatement
> xStatement
;
3105 Reference
< XResultSet
> xListCursor
;
3106 Reference
< ::com::sun::star::sdb::XColumn
> xDataField
;
3110 Reference
< XDatabaseMetaData
> xMeta
= xConnection
->getMetaData();
3112 OUString
aQuote(xMeta
->getIdentifierQuoteString());
3113 OUStringBuffer
aStatement("SELECT DISTINCT ");
3114 aStatement
.append(quoteName(aQuote
, aName
));
3115 if (!aFieldName
.isEmpty() && aName
!= aFieldName
)
3117 aStatement
.append(" AS ");
3118 aStatement
.append(quoteName(aQuote
, aFieldName
));
3121 aStatement
.append(" FROM ");
3123 Reference
< XPropertySet
> xTableNameAccess(xTablesNames
->getByName(aTableName
), UNO_QUERY_THROW
);
3124 aStatement
.append(composeTableNameForSelect(xConnection
, xTableNameAccess
));
3126 xStatement
= xConnection
->createStatement();
3127 Reference
< ::com::sun::star::beans::XPropertySet
> xStatementProps(xStatement
, UNO_QUERY
);
3128 xStatementProps
->setPropertyValue(FM_PROP_ESCAPE_PROCESSING
, makeAny(true));
3130 xListCursor
= xStatement
->executeQuery(aStatement
.makeStringAndClear());
3132 Reference
< ::com::sun::star::sdbcx::XColumnsSupplier
> xSupplyCols(xListCursor
, UNO_QUERY
);
3133 Reference
< ::com::sun::star::container::XIndexAccess
> xFields(xSupplyCols
->getColumns(), UNO_QUERY
);
3134 xDataField
.set(xFields
->getByIndex(0), css::uno::UNO_QUERY
);
3135 if (!xDataField
.is())
3138 catch(const Exception
&)
3140 ::comphelper::disposeComponent(xStatement
);
3145 ::std::vector
< OUString
> aStringList
;
3146 aStringList
.reserve(16);
3148 com::sun::star::util::Date aNullDate
= m_rColumn
.GetParent().getNullDate();
3149 sal_Int32 nFormatKey
= m_rColumn
.GetKey();
3150 Reference
< XNumberFormatter
> xFormatter
= m_rColumn
.GetParent().getNumberFormatter();
3151 sal_Int16 nKeyType
= ::comphelper::getNumberFormatType(xFormatter
->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey
);
3153 while (!xListCursor
->isAfterLast() && i
++ < SHRT_MAX
) // max anzahl eintraege
3155 aStr
= getFormattedValue(xDataField
, xFormatter
, aNullDate
, nFormatKey
, nKeyType
);
3156 aStringList
.push_back(aStr
);
3157 xListCursor
->next();
3160 // filling the entries for the combobox
3161 for (::std::vector
< OUString
>::const_iterator iter
= aStringList
.begin();
3162 iter
!= aStringList
.end(); ++iter
)
3163 ((ComboBox
*)m_pWindow
)->InsertEntry(*iter
, LISTBOX_APPEND
);
3169 OUString
DbFilterField::GetFormatText(const Reference
< XColumn
>& /*_rxField*/, const Reference
< XNumberFormatter
>& /*xFormatter*/, Color
** /*ppColor*/)
3175 void DbFilterField::UpdateFromField(const Reference
< XColumn
>& /*_rxField*/, const Reference
< XNumberFormatter
>& /*xFormatter*/)
3177 OSL_FAIL( "DbFilterField::UpdateFromField: cannot update a filter control from a field!" );
3181 IMPL_LINK_NOARG(DbFilterField
, OnClick
)
3183 TriState eState
= ((CheckBoxControl
*)m_pWindow
)->GetBox().GetState();
3191 case TRISTATE_FALSE
:
3194 case TRISTATE_INDET
:
3198 if (m_aText
!= aText
)
3201 m_aCommitLink
.Call(this);
3206 /*************************************************************************/
3207 TYPEINIT0(FmXGridCell
);
3211 FmXGridCell::FmXGridCell( DbGridColumn
* pColumn
, DbCellControl
* _pControl
)
3212 :OComponentHelper(m_aMutex
)
3214 ,m_pCellControl( _pControl
)
3215 ,m_aWindowListeners( m_aMutex
)
3216 ,m_aFocusListeners( m_aMutex
)
3217 ,m_aKeyListeners( m_aMutex
)
3218 ,m_aMouseListeners( m_aMutex
)
3219 ,m_aMouseMotionListeners( m_aMutex
)
3224 void FmXGridCell::init()
3226 Window
* pEventWindow( getEventWindow() );
3228 pEventWindow
->AddEventListener( LINK( this, FmXGridCell
, OnWindowEvent
) );
3232 Window
* FmXGridCell::getEventWindow() const
3234 if ( m_pCellControl
)
3235 return &m_pCellControl
->GetWindow();
3240 FmXGridCell::~FmXGridCell()
3242 if (!OComponentHelper::rBHelper
.bDisposed
)
3251 void FmXGridCell::SetTextLineColor()
3254 m_pCellControl
->SetTextLineColor();
3258 void FmXGridCell::SetTextLineColor(const Color
& _rColor
)
3261 m_pCellControl
->SetTextLineColor(_rColor
);
3266 Sequence
< Type
> SAL_CALL
FmXGridCell::getTypes( ) throw (RuntimeException
, std::exception
)
3268 Sequence
< uno::Type
> aTypes
= ::comphelper::concatSequences(
3269 ::cppu::OComponentHelper::getTypes(),
3270 FmXGridCell_Base::getTypes()
3272 if ( m_pCellControl
)
3273 aTypes
= ::comphelper::concatSequences(
3275 FmXGridCell_WindowBase::getTypes()
3281 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXGridCell
)
3285 void FmXGridCell::disposing()
3287 lang::EventObject
aEvent( *this );
3288 m_aWindowListeners
.disposeAndClear( aEvent
);
3289 m_aFocusListeners
.disposeAndClear( aEvent
);
3290 m_aKeyListeners
.disposeAndClear( aEvent
);
3291 m_aMouseListeners
.disposeAndClear( aEvent
);
3292 m_aMouseMotionListeners
.disposeAndClear( aEvent
);
3294 OComponentHelper::disposing();
3296 DELETEZ(m_pCellControl
);
3300 Any SAL_CALL
FmXGridCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
3302 Any aReturn
= OComponentHelper::queryAggregation( _rType
);
3304 if ( !aReturn
.hasValue() )
3305 aReturn
= FmXGridCell_Base::queryInterface( _rType
);
3307 if ( !aReturn
.hasValue() && ( m_pCellControl
!= NULL
) )
3308 aReturn
= FmXGridCell_WindowBase::queryInterface( _rType
);
3313 // ::com::sun::star::awt::XControl
3315 Reference
< XInterface
> FmXGridCell::getContext() throw( RuntimeException
, std::exception
)
3317 return Reference
< XInterface
> ();
3321 Reference
< ::com::sun::star::awt::XControlModel
> FmXGridCell::getModel() throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
3323 return Reference
< ::com::sun::star::awt::XControlModel
> (m_pColumn
->getModel(), UNO_QUERY
);
3326 // ::com::sun::star::form::XBoundControl
3328 sal_Bool
FmXGridCell::getLock() throw( RuntimeException
, std::exception
)
3330 return m_pColumn
->isLocked();
3334 void FmXGridCell::setLock(sal_Bool _bLock
) throw( RuntimeException
, std::exception
)
3336 if (getLock() == _bLock
)
3340 ::osl::MutexGuard
aGuard(m_aMutex
);
3341 m_pColumn
->setLock(_bLock
);
3346 void SAL_CALL
FmXGridCell::setPosSize( ::sal_Int32 _XX
, ::sal_Int32 _Y
, ::sal_Int32 _Width
, ::sal_Int32 _Height
, ::sal_Int16 _Flags
) throw (RuntimeException
, std::exception
)
3348 OSL_FAIL( "FmXGridCell::setPosSize: not implemented" );
3354 // not allowed to tamper with this for a grid cell
3358 awt::Rectangle SAL_CALL
FmXGridCell::getPosSize( ) throw (RuntimeException
, std::exception
)
3360 OSL_FAIL( "FmXGridCell::getPosSize: not implemented" );
3361 return awt::Rectangle();
3365 void SAL_CALL
FmXGridCell::setVisible( sal_Bool _Visible
) throw (RuntimeException
, std::exception
)
3367 OSL_FAIL( "FmXGridCell::setVisible: not implemented" );
3369 // not allowed to tamper with this for a grid cell
3373 void SAL_CALL
FmXGridCell::setEnable( sal_Bool _Enable
) throw (RuntimeException
, std::exception
)
3375 OSL_FAIL( "FmXGridCell::setEnable: not implemented" );
3377 // not allowed to tamper with this for a grid cell
3381 void SAL_CALL
FmXGridCell::setFocus( ) throw (RuntimeException
, std::exception
)
3383 OSL_FAIL( "FmXGridCell::setFocus: not implemented" );
3384 // not allowed to tamper with this for a grid cell
3388 void SAL_CALL
FmXGridCell::addWindowListener( const Reference
< awt::XWindowListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3390 m_aWindowListeners
.addInterface( _rxListener
);
3394 void SAL_CALL
FmXGridCell::removeWindowListener( const Reference
< awt::XWindowListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3396 m_aWindowListeners
.removeInterface( _rxListener
);
3400 void SAL_CALL
FmXGridCell::addFocusListener( const Reference
< awt::XFocusListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3402 m_aFocusListeners
.addInterface( _rxListener
);
3406 void SAL_CALL
FmXGridCell::removeFocusListener( const Reference
< awt::XFocusListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3408 m_aFocusListeners
.removeInterface( _rxListener
);
3412 void SAL_CALL
FmXGridCell::addKeyListener( const Reference
< awt::XKeyListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3414 m_aKeyListeners
.addInterface( _rxListener
);
3418 void SAL_CALL
FmXGridCell::removeKeyListener( const Reference
< awt::XKeyListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3420 m_aKeyListeners
.removeInterface( _rxListener
);
3424 void SAL_CALL
FmXGridCell::addMouseListener( const Reference
< awt::XMouseListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3426 m_aMouseListeners
.addInterface( _rxListener
);
3430 void SAL_CALL
FmXGridCell::removeMouseListener( const Reference
< awt::XMouseListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3432 m_aMouseListeners
.removeInterface( _rxListener
);
3436 void SAL_CALL
FmXGridCell::addMouseMotionListener( const Reference
< awt::XMouseMotionListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3438 m_aMouseMotionListeners
.addInterface( _rxListener
);
3442 void SAL_CALL
FmXGridCell::removeMouseMotionListener( const Reference
< awt::XMouseMotionListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3444 m_aMouseMotionListeners
.removeInterface( _rxListener
);
3448 void SAL_CALL
FmXGridCell::addPaintListener( const Reference
< awt::XPaintListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3450 OSL_FAIL( "FmXGridCell::addPaintListener: not implemented" );
3455 void SAL_CALL
FmXGridCell::removePaintListener( const Reference
< awt::XPaintListener
>& _rxListener
) throw (RuntimeException
, std::exception
)
3457 OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
3462 IMPL_LINK( FmXGridCell
, OnWindowEvent
, VclWindowEvent
*, _pEvent
)
3464 ENSURE_OR_THROW( _pEvent
, "illegal event pointer" );
3465 ENSURE_OR_THROW( _pEvent
->GetWindow(), "illegal window" );
3466 onWindowEvent( _pEvent
->GetId(), *_pEvent
->GetWindow(), _pEvent
->GetData() );
3471 void FmXGridCell::onFocusGained( const awt::FocusEvent
& _rEvent
)
3473 m_aFocusListeners
.notifyEach( &awt::XFocusListener::focusGained
, _rEvent
);
3477 void FmXGridCell::onFocusLost( const awt::FocusEvent
& _rEvent
)
3479 m_aFocusListeners
.notifyEach( &awt::XFocusListener::focusLost
, _rEvent
);
3483 void FmXGridCell::onWindowEvent( const sal_uIntPtr _nEventId
, const Window
& _rWindow
, const void* _pEventData
)
3485 switch ( _nEventId
)
3487 case VCLEVENT_CONTROL_GETFOCUS
:
3488 case VCLEVENT_WINDOW_GETFOCUS
:
3489 case VCLEVENT_CONTROL_LOSEFOCUS
:
3490 case VCLEVENT_WINDOW_LOSEFOCUS
:
3492 if ( ( _rWindow
.IsCompoundControl()
3493 && ( _nEventId
== VCLEVENT_CONTROL_GETFOCUS
3494 || _nEventId
== VCLEVENT_CONTROL_LOSEFOCUS
3497 || ( !_rWindow
.IsCompoundControl()
3498 && ( _nEventId
== VCLEVENT_WINDOW_GETFOCUS
3499 || _nEventId
== VCLEVENT_WINDOW_LOSEFOCUS
3504 if ( !m_aFocusListeners
.getLength() )
3507 bool bFocusGained
= ( _nEventId
== VCLEVENT_CONTROL_GETFOCUS
) || ( _nEventId
== VCLEVENT_WINDOW_GETFOCUS
);
3509 awt::FocusEvent aEvent
;
3510 aEvent
.Source
= *this;
3511 aEvent
.FocusFlags
= _rWindow
.GetGetFocusFlags();
3512 aEvent
.Temporary
= sal_False
;
3515 onFocusGained( aEvent
);
3517 onFocusLost( aEvent
);
3521 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN
:
3522 case VCLEVENT_WINDOW_MOUSEBUTTONUP
:
3524 if ( !m_aMouseListeners
.getLength() )
3527 const bool bButtonDown
= ( _nEventId
== VCLEVENT_WINDOW_MOUSEBUTTONDOWN
);
3529 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent
* >( _pEventData
), *this ) );
3530 m_aMouseListeners
.notifyEach( bButtonDown
? &awt::XMouseListener::mousePressed
: &awt::XMouseListener::mouseReleased
, aEvent
);
3533 case VCLEVENT_WINDOW_MOUSEMOVE
:
3535 const MouseEvent
& rMouseEvent
= *static_cast< const ::MouseEvent
* >( _pEventData
);
3536 if ( rMouseEvent
.IsEnterWindow() || rMouseEvent
.IsLeaveWindow() )
3538 if ( m_aMouseListeners
.getLength() != 0 )
3540 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent
, *this ) );
3541 m_aMouseListeners
.notifyEach( rMouseEvent
.IsEnterWindow() ? &awt::XMouseListener::mouseEntered
: &awt::XMouseListener::mouseExited
, aEvent
);
3544 else if ( !rMouseEvent
.IsEnterWindow() && !rMouseEvent
.IsLeaveWindow() )
3546 if ( m_aMouseMotionListeners
.getLength() != 0 )
3548 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent
, *this ) );
3549 aEvent
.ClickCount
= 0;
3550 const bool bSimpleMove
= ( ( rMouseEvent
.GetMode() & MOUSE_SIMPLEMOVE
) != 0 );
3551 m_aMouseMotionListeners
.notifyEach( bSimpleMove
? &awt::XMouseMotionListener::mouseMoved
: &awt::XMouseMotionListener::mouseDragged
, aEvent
);
3556 case VCLEVENT_WINDOW_KEYINPUT
:
3557 case VCLEVENT_WINDOW_KEYUP
:
3559 if ( !m_aKeyListeners
.getLength() )
3562 const bool bKeyPressed
= ( _nEventId
== VCLEVENT_WINDOW_KEYINPUT
);
3563 awt::KeyEvent
aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent
* >( _pEventData
), *this ) );
3564 m_aKeyListeners
.notifyEach( bKeyPressed
? &awt::XKeyListener::keyPressed
: &awt::XKeyListener::keyReleased
, aEvent
);
3570 /*************************************************************************/
3571 TYPEINIT1(FmXDataCell
, FmXGridCell
);
3573 void FmXDataCell::PaintFieldToCell(OutputDevice
& rDev
, const Rectangle
& rRect
,
3574 const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
,
3575 const Reference
< XNumberFormatter
>& xFormatter
)
3577 m_pCellControl
->PaintFieldToCell( rDev
, rRect
, _rxField
, xFormatter
);
3581 void FmXDataCell::UpdateFromColumn()
3583 Reference
< ::com::sun::star::sdb::XColumn
> xField(m_pColumn
->GetCurrentFieldValue());
3585 m_pCellControl
->UpdateFromField(xField
, m_pColumn
->GetParent().getNumberFormatter());
3588 /*************************************************************************/
3589 TYPEINIT1(FmXTextCell
, FmXDataCell
);
3591 FmXTextCell::FmXTextCell( DbGridColumn
* pColumn
, DbCellControl
& _rControl
)
3592 :FmXDataCell( pColumn
, _rControl
)
3593 ,m_bFastPaint( true )
3598 void FmXTextCell::PaintFieldToCell(OutputDevice
& rDev
,
3599 const Rectangle
& rRect
,
3600 const Reference
< ::com::sun::star::sdb::XColumn
>& _rxField
,
3601 const Reference
< XNumberFormatter
>& xFormatter
)
3603 if ( !m_bFastPaint
)
3605 FmXDataCell::PaintFieldToCell( rDev
, rRect
, _rxField
, xFormatter
);
3609 sal_uInt16 nStyle
= TEXT_DRAW_CLIP
| TEXT_DRAW_VCENTER
;
3610 if ( ( rDev
.GetOutDevType() == OUTDEV_WINDOW
) && !static_cast< Window
& >( rDev
).IsEnabled() )
3611 nStyle
|= TEXT_DRAW_DISABLE
;
3613 switch (m_pColumn
->GetAlignment())
3615 case ::com::sun::star::awt::TextAlign::RIGHT
:
3616 nStyle
|= TEXT_DRAW_RIGHT
;
3618 case ::com::sun::star::awt::TextAlign::CENTER
:
3619 nStyle
|= TEXT_DRAW_CENTER
;
3622 nStyle
|= TEXT_DRAW_LEFT
;
3625 Color
* pColor
= NULL
;
3626 OUString aText
= GetText(_rxField
, xFormatter
, &pColor
);
3629 Color
aOldTextColor( rDev
.GetTextColor() );
3630 rDev
.SetTextColor( *pColor
);
3631 rDev
.DrawText(rRect
, aText
, nStyle
);
3632 rDev
.SetTextColor( aOldTextColor
);
3635 rDev
.DrawText(rRect
, aText
, nStyle
);
3639 /*************************************************************************/
3642 FmXEditCell::FmXEditCell( DbGridColumn
* pColumn
, DbCellControl
& _rControl
)
3643 :FmXTextCell( pColumn
, _rControl
)
3644 ,m_aTextListeners(m_aMutex
)
3645 ,m_aChangeListeners( m_aMutex
)
3646 ,m_pEditImplementation( NULL
)
3647 ,m_bOwnEditImplementation( false )
3650 DbTextField
* pTextField
= PTR_CAST( DbTextField
, &_rControl
);
3654 m_pEditImplementation
= pTextField
->GetEditImplementation();
3655 if ( !pTextField
->IsSimpleEdit() )
3656 m_bFastPaint
= false;
3660 m_pEditImplementation
= new EditImplementation( static_cast< Edit
& >( _rControl
.GetWindow() ) );
3661 m_bOwnEditImplementation
= true;
3666 FmXEditCell::~FmXEditCell()
3668 if (!OComponentHelper::rBHelper
.bDisposed
)
3679 void FmXEditCell::disposing()
3681 ::com::sun::star::lang::EventObject
aEvt(*this);
3682 m_aTextListeners
.disposeAndClear(aEvt
);
3683 m_aChangeListeners
.disposeAndClear(aEvt
);
3685 m_pEditImplementation
->SetModifyHdl( Link() );
3686 if ( m_bOwnEditImplementation
)
3687 delete m_pEditImplementation
;
3688 m_pEditImplementation
= NULL
;
3690 FmXDataCell::disposing();
3694 Any SAL_CALL
FmXEditCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
3696 Any aReturn
= FmXTextCell::queryAggregation( _rType
);
3698 if ( !aReturn
.hasValue() )
3699 aReturn
= FmXEditCell_Base::queryInterface( _rType
);
3705 Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
FmXEditCell::getTypes( ) throw(RuntimeException
, std::exception
)
3707 return ::comphelper::concatSequences(
3708 FmXTextCell::getTypes(),
3709 FmXEditCell_Base::getTypes()
3714 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXEditCell
)
3716 // ::com::sun::star::awt::XTextComponent
3718 void SAL_CALL
FmXEditCell::addTextListener(const Reference
< ::com::sun::star::awt::XTextListener
>& l
) throw( RuntimeException
, std::exception
)
3720 m_aTextListeners
.addInterface( l
);
3724 void SAL_CALL
FmXEditCell::removeTextListener(const Reference
< ::com::sun::star::awt::XTextListener
>& l
) throw( RuntimeException
, std::exception
)
3726 m_aTextListeners
.removeInterface( l
);
3730 void SAL_CALL
FmXEditCell::setText( const OUString
& aText
) throw( RuntimeException
, std::exception
)
3732 ::osl::MutexGuard
aGuard( m_aMutex
);
3734 if ( m_pEditImplementation
)
3736 m_pEditImplementation
->SetText( aText
);
3738 // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht.
3739 // ::com::sun::star::awt::Toolkit soll JAVA-komform sein...
3745 void SAL_CALL
FmXEditCell::insertText(const ::com::sun::star::awt::Selection
& rSel
, const OUString
& aText
) throw(RuntimeException
, std::exception
)
3747 ::osl::MutexGuard
aGuard( m_aMutex
);
3749 if ( m_pEditImplementation
)
3751 m_pEditImplementation
->SetSelection( Selection( rSel
.Min
, rSel
.Max
) );
3752 m_pEditImplementation
->ReplaceSelected( aText
);
3757 OUString SAL_CALL
FmXEditCell::getText() throw( RuntimeException
, std::exception
)
3759 ::osl::MutexGuard
aGuard( m_aMutex
);
3762 if ( m_pEditImplementation
)
3764 if ( m_pEditImplementation
->GetControl().IsVisible() && m_pColumn
->GetParent().getDisplaySynchron())
3766 // if the display isn't sync with the cursor we can't ask the edit field
3767 LineEnd eLineEndFormat
= getModelLineEndSetting( m_pColumn
->getModel() );
3768 aText
= m_pEditImplementation
->GetText( eLineEndFormat
);
3772 Reference
< ::com::sun::star::sdb::XColumn
> xField(m_pColumn
->GetCurrentFieldValue());
3774 aText
= GetText(xField
, m_pColumn
->GetParent().getNumberFormatter());
3781 OUString SAL_CALL
FmXEditCell::getSelectedText( void ) throw( RuntimeException
, std::exception
)
3783 ::osl::MutexGuard
aGuard( m_aMutex
);
3786 if ( m_pEditImplementation
)
3788 LineEnd eLineEndFormat
= m_pColumn
? getModelLineEndSetting( m_pColumn
->getModel() ) : LINEEND_LF
;
3789 aText
= m_pEditImplementation
->GetSelected( eLineEndFormat
);
3795 void SAL_CALL
FmXEditCell::setSelection( const ::com::sun::star::awt::Selection
& aSelection
) throw( RuntimeException
, std::exception
)
3797 ::osl::MutexGuard
aGuard( m_aMutex
);
3799 if ( m_pEditImplementation
)
3800 m_pEditImplementation
->SetSelection( Selection( aSelection
.Min
, aSelection
.Max
) );
3804 ::com::sun::star::awt::Selection SAL_CALL
FmXEditCell::getSelection( void ) throw( RuntimeException
, std::exception
)
3806 ::osl::MutexGuard
aGuard( m_aMutex
);
3809 if ( m_pEditImplementation
)
3810 aSel
= m_pEditImplementation
->GetSelection();
3812 return ::com::sun::star::awt::Selection(aSel
.Min(), aSel
.Max());
3816 sal_Bool SAL_CALL
FmXEditCell::isEditable( void ) throw( RuntimeException
, std::exception
)
3818 ::osl::MutexGuard
aGuard( m_aMutex
);
3820 return ( m_pEditImplementation
&& !m_pEditImplementation
->IsReadOnly() && m_pEditImplementation
->GetControl().IsEnabled() ) ? sal_True
: sal_False
;
3824 void SAL_CALL
FmXEditCell::setEditable( sal_Bool bEditable
) throw( RuntimeException
, std::exception
)
3826 ::osl::MutexGuard
aGuard( m_aMutex
);
3828 if ( m_pEditImplementation
)
3829 m_pEditImplementation
->SetReadOnly( !bEditable
);
3833 sal_Int16 SAL_CALL
FmXEditCell::getMaxTextLen() throw( RuntimeException
, std::exception
)
3835 ::osl::MutexGuard
aGuard( m_aMutex
);
3837 return m_pEditImplementation
? m_pEditImplementation
->GetMaxTextLen() : 0;
3841 void SAL_CALL
FmXEditCell::setMaxTextLen( sal_Int16 nLen
) throw( RuntimeException
, std::exception
)
3843 ::osl::MutexGuard
aGuard( m_aMutex
);
3845 if ( m_pEditImplementation
)
3846 m_pEditImplementation
->SetMaxTextLen( nLen
);
3850 void SAL_CALL
FmXEditCell::addChangeListener( const Reference
< form::XChangeListener
>& _Listener
) throw (RuntimeException
, std::exception
)
3852 m_aChangeListeners
.addInterface( _Listener
);
3856 void SAL_CALL
FmXEditCell::removeChangeListener( const Reference
< form::XChangeListener
>& _Listener
) throw (RuntimeException
, std::exception
)
3858 m_aChangeListeners
.removeInterface( _Listener
);
3862 void FmXEditCell::onTextChanged()
3864 ::com::sun::star::awt::TextEvent aEvent
;
3865 aEvent
.Source
= *this;
3866 m_aTextListeners
.notifyEach( &awt::XTextListener::textChanged
, aEvent
);
3870 void FmXEditCell::onFocusGained( const awt::FocusEvent
& _rEvent
)
3872 FmXTextCell::onFocusGained( _rEvent
);
3873 m_sValueOnEnter
= getText();
3877 void FmXEditCell::onFocusLost( const awt::FocusEvent
& _rEvent
)
3879 FmXTextCell::onFocusLost( _rEvent
);
3881 if ( getText() != m_sValueOnEnter
)
3883 lang::EventObject
aEvent( *this );
3884 m_aChangeListeners
.notifyEach( &XChangeListener::changed
, aEvent
);
3889 void FmXEditCell::onWindowEvent( const sal_uIntPtr _nEventId
, const Window
& _rWindow
, const void* _pEventData
)
3891 switch ( _nEventId
)
3893 case VCLEVENT_EDIT_MODIFY
:
3895 if ( m_pEditImplementation
&& m_aTextListeners
.getLength() )
3901 FmXTextCell::onWindowEvent( _nEventId
, _rWindow
, _pEventData
);
3904 /*************************************************************************/
3906 FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn
* pColumn
, DbCellControl
& _rControl
)
3907 :FmXDataCell( pColumn
, _rControl
)
3908 ,m_aItemListeners(m_aMutex
)
3909 ,m_aActionListeners( m_aMutex
)
3910 ,m_pBox( & static_cast< CheckBoxControl
& >( _rControl
.GetWindow() ).GetBox() )
3915 FmXCheckBoxCell::~FmXCheckBoxCell()
3917 if (!OComponentHelper::rBHelper
.bDisposed
)
3927 void FmXCheckBoxCell::disposing()
3929 ::com::sun::star::lang::EventObject
aEvt(*this);
3930 m_aItemListeners
.disposeAndClear(aEvt
);
3931 m_aActionListeners
.disposeAndClear(aEvt
);
3933 static_cast< CheckBoxControl
& >( m_pCellControl
->GetWindow() ).SetClickHdl(Link());
3936 FmXDataCell::disposing();
3940 Any SAL_CALL
FmXCheckBoxCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
3942 Any aReturn
= FmXDataCell::queryAggregation( _rType
);
3944 if ( !aReturn
.hasValue() )
3945 aReturn
= FmXCheckBoxCell_Base::queryInterface( _rType
);
3951 Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
FmXCheckBoxCell::getTypes( ) throw(RuntimeException
, std::exception
)
3953 return ::comphelper::concatSequences(
3954 FmXDataCell::getTypes(),
3955 FmXCheckBoxCell_Base::getTypes()
3960 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXCheckBoxCell
)
3963 void SAL_CALL
FmXCheckBoxCell::addItemListener( const Reference
< ::com::sun::star::awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
3965 m_aItemListeners
.addInterface( l
);
3969 void SAL_CALL
FmXCheckBoxCell::removeItemListener( const Reference
< ::com::sun::star::awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
3971 m_aItemListeners
.removeInterface( l
);
3975 void SAL_CALL
FmXCheckBoxCell::setState( short n
) throw( RuntimeException
, std::exception
)
3977 ::osl::MutexGuard
aGuard( m_aMutex
);
3982 m_pBox
->SetState( (TriState
)n
);
3987 short SAL_CALL
FmXCheckBoxCell::getState() throw( RuntimeException
, std::exception
)
3989 ::osl::MutexGuard
aGuard( m_aMutex
);
3994 return (short)m_pBox
->GetState();
3996 return TRISTATE_INDET
;
4000 void SAL_CALL
FmXCheckBoxCell::enableTriState( sal_Bool b
) throw( RuntimeException
, std::exception
)
4002 ::osl::MutexGuard
aGuard( m_aMutex
);
4005 m_pBox
->EnableTriState( b
);
4009 void SAL_CALL
FmXCheckBoxCell::addActionListener( const Reference
< awt::XActionListener
>& _Listener
) throw (RuntimeException
, std::exception
)
4011 m_aActionListeners
.addInterface( _Listener
);
4015 void SAL_CALL
FmXCheckBoxCell::removeActionListener( const Reference
< awt::XActionListener
>& _Listener
) throw (RuntimeException
, std::exception
)
4017 m_aActionListeners
.removeInterface( _Listener
);
4021 void SAL_CALL
FmXCheckBoxCell::setLabel( const OUString
& _Label
) throw (RuntimeException
, std::exception
)
4023 SolarMutexGuard aGuard
;
4026 DbGridControl
& rGrid( m_pColumn
->GetParent() );
4027 rGrid
.SetColumnTitle( rGrid
.GetColumnId( m_pColumn
->GetFieldPos() ), _Label
);
4032 void SAL_CALL
FmXCheckBoxCell::setActionCommand( const OUString
& _Command
) throw (RuntimeException
, std::exception
)
4034 m_aActionCommand
= _Command
;
4038 Window
* FmXCheckBoxCell::getEventWindow() const
4044 void FmXCheckBoxCell::onWindowEvent( const sal_uIntPtr _nEventId
, const Window
& _rWindow
, const void* _pEventData
)
4046 switch ( _nEventId
)
4048 case VCLEVENT_CHECKBOX_TOGGLE
:
4050 // check boxes are to be committed immediately (this holds for ordinary check box controls in
4051 // documents, and this must hold for check boxes in grid columns, too
4052 // 91210 - 22.08.2001 - frank.schoenheit@sun.com
4053 m_pCellControl
->Commit();
4055 Reference
< XWindow
> xKeepAlive( this );
4056 if ( m_aItemListeners
.getLength() && m_pBox
)
4058 awt::ItemEvent aEvent
;
4059 aEvent
.Source
= *this;
4060 aEvent
.Highlighted
= sal_False
;
4061 aEvent
.Selected
= m_pBox
->GetState();
4062 m_aItemListeners
.notifyEach( &awt::XItemListener::itemStateChanged
, aEvent
);
4064 if ( m_aActionListeners
.getLength() )
4066 awt::ActionEvent aEvent
;
4067 aEvent
.Source
= *this;
4068 aEvent
.ActionCommand
= m_aActionCommand
;
4069 m_aActionListeners
.notifyEach( &awt::XActionListener::actionPerformed
, aEvent
);
4075 FmXDataCell::onWindowEvent( _nEventId
, _rWindow
, _pEventData
);
4080 /*************************************************************************/
4083 FmXListBoxCell::FmXListBoxCell(DbGridColumn
* pColumn
, DbCellControl
& _rControl
)
4084 :FmXTextCell( pColumn
, _rControl
)
4085 ,m_aItemListeners(m_aMutex
)
4086 ,m_aActionListeners(m_aMutex
)
4087 ,m_pBox( &static_cast< ListBox
& >( _rControl
.GetWindow() ) )
4090 m_pBox
->SetDoubleClickHdl( LINK( this, FmXListBoxCell
, OnDoubleClick
) );
4094 FmXListBoxCell::~FmXListBoxCell()
4096 if (!OComponentHelper::rBHelper
.bDisposed
)
4106 void FmXListBoxCell::disposing()
4108 ::com::sun::star::lang::EventObject
aEvt(*this);
4109 m_aItemListeners
.disposeAndClear(aEvt
);
4110 m_aActionListeners
.disposeAndClear(aEvt
);
4112 m_pBox
->SetSelectHdl( Link() );
4113 m_pBox
->SetDoubleClickHdl( Link() );
4116 FmXTextCell::disposing();
4120 Any SAL_CALL
FmXListBoxCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
4122 Any aReturn
= FmXTextCell::queryAggregation(_rType
);
4124 if ( !aReturn
.hasValue() )
4125 aReturn
= FmXListBoxCell_Base::queryInterface( _rType
);
4131 Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
FmXListBoxCell::getTypes( ) throw(RuntimeException
, std::exception
)
4133 return ::comphelper::concatSequences(
4134 FmXTextCell::getTypes(),
4135 FmXListBoxCell_Base::getTypes()
4140 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell
)
4143 void SAL_CALL
FmXListBoxCell::addItemListener(const Reference
< ::com::sun::star::awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
4145 m_aItemListeners
.addInterface( l
);
4149 void SAL_CALL
FmXListBoxCell::removeItemListener(const Reference
< ::com::sun::star::awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
4151 m_aItemListeners
.removeInterface( l
);
4155 void SAL_CALL
FmXListBoxCell::addActionListener(const Reference
< ::com::sun::star::awt::XActionListener
>& l
) throw( RuntimeException
, std::exception
)
4157 m_aActionListeners
.addInterface( l
);
4161 void SAL_CALL
FmXListBoxCell::removeActionListener(const Reference
< ::com::sun::star::awt::XActionListener
>& l
) throw( RuntimeException
, std::exception
)
4163 m_aActionListeners
.removeInterface( l
);
4167 void SAL_CALL
FmXListBoxCell::addItem(const OUString
& aItem
, sal_Int16 nPos
) throw( RuntimeException
, std::exception
)
4169 ::osl::MutexGuard
aGuard( m_aMutex
);
4171 m_pBox
->InsertEntry( aItem
, nPos
);
4175 void SAL_CALL
FmXListBoxCell::addItems(const ::comphelper::StringSequence
& aItems
, sal_Int16 nPos
) throw( RuntimeException
, std::exception
)
4177 ::osl::MutexGuard
aGuard( m_aMutex
);
4180 sal_uInt16 nP
= nPos
;
4181 for ( sal_uInt16 n
= 0; n
< aItems
.getLength(); n
++ )
4183 m_pBox
->InsertEntry( aItems
.getConstArray()[n
], nP
);
4184 if ( nPos
!= -1 ) // Nicht wenn 0xFFFF, weil LIST_APPEND
4191 void SAL_CALL
FmXListBoxCell::removeItems(sal_Int16 nPos
, sal_Int16 nCount
) throw( RuntimeException
, std::exception
)
4193 ::osl::MutexGuard
aGuard( m_aMutex
);
4196 for ( sal_uInt16 n
= nCount
; n
; )
4197 m_pBox
->RemoveEntry( nPos
+ (--n
) );
4202 sal_Int16 SAL_CALL
FmXListBoxCell::getItemCount() throw( RuntimeException
, std::exception
)
4204 ::osl::MutexGuard
aGuard( m_aMutex
);
4205 return m_pBox
? m_pBox
->GetEntryCount() : 0;
4209 OUString SAL_CALL
FmXListBoxCell::getItem(sal_Int16 nPos
) throw( RuntimeException
, std::exception
)
4211 ::osl::MutexGuard
aGuard( m_aMutex
);
4212 return m_pBox
? OUString(m_pBox
->GetEntry(nPos
)) : OUString();
4215 ::comphelper::StringSequence SAL_CALL
FmXListBoxCell::getItems() throw( RuntimeException
, std::exception
)
4217 ::osl::MutexGuard
aGuard( m_aMutex
);
4219 ::comphelper::StringSequence aSeq
;
4222 sal_uInt16 nEntries
= m_pBox
->GetEntryCount();
4223 aSeq
= ::comphelper::StringSequence( nEntries
);
4224 for ( sal_uInt16 n
= nEntries
; n
; )
4227 aSeq
.getArray()[n
] = m_pBox
->GetEntry( n
);
4234 sal_Int16 SAL_CALL
FmXListBoxCell::getSelectedItemPos() throw( RuntimeException
, std::exception
)
4236 ::osl::MutexGuard
aGuard( m_aMutex
);
4240 return m_pBox
->GetSelectEntryPos();
4246 Sequence
< sal_Int16
> SAL_CALL
FmXListBoxCell::getSelectedItemsPos() throw( RuntimeException
, std::exception
)
4248 ::osl::MutexGuard
aGuard( m_aMutex
);
4249 Sequence
<sal_Int16
> aSeq
;
4254 sal_uInt16 nSelEntries
= m_pBox
->GetSelectEntryCount();
4255 aSeq
= Sequence
<sal_Int16
>( nSelEntries
);
4256 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
4257 aSeq
.getArray()[n
] = m_pBox
->GetSelectEntryPos( n
);
4262 OUString SAL_CALL
FmXListBoxCell::getSelectedItem() throw( RuntimeException
, std::exception
)
4264 ::osl::MutexGuard
aGuard( m_aMutex
);
4271 aItem
= m_pBox
->GetSelectEntry();
4278 ::comphelper::StringSequence SAL_CALL
FmXListBoxCell::getSelectedItems() throw( RuntimeException
, std::exception
)
4280 ::osl::MutexGuard
aGuard( m_aMutex
);
4282 ::comphelper::StringSequence aSeq
;
4287 sal_uInt16 nSelEntries
= m_pBox
->GetSelectEntryCount();
4288 aSeq
= ::comphelper::StringSequence( nSelEntries
);
4289 for ( sal_uInt16 n
= 0; n
< nSelEntries
; n
++ )
4290 aSeq
.getArray()[n
] = m_pBox
->GetSelectEntry( n
);
4296 void SAL_CALL
FmXListBoxCell::selectItemPos(sal_Int16 nPos
, sal_Bool bSelect
) throw( RuntimeException
, std::exception
)
4298 ::osl::MutexGuard
aGuard( m_aMutex
);
4301 m_pBox
->SelectEntryPos( nPos
, bSelect
);
4305 void SAL_CALL
FmXListBoxCell::selectItemsPos(const Sequence
< sal_Int16
>& aPositions
, sal_Bool bSelect
) throw( RuntimeException
, std::exception
)
4307 ::osl::MutexGuard
aGuard( m_aMutex
);
4311 for ( sal_uInt16 n
= (sal_uInt16
)aPositions
.getLength(); n
; )
4312 m_pBox
->SelectEntryPos( (sal_uInt16
) aPositions
.getConstArray()[--n
], bSelect
);
4317 void SAL_CALL
FmXListBoxCell::selectItem(const OUString
& aItem
, sal_Bool bSelect
) throw( RuntimeException
, std::exception
)
4319 ::osl::MutexGuard
aGuard( m_aMutex
);
4322 m_pBox
->SelectEntry( aItem
, bSelect
);
4326 sal_Bool SAL_CALL
FmXListBoxCell::isMutipleMode() throw( RuntimeException
, std::exception
)
4328 ::osl::MutexGuard
aGuard( m_aMutex
);
4330 bool bMulti
= false;
4332 bMulti
= m_pBox
->IsMultiSelectionEnabled();
4337 void SAL_CALL
FmXListBoxCell::setMultipleMode(sal_Bool bMulti
) throw( RuntimeException
, std::exception
)
4339 ::osl::MutexGuard
aGuard( m_aMutex
);
4342 m_pBox
->EnableMultiSelection( bMulti
);
4346 sal_Int16 SAL_CALL
FmXListBoxCell::getDropDownLineCount() throw( RuntimeException
, std::exception
)
4348 ::osl::MutexGuard
aGuard( m_aMutex
);
4350 sal_Int16 nLines
= 0;
4352 nLines
= m_pBox
->GetDropDownLineCount();
4358 void SAL_CALL
FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines
) throw( RuntimeException
, std::exception
)
4360 ::osl::MutexGuard
aGuard( m_aMutex
);
4363 m_pBox
->SetDropDownLineCount( nLines
);
4367 void SAL_CALL
FmXListBoxCell::makeVisible(sal_Int16 nEntry
) throw( RuntimeException
, std::exception
)
4369 ::osl::MutexGuard
aGuard( m_aMutex
);
4372 m_pBox
->SetTopEntry( nEntry
);
4376 void FmXListBoxCell::onWindowEvent( const sal_uIntPtr _nEventId
, const Window
& _rWindow
, const void* _pEventData
)
4378 if ( ( &_rWindow
== m_pBox
)
4379 && ( _nEventId
== VCLEVENT_LISTBOX_SELECT
)
4382 OnDoubleClick( NULL
);
4384 ::com::sun::star::awt::ItemEvent aEvent
;
4385 aEvent
.Source
= *this;
4386 aEvent
.Highlighted
= sal_False
;
4388 // Bei Mehrfachselektion 0xFFFF, sonst die ID
4389 aEvent
.Selected
= (m_pBox
->GetSelectEntryCount() == 1 )
4390 ? m_pBox
->GetSelectEntryPos() : 0xFFFF;
4392 m_aItemListeners
.notifyEach( &awt::XItemListener::itemStateChanged
, aEvent
);
4396 FmXTextCell::onWindowEvent( _nEventId
, _rWindow
, _pEventData
);
4401 IMPL_LINK_NOARG(FmXListBoxCell
, OnDoubleClick
)
4405 ::cppu::OInterfaceIteratorHelper
aIt( m_aActionListeners
);
4407 ::com::sun::star::awt::ActionEvent aEvent
;
4408 aEvent
.Source
= *this;
4409 aEvent
.ActionCommand
= m_pBox
->GetSelectEntry();
4411 while( aIt
.hasMoreElements() )
4412 ((::com::sun::star::awt::XActionListener
*)aIt
.next())->actionPerformed( aEvent
);
4418 /*************************************************************************/
4422 FmXComboBoxCell::FmXComboBoxCell( DbGridColumn
* pColumn
, DbCellControl
& _rControl
)
4423 :FmXTextCell( pColumn
, _rControl
)
4424 ,m_aItemListeners( m_aMutex
)
4425 ,m_aActionListeners( m_aMutex
)
4426 ,m_pComboBox( &static_cast< ComboBox
& >( _rControl
.GetWindow() ) )
4431 FmXComboBoxCell::~FmXComboBoxCell()
4433 if ( !OComponentHelper::rBHelper
.bDisposed
)
4442 void FmXComboBoxCell::disposing()
4444 ::com::sun::star::lang::EventObject
aEvt(*this);
4445 m_aItemListeners
.disposeAndClear(aEvt
);
4446 m_aActionListeners
.disposeAndClear(aEvt
);
4448 FmXTextCell::disposing();
4452 Any SAL_CALL
FmXComboBoxCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
4454 Any aReturn
= FmXTextCell::queryAggregation(_rType
);
4456 if ( !aReturn
.hasValue() )
4457 aReturn
= FmXComboBoxCell_Base::queryInterface( _rType
);
4463 Sequence
< Type
> SAL_CALL
FmXComboBoxCell::getTypes( ) throw(RuntimeException
, std::exception
)
4465 return ::comphelper::concatSequences(
4466 FmXTextCell::getTypes(),
4467 FmXComboBoxCell_Base::getTypes()
4472 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXComboBoxCell
)
4475 void SAL_CALL
FmXComboBoxCell::addItemListener(const Reference
< awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
4477 m_aItemListeners
.addInterface( l
);
4481 void SAL_CALL
FmXComboBoxCell::removeItemListener(const Reference
< awt::XItemListener
>& l
) throw( RuntimeException
, std::exception
)
4483 m_aItemListeners
.removeInterface( l
);
4487 void SAL_CALL
FmXComboBoxCell::addActionListener(const Reference
< awt::XActionListener
>& l
) throw( RuntimeException
, std::exception
)
4489 m_aActionListeners
.addInterface( l
);
4493 void SAL_CALL
FmXComboBoxCell::removeActionListener(const Reference
< awt::XActionListener
>& l
) throw( RuntimeException
, std::exception
)
4495 m_aActionListeners
.removeInterface( l
);
4499 void SAL_CALL
FmXComboBoxCell::addItem( const OUString
& _Item
, sal_Int16 _Pos
) throw( RuntimeException
, std::exception
)
4501 ::osl::MutexGuard
aGuard( m_aMutex
);
4503 m_pComboBox
->InsertEntry( _Item
, _Pos
);
4507 void SAL_CALL
FmXComboBoxCell::addItems( const Sequence
< OUString
>& _Items
, sal_Int16 _Pos
) throw( RuntimeException
, std::exception
)
4509 ::osl::MutexGuard
aGuard( m_aMutex
);
4512 sal_uInt16 nP
= _Pos
;
4513 for ( sal_uInt16 n
= 0; n
< _Items
.getLength(); n
++ )
4515 m_pComboBox
->InsertEntry( _Items
.getConstArray()[n
], nP
);
4523 void SAL_CALL
FmXComboBoxCell::removeItems( sal_Int16 _Pos
, sal_Int16 _Count
) throw( RuntimeException
, std::exception
)
4525 ::osl::MutexGuard
aGuard( m_aMutex
);
4528 for ( sal_uInt16 n
= _Count
; n
; )
4529 m_pComboBox
->RemoveEntryAt( _Pos
+ (--n
) );
4534 sal_Int16 SAL_CALL
FmXComboBoxCell::getItemCount() throw( RuntimeException
, std::exception
)
4536 ::osl::MutexGuard
aGuard( m_aMutex
);
4537 return m_pComboBox
? m_pComboBox
->GetEntryCount() : 0;
4541 OUString SAL_CALL
FmXComboBoxCell::getItem( sal_Int16 _Pos
) throw( RuntimeException
, std::exception
)
4543 ::osl::MutexGuard
aGuard( m_aMutex
);
4544 return m_pComboBox
? OUString(m_pComboBox
->GetEntry(_Pos
)) : OUString();
4547 Sequence
< OUString
> SAL_CALL
FmXComboBoxCell::getItems() throw( RuntimeException
, std::exception
)
4549 ::osl::MutexGuard
aGuard( m_aMutex
);
4551 Sequence
< OUString
> aItems
;
4554 sal_uInt16 nEntries
= m_pComboBox
->GetEntryCount();
4555 aItems
.realloc( nEntries
);
4556 OUString
* pItem
= aItems
.getArray();
4557 for ( sal_uInt16 n
=0; n
<nEntries
; ++n
, ++pItem
)
4558 *pItem
= m_pComboBox
->GetEntry( n
);
4564 sal_Int16 SAL_CALL
FmXComboBoxCell::getDropDownLineCount() throw( RuntimeException
, std::exception
)
4566 ::osl::MutexGuard
aGuard( m_aMutex
);
4568 sal_Int16 nLines
= 0;
4570 nLines
= m_pComboBox
->GetDropDownLineCount();
4576 void SAL_CALL
FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines
) throw( RuntimeException
, std::exception
)
4578 ::osl::MutexGuard
aGuard( m_aMutex
);
4580 m_pComboBox
->SetDropDownLineCount( nLines
);
4584 void FmXComboBoxCell::onWindowEvent( const sal_uIntPtr _nEventId
, const Window
& _rWindow
, const void* _pEventData
)
4587 switch ( _nEventId
)
4589 case VCLEVENT_COMBOBOX_SELECT
:
4591 awt::ItemEvent aEvent
;
4592 aEvent
.Source
= *this;
4593 aEvent
.Highlighted
= sal_False
;
4595 // Bei Mehrfachselektion 0xFFFF, sonst die ID
4596 aEvent
.Selected
= ( m_pComboBox
->GetSelectEntryCount() == 1 )
4597 ? m_pComboBox
->GetSelectEntryPos()
4599 m_aItemListeners
.notifyEach( &awt::XItemListener::itemStateChanged
, aEvent
);
4604 FmXTextCell::onWindowEvent( _nEventId
, _rWindow
, _pEventData
);
4609 /*************************************************************************/
4610 TYPEINIT1(FmXFilterCell
, FmXGridCell
);
4612 FmXFilterCell::FmXFilterCell(DbGridColumn
* pColumn
, DbCellControl
* pControl
)
4613 :FmXGridCell( pColumn
, pControl
)
4614 ,m_aTextListeners(m_aMutex
)
4617 DBG_ASSERT( m_pCellControl
->ISA( DbFilterField
), "FmXFilterCell::FmXFilterCell: invalid cell control!" );
4618 static_cast< DbFilterField
* >( m_pCellControl
)->SetCommitHdl( LINK( this, FmXFilterCell
, OnCommit
) );
4622 FmXFilterCell::~FmXFilterCell()
4624 if (!OComponentHelper::rBHelper
.bDisposed
)
4634 sal_Int64 SAL_CALL
FmXFilterCell::getSomething( const Sequence
< sal_Int8
>& _rIdentifier
) throw(RuntimeException
, std::exception
)
4636 sal_Int64
nReturn(0);
4638 if ( (_rIdentifier
.getLength() == 16)
4639 && (0 == memcmp( getUnoTunnelId().getConstArray(), _rIdentifier
.getConstArray(), 16 ))
4642 nReturn
= reinterpret_cast<sal_Int64
>(this);
4650 class theFmXFilterCellUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theFmXFilterCellUnoTunnelId
> {};
4653 const Sequence
<sal_Int8
>& FmXFilterCell::getUnoTunnelId()
4655 return theFmXFilterCellUnoTunnelId::get().getSeq();
4659 void FmXFilterCell::PaintCell( OutputDevice
& rDev
, const Rectangle
& rRect
)
4661 static_cast< DbFilterField
* >( m_pCellControl
)->PaintCell( rDev
, rRect
);
4666 void FmXFilterCell::disposing()
4668 ::com::sun::star::lang::EventObject
aEvt(*this);
4669 m_aTextListeners
.disposeAndClear(aEvt
);
4671 ((DbFilterField
*)m_pCellControl
)->SetCommitHdl(Link());
4673 FmXGridCell::disposing();
4677 Any SAL_CALL
FmXFilterCell::queryAggregation( const ::com::sun::star::uno::Type
& _rType
) throw(RuntimeException
, std::exception
)
4679 Any aReturn
= FmXGridCell::queryAggregation(_rType
);
4681 if ( !aReturn
.hasValue() )
4682 aReturn
= FmXFilterCell_Base::queryInterface( _rType
);
4688 Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
FmXFilterCell::getTypes( ) throw(RuntimeException
, std::exception
)
4690 return ::comphelper::concatSequences(
4691 FmXGridCell::getTypes(),
4692 FmXFilterCell_Base::getTypes()
4697 IMPLEMENT_GET_IMPLEMENTATION_ID( FmXFilterCell
)
4699 // ::com::sun::star::awt::XTextComponent
4701 void SAL_CALL
FmXFilterCell::addTextListener(const Reference
< ::com::sun::star::awt::XTextListener
>& l
) throw( RuntimeException
, std::exception
)
4703 m_aTextListeners
.addInterface( l
);
4707 void SAL_CALL
FmXFilterCell::removeTextListener(const Reference
< ::com::sun::star::awt::XTextListener
>& l
) throw( RuntimeException
, std::exception
)
4709 m_aTextListeners
.removeInterface( l
);
4713 void SAL_CALL
FmXFilterCell::setText( const OUString
& aText
) throw( RuntimeException
, std::exception
)
4715 ::osl::MutexGuard
aGuard( m_aMutex
);
4716 ((DbFilterField
*)m_pCellControl
)->SetText(aText
);
4720 void SAL_CALL
FmXFilterCell::insertText( const ::com::sun::star::awt::Selection
& /*rSel*/, const OUString
& /*aText*/ ) throw( RuntimeException
, std::exception
)
4725 OUString SAL_CALL
FmXFilterCell::getText() throw( RuntimeException
, std::exception
)
4727 ::osl::MutexGuard
aGuard( m_aMutex
);
4728 return ((DbFilterField
*)m_pCellControl
)->GetText();
4732 OUString SAL_CALL
FmXFilterCell::getSelectedText( void ) throw( RuntimeException
, std::exception
)
4738 void SAL_CALL
FmXFilterCell::setSelection( const ::com::sun::star::awt::Selection
& /*aSelection*/ ) throw( RuntimeException
, std::exception
)
4743 ::com::sun::star::awt::Selection SAL_CALL
FmXFilterCell::getSelection( void ) throw( RuntimeException
, std::exception
)
4745 return ::com::sun::star::awt::Selection();
4749 sal_Bool SAL_CALL
FmXFilterCell::isEditable( void ) throw( RuntimeException
, std::exception
)
4755 void SAL_CALL
FmXFilterCell::setEditable( sal_Bool
/*bEditable*/ ) throw( RuntimeException
, std::exception
)
4760 sal_Int16 SAL_CALL
FmXFilterCell::getMaxTextLen() throw( RuntimeException
, std::exception
)
4766 void SAL_CALL
FmXFilterCell::setMaxTextLen( sal_Int16
/*nLen*/ ) throw( RuntimeException
, std::exception
)
4771 IMPL_LINK_NOARG(FmXFilterCell
, OnCommit
)
4773 ::cppu::OInterfaceIteratorHelper
aIt( m_aTextListeners
);
4774 ::com::sun::star::awt::TextEvent aEvt
;
4775 aEvt
.Source
= *this;
4776 while( aIt
.hasMoreElements() )
4777 ((::com::sun::star::awt::XTextListener
*)aIt
.next())->textChanged( aEvt
);
4781 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */