sync master with lastest vba changes
[ooovba.git] / toolkit / source / controls / unocontrols.cxx
blobb8ca5f1fac5df3d10368021d0a4c3f35beeb87c3
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 if (( sText.getLength() > 0 ) &&
234 ( sText.compareToAscii( "&", 1 ) == 0 ))
236 // Magic symbol '&' found at first place. Interpret as a place
237 // holder identifier. Now try to map it to the real value. The
238 // magic symbol must be removed.
239 rtl::OUString aKeyValue( sText.copy( 1 ));
240 if ( UnoControl::ImplMapPlaceHolder( aKeyValue ))
241 sText = aKeyValue;
244 xTextComponent->setText( sText );
245 bDone = sal_True;
249 if ( !bDone )
250 UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
253 void UnoEditControl::dispose() throw(uno::RuntimeException)
255 lang::EventObject aEvt( *this );
256 maTextListeners.disposeAndClear( aEvt );
257 UnoControl::dispose();
260 void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
262 UnoControl::createPeer( rxToolkit, rParentPeer );
264 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
265 if ( xText.is() )
267 xText->addTextListener( this );
269 if ( mbSetMaxTextLenInPeer )
270 xText->setMaxTextLen( mnMaxTextLen );
271 if ( mbSetTextInPeer )
272 xText->setText( maText );
276 void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException)
278 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
280 if ( mbHasTextProperty )
282 uno::Any aAny;
283 aAny <<= xText->getText();
284 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_False );
286 else
288 maText = xText->getText();
291 if ( maTextListeners.getLength() )
292 maTextListeners.textChanged( e );
295 void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
297 maTextListeners.addInterface( l );
300 void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
302 maTextListeners.removeInterface( l );
305 void UnoEditControl::setText( const ::rtl::OUString& aText ) throw(uno::RuntimeException)
307 if ( mbHasTextProperty )
309 uno::Any aAny;
310 aAny <<= aText;
311 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_True );
313 else
315 maText = aText;
316 mbSetTextInPeer = sal_True;
317 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
318 if ( xText.is() )
319 xText->setText( maText );
322 // Setting the property to the VCLXWindow doesn't call textChanged
323 if ( maTextListeners.getLength() )
325 awt::TextEvent aEvent;
326 aEvent.Source = *this;
327 maTextListeners.textChanged( aEvent );
331 namespace
333 static void lcl_normalize( awt::Selection& _rSel )
335 if ( _rSel.Min > _rSel.Max )
336 ::std::swap( _rSel.Min, _rSel.Max );
340 static bool lcl_intersect( const awt::Selection& _rLHS, const awt::Selection& _rRHS )
342 OSL_PRECOND( _rLHS.Min <= _rLHS.Max, "lcl_intersect: LHS to be normalized!" );
343 OSL_PRECOND( _rRHS.Min <= _rRHS.Max, "lcl_intersect: RHS to be normalized!" );
344 return !( ( _rLHS.Max < _rRHS.Min ) || ( _rLHS.Min > _rRHS.Max ) );
349 void UnoEditControl::insertText( const awt::Selection& rSel, const ::rtl::OUString& rNewText ) throw(uno::RuntimeException)
351 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
352 awt::Selection aSelection( rSel );
353 lcl_normalize( aSelection );
355 // preserve the selection resp. cursor position
356 awt::Selection aNewSelection( getSelection() );
357 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
358 // (not sure - looks uglier ...)
359 sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength();
360 if ( aNewSelection.Min > aSelection.Min )
361 aNewSelection.Min -= nDeletedCharacters;
362 if ( aNewSelection.Max > aSelection.Max )
363 aNewSelection.Max -= nDeletedCharacters;
364 #else
365 aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength();
366 aNewSelection.Min = aNewSelection.Max;
367 #endif
369 ::rtl::OUString aOldText = getText();
370 ::rtl::OUString aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
371 setText( aNewText );
373 setSelection( aNewSelection );
376 ::rtl::OUString UnoEditControl::getText() throw(uno::RuntimeException)
378 ::rtl::OUString aText = maText;
380 if ( mbHasTextProperty )
381 aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
382 else
384 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
385 if ( xText.is() )
386 aText = xText->getText();
389 return aText;
392 ::rtl::OUString UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException)
394 ::rtl::OUString sSelected;
395 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
396 if ( xText.is() )
397 sSelected = xText->getSelectedText();
399 return sSelected;
402 void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException)
404 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
405 if ( xText.is() )
406 xText->setSelection( aSelection );
409 awt::Selection UnoEditControl::getSelection( void ) throw(uno::RuntimeException)
411 awt::Selection aSel;
412 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
413 if ( xText.is() )
414 aSel = xText->getSelection();
415 return aSel;
418 sal_Bool UnoEditControl::isEditable( void ) throw(uno::RuntimeException)
420 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY );
423 void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException)
425 uno::Any aAny;
426 aAny <<= (sal_Bool)!bEditable;
427 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, sal_True );
430 sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException)
432 sal_Int16 nMaxLen = mnMaxTextLen;
434 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) )
435 nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN );
437 return nMaxLen;
440 void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException)
442 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) )
444 uno::Any aAny;
445 aAny <<= (sal_Int16)nLen;
446 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, sal_True );
448 else
450 mnMaxTextLen = nLen;
451 mbSetMaxTextLenInPeer = sal_True;
452 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
453 if ( xText.is() )
454 xText->setMaxTextLen( mnMaxTextLen );
458 awt::Size UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException)
460 return Impl_getMinimumSize();
463 awt::Size UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException)
465 return Impl_getPreferredSize();
468 awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
470 return Impl_calcAdjustedSize( rNewSize );
473 awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
475 return Impl_getMinimumSize( nCols, nLines );
478 void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
480 Impl_getColumnsAndLines( nCols, nLines );
484 // ----------------------------------------------------
485 // class UnoControlFileControlModel
486 // ----------------------------------------------------
487 UnoControlFileControlModel::UnoControlFileControlModel()
489 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
490 ImplRegisterProperty( BASEPROPERTY_BORDER );
491 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
492 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
493 ImplRegisterProperty( BASEPROPERTY_ENABLED );
494 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
495 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
496 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
497 ImplRegisterProperty( BASEPROPERTY_HELPURL );
498 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
499 ImplRegisterProperty( BASEPROPERTY_READONLY );
500 ImplRegisterProperty( BASEPROPERTY_TABSTOP );
501 ImplRegisterProperty( BASEPROPERTY_TEXT );
502 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
503 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
504 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
507 ::rtl::OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
509 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControlModel );
512 uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
514 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
516 uno::Any aAny;
517 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControl );
518 return aAny;
520 return UnoControlModel::ImplGetDefaultValue( nPropId );
523 ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper()
525 static UnoPropertyArrayHelper* pHelper = NULL;
526 if ( !pHelper )
528 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
529 pHelper = new UnoPropertyArrayHelper( aIDs );
531 return *pHelper;
534 // beans::XMultiPropertySet
535 uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException)
537 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
538 return xInfo;
541 // ----------------------------------------------------
542 // class UnoFileControl
543 // ----------------------------------------------------
544 UnoFileControl::UnoFileControl()
548 ::rtl::OUString UnoFileControl::GetComponentServiceName()
550 return ::rtl::OUString::createFromAscii( "filecontrol" );
553 // ----------------------------------------------------
554 // class ImageProducerControlModel
555 // ----------------------------------------------------
556 uno::Any SAL_CALL ImageProducerControlModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
558 return UnoControlModel::queryInterface( rType );
561 uno::Any SAL_CALL ImageProducerControlModel::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
563 uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XImageProducer*, this ) );
564 return (aRet.hasValue() ? aRet : UnoControlModel::queryAggregation( rType ));
567 void SAL_CALL ImageProducerControlModel::acquire() throw()
569 UnoControlModel::acquire();
572 void SAL_CALL ImageProducerControlModel::release() throw()
574 UnoControlModel::release();
577 uno::Any ImageProducerControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
579 if ( nPropId == BASEPROPERTY_GRAPHIC )
580 return uno::makeAny( uno::Reference< graphic::XGraphic >() );
582 return UnoControlModel::ImplGetDefaultValue( nPropId );
584 uno::Reference< graphic::XGraphic > getGraphicFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& rxGrfObj, const ::rtl::OUString& _rURL )
586 uno::Reference< graphic::XGraphic > xGraphic;
588 if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) )
590 // graphic manager uniqueid
591 rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
592 // get the DefaultContext
593 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
594 rxGrfObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID );
596 else // linked
597 rxGrfObj = NULL; // release the GraphicObject
599 if ( !_rURL.getLength() )
600 return xGraphic;
604 ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
605 uno::Reference< graphic::XGraphicProvider > xProvider;
606 if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
608 uno::Sequence< beans::PropertyValue > aMediaProperties(1);
609 aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
610 aMediaProperties[0].Value <<= _rURL;
611 xGraphic = xProvider->queryGraphic( aMediaProperties );
614 catch( const Exception& )
616 DBG_UNHANDLED_EXCEPTION();
619 return xGraphic;
622 void SAL_CALL ImageProducerControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
624 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
626 // - ImageAlign and ImagePosition need to correspond to each other
627 // - Graphic and ImageURL need to correspond to each other
630 switch ( nHandle )
632 case BASEPROPERTY_IMAGEURL:
633 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
635 mbAdjustingGraphic = true;
636 ::rtl::OUString sImageURL;
637 OSL_VERIFY( rValue >>= sImageURL );
638 setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( getGraphicFromURL_nothrow( mxGrfObj, sImageURL ) ) );
639 mbAdjustingGraphic = false;
641 break;
643 case BASEPROPERTY_GRAPHIC:
644 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
646 mbAdjustingGraphic = true;
647 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ), uno::makeAny( ::rtl::OUString() ) );
648 mbAdjustingGraphic = false;
650 break;
652 case BASEPROPERTY_IMAGEALIGN:
653 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) )
655 mbAdjustingImagePosition = true;
656 sal_Int16 nUNOValue = 0;
657 OSL_VERIFY( rValue >>= nUNOValue );
658 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEPOSITION ), uno::makeAny( getExtendedImagePosition( nUNOValue ) ) );
659 mbAdjustingImagePosition = false;
661 break;
662 case BASEPROPERTY_IMAGEPOSITION:
663 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) )
665 mbAdjustingImagePosition = true;
666 sal_Int16 nUNOValue = 0;
667 OSL_VERIFY( rValue >>= nUNOValue );
668 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEALIGN ), uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) );
669 mbAdjustingImagePosition = false;
671 break;
674 catch( const ::com::sun::star::uno::Exception& )
676 OSL_ENSURE( sal_False, "ImageProducerControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
677 mbAdjustingImagePosition = sal_False;
681 void ImageProducerControlModel::addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
683 maListeners.push_back( xConsumer );
686 void ImageProducerControlModel::removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& xConsumer ) throw (::com::sun::star::uno::RuntimeException)
688 maListeners.remove( xConsumer );
691 void ImageProducerControlModel::startProduction( ) throw (::com::sun::star::uno::RuntimeException)
693 uno::Sequence<uno::Any> aArgs(1);
694 aArgs.getArray()[0] = getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ) );
695 uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
696 uno::Reference< awt::XImageProducer > xImageProducer( xMSF->createInstanceWithArguments( ::rtl::OUString::createFromAscii( "com.sun.star.awt.ImageProducer" ), aArgs ), uno::UNO_QUERY );
697 if ( xImageProducer.is() )
699 std::list< uno::Reference< awt::XImageConsumer > >::iterator aIter( maListeners.begin() );
700 while ( aIter != maListeners.end() )
702 xImageProducer->addConsumer( *aIter );
703 aIter++;
705 xImageProducer->startProduction();
709 // ----------------------------------------------------
710 // class ImageConsumerControl
711 // ----------------------------------------------------
713 sal_Bool SAL_CALL ImageConsumerControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException )
715 // remove the peer as image consumer from the model
716 lcl_knitImageComponents( getModel(), getPeer(), false );
718 sal_Bool bReturn = UnoControlBase::setModel( _rModel );
720 // add the peer as image consumer to the model
721 lcl_knitImageComponents( getModel(), getPeer(), true );
723 return bReturn;
726 void SAL_CALL ImageConsumerControl::createPeer( const uno::Reference< awt::XToolkit >& rxToolkit, const uno::Reference< awt::XWindowPeer >& rParentPeer ) throw(uno::RuntimeException)
728 // remove the peer as image consumer from the model
729 lcl_knitImageComponents( getModel(), getPeer(), false );
731 UnoControlBase::createPeer( rxToolkit, rParentPeer );
733 // add the peer as image consumer to the model
734 lcl_knitImageComponents( getModel(), getPeer(), true );
737 void SAL_CALL ImageConsumerControl::dispose( ) throw(::com::sun::star::uno::RuntimeException)
739 // remove the peer as image consumer from the model
740 lcl_knitImageComponents( getModel(), getPeer(), false );
742 UnoControlBase::dispose();
745 void ImageConsumerControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
747 sal_uInt16 nType = GetPropertyId( rPropName );
748 if ( nType == BASEPROPERTY_IMAGEURL )
750 uno::Reference < awt::XImageProducer > xImgProd( getModel(), uno::UNO_QUERY );
751 uno::Reference < awt::XImageConsumer > xImgCons( getPeer(), uno::UNO_QUERY );
753 if ( xImgProd.is() && xImgCons.is() )
754 xImgProd->startProduction();
756 else
757 UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
760 // ----------------------------------------------------
761 // class UnoControlButtonModel
762 // ----------------------------------------------------
763 UnoControlButtonModel::UnoControlButtonModel()
765 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton );
767 osl_incrementInterlockedCount( &m_refCount );
769 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION ) );
770 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
771 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
773 osl_decrementInterlockedCount( &m_refCount );
776 ::rtl::OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
778 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel );
781 uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
783 switch ( nPropId )
785 case BASEPROPERTY_DEFAULTCONTROL:
786 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlButton ) );
787 case BASEPROPERTY_TOGGLE:
788 return uno::makeAny( (sal_Bool)sal_False );
789 case BASEPROPERTY_ALIGN:
790 return uno::makeAny( (sal_Int16)PROPERTY_ALIGN_CENTER );
791 case BASEPROPERTY_FOCUSONCLICK:
792 return uno::makeAny( (sal_Bool)sal_True );
795 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
798 ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper()
800 static UnoPropertyArrayHelper* pHelper = NULL;
801 if ( !pHelper )
803 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
804 pHelper = new UnoPropertyArrayHelper( aIDs );
806 return *pHelper;
809 // beans::XMultiPropertySet
810 uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException)
812 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
813 return xInfo;
816 // ----------------------------------------------------
817 // class UnoButtonControl
818 // ----------------------------------------------------
819 UnoButtonControl::UnoButtonControl()
820 : maActionListeners( *this )
821 , maItemListeners( *this )
823 maComponentInfos.nWidth = 50;
824 maComponentInfos.nHeight = 14;
827 ::rtl::OUString UnoButtonControl::GetComponentServiceName()
829 ::rtl::OUString aName( ::rtl::OUString::createFromAscii( "pushbutton" ) );
830 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) );
831 sal_Int16 n = sal_Int16();
832 if ( ( aVal >>= n ) && n )
834 // Use PushButtonType later when available...
835 switch ( n )
837 case 1 /*PushButtonType::OK*/: aName= ::rtl::OUString::createFromAscii( "okbutton" );
838 break;
839 case 2 /*PushButtonType::CANCEL*/: aName= ::rtl::OUString::createFromAscii( "cancelbutton" );
840 break;
841 case 3 /*PushButtonType::HELP*/: aName= ::rtl::OUString::createFromAscii( "helpbutton" );
842 break;
843 default:
845 DBG_ERROR( "Unknown Button Type!" );
849 return aName;
852 void UnoButtonControl::dispose() throw(uno::RuntimeException)
854 lang::EventObject aEvt;
855 aEvt.Source = (::cppu::OWeakObject*)this;
856 maActionListeners.disposeAndClear( aEvt );
857 maItemListeners.disposeAndClear( aEvt );
858 ImageConsumerControl::dispose();
861 void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
863 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
865 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
866 xButton->setActionCommand( maActionCommand );
867 if ( maActionListeners.getLength() )
868 xButton->addActionListener( &maActionListeners );
870 uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY );
871 if ( xPushButton.is() )
872 xPushButton->addItemListener( this );
875 void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
877 maActionListeners.addInterface( l );
878 if( getPeer().is() && maActionListeners.getLength() == 1 )
880 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
881 xButton->addActionListener( &maActionListeners );
885 void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
887 if( getPeer().is() && maActionListeners.getLength() == 1 )
889 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
890 xButton->removeActionListener( &maActionListeners );
892 maActionListeners.removeInterface( l );
895 void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
897 maItemListeners.addInterface( l );
900 void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
902 maItemListeners.removeInterface( l );
905 void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException)
907 ImageConsumerControl::disposing( Source );
910 void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException)
912 // forward to model
913 uno::Any aAny;
914 aAny <<= (sal_Int16)rEvent.Selected;
915 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
917 // multiplex
918 ItemEvent aEvent( rEvent );
919 aEvent.Source = *this;
920 maItemListeners.itemStateChanged( aEvent );
923 void UnoButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
925 uno::Any aAny;
926 aAny <<= rLabel;
927 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
930 void UnoButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
932 maActionCommand = rCommand;
933 if ( getPeer().is() )
935 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
936 xButton->setActionCommand( rCommand );
940 awt::Size UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException)
942 return Impl_getMinimumSize();
945 awt::Size UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException)
947 return Impl_getPreferredSize();
950 awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
952 return Impl_calcAdjustedSize( rNewSize );
955 // ----------------------------------------------------
956 // class UnoControlImageControlModel
957 // ----------------------------------------------------
958 UnoControlImageControlModel::UnoControlImageControlModel()
959 :mbAdjustingImageScaleMode( false )
961 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl );
964 ::rtl::OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
966 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControlModel );
969 uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
971 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
972 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl ) );
974 if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE )
975 return makeAny( awt::ImageScaleMode::Anisotropic );
977 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
980 ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper()
982 static UnoPropertyArrayHelper* pHelper = NULL;
983 if ( !pHelper )
985 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
986 pHelper = new UnoPropertyArrayHelper( aIDs );
988 return *pHelper;
991 // beans::XMultiPropertySet
992 uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException)
994 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
995 return xInfo;
998 void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception)
1000 ImageProducerControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
1002 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
1005 switch ( _nHandle )
1007 case BASEPROPERTY_IMAGE_SCALE_MODE:
1008 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) )
1010 mbAdjustingImageScaleMode = true;
1011 sal_Int16 nScaleMode( awt::ImageScaleMode::Anisotropic );
1012 OSL_VERIFY( _rValue >>= nScaleMode );
1013 setPropertyValue( GetPropertyName( BASEPROPERTY_SCALEIMAGE ), uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) );
1014 mbAdjustingImageScaleMode = false;
1016 break;
1017 case BASEPROPERTY_SCALEIMAGE:
1018 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) )
1020 mbAdjustingImageScaleMode = true;
1021 sal_Bool bScale = sal_True;
1022 OSL_VERIFY( _rValue >>= bScale );
1023 setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) );
1024 mbAdjustingImageScaleMode = false;
1026 break;
1029 catch( const Exception& )
1031 mbAdjustingImageScaleMode = false;
1032 throw;
1036 // ----------------------------------------------------
1037 // class UnoImageControlControl
1038 // ----------------------------------------------------
1039 UnoImageControlControl::UnoImageControlControl()
1040 : maActionListeners( *this )
1042 // Woher die Defaults nehmen?
1043 maComponentInfos.nWidth = 100;
1044 maComponentInfos.nHeight = 100;
1047 ::rtl::OUString UnoImageControlControl::GetComponentServiceName()
1049 return ::rtl::OUString::createFromAscii( "fixedimage" );
1052 void UnoImageControlControl::dispose() throw(uno::RuntimeException)
1054 lang::EventObject aEvt;
1055 aEvt.Source = (::cppu::OWeakObject*)this;
1056 maActionListeners.disposeAndClear( aEvt );
1057 UnoControl::dispose();
1060 sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException)
1062 return sal_True;
1065 awt::Size UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException)
1067 return Impl_getMinimumSize();
1070 awt::Size UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException)
1072 return Impl_getPreferredSize();
1075 awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1077 return Impl_calcAdjustedSize( rNewSize );
1080 // ----------------------------------------------------
1081 // class UnoControlRadioButtonModel
1082 // ----------------------------------------------------
1083 UnoControlRadioButtonModel::UnoControlRadioButtonModel()
1085 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton );
1088 ::rtl::OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1090 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel );
1093 uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1095 switch ( nPropId )
1097 case BASEPROPERTY_DEFAULTCONTROL:
1098 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButton ) );
1100 case BASEPROPERTY_VISUALEFFECT:
1101 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1104 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
1107 ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper()
1109 static UnoPropertyArrayHelper* pHelper = NULL;
1110 if ( !pHelper )
1112 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1113 pHelper = new UnoPropertyArrayHelper( aIDs );
1115 return *pHelper;
1118 // beans::XMultiPropertySet
1119 uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1121 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1122 return xInfo;
1127 // ----------------------------------------------------
1128 // class UnoRadioButtonControl
1129 // ----------------------------------------------------
1130 UnoRadioButtonControl::UnoRadioButtonControl()
1131 : maItemListeners( *this ), maActionListeners( *this )
1133 maComponentInfos.nWidth = 100;
1134 maComponentInfos.nHeight = 12;
1137 ::rtl::OUString UnoRadioButtonControl::GetComponentServiceName()
1139 return ::rtl::OUString::createFromAscii( "radiobutton" );
1142 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException)
1144 lang::EventObject aEvt;
1145 aEvt.Source = (::cppu::OWeakObject*)this;
1146 maItemListeners.disposeAndClear( aEvt );
1147 ImageConsumerControl::dispose();
1151 sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException)
1153 return sal_True;
1156 void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1158 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
1160 uno::Reference < awt::XRadioButton > xRadioButton( getPeer(), uno::UNO_QUERY );
1161 xRadioButton->addItemListener( this );
1163 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1164 xButton->setActionCommand( maActionCommand );
1165 if ( maActionListeners.getLength() )
1166 xButton->addActionListener( &maActionListeners );
1168 // as default, set the "AutoToggle" to true
1169 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1170 // have it enabled by default because of 85071)
1171 uno::Reference< awt::XVclWindowPeer > xVclWindowPeer( getPeer(), uno::UNO_QUERY );
1172 if ( xVclWindowPeer.is() )
1173 xVclWindowPeer->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE ), ::cppu::bool2any( sal_True ) );
1176 void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1178 maItemListeners.addInterface( l );
1181 void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1183 maItemListeners.removeInterface( l );
1186 void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1188 maActionListeners.addInterface( l );
1189 if( getPeer().is() && maActionListeners.getLength() == 1 )
1191 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1192 xButton->addActionListener( &maActionListeners );
1196 void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1198 if( getPeer().is() && maActionListeners.getLength() == 1 )
1200 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1201 xButton->removeActionListener( &maActionListeners );
1203 maActionListeners.removeInterface( l );
1206 void UnoRadioButtonControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
1208 uno::Any aAny;
1209 aAny <<= rLabel;
1210 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1213 void UnoRadioButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1215 maActionCommand = rCommand;
1216 if ( getPeer().is() )
1218 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1219 xButton->setActionCommand( rCommand );
1223 void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException)
1225 sal_Int16 nState = bOn ? 1 : 0;
1226 uno::Any aAny;
1227 aAny <<= nState;
1228 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1231 sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException)
1233 sal_Int16 nState = 0;
1234 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1235 aVal >>= nState;
1236 return nState ? sal_True : sal_False;
1239 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1241 uno::Any aAny;
1242 aAny <<= (sal_Int16)rEvent.Selected;
1243 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1245 // compatibility:
1246 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1247 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1248 // "0" to "1".
1249 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1250 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1251 // isn't the case anymore: For instance, this method here gets called for the radio button
1252 // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
1253 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1254 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1255 // all which matters here.
1256 // #i14703# - 2003-05-23 - fs@openoffice.org
1257 if ( 1 == rEvent.Selected )
1259 if ( maItemListeners.getLength() )
1260 maItemListeners.itemStateChanged( rEvent );
1262 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1263 // a radio button _without_ selecing another one, this would have caused a notification.
1264 // With the change done here, this today won't cause a notification anymore.
1266 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1267 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1268 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1269 // to be inconsistent with.
1272 awt::Size UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException)
1274 return Impl_getMinimumSize();
1277 awt::Size UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException)
1279 return Impl_getPreferredSize();
1282 awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1284 return Impl_calcAdjustedSize( rNewSize );
1287 // ----------------------------------------------------
1288 // class UnoControlCheckBoxModel
1289 // ----------------------------------------------------
1290 UnoControlCheckBoxModel::UnoControlCheckBoxModel()
1292 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox );
1295 ::rtl::OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1297 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel );
1300 uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1302 switch ( nPropId )
1304 case BASEPROPERTY_DEFAULTCONTROL:
1305 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBox ) );
1307 case BASEPROPERTY_VISUALEFFECT:
1308 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1311 return ImageProducerControlModel::ImplGetDefaultValue( nPropId );
1314 ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper()
1316 static UnoPropertyArrayHelper* pHelper = NULL;
1317 if ( !pHelper )
1319 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1320 pHelper = new UnoPropertyArrayHelper( aIDs );
1322 return *pHelper;
1325 // beans::XMultiPropertySet
1326 uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1328 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1329 return xInfo;
1334 // ----------------------------------------------------
1335 // class UnoCheckBoxControl
1336 // ----------------------------------------------------
1337 UnoCheckBoxControl::UnoCheckBoxControl()
1338 : maItemListeners( *this ), maActionListeners( *this )
1340 maComponentInfos.nWidth = 100;
1341 maComponentInfos.nHeight = 12;
1344 ::rtl::OUString UnoCheckBoxControl::GetComponentServiceName()
1346 return ::rtl::OUString::createFromAscii( "checkbox" );
1349 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException)
1351 lang::EventObject aEvt;
1352 aEvt.Source = (::cppu::OWeakObject*)this;
1353 maItemListeners.disposeAndClear( aEvt );
1354 ImageConsumerControl::dispose();
1357 sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException)
1359 return sal_True;
1362 void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1364 ImageConsumerControl::createPeer( rxToolkit, rParentPeer );
1366 uno::Reference < awt::XCheckBox > xCheckBox( getPeer(), uno::UNO_QUERY );
1367 xCheckBox->addItemListener( this );
1369 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1370 xButton->setActionCommand( maActionCommand );
1371 if ( maActionListeners.getLength() )
1372 xButton->addActionListener( &maActionListeners );
1375 void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1377 maItemListeners.addInterface( l );
1380 void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1382 maItemListeners.removeInterface( l );
1385 void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1387 maActionListeners.addInterface( l );
1388 if( getPeer().is() && maActionListeners.getLength() == 1 )
1390 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1391 xButton->addActionListener( &maActionListeners );
1395 void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1397 if( getPeer().is() && maActionListeners.getLength() == 1 )
1399 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1400 xButton->removeActionListener( &maActionListeners );
1402 maActionListeners.removeInterface( l );
1405 void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1407 maActionCommand = rCommand;
1408 if ( getPeer().is() )
1410 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1411 xButton->setActionCommand( rCommand );
1416 void UnoCheckBoxControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException)
1418 uno::Any aAny;
1419 aAny <<= rLabel;
1420 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1423 void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException)
1425 uno::Any aAny;
1426 aAny <<= (sal_Int16)n;
1427 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1430 short UnoCheckBoxControl::getState() throw(uno::RuntimeException)
1432 short nState = 0;
1433 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1434 aVal >>= nState;
1435 return nState;
1438 void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException)
1440 uno::Any aAny;
1441 aAny <<= b;
1442 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, sal_True );
1445 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1447 uno::Any aAny;
1448 aAny <<= (sal_Int16)rEvent.Selected;
1449 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1451 if ( maItemListeners.getLength() )
1452 maItemListeners.itemStateChanged( rEvent );
1455 awt::Size UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException)
1457 return Impl_getMinimumSize();
1460 awt::Size UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException)
1462 return Impl_getPreferredSize();
1465 awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1467 return Impl_calcAdjustedSize( rNewSize );
1470 // ----------------------------------------------------
1471 // class UnoControlFixedHyperlinkModel
1472 // ----------------------------------------------------
1473 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel()
1475 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink );
1478 ::rtl::OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1480 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel );
1483 uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1485 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1487 uno::Any aAny;
1488 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink );
1489 return aAny;
1491 else if ( nPropId == BASEPROPERTY_BORDER )
1493 uno::Any aAny;
1494 aAny <<= (sal_Int16)0;
1495 return aAny;
1497 else if ( nPropId == BASEPROPERTY_URL )
1499 uno::Any aAny;
1500 aAny <<= ::rtl::OUString();
1501 return aAny;
1504 return UnoControlModel::ImplGetDefaultValue( nPropId );
1507 ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper()
1509 static UnoPropertyArrayHelper* pHelper = NULL;
1510 if ( !pHelper )
1512 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1513 pHelper = new UnoPropertyArrayHelper( aIDs );
1515 return *pHelper;
1518 // beans::XMultiPropertySet
1519 uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1521 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1522 return xInfo;
1525 // ----------------------------------------------------
1526 // class UnoFixedHyperlinkControl
1527 // ----------------------------------------------------
1528 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1529 : maActionListeners( *this )
1531 maComponentInfos.nWidth = 100;
1532 maComponentInfos.nHeight = 12;
1535 ::rtl::OUString UnoFixedHyperlinkControl::GetComponentServiceName()
1537 return ::rtl::OUString::createFromAscii( "fixedhyperlink" );
1540 // uno::XInterface
1541 uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1543 uno::Any aRet = ::cppu::queryInterface( rType,
1544 SAL_STATIC_CAST( awt::XFixedHyperlink*, this ),
1545 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1546 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1549 // lang::XTypeProvider
1550 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl )
1551 getCppuType( ( uno::Reference< awt::XFixedHyperlink>* ) NULL ),
1552 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
1553 UnoControlBase::getTypes()
1554 IMPL_XTYPEPROVIDER_END
1556 sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException)
1558 return sal_True;
1561 void UnoFixedHyperlinkControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1563 uno::Any aAny;
1564 aAny <<= Text;
1565 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1568 ::rtl::OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException)
1570 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1573 void UnoFixedHyperlinkControl::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException)
1575 uno::Any aAny;
1576 aAny <<= URL;
1577 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, sal_True );
1580 ::rtl::OUString UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException)
1582 return ImplGetPropertyValue_UString( BASEPROPERTY_URL );
1585 void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1587 uno::Any aAny;
1588 aAny <<= (sal_Int16)nAlign;
1589 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1592 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException)
1594 short nAlign = 0;
1595 if ( mxModel.is() )
1597 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1598 aVal >>= nAlign;
1600 return nAlign;
1603 awt::Size UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException)
1605 return Impl_getMinimumSize();
1608 awt::Size UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException)
1610 return Impl_getPreferredSize();
1613 awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1615 return Impl_calcAdjustedSize( rNewSize );
1618 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException)
1620 lang::EventObject aEvt;
1621 aEvt.Source = (::cppu::OWeakObject*)this;
1622 maActionListeners.disposeAndClear( aEvt );
1623 UnoControlBase::dispose();
1626 void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
1628 UnoControlBase::createPeer( rxToolkit, rParentPeer );
1630 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1631 if ( maActionListeners.getLength() )
1632 xFixedHyperlink->addActionListener( &maActionListeners );
1635 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1637 maActionListeners.addInterface( l );
1638 if( getPeer().is() && maActionListeners.getLength() == 1 )
1640 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1641 xFixedHyperlink->addActionListener( &maActionListeners );
1645 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1647 if( getPeer().is() && maActionListeners.getLength() == 1 )
1649 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1650 xFixedHyperlink->removeActionListener( &maActionListeners );
1652 maActionListeners.removeInterface( l );
1655 // ----------------------------------------------------
1656 // class UnoControlFixedTextModel
1657 // ----------------------------------------------------
1658 UnoControlFixedTextModel::UnoControlFixedTextModel()
1660 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText );
1663 ::rtl::OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1665 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedTextModel );
1668 uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1670 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1672 uno::Any aAny;
1673 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedText );
1674 return aAny;
1676 else if ( nPropId == BASEPROPERTY_BORDER )
1678 uno::Any aAny;
1679 aAny <<= (sal_Int16)0;
1680 return aAny;
1683 return UnoControlModel::ImplGetDefaultValue( nPropId );
1686 ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper()
1688 static UnoPropertyArrayHelper* pHelper = NULL;
1689 if ( !pHelper )
1691 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1692 pHelper = new UnoPropertyArrayHelper( aIDs );
1694 return *pHelper;
1697 // beans::XMultiPropertySet
1698 uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1700 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1701 return xInfo;
1705 // ----------------------------------------------------
1706 // class UnoFixedTextControl
1707 // ----------------------------------------------------
1708 UnoFixedTextControl::UnoFixedTextControl()
1710 maComponentInfos.nWidth = 100;
1711 maComponentInfos.nHeight = 12;
1714 ::rtl::OUString UnoFixedTextControl::GetComponentServiceName()
1716 return ::rtl::OUString::createFromAscii( "fixedtext" );
1719 // uno::XInterface
1720 uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1722 uno::Any aRet = ::cppu::queryInterface( rType,
1723 SAL_STATIC_CAST( awt::XFixedText*, this ),
1724 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1725 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1728 // lang::XTypeProvider
1729 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl )
1730 getCppuType( ( uno::Reference< awt::XFixedText>* ) NULL ),
1731 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
1732 UnoControlBase::getTypes()
1733 IMPL_XTYPEPROVIDER_END
1735 sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException)
1737 return sal_True;
1740 void UnoFixedTextControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1742 uno::Any aAny;
1743 aAny <<= Text;
1744 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1747 ::rtl::OUString UnoFixedTextControl::getText() throw(uno::RuntimeException)
1749 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1752 void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1754 uno::Any aAny;
1755 aAny <<= (sal_Int16)nAlign;
1756 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1759 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException)
1761 short nAlign = 0;
1762 if ( mxModel.is() )
1764 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1765 aVal >>= nAlign;
1767 return nAlign;
1770 awt::Size UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException)
1772 return Impl_getMinimumSize();
1775 awt::Size UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException)
1777 return Impl_getPreferredSize();
1780 awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1782 return Impl_calcAdjustedSize( rNewSize );
1785 // ----------------------------------------------------
1786 // class UnoControlGroupBoxModel
1787 // ----------------------------------------------------
1788 UnoControlGroupBoxModel::UnoControlGroupBoxModel()
1790 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
1791 ImplRegisterProperty( BASEPROPERTY_ENABLED );
1792 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
1793 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
1794 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
1795 ImplRegisterProperty( BASEPROPERTY_HELPURL );
1796 ImplRegisterProperty( BASEPROPERTY_LABEL );
1797 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
1798 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
1799 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
1802 ::rtl::OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1804 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel );
1807 uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1809 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1811 uno::Any aAny;
1812 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox );
1813 return aAny;
1815 return UnoControlModel::ImplGetDefaultValue( nPropId );
1818 ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper()
1820 static UnoPropertyArrayHelper* pHelper = NULL;
1821 if ( !pHelper )
1823 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1824 pHelper = new UnoPropertyArrayHelper( aIDs );
1826 return *pHelper;
1829 // beans::XMultiPropertySet
1830 uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1832 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1833 return xInfo;
1836 // ----------------------------------------------------
1837 // class UnoGroupBoxControl
1838 // ----------------------------------------------------
1839 UnoGroupBoxControl::UnoGroupBoxControl()
1841 maComponentInfos.nWidth = 100;
1842 maComponentInfos.nHeight = 100;
1845 ::rtl::OUString UnoGroupBoxControl::GetComponentServiceName()
1847 return ::rtl::OUString::createFromAscii( "groupbox" );
1850 sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException)
1852 return sal_True;
1855 // MultiPage
1857 UnoMultiPageModel::UnoMultiPageModel()
1859 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
1860 ImplRegisterProperty( BASEPROPERTY_ENABLED );
1861 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
1862 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
1863 ImplRegisterProperty( BASEPROPERTY_HELPURL );
1864 ImplRegisterProperty( BASEPROPERTY_LABEL );
1865 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
1866 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
1867 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
1870 ::rtl::OUString UnoMultiPageModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1872 return ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel );
1875 uno::Any UnoMultiPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1877 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1879 uno::Any aAny;
1880 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox );
1881 //aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageControl );
1882 return aAny;
1884 return UnoControlModel::ImplGetDefaultValue( nPropId );
1887 ::cppu::IPropertyArrayHelper& UnoMultiPageModel::getInfoHelper()
1889 static UnoPropertyArrayHelper* pHelper = NULL;
1890 if ( !pHelper )
1892 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1893 pHelper = new UnoPropertyArrayHelper( aIDs );
1895 return *pHelper;
1898 // beans::XMultiPropertySet
1899 uno::Reference< beans::XPropertySetInfo > UnoMultiPageModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1901 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1902 return xInfo;
1905 // ----------------------------------------------------
1906 // class MultiPageControl
1907 // ----------------------------------------------------
1908 UnoMultiPageControl::UnoMultiPageControl()
1910 maComponentInfos.nWidth = 100;
1911 maComponentInfos.nHeight = 100;
1914 ::rtl::OUString UnoMultiPageControl::GetComponentServiceName()
1916 return ::rtl::OUString::createFromAscii( "multipage" );
1919 sal_Bool UnoMultiPageControl::isTransparent() throw(uno::RuntimeException)
1921 return sal_True;
1926 // ----------------------------------------------------
1927 // class UnoControlListBoxModel
1928 // ----------------------------------------------------
1929 UnoControlListBoxModel::UnoControlListBoxModel()
1931 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox );
1934 ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1936 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel );
1939 uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1941 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1943 uno::Any aAny;
1944 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBox );
1945 return aAny;
1947 return UnoControlModel::ImplGetDefaultValue( nPropId );
1950 ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper()
1952 static UnoPropertyArrayHelper* pHelper = NULL;
1953 if ( !pHelper )
1955 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1956 pHelper = new UnoPropertyArrayHelper( aIDs );
1958 return *pHelper;
1961 // beans::XMultiPropertySet
1962 uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
1964 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1965 return xInfo;
1968 void UnoControlListBoxModel::ImplPropertyChanged( sal_uInt16 nPropId )
1970 if ( nPropId == BASEPROPERTY_STRINGITEMLIST )
1972 uno::Sequence<sal_Int16> aSeq;
1973 uno::Any aAny;
1974 aAny <<= aSeq;
1975 setPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny );
1978 UnoControlModel::ImplPropertyChanged( nPropId );
1981 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
1982 uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(())
1984 // dependencies we know:
1985 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
1986 ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS );
1988 UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
1991 // ----------------------------------------------------
1992 // class UnoListBoxControl
1993 // ----------------------------------------------------
1994 UnoListBoxControl::UnoListBoxControl()
1995 : maActionListeners( *this ),
1996 maItemListeners( *this )
1998 maComponentInfos.nWidth = 100;
1999 maComponentInfos.nHeight = 12;
2002 ::rtl::OUString UnoListBoxControl::GetComponentServiceName()
2004 return ::rtl::OUString::createFromAscii( "listbox" );
2007 // uno::XInterface
2008 uno::Any UnoListBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2010 uno::Any aRet = ::cppu::queryInterface( rType,
2011 SAL_STATIC_CAST( awt::XListBox*, this ),
2012 SAL_STATIC_CAST( awt::XItemListener*, this ),
2013 SAL_STATIC_CAST( lang::XEventListener*, SAL_STATIC_CAST( awt::XItemListener*, this ) ),
2014 SAL_STATIC_CAST( awt::XLayoutConstrains*, this ),
2015 SAL_STATIC_CAST( awt::XTextLayoutConstrains*, this ) );
2016 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
2019 // lang::XTypeProvider
2020 IMPL_XTYPEPROVIDER_START( UnoListBoxControl )
2021 getCppuType( ( uno::Reference< awt::XListBox>* ) NULL ),
2022 getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ),
2023 getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
2024 getCppuType( ( uno::Reference< awt::XTextLayoutConstrains>* ) NULL ),
2025 UnoControlBase::getTypes()
2026 IMPL_XTYPEPROVIDER_END
2028 void UnoListBoxControl::dispose() throw(uno::RuntimeException)
2030 lang::EventObject aEvt;
2031 aEvt.Source = (::cppu::OWeakObject*)this;
2032 maActionListeners.disposeAndClear( aEvt );
2033 maItemListeners.disposeAndClear( aEvt );
2034 UnoControl::dispose();
2037 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2039 if ( getPeer().is() )
2041 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2042 DBG_ASSERT( xListBox.is(), "XListBox?" );
2044 uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos();
2045 uno::Any aAny;
2046 aAny <<= aSeq;
2047 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, sal_False );
2051 void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
2053 UnoControl::ImplSetPeerProperty( rPropName, rVal );
2055 // Wenn die SelectedItems vor der StringItemList gesetzt werden,
2056 // hat das keine Auswirkung...
2057 if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
2059 ::rtl::OUString aSelPropName = GetPropertyName( BASEPROPERTY_SELECTEDITEMS );
2060 uno::Any aVal = ImplGetPropertyValue( aSelPropName );
2061 if ( !( aVal.getValueType().getTypeClass() == uno::TypeClass_VOID ) )
2063 uno::Reference< awt::XVclWindowPeer > xW( getPeer(), uno::UNO_QUERY );
2064 if (xW.is())
2065 // same comment as in UnoControl::ImplSetPeerProperty - see there
2066 xW->setProperty( aSelPropName, aVal );
2071 void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2073 UnoControl::createPeer( rxToolkit, rParentPeer );
2075 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2076 xListBox->addItemListener( this );
2078 if ( maActionListeners.getLength() )
2079 xListBox->addActionListener( &maActionListeners );
2082 void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2084 maActionListeners.addInterface( l );
2085 if( getPeer().is() && maActionListeners.getLength() == 1 )
2087 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2088 xListBox->addActionListener( &maActionListeners );
2092 void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2094 if( getPeer().is() && maActionListeners.getLength() == 1 )
2096 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2097 xListBox->removeActionListener( &maActionListeners );
2099 maActionListeners.removeInterface( l );
2102 void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2104 maItemListeners.addInterface( l );
2107 void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2109 maItemListeners.removeInterface( l );
2112 void UnoListBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
2114 uno::Sequence< ::rtl::OUString> aSeq( 1 );
2115 aSeq.getArray()[0] = aItem;
2116 addItems( aSeq, nPos );
2119 void UnoListBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
2121 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2122 uno::Sequence< ::rtl::OUString> aSeq;
2123 aVal >>= aSeq;
2124 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2125 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2126 sal_uInt16 nNewLen = nOldLen + nNewItems;
2128 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2129 ::rtl::OUString* pNewData = aNewSeq.getArray();
2130 ::rtl::OUString* pOldData = aSeq.getArray();
2132 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2133 nPos = (sal_uInt16) nOldLen;
2135 sal_uInt16 n;
2136 // Items vor der Einfuege-Position
2137 for ( n = 0; n < nPos; n++ )
2138 pNewData[n] = pOldData[n];
2140 // Neue Items
2141 for ( n = 0; n < nNewItems; n++ )
2142 pNewData[nPos+n] = aItems.getConstArray()[n];
2144 // Rest der alten Items
2145 for ( n = nPos; n < nOldLen; n++ )
2146 pNewData[nNewItems+n] = pOldData[n];
2148 uno::Any aAny;
2149 aAny <<= aNewSeq;
2150 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2153 void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
2155 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2156 uno::Sequence< ::rtl::OUString> aSeq;
2157 aVal >>= aSeq;
2158 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2159 if ( nOldLen && ( nPos < nOldLen ) )
2161 if ( nCount > ( nOldLen-nPos ) )
2162 nCount = nOldLen-nPos;
2164 sal_uInt16 nNewLen = nOldLen - nCount;
2166 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2167 ::rtl::OUString* pNewData = aNewSeq.getArray();
2168 ::rtl::OUString* pOldData = aSeq.getArray();
2170 sal_uInt16 n;
2171 // Items vor der Entfern-Position
2172 for ( n = 0; n < nPos; n++ )
2173 pNewData[n] = pOldData[n];
2175 // Rest der Items
2176 for ( n = nPos; n < (nOldLen-nCount); n++ )
2177 pNewData[n] = pOldData[n+nCount];
2179 uno::Any aAny;
2180 aAny <<= aNewSeq;
2181 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2185 sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException)
2187 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2188 uno::Sequence< ::rtl::OUString> aSeq;
2189 aVal >>= aSeq;
2190 return (sal_Int16)aSeq.getLength();
2193 ::rtl::OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
2195 ::rtl::OUString aItem;
2196 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2197 uno::Sequence< ::rtl::OUString> aSeq;
2198 aVal >>= aSeq;
2199 if ( nPos < aSeq.getLength() )
2200 aItem = aSeq.getConstArray()[nPos];
2201 return aItem;
2204 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException)
2206 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2207 uno::Sequence< ::rtl::OUString> aSeq;
2208 aVal >>= aSeq;
2209 return aSeq;
2212 sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException)
2214 sal_Int16 n = -1;
2215 if ( getPeer().is() )
2217 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2218 n = xListBox->getSelectedItemPos();
2220 return n;
2223 uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException)
2225 uno::Sequence<sal_Int16> aSeq;
2226 if ( getPeer().is() )
2228 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2229 aSeq = xListBox->getSelectedItemsPos();
2231 return aSeq;
2234 ::rtl::OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException)
2236 ::rtl::OUString aItem;
2237 if ( getPeer().is() )
2239 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2240 aItem = xListBox->getSelectedItem();
2242 return aItem;
2245 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException)
2247 uno::Sequence< ::rtl::OUString> aSeq;
2248 if ( getPeer().is() )
2250 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2251 aSeq = xListBox->getSelectedItems();
2253 return aSeq;
2256 void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException)
2258 if ( getPeer().is() )
2260 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2261 xListBox->selectItemPos( nPos, bSelect );
2263 ImplUpdateSelectedItemsProperty();
2266 void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException)
2268 if ( getPeer().is() )
2270 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2271 xListBox->selectItemsPos( aPositions, bSelect );
2273 ImplUpdateSelectedItemsProperty();
2276 void UnoListBoxControl::selectItem( const ::rtl::OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException)
2278 if ( getPeer().is() )
2280 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2281 xListBox->selectItem( aItem, bSelect );
2283 ImplUpdateSelectedItemsProperty();
2286 void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException)
2288 if ( getPeer().is() )
2290 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2291 xListBox->makeVisible( nEntry );
2295 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
2297 uno::Any aAny;
2298 aAny <<= (sal_Int16)nLines;
2299 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
2302 sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
2304 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
2307 sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException)
2309 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION );
2312 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException)
2314 uno::Any aAny;
2315 aAny <<= bMulti;
2316 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, sal_True );
2319 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
2321 ImplUpdateSelectedItemsProperty();
2322 if ( maItemListeners.getLength() )
2326 maItemListeners.itemStateChanged( rEvent );
2328 catch( const Exception& e )
2330 #if OSL_DEBUG_LEVEL == 0
2331 (void) e; // suppress warning
2332 #else
2333 ::rtl::OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2334 sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
2335 OSL_ENSURE( sal_False, sMessage.getStr() );
2336 #endif
2341 awt::Size UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException)
2343 return Impl_getMinimumSize();
2346 awt::Size UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException)
2348 return Impl_getPreferredSize();
2351 awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
2353 return Impl_calcAdjustedSize( rNewSize );
2356 awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
2358 return Impl_getMinimumSize( nCols, nLines );
2361 void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
2363 Impl_getColumnsAndLines( nCols, nLines );
2366 // ----------------------------------------------------
2367 // class UnoControlComboBoxModel
2368 // ----------------------------------------------------
2369 UnoControlComboBoxModel::UnoControlComboBoxModel()
2371 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox );
2374 ::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2376 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel );
2379 uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2381 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2383 uno::Any aAny;
2384 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox );
2385 return aAny;
2387 return UnoControlModel::ImplGetDefaultValue( nPropId );
2391 ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper()
2393 static UnoPropertyArrayHelper* pHelper = NULL;
2394 if ( !pHelper )
2396 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2397 pHelper = new UnoPropertyArrayHelper( aIDs );
2399 return *pHelper;
2402 // beans::XMultiPropertySet
2403 uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2405 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2406 return xInfo;
2411 // ----------------------------------------------------
2412 // class UnoComboBoxControl
2413 // ----------------------------------------------------
2414 UnoComboBoxControl::UnoComboBoxControl()
2415 : maActionListeners( *this ),
2416 maItemListeners( *this )
2418 maComponentInfos.nWidth = 100;
2419 maComponentInfos.nHeight = 12;
2422 ::rtl::OUString UnoComboBoxControl::GetComponentServiceName()
2424 return ::rtl::OUString::createFromAscii( "combobox" );
2427 // uno::XInterface
2428 uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2430 uno::Any aRet = ::cppu::queryInterface( rType,
2431 SAL_STATIC_CAST( awt::XComboBox*, this ) );
2432 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
2435 // lang::XTypeProvider
2436 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl )
2437 getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ),
2438 UnoEditControl::getTypes()
2439 IMPL_XTYPEPROVIDER_END
2441 void UnoComboBoxControl::dispose() throw(uno::RuntimeException)
2443 lang::EventObject aEvt;
2444 aEvt.Source = (::cppu::OWeakObject*)this;
2445 maActionListeners.disposeAndClear( aEvt );
2446 maItemListeners.disposeAndClear( aEvt );
2447 UnoControl::dispose();
2450 void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2452 UnoEditControl::createPeer( rxToolkit, rParentPeer );
2454 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2455 if ( maActionListeners.getLength() )
2456 xComboBox->addActionListener( &maActionListeners );
2457 if ( maItemListeners.getLength() )
2458 xComboBox->addItemListener( &maItemListeners );
2461 void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2463 maActionListeners.addInterface( l );
2464 if( getPeer().is() && maActionListeners.getLength() == 1 )
2466 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2467 xComboBox->addActionListener( &maActionListeners );
2471 void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2473 if( getPeer().is() && maActionListeners.getLength() == 1 )
2475 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2476 xComboBox->removeActionListener( &maActionListeners );
2478 maActionListeners.removeInterface( l );
2481 void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2483 maItemListeners.addInterface( l );
2484 if( getPeer().is() && maItemListeners.getLength() == 1 )
2486 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
2487 xComboBox->addItemListener( &maItemListeners );
2491 void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2493 if( getPeer().is() && maItemListeners.getLength() == 1 )
2495 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY ); // MT: Mal alles so umstellen, schoener als Ref anlegen und query rufen
2496 xComboBox->removeItemListener( &maItemListeners );
2498 maItemListeners.removeInterface( l );
2501 void UnoComboBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
2503 uno::Sequence< ::rtl::OUString> aSeq( 1 );
2504 aSeq.getArray()[0] = aItem;
2505 addItems( aSeq, nPos );
2508 void UnoComboBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
2510 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2511 uno::Sequence< ::rtl::OUString> aSeq;
2512 aVal >>= aSeq;
2513 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2514 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2515 sal_uInt16 nNewLen = nOldLen + nNewItems;
2517 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2518 ::rtl::OUString* pNewData = aNewSeq.getArray();
2519 const ::rtl::OUString* pOldData = aSeq.getConstArray();
2521 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2522 nPos = (sal_uInt16) nOldLen;
2524 sal_uInt16 n;
2525 // Items vor der Einfuege-Position
2526 for ( n = 0; n < nPos; n++ )
2527 pNewData[n] = pOldData[n];
2529 // Neue Items
2530 for ( n = 0; n < nNewItems; n++ )
2531 pNewData[nPos+n] = aItems.getConstArray()[n];
2533 // Rest der alten Items
2534 for ( n = nPos; n < nOldLen; n++ )
2535 pNewData[nNewItems+n] = pOldData[n];
2537 uno::Any aAny;
2538 aAny <<= aNewSeq;
2539 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2542 void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
2544 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2545 uno::Sequence< ::rtl::OUString> aSeq;
2546 aVal >>= aSeq;
2547 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2548 if ( nOldLen && ( nPos < nOldLen ) )
2550 if ( nCount > ( nOldLen-nPos ) )
2551 nCount = nOldLen-nPos;
2553 sal_uInt16 nNewLen = nOldLen - nCount;
2555 uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2556 ::rtl::OUString* pNewData = aNewSeq.getArray();
2557 ::rtl::OUString* pOldData = aSeq.getArray();
2559 sal_uInt16 n;
2560 // Items vor der Entfern-Position
2561 for ( n = 0; n < nPos; n++ )
2562 pNewData[n] = pOldData[n];
2564 // Rest der Items
2565 for ( n = nPos; n < (nOldLen-nCount); n++ )
2566 pNewData[n] = pOldData[n+nCount];
2568 uno::Any aAny;
2569 aAny <<= aNewSeq;
2570 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2574 sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException)
2576 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2577 uno::Sequence< ::rtl::OUString> aSeq;
2578 aVal >>= aSeq;
2579 return (sal_Int16)aSeq.getLength();
2582 ::rtl::OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
2584 ::rtl::OUString aItem;
2585 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2586 uno::Sequence< ::rtl::OUString> aSeq;
2587 aVal >>= aSeq;
2588 if ( nPos < aSeq.getLength() )
2589 aItem = aSeq.getConstArray()[nPos];
2590 return aItem;
2593 uno::Sequence< ::rtl::OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException)
2595 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2596 uno::Sequence< ::rtl::OUString> aSeq;
2597 aVal >>= aSeq;
2598 return aSeq;
2601 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
2603 uno::Any aAny;
2604 aAny <<= nLines;
2605 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
2608 sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
2610 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
2614 // ----------------------------------------------------
2615 // UnoSpinFieldControl
2616 // ----------------------------------------------------
2617 UnoSpinFieldControl::UnoSpinFieldControl() : maSpinListeners( *this )
2619 mbRepeat = sal_False;
2622 // uno::XInterface
2623 uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2625 uno::Any aRet = ::cppu::queryInterface( rType,
2626 SAL_STATIC_CAST( awt::XSpinField*, this ) );
2627 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
2630 // lang::XTypeProvider
2631 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl )
2632 getCppuType( ( uno::Reference< awt::XSpinField>* ) NULL ),
2633 UnoEditControl::getTypes()
2634 IMPL_XTYPEPROVIDER_END
2636 void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2638 UnoEditControl::createPeer( rxToolkit, rParentPeer );
2640 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2641 xField->enableRepeat( mbRepeat );
2642 if ( maSpinListeners.getLength() )
2643 xField->addSpinListener( &maSpinListeners );
2646 // ::com::sun::star::awt::XSpinField
2647 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
2649 maSpinListeners.addInterface( l );
2650 if( getPeer().is() && maSpinListeners.getLength() == 1 )
2652 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2653 xField->addSpinListener( &maSpinListeners );
2657 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
2659 if( getPeer().is() && maSpinListeners.getLength() == 1 )
2661 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2662 xField->removeSpinListener( &maSpinListeners );
2664 maSpinListeners.removeInterface( l );
2667 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException)
2669 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2670 if ( xField.is() )
2671 xField->up();
2674 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException)
2676 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2677 if ( xField.is() )
2678 xField->down();
2681 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException)
2683 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2684 if ( xField.is() )
2685 xField->first();
2688 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException)
2690 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2691 if ( xField.is() )
2692 xField->last();
2695 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException)
2697 mbRepeat = bRepeat;
2699 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
2700 if ( xField.is() )
2701 xField->enableRepeat( bRepeat );
2704 // ----------------------------------------------------
2705 // class UnoControlDateFieldModel
2706 // ----------------------------------------------------
2707 UnoControlDateFieldModel::UnoControlDateFieldModel()
2709 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField );
2712 ::rtl::OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2714 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateFieldModel );
2717 uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2719 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2721 uno::Any aAny;
2722 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateField );
2723 return aAny;
2725 return UnoControlModel::ImplGetDefaultValue( nPropId );
2729 ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper()
2731 static UnoPropertyArrayHelper* pHelper = NULL;
2732 if ( !pHelper )
2734 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2735 pHelper = new UnoPropertyArrayHelper( aIDs );
2737 return *pHelper;
2740 // beans::XMultiPropertySet
2741 uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2743 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2744 return xInfo;
2749 // ----------------------------------------------------
2750 // class UnoDateFieldControl
2751 // ----------------------------------------------------
2752 UnoDateFieldControl::UnoDateFieldControl()
2754 mnFirst = Date( 1, 1, 1900 ).GetDate();
2755 mnLast = Date( 31, 12, 2200 ).GetDate();
2756 mbLongFormat = 2;
2759 ::rtl::OUString UnoDateFieldControl::GetComponentServiceName()
2761 return ::rtl::OUString::createFromAscii( "datefield" );
2764 // uno::XInterface
2765 uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2767 uno::Any aRet = ::cppu::queryInterface( rType,
2768 SAL_STATIC_CAST( awt::XDateField*, this ) );
2769 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
2772 // lang::XTypeProvider
2773 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl )
2774 getCppuType( ( uno::Reference< awt::XDateField>* ) NULL ),
2775 UnoSpinFieldControl::getTypes()
2776 IMPL_XTYPEPROVIDER_END
2778 void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
2780 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
2782 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2783 xField->setFirst( mnFirst );
2784 xField->setLast( mnLast );
2785 if ( mbLongFormat != 2 ) // not set
2786 xField->setLongFormat( mbLongFormat );
2790 void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
2792 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
2794 // also change the text property (#i25106#)
2795 if ( xPeer.is() )
2797 ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
2798 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
2801 // re-calc the Date property
2802 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2803 uno::Any aValue;
2804 if ( xField->isEmpty() )
2806 // the field says it's empty
2807 sal_Bool bEnforceFormat = sal_True;
2808 if ( xPeer.is() )
2809 xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat;
2810 if ( !bEnforceFormat )
2812 // and it also says that it is currently accepting invalid inputs, without
2813 // forcing it to a valid date
2814 uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY );
2815 if ( xText.is() && xText->getText().getLength() )
2816 // and in real, the text of the peer is *not* empty
2817 // -> simulate an invalid date, which is different from "no date"
2818 aValue <<= util::Date( 0, 0, 0 );
2821 else
2822 aValue <<= xField->getDate();
2824 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, sal_False );
2826 // multiplex the event
2827 if ( GetTextListeners().getLength() )
2828 GetTextListeners().textChanged( e );
2831 void UnoDateFieldControl::setDate( sal_Int32 Date ) throw(uno::RuntimeException)
2833 uno::Any aAny;
2834 aAny <<= Date;
2835 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, sal_True );
2838 sal_Int32 UnoDateFieldControl::getDate() throw(uno::RuntimeException)
2840 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE );
2843 void UnoDateFieldControl::setMin( sal_Int32 Date ) throw(uno::RuntimeException)
2845 uno::Any aAny;
2846 aAny <<= Date;
2847 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, sal_True );
2850 sal_Int32 UnoDateFieldControl::getMin() throw(uno::RuntimeException)
2852 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN );
2855 void UnoDateFieldControl::setMax( sal_Int32 Date ) throw(uno::RuntimeException)
2857 uno::Any aAny;
2858 aAny <<= Date;
2859 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, sal_True );
2862 sal_Int32 UnoDateFieldControl::getMax() throw(uno::RuntimeException)
2864 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX );
2867 void UnoDateFieldControl::setFirst( sal_Int32 Date ) throw(uno::RuntimeException)
2869 mnFirst = Date;
2870 if ( getPeer().is() )
2872 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2873 xField->setFirst( Date );
2877 sal_Int32 UnoDateFieldControl::getFirst() throw(uno::RuntimeException)
2879 return mnFirst;
2882 void UnoDateFieldControl::setLast( sal_Int32 Date ) throw(uno::RuntimeException)
2884 mnLast = Date;
2885 if ( getPeer().is() )
2887 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2888 xField->setLast( Date );
2892 sal_Int32 UnoDateFieldControl::getLast() throw(uno::RuntimeException)
2894 return mnLast;
2897 void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException)
2899 mbLongFormat = bLong;
2900 if ( getPeer().is() )
2902 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2903 xField->setLongFormat( bLong );
2907 sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException)
2909 return ( mbLongFormat != 2 ) ? mbLongFormat : sal_False;
2912 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException)
2914 if ( getPeer().is() )
2916 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2917 xField->setEmpty();
2921 sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException)
2923 sal_Bool bEmpty = sal_False;
2924 if ( getPeer().is() )
2926 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
2927 bEmpty = xField->isEmpty();
2929 return bEmpty;
2932 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
2934 uno::Any aAny;
2935 aAny <<= bStrict;
2936 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
2939 sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException)
2941 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
2944 // ----------------------------------------------------
2945 // class UnoControlTimeFieldModel
2946 // ----------------------------------------------------
2947 UnoControlTimeFieldModel::UnoControlTimeFieldModel()
2949 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField );
2952 ::rtl::OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2954 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel );
2957 uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2959 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2961 uno::Any aAny;
2962 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeField );
2963 return aAny;
2965 return UnoControlModel::ImplGetDefaultValue( nPropId );
2969 ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper()
2971 static UnoPropertyArrayHelper* pHelper = NULL;
2972 if ( !pHelper )
2974 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2975 pHelper = new UnoPropertyArrayHelper( aIDs );
2977 return *pHelper;
2980 // beans::XMultiPropertySet
2981 uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
2983 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2984 return xInfo;
2989 // ----------------------------------------------------
2990 // class UnoTimeFieldControl
2991 // ----------------------------------------------------
2992 UnoTimeFieldControl::UnoTimeFieldControl()
2994 mnFirst = Time( 0, 0 ).GetTime();
2995 mnLast = Time( 23, 59, 59, 99 ).GetTime();
2998 ::rtl::OUString UnoTimeFieldControl::GetComponentServiceName()
3000 return ::rtl::OUString::createFromAscii( "timefield" );
3003 // uno::XInterface
3004 uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3006 uno::Any aRet = ::cppu::queryInterface( rType,
3007 SAL_STATIC_CAST( awt::XTimeField*, this ) );
3008 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3011 // lang::XTypeProvider
3012 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl )
3013 getCppuType( ( uno::Reference< awt::XTimeField>* ) NULL ),
3014 UnoSpinFieldControl::getTypes()
3015 IMPL_XTYPEPROVIDER_END
3017 void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3019 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3021 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3022 xField->setFirst( mnFirst );
3023 xField->setLast( mnLast );
3026 void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3028 // also change the text property (#i25106#)
3029 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
3030 ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
3031 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
3033 // re-calc the Time property
3034 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3035 uno::Any aValue;
3036 if ( !xField->isEmpty() )
3037 aValue <<= xField->getTime();
3038 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, sal_False );
3040 // multiplex the event
3041 if ( GetTextListeners().getLength() )
3042 GetTextListeners().textChanged( e );
3045 void UnoTimeFieldControl::setTime( sal_Int32 Time ) throw(uno::RuntimeException)
3047 uno::Any aAny;
3048 aAny <<= Time;
3049 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, sal_True );
3052 sal_Int32 UnoTimeFieldControl::getTime() throw(uno::RuntimeException)
3054 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME );
3057 void UnoTimeFieldControl::setMin( sal_Int32 Time ) throw(uno::RuntimeException)
3059 uno::Any aAny;
3060 aAny <<= Time;
3061 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, sal_True );
3064 sal_Int32 UnoTimeFieldControl::getMin() throw(uno::RuntimeException)
3066 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN );
3069 void UnoTimeFieldControl::setMax( sal_Int32 Time ) throw(uno::RuntimeException)
3071 uno::Any aAny;
3072 aAny <<= Time;
3073 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, sal_True );
3076 sal_Int32 UnoTimeFieldControl::getMax() throw(uno::RuntimeException)
3078 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX );
3081 void UnoTimeFieldControl::setFirst( sal_Int32 Time ) throw(uno::RuntimeException)
3083 mnFirst = Time;
3084 if ( getPeer().is() )
3086 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3087 xField->setFirst( mnFirst );
3091 sal_Int32 UnoTimeFieldControl::getFirst() throw(uno::RuntimeException)
3093 return mnFirst;
3096 void UnoTimeFieldControl::setLast( sal_Int32 Time ) throw(uno::RuntimeException)
3098 mnLast = Time;
3099 if ( getPeer().is() )
3101 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3102 xField->setFirst( mnLast );
3106 sal_Int32 UnoTimeFieldControl::getLast() throw(uno::RuntimeException)
3108 return mnLast;
3111 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException)
3113 if ( getPeer().is() )
3115 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3116 xField->setEmpty();
3120 sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException)
3122 sal_Bool bEmpty = sal_False;
3123 if ( getPeer().is() )
3125 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3126 bEmpty = xField->isEmpty();
3128 return bEmpty;
3131 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3133 uno::Any aAny;
3134 aAny <<= bStrict;
3135 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3138 sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException)
3140 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3143 // ----------------------------------------------------
3144 // class UnoControlNumericFieldModel
3145 // ----------------------------------------------------
3146 UnoControlNumericFieldModel::UnoControlNumericFieldModel()
3148 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField );
3151 ::rtl::OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3153 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel );
3156 uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3158 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3160 uno::Any aAny;
3161 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericField );
3162 return aAny;
3164 return UnoControlModel::ImplGetDefaultValue( nPropId );
3168 ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper()
3170 static UnoPropertyArrayHelper* pHelper = NULL;
3171 if ( !pHelper )
3173 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3174 pHelper = new UnoPropertyArrayHelper( aIDs );
3176 return *pHelper;
3179 // beans::XMultiPropertySet
3180 uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3182 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3183 return xInfo;
3188 // ----------------------------------------------------
3189 // class UnoNumericFieldControl
3190 // ----------------------------------------------------
3191 UnoNumericFieldControl::UnoNumericFieldControl()
3193 mnFirst = 0;
3194 mnLast = 0x7FFFFFFF;
3197 ::rtl::OUString UnoNumericFieldControl::GetComponentServiceName()
3199 return ::rtl::OUString::createFromAscii( "numericfield" );
3202 // uno::XInterface
3203 uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3205 uno::Any aRet = ::cppu::queryInterface( rType,
3206 SAL_STATIC_CAST( awt::XNumericField*, this ) );
3207 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3210 // lang::XTypeProvider
3211 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl )
3212 getCppuType( ( uno::Reference< awt::XNumericField>* ) NULL ),
3213 UnoSpinFieldControl::getTypes()
3214 IMPL_XTYPEPROVIDER_END
3216 void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3218 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3220 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3221 xField->setFirst( mnFirst );
3222 xField->setLast( mnLast );
3226 void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3228 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3229 uno::Any aAny;
3230 aAny <<= xField->getValue();
3231 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3233 if ( GetTextListeners().getLength() )
3234 GetTextListeners().textChanged( e );
3237 void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3239 uno::Any aAny;
3240 aAny <<= Value;
3241 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3244 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException)
3246 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3249 void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3251 uno::Any aAny;
3252 aAny <<= Value;
3253 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3256 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException)
3258 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3261 void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3263 uno::Any aAny;
3264 aAny <<= Value;
3265 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3268 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException)
3270 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3273 void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3275 mnFirst = Value;
3276 if ( getPeer().is() )
3278 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3279 xField->setFirst( mnFirst );
3283 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException)
3285 return mnFirst;
3288 void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException)
3290 mnLast = Value;
3291 if ( getPeer().is() )
3293 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3294 xField->setLast( mnLast );
3298 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException)
3300 return mnLast;
3303 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3305 uno::Any aAny;
3306 aAny <<= bStrict;
3307 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3310 sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException)
3312 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3315 void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
3317 uno::Any aAny;
3318 aAny <<= Digits;
3319 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
3322 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException)
3324 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
3327 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
3329 uno::Any aAny;
3330 aAny <<= Digits;
3331 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
3334 sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException)
3336 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
3339 // ----------------------------------------------------
3340 // class UnoControlCurrencyFieldModel
3341 // ----------------------------------------------------
3342 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel()
3344 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField );
3347 ::rtl::OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3349 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel );
3352 uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3354 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3356 uno::Any aAny;
3357 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyField );
3358 return aAny;
3360 if ( nPropId == BASEPROPERTY_CURSYM_POSITION )
3362 uno::Any aAny;
3363 aAny <<= (sal_Bool)sal_False;
3364 return aAny;
3367 return UnoControlModel::ImplGetDefaultValue( nPropId );
3370 ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper()
3372 static UnoPropertyArrayHelper* pHelper = NULL;
3373 if ( !pHelper )
3375 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3376 pHelper = new UnoPropertyArrayHelper( aIDs );
3378 return *pHelper;
3381 // beans::XMultiPropertySet
3382 uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3384 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3385 return xInfo;
3388 // ----------------------------------------------------
3389 // class UnoCurrencyFieldControl
3390 // ----------------------------------------------------
3391 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
3393 mnFirst = 0;
3394 mnLast = 0x7FFFFFFF;
3397 ::rtl::OUString UnoCurrencyFieldControl::GetComponentServiceName()
3399 return ::rtl::OUString::createFromAscii( "longcurrencyfield" );
3402 // uno::XInterface
3403 uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3405 uno::Any aRet = ::cppu::queryInterface( rType,
3406 SAL_STATIC_CAST( awt::XCurrencyField*, this ) );
3407 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3410 // lang::XTypeProvider
3411 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl )
3412 getCppuType( ( uno::Reference< awt::XCurrencyField>* ) NULL ),
3413 UnoSpinFieldControl::getTypes()
3414 IMPL_XTYPEPROVIDER_END
3416 void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException)
3418 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3420 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3421 xField->setFirst( mnFirst );
3422 xField->setLast( mnLast );
3425 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3427 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3428 uno::Any aAny;
3429 aAny <<= xField->getValue();
3430 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3432 if ( GetTextListeners().getLength() )
3433 GetTextListeners().textChanged( e );
3436 void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3438 uno::Any aAny;
3439 aAny <<= Value;
3440 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3443 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException)
3445 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3448 void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3450 uno::Any aAny;
3451 aAny <<= Value;
3452 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3455 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException)
3457 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3460 void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3462 uno::Any aAny;
3463 aAny <<= Value;
3464 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3467 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException)
3469 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3472 void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3474 mnFirst = Value;
3475 if ( getPeer().is() )
3477 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3478 xField->setFirst( mnFirst );
3482 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException)
3484 return mnFirst;
3487 void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException)
3489 mnLast = Value;
3490 if ( getPeer().is() )
3492 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3493 xField->setLast( mnLast );
3497 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException)
3499 return mnLast;
3502 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3504 uno::Any aAny;
3505 aAny <<= bStrict;
3506 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3509 sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException)
3511 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3514 void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
3516 uno::Any aAny;
3517 aAny <<= Digits;
3518 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
3521 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException)
3523 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
3526 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
3528 uno::Any aAny;
3529 aAny <<= Digits;
3530 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
3533 sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException)
3535 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
3538 // ----------------------------------------------------
3539 // class UnoControlPatternFieldModel
3540 // ----------------------------------------------------
3541 UnoControlPatternFieldModel::UnoControlPatternFieldModel()
3543 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField );
3546 ::rtl::OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3548 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel );
3551 uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3553 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3555 uno::Any aAny;
3556 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternField );
3557 return aAny;
3559 return UnoControlModel::ImplGetDefaultValue( nPropId );
3562 ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper()
3564 static UnoPropertyArrayHelper* pHelper = NULL;
3565 if ( !pHelper )
3567 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3568 pHelper = new UnoPropertyArrayHelper( aIDs );
3570 return *pHelper;
3573 // beans::XMultiPropertySet
3574 uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3576 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3577 return xInfo;
3581 // ----------------------------------------------------
3582 // class UnoPatternFieldControl
3583 // ----------------------------------------------------
3584 UnoPatternFieldControl::UnoPatternFieldControl()
3588 ::rtl::OUString UnoPatternFieldControl::GetComponentServiceName()
3590 return ::rtl::OUString::createFromAscii( "patternfield" );
3593 void UnoPatternFieldControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
3595 sal_uInt16 nType = GetPropertyId( rPropName );
3596 if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) )
3598 // Die Masken koennen nicht nacheinander gesetzt werden.
3599 ::rtl::OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
3600 ::rtl::OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
3601 ::rtl::OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
3603 uno::Reference < awt::XPatternField > xPF( getPeer(), uno::UNO_QUERY );
3604 if (xPF.is())
3606 // same comment as in UnoControl::ImplSetPeerProperty - see there
3607 ::rtl::OUString sText( Text );
3608 if (( Text.getLength() > 0 ) &&
3609 ( Text.compareToAscii( "&", 1 ) == 0 ))
3611 // Magic symbol '&' found at first place. Interpret as a place
3612 // holder identifier. Now try to map it to the real value. The
3613 // magic symbol must be removed.
3614 rtl::OUString aKeyValue( Text.copy( 1 ));
3615 if ( UnoControl::ImplMapPlaceHolder( aKeyValue ))
3616 sText = aKeyValue;
3618 xPF->setString( sText );
3619 xPF->setMasks( EditMask, LiteralMask );
3622 else
3623 UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal );
3627 // uno::XInterface
3628 uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3630 uno::Any aRet = ::cppu::queryInterface( rType,
3631 SAL_STATIC_CAST( awt::XPatternField*, this ) );
3632 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3635 // lang::XTypeProvider
3636 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl )
3637 getCppuType( ( uno::Reference< awt::XPatternField>* ) NULL ),
3638 UnoSpinFieldControl::getTypes()
3639 IMPL_XTYPEPROVIDER_END
3641 void UnoPatternFieldControl::setString( const ::rtl::OUString& rString ) throw(uno::RuntimeException)
3643 setText( rString );
3646 ::rtl::OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException)
3648 return getText();
3651 void UnoPatternFieldControl::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
3653 uno::Any aAny;
3654 aAny <<= EditMask;
3655 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, sal_True );
3656 aAny <<= LiteralMask;
3657 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, sal_True );
3660 void UnoPatternFieldControl::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
3662 EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
3663 LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
3666 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3668 uno::Any aAny;
3669 aAny <<= bStrict;
3670 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3673 sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException)
3675 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3679 // ----------------------------------------------------
3680 // class UnoControlProgressBarModel
3681 // ----------------------------------------------------
3682 UnoControlProgressBarModel::UnoControlProgressBarModel()
3684 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
3685 ImplRegisterProperty( BASEPROPERTY_BORDER );
3686 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
3687 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
3688 ImplRegisterProperty( BASEPROPERTY_ENABLED );
3689 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
3690 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
3691 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
3692 ImplRegisterProperty( BASEPROPERTY_HELPURL );
3693 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
3694 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
3695 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
3696 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN );
3699 ::rtl::OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
3701 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBarModel );
3704 uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3706 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3708 uno::Any aAny;
3709 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBar );
3710 return aAny;
3713 return UnoControlModel::ImplGetDefaultValue( nPropId );
3716 ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper()
3718 static UnoPropertyArrayHelper* pHelper = NULL;
3719 if ( !pHelper )
3721 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3722 pHelper = new UnoPropertyArrayHelper( aIDs );
3724 return *pHelper;
3727 // beans::XMultiPropertySet
3728 uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3730 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3731 return xInfo;
3735 // ----------------------------------------------------
3736 // class UnoProgressBarControl
3737 // ----------------------------------------------------
3738 UnoProgressBarControl::UnoProgressBarControl()
3742 ::rtl::OUString UnoProgressBarControl::GetComponentServiceName()
3744 return ::rtl::OUString::createFromAscii( "ProgressBar" );
3747 // uno::XInterface
3748 uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3750 uno::Any aRet = ::cppu::queryInterface( rType,
3751 SAL_STATIC_CAST( awt::XProgressBar*, this ) );
3752 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
3755 // lang::XTypeProvider
3756 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl )
3757 getCppuType( ( uno::Reference< awt::XProgressBar>* ) NULL ),
3758 UnoControlBase::getTypes()
3759 IMPL_XTYPEPROVIDER_END
3761 // ::com::sun::star::awt::XProgressBar
3762 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
3764 uno::Any aAny;
3765 aAny <<= nColor;
3766 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, sal_True );
3769 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
3771 uno::Any aAny;
3772 aAny <<= nColor;
3773 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, sal_True );
3776 void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
3778 uno::Any aAny;
3779 aAny <<= nValue;
3780 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, sal_True );
3783 void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
3785 uno::Any aMin;
3786 uno::Any aMax;
3788 if ( nMin < nMax )
3790 // take correct min and max
3791 aMin <<= nMin;
3792 aMax <<= nMax;
3794 else
3796 // change min and max
3797 aMin <<= nMax;
3798 aMax <<= nMin;
3801 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, sal_True );
3802 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, sal_True );
3805 sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException)
3807 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE );
3811 // ----------------------------------------------------
3812 // class UnoControlFixedLineModel
3813 // ----------------------------------------------------
3814 UnoControlFixedLineModel::UnoControlFixedLineModel()
3816 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
3817 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
3818 ImplRegisterProperty( BASEPROPERTY_ENABLED );
3819 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
3820 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
3821 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
3822 ImplRegisterProperty( BASEPROPERTY_HELPURL );
3823 ImplRegisterProperty( BASEPROPERTY_LABEL );
3824 ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
3825 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
3828 ::rtl::OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
3830 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLineModel );
3833 uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3835 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3837 uno::Any aAny;
3838 aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLine );
3839 return aAny;
3841 return UnoControlModel::ImplGetDefaultValue( nPropId );
3844 ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper()
3846 static UnoPropertyArrayHelper* pHelper = NULL;
3847 if ( !pHelper )
3849 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3850 pHelper = new UnoPropertyArrayHelper( aIDs );
3852 return *pHelper;
3855 // beans::XMultiPropertySet
3856 uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException)
3858 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3859 return xInfo;
3862 // ----------------------------------------------------
3863 // class UnoFixedLineControl
3864 // ----------------------------------------------------
3865 UnoFixedLineControl::UnoFixedLineControl()
3867 maComponentInfos.nWidth = 100; // ??
3868 maComponentInfos.nHeight = 100; // ??
3871 ::rtl::OUString UnoFixedLineControl::GetComponentServiceName()
3873 return ::rtl::OUString::createFromAscii( "FixedLine" );
3876 sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException)
3878 return sal_True;