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