Branch libreoffice-5-0-4
[LibreOffice.git] / toolkit / source / controls / unocontrols.cxx
blobbf62b7ca69fbe9671653fa5fc9ba62ab0480ffc5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/awt/XTextArea.hpp>
21 #include <com/sun/star/awt/XVclWindowPeer.hpp>
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/awt/PosSize.hpp>
25 #include <com/sun/star/awt/VisualEffect.hpp>
26 #include <com/sun/star/awt/LineEndFormat.hpp>
27 #include <com/sun/star/graphic/GraphicProvider.hpp>
28 #include <com/sun/star/graphic/XGraphicProvider.hpp>
29 #include <com/sun/star/graphic/GraphicObject.hpp>
30 #include <com/sun/star/util/Date.hpp>
31 #include <com/sun/star/awt/ImageScaleMode.hpp>
34 #include <toolkit/controls/formattedcontrol.hxx>
35 #include <toolkit/controls/roadmapcontrol.hxx>
36 #include <toolkit/controls/unocontrols.hxx>
37 #include <toolkit/controls/stdtabcontroller.hxx>
38 #include <toolkit/helper/property.hxx>
39 #include <toolkit/helper/servicenames.hxx>
40 #include <toolkit/helper/macros.hxx>
42 // for introspection
43 #include <toolkit/awt/vclxwindows.hxx>
44 #include <cppuhelper/typeprovider.hxx>
45 #include <cppuhelper/queryinterface.hxx>
46 #include <comphelper/processfactory.hxx>
47 #include <vcl/wrkwin.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/edit.hxx>
50 #include <vcl/button.hxx>
51 #include <vcl/group.hxx>
52 #include <vcl/fixed.hxx>
53 #include <vcl/lstbox.hxx>
54 #include <vcl/combobox.hxx>
55 #include <tools/debug.hxx>
56 #include <tools/diagnose_ex.h>
57 #include <tools/date.hxx>
58 #include <tools/time.hxx>
60 #include <algorithm>
61 #include <functional>
63 #include "helper/imagealign.hxx"
64 #include "helper/unopropertyarrayhelper.hxx"
66 using namespace css;
67 using namespace css::awt;
68 using namespace css::lang;
69 using namespace css::uno;
70 using ::com::sun::star::graphic::XGraphic;
71 using ::com::sun::star::uno::Reference;
72 using namespace ::toolkit;
74 uno::Reference< graphic::XGraphic >
75 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const OUString& _rURL )
77 if ( _rURL.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
79 // graphic manager uniqueid
80 OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
81 xOutGraphicObj = graphic::GraphicObject::createWithId( ::comphelper::getProcessComponentContext(), sID );
83 else // linked
84 xOutGraphicObj = NULL; // release the GraphicObject
86 return ImageHelper::getGraphicFromURL_nothrow( _rURL );
89 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
90 ImageHelper::getGraphicFromURL_nothrow( const OUString& _rURL )
92 uno::Reference< graphic::XGraphic > xGraphic;
93 if ( _rURL.isEmpty() )
94 return xGraphic;
96 try
98 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
99 uno::Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) );
100 uno::Sequence< beans::PropertyValue > aMediaProperties(1);
101 aMediaProperties[0].Name = "URL";
102 aMediaProperties[0].Value <<= _rURL;
103 xGraphic = xProvider->queryGraphic( aMediaProperties );
105 catch (const Exception&)
107 DBG_UNHANDLED_EXCEPTION();
110 return xGraphic;
113 // class UnoControlEditModel
115 UnoControlEditModel::UnoControlEditModel( const Reference< XComponentContext >& rxContext )
116 :UnoControlModel( rxContext )
118 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit );
121 OUString UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
123 return OUString::createFromAscii( szServiceName_UnoControlEditModel );
126 uno::Any UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
128 uno::Any aReturn;
130 switch ( nPropId )
132 case BASEPROPERTY_LINE_END_FORMAT:
133 aReturn <<= (sal_Int16)awt::LineEndFormat::LINE_FEED; // LF
134 break;
135 case BASEPROPERTY_DEFAULTCONTROL:
136 aReturn <<= OUString::createFromAscii( szServiceName_UnoControlEdit );
137 break;
138 default:
139 aReturn = UnoControlModel::ImplGetDefaultValue( nPropId );
140 break;
142 return aReturn;
145 ::cppu::IPropertyArrayHelper& UnoControlEditModel::getInfoHelper()
147 static UnoPropertyArrayHelper* pHelper = NULL;
148 if ( !pHelper )
150 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
151 pHelper = new UnoPropertyArrayHelper( aIDs );
153 return *pHelper;
156 // beans::XMultiPropertySet
157 uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
159 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
160 return xInfo;
163 OUString UnoControlEditModel::getImplementationName()
164 throw (css::uno::RuntimeException, std::exception)
166 return OUString("stardiv.Toolkit.UnoControlEditModel");
169 css::uno::Sequence<OUString> UnoControlEditModel::getSupportedServiceNames()
170 throw (css::uno::RuntimeException, std::exception)
172 auto s(UnoControlModel::getSupportedServiceNames());
173 s.realloc(s.getLength() + 2);
174 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlEditModel";
175 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.Edit";
176 return s;
179 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
180 stardiv_Toolkit_UnoControlEditModel_get_implementation(
181 css::uno::XComponentContext *context,
182 css::uno::Sequence<css::uno::Any> const &)
184 return cppu::acquire(new UnoControlEditModel(context));
188 // class UnoEditControl
190 UnoEditControl::UnoEditControl()
191 :UnoControlBase()
192 ,maTextListeners( *this )
193 ,mnMaxTextLen( 0 )
194 ,mbSetTextInPeer( false )
195 ,mbSetMaxTextLenInPeer( false )
196 ,mbHasTextProperty( false )
198 maComponentInfos.nWidth = 100;
199 maComponentInfos.nHeight = 12;
200 mnMaxTextLen = 0;
201 mbSetMaxTextLenInPeer = false;
204 uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
206 uno::Any aReturn = UnoControlBase::queryAggregation( rType );
207 if ( !aReturn.hasValue() )
208 aReturn = UnoEditControl_Base::queryInterface( rType );
209 return aReturn;
212 uno::Any SAL_CALL UnoEditControl::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
214 return UnoControlBase::queryInterface( rType );
217 void SAL_CALL UnoEditControl::acquire( ) throw ()
219 UnoControlBase::acquire();
222 void SAL_CALL UnoEditControl::release( ) throw ()
224 UnoControlBase::release();
227 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl, UnoControlBase, UnoEditControl_Base )
229 OUString UnoEditControl::GetComponentServiceName()
231 // by default, we want a simple edit field
232 OUString sName( "Edit" );
234 // but maybe we are to display multi-line text?
235 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE ) );
236 bool b = bool();
237 if ( ( aVal >>= b ) && b )
238 sName = "MultiLineEdit";
240 return sName;
243 sal_Bool SAL_CALL UnoEditControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException, std::exception )
245 bool bReturn = UnoControlBase::setModel( _rModel );
246 mbHasTextProperty = ImplHasProperty( BASEPROPERTY_TEXT );
247 return bReturn;
250 void UnoEditControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
252 bool bDone = false;
253 if ( GetPropertyId( rPropName ) == BASEPROPERTY_TEXT )
255 // #96986# use setText(), or text listener will not be called.
256 uno::Reference < awt::XTextComponent > xTextComponent( getPeer(), uno::UNO_QUERY );
257 if ( xTextComponent.is() )
259 OUString sText;
260 rVal >>= sText;
261 ImplCheckLocalize( sText );
262 xTextComponent->setText( sText );
263 bDone = true;
267 if ( !bDone )
268 UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
271 void UnoEditControl::dispose() throw(uno::RuntimeException, std::exception)
273 lang::EventObject aEvt( *this );
274 maTextListeners.disposeAndClear( aEvt );
275 UnoControl::dispose();
278 void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
280 UnoControl::createPeer( rxToolkit, rParentPeer );
282 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
283 if ( xText.is() )
285 xText->addTextListener( this );
287 if ( mbSetMaxTextLenInPeer )
288 xText->setMaxTextLen( mnMaxTextLen );
289 if ( mbSetTextInPeer )
290 xText->setText( maText );
294 void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException, std::exception)
296 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
298 if ( mbHasTextProperty )
300 uno::Any aAny;
301 aAny <<= xText->getText();
302 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, false );
304 else
306 maText = xText->getText();
309 if ( maTextListeners.getLength() )
310 maTextListeners.textChanged( e );
313 void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException, std::exception)
315 maTextListeners.addInterface( l );
318 void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException, std::exception)
320 maTextListeners.removeInterface( l );
323 void UnoEditControl::setText( const OUString& aText ) throw(uno::RuntimeException, std::exception)
325 if ( mbHasTextProperty )
327 uno::Any aAny;
328 aAny <<= aText;
329 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, true );
331 else
333 maText = aText;
334 mbSetTextInPeer = true;
335 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
336 if ( xText.is() )
337 xText->setText( maText );
340 // Setting the property to the VCLXWindow doesn't call textChanged
341 if ( maTextListeners.getLength() )
343 awt::TextEvent aEvent;
344 aEvent.Source = *this;
345 maTextListeners.textChanged( aEvent );
349 namespace
351 static void lcl_normalize( awt::Selection& _rSel )
353 if ( _rSel.Min > _rSel.Max )
354 ::std::swap( _rSel.Min, _rSel.Max );
358 void UnoEditControl::insertText( const awt::Selection& rSel, const OUString& rNewText ) throw(uno::RuntimeException, std::exception)
360 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
361 awt::Selection aSelection( rSel );
362 lcl_normalize( aSelection );
364 // preserve the selection resp. cursor position
365 awt::Selection aNewSelection( getSelection() );
366 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
367 // (not sure - looks uglier ...)
368 sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength();
369 if ( aNewSelection.Min > aSelection.Min )
370 aNewSelection.Min -= nDeletedCharacters;
371 if ( aNewSelection.Max > aSelection.Max )
372 aNewSelection.Max -= nDeletedCharacters;
373 #else
374 aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength();
375 aNewSelection.Min = aNewSelection.Max;
376 #endif
378 OUString aOldText = getText();
379 OUString aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
380 setText( aNewText );
382 setSelection( aNewSelection );
385 OUString UnoEditControl::getText() throw(uno::RuntimeException, std::exception)
387 OUString aText = maText;
389 if ( mbHasTextProperty )
390 aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
391 else
393 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
394 if ( xText.is() )
395 aText = xText->getText();
398 return aText;
401 OUString UnoEditControl::getSelectedText() throw(uno::RuntimeException, std::exception)
403 OUString sSelected;
404 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
405 if ( xText.is() )
406 sSelected = xText->getSelectedText();
408 return sSelected;
411 void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException, std::exception)
413 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
414 if ( xText.is() )
415 xText->setSelection( aSelection );
418 awt::Selection UnoEditControl::getSelection() throw(uno::RuntimeException, std::exception)
420 awt::Selection aSel;
421 uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
422 if ( xText.is() )
423 aSel = xText->getSelection();
424 return aSel;
427 sal_Bool UnoEditControl::isEditable() throw(uno::RuntimeException, std::exception)
429 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY );
432 void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException, std::exception)
434 uno::Any aAny;
435 aAny <<= !bEditable;
436 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, true );
439 sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException, std::exception)
441 sal_Int16 nMaxLen = mnMaxTextLen;
443 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) )
444 nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN );
446 return nMaxLen;
449 void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException, std::exception)
451 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) )
453 uno::Any aAny;
454 aAny <<= (sal_Int16)nLen;
455 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, true );
457 else
459 mnMaxTextLen = nLen;
460 mbSetMaxTextLenInPeer = true;
461 uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
462 if ( xText.is() )
463 xText->setMaxTextLen( mnMaxTextLen );
467 awt::Size UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
469 return Impl_getMinimumSize();
472 awt::Size UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
474 return Impl_getPreferredSize();
477 awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
479 return Impl_calcAdjustedSize( rNewSize );
482 awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException, std::exception)
484 return Impl_getMinimumSize( nCols, nLines );
487 void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException, std::exception)
489 Impl_getColumnsAndLines( nCols, nLines );
492 OUString UnoEditControl::getImplementationName( ) throw(uno::RuntimeException, std::exception)
494 return OUString( "stardiv.Toolkit.UnoEditControl" );
497 uno::Sequence< OUString > UnoEditControl::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
499 uno::Sequence< OUString > aNames = UnoControlBase::getSupportedServiceNames( );
500 aNames.realloc( aNames.getLength() + 2 );
501 aNames[ aNames.getLength() - 2 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit );
502 aNames[ aNames.getLength() - 1 ] = "stardiv.vcl.control.Edit";
503 return aNames;
506 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
507 stardiv_Toolkit_UnoEditControl_get_implementation(
508 css::uno::XComponentContext *,
509 css::uno::Sequence<css::uno::Any> const &)
511 return cppu::acquire(new UnoEditControl());
515 // class UnoControlFileControlModel
517 UnoControlFileControlModel::UnoControlFileControlModel( const Reference< XComponentContext >& rxContext )
518 :UnoControlModel( rxContext )
520 ImplRegisterProperty( BASEPROPERTY_ALIGN );
521 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
522 ImplRegisterProperty( BASEPROPERTY_BORDER );
523 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
524 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
525 ImplRegisterProperty( BASEPROPERTY_ENABLED );
526 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
527 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
528 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
529 ImplRegisterProperty( BASEPROPERTY_HELPURL );
530 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
531 ImplRegisterProperty( BASEPROPERTY_READONLY );
532 ImplRegisterProperty( BASEPROPERTY_TABSTOP );
533 ImplRegisterProperty( BASEPROPERTY_TEXT );
534 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN );
535 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
536 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
537 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
540 OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
542 return OUString::createFromAscii( szServiceName_UnoControlFileControlModel );
545 uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
547 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
549 uno::Any aAny;
550 aAny <<= OUString::createFromAscii( szServiceName_UnoControlFileControl );
551 return aAny;
553 return UnoControlModel::ImplGetDefaultValue( nPropId );
556 ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper()
558 static UnoPropertyArrayHelper* pHelper = NULL;
559 if ( !pHelper )
561 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
562 pHelper = new UnoPropertyArrayHelper( aIDs );
564 return *pHelper;
567 // beans::XMultiPropertySet
568 uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
570 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
571 return xInfo;
574 OUString UnoControlFileControlModel::getImplementationName()
575 throw (css::uno::RuntimeException, std::exception)
577 return OUString("stardiv.Toolkit.UnoControlFileControlModel");
580 css::uno::Sequence<OUString>
581 UnoControlFileControlModel::getSupportedServiceNames()
582 throw (css::uno::RuntimeException, std::exception)
584 auto s(UnoControlModel::getSupportedServiceNames());
585 s.realloc(s.getLength() + 2);
586 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFileControlModel";
587 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.FileControl";
588 return s;
591 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
592 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
593 css::uno::XComponentContext *context,
594 css::uno::Sequence<css::uno::Any> const &)
596 return cppu::acquire(new UnoControlFileControlModel(context));
600 // class UnoFileControl
602 UnoFileControl::UnoFileControl()
603 :UnoEditControl()
607 OUString UnoFileControl::GetComponentServiceName()
609 return OUString("filecontrol");
612 OUString UnoFileControl::getImplementationName()
613 throw (css::uno::RuntimeException, std::exception)
615 return OUString("stardiv.Toolkit.UnoFileControl");
618 css::uno::Sequence<OUString> UnoFileControl::getSupportedServiceNames()
619 throw (css::uno::RuntimeException, std::exception)
621 auto s(UnoEditControl::getSupportedServiceNames());
622 s.realloc(s.getLength() + 2);
623 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFileControl";
624 s[s.getLength() - 1] = "stardiv.vcl.control.FileControl";
625 return s;
628 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
629 stardiv_Toolkit_UnoFileControl_get_implementation(
630 css::uno::XComponentContext *,
631 css::uno::Sequence<css::uno::Any> const &)
633 return cppu::acquire(new UnoFileControl());
637 // class GraphicControlModel
639 uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
641 if ( nPropId == BASEPROPERTY_GRAPHIC )
642 return uno::makeAny( uno::Reference< graphic::XGraphic >() );
644 return UnoControlModel::ImplGetDefaultValue( nPropId );
647 void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception, std::exception)
649 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
651 // - ImageAlign and ImagePosition need to correspond to each other
652 // - Graphic and ImageURL need to correspond to each other
655 switch ( nHandle )
657 case BASEPROPERTY_IMAGEURL:
658 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
660 mbAdjustingGraphic = true;
661 OUString sImageURL;
662 OSL_VERIFY( rValue >>= sImageURL );
663 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL ) ) );
664 mbAdjustingGraphic = false;
666 break;
668 case BASEPROPERTY_GRAPHIC:
669 if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
671 mbAdjustingGraphic = true;
672 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL, uno::makeAny( OUString() ) );
673 mbAdjustingGraphic = false;
675 break;
677 case BASEPROPERTY_IMAGEALIGN:
678 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) )
680 mbAdjustingImagePosition = true;
681 sal_Int16 nUNOValue = 0;
682 OSL_VERIFY( rValue >>= nUNOValue );
683 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION, uno::makeAny( getExtendedImagePosition( nUNOValue ) ) );
684 mbAdjustingImagePosition = false;
686 break;
687 case BASEPROPERTY_IMAGEPOSITION:
688 if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) )
690 mbAdjustingImagePosition = true;
691 sal_Int16 nUNOValue = 0;
692 OSL_VERIFY( rValue >>= nUNOValue );
693 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) );
694 mbAdjustingImagePosition = false;
696 break;
699 catch( const ::com::sun::star::uno::Exception& )
701 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
702 DBG_UNHANDLED_EXCEPTION();
703 mbAdjustingImagePosition = false;
708 // class UnoControlButtonModel
710 UnoControlButtonModel::UnoControlButtonModel( const Reference< XComponentContext >& rxContext )
711 :GraphicControlModel( rxContext )
713 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton );
715 osl_atomic_increment( &m_refCount );
717 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION ) );
718 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
719 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
721 osl_atomic_decrement( &m_refCount );
724 OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
726 return OUString::createFromAscii( szServiceName_UnoControlButtonModel );
729 uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
731 switch ( nPropId )
733 case BASEPROPERTY_DEFAULTCONTROL:
734 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton ) );
735 case BASEPROPERTY_TOGGLE:
736 return uno::makeAny( false );
737 case BASEPROPERTY_ALIGN:
738 return uno::makeAny( (sal_Int16)PROPERTY_ALIGN_CENTER );
739 case BASEPROPERTY_FOCUSONCLICK:
740 return uno::makeAny( true );
743 return GraphicControlModel::ImplGetDefaultValue( nPropId );
746 ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper()
748 static UnoPropertyArrayHelper* pHelper = NULL;
749 if ( !pHelper )
751 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
752 pHelper = new UnoPropertyArrayHelper( aIDs );
754 return *pHelper;
757 // beans::XMultiPropertySet
758 uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
760 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
761 return xInfo;
764 OUString UnoControlButtonModel::getImplementationName()
765 throw (css::uno::RuntimeException, std::exception)
767 return OUString("stardiv.Toolkit.UnoControlButtonModel");
770 css::uno::Sequence<OUString> UnoControlButtonModel::getSupportedServiceNames()
771 throw (css::uno::RuntimeException, std::exception)
773 auto s(GraphicControlModel::getSupportedServiceNames());
774 s.realloc(s.getLength() + 2);
775 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlButtonModel";
776 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.Button";
777 return s;
780 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
781 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
782 css::uno::XComponentContext *context,
783 css::uno::Sequence<css::uno::Any> const &)
785 return cppu::acquire(new UnoControlButtonModel(context));
789 // class UnoButtonControl
791 UnoButtonControl::UnoButtonControl()
792 :UnoButtonControl_Base()
793 ,maActionListeners( *this )
794 ,maItemListeners( *this )
796 maComponentInfos.nWidth = 50;
797 maComponentInfos.nHeight = 14;
800 OUString UnoButtonControl::GetComponentServiceName()
802 OUString aName( "pushbutton" );
803 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) );
804 sal_Int16 n = sal_Int16();
805 if ( ( aVal >>= n ) && n )
807 // Use PushButtonType later when available...
808 switch ( n )
810 case 1 /*PushButtonType::OK*/: aName = "okbutton";
811 break;
812 case 2 /*PushButtonType::CANCEL*/: aName = "cancelbutton";
813 break;
814 case 3 /*PushButtonType::HELP*/: aName = "helpbutton";
815 break;
816 default:
818 OSL_FAIL( "Unknown Button Type!" );
822 return aName;
825 void UnoButtonControl::dispose() throw(uno::RuntimeException, std::exception)
827 lang::EventObject aEvt;
828 aEvt.Source = (::cppu::OWeakObject*)this;
829 maActionListeners.disposeAndClear( aEvt );
830 maItemListeners.disposeAndClear( aEvt );
831 UnoControlBase::dispose();
834 void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
836 UnoControlBase::createPeer( rxToolkit, rParentPeer );
838 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
839 xButton->setActionCommand( maActionCommand );
840 if ( maActionListeners.getLength() )
841 xButton->addActionListener( &maActionListeners );
843 uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY );
844 if ( xPushButton.is() )
845 xPushButton->addItemListener( this );
848 void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
850 maActionListeners.addInterface( l );
851 if( getPeer().is() && maActionListeners.getLength() == 1 )
853 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
854 xButton->addActionListener( &maActionListeners );
858 void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
860 if( getPeer().is() && maActionListeners.getLength() == 1 )
862 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
863 xButton->removeActionListener( &maActionListeners );
865 maActionListeners.removeInterface( l );
868 void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
870 maItemListeners.addInterface( l );
873 void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
875 maItemListeners.removeInterface( l );
878 void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException, std::exception)
880 UnoControlBase::disposing( Source );
883 void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException, std::exception)
885 // forward to model
886 uno::Any aAny;
887 aAny <<= (sal_Int16)rEvent.Selected;
888 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, false );
890 // multiplex
891 ItemEvent aEvent( rEvent );
892 aEvent.Source = *this;
893 maItemListeners.itemStateChanged( aEvent );
896 void UnoButtonControl::setLabel( const OUString& rLabel ) throw(uno::RuntimeException, std::exception)
898 uno::Any aAny;
899 aAny <<= rLabel;
900 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, true );
903 void UnoButtonControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException, std::exception)
905 maActionCommand = rCommand;
906 if ( getPeer().is() )
908 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
909 xButton->setActionCommand( rCommand );
913 awt::Size UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
915 return Impl_getMinimumSize();
918 awt::Size UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
920 return Impl_getPreferredSize();
923 awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
925 return Impl_calcAdjustedSize( rNewSize );
928 OUString UnoButtonControl::getImplementationName()
929 throw (css::uno::RuntimeException, std::exception)
931 return OUString("stardiv.Toolkit.UnoButtonControl");
934 css::uno::Sequence<OUString> UnoButtonControl::getSupportedServiceNames()
935 throw (css::uno::RuntimeException, std::exception)
937 auto s(UnoControlBase::getSupportedServiceNames());
938 s.realloc(s.getLength() + 2);
939 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlButton";
940 s[s.getLength() - 1] = "stardiv.vcl.control.Button";
941 return s;
944 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
945 stardiv_Toolkit_UnoButtonControl_get_implementation(
946 css::uno::XComponentContext *,
947 css::uno::Sequence<css::uno::Any> const &)
949 return cppu::acquire(new UnoButtonControl());
953 // class UnoControlImageControlModel
955 UnoControlImageControlModel::UnoControlImageControlModel( const Reference< XComponentContext >& rxContext )
956 :GraphicControlModel( rxContext )
957 ,mbAdjustingImageScaleMode( false )
959 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl );
962 OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
964 return OUString::createFromAscii( szServiceName_UnoControlImageControlModel );
967 OUString UnoControlImageControlModel::getImplementationName()
968 throw (css::uno::RuntimeException, std::exception)
970 return OUString("stardiv.Toolkit.UnoControlImageControlModel");
973 css::uno::Sequence<OUString>
974 UnoControlImageControlModel::getSupportedServiceNames()
975 throw (css::uno::RuntimeException, std::exception)
977 auto s(GraphicControlModel::getSupportedServiceNames());
978 s.realloc(s.getLength() + 4);
979 s[s.getLength() - 4] = "com.sun.star.awt.UnoControlImageButtonModel";
980 s[s.getLength() - 3] = "com.sun.star.awt.UnoControlImageControlModel";
981 s[s.getLength() - 2] = "stardiv.vcl.controlmodel.ImageButton";
982 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.ImageControl";
983 return s;
986 uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
988 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
989 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl ) );
991 if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE )
992 return makeAny( awt::ImageScaleMode::ANISOTROPIC );
994 return GraphicControlModel::ImplGetDefaultValue( nPropId );
997 ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper()
999 static UnoPropertyArrayHelper* pHelper = NULL;
1000 if ( !pHelper )
1002 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1003 pHelper = new UnoPropertyArrayHelper( aIDs );
1005 return *pHelper;
1008 // beans::XMultiPropertySet
1009 uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
1011 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1012 return xInfo;
1015 void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception, std::exception)
1017 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
1019 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
1022 switch ( _nHandle )
1024 case BASEPROPERTY_IMAGE_SCALE_MODE:
1025 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) )
1027 mbAdjustingImageScaleMode = true;
1028 sal_Int16 nScaleMode( awt::ImageScaleMode::ANISOTROPIC );
1029 OSL_VERIFY( _rValue >>= nScaleMode );
1030 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE, uno::makeAny( nScaleMode != awt::ImageScaleMode::NONE ) );
1031 mbAdjustingImageScaleMode = false;
1033 break;
1034 case BASEPROPERTY_SCALEIMAGE:
1035 if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) )
1037 mbAdjustingImageScaleMode = true;
1038 bool bScale = true;
1039 OSL_VERIFY( _rValue >>= bScale );
1040 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE, uno::makeAny( bScale ? awt::ImageScaleMode::ANISOTROPIC : awt::ImageScaleMode::NONE ) );
1041 mbAdjustingImageScaleMode = false;
1043 break;
1046 catch( const Exception& )
1048 mbAdjustingImageScaleMode = false;
1049 throw;
1053 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1054 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
1055 css::uno::XComponentContext *context,
1056 css::uno::Sequence<css::uno::Any> const &)
1058 return cppu::acquire(new UnoControlImageControlModel(context));
1062 // class UnoImageControlControl
1064 UnoImageControlControl::UnoImageControlControl()
1065 :UnoImageControlControl_Base()
1066 ,maActionListeners( *this )
1068 // TODO: Where should I look for defaults?
1069 maComponentInfos.nWidth = 100;
1070 maComponentInfos.nHeight = 100;
1073 OUString UnoImageControlControl::GetComponentServiceName()
1075 return OUString("fixedimage");
1078 void UnoImageControlControl::dispose() throw(uno::RuntimeException, std::exception)
1080 lang::EventObject aEvt;
1081 aEvt.Source = (::cppu::OWeakObject*)this;
1082 maActionListeners.disposeAndClear( aEvt );
1083 UnoControl::dispose();
1086 sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException, std::exception)
1088 return sal_True;
1091 awt::Size UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
1093 return Impl_getMinimumSize();
1096 awt::Size UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
1098 return Impl_getPreferredSize();
1101 awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
1103 return Impl_calcAdjustedSize( rNewSize );
1106 OUString UnoImageControlControl::getImplementationName()
1107 throw (css::uno::RuntimeException, std::exception)
1109 return OUString("stardiv.Toolkit.UnoImageControlControl");
1112 css::uno::Sequence<OUString> UnoImageControlControl::getSupportedServiceNames()
1113 throw (css::uno::RuntimeException, std::exception)
1115 auto s(UnoControlBase::getSupportedServiceNames());
1116 s.realloc(s.getLength() + 4);
1117 s[s.getLength() - 4] = "com.sun.star.awt.UnoControlImageButton";
1118 s[s.getLength() - 3] = "com.sun.star.awt.UnoControlImageControl";
1119 s[s.getLength() - 2] = "stardiv.vcl.control.ImageButton";
1120 s[s.getLength() - 1] = "stardiv.vcl.control.ImageControl";
1121 return s;
1124 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1125 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1126 css::uno::XComponentContext *,
1127 css::uno::Sequence<css::uno::Any> const &)
1129 return cppu::acquire(new UnoImageControlControl());
1133 // class UnoControlRadioButtonModel
1135 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference< XComponentContext >& rxContext )
1136 :GraphicControlModel( rxContext )
1138 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton );
1141 OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
1143 return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel );
1146 uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1148 switch ( nPropId )
1150 case BASEPROPERTY_DEFAULTCONTROL:
1151 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton ) );
1153 case BASEPROPERTY_VISUALEFFECT:
1154 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1157 return GraphicControlModel::ImplGetDefaultValue( nPropId );
1160 ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper()
1162 static UnoPropertyArrayHelper* pHelper = NULL;
1163 if ( !pHelper )
1165 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1166 pHelper = new UnoPropertyArrayHelper( aIDs );
1168 return *pHelper;
1171 // beans::XMultiPropertySet
1172 uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
1174 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1175 return xInfo;
1178 OUString UnoControlRadioButtonModel::getImplementationName()
1179 throw (css::uno::RuntimeException, std::exception)
1181 return OUString("stardiv.Toolkit.UnoControlRadioButtonModel");
1184 css::uno::Sequence<OUString>
1185 UnoControlRadioButtonModel::getSupportedServiceNames()
1186 throw (css::uno::RuntimeException, std::exception)
1188 auto s(GraphicControlModel::getSupportedServiceNames());
1189 s.realloc(s.getLength() + 2);
1190 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButtonModel";
1191 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.RadioButton";
1192 return s;
1195 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1196 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1197 css::uno::XComponentContext *context,
1198 css::uno::Sequence<css::uno::Any> const &)
1200 return cppu::acquire(new UnoControlRadioButtonModel(context));
1204 // class UnoRadioButtonControl
1206 UnoRadioButtonControl::UnoRadioButtonControl()
1207 :UnoRadioButtonControl_Base()
1208 ,maItemListeners( *this )
1209 ,maActionListeners( *this )
1211 maComponentInfos.nWidth = 100;
1212 maComponentInfos.nHeight = 12;
1215 OUString UnoRadioButtonControl::GetComponentServiceName()
1217 return OUString("radiobutton");
1220 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException, std::exception)
1222 lang::EventObject aEvt;
1223 aEvt.Source = (::cppu::OWeakObject*)this;
1224 maItemListeners.disposeAndClear( aEvt );
1225 UnoControlBase::dispose();
1229 sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException, std::exception)
1231 return sal_True;
1234 void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
1236 UnoControlBase::createPeer( rxToolkit, rParentPeer );
1238 uno::Reference < awt::XRadioButton > xRadioButton( getPeer(), uno::UNO_QUERY );
1239 xRadioButton->addItemListener( this );
1241 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1242 xButton->setActionCommand( maActionCommand );
1243 if ( maActionListeners.getLength() )
1244 xButton->addActionListener( &maActionListeners );
1246 // as default, set the "AutoToggle" to true
1247 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1248 // have it enabled by default because of 85071)
1249 uno::Reference< awt::XVclWindowPeer > xVclWindowPeer( getPeer(), uno::UNO_QUERY );
1250 if ( xVclWindowPeer.is() )
1251 xVclWindowPeer->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE ), css::uno::Any(true) );
1254 void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
1256 maItemListeners.addInterface( l );
1259 void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
1261 maItemListeners.removeInterface( l );
1264 void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1266 maActionListeners.addInterface( l );
1267 if( getPeer().is() && maActionListeners.getLength() == 1 )
1269 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1270 xButton->addActionListener( &maActionListeners );
1274 void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1276 if( getPeer().is() && maActionListeners.getLength() == 1 )
1278 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1279 xButton->removeActionListener( &maActionListeners );
1281 maActionListeners.removeInterface( l );
1284 void UnoRadioButtonControl::setLabel( const OUString& rLabel ) throw(uno::RuntimeException, std::exception)
1286 uno::Any aAny;
1287 aAny <<= rLabel;
1288 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, true );
1291 void UnoRadioButtonControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException, std::exception)
1293 maActionCommand = rCommand;
1294 if ( getPeer().is() )
1296 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1297 xButton->setActionCommand( rCommand );
1301 void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException, std::exception)
1303 sal_Int16 nState = bOn ? 1 : 0;
1304 uno::Any aAny;
1305 aAny <<= nState;
1306 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, true );
1309 sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException, std::exception)
1311 sal_Int16 nState = 0;
1312 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1313 aVal >>= nState;
1314 return nState ? sal_True : sal_False;
1317 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException, std::exception)
1319 uno::Any aAny;
1320 aAny <<= (sal_Int16)rEvent.Selected;
1321 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, false );
1323 // compatibility:
1324 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1325 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1326 // "0" to "1".
1327 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1328 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1329 // isn't the case anymore: For instance, this method here gets called for the radio button
1330 // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
1331 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1332 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1333 // all which matters here.
1334 // #i14703#
1335 if ( 1 == rEvent.Selected )
1337 if ( maItemListeners.getLength() )
1338 maItemListeners.itemStateChanged( rEvent );
1340 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1341 // a radio button _without_ selecing another one, this would have caused a notification.
1342 // With the change done here, this today won't cause a notification anymore.
1344 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1345 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1346 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1347 // to be inconsistent with.
1350 awt::Size UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
1352 return Impl_getMinimumSize();
1355 awt::Size UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
1357 return Impl_getPreferredSize();
1360 awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
1362 return Impl_calcAdjustedSize( rNewSize );
1365 OUString UnoRadioButtonControl::getImplementationName()
1366 throw (css::uno::RuntimeException, std::exception)
1368 return OUString("stardiv.Toolkit.UnoRadioButtonControl");
1371 css::uno::Sequence<OUString> UnoRadioButtonControl::getSupportedServiceNames()
1372 throw (css::uno::RuntimeException, std::exception)
1374 auto s(UnoControlBase::getSupportedServiceNames());
1375 s.realloc(s.getLength() + 2);
1376 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButton";
1377 s[s.getLength() - 1] = "stardiv.vcl.control.RadioButton";
1378 return s;
1381 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1382 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1383 css::uno::XComponentContext *,
1384 css::uno::Sequence<css::uno::Any> const &)
1386 return cppu::acquire(new UnoRadioButtonControl());
1390 // class UnoControlCheckBoxModel
1392 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference< XComponentContext >& rxContext )
1393 :GraphicControlModel( rxContext )
1395 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox );
1398 OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
1400 return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel );
1403 uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1405 switch ( nPropId )
1407 case BASEPROPERTY_DEFAULTCONTROL:
1408 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox ) );
1410 case BASEPROPERTY_VISUALEFFECT:
1411 return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1414 return GraphicControlModel::ImplGetDefaultValue( nPropId );
1417 ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper()
1419 static UnoPropertyArrayHelper* pHelper = NULL;
1420 if ( !pHelper )
1422 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1423 pHelper = new UnoPropertyArrayHelper( aIDs );
1425 return *pHelper;
1428 // beans::XMultiPropertySet
1429 uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
1431 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1432 return xInfo;
1435 OUString UnoControlCheckBoxModel::getImplementationName()
1436 throw (css::uno::RuntimeException, std::exception)
1438 return OUString( "stardiv.Toolkit.UnoControlCheckBoxModel");
1441 css::uno::Sequence<OUString> UnoControlCheckBoxModel::getSupportedServiceNames()
1442 throw (css::uno::RuntimeException, std::exception)
1444 auto s(GraphicControlModel::getSupportedServiceNames());
1445 s.realloc(s.getLength() + 2);
1446 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBoxModel";
1447 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.CheckBox";
1448 return s;
1451 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1452 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1453 css::uno::XComponentContext *context,
1454 css::uno::Sequence<css::uno::Any> const &)
1456 return cppu::acquire(new UnoControlCheckBoxModel(context));
1460 // class UnoCheckBoxControl
1462 UnoCheckBoxControl::UnoCheckBoxControl()
1463 :UnoCheckBoxControl_Base()
1464 ,maItemListeners( *this ), maActionListeners( *this )
1466 maComponentInfos.nWidth = 100;
1467 maComponentInfos.nHeight = 12;
1470 OUString UnoCheckBoxControl::GetComponentServiceName()
1472 return OUString("checkbox");
1475 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException, std::exception)
1477 lang::EventObject aEvt;
1478 aEvt.Source = (::cppu::OWeakObject*)this;
1479 maItemListeners.disposeAndClear( aEvt );
1480 UnoControlBase::dispose();
1483 sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException, std::exception)
1485 return sal_True;
1488 void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
1490 UnoControlBase::createPeer( rxToolkit, rParentPeer );
1492 uno::Reference < awt::XCheckBox > xCheckBox( getPeer(), uno::UNO_QUERY );
1493 xCheckBox->addItemListener( this );
1495 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1496 xButton->setActionCommand( maActionCommand );
1497 if ( maActionListeners.getLength() )
1498 xButton->addActionListener( &maActionListeners );
1501 void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
1503 maItemListeners.addInterface( l );
1506 void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
1508 maItemListeners.removeInterface( l );
1511 void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1513 maActionListeners.addInterface( l );
1514 if( getPeer().is() && maActionListeners.getLength() == 1 )
1516 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1517 xButton->addActionListener( &maActionListeners );
1521 void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1523 if( getPeer().is() && maActionListeners.getLength() == 1 )
1525 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1526 xButton->removeActionListener( &maActionListeners );
1528 maActionListeners.removeInterface( l );
1531 void UnoCheckBoxControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException, std::exception)
1533 maActionCommand = rCommand;
1534 if ( getPeer().is() )
1536 uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1537 xButton->setActionCommand( rCommand );
1542 void UnoCheckBoxControl::setLabel( const OUString& rLabel ) throw(uno::RuntimeException, std::exception)
1544 uno::Any aAny;
1545 aAny <<= rLabel;
1546 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, true );
1549 void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException, std::exception)
1551 uno::Any aAny;
1552 aAny <<= (sal_Int16)n;
1553 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, true );
1556 short UnoCheckBoxControl::getState() throw(uno::RuntimeException, std::exception)
1558 short nState = 0;
1559 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1560 aVal >>= nState;
1561 return nState;
1564 void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException, std::exception)
1566 uno::Any aAny;
1567 aAny <<= b;
1568 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, true );
1571 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException, std::exception)
1573 uno::Any aAny;
1574 aAny <<= (sal_Int16)rEvent.Selected;
1575 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, false );
1577 if ( maItemListeners.getLength() )
1578 maItemListeners.itemStateChanged( rEvent );
1581 awt::Size UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
1583 return Impl_getMinimumSize();
1586 awt::Size UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
1588 return Impl_getPreferredSize();
1591 awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
1593 return Impl_calcAdjustedSize( rNewSize );
1596 OUString UnoCheckBoxControl::getImplementationName()
1597 throw (css::uno::RuntimeException, std::exception)
1599 return OUString("stardiv.Toolkit.UnoCheckBoxControl");
1602 css::uno::Sequence<OUString> UnoCheckBoxControl::getSupportedServiceNames()
1603 throw (css::uno::RuntimeException, std::exception)
1605 auto s(UnoControlBase::getSupportedServiceNames());
1606 s.realloc(s.getLength() + 2);
1607 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBox";
1608 s[s.getLength() - 1] = "stardiv.vcl.control.CheckBox";
1609 return s;
1612 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1613 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1614 css::uno::XComponentContext *,
1615 css::uno::Sequence<css::uno::Any> const &)
1617 return cppu::acquire(new UnoCheckBoxControl());
1621 // class UnoControlFixedHyperlinkModel
1623 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference< XComponentContext >& rxContext )
1624 :UnoControlModel( rxContext )
1626 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink );
1629 OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
1631 return OUString( "com.sun.star.awt.UnoControlFixedHyperlinkModel" );
1634 uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1636 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1638 uno::Any aAny;
1639 aAny <<= OUString( "com.sun.star.awt.UnoControlFixedHyperlink" );
1640 return aAny;
1642 else if ( nPropId == BASEPROPERTY_BORDER )
1644 uno::Any aAny;
1645 aAny <<= (sal_Int16)0;
1646 return aAny;
1648 else if ( nPropId == BASEPROPERTY_URL )
1650 uno::Any aAny;
1651 aAny <<= OUString();
1652 return aAny;
1655 return UnoControlModel::ImplGetDefaultValue( nPropId );
1658 ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper()
1660 static UnoPropertyArrayHelper* pHelper = NULL;
1661 if ( !pHelper )
1663 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1664 pHelper = new UnoPropertyArrayHelper( aIDs );
1666 return *pHelper;
1669 // beans::XMultiPropertySet
1670 uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
1672 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1673 return xInfo;
1676 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1677 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1678 css::uno::XComponentContext *context,
1679 css::uno::Sequence<css::uno::Any> const &)
1681 return cppu::acquire(new UnoControlFixedHyperlinkModel(context));
1685 // class UnoFixedHyperlinkControl
1687 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1688 :UnoControlBase()
1689 ,maActionListeners( *this )
1691 maComponentInfos.nWidth = 100;
1692 maComponentInfos.nHeight = 12;
1695 OUString UnoFixedHyperlinkControl::GetComponentServiceName()
1697 return OUString("fixedhyperlink");
1700 // uno::XInterface
1701 uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
1703 uno::Any aRet = ::cppu::queryInterface( rType,
1704 (static_cast< awt::XFixedHyperlink* >(this)),
1705 (static_cast< awt::XLayoutConstrains* >(this)) );
1706 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1709 // lang::XTypeProvider
1710 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl )
1711 cppu::UnoType<awt::XFixedHyperlink>::get(),
1712 cppu::UnoType<awt::XLayoutConstrains>::get(),
1713 UnoControlBase::getTypes()
1714 IMPL_XTYPEPROVIDER_END
1716 sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException, std::exception)
1718 return sal_True;
1721 void UnoFixedHyperlinkControl::setText( const OUString& Text ) throw(uno::RuntimeException, std::exception)
1723 uno::Any aAny;
1724 aAny <<= Text;
1725 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, true );
1728 OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException, std::exception)
1730 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1733 void UnoFixedHyperlinkControl::setURL( const OUString& URL ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1735 uno::Any aAny;
1736 aAny <<= URL;
1737 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, true );
1740 OUString UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1742 return ImplGetPropertyValue_UString( BASEPROPERTY_URL );
1745 void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException, std::exception)
1747 uno::Any aAny;
1748 aAny <<= (sal_Int16)nAlign;
1749 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, true );
1752 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException, std::exception)
1754 short nAlign = 0;
1755 if ( mxModel.is() )
1757 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1758 aVal >>= nAlign;
1760 return nAlign;
1763 awt::Size UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
1765 return Impl_getMinimumSize();
1768 awt::Size UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
1770 return Impl_getPreferredSize();
1773 awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
1775 return Impl_calcAdjustedSize( rNewSize );
1778 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException, std::exception)
1780 lang::EventObject aEvt;
1781 aEvt.Source = (::cppu::OWeakObject*)this;
1782 maActionListeners.disposeAndClear( aEvt );
1783 UnoControlBase::dispose();
1786 void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
1788 UnoControlBase::createPeer( rxToolkit, rParentPeer );
1790 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1791 if ( maActionListeners.getLength() )
1792 xFixedHyperlink->addActionListener( &maActionListeners );
1795 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1797 maActionListeners.addInterface( l );
1798 if( getPeer().is() && maActionListeners.getLength() == 1 )
1800 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1801 xFixedHyperlink->addActionListener( &maActionListeners );
1805 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
1807 if( getPeer().is() && maActionListeners.getLength() == 1 )
1809 uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1810 xFixedHyperlink->removeActionListener( &maActionListeners );
1812 maActionListeners.removeInterface( l );
1815 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1816 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1817 css::uno::XComponentContext *,
1818 css::uno::Sequence<css::uno::Any> const &)
1820 return cppu::acquire(new UnoFixedHyperlinkControl());
1824 // class UnoControlFixedTextModel
1826 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference< XComponentContext >& rxContext )
1827 :UnoControlModel( rxContext )
1829 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText );
1832 OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
1834 return OUString( "stardiv.vcl.controlmodel.FixedText" );
1837 uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1839 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1841 uno::Any aAny;
1842 aAny <<= OUString::createFromAscii( szServiceName_UnoControlFixedText );
1843 return aAny;
1845 else if ( nPropId == BASEPROPERTY_BORDER )
1847 uno::Any aAny;
1848 aAny <<= (sal_Int16)0;
1849 return aAny;
1852 return UnoControlModel::ImplGetDefaultValue( nPropId );
1855 ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper()
1857 static UnoPropertyArrayHelper* pHelper = NULL;
1858 if ( !pHelper )
1860 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
1861 pHelper = new UnoPropertyArrayHelper( aIDs );
1863 return *pHelper;
1866 // beans::XMultiPropertySet
1867 uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
1869 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1870 return xInfo;
1873 OUString UnoControlFixedTextModel::getImplementationName()
1874 throw (css::uno::RuntimeException, std::exception)
1876 return OUString("stardiv.Toolkit.UnoControlFixedTextModel");
1879 css::uno::Sequence<OUString>
1880 UnoControlFixedTextModel::getSupportedServiceNames()
1881 throw (css::uno::RuntimeException, std::exception)
1883 auto s(UnoControlModel::getSupportedServiceNames());
1884 s.realloc(s.getLength() + 2);
1885 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFixedTextModel";
1886 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.FixedText";
1887 return s;
1890 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1891 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1892 css::uno::XComponentContext *context,
1893 css::uno::Sequence<css::uno::Any> const &)
1895 return cppu::acquire(new UnoControlFixedTextModel(context));
1899 // class UnoFixedTextControl
1901 UnoFixedTextControl::UnoFixedTextControl()
1902 :UnoControlBase()
1904 maComponentInfos.nWidth = 100;
1905 maComponentInfos.nHeight = 12;
1908 OUString UnoFixedTextControl::GetComponentServiceName()
1910 return OUString("fixedtext");
1913 // uno::XInterface
1914 uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
1916 uno::Any aRet = ::cppu::queryInterface( rType,
1917 (static_cast< awt::XFixedText* >(this)),
1918 (static_cast< awt::XLayoutConstrains* >(this)) );
1919 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1922 // lang::XTypeProvider
1923 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl )
1924 cppu::UnoType<awt::XFixedText>::get(),
1925 cppu::UnoType<awt::XLayoutConstrains>::get(),
1926 UnoControlBase::getTypes()
1927 IMPL_XTYPEPROVIDER_END
1929 sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException, std::exception)
1931 return sal_True;
1934 void UnoFixedTextControl::setText( const OUString& Text ) throw(uno::RuntimeException, std::exception)
1936 uno::Any aAny;
1937 aAny <<= Text;
1938 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, true );
1941 OUString UnoFixedTextControl::getText() throw(uno::RuntimeException, std::exception)
1943 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1946 void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException, std::exception)
1948 uno::Any aAny;
1949 aAny <<= (sal_Int16)nAlign;
1950 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, true );
1953 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException, std::exception)
1955 short nAlign = 0;
1956 if ( mxModel.is() )
1958 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1959 aVal >>= nAlign;
1961 return nAlign;
1964 awt::Size UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
1966 return Impl_getMinimumSize();
1969 awt::Size UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
1971 return Impl_getPreferredSize();
1974 awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
1976 return Impl_calcAdjustedSize( rNewSize );
1979 OUString UnoFixedTextControl::getImplementationName()
1980 throw (css::uno::RuntimeException, std::exception)
1982 return OUString("stardiv.Toolkit.UnoFixedTextControl");
1985 css::uno::Sequence<OUString> UnoFixedTextControl::getSupportedServiceNames()
1986 throw (css::uno::RuntimeException, std::exception)
1988 auto s(UnoControlBase::getSupportedServiceNames());
1989 s.realloc(s.getLength() + 2);
1990 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFixedText";
1991 s[s.getLength() - 1] = "stardiv.vcl.control.FixedText";
1992 return s;
1995 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
1996 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1997 css::uno::XComponentContext *,
1998 css::uno::Sequence<css::uno::Any> const &)
2000 return cppu::acquire(new UnoFixedTextControl());
2004 // class UnoControlGroupBoxModel
2006 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference< XComponentContext >& rxContext )
2007 :UnoControlModel( rxContext )
2009 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
2010 ImplRegisterProperty( BASEPROPERTY_ENABLED );
2011 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
2012 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
2013 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
2014 ImplRegisterProperty( BASEPROPERTY_HELPURL );
2015 ImplRegisterProperty( BASEPROPERTY_LABEL );
2016 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
2017 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
2018 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
2021 OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
2023 return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel );
2026 uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2028 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2030 uno::Any aAny;
2031 aAny <<= OUString::createFromAscii( szServiceName_UnoControlGroupBox );
2032 return aAny;
2034 return UnoControlModel::ImplGetDefaultValue( nPropId );
2037 ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper()
2039 static UnoPropertyArrayHelper* pHelper = NULL;
2040 if ( !pHelper )
2042 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2043 pHelper = new UnoPropertyArrayHelper( aIDs );
2045 return *pHelper;
2048 // beans::XMultiPropertySet
2049 uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
2051 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2052 return xInfo;
2055 OUString UnoControlGroupBoxModel::getImplementationName()
2056 throw (css::uno::RuntimeException, std::exception)
2058 return OUString("stardiv.Toolkit.UnoControlGroupBoxModel");
2061 css::uno::Sequence<OUString> UnoControlGroupBoxModel::getSupportedServiceNames()
2062 throw (css::uno::RuntimeException, std::exception)
2064 auto s(UnoControlModel::getSupportedServiceNames());
2065 s.realloc(s.getLength() + 2);
2066 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBoxModel";
2067 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.GroupBox";
2068 return s;
2071 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
2072 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
2073 css::uno::XComponentContext *context,
2074 css::uno::Sequence<css::uno::Any> const &)
2076 return cppu::acquire(new UnoControlGroupBoxModel(context));
2080 // class UnoGroupBoxControl
2082 UnoGroupBoxControl::UnoGroupBoxControl()
2083 :UnoControlBase()
2085 maComponentInfos.nWidth = 100;
2086 maComponentInfos.nHeight = 100;
2089 OUString UnoGroupBoxControl::GetComponentServiceName()
2091 return OUString("groupbox");
2094 sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException, std::exception)
2096 return sal_True;
2099 OUString UnoGroupBoxControl::getImplementationName()
2100 throw (css::uno::RuntimeException, std::exception)
2102 return OUString("stardiv.Toolkit.UnoGroupBoxControl");
2105 css::uno::Sequence<OUString> UnoGroupBoxControl::getSupportedServiceNames()
2106 throw (css::uno::RuntimeException, std::exception)
2108 auto s(UnoControlBase::getSupportedServiceNames());
2109 s.realloc(s.getLength() + 2);
2110 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBox";
2111 s[s.getLength() - 1] = "stardiv.vcl.control.GroupBox";
2112 return s;
2115 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
2116 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
2117 css::uno::XComponentContext *,
2118 css::uno::Sequence<css::uno::Any> const &)
2120 return cppu::acquire(new UnoGroupBoxControl());
2124 // = UnoControlListBoxModel_Data
2126 struct ListItem
2128 OUString ItemText;
2129 OUString ItemImageURL;
2130 Any ItemData;
2132 ListItem()
2133 :ItemText()
2134 ,ItemImageURL()
2135 ,ItemData()
2139 ListItem( const OUString& i_rItemText )
2140 :ItemText( i_rItemText )
2141 ,ItemImageURL()
2142 ,ItemData()
2147 typedef beans::Pair< OUString, OUString > UnoListItem;
2149 struct StripItemData : public ::std::unary_function< ListItem, UnoListItem >
2151 UnoListItem operator()( const ListItem& i_rItem )
2153 return UnoListItem( i_rItem.ItemText, i_rItem.ItemImageURL );
2157 struct UnoControlListBoxModel_Data
2159 UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl )
2160 :m_bSettingLegacyProperty( false )
2161 ,m_rAntiImpl( i_rAntiImpl )
2162 ,m_aListItems()
2166 sal_Int32 getItemCount() const { return sal_Int32( m_aListItems.size() ); }
2168 const ListItem& getItem( const sal_Int32 i_nIndex ) const
2170 if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
2171 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
2172 return m_aListItems[ i_nIndex ];
2175 ListItem& getItem( const sal_Int32 i_nIndex )
2177 return const_cast< ListItem& >( static_cast< const UnoControlListBoxModel_Data* >( this )->getItem( i_nIndex ) );
2180 ListItem& insertItem( const sal_Int32 i_nIndex )
2182 if ( ( i_nIndex < 0 ) || ( i_nIndex > sal_Int32( m_aListItems.size() ) ) )
2183 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
2184 return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() );
2187 Sequence< UnoListItem > getAllItems() const
2189 Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) );
2190 ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() );
2191 return aItems;
2194 void copyItems( const UnoControlListBoxModel_Data& i_copySource )
2196 m_aListItems = i_copySource.m_aListItems;
2199 void setAllItems( const ::std::vector< ListItem >& i_rItems )
2201 m_aListItems = i_rItems;
2204 void removeItem( const sal_Int32 i_nIndex )
2206 if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
2207 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
2208 m_aListItems.erase( m_aListItems.begin() + i_nIndex );
2211 void removeAllItems()
2213 ::std::vector< ListItem > aEmpty;
2214 m_aListItems.swap( aEmpty );
2217 public:
2218 bool m_bSettingLegacyProperty;
2220 private:
2221 UnoControlListBoxModel& m_rAntiImpl;
2222 ::std::vector< ListItem > m_aListItems;
2226 // = UnoControlListBoxModel
2229 UnoControlListBoxModel::UnoControlListBoxModel( const Reference< XComponentContext >& rxContext, ConstructorMode const i_mode )
2230 :UnoControlListBoxModel_Base( rxContext )
2231 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2232 ,m_aItemListListeners( GetMutex() )
2234 if ( i_mode == ConstructDefault )
2236 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox );
2240 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource )
2241 :UnoControlListBoxModel_Base( i_rSource )
2242 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2243 ,m_aItemListListeners( GetMutex() )
2245 m_xData->copyItems( *i_rSource.m_xData );
2247 UnoControlListBoxModel::~UnoControlListBoxModel()
2251 OUString UnoControlListBoxModel::getImplementationName()
2252 throw (css::uno::RuntimeException, std::exception)
2254 return OUString("stardiv.Toolkit.UnoControlListBoxModel");
2257 css::uno::Sequence<OUString> UnoControlListBoxModel::getSupportedServiceNames()
2258 throw (css::uno::RuntimeException, std::exception)
2260 auto s(UnoControlModel::getSupportedServiceNames());
2261 s.realloc(s.getLength() + 2);
2262 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlListBoxModel";
2263 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.ListBox";
2264 return s;
2267 OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
2269 return OUString::createFromAscii( szServiceName_UnoControlListBoxModel );
2273 uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2275 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2277 uno::Any aAny;
2278 aAny <<= OUString::createFromAscii( szServiceName_UnoControlListBox );
2279 return aAny;
2281 return UnoControlModel::ImplGetDefaultValue( nPropId );
2285 ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper()
2287 static UnoPropertyArrayHelper* pHelper = NULL;
2288 if ( !pHelper )
2290 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
2291 pHelper = new UnoPropertyArrayHelper( aIDs );
2293 return *pHelper;
2297 // beans::XMultiPropertySet
2298 uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
2300 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2301 return xInfo;
2305 namespace
2307 struct CreateListItem : public ::std::unary_function< OUString, ListItem >
2309 ListItem operator()( const OUString& i_rItemText )
2311 return ListItem( i_rItemText );
2317 void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception, std::exception)
2319 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
2321 if ( nHandle == BASEPROPERTY_STRINGITEMLIST )
2323 // reset selection
2324 uno::Sequence<sal_Int16> aSeq;
2325 uno::Any aAny;
2326 aAny <<= aSeq;
2327 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, aAny );
2329 if ( !m_xData->m_bSettingLegacyProperty )
2331 // synchronize the legacy StringItemList property with our list items
2332 Sequence< OUString > aStringItemList;
2333 Any aPropValue;
2334 getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
2335 OSL_VERIFY( aPropValue >>= aStringItemList );
2337 ::std::vector< ListItem > aItems( aStringItemList.getLength() );
2338 ::std::transform(
2339 aStringItemList.getConstArray(),
2340 aStringItemList.getConstArray() + aStringItemList.getLength(),
2341 aItems.begin(),
2342 CreateListItem()
2344 m_xData->setAllItems( aItems );
2346 // since an XItemListListener does not have a "all items modified" or some such method,
2347 // we simulate this by notifying removal of all items, followed by insertion of all new
2348 // items
2349 lang::EventObject aEvent;
2350 aEvent.Source = *this;
2351 m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
2352 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2353 // which is wrong for the above notifications ...
2359 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
2360 uno::Any* _pValues, sal_Int32* _pValidHandles ) const
2362 // dependencies we know:
2363 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2364 ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS );
2366 UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
2370 ::sal_Int32 SAL_CALL UnoControlListBoxModel::getItemCount() throw (RuntimeException, std::exception)
2372 ::osl::MutexGuard aGuard( GetMutex() );
2373 return m_xData->getItemCount();
2377 void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const OUString& i_rItemText, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2379 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2380 // SYNCHRONIZED ----->
2381 ListItem& rItem( m_xData->insertItem( i_nPosition ) );
2382 rItem.ItemText = i_rItemText;
2383 rItem.ItemImageURL = i_rItemImageURL;
2385 impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
2386 // <----- SYNCHRONIZED
2390 void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, const OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2392 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2393 // SYNCHRONIZED ----->
2394 ListItem& rItem( m_xData->insertItem( i_nPosition ) );
2395 rItem.ItemText = i_rItemText;
2397 impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
2398 // <----- SYNCHRONIZED
2402 void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2404 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2405 // SYNCHRONIZED ----->
2406 ListItem& rItem( m_xData->insertItem( i_nPosition ) );
2407 rItem.ItemImageURL = i_rItemImageURL;
2409 impl_handleInsert( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
2410 // <----- SYNCHRONIZED
2414 void SAL_CALL UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2416 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2417 // SYNCHRONIZED ----->
2418 m_xData->removeItem( i_nPosition );
2420 impl_handleRemove( i_nPosition, aGuard );
2421 // <----- SYNCHRONIZED
2425 void SAL_CALL UnoControlListBoxModel::removeAllItems( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
2427 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2428 // SYNCHRONIZED ----->
2429 m_xData->removeAllItems();
2431 impl_handleRemove( -1, aGuard );
2432 // <----- SYNCHRONIZED
2436 void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, const OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2438 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2439 // SYNCHRONIZED ----->
2440 ListItem& rItem( m_xData->getItem( i_nPosition ) );
2441 rItem.ItemText = i_rItemText;
2443 impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
2444 // <----- SYNCHRONIZED
2448 void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2450 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2451 // SYNCHRONIZED ----->
2452 ListItem& rItem( m_xData->getItem( i_nPosition ) );
2453 rItem.ItemImageURL = i_rItemImageURL;
2455 impl_handleModify( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
2456 // <----- SYNCHRONIZED
2460 void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition, const OUString& i_rItemText, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2462 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2463 // SYNCHRONIZED ----->
2464 ListItem& rItem( m_xData->getItem( i_nPosition ) );
2465 rItem.ItemText = i_rItemText;
2466 rItem.ItemImageURL = i_rItemImageURL;
2468 impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
2469 // <----- SYNCHRONIZED
2473 void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2475 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2476 ListItem& rItem( m_xData->getItem( i_nPosition ) );
2477 rItem.ItemData = i_rDataValue;
2481 OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2483 ::osl::MutexGuard aGuard( GetMutex() );
2484 const ListItem& rItem( m_xData->getItem( i_nPosition ) );
2485 return rItem.ItemText;
2489 OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2491 ::osl::MutexGuard aGuard( GetMutex() );
2492 const ListItem& rItem( m_xData->getItem( i_nPosition ) );
2493 return rItem.ItemImageURL;
2497 beans::Pair< OUString, OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2499 ::osl::MutexGuard aGuard( GetMutex() );
2500 const ListItem& rItem( m_xData->getItem( i_nPosition ) );
2501 return beans::Pair< OUString, OUString >( rItem.ItemText, rItem.ItemImageURL );
2505 Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
2507 ::osl::ClearableMutexGuard aGuard( GetMutex() );
2508 const ListItem& rItem( m_xData->getItem( i_nPosition ) );
2509 return rItem.ItemData;
2513 Sequence< beans::Pair< OUString, OUString > > SAL_CALL UnoControlListBoxModel::getAllItems( ) throw (RuntimeException, std::exception)
2515 ::osl::MutexGuard aGuard( GetMutex() );
2516 return m_xData->getAllItems();
2520 void SAL_CALL UnoControlListBoxModel::addItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException, std::exception)
2522 if ( i_Listener.is() )
2523 m_aItemListListeners.addInterface( i_Listener );
2527 void SAL_CALL UnoControlListBoxModel::removeItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException, std::exception)
2529 if ( i_Listener.is() )
2530 m_aItemListListeners.removeInterface( i_Listener );
2534 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< OUString >& o_rStringItems ) const
2536 Sequence< OUString > aStringItemList;
2537 Any aPropValue;
2538 getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
2539 OSL_VERIFY( aPropValue >>= aStringItemList );
2541 o_rStringItems.resize( size_t( aStringItemList.getLength() ) );
2542 ::std::copy(
2543 aStringItemList.getConstArray(),
2544 aStringItemList.getConstArray() + aStringItemList.getLength(),
2545 o_rStringItems.begin()
2550 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< OUString >& i_rStringItems )
2552 Sequence< OUString > aStringItems( i_rStringItems.size() );
2553 ::std::copy(
2554 i_rStringItems.begin(),
2555 i_rStringItems.end(),
2556 aStringItems.getArray()
2558 m_xData->m_bSettingLegacyProperty = true;
2561 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST, uno::makeAny( aStringItems ) );
2563 catch( const Exception& )
2565 m_xData->m_bSettingLegacyProperty = false;
2566 throw;
2568 m_xData->m_bSettingLegacyProperty = false;
2572 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
2573 const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2575 // SYNCHRONIZED ----->
2576 // sync with legacy StringItemList property
2577 ::std::vector< OUString > aStringItems;
2578 impl_getStringItemList( aStringItems );
2579 OSL_ENSURE( size_t( i_nItemPosition ) <= aStringItems.size(), "UnoControlListBoxModel::impl_handleInsert" );
2580 if ( size_t( i_nItemPosition ) <= aStringItems.size() )
2582 const OUString sItemText( !!i_rItemText ? *i_rItemText : OUString() );
2583 aStringItems.insert( aStringItems.begin() + i_nItemPosition, sItemText );
2586 i_rClearBeforeNotify.clear();
2587 // <----- SYNCHRONIZED
2588 impl_setStringItemList_nolck( aStringItems );
2590 // notify ItemListListeners
2591 impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemInserted );
2595 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2597 // SYNCHRONIZED ----->
2598 const bool bAllItems = ( i_nItemPosition < 0 );
2599 // sync with legacy StringItemList property
2600 ::std::vector< OUString > aStringItems;
2601 impl_getStringItemList( aStringItems );
2602 if ( !bAllItems )
2604 OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleRemove" );
2605 if ( size_t( i_nItemPosition ) < aStringItems.size() )
2607 aStringItems.erase( aStringItems.begin() + i_nItemPosition );
2610 else
2612 aStringItems.resize(0);
2615 i_rClearBeforeNotify.clear();
2616 // <----- SYNCHRONIZED
2617 impl_setStringItemList_nolck( aStringItems );
2619 // notify ItemListListeners
2620 if ( bAllItems )
2622 EventObject aEvent( *this );
2623 m_aItemListListeners.notifyEach( &XItemListListener::allItemsRemoved, aEvent );
2625 else
2627 impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< OUString >(), ::boost::optional< OUString >(),
2628 &XItemListListener::listItemRemoved );
2633 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
2634 const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2636 // SYNCHRONIZED ----->
2637 if ( !!i_rItemText )
2639 // sync with legacy StringItemList property
2640 ::std::vector< OUString > aStringItems;
2641 impl_getStringItemList( aStringItems );
2642 OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleModify" );
2643 if ( size_t( i_nItemPosition ) < aStringItems.size() )
2645 aStringItems[ i_nItemPosition] = *i_rItemText;
2648 i_rClearBeforeNotify.clear();
2649 // <----- SYNCHRONIZED
2650 impl_setStringItemList_nolck( aStringItems );
2652 else
2654 i_rClearBeforeNotify.clear();
2655 // <----- SYNCHRONIZED
2658 // notify ItemListListeners
2659 impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemModified );
2663 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
2664 const ::boost::optional< OUString >& i_rItemImageURL,
2665 void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) )
2667 ItemListEvent aEvent;
2668 aEvent.Source = *this;
2669 aEvent.ItemPosition = i_nItemPosition;
2670 if ( !!i_rItemText )
2672 aEvent.ItemText.IsPresent = sal_True;
2673 aEvent.ItemText.Value = *i_rItemText;
2675 if ( !!i_rItemImageURL )
2677 aEvent.ItemImageURL.IsPresent = sal_True;
2678 aEvent.ItemImageURL.Value = *i_rItemImageURL;
2681 m_aItemListListeners.notifyEach( NotificationMethod, aEvent );
2684 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
2685 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2686 css::uno::XComponentContext *context,
2687 css::uno::Sequence<css::uno::Any> const &)
2689 return cppu::acquire(new UnoControlListBoxModel(context));
2693 // class UnoListBoxControl
2695 UnoListBoxControl::UnoListBoxControl()
2696 :UnoListBoxControl_Base()
2697 ,maActionListeners( *this )
2698 ,maItemListeners( *this )
2700 maComponentInfos.nWidth = 100;
2701 maComponentInfos.nHeight = 12;
2704 OUString UnoListBoxControl::GetComponentServiceName()
2706 return OUString("listbox");
2709 OUString UnoListBoxControl::getImplementationName()
2710 throw (css::uno::RuntimeException, std::exception)
2712 return OUString("stardiv.Toolkit.UnoListBoxControl");
2715 css::uno::Sequence<OUString> UnoListBoxControl::getSupportedServiceNames()
2716 throw (css::uno::RuntimeException, std::exception)
2718 auto s(UnoControlBase::getSupportedServiceNames());
2719 s.realloc(s.getLength() + 2);
2720 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlListBox";
2721 s[s.getLength() - 1] = "stardiv.vcl.control.ListBox";
2722 return s;
2725 void UnoListBoxControl::dispose() throw(uno::RuntimeException, std::exception)
2727 lang::EventObject aEvt;
2728 aEvt.Source = (::cppu::OWeakObject*)this;
2729 maActionListeners.disposeAndClear( aEvt );
2730 maItemListeners.disposeAndClear( aEvt );
2731 UnoControl::dispose();
2734 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2736 if ( getPeer().is() )
2738 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2739 DBG_ASSERT( xListBox.is(), "XListBox?" );
2741 uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos();
2742 uno::Any aAny;
2743 aAny <<= aSeq;
2744 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, false );
2748 void UnoListBoxControl::updateFromModel()
2750 UnoControlBase::updateFromModel();
2752 Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
2753 ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2755 EventObject aEvent( getModel() );
2756 xItemListListener->itemListChanged( aEvent );
2758 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2759 // already did this, our peer(s) can only legitimately set the selection after they have the string
2760 // item list, which we just notified with the itemListChanged call.
2761 const OUString sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ) );
2762 ImplSetPeerProperty( sSelectedItemsPropName, ImplGetPropertyValue( sSelectedItemsPropName ) );
2765 void UnoListBoxControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
2767 if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
2768 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2769 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2770 // will be forwarded to the peer, which will update itself accordingly.
2771 return;
2773 UnoControl::ImplSetPeerProperty( rPropName, rVal );
2776 void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
2778 UnoControl::createPeer( rxToolkit, rParentPeer );
2780 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2781 xListBox->addItemListener( this );
2783 if ( maActionListeners.getLength() )
2784 xListBox->addActionListener( &maActionListeners );
2787 void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
2789 maActionListeners.addInterface( l );
2790 if( getPeer().is() && maActionListeners.getLength() == 1 )
2792 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2793 xListBox->addActionListener( &maActionListeners );
2797 void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
2799 if( getPeer().is() && maActionListeners.getLength() == 1 )
2801 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2802 xListBox->removeActionListener( &maActionListeners );
2804 maActionListeners.removeInterface( l );
2807 void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
2809 maItemListeners.addInterface( l );
2812 void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
2814 maItemListeners.removeInterface( l );
2817 void UnoListBoxControl::addItem( const OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
2819 uno::Sequence< OUString> aSeq( 1 );
2820 aSeq.getArray()[0] = aItem;
2821 addItems( aSeq, nPos );
2824 void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
2826 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2827 uno::Sequence< OUString> aSeq;
2828 aVal >>= aSeq;
2829 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2830 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2831 sal_uInt16 nNewLen = nOldLen + nNewItems;
2833 uno::Sequence< OUString> aNewSeq( nNewLen );
2834 OUString* pNewData = aNewSeq.getArray();
2835 OUString* pOldData = aSeq.getArray();
2837 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2838 nPos = (sal_uInt16) nOldLen;
2840 sal_uInt16 n;
2841 // Items vor der Einfuege-Position
2842 for ( n = 0; n < nPos; n++ )
2843 pNewData[n] = pOldData[n];
2845 // Neue Items
2846 for ( n = 0; n < nNewItems; n++ )
2847 pNewData[nPos+n] = aItems.getConstArray()[n];
2849 // Rest der alten Items
2850 for ( n = nPos; n < nOldLen; n++ )
2851 pNewData[nNewItems+n] = pOldData[n];
2853 uno::Any aAny;
2854 aAny <<= aNewSeq;
2855 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, true );
2858 void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException, std::exception)
2860 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2861 uno::Sequence< OUString> aSeq;
2862 aVal >>= aSeq;
2863 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2864 if ( nOldLen && ( nPos < nOldLen ) )
2866 if ( nCount > ( nOldLen-nPos ) )
2867 nCount = nOldLen-nPos;
2869 sal_uInt16 nNewLen = nOldLen - nCount;
2871 uno::Sequence< OUString> aNewSeq( nNewLen );
2872 OUString* pNewData = aNewSeq.getArray();
2873 OUString* pOldData = aSeq.getArray();
2875 sal_uInt16 n;
2876 // Items vor der Entfern-Position
2877 for ( n = 0; n < nPos; n++ )
2878 pNewData[n] = pOldData[n];
2880 // Rest der Items
2881 for ( n = nPos; n < (nOldLen-nCount); n++ )
2882 pNewData[n] = pOldData[n+nCount];
2884 uno::Any aAny;
2885 aAny <<= aNewSeq;
2886 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, true );
2890 sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException, std::exception)
2892 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2893 uno::Sequence< OUString> aSeq;
2894 aVal >>= aSeq;
2895 return (sal_Int16)aSeq.getLength();
2898 OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
2900 OUString aItem;
2901 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2902 uno::Sequence< OUString> aSeq;
2903 aVal >>= aSeq;
2904 if ( nPos < aSeq.getLength() )
2905 aItem = aSeq.getConstArray()[nPos];
2906 return aItem;
2909 uno::Sequence< OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException, std::exception)
2911 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2912 uno::Sequence< OUString> aSeq;
2913 aVal >>= aSeq;
2914 return aSeq;
2917 sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException, std::exception)
2919 sal_Int16 n = -1;
2920 if ( getPeer().is() )
2922 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2923 n = xListBox->getSelectedItemPos();
2925 return n;
2928 uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException, std::exception)
2930 uno::Sequence<sal_Int16> aSeq;
2931 if ( getPeer().is() )
2933 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2934 aSeq = xListBox->getSelectedItemsPos();
2936 return aSeq;
2939 OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException, std::exception)
2941 OUString aItem;
2942 if ( getPeer().is() )
2944 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2945 aItem = xListBox->getSelectedItem();
2947 return aItem;
2950 uno::Sequence< OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException, std::exception)
2952 uno::Sequence< OUString> aSeq;
2953 if ( getPeer().is() )
2955 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2956 aSeq = xListBox->getSelectedItems();
2958 return aSeq;
2961 void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException, std::exception)
2963 if ( getPeer().is() )
2965 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2966 xListBox->selectItemPos( nPos, bSelect );
2968 ImplUpdateSelectedItemsProperty();
2971 void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException, std::exception)
2973 if ( getPeer().is() )
2975 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2976 xListBox->selectItemsPos( aPositions, bSelect );
2978 ImplUpdateSelectedItemsProperty();
2981 void UnoListBoxControl::selectItem( const OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException, std::exception)
2983 if ( getPeer().is() )
2985 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2986 xListBox->selectItem( aItem, bSelect );
2988 ImplUpdateSelectedItemsProperty();
2991 void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException, std::exception)
2993 if ( getPeer().is() )
2995 uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2996 xListBox->makeVisible( nEntry );
3000 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException, std::exception)
3002 uno::Any aAny;
3003 aAny <<= (sal_Int16)nLines;
3004 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, true );
3007 sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException, std::exception)
3009 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
3012 sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException, std::exception)
3014 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION );
3017 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException, std::exception)
3019 uno::Any aAny;
3020 aAny <<= bMulti;
3021 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, true );
3024 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException, std::exception)
3026 ImplUpdateSelectedItemsProperty();
3027 if ( maItemListeners.getLength() )
3031 maItemListeners.itemStateChanged( rEvent );
3033 catch( const Exception& e )
3035 #if OSL_DEBUG_LEVEL == 0
3036 (void) e; // suppress warning
3037 #else
3038 OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
3039 sMessage += OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
3040 OSL_FAIL( sMessage.getStr() );
3041 #endif
3046 awt::Size UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException, std::exception)
3048 return Impl_getMinimumSize();
3051 awt::Size UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException, std::exception)
3053 return Impl_getPreferredSize();
3056 awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException, std::exception)
3058 return Impl_calcAdjustedSize( rNewSize );
3061 awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException, std::exception)
3063 return Impl_getMinimumSize( nCols, nLines );
3066 void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException, std::exception)
3068 Impl_getColumnsAndLines( nCols, nLines );
3071 sal_Bool SAL_CALL UnoListBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException, std::exception )
3073 ::osl::MutexGuard aGuard( GetMutex() );
3075 const Reference< XItemList > xOldItems( getModel(), UNO_QUERY );
3076 OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
3077 const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY );
3078 OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoListBoxControl::setModel: illegal new model!" );
3080 if ( !UnoListBoxControl_Base::setModel( i_rModel ) )
3081 return sal_False;
3083 if ( xOldItems.is() )
3084 xOldItems->removeItemListListener( this );
3085 if ( xNewItems.is() )
3086 xNewItems->addItemListListener( this );
3088 return sal_True;
3091 void SAL_CALL UnoListBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3093 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3094 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
3095 if ( xPeerListener.is() )
3096 xPeerListener->listItemInserted( i_rEvent );
3099 void SAL_CALL UnoListBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3101 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3102 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
3103 if ( xPeerListener.is() )
3104 xPeerListener->listItemRemoved( i_rEvent );
3107 void SAL_CALL UnoListBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3109 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3110 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
3111 if ( xPeerListener.is() )
3112 xPeerListener->listItemModified( i_rEvent );
3115 void SAL_CALL UnoListBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException, std::exception)
3117 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3118 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
3119 if ( xPeerListener.is() )
3120 xPeerListener->allItemsRemoved( i_rEvent );
3123 void SAL_CALL UnoListBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException, std::exception)
3125 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3126 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
3127 if ( xPeerListener.is() )
3128 xPeerListener->itemListChanged( i_rEvent );
3131 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
3132 stardiv_Toolkit_UnoListBoxControl_get_implementation(
3133 css::uno::XComponentContext *,
3134 css::uno::Sequence<css::uno::Any> const &)
3136 return cppu::acquire(new UnoListBoxControl());
3140 // class UnoControlComboBoxModel
3142 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference< XComponentContext >& rxContext )
3143 :UnoControlListBoxModel( rxContext, ConstructWithoutProperties )
3145 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox );
3148 OUString UnoControlComboBoxModel::getImplementationName()
3149 throw (css::uno::RuntimeException, std::exception)
3151 return OUString("stardiv.Toolkit.UnoControlComboBoxModel");
3154 css::uno::Sequence<OUString> UnoControlComboBoxModel::getSupportedServiceNames()
3155 throw (css::uno::RuntimeException, std::exception)
3157 auto s(UnoControlModel::getSupportedServiceNames());
3158 s.realloc(s.getLength() + 2);
3159 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlComboBoxModel";
3160 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.ComboBox";
3161 return s;
3164 uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
3166 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3167 return xInfo;
3170 ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper()
3172 static UnoPropertyArrayHelper* pHelper = NULL;
3173 if ( !pHelper )
3175 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3176 pHelper = new UnoPropertyArrayHelper( aIDs );
3178 return *pHelper;
3182 OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
3184 return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel );
3186 void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception, std::exception)
3188 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
3190 if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_xData->m_bSettingLegacyProperty)
3192 // synchronize the legacy StringItemList property with our list items
3193 Sequence< OUString > aStringItemList;
3194 Any aPropValue;
3195 getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
3196 OSL_VERIFY( aPropValue >>= aStringItemList );
3198 ::std::vector< ListItem > aItems( aStringItemList.getLength() );
3199 ::std::transform(
3200 aStringItemList.getConstArray(),
3201 aStringItemList.getConstArray() + aStringItemList.getLength(),
3202 aItems.begin(),
3203 CreateListItem()
3205 m_xData->setAllItems( aItems );
3207 // since an XItemListListener does not have a "all items modified" or some such method,
3208 // we simulate this by notifying removal of all items, followed by insertion of all new
3209 // items
3210 lang::EventObject aEvent;
3211 aEvent.Source = *this;
3212 m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
3213 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
3214 // which is wrong for the above notifications ...
3218 uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3220 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3222 uno::Any aAny;
3223 aAny <<= OUString::createFromAscii( szServiceName_UnoControlComboBox );
3224 return aAny;
3226 return UnoControlModel::ImplGetDefaultValue( nPropId );
3229 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
3230 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
3231 css::uno::XComponentContext *context,
3232 css::uno::Sequence<css::uno::Any> const &)
3234 return cppu::acquire(new UnoControlComboBoxModel(context));
3238 // class UnoComboBoxControl
3240 UnoComboBoxControl::UnoComboBoxControl()
3241 :UnoEditControl()
3242 ,maActionListeners( *this )
3243 ,maItemListeners( *this )
3245 maComponentInfos.nWidth = 100;
3246 maComponentInfos.nHeight = 12;
3249 OUString UnoComboBoxControl::getImplementationName()
3250 throw (css::uno::RuntimeException, std::exception)
3252 return OUString( "stardiv.Toolkit.UnoComboBoxControl");
3255 css::uno::Sequence<OUString> UnoComboBoxControl::getSupportedServiceNames()
3256 throw (css::uno::RuntimeException, std::exception)
3258 auto s(UnoEditControl::getSupportedServiceNames());
3259 s.realloc(s.getLength() + 2);
3260 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlComboBox";
3261 s[s.getLength() - 1] = "stardiv.vcl.control.ComboBox";
3262 return s;
3265 OUString UnoComboBoxControl::GetComponentServiceName()
3267 return OUString("combobox");
3270 void UnoComboBoxControl::dispose() throw(uno::RuntimeException, std::exception)
3272 lang::EventObject aEvt;
3273 aEvt.Source = (::cppu::OWeakObject*)this;
3274 maActionListeners.disposeAndClear( aEvt );
3275 maItemListeners.disposeAndClear( aEvt );
3276 UnoControl::dispose();
3278 uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
3280 uno::Any aRet = ::cppu::queryInterface( rType,
3281 (static_cast< awt::XComboBox* >(this)) );
3282 if ( !aRet.hasValue() )
3284 aRet = ::cppu::queryInterface( rType,
3285 (static_cast< awt::XItemListener* >(this)) );
3286 if ( !aRet.hasValue() )
3288 aRet = ::cppu::queryInterface( rType,
3289 (static_cast< awt::XItemListListener* >(this)) );
3292 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
3294 // lang::XTypeProvider
3295 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl )
3296 cppu::UnoType<awt::XComboBox>::get(),
3297 cppu::UnoType<awt::XItemListener>::get(),
3298 cppu::UnoType<awt::XItemListListener>::get(),
3299 UnoEditControl::getTypes()
3300 IMPL_XTYPEPROVIDER_END
3302 void UnoComboBoxControl::updateFromModel()
3304 UnoEditControl::updateFromModel();
3306 Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
3307 ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3309 EventObject aEvent( getModel() );
3310 xItemListListener->itemListChanged( aEvent );
3312 void UnoComboBoxControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
3314 if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
3315 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3316 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3317 // will be forwarded to the peer, which will update itself accordingly.
3318 return;
3320 UnoEditControl::ImplSetPeerProperty( rPropName, rVal );
3322 void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
3324 UnoEditControl::createPeer( rxToolkit, rParentPeer );
3326 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
3327 if ( maActionListeners.getLength() )
3328 xComboBox->addActionListener( &maActionListeners );
3329 if ( maItemListeners.getLength() )
3330 xComboBox->addItemListener( &maItemListeners );
3333 void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
3335 maActionListeners.addInterface( l );
3336 if( getPeer().is() && maActionListeners.getLength() == 1 )
3338 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
3339 xComboBox->addActionListener( &maActionListeners );
3343 void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException, std::exception)
3345 if( getPeer().is() && maActionListeners.getLength() == 1 )
3347 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
3348 xComboBox->removeActionListener( &maActionListeners );
3350 maActionListeners.removeInterface( l );
3353 void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
3355 maItemListeners.addInterface( l );
3356 if( getPeer().is() && maItemListeners.getLength() == 1 )
3358 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
3359 xComboBox->addItemListener( &maItemListeners );
3363 void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException, std::exception)
3365 if( getPeer().is() && maItemListeners.getLength() == 1 )
3367 // This call is prettier than creating a Ref and calling query
3368 uno::Reference < awt::XComboBox > xComboBox( getPeer(), uno::UNO_QUERY );
3369 xComboBox->removeItemListener( &maItemListeners );
3371 maItemListeners.removeInterface( l );
3373 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException, std::exception)
3375 if ( maItemListeners.getLength() )
3379 maItemListeners.itemStateChanged( rEvent );
3381 catch( const Exception& e )
3383 #if OSL_DEBUG_LEVEL == 0
3384 (void) e; // suppress warning
3385 #else
3386 OString sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
3387 sMessage += OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
3388 OSL_FAIL( sMessage.getStr() );
3389 #endif
3393 sal_Bool SAL_CALL UnoComboBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException, std::exception )
3395 ::osl::MutexGuard aGuard( GetMutex() );
3397 const Reference< XItemList > xOldItems( getModel(), UNO_QUERY );
3398 OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3399 const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY );
3400 OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3402 if ( !UnoEditControl::setModel( i_rModel ) )
3403 return sal_False;
3405 if ( xOldItems.is() )
3406 xOldItems->removeItemListListener( this );
3407 if ( xNewItems.is() )
3408 xNewItems->addItemListListener( this );
3410 return sal_True;
3413 void SAL_CALL UnoComboBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3415 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3416 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3417 if ( xPeerListener.is() )
3418 xPeerListener->listItemInserted( i_rEvent );
3421 void SAL_CALL UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3423 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3424 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3425 if ( xPeerListener.is() )
3426 xPeerListener->listItemRemoved( i_rEvent );
3429 void SAL_CALL UnoComboBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException, std::exception)
3431 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3432 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3433 if ( xPeerListener.is() )
3434 xPeerListener->listItemModified( i_rEvent );
3437 void SAL_CALL UnoComboBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException, std::exception)
3439 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3440 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3441 if ( xPeerListener.is() )
3442 xPeerListener->allItemsRemoved( i_rEvent );
3445 void SAL_CALL UnoComboBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException, std::exception)
3447 const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
3448 OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3449 if ( xPeerListener.is() )
3450 xPeerListener->itemListChanged( i_rEvent );
3453 void UnoComboBoxControl::addItem( const OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
3455 uno::Sequence< OUString> aSeq( 1 );
3456 aSeq.getArray()[0] = aItem;
3457 addItems( aSeq, nPos );
3460 void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
3462 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3463 uno::Sequence< OUString> aSeq;
3464 aVal >>= aSeq;
3465 sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
3466 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
3467 sal_uInt16 nNewLen = nOldLen + nNewItems;
3469 uno::Sequence< OUString> aNewSeq( nNewLen );
3470 OUString* pNewData = aNewSeq.getArray();
3471 const OUString* pOldData = aSeq.getConstArray();
3473 if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
3474 nPos = (sal_uInt16) nOldLen;
3476 sal_uInt16 n;
3477 // items before the insert position
3478 for ( n = 0; n < nPos; n++ )
3479 pNewData[n] = pOldData[n];
3481 // New items
3482 for ( n = 0; n < nNewItems; n++ )
3483 pNewData[nPos+n] = aItems.getConstArray()[n];
3485 // remainder of old items
3486 for ( n = nPos; n < nOldLen; n++ )
3487 pNewData[nNewItems+n] = pOldData[n];
3489 uno::Any aAny;
3490 aAny <<= aNewSeq;
3491 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, true );
3494 void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException, std::exception)
3496 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3497 uno::Sequence< OUString> aSeq;
3498 aVal >>= aSeq;
3499 sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
3500 if ( nOldLen && ( nPos < nOldLen ) )
3502 if ( nCount > ( nOldLen-nPos ) )
3503 nCount = nOldLen-nPos;
3505 sal_uInt16 nNewLen = nOldLen - nCount;
3507 uno::Sequence< OUString> aNewSeq( nNewLen );
3508 OUString* pNewData = aNewSeq.getArray();
3509 OUString* pOldData = aSeq.getArray();
3511 sal_uInt16 n;
3512 // items before the deletion position
3513 for ( n = 0; n < nPos; n++ )
3514 pNewData[n] = pOldData[n];
3516 // remainder of old items
3517 for ( n = nPos; n < (nOldLen-nCount); n++ )
3518 pNewData[n] = pOldData[n+nCount];
3520 uno::Any aAny;
3521 aAny <<= aNewSeq;
3522 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, true );
3526 sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException, std::exception)
3528 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3529 uno::Sequence< OUString> aSeq;
3530 aVal >>= aSeq;
3531 return (sal_Int16)aSeq.getLength();
3534 OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException, std::exception)
3536 OUString aItem;
3537 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3538 uno::Sequence< OUString> aSeq;
3539 aVal >>= aSeq;
3540 if ( nPos < aSeq.getLength() )
3541 aItem = aSeq.getConstArray()[nPos];
3542 return aItem;
3545 uno::Sequence< OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException, std::exception)
3547 uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3548 uno::Sequence< OUString> aSeq;
3549 aVal >>= aSeq;
3550 return aSeq;
3553 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException, std::exception)
3555 uno::Any aAny;
3556 aAny <<= nLines;
3557 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, true );
3560 sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException, std::exception)
3562 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
3565 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
3566 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3567 css::uno::XComponentContext *,
3568 css::uno::Sequence<css::uno::Any> const &)
3570 return cppu::acquire(new UnoComboBoxControl());
3574 // UnoSpinFieldControl
3576 UnoSpinFieldControl::UnoSpinFieldControl()
3577 :UnoEditControl()
3578 ,maSpinListeners( *this )
3580 mbRepeat = false;
3583 // uno::XInterface
3584 uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
3586 uno::Any aRet = ::cppu::queryInterface( rType,
3587 (static_cast< awt::XSpinField* >(this)) );
3588 return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
3591 // lang::XTypeProvider
3592 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl )
3593 cppu::UnoType<awt::XSpinField>::get(),
3594 UnoEditControl::getTypes()
3595 IMPL_XTYPEPROVIDER_END
3597 void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
3599 UnoEditControl::createPeer( rxToolkit, rParentPeer );
3601 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3602 xField->enableRepeat( mbRepeat );
3603 if ( maSpinListeners.getLength() )
3604 xField->addSpinListener( &maSpinListeners );
3607 // ::com::sun::star::awt::XSpinField
3608 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3610 maSpinListeners.addInterface( l );
3611 if( getPeer().is() && maSpinListeners.getLength() == 1 )
3613 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3614 xField->addSpinListener( &maSpinListeners );
3618 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3620 if( getPeer().is() && maSpinListeners.getLength() == 1 )
3622 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3623 xField->removeSpinListener( &maSpinListeners );
3625 maSpinListeners.removeInterface( l );
3628 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException, std::exception)
3630 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3631 if ( xField.is() )
3632 xField->up();
3635 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException, std::exception)
3637 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3638 if ( xField.is() )
3639 xField->down();
3642 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException, std::exception)
3644 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3645 if ( xField.is() )
3646 xField->first();
3649 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException, std::exception)
3651 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3652 if ( xField.is() )
3653 xField->last();
3656 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException, std::exception)
3658 mbRepeat = bRepeat;
3660 uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3661 if ( xField.is() )
3662 xField->enableRepeat( bRepeat );
3666 // class UnoControlDateFieldModel
3668 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference< XComponentContext >& rxContext )
3669 :UnoControlModel( rxContext )
3671 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField );
3674 OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
3676 return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel );
3679 uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3681 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3683 uno::Any aAny;
3684 aAny <<= OUString::createFromAscii( szServiceName_UnoControlDateField );
3685 return aAny;
3687 return UnoControlModel::ImplGetDefaultValue( nPropId );
3691 ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper()
3693 static UnoPropertyArrayHelper* pHelper = NULL;
3694 if ( !pHelper )
3696 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3697 pHelper = new UnoPropertyArrayHelper( aIDs );
3699 return *pHelper;
3702 // beans::XMultiPropertySet
3703 uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
3705 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3706 return xInfo;
3709 OUString UnoControlDateFieldModel::getImplementationName()
3710 throw (css::uno::RuntimeException, std::exception)
3712 return OUString("stardiv.Toolkit.UnoControlDateFieldModel");
3715 css::uno::Sequence<OUString>
3716 UnoControlDateFieldModel::getSupportedServiceNames()
3717 throw (css::uno::RuntimeException, std::exception)
3719 auto s(UnoControlModel::getSupportedServiceNames());
3720 s.realloc(s.getLength() + 2);
3721 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlDateFieldModel";
3722 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.DateField";
3723 return s;
3726 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
3727 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3728 css::uno::XComponentContext *context,
3729 css::uno::Sequence<css::uno::Any> const &)
3731 return cppu::acquire(new UnoControlDateFieldModel(context));
3735 // class UnoDateFieldControl
3737 UnoDateFieldControl::UnoDateFieldControl()
3738 :UnoSpinFieldControl()
3740 mnFirst = util::Date( 1, 1, 1900 );
3741 mnLast = util::Date( 31, 12, 2200 );
3742 mbLongFormat = TRISTATE_INDET;
3745 OUString UnoDateFieldControl::GetComponentServiceName()
3747 return OUString("datefield");
3750 // uno::XInterface
3751 uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
3753 uno::Any aRet = ::cppu::queryInterface( rType,
3754 (static_cast< awt::XDateField* >(this)) );
3755 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3758 // lang::XTypeProvider
3759 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl )
3760 cppu::UnoType<awt::XDateField>::get(),
3761 UnoSpinFieldControl::getTypes()
3762 IMPL_XTYPEPROVIDER_END
3764 void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
3766 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3768 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3769 xField->setFirst( mnFirst );
3770 xField->setLast( mnLast );
3771 if ( mbLongFormat != TRISTATE_INDET )
3772 xField->setLongFormat( mbLongFormat );
3776 void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException, std::exception)
3778 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
3780 // also change the text property (#i25106#)
3781 if ( xPeer.is() )
3783 OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
3784 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), false );
3787 // re-calc the Date property
3788 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3789 uno::Any aValue;
3790 if ( xField->isEmpty() )
3792 // the field says it's empty
3793 bool bEnforceFormat = true;
3794 if ( xPeer.is() )
3795 xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat;
3796 if ( !bEnforceFormat )
3798 // and it also says that it is currently accepting invalid inputs, without
3799 // forcing it to a valid date
3800 uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY );
3801 if ( xText.is() && xText->getText().getLength() )
3802 // and in real, the text of the peer is *not* empty
3803 // -> simulate an invalid date, which is different from "no date"
3804 aValue <<= util::Date();
3807 else
3808 aValue <<= xField->getDate();
3810 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, false );
3812 // multiplex the event
3813 if ( GetTextListeners().getLength() )
3814 GetTextListeners().textChanged( e );
3817 void UnoDateFieldControl::setDate( const util::Date& Date ) throw(uno::RuntimeException, std::exception)
3819 uno::Any aAny;
3820 aAny <<= Date;
3821 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, true );
3824 util::Date UnoDateFieldControl::getDate() throw(uno::RuntimeException, std::exception)
3826 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE );
3829 void UnoDateFieldControl::setMin( const util::Date& Date ) throw(uno::RuntimeException, std::exception)
3831 uno::Any aAny;
3832 aAny <<= Date;
3833 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, true );
3836 util::Date UnoDateFieldControl::getMin() throw(uno::RuntimeException, std::exception)
3838 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN );
3841 void UnoDateFieldControl::setMax( const util::Date& Date ) throw(uno::RuntimeException, std::exception)
3843 uno::Any aAny;
3844 aAny <<= Date;
3845 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, true );
3848 util::Date UnoDateFieldControl::getMax() throw(uno::RuntimeException, std::exception)
3850 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX );
3853 void UnoDateFieldControl::setFirst( const util::Date& Date ) throw(uno::RuntimeException, std::exception)
3855 mnFirst = Date;
3856 if ( getPeer().is() )
3858 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3859 xField->setFirst( Date );
3863 util::Date UnoDateFieldControl::getFirst() throw(uno::RuntimeException, std::exception)
3865 return mnFirst;
3868 void UnoDateFieldControl::setLast( const util::Date& Date ) throw(uno::RuntimeException, std::exception)
3870 mnLast = Date;
3871 if ( getPeer().is() )
3873 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3874 xField->setLast( Date );
3878 util::Date UnoDateFieldControl::getLast() throw(uno::RuntimeException, std::exception)
3880 return mnLast;
3883 void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException, std::exception)
3885 mbLongFormat = bLong ? TRISTATE_TRUE : TRISTATE_FALSE;
3886 if ( getPeer().is() )
3888 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3889 xField->setLongFormat( bLong );
3893 sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException, std::exception)
3895 return mbLongFormat == TRISTATE_TRUE;
3898 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException, std::exception)
3900 if ( getPeer().is() )
3902 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3903 xField->setEmpty();
3907 sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException, std::exception)
3909 bool bEmpty = false;
3910 if ( getPeer().is() )
3912 uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3913 bEmpty = xField->isEmpty();
3915 return bEmpty;
3918 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException, std::exception)
3920 uno::Any aAny;
3921 aAny <<= bStrict;
3922 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, true );
3925 sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException, std::exception)
3927 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3930 OUString UnoDateFieldControl::getImplementationName()
3931 throw (css::uno::RuntimeException, std::exception)
3933 return OUString("stardiv.Toolkit.UnoDateFieldControl");
3936 css::uno::Sequence<OUString> UnoDateFieldControl::getSupportedServiceNames()
3937 throw (css::uno::RuntimeException, std::exception)
3939 auto s(UnoSpinFieldControl::getSupportedServiceNames());
3940 s.realloc(s.getLength() + 2);
3941 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlDateField";
3942 s[s.getLength() - 1] = "stardiv.vcl.control.DateField";
3943 return s;
3946 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
3947 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3948 css::uno::XComponentContext *,
3949 css::uno::Sequence<css::uno::Any> const &)
3951 return cppu::acquire(new UnoDateFieldControl());
3955 // class UnoControlTimeFieldModel
3957 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference< XComponentContext >& rxContext )
3958 :UnoControlModel( rxContext )
3960 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField );
3963 OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
3965 return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel );
3968 uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3970 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3972 uno::Any aAny;
3973 aAny <<= OUString::createFromAscii( szServiceName_UnoControlTimeField );
3974 return aAny;
3976 return UnoControlModel::ImplGetDefaultValue( nPropId );
3980 ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper()
3982 static UnoPropertyArrayHelper* pHelper = NULL;
3983 if ( !pHelper )
3985 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
3986 pHelper = new UnoPropertyArrayHelper( aIDs );
3988 return *pHelper;
3991 // beans::XMultiPropertySet
3992 uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
3994 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3995 return xInfo;
3998 OUString UnoControlTimeFieldModel::getImplementationName()
3999 throw (css::uno::RuntimeException, std::exception)
4001 return OUString("stardiv.Toolkit.UnoControlTimeFieldModel");
4004 css::uno::Sequence<OUString>
4005 UnoControlTimeFieldModel::getSupportedServiceNames()
4006 throw (css::uno::RuntimeException, std::exception)
4008 auto s(UnoControlModel::getSupportedServiceNames());
4009 s.realloc(s.getLength() + 2);
4010 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlTimeFieldModel";
4011 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.TimeField";
4012 return s;
4015 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4016 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
4017 css::uno::XComponentContext *context,
4018 css::uno::Sequence<css::uno::Any> const &)
4020 return cppu::acquire(new UnoControlTimeFieldModel(context));
4024 // class UnoTimeFieldControl
4026 UnoTimeFieldControl::UnoTimeFieldControl()
4027 :UnoSpinFieldControl()
4029 mnFirst = util::Time( 0, 0, 0, 0, false );
4030 mnLast = util::Time( 999999999, 59, 59, 23, false );
4033 OUString UnoTimeFieldControl::GetComponentServiceName()
4035 return OUString("timefield");
4038 // uno::XInterface
4039 uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4041 uno::Any aRet = ::cppu::queryInterface( rType,
4042 (static_cast< awt::XTimeField* >(this)) );
4043 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
4046 // lang::XTypeProvider
4047 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl )
4048 cppu::UnoType<awt::XTimeField>::get(),
4049 UnoSpinFieldControl::getTypes()
4050 IMPL_XTYPEPROVIDER_END
4052 void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
4054 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
4056 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4057 xField->setFirst( mnFirst );
4058 xField->setLast( mnLast );
4061 void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException, std::exception)
4063 // also change the text property (#i25106#)
4064 uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
4065 OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
4066 ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), false );
4068 // re-calc the Time property
4069 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4070 uno::Any aValue;
4071 if ( !xField->isEmpty() )
4072 aValue <<= xField->getTime();
4073 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, false );
4075 // multiplex the event
4076 if ( GetTextListeners().getLength() )
4077 GetTextListeners().textChanged( e );
4080 void UnoTimeFieldControl::setTime( const util::Time& Time ) throw(uno::RuntimeException, std::exception)
4082 uno::Any aAny;
4083 aAny <<= Time;
4084 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, true );
4087 util::Time UnoTimeFieldControl::getTime() throw(uno::RuntimeException, std::exception)
4089 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME );
4092 void UnoTimeFieldControl::setMin( const util::Time& Time ) throw(uno::RuntimeException, std::exception)
4094 uno::Any aAny;
4095 aAny <<= Time;
4096 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, true );
4099 util::Time UnoTimeFieldControl::getMin() throw(uno::RuntimeException, std::exception)
4101 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN );
4104 void UnoTimeFieldControl::setMax( const util::Time& Time ) throw(uno::RuntimeException, std::exception)
4106 uno::Any aAny;
4107 aAny <<= Time;
4108 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, true );
4111 util::Time UnoTimeFieldControl::getMax() throw(uno::RuntimeException, std::exception)
4113 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX );
4116 void UnoTimeFieldControl::setFirst( const util::Time& Time ) throw(uno::RuntimeException, std::exception)
4118 mnFirst = Time;
4119 if ( getPeer().is() )
4121 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4122 xField->setFirst( mnFirst );
4126 util::Time UnoTimeFieldControl::getFirst() throw(uno::RuntimeException, std::exception)
4128 return mnFirst;
4131 void UnoTimeFieldControl::setLast( const util::Time& Time ) throw(uno::RuntimeException, std::exception)
4133 mnLast = Time;
4134 if ( getPeer().is() )
4136 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4137 xField->setFirst( mnLast );
4141 util::Time UnoTimeFieldControl::getLast() throw(uno::RuntimeException, std::exception)
4143 return mnLast;
4146 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException, std::exception)
4148 if ( getPeer().is() )
4150 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4151 xField->setEmpty();
4155 sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException, std::exception)
4157 bool bEmpty = false;
4158 if ( getPeer().is() )
4160 uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
4161 bEmpty = xField->isEmpty();
4163 return bEmpty;
4166 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException, std::exception)
4168 uno::Any aAny;
4169 aAny <<= bStrict;
4170 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, true );
4173 sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException, std::exception)
4175 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4178 OUString UnoTimeFieldControl::getImplementationName()
4179 throw (css::uno::RuntimeException, std::exception)
4181 return OUString("stardiv.Toolkit.UnoTimeFieldControl");
4184 css::uno::Sequence<OUString> UnoTimeFieldControl::getSupportedServiceNames()
4185 throw (css::uno::RuntimeException, std::exception)
4187 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4188 s.realloc(s.getLength() + 2);
4189 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlTimeField";
4190 s[s.getLength() - 1] = "stardiv.vcl.control.TimeField";
4191 return s;
4194 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4195 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
4196 css::uno::XComponentContext *,
4197 css::uno::Sequence<css::uno::Any> const &)
4199 return cppu::acquire(new UnoTimeFieldControl());
4203 // class UnoControlNumericFieldModel
4205 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference< XComponentContext >& rxContext )
4206 :UnoControlModel( rxContext )
4208 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField );
4211 OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
4213 return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel );
4216 uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4218 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4220 uno::Any aAny;
4221 aAny <<= OUString::createFromAscii( szServiceName_UnoControlNumericField );
4222 return aAny;
4224 return UnoControlModel::ImplGetDefaultValue( nPropId );
4228 ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper()
4230 static UnoPropertyArrayHelper* pHelper = NULL;
4231 if ( !pHelper )
4233 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
4234 pHelper = new UnoPropertyArrayHelper( aIDs );
4236 return *pHelper;
4239 // beans::XMultiPropertySet
4240 uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
4242 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4243 return xInfo;
4246 OUString UnoControlNumericFieldModel::getImplementationName()
4247 throw (css::uno::RuntimeException, std::exception)
4249 return OUString("stardiv.Toolkit.UnoControlNumericFieldModel");
4252 css::uno::Sequence<OUString>
4253 UnoControlNumericFieldModel::getSupportedServiceNames()
4254 throw (css::uno::RuntimeException, std::exception)
4256 auto s(UnoControlModel::getSupportedServiceNames());
4257 s.realloc(s.getLength() + 2);
4258 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlNumericFieldModel";
4259 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.NumericField";
4260 return s;
4263 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4264 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
4265 css::uno::XComponentContext *context,
4266 css::uno::Sequence<css::uno::Any> const &)
4268 return cppu::acquire(new UnoControlNumericFieldModel(context));
4272 // class UnoNumericFieldControl
4274 UnoNumericFieldControl::UnoNumericFieldControl()
4275 :UnoSpinFieldControl()
4277 mnFirst = 0;
4278 mnLast = 0x7FFFFFFF;
4281 OUString UnoNumericFieldControl::GetComponentServiceName()
4283 return OUString("numericfield");
4286 // uno::XInterface
4287 uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4289 uno::Any aRet = ::cppu::queryInterface( rType,
4290 (static_cast< awt::XNumericField* >(this)) );
4291 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
4294 // lang::XTypeProvider
4295 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl )
4296 cppu::UnoType<awt::XNumericField>::get(),
4297 UnoSpinFieldControl::getTypes()
4298 IMPL_XTYPEPROVIDER_END
4300 void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
4302 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
4304 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
4305 xField->setFirst( mnFirst );
4306 xField->setLast( mnLast );
4310 void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException, std::exception)
4312 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
4313 uno::Any aAny;
4314 aAny <<= xField->getValue();
4315 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, false );
4317 if ( GetTextListeners().getLength() )
4318 GetTextListeners().textChanged( e );
4321 void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException, std::exception)
4323 uno::Any aAny;
4324 aAny <<= Value;
4325 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, true );
4328 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException, std::exception)
4330 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
4333 void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException, std::exception)
4335 uno::Any aAny;
4336 aAny <<= Value;
4337 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, true );
4340 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException, std::exception)
4342 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
4345 void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException, std::exception)
4347 uno::Any aAny;
4348 aAny <<= Value;
4349 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, true );
4352 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException, std::exception)
4354 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
4357 void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException, std::exception)
4359 mnFirst = Value;
4360 if ( getPeer().is() )
4362 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
4363 xField->setFirst( mnFirst );
4367 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException, std::exception)
4369 return mnFirst;
4372 void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException, std::exception)
4374 mnLast = Value;
4375 if ( getPeer().is() )
4377 uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
4378 xField->setLast( mnLast );
4382 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException, std::exception)
4384 return mnLast;
4387 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException, std::exception)
4389 uno::Any aAny;
4390 aAny <<= bStrict;
4391 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, true );
4394 sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException, std::exception)
4396 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4399 OUString UnoNumericFieldControl::getImplementationName()
4400 throw (css::uno::RuntimeException, std::exception)
4402 return OUString("stardiv.Toolkit.UnoNumericFieldControl");
4405 css::uno::Sequence<OUString> UnoNumericFieldControl::getSupportedServiceNames()
4406 throw (css::uno::RuntimeException, std::exception)
4408 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4409 s.realloc(s.getLength() + 2);
4410 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlNumericField";
4411 s[s.getLength() - 1] = "stardiv.vcl.control.NumericField";
4412 return s;
4415 void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException, std::exception)
4417 uno::Any aAny;
4418 aAny <<= Digits;
4419 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, true );
4422 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException, std::exception)
4424 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
4427 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException, std::exception)
4429 uno::Any aAny;
4430 aAny <<= Digits;
4431 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, true );
4434 sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException, std::exception)
4436 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
4439 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4440 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4441 css::uno::XComponentContext *,
4442 css::uno::Sequence<css::uno::Any> const &)
4444 return cppu::acquire(new UnoNumericFieldControl());
4448 // class UnoControlCurrencyFieldModel
4450 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference< XComponentContext >& rxContext )
4451 :UnoControlModel( rxContext )
4453 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField );
4456 OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
4458 return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel );
4461 uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4463 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4465 uno::Any aAny;
4466 aAny <<= OUString::createFromAscii( szServiceName_UnoControlCurrencyField );
4467 return aAny;
4469 if ( nPropId == BASEPROPERTY_CURSYM_POSITION )
4471 uno::Any aAny;
4472 aAny <<= false;
4473 return aAny;
4476 return UnoControlModel::ImplGetDefaultValue( nPropId );
4479 ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper()
4481 static UnoPropertyArrayHelper* pHelper = NULL;
4482 if ( !pHelper )
4484 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
4485 pHelper = new UnoPropertyArrayHelper( aIDs );
4487 return *pHelper;
4490 // beans::XMultiPropertySet
4491 uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
4493 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4494 return xInfo;
4497 OUString UnoControlCurrencyFieldModel::getImplementationName()
4498 throw (css::uno::RuntimeException, std::exception)
4500 return OUString("stardiv.Toolkit.UnoControlCurrencyFieldModel");
4503 css::uno::Sequence<OUString>
4504 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4505 throw (css::uno::RuntimeException, std::exception)
4507 auto s(UnoControlModel::getSupportedServiceNames());
4508 s.realloc(s.getLength() + 2);
4509 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyFieldModel";
4510 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.CurrencyField";
4511 return s;
4514 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4515 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4516 css::uno::XComponentContext *context,
4517 css::uno::Sequence<css::uno::Any> const &)
4519 return cppu::acquire(new UnoControlCurrencyFieldModel(context));
4523 // class UnoCurrencyFieldControl
4525 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4526 :UnoSpinFieldControl()
4528 mnFirst = 0;
4529 mnLast = 0x7FFFFFFF;
4532 OUString UnoCurrencyFieldControl::GetComponentServiceName()
4534 return OUString("longcurrencyfield");
4537 // uno::XInterface
4538 uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4540 uno::Any aRet = ::cppu::queryInterface( rType,
4541 (static_cast< awt::XCurrencyField* >(this)) );
4542 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
4545 // lang::XTypeProvider
4546 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl )
4547 cppu::UnoType<awt::XCurrencyField>::get(),
4548 UnoSpinFieldControl::getTypes()
4549 IMPL_XTYPEPROVIDER_END
4551 void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException, std::exception)
4553 UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
4555 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
4556 xField->setFirst( mnFirst );
4557 xField->setLast( mnLast );
4560 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException, std::exception)
4562 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
4563 uno::Any aAny;
4564 aAny <<= xField->getValue();
4565 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, false );
4567 if ( GetTextListeners().getLength() )
4568 GetTextListeners().textChanged( e );
4571 void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException, std::exception)
4573 uno::Any aAny;
4574 aAny <<= Value;
4575 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, true );
4578 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException, std::exception)
4580 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
4583 void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException, std::exception)
4585 uno::Any aAny;
4586 aAny <<= Value;
4587 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, true );
4590 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException, std::exception)
4592 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
4595 void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException, std::exception)
4597 uno::Any aAny;
4598 aAny <<= Value;
4599 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, true );
4602 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException, std::exception)
4604 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
4607 void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException, std::exception)
4609 mnFirst = Value;
4610 if ( getPeer().is() )
4612 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
4613 xField->setFirst( mnFirst );
4617 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException, std::exception)
4619 return mnFirst;
4622 void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException, std::exception)
4624 mnLast = Value;
4625 if ( getPeer().is() )
4627 uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
4628 xField->setLast( mnLast );
4632 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException, std::exception)
4634 return mnLast;
4637 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException, std::exception)
4639 uno::Any aAny;
4640 aAny <<= bStrict;
4641 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, true );
4644 sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException, std::exception)
4646 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4649 OUString UnoCurrencyFieldControl::getImplementationName()
4650 throw (css::uno::RuntimeException, std::exception)
4652 return OUString("stardiv.Toolkit.UnoCurrencyFieldControl");
4655 css::uno::Sequence<OUString>
4656 UnoCurrencyFieldControl::getSupportedServiceNames()
4657 throw (css::uno::RuntimeException, std::exception)
4659 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4660 s.realloc(s.getLength() + 2);
4661 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyField";
4662 s[s.getLength() - 1] = "stardiv.vcl.control.CurrencyField";
4663 return s;
4666 void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException, std::exception)
4668 uno::Any aAny;
4669 aAny <<= Digits;
4670 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, true );
4673 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException, std::exception)
4675 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
4678 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException, std::exception)
4680 uno::Any aAny;
4681 aAny <<= Digits;
4682 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, true );
4685 sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException, std::exception)
4687 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
4690 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4691 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4692 css::uno::XComponentContext *,
4693 css::uno::Sequence<css::uno::Any> const &)
4695 return cppu::acquire(new UnoCurrencyFieldControl());
4699 // class UnoControlPatternFieldModel
4701 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference< XComponentContext >& rxContext )
4702 :UnoControlModel( rxContext )
4704 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField );
4707 OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception)
4709 return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel );
4712 uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4714 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4716 uno::Any aAny;
4717 aAny <<= OUString::createFromAscii( szServiceName_UnoControlPatternField );
4718 return aAny;
4720 return UnoControlModel::ImplGetDefaultValue( nPropId );
4723 ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper()
4725 static UnoPropertyArrayHelper* pHelper = NULL;
4726 if ( !pHelper )
4728 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
4729 pHelper = new UnoPropertyArrayHelper( aIDs );
4731 return *pHelper;
4734 // beans::XMultiPropertySet
4735 uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
4737 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4738 return xInfo;
4741 OUString UnoControlPatternFieldModel::getImplementationName()
4742 throw (css::uno::RuntimeException, std::exception)
4744 return OUString("stardiv.Toolkit.UnoControlPatternFieldModel");
4747 css::uno::Sequence<OUString>
4748 UnoControlPatternFieldModel::getSupportedServiceNames()
4749 throw (css::uno::RuntimeException, std::exception)
4751 auto s(UnoControlModel::getSupportedServiceNames());
4752 s.realloc(s.getLength() + 2);
4753 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlPatternFieldModel";
4754 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.PatternField";
4755 return s;
4758 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4759 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4760 css::uno::XComponentContext *context,
4761 css::uno::Sequence<css::uno::Any> const &)
4763 return cppu::acquire(new UnoControlPatternFieldModel(context));
4767 // class UnoPatternFieldControl
4769 UnoPatternFieldControl::UnoPatternFieldControl()
4770 :UnoSpinFieldControl()
4774 OUString UnoPatternFieldControl::GetComponentServiceName()
4776 return OUString("patternfield");
4779 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
4781 sal_uInt16 nType = GetPropertyId( rPropName );
4782 if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) )
4784 // These masks cannot be set consecutively
4785 OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
4786 OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
4787 OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
4789 uno::Reference < awt::XPatternField > xPF( getPeer(), uno::UNO_QUERY );
4790 if (xPF.is())
4792 // same comment as in UnoControl::ImplSetPeerProperty - see there
4793 OUString sText( Text );
4794 ImplCheckLocalize( sText );
4795 xPF->setString( sText );
4796 xPF->setMasks( EditMask, LiteralMask );
4799 else
4800 UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal );
4804 // uno::XInterface
4805 uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4807 uno::Any aRet = ::cppu::queryInterface( rType,
4808 (static_cast< awt::XPatternField* >(this)) );
4809 return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
4812 // lang::XTypeProvider
4813 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl )
4814 cppu::UnoType<awt::XPatternField>::get(),
4815 UnoSpinFieldControl::getTypes()
4816 IMPL_XTYPEPROVIDER_END
4818 void UnoPatternFieldControl::setString( const OUString& rString ) throw(uno::RuntimeException, std::exception)
4820 setText( rString );
4823 OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException, std::exception)
4825 return getText();
4828 void UnoPatternFieldControl::setMasks( const OUString& EditMask, const OUString& LiteralMask ) throw(uno::RuntimeException, std::exception)
4830 uno::Any aAny;
4831 aAny <<= EditMask;
4832 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, true );
4833 aAny <<= LiteralMask;
4834 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, true );
4837 void UnoPatternFieldControl::getMasks( OUString& EditMask, OUString& LiteralMask ) throw(uno::RuntimeException, std::exception)
4839 EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
4840 LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
4843 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException, std::exception)
4845 uno::Any aAny;
4846 aAny <<= bStrict;
4847 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, true );
4850 sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException, std::exception)
4852 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4855 OUString UnoPatternFieldControl::getImplementationName()
4856 throw (css::uno::RuntimeException, std::exception)
4858 return OUString("stardiv.Toolkit.UnoPatternFieldControl");
4861 css::uno::Sequence<OUString> UnoPatternFieldControl::getSupportedServiceNames()
4862 throw (css::uno::RuntimeException, std::exception)
4864 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4865 s.realloc(s.getLength() + 2);
4866 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlPatternField";
4867 s[s.getLength() - 1] = "stardiv.vcl.control.PatternField";
4868 return s;
4871 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4872 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4873 css::uno::XComponentContext *,
4874 css::uno::Sequence<css::uno::Any> const &)
4876 return cppu::acquire(new UnoPatternFieldControl());
4880 // class UnoControlProgressBarModel
4882 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference< XComponentContext >& rxContext )
4883 :UnoControlModel( rxContext )
4885 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
4886 ImplRegisterProperty( BASEPROPERTY_BORDER );
4887 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
4888 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
4889 ImplRegisterProperty( BASEPROPERTY_ENABLED );
4890 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
4891 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
4892 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
4893 ImplRegisterProperty( BASEPROPERTY_HELPURL );
4894 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
4895 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
4896 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
4897 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN );
4900 OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4902 return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel );
4905 uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4907 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4909 uno::Any aAny;
4910 aAny <<= OUString::createFromAscii( szServiceName_UnoControlProgressBar );
4911 return aAny;
4914 return UnoControlModel::ImplGetDefaultValue( nPropId );
4917 ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper()
4919 static UnoPropertyArrayHelper* pHelper = NULL;
4920 if ( !pHelper )
4922 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
4923 pHelper = new UnoPropertyArrayHelper( aIDs );
4925 return *pHelper;
4928 // beans::XMultiPropertySet
4929 uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
4931 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4932 return xInfo;
4935 OUString UnoControlProgressBarModel::getImplementationName()
4936 throw (css::uno::RuntimeException, std::exception)
4938 return OUString("stardiv.Toolkit.UnoControlProgressBarModel");
4941 css::uno::Sequence<OUString>
4942 UnoControlProgressBarModel::getSupportedServiceNames()
4943 throw (css::uno::RuntimeException, std::exception)
4945 auto s(UnoControlModel::getSupportedServiceNames());
4946 s.realloc(s.getLength() + 2);
4947 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBarModel";
4948 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.ProgressBar";
4949 return s;
4952 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
4953 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4954 css::uno::XComponentContext *context,
4955 css::uno::Sequence<css::uno::Any> const &)
4957 return cppu::acquire(new UnoControlProgressBarModel(context));
4961 // class UnoProgressBarControl
4963 UnoProgressBarControl::UnoProgressBarControl()
4964 :UnoControlBase()
4968 OUString UnoProgressBarControl::GetComponentServiceName()
4970 return OUString("ProgressBar");
4973 // uno::XInterface
4974 uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4976 uno::Any aRet = ::cppu::queryInterface( rType,
4977 (static_cast< awt::XProgressBar* >(this)) );
4978 return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
4981 // lang::XTypeProvider
4982 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl )
4983 cppu::UnoType<awt::XProgressBar>::get(),
4984 UnoControlBase::getTypes()
4985 IMPL_XTYPEPROVIDER_END
4987 // ::com::sun::star::awt::XProgressBar
4988 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4990 uno::Any aAny;
4991 aAny <<= nColor;
4992 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, true );
4995 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException, std::exception)
4997 uno::Any aAny;
4998 aAny <<= nColor;
4999 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, true );
5002 void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5004 uno::Any aAny;
5005 aAny <<= nValue;
5006 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, true );
5009 void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException, std::exception )
5011 uno::Any aMin;
5012 uno::Any aMax;
5014 if ( nMin < nMax )
5016 // take correct min and max
5017 aMin <<= nMin;
5018 aMax <<= nMax;
5020 else
5022 // change min and max
5023 aMin <<= nMax;
5024 aMax <<= nMin;
5027 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, true );
5028 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, true );
5031 sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException, std::exception)
5033 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE );
5036 OUString UnoProgressBarControl::getImplementationName()
5037 throw (css::uno::RuntimeException, std::exception)
5039 return OUString("stardiv.Toolkit.UnoProgressBarControl");
5042 css::uno::Sequence<OUString> UnoProgressBarControl::getSupportedServiceNames()
5043 throw (css::uno::RuntimeException, std::exception)
5045 auto s(UnoControlBase::getSupportedServiceNames());
5046 s.realloc(s.getLength() + 2);
5047 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBar";
5048 s[s.getLength() - 1] = "stardiv.vcl.control.ProgressBar";
5049 return s;
5052 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
5053 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
5054 css::uno::XComponentContext *,
5055 css::uno::Sequence<css::uno::Any> const &)
5057 return cppu::acquire(new UnoProgressBarControl());
5061 // class UnoControlFixedLineModel
5063 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference< XComponentContext >& rxContext )
5064 :UnoControlModel( rxContext )
5066 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
5067 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
5068 ImplRegisterProperty( BASEPROPERTY_ENABLED );
5069 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
5070 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
5071 ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
5072 ImplRegisterProperty( BASEPROPERTY_HELPURL );
5073 ImplRegisterProperty( BASEPROPERTY_LABEL );
5074 ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
5075 ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
5078 OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
5080 return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel );
5083 uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
5085 if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
5087 uno::Any aAny;
5088 aAny <<= OUString::createFromAscii( szServiceName_UnoControlFixedLine );
5089 return aAny;
5091 return UnoControlModel::ImplGetDefaultValue( nPropId );
5094 ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper()
5096 static UnoPropertyArrayHelper* pHelper = NULL;
5097 if ( !pHelper )
5099 uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
5100 pHelper = new UnoPropertyArrayHelper( aIDs );
5102 return *pHelper;
5105 // beans::XMultiPropertySet
5106 uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException, std::exception)
5108 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
5109 return xInfo;
5112 OUString UnoControlFixedLineModel::getImplementationName()
5113 throw (css::uno::RuntimeException, std::exception)
5115 return OUString("stardiv.Toolkit.UnoControlFixedLineModel");
5118 css::uno::Sequence<OUString>
5119 UnoControlFixedLineModel::getSupportedServiceNames()
5120 throw (css::uno::RuntimeException, std::exception)
5122 auto s(UnoControlModel::getSupportedServiceNames());
5123 s.realloc(s.getLength() + 2);
5124 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLineModel";
5125 s[s.getLength() - 1] = "stardiv.vcl.controlmodel.FixedLine";
5126 return s;
5129 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
5130 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
5131 css::uno::XComponentContext *context,
5132 css::uno::Sequence<css::uno::Any> const &)
5134 return cppu::acquire(new UnoControlFixedLineModel(context));
5138 // class UnoFixedLineControl
5140 UnoFixedLineControl::UnoFixedLineControl()
5141 :UnoControlBase()
5143 maComponentInfos.nWidth = 100; // ??
5144 maComponentInfos.nHeight = 100; // ??
5147 OUString UnoFixedLineControl::GetComponentServiceName()
5149 return OUString("FixedLine");
5152 sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException, std::exception)
5154 return sal_True;
5157 OUString UnoFixedLineControl::getImplementationName()
5158 throw (css::uno::RuntimeException, std::exception)
5160 return OUString("stardiv.Toolkit.UnoFixedLineControl");
5163 css::uno::Sequence<OUString> UnoFixedLineControl::getSupportedServiceNames()
5164 throw (css::uno::RuntimeException, std::exception)
5166 auto s(UnoControlBase::getSupportedServiceNames());
5167 s.realloc(s.getLength() + 2);
5168 s[s.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLine";
5169 s[s.getLength() - 1] = "stardiv.vcl.control.FixedLine";
5170 return s;
5173 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
5174 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
5175 css::uno::XComponentContext *,
5176 css::uno::Sequence<css::uno::Any> const &)
5178 return cppu::acquire(new UnoFixedLineControl());
5181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */