1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: standardcontrol.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "standardcontrol.hxx"
34 #include "pcrcommon.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/util/DateTime.hpp>
38 #include <com/sun/star/util/Date.hpp>
39 #include <com/sun/star/util/Time.hpp>
40 #include <com/sun/star/util/Color.hpp>
41 #include <com/sun/star/util/MeasureUnit.hpp>
42 #include <com/sun/star/inspection/PropertyControlType.hpp>
43 /** === end UNO includes === **/
44 #include <rtl/math.hxx>
45 #include <sfx2/objsh.hxx>
47 //==================================================================
48 // ugly dependencies for the OColorControl
49 #ifndef _SVX_SVXIDS_HRC
50 #include <svx/svxids.hrc>
52 #include <svx/drawitem.hxx>
54 //==================================================================
55 #include <vcl/floatwin.hxx>
56 #include <svtools/svmedit.hxx>
57 #include <svtools/colorcfg.hxx>
58 #include <svtools/syslocale.hxx>
59 #include <unotools/datetime.hxx>
60 #include <i18npool/mslangid.hxx>
61 #ifndef _SV_BUTTON_HXX
62 #include <vcl/button.hxx>
64 #include <vcl/svapp.hxx>
65 //==================================================================
69 #include <boost/bind.hpp>
71 //............................................................................
74 //............................................................................
76 using namespace ::com::sun::star
;
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::awt
;
79 using namespace ::com::sun::star::lang
;
80 using namespace ::com::sun::star::util
;
81 using namespace ::com::sun::star::beans
;
82 using namespace ::com::sun::star::inspection
;
84 //==================================================================
86 //==================================================================
87 //------------------------------------------------------------------
88 OTimeControl::OTimeControl( Window
* pParent
, WinBits nWinStyle
)
89 :OTimeControl_Base( PropertyControlType::TimeField
, pParent
, nWinStyle
)
91 getTypedControlWindow()->SetStrictFormat( sal_True
);
92 getTypedControlWindow()->SetFormat( TIMEF_SEC
);
93 getTypedControlWindow()->EnableEmptyFieldValue( sal_True
);
96 //------------------------------------------------------------------
97 void SAL_CALL
OTimeControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
100 if ( !( _rValue
>>= aUNOTime
) )
102 getTypedControlWindow()->SetText( String() );
103 getTypedControlWindow()->SetEmptyTime();
107 ::Time
aTime( aUNOTime
.Hours
, aUNOTime
.Minutes
, aUNOTime
.Seconds
, aUNOTime
.HundredthSeconds
);
108 getTypedControlWindow()->SetTime( aTime
);
112 //------------------------------------------------------------------
113 Any SAL_CALL
OTimeControl::getValue() throw (RuntimeException
)
116 if ( getTypedControlWindow()->GetText().Len()>0 )
118 ::Time
aTime( getTypedControlWindow()->GetTime() );
119 util::Time
aUNOTime( aTime
.Get100Sec(), aTime
.GetSec(), aTime
.GetMin(), aTime
.GetHour() );
120 aPropValue
<<= aUNOTime
;
125 //------------------------------------------------------------------
126 Type SAL_CALL
OTimeControl::getValueType() throw (RuntimeException
)
128 return ::getCppuType( static_cast< util::Time
* >( NULL
) );
131 //==================================================================
133 //==================================================================
134 //------------------------------------------------------------------
135 ODateControl::ODateControl( Window
* pParent
, WinBits nWinStyle
)
136 :ODateControl_Base( PropertyControlType::DateField
, pParent
, nWinStyle
| WB_DROPDOWN
)
138 WindowType
* pControlWindow
= getTypedControlWindow();
139 pControlWindow
->SetStrictFormat(sal_True
);
141 pControlWindow
->SetMin( ::Date( 1,1,1600 ) );
142 pControlWindow
->SetFirst( ::Date( 1,1,1600 ) );
143 pControlWindow
->SetLast( ::Date( 1, 1, 9999 ) );
144 pControlWindow
->SetMax( ::Date( 1, 1, 9999 ) );
146 pControlWindow
->SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY
);
147 pControlWindow
->EnableEmptyFieldValue( sal_True
);
150 //------------------------------------------------------------------
151 void SAL_CALL
ODateControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
154 if ( !( _rValue
>>= aUNODate
) )
156 getTypedControlWindow()->SetText( String() );
157 getTypedControlWindow()->SetEmptyDate();
161 ::Date
aDate( aUNODate
.Day
, aUNODate
.Month
, aUNODate
.Year
);
162 getTypedControlWindow()->SetDate( aDate
);
166 //------------------------------------------------------------------
167 Any SAL_CALL
ODateControl::getValue() throw (RuntimeException
)
170 if ( getTypedControlWindow()->GetText().Len() > 0 )
172 ::Date
aDate( getTypedControlWindow()->GetDate() );
173 util::Date
aUNODate( aDate
.GetDay(), aDate
.GetMonth(), aDate
.GetYear() );
174 aPropValue
<<= aUNODate
;
179 //------------------------------------------------------------------
180 Type SAL_CALL
ODateControl::getValueType() throw (RuntimeException
)
182 return ::getCppuType( static_cast< util::Date
* >( NULL
) );
185 //==================================================================
187 //==================================================================
188 //------------------------------------------------------------------
189 OEditControl::OEditControl(Window
* _pParent
, sal_Bool _bPW
, WinBits _nWinStyle
)
190 :OEditControl_Base( _bPW
? PropertyControlType::CharacterField
: PropertyControlType::TextField
, _pParent
, _nWinStyle
)
192 m_bIsPassword
= _bPW
;
195 getTypedControlWindow()->SetMaxTextLen( 1 );
198 //------------------------------------------------------------------
199 void SAL_CALL
OEditControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
201 ::rtl::OUString sText
;
204 sal_Int16 nValue
= 0;
208 sal_Unicode nCharacter
= nValue
;
209 sText
= String( &nCharacter
, 1 );
215 getTypedControlWindow()->SetText( sText
);
218 //------------------------------------------------------------------
219 Any SAL_CALL
OEditControl::getValue() throw (RuntimeException
)
223 ::rtl::OUString
sText( getTypedControlWindow()->GetText() );
226 if ( sText
.getLength() )
227 aPropValue
<<= (sal_Int16
)sText
.getStr()[0];
230 aPropValue
<<= sText
;
235 //------------------------------------------------------------------
236 Type SAL_CALL
OEditControl::getValueType() throw (RuntimeException
)
238 return m_bIsPassword
? ::getCppuType( static_cast< sal_Int16
* >( NULL
) ) : ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) );
241 //------------------------------------------------------------------
242 void OEditControl::modified()
244 OEditControl_Base::modified();
246 // for pasword controls, we fire a commit for every single change
248 m_aImplControl
.notifyModifiedValue();
251 //------------------------------------------------------------------
252 static long ImplCalcLongValue( double nValue
, sal_uInt16 nDigits
)
255 for ( sal_uInt16 d
= 0; d
< nDigits
; ++d
)
258 if ( n
> ::std::numeric_limits
< long >::max() )
259 return ::std::numeric_limits
< long >::max();
263 //------------------------------------------------------------------
264 static double ImplCalcDoubleValue( long nValue
, sal_uInt16 nDigits
)
267 for ( sal_uInt16 d
= 0; d
< nDigits
; ++d
)
272 //==================================================================
273 // class ODateTimeControl
274 //==================================================================
275 //------------------------------------------------------------------
276 ODateTimeControl::ODateTimeControl( Window
* _pParent
, WinBits _nWinStyle
)
277 :ODateTimeControl_Base( PropertyControlType::DateTimeField
, _pParent
, _nWinStyle
)
279 getTypedControlWindow()->EnableEmptyField( sal_True
);
281 // determine a default format
282 Locale aSysLocale
= SvtSysLocale().GetLocaleData().getLocale();
283 LanguageType eSysLanguage
= MsLangId::convertLocaleToLanguage( aSysLocale
);
285 getTypedControlWindow()->SetFormatter( getTypedControlWindow()->StandardFormatter() );
286 SvNumberFormatter
* pFormatter
= getTypedControlWindow()->GetFormatter();
287 ULONG nStandardDateTimeFormat
= pFormatter
->GetStandardFormat( NUMBERFORMAT_DATETIME
, eSysLanguage
);
289 getTypedControlWindow()->SetFormatKey( nStandardDateTimeFormat
);
292 //------------------------------------------------------------------
293 void SAL_CALL
ODateTimeControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
295 if ( !_rValue
.hasValue() )
297 getTypedControlWindow()->SetText( String() );
301 util::DateTime aUNODateTime
;
302 OSL_VERIFY( _rValue
>>= aUNODateTime
);
304 ::DateTime aDateTime
;
305 ::utl::typeConvert( aUNODateTime
, aDateTime
);
307 double nValue
= aDateTime
- ::DateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
308 getTypedControlWindow()->SetValue( nValue
);
312 //------------------------------------------------------------------
313 Any SAL_CALL
ODateTimeControl::getValue() throw (RuntimeException
)
316 if ( getTypedControlWindow()->GetText().Len() )
318 double nValue
= getTypedControlWindow()->GetValue();
320 ::DateTime
aDateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
322 // add the "days" part
323 double nDays
= floor( nValue
);
326 // add the "time" part
327 double nTime
= nValue
- nDays
;
328 nTime
= ::rtl::math::round( nTime
* 86400.0 ) / 86400.0;
329 // we're not interested in 100th seconds, and this here prevents rounding errors
332 util::DateTime aUNODateTime
;
333 ::utl::typeConvert( aDateTime
, aUNODateTime
);
335 aPropValue
<<= aUNODateTime
;
340 //------------------------------------------------------------------
341 Type SAL_CALL
ODateTimeControl::getValueType() throw (RuntimeException
)
343 return ::getCppuType( static_cast< util::DateTime
* >( NULL
) );
346 //========================================================================
348 //========================================================================
349 //--------------------------------------------------------------------
350 HyperlinkInput::HyperlinkInput( Window
* _pParent
, WinBits _nWinStyle
)
351 :Edit( _pParent
, _nWinStyle
)
353 ::svtools::ColorConfig aColorConfig
;
354 ::svtools::ColorConfigValue
aLinkColor( aColorConfig
.GetColorValue( ::svtools::LINKS
) );
356 AllSettings
aAllSettings( GetSettings() );
357 StyleSettings
aStyleSettings( aAllSettings
.GetStyleSettings() );
359 Font
aFieldFont( aStyleSettings
.GetFieldFont() );
360 aFieldFont
.SetUnderline( UNDERLINE_SINGLE
);
361 aFieldFont
.SetColor( aLinkColor
.nColor
);
362 aStyleSettings
.SetFieldFont( aFieldFont
);
364 aStyleSettings
.SetFieldTextColor( aLinkColor
.nColor
);
366 aAllSettings
.SetStyleSettings( aStyleSettings
);
367 SetSettings( aAllSettings
);
370 //--------------------------------------------------------------------
371 void HyperlinkInput::MouseMove( const ::MouseEvent
& rMEvt
)
373 Edit::MouseMove( rMEvt
);
375 PointerStyle
ePointerStyle( POINTER_TEXT
);
377 if ( !rMEvt
.IsLeaveWindow() )
379 if ( impl_textHitTest( rMEvt
.GetPosPixel() ) )
380 ePointerStyle
= POINTER_REFHAND
;
383 SetPointer( Pointer( ePointerStyle
) );
386 //--------------------------------------------------------------------
387 void HyperlinkInput::MouseButtonDown( const ::MouseEvent
& rMEvt
)
389 Edit::MouseButtonDown( rMEvt
);
391 if ( impl_textHitTest( rMEvt
.GetPosPixel() ) )
392 m_aMouseButtonDownPos
= rMEvt
.GetPosPixel();
394 m_aMouseButtonDownPos
.X() = m_aMouseButtonDownPos
.Y() = -1;
397 //--------------------------------------------------------------------
398 void HyperlinkInput::MouseButtonUp( const ::MouseEvent
& rMEvt
)
400 Edit::MouseButtonUp( rMEvt
);
402 impl_checkEndClick( rMEvt
);
405 //--------------------------------------------------------------------
406 bool HyperlinkInput::impl_textHitTest( const ::Point
& _rWindowPos
)
408 xub_StrLen nPos
= GetCharPos( _rWindowPos
);
409 return ( ( nPos
!= STRING_LEN
) && ( nPos
< GetText().Len() ) );
412 //--------------------------------------------------------------------
413 void HyperlinkInput::impl_checkEndClick( const ::MouseEvent rMEvt
)
415 const MouseSettings
& rMouseSettings( GetSettings().GetMouseSettings() );
416 if ( ( abs( rMEvt
.GetPosPixel().X() - m_aMouseButtonDownPos
.X() ) < rMouseSettings
.GetStartDragWidth() )
417 && ( abs( rMEvt
.GetPosPixel().Y() - m_aMouseButtonDownPos
.Y() ) < rMouseSettings
.GetStartDragHeight() )
419 Application::PostUserEvent( m_aClickHandler
);
422 //--------------------------------------------------------------------
423 void HyperlinkInput::Tracking( const TrackingEvent
& rTEvt
)
425 Edit::Tracking( rTEvt
);
427 if ( rTEvt
.IsTrackingEnded() )
428 impl_checkEndClick( rTEvt
.GetMouseEvent() );
431 //========================================================================
432 //= OHyperlinkControl
433 //========================================================================
434 //--------------------------------------------------------------------
435 OHyperlinkControl::OHyperlinkControl( Window
* _pParent
, WinBits _nWinStyle
)
436 :OHyperlinkControl_Base( PropertyControlType::HyperlinkField
, _pParent
, _nWinStyle
)
437 ,m_aActionListeners( m_aMutex
)
439 getTypedControlWindow()->SetClickHdl( LINK( this, OHyperlinkControl
, OnHyperlinkClicked
) );
442 //--------------------------------------------------------------------
443 Any SAL_CALL
OHyperlinkControl::getValue() throw (RuntimeException
)
445 ::rtl::OUString sText
= getTypedControlWindow()->GetText();
446 return makeAny( sText
);
449 //--------------------------------------------------------------------
450 void SAL_CALL
OHyperlinkControl::setValue( const Any
& _value
) throw (IllegalTypeException
, RuntimeException
)
452 ::rtl::OUString sText
;
454 getTypedControlWindow()->SetText( sText
);
457 //--------------------------------------------------------------------
458 Type SAL_CALL
OHyperlinkControl::getValueType() throw (RuntimeException
)
460 return ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) );
463 //--------------------------------------------------------------------
464 void SAL_CALL
OHyperlinkControl::addActionListener( const Reference
< XActionListener
>& listener
) throw (RuntimeException
)
467 m_aActionListeners
.addInterface( listener
);
470 //--------------------------------------------------------------------
471 void SAL_CALL
OHyperlinkControl::removeActionListener( const Reference
< XActionListener
>& listener
) throw (RuntimeException
)
473 m_aActionListeners
.removeInterface( listener
);
476 //------------------------------------------------------------------
477 void SAL_CALL
OHyperlinkControl::disposing()
479 OHyperlinkControl_Base::disposing();
481 EventObject
aEvent( *this );
482 m_aActionListeners
.disposeAndClear( aEvent
);
485 //------------------------------------------------------------------
486 IMPL_LINK( OHyperlinkControl
, OnHyperlinkClicked
, void*, /*_NotInterestedIn*/ )
488 ActionEvent
aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "clicked" ) ) );
489 m_aActionListeners
.forEach
< XActionListener
>(
491 &XActionListener::actionPerformed
,
492 _1
, boost::cref(aEvent
) ) );
497 //==================================================================
499 //==================================================================
500 //------------------------------------------------------------------
501 ONumericControl::ONumericControl( Window
* _pParent
, WinBits _nWinStyle
)
502 :ONumericControl_Base( PropertyControlType::NumericField
, _pParent
, _nWinStyle
)
503 ,m_eValueUnit( FUNIT_NONE
)
504 ,m_nFieldToUNOValueFactor( 1 )
506 getTypedControlWindow()->SetDefaultUnit( FUNIT_NONE
);
508 getTypedControlWindow()->EnableEmptyFieldValue( sal_True
);
509 getTypedControlWindow()->SetStrictFormat( sal_True
);
510 Optional
< double > value( getMaxValue() );
511 value
.Value
= -value
.Value
;
512 setMinValue( value
);
515 //--------------------------------------------------------------------
516 ::sal_Int16 SAL_CALL
ONumericControl::getDecimalDigits() throw (RuntimeException
)
518 return getTypedControlWindow()->GetDecimalDigits();
521 //--------------------------------------------------------------------
522 void SAL_CALL
ONumericControl::setDecimalDigits( ::sal_Int16 _decimaldigits
) throw (RuntimeException
)
524 getTypedControlWindow()->SetDecimalDigits( _decimaldigits
);
527 //--------------------------------------------------------------------
528 Optional
< double > SAL_CALL
ONumericControl::getMinValue() throw (RuntimeException
)
530 Optional
< double > aReturn( sal_True
, 0 );
532 sal_Int64 minValue
= getTypedControlWindow()->GetMin();
533 if ( minValue
== ::std::numeric_limits
< sal_Int64
>::min() )
534 aReturn
.IsPresent
= sal_False
;
536 aReturn
.Value
= (double)minValue
;
541 //--------------------------------------------------------------------
542 void SAL_CALL
ONumericControl::setMinValue( const Optional
< double >& _minvalue
) throw (RuntimeException
)
544 if ( !_minvalue
.IsPresent
)
545 getTypedControlWindow()->SetMin( ::std::numeric_limits
< sal_Int64
>::min() );
547 getTypedControlWindow()->SetMin( impl_apiValueToFieldValue_nothrow( _minvalue
.Value
) , m_eValueUnit
);
550 //--------------------------------------------------------------------
551 Optional
< double > SAL_CALL
ONumericControl::getMaxValue() throw (RuntimeException
)
553 Optional
< double > aReturn( sal_True
, 0 );
555 sal_Int64 maxValue
= getTypedControlWindow()->GetMax();
556 if ( maxValue
== ::std::numeric_limits
< sal_Int64
>::max() )
557 aReturn
.IsPresent
= sal_False
;
559 aReturn
.Value
= (double)maxValue
;
564 //--------------------------------------------------------------------
565 void SAL_CALL
ONumericControl::setMaxValue( const Optional
< double >& _maxvalue
) throw (RuntimeException
)
567 if ( !_maxvalue
.IsPresent
)
568 getTypedControlWindow()->SetMax( ::std::numeric_limits
< sal_Int64
>::max() );
570 getTypedControlWindow()->SetMax( impl_apiValueToFieldValue_nothrow( _maxvalue
.Value
), m_eValueUnit
);
573 //--------------------------------------------------------------------
574 ::sal_Int16 SAL_CALL
ONumericControl::getDisplayUnit() throw (RuntimeException
)
576 return VCLUnoHelper::ConvertToMeasurementUnit( getTypedControlWindow()->GetUnit(), 1 );
579 //--------------------------------------------------------------------
580 void SAL_CALL
ONumericControl::setDisplayUnit( ::sal_Int16 _displayunit
) throw (IllegalArgumentException
, RuntimeException
)
582 if ( ( _displayunit
< MeasureUnit::MM_100TH
) || ( _displayunit
> MeasureUnit::PERCENT
) )
583 throw IllegalArgumentException();
584 if ( ( _displayunit
== MeasureUnit::MM_100TH
)
585 || ( _displayunit
== MeasureUnit::MM_10TH
)
586 || ( _displayunit
== MeasureUnit::INCH_1000TH
)
587 || ( _displayunit
== MeasureUnit::INCH_100TH
)
588 || ( _displayunit
== MeasureUnit::INCH_10TH
)
589 || ( _displayunit
== MeasureUnit::PERCENT
)
591 throw IllegalArgumentException();
593 sal_Int16 nDummyFactor
= 1;
594 FieldUnit eFieldUnit
= VCLUnoHelper::ConvertToFieldUnit( _displayunit
, nDummyFactor
);
595 if ( nDummyFactor
!= 1 )
596 // everything which survived the checks above should result in a factor of 1, i.e.,
597 // it should have a direct counterpart as FieldUnit
598 throw RuntimeException();
599 getTypedControlWindow()->SetUnit( eFieldUnit
);
602 //--------------------------------------------------------------------
603 ::sal_Int16 SAL_CALL
ONumericControl::getValueUnit() throw (RuntimeException
)
605 return VCLUnoHelper::ConvertToMeasurementUnit( m_eValueUnit
, m_nFieldToUNOValueFactor
);
608 //--------------------------------------------------------------------
609 void SAL_CALL
ONumericControl::setValueUnit( ::sal_Int16 _valueunit
) throw (RuntimeException
)
611 if ( ( _valueunit
< MeasureUnit::MM_100TH
) || ( _valueunit
> MeasureUnit::PERCENT
) )
612 throw IllegalArgumentException();
613 m_eValueUnit
= VCLUnoHelper::ConvertToFieldUnit( _valueunit
, m_nFieldToUNOValueFactor
);
616 //--------------------------------------------------------------------
617 void SAL_CALL
ONumericControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
619 if ( !_rValue
.hasValue() )
621 getTypedControlWindow()->SetText( String() );
622 getTypedControlWindow()->SetEmptyFieldValue();
627 OSL_VERIFY( _rValue
>>= nValue
);
628 long nControlValue
= impl_apiValueToFieldValue_nothrow( nValue
);
629 getTypedControlWindow()->SetValue( nControlValue
, m_eValueUnit
);
633 //------------------------------------------------------------------
634 long ONumericControl::impl_apiValueToFieldValue_nothrow( double _nApiValue
) const
636 long nControlValue
= ImplCalcLongValue( _nApiValue
, getTypedControlWindow()->GetDecimalDigits() );
637 nControlValue
/= m_nFieldToUNOValueFactor
;
638 return nControlValue
;
641 //------------------------------------------------------------------
642 double ONumericControl::impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue
) const
644 double nApiValue
= ImplCalcDoubleValue( (long)_nFieldValue
, getTypedControlWindow()->GetDecimalDigits() );
645 nApiValue
*= m_nFieldToUNOValueFactor
;
649 //------------------------------------------------------------------
650 Any SAL_CALL
ONumericControl::getValue() throw (RuntimeException
)
653 if ( getTypedControlWindow()->GetText().Len() )
655 double nValue
= impl_fieldValueToApiValue_nothrow( getTypedControlWindow()->GetValue( m_eValueUnit
) );
656 aPropValue
<<= nValue
;
661 //------------------------------------------------------------------
662 Type SAL_CALL
ONumericControl::getValueType() throw (RuntimeException
)
664 return ::getCppuType( static_cast< double* >( NULL
) );
667 //==================================================================
669 //==================================================================
670 #define LB_DEFAULT_COUNT 20
671 //------------------------------------------------------------------
672 String
MakeHexStr(sal_uInt32 nVal
, sal_uInt32 nLength
)
677 char c
=char(nVal
& 0x000F);
683 while (aStr
.Len() < nLength
) aStr
.Insert('0',0);
687 //------------------------------------------------------------------
688 OColorControl::OColorControl(Window
* pParent
, WinBits nWinStyle
)
689 :OColorControl_Base( PropertyControlType::ColorListBox
, pParent
, nWinStyle
)
691 // initialize the color listbox
692 XColorTable
* pColorTable
= NULL
;
693 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
694 const SfxPoolItem
* pItem
= pDocSh
? pDocSh
->GetItem( SID_COLOR_TABLE
) : NULL
;
697 DBG_ASSERT(pItem
->ISA(SvxColorTableItem
), "OColorControl::OColorControl: invalid color item!");
698 pColorTable
= ( (SvxColorTableItem
*)pItem
)->GetColorTable();
703 pColorTable
= XColorTable::GetStdColorTable();
707 DBG_ASSERT(pColorTable
, "OColorControl::OColorControl: no color table!");
711 for (sal_uInt16 i
= 0; i
< pColorTable
->Count(); ++i
)
713 XColorEntry
* pEntry
= pColorTable
->GetColor( i
);
714 getTypedControlWindow()->InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
718 getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT
);
719 if ( ( nWinStyle
& WB_READONLY
) != 0 )
721 getTypedControlWindow()->SetReadOnly( TRUE
);
722 getTypedControlWindow()->Enable( TRUE
);
726 //------------------------------------------------------------------
727 void SAL_CALL
OColorControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
729 if ( _rValue
.hasValue() )
731 ::com::sun::star::util::Color nColor
= COL_TRANSPARENT
;
732 if ( _rValue
>>= nColor
)
734 ::Color
aRgbCol((ColorData
)nColor
);
736 getTypedControlWindow()->SelectEntry( aRgbCol
);
737 if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol
) )
738 { // the given color is not part of the list -> insert a new entry with the hex code of the color
739 String aStr
= String::CreateFromAscii("0x");
740 aStr
+= MakeHexStr(nColor
,8);
741 getTypedControlWindow()->InsertEntry( aRgbCol
, aStr
);
742 getTypedControlWindow()->SelectEntry( aRgbCol
);
747 ::rtl::OUString sNonColorValue
;
748 if ( !( _rValue
>>= sNonColorValue
) )
749 throw IllegalTypeException();
750 getTypedControlWindow()->SelectEntry( sNonColorValue
);
751 if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue
) )
752 getTypedControlWindow()->SetNoSelection();
756 getTypedControlWindow()->SetNoSelection();
759 //------------------------------------------------------------------
760 Any SAL_CALL
OColorControl::getValue() throw (RuntimeException
)
763 if ( getTypedControlWindow()->GetSelectEntryCount() > 0 )
765 ::rtl::OUString sSelectedEntry
= getTypedControlWindow()->GetSelectEntry();
766 if ( m_aNonColorEntries
.find( sSelectedEntry
) != m_aNonColorEntries
.end() )
767 aPropValue
<<= sSelectedEntry
;
770 ::Color aRgbCol
= getTypedControlWindow()->GetSelectEntryColor();
771 aPropValue
<<= (::com::sun::star::util::Color
)aRgbCol
.GetColor();
777 //------------------------------------------------------------------
778 Type SAL_CALL
OColorControl::getValueType() throw (RuntimeException
)
780 return ::getCppuType( static_cast< sal_Int32
* >( NULL
) );
783 //------------------------------------------------------------------
784 void SAL_CALL
OColorControl::clearList() throw (RuntimeException
)
786 getTypedControlWindow()->Clear();
789 //------------------------------------------------------------------
790 void SAL_CALL
OColorControl::prependListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
792 getTypedControlWindow()->InsertEntry( NewEntry
, 0 );
793 m_aNonColorEntries
.insert( NewEntry
);
796 //------------------------------------------------------------------
797 void SAL_CALL
OColorControl::appendListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
799 getTypedControlWindow()->InsertEntry( NewEntry
);
800 m_aNonColorEntries
.insert( NewEntry
);
802 //------------------------------------------------------------------
803 Sequence
< ::rtl::OUString
> SAL_CALL
OColorControl::getListEntries( ) throw (RuntimeException
)
805 if ( !m_aNonColorEntries
.empty() )
806 return Sequence
< ::rtl::OUString
>(&(*m_aNonColorEntries
.begin()),m_aNonColorEntries
.size());
807 return Sequence
< ::rtl::OUString
>();
810 //------------------------------------------------------------------
811 void OColorControl::modified()
813 OColorControl_Base::modified();
815 if ( !getTypedControlWindow()->IsTravelSelect() )
817 m_aImplControl
.notifyModifiedValue();
820 //==================================================================
822 //==================================================================
823 //------------------------------------------------------------------
824 OListboxControl::OListboxControl( Window
* pParent
, WinBits nWinStyle
)
825 :OListboxControl_Base( PropertyControlType::ListBox
, pParent
, nWinStyle
)
827 getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT
);
828 if ( ( nWinStyle
& WB_READONLY
) != 0 )
830 getTypedControlWindow()->SetReadOnly( TRUE
);
831 getTypedControlWindow()->Enable( TRUE
);
835 //------------------------------------------------------------------
836 Any SAL_CALL
OListboxControl::getValue() throw (RuntimeException
)
838 ::rtl::OUString
sControlValue( getTypedControlWindow()->GetSelectEntry() );
841 if ( sControlValue
.getLength() )
842 aPropValue
<<= sControlValue
;
846 //------------------------------------------------------------------
847 Type SAL_CALL
OListboxControl::getValueType() throw (RuntimeException
)
849 return ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) );
852 //------------------------------------------------------------------
853 void SAL_CALL
OListboxControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
855 if ( !_rValue
.hasValue() )
856 getTypedControlWindow()->SetNoSelection();
859 ::rtl::OUString sSelection
;
860 _rValue
>>= sSelection
;
862 if ( !sSelection
.equals( getTypedControlWindow()->GetSelectEntry() ) )
863 getTypedControlWindow()->SelectEntry( sSelection
);
865 if ( !getTypedControlWindow()->IsEntrySelected( sSelection
) )
867 getTypedControlWindow()->InsertEntry( sSelection
, 0 );
868 getTypedControlWindow()->SelectEntry( sSelection
);
873 //------------------------------------------------------------------
874 void SAL_CALL
OListboxControl::clearList() throw (RuntimeException
)
876 getTypedControlWindow()->Clear();
879 //------------------------------------------------------------------
880 void SAL_CALL
OListboxControl::prependListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
882 getTypedControlWindow()->InsertEntry( NewEntry
, 0 );
885 //------------------------------------------------------------------
886 void SAL_CALL
OListboxControl::appendListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
888 getTypedControlWindow()->InsertEntry( NewEntry
);
890 //------------------------------------------------------------------
891 Sequence
< ::rtl::OUString
> SAL_CALL
OListboxControl::getListEntries( ) throw (RuntimeException
)
893 const USHORT nCount
= getTypedControlWindow()->GetEntryCount();
894 Sequence
< ::rtl::OUString
> aRet(nCount
);
895 ::rtl::OUString
* pIter
= aRet
.getArray();
896 for (USHORT i
= 0; i
< nCount
; ++i
,++pIter
)
897 *pIter
= getTypedControlWindow()->GetEntry(i
);
902 //------------------------------------------------------------------
903 void OListboxControl::modified()
905 OListboxControl_Base::modified();
907 if ( !getTypedControlWindow()->IsTravelSelect() )
909 m_aImplControl
.notifyModifiedValue();
912 //==================================================================
914 //==================================================================
915 //------------------------------------------------------------------
916 OComboboxControl::OComboboxControl( Window
* pParent
, WinBits nWinStyle
)
917 :OComboboxControl_Base( PropertyControlType::ComboBox
, pParent
, nWinStyle
)
919 getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT
);
920 getTypedControlWindow()->SetSelectHdl( LINK( this, OComboboxControl
, OnEntrySelected
) );
923 //------------------------------------------------------------------
924 void SAL_CALL
OComboboxControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
926 ::rtl::OUString sText
;
928 getTypedControlWindow()->SetText( sText
);
931 //------------------------------------------------------------------
932 Any SAL_CALL
OComboboxControl::getValue() throw (RuntimeException
)
934 return makeAny( ::rtl::OUString( getTypedControlWindow()->GetText() ) );
937 //------------------------------------------------------------------
938 Type SAL_CALL
OComboboxControl::getValueType() throw (RuntimeException
)
940 return ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) );
943 //------------------------------------------------------------------
944 void SAL_CALL
OComboboxControl::clearList() throw (RuntimeException
)
946 getTypedControlWindow()->Clear();
949 //------------------------------------------------------------------
950 void SAL_CALL
OComboboxControl::prependListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
952 getTypedControlWindow()->InsertEntry( NewEntry
, 0 );
955 //------------------------------------------------------------------
956 void SAL_CALL
OComboboxControl::appendListEntry( const ::rtl::OUString
& NewEntry
) throw (RuntimeException
)
958 getTypedControlWindow()->InsertEntry( NewEntry
);
960 //------------------------------------------------------------------
961 Sequence
< ::rtl::OUString
> SAL_CALL
OComboboxControl::getListEntries( ) throw (RuntimeException
)
963 const USHORT nCount
= getTypedControlWindow()->GetEntryCount();
964 Sequence
< ::rtl::OUString
> aRet(nCount
);
965 ::rtl::OUString
* pIter
= aRet
.getArray();
966 for (USHORT i
= 0; i
< nCount
; ++i
,++pIter
)
967 *pIter
= getTypedControlWindow()->GetEntry(i
);
972 //------------------------------------------------------------------
973 IMPL_LINK( OComboboxControl
, OnEntrySelected
, void*, /*_pNothing*/ )
975 if ( !getTypedControlWindow()->IsTravelSelect() )
977 m_aImplControl
.notifyModifiedValue();
981 //==================================================================
982 //= OMultilineFloatingEdit
983 //==================================================================
984 class OMultilineFloatingEdit
: public FloatingWindow
987 MultiLineEdit m_aImplEdit
;
990 virtual void Resize();
993 OMultilineFloatingEdit(Window
* _pParen
);
994 MultiLineEdit
* getEdit() { return &m_aImplEdit
; }
997 virtual long PreNotify(NotifyEvent
& _rNEvt
);
1000 //------------------------------------------------------------------
1001 OMultilineFloatingEdit::OMultilineFloatingEdit(Window
* _pParent
)
1002 :FloatingWindow(_pParent
, WB_BORDER
)
1003 ,m_aImplEdit(this, WB_VSCROLL
|WB_IGNORETAB
|WB_NOBORDER
)
1008 //------------------------------------------------------------------
1009 void OMultilineFloatingEdit::Resize()
1011 m_aImplEdit
.SetSizePixel(GetOutputSizePixel());
1014 //------------------------------------------------------------------
1015 long OMultilineFloatingEdit::PreNotify(NotifyEvent
& _rNEvt
)
1017 long nResult
= sal_True
;
1019 sal_uInt16 nSwitch
= _rNEvt
.GetType();
1020 if (EVENT_KEYINPUT
== nSwitch
)
1022 const KeyCode
& aKeyCode
= _rNEvt
.GetKeyEvent()->GetKeyCode();
1023 sal_uInt16 nKey
= aKeyCode
.GetCode();
1025 if ( ( (KEY_RETURN
== nKey
)
1026 && !aKeyCode
.IsShift()
1028 || ( (KEY_UP
== nKey
)
1029 && aKeyCode
.IsMod2()
1036 nResult
=FloatingWindow::PreNotify(_rNEvt
);
1039 nResult
=FloatingWindow::PreNotify(_rNEvt
);
1044 //==================================================================
1045 //= DropDownEditControl_Base
1046 //==================================================================
1047 //------------------------------------------------------------------
1048 DropDownEditControl::DropDownEditControl( Window
* _pParent
, WinBits _nStyle
)
1049 :DropDownEditControl_Base( _pParent
, _nStyle
)
1050 ,m_pFloatingEdit( NULL
)
1051 ,m_pImplEdit( NULL
)
1052 ,m_pDropdownButton( NULL
)
1053 ,m_nOperationMode( eStringList
)
1054 ,m_bDropdown( sal_False
)
1056 SetCompoundControl( TRUE
);
1058 m_pImplEdit
= new MultiLineEdit( this, WB_TABSTOP
| WB_IGNORETAB
| WB_NOBORDER
| (_nStyle
& WB_READONLY
) );
1059 SetSubEdit( m_pImplEdit
);
1060 m_pImplEdit
->Show();
1062 if ( _nStyle
& WB_DROPDOWN
)
1064 m_pDropdownButton
= new PushButton( this, WB_NOLIGHTBORDER
| WB_RECTSTYLE
| WB_NOTABSTOP
);
1065 m_pDropdownButton
->SetSymbol(SYMBOL_SPIN_DOWN
);
1066 m_pDropdownButton
->SetClickHdl( LINK( this, DropDownEditControl
, DropDownHdl
) );
1067 m_pDropdownButton
->Show();
1070 m_pFloatingEdit
= new OMultilineFloatingEdit(this); //FloatingWindow
1072 m_pFloatingEdit
->SetPopupModeEndHdl( LINK( this, DropDownEditControl
, ReturnHdl
) );
1073 m_pFloatingEdit
->getEdit()->SetReadOnly( ( _nStyle
& WB_READONLY
) != 0 );
1076 //------------------------------------------------------------------
1077 void DropDownEditControl::setControlHelper( ControlHelper
& _rControlHelper
)
1079 DropDownEditControl_Base::setControlHelper( _rControlHelper
);
1080 m_pFloatingEdit
->getEdit()->SetModifyHdl( LINK( &_rControlHelper
, ControlHelper
, ModifiedHdl
) );
1081 m_pImplEdit
->SetGetFocusHdl( LINK( &_rControlHelper
, ControlHelper
, GetFocusHdl
) );
1082 m_pImplEdit
->SetModifyHdl( LINK( &_rControlHelper
, ControlHelper
, ModifiedHdl
) );
1083 m_pImplEdit
->SetLoseFocusHdl( LINK( &_rControlHelper
, ControlHelper
, LoseFocusHdl
) );
1086 //------------------------------------------------------------------
1087 DropDownEditControl::~DropDownEditControl()
1090 ::std::auto_ptr
<Window
> aTemp(m_pFloatingEdit
);
1091 m_pFloatingEdit
= NULL
;
1094 ::std::auto_ptr
<Window
> aTemp(m_pImplEdit
);
1099 ::std::auto_ptr
<Window
> aTemp(m_pDropdownButton
);
1100 m_pDropdownButton
= NULL
;
1104 //------------------------------------------------------------------
1105 void DropDownEditControl::Resize()
1107 ::Size aOutSz
= GetOutputSizePixel();
1109 if (m_pDropdownButton
!=NULL
)
1111 long nSBWidth
= GetSettings().GetStyleSettings().GetScrollBarSize();
1112 nSBWidth
= CalcZoom( nSBWidth
);
1113 m_pImplEdit
->SetPosSizePixel( 0, 1, aOutSz
.Width() - nSBWidth
, aOutSz
.Height()-2 );
1114 m_pDropdownButton
->SetPosSizePixel( aOutSz
.Width() - nSBWidth
, 0, nSBWidth
, aOutSz
.Height() );
1117 m_pImplEdit
->SetPosSizePixel( 0, 1, aOutSz
.Width(), aOutSz
.Height()-2 );
1120 //------------------------------------------------------------------
1121 long DropDownEditControl::PreNotify( NotifyEvent
& rNEvt
)
1125 if (rNEvt
.GetType() == EVENT_KEYINPUT
)
1127 const KeyCode
& aKeyCode
= rNEvt
.GetKeyEvent()->GetKeyCode();
1128 sal_uInt16 nKey
= aKeyCode
.GetCode();
1130 if ( nKey
== KEY_RETURN
&& !aKeyCode
.IsShift() )
1134 m_pHelper
->LoseFocusHdl( m_pImplEdit
);
1135 m_pHelper
->activateNextControl();
1138 else if ( nKey
== KEY_DOWN
&& aKeyCode
.IsMod2() )
1141 ShowDropDown( sal_True
);
1143 else if ( KEYGROUP_CURSOR
== aKeyCode
.GetGroup()
1145 || KEYGROUP_FKEYS
== aKeyCode
.GetGroup()
1146 || m_nOperationMode
== eMultiLineText
1149 nResult
= DropDownEditControl_Base::PreNotify( rNEvt
);
1151 else if ( m_nOperationMode
== eStringList
)
1153 Selection aSel
= m_pImplEdit
->GetSelection();
1154 if ( aSel
.Min() != aSel
.Max() )
1156 aSel
.Min() = FindPos( aSel
.Min() );
1157 aSel
.Max() = FindPos( aSel
.Max() );
1161 aSel
.Min() = FindPos( aSel
.Min() );
1162 aSel
.Max() = aSel
.Min();
1165 ShowDropDown( sal_True
);
1166 m_pFloatingEdit
->getEdit()->GrabFocus();
1167 m_pFloatingEdit
->getEdit()->SetSelection( aSel
);
1168 Window
* pFocusWin
= Application::GetFocusWindow();
1169 pFocusWin
->KeyInput( *rNEvt
.GetKeyEvent() );
1173 nResult
= DropDownEditControl_Base::PreNotify(rNEvt
);
1178 //------------------------------------------------------------------
1181 //..............................................................
1182 StlSyntaxSequence
< ::rtl::OUString
> lcl_convertMultiLineToList( const String
& _rCompsedTextWithLineBreaks
)
1184 xub_StrLen
nLines( _rCompsedTextWithLineBreaks
.GetTokenCount( '\n' ) );
1185 StlSyntaxSequence
< ::rtl::OUString
> aStrings( nLines
);
1186 StlSyntaxSequence
< ::rtl::OUString
>::iterator stringItem
= aStrings
.begin();
1187 for ( xub_StrLen token
= 0; token
< nLines
; ++token
, ++stringItem
)
1188 *stringItem
= _rCompsedTextWithLineBreaks
.GetToken( token
, '\n' );
1192 String
lcl_convertListToMultiLine( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
)
1194 String sMultiLineText
;
1195 for ( StlSyntaxSequence
< ::rtl::OUString
>::const_iterator item
= _rStrings
.begin();
1196 item
!= _rStrings
.end();
1199 sMultiLineText
+= String( *item
);
1200 if ( ++item
!= _rStrings
.end() )
1201 sMultiLineText
+= '\n';
1203 return sMultiLineText
;
1206 //..............................................................
1207 String
lcl_convertListToDisplayText( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
)
1209 ::rtl::OUStringBuffer aComposed
;
1210 for ( StlSyntaxSequence
< ::rtl::OUString
>::const_iterator strings
= _rStrings
.begin();
1211 strings
!= _rStrings
.end();
1215 if ( strings
!= _rStrings
.begin() )
1216 aComposed
.append( (sal_Unicode
)';' );
1217 aComposed
.append( (sal_Unicode
)'\"' );
1218 aComposed
.append( *strings
);
1219 aComposed
.append( (sal_Unicode
)'\"' );
1221 return aComposed
.makeStringAndClear();
1225 //------------------------------------------------------------------
1226 #define STD_HEIGHT 100
1227 sal_Bool
DropDownEditControl::ShowDropDown( sal_Bool bShow
)
1231 ::Point aMePos
= GetPosPixel();
1232 aMePos
= GetParent()->OutputToScreenPixel( aMePos
);
1233 ::Size aSize
=GetSizePixel();
1234 ::Rectangle
aRect(aMePos
,aSize
);
1235 aSize
.Height() = STD_HEIGHT
;
1236 m_pFloatingEdit
->SetOutputSizePixel(aSize
);
1237 m_pFloatingEdit
->StartPopupMode( aRect
, FLOATWIN_POPUPMODE_DOWN
);
1239 m_pFloatingEdit
->Show();
1240 m_pFloatingEdit
->getEdit()->GrabFocus();
1241 m_pFloatingEdit
->getEdit()->SetSelection(Selection(m_pFloatingEdit
->getEdit()->GetText().Len()));
1242 m_bDropdown
=sal_True
;
1243 if ( m_nOperationMode
== eMultiLineText
)
1244 m_pFloatingEdit
->getEdit()->SetText( m_pImplEdit
->GetText() );
1245 m_pImplEdit
->SetText(String());
1249 m_pFloatingEdit
->Hide();
1250 m_pFloatingEdit
->Invalidate();
1251 m_pFloatingEdit
->Update();
1253 // transfer the text from the floating edit to our own edit
1254 String
sDisplayText( m_pFloatingEdit
->getEdit()->GetText() );
1255 if ( m_nOperationMode
== eStringList
)
1256 sDisplayText
= lcl_convertListToDisplayText( lcl_convertMultiLineToList( sDisplayText
) );
1258 m_pImplEdit
->SetText( sDisplayText
);
1259 GetParent()->Invalidate( INVALIDATE_CHILDREN
);
1260 m_bDropdown
= sal_False
;
1261 m_pImplEdit
->GrabFocus();
1267 //------------------------------------------------------------------
1268 long DropDownEditControl::FindPos(long nSinglePos
)
1273 String aStr
=m_pFloatingEdit
->getEdit()->GetText();
1274 String aStr1
= GetText();
1276 if ((nSinglePos
== 0) || (nSinglePos
== aStr1
.Len()))
1283 sal_Int32 nCount
= aStr
.GetTokenCount('\n');
1285 String aInput
= aStr
.GetToken(0,'\n' );
1295 if (nSinglePos
<= aOutput
.Len())
1297 nPos
=nSinglePos
-nDiff
;
1301 for (sal_Int32 i
=1; i
<nCount
; ++i
)
1303 aInput
=aStr
.GetToken((sal_uInt16
)i
, '\n');
1312 if (nSinglePos
<= aOutput
.Len())
1314 nPos
=nSinglePos
-nDiff
;
1324 //------------------------------------------------------------------
1325 IMPL_LINK( DropDownEditControl
, ReturnHdl
, OMultilineFloatingEdit
*, /*pMEd*/)
1328 String aStr
= m_pFloatingEdit
->getEdit()->GetText();
1329 String aStr2
= GetText();
1330 ShowDropDown(sal_False
);
1332 if (aStr
!=aStr2
|| ( m_nOperationMode
== eStringList
) )
1335 m_pHelper
->notifyModifiedValue();
1341 //------------------------------------------------------------------
1342 IMPL_LINK( DropDownEditControl
, DropDownHdl
, PushButton
*, /*pPb*/ )
1344 ShowDropDown(!m_bDropdown
);
1348 //------------------------------------------------------------------
1349 void DropDownEditControl::SetStringListValue( const StlSyntaxSequence
< ::rtl::OUString
>& _rStrings
)
1351 SetText( lcl_convertListToDisplayText( _rStrings
) );
1352 m_pFloatingEdit
->getEdit()->SetText( lcl_convertListToMultiLine( _rStrings
) );
1355 //------------------------------------------------------------------
1356 StlSyntaxSequence
< ::rtl::OUString
> DropDownEditControl::GetStringListValue() const
1358 return lcl_convertMultiLineToList( m_pFloatingEdit
->getEdit()->GetText() );
1361 //------------------------------------------------------------------
1362 void DropDownEditControl::SetTextValue( const ::rtl::OUString
& _rText
)
1364 OSL_PRECOND( m_nOperationMode
== eMultiLineText
, "DropDownEditControl::SetTextValue: illegal call!" );
1366 m_pFloatingEdit
->getEdit()->SetText( _rText
);
1370 //------------------------------------------------------------------
1371 ::rtl::OUString
DropDownEditControl::GetTextValue() const
1373 OSL_PRECOND( m_nOperationMode
== eMultiLineText
, "DropDownEditControl::GetTextValue: illegal call!" );
1377 //==================================================================
1378 //= OMultilineEditControl
1379 //==================================================================
1380 //------------------------------------------------------------------
1381 OMultilineEditControl::OMultilineEditControl( Window
* pParent
, MultiLineOperationMode _eMode
, WinBits nWinStyle
)
1382 :OMultilineEditControl_Base( _eMode
== eMultiLineText
? PropertyControlType::MultiLineTextField
: PropertyControlType::StringListField
1384 , ( nWinStyle
| WB_DIALOGCONTROL
) & ( ~WB_READONLY
| ~WB_DROPDOWN
)
1387 getTypedControlWindow()->setOperationMode( _eMode
);
1390 //------------------------------------------------------------------
1391 void SAL_CALL
OMultilineEditControl::setValue( const Any
& _rValue
) throw (IllegalTypeException
, RuntimeException
)
1393 impl_checkDisposed_throw();
1395 switch ( getTypedControlWindow()->getOperationMode() )
1397 case eMultiLineText
:
1399 ::rtl::OUString sText
;
1400 if ( !( _rValue
>>= sText
) && _rValue
.hasValue() )
1401 throw IllegalTypeException();
1402 getTypedControlWindow()->SetTextValue( sText
);
1407 Sequence
< ::rtl::OUString
> aStringLines
;
1408 if ( !( _rValue
>>= aStringLines
) && _rValue
.hasValue() )
1409 throw IllegalTypeException();
1410 getTypedControlWindow()->SetStringListValue( aStringLines
);
1416 //------------------------------------------------------------------
1417 Any SAL_CALL
OMultilineEditControl::getValue() throw (RuntimeException
)
1419 impl_checkDisposed_throw();
1422 switch ( getTypedControlWindow()->getOperationMode() )
1424 case eMultiLineText
:
1425 aValue
<<= getTypedControlWindow()->GetTextValue();
1428 aValue
<<= getTypedControlWindow()->GetStringListValue();
1434 //------------------------------------------------------------------
1435 Type SAL_CALL
OMultilineEditControl::getValueType() throw (RuntimeException
)
1437 if ( getTypedControlWindow()->getOperationMode() == eMultiLineText
)
1438 return ::getCppuType( static_cast< ::rtl::OUString
* >( NULL
) );
1439 return ::getCppuType( static_cast< Sequence
< ::rtl::OUString
>* >( NULL
) );
1442 //............................................................................
1444 //............................................................................