merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / controls / unocontrols.cxx
blob87981f913a32fa62ecf561c802aefa4ee92b8e57
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unocontrols.cxx,v $
10 * $Revision: 1.87 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
33 #include <com/sun/star/awt/XTextArea.hpp>
34 #include <com/sun/star/awt/XVclWindowPeer.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/awt/PosSize.hpp>
37 #include <com/sun/star/awt/VisualEffect.hpp>
38 #include <com/sun/star/awt/LineEndFormat.hpp>
39 #include <com/sun/star/graphic/XGraphicProvider.hpp>
40 #include <com/sun/star/graphic/GraphicObject.hpp>
41 #include <com/sun/star/util/Date.hpp>
42 #include <com/sun/star/awt/ImageScaleMode.hpp>
45 #include <toolkit/controls/formattedcontrol.hxx>
46 #include <toolkit/controls/roadmapcontrol.hxx>
47 #include <toolkit/controls/unocontrols.hxx>
48 #include <toolkit/controls/geometrycontrolmodel.hxx>
49 #include <toolkit/controls/stdtabcontroller.hxx>
50 #include <toolkit/helper/property.hxx>
51 #include <toolkit/helper/unopropertyarrayhelper.hxx>
52 #include <toolkit/helper/unomemorystream.hxx>
53 #include <toolkit/helper/servicenames.hxx>
54 #include <toolkit/helper/macros.hxx>
55 #include <toolkit/helper/imagealign.hxx>
57 // for introspection
58 #include <toolkit/awt/vclxwindows.hxx>
59 #include <cppuhelper/typeprovider.hxx>
60 #include <comphelper/componentcontext.hxx>
61 #include <comphelper/processfactory.hxx>
62 #include <comphelper/extract.hxx>
63 #include <vcl/wrkwin.hxx>
64 #include <vcl/svapp.hxx>
65 #include <vcl/edit.hxx>
66 #ifndef _SV_BUTTON_HXX
67 #include <vcl/button.hxx>
68 #endif
69 #include <vcl/group.hxx>
70 #include <vcl/fixed.hxx>
71 #include <vcl/lstbox.hxx>
72 #include <vcl/combobox.hxx>
73 #include <tools/debug.hxx>
74 #include <tools/diagnose_ex.h>
75 #include <tools/date.hxx>
76 #include <tools/time.hxx>
78 #include <algorithm>
80 using namespace ::com::sun::star;
81 using namespace ::toolkit;
84 // ----------------------------------------------------
85 // helper
86 // ----------------------------------------------------
88 static void lcl_knitImageComponents( const uno::Reference< awt::XControlModel >& _rxModel,
89 const uno::Reference< awt::XWindowPeer >& _rxPeer,
90 bool _bAdd )
92 uno::Reference< awt::XImageProducer > xProducer( _rxModel, uno::UNO_QUERY );
93 if ( xProducer.is() )
95 uno::Reference< awt::XImageConsumer > xConsumer( _rxPeer, uno::UNO_QUERY );
96 if ( xConsumer.is() )
98 if ( _bAdd )
100 xProducer->addConsumer( xConsumer );
101 xProducer->startProduction();
103 else
104 xProducer->removeConsumer( xConsumer );
109 // ----------------------------------------------------
110 // class UnoControlEditModel
111 // ----------------------------------------------------
112 UnoControlEditModel::UnoControlEditModel()
114 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit );
117 ::rtl::OUString UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
119 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlEditModel );
122 uno::Any UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
124 uno::Any aReturn;
126 switch ( nPropId )
128 case BASEPROPERTY_LINE_END_FORMAT:
129 aReturn <<= (sal_Int16)awt::LineEndFormat::LINE_FEED; // LF
130 break;
131 case BASEPROPERTY_DEFAULTCONTROL:
132 aReturn <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlEdit );
133 break;
134 default:
135 aReturn = UnoControlModel::ImplGetDefaultValue( nPropId );
136 break;
138 return aReturn;
141 ::cppu::IPropertyArrayHelper& UnoControlEditModel::getInfoHelper()
143 static UnoPropertyArrayHelper* pHelper = NULL;
144 if ( !pHelper )
146 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
147 pHelper = new UnoPropertyArrayHelper( aIDs );
149 return *pHelper;
152 // beans::XMultiPropertySet
153 uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException)
155 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
156 return xInfo;
160 // ----------------------------------------------------
161 // class UnoEditControl
162 // ----------------------------------------------------
163 UnoEditControl::UnoEditControl()
164 :maTextListeners( *this )
165 ,mnMaxTextLen( 0 )
166 ,mbSetTextInPeer( sal_False )
167 ,mbSetMaxTextLenInPeer( sal_False )
168 ,mbHasTextProperty( sal_False )
170 maComponentInfos.nWidth = 100;
171 maComponentInfos.nHeight = 12;
172 mnMaxTextLen = 0;
173 mbSetMaxTextLenInPeer = FALSE;
176 uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
178 uno::Any aReturn = UnoControlBase::queryAggregation( rType );
179 if ( !aReturn.hasValue() )
180 aReturn = UnoEditControl_Base::queryInterface( rType );
181 return aReturn;
184 uno::Any SAL_CALL UnoEditControl::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
186 return UnoControlBase::queryInterface( rType );
189 void SAL_CALL UnoEditControl::acquire( ) throw ()
191 UnoControlBase::acquire();
194 void SAL_CALL UnoEditControl::release( ) throw ()
196 UnoControlBase::release();
199 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl, UnoControlBase, UnoEditControl_Base )
201 ::rtl::OUString UnoEditControl::GetComponentServiceName()
203 // by default, we want a simple edit field
204 ::rtl::OUString sName( ::rtl::OUString::createFromAscii( "Edit" ) );
206 // but maybe we are to display multi-line text?
207 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE ) );
208 sal_Bool b = sal_Bool();
209 if ( ( aVal >>= b ) && b )
210 sName= ::rtl::OUString::createFromAscii( "MultiLineEdit" );
212 return sName;
215 sal_Bool SAL_CALL UnoEditControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException )
217 sal_Bool bReturn = UnoControlBase::setModel( _rModel );
218 mbHasTextProperty = ImplHasProperty( BASEPROPERTY_TEXT );
219 return bReturn;
222 void UnoEditControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
224 sal_Bool bDone = sal_False;
225 if ( GetPropertyId( rPropName ) == BASEPROPERTY_TEXT )
227 // #96986# use setText(), or text listener will not be called.
228 uno::Reference < awt::XTextComponent > xTextComponent( getPeer(), uno::UNO_QUERY );
229 if ( xTextComponent.is() )
231 ::rtl::OUString sText;
232 rVal >>= sText;
233 ImplCheckLocalize( sText );
234 xTextComponent->setText( sText );
235 bDone = sal_True;
239 if ( !bDone )
240 UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
243 void UnoEditControl::dispose() throw(uno::RuntimeException)
245 lang::EventObject aEvt( *this );
246 maTextListeners.disposeAndClear( aEvt );
247 UnoControl::dispose();
250 void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
252 UnoControl::createPeer( rxToolkit, rParentPeer );
254 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
255 if ( xText.is() )
257 xText->addTextListener( this );
259 if ( mbSetMaxTextLenInPeer )
260 xText->setMaxTextLen( mnMaxTextLen );
261 if ( mbSetTextInPeer )
262 xText->setText( maText );
266 void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException)
268 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
270 if ( mbHasTextProperty )
272 uno::Any aAny;
273 aAny <<= xText->getText();
274 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_False );
276 else
278 maText = xText->getText();
281 if ( maTextListeners.getLength() )
282 maTextListeners.textChanged( e );
285 void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
287 maTextListeners.addInterface( l );
290 void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
292 maTextListeners.removeInterface( l );
295 void UnoEditControl::setText( const ::rtl::OUString& aText ) throw(uno::RuntimeException)
297 if ( mbHasTextProperty )
299 uno::Any aAny;
300 aAny <<= aText;
301 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_True );
303 else
305 maText = aText;
306 mbSetTextInPeer = sal_True;
307 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
308 if ( xText.is() )
309 xText->setText( maText );
312 // Setting the property to the VCLXWindow doesn't call textChanged
313 if ( maTextListeners.getLength() )
315 awt::TextEvent aEvent;
316 aEvent.Source = *this;
317 maTextListeners.textChanged( aEvent );
321 namespace
323 static void lcl_normalize( awt::Selection& _rSel )
325 if ( _rSel.Min > _rSel.Max )
326 ::std::swap( _rSel.Min, _rSel.Max );
330 static bool lcl_intersect( const awt::Selection& _rLHS, const awt::Selection& _rRHS )
332 OSL_PRECOND( _rLHS.Min <= _rLHS.Max, "lcl_intersect: LHS to be normalized!" );
333 OSL_PRECOND( _rRHS.Min <= _rRHS.Max, "lcl_intersect: RHS to be normalized!" );
334 return !( ( _rLHS.Max < _rRHS.Min ) || ( _rLHS.Min > _rRHS.Max ) );
339 void UnoEditControl::insertText( const awt::Selection& rSel, const ::rtl::OUString& rNewText ) throw(uno::RuntimeException)
341 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
342 awt::Selection aSelection( rSel );
343 lcl_normalize( aSelection );
345 // preserve the selection resp. cursor position
346 awt::Selection aNewSelection( getSelection() );
347 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
348 // (not sure - looks uglier ...)
349 sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength();
350 if ( aNewSelection.Min > aSelection.Min )
351 aNewSelection.Min -= nDeletedCharacters;
352 if ( aNewSelection.Max > aSelection.Max )
353 aNewSelection.Max -= nDeletedCharacters;
354 #else
355 aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength();
356 aNewSelection.Min = aNewSelection.Max;
357 #endif
359 ::rtl::OUString aOldText = getText();
360 ::rtl::OUString aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
361 setText( aNewText );
363 setSelection( aNewSelection );
366 ::rtl::OUString UnoEditControl::getText() throw(uno::RuntimeException)
368 ::rtl::OUString aText = maText;
370 if ( mbHasTextProperty )
371 aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
372 else
374 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
375 if ( xText.is() )
376 aText = xText->getText();
379 return aText;
382 ::rtl::OUString UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException)
384 ::rtl::OUString sSelected;
385 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
386 if ( xText.is() )
387 sSelected = xText->getSelectedText();
389 return sSelected;
392 void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException)
394 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
395 if ( xText.is() )
396 xText->setSelection( aSelection );
399 awt::Selection UnoEditControl::getSelection( void ) throw(uno::RuntimeException)
401 awt::Selection aSel;
402 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
403 if ( xText.is() )
404 aSel = xText->getSelection();
405 return aSel;
408 sal_Bool UnoEditControl::isEditable( void ) throw(uno::RuntimeException)
410 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY );
413 void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException)
415 uno::Any aAny;
416 aAny <<= (sal_Bool)!bEditable;
417 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, sal_True );
420 sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException)
422 sal_Int16 nMaxLen = mnMaxTextLen;
424 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) )
425 nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN );
427 return nMaxLen;
430 void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException)
432 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) )
434 uno::Any aAny;
435 aAny <<= (sal_Int16)nLen;
436 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, sal_True );
438 else
440 mnMaxTextLen = nLen;
441 mbSetMaxTextLenInPeer = sal_True;
442 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
443 if ( xText.is() )
444 xText->setMaxTextLen( mnMaxTextLen );
448 awt::Size UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException)
450 return Impl_getMinimumSize();
453 awt::Size UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException)
455 return Impl_getPreferredSize();
458 awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
460 return Impl_calcAdjustedSize( rNewSize );
463 awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
465 return Impl_getMinimumSize( nCols, nLines );
468 void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
470 Impl_getColumnsAndLines( nCols, nLines );
474 // ----------------------------------------------------
475 // class UnoControlFileControlModel
476 // ----------------------------------------------------
477 UnoControlFileControlModel::UnoControlFileControlModel()
479 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
480 ImplRegisterProperty( BASEPROPERTY_BORDER );
481 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
482 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
483 ImplRegisterProperty( BASEPROPERTY_ENABLED );
484 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
485 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
486 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
487 ImplRegisterProperty( BASEPROPERTY_HELPURL );
488 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
489 ImplRegisterProperty( BASEPROPERTY_READONLY );
490 ImplRegisterProperty( BASEPROPERTY_TABSTOP );
491 ImplRegisterProperty( BASEPROPERTY_TEXT );
492 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
493 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
494 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
497 ::rtl::OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
499 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControlModel );
502 uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
504 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
506 uno::Any aAny;
507 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControl );
508 return aAny;
510 return UnoControlModel::ImplGetDefaultValue( nPropId );
513 ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper()
515 static UnoPropertyArrayHelper* pHelper = NULL;
516 if ( !pHelper )
518 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
519 pHelper = new UnoPropertyArrayHelper( aIDs );
521 return *pHelper;
524 // beans::XMultiPropertySet
525 uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException)
527 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
528 return xInfo;
531 // ----------------------------------------------------
532 // class UnoFileControl
533 // ----------------------------------------------------
534 UnoFileControl::UnoFileControl()
538 ::rtl::OUString UnoFileControl::GetComponentServiceName()
540 return ::rtl::OUString::createFromAscii( "filecontrol" );
543 // ----------------------------------------------------
544 // class ImageProducerControlModel
545 // ----------------------------------------------------
546 uno::Any SAL_CALL ImageProducerControlModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
548 return UnoControlModel::queryInterface( rType );
551 uno::Any SAL_CALL ImageProducerControlModel::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
553 uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XImageProducer*, this ) );
554 return (aRet.hasValue() ? aRet : UnoControlModel::queryAggregation( rType ));
557 void SAL_CALL ImageProducerControlModel::acquire() throw()
559 UnoControlModel::acquire();
562 void SAL_CALL ImageProducerControlModel::release() throw()
564 UnoControlModel::release();
567 uno::Any ImageProducerControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
569 if ( nPropId == BASEPROPERTY_GRAPHIC )
570 return uno::makeAny( uno::Reference< graphic::XGraphic >() );
572 return UnoControlModel::ImplGetDefaultValue( nPropId );
574 uno::Reference< graphic::XGraphic > getGraphicFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& rxGrfObj, const ::rtl::OUString& _rURL )
576 uno::Reference< graphic::XGraphic > xGraphic;
578 if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) )
580 // graphic manager uniqueid
581 rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
582 // get the DefaultContext
583 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
584 rxGrfObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID );
586 else // linked
587 rxGrfObj = NULL; // release the GraphicObject
589 if ( !_rURL.getLength() )
590 return xGraphic;
594 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
595 uno::Reference< graphic::XGraphicProvider > xProvider;
596 if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
598 uno::Sequence< beans::PropertyValue > aMediaProperties(1);
599 aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
600 aMediaProperties[0].Value <<= _rURL;
601 xGraphic = xProvider->queryGraphic( aMediaProperties );
604 catch( const Exception& )
606 DBG_UNHANDLED_EXCEPTION();
609 return xGraphic;
612 void SAL_CALL ImageProducerControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
614 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
616 // - ImageAlign and ImagePosition need to correspond to each other
617 // - Graphic and ImageURL need to correspond to each other
620 switch ( nHandle )
622 case BASEPROPERTY_IMAGEURL:
623 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
625 mbAdjustingGraphic = true;
626 ::rtl::OUString sImageURL;
627 OSL_VERIFY( rValue >>= sImageURL );
628 setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( getGraphicFromURL_nothrow( mxGrfObj, sImageURL ) ) );
629 mbAdjustingGraphic = false;
631 break;
633 case BASEPROPERTY_GRAPHIC:
634 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
636 mbAdjustingGraphic = true;
637 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ), uno::makeAny( ::rtl::OUString() ) );
638 mbAdjustingGraphic = false;
640 break;
642 case BASEPROPERTY_IMAGEALIGN:
643 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) )
645 mbAdjustingImagePosition = true;
646 sal_Int16 nUNOValue = 0;
647 OSL_VERIFY( rValue >>= nUNOValue );
648 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEPOSITION ), uno::makeAny( getExtendedImagePosition( nUNOValue ) ) );
649 mbAdjustingImagePosition = false;
651 break;
652 case BASEPROPERTY_IMAGEPOSITION:
653 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) )
655 mbAdjustingImagePosition = true;
656 sal_Int16 nUNOValue = 0;
657 OSL_VERIFY( rValue >>= nUNOValue );
658 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEALIGN ), uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) );
659 mbAdjustingImagePosition = false;
661 break;
664 catch( const ::com::sun::star::uno::Exception& )
666 OSL_ENSURE( sal_False, "ImageProducerControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
667 mbAdjustingImagePosition = sal_False;
671 void ImageProducerControlModel::addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
673 maListeners.push_back( xConsumer );
676 void ImageProducerControlModel::removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
678 maListeners.remove( xConsumer );
681 void ImageProducerControlModel::startProduction( ) throw (::com::sun::star::uno::RuntimeException)
683 uno::Sequence<uno::Any> aArgs(1);
684 aArgs.getArray()[0] = getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) );
685 uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
686 uno::Reference< awt::XImageProducer > xImageProducer( xMSF->createInstanceWithArguments( ::rtl::OUString::createFromAscii( "com.sun.star.awt.ImageProducer" ), aArgs ), uno::UNO_QUERY );
687 if ( xImageProducer.is() )
689 std::list< uno::Reference< awt::XImageConsumer > >::iterator aIter( maListeners.begin() );
690 while ( aIter != maListeners.end() )
692 xImageProducer->addConsumer( *aIter );
693 aIter++;
695 xImageProducer->startProduction();
699 // ----------------------------------------------------
700 // class ImageConsumerControl
701 // ----------------------------------------------------
703 sal_Bool SAL_CALL ImageConsumerControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException )
705 // remove the peer as image consumer from the model
706 lcl_knitImageComponents( getModel(), getPeer(), false );
708 sal_Bool bReturn = UnoControlBase::setModel( _rModel );
710 // add the peer as image consumer to the model
711 lcl_knitImageComponents( getModel(), getPeer(), true );
713 return bReturn;
716 void SAL_CALL ImageConsumerControl::createPeer( const uno::Reference< awt::XToolkit >& rxToolkit, const uno::Reference< awt::XWindowPeer >& rParentPeer ) throw(uno::RuntimeException)
718 // remove the peer as image consumer from the model
719 lcl_knitImageComponents( getModel(), getPeer(), false );
721 UnoControlBase::createPeer( rxToolkit, rParentPeer );
723 // add the peer as image consumer to the model
724 lcl_knitImageComponents( getModel(), getPeer(), true );
727 void SAL_CALL ImageConsumerControl::dispose( ) throw(::com::sun::star::uno::RuntimeException)
729 // remove the peer as image consumer from the model
730 lcl_knitImageComponents( getModel(), getPeer(), false );
732 UnoControlBase::dispose();
735 void ImageConsumerControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
737 sal_uInt16 nType = GetPropertyId( rPropName );
738 if ( nType == BASEPROPERTY_IMAGEURL )
740 uno::Reference < awt::XImageProducer > xImgProd( getModel(), uno::UNO_QUERY );
741 uno::Reference < awt::XImageConsumer > xImgCons( getPeer(), uno::UNO_QUERY );
743 if ( xImgProd.is() && xImgCons.is() )
744 xImgProd->startProduction();
746 else
747 UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
750 // ----------------------------------------------------
751 // class UnoControlButtonModel
752 // ----------------------------------------------------
753 UnoControlButtonModel::UnoControlButtonModel()
755 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton );
757 osl_incrementInterlockedCount( &m_refCount );
759 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION ) );
760 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
761 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
763 osl_decrementInterlockedCount( &m_refCount );
766 ::rtl::OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
768 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel );
771 uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
773 switch ( nPropId )
775 case BASEPROPERTY_DEFAULTCONTROL:
776 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlButton ) );
777 case BASEPROPERTY_TOGGLE:
778 return uno::makeAny( (sal_Bool)sal_False );
779 case BASEPROPERTY_ALIGN:
780 return uno::makeAny( (sal_Int16)PROPERTY_ALIGN_CENTER );
781 case BASEPROPERTY_FOCUSONCLICK:
782 return uno::makeAny( (sal_Bool)sal_True );
785 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
788 ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper()
790 static UnoPropertyArrayHelper* pHelper = NULL;
791 if ( !pHelper )
793 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
794 pHelper = new UnoPropertyArrayHelper( aIDs );
796 return *pHelper;
799 // beans::XMultiPropertySet
800 uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException)
802 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
803 return xInfo;
806 // ----------------------------------------------------
807 // class UnoButtonControl
808 // ----------------------------------------------------
809 UnoButtonControl::UnoButtonControl()
810 : maActionListeners( *this )
811 , maItemListeners( *this )
813 maComponentInfos.nWidth = 50;
814 maComponentInfos.nHeight = 14;
817 ::rtl::OUString UnoButtonControl::GetComponentServiceName()
819 ::rtl::OUString aName( ::rtl::OUString::createFromAscii( "pushbutton" ) );
820 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) );
821 sal_Int16 n = sal_Int16();
822 if ( ( aVal >>= n ) && n )
824 // Use PushButtonType later when available...
825 switch ( n )
827 case 1 /*PushButtonType::OK*/: aName= ::rtl::OUString::createFromAscii( "okbutton" );
828 break;
829 case 2 /*PushButtonType::CANCEL*/: aName= ::rtl::OUString::createFromAscii( "cancelbutton" );
830 break;
831 case 3 /*PushButtonType::HELP*/: aName= ::rtl::OUString::createFromAscii( "helpbutton" );
832 break;
833 default:
835 DBG_ERROR( "Unknown Button Type!" );
839 return aName;
842 void UnoButtonControl::dispose() throw(uno::RuntimeException)
844 lang::EventObject aEvt;
845 aEvt.Source = (::cppu::OWeakObject*)this;
846 maActionListeners.disposeAndClear( aEvt );
847 maItemListeners.disposeAndClear( aEvt );
848 ImageConsumerControl::dispose();
851 void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
853 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
855 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
856 xButton->setActionCommand( maActionCommand );
857 if ( maActionListeners.getLength() )
858 xButton->addActionListener( &maActionListeners );
860 uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY );
861 if ( xPushButton.is() )
862 xPushButton->addItemListener( this );
865 void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
867 maActionListeners.addInterface( l );
868 if( getPeer().is() && maActionListeners.getLength() == 1 )
870 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
871 xButton->addActionListener( &maActionListeners );
875 void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
877 if( getPeer().is() && maActionListeners.getLength() == 1 )
879 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
880 xButton->removeActionListener( &maActionListeners );
882 maActionListeners.removeInterface( l );
885 void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
887 maItemListeners.addInterface( l );
890 void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
892 maItemListeners.removeInterface( l );
895 void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException)
897 ImageConsumerControl::disposing( Source );
900 void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException)
902 // forward to model
903 uno::Any aAny;
904 aAny <<= (sal_Int16)rEvent.Selected;
905 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
907 // multiplex
908 ItemEvent aEvent( rEvent );
909 aEvent.Source = *this;
910 maItemListeners.itemStateChanged( aEvent );
913 void UnoButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
915 uno::Any aAny;
916 aAny <<= rLabel;
917 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
920 void UnoButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
922 maActionCommand = rCommand;
923 if ( getPeer().is() )
925 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
926 xButton->setActionCommand( rCommand );
930 awt::Size UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException)
932 return Impl_getMinimumSize();
935 awt::Size UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException)
937 return Impl_getPreferredSize();
940 awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
942 return Impl_calcAdjustedSize( rNewSize );
945 // ----------------------------------------------------
946 // class UnoControlImageControlModel
947 // ----------------------------------------------------
948 UnoControlImageControlModel::UnoControlImageControlModel()
949 :mbAdjustingImageScaleMode( false )
951 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl );
954 ::rtl::OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
956 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControlModel );
959 uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
961 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
962 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl ) );
964 if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE )
965 return makeAny( awt::ImageScaleMode::Anisotropic );
967 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
970 ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper()
972 static UnoPropertyArrayHelper* pHelper = NULL;
973 if ( !pHelper )
975 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
976 pHelper = new UnoPropertyArrayHelper( aIDs );
978 return *pHelper;
981 // beans::XMultiPropertySet
982 uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException)
984 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
985 return xInfo;
988 void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception)
990 ImageProducerControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
992 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
995 switch ( _nHandle )
997 case BASEPROPERTY_IMAGE_SCALE_MODE:
998 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) )
1000 mbAdjustingImageScaleMode = true;
1001 sal_Int16 nScaleMode( awt::ImageScaleMode::Anisotropic );
1002 OSL_VERIFY( _rValue >>= nScaleMode );
1003 setPropertyValue( GetPropertyName( BASEPROPERTY_SCALEIMAGE ), uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) );
1004 mbAdjustingImageScaleMode = false;
1006 break;
1007 case BASEPROPERTY_SCALEIMAGE:
1008 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) )
1010 mbAdjustingImageScaleMode = true;
1011 sal_Bool bScale = sal_True;
1012 OSL_VERIFY( _rValue >>= bScale );
1013 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) );
1014 mbAdjustingImageScaleMode = false;
1016 break;
1019 catch( const Exception& )
1021 mbAdjustingImageScaleMode = false;
1022 throw;
1026 // ----------------------------------------------------
1027 // class UnoImageControlControl
1028 // ----------------------------------------------------
1029 UnoImageControlControl::UnoImageControlControl()
1030 : maActionListeners( *this )
1032 // Woher die Defaults nehmen?
1033 maComponentInfos.nWidth = 100;
1034 maComponentInfos.nHeight = 100;
1037 ::rtl::OUString UnoImageControlControl::GetComponentServiceName()
1039 return ::rtl::OUString::createFromAscii( "fixedimage" );
1042 void UnoImageControlControl::dispose() throw(uno::RuntimeException)
1044 lang::EventObject aEvt;
1045 aEvt.Source = (::cppu::OWeakObject*)this;
1046 maActionListeners.disposeAndClear( aEvt );
1047 UnoControl::dispose();
1050 sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException)
1052 return sal_True;
1055 awt::Size UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException)
1057 return Impl_getMinimumSize();
1060 awt::Size UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException)
1062 return Impl_getPreferredSize();
1065 awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1067 return Impl_calcAdjustedSize( rNewSize );
1070 // ----------------------------------------------------
1071 // class UnoControlRadioButtonModel
1072 // ----------------------------------------------------
1073 UnoControlRadioButtonModel::UnoControlRadioButtonModel()
1075 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton );
1078 ::rtl::OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1080 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel );
1083 uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1085 switch ( nPropId )
1087 case BASEPROPERTY_DEFAULTCONTROL:
1088 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButton ) );
1090 case BASEPROPERTY_VISUALEFFECT:
1091 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1094 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
1097 ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper()
1099 static UnoPropertyArrayHelper* pHelper = NULL;
1100 if ( !pHelper )
1102 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1103 pHelper = new UnoPropertyArrayHelper( aIDs );
1105 return *pHelper;
1108 // beans::XMultiPropertySet
1109 uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1111 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1112 return xInfo;
1117 // ----------------------------------------------------
1118 // class UnoRadioButtonControl
1119 // ----------------------------------------------------
1120 UnoRadioButtonControl::UnoRadioButtonControl()
1121 : maItemListeners( *this ), maActionListeners( *this )
1123 maComponentInfos.nWidth = 100;
1124 maComponentInfos.nHeight = 12;
1127 ::rtl::OUString UnoRadioButtonControl::GetComponentServiceName()
1129 return ::rtl::OUString::createFromAscii( "radiobutton" );
1132 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException)
1134 lang::EventObject aEvt;
1135 aEvt.Source = (::cppu::OWeakObject*)this;
1136 maItemListeners.disposeAndClear( aEvt );
1137 ImageConsumerControl::dispose();
1141 sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException)
1143 return sal_True;
1146 void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1148 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
1150 uno::Reference < awt::XRadioButton > xRadioButton( getPeer(), uno::UNO_QUERY );
1151 xRadioButton->addItemListener( this );
1153 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1154 xButton->setActionCommand( maActionCommand );
1155 if ( maActionListeners.getLength() )
1156 xButton->addActionListener( &maActionListeners );
1158 // as default, set the "AutoToggle" to true
1159 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1160 // have it enabled by default because of 85071)
1161 uno::Reference< awt::XVclWindowPeer > xVclWindowPeer( getPeer(), uno::UNO_QUERY );
1162 if ( xVclWindowPeer.is() )
1163 xVclWindowPeer->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE ), ::cppu::bool2any( sal_True ) );
1166 void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1168 maItemListeners.addInterface( l );
1171 void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1173 maItemListeners.removeInterface( l );
1176 void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1178 maActionListeners.addInterface( l );
1179 if( getPeer().is() && maActionListeners.getLength() == 1 )
1181 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1182 xButton->addActionListener( &maActionListeners );
1186 void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1188 if( getPeer().is() && maActionListeners.getLength() == 1 )
1190 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1191 xButton->removeActionListener( &maActionListeners );
1193 maActionListeners.removeInterface( l );
1196 void UnoRadioButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
1198 uno::Any aAny;
1199 aAny <<= rLabel;
1200 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1203 void UnoRadioButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1205 maActionCommand = rCommand;
1206 if ( getPeer().is() )
1208 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1209 xButton->setActionCommand( rCommand );
1213 void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException)
1215 sal_Int16 nState = bOn ? 1 : 0;
1216 uno::Any aAny;
1217 aAny <<= nState;
1218 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1221 sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException)
1223 sal_Int16 nState = 0;
1224 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1225 aVal >>= nState;
1226 return nState ? sal_True : sal_False;
1229 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1231 uno::Any aAny;
1232 aAny <<= (sal_Int16)rEvent.Selected;
1233 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1235 // compatibility:
1236 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1237 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1238 // "0" to "1".
1239 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1240 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1241 // isn't the case anymore: For instance, this method here gets called for the radio button
1242 // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
1243 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1244 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1245 // all which matters here.
1246 // #i14703# - 2003-05-23 - fs@openoffice.org
1247 if ( 1 == rEvent.Selected )
1249 if ( maItemListeners.getLength() )
1250 maItemListeners.itemStateChanged( rEvent );
1252 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1253 // a radio button _without_ selecing another one, this would have caused a notification.
1254 // With the change done here, this today won't cause a notification anymore.
1256 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1257 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1258 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1259 // to be inconsistent with.
1262 awt::Size UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException)
1264 return Impl_getMinimumSize();
1267 awt::Size UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException)
1269 return Impl_getPreferredSize();
1272 awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1274 return Impl_calcAdjustedSize( rNewSize );
1277 // ----------------------------------------------------
1278 // class UnoControlCheckBoxModel
1279 // ----------------------------------------------------
1280 UnoControlCheckBoxModel::UnoControlCheckBoxModel()
1282 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox );
1285 ::rtl::OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1287 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel );
1290 uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1292 switch ( nPropId )
1294 case BASEPROPERTY_DEFAULTCONTROL:
1295 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBox ) );
1297 case BASEPROPERTY_VISUALEFFECT:
1298 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1301 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
1304 ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper()
1306 static UnoPropertyArrayHelper* pHelper = NULL;
1307 if ( !pHelper )
1309 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1310 pHelper = new UnoPropertyArrayHelper( aIDs );
1312 return *pHelper;
1315 // beans::XMultiPropertySet
1316 uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1318 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1319 return xInfo;
1324 // ----------------------------------------------------
1325 // class UnoCheckBoxControl
1326 // ----------------------------------------------------
1327 UnoCheckBoxControl::UnoCheckBoxControl()
1328 : maItemListeners( *this ), maActionListeners( *this )
1330 maComponentInfos.nWidth = 100;
1331 maComponentInfos.nHeight = 12;
1334 ::rtl::OUString UnoCheckBoxControl::GetComponentServiceName()
1336 return ::rtl::OUString::createFromAscii( "checkbox" );
1339 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException)
1341 lang::EventObject aEvt;
1342 aEvt.Source = (::cppu::OWeakObject*)this;
1343 maItemListeners.disposeAndClear( aEvt );
1344 ImageConsumerControl::dispose();
1347 sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException)
1349 return sal_True;
1352 void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1354 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
1356 uno::Reference < awt::XCheckBox > xCheckBox( getPeer(), uno::UNO_QUERY );
1357 xCheckBox->addItemListener( this );
1359 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1360 xButton->setActionCommand( maActionCommand );
1361 if ( maActionListeners.getLength() )
1362 xButton->addActionListener( &maActionListeners );
1365 void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1367 maItemListeners.addInterface( l );
1370 void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1372 maItemListeners.removeInterface( l );
1375 void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1377 maActionListeners.addInterface( l );
1378 if( getPeer().is() && maActionListeners.getLength() == 1 )
1380 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1381 xButton->addActionListener( &maActionListeners );
1385 void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1387 if( getPeer().is() && maActionListeners.getLength() == 1 )
1389 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1390 xButton->removeActionListener( &maActionListeners );
1392 maActionListeners.removeInterface( l );
1395 void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1397 maActionCommand = rCommand;
1398 if ( getPeer().is() )
1400 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1401 xButton->setActionCommand( rCommand );
1406 void UnoCheckBoxControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
1408 uno::Any aAny;
1409 aAny <<= rLabel;
1410 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1413 void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException)
1415 uno::Any aAny;
1416 aAny <<= (sal_Int16)n;
1417 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1420 short UnoCheckBoxControl::getState() throw(uno::RuntimeException)
1422 short nState = 0;
1423 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1424 aVal >>= nState;
1425 return nState;
1428 void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException)
1430 uno::Any aAny;
1431 aAny <<= b;
1432 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, sal_True );
1435 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1437 uno::Any aAny;
1438 aAny <<= (sal_Int16)rEvent.Selected;
1439 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1441 if ( maItemListeners.getLength() )
1442 maItemListeners.itemStateChanged( rEvent );
1445 awt::Size UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException)
1447 return Impl_getMinimumSize();
1450 awt::Size UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException)
1452 return Impl_getPreferredSize();
1455 awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1457 return Impl_calcAdjustedSize( rNewSize );
1460 // ----------------------------------------------------
1461 // class UnoControlFixedHyperlinkModel
1462 // ----------------------------------------------------
1463 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel()
1465 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink );
1468 ::rtl::OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1470 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel );
1473 uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1475 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1477 uno::Any aAny;
1478 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink );
1479 return aAny;
1481 else if ( nPropId == BASEPROPERTY_BORDER )
1483 uno::Any aAny;
1484 aAny <<= (sal_Int16)0;
1485 return aAny;
1487 else if ( nPropId == BASEPROPERTY_URL )
1489 uno::Any aAny;
1490 aAny <<= ::rtl::OUString();
1491 return aAny;
1494 return UnoControlModel::ImplGetDefaultValue( nPropId );
1497 ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper()
1499 static UnoPropertyArrayHelper* pHelper = NULL;
1500 if ( !pHelper )
1502 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1503 pHelper = new UnoPropertyArrayHelper( aIDs );
1505 return *pHelper;
1508 // beans::XMultiPropertySet
1509 uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1511 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1512 return xInfo;
1515 // ----------------------------------------------------
1516 // class UnoFixedHyperlinkControl
1517 // ----------------------------------------------------
1518 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1519 : maActionListeners( *this )
1521 maComponentInfos.nWidth = 100;
1522 maComponentInfos.nHeight = 12;
1525 ::rtl::OUString UnoFixedHyperlinkControl::GetComponentServiceName()
1527 return ::rtl::OUString::createFromAscii( "fixedhyperlink" );
1530 // uno::XInterface
1531 uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1533 uno::Any aRet = ::cppu::queryInterface( rType,
1534 SAL_STATIC_CAST( awt::XFixedHyperlink*, this ),
1535 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1536 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1539 // lang::XTypeProvider
1540 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl )
1541 getCppuType( ( uno::Reference< awt::XFixedHyperlink>* ) NULL ),
1542 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
1543 UnoControlBase::getTypes()
1544 IMPL_XTYPEPROVIDER_END
1546 sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException)
1548 return sal_True;
1551 void UnoFixedHyperlinkControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1553 uno::Any aAny;
1554 aAny <<= Text;
1555 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1558 ::rtl::OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException)
1560 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1563 void UnoFixedHyperlinkControl::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException)
1565 uno::Any aAny;
1566 aAny <<= URL;
1567 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, sal_True );
1570 ::rtl::OUString UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException)
1572 return ImplGetPropertyValue_UString( BASEPROPERTY_URL );
1575 void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1577 uno::Any aAny;
1578 aAny <<= (sal_Int16)nAlign;
1579 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1582 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException)
1584 short nAlign = 0;
1585 if ( mxModel.is() )
1587 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1588 aVal >>= nAlign;
1590 return nAlign;
1593 awt::Size UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException)
1595 return Impl_getMinimumSize();
1598 awt::Size UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException)
1600 return Impl_getPreferredSize();
1603 awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1605 return Impl_calcAdjustedSize( rNewSize );
1608 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException)
1610 lang::EventObject aEvt;
1611 aEvt.Source = (::cppu::OWeakObject*)this;
1612 maActionListeners.disposeAndClear( aEvt );
1613 UnoControlBase::dispose();
1616 void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1618 UnoControlBase::createPeer( rxToolkit, rParentPeer );
1620 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1621 if ( maActionListeners.getLength() )
1622 xFixedHyperlink->addActionListener( &maActionListeners );
1625 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1627 maActionListeners.addInterface( l );
1628 if( getPeer().is() && maActionListeners.getLength() == 1 )
1630 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1631 xFixedHyperlink->addActionListener( &maActionListeners );
1635 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1637 if( getPeer().is() && maActionListeners.getLength() == 1 )
1639 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1640 xFixedHyperlink->removeActionListener( &maActionListeners );
1642 maActionListeners.removeInterface( l );
1645 // ----------------------------------------------------
1646 // class UnoControlFixedTextModel
1647 // ----------------------------------------------------
1648 UnoControlFixedTextModel::UnoControlFixedTextModel()
1650 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText );
1653 ::rtl::OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1655 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedTextModel );
1658 uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1660 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1662 uno::Any aAny;
1663 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedText );
1664 return aAny;
1666 else if ( nPropId == BASEPROPERTY_BORDER )
1668 uno::Any aAny;
1669 aAny <<= (sal_Int16)0;
1670 return aAny;
1673 return UnoControlModel::ImplGetDefaultValue( nPropId );
1676 ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper()
1678 static UnoPropertyArrayHelper* pHelper = NULL;
1679 if ( !pHelper )
1681 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1682 pHelper = new UnoPropertyArrayHelper( aIDs );
1684 return *pHelper;
1687 // beans::XMultiPropertySet
1688 uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1690 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1691 return xInfo;
1695 // ----------------------------------------------------
1696 // class UnoFixedTextControl
1697 // ----------------------------------------------------
1698 UnoFixedTextControl::UnoFixedTextControl()
1700 maComponentInfos.nWidth = 100;
1701 maComponentInfos.nHeight = 12;
1704 ::rtl::OUString UnoFixedTextControl::GetComponentServiceName()
1706 return ::rtl::OUString::createFromAscii( "fixedtext" );
1709 // uno::XInterface
1710 uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1712 uno::Any aRet = ::cppu::queryInterface( rType,
1713 SAL_STATIC_CAST( awt::XFixedText*, this ),
1714 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1715 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1718 // lang::XTypeProvider
1719 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl )
1720 getCppuType( ( uno::Reference< awt::XFixedText>* ) NULL ),
1721 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
1722 UnoControlBase::getTypes()
1723 IMPL_XTYPEPROVIDER_END
1725 sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException)
1727 return sal_True;
1730 void UnoFixedTextControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1732 uno::Any aAny;
1733 aAny <<= Text;
1734 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1737 ::rtl::OUString UnoFixedTextControl::getText() throw(uno::RuntimeException)
1739 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1742 void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1744 uno::Any aAny;
1745 aAny <<= (sal_Int16)nAlign;
1746 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1749 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException)
1751 short nAlign = 0;
1752 if ( mxModel.is() )
1754 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1755 aVal >>= nAlign;
1757 return nAlign;
1760 awt::Size UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException)
1762 return Impl_getMinimumSize();
1765 awt::Size UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException)
1767 return Impl_getPreferredSize();
1770 awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1772 return Impl_calcAdjustedSize( rNewSize );
1775 // ----------------------------------------------------
1776 // class UnoControlGroupBoxModel
1777 // ----------------------------------------------------
1778 UnoControlGroupBoxModel::UnoControlGroupBoxModel()
1780 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
1781 ImplRegisterProperty( BASEPROPERTY_ENABLED );
1782 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
1783 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
1784 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
1785 ImplRegisterProperty( BASEPROPERTY_HELPURL );
1786 ImplRegisterProperty( BASEPROPERTY_LABEL );
1787 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
1788 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
1789 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
1792 ::rtl::OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1794 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel );
1797 uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1799 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1801 uno::Any aAny;
1802 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox );
1803 return aAny;
1805 return UnoControlModel::ImplGetDefaultValue( nPropId );
1808 ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper()
1810 static UnoPropertyArrayHelper* pHelper = NULL;
1811 if ( !pHelper )
1813 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1814 pHelper = new UnoPropertyArrayHelper( aIDs );
1816 return *pHelper;
1819 // beans::XMultiPropertySet
1820 uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1822 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1823 return xInfo;
1826 // ----------------------------------------------------
1827 // class UnoGroupBoxControl
1828 // ----------------------------------------------------
1829 UnoGroupBoxControl::UnoGroupBoxControl()
1831 maComponentInfos.nWidth = 100;
1832 maComponentInfos.nHeight = 100;
1835 ::rtl::OUString UnoGroupBoxControl::GetComponentServiceName()
1837 return ::rtl::OUString::createFromAscii( "groupbox" );
1840 sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException)
1842 return sal_True;
1845 // MultiPage
1847 UnoMultiPageModel::UnoMultiPageModel()
1849 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
1850 ImplRegisterProperty( BASEPROPERTY_ENABLED );
1851 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
1852 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
1853 ImplRegisterProperty( BASEPROPERTY_HELPURL );
1854 ImplRegisterProperty( BASEPROPERTY_LABEL );
1855 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
1856 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
1857 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
1860 ::rtl::OUString UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1862 return ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
1865 uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1867 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1869 uno::Any aAny;
1870 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox );
1871 //aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageControl );
1872 return aAny;
1874 return UnoControlModel::ImplGetDefaultValue( nPropId );
1877 ::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
1879 static UnoPropertyArrayHelper* pHelper = NULL;
1880 if ( !pHelper )
1882 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1883 pHelper = new UnoPropertyArrayHelper( aIDs );
1885 return *pHelper;
1888 // beans::XMultiPropertySet
1889 uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1891 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1892 return xInfo;
1895 // ----------------------------------------------------
1896 // class MultiPageControl
1897 // ----------------------------------------------------
1898 UnoMultiPageControl::UnoMultiPageControl()
1900 maComponentInfos.nWidth = 100;
1901 maComponentInfos.nHeight = 100;
1904 ::rtl::OUString UnoMultiPageControl::GetComponentServiceName()
1906 return ::rtl::OUString::createFromAscii( "multipage" );
1909 sal_Bool UnoMultiPageControl::isTransparent() throw(uno::RuntimeException)
1911 return sal_True;
1916 // ----------------------------------------------------
1917 // class UnoControlListBoxModel
1918 // ----------------------------------------------------
1919 UnoControlListBoxModel::UnoControlListBoxModel()
1921 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox );
1924 ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1926 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel );
1929 uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1931 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1933 uno::Any aAny;
1934 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBox );
1935 return aAny;
1937 return UnoControlModel::ImplGetDefaultValue( nPropId );
1940 ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper()
1942 static UnoPropertyArrayHelper* pHelper = NULL;
1943 if ( !pHelper )
1945 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1946 pHelper = new UnoPropertyArrayHelper( aIDs );
1948 return *pHelper;
1951 // beans::XMultiPropertySet
1952 uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1954 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1955 return xInfo;
1958 void UnoControlListBoxModel::ImplPropertyChanged( sal_uInt16 nPropId )
1960 if ( nPropId == BASEPROPERTY_STRINGITEMLIST )
1962 uno::Sequence<sal_Int16> aSeq;
1963 uno::Any aAny;
1964 aAny <<= aSeq;
1965 setPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny );
1968 UnoControlModel::ImplPropertyChanged( nPropId );
1971 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
1972 uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(())
1974 // dependencies we know:
1975 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
1976 ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS );
1978 UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
1981 // ----------------------------------------------------
1982 // class UnoListBoxControl
1983 // ----------------------------------------------------
1984 UnoListBoxControl::UnoListBoxControl()
1985 : maActionListeners( *this ),
1986 maItemListeners( *this )
1988 maComponentInfos.nWidth = 100;
1989 maComponentInfos.nHeight = 12;
1992 ::rtl::OUString UnoListBoxControl::GetComponentServiceName()
1994 return ::rtl::OUString::createFromAscii( "listbox" );
1997 // uno::XInterface
1998 uno::Any UnoListBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2000 uno::Any aRet = ::cppu::queryInterface( rType,
2001 SAL_STATIC_CAST( awt::XListBox*, this ),
2002 SAL_STATIC_CAST( awt::XItemListener*, this ),
2003 SAL_STATIC_CAST( lang::XEventListener*, SAL_STATIC_CAST( awt::XItemListener*, this ) ),
2004 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ),
2005 SAL_STATIC_CAST( awt::XTextLayoutConstrains*, this ) );
2006 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
2009 // lang::XTypeProvider
2010 IMPL_XTYPEPROVIDER_START( UnoListBoxControl )
2011 getCppuType( ( uno::Reference< awt::XListBox>* ) NULL ),
2012 getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ),
2013 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
2014 getCppuType( ( uno::Reference< awt::XTextLayoutConstrains>* ) NULL ),
2015 UnoControlBase::getTypes()
2016 IMPL_XTYPEPROVIDER_END
2018 void UnoListBoxControl::dispose() throw(uno::RuntimeException)
2020 lang::EventObject aEvt;
2021 aEvt.Source = (::cppu::OWeakObject*)this;
2022 maActionListeners.disposeAndClear( aEvt );
2023 maItemListeners.disposeAndClear( aEvt );
2024 UnoControl::dispose();
2027 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2029 if ( getPeer().is() )
2031 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2032 DBG_ASSERT( xListBox.is(), "XListBox?" );
2034 uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos();
2035 uno::Any aAny;
2036 aAny <<= aSeq;
2037 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, sal_False );
2041 void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
2043 UnoControl::ImplSetPeerProperty( rPropName, rVal );
2045 // Wenn die SelectedItems vor der StringItemList gesetzt werden,
2046 // hat das keine Auswirkung...
2047 if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
2049 ::rtl::OUString aSelPropName = GetPropertyName( BASEPROPERTY_SELECTEDITEMS );
2050 uno::Any aVal = ImplGetPropertyValue( aSelPropName );
2051 if ( !( aVal.getValueType().getTypeClass() == uno::TypeClass_VOID ) )
2053 uno::Reference< awt::XVclWindowPeer > xW( getPeer(), uno::UNO_QUERY );
2054 if (xW.is())
2055 // same comment as in UnoControl::ImplSetPeerProperty - see there
2056 xW->setProperty( aSelPropName, aVal );
2061 void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2063 UnoControl::createPeer( rxToolkit, rParentPeer );
2065 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2066 xListBox->addItemListener( this );
2068 if ( maActionListeners.getLength() )
2069 xListBox->addActionListener( &maActionListeners );
2072 void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2074 maActionListeners.addInterface( l );
2075 if( getPeer().is() && maActionListeners.getLength() == 1 )
2077 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2078 xListBox->addActionListener( &maActionListeners );
2082 void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2084 if( getPeer().is() && maActionListeners.getLength() == 1 )
2086 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2087 xListBox->removeActionListener( &maActionListeners );
2089 maActionListeners.removeInterface( l );
2092 void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2094 maItemListeners.addInterface( l );
2097 void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2099 maItemListeners.removeInterface( l );
2102 void UnoListBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
2104 uno::Sequence< ::rtl::OUString> aSeq( 1 );
2105 aSeq.getArray()[0] = aItem;
2106 addItems( aSeq, nPos );
2109 void UnoListBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
2111 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2112 uno::Sequence< ::rtl::OUString> aSeq;
2113 aVal >>= aSeq;
2114 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2115 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2116 sal_uInt16 nNewLen = nOldLen + nNewItems;
2118 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2119 ::rtl::OUString* pNewData = aNewSeq.getArray();
2120 ::rtl::OUString* pOldData = aSeq.getArray();
2122 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2123 nPos = (sal_uInt16) nOldLen;
2125 sal_uInt16 n;
2126 // Items vor der Einfuege-Position
2127 for ( n = 0; n < nPos; n++ )
2128 pNewData[n] = pOldData[n];
2130 // Neue Items
2131 for ( n = 0; n < nNewItems; n++ )
2132 pNewData[nPos+n] = aItems.getConstArray()[n];
2134 // Rest der alten Items
2135 for ( n = nPos; n < nOldLen; n++ )
2136 pNewData[nNewItems+n] = pOldData[n];
2138 uno::Any aAny;
2139 aAny <<= aNewSeq;
2140 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2143 void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
2145 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2146 uno::Sequence< ::rtl::OUString> aSeq;
2147 aVal >>= aSeq;
2148 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2149 if ( nOldLen && ( nPos < nOldLen ) )
2151 if ( nCount > ( nOldLen-nPos ) )
2152 nCount = nOldLen-nPos;
2154 sal_uInt16 nNewLen = nOldLen - nCount;
2156 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2157 ::rtl::OUString* pNewData = aNewSeq.getArray();
2158 ::rtl::OUString* pOldData = aSeq.getArray();
2160 sal_uInt16 n;
2161 // Items vor der Entfern-Position
2162 for ( n = 0; n < nPos; n++ )
2163 pNewData[n] = pOldData[n];
2165 // Rest der Items
2166 for ( n = nPos; n < (nOldLen-nCount); n++ )
2167 pNewData[n] = pOldData[n+nCount];
2169 uno::Any aAny;
2170 aAny <<= aNewSeq;
2171 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2175 sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException)
2177 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2178 uno::Sequence< ::rtl::OUString> aSeq;
2179 aVal >>= aSeq;
2180 return (sal_Int16)aSeq.getLength();
2183 ::rtl::OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
2185 ::rtl::OUString aItem;
2186 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2187 uno::Sequence< ::rtl::OUString> aSeq;
2188 aVal >>= aSeq;
2189 if ( nPos < aSeq.getLength() )
2190 aItem = aSeq.getConstArray()[nPos];
2191 return aItem;
2194 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException)
2196 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2197 uno::Sequence< ::rtl::OUString> aSeq;
2198 aVal >>= aSeq;
2199 return aSeq;
2202 sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException)
2204 sal_Int16 n = -1;
2205 if ( getPeer().is() )
2207 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2208 n = xListBox->getSelectedItemPos();
2210 return n;
2213 uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException)
2215 uno::Sequence<sal_Int16> aSeq;
2216 if ( getPeer().is() )
2218 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2219 aSeq = xListBox->getSelectedItemsPos();
2221 return aSeq;
2224 ::rtl::OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException)
2226 ::rtl::OUString aItem;
2227 if ( getPeer().is() )
2229 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2230 aItem = xListBox->getSelectedItem();
2232 return aItem;
2235 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException)
2237 uno::Sequence< ::rtl::OUString> aSeq;
2238 if ( getPeer().is() )
2240 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2241 aSeq = xListBox->getSelectedItems();
2243 return aSeq;
2246 void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException)
2248 if ( getPeer().is() )
2250 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2251 xListBox->selectItemPos( nPos, bSelect );
2253 ImplUpdateSelectedItemsProperty();
2256 void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException)
2258 if ( getPeer().is() )
2260 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2261 xListBox->selectItemsPos( aPositions, bSelect );
2263 ImplUpdateSelectedItemsProperty();
2266 void UnoListBoxControl::selectItem( const ::rtl::OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException)
2268 if ( getPeer().is() )
2270 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2271 xListBox->selectItem( aItem, bSelect );
2273 ImplUpdateSelectedItemsProperty();
2276 void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException)
2278 if ( getPeer().is() )
2280 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2281 xListBox->makeVisible( nEntry );
2285 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
2287 uno::Any aAny;
2288 aAny <<= (sal_Int16)nLines;
2289 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
2292 sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
2294 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
2297 sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException)
2299 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION );
2302 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException)
2304 uno::Any aAny;
2305 aAny <<= bMulti;
2306 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, sal_True );
2309 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
2311 ImplUpdateSelectedItemsProperty();
2312 if ( maItemListeners.getLength() )
2316 maItemListeners.itemStateChanged( rEvent );
2318 catch( const Exception& e )
2320 #if OSL_DEBUG_LEVEL == 0
2321 (void) e; // suppress warning
2322 #else
2323 ::rtl::OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2324 sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
2325 OSL_ENSURE( sal_False, sMessage.getStr() );
2326 #endif
2331 awt::Size UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException)
2333 return Impl_getMinimumSize();
2336 awt::Size UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException)
2338 return Impl_getPreferredSize();
2341 awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
2343 return Impl_calcAdjustedSize( rNewSize );
2346 awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
2348 return Impl_getMinimumSize( nCols, nLines );
2351 void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
2353 Impl_getColumnsAndLines( nCols, nLines );
2356 // ----------------------------------------------------
2357 // class UnoControlComboBoxModel
2358 // ----------------------------------------------------
2359 UnoControlComboBoxModel::UnoControlComboBoxModel()
2361 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox );
2364 ::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2366 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel );
2369 uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2371 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2373 uno::Any aAny;
2374 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox );
2375 return aAny;
2377 return UnoControlModel::ImplGetDefaultValue( nPropId );
2381 ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper()
2383 static UnoPropertyArrayHelper* pHelper = NULL;
2384 if ( !pHelper )
2386 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2387 pHelper = new UnoPropertyArrayHelper( aIDs );
2389 return *pHelper;
2392 // beans::XMultiPropertySet
2393 uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2395 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2396 return xInfo;
2401 // ----------------------------------------------------
2402 // class UnoComboBoxControl
2403 // ----------------------------------------------------
2404 UnoComboBoxControl::UnoComboBoxControl()
2405 : maActionListeners( *this ),
2406 maItemListeners( *this )
2408 maComponentInfos.nWidth = 100;
2409 maComponentInfos.nHeight = 12;
2412 ::rtl::OUString UnoComboBoxControl::GetComponentServiceName()
2414 return ::rtl::OUString::createFromAscii( "combobox" );
2417 // uno::XInterface
2418 uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2420 uno::Any aRet = ::cppu::queryInterface( rType,
2421 SAL_STATIC_CAST( awt::XComboBox*, this ) );
2422 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
2425 // lang::XTypeProvider
2426 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl )
2427 getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ),
2428 UnoEditControl::getTypes()
2429 IMPL_XTYPEPROVIDER_END
2431 void UnoComboBoxControl::dispose() throw(uno::RuntimeException)
2433 lang::EventObject aEvt;
2434 aEvt.Source = (::cppu::OWeakObject*)this;
2435 maActionListeners.disposeAndClear( aEvt );
2436 maItemListeners.disposeAndClear( aEvt );
2437 UnoControl::dispose();
2440 void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2442 UnoEditControl::createPeer( rxToolkit, rParentPeer );
2444 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2445 if ( maActionListeners.getLength() )
2446 xComboBox->addActionListener( &maActionListeners );
2447 if ( maItemListeners.getLength() )
2448 xComboBox->addItemListener( &maItemListeners );
2451 void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2453 maActionListeners.addInterface( l );
2454 if( getPeer().is() && maActionListeners.getLength() == 1 )
2456 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2457 xComboBox->addActionListener( &maActionListeners );
2461 void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2463 if( getPeer().is() && maActionListeners.getLength() == 1 )
2465 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2466 xComboBox->removeActionListener( &maActionListeners );
2468 maActionListeners.removeInterface( l );
2471 void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2473 maItemListeners.addInterface( l );
2474 if( getPeer().is() && maItemListeners.getLength() == 1 )
2476 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2477 xComboBox->addItemListener( &maItemListeners );
2481 void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2483 if( getPeer().is() && maItemListeners.getLength() == 1 )
2485 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); // MT: Mal alles so umstellen, schoener als Ref anlegen und query rufen
2486 xComboBox->removeItemListener( &maItemListeners );
2488 maItemListeners.removeInterface( l );
2491 void UnoComboBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
2493 uno::Sequence< ::rtl::OUString> aSeq( 1 );
2494 aSeq.getArray()[0] = aItem;
2495 addItems( aSeq, nPos );
2498 void UnoComboBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
2500 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2501 uno::Sequence< ::rtl::OUString> aSeq;
2502 aVal >>= aSeq;
2503 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2504 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2505 sal_uInt16 nNewLen = nOldLen + nNewItems;
2507 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2508 ::rtl::OUString* pNewData = aNewSeq.getArray();
2509 const ::rtl::OUString* pOldData = aSeq.getConstArray();
2511 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2512 nPos = (sal_uInt16) nOldLen;
2514 sal_uInt16 n;
2515 // Items vor der Einfuege-Position
2516 for ( n = 0; n < nPos; n++ )
2517 pNewData[n] = pOldData[n];
2519 // Neue Items
2520 for ( n = 0; n < nNewItems; n++ )
2521 pNewData[nPos+n] = aItems.getConstArray()[n];
2523 // Rest der alten Items
2524 for ( n = nPos; n < nOldLen; n++ )
2525 pNewData[nNewItems+n] = pOldData[n];
2527 uno::Any aAny;
2528 aAny <<= aNewSeq;
2529 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2532 void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
2534 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2535 uno::Sequence< ::rtl::OUString> aSeq;
2536 aVal >>= aSeq;
2537 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2538 if ( nOldLen && ( nPos < nOldLen ) )
2540 if ( nCount > ( nOldLen-nPos ) )
2541 nCount = nOldLen-nPos;
2543 sal_uInt16 nNewLen = nOldLen - nCount;
2545 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2546 ::rtl::OUString* pNewData = aNewSeq.getArray();
2547 ::rtl::OUString* pOldData = aSeq.getArray();
2549 sal_uInt16 n;
2550 // Items vor der Entfern-Position
2551 for ( n = 0; n < nPos; n++ )
2552 pNewData[n] = pOldData[n];
2554 // Rest der Items
2555 for ( n = nPos; n < (nOldLen-nCount); n++ )
2556 pNewData[n] = pOldData[n+nCount];
2558 uno::Any aAny;
2559 aAny <<= aNewSeq;
2560 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2564 sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException)
2566 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2567 uno::Sequence< ::rtl::OUString> aSeq;
2568 aVal >>= aSeq;
2569 return (sal_Int16)aSeq.getLength();
2572 ::rtl::OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
2574 ::rtl::OUString aItem;
2575 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2576 uno::Sequence< ::rtl::OUString> aSeq;
2577 aVal >>= aSeq;
2578 if ( nPos < aSeq.getLength() )
2579 aItem = aSeq.getConstArray()[nPos];
2580 return aItem;
2583 uno::Sequence< ::rtl::OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException)
2585 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2586 uno::Sequence< ::rtl::OUString> aSeq;
2587 aVal >>= aSeq;
2588 return aSeq;
2591 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
2593 uno::Any aAny;
2594 aAny <<= nLines;
2595 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
2598 sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
2600 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
2604 // ----------------------------------------------------
2605 // UnoSpinFieldControl
2606 // ----------------------------------------------------
2607 UnoSpinFieldControl::UnoSpinFieldControl() : maSpinListeners( *this )
2609 mbRepeat = sal_False;
2612 // uno::XInterface
2613 uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2615 uno::Any aRet = ::cppu::queryInterface( rType,
2616 SAL_STATIC_CAST( awt::XSpinField*, this ) );
2617 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
2620 // lang::XTypeProvider
2621 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl )
2622 getCppuType( ( uno::Reference< awt::XSpinField>* ) NULL ),
2623 UnoEditControl::getTypes()
2624 IMPL_XTYPEPROVIDER_END
2626 void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2628 UnoEditControl::createPeer( rxToolkit, rParentPeer );
2630 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2631 xField->enableRepeat( mbRepeat );
2632 if ( maSpinListeners.getLength() )
2633 xField->addSpinListener( &maSpinListeners );
2636 // ::com::sun::star::awt::XSpinField
2637 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
2639 maSpinListeners.addInterface( l );
2640 if( getPeer().is() && maSpinListeners.getLength() == 1 )
2642 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2643 xField->addSpinListener( &maSpinListeners );
2647 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
2649 if( getPeer().is() && maSpinListeners.getLength() == 1 )
2651 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2652 xField->removeSpinListener( &maSpinListeners );
2654 maSpinListeners.removeInterface( l );
2657 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException)
2659 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2660 if ( xField.is() )
2661 xField->up();
2664 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException)
2666 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2667 if ( xField.is() )
2668 xField->down();
2671 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException)
2673 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2674 if ( xField.is() )
2675 xField->first();
2678 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException)
2680 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2681 if ( xField.is() )
2682 xField->last();
2685 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException)
2687 mbRepeat = bRepeat;
2689 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2690 if ( xField.is() )
2691 xField->enableRepeat( bRepeat );
2694 // ----------------------------------------------------
2695 // class UnoControlDateFieldModel
2696 // ----------------------------------------------------
2697 UnoControlDateFieldModel::UnoControlDateFieldModel()
2699 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField );
2702 ::rtl::OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2704 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateFieldModel );
2707 uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2709 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2711 uno::Any aAny;
2712 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateField );
2713 return aAny;
2715 return UnoControlModel::ImplGetDefaultValue( nPropId );
2719 ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper()
2721 static UnoPropertyArrayHelper* pHelper = NULL;
2722 if ( !pHelper )
2724 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2725 pHelper = new UnoPropertyArrayHelper( aIDs );
2727 return *pHelper;
2730 // beans::XMultiPropertySet
2731 uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2733 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2734 return xInfo;
2739 // ----------------------------------------------------
2740 // class UnoDateFieldControl
2741 // ----------------------------------------------------
2742 UnoDateFieldControl::UnoDateFieldControl()
2744 mnFirst = Date( 1, 1, 1900 ).GetDate();
2745 mnLast = Date( 31, 12, 2200 ).GetDate();
2746 mbLongFormat = 2;
2749 ::rtl::OUString UnoDateFieldControl::GetComponentServiceName()
2751 return ::rtl::OUString::createFromAscii( "datefield" );
2754 // uno::XInterface
2755 uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2757 uno::Any aRet = ::cppu::queryInterface( rType,
2758 SAL_STATIC_CAST( awt::XDateField*, this ) );
2759 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
2762 // lang::XTypeProvider
2763 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl )
2764 getCppuType( ( uno::Reference< awt::XDateField>* ) NULL ),
2765 UnoSpinFieldControl::getTypes()
2766 IMPL_XTYPEPROVIDER_END
2768 void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2770 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
2772 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2773 xField->setFirst( mnFirst );
2774 xField->setLast( mnLast );
2775 if ( mbLongFormat != 2 ) // not set
2776 xField->setLongFormat( mbLongFormat );
2780 void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
2782 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
2784 // also change the text property (#i25106#)
2785 if ( xPeer.is() )
2787 ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
2788 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
2791 // re-calc the Date property
2792 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2793 uno::Any aValue;
2794 if ( xField->isEmpty() )
2796 // the field says it's empty
2797 sal_Bool bEnforceFormat = sal_True;
2798 if ( xPeer.is() )
2799 xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat;
2800 if ( !bEnforceFormat )
2802 // and it also says that it is currently accepting invalid inputs, without
2803 // forcing it to a valid date
2804 uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY );
2805 if ( xText.is() && xText->getText().getLength() )
2806 // and in real, the text of the peer is *not* empty
2807 // -> simulate an invalid date, which is different from "no date"
2808 aValue <<= util::Date( 0, 0, 0 );
2811 else
2812 aValue <<= xField->getDate();
2814 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, sal_False );
2816 // multiplex the event
2817 if ( GetTextListeners().getLength() )
2818 GetTextListeners().textChanged( e );
2821 void UnoDateFieldControl::setDate( sal_Int32 Date ) throw(uno::RuntimeException)
2823 uno::Any aAny;
2824 aAny <<= Date;
2825 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, sal_True );
2828 sal_Int32 UnoDateFieldControl::getDate() throw(uno::RuntimeException)
2830 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE );
2833 void UnoDateFieldControl::setMin( sal_Int32 Date ) throw(uno::RuntimeException)
2835 uno::Any aAny;
2836 aAny <<= Date;
2837 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, sal_True );
2840 sal_Int32 UnoDateFieldControl::getMin() throw(uno::RuntimeException)
2842 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN );
2845 void UnoDateFieldControl::setMax( sal_Int32 Date ) throw(uno::RuntimeException)
2847 uno::Any aAny;
2848 aAny <<= Date;
2849 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, sal_True );
2852 sal_Int32 UnoDateFieldControl::getMax() throw(uno::RuntimeException)
2854 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX );
2857 void UnoDateFieldControl::setFirst( sal_Int32 Date ) throw(uno::RuntimeException)
2859 mnFirst = Date;
2860 if ( getPeer().is() )
2862 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2863 xField->setFirst( Date );
2867 sal_Int32 UnoDateFieldControl::getFirst() throw(uno::RuntimeException)
2869 return mnFirst;
2872 void UnoDateFieldControl::setLast( sal_Int32 Date ) throw(uno::RuntimeException)
2874 mnLast = Date;
2875 if ( getPeer().is() )
2877 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2878 xField->setLast( Date );
2882 sal_Int32 UnoDateFieldControl::getLast() throw(uno::RuntimeException)
2884 return mnLast;
2887 void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException)
2889 mbLongFormat = bLong;
2890 if ( getPeer().is() )
2892 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2893 xField->setLongFormat( bLong );
2897 sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException)
2899 return ( mbLongFormat != 2 ) ? mbLongFormat : sal_False;
2902 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException)
2904 if ( getPeer().is() )
2906 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2907 xField->setEmpty();
2911 sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException)
2913 sal_Bool bEmpty = sal_False;
2914 if ( getPeer().is() )
2916 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2917 bEmpty = xField->isEmpty();
2919 return bEmpty;
2922 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
2924 uno::Any aAny;
2925 aAny <<= bStrict;
2926 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
2929 sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException)
2931 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
2934 // ----------------------------------------------------
2935 // class UnoControlTimeFieldModel
2936 // ----------------------------------------------------
2937 UnoControlTimeFieldModel::UnoControlTimeFieldModel()
2939 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField );
2942 ::rtl::OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2944 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel );
2947 uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2949 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2951 uno::Any aAny;
2952 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeField );
2953 return aAny;
2955 return UnoControlModel::ImplGetDefaultValue( nPropId );
2959 ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper()
2961 static UnoPropertyArrayHelper* pHelper = NULL;
2962 if ( !pHelper )
2964 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2965 pHelper = new UnoPropertyArrayHelper( aIDs );
2967 return *pHelper;
2970 // beans::XMultiPropertySet
2971 uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2973 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2974 return xInfo;
2979 // ----------------------------------------------------
2980 // class UnoTimeFieldControl
2981 // ----------------------------------------------------
2982 UnoTimeFieldControl::UnoTimeFieldControl()
2984 mnFirst = Time( 0, 0 ).GetTime();
2985 mnLast = Time( 23, 59, 59, 99 ).GetTime();
2988 ::rtl::OUString UnoTimeFieldControl::GetComponentServiceName()
2990 return ::rtl::OUString::createFromAscii( "timefield" );
2993 // uno::XInterface
2994 uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2996 uno::Any aRet = ::cppu::queryInterface( rType,
2997 SAL_STATIC_CAST( awt::XTimeField*, this ) );
2998 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3001 // lang::XTypeProvider
3002 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl )
3003 getCppuType( ( uno::Reference< awt::XTimeField>* ) NULL ),
3004 UnoSpinFieldControl::getTypes()
3005 IMPL_XTYPEPROVIDER_END
3007 void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3009 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3011 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3012 xField->setFirst( mnFirst );
3013 xField->setLast( mnLast );
3016 void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3018 // also change the text property (#i25106#)
3019 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
3020 ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
3021 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
3023 // re-calc the Time property
3024 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3025 uno::Any aValue;
3026 if ( !xField->isEmpty() )
3027 aValue <<= xField->getTime();
3028 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, sal_False );
3030 // multiplex the event
3031 if ( GetTextListeners().getLength() )
3032 GetTextListeners().textChanged( e );
3035 void UnoTimeFieldControl::setTime( sal_Int32 Time ) throw(uno::RuntimeException)
3037 uno::Any aAny;
3038 aAny <<= Time;
3039 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, sal_True );
3042 sal_Int32 UnoTimeFieldControl::getTime() throw(uno::RuntimeException)
3044 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME );
3047 void UnoTimeFieldControl::setMin( sal_Int32 Time ) throw(uno::RuntimeException)
3049 uno::Any aAny;
3050 aAny <<= Time;
3051 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, sal_True );
3054 sal_Int32 UnoTimeFieldControl::getMin() throw(uno::RuntimeException)
3056 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN );
3059 void UnoTimeFieldControl::setMax( sal_Int32 Time ) throw(uno::RuntimeException)
3061 uno::Any aAny;
3062 aAny <<= Time;
3063 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, sal_True );
3066 sal_Int32 UnoTimeFieldControl::getMax() throw(uno::RuntimeException)
3068 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX );
3071 void UnoTimeFieldControl::setFirst( sal_Int32 Time ) throw(uno::RuntimeException)
3073 mnFirst = Time;
3074 if ( getPeer().is() )
3076 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3077 xField->setFirst( mnFirst );
3081 sal_Int32 UnoTimeFieldControl::getFirst() throw(uno::RuntimeException)
3083 return mnFirst;
3086 void UnoTimeFieldControl::setLast( sal_Int32 Time ) throw(uno::RuntimeException)
3088 mnLast = Time;
3089 if ( getPeer().is() )
3091 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3092 xField->setFirst( mnLast );
3096 sal_Int32 UnoTimeFieldControl::getLast() throw(uno::RuntimeException)
3098 return mnLast;
3101 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException)
3103 if ( getPeer().is() )
3105 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3106 xField->setEmpty();
3110 sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException)
3112 sal_Bool bEmpty = sal_False;
3113 if ( getPeer().is() )
3115 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3116 bEmpty = xField->isEmpty();
3118 return bEmpty;
3121 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3123 uno::Any aAny;
3124 aAny <<= bStrict;
3125 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3128 sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException)
3130 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3133 // ----------------------------------------------------
3134 // class UnoControlNumericFieldModel
3135 // ----------------------------------------------------
3136 UnoControlNumericFieldModel::UnoControlNumericFieldModel()
3138 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField );
3141 ::rtl::OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3143 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel );
3146 uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3148 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3150 uno::Any aAny;
3151 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericField );
3152 return aAny;
3154 return UnoControlModel::ImplGetDefaultValue( nPropId );
3158 ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper()
3160 static UnoPropertyArrayHelper* pHelper = NULL;
3161 if ( !pHelper )
3163 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3164 pHelper = new UnoPropertyArrayHelper( aIDs );
3166 return *pHelper;
3169 // beans::XMultiPropertySet
3170 uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3172 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3173 return xInfo;
3178 // ----------------------------------------------------
3179 // class UnoNumericFieldControl
3180 // ----------------------------------------------------
3181 UnoNumericFieldControl::UnoNumericFieldControl()
3183 mnFirst = 0;
3184 mnLast = 0x7FFFFFFF;
3187 ::rtl::OUString UnoNumericFieldControl::GetComponentServiceName()
3189 return ::rtl::OUString::createFromAscii( "numericfield" );
3192 // uno::XInterface
3193 uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3195 uno::Any aRet = ::cppu::queryInterface( rType,
3196 SAL_STATIC_CAST( awt::XNumericField*, this ) );
3197 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3200 // lang::XTypeProvider
3201 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl )
3202 getCppuType( ( uno::Reference< awt::XNumericField>* ) NULL ),
3203 UnoSpinFieldControl::getTypes()
3204 IMPL_XTYPEPROVIDER_END
3206 void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3208 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3210 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3211 xField->setFirst( mnFirst );
3212 xField->setLast( mnLast );
3216 void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3218 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3219 uno::Any aAny;
3220 aAny <<= xField->getValue();
3221 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3223 if ( GetTextListeners().getLength() )
3224 GetTextListeners().textChanged( e );
3227 void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3229 uno::Any aAny;
3230 aAny <<= Value;
3231 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3234 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException)
3236 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3239 void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3241 uno::Any aAny;
3242 aAny <<= Value;
3243 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3246 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException)
3248 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3251 void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3253 uno::Any aAny;
3254 aAny <<= Value;
3255 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3258 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException)
3260 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3263 void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3265 mnFirst = Value;
3266 if ( getPeer().is() )
3268 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3269 xField->setFirst( mnFirst );
3273 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException)
3275 return mnFirst;
3278 void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException)
3280 mnLast = Value;
3281 if ( getPeer().is() )
3283 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3284 xField->setLast( mnLast );
3288 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException)
3290 return mnLast;
3293 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3295 uno::Any aAny;
3296 aAny <<= bStrict;
3297 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3300 sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException)
3302 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3305 void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
3307 uno::Any aAny;
3308 aAny <<= Digits;
3309 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
3312 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException)
3314 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
3317 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
3319 uno::Any aAny;
3320 aAny <<= Digits;
3321 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
3324 sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException)
3326 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
3329 // ----------------------------------------------------
3330 // class UnoControlCurrencyFieldModel
3331 // ----------------------------------------------------
3332 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel()
3334 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField );
3337 ::rtl::OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3339 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel );
3342 uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3344 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3346 uno::Any aAny;
3347 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyField );
3348 return aAny;
3350 if ( nPropId == BASEPROPERTY_CURSYM_POSITION )
3352 uno::Any aAny;
3353 aAny <<= (sal_Bool)sal_False;
3354 return aAny;
3357 return UnoControlModel::ImplGetDefaultValue( nPropId );
3360 ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper()
3362 static UnoPropertyArrayHelper* pHelper = NULL;
3363 if ( !pHelper )
3365 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3366 pHelper = new UnoPropertyArrayHelper( aIDs );
3368 return *pHelper;
3371 // beans::XMultiPropertySet
3372 uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3374 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3375 return xInfo;
3378 // ----------------------------------------------------
3379 // class UnoCurrencyFieldControl
3380 // ----------------------------------------------------
3381 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
3383 mnFirst = 0;
3384 mnLast = 0x7FFFFFFF;
3387 ::rtl::OUString UnoCurrencyFieldControl::GetComponentServiceName()
3389 return ::rtl::OUString::createFromAscii( "longcurrencyfield" );
3392 // uno::XInterface
3393 uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3395 uno::Any aRet = ::cppu::queryInterface( rType,
3396 SAL_STATIC_CAST( awt::XCurrencyField*, this ) );
3397 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3400 // lang::XTypeProvider
3401 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl )
3402 getCppuType( ( uno::Reference< awt::XCurrencyField>* ) NULL ),
3403 UnoSpinFieldControl::getTypes()
3404 IMPL_XTYPEPROVIDER_END
3406 void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3408 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3410 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3411 xField->setFirst( mnFirst );
3412 xField->setLast( mnLast );
3415 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3417 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3418 uno::Any aAny;
3419 aAny <<= xField->getValue();
3420 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3422 if ( GetTextListeners().getLength() )
3423 GetTextListeners().textChanged( e );
3426 void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3428 uno::Any aAny;
3429 aAny <<= Value;
3430 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3433 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException)
3435 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3438 void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3440 uno::Any aAny;
3441 aAny <<= Value;
3442 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3445 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException)
3447 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3450 void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3452 uno::Any aAny;
3453 aAny <<= Value;
3454 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3457 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException)
3459 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3462 void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3464 mnFirst = Value;
3465 if ( getPeer().is() )
3467 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3468 xField->setFirst( mnFirst );
3472 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException)
3474 return mnFirst;
3477 void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException)
3479 mnLast = Value;
3480 if ( getPeer().is() )
3482 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3483 xField->setLast( mnLast );
3487 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException)
3489 return mnLast;
3492 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3494 uno::Any aAny;
3495 aAny <<= bStrict;
3496 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3499 sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException)
3501 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3504 void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
3506 uno::Any aAny;
3507 aAny <<= Digits;
3508 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
3511 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException)
3513 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
3516 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
3518 uno::Any aAny;
3519 aAny <<= Digits;
3520 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
3523 sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException)
3525 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
3528 // ----------------------------------------------------
3529 // class UnoControlPatternFieldModel
3530 // ----------------------------------------------------
3531 UnoControlPatternFieldModel::UnoControlPatternFieldModel()
3533 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField );
3536 ::rtl::OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3538 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel );
3541 uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3543 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3545 uno::Any aAny;
3546 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternField );
3547 return aAny;
3549 return UnoControlModel::ImplGetDefaultValue( nPropId );
3552 ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper()
3554 static UnoPropertyArrayHelper* pHelper = NULL;
3555 if ( !pHelper )
3557 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3558 pHelper = new UnoPropertyArrayHelper( aIDs );
3560 return *pHelper;
3563 // beans::XMultiPropertySet
3564 uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3566 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3567 return xInfo;
3571 // ----------------------------------------------------
3572 // class UnoPatternFieldControl
3573 // ----------------------------------------------------
3574 UnoPatternFieldControl::UnoPatternFieldControl()
3578 ::rtl::OUString UnoPatternFieldControl::GetComponentServiceName()
3580 return ::rtl::OUString::createFromAscii( "patternfield" );
3583 void UnoPatternFieldControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
3585 sal_uInt16 nType = GetPropertyId( rPropName );
3586 if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) )
3588 // Die Masken koennen nicht nacheinander gesetzt werden.
3589 ::rtl::OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
3590 ::rtl::OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
3591 ::rtl::OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
3593 uno::Reference < awt::XPatternField > xPF( getPeer(), uno::UNO_QUERY );
3594 if (xPF.is())
3596 // same comment as in UnoControl::ImplSetPeerProperty - see there
3597 ::rtl::OUString sText( Text );
3598 ImplCheckLocalize( sText );
3599 xPF->setString( sText );
3600 xPF->setMasks( EditMask, LiteralMask );
3603 else
3604 UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal );
3608 // uno::XInterface
3609 uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3611 uno::Any aRet = ::cppu::queryInterface( rType,
3612 SAL_STATIC_CAST( awt::XPatternField*, this ) );
3613 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3616 // lang::XTypeProvider
3617 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl )
3618 getCppuType( ( uno::Reference< awt::XPatternField>* ) NULL ),
3619 UnoSpinFieldControl::getTypes()
3620 IMPL_XTYPEPROVIDER_END
3622 void UnoPatternFieldControl::setString( const ::rtl::OUString& rString ) throw(uno::RuntimeException)
3624 setText( rString );
3627 ::rtl::OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException)
3629 return getText();
3632 void UnoPatternFieldControl::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
3634 uno::Any aAny;
3635 aAny <<= EditMask;
3636 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, sal_True );
3637 aAny <<= LiteralMask;
3638 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, sal_True );
3641 void UnoPatternFieldControl::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
3643 EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
3644 LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
3647 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3649 uno::Any aAny;
3650 aAny <<= bStrict;
3651 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3654 sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException)
3656 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3660 // ----------------------------------------------------
3661 // class UnoControlProgressBarModel
3662 // ----------------------------------------------------
3663 UnoControlProgressBarModel::UnoControlProgressBarModel()
3665 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
3666 ImplRegisterProperty( BASEPROPERTY_BORDER );
3667 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
3668 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
3669 ImplRegisterProperty( BASEPROPERTY_ENABLED );
3670 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
3671 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
3672 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
3673 ImplRegisterProperty( BASEPROPERTY_HELPURL );
3674 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
3675 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
3676 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
3677 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN );
3680 ::rtl::OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
3682 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBarModel );
3685 uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3687 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3689 uno::Any aAny;
3690 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBar );
3691 return aAny;
3694 return UnoControlModel::ImplGetDefaultValue( nPropId );
3697 ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper()
3699 static UnoPropertyArrayHelper* pHelper = NULL;
3700 if ( !pHelper )
3702 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3703 pHelper = new UnoPropertyArrayHelper( aIDs );
3705 return *pHelper;
3708 // beans::XMultiPropertySet
3709 uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3711 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3712 return xInfo;
3716 // ----------------------------------------------------
3717 // class UnoProgressBarControl
3718 // ----------------------------------------------------
3719 UnoProgressBarControl::UnoProgressBarControl()
3723 ::rtl::OUString UnoProgressBarControl::GetComponentServiceName()
3725 return ::rtl::OUString::createFromAscii( "ProgressBar" );
3728 // uno::XInterface
3729 uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3731 uno::Any aRet = ::cppu::queryInterface( rType,
3732 SAL_STATIC_CAST( awt::XProgressBar*, this ) );
3733 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
3736 // lang::XTypeProvider
3737 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl )
3738 getCppuType( ( uno::Reference< awt::XProgressBar>* ) NULL ),
3739 UnoControlBase::getTypes()
3740 IMPL_XTYPEPROVIDER_END
3742 // ::com::sun::star::awt::XProgressBar
3743 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
3745 uno::Any aAny;
3746 aAny <<= nColor;
3747 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, sal_True );
3750 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
3752 uno::Any aAny;
3753 aAny <<= nColor;
3754 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, sal_True );
3757 void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
3759 uno::Any aAny;
3760 aAny <<= nValue;
3761 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, sal_True );
3764 void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
3766 uno::Any aMin;
3767 uno::Any aMax;
3769 if ( nMin < nMax )
3771 // take correct min and max
3772 aMin <<= nMin;
3773 aMax <<= nMax;
3775 else
3777 // change min and max
3778 aMin <<= nMax;
3779 aMax <<= nMin;
3782 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, sal_True );
3783 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, sal_True );
3786 sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException)
3788 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE );
3792 // ----------------------------------------------------
3793 // class UnoControlFixedLineModel
3794 // ----------------------------------------------------
3795 UnoControlFixedLineModel::UnoControlFixedLineModel()
3797 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
3798 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
3799 ImplRegisterProperty( BASEPROPERTY_ENABLED );
3800 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
3801 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
3802 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
3803 ImplRegisterProperty( BASEPROPERTY_HELPURL );
3804 ImplRegisterProperty( BASEPROPERTY_LABEL );
3805 ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
3806 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
3809 ::rtl::OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
3811 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLineModel );
3814 uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3816 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3818 uno::Any aAny;
3819 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLine );
3820 return aAny;
3822 return UnoControlModel::ImplGetDefaultValue( nPropId );
3825 ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper()
3827 static UnoPropertyArrayHelper* pHelper = NULL;
3828 if ( !pHelper )
3830 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3831 pHelper = new UnoPropertyArrayHelper( aIDs );
3833 return *pHelper;
3836 // beans::XMultiPropertySet
3837 uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3839 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3840 return xInfo;
3843 // ----------------------------------------------------
3844 // class UnoFixedLineControl
3845 // ----------------------------------------------------
3846 UnoFixedLineControl::UnoFixedLineControl()
3848 maComponentInfos.nWidth = 100; // ??
3849 maComponentInfos.nHeight = 100; // ??
3852 ::rtl::OUString UnoFixedLineControl::GetComponentServiceName()
3854 return ::rtl::OUString::createFromAscii( "FixedLine" );
3857 sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException)
3859 return sal_True;