Bump version to 5.0-14
[LibreOffice.git] / svtools / source / uno / unoiface.cxx
bloba768bcf09d5df83aeebebd9dc0a5e24ffeb0424b
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 <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 <cppuhelper/queryinterface.hxx>
33 #include <comphelper/processfactory.hxx>
34 #include <toolkit/helper/convert.hxx>
35 #include <toolkit/helper/property.hxx>
36 #include <svtools/fmtfield.hxx>
37 #include <svl/numuno.hxx>
38 #include <svtools/calendar.hxx>
39 #include <svtools/treelistbox.hxx>
40 #include "treecontrolpeer.hxx"
41 #include "svtxgridcontrol.hxx"
42 #include <table/tablecontrol.hxx>
44 namespace
46 static void lcl_setWinBits( vcl::Window* _pWindow, WinBits _nBits, bool _bSet )
48 WinBits nStyle = _pWindow->GetStyle();
49 if ( _bSet )
50 nStyle |= _nBits;
51 else
52 nStyle &= ~_nBits;
53 _pWindow->SetStyle( nStyle );
58 // help function for the toolkit...
61 extern "C" {
63 SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const ::com::sun::star::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits )
65 vcl::Window* pWindow = NULL;
66 OUString aServiceName( pDescriptor->WindowServiceName );
67 if ( aServiceName.equalsIgnoreAsciiCase( "MultiLineEdit" ) )
69 if ( pParent )
71 pWindow = VclPtr<MultiLineEdit>::Create( pParent, nWinBits|WB_IGNORETAB);
72 static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus();
73 *ppNewComp = new VCLXMultiLineEdit;
75 else
77 *ppNewComp = NULL;
78 return NULL;
81 else if ( aServiceName.equalsIgnoreAsciiCase( "FileControl" ) )
83 if ( pParent )
85 pWindow = VclPtr<FileControl>::Create( pParent, nWinBits );
86 *ppNewComp = new VCLXFileControl;
88 else
90 *ppNewComp = NULL;
91 return NULL;
94 else if (aServiceName.equalsIgnoreAsciiCase("FormattedField") )
96 pWindow = VclPtr<FormattedField>::Create( pParent, nWinBits );
97 *ppNewComp = new SVTXFormattedField;
99 else if (aServiceName.equalsIgnoreAsciiCase("NumericField") )
101 pWindow = VclPtr<DoubleNumericField>::Create( pParent, nWinBits );
102 *ppNewComp = new SVTXNumericField;
104 else if (aServiceName.equalsIgnoreAsciiCase("LongCurrencyField") )
106 pWindow = VclPtr<DoubleCurrencyField>::Create( pParent, nWinBits );
107 *ppNewComp = new SVTXCurrencyField;
109 else if (aServiceName.equalsIgnoreAsciiCase("datefield") )
111 pWindow = VclPtr<CalendarField>::Create( pParent, nWinBits);
112 static_cast<CalendarField*>(pWindow)->EnableToday();
113 static_cast<CalendarField*>(pWindow)->EnableNone();
114 static_cast<CalendarField*>(pWindow)->EnableEmptyFieldValue( true );
115 SVTXDateField * newComp = new SVTXDateField;
116 *ppNewComp = newComp;
117 newComp->SetFormatter( (FormatterBase*)static_cast<DateField*>(pWindow) );
119 else if (aServiceName.equalsIgnoreAsciiCase("roadmap") )
121 pWindow = VclPtr< ::svt::ORoadmap >::Create( pParent, WB_TABSTOP );
122 *ppNewComp = new SVTXRoadmap;
124 else if ( aServiceName.equalsIgnoreAsciiCase( "ProgressBar" ) )
126 if ( pParent )
128 pWindow = VclPtr<ProgressBar>::Create( pParent, nWinBits );
129 *ppNewComp = new VCLXProgressBar;
131 else
133 *ppNewComp = NULL;
134 return NULL;
137 else if ( aServiceName.equalsIgnoreAsciiCase( "Tree" ) )
139 TreeControlPeer* pPeer = new TreeControlPeer;
140 *ppNewComp = pPeer;
141 pWindow = pPeer->createVclControl( pParent, nWinBits );
143 else if ( aServiceName.equalsIgnoreAsciiCase( "FixedHyperlink" ) )
145 if ( pParent )
147 pWindow = VclPtr<FixedHyperlink>::Create( pParent, nWinBits );
148 *ppNewComp = new VCLXFixedHyperlink;
150 else
152 *ppNewComp = NULL;
153 return NULL;
156 else if ( aServiceName.equalsIgnoreAsciiCase( "Grid" ) )
158 if ( pParent )
160 pWindow = VclPtr< ::svt::table::TableControl >::Create(pParent, nWinBits);
161 *ppNewComp = new SVTXGridControl;
163 else
165 *ppNewComp = NULL;
166 return NULL;
169 return pWindow;
172 } // extern "C"
175 // class VCLXMultiLineEdit
177 VCLXMultiLineEdit::VCLXMultiLineEdit()
178 :maTextListeners( *this )
179 ,meLineEndType( LINEEND_LF ) // default behavior before introducing this property: LF (unix-like)
183 VCLXMultiLineEdit::~VCLXMultiLineEdit()
187 ::com::sun::star::uno::Any VCLXMultiLineEdit::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
189 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
190 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
191 (static_cast< ::com::sun::star::awt::XTextArea* >(this)),
192 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)),
193 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
194 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
197 // ::com::sun::star::lang::XTypeProvider
198 IMPL_XTYPEPROVIDER_START( VCLXMultiLineEdit )
199 cppu::UnoType<com::sun::star::awt::XTextComponent>::get(),
200 cppu::UnoType<com::sun::star::awt::XTextArea>::get(),
201 cppu::UnoType<com::sun::star::awt::XTextLayoutConstrains>::get(),
202 VCLXWindow::getTypes()
203 IMPL_XTYPEPROVIDER_END
205 void VCLXMultiLineEdit::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
207 maTextListeners.addInterface( l );
210 void VCLXMultiLineEdit::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
212 maTextListeners.removeInterface( l );
215 void VCLXMultiLineEdit::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
217 SolarMutexGuard aGuard;
219 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
220 if ( pEdit )
222 pEdit->SetText( aText );
224 // #107218# Call same listeners like VCL would do after user interaction
225 SetSynthesizingVCLEvent( true );
226 pEdit->SetModifyFlag();
227 pEdit->Modify();
228 SetSynthesizingVCLEvent( false );
232 void VCLXMultiLineEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
234 SolarMutexGuard aGuard;
236 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
237 if ( pEdit )
239 setSelection( rSel );
240 pEdit->ReplaceSelected( aText );
244 OUString VCLXMultiLineEdit::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
246 SolarMutexGuard aGuard;
248 OUString aText;
249 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
250 if ( pEdit )
251 aText = pEdit->GetText( meLineEndType );
252 return aText;
255 OUString VCLXMultiLineEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeException, std::exception)
257 SolarMutexGuard aGuard;
259 OUString aText;
260 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
261 if ( pMultiLineEdit)
262 aText = pMultiLineEdit->GetSelected( meLineEndType );
263 return aText;
267 void VCLXMultiLineEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException, std::exception)
269 SolarMutexGuard aGuard;
271 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
272 if ( pMultiLineEdit )
274 pMultiLineEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
278 ::com::sun::star::awt::Selection VCLXMultiLineEdit::getSelection() throw(::com::sun::star::uno::RuntimeException, std::exception)
280 SolarMutexGuard aGuard;
282 ::com::sun::star::awt::Selection aSel;
283 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
284 if ( pMultiLineEdit )
286 aSel.Min = pMultiLineEdit->GetSelection().Min();
287 aSel.Max = pMultiLineEdit->GetSelection().Max();
289 return aSel;
292 sal_Bool VCLXMultiLineEdit::isEditable() throw(::com::sun::star::uno::RuntimeException, std::exception)
294 SolarMutexGuard aGuard;
296 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
297 return ( pMultiLineEdit && !pMultiLineEdit->IsReadOnly() && pMultiLineEdit->IsEnabled() ) ? sal_True : sal_False;
300 void VCLXMultiLineEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
302 SolarMutexGuard aGuard;
304 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
305 if ( pMultiLineEdit )
306 pMultiLineEdit->SetReadOnly( !bEditable );
309 void VCLXMultiLineEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException, std::exception)
311 SolarMutexGuard aGuard;
313 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
314 if ( pMultiLineEdit )
315 pMultiLineEdit->SetMaxTextLen( nLen );
318 sal_Int16 VCLXMultiLineEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException, std::exception)
320 SolarMutexGuard aGuard;
322 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
323 return pMultiLineEdit ? (sal_Int16)pMultiLineEdit->GetMaxTextLen() : (sal_Int16)0;
326 OUString VCLXMultiLineEdit::getTextLines() throw(::com::sun::star::uno::RuntimeException, std::exception)
328 SolarMutexGuard aGuard;
330 OUString aText;
331 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
332 if ( pEdit )
333 aText = pEdit->GetTextLines( meLineEndType );
334 return aText;
337 ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
339 SolarMutexGuard aGuard;
341 ::com::sun::star::awt::Size aSz;
342 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
343 if ( pEdit )
344 aSz = AWTSize(pEdit->CalcMinimumSize());
345 return aSz;
348 ::com::sun::star::awt::Size VCLXMultiLineEdit::getPreferredSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
350 return getMinimumSize();
353 ::com::sun::star::awt::Size VCLXMultiLineEdit::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
355 SolarMutexGuard aGuard;
357 ::com::sun::star::awt::Size aSz = rNewSize;
358 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
359 if ( pEdit )
360 aSz = AWTSize(pEdit->CalcAdjustedSize( VCLSize(rNewSize )));
361 return aSz;
364 ::com::sun::star::awt::Size VCLXMultiLineEdit::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
366 SolarMutexGuard aGuard;
368 ::com::sun::star::awt::Size aSz;
369 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
370 if ( pEdit )
371 aSz = AWTSize(pEdit->CalcBlockSize( nCols, nLines ));
372 return aSz;
375 void VCLXMultiLineEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
377 SolarMutexGuard aGuard;
379 nCols = nLines = 0;
380 VclPtr< MultiLineEdit > pEdit = GetAs< MultiLineEdit >();
381 if ( pEdit )
383 sal_uInt16 nC, nL;
384 pEdit->GetMaxVisColumnsAndLines( nC, nL );
385 nCols = nC;
386 nLines = nL;
390 void VCLXMultiLineEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
392 switch ( rVclWindowEvent.GetId() )
394 case VCLEVENT_EDIT_MODIFY:
396 if ( maTextListeners.getLength() )
398 ::com::sun::star::awt::TextEvent aEvent;
399 aEvent.Source = (::cppu::OWeakObject*)this;
400 maTextListeners.textChanged( aEvent );
403 break;
404 default:
406 VCLXWindow::ProcessWindowEvent( rVclWindowEvent );
408 break;
412 void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
414 SolarMutexGuard aGuard;
416 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
417 if ( pMultiLineEdit )
419 sal_uInt16 nPropType = GetPropertyId( PropertyName );
420 switch ( nPropType )
422 case BASEPROPERTY_LINE_END_FORMAT:
424 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
425 OSL_VERIFY( Value >>= nLineEndType );
426 switch ( nLineEndType )
428 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break;
429 case ::com::sun::star::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break;
430 case ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break;
431 default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break;
434 break;
436 case BASEPROPERTY_READONLY:
438 bool b;
439 if ( Value >>= b )
440 pMultiLineEdit->SetReadOnly( b );
442 break;
443 case BASEPROPERTY_MAXTEXTLEN:
445 sal_Int16 n = sal_Int16();
446 if ( Value >>= n )
447 pMultiLineEdit->SetMaxTextLen( n );
449 break;
450 case BASEPROPERTY_HIDEINACTIVESELECTION:
452 bool b;
453 if ( Value >>= b )
455 pMultiLineEdit->EnableFocusSelectionHide( b );
456 lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b );
459 break;
460 default:
462 VCLXWindow::setProperty( PropertyName, Value );
468 ::com::sun::star::uno::Any VCLXMultiLineEdit::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
470 SolarMutexGuard aGuard;
472 ::com::sun::star::uno::Any aProp;
473 VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >();
474 if ( pMultiLineEdit )
476 sal_uInt16 nPropType = GetPropertyId( PropertyName );
477 switch ( nPropType )
479 case BASEPROPERTY_LINE_END_FORMAT:
481 sal_Int16 nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED;
482 switch ( meLineEndType )
484 case LINEEND_CR: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN; break;
485 case LINEEND_LF: nLineEndType = ::com::sun::star::awt::LineEndFormat::LINE_FEED; break;
486 case LINEEND_CRLF: nLineEndType = ::com::sun::star::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; break;
487 default: OSL_FAIL( "VCLXMultiLineEdit::getProperty: invalid line end value!" ); break;
489 aProp <<= nLineEndType;
491 break;
493 case BASEPROPERTY_READONLY:
495 aProp <<= pMultiLineEdit->IsReadOnly();
497 break;
498 case BASEPROPERTY_MAXTEXTLEN:
500 aProp <<= (sal_Int16) pMultiLineEdit->GetMaxTextLen();
502 break;
503 default:
505 aProp <<= VCLXWindow::getProperty( PropertyName );
509 return aProp;
512 void SAL_CALL VCLXMultiLineEdit::setFocus( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
514 SolarMutexGuard aGuard;
516 // don't grab the focus if we already have it. Reason is that the only thing which the edit
517 // does is forwarding the focus to it's text window. This text window then does a "select all".
518 // So if the text window already has the focus, and we give the focus to the multi line
519 // edit, then all which happens is that everything is selected.
520 // #i27072#
521 if ( GetWindow() && !GetWindow()->HasChildPathFocus() )
522 GetWindow()->GrabFocus();
525 void VCLXMultiLineEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
527 PushPropertyIds( rIds,
528 // FIXME: elide duplication ?
529 BASEPROPERTY_LINE_END_FORMAT,
530 BASEPROPERTY_READONLY,
531 BASEPROPERTY_MAXTEXTLEN,
532 BASEPROPERTY_HIDEINACTIVESELECTION,
534 VCLXWindow::ImplGetPropertyIds( rIds, true );
538 // class VCLXFileControl
540 VCLXFileControl::VCLXFileControl() : maTextListeners( *this )
544 VCLXFileControl::~VCLXFileControl()
546 VclPtr< FileControl > pControl = GetAs< FileControl >();
547 if ( pControl )
548 pControl->GetEdit().SetModifyHdl( Link<>() );
551 ::com::sun::star::uno::Any VCLXFileControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
553 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
554 (static_cast< ::com::sun::star::awt::XTextComponent* >(this)),
555 (static_cast< ::com::sun::star::awt::XTextLayoutConstrains* >(this)),
556 (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
557 return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
560 // ::com::sun::star::lang::XTypeProvider
561 IMPL_XTYPEPROVIDER_START( VCLXFileControl )
562 cppu::UnoType<com::sun::star::awt::XTextComponent>::get(),
563 cppu::UnoType<com::sun::star::awt::XTextLayoutConstrains>::get(),
564 VCLXWindow::getTypes()
565 IMPL_XTYPEPROVIDER_END
567 void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
569 SolarMutexGuard aGuard;
571 VclPtr< FileControl > pControl = GetAs< FileControl >();
572 if ( pControl )
574 sal_uInt16 nPropType = GetPropertyId( PropertyName );
575 switch ( nPropType )
577 case BASEPROPERTY_HIDEINACTIVESELECTION:
579 bool bValue(false);
580 OSL_VERIFY( Value >>= bValue );
582 lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue );
583 lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue );
585 break;
587 default:
588 VCLXWindow::setProperty( PropertyName, Value );
589 break;
594 void VCLXFileControl::SetWindow( const VclPtr< vcl::Window > &pWindow )
596 VclPtr< FileControl > pPrevFileControl = GetAsDynamic< FileControl >();
597 if ( pPrevFileControl )
598 pPrevFileControl->SetEditModifyHdl( Link<>() );
600 FileControl* pNewFileControl = dynamic_cast<FileControl*>( pWindow.get() );
601 if ( pNewFileControl )
602 pNewFileControl->SetEditModifyHdl( LINK( this, VCLXFileControl, ModifyHdl ) );
604 VCLXWindow::SetWindow( pWindow );
607 void VCLXFileControl::addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
609 maTextListeners.addInterface( l );
612 void VCLXFileControl::removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
614 maTextListeners.removeInterface( l );
617 void VCLXFileControl::setText( const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
619 SolarMutexGuard aGuard;
621 vcl::Window* pWindow = GetWindow();
622 if ( pWindow )
624 pWindow->SetText( aText );
626 // also in Java a textChanged is triggered, not in VCL.
627 // ::com::sun::star::awt::Toolkit should be JAVA-compliant...
628 ModifyHdl( NULL );
632 void VCLXFileControl::insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
634 SolarMutexGuard aGuard;
636 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
637 if ( pFileControl )
639 pFileControl->GetEdit().SetSelection( Selection( rSel.Min, rSel.Max ) );
640 pFileControl->GetEdit().ReplaceSelected( aText );
644 OUString VCLXFileControl::getText() throw(::com::sun::star::uno::RuntimeException, std::exception)
646 SolarMutexGuard aGuard;
648 OUString aText;
649 vcl::Window* pWindow = GetWindow();
650 if ( pWindow )
651 aText = pWindow->GetText();
652 return aText;
655 OUString VCLXFileControl::getSelectedText() throw(::com::sun::star::uno::RuntimeException, std::exception)
657 SolarMutexGuard aGuard;
659 OUString aText;
660 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
661 if ( pFileControl)
662 aText = pFileControl->GetEdit().GetSelected();
663 return aText;
667 void VCLXFileControl::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw(::com::sun::star::uno::RuntimeException, std::exception)
669 SolarMutexGuard aGuard;
671 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
672 if ( pFileControl )
673 pFileControl->GetEdit().SetSelection( Selection( aSelection.Min, aSelection.Max ) );
676 ::com::sun::star::awt::Selection VCLXFileControl::getSelection() throw(::com::sun::star::uno::RuntimeException, std::exception)
678 SolarMutexGuard aGuard;
680 ::com::sun::star::awt::Selection aSel;
681 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
682 if ( pFileControl )
684 aSel.Min = pFileControl->GetEdit().GetSelection().Min();
685 aSel.Max = pFileControl->GetEdit().GetSelection().Max();
687 return aSel;
690 sal_Bool VCLXFileControl::isEditable() throw(::com::sun::star::uno::RuntimeException, std::exception)
692 SolarMutexGuard aGuard;
694 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
695 return ( pFileControl && !pFileControl->GetEdit().IsReadOnly() && pFileControl->GetEdit().IsEnabled() ) ? sal_True : sal_False;
698 void VCLXFileControl::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::RuntimeException, std::exception)
700 SolarMutexGuard aGuard;
702 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
703 if ( pFileControl )
704 pFileControl->GetEdit().SetReadOnly( !bEditable );
707 void VCLXFileControl::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::RuntimeException, std::exception)
709 SolarMutexGuard aGuard;
711 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
712 if ( pFileControl )
713 pFileControl->GetEdit().SetMaxTextLen( nLen );
716 sal_Int16 VCLXFileControl::getMaxTextLen() throw(::com::sun::star::uno::RuntimeException, std::exception)
718 SolarMutexGuard aGuard;
720 VclPtr< FileControl > pFileControl = GetAs< FileControl >();
721 return pFileControl ? pFileControl->GetEdit().GetMaxTextLen() : 0;
725 IMPL_LINK_NOARG(VCLXFileControl, ModifyHdl)
727 ::com::sun::star::awt::TextEvent aEvent;
728 aEvent.Source = (::cppu::OWeakObject*)this;
729 maTextListeners.textChanged( aEvent );
731 return 1;
734 ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
736 SolarMutexGuard aGuard;
738 ::com::sun::star::awt::Size aSz;
739 VclPtr< FileControl > pControl = GetAs< FileControl >();
740 if ( pControl )
742 Size aTmpSize = pControl->GetEdit().CalcMinimumSize();
743 aTmpSize.Width() += pControl->GetButton().CalcMinimumSize().Width();
744 aSz = AWTSize(pControl->CalcWindowSize( aTmpSize ));
746 return aSz;
749 ::com::sun::star::awt::Size VCLXFileControl::getPreferredSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
751 ::com::sun::star::awt::Size aSz = getMinimumSize();
752 aSz.Height += 4;
753 return aSz;
756 ::com::sun::star::awt::Size VCLXFileControl::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
758 SolarMutexGuard aGuard;
760 ::com::sun::star::awt::Size aSz =rNewSize;
761 VclPtr< FileControl > pControl = GetAs< FileControl >();
762 if ( pControl )
764 ::com::sun::star::awt::Size aMinSz = getMinimumSize();
765 if ( aSz.Height != aMinSz.Height )
766 aSz.Height = aMinSz.Height;
768 return aSz;
771 ::com::sun::star::awt::Size VCLXFileControl::getMinimumSize( sal_Int16 nCols, sal_Int16 ) throw(::com::sun::star::uno::RuntimeException, std::exception)
773 SolarMutexGuard aGuard;
775 ::com::sun::star::awt::Size aSz;
776 VclPtr< FileControl > pControl = GetAs< FileControl >();
777 if ( pControl )
779 aSz = AWTSize(pControl->GetEdit().CalcSize( nCols ));
780 aSz.Width += pControl->GetButton().CalcMinimumSize().Width();
782 return aSz;
785 void VCLXFileControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
787 SolarMutexGuard aGuard;
789 nCols = 0;
790 nLines = 1;
791 VclPtr< FileControl > pControl = GetAs< FileControl >();
792 if ( pControl )
793 nCols = pControl->GetEdit().GetMaxVisChars();
796 void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
798 PushPropertyIds( rIds,
799 // FIXME: elide duplication ?
800 BASEPROPERTY_HIDEINACTIVESELECTION,
802 VCLXWindow::ImplGetPropertyIds( rIds, true );
807 // class SVTXFormattedField
810 SVTXFormattedField::SVTXFormattedField()
811 :m_pCurrentSupplier(NULL)
812 ,bIsStandardSupplier(true)
813 ,nKeyToSetDelayed(-1)
818 SVTXFormattedField::~SVTXFormattedField()
820 if (m_pCurrentSupplier)
822 m_pCurrentSupplier->release();
823 m_pCurrentSupplier = NULL;
828 void SVTXFormattedField::SetWindow( const VclPtr< vcl::Window > &_pWindow )
830 VCLXSpinField::SetWindow(_pWindow);
831 if (GetAs< FormattedField >())
832 GetAs< FormattedField >()->SetAutoColor(true);
836 void SVTXFormattedField::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
838 SolarMutexGuard aGuard;
840 FormattedField* pField = GetAs< FormattedField >();
841 if ( pField )
843 sal_uInt16 nPropType = GetPropertyId( PropertyName );
844 switch (nPropType)
846 case BASEPROPERTY_ENFORCE_FORMAT:
848 bool bEnable( true );
849 if ( Value >>= bEnable )
850 pField->EnableNotANumber( !bEnable );
852 break;
854 case BASEPROPERTY_EFFECTIVE_MIN:
855 case BASEPROPERTY_VALUEMIN_DOUBLE:
856 SetMinValue(Value);
857 break;
859 case BASEPROPERTY_EFFECTIVE_MAX:
860 case BASEPROPERTY_VALUEMAX_DOUBLE:
861 SetMaxValue(Value);
862 break;
864 case BASEPROPERTY_EFFECTIVE_DEFAULT:
865 SetDefaultValue(Value);
866 break;
868 case BASEPROPERTY_TREATASNUMBER:
870 bool b;
871 if ( Value >>= b )
872 SetTreatAsNumber(b);
874 break;
876 case BASEPROPERTY_FORMATSSUPPLIER:
877 if (!Value.hasValue())
878 setFormatsSupplier(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > (NULL));
879 else
881 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS;
882 if ( Value >>= xNFS )
883 setFormatsSupplier(xNFS);
885 break;
886 case BASEPROPERTY_FORMATKEY:
887 if (!Value.hasValue())
888 setFormatKey(0);
889 else
891 sal_Int32 n = 0;
892 if ( Value >>= n )
893 setFormatKey(n);
895 break;
897 case BASEPROPERTY_EFFECTIVE_VALUE:
898 case BASEPROPERTY_VALUE_DOUBLE:
900 const ::com::sun::star::uno::TypeClass rTC = Value.getValueType().getTypeClass();
901 if (rTC != ::com::sun::star::uno::TypeClass_STRING)
902 // no string
903 if (rTC != ::com::sun::star::uno::TypeClass_DOUBLE)
904 // no double
905 if (Value.hasValue())
906 { // but a value
907 // try if it is something converitble
908 sal_Int32 nValue = 0;
909 if (!(Value >>= nValue))
910 throw ::com::sun::star::lang::IllegalArgumentException();
911 SetValue(::com::sun::star::uno::makeAny((double)nValue));
912 break;
915 SetValue(Value);
917 break;
918 case BASEPROPERTY_VALUESTEP_DOUBLE:
920 double d = 0.0;
921 if ( Value >>= d )
922 pField->SetSpinSize( d );
923 else
925 sal_Int32 n = 0;
926 if ( Value >>= n )
927 pField->SetSpinSize( n );
930 break;
931 case BASEPROPERTY_DECIMALACCURACY:
933 sal_Int32 n = 0;
934 if ( Value >>= n )
935 pField->SetDecimalDigits( (sal_uInt16)n );
937 break;
938 case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
940 bool b;
941 if ( Value >>= b )
942 pField->SetThousandsSep( b );
944 break;
946 default:
947 VCLXSpinField::setProperty( PropertyName, Value );
950 if (BASEPROPERTY_TEXTCOLOR == nPropType)
951 { // after setting a new text color, think again about the AutoColor flag of the control
952 // 17.05.2001 - 86859 - frank.schoenheit@germany.sun.com
953 pField->SetAutoColor(!Value.hasValue());
956 else
957 VCLXSpinField::setProperty( PropertyName, Value );
961 ::com::sun::star::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
963 SolarMutexGuard aGuard;
965 ::com::sun::star::uno::Any aReturn;
967 FormattedField* pField = GetAs< FormattedField >();
968 if ( pField )
970 sal_uInt16 nPropType = GetPropertyId( PropertyName );
971 switch (nPropType)
973 case BASEPROPERTY_EFFECTIVE_MIN:
974 case BASEPROPERTY_VALUEMIN_DOUBLE:
975 aReturn <<= GetMinValue();
976 break;
978 case BASEPROPERTY_EFFECTIVE_MAX:
979 case BASEPROPERTY_VALUEMAX_DOUBLE:
980 aReturn <<= GetMaxValue();
981 break;
983 case BASEPROPERTY_EFFECTIVE_DEFAULT:
984 aReturn <<= GetDefaultValue();
985 break;
987 case BASEPROPERTY_TREATASNUMBER:
988 aReturn <<= GetTreatAsNumber();
989 break;
991 case BASEPROPERTY_EFFECTIVE_VALUE:
992 case BASEPROPERTY_VALUE_DOUBLE:
993 aReturn <<= GetValue();
994 break;
996 case BASEPROPERTY_VALUESTEP_DOUBLE:
997 aReturn <<= pField->GetSpinSize();
998 break;
1000 case BASEPROPERTY_DECIMALACCURACY:
1001 aReturn <<= pField->GetDecimalDigits();
1002 break;
1004 case BASEPROPERTY_FORMATSSUPPLIER:
1006 if (!bIsStandardSupplier)
1007 { // ansonsten void
1008 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getFormatsSupplier();
1009 aReturn <<= xSupplier;
1012 break;
1014 case BASEPROPERTY_FORMATKEY:
1016 if (!bIsStandardSupplier)
1017 aReturn <<= getFormatKey();
1019 break;
1021 default:
1022 aReturn <<= VCLXSpinField::getProperty(PropertyName);
1025 return aReturn;
1028 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier() const
1030 return ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > (m_pCurrentSupplier);
1033 ::com::sun::star::uno::Any SVTXFormattedField::convertEffectiveValue(const ::com::sun::star::uno::Any& rValue)
1035 ::com::sun::star::uno::Any aReturn;
1037 FormattedField* pField = GetAs< FormattedField >();
1038 if (!pField)
1039 return aReturn;
1041 switch (rValue.getValueType().getTypeClass())
1043 case ::com::sun::star::uno::TypeClass_DOUBLE:
1044 if (pField->TreatingAsNumber())
1046 double d = 0.0;
1047 rValue >>= d;
1048 aReturn <<= d;
1050 else
1052 SvNumberFormatter* pFormatter = pField->GetFormatter();
1053 if (!pFormatter)
1054 pFormatter = pField->StandardFormatter();
1055 // should never fail
1057 Color* pDum;
1058 double d = 0.0;
1059 rValue >>= d;
1060 OUString sConverted;
1061 pFormatter->GetOutputString(d, 0, sConverted, &pDum);
1062 aReturn <<= sConverted;
1064 break;
1065 case ::com::sun::star::uno::TypeClass_STRING:
1067 OUString aStr;
1068 rValue >>= aStr;
1069 if (pField->TreatingAsNumber())
1071 SvNumberFormatter* pFormatter = pField->GetFormatter();
1072 if (!pFormatter)
1073 pFormatter = pField->StandardFormatter();
1075 double dVal;
1076 sal_uInt32 nTestFormat(0);
1077 if (!pFormatter->IsNumberFormat(aStr, nTestFormat, dVal))
1078 aReturn.clear();
1079 aReturn <<= dVal;
1081 else
1082 aReturn <<= aStr;
1084 break;
1085 default:
1086 aReturn.clear();
1087 break;
1089 return aReturn;
1093 void SVTXFormattedField::SetMinValue(const ::com::sun::star::uno::Any& rValue)
1095 FormattedField* pField = GetAs< FormattedField >();
1096 if (!pField)
1097 return;
1099 switch (rValue.getValueType().getTypeClass())
1102 case ::com::sun::star::uno::TypeClass_DOUBLE:
1104 double d = 0.0;
1105 rValue >>= d;
1106 pField->SetMinValue(d);
1108 break;
1109 default:
1110 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID, "SVTXFormattedField::SetMinValue : invalid argument (an exception will be thrown) !");
1111 if ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID )
1114 throw ::com::sun::star::lang::IllegalArgumentException();
1116 pField->ClearMinValue();
1117 break;
1122 ::com::sun::star::uno::Any SVTXFormattedField::GetMinValue()
1124 FormattedField* pField = GetAs< FormattedField >();
1125 if (!pField || !pField->HasMinValue())
1126 return ::com::sun::star::uno::Any();
1128 ::com::sun::star::uno::Any aReturn;
1129 aReturn <<= pField->GetMinValue();
1130 return aReturn;
1134 void SVTXFormattedField::SetMaxValue(const ::com::sun::star::uno::Any& rValue)
1136 FormattedField* pField = GetAs< FormattedField >();
1137 if (!pField)
1138 return;
1140 switch (rValue.getValueType().getTypeClass())
1143 case ::com::sun::star::uno::TypeClass_DOUBLE:
1145 double d = 0.0;
1146 rValue >>= d;
1147 pField->SetMaxValue(d);
1149 break;
1150 default:
1151 if (rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID)
1154 throw ::com::sun::star::lang::IllegalArgumentException();
1156 pField->ClearMaxValue();
1157 break;
1162 ::com::sun::star::uno::Any SVTXFormattedField::GetMaxValue()
1164 FormattedField* pField = GetAs< FormattedField >();
1165 if (!pField || !pField->HasMaxValue())
1166 return ::com::sun::star::uno::Any();
1168 ::com::sun::star::uno::Any aReturn;
1169 aReturn <<= pField->GetMaxValue();
1170 return aReturn;
1174 void SVTXFormattedField::SetDefaultValue(const ::com::sun::star::uno::Any& rValue)
1176 FormattedField* pField = GetAs< FormattedField >();
1177 if (!pField)
1178 return;
1180 ::com::sun::star::uno::Any aConverted = convertEffectiveValue(rValue);
1182 switch (aConverted.getValueType().getTypeClass())
1185 case ::com::sun::star::uno::TypeClass_DOUBLE:
1187 double d = 0.0;
1188 aConverted >>= d;
1189 pField->SetDefaultValue(d);
1191 break;
1192 case ::com::sun::star::uno::TypeClass_STRING:
1194 OUString aStr;
1195 aConverted >>= aStr;
1196 pField->SetDefaultText( aStr );
1198 break;
1199 default:
1200 pField->EnableEmptyField(true);
1201 // nur noch void erlaubt
1202 break;
1207 ::com::sun::star::uno::Any SVTXFormattedField::GetDefaultValue()
1209 FormattedField* pField = GetAs< FormattedField >();
1210 if (!pField || pField->IsEmptyFieldEnabled())
1211 return ::com::sun::star::uno::Any();
1213 ::com::sun::star::uno::Any aReturn;
1214 if (pField->TreatingAsNumber())
1215 aReturn <<= pField->GetDefaultValue();
1216 else
1217 aReturn <<= OUString( pField->GetDefaultText() );
1218 return aReturn;
1222 bool SVTXFormattedField::GetTreatAsNumber()
1224 FormattedField* pField = GetAs< FormattedField >();
1225 if (pField)
1226 return pField->TreatingAsNumber();
1228 return true;
1232 void SVTXFormattedField::SetTreatAsNumber(bool bSet)
1234 FormattedField* pField = GetAs< FormattedField >();
1235 if (pField)
1236 pField->TreatAsNumber(bSet);
1240 ::com::sun::star::uno::Any SVTXFormattedField::GetValue()
1242 FormattedField* pField = GetAs< FormattedField >();
1243 if (!pField)
1244 return ::com::sun::star::uno::Any();
1246 ::com::sun::star::uno::Any aReturn;
1247 if (!pField->TreatingAsNumber())
1249 OUString sText = pField->GetTextValue();
1250 aReturn <<= sText;
1252 else
1254 if (!pField->GetText().isEmpty()) // empty is returned as void by default
1255 aReturn <<= pField->GetValue();
1258 return aReturn;
1262 void SVTXFormattedField::SetValue(const ::com::sun::star::uno::Any& rValue)
1264 FormattedField* pField = GetAs< FormattedField >();
1265 if (!pField)
1266 return;
1268 if (!rValue.hasValue())
1270 pField->SetText("");
1272 else
1274 if (rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE )
1276 double d = 0.0;
1277 rValue >>= d;
1278 pField->SetValue(d);
1280 else
1282 DBG_ASSERT(rValue.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING, "SVTXFormattedField::SetValue : invalid argument !");
1284 OUString sText;
1285 rValue >>= sText;
1286 if (!pField->TreatingAsNumber())
1287 pField->SetTextFormatted(sText);
1288 else
1289 pField->SetTextValue(sText);
1292 // NotifyTextListeners();
1298 void SVTXFormattedField::setFormatsSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > & xSupplier)
1300 FormattedField* pField = GetAs< FormattedField >();
1302 SvNumberFormatsSupplierObj* pNew = NULL;
1303 if (!xSupplier.is())
1305 if (pField)
1307 pNew = new SvNumberFormatsSupplierObj(pField->StandardFormatter());
1308 bIsStandardSupplier = true;
1311 else
1313 pNew = SvNumberFormatsSupplierObj::getImplementation(xSupplier);
1314 bIsStandardSupplier = false;
1317 if (!pNew)
1318 return; // TODO : how to process ?
1320 if (m_pCurrentSupplier)
1321 m_pCurrentSupplier->release();
1322 m_pCurrentSupplier = pNew;
1323 m_pCurrentSupplier->acquire();
1324 if (pField)
1326 // save the actual value
1327 ::com::sun::star::uno::Any aCurrent = GetValue();
1328 pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), false);
1329 if (nKeyToSetDelayed != -1)
1331 pField->SetFormatKey(nKeyToSetDelayed);
1332 nKeyToSetDelayed = -1;
1334 SetValue(aCurrent);
1335 NotifyTextListeners();
1340 sal_Int32 SVTXFormattedField::getFormatKey() const
1342 FormattedField* pField = GetAs< FormattedField >();
1343 return pField ? pField->GetFormatKey() : 0;
1347 void SVTXFormattedField::setFormatKey(sal_Int32 nKey)
1349 FormattedField* pField = GetAs< FormattedField >();
1350 if (pField)
1352 if (pField->GetFormatter())
1353 pField->SetFormatKey(nKey);
1354 else
1356 // probably I am in a block, in which first the key and next the formatter will be set,
1357 // initially this happens quite certain, as the properties are set in alphabettic sequence,
1358 // and the FormatsSupplier is processed before the FormatKey
1359 nKeyToSetDelayed = nKey;
1361 NotifyTextListeners();
1366 void SVTXFormattedField::NotifyTextListeners()
1368 if ( GetTextListeners().getLength() )
1370 ::com::sun::star::awt::TextEvent aEvent;
1371 aEvent.Source = (::cppu::OWeakObject*)this;
1372 GetTextListeners().textChanged( aEvent );
1376 void SVTXFormattedField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1378 PushPropertyIds( rIds,
1379 // FIXME: elide duplication ?
1380 BASEPROPERTY_EFFECTIVE_MIN,
1381 BASEPROPERTY_VALUEMIN_DOUBLE,
1382 BASEPROPERTY_EFFECTIVE_MAX,
1383 BASEPROPERTY_VALUEMAX_DOUBLE,
1384 BASEPROPERTY_EFFECTIVE_DEFAULT,
1385 BASEPROPERTY_TREATASNUMBER,
1386 BASEPROPERTY_EFFECTIVE_VALUE,
1387 BASEPROPERTY_VALUE_DOUBLE,
1388 BASEPROPERTY_VALUESTEP_DOUBLE,
1389 BASEPROPERTY_DECIMALACCURACY,
1390 BASEPROPERTY_FORMATSSUPPLIER,
1391 BASEPROPERTY_NUMSHOWTHOUSANDSEP,
1392 BASEPROPERTY_FORMATKEY,
1393 BASEPROPERTY_TREATASNUMBER,
1394 BASEPROPERTY_ENFORCE_FORMAT,
1396 VCLXWindow::ImplGetPropertyIds( rIds, true );
1397 VCLXSpinField::ImplGetPropertyIds( rIds );
1402 // class SVTXRoadmap
1404 using namespace svt;
1406 SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this )
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 = GetAs< svt::ORoadmap >();
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, std::exception)
1442 SolarMutexGuard aGuard;
1443 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
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 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, std::exception)
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, std::exception)
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 = 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, std::exception)
1516 SolarMutexGuard aGuard;
1517 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
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, std::exception)
1529 SolarMutexGuard aGuard;
1530 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
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, std::exception)
1541 SolarMutexGuard aGuard;
1542 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
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 );
1555 void SVTXRoadmap::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
1557 SolarMutexGuard aGuard;
1559 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
1560 if ( pField )
1562 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1563 switch (nPropType)
1565 case BASEPROPERTY_COMPLETE:
1567 bool b = false;
1568 Value >>= b;
1569 pField->SetRoadmapComplete( b);
1571 break;
1573 case BASEPROPERTY_ACTIVATED:
1575 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 );
1610 ::com::sun::star::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1612 SolarMutexGuard aGuard;
1614 ::com::sun::star::uno::Any aReturn;
1616 ::svt::ORoadmap* pField = GetAs< svt::ORoadmap >();
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 VclPtr< ::svt::ORoadmap > pButton = GetAs< ::svt::ORoadmap >();
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 );
1659 // class SVTXNumericField
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, std::exception)
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 cppu::UnoType<com::sun::star::awt::XNumericField>::get(),
1680 SVTXFormattedField::getTypes()
1681 IMPL_XTYPEPROVIDER_END
1684 void SVTXNumericField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1686 SolarMutexGuard aGuard;
1688 FormattedField* pField = GetAs< FormattedField >();
1689 if ( pField )
1690 pField->SetValue( Value );
1693 double SVTXNumericField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
1695 SolarMutexGuard aGuard;
1697 FormattedField* pField = GetAs< FormattedField >();
1698 return pField ? pField->GetValue() : 0;
1701 void SVTXNumericField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1703 SolarMutexGuard aGuard;
1705 FormattedField* pField = GetAs< FormattedField >();
1706 if ( pField )
1707 pField->SetMinValue( Value );
1710 double SVTXNumericField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
1712 SolarMutexGuard aGuard;
1714 FormattedField* pField = GetAs< FormattedField >();
1715 return pField ? pField->GetMinValue() : 0;
1718 void SVTXNumericField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1720 SolarMutexGuard aGuard;
1722 FormattedField* pField = GetAs< FormattedField >();
1723 if ( pField )
1724 pField->SetMaxValue( Value );
1727 double SVTXNumericField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
1729 SolarMutexGuard aGuard;
1731 FormattedField* pField = GetAs< FormattedField >();
1732 return pField ? pField->GetMaxValue() : 0;
1735 void SVTXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1737 SolarMutexGuard aGuard;
1739 FormattedField* pField = GetAs< FormattedField >();
1740 if ( pField )
1741 pField->SetSpinFirst( Value );
1744 double SVTXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
1746 SolarMutexGuard aGuard;
1748 FormattedField* pField = GetAs< FormattedField >();
1749 return pField ? pField->GetSpinFirst() : 0;
1752 void SVTXNumericField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1754 SolarMutexGuard aGuard;
1756 FormattedField* pField = GetAs< FormattedField >();
1757 if ( pField )
1758 pField->SetSpinLast( Value );
1761 double SVTXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
1763 SolarMutexGuard aGuard;
1765 FormattedField* pField = GetAs< FormattedField >();
1766 return pField ? pField->GetSpinLast() : 0;
1769 void SVTXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1771 SolarMutexGuard aGuard;
1773 FormattedField* pField = GetAs< FormattedField >();
1774 if ( pField )
1775 pField->SetSpinSize( Value );
1778 double SVTXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
1780 SolarMutexGuard aGuard;
1782 FormattedField* pField = GetAs< FormattedField >();
1783 return pField ? pField->GetSpinSize() : 0;
1786 void SVTXNumericField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1788 SolarMutexGuard aGuard;
1790 FormattedField* pField = GetAs< FormattedField >();
1791 if ( pField )
1792 pField->SetDecimalDigits( Value );
1795 sal_Int16 SVTXNumericField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
1797 SolarMutexGuard aGuard;
1799 FormattedField* pField = GetAs< FormattedField >();
1800 return pField ? pField->GetDecimalDigits() : 0;
1803 void SVTXNumericField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1805 SolarMutexGuard aGuard;
1807 FormattedField* pField = GetAs< FormattedField >();
1808 if ( pField )
1809 pField->SetStrictFormat( bStrict );
1812 sal_Bool SVTXNumericField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
1814 SolarMutexGuard aGuard;
1816 FormattedField* pField = GetAs< FormattedField >();
1817 return pField ? pField->IsStrictFormat() : sal_False;
1820 void SVTXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
1822 SVTXFormattedField::ImplGetPropertyIds( rIds );
1826 // class SVTXCurrencyField
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, std::exception)
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 cppu::UnoType<com::sun::star::awt::XCurrencyField>::get(),
1847 SVTXFormattedField::getTypes()
1848 IMPL_XTYPEPROVIDER_END
1850 void SVTXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1852 SolarMutexGuard aGuard;
1854 FormattedField* pField = GetAs< FormattedField >();
1855 if ( pField )
1856 pField->SetValue( Value );
1859 double SVTXCurrencyField::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
1861 SolarMutexGuard aGuard;
1863 FormattedField* pField = GetAs< FormattedField >();
1864 return pField ? pField->GetValue() : 0;
1867 void SVTXCurrencyField::setMin( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1869 SolarMutexGuard aGuard;
1871 FormattedField* pField = GetAs< FormattedField >();
1872 if ( pField )
1873 pField->SetMinValue( Value );
1876 double SVTXCurrencyField::getMin() throw(::com::sun::star::uno::RuntimeException, std::exception)
1878 SolarMutexGuard aGuard;
1880 FormattedField* pField = GetAs< FormattedField >();
1881 return pField ? pField->GetMinValue() : 0;
1884 void SVTXCurrencyField::setMax( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1886 SolarMutexGuard aGuard;
1888 FormattedField* pField = GetAs< FormattedField >();
1889 if ( pField )
1890 pField->SetMaxValue( Value );
1893 double SVTXCurrencyField::getMax() throw(::com::sun::star::uno::RuntimeException, std::exception)
1895 SolarMutexGuard aGuard;
1897 FormattedField* pField = GetAs< FormattedField >();
1898 return pField ? pField->GetMaxValue() : 0;
1901 void SVTXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1903 SolarMutexGuard aGuard;
1905 FormattedField* pField = GetAs< FormattedField >();
1906 if ( pField )
1907 pField->SetSpinFirst( Value );
1910 double SVTXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeException, std::exception)
1912 SolarMutexGuard aGuard;
1914 FormattedField* pField = GetAs< FormattedField >();
1915 return pField ? pField->GetSpinFirst() : 0;
1918 void SVTXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1920 SolarMutexGuard aGuard;
1922 FormattedField* pField = GetAs< FormattedField >();
1923 if ( pField )
1924 pField->SetSpinLast( Value );
1927 double SVTXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeException, std::exception)
1929 SolarMutexGuard aGuard;
1931 FormattedField* pField = GetAs< FormattedField >();
1932 return pField ? pField->GetSpinLast() : 0;
1935 void SVTXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1937 SolarMutexGuard aGuard;
1939 FormattedField* pField = GetAs< FormattedField >();
1940 if ( pField )
1941 pField->SetSpinSize( Value );
1944 double SVTXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
1946 SolarMutexGuard aGuard;
1948 FormattedField* pField = GetAs< FormattedField >();
1949 return pField ? pField->GetSpinSize() : 0;
1952 void SVTXCurrencyField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1954 SolarMutexGuard aGuard;
1956 FormattedField* pField = GetAs< FormattedField >();
1957 if ( pField )
1958 pField->SetDecimalDigits( Value );
1961 sal_Int16 SVTXCurrencyField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException, std::exception)
1963 SolarMutexGuard aGuard;
1965 FormattedField* pField = GetAs< FormattedField >();
1966 return pField ? pField->GetDecimalDigits() : 0;
1969 void SVTXCurrencyField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1971 SolarMutexGuard aGuard;
1973 FormattedField* pField = GetAs< FormattedField >();
1974 if ( pField )
1975 pField->SetStrictFormat( bStrict );
1978 sal_Bool SVTXCurrencyField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException, std::exception)
1980 SolarMutexGuard aGuard;
1982 FormattedField* pField = GetAs< FormattedField >();
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, std::exception)
1988 SolarMutexGuard aGuard;
1990 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
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 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, std::exception)
2021 SolarMutexGuard aGuard;
2023 ::com::sun::star::uno::Any aReturn;
2025 VclPtr< DoubleCurrencyField > pField = GetAs< DoubleCurrencyField >();
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 );
2059 // class VCLXProgressBar
2062 VCLXProgressBar::VCLXProgressBar()
2063 :m_nValue(0)
2064 ,m_nValueMin(0)
2065 ,m_nValueMax(100)
2069 VCLXProgressBar::~VCLXProgressBar()
2073 void VCLXProgressBar::ImplUpdateValue()
2075 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
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, std::exception)
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 cppu::UnoType<com::sun::star::awt::XProgressBar>::get(),
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, std::exception)
2142 SolarMutexGuard aGuard;
2144 vcl::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, std::exception)
2154 SolarMutexGuard aGuard;
2156 vcl::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, std::exception)
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, std::exception )
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, std::exception)
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, std::exception)
2204 SolarMutexGuard aGuard;
2206 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
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 vcl::Window* pWindow = GetWindow();
2233 if ( pWindow )
2235 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, std::exception)
2262 SolarMutexGuard aGuard;
2264 ::com::sun::star::uno::Any aProp;
2265 VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >();
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 );
2307 // class SVTXDateField
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, std::exception)
2320 VCLXDateField::setProperty( PropertyName, Value );
2322 // some properties need to be forwarded to the sub edit, too
2323 SolarMutexGuard g;
2324 VclPtr< Edit > pSubEdit = GetWindow() ? static_cast< Edit* >( GetWindow().get() )->GetSubEdit() : NULL;
2325 if ( !pSubEdit )
2326 return;
2328 switch ( GetPropertyId( PropertyName ) )
2330 case BASEPROPERTY_TEXTLINECOLOR:
2331 if ( !Value.hasValue() )
2332 pSubEdit->SetTextLineColor();
2333 else
2335 sal_Int32 nColor = 0;
2336 if ( Value >>= nColor )
2337 pSubEdit->SetTextLineColor( Color( nColor ) );
2339 break;
2343 void SVTXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
2345 PushPropertyIds( rIds,
2346 BASEPROPERTY_TEXTLINECOLOR,
2348 VCLXDateField::ImplGetPropertyIds( rIds );
2351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */