GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / uno / unoiface.cxx
blobe0cf91e1b3b0ecd9215bb54b46b55568ac532ee8
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 OUString aServiceName( pDescriptor->WindowServiceName );
66 if ( aServiceName.equalsIgnoreAsciiCase( "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.equalsIgnoreAsciiCase( "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.equalsIgnoreAsciiCase("FormattedField") )
95 pWindow = new FormattedField( pParent, nWinBits );
96 *ppNewComp = new SVTXFormattedField;
98 else if (aServiceName.equalsIgnoreAsciiCase("NumericField") )
100 pWindow = new DoubleNumericField( pParent, nWinBits );
101 *ppNewComp = new SVTXNumericField;
103 else if (aServiceName.equalsIgnoreAsciiCase("LongCurrencyField") )
105 pWindow = new DoubleCurrencyField( pParent, nWinBits );
106 *ppNewComp = new SVTXCurrencyField;
108 else if (aServiceName.equalsIgnoreAsciiCase("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.equalsIgnoreAsciiCase("roadmap") )
119 pWindow = new ::svt::ORoadmap( pParent, WB_TABSTOP );
120 *ppNewComp = new SVTXRoadmap;
122 else if ( aServiceName.equalsIgnoreAsciiCase( "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.equalsIgnoreAsciiCase( "Tree" ) )
137 TreeControlPeer* pPeer = new TreeControlPeer;
138 *ppNewComp = pPeer;
139 pWindow = pPeer->createVclControl( pParent, nWinBits );
141 else if ( aServiceName.equalsIgnoreAsciiCase( "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.equalsIgnoreAsciiCase( "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 OUString sConverted;
1055 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
1056 aReturn <<= sConverted;
1058 break;
1059 case ::com::sun::star::uno::TypeClass_STRING:
1061 OUString aStr;
1062 rValue >>= aStr;
1063 if (pField->TreatingAsNumber())
1065 SvNumberFormatter* pFormatter = pField->GetFormatter();
1066 if (!pFormatter)
1067 pFormatter = pField->StandardFormatter();
1069 double dVal;
1070 sal_uInt32 nTestFormat(0);
1071 if (!pFormatter->IsNumberFormat(aStr, nTestFormat, dVal))
1072 aReturn.clear();
1073 aReturn <<= dVal;
1075 else
1076 aReturn <<= aStr;
1078 break;
1079 default:
1080 aReturn.clear();
1081 break;
1083 return aReturn;
1086 // --------------------------------------------------------------------------------------
1087 void SVTXFormattedField::SetMinValue(const ::com::sun::star::uno::Any& rValue)
1089 FormattedField* pField = GetFormattedField();
1090 if (!pField)
1091 return;
1093 switch (rValue.getValueType().getTypeClass())
1096 case ::com::sun::star::uno::TypeClass_DOUBLE:
1098 double d = 0.0;
1099 rValue >>= d;
1100 pField->SetMinValue(d);
1102 break;
1103 default:
1104 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
1105 if ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID )
1108 throw ::com::sun::star::lang::IllegalArgumentException();
1110 pField->ClearMinValue();
1111 break;
1115 // --------------------------------------------------------------------------------------
1116 ::com::sun::star::uno::Any SVTXFormattedField::GetMinValue()
1118 FormattedField* pField = GetFormattedField();
1119 if (!pField || !pField->HasMinValue())
1120 return ::com::sun::star::uno::Any();
1122 ::com::sun::star::uno::Any aReturn;
1123 aReturn <<= pField->GetMinValue();
1124 return aReturn;
1127 // --------------------------------------------------------------------------------------
1128 void SVTXFormattedField::SetMaxValue(const ::com::sun::star::uno::Any& rValue)
1130 FormattedField* pField = GetFormattedField();
1131 if (!pField)
1132 return;
1134 switch (rValue.getValueType().getTypeClass())
1137 case ::com::sun::star::uno::TypeClass_DOUBLE:
1139 double d = 0.0;
1140 rValue >>= d;
1141 pField->SetMaxValue(d);
1143 break;
1144 default:
1145 if (rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID)
1148 throw ::com::sun::star::lang::IllegalArgumentException();
1150 pField->ClearMaxValue();
1151 break;
1155 // --------------------------------------------------------------------------------------
1156 ::com::sun::star::uno::Any SVTXFormattedField::GetMaxValue()
1158 FormattedField* pField = GetFormattedField();
1159 if (!pField || !pField->HasMaxValue())
1160 return ::com::sun::star::uno::Any();
1162 ::com::sun::star::uno::Any aReturn;
1163 aReturn <<= pField->GetMaxValue();
1164 return aReturn;
1167 // --------------------------------------------------------------------------------------
1168 void SVTXFormattedField::SetDefaultValue(const ::com::sun::star::uno::Any& rValue)
1170 FormattedField* pField = GetFormattedField();
1171 if (!pField)
1172 return;
1174 ::com::sun::star::uno::Any aConverted = convertEffectiveValue(rValue);
1176 switch (aConverted.getValueType().getTypeClass())
1179 case ::com::sun::star::uno::TypeClass_DOUBLE:
1181 double d = 0.0;
1182 aConverted >>= d;
1183 pField->SetDefaultValue(d);
1185 break;
1186 case ::com::sun::star::uno::TypeClass_STRING:
1188 OUString aStr;
1189 aConverted >>= aStr;
1190 pField->SetDefaultText( aStr );
1192 break;
1193 default:
1194 pField->EnableEmptyField(sal_True);
1195 // nur noch void erlaubt
1196 break;
1200 // --------------------------------------------------------------------------------------
1201 ::com::sun::star::uno::Any SVTXFormattedField::GetDefaultValue()
1203 FormattedField* pField = GetFormattedField();
1204 if (!pField || pField->IsEmptyFieldEnabled())
1205 return ::com::sun::star::uno::Any();
1207 ::com::sun::star::uno::Any aReturn;
1208 if (pField->TreatingAsNumber())
1209 aReturn <<= pField->GetDefaultValue();
1210 else
1211 aReturn <<= OUString( pField->GetDefaultText() );
1212 return aReturn;
1215 // --------------------------------------------------------------------------------------
1216 sal_Bool SVTXFormattedField::GetTreatAsNumber()
1218 FormattedField* pField = GetFormattedField();
1219 if (pField)
1220 return pField->TreatingAsNumber();
1222 return sal_True;
1225 // --------------------------------------------------------------------------------------
1226 void SVTXFormattedField::SetTreatAsNumber(sal_Bool bSet)
1228 FormattedField* pField = GetFormattedField();
1229 if (pField)
1230 pField->TreatAsNumber(bSet);
1233 // --------------------------------------------------------------------------------------
1234 ::com::sun::star::uno::Any SVTXFormattedField::GetValue()
1236 FormattedField* pField = GetFormattedField();
1237 if (!pField)
1238 return ::com::sun::star::uno::Any();
1240 ::com::sun::star::uno::Any aReturn;
1241 if (!pField->TreatingAsNumber())
1243 OUString sText = pField->GetTextValue();
1244 aReturn <<= sText;
1246 else
1248 if (!pField->GetText().isEmpty()) // empty wird erst mal standardmaessig als void nach draussen gereicht
1249 aReturn <<= pField->GetValue();
1252 return aReturn;
1255 // --------------------------------------------------------------------------------------
1256 void SVTXFormattedField::SetValue(const ::com::sun::star::uno::Any& rValue)
1258 FormattedField* pField = GetFormattedField();
1259 if (!pField)
1260 return;
1262 if (!rValue.hasValue())
1264 pField->SetText("");
1266 else
1268 if (rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE )
1270 double d = 0.0;
1271 rValue >>= d;
1272 pField->SetValue(d);
1274 else
1276 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
1278 OUString sText;
1279 rValue >>= sText;
1280 if (!pField->TreatingAsNumber())
1281 pField->SetTextFormatted(sText);
1282 else
1283 pField->SetTextValue(sText);
1286 // NotifyTextListeners();
1289 // --------------------------------------------------------------------------------------
1290 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier(void) const
1292 return ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > ((::com::sun::star::util::XNumberFormatsSupplier*)m_pCurrentSupplier);
1295 // --------------------------------------------------------------------------------------
1296 void SVTXFormattedField::setFormatsSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier)
1298 FormattedField* pField = GetFormattedField();
1300 SvNumberFormatsSupplierObj* pNew = NULL;
1301 if (!xSupplier.is())
1303 if (pField)
1305 pNew = new SvNumberFormatsSupplierObj(pField->StandardFormatter());
1306 bIsStandardSupplier = sal_True;
1309 else
1311 pNew = SvNumberFormatsSupplierObj::getImplementation(xSupplier);
1312 bIsStandardSupplier = sal_False;
1315 if (!pNew)
1316 return; // TODO : wie das behandeln ?
1318 if (m_pCurrentSupplier)
1319 m_pCurrentSupplier->release();
1320 m_pCurrentSupplier = pNew;
1321 m_pCurrentSupplier->acquire();
1322 if (pField)
1324 // den aktuellen Value mit hinueberretten
1325 ::com::sun::star::uno::Any aCurrent = GetValue();
1326 pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), sal_False);
1327 if (nKeyToSetDelayed != -1)
1329 pField->SetFormatKey(nKeyToSetDelayed);
1330 nKeyToSetDelayed = -1;
1332 SetValue(aCurrent);
1333 NotifyTextListeners();
1337 // --------------------------------------------------------------------------------------
1338 sal_Int32 SVTXFormattedField::getFormatKey(void) const
1340 FormattedField* pField = GetFormattedField();
1341 return pField ? pField->GetFormatKey() : 0;
1344 // --------------------------------------------------------------------------------------
1345 void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
1347 FormattedField* pField = GetFormattedField();
1348 if (pField)
1350 if (pField->GetFormatter())
1351 pField->SetFormatKey(nKey);
1352 else
1353 { // Wahrscheinlich bin ich gerade in einem Block, in dem erst der Key und dann der Formatter gesetzt
1354 // wird, das passiert initial mit ziemlicher Sicherheit, da die Properties in alphabetischer Reihenfolge
1355 // gesetzt werden, und der FormatsSupplier nun mal vor dem FormatKey kommt
1356 nKeyToSetDelayed = nKey;
1358 NotifyTextListeners();
1362 // --------------------------------------------------------------------------------------
1363 void SVTXFormattedField::NotifyTextListeners()
1365 if ( GetTextListeners().getLength() )
1367 ::com::sun::star::awt::TextEvent aEvent;
1368 aEvent.Source = (::cppu::OWeakObject*)this;
1369 GetTextListeners().textChanged( aEvent );
1373 void SVTXFormattedField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1375 PushPropertyIds( rIds,
1376 // FIXME: elide duplication ?
1377 BASEPROPERTY_EFFECTIVE_MIN,
1378 BASEPROPERTY_VALUEMIN_DOUBLE,
1379 BASEPROPERTY_EFFECTIVE_MAX,
1380 BASEPROPERTY_VALUEMAX_DOUBLE,
1381 BASEPROPERTY_EFFECTIVE_DEFAULT,
1382 BASEPROPERTY_TREATASNUMBER,
1383 BASEPROPERTY_EFFECTIVE_VALUE,
1384 BASEPROPERTY_VALUE_DOUBLE,
1385 BASEPROPERTY_VALUESTEP_DOUBLE,
1386 BASEPROPERTY_DECIMALACCURACY,
1387 BASEPROPERTY_FORMATSSUPPLIER,
1388 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
1389 BASEPROPERTY_FORMATKEY,
1390 BASEPROPERTY_TREATASNUMBER,
1391 BASEPROPERTY_ENFORCE_FORMAT,
1393 VCLXWindow::ImplGetPropertyIds( rIds, true );
1394 VCLXSpinField::ImplGetPropertyIds( rIds );
1398 // ----------------------------------------------------
1399 // class SVTXRoadmap
1400 // ----------------------------------------------------
1402 using namespace svt;
1404 // --------------------------------------------------------------------------------------
1405 SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this )
1409 // --------------------------------------------------------------------------------------
1410 SVTXRoadmap::~SVTXRoadmap()
1414 void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
1416 switch ( rVclWindowEvent.GetId() )
1418 case VCLEVENT_ROADMAP_ITEMSELECTED:
1420 SolarMutexGuard aGuard;
1421 ::svt::ORoadmap* pField = GetRoadmap();
1422 if ( pField )
1424 sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID();
1425 ::com::sun::star::awt::ItemEvent aEvent;
1426 aEvent.Selected = CurItemID;
1427 aEvent.Highlighted = CurItemID;
1428 aEvent.ItemId = CurItemID;
1429 maItemListeners.itemStateChanged( aEvent );
1432 break;
1433 default:
1434 SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent );
1435 break;
1440 void SVTXRoadmap::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
1442 SolarMutexGuard aGuard;
1443 ::svt::ORoadmap* pField = GetRoadmap();
1444 if ( pField )
1446 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1447 xRoadmapItem = evt.Source;
1448 sal_Int32 nID = 0;
1449 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1450 ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue("ID");
1451 aValue >>= nID;
1453 ::com::sun::star::uno::Any rVal = evt.NewValue;
1454 evt.NewValue >>= rVal;
1455 OUString sPropertyName = evt.PropertyName;
1456 if ( sPropertyName == "Enabled" )
1458 sal_Bool bEnable = false;
1459 evt.NewValue >>= bEnable;
1460 pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable );
1462 else if ( sPropertyName == "Label" )
1464 OUString sLabel;
1465 evt.NewValue >>= sLabel;
1466 pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel );
1468 else if ( sPropertyName == "ID" )
1470 sal_Int32 nNewID = 0;
1471 evt.NewValue >>= nNewID;
1472 evt.OldValue >>= nID;
1473 pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID );
1475 // else
1476 // Todo: handle Interactive appropriately
1481 void SVTXRoadmap::addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1483 maItemListeners.addInterface( l );
1486 void SVTXRoadmap::removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException)
1488 maItemListeners.removeInterface( l );
1491 RMItemData SVTXRoadmap::GetRMItemData( const ::com::sun::star::container::ContainerEvent& _rEvent )
1493 RMItemData aCurRMItemData;
1494 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRoadmapItem;
1495 _rEvent.Element >>= xRoadmapItem;
1496 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropertySet( xRoadmapItem, ::com::sun::star::uno::UNO_QUERY );
1497 if ( xPropertySet.is() )
1499 ::com::sun::star::uno::Any aValue = xPropertySet->getPropertyValue("Label");
1500 aValue >>= aCurRMItemData.Label;
1501 aValue = xPropertySet->getPropertyValue("ID");
1502 aValue >>= aCurRMItemData.n_ID;
1503 aValue = xPropertySet->getPropertyValue("Enabled");
1504 aValue >>= aCurRMItemData.b_Enabled;
1506 else
1508 aCurRMItemData.b_Enabled = sal_False;
1509 aCurRMItemData.n_ID = 0;
1511 return aCurRMItemData;
1514 void SVTXRoadmap::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1516 SolarMutexGuard aGuard;
1517 ::svt::ORoadmap* pField = GetRoadmap();
1518 if ( pField )
1520 RMItemData CurItemData = GetRMItemData( _rEvent );
1521 sal_Int32 InsertIndex = 0;
1522 _rEvent.Accessor >>= InsertIndex;
1523 pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1527 void SVTXRoadmap::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1529 SolarMutexGuard aGuard;
1530 ::svt::ORoadmap* pField = GetRoadmap();
1531 if ( pField )
1533 sal_Int32 DelIndex = 0;
1534 _rEvent.Accessor >>= DelIndex;
1535 pField->DeleteRoadmapItem(DelIndex);
1539 void SVTXRoadmap::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent )throw(::com::sun::star::uno::RuntimeException)
1541 SolarMutexGuard aGuard;
1542 ::svt::ORoadmap* pField = GetRoadmap();
1543 if ( pField )
1545 RMItemData CurItemData = GetRMItemData( _rEvent );
1546 sal_Int32 ReplaceIndex = 0;
1547 _rEvent.Accessor >>= ReplaceIndex;
1548 pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, (RoadmapTypes::ItemId)CurItemData.n_ID, CurItemData.b_Enabled );
1554 // --------------------------------------------------------------------------------------
1555 void SVTXRoadmap::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1557 SolarMutexGuard aGuard;
1559 ::svt::ORoadmap* pField = GetRoadmap();
1560 if ( pField )
1562 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1563 switch (nPropType)
1565 case BASEPROPERTY_COMPLETE:
1567 sal_Bool b = false;
1568 Value >>= b;
1569 pField->SetRoadmapComplete( b);
1571 break;
1573 case BASEPROPERTY_ACTIVATED:
1575 sal_Bool b = false;
1576 Value >>= b;
1577 pField->SetRoadmapInteractive( b);
1579 break;
1581 case BASEPROPERTY_CURRENTITEMID:
1583 sal_Int32 nId = 0;
1584 Value >>= nId;
1585 pField->SelectRoadmapItemByID( (RoadmapTypes::ItemId)nId );
1587 break;
1589 case BASEPROPERTY_TEXT:
1591 OUString aStr;
1592 Value >>= aStr;
1593 pField->SetText( aStr );
1594 pField->Invalidate();
1596 break;
1598 default:
1599 SVTXRoadmap_Base::setProperty( PropertyName, Value );
1600 break;
1604 else
1605 SVTXRoadmap_Base::setProperty( PropertyName, Value );
1609 // --------------------------------------------------------------------------------------
1610 ::com::sun::star::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
1612 SolarMutexGuard aGuard;
1614 ::com::sun::star::uno::Any aReturn;
1616 ::svt::ORoadmap* pField = GetRoadmap();
1617 if ( pField )
1619 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1620 switch (nPropType)
1622 case BASEPROPERTY_COMPLETE:
1623 aReturn <<= pField->IsRoadmapComplete();
1624 break;
1625 case BASEPROPERTY_ACTIVATED:
1626 aReturn <<= pField->IsRoadmapInteractive();
1627 break;
1628 case BASEPROPERTY_CURRENTITEMID:
1629 aReturn <<= pField->GetCurrentRoadmapItemID();
1630 break;
1631 default:
1632 aReturn = SVTXRoadmap_Base::getProperty(PropertyName);
1633 break;
1636 return aReturn;
1639 void SVTXRoadmap::ImplSetNewImage()
1641 OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" );
1642 ::svt::ORoadmap* pButton = static_cast< ::svt::ORoadmap* >( GetWindow() );
1643 pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() );
1646 void SVTXRoadmap::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1648 PushPropertyIds( rIds,
1649 BASEPROPERTY_COMPLETE,
1650 BASEPROPERTY_ACTIVATED,
1651 BASEPROPERTY_CURRENTITEMID,
1652 BASEPROPERTY_TEXT,
1654 VCLXWindow::ImplGetPropertyIds( rIds, true );
1655 VCLXGraphicControl::ImplGetPropertyIds( rIds );
1658 // ----------------------------------------------------
1659 // class SVTXNumericField
1660 // ----------------------------------------------------
1661 SVTXNumericField::SVTXNumericField()
1665 SVTXNumericField::~SVTXNumericField()
1669 ::com::sun::star::uno::Any SVTXNumericField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1671 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1672 (static_cast< ::com::sun::star::awt::XNumericField* >(this)),
1673 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
1674 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1677 // ::com::sun::star::lang::XTypeProvider
1678 IMPL_XTYPEPROVIDER_START( SVTXNumericField )
1679 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XNumericField>* ) NULL ),
1680 SVTXFormattedField::getTypes()
1681 IMPL_XTYPEPROVIDER_END
1684 void SVTXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1686 SolarMutexGuard aGuard;
1688 FormattedField* pField = GetFormattedField();
1689 if ( pField )
1690 pField->SetValue( Value );
1693 double SVTXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException)
1695 SolarMutexGuard aGuard;
1697 FormattedField* pField = GetFormattedField();
1698 return pField ? pField->GetValue() : 0;
1701 void SVTXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1703 SolarMutexGuard aGuard;
1705 FormattedField* pField = GetFormattedField();
1706 if ( pField )
1707 pField->SetMinValue( Value );
1710 double SVTXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException)
1712 SolarMutexGuard aGuard;
1714 FormattedField* pField = GetFormattedField();
1715 return pField ? pField->GetMinValue() : 0;
1718 void SVTXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1720 SolarMutexGuard aGuard;
1722 FormattedField* pField = GetFormattedField();
1723 if ( pField )
1724 pField->SetMaxValue( Value );
1727 double SVTXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException)
1729 SolarMutexGuard aGuard;
1731 FormattedField* pField = GetFormattedField();
1732 return pField ? pField->GetMaxValue() : 0;
1735 void SVTXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1737 SolarMutexGuard aGuard;
1739 FormattedField* pField = GetFormattedField();
1740 if ( pField )
1741 pField->SetSpinFirst( Value );
1744 double SVTXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1746 SolarMutexGuard aGuard;
1748 FormattedField* pField = GetFormattedField();
1749 return pField ? pField->GetSpinFirst() : 0;
1752 void SVTXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1754 SolarMutexGuard aGuard;
1756 FormattedField* pField = GetFormattedField();
1757 if ( pField )
1758 pField->SetSpinLast( Value );
1761 double SVTXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException)
1763 SolarMutexGuard aGuard;
1765 FormattedField* pField = GetFormattedField();
1766 return pField ? pField->GetSpinLast() : 0;
1769 void SVTXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1771 SolarMutexGuard aGuard;
1773 FormattedField* pField = GetFormattedField();
1774 if ( pField )
1775 pField->SetSpinSize( Value );
1778 double SVTXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1780 SolarMutexGuard aGuard;
1782 FormattedField* pField = GetFormattedField();
1783 return pField ? pField->GetSpinSize() : 0;
1786 void SVTXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1788 SolarMutexGuard aGuard;
1790 FormattedField* pField = GetFormattedField();
1791 if ( pField )
1792 pField->SetDecimalDigits( Value );
1795 sal_Int16 SVTXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1797 SolarMutexGuard aGuard;
1799 FormattedField* pField = GetFormattedField();
1800 return pField ? pField->GetDecimalDigits() : 0;
1803 void SVTXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1805 SolarMutexGuard aGuard;
1807 FormattedField* pField = GetFormattedField();
1808 if ( pField )
1809 pField->SetStrictFormat( bStrict );
1812 sal_Bool SVTXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1814 SolarMutexGuard aGuard;
1816 FormattedField* pField = GetFormattedField();
1817 return pField ? pField->IsStrictFormat() : sal_False;
1820 void SVTXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1822 SVTXFormattedField::ImplGetPropertyIds( rIds );
1825 // ----------------------------------------------------
1826 // class SVTXCurrencyField
1827 // ----------------------------------------------------
1828 SVTXCurrencyField::SVTXCurrencyField()
1832 SVTXCurrencyField::~SVTXCurrencyField()
1836 ::com::sun::star::uno::Any SVTXCurrencyField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
1838 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
1839 (static_cast< ::com::sun::star::awt::XCurrencyField* >(this)),
1840 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
1841 return (aRet.hasValue() ? aRet : SVTXFormattedField::queryInterface( rType ));
1844 // ::com::sun::star::lang::XTypeProvider
1845 IMPL_XTYPEPROVIDER_START( SVTXCurrencyField )
1846 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCurrencyField>* ) NULL ),
1847 SVTXFormattedField::getTypes()
1848 IMPL_XTYPEPROVIDER_END
1850 void SVTXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException)
1852 SolarMutexGuard aGuard;
1854 FormattedField* pField = GetFormattedField();
1855 if ( pField )
1856 pField->SetValue( Value );
1859 double SVTXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException)
1861 SolarMutexGuard aGuard;
1863 FormattedField* pField = GetFormattedField();
1864 return pField ? pField->GetValue() : 0;
1867 void SVTXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException)
1869 SolarMutexGuard aGuard;
1871 FormattedField* pField = GetFormattedField();
1872 if ( pField )
1873 pField->SetMinValue( Value );
1876 double SVTXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException)
1878 SolarMutexGuard aGuard;
1880 FormattedField* pField = GetFormattedField();
1881 return pField ? pField->GetMinValue() : 0;
1884 void SVTXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException)
1886 SolarMutexGuard aGuard;
1888 FormattedField* pField = GetFormattedField();
1889 if ( pField )
1890 pField->SetMaxValue( Value );
1893 double SVTXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException)
1895 SolarMutexGuard aGuard;
1897 FormattedField* pField = GetFormattedField();
1898 return pField ? pField->GetMaxValue() : 0;
1901 void SVTXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException)
1903 SolarMutexGuard aGuard;
1905 FormattedField* pField = GetFormattedField();
1906 if ( pField )
1907 pField->SetSpinFirst( Value );
1910 double SVTXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException)
1912 SolarMutexGuard aGuard;
1914 FormattedField* pField = GetFormattedField();
1915 return pField ? pField->GetSpinFirst() : 0;
1918 void SVTXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException)
1920 SolarMutexGuard aGuard;
1922 FormattedField* pField = GetFormattedField();
1923 if ( pField )
1924 pField->SetSpinLast( Value );
1927 double SVTXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException)
1929 SolarMutexGuard aGuard;
1931 FormattedField* pField = GetFormattedField();
1932 return pField ? pField->GetSpinLast() : 0;
1935 void SVTXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException)
1937 SolarMutexGuard aGuard;
1939 FormattedField* pField = GetFormattedField();
1940 if ( pField )
1941 pField->SetSpinSize( Value );
1944 double SVTXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
1946 SolarMutexGuard aGuard;
1948 FormattedField* pField = GetFormattedField();
1949 return pField ? pField->GetSpinSize() : 0;
1952 void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
1954 SolarMutexGuard aGuard;
1956 FormattedField* pField = GetFormattedField();
1957 if ( pField )
1958 pField->SetDecimalDigits( Value );
1961 sal_Int16 SVTXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
1963 SolarMutexGuard aGuard;
1965 FormattedField* pField = GetFormattedField();
1966 return pField ? pField->GetDecimalDigits() : 0;
1969 void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
1971 SolarMutexGuard aGuard;
1973 FormattedField* pField = GetFormattedField();
1974 if ( pField )
1975 pField->SetStrictFormat( bStrict );
1978 sal_Bool SVTXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
1980 SolarMutexGuard aGuard;
1982 FormattedField* pField = GetFormattedField();
1983 return pField ? pField->IsStrictFormat() : sal_False;
1986 void SVTXCurrencyField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
1988 SolarMutexGuard aGuard;
1990 DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
1991 if ( pField )
1993 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1994 switch (nPropType)
1996 case BASEPROPERTY_CURRENCYSYMBOL:
1998 OUString aStr;
1999 Value >>= aStr;
2000 pField->setCurrencySymbol( aStr );
2002 break;
2003 case BASEPROPERTY_CURSYM_POSITION:
2005 sal_Bool b = false;
2006 Value >>= b;
2007 pField->setPrependCurrSym(b);
2009 break;
2011 default:
2012 SVTXFormattedField::setProperty(PropertyName, Value);
2015 else
2016 SVTXFormattedField::setProperty(PropertyName, Value);
2019 ::com::sun::star::uno::Any SVTXCurrencyField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2021 SolarMutexGuard aGuard;
2023 ::com::sun::star::uno::Any aReturn;
2025 DoubleCurrencyField* pField = (DoubleCurrencyField*)GetFormattedField();
2026 if ( pField )
2028 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2029 switch (nPropType)
2031 case BASEPROPERTY_CURRENCYSYMBOL:
2033 aReturn <<= OUString( pField->getCurrencySymbol() );
2035 break;
2036 case BASEPROPERTY_CURSYM_POSITION:
2038 aReturn <<= pField->getPrependCurrSym();
2040 break;
2041 default:
2042 return SVTXFormattedField::getProperty(PropertyName);
2045 return SVTXFormattedField::getProperty(PropertyName);
2048 void SVTXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2050 PushPropertyIds( rIds,
2051 BASEPROPERTY_CURRENCYSYMBOL,
2052 BASEPROPERTY_CURSYM_POSITION,
2054 SVTXFormattedField::ImplGetPropertyIds( rIds );
2058 // ----------------------------------------------------
2059 // class VCLXProgressBar
2060 // ----------------------------------------------------
2062 VCLXProgressBar::VCLXProgressBar()
2063 :m_nValue(0)
2064 ,m_nValueMin(0)
2065 ,m_nValueMax(100)
2069 VCLXProgressBar::~VCLXProgressBar()
2073 void VCLXProgressBar::ImplUpdateValue()
2075 ProgressBar* pProgressBar = (ProgressBar*) GetWindow();
2076 if ( pProgressBar )
2078 sal_Int32 nVal;
2079 sal_Int32 nValMin;
2080 sal_Int32 nValMax;
2082 // check min and max
2083 if (m_nValueMin < m_nValueMax)
2085 nValMin = m_nValueMin;
2086 nValMax = m_nValueMax;
2088 else
2090 nValMin = m_nValueMax;
2091 nValMax = m_nValueMin;
2094 // check value
2095 if (m_nValue < nValMin)
2097 nVal = nValMin;
2099 else if (m_nValue > nValMax)
2101 nVal = nValMax;
2103 else
2105 nVal = m_nValue;
2108 // calculate percent
2109 sal_Int32 nPercent;
2110 if (nValMin != nValMax)
2112 nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin);
2114 else
2116 nPercent = 0;
2119 // set progressbar value
2120 pProgressBar->SetValue( (sal_uInt16) nPercent );
2124 // ::com::sun::star::uno::XInterface
2125 ::com::sun::star::uno::Any VCLXProgressBar::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
2127 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
2128 (static_cast< ::com::sun::star::awt::XProgressBar* >(this)),
2129 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
2130 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
2133 // ::com::sun::star::lang::XTypeProvider
2134 IMPL_XTYPEPROVIDER_START( VCLXProgressBar )
2135 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XProgressBar>* ) NULL ),
2136 VCLXWindow::getTypes()
2137 IMPL_XTYPEPROVIDER_END
2139 // ::com::sun::star::awt::XProgressBar
2140 void VCLXProgressBar::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2142 SolarMutexGuard aGuard;
2144 Window* pWindow = GetWindow();
2145 if ( pWindow )
2147 Color aColor( nColor );
2148 pWindow->SetControlForeground( aColor );
2152 void VCLXProgressBar::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
2154 SolarMutexGuard aGuard;
2156 Window* pWindow = GetWindow();
2157 if ( pWindow )
2159 Color aColor( nColor );
2160 pWindow->SetBackground( aColor );
2161 pWindow->SetControlBackground( aColor );
2162 pWindow->Invalidate();
2166 void VCLXProgressBar::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
2168 SolarMutexGuard aGuard;
2170 m_nValue = nValue;
2171 ImplUpdateValue();
2174 void VCLXProgressBar::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
2176 SolarMutexGuard aGuard;
2178 if ( nMin < nMax )
2180 // take correct min and max
2181 m_nValueMin = nMin;
2182 m_nValueMax = nMax;
2184 else
2186 // change min and max
2187 m_nValueMin = nMax;
2188 m_nValueMax = nMin;
2191 ImplUpdateValue();
2194 sal_Int32 VCLXProgressBar::getValue() throw(::com::sun::star::uno::RuntimeException)
2196 SolarMutexGuard aGuard;
2198 return m_nValue;
2201 // ::com::sun::star::awt::VclWindowPeer
2202 void VCLXProgressBar::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
2204 SolarMutexGuard aGuard;
2206 ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2207 if ( pProgressBar )
2209 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2210 switch ( nPropType )
2212 case BASEPROPERTY_PROGRESSVALUE:
2214 if ( Value >>= m_nValue )
2215 ImplUpdateValue();
2217 break;
2218 case BASEPROPERTY_PROGRESSVALUE_MIN:
2220 if ( Value >>= m_nValueMin )
2221 ImplUpdateValue();
2223 break;
2224 case BASEPROPERTY_PROGRESSVALUE_MAX:
2226 if ( Value >>= m_nValueMax )
2227 ImplUpdateValue();
2229 break;
2230 case BASEPROPERTY_FILLCOLOR:
2232 Window* pWindow = GetWindow();
2233 if ( pWindow )
2235 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
2237 if ( bVoid )
2239 pWindow->SetControlForeground();
2241 else
2243 sal_Int32 nColor = 0;
2244 if ( Value >>= nColor )
2246 Color aColor( nColor );
2247 pWindow->SetControlForeground( aColor );
2252 break;
2253 default:
2254 VCLXWindow::setProperty( PropertyName, Value );
2255 break;
2260 ::com::sun::star::uno::Any VCLXProgressBar::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2262 SolarMutexGuard aGuard;
2264 ::com::sun::star::uno::Any aProp;
2265 ProgressBar* pProgressBar = (ProgressBar*)GetWindow();
2266 if ( pProgressBar )
2268 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2269 switch ( nPropType )
2271 case BASEPROPERTY_PROGRESSVALUE:
2273 aProp <<= m_nValue;
2275 break;
2276 case BASEPROPERTY_PROGRESSVALUE_MIN:
2278 aProp <<= m_nValueMin;
2280 break;
2281 case BASEPROPERTY_PROGRESSVALUE_MAX:
2283 aProp <<= m_nValueMax;
2285 break;
2286 default:
2287 aProp <<= VCLXWindow::getProperty( PropertyName );
2288 break;
2291 return aProp;
2294 void VCLXProgressBar::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2296 PushPropertyIds( rIds,
2297 BASEPROPERTY_PROGRESSVALUE,
2298 BASEPROPERTY_PROGRESSVALUE_MIN,
2299 BASEPROPERTY_PROGRESSVALUE_MAX,
2300 BASEPROPERTY_FILLCOLOR,
2302 VCLXWindow::ImplGetPropertyIds( rIds, true );
2306 // ----------------------------------------------------
2307 // class SVTXDateField
2308 // ----------------------------------------------------
2309 SVTXDateField::SVTXDateField()
2310 :VCLXDateField()
2314 SVTXDateField::~SVTXDateField()
2318 void SAL_CALL SVTXDateField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException)
2320 VCLXDateField::setProperty( PropertyName, Value );
2322 // some properties need to be forwarded to the sub edit, too
2323 Edit* pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow() )->GetSubEdit() : NULL;
2324 if ( !pSubEdit )
2325 return;
2327 switch ( GetPropertyId( PropertyName ) )
2329 case BASEPROPERTY_TEXTLINECOLOR:
2330 if ( !Value.hasValue() )
2331 pSubEdit->SetTextLineColor();
2332 else
2334 sal_Int32 nColor = 0;
2335 if ( Value >>= nColor )
2336 pSubEdit->SetTextLineColor( Color( nColor ) );
2338 break;
2342 void SVTXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2344 PushPropertyIds( rIds,
2345 BASEPROPERTY_TEXTLINECOLOR,
2347 VCLXDateField::ImplGetPropertyIds( rIds );
2350 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */