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 <tools/urlobj.hxx>
35 #include <helper/property.hxx>
36 #include <toolkit/helper/macros.hxx>
37 #include <unotools/securityoptions.hxx>
40 #include <awt/vclxwindows.hxx>
41 #include <cppuhelper/typeprovider.hxx>
42 #include <cppuhelper/queryinterface.hxx>
43 #include <comphelper/processfactory.hxx>
44 #include <comphelper/propertyvalue.hxx>
45 #include <tools/debug.hxx>
46 #include <comphelper/diagnose_ex.hxx>
50 #include <helper/imagealign.hxx>
51 #include <helper/unopropertyarrayhelper.hxx>
55 using namespace css::awt
;
56 using namespace css::lang
;
57 using namespace css::uno
;
58 using ::com::sun::star::graphic::XGraphic
;
59 using ::com::sun::star::uno::Reference
;
60 using namespace ::toolkit
;
62 uno::Reference
< graphic::XGraphic
>
63 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const OUString
& _rURL
)
65 xOutGraphicObj
= nullptr;
66 return ImageHelper::getGraphicFromURL_nothrow( _rURL
, u
""_ustr
);
69 css::uno::Reference
< css::graphic::XGraphic
>
70 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
, OUString
const & referer
)
72 uno::Reference
< graphic::XGraphic
> xGraphic
;
73 if (_rURL
.isEmpty() || SvtSecurityOptions::isUntrustedReferer(referer
) || INetURLObject(_rURL
).IsExoticProtocol())
78 const uno::Reference
< uno::XComponentContext
>& xContext( ::comphelper::getProcessComponentContext() );
79 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
80 xGraphic
= xProvider
->queryGraphic({ comphelper::makePropertyValue(u
"URL"_ustr
, _rURL
) });
82 catch (const Exception
&)
84 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
91 UnoControlEditModel::UnoControlEditModel( const Reference
< XComponentContext
>& rxContext
)
92 :UnoControlModel( rxContext
)
94 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXEdit
>();
97 OUString
UnoControlEditModel::getServiceName( )
99 return u
"stardiv.vcl.controlmodel.Edit"_ustr
;
102 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
108 case BASEPROPERTY_LINE_END_FORMAT
:
109 aReturn
<<= sal_Int16(awt::LineEndFormat::LINE_FEED
); // LF
111 case BASEPROPERTY_DEFAULTCONTROL
:
112 aReturn
<<= u
"stardiv.vcl.control.Edit"_ustr
;
115 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
121 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
123 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
127 // beans::XMultiPropertySet
128 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( )
130 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
134 OUString
UnoControlEditModel::getImplementationName()
136 return u
"stardiv.Toolkit.UnoControlEditModel"_ustr
;
139 css::uno::Sequence
<OUString
> UnoControlEditModel::getSupportedServiceNames()
141 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlEditModel"_ustr
, u
"stardiv.vcl.controlmodel.Edit"_ustr
};
142 return comphelper::concatSequences(UnoControlModel::getSupportedServiceNames(), vals
);
145 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
146 stardiv_Toolkit_UnoControlEditModel_get_implementation(
147 css::uno::XComponentContext
*context
,
148 css::uno::Sequence
<css::uno::Any
> const &)
150 return cppu::acquire(new UnoControlEditModel(context
));
155 UnoEditControl::UnoEditControl()
156 :maTextListeners( *this )
158 ,mbSetTextInPeer( false )
159 ,mbSetMaxTextLenInPeer( false )
160 ,mbHasTextProperty( false )
162 maComponentInfos
.nWidth
= 100;
163 maComponentInfos
.nHeight
= 12;
166 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
)
168 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
169 if ( !aReturn
.hasValue() )
170 aReturn
= UnoEditControl_Base::queryInterface( rType
);
174 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
)
176 return UnoControlBase::queryInterface( rType
);
179 void SAL_CALL
UnoEditControl::acquire( ) noexcept
181 UnoControlBase::acquire();
184 void SAL_CALL
UnoEditControl::release( ) noexcept
186 UnoControlBase::release();
189 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
191 OUString
UnoEditControl::GetComponentServiceName() const
193 // by default, we want a simple edit field
194 OUString
sName( u
"Edit"_ustr
);
196 // but maybe we are to display multi-line text?
197 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
199 if ( ( aVal
>>= b
) && b
)
200 sName
= "MultiLineEdit";
205 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
)
207 bool bReturn
= UnoControlBase::setModel( _rModel
);
208 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
212 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
215 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
217 // #96986# use setText(), or text listener will not be called.
218 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
219 if ( xTextComponent
.is() )
223 ImplCheckLocalize( sText
);
224 xTextComponent
->setText( sText
);
230 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
233 void UnoEditControl::dispose()
235 lang::EventObject
aEvt( *this );
236 maTextListeners
.disposeAndClear( aEvt
);
237 UnoControl::dispose();
240 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
242 UnoControl::createPeer( rxToolkit
, rParentPeer
);
244 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
247 xText
->addTextListener( this );
249 if ( mbSetMaxTextLenInPeer
)
250 xText
->setMaxTextLen( mnMaxTextLen
);
251 if ( mbSetTextInPeer
)
252 xText
->setText( maText
);
256 void UnoEditControl::textChanged(const awt::TextEvent
& e
)
258 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
260 if ( mbHasTextProperty
)
262 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(xText
->getText()), false );
266 maText
= xText
->getText();
269 if ( maTextListeners
.getLength() )
270 maTextListeners
.textChanged( e
);
273 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
)
275 // tdf#150974 some extensions pass null
278 SAL_WARN("toolkit", "null XTextListener");
281 maTextListeners
.addInterface( l
);
284 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
)
286 // tdf#150974 some extensions pass null
289 SAL_WARN("toolkit", "null XTextListener");
292 maTextListeners
.removeInterface( l
);
295 void UnoEditControl::setText( const OUString
& aText
)
297 if ( mbHasTextProperty
)
299 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(aText
), true );
304 mbSetTextInPeer
= true;
305 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
307 xText
->setText( maText
);
310 // Setting the property to the VCLXWindow doesn't call textChanged
311 if ( maTextListeners
.getLength() )
313 awt::TextEvent aEvent
;
314 aEvent
.Source
= *this;
315 maTextListeners
.textChanged( aEvent
);
321 void lcl_normalize( awt::Selection
& _rSel
)
323 if ( _rSel
.Min
> _rSel
.Max
)
324 ::std::swap( _rSel
.Min
, _rSel
.Max
);
328 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
)
330 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
331 awt::Selection
aSelection( rSel
);
332 lcl_normalize( aSelection
);
334 OUString aOldText
= getText();
335 if (aSelection
.Min
< 0 || aOldText
.getLength() < aSelection
.Max
)
337 throw lang::IllegalArgumentException();
340 // preserve the selection resp. cursor position
341 awt::Selection
aNewSelection( getSelection() );
342 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
343 // (not sure - looks uglier ...)
344 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
345 if ( aNewSelection
.Min
> aSelection
.Min
)
346 aNewSelection
.Min
-= nDeletedCharacters
;
347 if ( aNewSelection
.Max
> aSelection
.Max
)
348 aNewSelection
.Max
-= nDeletedCharacters
;
350 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
351 aNewSelection
.Min
= aNewSelection
.Max
;
354 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
357 setSelection( aNewSelection
);
360 OUString
UnoEditControl::getText()
362 OUString aText
= maText
;
364 if ( mbHasTextProperty
)
365 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
368 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
370 aText
= xText
->getText();
376 OUString
UnoEditControl::getSelectedText()
379 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
381 sSelected
= xText
->getSelectedText();
386 void UnoEditControl::setSelection( const awt::Selection
& aSelection
)
388 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
390 xText
->setSelection( aSelection
);
393 awt::Selection
UnoEditControl::getSelection()
396 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
398 aSel
= xText
->getSelection();
402 sal_Bool
UnoEditControl::isEditable()
404 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
407 void UnoEditControl::setEditable( sal_Bool bEditable
)
409 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), uno::Any(!bEditable
), true );
412 sal_Int16
UnoEditControl::getMaxTextLen()
414 sal_Int16 nMaxLen
= mnMaxTextLen
;
416 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
417 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
422 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
)
424 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
426 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), uno::Any(nLen
), true );
431 mbSetMaxTextLenInPeer
= true;
432 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
434 xText
->setMaxTextLen( mnMaxTextLen
);
438 awt::Size
UnoEditControl::getMinimumSize( )
440 return Impl_getMinimumSize();
443 awt::Size
UnoEditControl::getPreferredSize( )
445 return Impl_getPreferredSize();
448 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
)
450 return Impl_calcAdjustedSize( rNewSize
);
453 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
455 return Impl_getMinimumSize( nCols
, nLines
);
458 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
460 Impl_getColumnsAndLines( nCols
, nLines
);
463 OUString
UnoEditControl::getImplementationName( )
465 return u
"stardiv.Toolkit.UnoEditControl"_ustr
;
468 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames()
470 css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlEdit"_ustr
, u
"stardiv.vcl.control.Edit"_ustr
};
471 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames( ), vals
);
474 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
475 stardiv_Toolkit_UnoEditControl_get_implementation(
476 css::uno::XComponentContext
*,
477 css::uno::Sequence
<css::uno::Any
> const &)
479 return cppu::acquire(new UnoEditControl());
484 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
485 :UnoControlModel( rxContext
)
487 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
488 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
489 ImplRegisterProperty( BASEPROPERTY_BORDER
);
490 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
491 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
492 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
493 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
494 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
495 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
496 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
497 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
498 ImplRegisterProperty( BASEPROPERTY_READONLY
);
499 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
500 ImplRegisterProperty( BASEPROPERTY_TEXT
);
501 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
502 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
503 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
504 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
507 OUString
UnoControlFileControlModel::getServiceName()
509 return u
"stardiv.vcl.controlmodel.FileControl"_ustr
;
512 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
514 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
516 return uno::Any( u
"stardiv.vcl.control.FileControl"_ustr
);
518 return UnoControlModel::ImplGetDefaultValue( nPropId
);
521 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
523 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
527 // beans::XMultiPropertySet
528 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( )
530 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
534 OUString
UnoControlFileControlModel::getImplementationName()
536 return u
"stardiv.Toolkit.UnoControlFileControlModel"_ustr
;
539 css::uno::Sequence
<OUString
>
540 UnoControlFileControlModel::getSupportedServiceNames()
542 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFileControlModel"_ustr
, u
"stardiv.vcl.controlmodel.FileControl"_ustr
};
543 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
546 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
547 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
548 css::uno::XComponentContext
*context
,
549 css::uno::Sequence
<css::uno::Any
> const &)
551 return cppu::acquire(new UnoControlFileControlModel(context
));
556 UnoFileControl::UnoFileControl()
560 OUString
UnoFileControl::GetComponentServiceName() const
562 return u
"filecontrol"_ustr
;
565 OUString
UnoFileControl::getImplementationName()
567 return u
"stardiv.Toolkit.UnoFileControl"_ustr
;
570 css::uno::Sequence
<OUString
> UnoFileControl::getSupportedServiceNames()
572 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFileControl"_ustr
, u
"stardiv.vcl.control.FileControl"_ustr
};
573 return comphelper::concatSequences( UnoEditControl::getSupportedServiceNames(), vals
);
576 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
577 stardiv_Toolkit_UnoFileControl_get_implementation(
578 css::uno::XComponentContext
*,
579 css::uno::Sequence
<css::uno::Any
> const &)
581 return cppu::acquire(new UnoFileControl());
586 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
588 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
589 return uno::Any( uno::Reference
< graphic::XGraphic
>() );
591 return UnoControlModel::ImplGetDefaultValue( nPropId
);
594 void GraphicControlModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const css::uno::Any
& rValue
)
596 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
598 // - ImageAlign and ImagePosition need to correspond to each other
599 // - Graphic and ImageURL need to correspond to each other
604 case BASEPROPERTY_IMAGEURL
:
605 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
607 mbAdjustingGraphic
= true;
609 OSL_VERIFY( rValue
>>= sImageURL
);
611 getFastPropertyValue(rGuard
, any
, BASEPROPERTY_REFERER
);
614 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_GRAPHIC
, uno::Any( ImageHelper::getGraphicFromURL_nothrow( sImageURL
, referer
) ) );
615 mbAdjustingGraphic
= false;
619 case BASEPROPERTY_GRAPHIC
:
620 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
622 mbAdjustingGraphic
= true;
623 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEURL
, uno::Any( OUString() ) );
624 mbAdjustingGraphic
= false;
628 case BASEPROPERTY_IMAGEALIGN
:
629 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
631 mbAdjustingImagePosition
= true;
632 sal_Int16 nUNOValue
= 0;
633 OSL_VERIFY( rValue
>>= nUNOValue
);
634 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEPOSITION
, uno::Any( getExtendedImagePosition( nUNOValue
) ) );
635 mbAdjustingImagePosition
= false;
638 case BASEPROPERTY_IMAGEPOSITION
:
639 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
641 mbAdjustingImagePosition
= true;
642 sal_Int16 nUNOValue
= 0;
643 OSL_VERIFY( rValue
>>= nUNOValue
);
644 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGEALIGN
, uno::Any( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
645 mbAdjustingImagePosition
= false;
650 catch( const css::uno::Exception
& )
652 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
653 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
654 mbAdjustingImagePosition
= false;
660 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
661 :GraphicControlModel( rxContext
)
663 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXButton
>();
665 osl_atomic_increment( &m_refCount
);
667 std::unique_lock
aGuard(m_aMutex
);
668 setFastPropertyValue_NoBroadcast( aGuard
, BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
669 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
670 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
672 osl_atomic_decrement( &m_refCount
);
675 OUString
UnoControlButtonModel::getServiceName()
677 return u
"stardiv.vcl.controlmodel.Button"_ustr
;
680 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
684 case BASEPROPERTY_DEFAULTCONTROL
:
685 return uno::Any( u
"stardiv.vcl.control.Button"_ustr
);
686 case BASEPROPERTY_TOGGLE
:
687 return uno::Any( false );
688 case BASEPROPERTY_ALIGN
:
689 return uno::Any( sal_Int16(PROPERTY_ALIGN_CENTER
) );
690 case BASEPROPERTY_FOCUSONCLICK
:
691 return uno::Any( true );
694 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
697 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
699 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
703 // beans::XMultiPropertySet
704 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( )
706 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
710 OUString
UnoControlButtonModel::getImplementationName()
712 return u
"stardiv.Toolkit.UnoControlButtonModel"_ustr
;
715 css::uno::Sequence
<OUString
> UnoControlButtonModel::getSupportedServiceNames()
717 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlButtonModel"_ustr
, u
"stardiv.vcl.controlmodel.Button"_ustr
};
718 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
721 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
722 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
723 css::uno::XComponentContext
*context
,
724 css::uno::Sequence
<css::uno::Any
> const &)
726 return cppu::acquire(new UnoControlButtonModel(context
));
731 UnoButtonControl::UnoButtonControl()
732 :maActionListeners( *this )
733 ,maItemListeners( *this )
735 maComponentInfos
.nWidth
= 50;
736 maComponentInfos
.nHeight
= 14;
739 OUString
UnoButtonControl::GetComponentServiceName() const
741 OUString
aName( u
"pushbutton"_ustr
);
742 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
743 sal_Int16 n
= sal_Int16();
744 if ( ( aVal
>>= n
) && n
)
746 // Use PushButtonType later when available...
749 case 1 /*PushButtonType::OK*/: aName
= "okbutton";
751 case 2 /*PushButtonType::CANCEL*/: aName
= "cancelbutton";
753 case 3 /*PushButtonType::HELP*/: aName
= "helpbutton";
757 OSL_FAIL( "Unknown Button Type!" );
764 void UnoButtonControl::dispose()
766 lang::EventObject aEvt
;
767 aEvt
.Source
= getXWeak();
768 maActionListeners
.disposeAndClear( aEvt
);
769 maItemListeners
.disposeAndClear( aEvt
);
770 UnoControlBase::dispose();
773 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
775 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
777 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
778 xButton
->setActionCommand( maActionCommand
);
779 if ( maActionListeners
.getLength() )
780 xButton
->addActionListener( &maActionListeners
);
782 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
783 if ( xPushButton
.is() )
784 xPushButton
->addItemListener( this );
787 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
789 // tdf#150974 some extensions pass null
792 SAL_WARN("toolkit", "null XActionListener");
796 maActionListeners
.addInterface( l
);
797 if( getPeer().is() && maActionListeners
.getLength() == 1 )
799 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
800 xButton
->addActionListener( &maActionListeners
);
804 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
806 // tdf#150974 some extensions pass null
809 SAL_WARN("toolkit", "null XActionListener");
813 if( getPeer().is() && maActionListeners
.getLength() == 1 )
815 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
816 xButton
->removeActionListener( &maActionListeners
);
818 maActionListeners
.removeInterface( l
);
821 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
823 maItemListeners
.addInterface( l
);
826 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
828 maItemListeners
.removeInterface( l
);
831 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
)
833 UnoControlBase::disposing( Source
);
836 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
839 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
842 ItemEvent
aEvent( rEvent
);
843 aEvent
.Source
= *this;
844 maItemListeners
.itemStateChanged( aEvent
);
847 void UnoButtonControl::setLabel( const OUString
& rLabel
)
849 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
852 void UnoButtonControl::setActionCommand( const OUString
& rCommand
)
854 maActionCommand
= rCommand
;
855 if ( getPeer().is() )
857 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
858 xButton
->setActionCommand( rCommand
);
862 awt::Size
UnoButtonControl::getMinimumSize( )
864 return Impl_getMinimumSize();
867 awt::Size
UnoButtonControl::getPreferredSize( )
869 return Impl_getPreferredSize();
872 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
874 return Impl_calcAdjustedSize( rNewSize
);
877 OUString
UnoButtonControl::getImplementationName()
879 return u
"stardiv.Toolkit.UnoButtonControl"_ustr
;
882 css::uno::Sequence
<OUString
> UnoButtonControl::getSupportedServiceNames()
884 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlButton"_ustr
, u
"stardiv.vcl.control.Button"_ustr
};
885 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
888 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
889 stardiv_Toolkit_UnoButtonControl_get_implementation(
890 css::uno::XComponentContext
*,
891 css::uno::Sequence
<css::uno::Any
> const &)
893 return cppu::acquire(new UnoButtonControl());
898 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
899 :GraphicControlModel( rxContext
)
900 ,mbAdjustingImageScaleMode( false )
902 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXImageControl
>();
905 OUString
UnoControlImageControlModel::getServiceName()
907 return u
"stardiv.vcl.controlmodel.ImageControl"_ustr
;
910 OUString
UnoControlImageControlModel::getImplementationName()
912 return u
"stardiv.Toolkit.UnoControlImageControlModel"_ustr
;
915 css::uno::Sequence
<OUString
>
916 UnoControlImageControlModel::getSupportedServiceNames()
918 const css::uno::Sequence
<OUString
> vals
{
919 u
"com.sun.star.awt.UnoControlImageButtonModel"_ustr
,
920 u
"com.sun.star.awt.UnoControlImageControlModel"_ustr
,
921 u
"stardiv.vcl.controlmodel.ImageButton"_ustr
,
922 u
"stardiv.vcl.controlmodel.ImageControl"_ustr
924 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
927 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
929 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
930 return uno::Any( u
"stardiv.vcl.control.ImageControl"_ustr
);
932 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
933 return Any( awt::ImageScaleMode::ANISOTROPIC
);
935 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
938 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
940 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
944 // beans::XMultiPropertySet
945 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( )
947 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
951 void UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
953 GraphicControlModel::setFastPropertyValue_NoBroadcast( rGuard
, _nHandle
, _rValue
);
955 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
960 case BASEPROPERTY_IMAGE_SCALE_MODE
:
961 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
963 mbAdjustingImageScaleMode
= true;
964 sal_Int16
nScaleMode( awt::ImageScaleMode::ANISOTROPIC
);
965 OSL_VERIFY( _rValue
>>= nScaleMode
);
966 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_SCALEIMAGE
, uno::Any( nScaleMode
!= awt::ImageScaleMode::NONE
) );
967 mbAdjustingImageScaleMode
= false;
970 case BASEPROPERTY_SCALEIMAGE
:
971 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
973 mbAdjustingImageScaleMode
= true;
975 OSL_VERIFY( _rValue
>>= bScale
);
976 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_IMAGE_SCALE_MODE
, uno::Any( bScale
? awt::ImageScaleMode::ANISOTROPIC
: awt::ImageScaleMode::NONE
) );
977 mbAdjustingImageScaleMode
= false;
982 catch( const Exception
& )
984 mbAdjustingImageScaleMode
= false;
989 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
990 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
991 css::uno::XComponentContext
*context
,
992 css::uno::Sequence
<css::uno::Any
> const &)
994 return cppu::acquire(new UnoControlImageControlModel(context
));
999 UnoImageControlControl::UnoImageControlControl()
1000 :maActionListeners( *this )
1002 // TODO: Where should I look for defaults?
1003 maComponentInfos
.nWidth
= 100;
1004 maComponentInfos
.nHeight
= 100;
1007 OUString
UnoImageControlControl::GetComponentServiceName() const
1009 return u
"fixedimage"_ustr
;
1012 void UnoImageControlControl::dispose()
1014 lang::EventObject aEvt
;
1015 aEvt
.Source
= getXWeak();
1016 maActionListeners
.disposeAndClear( aEvt
);
1017 UnoControl::dispose();
1020 sal_Bool
UnoImageControlControl::isTransparent()
1025 awt::Size
UnoImageControlControl::getMinimumSize( )
1027 return Impl_getMinimumSize();
1030 awt::Size
UnoImageControlControl::getPreferredSize( )
1032 return Impl_getPreferredSize();
1035 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1037 return Impl_calcAdjustedSize( rNewSize
);
1040 OUString
UnoImageControlControl::getImplementationName()
1042 return u
"stardiv.Toolkit.UnoImageControlControl"_ustr
;
1045 css::uno::Sequence
<OUString
> UnoImageControlControl::getSupportedServiceNames()
1047 const css::uno::Sequence
<OUString
> vals
{
1048 u
"com.sun.star.awt.UnoControlImageButton"_ustr
,
1049 u
"com.sun.star.awt.UnoControlImageControl"_ustr
,
1050 u
"stardiv.vcl.control.ImageButton"_ustr
,
1051 u
"stardiv.vcl.control.ImageControl"_ustr
1053 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1056 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1057 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1058 css::uno::XComponentContext
*,
1059 css::uno::Sequence
<css::uno::Any
> const &)
1061 return cppu::acquire(new UnoImageControlControl());
1066 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
1067 :GraphicControlModel( rxContext
)
1069 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXRadioButton
>();
1072 OUString
UnoControlRadioButtonModel::getServiceName()
1074 return u
"stardiv.vcl.controlmodel.RadioButton"_ustr
;
1077 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1081 case BASEPROPERTY_DEFAULTCONTROL
:
1082 return uno::Any( u
"stardiv.vcl.control.RadioButton"_ustr
);
1084 case BASEPROPERTY_VISUALEFFECT
:
1085 return uno::Any( sal_Int16(awt::VisualEffect::LOOK3D
) );
1088 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1091 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
1093 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1097 // beans::XMultiPropertySet
1098 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( )
1100 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1104 OUString
UnoControlRadioButtonModel::getImplementationName()
1106 return u
"stardiv.Toolkit.UnoControlRadioButtonModel"_ustr
;
1109 css::uno::Sequence
<OUString
>
1110 UnoControlRadioButtonModel::getSupportedServiceNames()
1112 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlRadioButtonModel"_ustr
, u
"stardiv.vcl.controlmodel.RadioButton"_ustr
};
1113 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
1116 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1117 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1118 css::uno::XComponentContext
*context
,
1119 css::uno::Sequence
<css::uno::Any
> const &)
1121 return cppu::acquire(new UnoControlRadioButtonModel(context
));
1126 UnoRadioButtonControl::UnoRadioButtonControl()
1127 :maItemListeners( *this )
1128 ,maActionListeners( *this )
1130 maComponentInfos
.nWidth
= 100;
1131 maComponentInfos
.nHeight
= 12;
1134 OUString
UnoRadioButtonControl::GetComponentServiceName() const
1136 return u
"radiobutton"_ustr
;
1139 void UnoRadioButtonControl::dispose()
1141 lang::EventObject aEvt
;
1142 aEvt
.Source
= getXWeak();
1143 maItemListeners
.disposeAndClear( aEvt
);
1144 UnoControlBase::dispose();
1148 sal_Bool
UnoRadioButtonControl::isTransparent()
1153 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1155 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1157 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1158 xRadioButton
->addItemListener( this );
1160 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1161 xButton
->setActionCommand( maActionCommand
);
1162 if ( maActionListeners
.getLength() )
1163 xButton
->addActionListener( &maActionListeners
);
1165 // as default, set the "AutoToggle" to true
1166 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1167 // have it enabled by default because of 85071)
1168 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1169 if ( xVclWindowPeer
.is() )
1170 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), css::uno::Any(true) );
1173 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1175 maItemListeners
.addInterface( l
);
1178 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1180 maItemListeners
.removeInterface( l
);
1183 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1185 maActionListeners
.addInterface( l
);
1186 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1188 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1189 xButton
->addActionListener( &maActionListeners
);
1193 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1195 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1197 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1198 xButton
->removeActionListener( &maActionListeners
);
1200 maActionListeners
.removeInterface( l
);
1203 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
)
1205 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1208 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
)
1210 maActionCommand
= rCommand
;
1211 if ( getPeer().is() )
1213 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1214 xButton
->setActionCommand( rCommand
);
1218 void UnoRadioButtonControl::setState( sal_Bool bOn
)
1220 sal_Int16 nState
= bOn
? 1 : 0;
1221 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(nState
), true );
1224 sal_Bool
UnoRadioButtonControl::getState()
1226 sal_Int16 nState
= 0;
1227 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1232 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1234 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1237 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1238 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1240 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1241 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1242 // isn't the case anymore: For instance, this method here gets called for the radio button
1243 // which is being implicitly _de_selected, too. This is pretty bad for compatibility.
1244 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1245 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1246 // all which matters here.
1248 if ( 1 == rEvent
.Selected
)
1250 if ( maItemListeners
.getLength() )
1251 maItemListeners
.itemStateChanged( rEvent
);
1253 // note that speaking strictly, this is wrong: When in 1.0.x, the user would have de-selected
1254 // a radio button _without_ selecting another one, this would have caused a notification.
1255 // With the change done here, this today won't cause a notification anymore.
1257 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1258 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1259 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1260 // to be inconsistent with.
1263 awt::Size
UnoRadioButtonControl::getMinimumSize( )
1265 return Impl_getMinimumSize();
1268 awt::Size
UnoRadioButtonControl::getPreferredSize( )
1270 return Impl_getPreferredSize();
1273 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1275 return Impl_calcAdjustedSize( rNewSize
);
1278 OUString
UnoRadioButtonControl::getImplementationName()
1280 return u
"stardiv.Toolkit.UnoRadioButtonControl"_ustr
;
1283 css::uno::Sequence
<OUString
> UnoRadioButtonControl::getSupportedServiceNames()
1285 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlRadioButton"_ustr
, u
"stardiv.vcl.control.RadioButton"_ustr
};
1286 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1289 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1290 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1291 css::uno::XComponentContext
*,
1292 css::uno::Sequence
<css::uno::Any
> const &)
1294 return cppu::acquire(new UnoRadioButtonControl());
1299 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1300 :GraphicControlModel( rxContext
)
1302 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXCheckBox
>();
1305 OUString
UnoControlCheckBoxModel::getServiceName()
1307 return u
"stardiv.vcl.controlmodel.CheckBox"_ustr
;
1310 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1314 case BASEPROPERTY_DEFAULTCONTROL
:
1315 return uno::Any( u
"stardiv.vcl.control.CheckBox"_ustr
);
1317 case BASEPROPERTY_VISUALEFFECT
:
1318 return uno::Any( sal_Int16(awt::VisualEffect::LOOK3D
) );
1321 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1324 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1326 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1330 // beans::XMultiPropertySet
1331 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( )
1333 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1337 OUString
UnoControlCheckBoxModel::getImplementationName()
1339 return u
"stardiv.Toolkit.UnoControlCheckBoxModel"_ustr
;
1342 css::uno::Sequence
<OUString
> UnoControlCheckBoxModel::getSupportedServiceNames()
1344 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlCheckBoxModel"_ustr
, u
"stardiv.vcl.controlmodel.CheckBox"_ustr
};
1345 return comphelper::concatSequences( GraphicControlModel::getSupportedServiceNames(), vals
);
1348 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1349 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1350 css::uno::XComponentContext
*context
,
1351 css::uno::Sequence
<css::uno::Any
> const &)
1353 return cppu::acquire(new UnoControlCheckBoxModel(context
));
1358 UnoCheckBoxControl::UnoCheckBoxControl()
1359 :maItemListeners( *this ), maActionListeners( *this )
1361 maComponentInfos
.nWidth
= 100;
1362 maComponentInfos
.nHeight
= 12;
1365 OUString
UnoCheckBoxControl::GetComponentServiceName() const
1367 return u
"checkbox"_ustr
;
1370 void UnoCheckBoxControl::dispose()
1372 lang::EventObject aEvt
;
1373 aEvt
.Source
= getXWeak();
1374 maItemListeners
.disposeAndClear( aEvt
);
1375 UnoControlBase::dispose();
1378 sal_Bool
UnoCheckBoxControl::isTransparent()
1383 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1385 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1387 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1388 xCheckBox
->addItemListener( this );
1390 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1391 xButton
->setActionCommand( maActionCommand
);
1392 if ( maActionListeners
.getLength() )
1393 xButton
->addActionListener( &maActionListeners
);
1396 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1398 maItemListeners
.addInterface( l
);
1401 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1403 maItemListeners
.removeInterface( l
);
1406 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1408 maActionListeners
.addInterface( l
);
1409 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1411 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1412 xButton
->addActionListener( &maActionListeners
);
1416 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1418 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1420 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1421 xButton
->removeActionListener( &maActionListeners
);
1423 maActionListeners
.removeInterface( l
);
1426 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
)
1428 maActionCommand
= rCommand
;
1429 if ( getPeer().is() )
1431 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1432 xButton
->setActionCommand( rCommand
);
1437 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
)
1439 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1442 void UnoCheckBoxControl::setState( sal_Int16 n
)
1444 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(n
), true );
1447 sal_Int16
UnoCheckBoxControl::getState()
1449 sal_Int16 nState
= 0;
1450 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1455 void UnoCheckBoxControl::enableTriState( sal_Bool b
)
1457 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), uno::Any(b
), true );
1460 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1462 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1464 if ( maItemListeners
.getLength() )
1465 maItemListeners
.itemStateChanged( rEvent
);
1468 awt::Size
UnoCheckBoxControl::getMinimumSize( )
1470 return Impl_getMinimumSize();
1473 awt::Size
UnoCheckBoxControl::getPreferredSize( )
1475 return Impl_getPreferredSize();
1478 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1480 return Impl_calcAdjustedSize( rNewSize
);
1483 OUString
UnoCheckBoxControl::getImplementationName()
1485 return u
"stardiv.Toolkit.UnoCheckBoxControl"_ustr
;
1488 css::uno::Sequence
<OUString
> UnoCheckBoxControl::getSupportedServiceNames()
1490 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlCheckBox"_ustr
, u
"stardiv.vcl.control.CheckBox"_ustr
};
1491 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1494 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1495 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1496 css::uno::XComponentContext
*,
1497 css::uno::Sequence
<css::uno::Any
> const &)
1499 return cppu::acquire(new UnoCheckBoxControl());
1504 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1505 :UnoControlModel( rxContext
)
1507 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXFixedHyperlink
>();
1510 OUString
UnoControlFixedHyperlinkModel::getServiceName()
1512 return u
"com.sun.star.awt.UnoControlFixedHyperlinkModel"_ustr
;
1515 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1517 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1519 return uno::Any( u
"com.sun.star.awt.UnoControlFixedHyperlink"_ustr
);
1521 else if ( nPropId
== BASEPROPERTY_BORDER
)
1523 return uno::Any(sal_Int16(0));
1525 else if ( nPropId
== BASEPROPERTY_URL
)
1527 return uno::Any( OUString() );
1530 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1533 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1535 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1539 // beans::XMultiPropertySet
1540 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( )
1542 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1546 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1547 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1548 css::uno::XComponentContext
*context
,
1549 css::uno::Sequence
<css::uno::Any
> const &)
1551 return cppu::acquire(new UnoControlFixedHyperlinkModel(context
));
1556 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1557 :maActionListeners( *this )
1559 maComponentInfos
.nWidth
= 100;
1560 maComponentInfos
.nHeight
= 12;
1563 OUString
UnoFixedHyperlinkControl::GetComponentServiceName() const
1565 return u
"fixedhyperlink"_ustr
;
1569 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
)
1571 uno::Any aRet
= ::cppu::queryInterface( rType
,
1572 static_cast< awt::XFixedHyperlink
* >(this),
1573 static_cast< awt::XLayoutConstrains
* >(this) );
1574 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1577 IMPL_IMPLEMENTATION_ID( UnoFixedHyperlinkControl
)
1579 // lang::XTypeProvider
1580 css::uno::Sequence
< css::uno::Type
> UnoFixedHyperlinkControl::getTypes()
1582 static const ::cppu::OTypeCollection
aTypeList(
1583 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
1584 cppu::UnoType
<awt::XFixedHyperlink
>::get(),
1585 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1586 UnoControlBase::getTypes()
1588 return aTypeList
.getTypes();
1591 sal_Bool
UnoFixedHyperlinkControl::isTransparent()
1596 void UnoFixedHyperlinkControl::setText( const OUString
& Text
)
1598 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1601 OUString
UnoFixedHyperlinkControl::getText()
1603 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1606 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
)
1608 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), uno::Any(URL
), true );
1611 OUString
UnoFixedHyperlinkControl::getURL( )
1613 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1616 void UnoFixedHyperlinkControl::setAlignment( sal_Int16 nAlign
)
1618 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(nAlign
), true );
1621 sal_Int16
UnoFixedHyperlinkControl::getAlignment()
1623 sal_Int16 nAlign
= 0;
1626 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1632 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( )
1634 return Impl_getMinimumSize();
1637 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( )
1639 return Impl_getPreferredSize();
1642 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1644 return Impl_calcAdjustedSize( rNewSize
);
1647 void UnoFixedHyperlinkControl::dispose()
1649 lang::EventObject aEvt
;
1650 aEvt
.Source
= getXWeak();
1651 maActionListeners
.disposeAndClear( aEvt
);
1652 UnoControlBase::dispose();
1655 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1657 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1659 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1660 if ( maActionListeners
.getLength() )
1661 xFixedHyperlink
->addActionListener( &maActionListeners
);
1664 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1666 maActionListeners
.addInterface( l
);
1667 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1669 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1670 xFixedHyperlink
->addActionListener( &maActionListeners
);
1674 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1676 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1678 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1679 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1681 maActionListeners
.removeInterface( l
);
1684 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1685 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1686 css::uno::XComponentContext
*,
1687 css::uno::Sequence
<css::uno::Any
> const &)
1689 return cppu::acquire(new UnoFixedHyperlinkControl());
1694 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1695 :UnoControlModel( rxContext
)
1697 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXFixedText
>();
1700 OUString
UnoControlFixedTextModel::getServiceName()
1702 return u
"stardiv.vcl.controlmodel.FixedText"_ustr
;
1705 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1707 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1709 return uno::Any( u
"stardiv.vcl.control.FixedText"_ustr
);
1711 else if ( nPropId
== BASEPROPERTY_BORDER
)
1713 return uno::Any(sal_Int16(0));
1716 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1719 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1721 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1725 // beans::XMultiPropertySet
1726 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( )
1728 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1732 OUString
UnoControlFixedTextModel::getImplementationName()
1734 return u
"stardiv.Toolkit.UnoControlFixedTextModel"_ustr
;
1737 css::uno::Sequence
<OUString
>
1738 UnoControlFixedTextModel::getSupportedServiceNames()
1740 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFixedTextModel"_ustr
, u
"stardiv.vcl.controlmodel.FixedText"_ustr
};
1741 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
1744 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1745 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1746 css::uno::XComponentContext
*context
,
1747 css::uno::Sequence
<css::uno::Any
> const &)
1749 return cppu::acquire(new UnoControlFixedTextModel(context
));
1754 UnoFixedTextControl::UnoFixedTextControl()
1756 maComponentInfos
.nWidth
= 100;
1757 maComponentInfos
.nHeight
= 12;
1760 OUString
UnoFixedTextControl::GetComponentServiceName() const
1762 return u
"fixedtext"_ustr
;
1766 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
)
1768 uno::Any aRet
= ::cppu::queryInterface( rType
,
1769 static_cast< awt::XFixedText
* >(this),
1770 static_cast< awt::XLayoutConstrains
* >(this) );
1771 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1774 IMPL_IMPLEMENTATION_ID( UnoFixedTextControl
)
1776 // lang::XTypeProvider
1777 css::uno::Sequence
< css::uno::Type
> UnoFixedTextControl::getTypes()
1779 static const ::cppu::OTypeCollection
aTypeList(
1780 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
1781 cppu::UnoType
<awt::XFixedText
>::get(),
1782 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1783 UnoControlBase::getTypes()
1785 return aTypeList
.getTypes();
1788 sal_Bool
UnoFixedTextControl::isTransparent()
1793 void UnoFixedTextControl::setText( const OUString
& Text
)
1795 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1798 OUString
UnoFixedTextControl::getText()
1800 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1803 void UnoFixedTextControl::setAlignment( sal_Int16 nAlign
)
1805 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(nAlign
), true );
1808 sal_Int16
UnoFixedTextControl::getAlignment()
1810 sal_Int16 nAlign
= 0;
1813 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1819 awt::Size
UnoFixedTextControl::getMinimumSize( )
1821 return Impl_getMinimumSize();
1824 awt::Size
UnoFixedTextControl::getPreferredSize( )
1826 return Impl_getPreferredSize();
1829 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1831 return Impl_calcAdjustedSize( rNewSize
);
1834 OUString
UnoFixedTextControl::getImplementationName()
1836 return u
"stardiv.Toolkit.UnoFixedTextControl"_ustr
;
1839 css::uno::Sequence
<OUString
> UnoFixedTextControl::getSupportedServiceNames()
1841 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFixedText"_ustr
, u
"stardiv.vcl.control.FixedText"_ustr
};
1842 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1845 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1846 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1847 css::uno::XComponentContext
*,
1848 css::uno::Sequence
<css::uno::Any
> const &)
1850 return cppu::acquire(new UnoFixedTextControl());
1855 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1856 :UnoControlModel( rxContext
)
1858 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1859 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1860 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1861 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1862 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1863 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1864 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1865 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1866 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1867 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1870 OUString
UnoControlGroupBoxModel::getServiceName()
1872 return u
"stardiv.vcl.controlmodel.GroupBox"_ustr
;
1875 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1877 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1879 return uno::Any(u
"stardiv.vcl.control.GroupBox"_ustr
);
1881 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1884 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1886 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
1890 // beans::XMultiPropertySet
1891 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( )
1893 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1897 OUString
UnoControlGroupBoxModel::getImplementationName()
1899 return u
"stardiv.Toolkit.UnoControlGroupBoxModel"_ustr
;
1902 css::uno::Sequence
<OUString
> UnoControlGroupBoxModel::getSupportedServiceNames()
1904 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlGroupBoxModel"_ustr
, u
"stardiv.vcl.controlmodel.GroupBox"_ustr
};
1905 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
1908 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1909 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
1910 css::uno::XComponentContext
*context
,
1911 css::uno::Sequence
<css::uno::Any
> const &)
1913 return cppu::acquire(new UnoControlGroupBoxModel(context
));
1918 UnoGroupBoxControl::UnoGroupBoxControl()
1920 maComponentInfos
.nWidth
= 100;
1921 maComponentInfos
.nHeight
= 100;
1924 OUString
UnoGroupBoxControl::GetComponentServiceName() const
1926 return u
"groupbox"_ustr
;
1929 sal_Bool
UnoGroupBoxControl::isTransparent()
1934 OUString
UnoGroupBoxControl::getImplementationName()
1936 return u
"stardiv.Toolkit.UnoGroupBoxControl"_ustr
;
1939 css::uno::Sequence
<OUString
> UnoGroupBoxControl::getSupportedServiceNames()
1941 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlGroupBox"_ustr
, u
"stardiv.vcl.control.GroupBox"_ustr
};
1942 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
1945 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1946 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
1947 css::uno::XComponentContext
*,
1948 css::uno::Sequence
<css::uno::Any
> const &)
1950 return cppu::acquire(new UnoGroupBoxControl());
1954 // = UnoControlListBoxModel_Data
1961 OUString ItemImageURL
;
1968 explicit ListItem( OUString i_ItemText
)
1969 :ItemText(std::move( i_ItemText
))
1976 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
1980 struct StripItemData
1982 UnoListItem
operator()( const ListItem
& i_rItem
)
1984 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
1990 struct UnoControlListBoxModel_Data
1992 explicit UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
1993 :m_bSettingLegacyProperty( false )
1994 ,m_rAntiImpl( i_rAntiImpl
)
1998 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
2000 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
2002 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) >= m_aListItems
.size() ) )
2003 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2004 return m_aListItems
[ i_nIndex
];
2007 ListItem
& getItem( const sal_Int32 i_nIndex
)
2009 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
2012 ListItem
& insertItem( const sal_Int32 i_nIndex
)
2014 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) > m_aListItems
.size() ) )
2015 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2016 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
2019 Sequence
< UnoListItem
> getAllItems() const
2021 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
2022 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
2026 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
2028 m_aListItems
= i_copySource
.m_aListItems
;
2031 void setAllItems( ::std::vector
< ListItem
>&& i_rItems
)
2033 m_aListItems
= std::move(i_rItems
);
2036 void removeItem( const sal_Int32 i_nIndex
)
2038 if ( ( i_nIndex
< 0 ) || ( o3tl::make_unsigned(i_nIndex
) >= m_aListItems
.size() ) )
2039 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2040 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
2043 void removeAllItems()
2045 std::vector
<ListItem
>().swap(m_aListItems
);
2049 bool m_bSettingLegacyProperty
;
2052 UnoControlListBoxModel
& m_rAntiImpl
;
2053 ::std::vector
< ListItem
> m_aListItems
;
2057 // = UnoControlListBoxModel
2060 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
2061 :UnoControlListBoxModel_Base( rxContext
)
2062 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2064 if ( i_mode
== ConstructDefault
)
2066 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXListBox
>();
2070 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
2071 :UnoControlListBoxModel_Base( i_rSource
)
2072 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2074 m_xData
->copyItems( *i_rSource
.m_xData
);
2076 UnoControlListBoxModel::~UnoControlListBoxModel()
2080 OUString
UnoControlListBoxModel::getImplementationName()
2082 return u
"stardiv.Toolkit.UnoControlListBoxModel"_ustr
;
2085 css::uno::Sequence
<OUString
> UnoControlListBoxModel::getSupportedServiceNames()
2087 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlListBoxModel"_ustr
, u
"stardiv.vcl.controlmodel.ListBox"_ustr
};
2088 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
2091 OUString
UnoControlListBoxModel::getServiceName()
2093 return u
"stardiv.vcl.controlmodel.ListBox"_ustr
;
2097 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2099 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2101 return uno::Any( u
"stardiv.vcl.control.ListBox"_ustr
);
2103 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2107 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
2109 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
2114 // beans::XMultiPropertySet
2115 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( )
2117 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2124 struct CreateListItem
2126 ListItem
operator()( const OUString
& i_rItemText
)
2128 return ListItem( i_rItemText
);
2134 void UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const uno::Any
& rValue
)
2136 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
2138 if ( nHandle
!= BASEPROPERTY_STRINGITEMLIST
)
2142 uno::Sequence
<sal_Int16
> aSeq
;
2143 setDependentFastPropertyValue( rGuard
, BASEPROPERTY_SELECTEDITEMS
, uno::Any(aSeq
) );
2145 if ( m_xData
->m_bSettingLegacyProperty
)
2148 // synchronize the legacy StringItemList property with our list items
2149 Sequence
< OUString
> aStringItemList
;
2151 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2152 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2154 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2156 std::cbegin(aStringItemList
),
2157 std::cend(aStringItemList
),
2161 m_xData
->setAllItems( std::move(aItems
) );
2163 // since an XItemListListener does not have a "all items modified" or some such method,
2164 // we simulate this by notifying removal of all items, followed by insertion of all new
2166 lang::EventObject aEvent
;
2167 aEvent
.Source
= *this;
2168 m_aItemListListeners
.notifyEach( rGuard
, &XItemListListener::itemListChanged
, aEvent
);
2169 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2170 // which is wrong for the above notifications ...
2174 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
2175 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const
2177 // dependencies we know:
2178 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2179 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
2180 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_TYPEDITEMLIST
2181 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_TYPEDITEMLIST
);
2183 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
2187 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount()
2189 std::unique_lock
aGuard( m_aMutex
);
2190 return m_xData
->getItemCount();
2194 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2196 std::unique_lock
aGuard( m_aMutex
);
2197 // SYNCHRONIZED ----->
2198 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2199 rItem
.ItemText
= i_rItemText
;
2200 rItem
.ItemImageURL
= i_rItemImageURL
;
2202 impl_handleInsert( aGuard
, i_nPosition
, i_rItemText
, i_rItemImageURL
);
2203 // <----- SYNCHRONIZED
2207 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2209 std::unique_lock
aGuard( m_aMutex
);
2210 // SYNCHRONIZED ----->
2211 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2212 rItem
.ItemText
= i_rItemText
;
2214 impl_handleInsert( aGuard
, i_nPosition
, i_rItemText
, ::std::optional
< OUString
>() );
2215 // <----- SYNCHRONIZED
2219 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2221 std::unique_lock
aGuard( m_aMutex
);
2222 // SYNCHRONIZED ----->
2223 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2224 rItem
.ItemImageURL
= i_rItemImageURL
;
2226 impl_handleInsert( aGuard
, i_nPosition
, ::std::optional
< OUString
>(), i_rItemImageURL
);
2227 // <----- SYNCHRONIZED
2231 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
)
2233 std::unique_lock
aGuard( m_aMutex
);
2234 // SYNCHRONIZED ----->
2235 m_xData
->removeItem( i_nPosition
);
2237 impl_handleRemove( i_nPosition
, aGuard
);
2238 // <----- SYNCHRONIZED
2242 void SAL_CALL
UnoControlListBoxModel::removeAllItems( )
2244 std::unique_lock
aGuard( m_aMutex
);
2245 // SYNCHRONIZED ----->
2246 m_xData
->removeAllItems();
2248 impl_handleRemove( -1, aGuard
);
2249 // <----- SYNCHRONIZED
2253 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2255 std::unique_lock
aGuard( m_aMutex
);
2256 // SYNCHRONIZED ----->
2257 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2258 rItem
.ItemText
= i_rItemText
;
2260 impl_handleModify( i_nPosition
, i_rItemText
, ::std::optional
< OUString
>(), aGuard
);
2261 // <----- SYNCHRONIZED
2265 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2267 std::unique_lock
aGuard( m_aMutex
);
2268 // SYNCHRONIZED ----->
2269 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2270 rItem
.ItemImageURL
= i_rItemImageURL
;
2272 impl_handleModify( i_nPosition
, ::std::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2273 // <----- SYNCHRONIZED
2277 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2279 std::unique_lock
aGuard( m_aMutex
);
2280 // SYNCHRONIZED ----->
2281 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2282 rItem
.ItemText
= i_rItemText
;
2283 rItem
.ItemImageURL
= i_rItemImageURL
;
2285 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2286 // <----- SYNCHRONIZED
2290 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
)
2292 std::unique_lock
aGuard( m_aMutex
);
2293 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2294 rItem
.ItemData
= i_rDataValue
;
2298 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
)
2300 std::unique_lock
aGuard( m_aMutex
);
2301 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2302 return rItem
.ItemText
;
2306 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
)
2308 std::unique_lock
aGuard( m_aMutex
);
2309 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2310 return rItem
.ItemImageURL
;
2314 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
)
2316 std::unique_lock
aGuard( m_aMutex
);
2317 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2318 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2322 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
)
2324 std::unique_lock
aGuard( m_aMutex
);
2325 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2326 return rItem
.ItemData
;
2330 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( )
2332 std::unique_lock
aGuard( m_aMutex
);
2333 return m_xData
->getAllItems();
2337 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2339 std::unique_lock
aGuard( m_aMutex
);
2340 if ( i_Listener
.is() )
2341 m_aItemListListeners
.addInterface( aGuard
, i_Listener
);
2345 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2347 std::unique_lock
aGuard( m_aMutex
);
2348 if ( i_Listener
.is() )
2349 m_aItemListListeners
.removeInterface( aGuard
, i_Listener
);
2353 void UnoControlListBoxModel::impl_getStringItemList( std::unique_lock
<std::mutex
>& rGuard
, ::std::vector
< OUString
>& o_rStringItems
) const
2355 Sequence
< OUString
> aStringItemList
;
2357 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2358 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2360 comphelper::sequenceToContainer(o_rStringItems
, aStringItemList
);
2364 void UnoControlListBoxModel::impl_setStringItemList( std::unique_lock
<std::mutex
>& rGuard
, const ::std::vector
< OUString
>& i_rStringItems
)
2366 Sequence
< OUString
> aStringItems( comphelper::containerToSequence(i_rStringItems
) );
2367 m_xData
->m_bSettingLegacyProperty
= true;
2370 setFastPropertyValueImpl( rGuard
, BASEPROPERTY_STRINGITEMLIST
, uno::Any( aStringItems
) );
2372 catch( const Exception
& )
2374 m_xData
->m_bSettingLegacyProperty
= false;
2377 m_xData
->m_bSettingLegacyProperty
= false;
2381 void UnoControlListBoxModel::impl_handleInsert( std::unique_lock
<std::mutex
>& rGuard
,
2382 const sal_Int32 i_nItemPosition
,
2383 const ::std::optional
< OUString
>& i_rItemText
,
2384 const ::std::optional
< OUString
>& i_rItemImageURL
)
2386 // SYNCHRONIZED ----->
2387 // sync with legacy StringItemList property
2388 ::std::vector
< OUString
> aStringItems
;
2389 impl_getStringItemList( rGuard
, aStringItems
);
2390 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2391 if ( o3tl::make_unsigned( i_nItemPosition
) <= aStringItems
.size() )
2393 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2394 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2397 impl_setStringItemList( rGuard
, aStringItems
);
2399 // notify ItemListListeners
2400 impl_notifyItemListEvent( rGuard
, i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2404 void UnoControlListBoxModel::impl_handleRemove(
2405 const sal_Int32 i_nItemPosition
,
2406 std::unique_lock
<std::mutex
>& i_rClearBeforeNotify
)
2408 // SYNCHRONIZED ----->
2409 const bool bAllItems
= ( i_nItemPosition
< 0 );
2410 // sync with legacy StringItemList property
2411 ::std::vector
< OUString
> aStringItems
;
2412 impl_getStringItemList( i_rClearBeforeNotify
, aStringItems
);
2415 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2416 if ( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size() )
2418 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2423 aStringItems
.resize(0);
2426 impl_setStringItemList( i_rClearBeforeNotify
, aStringItems
);
2428 // notify ItemListListeners
2431 EventObject
aEvent( *this );
2432 m_aItemListListeners
.notifyEach( i_rClearBeforeNotify
, &XItemListListener::allItemsRemoved
, aEvent
);
2436 impl_notifyItemListEvent( i_rClearBeforeNotify
, i_nItemPosition
, ::std::optional
< OUString
>(), ::std::optional
< OUString
>(),
2437 &XItemListListener::listItemRemoved
);
2442 void UnoControlListBoxModel::impl_handleModify(
2443 const sal_Int32 i_nItemPosition
, const ::std::optional
< OUString
>& i_rItemText
,
2444 const ::std::optional
< OUString
>& i_rItemImageURL
,
2445 std::unique_lock
<std::mutex
>& i_rClearBeforeNotify
)
2447 // SYNCHRONIZED ----->
2448 if ( !!i_rItemText
)
2450 // sync with legacy StringItemList property
2451 ::std::vector
< OUString
> aStringItems
;
2452 impl_getStringItemList( i_rClearBeforeNotify
, aStringItems
);
2453 OSL_ENSURE( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2454 if ( o3tl::make_unsigned( i_nItemPosition
) < aStringItems
.size() )
2456 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2459 impl_setStringItemList( i_rClearBeforeNotify
, aStringItems
);
2462 // notify ItemListListeners
2463 impl_notifyItemListEvent( i_rClearBeforeNotify
, i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2467 void UnoControlListBoxModel::impl_notifyItemListEvent(
2468 std::unique_lock
<std::mutex
>& rGuard
,
2469 const sal_Int32 i_nItemPosition
, const ::std::optional
< OUString
>& i_rItemText
,
2470 const ::std::optional
< OUString
>& i_rItemImageURL
,
2471 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2473 ItemListEvent aEvent
;
2474 aEvent
.Source
= *this;
2475 aEvent
.ItemPosition
= i_nItemPosition
;
2476 if ( !!i_rItemText
)
2478 aEvent
.ItemText
.IsPresent
= true;
2479 aEvent
.ItemText
.Value
= *i_rItemText
;
2481 if ( !!i_rItemImageURL
)
2483 aEvent
.ItemImageURL
.IsPresent
= true;
2484 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2487 m_aItemListListeners
.notifyEach( rGuard
, NotificationMethod
, aEvent
);
2490 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2491 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2492 css::uno::XComponentContext
*context
,
2493 css::uno::Sequence
<css::uno::Any
> const &)
2495 return cppu::acquire(new UnoControlListBoxModel(context
));
2500 UnoListBoxControl::UnoListBoxControl()
2501 :maActionListeners( *this )
2502 ,maItemListeners( *this )
2504 maComponentInfos
.nWidth
= 100;
2505 maComponentInfos
.nHeight
= 12;
2508 OUString
UnoListBoxControl::GetComponentServiceName() const
2510 return u
"listbox"_ustr
;
2513 OUString
UnoListBoxControl::getImplementationName()
2515 return u
"stardiv.Toolkit.UnoListBoxControl"_ustr
;
2518 css::uno::Sequence
<OUString
> UnoListBoxControl::getSupportedServiceNames()
2520 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlListBox"_ustr
, u
"stardiv.vcl.control.ListBox"_ustr
};
2521 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
2524 void UnoListBoxControl::dispose()
2526 lang::EventObject aEvt
;
2527 aEvt
.Source
= getXWeak();
2528 maActionListeners
.disposeAndClear( aEvt
);
2529 maItemListeners
.disposeAndClear( aEvt
);
2530 UnoControl::dispose();
2533 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2535 if ( getPeer().is() )
2537 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2538 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2540 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2541 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), uno::Any(aSeq
), false );
2545 void UnoListBoxControl::updateFromModel()
2547 UnoControlBase::updateFromModel();
2549 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2550 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2552 EventObject
aEvent( getModel() );
2553 xItemListListener
->itemListChanged( aEvent
);
2555 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2556 // already did this, our peer(s) can only legitimately set the selection after they have the string
2557 // item list, which we just notified with the itemListChanged call.
2558 const OUString
& sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2559 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2562 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2564 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2565 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2566 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2567 // will be forwarded to the peer, which will update itself accordingly.
2570 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2573 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
2575 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2577 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2578 xListBox
->addItemListener( this );
2580 if ( maActionListeners
.getLength() )
2581 xListBox
->addActionListener( &maActionListeners
);
2584 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2586 maActionListeners
.addInterface( l
);
2587 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2589 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2590 xListBox
->addActionListener( &maActionListeners
);
2594 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2596 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2598 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2599 xListBox
->removeActionListener( &maActionListeners
);
2601 maActionListeners
.removeInterface( l
);
2604 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2606 maItemListeners
.addInterface( l
);
2609 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2611 maItemListeners
.removeInterface( l
);
2614 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
2616 uno::Sequence
<OUString
> aSeq
{ aItem
};
2617 addItems( aSeq
, nPos
);
2620 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
2622 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2623 uno::Sequence
< OUString
> aSeq
;
2625 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
2626 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2627 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2629 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2631 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2634 // Items before the Paste-Position
2635 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
2638 it
= std::copy(aItems
.begin(), aItems
.end(), it
);
2640 // Rest of old Items
2641 std::copy(std::next(std::cbegin(aSeq
), nPos
), std::cend(aSeq
), it
);
2643 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2646 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
2648 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2649 uno::Sequence
< OUString
> aSeq
;
2651 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2652 if ( !(nOldLen
&& ( nPos
< nOldLen
)) )
2655 if ( nCount
> ( nOldLen
-nPos
) )
2656 nCount
= nOldLen
-nPos
;
2658 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2660 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2662 // Items before the Remove-Position
2663 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
2666 std::copy(std::next(std::cbegin(aSeq
), nPos
+ nCount
), std::cend(aSeq
), it
);
2668 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2671 sal_Int16
UnoListBoxControl::getItemCount()
2673 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2674 uno::Sequence
< OUString
> aSeq
;
2676 return static_cast<sal_Int16
>(aSeq
.getLength());
2679 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
)
2682 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2683 uno::Sequence
< OUString
> aSeq
;
2685 if ( nPos
< aSeq
.getLength() )
2690 uno::Sequence
< OUString
> UnoListBoxControl::getItems()
2692 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2693 uno::Sequence
< OUString
> aSeq
;
2698 sal_Int16
UnoListBoxControl::getSelectedItemPos()
2701 if ( getPeer().is() )
2703 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2704 n
= xListBox
->getSelectedItemPos();
2709 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos()
2711 uno::Sequence
<sal_Int16
> aSeq
;
2712 if ( getPeer().is() )
2714 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2715 aSeq
= xListBox
->getSelectedItemsPos();
2720 OUString
UnoListBoxControl::getSelectedItem()
2723 if ( getPeer().is() )
2725 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2726 aItem
= xListBox
->getSelectedItem();
2731 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems()
2733 uno::Sequence
< OUString
> aSeq
;
2734 if ( getPeer().is() )
2736 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2737 aSeq
= xListBox
->getSelectedItems();
2742 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
)
2744 if ( getPeer().is() )
2746 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2747 xListBox
->selectItemPos( nPos
, bSelect
);
2749 ImplUpdateSelectedItemsProperty();
2752 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
)
2754 if ( getPeer().is() )
2756 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2757 xListBox
->selectItemsPos( aPositions
, bSelect
);
2759 ImplUpdateSelectedItemsProperty();
2762 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
)
2764 if ( getPeer().is() )
2766 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2767 xListBox
->selectItem( aItem
, bSelect
);
2769 ImplUpdateSelectedItemsProperty();
2772 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
)
2774 if ( getPeer().is() )
2776 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2777 xListBox
->makeVisible( nEntry
);
2781 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
)
2783 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
2786 sal_Int16
UnoListBoxControl::getDropDownLineCount()
2788 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2791 sal_Bool
UnoListBoxControl::isMutipleMode()
2793 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2796 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
)
2798 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), uno::Any(bMulti
), true );
2801 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
2803 ImplUpdateSelectedItemsProperty();
2804 if ( maItemListeners
.getLength() )
2808 maItemListeners
.itemStateChanged( rEvent
);
2810 catch( const Exception
& )
2812 TOOLS_WARN_EXCEPTION( "toolkit", "UnoListBoxControl::itemStateChanged");
2817 awt::Size
UnoListBoxControl::getMinimumSize( )
2819 return Impl_getMinimumSize();
2822 awt::Size
UnoListBoxControl::getPreferredSize( )
2824 return Impl_getPreferredSize();
2827 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
2829 return Impl_calcAdjustedSize( rNewSize
);
2832 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
2834 return Impl_getMinimumSize( nCols
, nLines
);
2837 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
2839 Impl_getColumnsAndLines( nCols
, nLines
);
2842 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
2844 ::osl::MutexGuard
aGuard( GetMutex() );
2846 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2847 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2848 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2849 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2851 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2854 if ( xOldItems
.is() )
2855 xOldItems
->removeItemListListener( this );
2856 if ( xNewItems
.is() )
2857 xNewItems
->addItemListListener( this );
2862 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
2864 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2865 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2866 if ( xPeerListener
.is() )
2867 xPeerListener
->listItemInserted( i_rEvent
);
2870 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
2872 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2873 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
2874 if ( xPeerListener
.is() )
2875 xPeerListener
->listItemRemoved( i_rEvent
);
2878 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
2880 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2881 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
2882 if ( xPeerListener
.is() )
2883 xPeerListener
->listItemModified( i_rEvent
);
2886 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
2888 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2889 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
2890 if ( xPeerListener
.is() )
2891 xPeerListener
->allItemsRemoved( i_rEvent
);
2894 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
2896 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2897 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
2898 if ( xPeerListener
.is() )
2899 xPeerListener
->itemListChanged( i_rEvent
);
2902 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2903 stardiv_Toolkit_UnoListBoxControl_get_implementation(
2904 css::uno::XComponentContext
*,
2905 css::uno::Sequence
<css::uno::Any
> const &)
2907 return cppu::acquire(new UnoListBoxControl());
2912 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
2913 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
2915 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXComboBox
>();
2918 OUString
UnoControlComboBoxModel::getImplementationName()
2920 return u
"stardiv.Toolkit.UnoControlComboBoxModel"_ustr
;
2923 css::uno::Sequence
<OUString
> UnoControlComboBoxModel::getSupportedServiceNames()
2925 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlComboBoxModel"_ustr
, u
"stardiv.vcl.controlmodel.ComboBox"_ustr
};
2926 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
2929 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( )
2931 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2935 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
2937 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
2942 OUString
UnoControlComboBoxModel::getServiceName()
2944 return u
"stardiv.vcl.controlmodel.ComboBox"_ustr
;
2947 void UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nHandle
, const uno::Any
& rValue
)
2949 UnoControlModel::setFastPropertyValue_NoBroadcast( rGuard
, nHandle
, rValue
);
2951 if (nHandle
!= BASEPROPERTY_STRINGITEMLIST
|| m_xData
->m_bSettingLegacyProperty
)
2954 // synchronize the legacy StringItemList property with our list items
2955 Sequence
< OUString
> aStringItemList
;
2957 getFastPropertyValue( rGuard
, aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2958 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2960 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2962 std::cbegin(aStringItemList
),
2963 std::cend(aStringItemList
),
2967 m_xData
->setAllItems( std::move(aItems
) );
2969 // since an XItemListListener does not have a "all items modified" or some such method,
2970 // we simulate this by notifying removal of all items, followed by insertion of all new
2972 lang::EventObject aEvent
;
2973 aEvent
.Source
= *this;
2974 m_aItemListListeners
.notifyEach( rGuard
, &XItemListListener::itemListChanged
, aEvent
);
2977 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2979 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2981 return uno::Any( u
"stardiv.vcl.control.ComboBox"_ustr
);
2983 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2986 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2987 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
2988 css::uno::XComponentContext
*context
,
2989 css::uno::Sequence
<css::uno::Any
> const &)
2991 return cppu::acquire(new UnoControlComboBoxModel(context
));
2996 UnoComboBoxControl::UnoComboBoxControl()
2997 :maActionListeners( *this )
2998 ,maItemListeners( *this )
3000 maComponentInfos
.nWidth
= 100;
3001 maComponentInfos
.nHeight
= 12;
3004 OUString
UnoComboBoxControl::getImplementationName()
3006 return u
"stardiv.Toolkit.UnoComboBoxControl"_ustr
;
3009 css::uno::Sequence
<OUString
> UnoComboBoxControl::getSupportedServiceNames()
3011 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlComboBox"_ustr
, u
"stardiv.vcl.control.ComboBox"_ustr
};
3012 return comphelper::concatSequences( UnoEditControl::getSupportedServiceNames(), vals
);
3015 OUString
UnoComboBoxControl::GetComponentServiceName() const
3017 return u
"combobox"_ustr
;
3020 void UnoComboBoxControl::dispose()
3022 lang::EventObject aEvt
;
3023 aEvt
.Source
= getXWeak();
3024 maActionListeners
.disposeAndClear( aEvt
);
3025 maItemListeners
.disposeAndClear( aEvt
);
3026 UnoControl::dispose();
3028 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
)
3030 uno::Any aRet
= ::cppu::queryInterface( rType
,
3031 static_cast< awt::XComboBox
* >(this) );
3032 if ( !aRet
.hasValue() )
3034 aRet
= ::cppu::queryInterface( rType
,
3035 static_cast< awt::XItemListener
* >(this) );
3036 if ( !aRet
.hasValue() )
3038 aRet
= ::cppu::queryInterface( rType
,
3039 static_cast< awt::XItemListListener
* >(this) );
3042 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3045 IMPL_IMPLEMENTATION_ID( UnoComboBoxControl
)
3047 // lang::XTypeProvider
3048 css::uno::Sequence
< css::uno::Type
> UnoComboBoxControl::getTypes()
3050 static const ::cppu::OTypeCollection
aTypeList(
3051 cppu::UnoType
<awt::XComboBox
>::get(),
3052 cppu::UnoType
<awt::XItemListener
>::get(),
3053 cppu::UnoType
<awt::XItemListListener
>::get(),
3054 UnoEditControl::getTypes()
3056 return aTypeList
.getTypes();
3059 void UnoComboBoxControl::updateFromModel()
3061 UnoEditControl::updateFromModel();
3063 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
3064 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3066 EventObject
aEvent( getModel() );
3067 xItemListListener
->itemListChanged( aEvent
);
3069 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
3071 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
3072 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3073 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3074 // will be forwarded to the peer, which will update itself accordingly.
3077 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
3079 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3081 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3083 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3084 if ( maActionListeners
.getLength() )
3085 xComboBox
->addActionListener( &maActionListeners
);
3086 if ( maItemListeners
.getLength() )
3087 xComboBox
->addItemListener( &maItemListeners
);
3090 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3092 maActionListeners
.addInterface( l
);
3093 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3095 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3096 xComboBox
->addActionListener( &maActionListeners
);
3100 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3102 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3104 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3105 xComboBox
->removeActionListener( &maActionListeners
);
3107 maActionListeners
.removeInterface( l
);
3110 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3112 maItemListeners
.addInterface( l
);
3113 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3115 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3116 xComboBox
->addItemListener( &maItemListeners
);
3120 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3122 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3124 // This call is prettier than creating a Ref and calling query
3125 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3126 xComboBox
->removeItemListener( &maItemListeners
);
3128 maItemListeners
.removeInterface( l
);
3130 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
3132 if ( maItemListeners
.getLength() )
3136 maItemListeners
.itemStateChanged( rEvent
);
3138 catch( const Exception
& )
3140 TOOLS_WARN_EXCEPTION( "toolkit", "UnoComboBoxControl::itemStateChanged");
3144 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
3146 ::osl::MutexGuard
aGuard( GetMutex() );
3148 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3149 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3150 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3151 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3153 if ( !UnoEditControl::setModel( i_rModel
) )
3156 if ( xOldItems
.is() )
3157 xOldItems
->removeItemListListener( this );
3158 if ( xNewItems
.is() )
3159 xNewItems
->addItemListListener( this );
3164 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
3166 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3167 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3168 if ( xPeerListener
.is() )
3169 xPeerListener
->listItemInserted( i_rEvent
);
3172 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
3174 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3175 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3176 if ( xPeerListener
.is() )
3177 xPeerListener
->listItemRemoved( i_rEvent
);
3180 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
3182 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3183 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3184 if ( xPeerListener
.is() )
3185 xPeerListener
->listItemModified( i_rEvent
);
3188 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3190 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3191 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3192 if ( xPeerListener
.is() )
3193 xPeerListener
->allItemsRemoved( i_rEvent
);
3196 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3198 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3199 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3200 if ( xPeerListener
.is() )
3201 xPeerListener
->itemListChanged( i_rEvent
);
3204 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
3206 uno::Sequence
<OUString
> aSeq
{ aItem
};
3207 addItems( aSeq
, nPos
);
3210 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
3212 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3213 uno::Sequence
< OUString
> aSeq
;
3215 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
3216 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3217 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3219 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3221 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3224 // items before the insert position
3225 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
3228 it
= std::copy(aItems
.begin(), aItems
.end(), it
);
3230 // remainder of old items
3231 std::copy(std::next(std::cbegin(aSeq
), nPos
), std::cend(aSeq
), it
);
3233 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), Any(aNewSeq
), true );
3236 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
3238 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3239 uno::Sequence
< OUString
> aSeq
;
3241 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3242 if ( !nOldLen
|| ( nPos
>= nOldLen
) )
3245 if ( nCount
> ( nOldLen
-nPos
) )
3246 nCount
= nOldLen
-nPos
;
3248 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3250 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3252 // items before the deletion position
3253 auto it
= std::copy(std::cbegin(aSeq
), std::next(std::cbegin(aSeq
), nPos
), aNewSeq
.getArray());
3255 // remainder of old items
3256 std::copy(std::next(std::cbegin(aSeq
), nPos
+ nCount
), std::cend(aSeq
), it
);
3258 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
3261 sal_Int16
UnoComboBoxControl::getItemCount()
3263 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3264 uno::Sequence
< OUString
> aSeq
;
3266 return static_cast<sal_Int16
>(aSeq
.getLength());
3269 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
)
3272 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3273 uno::Sequence
< OUString
> aSeq
;
3275 if ( nPos
< aSeq
.getLength() )
3280 uno::Sequence
< OUString
> UnoComboBoxControl::getItems()
3282 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3283 uno::Sequence
< OUString
> aSeq
;
3288 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
)
3290 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
3293 sal_Int16
UnoComboBoxControl::getDropDownLineCount()
3295 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3298 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3299 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3300 css::uno::XComponentContext
*,
3301 css::uno::Sequence
<css::uno::Any
> const &)
3303 return cppu::acquire(new UnoComboBoxControl());
3307 // UnoSpinFieldControl
3309 UnoSpinFieldControl::UnoSpinFieldControl()
3310 :maSpinListeners( *this )
3316 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
)
3318 uno::Any aRet
= ::cppu::queryInterface( rType
,
3319 static_cast< awt::XSpinField
* >(this) );
3320 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3323 IMPL_IMPLEMENTATION_ID( UnoSpinFieldControl
)
3325 // lang::XTypeProvider
3326 css::uno::Sequence
< css::uno::Type
> UnoSpinFieldControl::getTypes()
3328 static const ::cppu::OTypeCollection
aTypeList(
3329 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3330 cppu::UnoType
<awt::XSpinField
>::get(),
3331 UnoEditControl::getTypes()
3333 return aTypeList
.getTypes();
3336 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3338 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3340 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3341 xField
->enableRepeat( mbRepeat
);
3342 if ( maSpinListeners
.getLength() )
3343 xField
->addSpinListener( &maSpinListeners
);
3346 // css::awt::XSpinField
3347 void UnoSpinFieldControl::addSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3349 maSpinListeners
.addInterface( l
);
3350 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3352 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3353 xField
->addSpinListener( &maSpinListeners
);
3357 void UnoSpinFieldControl::removeSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3359 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3361 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3362 xField
->removeSpinListener( &maSpinListeners
);
3364 maSpinListeners
.removeInterface( l
);
3367 void UnoSpinFieldControl::up()
3369 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3374 void UnoSpinFieldControl::down()
3376 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3381 void UnoSpinFieldControl::first()
3383 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3388 void UnoSpinFieldControl::last()
3390 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3395 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
)
3399 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3401 xField
->enableRepeat( bRepeat
);
3406 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3407 :UnoControlModel( rxContext
)
3409 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXDateField
>();
3412 OUString
UnoControlDateFieldModel::getServiceName()
3414 return u
"stardiv.vcl.controlmodel.DateField"_ustr
;
3417 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3419 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3421 return uno::Any( u
"stardiv.vcl.control.DateField"_ustr
);
3423 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3427 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3429 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3433 // beans::XMultiPropertySet
3434 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( )
3436 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3440 OUString
UnoControlDateFieldModel::getImplementationName()
3442 return u
"stardiv.Toolkit.UnoControlDateFieldModel"_ustr
;
3445 css::uno::Sequence
<OUString
>
3446 UnoControlDateFieldModel::getSupportedServiceNames()
3448 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlDateFieldModel"_ustr
, u
"stardiv.vcl.controlmodel.DateField"_ustr
};
3449 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3452 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3453 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3454 css::uno::XComponentContext
*context
,
3455 css::uno::Sequence
<css::uno::Any
> const &)
3457 return cppu::acquire(new UnoControlDateFieldModel(context
));
3462 UnoDateFieldControl::UnoDateFieldControl()
3464 mnFirst
= util::Date( 1, 1, 1900 );
3465 mnLast
= util::Date( 31, 12, 2200 );
3466 mbLongFormat
= TRISTATE_INDET
;
3469 OUString
UnoDateFieldControl::GetComponentServiceName() const
3471 return u
"datefield"_ustr
;
3475 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
)
3477 uno::Any aRet
= ::cppu::queryInterface( rType
,
3478 static_cast< awt::XDateField
* >(this) );
3479 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3482 IMPL_IMPLEMENTATION_ID( UnoDateFieldControl
)
3484 // lang::XTypeProvider
3485 css::uno::Sequence
< css::uno::Type
> UnoDateFieldControl::getTypes()
3487 static const ::cppu::OTypeCollection
aTypeList(
3488 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3489 cppu::UnoType
<awt::XDateField
>::get(),
3490 UnoSpinFieldControl::getTypes()
3492 return aTypeList
.getTypes();
3495 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3497 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3499 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3500 xField
->setFirst( mnFirst
);
3501 xField
->setLast( mnLast
);
3502 if ( mbLongFormat
!= TRISTATE_INDET
)
3503 xField
->setLongFormat( mbLongFormat
!= TRISTATE_FALSE
);
3507 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
)
3509 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3511 // also change the text property (#i25106#)
3514 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3515 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3518 // re-calc the Date property
3519 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3521 if ( xField
->isEmpty() )
3523 // the field says it's empty
3524 bool bEnforceFormat
= true;
3526 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3527 if ( !bEnforceFormat
)
3529 // and it also says that it is currently accepting invalid inputs, without
3530 // forcing it to a valid date
3531 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3532 if ( xText
.is() && xText
->getText().getLength() )
3533 // and in real, the text of the peer is *not* empty
3534 // -> simulate an invalid date, which is different from "no date"
3535 aValue
<<= util::Date();
3539 aValue
<<= xField
->getDate();
3541 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, false );
3543 // multiplex the event
3544 if ( GetTextListeners().getLength() )
3545 GetTextListeners().textChanged( e
);
3548 void UnoDateFieldControl::setDate( const util::Date
& Date
)
3550 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), uno::Any(Date
), true );
3553 util::Date
UnoDateFieldControl::getDate()
3555 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3558 void UnoDateFieldControl::setMin( const util::Date
& Date
)
3560 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), uno::Any(Date
), true );
3563 util::Date
UnoDateFieldControl::getMin()
3565 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3568 void UnoDateFieldControl::setMax( const util::Date
& Date
)
3570 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), uno::Any(Date
), true );
3573 util::Date
UnoDateFieldControl::getMax()
3575 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3578 void UnoDateFieldControl::setFirst( const util::Date
& Date
)
3581 if ( getPeer().is() )
3583 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3584 xField
->setFirst( Date
);
3588 util::Date
UnoDateFieldControl::getFirst()
3593 void UnoDateFieldControl::setLast( const util::Date
& Date
)
3596 if ( getPeer().is() )
3598 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3599 xField
->setLast( Date
);
3603 util::Date
UnoDateFieldControl::getLast()
3608 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
)
3610 mbLongFormat
= bLong
? TRISTATE_TRUE
: TRISTATE_FALSE
;
3611 if ( getPeer().is() )
3613 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3614 xField
->setLongFormat( bLong
);
3618 sal_Bool
UnoDateFieldControl::isLongFormat()
3620 return mbLongFormat
== TRISTATE_TRUE
;
3623 void UnoDateFieldControl::setEmpty()
3625 if ( getPeer().is() )
3627 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3632 sal_Bool
UnoDateFieldControl::isEmpty()
3634 bool bEmpty
= false;
3635 if ( getPeer().is() )
3637 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3638 bEmpty
= xField
->isEmpty();
3643 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
)
3645 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3648 sal_Bool
UnoDateFieldControl::isStrictFormat()
3650 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3653 OUString
UnoDateFieldControl::getImplementationName()
3655 return u
"stardiv.Toolkit.UnoDateFieldControl"_ustr
;
3658 css::uno::Sequence
<OUString
> UnoDateFieldControl::getSupportedServiceNames()
3660 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlDateField"_ustr
, u
"stardiv.vcl.control.DateField"_ustr
};
3661 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
3664 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3665 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3666 css::uno::XComponentContext
*,
3667 css::uno::Sequence
<css::uno::Any
> const &)
3669 return cppu::acquire(new UnoDateFieldControl());
3674 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3675 :UnoControlModel( rxContext
)
3677 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXTimeField
>();
3680 OUString
UnoControlTimeFieldModel::getServiceName()
3682 return u
"stardiv.vcl.controlmodel.TimeField"_ustr
;
3685 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3687 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3689 return uno::Any( u
"stardiv.vcl.control.TimeField"_ustr
);
3691 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3695 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3697 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3701 // beans::XMultiPropertySet
3702 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( )
3704 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3708 OUString
UnoControlTimeFieldModel::getImplementationName()
3710 return u
"stardiv.Toolkit.UnoControlTimeFieldModel"_ustr
;
3713 css::uno::Sequence
<OUString
>
3714 UnoControlTimeFieldModel::getSupportedServiceNames()
3716 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlTimeFieldModel"_ustr
, u
"stardiv.vcl.controlmodel.TimeField"_ustr
};
3717 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3720 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3721 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
3722 css::uno::XComponentContext
*context
,
3723 css::uno::Sequence
<css::uno::Any
> const &)
3725 return cppu::acquire(new UnoControlTimeFieldModel(context
));
3730 UnoTimeFieldControl::UnoTimeFieldControl()
3732 mnFirst
= util::Time( 0, 0, 0, 0, false );
3733 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3736 OUString
UnoTimeFieldControl::GetComponentServiceName() const
3738 return u
"timefield"_ustr
;
3742 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
)
3744 uno::Any aRet
= ::cppu::queryInterface( rType
,
3745 static_cast< awt::XTimeField
* >(this) );
3746 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3749 IMPL_IMPLEMENTATION_ID( UnoTimeFieldControl
)
3751 // lang::XTypeProvider
3752 css::uno::Sequence
< css::uno::Type
> UnoTimeFieldControl::getTypes()
3754 static const ::cppu::OTypeCollection
aTypeList(
3755 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3756 cppu::UnoType
<awt::XTimeField
>::get(),
3757 UnoSpinFieldControl::getTypes()
3759 return aTypeList
.getTypes();
3762 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3764 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3766 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3767 xField
->setFirst( mnFirst
);
3768 xField
->setLast( mnLast
);
3771 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
)
3773 // also change the text property (#i25106#)
3774 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3775 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3776 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3778 // re-calc the Time property
3779 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3781 if ( !xField
->isEmpty() )
3782 aValue
<<= xField
->getTime();
3783 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, false );
3785 // multiplex the event
3786 if ( GetTextListeners().getLength() )
3787 GetTextListeners().textChanged( e
);
3790 void UnoTimeFieldControl::setTime( const util::Time
& Time
)
3792 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), Any(Time
), true );
3795 util::Time
UnoTimeFieldControl::getTime()
3797 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3800 void UnoTimeFieldControl::setMin( const util::Time
& Time
)
3802 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), uno::Any(Time
), true );
3805 util::Time
UnoTimeFieldControl::getMin()
3807 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
3810 void UnoTimeFieldControl::setMax( const util::Time
& Time
)
3812 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), uno::Any(Time
), true );
3815 util::Time
UnoTimeFieldControl::getMax()
3817 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
3820 void UnoTimeFieldControl::setFirst( const util::Time
& Time
)
3823 if ( getPeer().is() )
3825 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3826 xField
->setFirst( mnFirst
);
3830 util::Time
UnoTimeFieldControl::getFirst()
3835 void UnoTimeFieldControl::setLast( const util::Time
& Time
)
3838 if ( getPeer().is() )
3840 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3841 xField
->setFirst( mnLast
);
3845 util::Time
UnoTimeFieldControl::getLast()
3850 void UnoTimeFieldControl::setEmpty()
3852 if ( getPeer().is() )
3854 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3859 sal_Bool
UnoTimeFieldControl::isEmpty()
3861 bool bEmpty
= false;
3862 if ( getPeer().is() )
3864 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3865 bEmpty
= xField
->isEmpty();
3870 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
)
3872 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3875 sal_Bool
UnoTimeFieldControl::isStrictFormat()
3877 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3880 OUString
UnoTimeFieldControl::getImplementationName()
3882 return u
"stardiv.Toolkit.UnoTimeFieldControl"_ustr
;
3885 css::uno::Sequence
<OUString
> UnoTimeFieldControl::getSupportedServiceNames()
3887 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlTimeField"_ustr
, u
"stardiv.vcl.control.TimeField"_ustr
};
3888 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
3891 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3892 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
3893 css::uno::XComponentContext
*,
3894 css::uno::Sequence
<css::uno::Any
> const &)
3896 return cppu::acquire(new UnoTimeFieldControl());
3901 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
3902 :UnoControlModel( rxContext
)
3904 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXNumericField
>();
3907 OUString
UnoControlNumericFieldModel::getServiceName()
3909 return u
"stardiv.vcl.controlmodel.NumericField"_ustr
;
3912 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3914 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3916 return uno::Any( u
"stardiv.vcl.control.NumericField"_ustr
);
3918 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3922 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
3924 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
3928 // beans::XMultiPropertySet
3929 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( )
3931 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3935 OUString
UnoControlNumericFieldModel::getImplementationName()
3937 return u
"stardiv.Toolkit.UnoControlNumericFieldModel"_ustr
;
3940 css::uno::Sequence
<OUString
>
3941 UnoControlNumericFieldModel::getSupportedServiceNames()
3943 const css::uno::Sequence
<OUString
> vals
{ u
"stardiv.vcl.controlmodel.NumericField"_ustr
, u
"com.sun.star.awt.UnoControlNumericFieldModel"_ustr
};
3944 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
3947 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3948 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
3949 css::uno::XComponentContext
*context
,
3950 css::uno::Sequence
<css::uno::Any
> const &)
3952 return cppu::acquire(new UnoControlNumericFieldModel(context
));
3957 UnoNumericFieldControl::UnoNumericFieldControl()
3960 mnLast
= 0x7FFFFFFF;
3963 OUString
UnoNumericFieldControl::GetComponentServiceName() const
3965 return u
"numericfield"_ustr
;
3969 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
)
3971 uno::Any aRet
= ::cppu::queryInterface( rType
,
3972 static_cast< awt::XNumericField
* >(this) );
3973 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3976 IMPL_IMPLEMENTATION_ID( UnoNumericFieldControl
)
3978 // lang::XTypeProvider
3979 css::uno::Sequence
< css::uno::Type
> UnoNumericFieldControl::getTypes()
3981 static const ::cppu::OTypeCollection
aTypeList(
3982 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
3983 cppu::UnoType
<awt::XNumericField
>::get(),
3984 UnoSpinFieldControl::getTypes()
3986 return aTypeList
.getTypes();
3989 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3991 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3993 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3994 xField
->setFirst( mnFirst
);
3995 xField
->setLast( mnLast
);
3999 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
)
4001 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4002 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4004 if ( GetTextListeners().getLength() )
4005 GetTextListeners().textChanged( e
);
4008 void UnoNumericFieldControl::setValue( double Value
)
4010 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(Value
), true );
4013 double UnoNumericFieldControl::getValue()
4015 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4018 void UnoNumericFieldControl::setMin( double Value
)
4020 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4023 double UnoNumericFieldControl::getMin()
4025 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4028 void UnoNumericFieldControl::setMax( double Value
)
4030 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4033 double UnoNumericFieldControl::getMax()
4035 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4038 void UnoNumericFieldControl::setFirst( double Value
)
4041 if ( getPeer().is() )
4043 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4044 xField
->setFirst( mnFirst
);
4048 double UnoNumericFieldControl::getFirst()
4053 void UnoNumericFieldControl::setLast( double Value
)
4056 if ( getPeer().is() )
4058 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4059 xField
->setLast( mnLast
);
4063 double UnoNumericFieldControl::getLast()
4068 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
)
4070 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4073 sal_Bool
UnoNumericFieldControl::isStrictFormat()
4075 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4078 OUString
UnoNumericFieldControl::getImplementationName()
4080 return u
"stardiv.Toolkit.UnoNumericFieldControl"_ustr
;
4083 css::uno::Sequence
<OUString
> UnoNumericFieldControl::getSupportedServiceNames()
4085 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlNumericField"_ustr
, u
"stardiv.vcl.control.NumericField"_ustr
};
4086 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4089 void UnoNumericFieldControl::setSpinSize( double Digits
)
4091 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4094 double UnoNumericFieldControl::getSpinSize()
4096 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4099 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
)
4101 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4104 sal_Int16
UnoNumericFieldControl::getDecimalDigits()
4106 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4109 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4110 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4111 css::uno::XComponentContext
*,
4112 css::uno::Sequence
<css::uno::Any
> const &)
4114 return cppu::acquire(new UnoNumericFieldControl());
4117 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
4118 :UnoControlModel( rxContext
)
4120 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<SVTXCurrencyField
>();
4123 OUString
UnoControlCurrencyFieldModel::getServiceName()
4125 return u
"stardiv.vcl.controlmodel.CurrencyField"_ustr
;
4128 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4130 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4132 return uno::Any( u
"stardiv.vcl.control.CurrencyField"_ustr
);
4134 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
4136 return uno::Any(false);
4139 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4142 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
4144 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4148 // beans::XMultiPropertySet
4149 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( )
4151 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4155 OUString
UnoControlCurrencyFieldModel::getImplementationName()
4157 return u
"stardiv.Toolkit.UnoControlCurrencyFieldModel"_ustr
;
4160 css::uno::Sequence
<OUString
>
4161 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4163 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlCurrencyFieldModel"_ustr
, u
"stardiv.vcl.controlmodel.CurrencyField"_ustr
};
4164 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4167 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4168 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4169 css::uno::XComponentContext
*context
,
4170 css::uno::Sequence
<css::uno::Any
> const &)
4172 return cppu::acquire(new UnoControlCurrencyFieldModel(context
));
4177 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4180 mnLast
= 0x7FFFFFFF;
4183 OUString
UnoCurrencyFieldControl::GetComponentServiceName() const
4185 return u
"longcurrencyfield"_ustr
;
4189 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
)
4191 uno::Any aRet
= ::cppu::queryInterface( rType
,
4192 static_cast< awt::XCurrencyField
* >(this) );
4193 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4196 IMPL_IMPLEMENTATION_ID( UnoCurrencyFieldControl
)
4198 // lang::XTypeProvider
4199 css::uno::Sequence
< css::uno::Type
> UnoCurrencyFieldControl::getTypes()
4201 static const ::cppu::OTypeCollection
aTypeList(
4202 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4203 cppu::UnoType
<awt::XCurrencyField
>::get(),
4204 UnoSpinFieldControl::getTypes()
4206 return aTypeList
.getTypes();
4209 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4211 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4213 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4214 xField
->setFirst( mnFirst
);
4215 xField
->setLast( mnLast
);
4218 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
)
4220 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4221 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4223 if ( GetTextListeners().getLength() )
4224 GetTextListeners().textChanged( e
);
4227 void UnoCurrencyFieldControl::setValue( double Value
)
4229 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), Any(Value
), true );
4232 double UnoCurrencyFieldControl::getValue()
4234 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4237 void UnoCurrencyFieldControl::setMin( double Value
)
4239 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4242 double UnoCurrencyFieldControl::getMin()
4244 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4247 void UnoCurrencyFieldControl::setMax( double Value
)
4249 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4252 double UnoCurrencyFieldControl::getMax()
4254 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4257 void UnoCurrencyFieldControl::setFirst( double Value
)
4260 if ( getPeer().is() )
4262 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4263 xField
->setFirst( mnFirst
);
4267 double UnoCurrencyFieldControl::getFirst()
4272 void UnoCurrencyFieldControl::setLast( double Value
)
4275 if ( getPeer().is() )
4277 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4278 xField
->setLast( mnLast
);
4282 double UnoCurrencyFieldControl::getLast()
4287 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
)
4289 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4292 sal_Bool
UnoCurrencyFieldControl::isStrictFormat()
4294 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4297 OUString
UnoCurrencyFieldControl::getImplementationName()
4299 return u
"stardiv.Toolkit.UnoCurrencyFieldControl"_ustr
;
4302 css::uno::Sequence
<OUString
>
4303 UnoCurrencyFieldControl::getSupportedServiceNames()
4305 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlCurrencyField"_ustr
, u
"stardiv.vcl.control.CurrencyField"_ustr
};
4306 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4309 void UnoCurrencyFieldControl::setSpinSize( double Digits
)
4311 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4314 double UnoCurrencyFieldControl::getSpinSize()
4316 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4319 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
)
4321 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4324 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits()
4326 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4329 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4330 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4331 css::uno::XComponentContext
*,
4332 css::uno::Sequence
<css::uno::Any
> const &)
4334 return cppu::acquire(new UnoCurrencyFieldControl());
4339 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4340 :UnoControlModel( rxContext
)
4342 UNO_CONTROL_MODEL_REGISTER_PROPERTIES
<VCLXPatternField
>();
4345 OUString
UnoControlPatternFieldModel::getServiceName()
4347 return u
"stardiv.vcl.controlmodel.PatternField"_ustr
;
4350 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4352 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4354 return uno::Any( u
"stardiv.vcl.control.PatternField"_ustr
);
4356 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4359 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4361 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4365 // beans::XMultiPropertySet
4366 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( )
4368 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4372 OUString
UnoControlPatternFieldModel::getImplementationName()
4374 return u
"stardiv.Toolkit.UnoControlPatternFieldModel"_ustr
;
4377 css::uno::Sequence
<OUString
>
4378 UnoControlPatternFieldModel::getSupportedServiceNames()
4380 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlPatternFieldModel"_ustr
, u
"stardiv.vcl.controlmodel.PatternField"_ustr
};
4381 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4384 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4385 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4386 css::uno::XComponentContext
*context
,
4387 css::uno::Sequence
<css::uno::Any
> const &)
4389 return cppu::acquire(new UnoControlPatternFieldModel(context
));
4394 UnoPatternFieldControl::UnoPatternFieldControl()
4398 OUString
UnoPatternFieldControl::GetComponentServiceName() const
4400 return u
"patternfield"_ustr
;
4403 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4405 sal_uInt16 nType
= GetPropertyId( rPropName
);
4406 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4408 // These masks cannot be set consecutively
4409 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4410 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4411 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4413 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4416 // same comment as in UnoControl::ImplSetPeerProperty - see there
4417 ImplCheckLocalize( Text
);
4418 xPF
->setString( Text
);
4419 xPF
->setMasks( EditMask
, LiteralMask
);
4423 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4428 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
)
4430 uno::Any aRet
= ::cppu::queryInterface( rType
,
4431 static_cast< awt::XPatternField
* >(this) );
4432 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4435 IMPL_IMPLEMENTATION_ID( UnoPatternFieldControl
)
4437 // lang::XTypeProvider
4438 css::uno::Sequence
< css::uno::Type
> UnoPatternFieldControl::getTypes()
4440 static const ::cppu::OTypeCollection
aTypeList(
4441 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4442 cppu::UnoType
<awt::XPatternField
>::get(),
4443 UnoSpinFieldControl::getTypes()
4445 return aTypeList
.getTypes();
4448 void UnoPatternFieldControl::setString( const OUString
& rString
)
4453 OUString
UnoPatternFieldControl::getString()
4458 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
)
4460 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), uno::Any(EditMask
), true );
4461 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), uno::Any(LiteralMask
), true );
4464 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
)
4466 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4467 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4470 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
)
4472 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4475 sal_Bool
UnoPatternFieldControl::isStrictFormat()
4477 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4480 OUString
UnoPatternFieldControl::getImplementationName()
4482 return u
"stardiv.Toolkit.UnoPatternFieldControl"_ustr
;
4485 css::uno::Sequence
<OUString
> UnoPatternFieldControl::getSupportedServiceNames()
4487 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlPatternField"_ustr
, u
"stardiv.vcl.control.PatternField"_ustr
};
4488 return comphelper::concatSequences( UnoSpinFieldControl::getSupportedServiceNames(), vals
);
4491 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4492 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4493 css::uno::XComponentContext
*,
4494 css::uno::Sequence
<css::uno::Any
> const &)
4496 return cppu::acquire(new UnoPatternFieldControl());
4501 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4502 :UnoControlModel( rxContext
)
4504 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4505 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4506 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4507 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4508 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4509 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4510 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4511 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4512 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4513 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4514 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4515 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4516 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4519 OUString
UnoControlProgressBarModel::getServiceName( )
4521 return u
"stardiv.vcl.controlmodel.ProgressBar"_ustr
;
4524 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4526 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4528 return uno::Any( u
"stardiv.vcl.control.ProgressBar"_ustr
);
4531 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4534 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4536 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4540 // beans::XMultiPropertySet
4541 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( )
4543 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4547 OUString
UnoControlProgressBarModel::getImplementationName()
4549 return u
"stardiv.Toolkit.UnoControlProgressBarModel"_ustr
;
4552 css::uno::Sequence
<OUString
>
4553 UnoControlProgressBarModel::getSupportedServiceNames()
4555 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlProgressBarModel"_ustr
, u
"stardiv.vcl.controlmodel.ProgressBar"_ustr
};
4556 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4559 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4560 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4561 css::uno::XComponentContext
*context
,
4562 css::uno::Sequence
<css::uno::Any
> const &)
4564 return cppu::acquire(new UnoControlProgressBarModel(context
));
4569 UnoProgressBarControl::UnoProgressBarControl()
4573 OUString
UnoProgressBarControl::GetComponentServiceName() const
4575 return u
"ProgressBar"_ustr
;
4579 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
)
4581 uno::Any aRet
= ::cppu::queryInterface( rType
,
4582 static_cast< awt::XProgressBar
* >(this) );
4583 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4586 IMPL_IMPLEMENTATION_ID( UnoProgressBarControl
)
4588 // lang::XTypeProvider
4589 css::uno::Sequence
< css::uno::Type
> UnoProgressBarControl::getTypes()
4591 static const ::cppu::OTypeCollection
aTypeList(
4592 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
4593 cppu::UnoType
<awt::XProgressBar
>::get(),
4594 UnoControlBase::getTypes()
4596 return aTypeList
.getTypes();
4599 // css::awt::XProgressBar
4600 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
)
4602 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), uno::Any(nColor
), true );
4605 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
)
4607 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), uno::Any(nColor
), true );
4610 void UnoProgressBarControl::setValue( sal_Int32 nValue
)
4612 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), uno::Any(nValue
), true );
4615 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
)
4622 // take correct min and max
4628 // change min and max
4633 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, true );
4634 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, true );
4637 sal_Int32
UnoProgressBarControl::getValue()
4639 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4642 OUString
UnoProgressBarControl::getImplementationName()
4644 return u
"stardiv.Toolkit.UnoProgressBarControl"_ustr
;
4647 css::uno::Sequence
<OUString
> UnoProgressBarControl::getSupportedServiceNames()
4649 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlProgressBar"_ustr
, u
"stardiv.vcl.control.ProgressBar"_ustr
};
4650 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
4653 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4654 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
4655 css::uno::XComponentContext
*,
4656 css::uno::Sequence
<css::uno::Any
> const &)
4658 return cppu::acquire(new UnoProgressBarControl());
4663 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4664 :UnoControlModel( rxContext
)
4666 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4667 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4668 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4669 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4670 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4671 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4672 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4673 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4674 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4675 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4678 OUString
UnoControlFixedLineModel::getServiceName( )
4680 return u
"stardiv.vcl.controlmodel.FixedLine"_ustr
;
4683 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4685 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4687 return uno::Any( u
"stardiv.vcl.control.FixedLine"_ustr
);
4689 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4692 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4694 static UnoPropertyArrayHelper
aHelper( ImplGetPropertyIds() );
4698 // beans::XMultiPropertySet
4699 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( )
4701 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4705 OUString
UnoControlFixedLineModel::getImplementationName()
4707 return u
"stardiv.Toolkit.UnoControlFixedLineModel"_ustr
;
4710 css::uno::Sequence
<OUString
>
4711 UnoControlFixedLineModel::getSupportedServiceNames()
4713 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFixedLineModel"_ustr
, u
"stardiv.vcl.controlmodel.FixedLine"_ustr
};
4714 return comphelper::concatSequences( UnoControlModel::getSupportedServiceNames(), vals
);
4717 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4718 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
4719 css::uno::XComponentContext
*context
,
4720 css::uno::Sequence
<css::uno::Any
> const &)
4722 return cppu::acquire(new UnoControlFixedLineModel(context
));
4727 UnoFixedLineControl::UnoFixedLineControl()
4729 maComponentInfos
.nWidth
= 100; // ??
4730 maComponentInfos
.nHeight
= 100; // ??
4733 OUString
UnoFixedLineControl::GetComponentServiceName() const
4735 return u
"FixedLine"_ustr
;
4738 sal_Bool
UnoFixedLineControl::isTransparent()
4743 OUString
UnoFixedLineControl::getImplementationName()
4745 return u
"stardiv.Toolkit.UnoFixedLineControl"_ustr
;
4748 css::uno::Sequence
<OUString
> UnoFixedLineControl::getSupportedServiceNames()
4750 const css::uno::Sequence
<OUString
> vals
{ u
"com.sun.star.awt.UnoControlFixedLine"_ustr
, u
"stardiv.vcl.control.FixedLine"_ustr
};
4751 return comphelper::concatSequences( UnoControlBase::getSupportedServiceNames(), vals
);
4754 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4755 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
4756 css::uno::XComponentContext
*,
4757 css::uno::Sequence
<css::uno::Any
> const &)
4759 return cppu::acquire(new UnoFixedLineControl());
4762 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */