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/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/awt/VisualEffect.hpp>
25 #include <com/sun/star/awt/LineEndFormat.hpp>
26 #include <com/sun/star/graphic/GraphicProvider.hpp>
27 #include <com/sun/star/graphic/XGraphicProvider.hpp>
28 #include <com/sun/star/util/Date.hpp>
29 #include <com/sun/star/awt/ImageScaleMode.hpp>
31 #include <o3tl/safeint.hxx>
32 #include <controls/formattedcontrol.hxx>
33 #include <toolkit/controls/unocontrols.hxx>
34 #include <helper/property.hxx>
35 #include <toolkit/helper/macros.hxx>
38 #include <awt/vclxwindows.hxx>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <cppuhelper/queryinterface.hxx>
41 #include <comphelper/processfactory.hxx>
42 #include <comphelper/propertyvalue.hxx>
43 #include <tools/debug.hxx>
44 #include <comphelper/diagnose_ex.hxx>
48 #include <helper/imagealign.hxx>
49 #include <helper/unopropertyarrayhelper.hxx>
53 using namespace css::awt
;
54 using namespace css::lang
;
55 using namespace css::uno
;
56 using ::com::sun::star::graphic::XGraphic
;
57 using ::com::sun::star::uno::Reference
;
58 using namespace ::toolkit
;
60 uno::Reference
< graphic::XGraphic
>
61 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const OUString
& _rURL
)
63 xOutGraphicObj
= nullptr;
64 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
67 css::uno::Reference
< css::graphic::XGraphic
>
68 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
)
70 uno::Reference
< graphic::XGraphic
> xGraphic
;
71 if ( _rURL
.isEmpty() )
76 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
77 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
78 xGraphic
= xProvider
->queryGraphic({ comphelper::makePropertyValue("URL", _rURL
) });
80 catch (const Exception
&)
82 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
89 UnoControlEditModel::UnoControlEditModel( const Reference
< XComponentContext
>& rxContext
)
90 :UnoControlModel( rxContext
)
92 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXEdit
>();
95 OUString
UnoControlEditModel::getServiceName( )
97 return "stardiv.vcl.controlmodel.Edit";
100 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
106 case BASEPROPERTY_LINE_END_FORMAT
:
107 aReturn
<<= sal_Int16(awt::LineEndFormat::LINE_FEED
); // LF
109 case BASEPROPERTY_DEFAULTCONTROL
:
110 aReturn
<<= OUString( "stardiv.vcl.control.Edit" );
113 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
119 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
121 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
125 // beans::XMultiPropertySet
126 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( )
128 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
132 OUString
UnoControlEditModel::getImplementationName()
134 return "stardiv.Toolkit.UnoControlEditModel";
137 css::uno::Sequence
<OUString
> UnoControlEditModel::getSupportedServiceNames()
139 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlEditModel", "stardiv.vcl.controlmodel.Edit" };
140 return comphelper::concatSequences(UnoControlModel::getSupportedServiceNames(), vals
);
143 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
144 stardiv_Toolkit_UnoControlEditModel_get_implementation(
145 css::uno::XComponentContext
*context
,
146 css::uno::Sequence
<css::uno::Any
> const &)
148 return cppu::acquire(new UnoControlEditModel(context
));
153 UnoEditControl::UnoEditControl()
154 :maTextListeners( *this )
156 ,mbSetTextInPeer( false )
157 ,mbSetMaxTextLenInPeer( false )
158 ,mbHasTextProperty( false )
160 maComponentInfos
.nWidth
= 100;
161 maComponentInfos
.nHeight
= 12;
164 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
)
166 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
167 if ( !aReturn
.hasValue() )
168 aReturn
= UnoEditControl_Base::queryInterface( rType
);
172 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
)
174 return UnoControlBase::queryInterface( rType
);
177 void SAL_CALL
UnoEditControl::acquire( ) noexcept
179 UnoControlBase::acquire();
182 void SAL_CALL
UnoEditControl::release( ) noexcept
184 UnoControlBase::release();
187 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
189 OUString
UnoEditControl::GetComponentServiceName() const
191 // by default, we want a simple edit field
192 OUString
sName( "Edit" );
194 // but maybe we are to display multi-line text?
195 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
197 if ( ( aVal
>>= b
) && b
)
198 sName
= "MultiLineEdit";
203 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
)
205 bool bReturn
= UnoControlBase::setModel( _rModel
);
206 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
210 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
213 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
215 // #96986# use setText(), or text listener will not be called.
216 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
217 if ( xTextComponent
.is() )
221 ImplCheckLocalize( sText
);
222 xTextComponent
->setText( sText
);
228 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
231 void UnoEditControl::dispose()
233 lang::EventObject
aEvt( *this );
234 maTextListeners
.disposeAndClear( aEvt
);
235 UnoControl::dispose();
238 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
240 UnoControl::createPeer( rxToolkit
, rParentPeer
);
242 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
245 xText
->addTextListener( this );
247 if ( mbSetMaxTextLenInPeer
)
248 xText
->setMaxTextLen( mnMaxTextLen
);
249 if ( mbSetTextInPeer
)
250 xText
->setText( maText
);
254 void UnoEditControl::textChanged(const awt::TextEvent
& e
)
256 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
258 if ( mbHasTextProperty
)
260 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(xText
->getText()), false );
264 maText
= xText
->getText();
267 if ( maTextListeners
.getLength() )
268 maTextListeners
.textChanged( e
);
271 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
)
273 // tdf#150974 some extensions pass null
276 SAL_WARN("toolkit", "null XTextListener");
279 maTextListeners
.addInterface( l
);
282 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
)
284 // tdf#150974 some extensions pass null
287 SAL_WARN("toolkit", "null XTextListener");
290 maTextListeners
.removeInterface( l
);
293 void UnoEditControl::setText( const OUString
& aText
)
295 if ( mbHasTextProperty
)
297 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(aText
), true );
302 mbSetTextInPeer
= true;
303 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
305 xText
->setText( maText
);
308 // Setting the property to the VCLXWindow doesn't call textChanged
309 if ( maTextListeners
.getLength() )
311 awt::TextEvent aEvent
;
312 aEvent
.Source
= *this;
313 maTextListeners
.textChanged( aEvent
);
319 void lcl_normalize( awt::Selection
& _rSel
)
321 if ( _rSel
.Min
> _rSel
.Max
)
322 ::std::swap( _rSel
.Min
, _rSel
.Max
);
326 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
)
328 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
329 awt::Selection
aSelection( rSel
);
330 lcl_normalize( aSelection
);
332 OUString aOldText
= getText();
333 if (aSelection
.Min
< 0 || aOldText
.getLength() < aSelection
.Max
)
335 throw lang::IllegalArgumentException();
338 // preserve the selection resp. cursor position
339 awt::Selection
aNewSelection( getSelection() );
340 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
341 // (not sure - looks uglier ...)
342 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
343 if ( aNewSelection
.Min
> aSelection
.Min
)
344 aNewSelection
.Min
-= nDeletedCharacters
;
345 if ( aNewSelection
.Max
> aSelection
.Max
)
346 aNewSelection
.Max
-= nDeletedCharacters
;
348 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
349 aNewSelection
.Min
= aNewSelection
.Max
;
352 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
355 setSelection( aNewSelection
);
358 OUString
UnoEditControl::getText()
360 OUString aText
= maText
;
362 if ( mbHasTextProperty
)
363 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
366 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
368 aText
= xText
->getText();
374 OUString
UnoEditControl::getSelectedText()
377 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
379 sSelected
= xText
->getSelectedText();
384 void UnoEditControl::setSelection( const awt::Selection
& aSelection
)
386 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
388 xText
->setSelection( aSelection
);
391 awt::Selection
UnoEditControl::getSelection()
394 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
396 aSel
= xText
->getSelection();
400 sal_Bool
UnoEditControl::isEditable()
402 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
405 void UnoEditControl::setEditable( sal_Bool bEditable
)
407 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), uno::Any(!bEditable
), true );
410 sal_Int16
UnoEditControl::getMaxTextLen()
412 sal_Int16 nMaxLen
= mnMaxTextLen
;
414 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
415 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
420 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
)
422 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
424 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), uno::Any(nLen
), true );
429 mbSetMaxTextLenInPeer
= true;
430 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
432 xText
->setMaxTextLen( mnMaxTextLen
);
436 awt::Size
UnoEditControl::getMinimumSize( )
438 return Impl_getMinimumSize();
441 awt::Size
UnoEditControl::getPreferredSize( )
443 return Impl_getPreferredSize();
446 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
)
448 return Impl_calcAdjustedSize( rNewSize
);
451 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
453 return Impl_getMinimumSize( nCols
, nLines
);
456 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
458 Impl_getColumnsAndLines( nCols
, nLines
);
461 OUString
UnoEditControl::getImplementationName( )
463 return "stardiv.Toolkit.UnoEditControl";
466 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames()
468 css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlEdit", "stardiv.vcl.control.Edit" };
469 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames( ), vals
);
472 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
473 stardiv_Toolkit_UnoEditControl_get_implementation(
474 css::uno::XComponentContext
*,
475 css::uno::Sequence
<css::uno::Any
> const &)
477 return cppu::acquire(new UnoEditControl());
482 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
483 :UnoControlModel( rxContext
)
485 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
486 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
487 ImplRegisterProperty( BASEPROPERTY_BORDER
);
488 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
489 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
490 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
491 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
492 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
493 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
494 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
495 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
496 ImplRegisterProperty( BASEPROPERTY_READONLY
);
497 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
498 ImplRegisterProperty( BASEPROPERTY_TEXT
);
499 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
500 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
501 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
502 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
505 OUString
UnoControlFileControlModel::getServiceName()
507 return "stardiv.vcl.controlmodel.FileControl";
510 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
512 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
514 return uno::Any( OUString( "stardiv.vcl.control.FileControl" ) );
516 return UnoControlModel::ImplGetDefaultValue( nPropId
);
519 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
521 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
525 // beans::XMultiPropertySet
526 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( )
528 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
532 OUString
UnoControlFileControlModel::getImplementationName()
534 return "stardiv.Toolkit.UnoControlFileControlModel";
537 css::uno::Sequence
<OUString
>
538 UnoControlFileControlModel::getSupportedServiceNames()
540 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFileControlModel", "stardiv.vcl.controlmodel.FileControl" };
541 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
544 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
545 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
546 css::uno::XComponentContext
*context
,
547 css::uno::Sequence
<css::uno::Any
> const &)
549 return cppu::acquire(new UnoControlFileControlModel(context
));
554 UnoFileControl::UnoFileControl()
558 OUString
UnoFileControl::GetComponentServiceName() const
560 return "filecontrol";
563 OUString
UnoFileControl::getImplementationName()
565 return "stardiv.Toolkit.UnoFileControl";
568 css::uno::Sequence
<OUString
> UnoFileControl::getSupportedServiceNames()
570 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFileControl", "stardiv.vcl.control.FileControl" };
571 return comphelper::concatSequences( UnoEditControl::getSupportedServiceNames(), vals
);
574 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
575 stardiv_Toolkit_UnoFileControl_get_implementation(
576 css::uno::XComponentContext
*,
577 css::uno::Sequence
<css::uno::Any
> const &)
579 return cppu::acquire(new UnoFileControl());
584 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
586 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
587 return uno::Any( uno::Reference
< graphic::XGraphic
>() );
589 return UnoControlModel::ImplGetDefaultValue( nPropId
);
592 void GraphicControlModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const css::uno::Any
& rValue
)
594 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
596 // - ImageAlign and ImagePosition need to correspond to each other
597 // - Graphic and ImageURL need to correspond to each other
602 case BASEPROPERTY_IMAGEURL
:
603 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
605 mbAdjustingGraphic
= true;
607 OSL_VERIFY( rValue
>>= sImageURL
);
608 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_GRAPHIC
, uno::Any( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
609 mbAdjustingGraphic
= false;
613 case BASEPROPERTY_GRAPHIC
:
614 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
616 mbAdjustingGraphic
= true;
617 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEURL
, uno::Any( OUString() ) );
618 mbAdjustingGraphic
= false;
622 case BASEPROPERTY_IMAGEALIGN
:
623 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
625 mbAdjustingImagePosition
= true;
626 sal_Int16 nUNOValue
= 0;
627 OSL_VERIFY( rValue
>>= nUNOValue
);
628 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEPOSITION
, uno::Any( getExtendedImagePosition( nUNOValue
) ) );
629 mbAdjustingImagePosition
= false;
632 case BASEPROPERTY_IMAGEPOSITION
:
633 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
635 mbAdjustingImagePosition
= true;
636 sal_Int16 nUNOValue
= 0;
637 OSL_VERIFY( rValue
>>= nUNOValue
);
638 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEALIGN
, uno::Any( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
639 mbAdjustingImagePosition
= false;
644 catch( const css::uno::Exception
& )
646 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
647 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
648 mbAdjustingImagePosition
= false;
654 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
655 :GraphicControlModel( rxContext
)
657 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXButton
>();
659 osl_atomic_increment( &m_refCount
);
661 std::unique_lock
aGuard(m_aMutex
);
662 setFastPropertyValue_NoBroadcast( aGuard
, BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
663 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
664 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
666 osl_atomic_decrement( &m_refCount
);
669 OUString
UnoControlButtonModel::getServiceName()
671 return "stardiv.vcl.controlmodel.Button";
674 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
678 case BASEPROPERTY_DEFAULTCONTROL
:
679 return uno::Any( OUString( "stardiv.vcl.control.Button" ) );
680 case BASEPROPERTY_TOGGLE
:
681 return uno::Any( false );
682 case BASEPROPERTY_ALIGN
:
683 return uno::Any( sal_Int16(PROPERTY_ALIGN_CENTER
) );
684 case BASEPROPERTY_FOCUSONCLICK
:
685 return uno::Any( true );
688 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
691 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
693 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
697 // beans::XMultiPropertySet
698 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( )
700 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
704 OUString
UnoControlButtonModel::getImplementationName()
706 return "stardiv.Toolkit.UnoControlButtonModel";
709 css::uno::Sequence
<OUString
> UnoControlButtonModel::getSupportedServiceNames()
711 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlButtonModel", "stardiv.vcl.controlmodel.Button" };
712 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
715 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
716 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
717 css::uno::XComponentContext
*context
,
718 css::uno::Sequence
<css::uno::Any
> const &)
720 return cppu::acquire(new UnoControlButtonModel(context
));
725 UnoButtonControl::UnoButtonControl()
726 :maActionListeners( *this )
727 ,maItemListeners( *this )
729 maComponentInfos
.nWidth
= 50;
730 maComponentInfos
.nHeight
= 14;
733 OUString
UnoButtonControl::GetComponentServiceName() const
735 OUString
aName( "pushbutton" );
736 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
737 sal_Int16 n
= sal_Int16();
738 if ( ( aVal
>>= n
) && n
)
740 // Use PushButtonType later when available...
743 case 1 /*PushButtonType::OK*/: aName
= "okbutton";
745 case 2 /*PushButtonType::CANCEL*/: aName
= "cancelbutton";
747 case 3 /*PushButtonType::HELP*/: aName
= "helpbutton";
751 OSL_FAIL( "Unknown Button Type!" );
758 void UnoButtonControl::dispose()
760 lang::EventObject aEvt
;
761 aEvt
.Source
= getXWeak();
762 maActionListeners
.disposeAndClear( aEvt
);
763 maItemListeners
.disposeAndClear( aEvt
);
764 UnoControlBase::dispose();
767 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
769 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
771 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
772 xButton
->setActionCommand( maActionCommand
);
773 if ( maActionListeners
.getLength() )
774 xButton
->addActionListener( &maActionListeners
);
776 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
777 if ( xPushButton
.is() )
778 xPushButton
->addItemListener( this );
781 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
783 // tdf#150974 some extensions pass null
786 SAL_WARN("toolkit", "null XActionListener");
790 maActionListeners
.addInterface( l
);
791 if( getPeer().is() && maActionListeners
.getLength() == 1 )
793 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
794 xButton
->addActionListener( &maActionListeners
);
798 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
800 // tdf#150974 some extensions pass null
803 SAL_WARN("toolkit", "null XActionListener");
807 if( getPeer().is() && maActionListeners
.getLength() == 1 )
809 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
810 xButton
->removeActionListener( &maActionListeners
);
812 maActionListeners
.removeInterface( l
);
815 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
817 maItemListeners
.addInterface( l
);
820 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
822 maItemListeners
.removeInterface( l
);
825 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
)
827 UnoControlBase::disposing( Source
);
830 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
833 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
836 ItemEvent
aEvent( rEvent
);
837 aEvent
.Source
= *this;
838 maItemListeners
.itemStateChanged( aEvent
);
841 void UnoButtonControl::setLabel( const OUString
& rLabel
)
843 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
846 void UnoButtonControl::setActionCommand( const OUString
& rCommand
)
848 maActionCommand
= rCommand
;
849 if ( getPeer().is() )
851 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
852 xButton
->setActionCommand( rCommand
);
856 awt::Size
UnoButtonControl::getMinimumSize( )
858 return Impl_getMinimumSize();
861 awt::Size
UnoButtonControl::getPreferredSize( )
863 return Impl_getPreferredSize();
866 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
868 return Impl_calcAdjustedSize( rNewSize
);
871 OUString
UnoButtonControl::getImplementationName()
873 return "stardiv.Toolkit.UnoButtonControl";
876 css::uno::Sequence
<OUString
> UnoButtonControl::getSupportedServiceNames()
878 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlButton", "stardiv.vcl.control.Button" };
879 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
882 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
883 stardiv_Toolkit_UnoButtonControl_get_implementation(
884 css::uno::XComponentContext
*,
885 css::uno::Sequence
<css::uno::Any
> const &)
887 return cppu::acquire(new UnoButtonControl());
892 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
893 :GraphicControlModel( rxContext
)
894 ,mbAdjustingImageScaleMode( false )
896 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXImageControl
>();
899 OUString
UnoControlImageControlModel::getServiceName()
901 return "stardiv.vcl.controlmodel.ImageControl";
904 OUString
UnoControlImageControlModel::getImplementationName()
906 return "stardiv.Toolkit.UnoControlImageControlModel";
909 css::uno::Sequence
<OUString
>
910 UnoControlImageControlModel::getSupportedServiceNames()
912 const css::uno::Sequence
<OUString
> vals
{
913 "com.sun.star.awt.UnoControlImageButtonModel",
914 "com.sun.star.awt.UnoControlImageControlModel",
915 "stardiv.vcl.controlmodel.ImageButton",
916 "stardiv.vcl.controlmodel.ImageControl"
918 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
921 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
923 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
924 return uno::Any( OUString( "stardiv.vcl.control.ImageControl" ) );
926 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
927 return Any( awt::ImageScaleMode::ANISOTROPIC
);
929 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
932 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
934 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
938 // beans::XMultiPropertySet
939 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( )
941 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
945 void UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
947 GraphicControlModel::setFastPropertyValue_NoBroadcast( rGuard
, _nHandle
, _rValue
);
949 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
954 case BASEPROPERTY_IMAGE_SCALE_MODE
:
955 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
957 mbAdjustingImageScaleMode
= true;
958 sal_Int16
nScaleMode( awt::ImageScaleMode::ANISOTROPIC
);
959 OSL_VERIFY( _rValue
>>= nScaleMode
);
960 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_SCALEIMAGE
, uno::Any( nScaleMode
!= awt::ImageScaleMode::NONE
) );
961 mbAdjustingImageScaleMode
= false;
964 case BASEPROPERTY_SCALEIMAGE
:
965 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
967 mbAdjustingImageScaleMode
= true;
969 OSL_VERIFY( _rValue
>>= bScale
);
970 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGE_SCALE_MODE
, uno::Any( bScale
? awt::ImageScaleMode::ANISOTROPIC
: awt::ImageScaleMode::NONE
) );
971 mbAdjustingImageScaleMode
= false;
976 catch( const Exception
& )
978 mbAdjustingImageScaleMode
= false;
983 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
984 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
985 css::uno::XComponentContext
*context
,
986 css::uno::Sequence
<css::uno::Any
> const &)
988 return cppu::acquire(new UnoControlImageControlModel(context
));
993 UnoImageControlControl::UnoImageControlControl()
994 :maActionListeners( *this )
996 // TODO: Where should I look for defaults?
997 maComponentInfos
.nWidth
= 100;
998 maComponentInfos
.nHeight
= 100;
1001 OUString
UnoImageControlControl::GetComponentServiceName() const
1003 return "fixedimage";
1006 void UnoImageControlControl::dispose()
1008 lang::EventObject aEvt
;
1009 aEvt
.Source
= getXWeak();
1010 maActionListeners
.disposeAndClear( aEvt
);
1011 UnoControl::dispose();
1014 sal_Bool
UnoImageControlControl::isTransparent()
1019 awt::Size
UnoImageControlControl::getMinimumSize( )
1021 return Impl_getMinimumSize();
1024 awt::Size
UnoImageControlControl::getPreferredSize( )
1026 return Impl_getPreferredSize();
1029 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1031 return Impl_calcAdjustedSize( rNewSize
);
1034 OUString
UnoImageControlControl::getImplementationName()
1036 return "stardiv.Toolkit.UnoImageControlControl";
1039 css::uno::Sequence
<OUString
> UnoImageControlControl::getSupportedServiceNames()
1041 const css::uno::Sequence
<OUString
> vals
{
1042 "com.sun.star.awt.UnoControlImageButton",
1043 "com.sun.star.awt.UnoControlImageControl",
1044 "stardiv.vcl.control.ImageButton",
1045 "stardiv.vcl.control.ImageControl"
1047 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1050 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1051 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1052 css::uno::XComponentContext
*,
1053 css::uno::Sequence
<css::uno::Any
> const &)
1055 return cppu::acquire(new UnoImageControlControl());
1060 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
1061 :GraphicControlModel( rxContext
)
1063 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXRadioButton
>();
1066 OUString
UnoControlRadioButtonModel::getServiceName()
1068 return "stardiv.vcl.controlmodel.RadioButton";
1071 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1075 case BASEPROPERTY_DEFAULTCONTROL
:
1076 return uno::Any( OUString( "stardiv.vcl.control.RadioButton" ) );
1078 case BASEPROPERTY_VISUALEFFECT
:
1079 return uno::Any( sal_Int16(awt::VisualEffect::LOOK3D
) );
1082 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1085 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
1087 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1091 // beans::XMultiPropertySet
1092 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( )
1094 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1098 OUString
UnoControlRadioButtonModel::getImplementationName()
1100 return "stardiv.Toolkit.UnoControlRadioButtonModel";
1103 css::uno::Sequence
<OUString
>
1104 UnoControlRadioButtonModel::getSupportedServiceNames()
1106 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlRadioButtonModel", "stardiv.vcl.controlmodel.RadioButton" };
1107 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
1110 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1111 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1112 css::uno::XComponentContext
*context
,
1113 css::uno::Sequence
<css::uno::Any
> const &)
1115 return cppu::acquire(new UnoControlRadioButtonModel(context
));
1120 UnoRadioButtonControl::UnoRadioButtonControl()
1121 :maItemListeners( *this )
1122 ,maActionListeners( *this )
1124 maComponentInfos
.nWidth
= 100;
1125 maComponentInfos
.nHeight
= 12;
1128 OUString
UnoRadioButtonControl::GetComponentServiceName() const
1130 return "radiobutton";
1133 void UnoRadioButtonControl::dispose()
1135 lang::EventObject aEvt
;
1136 aEvt
.Source
= getXWeak();
1137 maItemListeners
.disposeAndClear( aEvt
);
1138 UnoControlBase::dispose();
1142 sal_Bool
UnoRadioButtonControl::isTransparent()
1147 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1149 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1151 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1152 xRadioButton
->addItemListener( this );
1154 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1155 xButton
->setActionCommand( maActionCommand
);
1156 if ( maActionListeners
.getLength() )
1157 xButton
->addActionListener( &maActionListeners
);
1159 // as default, set the "AutoToggle" to true
1160 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1161 // have it enabled by default because of 85071)
1162 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1163 if ( xVclWindowPeer
.is() )
1164 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), css::uno::Any(true) );
1167 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1169 maItemListeners
.addInterface( l
);
1172 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1174 maItemListeners
.removeInterface( l
);
1177 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1179 maActionListeners
.addInterface( l
);
1180 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1182 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1183 xButton
->addActionListener( &maActionListeners
);
1187 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1189 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1191 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1192 xButton
->removeActionListener( &maActionListeners
);
1194 maActionListeners
.removeInterface( l
);
1197 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
)
1199 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1202 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
)
1204 maActionCommand
= rCommand
;
1205 if ( getPeer().is() )
1207 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1208 xButton
->setActionCommand( rCommand
);
1212 void UnoRadioButtonControl::setState( sal_Bool bOn
)
1214 sal_Int16 nState
= bOn
? 1 : 0;
1215 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(nState
), true );
1218 sal_Bool
UnoRadioButtonControl::getState()
1220 sal_Int16 nState
= 0;
1221 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1226 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1228 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1231 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1232 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1234 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1235 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1236 // isn't the case anymore: For instance, this method here gets called for the radio button
1237 // which is being implicitly _de_selected, too. This is pretty bad for compatibility.
1238 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1239 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1240 // all which matters here.
1242 if ( 1 == rEvent
.Selected
)
1244 if ( maItemListeners
.getLength() )
1245 maItemListeners
.itemStateChanged( rEvent
);
1247 // note that speaking strictly, this is wrong: When in 1.0.x, the user would have de-selected
1248 // a radio button _without_ selecting another one, this would have caused a notification.
1249 // With the change done here, this today won't cause a notification anymore.
1251 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1252 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1253 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1254 // to be inconsistent with.
1257 awt::Size
UnoRadioButtonControl::getMinimumSize( )
1259 return Impl_getMinimumSize();
1262 awt::Size
UnoRadioButtonControl::getPreferredSize( )
1264 return Impl_getPreferredSize();
1267 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1269 return Impl_calcAdjustedSize( rNewSize
);
1272 OUString
UnoRadioButtonControl::getImplementationName()
1274 return "stardiv.Toolkit.UnoRadioButtonControl";
1277 css::uno::Sequence
<OUString
> UnoRadioButtonControl::getSupportedServiceNames()
1279 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlRadioButton", "stardiv.vcl.control.RadioButton" };
1280 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1283 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1284 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1285 css::uno::XComponentContext
*,
1286 css::uno::Sequence
<css::uno::Any
> const &)
1288 return cppu::acquire(new UnoRadioButtonControl());
1293 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1294 :GraphicControlModel( rxContext
)
1296 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXCheckBox
>();
1299 OUString
UnoControlCheckBoxModel::getServiceName()
1301 return "stardiv.vcl.controlmodel.CheckBox";
1304 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1308 case BASEPROPERTY_DEFAULTCONTROL
:
1309 return uno::Any( OUString( "stardiv.vcl.control.CheckBox" ) );
1311 case BASEPROPERTY_VISUALEFFECT
:
1312 return uno::Any( sal_Int16(awt::VisualEffect::LOOK3D
) );
1315 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1318 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1320 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1324 // beans::XMultiPropertySet
1325 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( )
1327 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1331 OUString
UnoControlCheckBoxModel::getImplementationName()
1333 return "stardiv.Toolkit.UnoControlCheckBoxModel";
1336 css::uno::Sequence
<OUString
> UnoControlCheckBoxModel::getSupportedServiceNames()
1338 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlCheckBoxModel", "stardiv.vcl.controlmodel.CheckBox" };
1339 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
1342 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1343 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1344 css::uno::XComponentContext
*context
,
1345 css::uno::Sequence
<css::uno::Any
> const &)
1347 return cppu::acquire(new UnoControlCheckBoxModel(context
));
1352 UnoCheckBoxControl::UnoCheckBoxControl()
1353 :maItemListeners( *this ), maActionListeners( *this )
1355 maComponentInfos
.nWidth
= 100;
1356 maComponentInfos
.nHeight
= 12;
1359 OUString
UnoCheckBoxControl::GetComponentServiceName() const
1364 void UnoCheckBoxControl::dispose()
1366 lang::EventObject aEvt
;
1367 aEvt
.Source
= getXWeak();
1368 maItemListeners
.disposeAndClear( aEvt
);
1369 UnoControlBase::dispose();
1372 sal_Bool
UnoCheckBoxControl::isTransparent()
1377 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1379 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1381 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1382 xCheckBox
->addItemListener( this );
1384 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1385 xButton
->setActionCommand( maActionCommand
);
1386 if ( maActionListeners
.getLength() )
1387 xButton
->addActionListener( &maActionListeners
);
1390 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1392 maItemListeners
.addInterface( l
);
1395 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1397 maItemListeners
.removeInterface( l
);
1400 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1402 maActionListeners
.addInterface( l
);
1403 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1405 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1406 xButton
->addActionListener( &maActionListeners
);
1410 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1412 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1414 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1415 xButton
->removeActionListener( &maActionListeners
);
1417 maActionListeners
.removeInterface( l
);
1420 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
)
1422 maActionCommand
= rCommand
;
1423 if ( getPeer().is() )
1425 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1426 xButton
->setActionCommand( rCommand
);
1431 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
)
1433 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1436 void UnoCheckBoxControl::setState( sal_Int16 n
)
1438 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(n
), true );
1441 sal_Int16
UnoCheckBoxControl::getState()
1443 sal_Int16 nState
= 0;
1444 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1449 void UnoCheckBoxControl::enableTriState( sal_Bool b
)
1451 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), uno::Any(b
), true );
1454 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1456 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1458 if ( maItemListeners
.getLength() )
1459 maItemListeners
.itemStateChanged( rEvent
);
1462 awt::Size
UnoCheckBoxControl::getMinimumSize( )
1464 return Impl_getMinimumSize();
1467 awt::Size
UnoCheckBoxControl::getPreferredSize( )
1469 return Impl_getPreferredSize();
1472 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1474 return Impl_calcAdjustedSize( rNewSize
);
1477 OUString
UnoCheckBoxControl::getImplementationName()
1479 return "stardiv.Toolkit.UnoCheckBoxControl";
1482 css::uno::Sequence
<OUString
> UnoCheckBoxControl::getSupportedServiceNames()
1484 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlCheckBox", "stardiv.vcl.control.CheckBox" };
1485 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1488 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1489 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1490 css::uno::XComponentContext
*,
1491 css::uno::Sequence
<css::uno::Any
> const &)
1493 return cppu::acquire(new UnoCheckBoxControl());
1498 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1499 :UnoControlModel( rxContext
)
1501 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXFixedHyperlink
>();
1504 OUString
UnoControlFixedHyperlinkModel::getServiceName()
1506 return "com.sun.star.awt.UnoControlFixedHyperlinkModel";
1509 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1511 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1513 return uno::Any( OUString( "com.sun.star.awt.UnoControlFixedHyperlink" ) );
1515 else if ( nPropId
== BASEPROPERTY_BORDER
)
1517 return uno::Any(sal_Int16(0));
1519 else if ( nPropId
== BASEPROPERTY_URL
)
1521 return uno::Any( OUString() );
1524 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1527 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1529 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1533 // beans::XMultiPropertySet
1534 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( )
1536 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1540 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1541 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1542 css::uno::XComponentContext
*context
,
1543 css::uno::Sequence
<css::uno::Any
> const &)
1545 return cppu::acquire(new UnoControlFixedHyperlinkModel(context
));
1550 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1551 :maActionListeners( *this )
1553 maComponentInfos
.nWidth
= 100;
1554 maComponentInfos
.nHeight
= 12;
1557 OUString
UnoFixedHyperlinkControl::GetComponentServiceName() const
1559 return "fixedhyperlink";
1563 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
)
1565 uno::Any aRet
= ::cppu::queryInterface( rType
,
1566 static_cast< awt::XFixedHyperlink
* >(this),
1567 static_cast< awt::XLayoutConstrains
* >(this) );
1568 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1571 IMPL_IMPLEMENTATION_ID( UnoFixedHyperlinkControl
)
1573 // lang::XTypeProvider
1574 css::uno::Sequence
< css::uno::Type
> UnoFixedHyperlinkControl::getTypes()
1576 static const ::cppu::OTypeCollection
aTypeList(
1577 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
1578 cppu::UnoType
<awt::XFixedHyperlink
>::get(),
1579 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1580 UnoControlBase::getTypes()
1582 return aTypeList
.getTypes();
1585 sal_Bool
UnoFixedHyperlinkControl::isTransparent()
1590 void UnoFixedHyperlinkControl::setText( const OUString
& Text
)
1592 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1595 OUString
UnoFixedHyperlinkControl::getText()
1597 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1600 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
)
1602 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), uno::Any(URL
), true );
1605 OUString
UnoFixedHyperlinkControl::getURL( )
1607 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1610 void UnoFixedHyperlinkControl::setAlignment( sal_Int16 nAlign
)
1612 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(nAlign
), true );
1615 sal_Int16
UnoFixedHyperlinkControl::getAlignment()
1617 sal_Int16 nAlign
= 0;
1620 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1626 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( )
1628 return Impl_getMinimumSize();
1631 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( )
1633 return Impl_getPreferredSize();
1636 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1638 return Impl_calcAdjustedSize( rNewSize
);
1641 void UnoFixedHyperlinkControl::dispose()
1643 lang::EventObject aEvt
;
1644 aEvt
.Source
= getXWeak();
1645 maActionListeners
.disposeAndClear( aEvt
);
1646 UnoControlBase::dispose();
1649 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1651 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1653 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1654 if ( maActionListeners
.getLength() )
1655 xFixedHyperlink
->addActionListener( &maActionListeners
);
1658 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1660 maActionListeners
.addInterface( l
);
1661 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1663 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1664 xFixedHyperlink
->addActionListener( &maActionListeners
);
1668 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1670 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1672 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1673 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1675 maActionListeners
.removeInterface( l
);
1678 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1679 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1680 css::uno::XComponentContext
*,
1681 css::uno::Sequence
<css::uno::Any
> const &)
1683 return cppu::acquire(new UnoFixedHyperlinkControl());
1688 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1689 :UnoControlModel( rxContext
)
1691 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXFixedText
>();
1694 OUString
UnoControlFixedTextModel::getServiceName()
1696 return "stardiv.vcl.controlmodel.FixedText";
1699 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1701 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1703 return uno::Any( OUString( "stardiv.vcl.control.FixedText" ) );
1705 else if ( nPropId
== BASEPROPERTY_BORDER
)
1707 return uno::Any(sal_Int16(0));
1710 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1713 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1715 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1719 // beans::XMultiPropertySet
1720 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( )
1722 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1726 OUString
UnoControlFixedTextModel::getImplementationName()
1728 return "stardiv.Toolkit.UnoControlFixedTextModel";
1731 css::uno::Sequence
<OUString
>
1732 UnoControlFixedTextModel::getSupportedServiceNames()
1734 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFixedTextModel", "stardiv.vcl.controlmodel.FixedText" };
1735 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
1738 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1739 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1740 css::uno::XComponentContext
*context
,
1741 css::uno::Sequence
<css::uno::Any
> const &)
1743 return cppu::acquire(new UnoControlFixedTextModel(context
));
1748 UnoFixedTextControl::UnoFixedTextControl()
1750 maComponentInfos
.nWidth
= 100;
1751 maComponentInfos
.nHeight
= 12;
1754 OUString
UnoFixedTextControl::GetComponentServiceName() const
1760 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
)
1762 uno::Any aRet
= ::cppu::queryInterface( rType
,
1763 static_cast< awt::XFixedText
* >(this),
1764 static_cast< awt::XLayoutConstrains
* >(this) );
1765 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1768 IMPL_IMPLEMENTATION_ID( UnoFixedTextControl
)
1770 // lang::XTypeProvider
1771 css::uno::Sequence
< css::uno::Type
> UnoFixedTextControl::getTypes()
1773 static const ::cppu::OTypeCollection
aTypeList(
1774 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
1775 cppu::UnoType
<awt::XFixedText
>::get(),
1776 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1777 UnoControlBase::getTypes()
1779 return aTypeList
.getTypes();
1782 sal_Bool
UnoFixedTextControl::isTransparent()
1787 void UnoFixedTextControl::setText( const OUString
& Text
)
1789 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1792 OUString
UnoFixedTextControl::getText()
1794 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1797 void UnoFixedTextControl::setAlignment( sal_Int16 nAlign
)
1799 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(nAlign
), true );
1802 sal_Int16
UnoFixedTextControl::getAlignment()
1804 sal_Int16 nAlign
= 0;
1807 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1813 awt::Size
UnoFixedTextControl::getMinimumSize( )
1815 return Impl_getMinimumSize();
1818 awt::Size
UnoFixedTextControl::getPreferredSize( )
1820 return Impl_getPreferredSize();
1823 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1825 return Impl_calcAdjustedSize( rNewSize
);
1828 OUString
UnoFixedTextControl::getImplementationName()
1830 return "stardiv.Toolkit.UnoFixedTextControl";
1833 css::uno::Sequence
<OUString
> UnoFixedTextControl::getSupportedServiceNames()
1835 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFixedText", "stardiv.vcl.control.FixedText" };
1836 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1839 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1840 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1841 css::uno::XComponentContext
*,
1842 css::uno::Sequence
<css::uno::Any
> const &)
1844 return cppu::acquire(new UnoFixedTextControl());
1849 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1850 :UnoControlModel( rxContext
)
1852 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1853 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1854 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1855 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1856 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1857 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1858 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1859 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1860 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1861 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1864 OUString
UnoControlGroupBoxModel::getServiceName()
1866 return "stardiv.vcl.controlmodel.GroupBox";
1869 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1871 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1873 return uno::Any(OUString( "stardiv.vcl.control.GroupBox" ) );
1875 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1878 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1880 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1884 // beans::XMultiPropertySet
1885 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( )
1887 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1891 OUString
UnoControlGroupBoxModel::getImplementationName()
1893 return "stardiv.Toolkit.UnoControlGroupBoxModel";
1896 css::uno::Sequence
<OUString
> UnoControlGroupBoxModel::getSupportedServiceNames()
1898 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlGroupBoxModel", "stardiv.vcl.controlmodel.GroupBox" };
1899 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
1902 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1903 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
1904 css::uno::XComponentContext
*context
,
1905 css::uno::Sequence
<css::uno::Any
> const &)
1907 return cppu::acquire(new UnoControlGroupBoxModel(context
));
1912 UnoGroupBoxControl::UnoGroupBoxControl()
1914 maComponentInfos
.nWidth
= 100;
1915 maComponentInfos
.nHeight
= 100;
1918 OUString
UnoGroupBoxControl::GetComponentServiceName() const
1923 sal_Bool
UnoGroupBoxControl::isTransparent()
1928 OUString
UnoGroupBoxControl::getImplementationName()
1930 return "stardiv.Toolkit.UnoGroupBoxControl";
1933 css::uno::Sequence
<OUString
> UnoGroupBoxControl::getSupportedServiceNames()
1935 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlGroupBox", "stardiv.vcl.control.GroupBox" };
1936 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1939 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1940 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
1941 css::uno::XComponentContext
*,
1942 css::uno::Sequence
<css::uno::Any
> const &)
1944 return cppu::acquire(new UnoGroupBoxControl());
1948 // = UnoControlListBoxModel_Data
1955 OUString ItemImageURL
;
1962 explicit ListItem( OUString i_ItemText
)
1963 :ItemText(std::move( i_ItemText
))
1970 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
1974 struct StripItemData
1976 UnoListItem
operator()( const ListItem
& i_rItem
)
1978 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
1984 struct UnoControlListBoxModel_Data
1986 explicit UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
1987 :m_bSettingLegacyProperty( false )
1988 ,m_rAntiImpl( i_rAntiImpl
)
1992 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
1994 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
1996 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) >= m_aListItems
.size() ) )
1997 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
1998 return m_aListItems
[ i_nIndex
];
2001 ListItem
& getItem( const sal_Int32 i_nIndex
)
2003 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
2006 ListItem
& insertItem( const sal_Int32 i_nIndex
)
2008 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) > m_aListItems
.size() ) )
2009 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2010 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
2013 Sequence
< UnoListItem
> getAllItems() const
2015 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
2016 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
2020 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
2022 m_aListItems
= i_copySource
.m_aListItems
;
2025 void setAllItems( ::std::vector
< ListItem
>&& i_rItems
)
2027 m_aListItems
= std::move(i_rItems
);
2030 void removeItem( const sal_Int32 i_nIndex
)
2032 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) >= m_aListItems
.size() ) )
2033 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2034 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
2037 void removeAllItems()
2039 std::vector
<ListItem
>().swap(m_aListItems
);
2043 bool m_bSettingLegacyProperty
;
2046 UnoControlListBoxModel
& m_rAntiImpl
;
2047 ::std::vector
< ListItem
> m_aListItems
;
2051 // = UnoControlListBoxModel
2054 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
2055 :UnoControlListBoxModel_Base( rxContext
)
2056 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2058 if ( i_mode
== ConstructDefault
)
2060 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXListBox
>();
2064 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
2065 :UnoControlListBoxModel_Base( i_rSource
)
2066 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2068 m_xData
->copyItems( *i_rSource
.m_xData
);
2070 UnoControlListBoxModel::~UnoControlListBoxModel()
2074 OUString
UnoControlListBoxModel::getImplementationName()
2076 return "stardiv.Toolkit.UnoControlListBoxModel";
2079 css::uno::Sequence
<OUString
> UnoControlListBoxModel::getSupportedServiceNames()
2081 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlListBoxModel", "stardiv.vcl.controlmodel.ListBox" };
2082 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
2085 OUString
UnoControlListBoxModel::getServiceName()
2087 return "stardiv.vcl.controlmodel.ListBox";
2091 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2093 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2095 return uno::Any( OUString( "stardiv.vcl.control.ListBox" ) );
2097 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2101 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
2103 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
2108 // beans::XMultiPropertySet
2109 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( )
2111 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2118 struct CreateListItem
2120 ListItem
operator()( const OUString
& i_rItemText
)
2122 return ListItem( i_rItemText
);
2128 void UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const uno::Any
& rValue
)
2130 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
2132 if ( nHandle
!= BASEPROPERTY_STRINGITEMLIST
)
2136 uno::Sequence
<sal_Int16
> aSeq
;
2137 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_SELECTEDITEMS
, uno::Any(aSeq
) );
2139 if ( m_xData
->m_bSettingLegacyProperty
)
2142 // synchronize the legacy StringItemList property with our list items
2143 Sequence
< OUString
> aStringItemList
;
2145 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2146 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2148 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2150 std::cbegin(aStringItemList
),
2151 std::cend(aStringItemList
),
2155 m_xData
->setAllItems( std::move(aItems
) );
2157 // since an XItemListListener does not have a "all items modified" or some such method,
2158 // we simulate this by notifying removal of all items, followed by insertion of all new
2160 lang::EventObject aEvent
;
2161 aEvent
.Source
= *this;
2162 m_aItemListListeners
.notifyEach( rGuard
, &XItemListListener::itemListChanged
, aEvent
);
2163 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2164 // which is wrong for the above notifications ...
2168 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
2169 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const
2171 // dependencies we know:
2172 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2173 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
2174 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_TYPEDITEMLIST
2175 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_TYPEDITEMLIST
);
2177 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
2181 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount()
2183 std::unique_lock
aGuard( m_aMutex
);
2184 return m_xData
->getItemCount();
2188 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2190 std::unique_lock
aGuard( m_aMutex
);
2191 // SYNCHRONIZED ----->
2192 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2193 rItem
.ItemText
= i_rItemText
;
2194 rItem
.ItemImageURL
= i_rItemImageURL
;
2196 impl_handleInsert( aGuard
, i_nPosition
, i_rItemText
, i_rItemImageURL
);
2197 // <----- SYNCHRONIZED
2201 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2203 std::unique_lock
aGuard( m_aMutex
);
2204 // SYNCHRONIZED ----->
2205 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2206 rItem
.ItemText
= i_rItemText
;
2208 impl_handleInsert( aGuard
, i_nPosition
, i_rItemText
, ::std::optional
< OUString
>() );
2209 // <----- SYNCHRONIZED
2213 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2215 std::unique_lock
aGuard( m_aMutex
);
2216 // SYNCHRONIZED ----->
2217 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2218 rItem
.ItemImageURL
= i_rItemImageURL
;
2220 impl_handleInsert( aGuard
, i_nPosition
, ::std::optional
< OUString
>(), i_rItemImageURL
);
2221 // <----- SYNCHRONIZED
2225 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
)
2227 std::unique_lock
aGuard( m_aMutex
);
2228 // SYNCHRONIZED ----->
2229 m_xData
->removeItem( i_nPosition
);
2231 impl_handleRemove( i_nPosition
, aGuard
);
2232 // <----- SYNCHRONIZED
2236 void SAL_CALL
UnoControlListBoxModel::removeAllItems( )
2238 std::unique_lock
aGuard( m_aMutex
);
2239 // SYNCHRONIZED ----->
2240 m_xData
->removeAllItems();
2242 impl_handleRemove( -1, aGuard
);
2243 // <----- SYNCHRONIZED
2247 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2249 std::unique_lock
aGuard( m_aMutex
);
2250 // SYNCHRONIZED ----->
2251 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2252 rItem
.ItemText
= i_rItemText
;
2254 impl_handleModify( i_nPosition
, i_rItemText
, ::std::optional
< OUString
>(), aGuard
);
2255 // <----- SYNCHRONIZED
2259 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2261 std::unique_lock
aGuard( m_aMutex
);
2262 // SYNCHRONIZED ----->
2263 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2264 rItem
.ItemImageURL
= i_rItemImageURL
;
2266 impl_handleModify( i_nPosition
, ::std::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2267 // <----- SYNCHRONIZED
2271 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2273 std::unique_lock
aGuard( m_aMutex
);
2274 // SYNCHRONIZED ----->
2275 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2276 rItem
.ItemText
= i_rItemText
;
2277 rItem
.ItemImageURL
= i_rItemImageURL
;
2279 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2280 // <----- SYNCHRONIZED
2284 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
)
2286 std::unique_lock
aGuard( m_aMutex
);
2287 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2288 rItem
.ItemData
= i_rDataValue
;
2292 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
)
2294 std::unique_lock
aGuard( m_aMutex
);
2295 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2296 return rItem
.ItemText
;
2300 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
)
2302 std::unique_lock
aGuard( m_aMutex
);
2303 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2304 return rItem
.ItemImageURL
;
2308 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
)
2310 std::unique_lock
aGuard( m_aMutex
);
2311 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2312 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2316 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
)
2318 std::unique_lock
aGuard( m_aMutex
);
2319 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2320 return rItem
.ItemData
;
2324 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( )
2326 std::unique_lock
aGuard( m_aMutex
);
2327 return m_xData
->getAllItems();
2331 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2333 std::unique_lock
aGuard( m_aMutex
);
2334 if ( i_Listener
.is() )
2335 m_aItemListListeners
.addInterface( aGuard
, i_Listener
);
2339 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2341 std::unique_lock
aGuard( m_aMutex
);
2342 if ( i_Listener
.is() )
2343 m_aItemListListeners
.removeInterface( aGuard
, i_Listener
);
2347 void UnoControlListBoxModel::impl_getStringItemList( std::unique_lock
<std::mutex
>& rGuard
, ::std::vector
< OUString
>& o_rStringItems
) const
2349 Sequence
< OUString
> aStringItemList
;
2351 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2352 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2354 comphelper::sequenceToContainer(o_rStringItems
, aStringItemList
);
2358 void UnoControlListBoxModel::impl_setStringItemList( std::unique_lock
<std::mutex
>& rGuard
, const ::std::vector
< OUString
>& i_rStringItems
)
2360 Sequence
< OUString
> aStringItems( comphelper::containerToSequence(i_rStringItems
) );
2361 m_xData
->m_bSettingLegacyProperty
= true;
2364 setFastPropertyValueImpl( rGuard
, BASEPROPERTY_STRINGITEMLIST
, uno::Any( aStringItems
) );
2366 catch( const Exception
& )
2368 m_xData
->m_bSettingLegacyProperty
= false;
2371 m_xData
->m_bSettingLegacyProperty
= false;
2375 void UnoControlListBoxModel::impl_handleInsert( std::unique_lock
<std::mutex
>& rGuard
,
2376 const sal_Int32 i_nItemPosition
,
2377 const ::std::optional
< OUString
>& i_rItemText
,
2378 const ::std::optional
< OUString
>& i_rItemImageURL
)
2380 // SYNCHRONIZED ----->
2381 // sync with legacy StringItemList property
2382 ::std::vector
< OUString
> aStringItems
;
2383 impl_getStringItemList( rGuard
, aStringItems
);
2384 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2385 if ( o3tl::make_unsigned( i_nItemPosition
) <= aStringItems
.size() )
2387 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2388 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2391 impl_setStringItemList( rGuard
, aStringItems
);
2393 // notify ItemListListeners
2394 impl_notifyItemListEvent( rGuard
, i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2398 void UnoControlListBoxModel::impl_handleRemove(
2399 const sal_Int32 i_nItemPosition
,
2400 std::unique_lock
<std::mutex
>& i_rClearBeforeNotify
)
2402 // SYNCHRONIZED ----->
2403 const bool bAllItems
= ( i_nItemPosition
< 0 );
2404 // sync with legacy StringItemList property
2405 ::std::vector
< OUString
> aStringItems
;
2406 impl_getStringItemList( i_rClearBeforeNotify
, aStringItems
);
2409 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2410 if ( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size() )
2412 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2417 aStringItems
.resize(0);
2420 impl_setStringItemList( i_rClearBeforeNotify
, aStringItems
);
2422 // notify ItemListListeners
2425 EventObject
aEvent( *this );
2426 m_aItemListListeners
.notifyEach( i_rClearBeforeNotify
, &XItemListListener::allItemsRemoved
, aEvent
);
2430 impl_notifyItemListEvent( i_rClearBeforeNotify
, i_nItemPosition
, ::std::optional
< OUString
>(), ::std::optional
< OUString
>(),
2431 &XItemListListener::listItemRemoved
);
2436 void UnoControlListBoxModel::impl_handleModify(
2437 const sal_Int32 i_nItemPosition
, const ::std::optional
< OUString
>& i_rItemText
,
2438 const ::std::optional
< OUString
>& i_rItemImageURL
,
2439 std::unique_lock
<std::mutex
>& i_rClearBeforeNotify
)
2441 // SYNCHRONIZED ----->
2442 if ( !!i_rItemText
)
2444 // sync with legacy StringItemList property
2445 ::std::vector
< OUString
> aStringItems
;
2446 impl_getStringItemList( i_rClearBeforeNotify
, aStringItems
);
2447 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2448 if ( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size() )
2450 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2453 impl_setStringItemList( i_rClearBeforeNotify
, aStringItems
);
2456 // notify ItemListListeners
2457 impl_notifyItemListEvent( i_rClearBeforeNotify
, i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2461 void UnoControlListBoxModel::impl_notifyItemListEvent(
2462 std::unique_lock
<std::mutex
>& rGuard
,
2463 const sal_Int32 i_nItemPosition
, const ::std::optional
< OUString
>& i_rItemText
,
2464 const ::std::optional
< OUString
>& i_rItemImageURL
,
2465 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2467 ItemListEvent aEvent
;
2468 aEvent
.Source
= *this;
2469 aEvent
.ItemPosition
= i_nItemPosition
;
2470 if ( !!i_rItemText
)
2472 aEvent
.ItemText
.IsPresent
= true;
2473 aEvent
.ItemText
.Value
= *i_rItemText
;
2475 if ( !!i_rItemImageURL
)
2477 aEvent
.ItemImageURL
.IsPresent
= true;
2478 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2481 m_aItemListListeners
.notifyEach( rGuard
, NotificationMethod
, aEvent
);
2484 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2485 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2486 css::uno::XComponentContext
*context
,
2487 css::uno::Sequence
<css::uno::Any
> const &)
2489 return cppu::acquire(new UnoControlListBoxModel(context
));
2494 UnoListBoxControl::UnoListBoxControl()
2495 :maActionListeners( *this )
2496 ,maItemListeners( *this )
2498 maComponentInfos
.nWidth
= 100;
2499 maComponentInfos
.nHeight
= 12;
2502 OUString
UnoListBoxControl::GetComponentServiceName() const
2507 OUString
UnoListBoxControl::getImplementationName()
2509 return "stardiv.Toolkit.UnoListBoxControl";
2512 css::uno::Sequence
<OUString
> UnoListBoxControl::getSupportedServiceNames()
2514 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlListBox", "stardiv.vcl.control.ListBox" };
2515 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
2518 void UnoListBoxControl::dispose()
2520 lang::EventObject aEvt
;
2521 aEvt
.Source
= getXWeak();
2522 maActionListeners
.disposeAndClear( aEvt
);
2523 maItemListeners
.disposeAndClear( aEvt
);
2524 UnoControl::dispose();
2527 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2529 if ( getPeer().is() )
2531 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2532 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2534 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2535 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), uno::Any(aSeq
), false );
2539 void UnoListBoxControl::updateFromModel()
2541 UnoControlBase::updateFromModel();
2543 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2544 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2546 EventObject
aEvent( getModel() );
2547 xItemListListener
->itemListChanged( aEvent
);
2549 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2550 // already did this, our peer(s) can only legitimately set the selection after they have the string
2551 // item list, which we just notified with the itemListChanged call.
2552 const OUString
& sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2553 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2556 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2558 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2559 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2560 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2561 // will be forwarded to the peer, which will update itself accordingly.
2564 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2567 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
2569 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2571 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2572 xListBox
->addItemListener( this );
2574 if ( maActionListeners
.getLength() )
2575 xListBox
->addActionListener( &maActionListeners
);
2578 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2580 maActionListeners
.addInterface( l
);
2581 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2583 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2584 xListBox
->addActionListener( &maActionListeners
);
2588 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2590 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2592 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2593 xListBox
->removeActionListener( &maActionListeners
);
2595 maActionListeners
.removeInterface( l
);
2598 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2600 maItemListeners
.addInterface( l
);
2603 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2605 maItemListeners
.removeInterface( l
);
2608 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
2610 uno::Sequence
<OUString
> aSeq
{ aItem
};
2611 addItems( aSeq
, nPos
);
2614 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
2616 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2617 uno::Sequence
< OUString
> aSeq
;
2619 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
2620 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2621 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2623 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2625 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2628 // Items before the Paste-Position
2629 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
2632 it
= std::copy(aItems
.begin(), aItems
.end(), it
);
2634 // Rest of old Items
2635 std::copy(std::next(std::cbegin(aSeq
), nPos
), std::cend(aSeq
), it
);
2637 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2640 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
2642 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2643 uno::Sequence
< OUString
> aSeq
;
2645 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2646 if ( !(nOldLen
&& ( nPos
< nOldLen
)) )
2649 if ( nCount
> ( nOldLen
-nPos
) )
2650 nCount
= nOldLen
-nPos
;
2652 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2654 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2656 // Items before the Remove-Position
2657 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
2660 std::copy(std::next(std::cbegin(aSeq
), nPos
+ nCount
), std::cend(aSeq
), it
);
2662 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2665 sal_Int16
UnoListBoxControl::getItemCount()
2667 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2668 uno::Sequence
< OUString
> aSeq
;
2670 return static_cast<sal_Int16
>(aSeq
.getLength());
2673 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
)
2676 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2677 uno::Sequence
< OUString
> aSeq
;
2679 if ( nPos
< aSeq
.getLength() )
2684 uno::Sequence
< OUString
> UnoListBoxControl::getItems()
2686 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2687 uno::Sequence
< OUString
> aSeq
;
2692 sal_Int16
UnoListBoxControl::getSelectedItemPos()
2695 if ( getPeer().is() )
2697 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2698 n
= xListBox
->getSelectedItemPos();
2703 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos()
2705 uno::Sequence
<sal_Int16
> aSeq
;
2706 if ( getPeer().is() )
2708 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2709 aSeq
= xListBox
->getSelectedItemsPos();
2714 OUString
UnoListBoxControl::getSelectedItem()
2717 if ( getPeer().is() )
2719 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2720 aItem
= xListBox
->getSelectedItem();
2725 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems()
2727 uno::Sequence
< OUString
> aSeq
;
2728 if ( getPeer().is() )
2730 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2731 aSeq
= xListBox
->getSelectedItems();
2736 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
)
2738 if ( getPeer().is() )
2740 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2741 xListBox
->selectItemPos( nPos
, bSelect
);
2743 ImplUpdateSelectedItemsProperty();
2746 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
)
2748 if ( getPeer().is() )
2750 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2751 xListBox
->selectItemsPos( aPositions
, bSelect
);
2753 ImplUpdateSelectedItemsProperty();
2756 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
)
2758 if ( getPeer().is() )
2760 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2761 xListBox
->selectItem( aItem
, bSelect
);
2763 ImplUpdateSelectedItemsProperty();
2766 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
)
2768 if ( getPeer().is() )
2770 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2771 xListBox
->makeVisible( nEntry
);
2775 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
)
2777 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
2780 sal_Int16
UnoListBoxControl::getDropDownLineCount()
2782 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2785 sal_Bool
UnoListBoxControl::isMutipleMode()
2787 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2790 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
)
2792 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), uno::Any(bMulti
), true );
2795 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
2797 ImplUpdateSelectedItemsProperty();
2798 if ( maItemListeners
.getLength() )
2802 maItemListeners
.itemStateChanged( rEvent
);
2804 catch( const Exception
& )
2806 TOOLS_WARN_EXCEPTION( "toolkit", "UnoListBoxControl::itemStateChanged");
2811 awt::Size
UnoListBoxControl::getMinimumSize( )
2813 return Impl_getMinimumSize();
2816 awt::Size
UnoListBoxControl::getPreferredSize( )
2818 return Impl_getPreferredSize();
2821 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
2823 return Impl_calcAdjustedSize( rNewSize
);
2826 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
2828 return Impl_getMinimumSize( nCols
, nLines
);
2831 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
2833 Impl_getColumnsAndLines( nCols
, nLines
);
2836 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
2838 ::osl::MutexGuard
aGuard( GetMutex() );
2840 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2841 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2842 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2843 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2845 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2848 if ( xOldItems
.is() )
2849 xOldItems
->removeItemListListener( this );
2850 if ( xNewItems
.is() )
2851 xNewItems
->addItemListListener( this );
2856 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
2858 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2859 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2860 if ( xPeerListener
.is() )
2861 xPeerListener
->listItemInserted( i_rEvent
);
2864 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
2866 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2867 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
2868 if ( xPeerListener
.is() )
2869 xPeerListener
->listItemRemoved( i_rEvent
);
2872 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
2874 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2875 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
2876 if ( xPeerListener
.is() )
2877 xPeerListener
->listItemModified( i_rEvent
);
2880 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
2882 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2883 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
2884 if ( xPeerListener
.is() )
2885 xPeerListener
->allItemsRemoved( i_rEvent
);
2888 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
2890 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2891 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
2892 if ( xPeerListener
.is() )
2893 xPeerListener
->itemListChanged( i_rEvent
);
2896 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2897 stardiv_Toolkit_UnoListBoxControl_get_implementation(
2898 css::uno::XComponentContext
*,
2899 css::uno::Sequence
<css::uno::Any
> const &)
2901 return cppu::acquire(new UnoListBoxControl());
2906 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
2907 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
2909 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXComboBox
>();
2912 OUString
UnoControlComboBoxModel::getImplementationName()
2914 return "stardiv.Toolkit.UnoControlComboBoxModel";
2917 css::uno::Sequence
<OUString
> UnoControlComboBoxModel::getSupportedServiceNames()
2919 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlComboBoxModel", "stardiv.vcl.controlmodel.ComboBox" };
2920 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
2923 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( )
2925 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2929 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
2931 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
2936 OUString
UnoControlComboBoxModel::getServiceName()
2938 return "stardiv.vcl.controlmodel.ComboBox";
2941 void UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const uno::Any
& rValue
)
2943 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
2945 if (nHandle
!= BASEPROPERTY_STRINGITEMLIST
|| m_xData
->m_bSettingLegacyProperty
)
2948 // synchronize the legacy StringItemList property with our list items
2949 Sequence
< OUString
> aStringItemList
;
2951 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2952 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2954 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2956 std::cbegin(aStringItemList
),
2957 std::cend(aStringItemList
),
2961 m_xData
->setAllItems( std::move(aItems
) );
2963 // since an XItemListListener does not have a "all items modified" or some such method,
2964 // we simulate this by notifying removal of all items, followed by insertion of all new
2966 lang::EventObject aEvent
;
2967 aEvent
.Source
= *this;
2968 m_aItemListListeners
.notifyEach( rGuard
, &XItemListListener::itemListChanged
, aEvent
);
2971 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2973 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2975 return uno::Any( OUString( "stardiv.vcl.control.ComboBox" ) );
2977 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2980 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2981 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
2982 css::uno::XComponentContext
*context
,
2983 css::uno::Sequence
<css::uno::Any
> const &)
2985 return cppu::acquire(new UnoControlComboBoxModel(context
));
2990 UnoComboBoxControl::UnoComboBoxControl()
2991 :maActionListeners( *this )
2992 ,maItemListeners( *this )
2994 maComponentInfos
.nWidth
= 100;
2995 maComponentInfos
.nHeight
= 12;
2998 OUString
UnoComboBoxControl::getImplementationName()
3000 return "stardiv.Toolkit.UnoComboBoxControl";
3003 css::uno::Sequence
<OUString
> UnoComboBoxControl::getSupportedServiceNames()
3005 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlComboBox", "stardiv.vcl.control.ComboBox" };
3006 return comphelper::concatSequences( UnoEditControl::getSupportedServiceNames(), vals
);
3009 OUString
UnoComboBoxControl::GetComponentServiceName() const
3014 void UnoComboBoxControl::dispose()
3016 lang::EventObject aEvt
;
3017 aEvt
.Source
= getXWeak();
3018 maActionListeners
.disposeAndClear( aEvt
);
3019 maItemListeners
.disposeAndClear( aEvt
);
3020 UnoControl::dispose();
3022 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
)
3024 uno::Any aRet
= ::cppu::queryInterface( rType
,
3025 static_cast< awt::XComboBox
* >(this) );
3026 if ( !aRet
.hasValue() )
3028 aRet
= ::cppu::queryInterface( rType
,
3029 static_cast< awt::XItemListener
* >(this) );
3030 if ( !aRet
.hasValue() )
3032 aRet
= ::cppu::queryInterface( rType
,
3033 static_cast< awt::XItemListListener
* >(this) );
3036 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3039 IMPL_IMPLEMENTATION_ID( UnoComboBoxControl
)
3041 // lang::XTypeProvider
3042 css::uno::Sequence
< css::uno::Type
> UnoComboBoxControl::getTypes()
3044 static const ::cppu::OTypeCollection
aTypeList(
3045 cppu::UnoType
<awt::XComboBox
>::get(),
3046 cppu::UnoType
<awt::XItemListener
>::get(),
3047 cppu::UnoType
<awt::XItemListListener
>::get(),
3048 UnoEditControl::getTypes()
3050 return aTypeList
.getTypes();
3053 void UnoComboBoxControl::updateFromModel()
3055 UnoEditControl::updateFromModel();
3057 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
3058 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3060 EventObject
aEvent( getModel() );
3061 xItemListListener
->itemListChanged( aEvent
);
3063 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
3065 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
3066 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3067 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3068 // will be forwarded to the peer, which will update itself accordingly.
3071 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
3073 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3075 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3077 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3078 if ( maActionListeners
.getLength() )
3079 xComboBox
->addActionListener( &maActionListeners
);
3080 if ( maItemListeners
.getLength() )
3081 xComboBox
->addItemListener( &maItemListeners
);
3084 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3086 maActionListeners
.addInterface( l
);
3087 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3089 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3090 xComboBox
->addActionListener( &maActionListeners
);
3094 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3096 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3098 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3099 xComboBox
->removeActionListener( &maActionListeners
);
3101 maActionListeners
.removeInterface( l
);
3104 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3106 maItemListeners
.addInterface( l
);
3107 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3109 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3110 xComboBox
->addItemListener( &maItemListeners
);
3114 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3116 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3118 // This call is prettier than creating a Ref and calling query
3119 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3120 xComboBox
->removeItemListener( &maItemListeners
);
3122 maItemListeners
.removeInterface( l
);
3124 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
3126 if ( maItemListeners
.getLength() )
3130 maItemListeners
.itemStateChanged( rEvent
);
3132 catch( const Exception
& )
3134 TOOLS_WARN_EXCEPTION( "toolkit", "UnoComboBoxControl::itemStateChanged");
3138 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
3140 ::osl::MutexGuard
aGuard( GetMutex() );
3142 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3143 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3144 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3145 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3147 if ( !UnoEditControl::setModel( i_rModel
) )
3150 if ( xOldItems
.is() )
3151 xOldItems
->removeItemListListener( this );
3152 if ( xNewItems
.is() )
3153 xNewItems
->addItemListListener( this );
3158 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
3160 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3161 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3162 if ( xPeerListener
.is() )
3163 xPeerListener
->listItemInserted( i_rEvent
);
3166 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
3168 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3169 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3170 if ( xPeerListener
.is() )
3171 xPeerListener
->listItemRemoved( i_rEvent
);
3174 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
3176 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3177 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3178 if ( xPeerListener
.is() )
3179 xPeerListener
->listItemModified( i_rEvent
);
3182 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3184 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3185 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3186 if ( xPeerListener
.is() )
3187 xPeerListener
->allItemsRemoved( i_rEvent
);
3190 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3192 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3193 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3194 if ( xPeerListener
.is() )
3195 xPeerListener
->itemListChanged( i_rEvent
);
3198 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
3200 uno::Sequence
<OUString
> aSeq
{ aItem
};
3201 addItems( aSeq
, nPos
);
3204 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
3206 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3207 uno::Sequence
< OUString
> aSeq
;
3209 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
3210 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3211 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3213 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3215 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3218 // items before the insert position
3219 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
3222 it
= std::copy(aItems
.begin(), aItems
.end(), it
);
3224 // remainder of old items
3225 std::copy(std::next(std::cbegin(aSeq
), nPos
), std::cend(aSeq
), it
);
3227 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), Any(aNewSeq
), true );
3230 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
3232 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3233 uno::Sequence
< OUString
> aSeq
;
3235 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3236 if ( !nOldLen
|| ( nPos
>= nOldLen
) )
3239 if ( nCount
> ( nOldLen
-nPos
) )
3240 nCount
= nOldLen
-nPos
;
3242 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3244 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3246 // items before the deletion position
3247 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
3249 // remainder of old items
3250 std::copy(std::next(std::cbegin(aSeq
), nPos
+ nCount
), std::cend(aSeq
), it
);
3252 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
3255 sal_Int16
UnoComboBoxControl::getItemCount()
3257 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3258 uno::Sequence
< OUString
> aSeq
;
3260 return static_cast<sal_Int16
>(aSeq
.getLength());
3263 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
)
3266 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3267 uno::Sequence
< OUString
> aSeq
;
3269 if ( nPos
< aSeq
.getLength() )
3274 uno::Sequence
< OUString
> UnoComboBoxControl::getItems()
3276 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3277 uno::Sequence
< OUString
> aSeq
;
3282 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
)
3284 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
3287 sal_Int16
UnoComboBoxControl::getDropDownLineCount()
3289 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3292 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3293 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3294 css::uno::XComponentContext
*,
3295 css::uno::Sequence
<css::uno::Any
> const &)
3297 return cppu::acquire(new UnoComboBoxControl());
3301 // UnoSpinFieldControl
3303 UnoSpinFieldControl::UnoSpinFieldControl()
3304 :maSpinListeners( *this )
3310 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
)
3312 uno::Any aRet
= ::cppu::queryInterface( rType
,
3313 static_cast< awt::XSpinField
* >(this) );
3314 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3317 IMPL_IMPLEMENTATION_ID( UnoSpinFieldControl
)
3319 // lang::XTypeProvider
3320 css::uno::Sequence
< css::uno::Type
> UnoSpinFieldControl::getTypes()
3322 static const ::cppu::OTypeCollection
aTypeList(
3323 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3324 cppu::UnoType
<awt::XSpinField
>::get(),
3325 UnoEditControl::getTypes()
3327 return aTypeList
.getTypes();
3330 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3332 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3334 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3335 xField
->enableRepeat( mbRepeat
);
3336 if ( maSpinListeners
.getLength() )
3337 xField
->addSpinListener( &maSpinListeners
);
3340 // css::awt::XSpinField
3341 void UnoSpinFieldControl::addSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3343 maSpinListeners
.addInterface( l
);
3344 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3346 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3347 xField
->addSpinListener( &maSpinListeners
);
3351 void UnoSpinFieldControl::removeSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3353 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3355 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3356 xField
->removeSpinListener( &maSpinListeners
);
3358 maSpinListeners
.removeInterface( l
);
3361 void UnoSpinFieldControl::up()
3363 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3368 void UnoSpinFieldControl::down()
3370 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3375 void UnoSpinFieldControl::first()
3377 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3382 void UnoSpinFieldControl::last()
3384 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3389 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
)
3393 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3395 xField
->enableRepeat( bRepeat
);
3400 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3401 :UnoControlModel( rxContext
)
3403 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXDateField
>();
3406 OUString
UnoControlDateFieldModel::getServiceName()
3408 return "stardiv.vcl.controlmodel.DateField";
3411 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3413 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3415 return uno::Any( OUString( "stardiv.vcl.control.DateField" ) );
3417 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3421 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3423 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3427 // beans::XMultiPropertySet
3428 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( )
3430 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3434 OUString
UnoControlDateFieldModel::getImplementationName()
3436 return "stardiv.Toolkit.UnoControlDateFieldModel";
3439 css::uno::Sequence
<OUString
>
3440 UnoControlDateFieldModel::getSupportedServiceNames()
3442 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlDateFieldModel", "stardiv.vcl.controlmodel.DateField" };
3443 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3446 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3447 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3448 css::uno::XComponentContext
*context
,
3449 css::uno::Sequence
<css::uno::Any
> const &)
3451 return cppu::acquire(new UnoControlDateFieldModel(context
));
3456 UnoDateFieldControl::UnoDateFieldControl()
3458 mnFirst
= util::Date( 1, 1, 1900 );
3459 mnLast
= util::Date( 31, 12, 2200 );
3460 mbLongFormat
= TRISTATE_INDET
;
3463 OUString
UnoDateFieldControl::GetComponentServiceName() const
3469 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
)
3471 uno::Any aRet
= ::cppu::queryInterface( rType
,
3472 static_cast< awt::XDateField
* >(this) );
3473 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3476 IMPL_IMPLEMENTATION_ID( UnoDateFieldControl
)
3478 // lang::XTypeProvider
3479 css::uno::Sequence
< css::uno::Type
> UnoDateFieldControl::getTypes()
3481 static const ::cppu::OTypeCollection
aTypeList(
3482 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3483 cppu::UnoType
<awt::XDateField
>::get(),
3484 UnoSpinFieldControl::getTypes()
3486 return aTypeList
.getTypes();
3489 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3491 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3493 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3494 xField
->setFirst( mnFirst
);
3495 xField
->setLast( mnLast
);
3496 if ( mbLongFormat
!= TRISTATE_INDET
)
3497 xField
->setLongFormat( mbLongFormat
!= TRISTATE_FALSE
);
3501 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
)
3503 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3505 // also change the text property (#i25106#)
3508 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3509 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3512 // re-calc the Date property
3513 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3515 if ( xField
->isEmpty() )
3517 // the field says it's empty
3518 bool bEnforceFormat
= true;
3520 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3521 if ( !bEnforceFormat
)
3523 // and it also says that it is currently accepting invalid inputs, without
3524 // forcing it to a valid date
3525 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3526 if ( xText
.is() && xText
->getText().getLength() )
3527 // and in real, the text of the peer is *not* empty
3528 // -> simulate an invalid date, which is different from "no date"
3529 aValue
<<= util::Date();
3533 aValue
<<= xField
->getDate();
3535 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, false );
3537 // multiplex the event
3538 if ( GetTextListeners().getLength() )
3539 GetTextListeners().textChanged( e
);
3542 void UnoDateFieldControl::setDate( const util::Date
& Date
)
3544 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), uno::Any(Date
), true );
3547 util::Date
UnoDateFieldControl::getDate()
3549 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3552 void UnoDateFieldControl::setMin( const util::Date
& Date
)
3554 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), uno::Any(Date
), true );
3557 util::Date
UnoDateFieldControl::getMin()
3559 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3562 void UnoDateFieldControl::setMax( const util::Date
& Date
)
3564 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), uno::Any(Date
), true );
3567 util::Date
UnoDateFieldControl::getMax()
3569 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3572 void UnoDateFieldControl::setFirst( const util::Date
& Date
)
3575 if ( getPeer().is() )
3577 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3578 xField
->setFirst( Date
);
3582 util::Date
UnoDateFieldControl::getFirst()
3587 void UnoDateFieldControl::setLast( const util::Date
& Date
)
3590 if ( getPeer().is() )
3592 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3593 xField
->setLast( Date
);
3597 util::Date
UnoDateFieldControl::getLast()
3602 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
)
3604 mbLongFormat
= bLong
? TRISTATE_TRUE
: TRISTATE_FALSE
;
3605 if ( getPeer().is() )
3607 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3608 xField
->setLongFormat( bLong
);
3612 sal_Bool
UnoDateFieldControl::isLongFormat()
3614 return mbLongFormat
== TRISTATE_TRUE
;
3617 void UnoDateFieldControl::setEmpty()
3619 if ( getPeer().is() )
3621 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3626 sal_Bool
UnoDateFieldControl::isEmpty()
3628 bool bEmpty
= false;
3629 if ( getPeer().is() )
3631 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3632 bEmpty
= xField
->isEmpty();
3637 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
)
3639 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3642 sal_Bool
UnoDateFieldControl::isStrictFormat()
3644 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3647 OUString
UnoDateFieldControl::getImplementationName()
3649 return "stardiv.Toolkit.UnoDateFieldControl";
3652 css::uno::Sequence
<OUString
> UnoDateFieldControl::getSupportedServiceNames()
3654 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlDateField", "stardiv.vcl.control.DateField" };
3655 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
3658 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3659 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3660 css::uno::XComponentContext
*,
3661 css::uno::Sequence
<css::uno::Any
> const &)
3663 return cppu::acquire(new UnoDateFieldControl());
3668 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3669 :UnoControlModel( rxContext
)
3671 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXTimeField
>();
3674 OUString
UnoControlTimeFieldModel::getServiceName()
3676 return "stardiv.vcl.controlmodel.TimeField";
3679 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3681 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3683 return uno::Any( OUString( "stardiv.vcl.control.TimeField" ) );
3685 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3689 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3691 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3695 // beans::XMultiPropertySet
3696 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( )
3698 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3702 OUString
UnoControlTimeFieldModel::getImplementationName()
3704 return "stardiv.Toolkit.UnoControlTimeFieldModel";
3707 css::uno::Sequence
<OUString
>
3708 UnoControlTimeFieldModel::getSupportedServiceNames()
3710 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlTimeFieldModel", "stardiv.vcl.controlmodel.TimeField" };
3711 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3714 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3715 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
3716 css::uno::XComponentContext
*context
,
3717 css::uno::Sequence
<css::uno::Any
> const &)
3719 return cppu::acquire(new UnoControlTimeFieldModel(context
));
3724 UnoTimeFieldControl::UnoTimeFieldControl()
3726 mnFirst
= util::Time( 0, 0, 0, 0, false );
3727 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3730 OUString
UnoTimeFieldControl::GetComponentServiceName() const
3736 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
)
3738 uno::Any aRet
= ::cppu::queryInterface( rType
,
3739 static_cast< awt::XTimeField
* >(this) );
3740 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3743 IMPL_IMPLEMENTATION_ID( UnoTimeFieldControl
)
3745 // lang::XTypeProvider
3746 css::uno::Sequence
< css::uno::Type
> UnoTimeFieldControl::getTypes()
3748 static const ::cppu::OTypeCollection
aTypeList(
3749 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3750 cppu::UnoType
<awt::XTimeField
>::get(),
3751 UnoSpinFieldControl::getTypes()
3753 return aTypeList
.getTypes();
3756 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3758 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3760 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3761 xField
->setFirst( mnFirst
);
3762 xField
->setLast( mnLast
);
3765 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
)
3767 // also change the text property (#i25106#)
3768 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3769 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3770 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3772 // re-calc the Time property
3773 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3775 if ( !xField
->isEmpty() )
3776 aValue
<<= xField
->getTime();
3777 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, false );
3779 // multiplex the event
3780 if ( GetTextListeners().getLength() )
3781 GetTextListeners().textChanged( e
);
3784 void UnoTimeFieldControl::setTime( const util::Time
& Time
)
3786 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), Any(Time
), true );
3789 util::Time
UnoTimeFieldControl::getTime()
3791 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3794 void UnoTimeFieldControl::setMin( const util::Time
& Time
)
3796 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), uno::Any(Time
), true );
3799 util::Time
UnoTimeFieldControl::getMin()
3801 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
3804 void UnoTimeFieldControl::setMax( const util::Time
& Time
)
3806 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), uno::Any(Time
), true );
3809 util::Time
UnoTimeFieldControl::getMax()
3811 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
3814 void UnoTimeFieldControl::setFirst( const util::Time
& Time
)
3817 if ( getPeer().is() )
3819 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3820 xField
->setFirst( mnFirst
);
3824 util::Time
UnoTimeFieldControl::getFirst()
3829 void UnoTimeFieldControl::setLast( const util::Time
& Time
)
3832 if ( getPeer().is() )
3834 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3835 xField
->setFirst( mnLast
);
3839 util::Time
UnoTimeFieldControl::getLast()
3844 void UnoTimeFieldControl::setEmpty()
3846 if ( getPeer().is() )
3848 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3853 sal_Bool
UnoTimeFieldControl::isEmpty()
3855 bool bEmpty
= false;
3856 if ( getPeer().is() )
3858 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3859 bEmpty
= xField
->isEmpty();
3864 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
)
3866 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3869 sal_Bool
UnoTimeFieldControl::isStrictFormat()
3871 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3874 OUString
UnoTimeFieldControl::getImplementationName()
3876 return "stardiv.Toolkit.UnoTimeFieldControl";
3879 css::uno::Sequence
<OUString
> UnoTimeFieldControl::getSupportedServiceNames()
3881 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlTimeField", "stardiv.vcl.control.TimeField" };
3882 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
3885 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3886 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
3887 css::uno::XComponentContext
*,
3888 css::uno::Sequence
<css::uno::Any
> const &)
3890 return cppu::acquire(new UnoTimeFieldControl());
3895 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
3896 :UnoControlModel( rxContext
)
3898 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXNumericField
>();
3901 OUString
UnoControlNumericFieldModel::getServiceName()
3903 return "stardiv.vcl.controlmodel.NumericField";
3906 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3908 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3910 return uno::Any( OUString( "stardiv.vcl.control.NumericField" ) );
3912 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3916 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
3918 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3922 // beans::XMultiPropertySet
3923 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( )
3925 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3929 OUString
UnoControlNumericFieldModel::getImplementationName()
3931 return "stardiv.Toolkit.UnoControlNumericFieldModel";
3934 css::uno::Sequence
<OUString
>
3935 UnoControlNumericFieldModel::getSupportedServiceNames()
3937 const css::uno::Sequence
<OUString
> vals
{ "stardiv.vcl.controlmodel.NumericField", "com.sun.star.awt.UnoControlNumericFieldModel" };
3938 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3941 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3942 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
3943 css::uno::XComponentContext
*context
,
3944 css::uno::Sequence
<css::uno::Any
> const &)
3946 return cppu::acquire(new UnoControlNumericFieldModel(context
));
3951 UnoNumericFieldControl::UnoNumericFieldControl()
3954 mnLast
= 0x7FFFFFFF;
3957 OUString
UnoNumericFieldControl::GetComponentServiceName() const
3959 return "numericfield";
3963 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
)
3965 uno::Any aRet
= ::cppu::queryInterface( rType
,
3966 static_cast< awt::XNumericField
* >(this) );
3967 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3970 IMPL_IMPLEMENTATION_ID( UnoNumericFieldControl
)
3972 // lang::XTypeProvider
3973 css::uno::Sequence
< css::uno::Type
> UnoNumericFieldControl::getTypes()
3975 static const ::cppu::OTypeCollection
aTypeList(
3976 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3977 cppu::UnoType
<awt::XNumericField
>::get(),
3978 UnoSpinFieldControl::getTypes()
3980 return aTypeList
.getTypes();
3983 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3985 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3987 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3988 xField
->setFirst( mnFirst
);
3989 xField
->setLast( mnLast
);
3993 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
)
3995 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3996 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
3998 if ( GetTextListeners().getLength() )
3999 GetTextListeners().textChanged( e
);
4002 void UnoNumericFieldControl::setValue( double Value
)
4004 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(Value
), true );
4007 double UnoNumericFieldControl::getValue()
4009 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4012 void UnoNumericFieldControl::setMin( double Value
)
4014 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4017 double UnoNumericFieldControl::getMin()
4019 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4022 void UnoNumericFieldControl::setMax( double Value
)
4024 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4027 double UnoNumericFieldControl::getMax()
4029 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4032 void UnoNumericFieldControl::setFirst( double Value
)
4035 if ( getPeer().is() )
4037 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4038 xField
->setFirst( mnFirst
);
4042 double UnoNumericFieldControl::getFirst()
4047 void UnoNumericFieldControl::setLast( double Value
)
4050 if ( getPeer().is() )
4052 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4053 xField
->setLast( mnLast
);
4057 double UnoNumericFieldControl::getLast()
4062 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
)
4064 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4067 sal_Bool
UnoNumericFieldControl::isStrictFormat()
4069 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4072 OUString
UnoNumericFieldControl::getImplementationName()
4074 return "stardiv.Toolkit.UnoNumericFieldControl";
4077 css::uno::Sequence
<OUString
> UnoNumericFieldControl::getSupportedServiceNames()
4079 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlNumericField", "stardiv.vcl.control.NumericField" };
4080 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4083 void UnoNumericFieldControl::setSpinSize( double Digits
)
4085 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4088 double UnoNumericFieldControl::getSpinSize()
4090 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4093 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
)
4095 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4098 sal_Int16
UnoNumericFieldControl::getDecimalDigits()
4100 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4103 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4104 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4105 css::uno::XComponentContext
*,
4106 css::uno::Sequence
<css::uno::Any
> const &)
4108 return cppu::acquire(new UnoNumericFieldControl());
4111 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
4112 :UnoControlModel( rxContext
)
4114 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<SVTXCurrencyField
>();
4117 OUString
UnoControlCurrencyFieldModel::getServiceName()
4119 return "stardiv.vcl.controlmodel.CurrencyField";
4122 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4124 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4126 return uno::Any( OUString( "stardiv.vcl.control.CurrencyField" ) );
4128 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
4130 return uno::Any(false);
4133 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4136 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
4138 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4142 // beans::XMultiPropertySet
4143 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( )
4145 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4149 OUString
UnoControlCurrencyFieldModel::getImplementationName()
4151 return "stardiv.Toolkit.UnoControlCurrencyFieldModel";
4154 css::uno::Sequence
<OUString
>
4155 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4157 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlCurrencyFieldModel", "stardiv.vcl.controlmodel.CurrencyField" };
4158 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4161 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4162 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4163 css::uno::XComponentContext
*context
,
4164 css::uno::Sequence
<css::uno::Any
> const &)
4166 return cppu::acquire(new UnoControlCurrencyFieldModel(context
));
4171 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4174 mnLast
= 0x7FFFFFFF;
4177 OUString
UnoCurrencyFieldControl::GetComponentServiceName() const
4179 return "longcurrencyfield";
4183 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
)
4185 uno::Any aRet
= ::cppu::queryInterface( rType
,
4186 static_cast< awt::XCurrencyField
* >(this) );
4187 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4190 IMPL_IMPLEMENTATION_ID( UnoCurrencyFieldControl
)
4192 // lang::XTypeProvider
4193 css::uno::Sequence
< css::uno::Type
> UnoCurrencyFieldControl::getTypes()
4195 static const ::cppu::OTypeCollection
aTypeList(
4196 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4197 cppu::UnoType
<awt::XCurrencyField
>::get(),
4198 UnoSpinFieldControl::getTypes()
4200 return aTypeList
.getTypes();
4203 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4205 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4207 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4208 xField
->setFirst( mnFirst
);
4209 xField
->setLast( mnLast
);
4212 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
)
4214 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4215 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4217 if ( GetTextListeners().getLength() )
4218 GetTextListeners().textChanged( e
);
4221 void UnoCurrencyFieldControl::setValue( double Value
)
4223 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), Any(Value
), true );
4226 double UnoCurrencyFieldControl::getValue()
4228 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4231 void UnoCurrencyFieldControl::setMin( double Value
)
4233 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4236 double UnoCurrencyFieldControl::getMin()
4238 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4241 void UnoCurrencyFieldControl::setMax( double Value
)
4243 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4246 double UnoCurrencyFieldControl::getMax()
4248 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4251 void UnoCurrencyFieldControl::setFirst( double Value
)
4254 if ( getPeer().is() )
4256 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4257 xField
->setFirst( mnFirst
);
4261 double UnoCurrencyFieldControl::getFirst()
4266 void UnoCurrencyFieldControl::setLast( double Value
)
4269 if ( getPeer().is() )
4271 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4272 xField
->setLast( mnLast
);
4276 double UnoCurrencyFieldControl::getLast()
4281 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
)
4283 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4286 sal_Bool
UnoCurrencyFieldControl::isStrictFormat()
4288 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4291 OUString
UnoCurrencyFieldControl::getImplementationName()
4293 return "stardiv.Toolkit.UnoCurrencyFieldControl";
4296 css::uno::Sequence
<OUString
>
4297 UnoCurrencyFieldControl::getSupportedServiceNames()
4299 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlCurrencyField", "stardiv.vcl.control.CurrencyField" };
4300 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4303 void UnoCurrencyFieldControl::setSpinSize( double Digits
)
4305 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4308 double UnoCurrencyFieldControl::getSpinSize()
4310 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4313 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
)
4315 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4318 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits()
4320 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4323 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4324 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4325 css::uno::XComponentContext
*,
4326 css::uno::Sequence
<css::uno::Any
> const &)
4328 return cppu::acquire(new UnoCurrencyFieldControl());
4333 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4334 :UnoControlModel( rxContext
)
4336 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXPatternField
>();
4339 OUString
UnoControlPatternFieldModel::getServiceName()
4341 return "stardiv.vcl.controlmodel.PatternField";
4344 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4346 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4348 return uno::Any( OUString( "stardiv.vcl.control.PatternField" ) );
4350 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4353 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4355 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4359 // beans::XMultiPropertySet
4360 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( )
4362 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4366 OUString
UnoControlPatternFieldModel::getImplementationName()
4368 return "stardiv.Toolkit.UnoControlPatternFieldModel";
4371 css::uno::Sequence
<OUString
>
4372 UnoControlPatternFieldModel::getSupportedServiceNames()
4374 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlPatternFieldModel", "stardiv.vcl.controlmodel.PatternField" };
4375 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4378 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4379 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4380 css::uno::XComponentContext
*context
,
4381 css::uno::Sequence
<css::uno::Any
> const &)
4383 return cppu::acquire(new UnoControlPatternFieldModel(context
));
4388 UnoPatternFieldControl::UnoPatternFieldControl()
4392 OUString
UnoPatternFieldControl::GetComponentServiceName() const
4394 return "patternfield";
4397 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4399 sal_uInt16 nType
= GetPropertyId( rPropName
);
4400 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4402 // These masks cannot be set consecutively
4403 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4404 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4405 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4407 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4410 // same comment as in UnoControl::ImplSetPeerProperty - see there
4411 OUString
sText( Text
);
4412 ImplCheckLocalize( sText
);
4413 xPF
->setString( sText
);
4414 xPF
->setMasks( EditMask
, LiteralMask
);
4418 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4423 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
)
4425 uno::Any aRet
= ::cppu::queryInterface( rType
,
4426 static_cast< awt::XPatternField
* >(this) );
4427 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4430 IMPL_IMPLEMENTATION_ID( UnoPatternFieldControl
)
4432 // lang::XTypeProvider
4433 css::uno::Sequence
< css::uno::Type
> UnoPatternFieldControl::getTypes()
4435 static const ::cppu::OTypeCollection
aTypeList(
4436 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4437 cppu::UnoType
<awt::XPatternField
>::get(),
4438 UnoSpinFieldControl::getTypes()
4440 return aTypeList
.getTypes();
4443 void UnoPatternFieldControl::setString( const OUString
& rString
)
4448 OUString
UnoPatternFieldControl::getString()
4453 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
)
4455 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), uno::Any(EditMask
), true );
4456 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), uno::Any(LiteralMask
), true );
4459 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
)
4461 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4462 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4465 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
)
4467 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4470 sal_Bool
UnoPatternFieldControl::isStrictFormat()
4472 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4475 OUString
UnoPatternFieldControl::getImplementationName()
4477 return "stardiv.Toolkit.UnoPatternFieldControl";
4480 css::uno::Sequence
<OUString
> UnoPatternFieldControl::getSupportedServiceNames()
4482 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlPatternField", "stardiv.vcl.control.PatternField" };
4483 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4486 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4487 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4488 css::uno::XComponentContext
*,
4489 css::uno::Sequence
<css::uno::Any
> const &)
4491 return cppu::acquire(new UnoPatternFieldControl());
4496 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4497 :UnoControlModel( rxContext
)
4499 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4500 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4501 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4502 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4503 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4504 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4505 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4506 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4507 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4508 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4509 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4510 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4511 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4514 OUString
UnoControlProgressBarModel::getServiceName( )
4516 return "stardiv.vcl.controlmodel.ProgressBar";
4519 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4521 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4523 return uno::Any( OUString( "stardiv.vcl.control.ProgressBar" ) );
4526 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4529 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4531 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4535 // beans::XMultiPropertySet
4536 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( )
4538 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4542 OUString
UnoControlProgressBarModel::getImplementationName()
4544 return "stardiv.Toolkit.UnoControlProgressBarModel";
4547 css::uno::Sequence
<OUString
>
4548 UnoControlProgressBarModel::getSupportedServiceNames()
4550 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlProgressBarModel", "stardiv.vcl.controlmodel.ProgressBar" };
4551 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4554 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4555 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4556 css::uno::XComponentContext
*context
,
4557 css::uno::Sequence
<css::uno::Any
> const &)
4559 return cppu::acquire(new UnoControlProgressBarModel(context
));
4564 UnoProgressBarControl::UnoProgressBarControl()
4568 OUString
UnoProgressBarControl::GetComponentServiceName() const
4570 return "ProgressBar";
4574 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
)
4576 uno::Any aRet
= ::cppu::queryInterface( rType
,
4577 static_cast< awt::XProgressBar
* >(this) );
4578 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4581 IMPL_IMPLEMENTATION_ID( UnoProgressBarControl
)
4583 // lang::XTypeProvider
4584 css::uno::Sequence
< css::uno::Type
> UnoProgressBarControl::getTypes()
4586 static const ::cppu::OTypeCollection
aTypeList(
4587 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4588 cppu::UnoType
<awt::XProgressBar
>::get(),
4589 UnoControlBase::getTypes()
4591 return aTypeList
.getTypes();
4594 // css::awt::XProgressBar
4595 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
)
4597 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), uno::Any(nColor
), true );
4600 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
)
4602 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), uno::Any(nColor
), true );
4605 void UnoProgressBarControl::setValue( sal_Int32 nValue
)
4607 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), uno::Any(nValue
), true );
4610 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
)
4617 // take correct min and max
4623 // change min and max
4628 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, true );
4629 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, true );
4632 sal_Int32
UnoProgressBarControl::getValue()
4634 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4637 OUString
UnoProgressBarControl::getImplementationName()
4639 return "stardiv.Toolkit.UnoProgressBarControl";
4642 css::uno::Sequence
<OUString
> UnoProgressBarControl::getSupportedServiceNames()
4644 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlProgressBar", "stardiv.vcl.control.ProgressBar" };
4645 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
4648 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4649 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
4650 css::uno::XComponentContext
*,
4651 css::uno::Sequence
<css::uno::Any
> const &)
4653 return cppu::acquire(new UnoProgressBarControl());
4658 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4659 :UnoControlModel( rxContext
)
4661 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4662 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4663 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4664 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4665 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4666 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4667 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4668 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4669 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4670 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4673 OUString
UnoControlFixedLineModel::getServiceName( )
4675 return "stardiv.vcl.controlmodel.FixedLine";
4678 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4680 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4682 return uno::Any( OUString( "stardiv.vcl.control.FixedLine" ) );
4684 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4687 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4689 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4693 // beans::XMultiPropertySet
4694 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( )
4696 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4700 OUString
UnoControlFixedLineModel::getImplementationName()
4702 return "stardiv.Toolkit.UnoControlFixedLineModel";
4705 css::uno::Sequence
<OUString
>
4706 UnoControlFixedLineModel::getSupportedServiceNames()
4708 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFixedLineModel", "stardiv.vcl.controlmodel.FixedLine" };
4709 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4712 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4713 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
4714 css::uno::XComponentContext
*context
,
4715 css::uno::Sequence
<css::uno::Any
> const &)
4717 return cppu::acquire(new UnoControlFixedLineModel(context
));
4722 UnoFixedLineControl::UnoFixedLineControl()
4724 maComponentInfos
.nWidth
= 100; // ??
4725 maComponentInfos
.nHeight
= 100; // ??
4728 OUString
UnoFixedLineControl::GetComponentServiceName() const
4733 sal_Bool
UnoFixedLineControl::isTransparent()
4738 OUString
UnoFixedLineControl::getImplementationName()
4740 return "stardiv.Toolkit.UnoFixedLineControl";
4743 css::uno::Sequence
<OUString
> UnoFixedLineControl::getSupportedServiceNames()
4745 const css::uno::Sequence
<OUString
> vals
{ "com.sun.star.awt.UnoControlFixedLine", "stardiv.vcl.control.FixedLine" };
4746 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
4749 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4750 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
4751 css::uno::XComponentContext
*,
4752 css::uno::Sequence
<css::uno::Any
> const &)
4754 return cppu::acquire(new UnoFixedLineControl());
4757 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */