1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
63 #include "helper/imagealign.hxx"
64 #include "helper/unopropertyarrayhelper.hxx"
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
);
84 xOutGraphicObj
= nullptr; // release the GraphicObject
86 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
89 css::uno::Reference
< css::graphic::XGraphic
>
90 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
)
92 uno::Reference
< graphic::XGraphic
> xGraphic
;
93 if ( _rURL
.isEmpty() )
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();
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(css::uno::RuntimeException
, std::exception
)
123 return OUString::createFromAscii( szServiceName_UnoControlEditModel
);
126 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
132 case BASEPROPERTY_LINE_END_FORMAT
:
133 aReturn
<<= (sal_Int16
)awt::LineEndFormat::LINE_FEED
; // LF
135 case BASEPROPERTY_DEFAULTCONTROL
:
136 aReturn
<<= OUString::createFromAscii( szServiceName_UnoControlEdit
);
139 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
145 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
147 static UnoPropertyArrayHelper
* pHelper
= nullptr;
150 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
151 pHelper
= new UnoPropertyArrayHelper( aIDs
);
156 // beans::XMultiPropertySet
157 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
159 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
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";
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()
192 ,maTextListeners( *this )
194 ,mbSetTextInPeer( false )
195 ,mbSetMaxTextLenInPeer( false )
196 ,mbHasTextProperty( false )
198 maComponentInfos
.nWidth
= 100;
199 maComponentInfos
.nHeight
= 12;
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
);
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
) );
237 if ( ( aVal
>>= b
) && b
)
238 sName
= "MultiLineEdit";
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
);
250 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
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() )
261 ImplCheckLocalize( sText
);
262 xTextComponent
->setText( sText
);
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
);
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 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(xText
->getText()), false );
304 maText
= xText
->getText();
307 if ( maTextListeners
.getLength() )
308 maTextListeners
.textChanged( e
);
311 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
, std::exception
)
313 maTextListeners
.addInterface( l
);
316 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
, std::exception
)
318 maTextListeners
.removeInterface( l
);
321 void UnoEditControl::setText( const OUString
& aText
) throw(uno::RuntimeException
, std::exception
)
323 if ( mbHasTextProperty
)
325 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(aText
), true );
330 mbSetTextInPeer
= true;
331 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
333 xText
->setText( maText
);
336 // Setting the property to the VCLXWindow doesn't call textChanged
337 if ( maTextListeners
.getLength() )
339 awt::TextEvent aEvent
;
340 aEvent
.Source
= *this;
341 maTextListeners
.textChanged( aEvent
);
347 void lcl_normalize( awt::Selection
& _rSel
)
349 if ( _rSel
.Min
> _rSel
.Max
)
350 ::std::swap( _rSel
.Min
, _rSel
.Max
);
354 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
) throw(uno::RuntimeException
, std::exception
)
356 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
357 awt::Selection
aSelection( rSel
);
358 lcl_normalize( aSelection
);
360 // preserve the selection resp. cursor position
361 awt::Selection
aNewSelection( getSelection() );
362 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
363 // (not sure - looks uglier ...)
364 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
365 if ( aNewSelection
.Min
> aSelection
.Min
)
366 aNewSelection
.Min
-= nDeletedCharacters
;
367 if ( aNewSelection
.Max
> aSelection
.Max
)
368 aNewSelection
.Max
-= nDeletedCharacters
;
370 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
371 aNewSelection
.Min
= aNewSelection
.Max
;
374 OUString aOldText
= getText();
375 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
378 setSelection( aNewSelection
);
381 OUString
UnoEditControl::getText() throw(uno::RuntimeException
, std::exception
)
383 OUString aText
= maText
;
385 if ( mbHasTextProperty
)
386 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
389 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
391 aText
= xText
->getText();
397 OUString
UnoEditControl::getSelectedText() throw(uno::RuntimeException
, std::exception
)
400 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
402 sSelected
= xText
->getSelectedText();
407 void UnoEditControl::setSelection( const awt::Selection
& aSelection
) throw(uno::RuntimeException
, std::exception
)
409 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
411 xText
->setSelection( aSelection
);
414 awt::Selection
UnoEditControl::getSelection() throw(uno::RuntimeException
, std::exception
)
417 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
419 aSel
= xText
->getSelection();
423 sal_Bool
UnoEditControl::isEditable() throw(uno::RuntimeException
, std::exception
)
425 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
428 void UnoEditControl::setEditable( sal_Bool bEditable
) throw(uno::RuntimeException
, std::exception
)
430 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), uno::Any(!bEditable
), true );
433 sal_Int16
UnoEditControl::getMaxTextLen() throw(uno::RuntimeException
, std::exception
)
435 sal_Int16 nMaxLen
= mnMaxTextLen
;
437 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
438 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
443 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
) throw(uno::RuntimeException
, std::exception
)
445 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
447 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), uno::Any((sal_Int16
)nLen
), true );
452 mbSetMaxTextLenInPeer
= true;
453 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
455 xText
->setMaxTextLen( mnMaxTextLen
);
459 awt::Size
UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
461 return Impl_getMinimumSize();
464 awt::Size
UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
466 return Impl_getPreferredSize();
469 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
471 return Impl_calcAdjustedSize( rNewSize
);
474 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
, std::exception
)
476 return Impl_getMinimumSize( nCols
, nLines
);
479 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
, std::exception
)
481 Impl_getColumnsAndLines( nCols
, nLines
);
484 OUString
UnoEditControl::getImplementationName( ) throw(uno::RuntimeException
, std::exception
)
486 return OUString( "stardiv.Toolkit.UnoEditControl" );
489 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames() throw(uno::RuntimeException
, std::exception
)
491 uno::Sequence
< OUString
> aNames
= UnoControlBase::getSupportedServiceNames( );
492 aNames
.realloc( aNames
.getLength() + 2 );
493 aNames
[ aNames
.getLength() - 2 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit
);
494 aNames
[ aNames
.getLength() - 1 ] = "stardiv.vcl.control.Edit";
498 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
499 stardiv_Toolkit_UnoEditControl_get_implementation(
500 css::uno::XComponentContext
*,
501 css::uno::Sequence
<css::uno::Any
> const &)
503 return cppu::acquire(new UnoEditControl());
507 // class UnoControlFileControlModel
509 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
510 :UnoControlModel( rxContext
)
512 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
513 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
514 ImplRegisterProperty( BASEPROPERTY_BORDER
);
515 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
516 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
517 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
518 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
519 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
520 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
521 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
522 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
523 ImplRegisterProperty( BASEPROPERTY_READONLY
);
524 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
525 ImplRegisterProperty( BASEPROPERTY_TEXT
);
526 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
527 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
528 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
529 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
532 OUString
UnoControlFileControlModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
534 return OUString::createFromAscii( szServiceName_UnoControlFileControlModel
);
537 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
539 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
541 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFileControl
) );
543 return UnoControlModel::ImplGetDefaultValue( nPropId
);
546 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
548 static UnoPropertyArrayHelper
* pHelper
= nullptr;
551 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
552 pHelper
= new UnoPropertyArrayHelper( aIDs
);
557 // beans::XMultiPropertySet
558 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
560 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
564 OUString
UnoControlFileControlModel::getImplementationName()
565 throw (css::uno::RuntimeException
, std::exception
)
567 return OUString("stardiv.Toolkit.UnoControlFileControlModel");
570 css::uno::Sequence
<OUString
>
571 UnoControlFileControlModel::getSupportedServiceNames()
572 throw (css::uno::RuntimeException
, std::exception
)
574 auto s(UnoControlModel::getSupportedServiceNames());
575 s
.realloc(s
.getLength() + 2);
576 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControlModel";
577 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FileControl";
581 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
582 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
583 css::uno::XComponentContext
*context
,
584 css::uno::Sequence
<css::uno::Any
> const &)
586 return cppu::acquire(new UnoControlFileControlModel(context
));
590 // class UnoFileControl
592 UnoFileControl::UnoFileControl()
597 OUString
UnoFileControl::GetComponentServiceName()
599 return OUString("filecontrol");
602 OUString
UnoFileControl::getImplementationName()
603 throw (css::uno::RuntimeException
, std::exception
)
605 return OUString("stardiv.Toolkit.UnoFileControl");
608 css::uno::Sequence
<OUString
> UnoFileControl::getSupportedServiceNames()
609 throw (css::uno::RuntimeException
, std::exception
)
611 auto s(UnoEditControl::getSupportedServiceNames());
612 s
.realloc(s
.getLength() + 2);
613 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControl";
614 s
[s
.getLength() - 1] = "stardiv.vcl.control.FileControl";
618 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
619 stardiv_Toolkit_UnoFileControl_get_implementation(
620 css::uno::XComponentContext
*,
621 css::uno::Sequence
<css::uno::Any
> const &)
623 return cppu::acquire(new UnoFileControl());
627 // class GraphicControlModel
629 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
631 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
632 return uno::makeAny( uno::Reference
< graphic::XGraphic
>() );
634 return UnoControlModel::ImplGetDefaultValue( nPropId
);
637 void SAL_CALL
GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) throw (css::uno::Exception
, std::exception
)
639 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
641 // - ImageAlign and ImagePosition need to correspond to each other
642 // - Graphic and ImageURL need to correspond to each other
647 case BASEPROPERTY_IMAGEURL
:
648 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
650 mbAdjustingGraphic
= true;
652 OSL_VERIFY( rValue
>>= sImageURL
);
653 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC
, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
654 mbAdjustingGraphic
= false;
658 case BASEPROPERTY_GRAPHIC
:
659 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
661 mbAdjustingGraphic
= true;
662 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL
, uno::makeAny( OUString() ) );
663 mbAdjustingGraphic
= false;
667 case BASEPROPERTY_IMAGEALIGN
:
668 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
670 mbAdjustingImagePosition
= true;
671 sal_Int16 nUNOValue
= 0;
672 OSL_VERIFY( rValue
>>= nUNOValue
);
673 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION
, uno::makeAny( getExtendedImagePosition( nUNOValue
) ) );
674 mbAdjustingImagePosition
= false;
677 case BASEPROPERTY_IMAGEPOSITION
:
678 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
680 mbAdjustingImagePosition
= true;
681 sal_Int16 nUNOValue
= 0;
682 OSL_VERIFY( rValue
>>= nUNOValue
);
683 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN
, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
684 mbAdjustingImagePosition
= false;
689 catch( const css::uno::Exception
& )
691 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
692 DBG_UNHANDLED_EXCEPTION();
693 mbAdjustingImagePosition
= false;
698 // class UnoControlButtonModel
700 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
701 :GraphicControlModel( rxContext
)
703 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton
);
705 osl_atomic_increment( &m_refCount
);
707 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
708 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
709 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
711 osl_atomic_decrement( &m_refCount
);
714 OUString
UnoControlButtonModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
716 return OUString::createFromAscii( szServiceName_UnoControlButtonModel
);
719 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
723 case BASEPROPERTY_DEFAULTCONTROL
:
724 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton
) );
725 case BASEPROPERTY_TOGGLE
:
726 return uno::makeAny( false );
727 case BASEPROPERTY_ALIGN
:
728 return uno::makeAny( (sal_Int16
)PROPERTY_ALIGN_CENTER
);
729 case BASEPROPERTY_FOCUSONCLICK
:
730 return uno::makeAny( true );
733 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
736 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
738 static UnoPropertyArrayHelper
* pHelper
= nullptr;
741 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
742 pHelper
= new UnoPropertyArrayHelper( aIDs
);
747 // beans::XMultiPropertySet
748 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
750 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
754 OUString
UnoControlButtonModel::getImplementationName()
755 throw (css::uno::RuntimeException
, std::exception
)
757 return OUString("stardiv.Toolkit.UnoControlButtonModel");
760 css::uno::Sequence
<OUString
> UnoControlButtonModel::getSupportedServiceNames()
761 throw (css::uno::RuntimeException
, std::exception
)
763 auto s(GraphicControlModel::getSupportedServiceNames());
764 s
.realloc(s
.getLength() + 2);
765 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButtonModel";
766 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Button";
770 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
771 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
772 css::uno::XComponentContext
*context
,
773 css::uno::Sequence
<css::uno::Any
> const &)
775 return cppu::acquire(new UnoControlButtonModel(context
));
779 // class UnoButtonControl
781 UnoButtonControl::UnoButtonControl()
782 :UnoButtonControl_Base()
783 ,maActionListeners( *this )
784 ,maItemListeners( *this )
786 maComponentInfos
.nWidth
= 50;
787 maComponentInfos
.nHeight
= 14;
790 OUString
UnoButtonControl::GetComponentServiceName()
792 OUString
aName( "pushbutton" );
793 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
794 sal_Int16 n
= sal_Int16();
795 if ( ( aVal
>>= n
) && n
)
797 // Use PushButtonType later when available...
800 case 1 /*PushButtonType::OK*/: aName
= "okbutton";
802 case 2 /*PushButtonType::CANCEL*/: aName
= "cancelbutton";
804 case 3 /*PushButtonType::HELP*/: aName
= "helpbutton";
808 OSL_FAIL( "Unknown Button Type!" );
815 void UnoButtonControl::dispose() throw(uno::RuntimeException
, std::exception
)
817 lang::EventObject aEvt
;
818 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
819 maActionListeners
.disposeAndClear( aEvt
);
820 maItemListeners
.disposeAndClear( aEvt
);
821 UnoControlBase::dispose();
824 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
826 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
828 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
829 xButton
->setActionCommand( maActionCommand
);
830 if ( maActionListeners
.getLength() )
831 xButton
->addActionListener( &maActionListeners
);
833 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
834 if ( xPushButton
.is() )
835 xPushButton
->addItemListener( this );
838 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
840 maActionListeners
.addInterface( l
);
841 if( getPeer().is() && maActionListeners
.getLength() == 1 )
843 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
844 xButton
->addActionListener( &maActionListeners
);
848 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
850 if( getPeer().is() && maActionListeners
.getLength() == 1 )
852 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
853 xButton
->removeActionListener( &maActionListeners
);
855 maActionListeners
.removeInterface( l
);
858 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
860 maItemListeners
.addInterface( l
);
863 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
865 maItemListeners
.removeInterface( l
);
868 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
) throw (uno::RuntimeException
, std::exception
)
870 UnoControlBase::disposing( Source
);
873 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw (uno::RuntimeException
, std::exception
)
876 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
)rEvent
.Selected
), false );
879 ItemEvent
aEvent( rEvent
);
880 aEvent
.Source
= *this;
881 maItemListeners
.itemStateChanged( aEvent
);
884 void UnoButtonControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
, std::exception
)
886 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
889 void UnoButtonControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
, std::exception
)
891 maActionCommand
= rCommand
;
892 if ( getPeer().is() )
894 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
895 xButton
->setActionCommand( rCommand
);
899 awt::Size
UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
901 return Impl_getMinimumSize();
904 awt::Size
UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
906 return Impl_getPreferredSize();
909 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
911 return Impl_calcAdjustedSize( rNewSize
);
914 OUString
UnoButtonControl::getImplementationName()
915 throw (css::uno::RuntimeException
, std::exception
)
917 return OUString("stardiv.Toolkit.UnoButtonControl");
920 css::uno::Sequence
<OUString
> UnoButtonControl::getSupportedServiceNames()
921 throw (css::uno::RuntimeException
, std::exception
)
923 auto s(UnoControlBase::getSupportedServiceNames());
924 s
.realloc(s
.getLength() + 2);
925 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButton";
926 s
[s
.getLength() - 1] = "stardiv.vcl.control.Button";
930 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
931 stardiv_Toolkit_UnoButtonControl_get_implementation(
932 css::uno::XComponentContext
*,
933 css::uno::Sequence
<css::uno::Any
> const &)
935 return cppu::acquire(new UnoButtonControl());
939 // class UnoControlImageControlModel
941 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
942 :GraphicControlModel( rxContext
)
943 ,mbAdjustingImageScaleMode( false )
945 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl
);
948 OUString
UnoControlImageControlModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
950 return OUString::createFromAscii( szServiceName_UnoControlImageControlModel
);
953 OUString
UnoControlImageControlModel::getImplementationName()
954 throw (css::uno::RuntimeException
, std::exception
)
956 return OUString("stardiv.Toolkit.UnoControlImageControlModel");
959 css::uno::Sequence
<OUString
>
960 UnoControlImageControlModel::getSupportedServiceNames()
961 throw (css::uno::RuntimeException
, std::exception
)
963 auto s(GraphicControlModel::getSupportedServiceNames());
964 s
.realloc(s
.getLength() + 4);
965 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButtonModel";
966 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControlModel";
967 s
[s
.getLength() - 2] = "stardiv.vcl.controlmodel.ImageButton";
968 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ImageControl";
972 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
974 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
975 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl
) );
977 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
978 return makeAny( awt::ImageScaleMode::ANISOTROPIC
);
980 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
983 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
985 static UnoPropertyArrayHelper
* pHelper
= nullptr;
988 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
989 pHelper
= new UnoPropertyArrayHelper( aIDs
);
994 // beans::XMultiPropertySet
995 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
997 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1001 void SAL_CALL
UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
) throw (css::uno::Exception
, std::exception
)
1003 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
1005 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
1010 case BASEPROPERTY_IMAGE_SCALE_MODE
:
1011 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
1013 mbAdjustingImageScaleMode
= true;
1014 sal_Int16
nScaleMode( awt::ImageScaleMode::ANISOTROPIC
);
1015 OSL_VERIFY( _rValue
>>= nScaleMode
);
1016 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE
, uno::makeAny( nScaleMode
!= awt::ImageScaleMode::NONE
) );
1017 mbAdjustingImageScaleMode
= false;
1020 case BASEPROPERTY_SCALEIMAGE
:
1021 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
1023 mbAdjustingImageScaleMode
= true;
1025 OSL_VERIFY( _rValue
>>= bScale
);
1026 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE
, uno::makeAny( bScale
? awt::ImageScaleMode::ANISOTROPIC
: awt::ImageScaleMode::NONE
) );
1027 mbAdjustingImageScaleMode
= false;
1032 catch( const Exception
& )
1034 mbAdjustingImageScaleMode
= false;
1039 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1040 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
1041 css::uno::XComponentContext
*context
,
1042 css::uno::Sequence
<css::uno::Any
> const &)
1044 return cppu::acquire(new UnoControlImageControlModel(context
));
1048 // class UnoImageControlControl
1050 UnoImageControlControl::UnoImageControlControl()
1051 :UnoImageControlControl_Base()
1052 ,maActionListeners( *this )
1054 // TODO: Where should I look for defaults?
1055 maComponentInfos
.nWidth
= 100;
1056 maComponentInfos
.nHeight
= 100;
1059 OUString
UnoImageControlControl::GetComponentServiceName()
1061 return OUString("fixedimage");
1064 void UnoImageControlControl::dispose() throw(uno::RuntimeException
, std::exception
)
1066 lang::EventObject aEvt
;
1067 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1068 maActionListeners
.disposeAndClear( aEvt
);
1069 UnoControl::dispose();
1072 sal_Bool
UnoImageControlControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
1077 awt::Size
UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
1079 return Impl_getMinimumSize();
1082 awt::Size
UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
1084 return Impl_getPreferredSize();
1087 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
1089 return Impl_calcAdjustedSize( rNewSize
);
1092 OUString
UnoImageControlControl::getImplementationName()
1093 throw (css::uno::RuntimeException
, std::exception
)
1095 return OUString("stardiv.Toolkit.UnoImageControlControl");
1098 css::uno::Sequence
<OUString
> UnoImageControlControl::getSupportedServiceNames()
1099 throw (css::uno::RuntimeException
, std::exception
)
1101 auto s(UnoControlBase::getSupportedServiceNames());
1102 s
.realloc(s
.getLength() + 4);
1103 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButton";
1104 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControl";
1105 s
[s
.getLength() - 2] = "stardiv.vcl.control.ImageButton";
1106 s
[s
.getLength() - 1] = "stardiv.vcl.control.ImageControl";
1110 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1111 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1112 css::uno::XComponentContext
*,
1113 css::uno::Sequence
<css::uno::Any
> const &)
1115 return cppu::acquire(new UnoImageControlControl());
1119 // class UnoControlRadioButtonModel
1121 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
1122 :GraphicControlModel( rxContext
)
1124 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton
);
1127 OUString
UnoControlRadioButtonModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
1129 return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel
);
1132 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1136 case BASEPROPERTY_DEFAULTCONTROL
:
1137 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton
) );
1139 case BASEPROPERTY_VISUALEFFECT
:
1140 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1143 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1146 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
1148 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1151 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1152 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1157 // beans::XMultiPropertySet
1158 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1160 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1164 OUString
UnoControlRadioButtonModel::getImplementationName()
1165 throw (css::uno::RuntimeException
, std::exception
)
1167 return OUString("stardiv.Toolkit.UnoControlRadioButtonModel");
1170 css::uno::Sequence
<OUString
>
1171 UnoControlRadioButtonModel::getSupportedServiceNames()
1172 throw (css::uno::RuntimeException
, std::exception
)
1174 auto s(GraphicControlModel::getSupportedServiceNames());
1175 s
.realloc(s
.getLength() + 2);
1176 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButtonModel";
1177 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.RadioButton";
1181 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1182 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1183 css::uno::XComponentContext
*context
,
1184 css::uno::Sequence
<css::uno::Any
> const &)
1186 return cppu::acquire(new UnoControlRadioButtonModel(context
));
1190 // class UnoRadioButtonControl
1192 UnoRadioButtonControl::UnoRadioButtonControl()
1193 :UnoRadioButtonControl_Base()
1194 ,maItemListeners( *this )
1195 ,maActionListeners( *this )
1197 maComponentInfos
.nWidth
= 100;
1198 maComponentInfos
.nHeight
= 12;
1201 OUString
UnoRadioButtonControl::GetComponentServiceName()
1203 return OUString("radiobutton");
1206 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException
, std::exception
)
1208 lang::EventObject aEvt
;
1209 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1210 maItemListeners
.disposeAndClear( aEvt
);
1211 UnoControlBase::dispose();
1215 sal_Bool
UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
1220 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
1222 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1224 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1225 xRadioButton
->addItemListener( this );
1227 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1228 xButton
->setActionCommand( maActionCommand
);
1229 if ( maActionListeners
.getLength() )
1230 xButton
->addActionListener( &maActionListeners
);
1232 // as default, set the "AutoToggle" to true
1233 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1234 // have it enabled by default because of 85071)
1235 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1236 if ( xVclWindowPeer
.is() )
1237 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), css::uno::Any(true) );
1240 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1242 maItemListeners
.addInterface( l
);
1245 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1247 maItemListeners
.removeInterface( l
);
1250 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1252 maActionListeners
.addInterface( l
);
1253 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1255 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1256 xButton
->addActionListener( &maActionListeners
);
1260 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1262 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1264 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1265 xButton
->removeActionListener( &maActionListeners
);
1267 maActionListeners
.removeInterface( l
);
1270 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
, std::exception
)
1272 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1275 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
, std::exception
)
1277 maActionCommand
= rCommand
;
1278 if ( getPeer().is() )
1280 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1281 xButton
->setActionCommand( rCommand
);
1285 void UnoRadioButtonControl::setState( sal_Bool bOn
) throw(uno::RuntimeException
, std::exception
)
1287 sal_Int16 nState
= bOn
? 1 : 0;
1288 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(nState
), true );
1291 sal_Bool
UnoRadioButtonControl::getState() throw(uno::RuntimeException
, std::exception
)
1293 sal_Int16 nState
= 0;
1294 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1299 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
, std::exception
)
1301 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
)rEvent
.Selected
), false );
1304 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1305 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1307 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1308 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1309 // isn't the case anymore: For instance, this method here gets called for the radio button
1310 // which is being implicitly _de_selected, too. This is pretty bad for compatibility.
1311 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1312 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1313 // all which matters here.
1315 if ( 1 == rEvent
.Selected
)
1317 if ( maItemListeners
.getLength() )
1318 maItemListeners
.itemStateChanged( rEvent
);
1320 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1321 // a radio button _without_ selecting another one, this would have caused a notification.
1322 // With the change done here, this today won't cause a notification anymore.
1324 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1325 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1326 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1327 // to be inconsistent with.
1330 awt::Size
UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
1332 return Impl_getMinimumSize();
1335 awt::Size
UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
1337 return Impl_getPreferredSize();
1340 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
1342 return Impl_calcAdjustedSize( rNewSize
);
1345 OUString
UnoRadioButtonControl::getImplementationName()
1346 throw (css::uno::RuntimeException
, std::exception
)
1348 return OUString("stardiv.Toolkit.UnoRadioButtonControl");
1351 css::uno::Sequence
<OUString
> UnoRadioButtonControl::getSupportedServiceNames()
1352 throw (css::uno::RuntimeException
, std::exception
)
1354 auto s(UnoControlBase::getSupportedServiceNames());
1355 s
.realloc(s
.getLength() + 2);
1356 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButton";
1357 s
[s
.getLength() - 1] = "stardiv.vcl.control.RadioButton";
1361 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1362 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1363 css::uno::XComponentContext
*,
1364 css::uno::Sequence
<css::uno::Any
> const &)
1366 return cppu::acquire(new UnoRadioButtonControl());
1370 // class UnoControlCheckBoxModel
1372 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1373 :GraphicControlModel( rxContext
)
1375 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox
);
1378 OUString
UnoControlCheckBoxModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
1380 return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel
);
1383 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1387 case BASEPROPERTY_DEFAULTCONTROL
:
1388 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox
) );
1390 case BASEPROPERTY_VISUALEFFECT
:
1391 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1394 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1397 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1399 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1402 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1403 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1408 // beans::XMultiPropertySet
1409 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1411 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1415 OUString
UnoControlCheckBoxModel::getImplementationName()
1416 throw (css::uno::RuntimeException
, std::exception
)
1418 return OUString( "stardiv.Toolkit.UnoControlCheckBoxModel");
1421 css::uno::Sequence
<OUString
> UnoControlCheckBoxModel::getSupportedServiceNames()
1422 throw (css::uno::RuntimeException
, std::exception
)
1424 auto s(GraphicControlModel::getSupportedServiceNames());
1425 s
.realloc(s
.getLength() + 2);
1426 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBoxModel";
1427 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CheckBox";
1431 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1432 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1433 css::uno::XComponentContext
*context
,
1434 css::uno::Sequence
<css::uno::Any
> const &)
1436 return cppu::acquire(new UnoControlCheckBoxModel(context
));
1440 // class UnoCheckBoxControl
1442 UnoCheckBoxControl::UnoCheckBoxControl()
1443 :UnoCheckBoxControl_Base()
1444 ,maItemListeners( *this ), maActionListeners( *this )
1446 maComponentInfos
.nWidth
= 100;
1447 maComponentInfos
.nHeight
= 12;
1450 OUString
UnoCheckBoxControl::GetComponentServiceName()
1452 return OUString("checkbox");
1455 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException
, std::exception
)
1457 lang::EventObject aEvt
;
1458 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1459 maItemListeners
.disposeAndClear( aEvt
);
1460 UnoControlBase::dispose();
1463 sal_Bool
UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
1468 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
1470 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1472 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1473 xCheckBox
->addItemListener( this );
1475 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1476 xButton
->setActionCommand( maActionCommand
);
1477 if ( maActionListeners
.getLength() )
1478 xButton
->addActionListener( &maActionListeners
);
1481 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1483 maItemListeners
.addInterface( l
);
1486 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1488 maItemListeners
.removeInterface( l
);
1491 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1493 maActionListeners
.addInterface( l
);
1494 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1496 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1497 xButton
->addActionListener( &maActionListeners
);
1501 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1503 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1505 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1506 xButton
->removeActionListener( &maActionListeners
);
1508 maActionListeners
.removeInterface( l
);
1511 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
, std::exception
)
1513 maActionCommand
= rCommand
;
1514 if ( getPeer().is() )
1516 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1517 xButton
->setActionCommand( rCommand
);
1522 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
, std::exception
)
1524 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1527 void UnoCheckBoxControl::setState( short n
) throw(uno::RuntimeException
, std::exception
)
1529 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
) n
), true );
1532 short UnoCheckBoxControl::getState() throw(uno::RuntimeException
, std::exception
)
1535 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1540 void UnoCheckBoxControl::enableTriState( sal_Bool b
) throw(uno::RuntimeException
, std::exception
)
1542 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), uno::Any(b
), true );
1545 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
, std::exception
)
1547 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
) rEvent
.Selected
), false );
1549 if ( maItemListeners
.getLength() )
1550 maItemListeners
.itemStateChanged( rEvent
);
1553 awt::Size
UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
1555 return Impl_getMinimumSize();
1558 awt::Size
UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
1560 return Impl_getPreferredSize();
1563 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
1565 return Impl_calcAdjustedSize( rNewSize
);
1568 OUString
UnoCheckBoxControl::getImplementationName()
1569 throw (css::uno::RuntimeException
, std::exception
)
1571 return OUString("stardiv.Toolkit.UnoCheckBoxControl");
1574 css::uno::Sequence
<OUString
> UnoCheckBoxControl::getSupportedServiceNames()
1575 throw (css::uno::RuntimeException
, std::exception
)
1577 auto s(UnoControlBase::getSupportedServiceNames());
1578 s
.realloc(s
.getLength() + 2);
1579 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBox";
1580 s
[s
.getLength() - 1] = "stardiv.vcl.control.CheckBox";
1584 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1585 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1586 css::uno::XComponentContext
*,
1587 css::uno::Sequence
<css::uno::Any
> const &)
1589 return cppu::acquire(new UnoCheckBoxControl());
1593 // class UnoControlFixedHyperlinkModel
1595 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1596 :UnoControlModel( rxContext
)
1598 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink
);
1601 OUString
UnoControlFixedHyperlinkModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
1603 return OUString( "com.sun.star.awt.UnoControlFixedHyperlinkModel" );
1606 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1608 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1610 return uno::Any( OUString( "com.sun.star.awt.UnoControlFixedHyperlink" ) );
1612 else if ( nPropId
== BASEPROPERTY_BORDER
)
1614 return uno::Any((sal_Int16
) 0);
1616 else if ( nPropId
== BASEPROPERTY_URL
)
1618 return uno::Any( OUString() );
1621 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1624 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1626 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1629 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1630 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1635 // beans::XMultiPropertySet
1636 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1638 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1642 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1643 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1644 css::uno::XComponentContext
*context
,
1645 css::uno::Sequence
<css::uno::Any
> const &)
1647 return cppu::acquire(new UnoControlFixedHyperlinkModel(context
));
1651 // class UnoFixedHyperlinkControl
1653 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1655 ,maActionListeners( *this )
1657 maComponentInfos
.nWidth
= 100;
1658 maComponentInfos
.nHeight
= 12;
1661 OUString
UnoFixedHyperlinkControl::GetComponentServiceName()
1663 return OUString("fixedhyperlink");
1667 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
1669 uno::Any aRet
= ::cppu::queryInterface( rType
,
1670 (static_cast< awt::XFixedHyperlink
* >(this)),
1671 (static_cast< awt::XLayoutConstrains
* >(this)) );
1672 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1675 // lang::XTypeProvider
1676 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl
)
1677 cppu::UnoType
<awt::XFixedHyperlink
>::get(),
1678 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1679 UnoControlBase::getTypes()
1680 IMPL_XTYPEPROVIDER_END
1682 sal_Bool
UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
1687 void UnoFixedHyperlinkControl::setText( const OUString
& Text
) throw(uno::RuntimeException
, std::exception
)
1689 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1692 OUString
UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException
, std::exception
)
1694 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1697 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
) throw(css::uno::RuntimeException
, std::exception
)
1699 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), uno::Any(URL
), true );
1702 OUString
UnoFixedHyperlinkControl::getURL( ) throw(css::uno::RuntimeException
, std::exception
)
1704 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1707 void UnoFixedHyperlinkControl::setAlignment( short nAlign
) throw(uno::RuntimeException
, std::exception
)
1709 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any((sal_Int16
) nAlign
), true );
1712 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException
, std::exception
)
1717 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1723 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
1725 return Impl_getMinimumSize();
1728 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
1730 return Impl_getPreferredSize();
1733 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
1735 return Impl_calcAdjustedSize( rNewSize
);
1738 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException
, std::exception
)
1740 lang::EventObject aEvt
;
1741 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1742 maActionListeners
.disposeAndClear( aEvt
);
1743 UnoControlBase::dispose();
1746 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
1748 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1750 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1751 if ( maActionListeners
.getLength() )
1752 xFixedHyperlink
->addActionListener( &maActionListeners
);
1755 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1757 maActionListeners
.addInterface( l
);
1758 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1760 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1761 xFixedHyperlink
->addActionListener( &maActionListeners
);
1765 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
1767 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1769 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1770 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1772 maActionListeners
.removeInterface( l
);
1775 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1776 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1777 css::uno::XComponentContext
*,
1778 css::uno::Sequence
<css::uno::Any
> const &)
1780 return cppu::acquire(new UnoFixedHyperlinkControl());
1784 // class UnoControlFixedTextModel
1786 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1787 :UnoControlModel( rxContext
)
1789 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText
);
1792 OUString
UnoControlFixedTextModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
1794 return OUString( "stardiv.vcl.controlmodel.FixedText" );
1797 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1799 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1801 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedText
) );
1803 else if ( nPropId
== BASEPROPERTY_BORDER
)
1805 return uno::Any((sal_Int16
)0);
1808 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1811 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1813 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1816 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1817 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1822 // beans::XMultiPropertySet
1823 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
1825 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1829 OUString
UnoControlFixedTextModel::getImplementationName()
1830 throw (css::uno::RuntimeException
, std::exception
)
1832 return OUString("stardiv.Toolkit.UnoControlFixedTextModel");
1835 css::uno::Sequence
<OUString
>
1836 UnoControlFixedTextModel::getSupportedServiceNames()
1837 throw (css::uno::RuntimeException
, std::exception
)
1839 auto s(UnoControlModel::getSupportedServiceNames());
1840 s
.realloc(s
.getLength() + 2);
1841 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedTextModel";
1842 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedText";
1846 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1847 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1848 css::uno::XComponentContext
*context
,
1849 css::uno::Sequence
<css::uno::Any
> const &)
1851 return cppu::acquire(new UnoControlFixedTextModel(context
));
1855 // class UnoFixedTextControl
1857 UnoFixedTextControl::UnoFixedTextControl()
1860 maComponentInfos
.nWidth
= 100;
1861 maComponentInfos
.nHeight
= 12;
1864 OUString
UnoFixedTextControl::GetComponentServiceName()
1866 return OUString("fixedtext");
1870 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
1872 uno::Any aRet
= ::cppu::queryInterface( rType
,
1873 (static_cast< awt::XFixedText
* >(this)),
1874 (static_cast< awt::XLayoutConstrains
* >(this)) );
1875 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1878 // lang::XTypeProvider
1879 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl
)
1880 cppu::UnoType
<awt::XFixedText
>::get(),
1881 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1882 UnoControlBase::getTypes()
1883 IMPL_XTYPEPROVIDER_END
1885 sal_Bool
UnoFixedTextControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
1890 void UnoFixedTextControl::setText( const OUString
& Text
) throw(uno::RuntimeException
, std::exception
)
1892 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1895 OUString
UnoFixedTextControl::getText() throw(uno::RuntimeException
, std::exception
)
1897 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1900 void UnoFixedTextControl::setAlignment( short nAlign
) throw(uno::RuntimeException
, std::exception
)
1902 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any((sal_Int16
) nAlign
), true );
1905 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException
, std::exception
)
1910 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1916 awt::Size
UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
1918 return Impl_getMinimumSize();
1921 awt::Size
UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
1923 return Impl_getPreferredSize();
1926 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
1928 return Impl_calcAdjustedSize( rNewSize
);
1931 OUString
UnoFixedTextControl::getImplementationName()
1932 throw (css::uno::RuntimeException
, std::exception
)
1934 return OUString("stardiv.Toolkit.UnoFixedTextControl");
1937 css::uno::Sequence
<OUString
> UnoFixedTextControl::getSupportedServiceNames()
1938 throw (css::uno::RuntimeException
, std::exception
)
1940 auto s(UnoControlBase::getSupportedServiceNames());
1941 s
.realloc(s
.getLength() + 2);
1942 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedText";
1943 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedText";
1947 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1948 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1949 css::uno::XComponentContext
*,
1950 css::uno::Sequence
<css::uno::Any
> const &)
1952 return cppu::acquire(new UnoFixedTextControl());
1956 // class UnoControlGroupBoxModel
1958 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1959 :UnoControlModel( rxContext
)
1961 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1962 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1963 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1964 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1965 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1966 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1967 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1968 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1969 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1970 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1973 OUString
UnoControlGroupBoxModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
1975 return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel
);
1978 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1980 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1982 return uno::Any(OUString::createFromAscii( szServiceName_UnoControlGroupBox
) );
1984 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1987 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1989 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1992 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1993 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1998 // beans::XMultiPropertySet
1999 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
2001 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2005 OUString
UnoControlGroupBoxModel::getImplementationName()
2006 throw (css::uno::RuntimeException
, std::exception
)
2008 return OUString("stardiv.Toolkit.UnoControlGroupBoxModel");
2011 css::uno::Sequence
<OUString
> UnoControlGroupBoxModel::getSupportedServiceNames()
2012 throw (css::uno::RuntimeException
, std::exception
)
2014 auto s(UnoControlModel::getSupportedServiceNames());
2015 s
.realloc(s
.getLength() + 2);
2016 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBoxModel";
2017 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.GroupBox";
2021 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
2022 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
2023 css::uno::XComponentContext
*context
,
2024 css::uno::Sequence
<css::uno::Any
> const &)
2026 return cppu::acquire(new UnoControlGroupBoxModel(context
));
2030 // class UnoGroupBoxControl
2032 UnoGroupBoxControl::UnoGroupBoxControl()
2035 maComponentInfos
.nWidth
= 100;
2036 maComponentInfos
.nHeight
= 100;
2039 OUString
UnoGroupBoxControl::GetComponentServiceName()
2041 return OUString("groupbox");
2044 sal_Bool
UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
2049 OUString
UnoGroupBoxControl::getImplementationName()
2050 throw (css::uno::RuntimeException
, std::exception
)
2052 return OUString("stardiv.Toolkit.UnoGroupBoxControl");
2055 css::uno::Sequence
<OUString
> UnoGroupBoxControl::getSupportedServiceNames()
2056 throw (css::uno::RuntimeException
, std::exception
)
2058 auto s(UnoControlBase::getSupportedServiceNames());
2059 s
.realloc(s
.getLength() + 2);
2060 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBox";
2061 s
[s
.getLength() - 1] = "stardiv.vcl.control.GroupBox";
2065 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
2066 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
2067 css::uno::XComponentContext
*,
2068 css::uno::Sequence
<css::uno::Any
> const &)
2070 return cppu::acquire(new UnoGroupBoxControl());
2074 // = UnoControlListBoxModel_Data
2079 OUString ItemImageURL
;
2089 explicit ListItem( const OUString
& i_rItemText
)
2090 :ItemText( i_rItemText
)
2097 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
2099 struct StripItemData
: public ::std::unary_function
< ListItem
, UnoListItem
>
2101 UnoListItem
operator()( const ListItem
& i_rItem
)
2103 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
2107 struct UnoControlListBoxModel_Data
2109 explicit UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
2110 :m_bSettingLegacyProperty( false )
2111 ,m_rAntiImpl( i_rAntiImpl
)
2116 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
2118 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
2120 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2121 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2122 return m_aListItems
[ i_nIndex
];
2125 ListItem
& getItem( const sal_Int32 i_nIndex
)
2127 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
2130 ListItem
& insertItem( const sal_Int32 i_nIndex
)
2132 if ( ( i_nIndex
< 0 ) || ( i_nIndex
> sal_Int32( m_aListItems
.size() ) ) )
2133 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2134 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
2137 Sequence
< UnoListItem
> getAllItems() const
2139 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
2140 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
2144 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
2146 m_aListItems
= i_copySource
.m_aListItems
;
2149 void setAllItems( const ::std::vector
< ListItem
>& i_rItems
)
2151 m_aListItems
= i_rItems
;
2154 void removeItem( const sal_Int32 i_nIndex
)
2156 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2157 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2158 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
2161 void removeAllItems()
2163 ::std::vector
< ListItem
> aEmpty
;
2164 m_aListItems
.swap( aEmpty
);
2168 bool m_bSettingLegacyProperty
;
2171 UnoControlListBoxModel
& m_rAntiImpl
;
2172 ::std::vector
< ListItem
> m_aListItems
;
2176 // = UnoControlListBoxModel
2179 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
2180 :UnoControlListBoxModel_Base( rxContext
)
2181 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2182 ,m_aItemListListeners( GetMutex() )
2184 if ( i_mode
== ConstructDefault
)
2186 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox
);
2190 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
2191 :UnoControlListBoxModel_Base( i_rSource
)
2192 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2193 ,m_aItemListListeners( GetMutex() )
2195 m_xData
->copyItems( *i_rSource
.m_xData
);
2197 UnoControlListBoxModel::~UnoControlListBoxModel()
2201 OUString
UnoControlListBoxModel::getImplementationName()
2202 throw (css::uno::RuntimeException
, std::exception
)
2204 return OUString("stardiv.Toolkit.UnoControlListBoxModel");
2207 css::uno::Sequence
<OUString
> UnoControlListBoxModel::getSupportedServiceNames()
2208 throw (css::uno::RuntimeException
, std::exception
)
2210 auto s(UnoControlModel::getSupportedServiceNames());
2211 s
.realloc(s
.getLength() + 2);
2212 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBoxModel";
2213 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ListBox";
2217 OUString
UnoControlListBoxModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
2219 return OUString::createFromAscii( szServiceName_UnoControlListBoxModel
);
2223 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2225 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2227 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlListBox
) );
2229 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2233 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
2235 static UnoPropertyArrayHelper
* pHelper
= nullptr;
2238 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
2239 pHelper
= new UnoPropertyArrayHelper( aIDs
);
2245 // beans::XMultiPropertySet
2246 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
2248 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2255 struct CreateListItem
: public ::std::unary_function
< OUString
, ListItem
>
2257 ListItem
operator()( const OUString
& i_rItemText
)
2259 return ListItem( i_rItemText
);
2265 void SAL_CALL
UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
, std::exception
)
2267 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
2269 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
)
2272 uno::Sequence
<sal_Int16
> aSeq
;
2273 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS
, uno::Any(aSeq
) );
2275 if ( !m_xData
->m_bSettingLegacyProperty
)
2277 // synchronize the legacy StringItemList property with our list items
2278 Sequence
< OUString
> aStringItemList
;
2280 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2281 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2283 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2285 aStringItemList
.getConstArray(),
2286 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2290 m_xData
->setAllItems( aItems
);
2292 // since an XItemListListener does not have a "all items modified" or some such method,
2293 // we simulate this by notifying removal of all items, followed by insertion of all new
2295 lang::EventObject aEvent
;
2296 aEvent
.Source
= *this;
2297 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
2298 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2299 // which is wrong for the above notifications ...
2305 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
2306 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const
2308 // dependencies we know:
2309 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2310 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
2312 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
2316 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount() throw (RuntimeException
, std::exception
)
2318 ::osl::MutexGuard
aGuard( GetMutex() );
2319 return m_xData
->getItemCount();
2323 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2325 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2326 // SYNCHRONIZED ----->
2327 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2328 rItem
.ItemText
= i_rItemText
;
2329 rItem
.ItemImageURL
= i_rItemImageURL
;
2331 impl_handleInsert( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2332 // <----- SYNCHRONIZED
2336 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2338 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2339 // SYNCHRONIZED ----->
2340 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2341 rItem
.ItemText
= i_rItemText
;
2343 impl_handleInsert( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2344 // <----- SYNCHRONIZED
2348 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2350 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2351 // SYNCHRONIZED ----->
2352 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2353 rItem
.ItemImageURL
= i_rItemImageURL
;
2355 impl_handleInsert( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2356 // <----- SYNCHRONIZED
2360 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2362 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2363 // SYNCHRONIZED ----->
2364 m_xData
->removeItem( i_nPosition
);
2366 impl_handleRemove( i_nPosition
, aGuard
);
2367 // <----- SYNCHRONIZED
2371 void SAL_CALL
UnoControlListBoxModel::removeAllItems( ) throw (css::uno::RuntimeException
, std::exception
)
2373 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2374 // SYNCHRONIZED ----->
2375 m_xData
->removeAllItems();
2377 impl_handleRemove( -1, aGuard
);
2378 // <----- SYNCHRONIZED
2382 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2384 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2385 // SYNCHRONIZED ----->
2386 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2387 rItem
.ItemText
= i_rItemText
;
2389 impl_handleModify( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2390 // <----- SYNCHRONIZED
2394 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2396 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2397 // SYNCHRONIZED ----->
2398 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2399 rItem
.ItemImageURL
= i_rItemImageURL
;
2401 impl_handleModify( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2402 // <----- SYNCHRONIZED
2406 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2408 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2409 // SYNCHRONIZED ----->
2410 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2411 rItem
.ItemText
= i_rItemText
;
2412 rItem
.ItemImageURL
= i_rItemImageURL
;
2414 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2415 // <----- SYNCHRONIZED
2419 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2421 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2422 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2423 rItem
.ItemData
= i_rDataValue
;
2427 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2429 ::osl::MutexGuard
aGuard( GetMutex() );
2430 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2431 return rItem
.ItemText
;
2435 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2437 ::osl::MutexGuard
aGuard( GetMutex() );
2438 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2439 return rItem
.ItemImageURL
;
2443 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2445 ::osl::MutexGuard
aGuard( GetMutex() );
2446 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2447 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2451 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
2453 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2454 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2455 return rItem
.ItemData
;
2459 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( ) throw (RuntimeException
, std::exception
)
2461 ::osl::MutexGuard
aGuard( GetMutex() );
2462 return m_xData
->getAllItems();
2466 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
, std::exception
)
2468 if ( i_Listener
.is() )
2469 m_aItemListListeners
.addInterface( i_Listener
);
2473 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
, std::exception
)
2475 if ( i_Listener
.is() )
2476 m_aItemListListeners
.removeInterface( i_Listener
);
2480 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector
< OUString
>& o_rStringItems
) const
2482 Sequence
< OUString
> aStringItemList
;
2484 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2485 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2487 o_rStringItems
.resize( size_t( aStringItemList
.getLength() ) );
2489 aStringItemList
.getConstArray(),
2490 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2491 o_rStringItems
.begin()
2496 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector
< OUString
>& i_rStringItems
)
2498 Sequence
< OUString
> aStringItems( comphelper::containerToSequence(i_rStringItems
) );
2499 m_xData
->m_bSettingLegacyProperty
= true;
2502 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST
, uno::makeAny( aStringItems
) );
2504 catch( const Exception
& )
2506 m_xData
->m_bSettingLegacyProperty
= false;
2509 m_xData
->m_bSettingLegacyProperty
= false;
2513 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2514 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2516 // SYNCHRONIZED ----->
2517 // sync with legacy StringItemList property
2518 ::std::vector
< OUString
> aStringItems
;
2519 impl_getStringItemList( aStringItems
);
2520 OSL_ENSURE( size_t( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2521 if ( size_t( i_nItemPosition
) <= aStringItems
.size() )
2523 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2524 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2527 i_rClearBeforeNotify
.clear();
2528 // <----- SYNCHRONIZED
2529 impl_setStringItemList_nolck( aStringItems
);
2531 // notify ItemListListeners
2532 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2536 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2538 // SYNCHRONIZED ----->
2539 const bool bAllItems
= ( i_nItemPosition
< 0 );
2540 // sync with legacy StringItemList property
2541 ::std::vector
< OUString
> aStringItems
;
2542 impl_getStringItemList( aStringItems
);
2545 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2546 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2548 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2553 aStringItems
.resize(0);
2556 i_rClearBeforeNotify
.clear();
2557 // <----- SYNCHRONIZED
2558 impl_setStringItemList_nolck( aStringItems
);
2560 // notify ItemListListeners
2563 EventObject
aEvent( *this );
2564 m_aItemListListeners
.notifyEach( &XItemListListener::allItemsRemoved
, aEvent
);
2568 impl_notifyItemListEvent_nolck( i_nItemPosition
, ::boost::optional
< OUString
>(), ::boost::optional
< OUString
>(),
2569 &XItemListListener::listItemRemoved
);
2574 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2575 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2577 // SYNCHRONIZED ----->
2578 if ( !!i_rItemText
)
2580 // sync with legacy StringItemList property
2581 ::std::vector
< OUString
> aStringItems
;
2582 impl_getStringItemList( aStringItems
);
2583 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2584 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2586 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2589 i_rClearBeforeNotify
.clear();
2590 // <----- SYNCHRONIZED
2591 impl_setStringItemList_nolck( aStringItems
);
2595 i_rClearBeforeNotify
.clear();
2596 // <----- SYNCHRONIZED
2599 // notify ItemListListeners
2600 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2604 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2605 const ::boost::optional
< OUString
>& i_rItemImageURL
,
2606 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2608 ItemListEvent aEvent
;
2609 aEvent
.Source
= *this;
2610 aEvent
.ItemPosition
= i_nItemPosition
;
2611 if ( !!i_rItemText
)
2613 aEvent
.ItemText
.IsPresent
= true;
2614 aEvent
.ItemText
.Value
= *i_rItemText
;
2616 if ( !!i_rItemImageURL
)
2618 aEvent
.ItemImageURL
.IsPresent
= true;
2619 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2622 m_aItemListListeners
.notifyEach( NotificationMethod
, aEvent
);
2625 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
2626 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2627 css::uno::XComponentContext
*context
,
2628 css::uno::Sequence
<css::uno::Any
> const &)
2630 return cppu::acquire(new UnoControlListBoxModel(context
));
2634 // class UnoListBoxControl
2636 UnoListBoxControl::UnoListBoxControl()
2637 :UnoListBoxControl_Base()
2638 ,maActionListeners( *this )
2639 ,maItemListeners( *this )
2641 maComponentInfos
.nWidth
= 100;
2642 maComponentInfos
.nHeight
= 12;
2645 OUString
UnoListBoxControl::GetComponentServiceName()
2647 return OUString("listbox");
2650 OUString
UnoListBoxControl::getImplementationName()
2651 throw (css::uno::RuntimeException
, std::exception
)
2653 return OUString("stardiv.Toolkit.UnoListBoxControl");
2656 css::uno::Sequence
<OUString
> UnoListBoxControl::getSupportedServiceNames()
2657 throw (css::uno::RuntimeException
, std::exception
)
2659 auto s(UnoControlBase::getSupportedServiceNames());
2660 s
.realloc(s
.getLength() + 2);
2661 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBox";
2662 s
[s
.getLength() - 1] = "stardiv.vcl.control.ListBox";
2666 void UnoListBoxControl::dispose() throw(uno::RuntimeException
, std::exception
)
2668 lang::EventObject aEvt
;
2669 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
2670 maActionListeners
.disposeAndClear( aEvt
);
2671 maItemListeners
.disposeAndClear( aEvt
);
2672 UnoControl::dispose();
2675 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2677 if ( getPeer().is() )
2679 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2680 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2682 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2683 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), uno::Any(aSeq
), false );
2687 void UnoListBoxControl::updateFromModel()
2689 UnoControlBase::updateFromModel();
2691 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2692 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2694 EventObject
aEvent( getModel() );
2695 xItemListListener
->itemListChanged( aEvent
);
2697 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2698 // already did this, our peer(s) can only legitimately set the selection after they have the string
2699 // item list, which we just notified with the itemListChanged call.
2700 const OUString
& sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2701 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2704 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2706 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2707 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2708 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2709 // will be forwarded to the peer, which will update itself accordingly.
2712 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2715 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
2717 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2719 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2720 xListBox
->addItemListener( this );
2722 if ( maActionListeners
.getLength() )
2723 xListBox
->addActionListener( &maActionListeners
);
2726 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
2728 maActionListeners
.addInterface( l
);
2729 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2731 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2732 xListBox
->addActionListener( &maActionListeners
);
2736 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
2738 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2740 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2741 xListBox
->removeActionListener( &maActionListeners
);
2743 maActionListeners
.removeInterface( l
);
2746 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
2748 maItemListeners
.addInterface( l
);
2751 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
2753 maItemListeners
.removeInterface( l
);
2756 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
2758 uno::Sequence
<OUString
> aSeq
{ aItem
};
2759 addItems( aSeq
, nPos
);
2762 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
2764 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2765 uno::Sequence
< OUString
> aSeq
;
2767 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
2768 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2769 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2771 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2772 OUString
* pNewData
= aNewSeq
.getArray();
2773 OUString
* pOldData
= aSeq
.getArray();
2775 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2776 nPos
= (sal_uInt16
) nOldLen
;
2779 // Items vor der Einfuege-Position
2780 for ( n
= 0; n
< nPos
; n
++ )
2781 pNewData
[n
] = pOldData
[n
];
2784 for ( n
= 0; n
< nNewItems
; n
++ )
2785 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
2787 // Rest der alten Items
2788 for ( n
= nPos
; n
< nOldLen
; n
++ )
2789 pNewData
[nNewItems
+n
] = pOldData
[n
];
2791 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2794 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
, std::exception
)
2796 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2797 uno::Sequence
< OUString
> aSeq
;
2799 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2800 if ( nOldLen
&& ( nPos
< nOldLen
) )
2802 if ( nCount
> ( nOldLen
-nPos
) )
2803 nCount
= nOldLen
-nPos
;
2805 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2807 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2808 OUString
* pNewData
= aNewSeq
.getArray();
2809 OUString
* pOldData
= aSeq
.getArray();
2812 // Items vor der Entfern-Position
2813 for ( n
= 0; n
< nPos
; n
++ )
2814 pNewData
[n
] = pOldData
[n
];
2817 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
2818 pNewData
[n
] = pOldData
[n
+nCount
];
2820 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2824 sal_Int16
UnoListBoxControl::getItemCount() throw(uno::RuntimeException
, std::exception
)
2826 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2827 uno::Sequence
< OUString
> aSeq
;
2829 return (sal_Int16
)aSeq
.getLength();
2832 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
2835 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2836 uno::Sequence
< OUString
> aSeq
;
2838 if ( nPos
< aSeq
.getLength() )
2839 aItem
= aSeq
.getConstArray()[nPos
];
2843 uno::Sequence
< OUString
> UnoListBoxControl::getItems() throw(uno::RuntimeException
, std::exception
)
2845 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2846 uno::Sequence
< OUString
> aSeq
;
2851 sal_Int16
UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException
, std::exception
)
2854 if ( getPeer().is() )
2856 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2857 n
= xListBox
->getSelectedItemPos();
2862 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException
, std::exception
)
2864 uno::Sequence
<sal_Int16
> aSeq
;
2865 if ( getPeer().is() )
2867 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2868 aSeq
= xListBox
->getSelectedItemsPos();
2873 OUString
UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException
, std::exception
)
2876 if ( getPeer().is() )
2878 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2879 aItem
= xListBox
->getSelectedItem();
2884 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException
, std::exception
)
2886 uno::Sequence
< OUString
> aSeq
;
2887 if ( getPeer().is() )
2889 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2890 aSeq
= xListBox
->getSelectedItems();
2895 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
) throw(uno::RuntimeException
, std::exception
)
2897 if ( getPeer().is() )
2899 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2900 xListBox
->selectItemPos( nPos
, bSelect
);
2902 ImplUpdateSelectedItemsProperty();
2905 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
) throw(uno::RuntimeException
, std::exception
)
2907 if ( getPeer().is() )
2909 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2910 xListBox
->selectItemsPos( aPositions
, bSelect
);
2912 ImplUpdateSelectedItemsProperty();
2915 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
) throw(uno::RuntimeException
, std::exception
)
2917 if ( getPeer().is() )
2919 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2920 xListBox
->selectItem( aItem
, bSelect
);
2922 ImplUpdateSelectedItemsProperty();
2925 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
) throw(uno::RuntimeException
, std::exception
)
2927 if ( getPeer().is() )
2929 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2930 xListBox
->makeVisible( nEntry
);
2934 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
, std::exception
)
2936 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any((sal_Int16
) nLines
), true );
2939 sal_Int16
UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException
, std::exception
)
2941 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2944 sal_Bool
UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException
, std::exception
)
2946 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2949 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
) throw(uno::RuntimeException
, std::exception
)
2951 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), uno::Any(bMulti
), true );
2954 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
, std::exception
)
2956 ImplUpdateSelectedItemsProperty();
2957 if ( maItemListeners
.getLength() )
2961 maItemListeners
.itemStateChanged( rEvent
);
2963 catch( const Exception
& e
)
2965 #if OSL_DEBUG_LEVEL == 0
2966 (void) e
; // suppress warning
2968 OString
sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2969 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2970 OSL_FAIL( sMessage
.getStr() );
2976 awt::Size
UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException
, std::exception
)
2978 return Impl_getMinimumSize();
2981 awt::Size
UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException
, std::exception
)
2983 return Impl_getPreferredSize();
2986 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
, std::exception
)
2988 return Impl_calcAdjustedSize( rNewSize
);
2991 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
, std::exception
)
2993 return Impl_getMinimumSize( nCols
, nLines
);
2996 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
, std::exception
)
2998 Impl_getColumnsAndLines( nCols
, nLines
);
3001 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
, std::exception
)
3003 ::osl::MutexGuard
aGuard( GetMutex() );
3005 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3006 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
3007 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3008 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
3010 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
3013 if ( xOldItems
.is() )
3014 xOldItems
->removeItemListListener( this );
3015 if ( xNewItems
.is() )
3016 xNewItems
->addItemListListener( this );
3021 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3023 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3024 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
3025 if ( xPeerListener
.is() )
3026 xPeerListener
->listItemInserted( i_rEvent
);
3029 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3031 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3032 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
3033 if ( xPeerListener
.is() )
3034 xPeerListener
->listItemRemoved( i_rEvent
);
3037 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3039 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3040 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
3041 if ( xPeerListener
.is() )
3042 xPeerListener
->listItemModified( i_rEvent
);
3045 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3047 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3048 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
3049 if ( xPeerListener
.is() )
3050 xPeerListener
->allItemsRemoved( i_rEvent
);
3053 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3055 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3056 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
3057 if ( xPeerListener
.is() )
3058 xPeerListener
->itemListChanged( i_rEvent
);
3061 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3062 stardiv_Toolkit_UnoListBoxControl_get_implementation(
3063 css::uno::XComponentContext
*,
3064 css::uno::Sequence
<css::uno::Any
> const &)
3066 return cppu::acquire(new UnoListBoxControl());
3070 // class UnoControlComboBoxModel
3072 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
3073 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
3075 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox
);
3078 OUString
UnoControlComboBoxModel::getImplementationName()
3079 throw (css::uno::RuntimeException
, std::exception
)
3081 return OUString("stardiv.Toolkit.UnoControlComboBoxModel");
3084 css::uno::Sequence
<OUString
> UnoControlComboBoxModel::getSupportedServiceNames()
3085 throw (css::uno::RuntimeException
, std::exception
)
3087 auto s(UnoControlModel::getSupportedServiceNames());
3088 s
.realloc(s
.getLength() + 2);
3089 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBoxModel";
3090 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ComboBox";
3094 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
3096 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3100 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
3102 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3105 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3106 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3112 OUString
UnoControlComboBoxModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
3114 return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel
);
3116 void SAL_CALL
UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
, std::exception
)
3118 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
3120 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
&& !m_xData
->m_bSettingLegacyProperty
)
3122 // synchronize the legacy StringItemList property with our list items
3123 Sequence
< OUString
> aStringItemList
;
3125 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
3126 OSL_VERIFY( aPropValue
>>= aStringItemList
);
3128 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
3130 aStringItemList
.getConstArray(),
3131 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
3135 m_xData
->setAllItems( aItems
);
3137 // since an XItemListListener does not have a "all items modified" or some such method,
3138 // we simulate this by notifying removal of all items, followed by insertion of all new
3140 lang::EventObject aEvent
;
3141 aEvent
.Source
= *this;
3142 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
3143 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
3144 // which is wrong for the above notifications ...
3148 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3150 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3152 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlComboBox
) );
3154 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3157 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3158 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
3159 css::uno::XComponentContext
*context
,
3160 css::uno::Sequence
<css::uno::Any
> const &)
3162 return cppu::acquire(new UnoControlComboBoxModel(context
));
3166 // class UnoComboBoxControl
3168 UnoComboBoxControl::UnoComboBoxControl()
3170 ,maActionListeners( *this )
3171 ,maItemListeners( *this )
3173 maComponentInfos
.nWidth
= 100;
3174 maComponentInfos
.nHeight
= 12;
3177 OUString
UnoComboBoxControl::getImplementationName()
3178 throw (css::uno::RuntimeException
, std::exception
)
3180 return OUString( "stardiv.Toolkit.UnoComboBoxControl");
3183 css::uno::Sequence
<OUString
> UnoComboBoxControl::getSupportedServiceNames()
3184 throw (css::uno::RuntimeException
, std::exception
)
3186 auto s(UnoEditControl::getSupportedServiceNames());
3187 s
.realloc(s
.getLength() + 2);
3188 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBox";
3189 s
[s
.getLength() - 1] = "stardiv.vcl.control.ComboBox";
3193 OUString
UnoComboBoxControl::GetComponentServiceName()
3195 return OUString("combobox");
3198 void UnoComboBoxControl::dispose() throw(uno::RuntimeException
, std::exception
)
3200 lang::EventObject aEvt
;
3201 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
3202 maActionListeners
.disposeAndClear( aEvt
);
3203 maItemListeners
.disposeAndClear( aEvt
);
3204 UnoControl::dispose();
3206 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
3208 uno::Any aRet
= ::cppu::queryInterface( rType
,
3209 (static_cast< awt::XComboBox
* >(this)) );
3210 if ( !aRet
.hasValue() )
3212 aRet
= ::cppu::queryInterface( rType
,
3213 (static_cast< awt::XItemListener
* >(this)) );
3214 if ( !aRet
.hasValue() )
3216 aRet
= ::cppu::queryInterface( rType
,
3217 (static_cast< awt::XItemListListener
* >(this)) );
3220 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3222 // lang::XTypeProvider
3223 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl
)
3224 cppu::UnoType
<awt::XComboBox
>::get(),
3225 cppu::UnoType
<awt::XItemListener
>::get(),
3226 cppu::UnoType
<awt::XItemListListener
>::get(),
3227 UnoEditControl::getTypes()
3228 IMPL_XTYPEPROVIDER_END
3230 void UnoComboBoxControl::updateFromModel()
3232 UnoEditControl::updateFromModel();
3234 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
3235 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3237 EventObject
aEvent( getModel() );
3238 xItemListListener
->itemListChanged( aEvent
);
3240 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
3242 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
3243 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3244 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3245 // will be forwarded to the peer, which will update itself accordingly.
3248 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
3250 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
3252 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3254 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3255 if ( maActionListeners
.getLength() )
3256 xComboBox
->addActionListener( &maActionListeners
);
3257 if ( maItemListeners
.getLength() )
3258 xComboBox
->addItemListener( &maItemListeners
);
3261 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
3263 maActionListeners
.addInterface( l
);
3264 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3266 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3267 xComboBox
->addActionListener( &maActionListeners
);
3271 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
, std::exception
)
3273 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3275 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3276 xComboBox
->removeActionListener( &maActionListeners
);
3278 maActionListeners
.removeInterface( l
);
3281 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
3283 maItemListeners
.addInterface( l
);
3284 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3286 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3287 xComboBox
->addItemListener( &maItemListeners
);
3291 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
, std::exception
)
3293 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3295 // This call is prettier than creating a Ref and calling query
3296 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3297 xComboBox
->removeItemListener( &maItemListeners
);
3299 maItemListeners
.removeInterface( l
);
3301 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
, std::exception
)
3303 if ( maItemListeners
.getLength() )
3307 maItemListeners
.itemStateChanged( rEvent
);
3309 catch( const Exception
& e
)
3311 #if OSL_DEBUG_LEVEL == 0
3312 (void) e
; // suppress warning
3314 OString
sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
3315 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
3316 OSL_FAIL( sMessage
.getStr() );
3321 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
, std::exception
)
3323 ::osl::MutexGuard
aGuard( GetMutex() );
3325 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3326 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3327 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3328 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3330 if ( !UnoEditControl::setModel( i_rModel
) )
3333 if ( xOldItems
.is() )
3334 xOldItems
->removeItemListListener( this );
3335 if ( xNewItems
.is() )
3336 xNewItems
->addItemListListener( this );
3341 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3343 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3344 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3345 if ( xPeerListener
.is() )
3346 xPeerListener
->listItemInserted( i_rEvent
);
3349 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3351 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3352 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3353 if ( xPeerListener
.is() )
3354 xPeerListener
->listItemRemoved( i_rEvent
);
3357 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3359 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3360 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3361 if ( xPeerListener
.is() )
3362 xPeerListener
->listItemModified( i_rEvent
);
3365 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3367 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3368 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3369 if ( xPeerListener
.is() )
3370 xPeerListener
->allItemsRemoved( i_rEvent
);
3373 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
, std::exception
)
3375 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3376 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3377 if ( xPeerListener
.is() )
3378 xPeerListener
->itemListChanged( i_rEvent
);
3381 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
3383 uno::Sequence
<OUString
> aSeq
{ aItem
};
3384 addItems( aSeq
, nPos
);
3387 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
3389 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3390 uno::Sequence
< OUString
> aSeq
;
3392 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
3393 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3394 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3396 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3397 OUString
* pNewData
= aNewSeq
.getArray();
3398 const OUString
* pOldData
= aSeq
.getConstArray();
3400 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3401 nPos
= (sal_uInt16
) nOldLen
;
3404 // items before the insert position
3405 for ( n
= 0; n
< nPos
; n
++ )
3406 pNewData
[n
] = pOldData
[n
];
3409 for ( n
= 0; n
< nNewItems
; n
++ )
3410 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
3412 // remainder of old items
3413 for ( n
= nPos
; n
< nOldLen
; n
++ )
3414 pNewData
[nNewItems
+n
] = pOldData
[n
];
3416 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), Any(aNewSeq
), true );
3419 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
, std::exception
)
3421 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3422 uno::Sequence
< OUString
> aSeq
;
3424 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3425 if ( nOldLen
&& ( nPos
< nOldLen
) )
3427 if ( nCount
> ( nOldLen
-nPos
) )
3428 nCount
= nOldLen
-nPos
;
3430 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3432 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3433 OUString
* pNewData
= aNewSeq
.getArray();
3434 OUString
* pOldData
= aSeq
.getArray();
3437 // items before the deletion position
3438 for ( n
= 0; n
< nPos
; n
++ )
3439 pNewData
[n
] = pOldData
[n
];
3441 // remainder of old items
3442 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
3443 pNewData
[n
] = pOldData
[n
+nCount
];
3445 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
3449 sal_Int16
UnoComboBoxControl::getItemCount() throw(uno::RuntimeException
, std::exception
)
3451 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3452 uno::Sequence
< OUString
> aSeq
;
3454 return (sal_Int16
)aSeq
.getLength();
3457 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
, std::exception
)
3460 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3461 uno::Sequence
< OUString
> aSeq
;
3463 if ( nPos
< aSeq
.getLength() )
3464 aItem
= aSeq
.getConstArray()[nPos
];
3468 uno::Sequence
< OUString
> UnoComboBoxControl::getItems() throw(uno::RuntimeException
, std::exception
)
3470 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3471 uno::Sequence
< OUString
> aSeq
;
3476 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
, std::exception
)
3478 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
3481 sal_Int16
UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException
, std::exception
)
3483 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3486 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3487 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3488 css::uno::XComponentContext
*,
3489 css::uno::Sequence
<css::uno::Any
> const &)
3491 return cppu::acquire(new UnoComboBoxControl());
3495 // UnoSpinFieldControl
3497 UnoSpinFieldControl::UnoSpinFieldControl()
3499 ,maSpinListeners( *this )
3505 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
3507 uno::Any aRet
= ::cppu::queryInterface( rType
,
3508 (static_cast< awt::XSpinField
* >(this)) );
3509 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3512 // lang::XTypeProvider
3513 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl
)
3514 cppu::UnoType
<awt::XSpinField
>::get(),
3515 UnoEditControl::getTypes()
3516 IMPL_XTYPEPROVIDER_END
3518 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
3520 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3522 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3523 xField
->enableRepeat( mbRepeat
);
3524 if ( maSpinListeners
.getLength() )
3525 xField
->addSpinListener( &maSpinListeners
);
3528 // css::awt::XSpinField
3529 void UnoSpinFieldControl::addSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
) throw(css::uno::RuntimeException
, std::exception
)
3531 maSpinListeners
.addInterface( l
);
3532 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3534 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3535 xField
->addSpinListener( &maSpinListeners
);
3539 void UnoSpinFieldControl::removeSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
) throw(css::uno::RuntimeException
, std::exception
)
3541 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3543 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3544 xField
->removeSpinListener( &maSpinListeners
);
3546 maSpinListeners
.removeInterface( l
);
3549 void UnoSpinFieldControl::up() throw(css::uno::RuntimeException
, std::exception
)
3551 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3556 void UnoSpinFieldControl::down() throw(css::uno::RuntimeException
, std::exception
)
3558 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3563 void UnoSpinFieldControl::first() throw(css::uno::RuntimeException
, std::exception
)
3565 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3570 void UnoSpinFieldControl::last() throw(css::uno::RuntimeException
, std::exception
)
3572 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3577 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
) throw(css::uno::RuntimeException
, std::exception
)
3581 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3583 xField
->enableRepeat( bRepeat
);
3587 // class UnoControlDateFieldModel
3589 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3590 :UnoControlModel( rxContext
)
3592 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField
);
3595 OUString
UnoControlDateFieldModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
3597 return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel
);
3600 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3602 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3604 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlDateField
) );
3606 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3610 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3612 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3615 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3616 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3621 // beans::XMultiPropertySet
3622 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
3624 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3628 OUString
UnoControlDateFieldModel::getImplementationName()
3629 throw (css::uno::RuntimeException
, std::exception
)
3631 return OUString("stardiv.Toolkit.UnoControlDateFieldModel");
3634 css::uno::Sequence
<OUString
>
3635 UnoControlDateFieldModel::getSupportedServiceNames()
3636 throw (css::uno::RuntimeException
, std::exception
)
3638 auto s(UnoControlModel::getSupportedServiceNames());
3639 s
.realloc(s
.getLength() + 2);
3640 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateFieldModel";
3641 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.DateField";
3645 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3646 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3647 css::uno::XComponentContext
*context
,
3648 css::uno::Sequence
<css::uno::Any
> const &)
3650 return cppu::acquire(new UnoControlDateFieldModel(context
));
3654 // class UnoDateFieldControl
3656 UnoDateFieldControl::UnoDateFieldControl()
3657 :UnoSpinFieldControl()
3659 mnFirst
= util::Date( 1, 1, 1900 );
3660 mnLast
= util::Date( 31, 12, 2200 );
3661 mbLongFormat
= TRISTATE_INDET
;
3664 OUString
UnoDateFieldControl::GetComponentServiceName()
3666 return OUString("datefield");
3670 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
3672 uno::Any aRet
= ::cppu::queryInterface( rType
,
3673 (static_cast< awt::XDateField
* >(this)) );
3674 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3677 // lang::XTypeProvider
3678 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl
)
3679 cppu::UnoType
<awt::XDateField
>::get(),
3680 UnoSpinFieldControl::getTypes()
3681 IMPL_XTYPEPROVIDER_END
3683 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
3685 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3687 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3688 xField
->setFirst( mnFirst
);
3689 xField
->setLast( mnLast
);
3690 if ( mbLongFormat
!= TRISTATE_INDET
)
3691 xField
->setLongFormat( mbLongFormat
);
3695 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
, std::exception
)
3697 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3699 // also change the text property (#i25106#)
3702 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3703 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3706 // re-calc the Date property
3707 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3709 if ( xField
->isEmpty() )
3711 // the field says it's empty
3712 bool bEnforceFormat
= true;
3714 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3715 if ( !bEnforceFormat
)
3717 // and it also says that it is currently accepting invalid inputs, without
3718 // forcing it to a valid date
3719 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3720 if ( xText
.is() && xText
->getText().getLength() )
3721 // and in real, the text of the peer is *not* empty
3722 // -> simulate an invalid date, which is different from "no date"
3723 aValue
<<= util::Date();
3727 aValue
<<= xField
->getDate();
3729 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, false );
3731 // multiplex the event
3732 if ( GetTextListeners().getLength() )
3733 GetTextListeners().textChanged( e
);
3736 void UnoDateFieldControl::setDate( const util::Date
& Date
) throw(uno::RuntimeException
, std::exception
)
3738 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), uno::Any(Date
), true );
3741 util::Date
UnoDateFieldControl::getDate() throw(uno::RuntimeException
, std::exception
)
3743 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3746 void UnoDateFieldControl::setMin( const util::Date
& Date
) throw(uno::RuntimeException
, std::exception
)
3748 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), uno::Any(Date
), true );
3751 util::Date
UnoDateFieldControl::getMin() throw(uno::RuntimeException
, std::exception
)
3753 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3756 void UnoDateFieldControl::setMax( const util::Date
& Date
) throw(uno::RuntimeException
, std::exception
)
3758 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), uno::Any(Date
), true );
3761 util::Date
UnoDateFieldControl::getMax() throw(uno::RuntimeException
, std::exception
)
3763 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3766 void UnoDateFieldControl::setFirst( const util::Date
& Date
) throw(uno::RuntimeException
, std::exception
)
3769 if ( getPeer().is() )
3771 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3772 xField
->setFirst( Date
);
3776 util::Date
UnoDateFieldControl::getFirst() throw(uno::RuntimeException
, std::exception
)
3781 void UnoDateFieldControl::setLast( const util::Date
& Date
) throw(uno::RuntimeException
, std::exception
)
3784 if ( getPeer().is() )
3786 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3787 xField
->setLast( Date
);
3791 util::Date
UnoDateFieldControl::getLast() throw(uno::RuntimeException
, std::exception
)
3796 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
) throw(uno::RuntimeException
, std::exception
)
3798 mbLongFormat
= bLong
? TRISTATE_TRUE
: TRISTATE_FALSE
;
3799 if ( getPeer().is() )
3801 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3802 xField
->setLongFormat( bLong
);
3806 sal_Bool
UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException
, std::exception
)
3808 return mbLongFormat
== TRISTATE_TRUE
;
3811 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException
, std::exception
)
3813 if ( getPeer().is() )
3815 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3820 sal_Bool
UnoDateFieldControl::isEmpty() throw(uno::RuntimeException
, std::exception
)
3822 bool bEmpty
= false;
3823 if ( getPeer().is() )
3825 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3826 bEmpty
= xField
->isEmpty();
3831 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
, std::exception
)
3833 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3836 sal_Bool
UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException
, std::exception
)
3838 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3841 OUString
UnoDateFieldControl::getImplementationName()
3842 throw (css::uno::RuntimeException
, std::exception
)
3844 return OUString("stardiv.Toolkit.UnoDateFieldControl");
3847 css::uno::Sequence
<OUString
> UnoDateFieldControl::getSupportedServiceNames()
3848 throw (css::uno::RuntimeException
, std::exception
)
3850 auto s(UnoSpinFieldControl::getSupportedServiceNames());
3851 s
.realloc(s
.getLength() + 2);
3852 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateField";
3853 s
[s
.getLength() - 1] = "stardiv.vcl.control.DateField";
3857 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3858 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3859 css::uno::XComponentContext
*,
3860 css::uno::Sequence
<css::uno::Any
> const &)
3862 return cppu::acquire(new UnoDateFieldControl());
3866 // class UnoControlTimeFieldModel
3868 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3869 :UnoControlModel( rxContext
)
3871 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField
);
3874 OUString
UnoControlTimeFieldModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
3876 return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel
);
3879 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3881 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3883 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlTimeField
) );
3885 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3889 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3891 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3894 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3895 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3900 // beans::XMultiPropertySet
3901 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
3903 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3907 OUString
UnoControlTimeFieldModel::getImplementationName()
3908 throw (css::uno::RuntimeException
, std::exception
)
3910 return OUString("stardiv.Toolkit.UnoControlTimeFieldModel");
3913 css::uno::Sequence
<OUString
>
3914 UnoControlTimeFieldModel::getSupportedServiceNames()
3915 throw (css::uno::RuntimeException
, std::exception
)
3917 auto s(UnoControlModel::getSupportedServiceNames());
3918 s
.realloc(s
.getLength() + 2);
3919 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeFieldModel";
3920 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.TimeField";
3924 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3925 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
3926 css::uno::XComponentContext
*context
,
3927 css::uno::Sequence
<css::uno::Any
> const &)
3929 return cppu::acquire(new UnoControlTimeFieldModel(context
));
3933 // class UnoTimeFieldControl
3935 UnoTimeFieldControl::UnoTimeFieldControl()
3936 :UnoSpinFieldControl()
3938 mnFirst
= util::Time( 0, 0, 0, 0, false );
3939 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3942 OUString
UnoTimeFieldControl::GetComponentServiceName()
3944 return OUString("timefield");
3948 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
3950 uno::Any aRet
= ::cppu::queryInterface( rType
,
3951 (static_cast< awt::XTimeField
* >(this)) );
3952 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3955 // lang::XTypeProvider
3956 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl
)
3957 cppu::UnoType
<awt::XTimeField
>::get(),
3958 UnoSpinFieldControl::getTypes()
3959 IMPL_XTYPEPROVIDER_END
3961 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
3963 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3965 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3966 xField
->setFirst( mnFirst
);
3967 xField
->setLast( mnLast
);
3970 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
, std::exception
)
3972 // also change the text property (#i25106#)
3973 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3974 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3975 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3977 // re-calc the Time property
3978 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3980 if ( !xField
->isEmpty() )
3981 aValue
<<= xField
->getTime();
3982 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, false );
3984 // multiplex the event
3985 if ( GetTextListeners().getLength() )
3986 GetTextListeners().textChanged( e
);
3989 void UnoTimeFieldControl::setTime( const util::Time
& Time
) throw(uno::RuntimeException
, std::exception
)
3991 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), Any(Time
), true );
3994 util::Time
UnoTimeFieldControl::getTime() throw(uno::RuntimeException
, std::exception
)
3996 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3999 void UnoTimeFieldControl::setMin( const util::Time
& Time
) throw(uno::RuntimeException
, std::exception
)
4001 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), uno::Any(Time
), true );
4004 util::Time
UnoTimeFieldControl::getMin() throw(uno::RuntimeException
, std::exception
)
4006 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
4009 void UnoTimeFieldControl::setMax( const util::Time
& Time
) throw(uno::RuntimeException
, std::exception
)
4011 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), uno::Any(Time
), true );
4014 util::Time
UnoTimeFieldControl::getMax() throw(uno::RuntimeException
, std::exception
)
4016 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
4019 void UnoTimeFieldControl::setFirst( const util::Time
& Time
) throw(uno::RuntimeException
, std::exception
)
4022 if ( getPeer().is() )
4024 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4025 xField
->setFirst( mnFirst
);
4029 util::Time
UnoTimeFieldControl::getFirst() throw(uno::RuntimeException
, std::exception
)
4034 void UnoTimeFieldControl::setLast( const util::Time
& Time
) throw(uno::RuntimeException
, std::exception
)
4037 if ( getPeer().is() )
4039 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4040 xField
->setFirst( mnLast
);
4044 util::Time
UnoTimeFieldControl::getLast() throw(uno::RuntimeException
, std::exception
)
4049 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException
, std::exception
)
4051 if ( getPeer().is() )
4053 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4058 sal_Bool
UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException
, std::exception
)
4060 bool bEmpty
= false;
4061 if ( getPeer().is() )
4063 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4064 bEmpty
= xField
->isEmpty();
4069 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
, std::exception
)
4071 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4074 sal_Bool
UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException
, std::exception
)
4076 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4079 OUString
UnoTimeFieldControl::getImplementationName()
4080 throw (css::uno::RuntimeException
, std::exception
)
4082 return OUString("stardiv.Toolkit.UnoTimeFieldControl");
4085 css::uno::Sequence
<OUString
> UnoTimeFieldControl::getSupportedServiceNames()
4086 throw (css::uno::RuntimeException
, std::exception
)
4088 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4089 s
.realloc(s
.getLength() + 2);
4090 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeField";
4091 s
[s
.getLength() - 1] = "stardiv.vcl.control.TimeField";
4095 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4096 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
4097 css::uno::XComponentContext
*,
4098 css::uno::Sequence
<css::uno::Any
> const &)
4100 return cppu::acquire(new UnoTimeFieldControl());
4104 // class UnoControlNumericFieldModel
4106 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
4107 :UnoControlModel( rxContext
)
4109 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField
);
4112 OUString
UnoControlNumericFieldModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
4114 return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel
);
4117 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4119 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4121 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlNumericField
) );
4123 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4127 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
4129 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4132 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4133 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4138 // beans::XMultiPropertySet
4139 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
4141 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4145 OUString
UnoControlNumericFieldModel::getImplementationName()
4146 throw (css::uno::RuntimeException
, std::exception
)
4148 return OUString("stardiv.Toolkit.UnoControlNumericFieldModel");
4151 css::uno::Sequence
<OUString
>
4152 UnoControlNumericFieldModel::getSupportedServiceNames()
4153 throw (css::uno::RuntimeException
, std::exception
)
4155 auto s(UnoControlModel::getSupportedServiceNames());
4156 s
.realloc(s
.getLength() + 2);
4157 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericFieldModel";
4158 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.NumericField";
4162 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4163 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
4164 css::uno::XComponentContext
*context
,
4165 css::uno::Sequence
<css::uno::Any
> const &)
4167 return cppu::acquire(new UnoControlNumericFieldModel(context
));
4171 // class UnoNumericFieldControl
4173 UnoNumericFieldControl::UnoNumericFieldControl()
4174 :UnoSpinFieldControl()
4177 mnLast
= 0x7FFFFFFF;
4180 OUString
UnoNumericFieldControl::GetComponentServiceName()
4182 return OUString("numericfield");
4186 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
4188 uno::Any aRet
= ::cppu::queryInterface( rType
,
4189 (static_cast< awt::XNumericField
* >(this)) );
4190 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4193 // lang::XTypeProvider
4194 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl
)
4195 cppu::UnoType
<awt::XNumericField
>::get(),
4196 UnoSpinFieldControl::getTypes()
4197 IMPL_XTYPEPROVIDER_END
4199 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
4201 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4203 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4204 xField
->setFirst( mnFirst
);
4205 xField
->setLast( mnLast
);
4209 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
, std::exception
)
4211 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4212 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4214 if ( GetTextListeners().getLength() )
4215 GetTextListeners().textChanged( e
);
4218 void UnoNumericFieldControl::setValue( double Value
) throw(uno::RuntimeException
, std::exception
)
4220 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(Value
), true );
4223 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException
, std::exception
)
4225 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4228 void UnoNumericFieldControl::setMin( double Value
) throw(uno::RuntimeException
, std::exception
)
4230 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4233 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException
, std::exception
)
4235 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4238 void UnoNumericFieldControl::setMax( double Value
) throw(uno::RuntimeException
, std::exception
)
4240 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4243 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException
, std::exception
)
4245 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4248 void UnoNumericFieldControl::setFirst( double Value
) throw(uno::RuntimeException
, std::exception
)
4251 if ( getPeer().is() )
4253 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4254 xField
->setFirst( mnFirst
);
4258 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException
, std::exception
)
4263 void UnoNumericFieldControl::setLast( double Value
) throw(uno::RuntimeException
, std::exception
)
4266 if ( getPeer().is() )
4268 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4269 xField
->setLast( mnLast
);
4273 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException
, std::exception
)
4278 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
, std::exception
)
4280 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4283 sal_Bool
UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException
, std::exception
)
4285 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4288 OUString
UnoNumericFieldControl::getImplementationName()
4289 throw (css::uno::RuntimeException
, std::exception
)
4291 return OUString("stardiv.Toolkit.UnoNumericFieldControl");
4294 css::uno::Sequence
<OUString
> UnoNumericFieldControl::getSupportedServiceNames()
4295 throw (css::uno::RuntimeException
, std::exception
)
4297 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4298 s
.realloc(s
.getLength() + 2);
4299 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericField";
4300 s
[s
.getLength() - 1] = "stardiv.vcl.control.NumericField";
4304 void UnoNumericFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
, std::exception
)
4306 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4309 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException
, std::exception
)
4311 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4314 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
, std::exception
)
4316 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4319 sal_Int16
UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException
, std::exception
)
4321 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4324 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4325 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4326 css::uno::XComponentContext
*,
4327 css::uno::Sequence
<css::uno::Any
> const &)
4329 return cppu::acquire(new UnoNumericFieldControl());
4333 // class UnoControlCurrencyFieldModel
4335 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
4336 :UnoControlModel( rxContext
)
4338 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField
);
4341 OUString
UnoControlCurrencyFieldModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
4343 return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel
);
4346 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4348 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4350 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlCurrencyField
) );
4352 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
4354 return uno::Any(false);
4357 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4360 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
4362 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4365 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4366 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4371 // beans::XMultiPropertySet
4372 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
4374 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4378 OUString
UnoControlCurrencyFieldModel::getImplementationName()
4379 throw (css::uno::RuntimeException
, std::exception
)
4381 return OUString("stardiv.Toolkit.UnoControlCurrencyFieldModel");
4384 css::uno::Sequence
<OUString
>
4385 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4386 throw (css::uno::RuntimeException
, std::exception
)
4388 auto s(UnoControlModel::getSupportedServiceNames());
4389 s
.realloc(s
.getLength() + 2);
4390 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyFieldModel";
4391 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CurrencyField";
4395 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4396 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4397 css::uno::XComponentContext
*context
,
4398 css::uno::Sequence
<css::uno::Any
> const &)
4400 return cppu::acquire(new UnoControlCurrencyFieldModel(context
));
4404 // class UnoCurrencyFieldControl
4406 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4407 :UnoSpinFieldControl()
4410 mnLast
= 0x7FFFFFFF;
4413 OUString
UnoCurrencyFieldControl::GetComponentServiceName()
4415 return OUString("longcurrencyfield");
4419 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
4421 uno::Any aRet
= ::cppu::queryInterface( rType
,
4422 (static_cast< awt::XCurrencyField
* >(this)) );
4423 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4426 // lang::XTypeProvider
4427 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl
)
4428 cppu::UnoType
<awt::XCurrencyField
>::get(),
4429 UnoSpinFieldControl::getTypes()
4430 IMPL_XTYPEPROVIDER_END
4432 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
, std::exception
)
4434 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4436 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4437 xField
->setFirst( mnFirst
);
4438 xField
->setLast( mnLast
);
4441 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
, std::exception
)
4443 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4444 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4446 if ( GetTextListeners().getLength() )
4447 GetTextListeners().textChanged( e
);
4450 void UnoCurrencyFieldControl::setValue( double Value
) throw(uno::RuntimeException
, std::exception
)
4452 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), Any(Value
), true );
4455 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException
, std::exception
)
4457 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4460 void UnoCurrencyFieldControl::setMin( double Value
) throw(uno::RuntimeException
, std::exception
)
4462 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4465 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException
, std::exception
)
4467 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4470 void UnoCurrencyFieldControl::setMax( double Value
) throw(uno::RuntimeException
, std::exception
)
4472 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4475 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException
, std::exception
)
4477 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4480 void UnoCurrencyFieldControl::setFirst( double Value
) throw(uno::RuntimeException
, std::exception
)
4483 if ( getPeer().is() )
4485 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4486 xField
->setFirst( mnFirst
);
4490 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException
, std::exception
)
4495 void UnoCurrencyFieldControl::setLast( double Value
) throw(uno::RuntimeException
, std::exception
)
4498 if ( getPeer().is() )
4500 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4501 xField
->setLast( mnLast
);
4505 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException
, std::exception
)
4510 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
, std::exception
)
4512 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4515 sal_Bool
UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException
, std::exception
)
4517 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4520 OUString
UnoCurrencyFieldControl::getImplementationName()
4521 throw (css::uno::RuntimeException
, std::exception
)
4523 return OUString("stardiv.Toolkit.UnoCurrencyFieldControl");
4526 css::uno::Sequence
<OUString
>
4527 UnoCurrencyFieldControl::getSupportedServiceNames()
4528 throw (css::uno::RuntimeException
, std::exception
)
4530 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4531 s
.realloc(s
.getLength() + 2);
4532 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyField";
4533 s
[s
.getLength() - 1] = "stardiv.vcl.control.CurrencyField";
4537 void UnoCurrencyFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
, std::exception
)
4539 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4542 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException
, std::exception
)
4544 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4547 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
, std::exception
)
4549 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4552 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException
, std::exception
)
4554 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4557 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4558 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4559 css::uno::XComponentContext
*,
4560 css::uno::Sequence
<css::uno::Any
> const &)
4562 return cppu::acquire(new UnoCurrencyFieldControl());
4566 // class UnoControlPatternFieldModel
4568 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4569 :UnoControlModel( rxContext
)
4571 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField
);
4574 OUString
UnoControlPatternFieldModel::getServiceName() throw(css::uno::RuntimeException
, std::exception
)
4576 return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel
);
4579 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4581 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4583 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlPatternField
) );
4585 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4588 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4590 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4593 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4594 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4599 // beans::XMultiPropertySet
4600 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
4602 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4606 OUString
UnoControlPatternFieldModel::getImplementationName()
4607 throw (css::uno::RuntimeException
, std::exception
)
4609 return OUString("stardiv.Toolkit.UnoControlPatternFieldModel");
4612 css::uno::Sequence
<OUString
>
4613 UnoControlPatternFieldModel::getSupportedServiceNames()
4614 throw (css::uno::RuntimeException
, std::exception
)
4616 auto s(UnoControlModel::getSupportedServiceNames());
4617 s
.realloc(s
.getLength() + 2);
4618 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternFieldModel";
4619 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.PatternField";
4623 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4624 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4625 css::uno::XComponentContext
*context
,
4626 css::uno::Sequence
<css::uno::Any
> const &)
4628 return cppu::acquire(new UnoControlPatternFieldModel(context
));
4632 // class UnoPatternFieldControl
4634 UnoPatternFieldControl::UnoPatternFieldControl()
4635 :UnoSpinFieldControl()
4639 OUString
UnoPatternFieldControl::GetComponentServiceName()
4641 return OUString("patternfield");
4644 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4646 sal_uInt16 nType
= GetPropertyId( rPropName
);
4647 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4649 // These masks cannot be set consecutively
4650 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4651 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4652 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4654 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4657 // same comment as in UnoControl::ImplSetPeerProperty - see there
4658 OUString
sText( Text
);
4659 ImplCheckLocalize( sText
);
4660 xPF
->setString( sText
);
4661 xPF
->setMasks( EditMask
, LiteralMask
);
4665 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4670 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
4672 uno::Any aRet
= ::cppu::queryInterface( rType
,
4673 (static_cast< awt::XPatternField
* >(this)) );
4674 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4677 // lang::XTypeProvider
4678 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl
)
4679 cppu::UnoType
<awt::XPatternField
>::get(),
4680 UnoSpinFieldControl::getTypes()
4681 IMPL_XTYPEPROVIDER_END
4683 void UnoPatternFieldControl::setString( const OUString
& rString
) throw(uno::RuntimeException
, std::exception
)
4688 OUString
UnoPatternFieldControl::getString() throw(uno::RuntimeException
, std::exception
)
4693 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
) throw(uno::RuntimeException
, std::exception
)
4695 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), uno::Any(EditMask
), true );
4696 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), uno::Any(LiteralMask
), true );
4699 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
) throw(uno::RuntimeException
, std::exception
)
4701 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4702 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4705 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
, std::exception
)
4707 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4710 sal_Bool
UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException
, std::exception
)
4712 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4715 OUString
UnoPatternFieldControl::getImplementationName()
4716 throw (css::uno::RuntimeException
, std::exception
)
4718 return OUString("stardiv.Toolkit.UnoPatternFieldControl");
4721 css::uno::Sequence
<OUString
> UnoPatternFieldControl::getSupportedServiceNames()
4722 throw (css::uno::RuntimeException
, std::exception
)
4724 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4725 s
.realloc(s
.getLength() + 2);
4726 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternField";
4727 s
[s
.getLength() - 1] = "stardiv.vcl.control.PatternField";
4731 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4732 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4733 css::uno::XComponentContext
*,
4734 css::uno::Sequence
<css::uno::Any
> const &)
4736 return cppu::acquire(new UnoPatternFieldControl());
4740 // class UnoControlProgressBarModel
4742 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4743 :UnoControlModel( rxContext
)
4745 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4746 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4747 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4748 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4749 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4750 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4751 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4752 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4753 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4754 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4755 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4756 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4757 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4760 OUString
UnoControlProgressBarModel::getServiceName( ) throw(css::uno::RuntimeException
, std::exception
)
4762 return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel
);
4765 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4767 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4769 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlProgressBar
) );
4772 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4775 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4777 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4780 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4781 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4786 // beans::XMultiPropertySet
4787 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
4789 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4793 OUString
UnoControlProgressBarModel::getImplementationName()
4794 throw (css::uno::RuntimeException
, std::exception
)
4796 return OUString("stardiv.Toolkit.UnoControlProgressBarModel");
4799 css::uno::Sequence
<OUString
>
4800 UnoControlProgressBarModel::getSupportedServiceNames()
4801 throw (css::uno::RuntimeException
, std::exception
)
4803 auto s(UnoControlModel::getSupportedServiceNames());
4804 s
.realloc(s
.getLength() + 2);
4805 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBarModel";
4806 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ProgressBar";
4810 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4811 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4812 css::uno::XComponentContext
*context
,
4813 css::uno::Sequence
<css::uno::Any
> const &)
4815 return cppu::acquire(new UnoControlProgressBarModel(context
));
4819 // class UnoProgressBarControl
4821 UnoProgressBarControl::UnoProgressBarControl()
4826 OUString
UnoProgressBarControl::GetComponentServiceName()
4828 return OUString("ProgressBar");
4832 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
, std::exception
)
4834 uno::Any aRet
= ::cppu::queryInterface( rType
,
4835 (static_cast< awt::XProgressBar
* >(this)) );
4836 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4839 // lang::XTypeProvider
4840 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl
)
4841 cppu::UnoType
<awt::XProgressBar
>::get(),
4842 UnoControlBase::getTypes()
4843 IMPL_XTYPEPROVIDER_END
4845 // css::awt::XProgressBar
4846 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
) throw(css::uno::RuntimeException
, std::exception
)
4848 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), uno::Any(nColor
), true );
4851 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
) throw(css::uno::RuntimeException
, std::exception
)
4853 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), uno::Any(nColor
), true );
4856 void UnoProgressBarControl::setValue( sal_Int32 nValue
) throw(css::uno::RuntimeException
, std::exception
)
4858 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), uno::Any(nValue
), true );
4861 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
) throw(css::uno::RuntimeException
, std::exception
)
4868 // take correct min and max
4874 // change min and max
4879 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, true );
4880 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, true );
4883 sal_Int32
UnoProgressBarControl::getValue() throw(css::uno::RuntimeException
, std::exception
)
4885 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4888 OUString
UnoProgressBarControl::getImplementationName()
4889 throw (css::uno::RuntimeException
, std::exception
)
4891 return OUString("stardiv.Toolkit.UnoProgressBarControl");
4894 css::uno::Sequence
<OUString
> UnoProgressBarControl::getSupportedServiceNames()
4895 throw (css::uno::RuntimeException
, std::exception
)
4897 auto s(UnoControlBase::getSupportedServiceNames());
4898 s
.realloc(s
.getLength() + 2);
4899 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBar";
4900 s
[s
.getLength() - 1] = "stardiv.vcl.control.ProgressBar";
4904 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4905 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
4906 css::uno::XComponentContext
*,
4907 css::uno::Sequence
<css::uno::Any
> const &)
4909 return cppu::acquire(new UnoProgressBarControl());
4913 // class UnoControlFixedLineModel
4915 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4916 :UnoControlModel( rxContext
)
4918 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4919 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4920 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4921 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4922 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4923 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4924 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4925 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4926 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4927 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4930 OUString
UnoControlFixedLineModel::getServiceName( ) throw(css::uno::RuntimeException
, std::exception
)
4932 return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel
);
4935 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4937 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4939 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedLine
) );
4941 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4944 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4946 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4949 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4950 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4955 // beans::XMultiPropertySet
4956 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException
, std::exception
)
4958 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4962 OUString
UnoControlFixedLineModel::getImplementationName()
4963 throw (css::uno::RuntimeException
, std::exception
)
4965 return OUString("stardiv.Toolkit.UnoControlFixedLineModel");
4968 css::uno::Sequence
<OUString
>
4969 UnoControlFixedLineModel::getSupportedServiceNames()
4970 throw (css::uno::RuntimeException
, std::exception
)
4972 auto s(UnoControlModel::getSupportedServiceNames());
4973 s
.realloc(s
.getLength() + 2);
4974 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLineModel";
4975 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedLine";
4979 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4980 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
4981 css::uno::XComponentContext
*context
,
4982 css::uno::Sequence
<css::uno::Any
> const &)
4984 return cppu::acquire(new UnoControlFixedLineModel(context
));
4988 // class UnoFixedLineControl
4990 UnoFixedLineControl::UnoFixedLineControl()
4993 maComponentInfos
.nWidth
= 100; // ??
4994 maComponentInfos
.nHeight
= 100; // ??
4997 OUString
UnoFixedLineControl::GetComponentServiceName()
4999 return OUString("FixedLine");
5002 sal_Bool
UnoFixedLineControl::isTransparent() throw(uno::RuntimeException
, std::exception
)
5007 OUString
UnoFixedLineControl::getImplementationName()
5008 throw (css::uno::RuntimeException
, std::exception
)
5010 return OUString("stardiv.Toolkit.UnoFixedLineControl");
5013 css::uno::Sequence
<OUString
> UnoFixedLineControl::getSupportedServiceNames()
5014 throw (css::uno::RuntimeException
, std::exception
)
5016 auto s(UnoControlBase::getSupportedServiceNames());
5017 s
.realloc(s
.getLength() + 2);
5018 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLine";
5019 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedLine";
5023 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
5024 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
5025 css::uno::XComponentContext
*,
5026 css::uno::Sequence
<css::uno::Any
> const &)
5028 return cppu::acquire(new UnoFixedLineControl());
5031 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */