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_svtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SVT_UNOIFACE_CXX 32*cdf0e10cSrcweir #include <tools/debug.hxx> 33*cdf0e10cSrcweir #include <vcl/svapp.hxx> 34*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 35*cdf0e10cSrcweir #include <unoiface.hxx> 36*cdf0e10cSrcweir #include <svtools/filedlg.hxx> 37*cdf0e10cSrcweir #include <svtools/filectrl.hxx> 38*cdf0e10cSrcweir #include <svtools/roadmap.hxx> 39*cdf0e10cSrcweir #include <svtools/fixedhyper.hxx> 40*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/awt/LineEndFormat.hpp> 43*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 44*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 45*cdf0e10cSrcweir #include <toolkit/helper/property.hxx> 46*cdf0e10cSrcweir #include <svtools/fmtfield.hxx> 47*cdf0e10cSrcweir #include <svl/numuno.hxx> 48*cdf0e10cSrcweir #include <svtools/calendar.hxx> 49*cdf0e10cSrcweir #include <svtools/prgsbar.hxx> 50*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 51*cdf0e10cSrcweir #include "treecontrolpeer.hxx" 52*cdf0e10cSrcweir #include "svtxgridcontrol.hxx" 53*cdf0e10cSrcweir #include <svtools/table/tablecontrol.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir static void lcl_setWinBits( Window* _pWindow, WinBits _nBits, sal_Bool _bSet ) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir WinBits nStyle = _pWindow->GetStyle(); 60*cdf0e10cSrcweir if ( _bSet ) 61*cdf0e10cSrcweir nStyle |= _nBits; 62*cdf0e10cSrcweir else 63*cdf0e10cSrcweir nStyle &= ~_nBits; 64*cdf0e10cSrcweir _pWindow->SetStyle( nStyle ); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // ---------------------------------------------------- 69*cdf0e10cSrcweir // help function for the toolkit... 70*cdf0e10cSrcweir // ---------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir extern "C" { 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, Window* pParent, WinBits nWinBits ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir Window* pWindow = NULL; 77*cdf0e10cSrcweir String aServiceName( pDescriptor->WindowServiceName ); 78*cdf0e10cSrcweir if ( aServiceName.EqualsIgnoreCaseAscii( "MultiLineEdit" ) ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if ( pParent ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir pWindow = new MultiLineEdit( pParent, nWinBits|WB_IGNORETAB); 83*cdf0e10cSrcweir static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus(); 84*cdf0e10cSrcweir *ppNewComp = new VCLXMultiLineEdit; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir else 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir *ppNewComp = NULL; 89*cdf0e10cSrcweir return NULL; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir else if ( aServiceName.EqualsIgnoreCaseAscii( "FileControl" ) ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if ( pParent ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir pWindow = new FileControl( pParent, nWinBits ); 97*cdf0e10cSrcweir *ppNewComp = new VCLXFileControl; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir else 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir *ppNewComp = NULL; 102*cdf0e10cSrcweir return NULL; 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir else if (aServiceName.EqualsIgnoreCaseAscii("FormattedField") ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir pWindow = new FormattedField( pParent, nWinBits ); 108*cdf0e10cSrcweir *ppNewComp = new SVTXFormattedField; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir else if (aServiceName.EqualsIgnoreCaseAscii("NumericField") ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir pWindow = new DoubleNumericField( pParent, nWinBits ); 113*cdf0e10cSrcweir *ppNewComp = new SVTXNumericField; 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir else if (aServiceName.EqualsIgnoreCaseAscii("LongCurrencyField") ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir pWindow = new DoubleCurrencyField( pParent, nWinBits ); 118*cdf0e10cSrcweir *ppNewComp = new SVTXCurrencyField; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir else if (aServiceName.EqualsIgnoreCaseAscii("datefield") ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir pWindow = new CalendarField( pParent, nWinBits); 123*cdf0e10cSrcweir static_cast<CalendarField*>(pWindow)->EnableToday(); 124*cdf0e10cSrcweir static_cast<CalendarField*>(pWindow)->EnableNone(); 125*cdf0e10cSrcweir static_cast<CalendarField*>(pWindow)->EnableEmptyFieldValue( sal_True ); 126*cdf0e10cSrcweir *ppNewComp = new SVTXDateField; 127*cdf0e10cSrcweir ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pWindow ); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir else if (aServiceName.EqualsIgnoreCaseAscii("roadmap") ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir pWindow = new ::svt::ORoadmap( pParent, WB_TABSTOP ); 132*cdf0e10cSrcweir *ppNewComp = new SVTXRoadmap; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir else if ( aServiceName.EqualsIgnoreCaseAscii( "ProgressBar" ) ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir if ( pParent ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir pWindow = new ProgressBar( pParent, nWinBits ); 139*cdf0e10cSrcweir *ppNewComp = new VCLXProgressBar; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir else 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir *ppNewComp = NULL; 144*cdf0e10cSrcweir return NULL; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir else if ( aServiceName.EqualsIgnoreCaseAscii( "Tree" ) ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir TreeControlPeer* pPeer = new TreeControlPeer; 150*cdf0e10cSrcweir *ppNewComp = pPeer; 151*cdf0e10cSrcweir pWindow = pPeer->createVclControl( pParent, nWinBits ); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir else if ( aServiceName.EqualsIgnoreCaseAscii( "FixedHyperlink" ) ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir if ( pParent ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir pWindow = new ::svt::FixedHyperlink( pParent, nWinBits ); 158*cdf0e10cSrcweir *ppNewComp = new VCLXFixedHyperlink; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir else 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir *ppNewComp = NULL; 163*cdf0e10cSrcweir return NULL; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir else if ( aServiceName.EqualsIgnoreCaseAscii( "Grid" ) ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir if ( pParent ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir pWindow = new ::svt::table::TableControl(pParent, nWinBits); 171*cdf0e10cSrcweir *ppNewComp = new SVTXGridControl; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir else 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir *ppNewComp = NULL; 176*cdf0e10cSrcweir return NULL; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir return pWindow; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir } // extern "C" 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir // ---------------------------------------------------- 185*cdf0e10cSrcweir // class VCLXMultiLineEdit 186*cdf0e10cSrcweir // ---------------------------------------------------- 187*cdf0e10cSrcweir VCLXMultiLineEdit::VCLXMultiLineEdit() 188*cdf0e10cSrcweir :maTextListeners( *this ) 189*cdf0e10cSrcweir ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir VCLXMultiLineEdit::~VCLXMultiLineEdit() 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMultiLineEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 200*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ), 201*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextArea*, this ), 202*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ), 203*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); 204*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 208*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXMultiLineEdit ) 209*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ), 210*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextArea>* ) NULL ), 211*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), 212*cdf0e10cSrcweir VCLXWindow::getTypes() 213*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir void VCLXMultiLineEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir maTextListeners.addInterface( l ); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir void VCLXMultiLineEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir maTextListeners.removeInterface( l ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir void VCLXMultiLineEdit::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow(); 230*cdf0e10cSrcweir if ( pEdit ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir pEdit->SetText( aText ); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir // #107218# Call same listeners like VCL would do after user interaction 235*cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_True ); 236*cdf0e10cSrcweir pEdit->SetModifyFlag(); 237*cdf0e10cSrcweir pEdit->Modify(); 238*cdf0e10cSrcweir SetSynthesizingVCLEvent( sal_False ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir void VCLXMultiLineEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow(); 247*cdf0e10cSrcweir if ( pEdit ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir setSelection( rSel ); 250*cdf0e10cSrcweir pEdit->ReplaceSelected( aText ); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getText() throw(::com::sun::star::uno::RuntimeException) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir ::rtl::OUString aText; 259*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow(); 260*cdf0e10cSrcweir if ( pEdit ) 261*cdf0e10cSrcweir aText = pEdit->GetText( meLineEndType ); 262*cdf0e10cSrcweir return aText; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir ::rtl::OUString aText; 270*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 271*cdf0e10cSrcweir if ( pMultiLineEdit) 272*cdf0e10cSrcweir aText = pMultiLineEdit->GetSelected( meLineEndType ); 273*cdf0e10cSrcweir return aText; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void VCLXMultiLineEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 282*cdf0e10cSrcweir if ( pMultiLineEdit ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir ::com::sun::star::awt::Selection VCLXMultiLineEdit::getSelection() throw(::com::sun::star::uno::RuntimeException) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir ::com::sun::star::awt::Selection aSel; 293*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 294*cdf0e10cSrcweir if ( pMultiLineEdit ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir aSel.Min = pMultiLineEdit->GetSelection().Min(); 297*cdf0e10cSrcweir aSel.Max = pMultiLineEdit->GetSelection().Max(); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir return aSel; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir sal_Bool VCLXMultiLineEdit::isEditable() throw(::com::sun::star::uno::RuntimeException) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 307*cdf0e10cSrcweir return ( pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled() ) ? sal_True : sal_False; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 315*cdf0e10cSrcweir if ( pMultiLineEdit ) 316*cdf0e10cSrcweir pMultiLineEdit->SetReadOnly( !bEditable ); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 324*cdf0e10cSrcweir if ( pMultiLineEdit ) 325*cdf0e10cSrcweir pMultiLineEdit->SetMaxTextLen( nLen ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir sal_Int16 VCLXMultiLineEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow(); 333*cdf0e10cSrcweir return pMultiLineEdit ? (sal_Int16)pMultiLineEdit->GetMaxTextLen() : (sal_Int16)0; 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir ::rtl::OUString VCLXMultiLineEdit::getTextLines() throw(::com::sun::star::uno::RuntimeException) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir ::rtl::OUString aText; 341*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow(); 342*cdf0e10cSrcweir if ( pEdit ) 343*cdf0e10cSrcweir aText = pEdit->GetTextLines( meLineEndType ); 344*cdf0e10cSrcweir return aText; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz; 352*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow(); 353*cdf0e10cSrcweir if ( pEdit ) 354*cdf0e10cSrcweir aSz = AWTSize(pEdit->CalcMinimumSize()); 355*cdf0e10cSrcweir return aSz; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getPreferredSize() throw(::com::sun::star::uno::RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir return getMinimumSize(); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = rNewSize; 368*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow(); 369*cdf0e10cSrcweir if ( pEdit ) 370*cdf0e10cSrcweir aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize ))); 371*cdf0e10cSrcweir return aSz; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz; 379*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow(); 380*cdf0e10cSrcweir if ( pEdit ) 381*cdf0e10cSrcweir aSz = AWTSize(pEdit->CalcSize( nCols, nLines )); 382*cdf0e10cSrcweir return aSz; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir nCols = nLines = 0; 390*cdf0e10cSrcweir MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow(); 391*cdf0e10cSrcweir if ( pEdit ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir sal_uInt16 nC, nL; 394*cdf0e10cSrcweir pEdit->GetMaxVisColumnsAndLines( nC, nL ); 395*cdf0e10cSrcweir nCols = nC; 396*cdf0e10cSrcweir nLines = nL; 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir case VCLEVENT_EDIT_MODIFY: 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir if ( maTextListeners.getLength() ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir ::com::sun::star::awt::TextEvent aEvent; 409*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 410*cdf0e10cSrcweir maTextListeners.textChanged( aEvent ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir break; 414*cdf0e10cSrcweir default: 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir VCLXWindow::ProcessWindowEvent( rVclWindowEvent ); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir break; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void VCLXMultiLineEdit::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow(); 427*cdf0e10cSrcweir if ( pMultiLineEdit ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 430*cdf0e10cSrcweir switch ( nPropType ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir case BASEPROPERTY_LINE_END_FORMAT: 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; 435*cdf0e10cSrcweir OSL_VERIFY( Value >>= nLineEndType ); 436*cdf0e10cSrcweir switch ( nLineEndType ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break; 439*cdf0e10cSrcweir case ::com::sun::star::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break; 440*cdf0e10cSrcweir case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break; 441*cdf0e10cSrcweir default: DBG_ERROR( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir break; 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir case BASEPROPERTY_READONLY: 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir sal_Bool b = sal_Bool(); 449*cdf0e10cSrcweir if ( Value >>= b ) 450*cdf0e10cSrcweir pMultiLineEdit->SetReadOnly( b ); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir break; 453*cdf0e10cSrcweir case BASEPROPERTY_MAXTEXTLEN: 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir sal_Int16 n = sal_Int16(); 456*cdf0e10cSrcweir if ( Value >>= n ) 457*cdf0e10cSrcweir pMultiLineEdit->SetMaxTextLen( n ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir break; 460*cdf0e10cSrcweir case BASEPROPERTY_HIDEINACTIVESELECTION: 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir sal_Bool b = sal_Bool(); 463*cdf0e10cSrcweir if ( Value >>= b ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir pMultiLineEdit->EnableFocusSelectionHide( b ); 466*cdf0e10cSrcweir lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b ); 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir break; 470*cdf0e10cSrcweir default: 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXMultiLineEdit::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 483*cdf0e10cSrcweir MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow(); 484*cdf0e10cSrcweir if ( pMultiLineEdit ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 487*cdf0e10cSrcweir switch ( nPropType ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir case BASEPROPERTY_LINE_END_FORMAT: 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; 492*cdf0e10cSrcweir switch ( meLineEndType ) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir case LINEEND_CR: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN; break; 495*cdf0e10cSrcweir case LINEEND_LF: nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; break; 496*cdf0e10cSrcweir case LINEEND_CRLF: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break; 497*cdf0e10cSrcweir default: DBG_ERROR( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir aProp <<= nLineEndType; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir break; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir case BASEPROPERTY_READONLY: 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir aProp <<= pMultiLineEdit->IsReadOnly(); 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir break; 508*cdf0e10cSrcweir case BASEPROPERTY_MAXTEXTLEN: 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir aProp <<= (sal_Int16) pMultiLineEdit->GetMaxTextLen(); 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir break; 513*cdf0e10cSrcweir default: 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir return aProp; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir void SAL_CALL VCLXMultiLineEdit::setFocus( ) throw(::com::sun::star::uno::RuntimeException) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir // don't grab the focus if we already have it. Reason is that the only thing which the edit 527*cdf0e10cSrcweir // does is forwarding the focus to it's text window. This text window then does a "select all". 528*cdf0e10cSrcweir // So if the text window already has the focus, and we give the focus to the multi line 529*cdf0e10cSrcweir // edit, then all which happens is that everything is selected. 530*cdf0e10cSrcweir // #i27072# - 2004-04-25 - fs@openoffice.org 531*cdf0e10cSrcweir if ( GetWindow() && !GetWindow()->HasChildPathFocus() ) 532*cdf0e10cSrcweir GetWindow()->GrabFocus(); 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir void VCLXMultiLineEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir PushPropertyIds( rIds, 538*cdf0e10cSrcweir // FIXME: elide duplication ? 539*cdf0e10cSrcweir BASEPROPERTY_LINE_END_FORMAT, 540*cdf0e10cSrcweir BASEPROPERTY_READONLY, 541*cdf0e10cSrcweir BASEPROPERTY_MAXTEXTLEN, 542*cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 543*cdf0e10cSrcweir 0); 544*cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds, true ); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir // ---------------------------------------------------- 548*cdf0e10cSrcweir // class VCLXFileControl 549*cdf0e10cSrcweir // ---------------------------------------------------- 550*cdf0e10cSrcweir VCLXFileControl::VCLXFileControl() : maTextListeners( *this ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir VCLXFileControl::~VCLXFileControl() 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir FileControl* pControl = (FileControl*) GetWindow(); 557*cdf0e10cSrcweir if ( pControl ) 558*cdf0e10cSrcweir pControl->GetEdit().SetModifyHdl( Link() ); 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXFileControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 564*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextComponent*, this ), 565*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ), 566*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); 567*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 571*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXFileControl ) 572*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ), 573*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), 574*cdf0e10cSrcweir VCLXWindow::getTypes() 575*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir void SAL_CALL VCLXFileControl::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir FileControl* pControl = (FileControl*)GetWindow(); 582*cdf0e10cSrcweir if ( pControl ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 585*cdf0e10cSrcweir switch ( nPropType ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir case BASEPROPERTY_HIDEINACTIVESELECTION: 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir sal_Bool bValue( sal_False ); 590*cdf0e10cSrcweir OSL_VERIFY( Value >>= bValue ); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue ); 593*cdf0e10cSrcweir lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue ); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir break; 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir default: 598*cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 599*cdf0e10cSrcweir break; 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir void VCLXFileControl::SetWindow( Window* pWindow ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir FileControl* pPrevFileControl = dynamic_cast<FileControl*>( GetWindow() ); 607*cdf0e10cSrcweir if ( pPrevFileControl ) 608*cdf0e10cSrcweir pPrevFileControl->GetEdit().SetModifyHdl( Link() ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow ); 611*cdf0e10cSrcweir if ( pNewFileControl ) 612*cdf0e10cSrcweir pNewFileControl->GetEdit().SetModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) ); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir VCLXWindow::SetWindow( pWindow ); 615*cdf0e10cSrcweir } 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir void VCLXFileControl::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir maTextListeners.addInterface( l ); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir void VCLXFileControl::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir maTextListeners.removeInterface( l ); 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir void VCLXFileControl::setText( const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir Window* pWindow = GetWindow(); 632*cdf0e10cSrcweir if ( pWindow ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir pWindow->SetText( aText ); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht. 637*cdf0e10cSrcweir // ::com::sun::star::awt::Toolkit soll JAVA-komform sein... 638*cdf0e10cSrcweir ModifyHdl( NULL ); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir void VCLXFileControl::insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 647*cdf0e10cSrcweir if ( pFileControl ) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) ); 650*cdf0e10cSrcweir pFileControl->GetEdit().ReplaceSelected( aText ); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir ::rtl::OUString VCLXFileControl::getText() throw(::com::sun::star::uno::RuntimeException) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir ::rtl::OUString aText; 659*cdf0e10cSrcweir Window* pWindow = GetWindow(); 660*cdf0e10cSrcweir if ( pWindow ) 661*cdf0e10cSrcweir aText = pWindow->GetText(); 662*cdf0e10cSrcweir return aText; 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir ::rtl::OUString VCLXFileControl::getSelectedText() throw(::com::sun::star::uno::RuntimeException) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir ::rtl::OUString aText; 670*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 671*cdf0e10cSrcweir if ( pFileControl) 672*cdf0e10cSrcweir aText = pFileControl->GetEdit().GetSelected(); 673*cdf0e10cSrcweir return aText; 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir void VCLXFileControl::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 682*cdf0e10cSrcweir if ( pFileControl ) 683*cdf0e10cSrcweir pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) ); 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir ::com::sun::star::awt::Selection VCLXFileControl::getSelection() throw(::com::sun::star::uno::RuntimeException) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir ::com::sun::star::awt::Selection aSel; 691*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 692*cdf0e10cSrcweir if ( pFileControl ) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir aSel.Min = pFileControl->GetEdit().GetSelection().Min(); 695*cdf0e10cSrcweir aSel.Max = pFileControl->GetEdit().GetSelection().Max(); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir return aSel; 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir sal_Bool VCLXFileControl::isEditable() throw(::com::sun::star::uno::RuntimeException) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 705*cdf0e10cSrcweir return ( pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled() ) ? sal_True : sal_False; 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir void VCLXFileControl::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 713*cdf0e10cSrcweir if ( pFileControl ) 714*cdf0e10cSrcweir pFileControl->GetEdit().SetReadOnly( !bEditable ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 722*cdf0e10cSrcweir if ( pFileControl ) 723*cdf0e10cSrcweir pFileControl->GetEdit().SetMaxTextLen( nLen ); 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir sal_Int16 VCLXFileControl::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir FileControl* pFileControl = (FileControl*) GetWindow(); 731*cdf0e10cSrcweir return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir IMPL_LINK( VCLXFileControl, ModifyHdl, Edit*, EMPTYARG ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir ::com::sun::star::awt::TextEvent aEvent; 738*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 739*cdf0e10cSrcweir maTextListeners.textChanged( aEvent ); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir return 1; 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize() throw(::com::sun::star::uno::RuntimeException) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz; 749*cdf0e10cSrcweir FileControl* pControl = (FileControl*) GetWindow(); 750*cdf0e10cSrcweir if ( pControl ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir Size aTmpSize = pControl->GetEdit().CalcMinimumSize(); 753*cdf0e10cSrcweir aTmpSize.Width() += pControl->GetButton().CalcMinimumSize().Width(); 754*cdf0e10cSrcweir aSz = AWTSize(pControl->CalcWindowSize( aTmpSize )); 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir return aSz; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getPreferredSize() throw(::com::sun::star::uno::RuntimeException) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz = getMinimumSize(); 762*cdf0e10cSrcweir aSz.Height += 4; 763*cdf0e10cSrcweir return aSz; 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz =rNewSize; 771*cdf0e10cSrcweir FileControl* pControl = (FileControl*) GetWindow(); 772*cdf0e10cSrcweir if ( pControl ) 773*cdf0e10cSrcweir { 774*cdf0e10cSrcweir ::com::sun::star::awt::Size aMinSz = getMinimumSize(); 775*cdf0e10cSrcweir if ( aSz.Height != aMinSz.Height ) 776*cdf0e10cSrcweir aSz.Height = aMinSz.Height; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir return aSz; 779*cdf0e10cSrcweir } 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir ::com::sun::star::awt::Size aSz; 786*cdf0e10cSrcweir FileControl* pControl = (FileControl*) GetWindow(); 787*cdf0e10cSrcweir if ( pControl ) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir aSz = AWTSize(pControl->GetEdit().CalcSize( nCols )); 790*cdf0e10cSrcweir aSz.Width += pControl->GetButton().CalcMinimumSize().Width(); 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir return aSz; 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir nCols = 0; 800*cdf0e10cSrcweir nLines = 1; 801*cdf0e10cSrcweir FileControl* pControl = (FileControl*) GetWindow(); 802*cdf0e10cSrcweir if ( pControl ) 803*cdf0e10cSrcweir nCols = (sal_Int16) pControl->GetEdit().GetMaxVisChars(); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir PushPropertyIds( rIds, 809*cdf0e10cSrcweir // FIXME: elide duplication ? 810*cdf0e10cSrcweir BASEPROPERTY_HIDEINACTIVESELECTION, 811*cdf0e10cSrcweir 0); 812*cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds, true ); 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir // ---------------------------------------------------- 817*cdf0e10cSrcweir // class SVTXFormattedField 818*cdf0e10cSrcweir // ---------------------------------------------------- 819*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 820*cdf0e10cSrcweir SVTXFormattedField::SVTXFormattedField() 821*cdf0e10cSrcweir :m_pCurrentSupplier(NULL) 822*cdf0e10cSrcweir ,bIsStandardSupplier(sal_True) 823*cdf0e10cSrcweir ,nKeyToSetDelayed(-1) 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 828*cdf0e10cSrcweir SVTXFormattedField::~SVTXFormattedField() 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir if (m_pCurrentSupplier) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir m_pCurrentSupplier->release(); 833*cdf0e10cSrcweir m_pCurrentSupplier = NULL; 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 838*cdf0e10cSrcweir void SVTXFormattedField::SetWindow( Window* _pWindow ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir VCLXSpinField::SetWindow(_pWindow); 841*cdf0e10cSrcweir if (GetFormattedField()) 842*cdf0e10cSrcweir GetFormattedField()->SetAutoColor(sal_True); 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 846*cdf0e10cSrcweir void SVTXFormattedField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 851*cdf0e10cSrcweir if ( pField ) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 854*cdf0e10cSrcweir switch (nPropType) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir case BASEPROPERTY_ENFORCE_FORMAT: 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir sal_Bool bEnable( sal_True ); 859*cdf0e10cSrcweir if ( Value >>= bEnable ) 860*cdf0e10cSrcweir pField->EnableNotANumber( !bEnable ); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir break; 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_MIN: 865*cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 866*cdf0e10cSrcweir SetMinValue(Value); 867*cdf0e10cSrcweir break; 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_MAX: 870*cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 871*cdf0e10cSrcweir SetMaxValue(Value); 872*cdf0e10cSrcweir break; 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_DEFAULT: 875*cdf0e10cSrcweir SetDefaultValue(Value); 876*cdf0e10cSrcweir break; 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir case BASEPROPERTY_TREATASNUMBER: 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir sal_Bool b = sal_Bool(); 881*cdf0e10cSrcweir if ( Value >>= b ) 882*cdf0e10cSrcweir SetTreatAsNumber(b); 883*cdf0e10cSrcweir } 884*cdf0e10cSrcweir break; 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir case BASEPROPERTY_FORMATSSUPPLIER: 887*cdf0e10cSrcweir if (!Value.hasValue()) 888*cdf0e10cSrcweir setFormatsSupplier(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > (NULL)); 889*cdf0e10cSrcweir else 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS; 892*cdf0e10cSrcweir if ( Value >>= xNFS ) 893*cdf0e10cSrcweir setFormatsSupplier(xNFS); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir break; 896*cdf0e10cSrcweir case BASEPROPERTY_FORMATKEY: 897*cdf0e10cSrcweir if (!Value.hasValue()) 898*cdf0e10cSrcweir setFormatKey(0); 899*cdf0e10cSrcweir else 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir sal_Int32 n = 0; 902*cdf0e10cSrcweir if ( Value >>= n ) 903*cdf0e10cSrcweir setFormatKey(n); 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir break; 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_VALUE: 908*cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 909*cdf0e10cSrcweir { 910*cdf0e10cSrcweir const ::com::sun::star::uno::TypeClass rTC = Value.getValueType().getTypeClass(); 911*cdf0e10cSrcweir if (rTC != ::com::sun::star::uno::TypeClass_STRING) 912*cdf0e10cSrcweir // no string 913*cdf0e10cSrcweir if (rTC != ::com::sun::star::uno::TypeClass_DOUBLE) 914*cdf0e10cSrcweir // no double 915*cdf0e10cSrcweir if (Value.hasValue()) 916*cdf0e10cSrcweir { // but a value 917*cdf0e10cSrcweir // try if it is something converitble 918*cdf0e10cSrcweir sal_Int32 nValue = 0; 919*cdf0e10cSrcweir if (!(Value >>= nValue)) 920*cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException(); 921*cdf0e10cSrcweir SetValue(::com::sun::star::uno::makeAny((double)nValue)); 922*cdf0e10cSrcweir break; 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir SetValue(Value); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir break; 928*cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir double d = 0.0; 931*cdf0e10cSrcweir if ( Value >>= d ) 932*cdf0e10cSrcweir pField->SetSpinSize( d ); 933*cdf0e10cSrcweir else 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir sal_Int32 n = 0; 936*cdf0e10cSrcweir if ( Value >>= n ) 937*cdf0e10cSrcweir pField->SetSpinSize( n ); 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir break; 941*cdf0e10cSrcweir case BASEPROPERTY_DECIMALACCURACY: 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir sal_Int32 n = 0; 944*cdf0e10cSrcweir if ( Value >>= n ) 945*cdf0e10cSrcweir pField->SetDecimalDigits( (sal_uInt16)n ); 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir break; 948*cdf0e10cSrcweir case BASEPROPERTY_NUMSHOWTHOUSANDSEP: 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir sal_Bool b = sal_Bool(); 951*cdf0e10cSrcweir if ( Value >>= b ) 952*cdf0e10cSrcweir pField->SetThousandsSep( b ); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir break; 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir default: 957*cdf0e10cSrcweir VCLXSpinField::setProperty( PropertyName, Value ); 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir if (BASEPROPERTY_TEXTCOLOR == nPropType) 961*cdf0e10cSrcweir { // after setting a new text color, think again about the AutoColor flag of the control 962*cdf0e10cSrcweir // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com 963*cdf0e10cSrcweir pField->SetAutoColor(!Value.hasValue()); 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir } 966*cdf0e10cSrcweir else 967*cdf0e10cSrcweir VCLXSpinField::setProperty( PropertyName, Value ); 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 971*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 978*cdf0e10cSrcweir if ( pField ) 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 981*cdf0e10cSrcweir switch (nPropType) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_MIN: 984*cdf0e10cSrcweir case BASEPROPERTY_VALUEMIN_DOUBLE: 985*cdf0e10cSrcweir aReturn <<= GetMinValue(); 986*cdf0e10cSrcweir break; 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_MAX: 989*cdf0e10cSrcweir case BASEPROPERTY_VALUEMAX_DOUBLE: 990*cdf0e10cSrcweir aReturn <<= GetMaxValue(); 991*cdf0e10cSrcweir break; 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_DEFAULT: 994*cdf0e10cSrcweir aReturn <<= GetDefaultValue(); 995*cdf0e10cSrcweir break; 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir case BASEPROPERTY_TREATASNUMBER: 998*cdf0e10cSrcweir aReturn <<= GetTreatAsNumber(); 999*cdf0e10cSrcweir break; 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir case BASEPROPERTY_EFFECTIVE_VALUE: 1002*cdf0e10cSrcweir case BASEPROPERTY_VALUE_DOUBLE: 1003*cdf0e10cSrcweir aReturn <<= GetValue(); 1004*cdf0e10cSrcweir break; 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir case BASEPROPERTY_VALUESTEP_DOUBLE: 1007*cdf0e10cSrcweir aReturn <<= pField->GetSpinSize(); 1008*cdf0e10cSrcweir break; 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir case BASEPROPERTY_DECIMALACCURACY: 1011*cdf0e10cSrcweir aReturn <<= pField->GetDecimalDigits(); 1012*cdf0e10cSrcweir break; 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir case BASEPROPERTY_FORMATSSUPPLIER: 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir if (!bIsStandardSupplier) 1017*cdf0e10cSrcweir { // ansonsten void 1018*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getFormatsSupplier(); 1019*cdf0e10cSrcweir aReturn <<= xSupplier; 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir } 1022*cdf0e10cSrcweir break; 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir case BASEPROPERTY_FORMATKEY: 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir if (!bIsStandardSupplier) 1027*cdf0e10cSrcweir aReturn <<= getFormatKey(); 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir break; 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir default: 1032*cdf0e10cSrcweir aReturn <<= VCLXSpinField::getProperty(PropertyName); 1033*cdf0e10cSrcweir } 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir return aReturn; 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1039*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::convertEffectiveValue(const ::com::sun::star::uno::Any& rValue) 1040*cdf0e10cSrcweir { 1041*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1044*cdf0e10cSrcweir if (!pField) 1045*cdf0e10cSrcweir return aReturn; 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir switch (rValue.getValueType().getTypeClass()) 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_DOUBLE: 1050*cdf0e10cSrcweir if (pField->TreatingAsNumber()) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir double d = 0.0; 1053*cdf0e10cSrcweir rValue >>= d; 1054*cdf0e10cSrcweir aReturn <<= d; 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir else 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir SvNumberFormatter* pFormatter = pField->GetFormatter(); 1059*cdf0e10cSrcweir if (!pFormatter) 1060*cdf0e10cSrcweir pFormatter = pField->StandardFormatter(); 1061*cdf0e10cSrcweir // should never fail 1062*cdf0e10cSrcweir 1063*cdf0e10cSrcweir Color* pDum; 1064*cdf0e10cSrcweir double d = 0.0; 1065*cdf0e10cSrcweir rValue >>= d; 1066*cdf0e10cSrcweir String sConverted; 1067*cdf0e10cSrcweir pFormatter->GetOutputString(d, 0, sConverted, &pDum); 1068*cdf0e10cSrcweir aReturn <<= ::rtl::OUString( sConverted ); 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir break; 1071*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_STRING: 1072*cdf0e10cSrcweir { 1073*cdf0e10cSrcweir ::rtl::OUString aStr; 1074*cdf0e10cSrcweir rValue >>= aStr; 1075*cdf0e10cSrcweir String sValue = aStr; 1076*cdf0e10cSrcweir if (pField->TreatingAsNumber()) 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir SvNumberFormatter* pFormatter = pField->GetFormatter(); 1079*cdf0e10cSrcweir if (!pFormatter) 1080*cdf0e10cSrcweir pFormatter = pField->StandardFormatter(); 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir double dVal; 1083*cdf0e10cSrcweir sal_uInt32 nTestFormat(0); 1084*cdf0e10cSrcweir if (!pFormatter->IsNumberFormat(sValue, nTestFormat, dVal)) 1085*cdf0e10cSrcweir aReturn.clear(); 1086*cdf0e10cSrcweir aReturn <<=dVal; 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir else 1089*cdf0e10cSrcweir aReturn <<= aStr; 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir break; 1092*cdf0e10cSrcweir default: 1093*cdf0e10cSrcweir aReturn.clear(); 1094*cdf0e10cSrcweir break; 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir return aReturn; 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1100*cdf0e10cSrcweir void SVTXFormattedField::SetMinValue(const ::com::sun::star::uno::Any& rValue) 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1103*cdf0e10cSrcweir if (!pField) 1104*cdf0e10cSrcweir return; 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir switch (rValue.getValueType().getTypeClass()) 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir { 1109*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_DOUBLE: 1110*cdf0e10cSrcweir { 1111*cdf0e10cSrcweir double d = 0.0; 1112*cdf0e10cSrcweir rValue >>= d; 1113*cdf0e10cSrcweir pField->SetMinValue(d); 1114*cdf0e10cSrcweir } 1115*cdf0e10cSrcweir break; 1116*cdf0e10cSrcweir default: 1117*cdf0e10cSrcweir DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !"); 1118*cdf0e10cSrcweir if ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID ) 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException(); 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir pField->ClearMinValue(); 1124*cdf0e10cSrcweir break; 1125*cdf0e10cSrcweir } 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1129*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetMinValue() 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1132*cdf0e10cSrcweir if (!pField || !pField->HasMinValue()) 1133*cdf0e10cSrcweir return ::com::sun::star::uno::Any(); 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1136*cdf0e10cSrcweir aReturn <<= pField->GetMinValue(); 1137*cdf0e10cSrcweir return aReturn; 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1141*cdf0e10cSrcweir void SVTXFormattedField::SetMaxValue(const ::com::sun::star::uno::Any& rValue) 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1144*cdf0e10cSrcweir if (!pField) 1145*cdf0e10cSrcweir return; 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir switch (rValue.getValueType().getTypeClass()) 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir { 1150*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_DOUBLE: 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir double d = 0.0; 1153*cdf0e10cSrcweir rValue >>= d; 1154*cdf0e10cSrcweir pField->SetMaxValue(d); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir break; 1157*cdf0e10cSrcweir default: 1158*cdf0e10cSrcweir if (rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID) 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException(); 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir pField->ClearMaxValue(); 1164*cdf0e10cSrcweir break; 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1169*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetMaxValue() 1170*cdf0e10cSrcweir { 1171*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1172*cdf0e10cSrcweir if (!pField || !pField->HasMaxValue()) 1173*cdf0e10cSrcweir return ::com::sun::star::uno::Any(); 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1176*cdf0e10cSrcweir aReturn <<= pField->GetMaxValue(); 1177*cdf0e10cSrcweir return aReturn; 1178*cdf0e10cSrcweir } 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1181*cdf0e10cSrcweir void SVTXFormattedField::SetDefaultValue(const ::com::sun::star::uno::Any& rValue) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1184*cdf0e10cSrcweir if (!pField) 1185*cdf0e10cSrcweir return; 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir ::com::sun::star::uno::Any aConverted = convertEffectiveValue(rValue); 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir switch (aConverted.getValueType().getTypeClass()) 1190*cdf0e10cSrcweir 1191*cdf0e10cSrcweir { 1192*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_DOUBLE: 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir double d = 0.0; 1195*cdf0e10cSrcweir aConverted >>= d; 1196*cdf0e10cSrcweir pField->SetDefaultValue(d); 1197*cdf0e10cSrcweir } 1198*cdf0e10cSrcweir break; 1199*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_STRING: 1200*cdf0e10cSrcweir { 1201*cdf0e10cSrcweir ::rtl::OUString aStr; 1202*cdf0e10cSrcweir aConverted >>= aStr; 1203*cdf0e10cSrcweir pField->SetDefaultText( aStr ); 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir break; 1206*cdf0e10cSrcweir default: 1207*cdf0e10cSrcweir pField->EnableEmptyField(sal_True); 1208*cdf0e10cSrcweir // nur noch void erlaubt 1209*cdf0e10cSrcweir break; 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir } 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1214*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetDefaultValue() 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1217*cdf0e10cSrcweir if (!pField || pField->IsEmptyFieldEnabled()) 1218*cdf0e10cSrcweir return ::com::sun::star::uno::Any(); 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1221*cdf0e10cSrcweir if (pField->TreatingAsNumber()) 1222*cdf0e10cSrcweir aReturn <<= pField->GetDefaultValue(); 1223*cdf0e10cSrcweir else 1224*cdf0e10cSrcweir aReturn <<= ::rtl::OUString( pField->GetDefaultText() ); 1225*cdf0e10cSrcweir return aReturn; 1226*cdf0e10cSrcweir } 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1229*cdf0e10cSrcweir sal_Bool SVTXFormattedField::GetTreatAsNumber() 1230*cdf0e10cSrcweir { 1231*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1232*cdf0e10cSrcweir if (pField) 1233*cdf0e10cSrcweir return pField->TreatingAsNumber(); 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir return sal_True; 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1239*cdf0e10cSrcweir void SVTXFormattedField::SetTreatAsNumber(sal_Bool bSet) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1242*cdf0e10cSrcweir if (pField) 1243*cdf0e10cSrcweir pField->TreatAsNumber(bSet); 1244*cdf0e10cSrcweir } 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1247*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXFormattedField::GetValue() 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1250*cdf0e10cSrcweir if (!pField) 1251*cdf0e10cSrcweir return ::com::sun::star::uno::Any(); 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1254*cdf0e10cSrcweir if (!pField->TreatingAsNumber()) 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir ::rtl::OUString sText = pField->GetTextValue(); 1257*cdf0e10cSrcweir aReturn <<= sText; 1258*cdf0e10cSrcweir } 1259*cdf0e10cSrcweir else 1260*cdf0e10cSrcweir { 1261*cdf0e10cSrcweir if (pField->GetText().Len()) // empty wird erst mal standardmaessig als void nach draussen gereicht 1262*cdf0e10cSrcweir aReturn <<= pField->GetValue(); 1263*cdf0e10cSrcweir } 1264*cdf0e10cSrcweir 1265*cdf0e10cSrcweir return aReturn; 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir 1268*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1269*cdf0e10cSrcweir void SVTXFormattedField::SetValue(const ::com::sun::star::uno::Any& rValue) 1270*cdf0e10cSrcweir { 1271*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1272*cdf0e10cSrcweir if (!pField) 1273*cdf0e10cSrcweir return; 1274*cdf0e10cSrcweir 1275*cdf0e10cSrcweir if (!rValue.hasValue()) 1276*cdf0e10cSrcweir { 1277*cdf0e10cSrcweir pField->SetText(String()); 1278*cdf0e10cSrcweir } 1279*cdf0e10cSrcweir else 1280*cdf0e10cSrcweir { 1281*cdf0e10cSrcweir if (rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE ) 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir double d = 0.0; 1284*cdf0e10cSrcweir rValue >>= d; 1285*cdf0e10cSrcweir pField->SetValue(d); 1286*cdf0e10cSrcweir } 1287*cdf0e10cSrcweir else 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !"); 1290*cdf0e10cSrcweir 1291*cdf0e10cSrcweir ::rtl::OUString sText; 1292*cdf0e10cSrcweir rValue >>= sText; 1293*cdf0e10cSrcweir String aStr( sText ); 1294*cdf0e10cSrcweir if (!pField->TreatingAsNumber()) 1295*cdf0e10cSrcweir pField->SetTextFormatted(aStr); 1296*cdf0e10cSrcweir else 1297*cdf0e10cSrcweir pField->SetTextValue(aStr); 1298*cdf0e10cSrcweir } 1299*cdf0e10cSrcweir } 1300*cdf0e10cSrcweir // NotifyTextListeners(); 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1304*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier(void) const 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir return ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > ((::com::sun::star::util::XNumberFormatsSupplier*)m_pCurrentSupplier); 1307*cdf0e10cSrcweir } 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1310*cdf0e10cSrcweir void SVTXFormattedField::setFormatsSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier) 1311*cdf0e10cSrcweir { 1312*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pNew = NULL; 1315*cdf0e10cSrcweir if (!xSupplier.is()) 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir if (pField) 1318*cdf0e10cSrcweir { 1319*cdf0e10cSrcweir pNew = new SvNumberFormatsSupplierObj(pField->StandardFormatter()); 1320*cdf0e10cSrcweir bIsStandardSupplier = sal_True; 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir else 1324*cdf0e10cSrcweir { 1325*cdf0e10cSrcweir pNew = SvNumberFormatsSupplierObj::getImplementation(xSupplier); 1326*cdf0e10cSrcweir bIsStandardSupplier = sal_False; 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir 1329*cdf0e10cSrcweir if (!pNew) 1330*cdf0e10cSrcweir return; // TODO : wie das behandeln ? 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir if (m_pCurrentSupplier) 1333*cdf0e10cSrcweir m_pCurrentSupplier->release(); 1334*cdf0e10cSrcweir m_pCurrentSupplier = pNew; 1335*cdf0e10cSrcweir m_pCurrentSupplier->acquire(); 1336*cdf0e10cSrcweir if (pField) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir // den aktuellen Value mit hinueberretten 1339*cdf0e10cSrcweir ::com::sun::star::uno::Any aCurrent = GetValue(); 1340*cdf0e10cSrcweir pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), sal_False); 1341*cdf0e10cSrcweir if (nKeyToSetDelayed != -1) 1342*cdf0e10cSrcweir { 1343*cdf0e10cSrcweir pField->SetFormatKey(nKeyToSetDelayed); 1344*cdf0e10cSrcweir nKeyToSetDelayed = -1; 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir SetValue(aCurrent); 1347*cdf0e10cSrcweir NotifyTextListeners(); 1348*cdf0e10cSrcweir } 1349*cdf0e10cSrcweir } 1350*cdf0e10cSrcweir 1351*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1352*cdf0e10cSrcweir sal_Int32 SVTXFormattedField::getFormatKey(void) const 1353*cdf0e10cSrcweir { 1354*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1355*cdf0e10cSrcweir return pField ? pField->GetFormatKey() : 0; 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1359*cdf0e10cSrcweir void SVTXFormattedField::setFormatKey(sal_Int32 nKey) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1362*cdf0e10cSrcweir if (pField) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir if (pField->GetFormatter()) 1365*cdf0e10cSrcweir pField->SetFormatKey(nKey); 1366*cdf0e10cSrcweir else 1367*cdf0e10cSrcweir { // Wahrscheinlich bin ich gerade in einem Block, in dem erst der Key und dann der Formatter gesetzt 1368*cdf0e10cSrcweir // wird, das passiert initial mit ziemlicher Sicherheit, da die Properties in alphabetischer Reihenfolge 1369*cdf0e10cSrcweir // gesetzt werden, und der FormatsSupplier nun mal vor dem FormatKey kommt 1370*cdf0e10cSrcweir nKeyToSetDelayed = nKey; 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir NotifyTextListeners(); 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir } 1375*cdf0e10cSrcweir 1376*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1377*cdf0e10cSrcweir void SVTXFormattedField::NotifyTextListeners() 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir if ( GetTextListeners().getLength() ) 1380*cdf0e10cSrcweir { 1381*cdf0e10cSrcweir ::com::sun::star::awt::TextEvent aEvent; 1382*cdf0e10cSrcweir aEvent.Source = (::cppu::OWeakObject*)this; 1383*cdf0e10cSrcweir GetTextListeners().textChanged( aEvent ); 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir void SVTXFormattedField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir PushPropertyIds( rIds, 1390*cdf0e10cSrcweir // FIXME: elide duplication ? 1391*cdf0e10cSrcweir BASEPROPERTY_EFFECTIVE_MIN, 1392*cdf0e10cSrcweir BASEPROPERTY_VALUEMIN_DOUBLE, 1393*cdf0e10cSrcweir BASEPROPERTY_EFFECTIVE_MAX, 1394*cdf0e10cSrcweir BASEPROPERTY_VALUEMAX_DOUBLE, 1395*cdf0e10cSrcweir BASEPROPERTY_EFFECTIVE_DEFAULT, 1396*cdf0e10cSrcweir BASEPROPERTY_TREATASNUMBER, 1397*cdf0e10cSrcweir BASEPROPERTY_EFFECTIVE_VALUE, 1398*cdf0e10cSrcweir BASEPROPERTY_VALUE_DOUBLE, 1399*cdf0e10cSrcweir BASEPROPERTY_VALUESTEP_DOUBLE, 1400*cdf0e10cSrcweir BASEPROPERTY_DECIMALACCURACY, 1401*cdf0e10cSrcweir BASEPROPERTY_FORMATSSUPPLIER, 1402*cdf0e10cSrcweir BASEPROPERTY_NUMSHOWTHOUSANDSEP, 1403*cdf0e10cSrcweir BASEPROPERTY_FORMATKEY, 1404*cdf0e10cSrcweir BASEPROPERTY_TREATASNUMBER, 1405*cdf0e10cSrcweir BASEPROPERTY_ENFORCE_FORMAT, 1406*cdf0e10cSrcweir 0); 1407*cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds, true ); 1408*cdf0e10cSrcweir VCLXSpinField::ImplGetPropertyIds( rIds ); 1409*cdf0e10cSrcweir } 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir // ---------------------------------------------------- 1413*cdf0e10cSrcweir // class SVTXRoadmap 1414*cdf0e10cSrcweir // ---------------------------------------------------- 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir using namespace svt; 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1419*cdf0e10cSrcweir SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this ) 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir } 1422*cdf0e10cSrcweir 1423*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1424*cdf0e10cSrcweir SVTXRoadmap::~SVTXRoadmap() 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir } 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 1431*cdf0e10cSrcweir { 1432*cdf0e10cSrcweir case VCLEVENT_ROADMAP_ITEMSELECTED: 1433*cdf0e10cSrcweir { 1434*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1435*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1436*cdf0e10cSrcweir if ( pField ) 1437*cdf0e10cSrcweir { 1438*cdf0e10cSrcweir sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); 1439*cdf0e10cSrcweir ::com::sun::star::awt::ItemEvent aEvent; 1440*cdf0e10cSrcweir aEvent.Selected = CurItemID; 1441*cdf0e10cSrcweir aEvent.Highlighted = CurItemID; 1442*cdf0e10cSrcweir aEvent.ItemId = CurItemID; 1443*cdf0e10cSrcweir maItemListeners.itemStateChanged( aEvent ); 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir } 1446*cdf0e10cSrcweir break; 1447*cdf0e10cSrcweir default: 1448*cdf0e10cSrcweir SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent ); 1449*cdf0e10cSrcweir break; 1450*cdf0e10cSrcweir } 1451*cdf0e10cSrcweir } 1452*cdf0e10cSrcweir 1453*cdf0e10cSrcweir 1454*cdf0e10cSrcweir void SVTXRoadmap::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException) 1455*cdf0e10cSrcweir { 1456*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1457*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1458*cdf0e10cSrcweir if ( pField ) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem; 1461*cdf0e10cSrcweir xRoadmapItem = evt.Source; 1462*cdf0e10cSrcweir sal_Int32 nID = 0; 1463*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY ); 1464*cdf0e10cSrcweir ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "ID" )); 1465*cdf0e10cSrcweir aValue >>= nID; 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir ::com::sun::star::uno::Any rVal = evt.NewValue; 1468*cdf0e10cSrcweir evt.NewValue >>= rVal; 1469*cdf0e10cSrcweir ::rtl::OUString sPropertyName = evt.PropertyName; 1470*cdf0e10cSrcweir if ( sPropertyName.equals(::rtl::OUString::createFromAscii( "Enabled" ) ) ) 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir sal_Bool bEnable = false; 1473*cdf0e10cSrcweir evt.NewValue >>= bEnable; 1474*cdf0e10cSrcweir pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable ); 1475*cdf0e10cSrcweir } 1476*cdf0e10cSrcweir else if ( sPropertyName.equals(::rtl::OUString::createFromAscii( "Label" ) ) ) 1477*cdf0e10cSrcweir { 1478*cdf0e10cSrcweir ::rtl::OUString sLabel; 1479*cdf0e10cSrcweir evt.NewValue >>= sLabel; 1480*cdf0e10cSrcweir pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel ); 1481*cdf0e10cSrcweir } 1482*cdf0e10cSrcweir else if ( sPropertyName.equals(::rtl::OUString::createFromAscii( "ID" ) ) ) 1483*cdf0e10cSrcweir { 1484*cdf0e10cSrcweir sal_Int32 nNewID = 0; 1485*cdf0e10cSrcweir evt.NewValue >>= nNewID; 1486*cdf0e10cSrcweir evt.OldValue >>= nID; 1487*cdf0e10cSrcweir pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID ); 1488*cdf0e10cSrcweir } 1489*cdf0e10cSrcweir // else 1490*cdf0e10cSrcweir // Todo: handle Interactive appropriately 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir } 1493*cdf0e10cSrcweir 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir void SVTXRoadmap::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException) 1496*cdf0e10cSrcweir { 1497*cdf0e10cSrcweir maItemListeners.addInterface( l ); 1498*cdf0e10cSrcweir } 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir void SVTXRoadmap::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException) 1501*cdf0e10cSrcweir { 1502*cdf0e10cSrcweir maItemListeners.removeInterface( l ); 1503*cdf0e10cSrcweir } 1504*cdf0e10cSrcweir 1505*cdf0e10cSrcweir RMItemData SVTXRoadmap::GetRMItemData( const ::com::sun::star::container::ContainerEvent& _rEvent ) 1506*cdf0e10cSrcweir { 1507*cdf0e10cSrcweir RMItemData aCurRMItemData; 1508*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem; 1509*cdf0e10cSrcweir _rEvent.Element >>= xRoadmapItem; 1510*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY ); 1511*cdf0e10cSrcweir if ( xPropertySet.is() ) 1512*cdf0e10cSrcweir { 1513*cdf0e10cSrcweir ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "Label" )); 1514*cdf0e10cSrcweir aValue >>= aCurRMItemData.Label; 1515*cdf0e10cSrcweir aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "ID" )); 1516*cdf0e10cSrcweir aValue >>= aCurRMItemData.n_ID; 1517*cdf0e10cSrcweir aValue = xPropertySet->getPropertyValue(::rtl::OUString::createFromAscii( "Enabled" )); 1518*cdf0e10cSrcweir aValue >>= aCurRMItemData.b_Enabled; 1519*cdf0e10cSrcweir } 1520*cdf0e10cSrcweir return aCurRMItemData;; 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir void SVTXRoadmap::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException) 1524*cdf0e10cSrcweir { 1525*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1526*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1527*cdf0e10cSrcweir if ( pField ) 1528*cdf0e10cSrcweir { 1529*cdf0e10cSrcweir RMItemData CurItemData = GetRMItemData( _rEvent ); 1530*cdf0e10cSrcweir sal_Int32 InsertIndex = 0; 1531*cdf0e10cSrcweir _rEvent.Accessor >>= InsertIndex; 1532*cdf0e10cSrcweir pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled ); 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir 1536*cdf0e10cSrcweir void SVTXRoadmap::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException) 1537*cdf0e10cSrcweir { 1538*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1539*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1540*cdf0e10cSrcweir if ( pField ) 1541*cdf0e10cSrcweir { 1542*cdf0e10cSrcweir sal_Int32 DelIndex = 0; 1543*cdf0e10cSrcweir _rEvent.Accessor >>= DelIndex; 1544*cdf0e10cSrcweir pField->DeleteRoadmapItem(DelIndex); 1545*cdf0e10cSrcweir // pField->GetCurrentRoadmapItem() 1546*cdf0e10cSrcweir // setProperty(::rtl::OUString.createFromAscii( "CurrentItem" )aAny, 1547*cdf0e10cSrcweir } 1548*cdf0e10cSrcweir } 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir void SVTXRoadmap::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1553*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1554*cdf0e10cSrcweir if ( pField ) 1555*cdf0e10cSrcweir { 1556*cdf0e10cSrcweir RMItemData CurItemData = GetRMItemData( _rEvent ); 1557*cdf0e10cSrcweir sal_Int32 ReplaceIndex = 0; 1558*cdf0e10cSrcweir _rEvent.Accessor >>= ReplaceIndex; 1559*cdf0e10cSrcweir pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled ); 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1566*cdf0e10cSrcweir void SVTXRoadmap::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 1567*cdf0e10cSrcweir { 1568*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1569*cdf0e10cSrcweir 1570*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1571*cdf0e10cSrcweir if ( pField ) 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1574*cdf0e10cSrcweir switch (nPropType) 1575*cdf0e10cSrcweir { 1576*cdf0e10cSrcweir case BASEPROPERTY_COMPLETE: 1577*cdf0e10cSrcweir { 1578*cdf0e10cSrcweir sal_Bool b = false; 1579*cdf0e10cSrcweir Value >>= b; 1580*cdf0e10cSrcweir pField->SetRoadmapComplete( b); 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir break; 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir case BASEPROPERTY_ACTIVATED: 1585*cdf0e10cSrcweir { 1586*cdf0e10cSrcweir sal_Bool b = false; 1587*cdf0e10cSrcweir Value >>= b; 1588*cdf0e10cSrcweir pField->SetRoadmapInteractive( b); 1589*cdf0e10cSrcweir } 1590*cdf0e10cSrcweir break; 1591*cdf0e10cSrcweir 1592*cdf0e10cSrcweir case BASEPROPERTY_CURRENTITEMID: 1593*cdf0e10cSrcweir { 1594*cdf0e10cSrcweir sal_Int32 nId = 0; 1595*cdf0e10cSrcweir Value >>= nId; 1596*cdf0e10cSrcweir pField->SelectRoadmapItemByID( (RoadmapTypes::ItemId)nId ); 1597*cdf0e10cSrcweir } 1598*cdf0e10cSrcweir break; 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir case BASEPROPERTY_TEXT: 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir ::rtl::OUString aStr; 1603*cdf0e10cSrcweir Value >>= aStr; 1604*cdf0e10cSrcweir pField->SetText( aStr ); 1605*cdf0e10cSrcweir pField->Invalidate(); 1606*cdf0e10cSrcweir } 1607*cdf0e10cSrcweir break; 1608*cdf0e10cSrcweir 1609*cdf0e10cSrcweir default: 1610*cdf0e10cSrcweir SVTXRoadmap_Base::setProperty( PropertyName, Value ); 1611*cdf0e10cSrcweir break; 1612*cdf0e10cSrcweir } 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir else 1616*cdf0e10cSrcweir SVTXRoadmap_Base::setProperty( PropertyName, Value ); 1617*cdf0e10cSrcweir } 1618*cdf0e10cSrcweir 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir // -------------------------------------------------------------------------------------- 1621*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXRoadmap::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 1622*cdf0e10cSrcweir { 1623*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir ::svt::ORoadmap* pField = GetRoadmap(); 1628*cdf0e10cSrcweir if ( pField ) 1629*cdf0e10cSrcweir { 1630*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 1631*cdf0e10cSrcweir switch (nPropType) 1632*cdf0e10cSrcweir { 1633*cdf0e10cSrcweir case BASEPROPERTY_COMPLETE: 1634*cdf0e10cSrcweir aReturn <<= pField->IsRoadmapComplete(); 1635*cdf0e10cSrcweir break; 1636*cdf0e10cSrcweir case BASEPROPERTY_ACTIVATED: 1637*cdf0e10cSrcweir aReturn <<= pField->IsRoadmapInteractive(); 1638*cdf0e10cSrcweir break; 1639*cdf0e10cSrcweir case BASEPROPERTY_CURRENTITEMID: 1640*cdf0e10cSrcweir aReturn <<= pField->GetCurrentRoadmapItemID(); 1641*cdf0e10cSrcweir break; 1642*cdf0e10cSrcweir default: 1643*cdf0e10cSrcweir aReturn = SVTXRoadmap_Base::getProperty(PropertyName); 1644*cdf0e10cSrcweir break; 1645*cdf0e10cSrcweir } 1646*cdf0e10cSrcweir } 1647*cdf0e10cSrcweir return aReturn; 1648*cdf0e10cSrcweir } 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir void SVTXRoadmap::ImplSetNewImage() 1651*cdf0e10cSrcweir { 1652*cdf0e10cSrcweir OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); 1653*cdf0e10cSrcweir ::svt::ORoadmap* pButton = static_cast< ::svt::ORoadmap* >( GetWindow() ); 1654*cdf0e10cSrcweir pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir void SVTXRoadmap::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir PushPropertyIds( rIds, 1660*cdf0e10cSrcweir BASEPROPERTY_COMPLETE, 1661*cdf0e10cSrcweir BASEPROPERTY_ACTIVATED, 1662*cdf0e10cSrcweir BASEPROPERTY_CURRENTITEMID, 1663*cdf0e10cSrcweir BASEPROPERTY_TEXT, 1664*cdf0e10cSrcweir 0); 1665*cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds, true ); 1666*cdf0e10cSrcweir VCLXGraphicControl::ImplGetPropertyIds( rIds ); 1667*cdf0e10cSrcweir } 1668*cdf0e10cSrcweir 1669*cdf0e10cSrcweir // ---------------------------------------------------- 1670*cdf0e10cSrcweir // class SVTXNumericField 1671*cdf0e10cSrcweir // ---------------------------------------------------- 1672*cdf0e10cSrcweir SVTXNumericField::SVTXNumericField() 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir } 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir SVTXNumericField::~SVTXNumericField() 1677*cdf0e10cSrcweir { 1678*cdf0e10cSrcweir } 1679*cdf0e10cSrcweir 1680*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 1681*cdf0e10cSrcweir { 1682*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 1683*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XNumericField*, this ), 1684*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); 1685*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType )); 1686*cdf0e10cSrcweir } 1687*cdf0e10cSrcweir 1688*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 1689*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( SVTXNumericField ) 1690*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ), 1691*cdf0e10cSrcweir SVTXFormattedField::getTypes() 1692*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir 1695*cdf0e10cSrcweir void SVTXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) 1696*cdf0e10cSrcweir { 1697*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1698*cdf0e10cSrcweir 1699*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1700*cdf0e10cSrcweir if ( pField ) 1701*cdf0e10cSrcweir pField->SetValue( Value ); 1702*cdf0e10cSrcweir } 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweir double SVTXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException) 1705*cdf0e10cSrcweir { 1706*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1709*cdf0e10cSrcweir return pField ? pField->GetValue() : 0; 1710*cdf0e10cSrcweir } 1711*cdf0e10cSrcweir 1712*cdf0e10cSrcweir void SVTXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) 1713*cdf0e10cSrcweir { 1714*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1715*cdf0e10cSrcweir 1716*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1717*cdf0e10cSrcweir if ( pField ) 1718*cdf0e10cSrcweir pField->SetMinValue( Value ); 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir 1721*cdf0e10cSrcweir double SVTXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException) 1722*cdf0e10cSrcweir { 1723*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1724*cdf0e10cSrcweir 1725*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1726*cdf0e10cSrcweir return pField ? pField->GetMinValue() : 0; 1727*cdf0e10cSrcweir } 1728*cdf0e10cSrcweir 1729*cdf0e10cSrcweir void SVTXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) 1730*cdf0e10cSrcweir { 1731*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1734*cdf0e10cSrcweir if ( pField ) 1735*cdf0e10cSrcweir pField->SetMaxValue( Value ); 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir 1738*cdf0e10cSrcweir double SVTXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException) 1739*cdf0e10cSrcweir { 1740*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1741*cdf0e10cSrcweir 1742*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1743*cdf0e10cSrcweir return pField ? pField->GetMaxValue() : 0; 1744*cdf0e10cSrcweir } 1745*cdf0e10cSrcweir 1746*cdf0e10cSrcweir void SVTXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) 1747*cdf0e10cSrcweir { 1748*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1749*cdf0e10cSrcweir 1750*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1751*cdf0e10cSrcweir if ( pField ) 1752*cdf0e10cSrcweir pField->SetSpinFirst( Value ); 1753*cdf0e10cSrcweir } 1754*cdf0e10cSrcweir 1755*cdf0e10cSrcweir double SVTXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException) 1756*cdf0e10cSrcweir { 1757*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1758*cdf0e10cSrcweir 1759*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1760*cdf0e10cSrcweir return pField ? pField->GetSpinFirst() : 0; 1761*cdf0e10cSrcweir } 1762*cdf0e10cSrcweir 1763*cdf0e10cSrcweir void SVTXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1766*cdf0e10cSrcweir 1767*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1768*cdf0e10cSrcweir if ( pField ) 1769*cdf0e10cSrcweir pField->SetSpinLast( Value ); 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir double SVTXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException) 1773*cdf0e10cSrcweir { 1774*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1775*cdf0e10cSrcweir 1776*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1777*cdf0e10cSrcweir return pField ? pField->GetSpinLast() : 0; 1778*cdf0e10cSrcweir } 1779*cdf0e10cSrcweir 1780*cdf0e10cSrcweir void SVTXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) 1781*cdf0e10cSrcweir { 1782*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1783*cdf0e10cSrcweir 1784*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1785*cdf0e10cSrcweir if ( pField ) 1786*cdf0e10cSrcweir pField->SetSpinSize( Value ); 1787*cdf0e10cSrcweir } 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir double SVTXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1792*cdf0e10cSrcweir 1793*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1794*cdf0e10cSrcweir return pField ? pField->GetSpinSize() : 0; 1795*cdf0e10cSrcweir } 1796*cdf0e10cSrcweir 1797*cdf0e10cSrcweir void SVTXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) 1798*cdf0e10cSrcweir { 1799*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1802*cdf0e10cSrcweir if ( pField ) 1803*cdf0e10cSrcweir pField->SetDecimalDigits( Value ); 1804*cdf0e10cSrcweir } 1805*cdf0e10cSrcweir 1806*cdf0e10cSrcweir sal_Int16 SVTXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) 1807*cdf0e10cSrcweir { 1808*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1809*cdf0e10cSrcweir 1810*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1811*cdf0e10cSrcweir return pField ? pField->GetDecimalDigits() : 0; 1812*cdf0e10cSrcweir } 1813*cdf0e10cSrcweir 1814*cdf0e10cSrcweir void SVTXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 1815*cdf0e10cSrcweir { 1816*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1817*cdf0e10cSrcweir 1818*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1819*cdf0e10cSrcweir if ( pField ) 1820*cdf0e10cSrcweir pField->SetStrictFormat( bStrict ); 1821*cdf0e10cSrcweir } 1822*cdf0e10cSrcweir 1823*cdf0e10cSrcweir sal_Bool SVTXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 1824*cdf0e10cSrcweir { 1825*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1828*cdf0e10cSrcweir return pField ? pField->IsStrictFormat() : sal_False; 1829*cdf0e10cSrcweir } 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir void SVTXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 1832*cdf0e10cSrcweir { 1833*cdf0e10cSrcweir SVTXFormattedField::ImplGetPropertyIds( rIds ); 1834*cdf0e10cSrcweir } 1835*cdf0e10cSrcweir 1836*cdf0e10cSrcweir // ---------------------------------------------------- 1837*cdf0e10cSrcweir // class SVTXCurrencyField 1838*cdf0e10cSrcweir // ---------------------------------------------------- 1839*cdf0e10cSrcweir SVTXCurrencyField::SVTXCurrencyField() 1840*cdf0e10cSrcweir { 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir SVTXCurrencyField::~SVTXCurrencyField() 1844*cdf0e10cSrcweir { 1845*cdf0e10cSrcweir } 1846*cdf0e10cSrcweir 1847*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 1848*cdf0e10cSrcweir { 1849*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 1850*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XCurrencyField*, this ), 1851*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); 1852*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType )); 1853*cdf0e10cSrcweir } 1854*cdf0e10cSrcweir 1855*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 1856*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( SVTXCurrencyField ) 1857*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ), 1858*cdf0e10cSrcweir SVTXFormattedField::getTypes() 1859*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 1860*cdf0e10cSrcweir 1861*cdf0e10cSrcweir void SVTXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException) 1862*cdf0e10cSrcweir { 1863*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1864*cdf0e10cSrcweir 1865*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1866*cdf0e10cSrcweir if ( pField ) 1867*cdf0e10cSrcweir pField->SetValue( Value ); 1868*cdf0e10cSrcweir } 1869*cdf0e10cSrcweir 1870*cdf0e10cSrcweir double SVTXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException) 1871*cdf0e10cSrcweir { 1872*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1873*cdf0e10cSrcweir 1874*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1875*cdf0e10cSrcweir return pField ? pField->GetValue() : 0; 1876*cdf0e10cSrcweir } 1877*cdf0e10cSrcweir 1878*cdf0e10cSrcweir void SVTXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException) 1879*cdf0e10cSrcweir { 1880*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1881*cdf0e10cSrcweir 1882*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1883*cdf0e10cSrcweir if ( pField ) 1884*cdf0e10cSrcweir pField->SetMinValue( Value ); 1885*cdf0e10cSrcweir } 1886*cdf0e10cSrcweir 1887*cdf0e10cSrcweir double SVTXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException) 1888*cdf0e10cSrcweir { 1889*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1890*cdf0e10cSrcweir 1891*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1892*cdf0e10cSrcweir return pField ? pField->GetMinValue() : 0; 1893*cdf0e10cSrcweir } 1894*cdf0e10cSrcweir 1895*cdf0e10cSrcweir void SVTXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException) 1896*cdf0e10cSrcweir { 1897*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1898*cdf0e10cSrcweir 1899*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1900*cdf0e10cSrcweir if ( pField ) 1901*cdf0e10cSrcweir pField->SetMaxValue( Value ); 1902*cdf0e10cSrcweir } 1903*cdf0e10cSrcweir 1904*cdf0e10cSrcweir double SVTXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1907*cdf0e10cSrcweir 1908*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1909*cdf0e10cSrcweir return pField ? pField->GetMaxValue() : 0; 1910*cdf0e10cSrcweir } 1911*cdf0e10cSrcweir 1912*cdf0e10cSrcweir void SVTXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException) 1913*cdf0e10cSrcweir { 1914*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1915*cdf0e10cSrcweir 1916*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1917*cdf0e10cSrcweir if ( pField ) 1918*cdf0e10cSrcweir pField->SetSpinFirst( Value ); 1919*cdf0e10cSrcweir } 1920*cdf0e10cSrcweir 1921*cdf0e10cSrcweir double SVTXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException) 1922*cdf0e10cSrcweir { 1923*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1924*cdf0e10cSrcweir 1925*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1926*cdf0e10cSrcweir return pField ? pField->GetSpinFirst() : 0; 1927*cdf0e10cSrcweir } 1928*cdf0e10cSrcweir 1929*cdf0e10cSrcweir void SVTXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException) 1930*cdf0e10cSrcweir { 1931*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1932*cdf0e10cSrcweir 1933*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1934*cdf0e10cSrcweir if ( pField ) 1935*cdf0e10cSrcweir pField->SetSpinLast( Value ); 1936*cdf0e10cSrcweir } 1937*cdf0e10cSrcweir 1938*cdf0e10cSrcweir double SVTXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException) 1939*cdf0e10cSrcweir { 1940*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1943*cdf0e10cSrcweir return pField ? pField->GetSpinLast() : 0; 1944*cdf0e10cSrcweir } 1945*cdf0e10cSrcweir 1946*cdf0e10cSrcweir void SVTXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException) 1947*cdf0e10cSrcweir { 1948*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1949*cdf0e10cSrcweir 1950*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1951*cdf0e10cSrcweir if ( pField ) 1952*cdf0e10cSrcweir pField->SetSpinSize( Value ); 1953*cdf0e10cSrcweir } 1954*cdf0e10cSrcweir 1955*cdf0e10cSrcweir double SVTXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException) 1956*cdf0e10cSrcweir { 1957*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1958*cdf0e10cSrcweir 1959*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1960*cdf0e10cSrcweir return pField ? pField->GetSpinSize() : 0; 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException) 1964*cdf0e10cSrcweir { 1965*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1966*cdf0e10cSrcweir 1967*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1968*cdf0e10cSrcweir if ( pField ) 1969*cdf0e10cSrcweir pField->SetDecimalDigits( Value ); 1970*cdf0e10cSrcweir } 1971*cdf0e10cSrcweir 1972*cdf0e10cSrcweir sal_Int16 SVTXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException) 1973*cdf0e10cSrcweir { 1974*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1975*cdf0e10cSrcweir 1976*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1977*cdf0e10cSrcweir return pField ? pField->GetDecimalDigits() : 0; 1978*cdf0e10cSrcweir } 1979*cdf0e10cSrcweir 1980*cdf0e10cSrcweir void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException) 1981*cdf0e10cSrcweir { 1982*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1983*cdf0e10cSrcweir 1984*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1985*cdf0e10cSrcweir if ( pField ) 1986*cdf0e10cSrcweir pField->SetStrictFormat( bStrict ); 1987*cdf0e10cSrcweir } 1988*cdf0e10cSrcweir 1989*cdf0e10cSrcweir sal_Bool SVTXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException) 1990*cdf0e10cSrcweir { 1991*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 1992*cdf0e10cSrcweir 1993*cdf0e10cSrcweir FormattedField* pField = GetFormattedField(); 1994*cdf0e10cSrcweir return pField ? pField->IsStrictFormat() : sal_False; 1995*cdf0e10cSrcweir } 1996*cdf0e10cSrcweir 1997*cdf0e10cSrcweir void SVTXCurrencyField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 1998*cdf0e10cSrcweir { 1999*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2000*cdf0e10cSrcweir 2001*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 2002*cdf0e10cSrcweir 2003*cdf0e10cSrcweir DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField(); 2004*cdf0e10cSrcweir if ( pField ) 2005*cdf0e10cSrcweir { 2006*cdf0e10cSrcweir #ifdef DBG_UTIL 2007*cdf0e10cSrcweir String sAssertion( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "SVTXCurrencyField::setProperty(" ) ) ); 2008*cdf0e10cSrcweir sAssertion += String( PropertyName ); 2009*cdf0e10cSrcweir sAssertion.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ") : invalid value !" ) ); 2010*cdf0e10cSrcweir #endif 2011*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2012*cdf0e10cSrcweir switch (nPropType) 2013*cdf0e10cSrcweir { 2014*cdf0e10cSrcweir case BASEPROPERTY_CURRENCYSYMBOL: 2015*cdf0e10cSrcweir { 2016*cdf0e10cSrcweir ::rtl::OUString aStr; 2017*cdf0e10cSrcweir Value >>= aStr; 2018*cdf0e10cSrcweir pField->setCurrencySymbol( aStr ); 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir break; 2021*cdf0e10cSrcweir case BASEPROPERTY_CURSYM_POSITION: 2022*cdf0e10cSrcweir { 2023*cdf0e10cSrcweir sal_Bool b = false; 2024*cdf0e10cSrcweir Value >>= b; 2025*cdf0e10cSrcweir pField->setPrependCurrSym(b); 2026*cdf0e10cSrcweir } 2027*cdf0e10cSrcweir break; 2028*cdf0e10cSrcweir 2029*cdf0e10cSrcweir default: 2030*cdf0e10cSrcweir SVTXFormattedField::setProperty(PropertyName, Value); 2031*cdf0e10cSrcweir } 2032*cdf0e10cSrcweir } 2033*cdf0e10cSrcweir else 2034*cdf0e10cSrcweir SVTXFormattedField::setProperty(PropertyName, Value); 2035*cdf0e10cSrcweir } 2036*cdf0e10cSrcweir 2037*cdf0e10cSrcweir ::com::sun::star::uno::Any SVTXCurrencyField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 2038*cdf0e10cSrcweir { 2039*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2040*cdf0e10cSrcweir 2041*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn; 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField(); 2044*cdf0e10cSrcweir if ( pField ) 2045*cdf0e10cSrcweir { 2046*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2047*cdf0e10cSrcweir switch (nPropType) 2048*cdf0e10cSrcweir { 2049*cdf0e10cSrcweir case BASEPROPERTY_CURRENCYSYMBOL: 2050*cdf0e10cSrcweir { 2051*cdf0e10cSrcweir aReturn <<= ::rtl::OUString( pField->getCurrencySymbol() ); 2052*cdf0e10cSrcweir } 2053*cdf0e10cSrcweir break; 2054*cdf0e10cSrcweir case BASEPROPERTY_CURSYM_POSITION: 2055*cdf0e10cSrcweir { 2056*cdf0e10cSrcweir aReturn <<= pField->getPrependCurrSym(); 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir break; 2059*cdf0e10cSrcweir default: 2060*cdf0e10cSrcweir return SVTXFormattedField::getProperty(PropertyName); 2061*cdf0e10cSrcweir } 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir return SVTXFormattedField::getProperty(PropertyName); 2064*cdf0e10cSrcweir } 2065*cdf0e10cSrcweir 2066*cdf0e10cSrcweir void SVTXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2067*cdf0e10cSrcweir { 2068*cdf0e10cSrcweir PushPropertyIds( rIds, 2069*cdf0e10cSrcweir BASEPROPERTY_CURRENCYSYMBOL, 2070*cdf0e10cSrcweir BASEPROPERTY_CURSYM_POSITION, 2071*cdf0e10cSrcweir 0); 2072*cdf0e10cSrcweir SVTXFormattedField::ImplGetPropertyIds( rIds ); 2073*cdf0e10cSrcweir } 2074*cdf0e10cSrcweir 2075*cdf0e10cSrcweir 2076*cdf0e10cSrcweir // ---------------------------------------------------- 2077*cdf0e10cSrcweir // class VCLXProgressBar 2078*cdf0e10cSrcweir // ---------------------------------------------------- 2079*cdf0e10cSrcweir 2080*cdf0e10cSrcweir VCLXProgressBar::VCLXProgressBar() 2081*cdf0e10cSrcweir :m_nValue(0) 2082*cdf0e10cSrcweir ,m_nValueMin(0) 2083*cdf0e10cSrcweir ,m_nValueMax(100) 2084*cdf0e10cSrcweir { 2085*cdf0e10cSrcweir } 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir VCLXProgressBar::~VCLXProgressBar() 2088*cdf0e10cSrcweir { 2089*cdf0e10cSrcweir } 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir void VCLXProgressBar::ImplUpdateValue() 2092*cdf0e10cSrcweir { 2093*cdf0e10cSrcweir ProgressBar* pProgressBar = (ProgressBar*) GetWindow(); 2094*cdf0e10cSrcweir if ( pProgressBar ) 2095*cdf0e10cSrcweir { 2096*cdf0e10cSrcweir sal_Int32 nVal; 2097*cdf0e10cSrcweir sal_Int32 nValMin; 2098*cdf0e10cSrcweir sal_Int32 nValMax; 2099*cdf0e10cSrcweir 2100*cdf0e10cSrcweir // check min and max 2101*cdf0e10cSrcweir if (m_nValueMin < m_nValueMax) 2102*cdf0e10cSrcweir { 2103*cdf0e10cSrcweir nValMin = m_nValueMin; 2104*cdf0e10cSrcweir nValMax = m_nValueMax; 2105*cdf0e10cSrcweir } 2106*cdf0e10cSrcweir else 2107*cdf0e10cSrcweir { 2108*cdf0e10cSrcweir nValMin = m_nValueMax; 2109*cdf0e10cSrcweir nValMax = m_nValueMin; 2110*cdf0e10cSrcweir } 2111*cdf0e10cSrcweir 2112*cdf0e10cSrcweir // check value 2113*cdf0e10cSrcweir if (m_nValue < nValMin) 2114*cdf0e10cSrcweir { 2115*cdf0e10cSrcweir nVal = nValMin; 2116*cdf0e10cSrcweir } 2117*cdf0e10cSrcweir else if (m_nValue > nValMax) 2118*cdf0e10cSrcweir { 2119*cdf0e10cSrcweir nVal = nValMax; 2120*cdf0e10cSrcweir } 2121*cdf0e10cSrcweir else 2122*cdf0e10cSrcweir { 2123*cdf0e10cSrcweir nVal = m_nValue; 2124*cdf0e10cSrcweir } 2125*cdf0e10cSrcweir 2126*cdf0e10cSrcweir // calculate percent 2127*cdf0e10cSrcweir sal_Int32 nPercent; 2128*cdf0e10cSrcweir if (nValMin != nValMax) 2129*cdf0e10cSrcweir { 2130*cdf0e10cSrcweir nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin); 2131*cdf0e10cSrcweir } 2132*cdf0e10cSrcweir else 2133*cdf0e10cSrcweir { 2134*cdf0e10cSrcweir nPercent = 0; 2135*cdf0e10cSrcweir } 2136*cdf0e10cSrcweir 2137*cdf0e10cSrcweir // set progressbar value 2138*cdf0e10cSrcweir pProgressBar->SetValue( (sal_uInt16) nPercent ); 2139*cdf0e10cSrcweir } 2140*cdf0e10cSrcweir } 2141*cdf0e10cSrcweir 2142*cdf0e10cSrcweir // ::com::sun::star::uno::XInterface 2143*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXProgressBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 2144*cdf0e10cSrcweir { 2145*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, 2146*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XProgressBar*, this ), 2147*cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); 2148*cdf0e10cSrcweir return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); 2149*cdf0e10cSrcweir } 2150*cdf0e10cSrcweir 2151*cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider 2152*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXProgressBar ) 2153*cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar>* ) NULL ), 2154*cdf0e10cSrcweir VCLXWindow::getTypes() 2155*cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END 2156*cdf0e10cSrcweir 2157*cdf0e10cSrcweir // ::com::sun::star::awt::XProgressBar 2158*cdf0e10cSrcweir void VCLXProgressBar::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) 2159*cdf0e10cSrcweir { 2160*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2161*cdf0e10cSrcweir 2162*cdf0e10cSrcweir Window* pWindow = GetWindow(); 2163*cdf0e10cSrcweir if ( pWindow ) 2164*cdf0e10cSrcweir { 2165*cdf0e10cSrcweir Color aColor( nColor ); 2166*cdf0e10cSrcweir pWindow->SetControlForeground( aColor ); 2167*cdf0e10cSrcweir } 2168*cdf0e10cSrcweir } 2169*cdf0e10cSrcweir 2170*cdf0e10cSrcweir void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException) 2171*cdf0e10cSrcweir { 2172*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2173*cdf0e10cSrcweir 2174*cdf0e10cSrcweir Window* pWindow = GetWindow(); 2175*cdf0e10cSrcweir if ( pWindow ) 2176*cdf0e10cSrcweir { 2177*cdf0e10cSrcweir Color aColor( nColor ); 2178*cdf0e10cSrcweir pWindow->SetBackground( aColor ); 2179*cdf0e10cSrcweir pWindow->SetControlBackground( aColor ); 2180*cdf0e10cSrcweir pWindow->Invalidate(); 2181*cdf0e10cSrcweir } 2182*cdf0e10cSrcweir } 2183*cdf0e10cSrcweir 2184*cdf0e10cSrcweir void VCLXProgressBar::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException) 2185*cdf0e10cSrcweir { 2186*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2187*cdf0e10cSrcweir 2188*cdf0e10cSrcweir m_nValue = nValue; 2189*cdf0e10cSrcweir ImplUpdateValue(); 2190*cdf0e10cSrcweir } 2191*cdf0e10cSrcweir 2192*cdf0e10cSrcweir void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException ) 2193*cdf0e10cSrcweir { 2194*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2195*cdf0e10cSrcweir 2196*cdf0e10cSrcweir if ( nMin < nMax ) 2197*cdf0e10cSrcweir { 2198*cdf0e10cSrcweir // take correct min and max 2199*cdf0e10cSrcweir m_nValueMin = nMin; 2200*cdf0e10cSrcweir m_nValueMax = nMax; 2201*cdf0e10cSrcweir } 2202*cdf0e10cSrcweir else 2203*cdf0e10cSrcweir { 2204*cdf0e10cSrcweir // change min and max 2205*cdf0e10cSrcweir m_nValueMin = nMax; 2206*cdf0e10cSrcweir m_nValueMax = nMin; 2207*cdf0e10cSrcweir } 2208*cdf0e10cSrcweir 2209*cdf0e10cSrcweir ImplUpdateValue(); 2210*cdf0e10cSrcweir } 2211*cdf0e10cSrcweir 2212*cdf0e10cSrcweir sal_Int32 VCLXProgressBar::getValue() throw(::com::sun::star::uno::RuntimeException) 2213*cdf0e10cSrcweir { 2214*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2215*cdf0e10cSrcweir 2216*cdf0e10cSrcweir return m_nValue; 2217*cdf0e10cSrcweir } 2218*cdf0e10cSrcweir 2219*cdf0e10cSrcweir // ::com::sun::star::awt::VclWindowPeer 2220*cdf0e10cSrcweir void VCLXProgressBar::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException) 2221*cdf0e10cSrcweir { 2222*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2223*cdf0e10cSrcweir 2224*cdf0e10cSrcweir ProgressBar* pProgressBar = (ProgressBar*)GetWindow(); 2225*cdf0e10cSrcweir if ( pProgressBar ) 2226*cdf0e10cSrcweir { 2227*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2228*cdf0e10cSrcweir switch ( nPropType ) 2229*cdf0e10cSrcweir { 2230*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE: 2231*cdf0e10cSrcweir { 2232*cdf0e10cSrcweir if ( Value >>= m_nValue ) 2233*cdf0e10cSrcweir ImplUpdateValue(); 2234*cdf0e10cSrcweir } 2235*cdf0e10cSrcweir break; 2236*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE_MIN: 2237*cdf0e10cSrcweir { 2238*cdf0e10cSrcweir if ( Value >>= m_nValueMin ) 2239*cdf0e10cSrcweir ImplUpdateValue(); 2240*cdf0e10cSrcweir } 2241*cdf0e10cSrcweir break; 2242*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE_MAX: 2243*cdf0e10cSrcweir { 2244*cdf0e10cSrcweir if ( Value >>= m_nValueMax ) 2245*cdf0e10cSrcweir ImplUpdateValue(); 2246*cdf0e10cSrcweir } 2247*cdf0e10cSrcweir break; 2248*cdf0e10cSrcweir case BASEPROPERTY_FILLCOLOR: 2249*cdf0e10cSrcweir { 2250*cdf0e10cSrcweir Window* pWindow = GetWindow(); 2251*cdf0e10cSrcweir if ( pWindow ) 2252*cdf0e10cSrcweir { 2253*cdf0e10cSrcweir sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; 2254*cdf0e10cSrcweir 2255*cdf0e10cSrcweir if ( bVoid ) 2256*cdf0e10cSrcweir { 2257*cdf0e10cSrcweir pWindow->SetControlForeground(); 2258*cdf0e10cSrcweir } 2259*cdf0e10cSrcweir else 2260*cdf0e10cSrcweir { 2261*cdf0e10cSrcweir sal_Int32 nColor = 0; 2262*cdf0e10cSrcweir if ( Value >>= nColor ) 2263*cdf0e10cSrcweir { 2264*cdf0e10cSrcweir Color aColor( nColor ); 2265*cdf0e10cSrcweir pWindow->SetControlForeground( aColor ); 2266*cdf0e10cSrcweir } 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir } 2269*cdf0e10cSrcweir } 2270*cdf0e10cSrcweir break; 2271*cdf0e10cSrcweir default: 2272*cdf0e10cSrcweir VCLXWindow::setProperty( PropertyName, Value ); 2273*cdf0e10cSrcweir break; 2274*cdf0e10cSrcweir } 2275*cdf0e10cSrcweir } 2276*cdf0e10cSrcweir } 2277*cdf0e10cSrcweir 2278*cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXProgressBar::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException) 2279*cdf0e10cSrcweir { 2280*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 2281*cdf0e10cSrcweir 2282*cdf0e10cSrcweir ::com::sun::star::uno::Any aProp; 2283*cdf0e10cSrcweir ProgressBar* pProgressBar = (ProgressBar*)GetWindow(); 2284*cdf0e10cSrcweir if ( pProgressBar ) 2285*cdf0e10cSrcweir { 2286*cdf0e10cSrcweir sal_uInt16 nPropType = GetPropertyId( PropertyName ); 2287*cdf0e10cSrcweir switch ( nPropType ) 2288*cdf0e10cSrcweir { 2289*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE: 2290*cdf0e10cSrcweir { 2291*cdf0e10cSrcweir aProp <<= m_nValue; 2292*cdf0e10cSrcweir } 2293*cdf0e10cSrcweir break; 2294*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE_MIN: 2295*cdf0e10cSrcweir { 2296*cdf0e10cSrcweir aProp <<= m_nValueMin; 2297*cdf0e10cSrcweir } 2298*cdf0e10cSrcweir break; 2299*cdf0e10cSrcweir case BASEPROPERTY_PROGRESSVALUE_MAX: 2300*cdf0e10cSrcweir { 2301*cdf0e10cSrcweir aProp <<= m_nValueMax; 2302*cdf0e10cSrcweir } 2303*cdf0e10cSrcweir break; 2304*cdf0e10cSrcweir default: 2305*cdf0e10cSrcweir aProp <<= VCLXWindow::getProperty( PropertyName ); 2306*cdf0e10cSrcweir break; 2307*cdf0e10cSrcweir } 2308*cdf0e10cSrcweir } 2309*cdf0e10cSrcweir return aProp; 2310*cdf0e10cSrcweir } 2311*cdf0e10cSrcweir 2312*cdf0e10cSrcweir void VCLXProgressBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2313*cdf0e10cSrcweir { 2314*cdf0e10cSrcweir PushPropertyIds( rIds, 2315*cdf0e10cSrcweir BASEPROPERTY_PROGRESSVALUE, 2316*cdf0e10cSrcweir BASEPROPERTY_PROGRESSVALUE_MIN, 2317*cdf0e10cSrcweir BASEPROPERTY_PROGRESSVALUE_MAX, 2318*cdf0e10cSrcweir BASEPROPERTY_FILLCOLOR, 2319*cdf0e10cSrcweir 0); 2320*cdf0e10cSrcweir VCLXWindow::ImplGetPropertyIds( rIds, true ); 2321*cdf0e10cSrcweir } 2322*cdf0e10cSrcweir 2323*cdf0e10cSrcweir 2324*cdf0e10cSrcweir // ---------------------------------------------------- 2325*cdf0e10cSrcweir // class SVTXDateField 2326*cdf0e10cSrcweir // ---------------------------------------------------- 2327*cdf0e10cSrcweir SVTXDateField::SVTXDateField() 2328*cdf0e10cSrcweir :VCLXDateField() 2329*cdf0e10cSrcweir { 2330*cdf0e10cSrcweir } 2331*cdf0e10cSrcweir 2332*cdf0e10cSrcweir SVTXDateField::~SVTXDateField() 2333*cdf0e10cSrcweir { 2334*cdf0e10cSrcweir } 2335*cdf0e10cSrcweir 2336*cdf0e10cSrcweir void SAL_CALL SVTXDateField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException) 2337*cdf0e10cSrcweir { 2338*cdf0e10cSrcweir VCLXDateField::setProperty( PropertyName, Value ); 2339*cdf0e10cSrcweir 2340*cdf0e10cSrcweir // some properties need to be forwarded to the sub edit, too 2341*cdf0e10cSrcweir Edit* pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow() )->GetSubEdit() : NULL; 2342*cdf0e10cSrcweir if ( !pSubEdit ) 2343*cdf0e10cSrcweir return; 2344*cdf0e10cSrcweir 2345*cdf0e10cSrcweir switch ( GetPropertyId( PropertyName ) ) 2346*cdf0e10cSrcweir { 2347*cdf0e10cSrcweir case BASEPROPERTY_TEXTLINECOLOR: 2348*cdf0e10cSrcweir if ( !Value.hasValue() ) 2349*cdf0e10cSrcweir pSubEdit->SetTextLineColor(); 2350*cdf0e10cSrcweir else 2351*cdf0e10cSrcweir { 2352*cdf0e10cSrcweir sal_Int32 nColor = 0; 2353*cdf0e10cSrcweir if ( Value >>= nColor ) 2354*cdf0e10cSrcweir pSubEdit->SetTextLineColor( Color( nColor ) ); 2355*cdf0e10cSrcweir } 2356*cdf0e10cSrcweir break; 2357*cdf0e10cSrcweir } 2358*cdf0e10cSrcweir } 2359*cdf0e10cSrcweir 2360*cdf0e10cSrcweir void SVTXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) 2361*cdf0e10cSrcweir { 2362*cdf0e10cSrcweir PushPropertyIds( rIds, 2363*cdf0e10cSrcweir BASEPROPERTY_TEXTLINECOLOR, 2364*cdf0e10cSrcweir 0); 2365*cdf0e10cSrcweir VCLXDateField::ImplGetPropertyIds( rIds ); 2366*cdf0e10cSrcweir } 2367