1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "standardcontrol.hxx" 31*cdf0e10cSrcweir #include "pcrcommon.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir /** === begin UNO includes === **/ 34*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/util/MeasureUnit.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp> 40*cdf0e10cSrcweir /** === end UNO includes === **/ 41*cdf0e10cSrcweir #include <rtl/math.hxx> 42*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir //================================================================== 45*cdf0e10cSrcweir // ugly dependencies for the OColorControl 46*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 47*cdf0e10cSrcweir #include <svx/svxids.hrc> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #include <svx/drawitem.hxx> 50*cdf0e10cSrcweir #include <svx/xtable.hxx> 51*cdf0e10cSrcweir //================================================================== 52*cdf0e10cSrcweir #include <vcl/floatwin.hxx> 53*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 54*cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 55*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 56*cdf0e10cSrcweir #include <unotools/datetime.hxx> 57*cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 58*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 59*cdf0e10cSrcweir #include <vcl/button.hxx> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #include <vcl/svapp.hxx> 62*cdf0e10cSrcweir //================================================================== 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <memory> 65*cdf0e10cSrcweir #include <limits> 66*cdf0e10cSrcweir #include <boost/bind.hpp> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //............................................................................ 69*cdf0e10cSrcweir namespace pcr 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir //............................................................................ 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using namespace ::com::sun::star; 74*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 75*cdf0e10cSrcweir using namespace ::com::sun::star::awt; 76*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 77*cdf0e10cSrcweir using namespace ::com::sun::star::util; 78*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 79*cdf0e10cSrcweir using namespace ::com::sun::star::inspection; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir //================================================================== 82*cdf0e10cSrcweir //= OTimeControl 83*cdf0e10cSrcweir //================================================================== 84*cdf0e10cSrcweir //------------------------------------------------------------------ 85*cdf0e10cSrcweir OTimeControl::OTimeControl( Window* pParent, WinBits nWinStyle ) 86*cdf0e10cSrcweir :OTimeControl_Base( PropertyControlType::TimeField, pParent, nWinStyle ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir getTypedControlWindow()->SetStrictFormat( sal_True ); 89*cdf0e10cSrcweir getTypedControlWindow()->SetFormat( TIMEF_SEC ); 90*cdf0e10cSrcweir getTypedControlWindow()->EnableEmptyFieldValue( sal_True ); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir //------------------------------------------------------------------ 94*cdf0e10cSrcweir void SAL_CALL OTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir util::Time aUNOTime; 97*cdf0e10cSrcweir if ( !( _rValue >>= aUNOTime ) ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir getTypedControlWindow()->SetText( String() ); 100*cdf0e10cSrcweir getTypedControlWindow()->SetEmptyTime(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir else 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir ::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.HundredthSeconds ); 105*cdf0e10cSrcweir getTypedControlWindow()->SetTime( aTime ); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //------------------------------------------------------------------ 110*cdf0e10cSrcweir Any SAL_CALL OTimeControl::getValue() throw (RuntimeException) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir Any aPropValue; 113*cdf0e10cSrcweir if ( getTypedControlWindow()->GetText().Len()>0 ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir ::Time aTime( getTypedControlWindow()->GetTime() ); 116*cdf0e10cSrcweir util::Time aUNOTime( aTime.Get100Sec(), aTime.GetSec(), aTime.GetMin(), aTime.GetHour() ); 117*cdf0e10cSrcweir aPropValue <<= aUNOTime; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir return aPropValue; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //------------------------------------------------------------------ 123*cdf0e10cSrcweir Type SAL_CALL OTimeControl::getValueType() throw (RuntimeException) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir return ::getCppuType( static_cast< util::Time* >( NULL ) ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //================================================================== 129*cdf0e10cSrcweir //= ODateControl 130*cdf0e10cSrcweir //================================================================== 131*cdf0e10cSrcweir //------------------------------------------------------------------ 132*cdf0e10cSrcweir ODateControl::ODateControl( Window* pParent, WinBits nWinStyle ) 133*cdf0e10cSrcweir :ODateControl_Base( PropertyControlType::DateField, pParent, nWinStyle | WB_DROPDOWN ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir WindowType* pControlWindow = getTypedControlWindow(); 136*cdf0e10cSrcweir pControlWindow->SetStrictFormat(sal_True); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir pControlWindow->SetMin( ::Date( 1,1,1600 ) ); 139*cdf0e10cSrcweir pControlWindow->SetFirst( ::Date( 1,1,1600 ) ); 140*cdf0e10cSrcweir pControlWindow->SetLast( ::Date( 1, 1, 9999 ) ); 141*cdf0e10cSrcweir pControlWindow->SetMax( ::Date( 1, 1, 9999 ) ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir pControlWindow->SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY ); 144*cdf0e10cSrcweir pControlWindow->EnableEmptyFieldValue( sal_True ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir //------------------------------------------------------------------ 148*cdf0e10cSrcweir void SAL_CALL ODateControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir util::Date aUNODate; 151*cdf0e10cSrcweir if ( !( _rValue >>= aUNODate ) ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir getTypedControlWindow()->SetText( String() ); 154*cdf0e10cSrcweir getTypedControlWindow()->SetEmptyDate(); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir else 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir ::Date aDate( aUNODate.Day, aUNODate.Month, aUNODate.Year ); 159*cdf0e10cSrcweir getTypedControlWindow()->SetDate( aDate ); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir //------------------------------------------------------------------ 164*cdf0e10cSrcweir Any SAL_CALL ODateControl::getValue() throw (RuntimeException) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir Any aPropValue; 167*cdf0e10cSrcweir if ( getTypedControlWindow()->GetText().Len() > 0 ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir ::Date aDate( getTypedControlWindow()->GetDate() ); 170*cdf0e10cSrcweir util::Date aUNODate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() ); 171*cdf0e10cSrcweir aPropValue <<= aUNODate; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir return aPropValue; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //------------------------------------------------------------------ 177*cdf0e10cSrcweir Type SAL_CALL ODateControl::getValueType() throw (RuntimeException) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return ::getCppuType( static_cast< util::Date* >( NULL ) ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir //================================================================== 183*cdf0e10cSrcweir //= OEditControl 184*cdf0e10cSrcweir //================================================================== 185*cdf0e10cSrcweir //------------------------------------------------------------------ 186*cdf0e10cSrcweir OEditControl::OEditControl(Window* _pParent, sal_Bool _bPW, WinBits _nWinStyle) 187*cdf0e10cSrcweir :OEditControl_Base( _bPW ? PropertyControlType::CharacterField : PropertyControlType::TextField, _pParent, _nWinStyle ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir m_bIsPassword = _bPW; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir if ( m_bIsPassword ) 192*cdf0e10cSrcweir getTypedControlWindow()->SetMaxTextLen( 1 ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir //------------------------------------------------------------------ 196*cdf0e10cSrcweir void SAL_CALL OEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir ::rtl::OUString sText; 199*cdf0e10cSrcweir if ( m_bIsPassword ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir sal_Int16 nValue = 0; 202*cdf0e10cSrcweir _rValue >>= nValue; 203*cdf0e10cSrcweir if ( nValue ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir sal_Unicode nCharacter = nValue; 206*cdf0e10cSrcweir sText = String( &nCharacter, 1 ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir _rValue >>= sText; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir getTypedControlWindow()->SetText( sText ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //------------------------------------------------------------------ 216*cdf0e10cSrcweir Any SAL_CALL OEditControl::getValue() throw (RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir Any aPropValue; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir ::rtl::OUString sText( getTypedControlWindow()->GetText() ); 221*cdf0e10cSrcweir if ( m_bIsPassword ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir if ( sText.getLength() ) 224*cdf0e10cSrcweir aPropValue <<= (sal_Int16)sText.getStr()[0]; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir else 227*cdf0e10cSrcweir aPropValue <<= sText; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir return aPropValue; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir //------------------------------------------------------------------ 233*cdf0e10cSrcweir Type SAL_CALL OEditControl::getValueType() throw (RuntimeException) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir return m_bIsPassword ? ::getCppuType( static_cast< sal_Int16* >( NULL ) ) : ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir //------------------------------------------------------------------ 239*cdf0e10cSrcweir void OEditControl::modified() 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir OEditControl_Base::modified(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir // for pasword controls, we fire a commit for every single change 244*cdf0e10cSrcweir if ( m_bIsPassword ) 245*cdf0e10cSrcweir m_aImplControl.notifyModifiedValue(); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir //------------------------------------------------------------------ 249*cdf0e10cSrcweir static long ImplCalcLongValue( double nValue, sal_uInt16 nDigits ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir double n = nValue; 252*cdf0e10cSrcweir for ( sal_uInt16 d = 0; d < nDigits; ++d ) 253*cdf0e10cSrcweir n *= 10; 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir if ( n > ::std::numeric_limits< long >::max() ) 256*cdf0e10cSrcweir return ::std::numeric_limits< long >::max(); 257*cdf0e10cSrcweir return (long)n; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir //------------------------------------------------------------------ 261*cdf0e10cSrcweir static double ImplCalcDoubleValue( long nValue, sal_uInt16 nDigits ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir double n = nValue; 264*cdf0e10cSrcweir for ( sal_uInt16 d = 0; d < nDigits; ++d ) 265*cdf0e10cSrcweir n /= 10; 266*cdf0e10cSrcweir return n; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir //================================================================== 270*cdf0e10cSrcweir // class ODateTimeControl 271*cdf0e10cSrcweir //================================================================== 272*cdf0e10cSrcweir //------------------------------------------------------------------ 273*cdf0e10cSrcweir ODateTimeControl::ODateTimeControl( Window* _pParent, WinBits _nWinStyle) 274*cdf0e10cSrcweir :ODateTimeControl_Base( PropertyControlType::DateTimeField, _pParent, _nWinStyle ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir getTypedControlWindow()->EnableEmptyField( sal_True ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir // determine a default format 279*cdf0e10cSrcweir Locale aSysLocale = SvtSysLocale().GetLocaleData().getLocale(); 280*cdf0e10cSrcweir LanguageType eSysLanguage = MsLangId::convertLocaleToLanguage( aSysLocale ); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir getTypedControlWindow()->SetFormatter( getTypedControlWindow()->StandardFormatter() ); 283*cdf0e10cSrcweir SvNumberFormatter* pFormatter = getTypedControlWindow()->GetFormatter(); 284*cdf0e10cSrcweir sal_uLong nStandardDateTimeFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATETIME, eSysLanguage ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir getTypedControlWindow()->SetFormatKey( nStandardDateTimeFormat ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir //------------------------------------------------------------------ 290*cdf0e10cSrcweir void SAL_CALL ODateTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir if ( !_rValue.hasValue() ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir getTypedControlWindow()->SetText( String() ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir util::DateTime aUNODateTime; 299*cdf0e10cSrcweir OSL_VERIFY( _rValue >>= aUNODateTime ); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir ::DateTime aDateTime; 302*cdf0e10cSrcweir ::utl::typeConvert( aUNODateTime, aDateTime ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir double nValue = aDateTime - ::DateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() ); 305*cdf0e10cSrcweir getTypedControlWindow()->SetValue( nValue ); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir //------------------------------------------------------------------ 310*cdf0e10cSrcweir Any SAL_CALL ODateTimeControl::getValue() throw (RuntimeException) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir Any aPropValue; 313*cdf0e10cSrcweir if ( getTypedControlWindow()->GetText().Len() ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir double nValue = getTypedControlWindow()->GetValue(); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir ::DateTime aDateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() ); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // add the "days" part 320*cdf0e10cSrcweir double nDays = floor( nValue ); 321*cdf0e10cSrcweir aDateTime += nDays; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // add the "time" part 324*cdf0e10cSrcweir double nTime = nValue - nDays; 325*cdf0e10cSrcweir nTime = ::rtl::math::round( nTime * 86400.0 ) / 86400.0; 326*cdf0e10cSrcweir // we're not interested in 100th seconds, and this here prevents rounding errors 327*cdf0e10cSrcweir aDateTime += nTime; 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir util::DateTime aUNODateTime; 330*cdf0e10cSrcweir ::utl::typeConvert( aDateTime, aUNODateTime ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir aPropValue <<= aUNODateTime; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir return aPropValue; 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir //------------------------------------------------------------------ 338*cdf0e10cSrcweir Type SAL_CALL ODateTimeControl::getValueType() throw (RuntimeException) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir return ::getCppuType( static_cast< util::DateTime* >( NULL ) ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //======================================================================== 344*cdf0e10cSrcweir //= HyperlinkInput 345*cdf0e10cSrcweir //======================================================================== 346*cdf0e10cSrcweir //-------------------------------------------------------------------- 347*cdf0e10cSrcweir HyperlinkInput::HyperlinkInput( Window* _pParent, WinBits _nWinStyle ) 348*cdf0e10cSrcweir :Edit( _pParent, _nWinStyle ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir ::svtools::ColorConfig aColorConfig; 351*cdf0e10cSrcweir ::svtools::ColorConfigValue aLinkColor( aColorConfig.GetColorValue( ::svtools::LINKS ) ); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir AllSettings aAllSettings( GetSettings() ); 354*cdf0e10cSrcweir StyleSettings aStyleSettings( aAllSettings.GetStyleSettings() ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir Font aFieldFont( aStyleSettings.GetFieldFont() ); 357*cdf0e10cSrcweir aFieldFont.SetUnderline( UNDERLINE_SINGLE ); 358*cdf0e10cSrcweir aFieldFont.SetColor( aLinkColor.nColor ); 359*cdf0e10cSrcweir aStyleSettings.SetFieldFont( aFieldFont ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir aStyleSettings.SetFieldTextColor( aLinkColor.nColor ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir aAllSettings.SetStyleSettings( aStyleSettings ); 364*cdf0e10cSrcweir SetSettings( aAllSettings ); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //-------------------------------------------------------------------- 368*cdf0e10cSrcweir void HyperlinkInput::MouseMove( const ::MouseEvent& rMEvt ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir Edit::MouseMove( rMEvt ); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir PointerStyle ePointerStyle( POINTER_TEXT ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if ( !rMEvt.IsLeaveWindow() ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir if ( impl_textHitTest( rMEvt.GetPosPixel() ) ) 377*cdf0e10cSrcweir ePointerStyle = POINTER_REFHAND; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir SetPointer( Pointer( ePointerStyle ) ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir //-------------------------------------------------------------------- 384*cdf0e10cSrcweir void HyperlinkInput::MouseButtonDown( const ::MouseEvent& rMEvt ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir Edit::MouseButtonDown( rMEvt ); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir if ( impl_textHitTest( rMEvt.GetPosPixel() ) ) 389*cdf0e10cSrcweir m_aMouseButtonDownPos = rMEvt.GetPosPixel(); 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir m_aMouseButtonDownPos.X() = m_aMouseButtonDownPos.Y() = -1; 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir //-------------------------------------------------------------------- 395*cdf0e10cSrcweir void HyperlinkInput::MouseButtonUp( const ::MouseEvent& rMEvt ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir Edit::MouseButtonUp( rMEvt ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir impl_checkEndClick( rMEvt ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir //-------------------------------------------------------------------- 403*cdf0e10cSrcweir bool HyperlinkInput::impl_textHitTest( const ::Point& _rWindowPos ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir xub_StrLen nPos = GetCharPos( _rWindowPos ); 406*cdf0e10cSrcweir return ( ( nPos != STRING_LEN ) && ( nPos < GetText().Len() ) ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //-------------------------------------------------------------------- 410*cdf0e10cSrcweir void HyperlinkInput::impl_checkEndClick( const ::MouseEvent rMEvt ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir const MouseSettings& rMouseSettings( GetSettings().GetMouseSettings() ); 413*cdf0e10cSrcweir if ( ( abs( rMEvt.GetPosPixel().X() - m_aMouseButtonDownPos.X() ) < rMouseSettings.GetStartDragWidth() ) 414*cdf0e10cSrcweir && ( abs( rMEvt.GetPosPixel().Y() - m_aMouseButtonDownPos.Y() ) < rMouseSettings.GetStartDragHeight() ) 415*cdf0e10cSrcweir ) 416*cdf0e10cSrcweir Application::PostUserEvent( m_aClickHandler ); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir //-------------------------------------------------------------------- 420*cdf0e10cSrcweir void HyperlinkInput::Tracking( const TrackingEvent& rTEvt ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir Edit::Tracking( rTEvt ); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ( rTEvt.IsTrackingEnded() ) 425*cdf0e10cSrcweir impl_checkEndClick( rTEvt.GetMouseEvent() ); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir //======================================================================== 429*cdf0e10cSrcweir //= OHyperlinkControl 430*cdf0e10cSrcweir //======================================================================== 431*cdf0e10cSrcweir //-------------------------------------------------------------------- 432*cdf0e10cSrcweir OHyperlinkControl::OHyperlinkControl( Window* _pParent, WinBits _nWinStyle ) 433*cdf0e10cSrcweir :OHyperlinkControl_Base( PropertyControlType::HyperlinkField, _pParent, _nWinStyle ) 434*cdf0e10cSrcweir ,m_aActionListeners( m_aMutex ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir getTypedControlWindow()->SetClickHdl( LINK( this, OHyperlinkControl, OnHyperlinkClicked ) ); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir //-------------------------------------------------------------------- 440*cdf0e10cSrcweir Any SAL_CALL OHyperlinkControl::getValue() throw (RuntimeException) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir ::rtl::OUString sText = getTypedControlWindow()->GetText(); 443*cdf0e10cSrcweir return makeAny( sText ); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir //-------------------------------------------------------------------- 447*cdf0e10cSrcweir void SAL_CALL OHyperlinkControl::setValue( const Any& _value ) throw (IllegalTypeException, RuntimeException) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir ::rtl::OUString sText; 450*cdf0e10cSrcweir _value >>= sText; 451*cdf0e10cSrcweir getTypedControlWindow()->SetText( sText ); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir //-------------------------------------------------------------------- 455*cdf0e10cSrcweir Type SAL_CALL OHyperlinkControl::getValueType() throw (RuntimeException) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir //-------------------------------------------------------------------- 461*cdf0e10cSrcweir void SAL_CALL OHyperlinkControl::addActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir if ( listener.is() ) 464*cdf0e10cSrcweir m_aActionListeners.addInterface( listener ); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir //-------------------------------------------------------------------- 468*cdf0e10cSrcweir void SAL_CALL OHyperlinkControl::removeActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir m_aActionListeners.removeInterface( listener ); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir //------------------------------------------------------------------ 474*cdf0e10cSrcweir void SAL_CALL OHyperlinkControl::disposing() 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir OHyperlinkControl_Base::disposing(); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir EventObject aEvent( *this ); 479*cdf0e10cSrcweir m_aActionListeners.disposeAndClear( aEvent ); 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir //------------------------------------------------------------------ 483*cdf0e10cSrcweir IMPL_LINK( OHyperlinkControl, OnHyperlinkClicked, void*, /*_NotInterestedIn*/ ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir ActionEvent aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "clicked" ) ) ); 486*cdf0e10cSrcweir m_aActionListeners.forEach< XActionListener >( 487*cdf0e10cSrcweir boost::bind( 488*cdf0e10cSrcweir &XActionListener::actionPerformed, 489*cdf0e10cSrcweir _1, boost::cref(aEvent) ) ); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir return 0; 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir //================================================================== 495*cdf0e10cSrcweir //= ONumericControl 496*cdf0e10cSrcweir //================================================================== 497*cdf0e10cSrcweir //------------------------------------------------------------------ 498*cdf0e10cSrcweir ONumericControl::ONumericControl( Window* _pParent, WinBits _nWinStyle ) 499*cdf0e10cSrcweir :ONumericControl_Base( PropertyControlType::NumericField, _pParent, _nWinStyle ) 500*cdf0e10cSrcweir ,m_eValueUnit( FUNIT_NONE ) 501*cdf0e10cSrcweir ,m_nFieldToUNOValueFactor( 1 ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir getTypedControlWindow()->SetDefaultUnit( FUNIT_NONE ); 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir getTypedControlWindow()->EnableEmptyFieldValue( sal_True ); 506*cdf0e10cSrcweir getTypedControlWindow()->SetStrictFormat( sal_True ); 507*cdf0e10cSrcweir Optional< double > value( getMaxValue() ); 508*cdf0e10cSrcweir value.Value = -value.Value; 509*cdf0e10cSrcweir setMinValue( value ); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir //-------------------------------------------------------------------- 513*cdf0e10cSrcweir ::sal_Int16 SAL_CALL ONumericControl::getDecimalDigits() throw (RuntimeException) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir return getTypedControlWindow()->GetDecimalDigits(); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir //-------------------------------------------------------------------- 519*cdf0e10cSrcweir void SAL_CALL ONumericControl::setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (RuntimeException) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir getTypedControlWindow()->SetDecimalDigits( _decimaldigits ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir //-------------------------------------------------------------------- 525*cdf0e10cSrcweir Optional< double > SAL_CALL ONumericControl::getMinValue() throw (RuntimeException) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir Optional< double > aReturn( sal_True, 0 ); 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir sal_Int64 minValue = getTypedControlWindow()->GetMin(); 530*cdf0e10cSrcweir if ( minValue == ::std::numeric_limits< sal_Int64 >::min() ) 531*cdf0e10cSrcweir aReturn.IsPresent = sal_False; 532*cdf0e10cSrcweir else 533*cdf0e10cSrcweir aReturn.Value = (double)minValue; 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir return aReturn; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir //-------------------------------------------------------------------- 539*cdf0e10cSrcweir void SAL_CALL ONumericControl::setMinValue( const Optional< double >& _minvalue ) throw (RuntimeException) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir if ( !_minvalue.IsPresent ) 542*cdf0e10cSrcweir getTypedControlWindow()->SetMin( ::std::numeric_limits< sal_Int64 >::min() ); 543*cdf0e10cSrcweir else 544*cdf0e10cSrcweir getTypedControlWindow()->SetMin( impl_apiValueToFieldValue_nothrow( _minvalue.Value ) , m_eValueUnit); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir //-------------------------------------------------------------------- 548*cdf0e10cSrcweir Optional< double > SAL_CALL ONumericControl::getMaxValue() throw (RuntimeException) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir Optional< double > aReturn( sal_True, 0 ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir sal_Int64 maxValue = getTypedControlWindow()->GetMax(); 553*cdf0e10cSrcweir if ( maxValue == ::std::numeric_limits< sal_Int64 >::max() ) 554*cdf0e10cSrcweir aReturn.IsPresent = sal_False; 555*cdf0e10cSrcweir else 556*cdf0e10cSrcweir aReturn.Value = (double)maxValue; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir return aReturn; 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir //-------------------------------------------------------------------- 562*cdf0e10cSrcweir void SAL_CALL ONumericControl::setMaxValue( const Optional< double >& _maxvalue ) throw (RuntimeException) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir if ( !_maxvalue.IsPresent ) 565*cdf0e10cSrcweir getTypedControlWindow()->SetMax( ::std::numeric_limits< sal_Int64 >::max() ); 566*cdf0e10cSrcweir else 567*cdf0e10cSrcweir getTypedControlWindow()->SetMax( impl_apiValueToFieldValue_nothrow( _maxvalue.Value ), m_eValueUnit ); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir //-------------------------------------------------------------------- 571*cdf0e10cSrcweir ::sal_Int16 SAL_CALL ONumericControl::getDisplayUnit() throw (RuntimeException) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir return VCLUnoHelper::ConvertToMeasurementUnit( getTypedControlWindow()->GetUnit(), 1 ); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir //-------------------------------------------------------------------- 577*cdf0e10cSrcweir void SAL_CALL ONumericControl::setDisplayUnit( ::sal_Int16 _displayunit ) throw (IllegalArgumentException, RuntimeException) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir if ( ( _displayunit < MeasureUnit::MM_100TH ) || ( _displayunit > MeasureUnit::PERCENT ) ) 580*cdf0e10cSrcweir throw IllegalArgumentException(); 581*cdf0e10cSrcweir if ( ( _displayunit == MeasureUnit::MM_100TH ) 582*cdf0e10cSrcweir || ( _displayunit == MeasureUnit::MM_10TH ) 583*cdf0e10cSrcweir || ( _displayunit == MeasureUnit::INCH_1000TH ) 584*cdf0e10cSrcweir || ( _displayunit == MeasureUnit::INCH_100TH ) 585*cdf0e10cSrcweir || ( _displayunit == MeasureUnit::INCH_10TH ) 586*cdf0e10cSrcweir || ( _displayunit == MeasureUnit::PERCENT ) 587*cdf0e10cSrcweir ) 588*cdf0e10cSrcweir throw IllegalArgumentException(); 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir sal_Int16 nDummyFactor = 1; 591*cdf0e10cSrcweir FieldUnit eFieldUnit = VCLUnoHelper::ConvertToFieldUnit( _displayunit, nDummyFactor ); 592*cdf0e10cSrcweir if ( nDummyFactor != 1 ) 593*cdf0e10cSrcweir // everything which survived the checks above should result in a factor of 1, i.e., 594*cdf0e10cSrcweir // it should have a direct counterpart as FieldUnit 595*cdf0e10cSrcweir throw RuntimeException(); 596*cdf0e10cSrcweir getTypedControlWindow()->SetUnit( eFieldUnit ); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir //-------------------------------------------------------------------- 600*cdf0e10cSrcweir ::sal_Int16 SAL_CALL ONumericControl::getValueUnit() throw (RuntimeException) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir return VCLUnoHelper::ConvertToMeasurementUnit( m_eValueUnit, m_nFieldToUNOValueFactor ); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir //-------------------------------------------------------------------- 606*cdf0e10cSrcweir void SAL_CALL ONumericControl::setValueUnit( ::sal_Int16 _valueunit ) throw (RuntimeException) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir if ( ( _valueunit < MeasureUnit::MM_100TH ) || ( _valueunit > MeasureUnit::PERCENT ) ) 609*cdf0e10cSrcweir throw IllegalArgumentException(); 610*cdf0e10cSrcweir m_eValueUnit = VCLUnoHelper::ConvertToFieldUnit( _valueunit, m_nFieldToUNOValueFactor ); 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir //-------------------------------------------------------------------- 614*cdf0e10cSrcweir void SAL_CALL ONumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir if ( !_rValue.hasValue() ) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir getTypedControlWindow()->SetText( String() ); 619*cdf0e10cSrcweir getTypedControlWindow()->SetEmptyFieldValue(); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir else 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir double nValue( 0 ); 624*cdf0e10cSrcweir OSL_VERIFY( _rValue >>= nValue ); 625*cdf0e10cSrcweir long nControlValue = impl_apiValueToFieldValue_nothrow( nValue ); 626*cdf0e10cSrcweir getTypedControlWindow()->SetValue( nControlValue, m_eValueUnit ); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir //------------------------------------------------------------------ 631*cdf0e10cSrcweir long ONumericControl::impl_apiValueToFieldValue_nothrow( double _nApiValue ) const 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir long nControlValue = ImplCalcLongValue( _nApiValue, getTypedControlWindow()->GetDecimalDigits() ); 634*cdf0e10cSrcweir nControlValue /= m_nFieldToUNOValueFactor; 635*cdf0e10cSrcweir return nControlValue; 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir //------------------------------------------------------------------ 639*cdf0e10cSrcweir double ONumericControl::impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir double nApiValue = ImplCalcDoubleValue( (long)_nFieldValue, getTypedControlWindow()->GetDecimalDigits() ); 642*cdf0e10cSrcweir nApiValue *= m_nFieldToUNOValueFactor; 643*cdf0e10cSrcweir return nApiValue; 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir //------------------------------------------------------------------ 647*cdf0e10cSrcweir Any SAL_CALL ONumericControl::getValue() throw (RuntimeException) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir Any aPropValue; 650*cdf0e10cSrcweir if ( getTypedControlWindow()->GetText().Len() ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir double nValue = impl_fieldValueToApiValue_nothrow( getTypedControlWindow()->GetValue( m_eValueUnit ) ); 653*cdf0e10cSrcweir aPropValue <<= nValue; 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir return aPropValue; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir //------------------------------------------------------------------ 659*cdf0e10cSrcweir Type SAL_CALL ONumericControl::getValueType() throw (RuntimeException) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir return ::getCppuType( static_cast< double* >( NULL ) ); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir //================================================================== 665*cdf0e10cSrcweir //= OColorControl 666*cdf0e10cSrcweir //================================================================== 667*cdf0e10cSrcweir #define LB_DEFAULT_COUNT 20 668*cdf0e10cSrcweir //------------------------------------------------------------------ 669*cdf0e10cSrcweir String MakeHexStr(sal_uInt32 nVal, sal_uInt32 nLength) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir String aStr; 672*cdf0e10cSrcweir while (nVal>0) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir char c=char(nVal & 0x000F); 675*cdf0e10cSrcweir nVal>>=4; 676*cdf0e10cSrcweir if (c<=9) c+='0'; 677*cdf0e10cSrcweir else c+='A'-10; 678*cdf0e10cSrcweir aStr.Insert(c,0); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir while (aStr.Len() < nLength) aStr.Insert('0',0); 681*cdf0e10cSrcweir return aStr; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir //------------------------------------------------------------------ 685*cdf0e10cSrcweir OColorControl::OColorControl(Window* pParent, WinBits nWinStyle) 686*cdf0e10cSrcweir :OColorControl_Base( PropertyControlType::ColorListBox, pParent, nWinStyle ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir // initialize the color listbox 689*cdf0e10cSrcweir XColorTable* pColorTable = NULL; 690*cdf0e10cSrcweir SfxObjectShell* pDocSh = SfxObjectShell::Current(); 691*cdf0e10cSrcweir const SfxPoolItem* pItem = pDocSh ? pDocSh->GetItem( SID_COLOR_TABLE ) : NULL; 692*cdf0e10cSrcweir if ( pItem ) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir DBG_ASSERT(pItem->ISA(SvxColorTableItem), "OColorControl::OColorControl: invalid color item!"); 695*cdf0e10cSrcweir pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir if ( !pColorTable ) 699*cdf0e10cSrcweir { 700*cdf0e10cSrcweir pColorTable = XColorTable::GetStdColorTable(); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir DBG_ASSERT(pColorTable, "OColorControl::OColorControl: no color table!"); 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir if (pColorTable) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < pColorTable->Count(); ++i) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir XColorEntry* pEntry = pColorTable->GetColor( i ); 711*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); 716*cdf0e10cSrcweir if ( ( nWinStyle & WB_READONLY ) != 0 ) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir getTypedControlWindow()->SetReadOnly( sal_True ); 719*cdf0e10cSrcweir getTypedControlWindow()->Enable( sal_True ); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir //------------------------------------------------------------------ 724*cdf0e10cSrcweir void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir if ( _rValue.hasValue() ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir ::com::sun::star::util::Color nColor = COL_TRANSPARENT; 729*cdf0e10cSrcweir if ( _rValue >>= nColor ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir ::Color aRgbCol((ColorData)nColor); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir getTypedControlWindow()->SelectEntry( aRgbCol ); 734*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol ) ) 735*cdf0e10cSrcweir { // the given color is not part of the list -> insert a new entry with the hex code of the color 736*cdf0e10cSrcweir String aStr = String::CreateFromAscii("0x"); 737*cdf0e10cSrcweir aStr += MakeHexStr(nColor,8); 738*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( aRgbCol, aStr ); 739*cdf0e10cSrcweir getTypedControlWindow()->SelectEntry( aRgbCol ); 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir else 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir ::rtl::OUString sNonColorValue; 745*cdf0e10cSrcweir if ( !( _rValue >>= sNonColorValue ) ) 746*cdf0e10cSrcweir throw IllegalTypeException(); 747*cdf0e10cSrcweir getTypedControlWindow()->SelectEntry( sNonColorValue ); 748*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue ) ) 749*cdf0e10cSrcweir getTypedControlWindow()->SetNoSelection(); 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir else 753*cdf0e10cSrcweir getTypedControlWindow()->SetNoSelection(); 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir //------------------------------------------------------------------ 757*cdf0e10cSrcweir Any SAL_CALL OColorControl::getValue() throw (RuntimeException) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir Any aPropValue; 760*cdf0e10cSrcweir if ( getTypedControlWindow()->GetSelectEntryCount() > 0 ) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir ::rtl::OUString sSelectedEntry = getTypedControlWindow()->GetSelectEntry(); 763*cdf0e10cSrcweir if ( m_aNonColorEntries.find( sSelectedEntry ) != m_aNonColorEntries.end() ) 764*cdf0e10cSrcweir aPropValue <<= sSelectedEntry; 765*cdf0e10cSrcweir else 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); 768*cdf0e10cSrcweir aPropValue <<= (::com::sun::star::util::Color)aRgbCol.GetColor(); 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir return aPropValue; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir //------------------------------------------------------------------ 775*cdf0e10cSrcweir Type SAL_CALL OColorControl::getValueType() throw (RuntimeException) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir return ::getCppuType( static_cast< sal_Int32* >( NULL ) ); 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir //------------------------------------------------------------------ 781*cdf0e10cSrcweir void SAL_CALL OColorControl::clearList() throw (RuntimeException) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir getTypedControlWindow()->Clear(); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir //------------------------------------------------------------------ 787*cdf0e10cSrcweir void SAL_CALL OColorControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry, 0 ); 790*cdf0e10cSrcweir m_aNonColorEntries.insert( NewEntry ); 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir //------------------------------------------------------------------ 794*cdf0e10cSrcweir void SAL_CALL OColorControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry ); 797*cdf0e10cSrcweir m_aNonColorEntries.insert( NewEntry ); 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir //------------------------------------------------------------------ 800*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OColorControl::getListEntries( ) throw (RuntimeException) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir if ( !m_aNonColorEntries.empty() ) 803*cdf0e10cSrcweir return Sequence< ::rtl::OUString >(&(*m_aNonColorEntries.begin()),m_aNonColorEntries.size()); 804*cdf0e10cSrcweir return Sequence< ::rtl::OUString >(); 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir //------------------------------------------------------------------ 808*cdf0e10cSrcweir void OColorControl::modified() 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir OColorControl_Base::modified(); 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsTravelSelect() ) 813*cdf0e10cSrcweir // fire a commit 814*cdf0e10cSrcweir m_aImplControl.notifyModifiedValue(); 815*cdf0e10cSrcweir } 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir //================================================================== 818*cdf0e10cSrcweir //= OListboxControl 819*cdf0e10cSrcweir //================================================================== 820*cdf0e10cSrcweir //------------------------------------------------------------------ 821*cdf0e10cSrcweir OListboxControl::OListboxControl( Window* pParent, WinBits nWinStyle) 822*cdf0e10cSrcweir :OListboxControl_Base( PropertyControlType::ListBox, pParent, nWinStyle ) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); 825*cdf0e10cSrcweir if ( ( nWinStyle & WB_READONLY ) != 0 ) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir getTypedControlWindow()->SetReadOnly( sal_True ); 828*cdf0e10cSrcweir getTypedControlWindow()->Enable( sal_True ); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir //------------------------------------------------------------------ 833*cdf0e10cSrcweir Any SAL_CALL OListboxControl::getValue() throw (RuntimeException) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir ::rtl::OUString sControlValue( getTypedControlWindow()->GetSelectEntry() ); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir Any aPropValue; 838*cdf0e10cSrcweir if ( sControlValue.getLength() ) 839*cdf0e10cSrcweir aPropValue <<= sControlValue; 840*cdf0e10cSrcweir return aPropValue; 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir //------------------------------------------------------------------ 844*cdf0e10cSrcweir Type SAL_CALL OListboxControl::getValueType() throw (RuntimeException) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir //------------------------------------------------------------------ 850*cdf0e10cSrcweir void SAL_CALL OListboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir if ( !_rValue.hasValue() ) 853*cdf0e10cSrcweir getTypedControlWindow()->SetNoSelection(); 854*cdf0e10cSrcweir else 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir ::rtl::OUString sSelection; 857*cdf0e10cSrcweir _rValue >>= sSelection; 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir if ( !sSelection.equals( getTypedControlWindow()->GetSelectEntry() ) ) 860*cdf0e10cSrcweir getTypedControlWindow()->SelectEntry( sSelection ); 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsEntrySelected( sSelection ) ) 863*cdf0e10cSrcweir { 864*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( sSelection, 0 ); 865*cdf0e10cSrcweir getTypedControlWindow()->SelectEntry( sSelection ); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir //------------------------------------------------------------------ 871*cdf0e10cSrcweir void SAL_CALL OListboxControl::clearList() throw (RuntimeException) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir getTypedControlWindow()->Clear(); 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir //------------------------------------------------------------------ 877*cdf0e10cSrcweir void SAL_CALL OListboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry, 0 ); 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir //------------------------------------------------------------------ 883*cdf0e10cSrcweir void SAL_CALL OListboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry ); 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir //------------------------------------------------------------------ 888*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OListboxControl::getListEntries( ) throw (RuntimeException) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir const sal_uInt16 nCount = getTypedControlWindow()->GetEntryCount(); 891*cdf0e10cSrcweir Sequence< ::rtl::OUString > aRet(nCount); 892*cdf0e10cSrcweir ::rtl::OUString* pIter = aRet.getArray(); 893*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount ; ++i,++pIter) 894*cdf0e10cSrcweir *pIter = getTypedControlWindow()->GetEntry(i); 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir return aRet; 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir //------------------------------------------------------------------ 900*cdf0e10cSrcweir void OListboxControl::modified() 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir OListboxControl_Base::modified(); 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsTravelSelect() ) 905*cdf0e10cSrcweir // fire a commit 906*cdf0e10cSrcweir m_aImplControl.notifyModifiedValue(); 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir //================================================================== 910*cdf0e10cSrcweir //= OComboboxControl 911*cdf0e10cSrcweir //================================================================== 912*cdf0e10cSrcweir //------------------------------------------------------------------ 913*cdf0e10cSrcweir OComboboxControl::OComboboxControl( Window* pParent, WinBits nWinStyle) 914*cdf0e10cSrcweir :OComboboxControl_Base( PropertyControlType::ComboBox, pParent, nWinStyle ) 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); 917*cdf0e10cSrcweir getTypedControlWindow()->SetSelectHdl( LINK( this, OComboboxControl, OnEntrySelected ) ); 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir //------------------------------------------------------------------ 921*cdf0e10cSrcweir void SAL_CALL OComboboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 922*cdf0e10cSrcweir { 923*cdf0e10cSrcweir ::rtl::OUString sText; 924*cdf0e10cSrcweir _rValue >>= sText; 925*cdf0e10cSrcweir getTypedControlWindow()->SetText( sText ); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir //------------------------------------------------------------------ 929*cdf0e10cSrcweir Any SAL_CALL OComboboxControl::getValue() throw (RuntimeException) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir return makeAny( ::rtl::OUString( getTypedControlWindow()->GetText() ) ); 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir //------------------------------------------------------------------ 935*cdf0e10cSrcweir Type SAL_CALL OComboboxControl::getValueType() throw (RuntimeException) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir //------------------------------------------------------------------ 941*cdf0e10cSrcweir void SAL_CALL OComboboxControl::clearList() throw (RuntimeException) 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir getTypedControlWindow()->Clear(); 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir //------------------------------------------------------------------ 947*cdf0e10cSrcweir void SAL_CALL OComboboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry, 0 ); 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir //------------------------------------------------------------------ 953*cdf0e10cSrcweir void SAL_CALL OComboboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir getTypedControlWindow()->InsertEntry( NewEntry ); 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir //------------------------------------------------------------------ 958*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OComboboxControl::getListEntries( ) throw (RuntimeException) 959*cdf0e10cSrcweir { 960*cdf0e10cSrcweir const sal_uInt16 nCount = getTypedControlWindow()->GetEntryCount(); 961*cdf0e10cSrcweir Sequence< ::rtl::OUString > aRet(nCount); 962*cdf0e10cSrcweir ::rtl::OUString* pIter = aRet.getArray(); 963*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nCount ; ++i,++pIter) 964*cdf0e10cSrcweir *pIter = getTypedControlWindow()->GetEntry(i); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir return aRet; 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir //------------------------------------------------------------------ 970*cdf0e10cSrcweir IMPL_LINK( OComboboxControl, OnEntrySelected, void*, /*_pNothing*/ ) 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir if ( !getTypedControlWindow()->IsTravelSelect() ) 973*cdf0e10cSrcweir // fire a commit 974*cdf0e10cSrcweir m_aImplControl.notifyModifiedValue(); 975*cdf0e10cSrcweir return 0L; 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir //================================================================== 979*cdf0e10cSrcweir //= OMultilineFloatingEdit 980*cdf0e10cSrcweir //================================================================== 981*cdf0e10cSrcweir class OMultilineFloatingEdit : public FloatingWindow 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir private: 984*cdf0e10cSrcweir MultiLineEdit m_aImplEdit; 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir protected: 987*cdf0e10cSrcweir virtual void Resize(); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir public: 990*cdf0e10cSrcweir OMultilineFloatingEdit(Window* _pParen); 991*cdf0e10cSrcweir MultiLineEdit* getEdit() { return &m_aImplEdit; } 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir protected: 994*cdf0e10cSrcweir virtual long PreNotify(NotifyEvent& _rNEvt); 995*cdf0e10cSrcweir }; 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir //------------------------------------------------------------------ 998*cdf0e10cSrcweir OMultilineFloatingEdit::OMultilineFloatingEdit(Window* _pParent) 999*cdf0e10cSrcweir :FloatingWindow(_pParent, WB_BORDER) 1000*cdf0e10cSrcweir ,m_aImplEdit(this, WB_VSCROLL|WB_IGNORETAB|WB_NOBORDER) 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir m_aImplEdit.Show(); 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir //------------------------------------------------------------------ 1006*cdf0e10cSrcweir void OMultilineFloatingEdit::Resize() 1007*cdf0e10cSrcweir { 1008*cdf0e10cSrcweir m_aImplEdit.SetSizePixel(GetOutputSizePixel()); 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir //------------------------------------------------------------------ 1012*cdf0e10cSrcweir long OMultilineFloatingEdit::PreNotify(NotifyEvent& _rNEvt) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir long nResult = sal_True; 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir sal_uInt16 nSwitch = _rNEvt.GetType(); 1017*cdf0e10cSrcweir if (EVENT_KEYINPUT == nSwitch) 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir const KeyCode& aKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode(); 1020*cdf0e10cSrcweir sal_uInt16 nKey = aKeyCode.GetCode(); 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir if ( ( (KEY_RETURN == nKey) 1023*cdf0e10cSrcweir && !aKeyCode.IsShift() 1024*cdf0e10cSrcweir ) 1025*cdf0e10cSrcweir || ( (KEY_UP == nKey) 1026*cdf0e10cSrcweir && aKeyCode.IsMod2() 1027*cdf0e10cSrcweir ) 1028*cdf0e10cSrcweir ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir EndPopupMode(); 1031*cdf0e10cSrcweir } 1032*cdf0e10cSrcweir else 1033*cdf0e10cSrcweir nResult=FloatingWindow::PreNotify(_rNEvt); 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir else 1036*cdf0e10cSrcweir nResult=FloatingWindow::PreNotify(_rNEvt); 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir return nResult; 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir //================================================================== 1042*cdf0e10cSrcweir //= DropDownEditControl_Base 1043*cdf0e10cSrcweir //================================================================== 1044*cdf0e10cSrcweir //------------------------------------------------------------------ 1045*cdf0e10cSrcweir DropDownEditControl::DropDownEditControl( Window* _pParent, WinBits _nStyle ) 1046*cdf0e10cSrcweir :DropDownEditControl_Base( _pParent, _nStyle ) 1047*cdf0e10cSrcweir ,m_pFloatingEdit( NULL ) 1048*cdf0e10cSrcweir ,m_pImplEdit( NULL ) 1049*cdf0e10cSrcweir ,m_pDropdownButton( NULL ) 1050*cdf0e10cSrcweir ,m_nOperationMode( eStringList ) 1051*cdf0e10cSrcweir ,m_bDropdown( sal_False ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir SetCompoundControl( sal_True ); 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir m_pImplEdit = new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) ); 1056*cdf0e10cSrcweir SetSubEdit( m_pImplEdit ); 1057*cdf0e10cSrcweir m_pImplEdit->Show(); 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir if ( _nStyle & WB_DROPDOWN ) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir m_pDropdownButton = new PushButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP); 1062*cdf0e10cSrcweir m_pDropdownButton->SetSymbol(SYMBOL_SPIN_DOWN); 1063*cdf0e10cSrcweir m_pDropdownButton->SetClickHdl( LINK( this, DropDownEditControl, DropDownHdl ) ); 1064*cdf0e10cSrcweir m_pDropdownButton->Show(); 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir m_pFloatingEdit = new OMultilineFloatingEdit(this); //FloatingWindow 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir m_pFloatingEdit->SetPopupModeEndHdl( LINK( this, DropDownEditControl, ReturnHdl ) ); 1070*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetReadOnly( ( _nStyle & WB_READONLY ) != 0 ); 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir //------------------------------------------------------------------ 1074*cdf0e10cSrcweir void DropDownEditControl::setControlHelper( ControlHelper& _rControlHelper ) 1075*cdf0e10cSrcweir { 1076*cdf0e10cSrcweir DropDownEditControl_Base::setControlHelper( _rControlHelper ); 1077*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) ); 1078*cdf0e10cSrcweir m_pImplEdit->SetGetFocusHdl( LINK( &_rControlHelper, ControlHelper, GetFocusHdl ) ); 1079*cdf0e10cSrcweir m_pImplEdit->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) ); 1080*cdf0e10cSrcweir m_pImplEdit->SetLoseFocusHdl( LINK( &_rControlHelper, ControlHelper, LoseFocusHdl ) ); 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir //------------------------------------------------------------------ 1084*cdf0e10cSrcweir DropDownEditControl::~DropDownEditControl() 1085*cdf0e10cSrcweir { 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pFloatingEdit); 1088*cdf0e10cSrcweir m_pFloatingEdit = NULL; 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir { 1091*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pImplEdit); 1092*cdf0e10cSrcweir SetSubEdit( NULL ); 1093*cdf0e10cSrcweir m_pImplEdit = NULL; 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pDropdownButton); 1097*cdf0e10cSrcweir m_pDropdownButton = NULL; 1098*cdf0e10cSrcweir } 1099*cdf0e10cSrcweir } 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir //------------------------------------------------------------------ 1102*cdf0e10cSrcweir void DropDownEditControl::Resize() 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir ::Size aOutSz = GetOutputSizePixel(); 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir if (m_pDropdownButton!=NULL) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); 1109*cdf0e10cSrcweir nSBWidth = CalcZoom( nSBWidth ); 1110*cdf0e10cSrcweir m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 ); 1111*cdf0e10cSrcweir m_pDropdownButton->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() ); 1112*cdf0e10cSrcweir } 1113*cdf0e10cSrcweir else 1114*cdf0e10cSrcweir m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width(), aOutSz.Height()-2 ); 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir //------------------------------------------------------------------ 1118*cdf0e10cSrcweir long DropDownEditControl::PreNotify( NotifyEvent& rNEvt ) 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir long nResult = 1; 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir if (rNEvt.GetType() == EVENT_KEYINPUT) 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode(); 1125*cdf0e10cSrcweir sal_uInt16 nKey = aKeyCode.GetCode(); 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir if ( nKey == KEY_RETURN && !aKeyCode.IsShift() ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir if ( m_pHelper ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir m_pHelper->LoseFocusHdl( m_pImplEdit ); 1132*cdf0e10cSrcweir m_pHelper->activateNextControl(); 1133*cdf0e10cSrcweir } 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir else if ( nKey == KEY_DOWN && aKeyCode.IsMod2() ) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir Invalidate(); 1138*cdf0e10cSrcweir ShowDropDown( sal_True ); 1139*cdf0e10cSrcweir } 1140*cdf0e10cSrcweir else if ( KEYGROUP_CURSOR == aKeyCode.GetGroup() 1141*cdf0e10cSrcweir || nKey == KEY_HELP 1142*cdf0e10cSrcweir || KEYGROUP_FKEYS == aKeyCode.GetGroup() 1143*cdf0e10cSrcweir || m_nOperationMode == eMultiLineText 1144*cdf0e10cSrcweir ) 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir nResult = DropDownEditControl_Base::PreNotify( rNEvt ); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir else if ( m_nOperationMode == eStringList ) 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir Selection aSel = m_pImplEdit->GetSelection(); 1151*cdf0e10cSrcweir if ( aSel.Min() != aSel.Max() ) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir aSel.Min() = FindPos( aSel.Min() ); 1154*cdf0e10cSrcweir aSel.Max() = FindPos( aSel.Max() ); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir else 1157*cdf0e10cSrcweir { 1158*cdf0e10cSrcweir aSel.Min() = FindPos( aSel.Min() ); 1159*cdf0e10cSrcweir aSel.Max() = aSel.Min(); 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir Invalidate(); 1162*cdf0e10cSrcweir ShowDropDown( sal_True ); 1163*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->GrabFocus(); 1164*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetSelection( aSel ); 1165*cdf0e10cSrcweir Window* pFocusWin = Application::GetFocusWindow(); 1166*cdf0e10cSrcweir pFocusWin->KeyInput( *rNEvt.GetKeyEvent() ); 1167*cdf0e10cSrcweir } 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir else 1170*cdf0e10cSrcweir nResult = DropDownEditControl_Base::PreNotify(rNEvt); 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir return nResult; 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir //------------------------------------------------------------------ 1176*cdf0e10cSrcweir namespace 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir //.............................................................. 1179*cdf0e10cSrcweir StlSyntaxSequence< ::rtl::OUString > lcl_convertMultiLineToList( const String& _rCompsedTextWithLineBreaks ) 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir xub_StrLen nLines( _rCompsedTextWithLineBreaks.GetTokenCount( '\n' ) ); 1182*cdf0e10cSrcweir StlSyntaxSequence< ::rtl::OUString > aStrings( nLines ); 1183*cdf0e10cSrcweir StlSyntaxSequence< ::rtl::OUString >::iterator stringItem = aStrings.begin(); 1184*cdf0e10cSrcweir for ( xub_StrLen token = 0; token < nLines; ++token, ++stringItem ) 1185*cdf0e10cSrcweir *stringItem = _rCompsedTextWithLineBreaks.GetToken( token, '\n' ); 1186*cdf0e10cSrcweir return aStrings; 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir String lcl_convertListToMultiLine( const StlSyntaxSequence< ::rtl::OUString >& _rStrings ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir String sMultiLineText; 1192*cdf0e10cSrcweir for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator item = _rStrings.begin(); 1193*cdf0e10cSrcweir item != _rStrings.end(); 1194*cdf0e10cSrcweir ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir sMultiLineText += String( *item ); 1197*cdf0e10cSrcweir if ( ++item != _rStrings.end() ) 1198*cdf0e10cSrcweir sMultiLineText += '\n'; 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir return sMultiLineText; 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir //.............................................................. 1204*cdf0e10cSrcweir String lcl_convertListToDisplayText( const StlSyntaxSequence< ::rtl::OUString >& _rStrings ) 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir ::rtl::OUStringBuffer aComposed; 1207*cdf0e10cSrcweir for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator strings = _rStrings.begin(); 1208*cdf0e10cSrcweir strings != _rStrings.end(); 1209*cdf0e10cSrcweir ++strings 1210*cdf0e10cSrcweir ) 1211*cdf0e10cSrcweir { 1212*cdf0e10cSrcweir if ( strings != _rStrings.begin() ) 1213*cdf0e10cSrcweir aComposed.append( (sal_Unicode)';' ); 1214*cdf0e10cSrcweir aComposed.append( (sal_Unicode)'\"' ); 1215*cdf0e10cSrcweir aComposed.append( *strings ); 1216*cdf0e10cSrcweir aComposed.append( (sal_Unicode)'\"' ); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir return aComposed.makeStringAndClear(); 1219*cdf0e10cSrcweir } 1220*cdf0e10cSrcweir } 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir //------------------------------------------------------------------ 1223*cdf0e10cSrcweir #define STD_HEIGHT 100 1224*cdf0e10cSrcweir sal_Bool DropDownEditControl::ShowDropDown( sal_Bool bShow ) 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir if (bShow) 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir ::Point aMePos= GetPosPixel(); 1229*cdf0e10cSrcweir aMePos = GetParent()->OutputToScreenPixel( aMePos ); 1230*cdf0e10cSrcweir ::Size aSize=GetSizePixel(); 1231*cdf0e10cSrcweir ::Rectangle aRect(aMePos,aSize); 1232*cdf0e10cSrcweir aSize.Height() = STD_HEIGHT; 1233*cdf0e10cSrcweir m_pFloatingEdit->SetOutputSizePixel(aSize); 1234*cdf0e10cSrcweir m_pFloatingEdit->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN ); 1235*cdf0e10cSrcweir 1236*cdf0e10cSrcweir m_pFloatingEdit->Show(); 1237*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->GrabFocus(); 1238*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetSelection(Selection(m_pFloatingEdit->getEdit()->GetText().Len())); 1239*cdf0e10cSrcweir m_bDropdown=sal_True; 1240*cdf0e10cSrcweir if ( m_nOperationMode == eMultiLineText ) 1241*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetText( m_pImplEdit->GetText() ); 1242*cdf0e10cSrcweir m_pImplEdit->SetText(String()); 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir else 1245*cdf0e10cSrcweir { 1246*cdf0e10cSrcweir m_pFloatingEdit->Hide(); 1247*cdf0e10cSrcweir m_pFloatingEdit->Invalidate(); 1248*cdf0e10cSrcweir m_pFloatingEdit->Update(); 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir // transfer the text from the floating edit to our own edit 1251*cdf0e10cSrcweir String sDisplayText( m_pFloatingEdit->getEdit()->GetText() ); 1252*cdf0e10cSrcweir if ( m_nOperationMode == eStringList ) 1253*cdf0e10cSrcweir sDisplayText = lcl_convertListToDisplayText( lcl_convertMultiLineToList( sDisplayText ) ); 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir m_pImplEdit->SetText( sDisplayText ); 1256*cdf0e10cSrcweir GetParent()->Invalidate( INVALIDATE_CHILDREN ); 1257*cdf0e10cSrcweir m_bDropdown = sal_False; 1258*cdf0e10cSrcweir m_pImplEdit->GrabFocus(); 1259*cdf0e10cSrcweir } 1260*cdf0e10cSrcweir return m_bDropdown; 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir } 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir //------------------------------------------------------------------ 1265*cdf0e10cSrcweir long DropDownEditControl::FindPos(long nSinglePos) 1266*cdf0e10cSrcweir { 1267*cdf0e10cSrcweir long nPos=0; 1268*cdf0e10cSrcweir long nDiff=0; 1269*cdf0e10cSrcweir String aOutput; 1270*cdf0e10cSrcweir String aStr=m_pFloatingEdit->getEdit()->GetText(); 1271*cdf0e10cSrcweir String aStr1 = GetText(); 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir if ((nSinglePos == 0) || (nSinglePos == aStr1.Len())) 1274*cdf0e10cSrcweir { 1275*cdf0e10cSrcweir return nSinglePos; 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir if (aStr.Len()>0) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir sal_Int32 nCount = aStr.GetTokenCount('\n'); 1281*cdf0e10cSrcweir 1282*cdf0e10cSrcweir String aInput = aStr.GetToken(0,'\n' ); 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir if (aInput.Len()>0) 1285*cdf0e10cSrcweir { 1286*cdf0e10cSrcweir aOutput+='\"'; 1287*cdf0e10cSrcweir nDiff++; 1288*cdf0e10cSrcweir aOutput+=aInput; 1289*cdf0e10cSrcweir aOutput+='\"'; 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir 1292*cdf0e10cSrcweir if (nSinglePos <= aOutput.Len()) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir nPos=nSinglePos-nDiff; 1295*cdf0e10cSrcweir } 1296*cdf0e10cSrcweir else 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir for (sal_Int32 i=1; i<nCount; ++i) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir aInput=aStr.GetToken((sal_uInt16)i, '\n'); 1301*cdf0e10cSrcweir if (aInput.Len()>0) 1302*cdf0e10cSrcweir { 1303*cdf0e10cSrcweir aOutput += ';'; 1304*cdf0e10cSrcweir aOutput += '\"'; 1305*cdf0e10cSrcweir nDiff += 2; 1306*cdf0e10cSrcweir aOutput += aInput; 1307*cdf0e10cSrcweir aOutput += '\"'; 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir if (nSinglePos <= aOutput.Len()) 1310*cdf0e10cSrcweir { 1311*cdf0e10cSrcweir nPos=nSinglePos-nDiff; 1312*cdf0e10cSrcweir break; 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir } 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir } 1318*cdf0e10cSrcweir return nPos; 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir //------------------------------------------------------------------ 1322*cdf0e10cSrcweir IMPL_LINK( DropDownEditControl, ReturnHdl, OMultilineFloatingEdit*, /*pMEd*/) 1323*cdf0e10cSrcweir { 1324*cdf0e10cSrcweir 1325*cdf0e10cSrcweir String aStr = m_pFloatingEdit->getEdit()->GetText(); 1326*cdf0e10cSrcweir String aStr2 = GetText(); 1327*cdf0e10cSrcweir ShowDropDown(sal_False); 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir if (aStr!=aStr2 || ( m_nOperationMode == eStringList ) ) 1330*cdf0e10cSrcweir { 1331*cdf0e10cSrcweir if ( m_pHelper ) 1332*cdf0e10cSrcweir m_pHelper->notifyModifiedValue(); 1333*cdf0e10cSrcweir } 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir return 0; 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir //------------------------------------------------------------------ 1339*cdf0e10cSrcweir IMPL_LINK( DropDownEditControl, DropDownHdl, PushButton*, /*pPb*/ ) 1340*cdf0e10cSrcweir { 1341*cdf0e10cSrcweir ShowDropDown(!m_bDropdown); 1342*cdf0e10cSrcweir return 0; 1343*cdf0e10cSrcweir } 1344*cdf0e10cSrcweir 1345*cdf0e10cSrcweir //------------------------------------------------------------------ 1346*cdf0e10cSrcweir void DropDownEditControl::SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings ) 1347*cdf0e10cSrcweir { 1348*cdf0e10cSrcweir SetText( lcl_convertListToDisplayText( _rStrings ) ); 1349*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetText( lcl_convertListToMultiLine( _rStrings ) ); 1350*cdf0e10cSrcweir } 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir //------------------------------------------------------------------ 1353*cdf0e10cSrcweir StlSyntaxSequence< ::rtl::OUString > DropDownEditControl::GetStringListValue() const 1354*cdf0e10cSrcweir { 1355*cdf0e10cSrcweir return lcl_convertMultiLineToList( m_pFloatingEdit->getEdit()->GetText() ); 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir //------------------------------------------------------------------ 1359*cdf0e10cSrcweir void DropDownEditControl::SetTextValue( const ::rtl::OUString& _rText ) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::SetTextValue: illegal call!" ); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir m_pFloatingEdit->getEdit()->SetText( _rText ); 1364*cdf0e10cSrcweir SetText( _rText ); 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir //------------------------------------------------------------------ 1368*cdf0e10cSrcweir ::rtl::OUString DropDownEditControl::GetTextValue() const 1369*cdf0e10cSrcweir { 1370*cdf0e10cSrcweir OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::GetTextValue: illegal call!" ); 1371*cdf0e10cSrcweir return GetText(); 1372*cdf0e10cSrcweir } 1373*cdf0e10cSrcweir 1374*cdf0e10cSrcweir //================================================================== 1375*cdf0e10cSrcweir //= OMultilineEditControl 1376*cdf0e10cSrcweir //================================================================== 1377*cdf0e10cSrcweir //------------------------------------------------------------------ 1378*cdf0e10cSrcweir OMultilineEditControl::OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle ) 1379*cdf0e10cSrcweir :OMultilineEditControl_Base( _eMode == eMultiLineText ? PropertyControlType::MultiLineTextField : PropertyControlType::StringListField 1380*cdf0e10cSrcweir , pParent 1381*cdf0e10cSrcweir , ( nWinStyle | WB_DIALOGCONTROL ) & ( ~WB_READONLY | ~WB_DROPDOWN ) 1382*cdf0e10cSrcweir , false ) 1383*cdf0e10cSrcweir { 1384*cdf0e10cSrcweir getTypedControlWindow()->setOperationMode( _eMode ); 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir //------------------------------------------------------------------ 1388*cdf0e10cSrcweir void SAL_CALL OMultilineEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException) 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir impl_checkDisposed_throw(); 1391*cdf0e10cSrcweir 1392*cdf0e10cSrcweir switch ( getTypedControlWindow()->getOperationMode() ) 1393*cdf0e10cSrcweir { 1394*cdf0e10cSrcweir case eMultiLineText: 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir ::rtl::OUString sText; 1397*cdf0e10cSrcweir if ( !( _rValue >>= sText ) && _rValue.hasValue() ) 1398*cdf0e10cSrcweir throw IllegalTypeException(); 1399*cdf0e10cSrcweir getTypedControlWindow()->SetTextValue( sText ); 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir break; 1402*cdf0e10cSrcweir case eStringList: 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir Sequence< ::rtl::OUString > aStringLines; 1405*cdf0e10cSrcweir if ( !( _rValue >>= aStringLines ) && _rValue.hasValue() ) 1406*cdf0e10cSrcweir throw IllegalTypeException(); 1407*cdf0e10cSrcweir getTypedControlWindow()->SetStringListValue( aStringLines ); 1408*cdf0e10cSrcweir } 1409*cdf0e10cSrcweir break; 1410*cdf0e10cSrcweir } 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir //------------------------------------------------------------------ 1414*cdf0e10cSrcweir Any SAL_CALL OMultilineEditControl::getValue() throw (RuntimeException) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir impl_checkDisposed_throw(); 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir Any aValue; 1419*cdf0e10cSrcweir switch ( getTypedControlWindow()->getOperationMode() ) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir case eMultiLineText: 1422*cdf0e10cSrcweir aValue <<= getTypedControlWindow()->GetTextValue(); 1423*cdf0e10cSrcweir break; 1424*cdf0e10cSrcweir case eStringList: 1425*cdf0e10cSrcweir aValue <<= getTypedControlWindow()->GetStringListValue(); 1426*cdf0e10cSrcweir break; 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir return aValue; 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir //------------------------------------------------------------------ 1432*cdf0e10cSrcweir Type SAL_CALL OMultilineEditControl::getValueType() throw (RuntimeException) 1433*cdf0e10cSrcweir { 1434*cdf0e10cSrcweir if ( getTypedControlWindow()->getOperationMode() == eMultiLineText ) 1435*cdf0e10cSrcweir return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); 1436*cdf0e10cSrcweir return ::getCppuType( static_cast< Sequence< ::rtl::OUString >* >( NULL ) ); 1437*cdf0e10cSrcweir } 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir //............................................................................ 1440*cdf0e10cSrcweir } // namespace pcr 1441*cdf0e10cSrcweir //............................................................................ 1442*cdf0e10cSrcweir 1443