fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / uno / unoiface.cxx
blob658623f8ca534c74b022cdbb2afa1d2420be62b3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/debug.hxx>
22 #include <vcl/fixedhyper.hxx>
23 #include <vcl/prgsbar.hxx>
24 #include <vcl/svapp.hxx>
25 #include <svtools/svmedit.hxx>
26 #include <unoiface.hxx>
27 #include <svtools/filectrl.hxx>
28 #include <svtools/roadmap.hxx>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
31 #include <com/sun/star/awt/LineEndFormat.hpp>
32 #include <comphelper/processfactory.hxx>
33 #include <toolkit/helper/convert.hxx>
34 #include <toolkit/helper/property.hxx>
35 #include <svtools/fmtfield.hxx>
36 #include <svl/numuno.hxx>
37 #include <svtools/calendar.hxx>
38 #include <svtools/treelistbox.hxx>
39 #include "treecontrolpeer.hxx"
40 #include "svtxgridcontrol.hxx"
41 #include <svtools/table/tablecontrol.hxx>
43 namespace
45 static void lcl_setWinBits( Window* _pWindow, WinBits _nBits, sal_Bool _bSet )
47 WinBits nStyle = _pWindow->GetStyle();
48 if ( _bSet )
49 nStyle |= _nBits;
50 else
51 nStyle &= ~_nBits;
52 _pWindow->SetStyle( nStyle );
56 // ----------------------------------------------------
57 // help function for the toolkit...
58 // ----------------------------------------------------
60 extern "C" {
62 SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, Window* pParent, WinBits nWinBits )
64 Window* pWindow = NULL;
65 String aServiceName( pDescriptor->WindowServiceName );
66 if ( aServiceName.EqualsIgnoreCaseAscii( "MultiLineEdit" ) )
68 if ( pParent )
70 pWindow = new MultiLineEdit( pParent, nWinBits|WB_IGNORETAB);
71 static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus();
72 *ppNewComp = new VCLXMultiLineEdit;
74 else
76 *ppNewComp = NULL;
77 return NULL;
80 else if ( aServiceName.EqualsIgnoreCaseAscii( "FileControl" ) )
82 if ( pParent )
84 pWindow = new FileControl( pParent, nWinBits );
85 *ppNewComp = new VCLXFileControl;
87 else
89 *ppNewComp = NULL;
90 return NULL;
93 else if (aServiceName.EqualsIgnoreCaseAscii("FormattedField") )
95 pWindow = new FormattedField( pParent, nWinBits );
96 *ppNewComp = new SVTXFormattedField;
98 else if (aServiceName.EqualsIgnoreCaseAscii("NumericField") )
100 pWindow = new DoubleNumericField( pParent, nWinBits );
101 *ppNewComp = new SVTXNumericField;
103 else if (aServiceName.EqualsIgnoreCaseAscii("LongCurrencyField") )
105 pWindow = new DoubleCurrencyField( pParent, nWinBits );
106 *ppNewComp = new SVTXCurrencyField;
108 else if (aServiceName.EqualsIgnoreCaseAscii("datefield") )
110 pWindow = new CalendarField( pParent, nWinBits);
111 static_cast<CalendarField*>(pWindow)->EnableToday();
112 static_cast<CalendarField*>(pWindow)->EnableNone();
113 static_cast<CalendarField*>(pWindow)->EnableEmptyFieldValue( sal_True );
114 *ppNewComp = new SVTXDateField;
115 ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pWindow );
117 else if (aServiceName.EqualsIgnoreCaseAscii("roadmap") )
119 pWindow = new ::svt::ORoadmap( pParent, WB_TABSTOP );
120 *ppNewComp = new SVTXRoadmap;
122 else if ( aServiceName.EqualsIgnoreCaseAscii( "ProgressBar" ) )
124 if ( pParent )
126 pWindow = new ProgressBar( pParent, nWinBits );
127 *ppNewComp = new VCLXProgressBar;
129 else
131 *ppNewComp = NULL;
132 return NULL;
135 else if ( aServiceName.EqualsIgnoreCaseAscii( "Tree" ) )
137 TreeControlPeer* pPeer = new TreeControlPeer;
138 *ppNewComp = pPeer;
139 pWindow = pPeer->createVclControl( pParent, nWinBits );
141 else if ( aServiceName.EqualsIgnoreCaseAscii( "FixedHyperlink" ) )
143 if ( pParent )
145 pWindow = new FixedHyperlink( pParent, nWinBits );
146 *ppNewComp = new VCLXFixedHyperlink;
148 else
150 *ppNewComp = NULL;
151 return NULL;
154 else if ( aServiceName.EqualsIgnoreCaseAscii( "Grid" ) )
156 if ( pParent )
158 pWindow = new ::svt::table::TableControl(pParent, nWinBits);
159 *ppNewComp = new SVTXGridControl;
161 else
163 *ppNewComp = NULL;
164 return NULL;
167 return pWindow;
170 } // extern "C"
172 // ----------------------------------------------------
173 // class VCLXMultiLineEdit
174 // ----------------------------------------------------
175 VCLXMultiLineEdit::VCLXMultiLineEdit()
176 :maTextListeners( *this )
177 ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like)
181 VCLXMultiLineEdit::~VCLXMultiLineEdit()
185 ::com::sun::star::uno::Any VCLXMultiLineEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
187 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
188 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
189 (static_cast< ::com::sun::star::awt::XTextArea* >(this)),
190 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)),
191 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
192 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
195 // ::com::sun::star::lang::XTypeProvider
196 IMPL_XTYPEPROVIDER_START( VCLXMultiLineEdit )
197 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
198 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextArea>* ) NULL ),
199 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
200 VCLXWindow::getTypes()
201 IMPL_XTYPEPROVIDER_END
203 void VCLXMultiLineEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
205 maTextListeners.addInterface( l );
208 void VCLXMultiLineEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
210 maTextListeners.removeInterface( l );
213 void VCLXMultiLineEdit::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
215 SolarMutexGuard aGuard;
217 MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
218 if ( pEdit )
220 pEdit->SetText( aText );
222 // #107218# Call same listeners like VCL would do after user interaction
223 SetSynthesizingVCLEvent( sal_True );
224 pEdit->SetModifyFlag();
225 pEdit->Modify();
226 SetSynthesizingVCLEvent( sal_False );
230 void VCLXMultiLineEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
232 SolarMutexGuard aGuard;
234 MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
235 if ( pEdit )
237 setSelection( rSel );
238 pEdit->ReplaceSelected( aText );
242 OUString VCLXMultiLineEdit::getText() throw(::com::sun::star::uno::RuntimeException)
244 SolarMutexGuard aGuard;
246 OUString aText;
247 MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
248 if ( pEdit )
249 aText = pEdit->GetText( meLineEndType );
250 return aText;
253 OUString VCLXMultiLineEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException)
255 SolarMutexGuard aGuard;
257 OUString aText;
258 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
259 if ( pMultiLineEdit)
260 aText = pMultiLineEdit->GetSelected( meLineEndType );
261 return aText;
265 void VCLXMultiLineEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException)
267 SolarMutexGuard aGuard;
269 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
270 if ( pMultiLineEdit )
272 pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
276 ::com::sun::star::awt::Selection VCLXMultiLineEdit::getSelection() throw(::com::sun::star::uno::RuntimeException)
278 SolarMutexGuard aGuard;
280 ::com::sun::star::awt::Selection aSel;
281 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
282 if ( pMultiLineEdit )
284 aSel.Min = pMultiLineEdit->GetSelection().Min();
285 aSel.Max = pMultiLineEdit->GetSelection().Max();
287 return aSel;
290 sal_Bool VCLXMultiLineEdit::isEditable() throw(::com::sun::star::uno::RuntimeException)
292 SolarMutexGuard aGuard;
294 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
295 return ( pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled() ) ? sal_True : sal_False;
298 void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException)
300 SolarMutexGuard aGuard;
302 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
303 if ( pMultiLineEdit )
304 pMultiLineEdit->SetReadOnly( !bEditable );
307 void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException)
309 SolarMutexGuard aGuard;
311 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
312 if ( pMultiLineEdit )
313 pMultiLineEdit->SetMaxTextLen( nLen );
316 sal_Int16 VCLXMultiLineEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException)
318 SolarMutexGuard aGuard;
320 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*) GetWindow();
321 return pMultiLineEdit ? (sal_Int16)pMultiLineEdit->GetMaxTextLen() : (sal_Int16)0;
324 OUString VCLXMultiLineEdit::getTextLines() throw(::com::sun::star::uno::RuntimeException)
326 SolarMutexGuard aGuard;
328 OUString aText;
329 MultiLineEdit* pEdit = (MultiLineEdit*)GetWindow();
330 if ( pEdit )
331 aText = pEdit->GetTextLines( meLineEndType );
332 return aText;
335 ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
337 SolarMutexGuard aGuard;
339 ::com::sun::star::awt::Size aSz;
340 MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
341 if ( pEdit )
342 aSz = AWTSize(pEdit->CalcMinimumSize());
343 return aSz;
346 ::com::sun::star::awt::Size VCLXMultiLineEdit::getPreferredSize() throw(::com::sun::star::uno::RuntimeException)
348 return getMinimumSize();
351 ::com::sun::star::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
353 SolarMutexGuard aGuard;
355 ::com::sun::star::awt::Size aSz = rNewSize;
356 MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
357 if ( pEdit )
358 aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
359 return aSz;
362 ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException)
364 SolarMutexGuard aGuard;
366 ::com::sun::star::awt::Size aSz;
367 MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
368 if ( pEdit )
369 aSz = AWTSize(pEdit->CalcSize( nCols, nLines ));
370 return aSz;
373 void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
375 SolarMutexGuard aGuard;
377 nCols = nLines = 0;
378 MultiLineEdit* pEdit = (MultiLineEdit*) GetWindow();
379 if ( pEdit )
381 sal_uInt16 nC, nL;
382 pEdit->GetMaxVisColumnsAndLines( nC, nL );
383 nCols = nC;
384 nLines = nL;
388 void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
390 switch ( rVclWindowEvent.GetId() )
392 case VCLEVENT_EDIT_MODIFY:
394 if ( maTextListeners.getLength() )
396 ::com::sun::star::awt::TextEvent aEvent;
397 aEvent.Source = (::cppu::OWeakObject*)this;
398 maTextListeners.textChanged( aEvent );
401 break;
402 default:
404 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
406 break;
410 void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
412 SolarMutexGuard aGuard;
414 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow();
415 if ( pMultiLineEdit )
417 sal_uInt16 nPropType = GetPropertyId( PropertyName );
418 switch ( nPropType )
420 case BASEPROPERTY_LINE_END_FORMAT:
422 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
423 OSL_VERIFY( Value >>= nLineEndType );
424 switch ( nLineEndType )
426 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break;
427 case ::com::sun::star::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break;
428 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
429 default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break;
432 break;
434 case BASEPROPERTY_READONLY:
436 sal_Bool b = sal_Bool();
437 if ( Value >>= b )
438 pMultiLineEdit->SetReadOnly( b );
440 break;
441 case BASEPROPERTY_MAXTEXTLEN:
443 sal_Int16 n = sal_Int16();
444 if ( Value >>= n )
445 pMultiLineEdit->SetMaxTextLen( n );
447 break;
448 case BASEPROPERTY_HIDEINACTIVESELECTION:
450 sal_Bool b = sal_Bool();
451 if ( Value >>= b )
453 pMultiLineEdit->EnableFocusSelectionHide( b );
454 lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
457 break;
458 default:
460 VCLXWindow::setProperty( PropertyName, Value );
466 ::com::sun::star::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
468 SolarMutexGuard aGuard;
470 ::com::sun::star::uno::Any aProp;
471 MultiLineEdit* pMultiLineEdit = (MultiLineEdit*)GetWindow();
472 if ( pMultiLineEdit )
474 sal_uInt16 nPropType = GetPropertyId( PropertyName );
475 switch ( nPropType )
477 case BASEPROPERTY_LINE_END_FORMAT:
479 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
480 switch ( meLineEndType )
482 case LINEEND_CR: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN; break;
483 case LINEEND_LF: nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; break;
484 case LINEEND_CRLF: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
485 default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break;
487 aProp <<= nLineEndType;
489 break;
491 case BASEPROPERTY_READONLY:
493 aProp <<= pMultiLineEdit->IsReadOnly();
495 break;
496 case BASEPROPERTY_MAXTEXTLEN:
498 aProp <<= (sal_Int16) pMultiLineEdit->GetMaxTextLen();
500 break;
501 default:
503 aProp <<= VCLXWindow::getProperty( PropertyName );
507 return aProp;
510 void SAL_CALL VCLXMultiLineEdit::setFocus( ) throw(::com::sun::star::uno::RuntimeException)
512 SolarMutexGuard aGuard;
514 // don't grab the focus if we already have it. Reason is that the only thing which the edit
515 // does is forwarding the focus to it's text window. This text window then does a "select all".
516 // So if the text window already has the focus, and we give the focus to the multi line
517 // edit, then all which happens is that everything is selected.
518 // #i27072#
519 if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
520 GetWindow()->GrabFocus();
523 void VCLXMultiLineEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
525 PushPropertyIds( rIds,
526 // FIXME: elide duplication ?
527 BASEPROPERTY_LINE_END_FORMAT,
528 BASEPROPERTY_READONLY,
529 BASEPROPERTY_MAXTEXTLEN,
530 BASEPROPERTY_HIDEINACTIVESELECTION,
532 VCLXWindow::ImplGetPropertyIds( rIds, true );
535 // ----------------------------------------------------
536 // class VCLXFileControl
537 // ----------------------------------------------------
538 VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
542 VCLXFileControl::~VCLXFileControl()
544 FileControl* pControl = (FileControl*) GetWindow();
545 if ( pControl )
546 pControl->GetEdit().SetModifyHdl( Link() );
549 ::com::sun::star::uno::Any VCLXFileControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
551 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
552 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
553 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)),
554 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
555 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
558 // ::com::sun::star::lang::XTypeProvider
559 IMPL_XTYPEPROVIDER_START( VCLXFileControl )
560 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent>* ) NULL ),
561 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ),
562 VCLXWindow::getTypes()
563 IMPL_XTYPEPROVIDER_END
565 void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
567 SolarMutexGuard aGuard;
569 FileControl* pControl = (FileControl*)GetWindow();
570 if ( pControl )
572 sal_uInt16 nPropType = GetPropertyId( PropertyName );
573 switch ( nPropType )
575 case BASEPROPERTY_HIDEINACTIVESELECTION:
577 sal_Bool bValue( sal_False );
578 OSL_VERIFY( Value >>= bValue );
580 lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
581 lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
583 break;
585 default:
586 VCLXWindow::setProperty( PropertyName, Value );
587 break;
592 void VCLXFileControl::SetWindow( Window* pWindow )
594 FileControl* pPrevFileControl = dynamic_cast<FileControl*>( GetWindow() );
595 if ( pPrevFileControl )
596 pPrevFileControl->GetEdit().SetModifyHdl( Link() );
598 FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow );
599 if ( pNewFileControl )
600 pNewFileControl->GetEdit().SetModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) );
602 VCLXWindow::SetWindow( pWindow );
605 void VCLXFileControl::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
607 maTextListeners.addInterface( l );
610 void VCLXFileControl::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException)
612 maTextListeners.removeInterface( l );
615 void VCLXFileControl::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
617 SolarMutexGuard aGuard;
619 Window* pWindow = GetWindow();
620 if ( pWindow )
622 pWindow->SetText( aText );
624 // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht.
625 // ::com::sun::star::awt::Toolkit soll JAVA-komform sein...
626 ModifyHdl( NULL );
630 void VCLXFileControl::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException)
632 SolarMutexGuard aGuard;
634 FileControl* pFileControl = (FileControl*) GetWindow();
635 if ( pFileControl )
637 pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
638 pFileControl->GetEdit().ReplaceSelected( aText );
642 OUString VCLXFileControl::getText() throw(::com::sun::star::uno::RuntimeException)
644 SolarMutexGuard aGuard;
646 OUString aText;
647 Window* pWindow = GetWindow();
648 if ( pWindow )
649 aText = pWindow->GetText();
650 return aText;
653 OUString VCLXFileControl::getSelectedText() throw(::com::sun::star::uno::RuntimeException)
655 SolarMutexGuard aGuard;
657 OUString aText;
658 FileControl* pFileControl = (FileControl*) GetWindow();
659 if ( pFileControl)
660 aText = pFileControl->GetEdit().GetSelected();
661 return aText;
665 void VCLXFileControl::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException)
667 SolarMutexGuard aGuard;
669 FileControl* pFileControl = (FileControl*) GetWindow();
670 if ( pFileControl )
671 pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
674 ::com::sun::star::awt::Selection VCLXFileControl::getSelection() throw(::com::sun::star::uno::RuntimeException)
676 SolarMutexGuard aGuard;
678 ::com::sun::star::awt::Selection aSel;
679 FileControl* pFileControl = (FileControl*) GetWindow();
680 if ( pFileControl )
682 aSel.Min = pFileControl->GetEdit().GetSelection().Min();
683 aSel.Max = pFileControl->GetEdit().GetSelection().Max();
685 return aSel;
688 sal_Bool VCLXFileControl::isEditable() throw(::com::sun::star::uno::RuntimeException)
690 SolarMutexGuard aGuard;
692 FileControl* pFileControl = (FileControl*) GetWindow();
693 return ( pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled() ) ? sal_True : sal_False;
696 void VCLXFileControl::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException)
698 SolarMutexGuard aGuard;
700 FileControl* pFileControl = (FileControl*) GetWindow();
701 if ( pFileControl )
702 pFileControl->GetEdit().SetReadOnly( !bEditable );
705 void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException)
707 SolarMutexGuard aGuard;
709 FileControl* pFileControl = (FileControl*) GetWindow();
710 if ( pFileControl )
711 pFileControl->GetEdit().SetMaxTextLen( nLen );
714 sal_Int16 VCLXFileControl::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException)
716 SolarMutexGuard aGuard;
718 FileControl* pFileControl = (FileControl*) GetWindow();
719 return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
723 IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl)
725 ::com::sun::star::awt::TextEvent aEvent;
726 aEvent.Source = (::cppu::OWeakObject*)this;
727 maTextListeners.textChanged( aEvent );
729 return 1;
732 ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize() throw(::com::sun::star::uno::RuntimeException)
734 SolarMutexGuard aGuard;
736 ::com::sun::star::awt::Size aSz;
737 FileControl* pControl = (FileControl*) GetWindow();
738 if ( pControl )
740 Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
741 aTmpSize.Width() += pControl->GetButton().CalcMinimumSize().Width();
742 aSz = AWTSize(pControl->CalcWindowSize( aTmpSize ));
744 return aSz;
747 ::com::sun::star::awt::Size VCLXFileControl::getPreferredSize() throw(::com::sun::star::uno::RuntimeException)
749 ::com::sun::star::awt::Size aSz = getMinimumSize();
750 aSz.Height += 4;
751 return aSz;
754 ::com::sun::star::awt::Size VCLXFileControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
756 SolarMutexGuard aGuard;
758 ::com::sun::star::awt::Size aSz =rNewSize;
759 FileControl* pControl = (FileControl*) GetWindow();
760 if ( pControl )
762 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
763 if ( aSz.Height != aMinSz.Height )
764 aSz.Height = aMinSz.Height;
766 return aSz;
769 ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException)
771 SolarMutexGuard aGuard;
773 ::com::sun::star::awt::Size aSz;
774 FileControl* pControl = (FileControl*) GetWindow();
775 if ( pControl )
777 aSz = AWTSize(pControl->GetEdit().CalcSize( nCols ));
778 aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
780 return aSz;
783 void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException)
785 SolarMutexGuard aGuard;
787 nCols = 0;
788 nLines = 1;
789 FileControl* pControl = (FileControl*) GetWindow();
790 if ( pControl )
791 nCols = (sal_Int16) pControl->GetEdit().GetMaxVisChars();
794 void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
796 PushPropertyIds( rIds,
797 // FIXME: elide duplication ?
798 BASEPROPERTY_HIDEINACTIVESELECTION,
800 VCLXWindow::ImplGetPropertyIds( rIds, true );
804 // ----------------------------------------------------
805 // class SVTXFormattedField
806 // ----------------------------------------------------
807 // --------------------------------------------------------------------------------------
808 SVTXFormattedField::SVTXFormattedField()
809 :m_pCurrentSupplier(NULL)
810 ,bIsStandardSupplier(sal_True)
811 ,nKeyToSetDelayed(-1)
815 // --------------------------------------------------------------------------------------
816 SVTXFormattedField::~SVTXFormattedField()
818 if (m_pCurrentSupplier)
820 m_pCurrentSupplier->release();
821 m_pCurrentSupplier = NULL;
825 // --------------------------------------------------------------------------------------
826 void SVTXFormattedField::SetWindow( Window* _pWindow )
828 VCLXSpinField::SetWindow(_pWindow);
829 if (GetFormattedField())
830 GetFormattedField()->SetAutoColor(sal_True);
833 // --------------------------------------------------------------------------------------
834 void SVTXFormattedField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
836 SolarMutexGuard aGuard;
838 FormattedField* pField = GetFormattedField();
839 if ( pField )
841 sal_uInt16 nPropType = GetPropertyId( PropertyName );
842 switch (nPropType)
844 case BASEPROPERTY_ENFORCE_FORMAT:
846 sal_Bool bEnable( sal_True );
847 if ( Value >>= bEnable )
848 pField->EnableNotANumber( !bEnable );
850 break;
852 case BASEPROPERTY_EFFECTIVE_MIN:
853 case BASEPROPERTY_VALUEMIN_DOUBLE:
854 SetMinValue(Value);
855 break;
857 case BASEPROPERTY_EFFECTIVE_MAX:
858 case BASEPROPERTY_VALUEMAX_DOUBLE:
859 SetMaxValue(Value);
860 break;
862 case BASEPROPERTY_EFFECTIVE_DEFAULT:
863 SetDefaultValue(Value);
864 break;
866 case BASEPROPERTY_TREATASNUMBER:
868 sal_Bool b = sal_Bool();
869 if ( Value >>= b )
870 SetTreatAsNumber(b);
872 break;
874 case BASEPROPERTY_FORMATSSUPPLIER:
875 if (!Value.hasValue())
876 setFormatsSupplier(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > (NULL));
877 else
879 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS;
880 if ( Value >>= xNFS )
881 setFormatsSupplier(xNFS);
883 break;
884 case BASEPROPERTY_FORMATKEY:
885 if (!Value.hasValue())
886 setFormatKey(0);
887 else
889 sal_Int32 n = 0;
890 if ( Value >>= n )
891 setFormatKey(n);
893 break;
895 case BASEPROPERTY_EFFECTIVE_VALUE:
896 case BASEPROPERTY_VALUE_DOUBLE:
898 const ::com::sun::star::uno::TypeClass rTC = Value.getValueType().getTypeClass();
899 if (rTC != ::com::sun::star::uno::TypeClass_STRING)
900 // no string
901 if (rTC != ::com::sun::star::uno::TypeClass_DOUBLE)
902 // no double
903 if (Value.hasValue())
904 { // but a value
905 // try if it is something converitble
906 sal_Int32 nValue = 0;
907 if (!(Value >>= nValue))
908 throw ::com::sun::star::lang::IllegalArgumentException();
909 SetValue(::com::sun::star::uno::makeAny((double)nValue));
910 break;
913 SetValue(Value);
915 break;
916 case BASEPROPERTY_VALUESTEP_DOUBLE:
918 double d = 0.0;
919 if ( Value >>= d )
920 pField->SetSpinSize( d );
921 else
923 sal_Int32 n = 0;
924 if ( Value >>= n )
925 pField->SetSpinSize( n );
928 break;
929 case BASEPROPERTY_DECIMALACCURACY:
931 sal_Int32 n = 0;
932 if ( Value >>= n )
933 pField->SetDecimalDigits( (sal_uInt16)n );
935 break;
936 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
938 sal_Bool b = sal_Bool();
939 if ( Value >>= b )
940 pField->SetThousandsSep( b );
942 break;
944 default:
945 VCLXSpinField::setProperty( PropertyName, Value );
948 if (BASEPROPERTY_TEXTCOLOR == nPropType)
949 { // after setting a new text color, think again about the AutoColor flag of the control
950 // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
951 pField->SetAutoColor(!Value.hasValue());
954 else
955 VCLXSpinField::setProperty( PropertyName, Value );
958 // --------------------------------------------------------------------------------------
959 ::com::sun::star::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
961 SolarMutexGuard aGuard;
963 ::com::sun::star::uno::Any aReturn;
965 FormattedField* pField = GetFormattedField();
966 if ( pField )
968 sal_uInt16 nPropType = GetPropertyId( PropertyName );
969 switch (nPropType)
971 case BASEPROPERTY_EFFECTIVE_MIN:
972 case BASEPROPERTY_VALUEMIN_DOUBLE:
973 aReturn <<= GetMinValue();
974 break;
976 case BASEPROPERTY_EFFECTIVE_MAX:
977 case BASEPROPERTY_VALUEMAX_DOUBLE:
978 aReturn <<= GetMaxValue();
979 break;
981 case BASEPROPERTY_EFFECTIVE_DEFAULT:
982 aReturn <<= GetDefaultValue();
983 break;
985 case BASEPROPERTY_TREATASNUMBER:
986 aReturn <<= GetTreatAsNumber();
987 break;
989 case BASEPROPERTY_EFFECTIVE_VALUE:
990 case BASEPROPERTY_VALUE_DOUBLE:
991 aReturn <<= GetValue();
992 break;
994 case BASEPROPERTY_VALUESTEP_DOUBLE:
995 aReturn <<= pField->GetSpinSize();
996 break;
998 case BASEPROPERTY_DECIMALACCURACY:
999 aReturn <<= pField->GetDecimalDigits();
1000 break;
1002 case BASEPROPERTY_FORMATSSUPPLIER:
1004 if (!bIsStandardSupplier)
1005 { // ansonsten void
1006 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getFormatsSupplier();
1007 aReturn <<= xSupplier;
1010 break;
1012 case BASEPROPERTY_FORMATKEY:
1014 if (!bIsStandardSupplier)
1015 aReturn <<= getFormatKey();
1017 break;
1019 default:
1020 aReturn <<= VCLXSpinField::getProperty(PropertyName);
1023 return aReturn;
1026 // --------------------------------------------------------------------------------------
1027 ::com::sun::star::uno::Any SVTXFormattedField::convertEffectiveValue(const ::com::sun::star::uno::Any& rValue)
1029 ::com::sun::star::uno::Any aReturn;
1031 FormattedField* pField = GetFormattedField();
1032 if (!pField)
1033 return aReturn;
1035 switch (rValue.getValueType().getTypeClass())
1037 case ::com::sun::star::uno::TypeClass_DOUBLE:
1038 if (pField->TreatingAsNumber())
1040 double d = 0.0;
1041 rValue >>= d;
1042 aReturn <<= d;
1044 else
1046 SvNumberFormatter* pFormatter = pField->GetFormatter();
1047 if (!pFormatter)
1048 pFormatter = pField->StandardFormatter();
1049 // should never fail
1051 Color* pDum;
1052 double d = 0.0;
1053 rValue >>= d;
1054 String sConverted;
1055 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
1056 aReturn <<= OUString( sConverted );
1058 break;
1059 case ::com::sun::star::uno::TypeClass_STRING:
1061 OUString aStr;
1062 rValue >>= aStr;
1063 String sValue = aStr;
1064 if (pField->TreatingAsNumber())
1066 SvNumberFormatter* pFormatter = pField->GetFormatter();
1067 if (!pFormatter)
1068 pFormatter = pField->StandardFormatter();
1070 double dVal;
1071 sal_uInt32 nTestFormat(0);
1072 if (!pFormatter->IsNumberFormat(sValue, nTestFormat, dVal))
1073 aReturn.clear();
1074 aReturn <<=dVal;
1076 else
1077 aReturn <<= aStr;
1079 break;
1080 default:
1081 aReturn.clear();
1082 break;
1084 return aReturn;
1087 // --------------------------------------------------------------------------------------
1088 void SVTXFormattedField::SetMinValue(const ::com::sun::star::uno::Any& rValue)
1090 FormattedField* pField = GetFormattedField();
1091 if (!pField)
1092 return;
1094 switch (rValue.getValueType().getTypeClass())
1097 case ::com::sun::star::uno::TypeClass_DOUBLE:
1099 double d = 0.0;
1100 rValue >>= d;
1101 pField->SetMinValue(d);
1103 break;
1104 default:
1105 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
1106 if ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID )
1109 throw ::com::sun::star::lang::IllegalArgumentException();
1111 pField->ClearMinValue();
1112 break;
1116 // --------------------------------------------------------------------------------------
1117 ::com::sun::star::uno::Any SVTXFormattedField::GetMinValue()
1119 FormattedField* pField = GetFormattedField();
1120 if (!pField || !pField->HasMinValue())
1121 return ::com::sun::star::uno::Any();
1123 ::com::sun::star::uno::Any aReturn;
1124 aReturn <<= pField->GetMinValue();
1125 return aReturn;
1128 // --------------------------------------------------------------------------------------
1129 void SVTXFormattedField::SetMaxValue(const ::com::sun::star::uno::Any& rValue)
1131 FormattedField* pField = GetFormattedField();
1132 if (!pField)
1133 return;
1135 switch (rValue.getValueType().getTypeClass())
1138 case ::com::sun::star::uno::TypeClass_DOUBLE:
1140 double d = 0.0;
1141 rValue >>= d;
1142 pField->SetMaxValue(d);
1144 break;
1145 default:
1146 if (rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID)
1149 throw ::com::sun::star::lang::IllegalArgumentException();
1151 pField->ClearMaxValue();
1152 break;
1156 // --------------------------------------------------------------------------------------
1157 ::com::sun::star::uno::Any SVTXFormattedField::GetMaxValue()
1159 FormattedField* pField = GetFormattedField();
1160 if (!pField || !pField->HasMaxValue())
1161 return ::com::sun::star::uno::Any();
1163 ::com::sun::star::uno::Any aReturn;
1164 aReturn <<= pField->GetMaxValue();
1165 return aReturn;
1168 // --------------------------------------------------------------------------------------
1169 void SVTXFormattedField::SetDefaultValue(const ::com::sun::star::uno::Any& rValue)
1171 FormattedField* pField = GetFormattedField();
1172 if (!pField)
1173 return;
1175 ::com::sun::star::uno::Any aConverted = convertEffectiveValue(rValue);
1177 switch (aConverted.getValueType().getTypeClass())
1180 case ::com::sun::star::uno::TypeClass_DOUBLE:
1182 double d = 0.0;
1183 aConverted >>= d;
1184 pField->SetDefaultValue(d);
1186 break;
1187 case ::com::sun::star::uno::TypeClass_STRING:
1189 OUString aStr;
1190 aConverted >>= aStr;
1191 pField->SetDefaultText( aStr );
1193 break;
1194 default:
1195 pField->EnableEmptyField(sal_True);
1196 // nur noch void erlaubt
1197 break;
1201 // --------------------------------------------------------------------------------------
1202 ::com::sun::star::uno::Any SVTXFormattedField::GetDefaultValue()
1204 FormattedField* pField = GetFormattedField();
1205 if (!pField || pField->IsEmptyFieldEnabled())
1206 return ::com::sun::star::uno::Any();
1208 ::com::sun::star::uno::Any aReturn;
1209 if (pField->TreatingAsNumber())
1210 aReturn <<= pField->GetDefaultValue();
1211 else
1212 aReturn <<= OUString( pField->GetDefaultText() );
1213 return aReturn;
1216 // --------------------------------------------------------------------------------------
1217 sal_Bool SVTXFormattedField::GetTreatAsNumber()
1219 FormattedField* pField = GetFormattedField();
1220 if (pField)
1221 return pField->TreatingAsNumber();
1223 return sal_True;
1226 // --------------------------------------------------------------------------------------
1227 void SVTXFormattedField::SetTreatAsNumber(sal_Bool bSet)
1229 FormattedField* pField = GetFormattedField();
1230 if (pField)
1231 pField->TreatAsNumber(bSet);
1234 // --------------------------------------------------------------------------------------
1235 ::com::sun::star::uno::Any SVTXFormattedField::GetValue()
1237 FormattedField* pField = GetFormattedField();
1238 if (!pField)
1239 return ::com::sun::star::uno::Any();
1241 ::com::sun::star::uno::Any aReturn;
1242 if (!pField->TreatingAsNumber())
1244 OUString sText = pField->GetTextValue();
1245 aReturn <<= sText;
1247 else
1249 if (!pField->GetText().isEmpty()) // empty wird erst mal standardmaessig als void nach draussen gereicht
1250 aReturn <<= pField->GetValue();
1253 return aReturn;
1256 // --------------------------------------------------------------------------------------
1257 void SVTXFormattedField::SetValue(const ::com::sun::star::uno::Any& rValue)
1259 FormattedField* pField = GetFormattedField();
1260 if (!pField)
1261 return;
1263 if (!rValue.hasValue())
1265 pField->SetText(String());
1267 else
1269 if (rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE )
1271 double d = 0.0;
1272 rValue >>= d;
1273 pField->SetValue(d);
1275 else
1277 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
1279 OUString sText;
1280 rValue >>= sText;
1281 String aStr( sText );
1282 if (!pField->TreatingAsNumber())
1283 pField->SetTextFormatted(aStr);
1284 else
1285 pField->SetTextValue(aStr);
1288 // NotifyTextListeners();
1291 // --------------------------------------------------------------------------------------
1292 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier(void) const
1294 return ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > ((::com::sun::star::util::XNumberFormatsSupplier*)m_pCurrentSupplier);
1297 // --------------------------------------------------------------------------------------
1298 void SVTXFormattedField::setFormatsSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier)
1300 FormattedField* pField = GetFormattedField();
1302 SvNumberFormatsSupplierObj* pNew = NULL;
1303 if (!xSupplier.is())
1305 if (pField)
1307 pNew = new SvNumberFormatsSupplierObj(pField->StandardFormatter());
1308 bIsStandardSupplier = sal_True;
1311 else
1313 pNew = SvNumberFormatsSupplierObj::getImplementation(xSupplier);
1314 bIsStandardSupplier = sal_False;
1317 if (!pNew)
1318 return; // TODO : wie das behandeln ?
1320 if (m_pCurrentSupplier)
1321 m_pCurrentSupplier->release();
1322 m_pCurrentSupplier = pNew;
1323 m_pCurrentSupplier->acquire();
1324 if (pField)
1326 // den aktuellen Value mit hinueberretten
1327 ::com::sun::star::uno::Any aCurrent = GetValue();
1328 pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), sal_False);
1329 if (nKeyToSetDelayed != -1)
1331 pField->SetFormatKey(nKeyToSetDelayed);
1332 nKeyToSetDelayed = -1;
1334 SetValue(aCurrent);
1335 NotifyTextListeners();
1339 // --------------------------------------------------------------------------------------
1340 sal_Int32 SVTXFormattedField::getFormatKey(void) const
1342 FormattedField* pField = GetFormattedField();
1343 return pField ? pField->GetFormatKey() : 0;
1346 // --------------------------------------------------------------------------------------
1347 void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
1349 FormattedField* pField = GetFormattedField();
1350 if (pField)
1352 if (pField->GetFormatter())
1353 pField->SetFormatKey(nKey);
1354 else
1355 { // Wahrscheinlich bin ich gerade in einem Block, in dem erst der Key und dann der Formatter gesetzt
1356 // wird, das passiert initial mit ziemlicher Sicherheit, da die Properties in alphabetischer Reihenfolge
1357 // gesetzt werden, und der FormatsSupplier nun mal vor dem FormatKey kommt
1358 nKeyToSetDelayed = nKey;
1360 NotifyTextListeners();
1364 // --------------------------------------------------------------------------------------
1365 void SVTXFormattedField::NotifyTextListeners()
1367 if ( GetTextListeners().getLength() )
1369 ::com::sun::star::awt::TextEvent aEvent;
1370 aEvent.Source = (::cppu::OWeakObject*)this;
1371 GetTextListeners().textChanged( aEvent );
1375 void SVTXFormattedField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1377 PushPropertyIds( rIds,
1378 // FIXME: elide duplication ?
1379 BASEPROPERTY_EFFECTIVE_MIN,
1380 BASEPROPERTY_VALUEMIN_DOUBLE,
1381 BASEPROPERTY_EFFECTIVE_MAX,
1382 BASEPROPERTY_VALUEMAX_DOUBLE,
1383 BASEPROPERTY_EFFECTIVE_DEFAULT,
1384 BASEPROPERTY_TREATASNUMBER,
1385 BASEPROPERTY_EFFECTIVE_VALUE,
1386 BASEPROPERTY_VALUE_DOUBLE,
1387 BASEPROPERTY_VALUESTEP_DOUBLE,
1388 BASEPROPERTY_DECIMALACCURACY,
1389 BASEPROPERTY_FORMATSSUPPLIER,
1390 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
1391 BASEPROPERTY_FORMATKEY,
1392 BASEPROPERTY_TREATASNUMBER,
1393 BASEPROPERTY_ENFORCE_FORMAT,
1395 VCLXWindow::ImplGetPropertyIds( rIds, true );
1396 VCLXSpinField::ImplGetPropertyIds( rIds );
1400 // ----------------------------------------------------
1401 // class SVTXRoadmap
1402 // ----------------------------------------------------
1404 using namespace svt;
1406 // --------------------------------------------------------------------------------------
1407 SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this )
1411 // --------------------------------------------------------------------------------------
1412 SVTXRoadmap::~SVTXRoadmap()
1416 void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1418 switch ( rVclWindowEvent.GetId() )
1420 case VCLEVENT_ROADMAP_ITEMSELECTED:
1422 SolarMutexGuard aGuard;
1423 ::svt::ORoadmap* pField = GetRoadmap();
1424 if ( pField )
1426 sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID();
1427 ::com::sun::star::awt::ItemEvent aEvent;
1428 aEvent.Selected = CurItemID;
1429 aEvent.Highlighted = CurItemID;
1430 aEvent.ItemId = CurItemID;
1431 maItemListeners.itemStateChanged( aEvent );
1434 break;
1435 default:
1436 SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent );
1437 break;
1442 void SVTXRoadmap::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
1444 SolarMutexGuard aGuard;
1445 ::svt::ORoadmap* pField = GetRoadmap();
1446 if ( pField )
1448 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1449 xRoadmapItem = evt.Source;
1450 sal_Int32 nID = 0;
1451 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1452 ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(OUString( "ID" ));
1453 aValue >>= nID;
1455 ::com::sun::star::uno::Any rVal = evt.NewValue;
1456 evt.NewValue >>= rVal;
1457 OUString sPropertyName = evt.PropertyName;
1458 if ( sPropertyName == "Enabled" )
1460 sal_Bool bEnable = false;
1461 evt.NewValue >>= bEnable;
1462 pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable );
1464 else if ( sPropertyName == "Label" )
1466 OUString sLabel;
1467 evt.NewValue >>= sLabel;
1468 pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel );
1470 else if ( sPropertyName == "ID" )
1472 sal_Int32 nNewID = 0;
1473 evt.NewValue >>= nNewID;
1474 evt.OldValue >>= nID;
1475 pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID );
1477 // else
1478 // Todo: handle Interactive appropriately
1483 void SVTXRoadmap::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1485 maItemListeners.addInterface( l );
1488 void SVTXRoadmap::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1490 maItemListeners.removeInterface( l );
1493 RMItemData SVTXRoadmap::GetRMItemData( const ::com::sun::star::container::ContainerEvent& _rEvent )
1495 RMItemData aCurRMItemData;
1496 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1497 _rEvent.Element >>= xRoadmapItem;
1498 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1499 if ( xPropertySet.is() )
1501 ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue(OUString( "Label" ));
1502 aValue >>= aCurRMItemData.Label;
1503 aValue = xPropertySet->getPropertyValue(OUString( "ID" ));
1504 aValue >>= aCurRMItemData.n_ID;
1505 aValue = xPropertySet->getPropertyValue(OUString( "Enabled" ));
1506 aValue >>= aCurRMItemData.b_Enabled;
1508 return aCurRMItemData;
1511 void SVTXRoadmap::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1513 SolarMutexGuard aGuard;
1514 ::svt::ORoadmap* pField = GetRoadmap();
1515 if ( pField )
1517 RMItemData CurItemData = GetRMItemData( _rEvent );
1518 sal_Int32 InsertIndex = 0;
1519 _rEvent.Accessor >>= InsertIndex;
1520 pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1524 void SVTXRoadmap::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1526 SolarMutexGuard aGuard;
1527 ::svt::ORoadmap* pField = GetRoadmap();
1528 if ( pField )
1530 sal_Int32 DelIndex = 0;
1531 _rEvent.Accessor >>= DelIndex;
1532 pField->DeleteRoadmapItem(DelIndex);
1536 void SVTXRoadmap::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1538 SolarMutexGuard aGuard;
1539 ::svt::ORoadmap* pField = GetRoadmap();
1540 if ( pField )
1542 RMItemData CurItemData = GetRMItemData( _rEvent );
1543 sal_Int32 ReplaceIndex = 0;
1544 _rEvent.Accessor >>= ReplaceIndex;
1545 pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1551 // --------------------------------------------------------------------------------------
1552 void SVTXRoadmap::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1554 SolarMutexGuard aGuard;
1556 ::svt::ORoadmap* pField = GetRoadmap();
1557 if ( pField )
1559 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1560 switch (nPropType)
1562 case BASEPROPERTY_COMPLETE:
1564 sal_Bool b = false;
1565 Value >>= b;
1566 pField->SetRoadmapComplete( b);
1568 break;
1570 case BASEPROPERTY_ACTIVATED:
1572 sal_Bool b = false;
1573 Value >>= b;
1574 pField->SetRoadmapInteractive( b);
1576 break;
1578 case BASEPROPERTY_CURRENTITEMID:
1580 sal_Int32 nId = 0;
1581 Value >>= nId;
1582 pField->SelectRoadmapItemByID( (RoadmapTypes::ItemId)nId );
1584 break;
1586 case BASEPROPERTY_TEXT:
1588 OUString aStr;
1589 Value >>= aStr;
1590 pField->SetText( aStr );
1591 pField->Invalidate();
1593 break;
1595 default:
1596 SVTXRoadmap_Base::setProperty( PropertyName, Value );
1597 break;
1601 else
1602 SVTXRoadmap_Base::setProperty( PropertyName, Value );
1606 // --------------------------------------------------------------------------------------
1607 ::com::sun::star::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
1609 SolarMutexGuard aGuard;
1611 ::com::sun::star::uno::Any aReturn;
1613 ::svt::ORoadmap* pField = GetRoadmap();
1614 if ( pField )
1616 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1617 switch (nPropType)
1619 case BASEPROPERTY_COMPLETE:
1620 aReturn <<= pField->IsRoadmapComplete();
1621 break;
1622 case BASEPROPERTY_ACTIVATED:
1623 aReturn <<= pField->IsRoadmapInteractive();
1624 break;
1625 case BASEPROPERTY_CURRENTITEMID:
1626 aReturn <<= pField->GetCurrentRoadmapItemID();
1627 break;
1628 default:
1629 aReturn = SVTXRoadmap_Base::getProperty(PropertyName);
1630 break;
1633 return aReturn;
1636 void SVTXRoadmap::ImplSetNewImage()
1638 OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" );
1639 ::svt::ORoadmap* pButton = static_cast< ::svt::ORoadmap* >( GetWindow() );
1640 pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() );
1643 void SVTXRoadmap::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1645 PushPropertyIds( rIds,
1646 BASEPROPERTY_COMPLETE,
1647 BASEPROPERTY_ACTIVATED,
1648 BASEPROPERTY_CURRENTITEMID,
1649 BASEPROPERTY_TEXT,
1651 VCLXWindow::ImplGetPropertyIds( rIds, true );
1652 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1655 // ----------------------------------------------------
1656 // class SVTXNumericField
1657 // ----------------------------------------------------
1658 SVTXNumericField::SVTXNumericField()
1662 SVTXNumericField::~SVTXNumericField()
1666 ::com::sun::star::uno::Any SVTXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1668 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1669 (static_cast< ::com::sun::star::awt::XNumericField* >(this)),
1670 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
1671 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1674 // ::com::sun::star::lang::XTypeProvider
1675 IMPL_XTYPEPROVIDER_START( SVTXNumericField )
1676 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
1677 SVTXFormattedField::getTypes()
1678 IMPL_XTYPEPROVIDER_END
1681 void SVTXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1683 SolarMutexGuard aGuard;
1685 FormattedField* pField = GetFormattedField();
1686 if ( pField )
1687 pField->SetValue( Value );
1690 double SVTXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException)
1692 SolarMutexGuard aGuard;
1694 FormattedField* pField = GetFormattedField();
1695 return pField ? pField->GetValue() : 0;
1698 void SVTXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1700 SolarMutexGuard aGuard;
1702 FormattedField* pField = GetFormattedField();
1703 if ( pField )
1704 pField->SetMinValue( Value );
1707 double SVTXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException)
1709 SolarMutexGuard aGuard;
1711 FormattedField* pField = GetFormattedField();
1712 return pField ? pField->GetMinValue() : 0;
1715 void SVTXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1717 SolarMutexGuard aGuard;
1719 FormattedField* pField = GetFormattedField();
1720 if ( pField )
1721 pField->SetMaxValue( Value );
1724 double SVTXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException)
1726 SolarMutexGuard aGuard;
1728 FormattedField* pField = GetFormattedField();
1729 return pField ? pField->GetMaxValue() : 0;
1732 void SVTXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1734 SolarMutexGuard aGuard;
1736 FormattedField* pField = GetFormattedField();
1737 if ( pField )
1738 pField->SetSpinFirst( Value );
1741 double SVTXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1743 SolarMutexGuard aGuard;
1745 FormattedField* pField = GetFormattedField();
1746 return pField ? pField->GetSpinFirst() : 0;
1749 void SVTXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1751 SolarMutexGuard aGuard;
1753 FormattedField* pField = GetFormattedField();
1754 if ( pField )
1755 pField->SetSpinLast( Value );
1758 double SVTXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException)
1760 SolarMutexGuard aGuard;
1762 FormattedField* pField = GetFormattedField();
1763 return pField ? pField->GetSpinLast() : 0;
1766 void SVTXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1768 SolarMutexGuard aGuard;
1770 FormattedField* pField = GetFormattedField();
1771 if ( pField )
1772 pField->SetSpinSize( Value );
1775 double SVTXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1777 SolarMutexGuard aGuard;
1779 FormattedField* pField = GetFormattedField();
1780 return pField ? pField->GetSpinSize() : 0;
1783 void SVTXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1785 SolarMutexGuard aGuard;
1787 FormattedField* pField = GetFormattedField();
1788 if ( pField )
1789 pField->SetDecimalDigits( Value );
1792 sal_Int16 SVTXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1794 SolarMutexGuard aGuard;
1796 FormattedField* pField = GetFormattedField();
1797 return pField ? pField->GetDecimalDigits() : 0;
1800 void SVTXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1802 SolarMutexGuard aGuard;
1804 FormattedField* pField = GetFormattedField();
1805 if ( pField )
1806 pField->SetStrictFormat( bStrict );
1809 sal_Bool SVTXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1811 SolarMutexGuard aGuard;
1813 FormattedField* pField = GetFormattedField();
1814 return pField ? pField->IsStrictFormat() : sal_False;
1817 void SVTXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1819 SVTXFormattedField::ImplGetPropertyIds( rIds );
1822 // ----------------------------------------------------
1823 // class SVTXCurrencyField
1824 // ----------------------------------------------------
1825 SVTXCurrencyField::SVTXCurrencyField()
1829 SVTXCurrencyField::~SVTXCurrencyField()
1833 ::com::sun::star::uno::Any SVTXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1835 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1836 (static_cast< ::com::sun::star::awt::XCurrencyField* >(this)),
1837 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
1838 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1841 // ::com::sun::star::lang::XTypeProvider
1842 IMPL_XTYPEPROVIDER_START( SVTXCurrencyField )
1843 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
1844 SVTXFormattedField::getTypes()
1845 IMPL_XTYPEPROVIDER_END
1847 void SVTXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1849 SolarMutexGuard aGuard;
1851 FormattedField* pField = GetFormattedField();
1852 if ( pField )
1853 pField->SetValue( Value );
1856 double SVTXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException)
1858 SolarMutexGuard aGuard;
1860 FormattedField* pField = GetFormattedField();
1861 return pField ? pField->GetValue() : 0;
1864 void SVTXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1866 SolarMutexGuard aGuard;
1868 FormattedField* pField = GetFormattedField();
1869 if ( pField )
1870 pField->SetMinValue( Value );
1873 double SVTXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException)
1875 SolarMutexGuard aGuard;
1877 FormattedField* pField = GetFormattedField();
1878 return pField ? pField->GetMinValue() : 0;
1881 void SVTXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1883 SolarMutexGuard aGuard;
1885 FormattedField* pField = GetFormattedField();
1886 if ( pField )
1887 pField->SetMaxValue( Value );
1890 double SVTXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException)
1892 SolarMutexGuard aGuard;
1894 FormattedField* pField = GetFormattedField();
1895 return pField ? pField->GetMaxValue() : 0;
1898 void SVTXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1900 SolarMutexGuard aGuard;
1902 FormattedField* pField = GetFormattedField();
1903 if ( pField )
1904 pField->SetSpinFirst( Value );
1907 double SVTXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1909 SolarMutexGuard aGuard;
1911 FormattedField* pField = GetFormattedField();
1912 return pField ? pField->GetSpinFirst() : 0;
1915 void SVTXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1917 SolarMutexGuard aGuard;
1919 FormattedField* pField = GetFormattedField();
1920 if ( pField )
1921 pField->SetSpinLast( Value );
1924 double SVTXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException)
1926 SolarMutexGuard aGuard;
1928 FormattedField* pField = GetFormattedField();
1929 return pField ? pField->GetSpinLast() : 0;
1932 void SVTXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1934 SolarMutexGuard aGuard;
1936 FormattedField* pField = GetFormattedField();
1937 if ( pField )
1938 pField->SetSpinSize( Value );
1941 double SVTXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1943 SolarMutexGuard aGuard;
1945 FormattedField* pField = GetFormattedField();
1946 return pField ? pField->GetSpinSize() : 0;
1949 void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1951 SolarMutexGuard aGuard;
1953 FormattedField* pField = GetFormattedField();
1954 if ( pField )
1955 pField->SetDecimalDigits( Value );
1958 sal_Int16 SVTXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1960 SolarMutexGuard aGuard;
1962 FormattedField* pField = GetFormattedField();
1963 return pField ? pField->GetDecimalDigits() : 0;
1966 void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1968 SolarMutexGuard aGuard;
1970 FormattedField* pField = GetFormattedField();
1971 if ( pField )
1972 pField->SetStrictFormat( bStrict );
1975 sal_Bool SVTXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1977 SolarMutexGuard aGuard;
1979 FormattedField* pField = GetFormattedField();
1980 return pField ? pField->IsStrictFormat() : sal_False;
1983 void SVTXCurrencyField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1985 SolarMutexGuard aGuard;
1987 ::com::sun::star::uno::Any aReturn;
1989 DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
1990 if ( pField )
1992 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1993 switch (nPropType)
1995 case BASEPROPERTY_CURRENCYSYMBOL:
1997 OUString aStr;
1998 Value >>= aStr;
1999 pField->setCurrencySymbol( aStr );
2001 break;
2002 case BASEPROPERTY_CURSYM_POSITION:
2004 sal_Bool b = false;
2005 Value >>= b;
2006 pField->setPrependCurrSym(b);
2008 break;
2010 default:
2011 SVTXFormattedField::setProperty(PropertyName, Value);
2014 else
2015 SVTXFormattedField::setProperty(PropertyName, Value);
2018 ::com::sun::star::uno::Any SVTXCurrencyField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2020 SolarMutexGuard aGuard;
2022 ::com::sun::star::uno::Any aReturn;
2024 DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
2025 if ( pField )
2027 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2028 switch (nPropType)
2030 case BASEPROPERTY_CURRENCYSYMBOL:
2032 aReturn <<= OUString( pField->getCurrencySymbol() );
2034 break;
2035 case BASEPROPERTY_CURSYM_POSITION:
2037 aReturn <<= pField->getPrependCurrSym();
2039 break;
2040 default:
2041 return SVTXFormattedField::getProperty(PropertyName);
2044 return SVTXFormattedField::getProperty(PropertyName);
2047 void SVTXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2049 PushPropertyIds( rIds,
2050 BASEPROPERTY_CURRENCYSYMBOL,
2051 BASEPROPERTY_CURSYM_POSITION,
2053 SVTXFormattedField::ImplGetPropertyIds( rIds );
2057 // ----------------------------------------------------
2058 // class VCLXProgressBar
2059 // ----------------------------------------------------
2061 VCLXProgressBar::VCLXProgressBar()
2062 :m_nValue(0)
2063 ,m_nValueMin(0)
2064 ,m_nValueMax(100)
2068 VCLXProgressBar::~VCLXProgressBar()
2072 void VCLXProgressBar::ImplUpdateValue()
2074 ProgressBar* pProgressBar = (ProgressBar*) GetWindow();
2075 if ( pProgressBar )
2077 sal_Int32 nVal;
2078 sal_Int32 nValMin;
2079 sal_Int32 nValMax;
2081 // check min and max
2082 if (m_nValueMin < m_nValueMax)
2084 nValMin = m_nValueMin;
2085 nValMax = m_nValueMax;
2087 else
2089 nValMin = m_nValueMax;
2090 nValMax = m_nValueMin;
2093 // check value
2094 if (m_nValue < nValMin)
2096 nVal = nValMin;
2098 else if (m_nValue > nValMax)
2100 nVal = nValMax;
2102 else
2104 nVal = m_nValue;
2107 // calculate percent
2108 sal_Int32 nPercent;
2109 if (nValMin != nValMax)
2111 nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
2113 else
2115 nPercent = 0;
2118 // set progressbar value
2119 pProgressBar->SetValue( (sal_uInt16) nPercent );
2123 // ::com::sun::star::uno::XInterface
2124 ::com::sun::star::uno::Any VCLXProgressBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2126 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2127 (static_cast< ::com::sun::star::awt::XProgressBar* >(this)),
2128 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
2129 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2132 // ::com::sun::star::lang::XTypeProvider
2133 IMPL_XTYPEPROVIDER_START( VCLXProgressBar )
2134 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar>* ) NULL ),
2135 VCLXWindow::getTypes()
2136 IMPL_XTYPEPROVIDER_END
2138 // ::com::sun::star::awt::XProgressBar
2139 void VCLXProgressBar::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2141 SolarMutexGuard aGuard;
2143 Window* pWindow = GetWindow();
2144 if ( pWindow )
2146 Color aColor( nColor );
2147 pWindow->SetControlForeground( aColor );
2151 void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2153 SolarMutexGuard aGuard;
2155 Window* pWindow = GetWindow();
2156 if ( pWindow )
2158 Color aColor( nColor );
2159 pWindow->SetBackground( aColor );
2160 pWindow->SetControlBackground( aColor );
2161 pWindow->Invalidate();
2165 void VCLXProgressBar::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
2167 SolarMutexGuard aGuard;
2169 m_nValue = nValue;
2170 ImplUpdateValue();
2173 void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
2175 SolarMutexGuard aGuard;
2177 if ( nMin < nMax )
2179 // take correct min and max
2180 m_nValueMin = nMin;
2181 m_nValueMax = nMax;
2183 else
2185 // change min and max
2186 m_nValueMin = nMax;
2187 m_nValueMax = nMin;
2190 ImplUpdateValue();
2193 sal_Int32 VCLXProgressBar::getValue() throw(::com::sun::star::uno::RuntimeException)
2195 SolarMutexGuard aGuard;
2197 return m_nValue;
2200 // ::com::sun::star::awt::VclWindowPeer
2201 void VCLXProgressBar::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
2203 SolarMutexGuard aGuard;
2205 ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2206 if ( pProgressBar )
2208 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2209 switch ( nPropType )
2211 case BASEPROPERTY_PROGRESSVALUE:
2213 if ( Value >>= m_nValue )
2214 ImplUpdateValue();
2216 break;
2217 case BASEPROPERTY_PROGRESSVALUE_MIN:
2219 if ( Value >>= m_nValueMin )
2220 ImplUpdateValue();
2222 break;
2223 case BASEPROPERTY_PROGRESSVALUE_MAX:
2225 if ( Value >>= m_nValueMax )
2226 ImplUpdateValue();
2228 break;
2229 case BASEPROPERTY_FILLCOLOR:
2231 Window* pWindow = GetWindow();
2232 if ( pWindow )
2234 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2236 if ( bVoid )
2238 pWindow->SetControlForeground();
2240 else
2242 sal_Int32 nColor = 0;
2243 if ( Value >>= nColor )
2245 Color aColor( nColor );
2246 pWindow->SetControlForeground( aColor );
2251 break;
2252 default:
2253 VCLXWindow::setProperty( PropertyName, Value );
2254 break;
2259 ::com::sun::star::uno::Any VCLXProgressBar::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2261 SolarMutexGuard aGuard;
2263 ::com::sun::star::uno::Any aProp;
2264 ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2265 if ( pProgressBar )
2267 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2268 switch ( nPropType )
2270 case BASEPROPERTY_PROGRESSVALUE:
2272 aProp <<= m_nValue;
2274 break;
2275 case BASEPROPERTY_PROGRESSVALUE_MIN:
2277 aProp <<= m_nValueMin;
2279 break;
2280 case BASEPROPERTY_PROGRESSVALUE_MAX:
2282 aProp <<= m_nValueMax;
2284 break;
2285 default:
2286 aProp <<= VCLXWindow::getProperty( PropertyName );
2287 break;
2290 return aProp;
2293 void VCLXProgressBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2295 PushPropertyIds( rIds,
2296 BASEPROPERTY_PROGRESSVALUE,
2297 BASEPROPERTY_PROGRESSVALUE_MIN,
2298 BASEPROPERTY_PROGRESSVALUE_MAX,
2299 BASEPROPERTY_FILLCOLOR,
2301 VCLXWindow::ImplGetPropertyIds( rIds, true );
2305 // ----------------------------------------------------
2306 // class SVTXDateField
2307 // ----------------------------------------------------
2308 SVTXDateField::SVTXDateField()
2309 :VCLXDateField()
2313 SVTXDateField::~SVTXDateField()
2317 void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException)
2319 VCLXDateField::setProperty( PropertyName, Value );
2321 // some properties need to be forwarded to the sub edit, too
2322 Edit* pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow() )->GetSubEdit() : NULL;
2323 if ( !pSubEdit )
2324 return;
2326 switch ( GetPropertyId( PropertyName ) )
2328 case BASEPROPERTY_TEXTLINECOLOR:
2329 if ( !Value.hasValue() )
2330 pSubEdit->SetTextLineColor();
2331 else
2333 sal_Int32 nColor = 0;
2334 if ( Value >>= nColor )
2335 pSubEdit->SetTextLineColor( Color( nColor ) );
2337 break;
2341 void SVTXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2343 PushPropertyIds( rIds,
2344 BASEPROPERTY_TEXTLINECOLOR,
2346 VCLXDateField::ImplGetPropertyIds( rIds );
2349 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */