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/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/awt/PosSize.hpp>
26 #include <com/sun/star/awt/VisualEffect.hpp>
27 #include <com/sun/star/awt/LineEndFormat.hpp>
28 #include <com/sun/star/graphic/GraphicProvider.hpp>
29 #include <com/sun/star/graphic/XGraphicProvider.hpp>
30 #include <com/sun/star/graphic/GraphicObject.hpp>
31 #include <com/sun/star/util/Date.hpp>
32 #include <com/sun/star/awt/ImageScaleMode.hpp>
35 #include <toolkit/controls/formattedcontrol.hxx>
36 #include <toolkit/controls/roadmapcontrol.hxx>
37 #include <toolkit/controls/unocontrols.hxx>
38 #include <toolkit/controls/stdtabcontroller.hxx>
39 #include <toolkit/helper/property.hxx>
40 #include <toolkit/helper/servicenames.hxx>
41 #include <toolkit/helper/macros.hxx>
44 #include <toolkit/awt/vclxwindows.hxx>
45 #include <cppuhelper/typeprovider.hxx>
46 #include <cppuhelper/queryinterface.hxx>
47 #include <comphelper/processfactory.hxx>
48 #include <vcl/wrkwin.hxx>
49 #include <vcl/svapp.hxx>
50 #include <vcl/edit.hxx>
51 #include <vcl/button.hxx>
52 #include <vcl/group.hxx>
53 #include <vcl/fixed.hxx>
54 #include <vcl/lstbox.hxx>
55 #include <vcl/combobox.hxx>
56 #include <tools/debug.hxx>
57 #include <tools/diagnose_ex.h>
58 #include <tools/date.hxx>
59 #include <tools/time.hxx>
63 #include <helper/imagealign.hxx>
64 #include <helper/unopropertyarrayhelper.hxx>
67 using namespace css::awt
;
68 using namespace css::lang
;
69 using namespace css::uno
;
70 using ::com::sun::star::graphic::XGraphic
;
71 using ::com::sun::star::uno::Reference
;
72 using namespace ::toolkit
;
74 uno::Reference
< graphic::XGraphic
>
75 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const OUString
& _rURL
)
77 xOutGraphicObj
= nullptr;
78 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
81 css::uno::Reference
< css::graphic::XGraphic
>
82 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
)
84 uno::Reference
< graphic::XGraphic
> xGraphic
;
85 if ( _rURL
.isEmpty() )
90 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
91 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
92 uno::Sequence
< beans::PropertyValue
> aMediaProperties(1);
93 aMediaProperties
[0].Name
= "URL";
94 aMediaProperties
[0].Value
<<= _rURL
;
95 xGraphic
= xProvider
->queryGraphic( aMediaProperties
);
97 catch (const Exception
&)
99 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
105 // class UnoControlEditModel
107 UnoControlEditModel::UnoControlEditModel( const Reference
< XComponentContext
>& rxContext
)
108 :UnoControlModel( rxContext
)
110 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit
);
113 OUString
UnoControlEditModel::getServiceName( )
115 return OUString::createFromAscii( szServiceName_UnoControlEditModel
);
118 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
124 case BASEPROPERTY_LINE_END_FORMAT
:
125 aReturn
<<= sal_Int16(awt::LineEndFormat::LINE_FEED
); // LF
127 case BASEPROPERTY_DEFAULTCONTROL
:
128 aReturn
<<= OUString::createFromAscii( szServiceName_UnoControlEdit
);
131 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
137 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
139 static UnoPropertyArrayHelper
* pHelper
= nullptr;
142 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
143 pHelper
= new UnoPropertyArrayHelper( aIDs
);
148 // beans::XMultiPropertySet
149 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( )
151 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
155 OUString
UnoControlEditModel::getImplementationName()
157 return OUString("stardiv.Toolkit.UnoControlEditModel");
160 css::uno::Sequence
<OUString
> UnoControlEditModel::getSupportedServiceNames()
162 auto s(UnoControlModel::getSupportedServiceNames());
163 s
.realloc(s
.getLength() + 2);
164 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlEditModel";
165 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Edit";
169 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
170 stardiv_Toolkit_UnoControlEditModel_get_implementation(
171 css::uno::XComponentContext
*context
,
172 css::uno::Sequence
<css::uno::Any
> const &)
174 return cppu::acquire(new UnoControlEditModel(context
));
178 // class UnoEditControl
180 UnoEditControl::UnoEditControl()
182 ,maTextListeners( *this )
184 ,mbSetTextInPeer( false )
185 ,mbSetMaxTextLenInPeer( false )
186 ,mbHasTextProperty( false )
188 maComponentInfos
.nWidth
= 100;
189 maComponentInfos
.nHeight
= 12;
191 mbSetMaxTextLenInPeer
= false;
194 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
)
196 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
197 if ( !aReturn
.hasValue() )
198 aReturn
= UnoEditControl_Base::queryInterface( rType
);
202 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
)
204 return UnoControlBase::queryInterface( rType
);
207 void SAL_CALL
UnoEditControl::acquire( ) throw ()
209 UnoControlBase::acquire();
212 void SAL_CALL
UnoEditControl::release( ) throw ()
214 UnoControlBase::release();
217 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
219 OUString
UnoEditControl::GetComponentServiceName()
221 // by default, we want a simple edit field
222 OUString
sName( "Edit" );
224 // but maybe we are to display multi-line text?
225 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
227 if ( ( aVal
>>= b
) && b
)
228 sName
= "MultiLineEdit";
233 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
)
235 bool bReturn
= UnoControlBase::setModel( _rModel
);
236 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
240 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
243 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
245 // #96986# use setText(), or text listener will not be called.
246 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
247 if ( xTextComponent
.is() )
251 ImplCheckLocalize( sText
);
252 xTextComponent
->setText( sText
);
258 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
261 void UnoEditControl::dispose()
263 lang::EventObject
aEvt( *this );
264 maTextListeners
.disposeAndClear( aEvt
);
265 UnoControl::dispose();
268 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
270 UnoControl::createPeer( rxToolkit
, rParentPeer
);
272 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
275 xText
->addTextListener( this );
277 if ( mbSetMaxTextLenInPeer
)
278 xText
->setMaxTextLen( mnMaxTextLen
);
279 if ( mbSetTextInPeer
)
280 xText
->setText( maText
);
284 void UnoEditControl::textChanged(const awt::TextEvent
& e
)
286 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
288 if ( mbHasTextProperty
)
290 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(xText
->getText()), false );
294 maText
= xText
->getText();
297 if ( maTextListeners
.getLength() )
298 maTextListeners
.textChanged( e
);
301 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
)
303 maTextListeners
.addInterface( l
);
306 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
)
308 maTextListeners
.removeInterface( l
);
311 void UnoEditControl::setText( const OUString
& aText
)
313 if ( mbHasTextProperty
)
315 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(aText
), true );
320 mbSetTextInPeer
= true;
321 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
323 xText
->setText( maText
);
326 // Setting the property to the VCLXWindow doesn't call textChanged
327 if ( maTextListeners
.getLength() )
329 awt::TextEvent aEvent
;
330 aEvent
.Source
= *this;
331 maTextListeners
.textChanged( aEvent
);
337 void lcl_normalize( awt::Selection
& _rSel
)
339 if ( _rSel
.Min
> _rSel
.Max
)
340 ::std::swap( _rSel
.Min
, _rSel
.Max
);
344 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
)
346 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
347 awt::Selection
aSelection( rSel
);
348 lcl_normalize( aSelection
);
350 // preserve the selection resp. cursor position
351 awt::Selection
aNewSelection( getSelection() );
352 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
353 // (not sure - looks uglier ...)
354 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
355 if ( aNewSelection
.Min
> aSelection
.Min
)
356 aNewSelection
.Min
-= nDeletedCharacters
;
357 if ( aNewSelection
.Max
> aSelection
.Max
)
358 aNewSelection
.Max
-= nDeletedCharacters
;
360 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
361 aNewSelection
.Min
= aNewSelection
.Max
;
364 OUString aOldText
= getText();
365 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
368 setSelection( aNewSelection
);
371 OUString
UnoEditControl::getText()
373 OUString aText
= maText
;
375 if ( mbHasTextProperty
)
376 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
379 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
381 aText
= xText
->getText();
387 OUString
UnoEditControl::getSelectedText()
390 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
392 sSelected
= xText
->getSelectedText();
397 void UnoEditControl::setSelection( const awt::Selection
& aSelection
)
399 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
401 xText
->setSelection( aSelection
);
404 awt::Selection
UnoEditControl::getSelection()
407 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
409 aSel
= xText
->getSelection();
413 sal_Bool
UnoEditControl::isEditable()
415 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
418 void UnoEditControl::setEditable( sal_Bool bEditable
)
420 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), uno::Any(!bEditable
), true );
423 sal_Int16
UnoEditControl::getMaxTextLen()
425 sal_Int16 nMaxLen
= mnMaxTextLen
;
427 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
428 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
433 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
)
435 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
437 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), uno::Any(nLen
), true );
442 mbSetMaxTextLenInPeer
= true;
443 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
445 xText
->setMaxTextLen( mnMaxTextLen
);
449 awt::Size
UnoEditControl::getMinimumSize( )
451 return Impl_getMinimumSize();
454 awt::Size
UnoEditControl::getPreferredSize( )
456 return Impl_getPreferredSize();
459 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
)
461 return Impl_calcAdjustedSize( rNewSize
);
464 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
466 return Impl_getMinimumSize( nCols
, nLines
);
469 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
471 Impl_getColumnsAndLines( nCols
, nLines
);
474 OUString
UnoEditControl::getImplementationName( )
476 return OUString( "stardiv.Toolkit.UnoEditControl" );
479 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames()
481 uno::Sequence
< OUString
> aNames
= UnoControlBase::getSupportedServiceNames( );
482 aNames
.realloc( aNames
.getLength() + 2 );
483 aNames
[ aNames
.getLength() - 2 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit
);
484 aNames
[ aNames
.getLength() - 1 ] = "stardiv.vcl.control.Edit";
488 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
489 stardiv_Toolkit_UnoEditControl_get_implementation(
490 css::uno::XComponentContext
*,
491 css::uno::Sequence
<css::uno::Any
> const &)
493 return cppu::acquire(new UnoEditControl());
497 // class UnoControlFileControlModel
499 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
500 :UnoControlModel( rxContext
)
502 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
503 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
504 ImplRegisterProperty( BASEPROPERTY_BORDER
);
505 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
506 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
507 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
508 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
509 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
510 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
511 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
512 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
513 ImplRegisterProperty( BASEPROPERTY_READONLY
);
514 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
515 ImplRegisterProperty( BASEPROPERTY_TEXT
);
516 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
517 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
518 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
519 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
522 OUString
UnoControlFileControlModel::getServiceName()
524 return OUString::createFromAscii( szServiceName_UnoControlFileControlModel
);
527 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
529 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
531 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFileControl
) );
533 return UnoControlModel::ImplGetDefaultValue( nPropId
);
536 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
538 static UnoPropertyArrayHelper
* pHelper
= nullptr;
541 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
542 pHelper
= new UnoPropertyArrayHelper( aIDs
);
547 // beans::XMultiPropertySet
548 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( )
550 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
554 OUString
UnoControlFileControlModel::getImplementationName()
556 return OUString("stardiv.Toolkit.UnoControlFileControlModel");
559 css::uno::Sequence
<OUString
>
560 UnoControlFileControlModel::getSupportedServiceNames()
562 auto s(UnoControlModel::getSupportedServiceNames());
563 s
.realloc(s
.getLength() + 2);
564 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControlModel";
565 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FileControl";
569 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
570 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
571 css::uno::XComponentContext
*context
,
572 css::uno::Sequence
<css::uno::Any
> const &)
574 return cppu::acquire(new UnoControlFileControlModel(context
));
578 // class UnoFileControl
580 UnoFileControl::UnoFileControl()
585 OUString
UnoFileControl::GetComponentServiceName()
587 return OUString("filecontrol");
590 OUString
UnoFileControl::getImplementationName()
592 return OUString("stardiv.Toolkit.UnoFileControl");
595 css::uno::Sequence
<OUString
> UnoFileControl::getSupportedServiceNames()
597 auto s(UnoEditControl::getSupportedServiceNames());
598 s
.realloc(s
.getLength() + 2);
599 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControl";
600 s
[s
.getLength() - 1] = "stardiv.vcl.control.FileControl";
604 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
605 stardiv_Toolkit_UnoFileControl_get_implementation(
606 css::uno::XComponentContext
*,
607 css::uno::Sequence
<css::uno::Any
> const &)
609 return cppu::acquire(new UnoFileControl());
613 // class GraphicControlModel
615 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
617 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
618 return uno::makeAny( uno::Reference
< graphic::XGraphic
>() );
620 return UnoControlModel::ImplGetDefaultValue( nPropId
);
623 void SAL_CALL
GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
)
625 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
627 // - ImageAlign and ImagePosition need to correspond to each other
628 // - Graphic and ImageURL need to correspond to each other
633 case BASEPROPERTY_IMAGEURL
:
634 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
636 mbAdjustingGraphic
= true;
638 OSL_VERIFY( rValue
>>= sImageURL
);
639 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC
, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
640 mbAdjustingGraphic
= false;
644 case BASEPROPERTY_GRAPHIC
:
645 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
647 mbAdjustingGraphic
= true;
648 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL
, uno::makeAny( OUString() ) );
649 mbAdjustingGraphic
= false;
653 case BASEPROPERTY_IMAGEALIGN
:
654 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
656 mbAdjustingImagePosition
= true;
657 sal_Int16 nUNOValue
= 0;
658 OSL_VERIFY( rValue
>>= nUNOValue
);
659 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION
, uno::makeAny( getExtendedImagePosition( nUNOValue
) ) );
660 mbAdjustingImagePosition
= false;
663 case BASEPROPERTY_IMAGEPOSITION
:
664 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
666 mbAdjustingImagePosition
= true;
667 sal_Int16 nUNOValue
= 0;
668 OSL_VERIFY( rValue
>>= nUNOValue
);
669 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN
, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
670 mbAdjustingImagePosition
= false;
675 catch( const css::uno::Exception
& )
677 DBG_UNHANDLED_EXCEPTION("toolkit.controls");
678 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
679 mbAdjustingImagePosition
= false;
684 // class UnoControlButtonModel
686 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
687 :GraphicControlModel( rxContext
)
689 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton
);
691 osl_atomic_increment( &m_refCount
);
693 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
694 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
695 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
697 osl_atomic_decrement( &m_refCount
);
700 OUString
UnoControlButtonModel::getServiceName()
702 return OUString::createFromAscii( szServiceName_UnoControlButtonModel
);
705 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
709 case BASEPROPERTY_DEFAULTCONTROL
:
710 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton
) );
711 case BASEPROPERTY_TOGGLE
:
712 return uno::makeAny( false );
713 case BASEPROPERTY_ALIGN
:
714 return uno::makeAny( sal_Int16(PROPERTY_ALIGN_CENTER
) );
715 case BASEPROPERTY_FOCUSONCLICK
:
716 return uno::makeAny( true );
719 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
722 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
724 static UnoPropertyArrayHelper
* pHelper
= nullptr;
727 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
728 pHelper
= new UnoPropertyArrayHelper( aIDs
);
733 // beans::XMultiPropertySet
734 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( )
736 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
740 OUString
UnoControlButtonModel::getImplementationName()
742 return OUString("stardiv.Toolkit.UnoControlButtonModel");
745 css::uno::Sequence
<OUString
> UnoControlButtonModel::getSupportedServiceNames()
747 auto s(GraphicControlModel::getSupportedServiceNames());
748 s
.realloc(s
.getLength() + 2);
749 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButtonModel";
750 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Button";
754 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
755 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
756 css::uno::XComponentContext
*context
,
757 css::uno::Sequence
<css::uno::Any
> const &)
759 return cppu::acquire(new UnoControlButtonModel(context
));
763 // class UnoButtonControl
765 UnoButtonControl::UnoButtonControl()
766 :UnoButtonControl_Base()
767 ,maActionListeners( *this )
768 ,maItemListeners( *this )
770 maComponentInfos
.nWidth
= 50;
771 maComponentInfos
.nHeight
= 14;
774 OUString
UnoButtonControl::GetComponentServiceName()
776 OUString
aName( "pushbutton" );
777 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
778 sal_Int16 n
= sal_Int16();
779 if ( ( aVal
>>= n
) && n
)
781 // Use PushButtonType later when available...
784 case 1 /*PushButtonType::OK*/: aName
= "okbutton";
786 case 2 /*PushButtonType::CANCEL*/: aName
= "cancelbutton";
788 case 3 /*PushButtonType::HELP*/: aName
= "helpbutton";
792 OSL_FAIL( "Unknown Button Type!" );
799 void UnoButtonControl::dispose()
801 lang::EventObject aEvt
;
802 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
803 maActionListeners
.disposeAndClear( aEvt
);
804 maItemListeners
.disposeAndClear( aEvt
);
805 UnoControlBase::dispose();
808 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
810 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
812 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
813 xButton
->setActionCommand( maActionCommand
);
814 if ( maActionListeners
.getLength() )
815 xButton
->addActionListener( &maActionListeners
);
817 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
818 if ( xPushButton
.is() )
819 xPushButton
->addItemListener( this );
822 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
824 maActionListeners
.addInterface( l
);
825 if( getPeer().is() && maActionListeners
.getLength() == 1 )
827 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
828 xButton
->addActionListener( &maActionListeners
);
832 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
834 if( getPeer().is() && maActionListeners
.getLength() == 1 )
836 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
837 xButton
->removeActionListener( &maActionListeners
);
839 maActionListeners
.removeInterface( l
);
842 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
844 maItemListeners
.addInterface( l
);
847 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
849 maItemListeners
.removeInterface( l
);
852 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
)
854 UnoControlBase::disposing( Source
);
857 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
860 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
863 ItemEvent
aEvent( rEvent
);
864 aEvent
.Source
= *this;
865 maItemListeners
.itemStateChanged( aEvent
);
868 void UnoButtonControl::setLabel( const OUString
& rLabel
)
870 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
873 void UnoButtonControl::setActionCommand( const OUString
& rCommand
)
875 maActionCommand
= rCommand
;
876 if ( getPeer().is() )
878 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
879 xButton
->setActionCommand( rCommand
);
883 awt::Size
UnoButtonControl::getMinimumSize( )
885 return Impl_getMinimumSize();
888 awt::Size
UnoButtonControl::getPreferredSize( )
890 return Impl_getPreferredSize();
893 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
895 return Impl_calcAdjustedSize( rNewSize
);
898 OUString
UnoButtonControl::getImplementationName()
900 return OUString("stardiv.Toolkit.UnoButtonControl");
903 css::uno::Sequence
<OUString
> UnoButtonControl::getSupportedServiceNames()
905 auto s(UnoControlBase::getSupportedServiceNames());
906 s
.realloc(s
.getLength() + 2);
907 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButton";
908 s
[s
.getLength() - 1] = "stardiv.vcl.control.Button";
912 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
913 stardiv_Toolkit_UnoButtonControl_get_implementation(
914 css::uno::XComponentContext
*,
915 css::uno::Sequence
<css::uno::Any
> const &)
917 return cppu::acquire(new UnoButtonControl());
921 // class UnoControlImageControlModel
923 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
924 :GraphicControlModel( rxContext
)
925 ,mbAdjustingImageScaleMode( false )
927 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl
);
930 OUString
UnoControlImageControlModel::getServiceName()
932 return OUString::createFromAscii( szServiceName_UnoControlImageControlModel
);
935 OUString
UnoControlImageControlModel::getImplementationName()
937 return OUString("stardiv.Toolkit.UnoControlImageControlModel");
940 css::uno::Sequence
<OUString
>
941 UnoControlImageControlModel::getSupportedServiceNames()
943 auto s(GraphicControlModel::getSupportedServiceNames());
944 s
.realloc(s
.getLength() + 4);
945 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButtonModel";
946 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControlModel";
947 s
[s
.getLength() - 2] = "stardiv.vcl.controlmodel.ImageButton";
948 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ImageControl";
952 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
954 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
955 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl
) );
957 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
958 return makeAny( awt::ImageScaleMode::ANISOTROPIC
);
960 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
963 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
965 static UnoPropertyArrayHelper
* pHelper
= nullptr;
968 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
969 pHelper
= new UnoPropertyArrayHelper( aIDs
);
974 // beans::XMultiPropertySet
975 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( )
977 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
981 void SAL_CALL
UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
983 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
985 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
990 case BASEPROPERTY_IMAGE_SCALE_MODE
:
991 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
993 mbAdjustingImageScaleMode
= true;
994 sal_Int16
nScaleMode( awt::ImageScaleMode::ANISOTROPIC
);
995 OSL_VERIFY( _rValue
>>= nScaleMode
);
996 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE
, uno::makeAny( nScaleMode
!= awt::ImageScaleMode::NONE
) );
997 mbAdjustingImageScaleMode
= false;
1000 case BASEPROPERTY_SCALEIMAGE
:
1001 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
1003 mbAdjustingImageScaleMode
= true;
1005 OSL_VERIFY( _rValue
>>= bScale
);
1006 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE
, uno::makeAny( bScale
? awt::ImageScaleMode::ANISOTROPIC
: awt::ImageScaleMode::NONE
) );
1007 mbAdjustingImageScaleMode
= false;
1012 catch( const Exception
& )
1014 mbAdjustingImageScaleMode
= false;
1019 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1020 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
1021 css::uno::XComponentContext
*context
,
1022 css::uno::Sequence
<css::uno::Any
> const &)
1024 return cppu::acquire(new UnoControlImageControlModel(context
));
1028 // class UnoImageControlControl
1030 UnoImageControlControl::UnoImageControlControl()
1031 :UnoImageControlControl_Base()
1032 ,maActionListeners( *this )
1034 // TODO: Where should I look for defaults?
1035 maComponentInfos
.nWidth
= 100;
1036 maComponentInfos
.nHeight
= 100;
1039 OUString
UnoImageControlControl::GetComponentServiceName()
1041 return OUString("fixedimage");
1044 void UnoImageControlControl::dispose()
1046 lang::EventObject aEvt
;
1047 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1048 maActionListeners
.disposeAndClear( aEvt
);
1049 UnoControl::dispose();
1052 sal_Bool
UnoImageControlControl::isTransparent()
1057 awt::Size
UnoImageControlControl::getMinimumSize( )
1059 return Impl_getMinimumSize();
1062 awt::Size
UnoImageControlControl::getPreferredSize( )
1064 return Impl_getPreferredSize();
1067 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1069 return Impl_calcAdjustedSize( rNewSize
);
1072 OUString
UnoImageControlControl::getImplementationName()
1074 return OUString("stardiv.Toolkit.UnoImageControlControl");
1077 css::uno::Sequence
<OUString
> UnoImageControlControl::getSupportedServiceNames()
1079 auto s(UnoControlBase::getSupportedServiceNames());
1080 s
.realloc(s
.getLength() + 4);
1081 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButton";
1082 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControl";
1083 s
[s
.getLength() - 2] = "stardiv.vcl.control.ImageButton";
1084 s
[s
.getLength() - 1] = "stardiv.vcl.control.ImageControl";
1088 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1089 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1090 css::uno::XComponentContext
*,
1091 css::uno::Sequence
<css::uno::Any
> const &)
1093 return cppu::acquire(new UnoImageControlControl());
1097 // class UnoControlRadioButtonModel
1099 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
1100 :GraphicControlModel( rxContext
)
1102 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton
);
1105 OUString
UnoControlRadioButtonModel::getServiceName()
1107 return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel
);
1110 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1114 case BASEPROPERTY_DEFAULTCONTROL
:
1115 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton
) );
1117 case BASEPROPERTY_VISUALEFFECT
:
1118 return uno::makeAny( sal_Int16(awt::VisualEffect::LOOK3D
) );
1121 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1124 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
1126 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1129 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1130 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1135 // beans::XMultiPropertySet
1136 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( )
1138 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1142 OUString
UnoControlRadioButtonModel::getImplementationName()
1144 return OUString("stardiv.Toolkit.UnoControlRadioButtonModel");
1147 css::uno::Sequence
<OUString
>
1148 UnoControlRadioButtonModel::getSupportedServiceNames()
1150 auto s(GraphicControlModel::getSupportedServiceNames());
1151 s
.realloc(s
.getLength() + 2);
1152 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButtonModel";
1153 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.RadioButton";
1157 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1158 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1159 css::uno::XComponentContext
*context
,
1160 css::uno::Sequence
<css::uno::Any
> const &)
1162 return cppu::acquire(new UnoControlRadioButtonModel(context
));
1166 // class UnoRadioButtonControl
1168 UnoRadioButtonControl::UnoRadioButtonControl()
1169 :UnoRadioButtonControl_Base()
1170 ,maItemListeners( *this )
1171 ,maActionListeners( *this )
1173 maComponentInfos
.nWidth
= 100;
1174 maComponentInfos
.nHeight
= 12;
1177 OUString
UnoRadioButtonControl::GetComponentServiceName()
1179 return OUString("radiobutton");
1182 void UnoRadioButtonControl::dispose()
1184 lang::EventObject aEvt
;
1185 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1186 maItemListeners
.disposeAndClear( aEvt
);
1187 UnoControlBase::dispose();
1191 sal_Bool
UnoRadioButtonControl::isTransparent()
1196 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1198 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1200 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1201 xRadioButton
->addItemListener( this );
1203 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1204 xButton
->setActionCommand( maActionCommand
);
1205 if ( maActionListeners
.getLength() )
1206 xButton
->addActionListener( &maActionListeners
);
1208 // as default, set the "AutoToggle" to true
1209 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1210 // have it enabled by default because of 85071)
1211 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1212 if ( xVclWindowPeer
.is() )
1213 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), css::uno::Any(true) );
1216 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1218 maItemListeners
.addInterface( l
);
1221 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1223 maItemListeners
.removeInterface( l
);
1226 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1228 maActionListeners
.addInterface( l
);
1229 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1231 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1232 xButton
->addActionListener( &maActionListeners
);
1236 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1238 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1240 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1241 xButton
->removeActionListener( &maActionListeners
);
1243 maActionListeners
.removeInterface( l
);
1246 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
)
1248 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1251 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
)
1253 maActionCommand
= rCommand
;
1254 if ( getPeer().is() )
1256 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1257 xButton
->setActionCommand( rCommand
);
1261 void UnoRadioButtonControl::setState( sal_Bool bOn
)
1263 sal_Int16 nState
= bOn
? 1 : 0;
1264 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(nState
), true );
1267 sal_Bool
UnoRadioButtonControl::getState()
1269 sal_Int16 nState
= 0;
1270 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1275 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1277 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1280 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1281 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1283 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1284 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1285 // isn't the case anymore: For instance, this method here gets called for the radio button
1286 // which is being implicitly _de_selected, too. This is pretty bad for compatibility.
1287 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1288 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1289 // all which matters here.
1291 if ( 1 == rEvent
.Selected
)
1293 if ( maItemListeners
.getLength() )
1294 maItemListeners
.itemStateChanged( rEvent
);
1296 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1297 // a radio button _without_ selecting another one, this would have caused a notification.
1298 // With the change done here, this today won't cause a notification anymore.
1300 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1301 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1302 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1303 // to be inconsistent with.
1306 awt::Size
UnoRadioButtonControl::getMinimumSize( )
1308 return Impl_getMinimumSize();
1311 awt::Size
UnoRadioButtonControl::getPreferredSize( )
1313 return Impl_getPreferredSize();
1316 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1318 return Impl_calcAdjustedSize( rNewSize
);
1321 OUString
UnoRadioButtonControl::getImplementationName()
1323 return OUString("stardiv.Toolkit.UnoRadioButtonControl");
1326 css::uno::Sequence
<OUString
> UnoRadioButtonControl::getSupportedServiceNames()
1328 auto s(UnoControlBase::getSupportedServiceNames());
1329 s
.realloc(s
.getLength() + 2);
1330 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButton";
1331 s
[s
.getLength() - 1] = "stardiv.vcl.control.RadioButton";
1335 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1336 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1337 css::uno::XComponentContext
*,
1338 css::uno::Sequence
<css::uno::Any
> const &)
1340 return cppu::acquire(new UnoRadioButtonControl());
1344 // class UnoControlCheckBoxModel
1346 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1347 :GraphicControlModel( rxContext
)
1349 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox
);
1352 OUString
UnoControlCheckBoxModel::getServiceName()
1354 return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel
);
1357 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1361 case BASEPROPERTY_DEFAULTCONTROL
:
1362 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox
) );
1364 case BASEPROPERTY_VISUALEFFECT
:
1365 return uno::makeAny( sal_Int16(awt::VisualEffect::LOOK3D
) );
1368 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1371 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1373 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1376 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1377 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1382 // beans::XMultiPropertySet
1383 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( )
1385 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1389 OUString
UnoControlCheckBoxModel::getImplementationName()
1391 return OUString( "stardiv.Toolkit.UnoControlCheckBoxModel");
1394 css::uno::Sequence
<OUString
> UnoControlCheckBoxModel::getSupportedServiceNames()
1396 auto s(GraphicControlModel::getSupportedServiceNames());
1397 s
.realloc(s
.getLength() + 2);
1398 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBoxModel";
1399 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CheckBox";
1403 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1404 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1405 css::uno::XComponentContext
*context
,
1406 css::uno::Sequence
<css::uno::Any
> const &)
1408 return cppu::acquire(new UnoControlCheckBoxModel(context
));
1412 // class UnoCheckBoxControl
1414 UnoCheckBoxControl::UnoCheckBoxControl()
1415 :UnoCheckBoxControl_Base()
1416 ,maItemListeners( *this ), maActionListeners( *this )
1418 maComponentInfos
.nWidth
= 100;
1419 maComponentInfos
.nHeight
= 12;
1422 OUString
UnoCheckBoxControl::GetComponentServiceName()
1424 return OUString("checkbox");
1427 void UnoCheckBoxControl::dispose()
1429 lang::EventObject aEvt
;
1430 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1431 maItemListeners
.disposeAndClear( aEvt
);
1432 UnoControlBase::dispose();
1435 sal_Bool
UnoCheckBoxControl::isTransparent()
1440 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1442 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1444 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1445 xCheckBox
->addItemListener( this );
1447 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1448 xButton
->setActionCommand( maActionCommand
);
1449 if ( maActionListeners
.getLength() )
1450 xButton
->addActionListener( &maActionListeners
);
1453 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1455 maItemListeners
.addInterface( l
);
1458 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1460 maItemListeners
.removeInterface( l
);
1463 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1465 maActionListeners
.addInterface( l
);
1466 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1468 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1469 xButton
->addActionListener( &maActionListeners
);
1473 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1475 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1477 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1478 xButton
->removeActionListener( &maActionListeners
);
1480 maActionListeners
.removeInterface( l
);
1483 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
)
1485 maActionCommand
= rCommand
;
1486 if ( getPeer().is() )
1488 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1489 xButton
->setActionCommand( rCommand
);
1494 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
)
1496 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1499 void UnoCheckBoxControl::setState( short n
)
1501 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(n
)), true );
1504 short UnoCheckBoxControl::getState()
1507 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1512 void UnoCheckBoxControl::enableTriState( sal_Bool b
)
1514 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), uno::Any(b
), true );
1517 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1519 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(static_cast<sal_Int16
>(rEvent
.Selected
)), false );
1521 if ( maItemListeners
.getLength() )
1522 maItemListeners
.itemStateChanged( rEvent
);
1525 awt::Size
UnoCheckBoxControl::getMinimumSize( )
1527 return Impl_getMinimumSize();
1530 awt::Size
UnoCheckBoxControl::getPreferredSize( )
1532 return Impl_getPreferredSize();
1535 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1537 return Impl_calcAdjustedSize( rNewSize
);
1540 OUString
UnoCheckBoxControl::getImplementationName()
1542 return OUString("stardiv.Toolkit.UnoCheckBoxControl");
1545 css::uno::Sequence
<OUString
> UnoCheckBoxControl::getSupportedServiceNames()
1547 auto s(UnoControlBase::getSupportedServiceNames());
1548 s
.realloc(s
.getLength() + 2);
1549 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBox";
1550 s
[s
.getLength() - 1] = "stardiv.vcl.control.CheckBox";
1554 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1555 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1556 css::uno::XComponentContext
*,
1557 css::uno::Sequence
<css::uno::Any
> const &)
1559 return cppu::acquire(new UnoCheckBoxControl());
1563 // class UnoControlFixedHyperlinkModel
1565 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1566 :UnoControlModel( rxContext
)
1568 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink
);
1571 OUString
UnoControlFixedHyperlinkModel::getServiceName()
1573 return OUString( "com.sun.star.awt.UnoControlFixedHyperlinkModel" );
1576 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1578 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1580 return uno::Any( OUString( "com.sun.star.awt.UnoControlFixedHyperlink" ) );
1582 else if ( nPropId
== BASEPROPERTY_BORDER
)
1584 return uno::Any(sal_Int16(0));
1586 else if ( nPropId
== BASEPROPERTY_URL
)
1588 return uno::Any( OUString() );
1591 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1594 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1596 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1599 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1600 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1605 // beans::XMultiPropertySet
1606 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( )
1608 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1612 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1613 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1614 css::uno::XComponentContext
*context
,
1615 css::uno::Sequence
<css::uno::Any
> const &)
1617 return cppu::acquire(new UnoControlFixedHyperlinkModel(context
));
1621 // class UnoFixedHyperlinkControl
1623 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1625 ,maActionListeners( *this )
1627 maComponentInfos
.nWidth
= 100;
1628 maComponentInfos
.nHeight
= 12;
1631 OUString
UnoFixedHyperlinkControl::GetComponentServiceName()
1633 return OUString("fixedhyperlink");
1637 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
)
1639 uno::Any aRet
= ::cppu::queryInterface( rType
,
1640 static_cast< awt::XFixedHyperlink
* >(this),
1641 static_cast< awt::XLayoutConstrains
* >(this) );
1642 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1645 // lang::XTypeProvider
1646 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl
)
1647 cppu::UnoType
<awt::XFixedHyperlink
>::get(),
1648 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1649 UnoControlBase::getTypes()
1650 IMPL_XTYPEPROVIDER_END
1652 sal_Bool
UnoFixedHyperlinkControl::isTransparent()
1657 void UnoFixedHyperlinkControl::setText( const OUString
& Text
)
1659 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1662 OUString
UnoFixedHyperlinkControl::getText()
1664 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1667 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
)
1669 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), uno::Any(URL
), true );
1672 OUString
UnoFixedHyperlinkControl::getURL( )
1674 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1677 void UnoFixedHyperlinkControl::setAlignment( short nAlign
)
1679 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(static_cast<sal_Int16
>(nAlign
)), true );
1682 short UnoFixedHyperlinkControl::getAlignment()
1687 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1693 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( )
1695 return Impl_getMinimumSize();
1698 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( )
1700 return Impl_getPreferredSize();
1703 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1705 return Impl_calcAdjustedSize( rNewSize
);
1708 void UnoFixedHyperlinkControl::dispose()
1710 lang::EventObject aEvt
;
1711 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1712 maActionListeners
.disposeAndClear( aEvt
);
1713 UnoControlBase::dispose();
1716 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1718 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1720 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1721 if ( maActionListeners
.getLength() )
1722 xFixedHyperlink
->addActionListener( &maActionListeners
);
1725 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1727 maActionListeners
.addInterface( l
);
1728 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1730 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1731 xFixedHyperlink
->addActionListener( &maActionListeners
);
1735 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1737 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1739 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1740 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1742 maActionListeners
.removeInterface( l
);
1745 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1746 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1747 css::uno::XComponentContext
*,
1748 css::uno::Sequence
<css::uno::Any
> const &)
1750 return cppu::acquire(new UnoFixedHyperlinkControl());
1754 // class UnoControlFixedTextModel
1756 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1757 :UnoControlModel( rxContext
)
1759 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText
);
1762 OUString
UnoControlFixedTextModel::getServiceName()
1764 return OUString( "stardiv.vcl.controlmodel.FixedText" );
1767 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1769 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1771 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedText
) );
1773 else if ( nPropId
== BASEPROPERTY_BORDER
)
1775 return uno::Any(sal_Int16(0));
1778 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1781 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1783 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1786 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1787 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1792 // beans::XMultiPropertySet
1793 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( )
1795 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1799 OUString
UnoControlFixedTextModel::getImplementationName()
1801 return OUString("stardiv.Toolkit.UnoControlFixedTextModel");
1804 css::uno::Sequence
<OUString
>
1805 UnoControlFixedTextModel::getSupportedServiceNames()
1807 auto s(UnoControlModel::getSupportedServiceNames());
1808 s
.realloc(s
.getLength() + 2);
1809 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedTextModel";
1810 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedText";
1814 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1815 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1816 css::uno::XComponentContext
*context
,
1817 css::uno::Sequence
<css::uno::Any
> const &)
1819 return cppu::acquire(new UnoControlFixedTextModel(context
));
1823 // class UnoFixedTextControl
1825 UnoFixedTextControl::UnoFixedTextControl()
1828 maComponentInfos
.nWidth
= 100;
1829 maComponentInfos
.nHeight
= 12;
1832 OUString
UnoFixedTextControl::GetComponentServiceName()
1834 return OUString("fixedtext");
1838 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
)
1840 uno::Any aRet
= ::cppu::queryInterface( rType
,
1841 static_cast< awt::XFixedText
* >(this),
1842 static_cast< awt::XLayoutConstrains
* >(this) );
1843 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1846 // lang::XTypeProvider
1847 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl
)
1848 cppu::UnoType
<awt::XFixedText
>::get(),
1849 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1850 UnoControlBase::getTypes()
1851 IMPL_XTYPEPROVIDER_END
1853 sal_Bool
UnoFixedTextControl::isTransparent()
1858 void UnoFixedTextControl::setText( const OUString
& Text
)
1860 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1863 OUString
UnoFixedTextControl::getText()
1865 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1868 void UnoFixedTextControl::setAlignment( short nAlign
)
1870 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any(static_cast<sal_Int16
>(nAlign
)), true );
1873 short UnoFixedTextControl::getAlignment()
1878 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1884 awt::Size
UnoFixedTextControl::getMinimumSize( )
1886 return Impl_getMinimumSize();
1889 awt::Size
UnoFixedTextControl::getPreferredSize( )
1891 return Impl_getPreferredSize();
1894 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1896 return Impl_calcAdjustedSize( rNewSize
);
1899 OUString
UnoFixedTextControl::getImplementationName()
1901 return OUString("stardiv.Toolkit.UnoFixedTextControl");
1904 css::uno::Sequence
<OUString
> UnoFixedTextControl::getSupportedServiceNames()
1906 auto s(UnoControlBase::getSupportedServiceNames());
1907 s
.realloc(s
.getLength() + 2);
1908 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedText";
1909 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedText";
1913 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1914 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1915 css::uno::XComponentContext
*,
1916 css::uno::Sequence
<css::uno::Any
> const &)
1918 return cppu::acquire(new UnoFixedTextControl());
1922 // class UnoControlGroupBoxModel
1924 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1925 :UnoControlModel( rxContext
)
1927 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1928 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1929 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1930 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1931 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1932 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1933 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1934 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1935 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1936 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1939 OUString
UnoControlGroupBoxModel::getServiceName()
1941 return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel
);
1944 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1946 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1948 return uno::Any(OUString::createFromAscii( szServiceName_UnoControlGroupBox
) );
1950 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1953 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1955 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1958 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1959 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1964 // beans::XMultiPropertySet
1965 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( )
1967 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1971 OUString
UnoControlGroupBoxModel::getImplementationName()
1973 return OUString("stardiv.Toolkit.UnoControlGroupBoxModel");
1976 css::uno::Sequence
<OUString
> UnoControlGroupBoxModel::getSupportedServiceNames()
1978 auto s(UnoControlModel::getSupportedServiceNames());
1979 s
.realloc(s
.getLength() + 2);
1980 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBoxModel";
1981 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.GroupBox";
1985 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
1986 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
1987 css::uno::XComponentContext
*context
,
1988 css::uno::Sequence
<css::uno::Any
> const &)
1990 return cppu::acquire(new UnoControlGroupBoxModel(context
));
1994 // class UnoGroupBoxControl
1996 UnoGroupBoxControl::UnoGroupBoxControl()
1999 maComponentInfos
.nWidth
= 100;
2000 maComponentInfos
.nHeight
= 100;
2003 OUString
UnoGroupBoxControl::GetComponentServiceName()
2005 return OUString("groupbox");
2008 sal_Bool
UnoGroupBoxControl::isTransparent()
2013 OUString
UnoGroupBoxControl::getImplementationName()
2015 return OUString("stardiv.Toolkit.UnoGroupBoxControl");
2018 css::uno::Sequence
<OUString
> UnoGroupBoxControl::getSupportedServiceNames()
2020 auto s(UnoControlBase::getSupportedServiceNames());
2021 s
.realloc(s
.getLength() + 2);
2022 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBox";
2023 s
[s
.getLength() - 1] = "stardiv.vcl.control.GroupBox";
2027 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2028 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
2029 css::uno::XComponentContext
*,
2030 css::uno::Sequence
<css::uno::Any
> const &)
2032 return cppu::acquire(new UnoGroupBoxControl());
2036 // = UnoControlListBoxModel_Data
2041 OUString ItemImageURL
;
2051 explicit ListItem( const OUString
& i_rItemText
)
2052 :ItemText( i_rItemText
)
2059 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
2061 struct StripItemData
2063 UnoListItem
operator()( const ListItem
& i_rItem
)
2065 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
2069 struct UnoControlListBoxModel_Data
2071 explicit UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
2072 :m_bSettingLegacyProperty( false )
2073 ,m_rAntiImpl( i_rAntiImpl
)
2078 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
2080 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
2082 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2083 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2084 return m_aListItems
[ i_nIndex
];
2087 ListItem
& getItem( const sal_Int32 i_nIndex
)
2089 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
2092 ListItem
& insertItem( const sal_Int32 i_nIndex
)
2094 if ( ( i_nIndex
< 0 ) || ( i_nIndex
> sal_Int32( m_aListItems
.size() ) ) )
2095 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2096 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
2099 Sequence
< UnoListItem
> getAllItems() const
2101 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
2102 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
2106 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
2108 m_aListItems
= i_copySource
.m_aListItems
;
2111 void setAllItems( const ::std::vector
< ListItem
>& i_rItems
)
2113 m_aListItems
= i_rItems
;
2116 void removeItem( const sal_Int32 i_nIndex
)
2118 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2119 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2120 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
2123 void removeAllItems()
2125 ::std::vector
< ListItem
> aEmpty
;
2126 m_aListItems
.swap( aEmpty
);
2130 bool m_bSettingLegacyProperty
;
2133 UnoControlListBoxModel
& m_rAntiImpl
;
2134 ::std::vector
< ListItem
> m_aListItems
;
2138 // = UnoControlListBoxModel
2141 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
2142 :UnoControlListBoxModel_Base( rxContext
)
2143 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2144 ,m_aItemListListeners( GetMutex() )
2146 if ( i_mode
== ConstructDefault
)
2148 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox
);
2152 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
2153 :UnoControlListBoxModel_Base( i_rSource
)
2154 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2155 ,m_aItemListListeners( GetMutex() )
2157 m_xData
->copyItems( *i_rSource
.m_xData
);
2159 UnoControlListBoxModel::~UnoControlListBoxModel()
2163 OUString
UnoControlListBoxModel::getImplementationName()
2165 return OUString("stardiv.Toolkit.UnoControlListBoxModel");
2168 css::uno::Sequence
<OUString
> UnoControlListBoxModel::getSupportedServiceNames()
2170 auto s(UnoControlModel::getSupportedServiceNames());
2171 s
.realloc(s
.getLength() + 2);
2172 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBoxModel";
2173 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ListBox";
2177 OUString
UnoControlListBoxModel::getServiceName()
2179 return OUString::createFromAscii( szServiceName_UnoControlListBoxModel
);
2183 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2185 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2187 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlListBox
) );
2189 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2193 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
2195 static UnoPropertyArrayHelper
* pHelper
= nullptr;
2198 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
2199 pHelper
= new UnoPropertyArrayHelper( aIDs
);
2205 // beans::XMultiPropertySet
2206 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( )
2208 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2215 struct CreateListItem
2217 ListItem
operator()( const OUString
& i_rItemText
)
2219 return ListItem( i_rItemText
);
2225 void SAL_CALL
UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
)
2227 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
2229 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
)
2232 uno::Sequence
<sal_Int16
> aSeq
;
2233 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS
, uno::Any(aSeq
) );
2235 if ( !m_xData
->m_bSettingLegacyProperty
)
2237 // synchronize the legacy StringItemList property with our list items
2238 Sequence
< OUString
> aStringItemList
;
2240 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2241 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2243 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2245 aStringItemList
.begin(),
2246 aStringItemList
.end(),
2250 m_xData
->setAllItems( aItems
);
2252 // since an XItemListListener does not have a "all items modified" or some such method,
2253 // we simulate this by notifying removal of all items, followed by insertion of all new
2255 lang::EventObject aEvent
;
2256 aEvent
.Source
= *this;
2257 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
2258 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2259 // which is wrong for the above notifications ...
2265 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
2266 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const
2268 // dependencies we know:
2269 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2270 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
2271 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_TYPEDITEMLIST
2272 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_TYPEDITEMLIST
);
2274 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
2278 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount()
2280 ::osl::MutexGuard
aGuard( GetMutex() );
2281 return m_xData
->getItemCount();
2285 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2287 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2288 // SYNCHRONIZED ----->
2289 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2290 rItem
.ItemText
= i_rItemText
;
2291 rItem
.ItemImageURL
= i_rItemImageURL
;
2293 impl_handleInsert( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2294 // <----- SYNCHRONIZED
2298 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2300 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2301 // SYNCHRONIZED ----->
2302 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2303 rItem
.ItemText
= i_rItemText
;
2305 impl_handleInsert( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2306 // <----- SYNCHRONIZED
2310 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2312 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2313 // SYNCHRONIZED ----->
2314 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2315 rItem
.ItemImageURL
= i_rItemImageURL
;
2317 impl_handleInsert( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2318 // <----- SYNCHRONIZED
2322 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
)
2324 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2325 // SYNCHRONIZED ----->
2326 m_xData
->removeItem( i_nPosition
);
2328 impl_handleRemove( i_nPosition
, aGuard
);
2329 // <----- SYNCHRONIZED
2333 void SAL_CALL
UnoControlListBoxModel::removeAllItems( )
2335 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2336 // SYNCHRONIZED ----->
2337 m_xData
->removeAllItems();
2339 impl_handleRemove( -1, aGuard
);
2340 // <----- SYNCHRONIZED
2344 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2346 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2347 // SYNCHRONIZED ----->
2348 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2349 rItem
.ItemText
= i_rItemText
;
2351 impl_handleModify( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2352 // <----- SYNCHRONIZED
2356 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2358 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2359 // SYNCHRONIZED ----->
2360 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2361 rItem
.ItemImageURL
= i_rItemImageURL
;
2363 impl_handleModify( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2364 // <----- SYNCHRONIZED
2368 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2370 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2371 // SYNCHRONIZED ----->
2372 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2373 rItem
.ItemText
= i_rItemText
;
2374 rItem
.ItemImageURL
= i_rItemImageURL
;
2376 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2377 // <----- SYNCHRONIZED
2381 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
)
2383 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2384 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2385 rItem
.ItemData
= i_rDataValue
;
2389 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
)
2391 ::osl::MutexGuard
aGuard( GetMutex() );
2392 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2393 return rItem
.ItemText
;
2397 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
)
2399 ::osl::MutexGuard
aGuard( GetMutex() );
2400 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2401 return rItem
.ItemImageURL
;
2405 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
)
2407 ::osl::MutexGuard
aGuard( GetMutex() );
2408 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2409 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2413 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
)
2415 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2416 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2417 return rItem
.ItemData
;
2421 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( )
2423 ::osl::MutexGuard
aGuard( GetMutex() );
2424 return m_xData
->getAllItems();
2428 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2430 if ( i_Listener
.is() )
2431 m_aItemListListeners
.addInterface( i_Listener
);
2435 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2437 if ( i_Listener
.is() )
2438 m_aItemListListeners
.removeInterface( i_Listener
);
2442 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector
< OUString
>& o_rStringItems
) const
2444 Sequence
< OUString
> aStringItemList
;
2446 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2447 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2449 o_rStringItems
.resize( size_t( aStringItemList
.getLength() ) );
2451 aStringItemList
.begin(),
2452 aStringItemList
.end(),
2453 o_rStringItems
.begin()
2458 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector
< OUString
>& i_rStringItems
)
2460 Sequence
< OUString
> aStringItems( comphelper::containerToSequence(i_rStringItems
) );
2461 m_xData
->m_bSettingLegacyProperty
= true;
2464 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST
, uno::makeAny( aStringItems
) );
2466 catch( const Exception
& )
2468 m_xData
->m_bSettingLegacyProperty
= false;
2471 m_xData
->m_bSettingLegacyProperty
= false;
2475 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2476 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2478 // SYNCHRONIZED ----->
2479 // sync with legacy StringItemList property
2480 ::std::vector
< OUString
> aStringItems
;
2481 impl_getStringItemList( aStringItems
);
2482 OSL_ENSURE( size_t( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2483 if ( size_t( i_nItemPosition
) <= aStringItems
.size() )
2485 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2486 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2489 i_rClearBeforeNotify
.clear();
2490 // <----- SYNCHRONIZED
2491 impl_setStringItemList_nolck( aStringItems
);
2493 // notify ItemListListeners
2494 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2498 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2500 // SYNCHRONIZED ----->
2501 const bool bAllItems
= ( i_nItemPosition
< 0 );
2502 // sync with legacy StringItemList property
2503 ::std::vector
< OUString
> aStringItems
;
2504 impl_getStringItemList( aStringItems
);
2507 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2508 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2510 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2515 aStringItems
.resize(0);
2518 i_rClearBeforeNotify
.clear();
2519 // <----- SYNCHRONIZED
2520 impl_setStringItemList_nolck( aStringItems
);
2522 // notify ItemListListeners
2525 EventObject
aEvent( *this );
2526 m_aItemListListeners
.notifyEach( &XItemListListener::allItemsRemoved
, aEvent
);
2530 impl_notifyItemListEvent_nolck( i_nItemPosition
, ::boost::optional
< OUString
>(), ::boost::optional
< OUString
>(),
2531 &XItemListListener::listItemRemoved
);
2536 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2537 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2539 // SYNCHRONIZED ----->
2540 if ( !!i_rItemText
)
2542 // sync with legacy StringItemList property
2543 ::std::vector
< OUString
> aStringItems
;
2544 impl_getStringItemList( aStringItems
);
2545 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2546 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2548 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2551 i_rClearBeforeNotify
.clear();
2552 // <----- SYNCHRONIZED
2553 impl_setStringItemList_nolck( aStringItems
);
2557 i_rClearBeforeNotify
.clear();
2558 // <----- SYNCHRONIZED
2561 // notify ItemListListeners
2562 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2566 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2567 const ::boost::optional
< OUString
>& i_rItemImageURL
,
2568 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2570 ItemListEvent aEvent
;
2571 aEvent
.Source
= *this;
2572 aEvent
.ItemPosition
= i_nItemPosition
;
2573 if ( !!i_rItemText
)
2575 aEvent
.ItemText
.IsPresent
= true;
2576 aEvent
.ItemText
.Value
= *i_rItemText
;
2578 if ( !!i_rItemImageURL
)
2580 aEvent
.ItemImageURL
.IsPresent
= true;
2581 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2584 m_aItemListListeners
.notifyEach( NotificationMethod
, aEvent
);
2587 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
2588 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2589 css::uno::XComponentContext
*context
,
2590 css::uno::Sequence
<css::uno::Any
> const &)
2592 return cppu::acquire(new UnoControlListBoxModel(context
));
2596 // class UnoListBoxControl
2598 UnoListBoxControl::UnoListBoxControl()
2599 :UnoListBoxControl_Base()
2600 ,maActionListeners( *this )
2601 ,maItemListeners( *this )
2603 maComponentInfos
.nWidth
= 100;
2604 maComponentInfos
.nHeight
= 12;
2607 OUString
UnoListBoxControl::GetComponentServiceName()
2609 return OUString("listbox");
2612 OUString
UnoListBoxControl::getImplementationName()
2614 return OUString("stardiv.Toolkit.UnoListBoxControl");
2617 css::uno::Sequence
<OUString
> UnoListBoxControl::getSupportedServiceNames()
2619 auto s(UnoControlBase::getSupportedServiceNames());
2620 s
.realloc(s
.getLength() + 2);
2621 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBox";
2622 s
[s
.getLength() - 1] = "stardiv.vcl.control.ListBox";
2626 void UnoListBoxControl::dispose()
2628 lang::EventObject aEvt
;
2629 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
2630 maActionListeners
.disposeAndClear( aEvt
);
2631 maItemListeners
.disposeAndClear( aEvt
);
2632 UnoControl::dispose();
2635 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2637 if ( getPeer().is() )
2639 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2640 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2642 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2643 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), uno::Any(aSeq
), false );
2647 void UnoListBoxControl::updateFromModel()
2649 UnoControlBase::updateFromModel();
2651 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2652 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2654 EventObject
aEvent( getModel() );
2655 xItemListListener
->itemListChanged( aEvent
);
2657 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2658 // already did this, our peer(s) can only legitimately set the selection after they have the string
2659 // item list, which we just notified with the itemListChanged call.
2660 const OUString
& sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2661 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2664 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2666 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2667 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2668 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2669 // will be forwarded to the peer, which will update itself accordingly.
2672 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2675 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
2677 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2679 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2680 xListBox
->addItemListener( this );
2682 if ( maActionListeners
.getLength() )
2683 xListBox
->addActionListener( &maActionListeners
);
2686 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2688 maActionListeners
.addInterface( l
);
2689 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2691 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2692 xListBox
->addActionListener( &maActionListeners
);
2696 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2698 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2700 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2701 xListBox
->removeActionListener( &maActionListeners
);
2703 maActionListeners
.removeInterface( l
);
2706 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2708 maItemListeners
.addInterface( l
);
2711 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2713 maItemListeners
.removeInterface( l
);
2716 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
2718 uno::Sequence
<OUString
> aSeq
{ aItem
};
2719 addItems( aSeq
, nPos
);
2722 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
2724 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2725 uno::Sequence
< OUString
> aSeq
;
2727 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
2728 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2729 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2731 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2732 OUString
* pNewData
= aNewSeq
.getArray();
2733 OUString
* pOldData
= aSeq
.getArray();
2735 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2739 // Items before the Paste-Position
2740 for ( n
= 0; n
< nPos
; n
++ )
2741 pNewData
[n
] = pOldData
[n
];
2744 for ( n
= 0; n
< nNewItems
; n
++ )
2745 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
2747 // Rest of old Items
2748 for ( n
= nPos
; n
< nOldLen
; n
++ )
2749 pNewData
[nNewItems
+n
] = pOldData
[n
];
2751 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2754 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
2756 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2757 uno::Sequence
< OUString
> aSeq
;
2759 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
2760 if ( nOldLen
&& ( nPos
< nOldLen
) )
2762 if ( nCount
> ( nOldLen
-nPos
) )
2763 nCount
= nOldLen
-nPos
;
2765 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2767 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2768 OUString
* pNewData
= aNewSeq
.getArray();
2769 OUString
* pOldData
= aSeq
.getArray();
2772 // Items before the Remove-Position
2773 for ( n
= 0; n
< nPos
; n
++ )
2774 pNewData
[n
] = pOldData
[n
];
2777 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
2778 pNewData
[n
] = pOldData
[n
+nCount
];
2780 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2784 sal_Int16
UnoListBoxControl::getItemCount()
2786 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2787 uno::Sequence
< OUString
> aSeq
;
2789 return static_cast<sal_Int16
>(aSeq
.getLength());
2792 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
)
2795 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2796 uno::Sequence
< OUString
> aSeq
;
2798 if ( nPos
< aSeq
.getLength() )
2799 aItem
= aSeq
.getConstArray()[nPos
];
2803 uno::Sequence
< OUString
> UnoListBoxControl::getItems()
2805 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2806 uno::Sequence
< OUString
> aSeq
;
2811 sal_Int16
UnoListBoxControl::getSelectedItemPos()
2814 if ( getPeer().is() )
2816 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2817 n
= xListBox
->getSelectedItemPos();
2822 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos()
2824 uno::Sequence
<sal_Int16
> aSeq
;
2825 if ( getPeer().is() )
2827 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2828 aSeq
= xListBox
->getSelectedItemsPos();
2833 OUString
UnoListBoxControl::getSelectedItem()
2836 if ( getPeer().is() )
2838 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2839 aItem
= xListBox
->getSelectedItem();
2844 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems()
2846 uno::Sequence
< OUString
> aSeq
;
2847 if ( getPeer().is() )
2849 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2850 aSeq
= xListBox
->getSelectedItems();
2855 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
)
2857 if ( getPeer().is() )
2859 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2860 xListBox
->selectItemPos( nPos
, bSelect
);
2862 ImplUpdateSelectedItemsProperty();
2865 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
)
2867 if ( getPeer().is() )
2869 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2870 xListBox
->selectItemsPos( aPositions
, bSelect
);
2872 ImplUpdateSelectedItemsProperty();
2875 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
)
2877 if ( getPeer().is() )
2879 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2880 xListBox
->selectItem( aItem
, bSelect
);
2882 ImplUpdateSelectedItemsProperty();
2885 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
)
2887 if ( getPeer().is() )
2889 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2890 xListBox
->makeVisible( nEntry
);
2894 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
)
2896 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
2899 sal_Int16
UnoListBoxControl::getDropDownLineCount()
2901 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2904 sal_Bool
UnoListBoxControl::isMutipleMode()
2906 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2909 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
)
2911 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), uno::Any(bMulti
), true );
2914 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
2916 ImplUpdateSelectedItemsProperty();
2917 if ( maItemListeners
.getLength() )
2921 maItemListeners
.itemStateChanged( rEvent
);
2923 catch( const Exception
& e
)
2925 SAL_WARN( "toolkit", "UnoListBoxControl::itemStateChanged: caught " << e
);
2930 awt::Size
UnoListBoxControl::getMinimumSize( )
2932 return Impl_getMinimumSize();
2935 awt::Size
UnoListBoxControl::getPreferredSize( )
2937 return Impl_getPreferredSize();
2940 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
2942 return Impl_calcAdjustedSize( rNewSize
);
2945 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
2947 return Impl_getMinimumSize( nCols
, nLines
);
2950 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
2952 Impl_getColumnsAndLines( nCols
, nLines
);
2955 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
2957 ::osl::MutexGuard
aGuard( GetMutex() );
2959 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2960 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2961 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2962 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2964 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2967 if ( xOldItems
.is() )
2968 xOldItems
->removeItemListListener( this );
2969 if ( xNewItems
.is() )
2970 xNewItems
->addItemListListener( this );
2975 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
2977 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2978 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2979 if ( xPeerListener
.is() )
2980 xPeerListener
->listItemInserted( i_rEvent
);
2983 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
2985 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2986 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
2987 if ( xPeerListener
.is() )
2988 xPeerListener
->listItemRemoved( i_rEvent
);
2991 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
2993 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2994 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
2995 if ( xPeerListener
.is() )
2996 xPeerListener
->listItemModified( i_rEvent
);
2999 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3001 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3002 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
3003 if ( xPeerListener
.is() )
3004 xPeerListener
->allItemsRemoved( i_rEvent
);
3007 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3009 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3010 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
3011 if ( xPeerListener
.is() )
3012 xPeerListener
->itemListChanged( i_rEvent
);
3015 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3016 stardiv_Toolkit_UnoListBoxControl_get_implementation(
3017 css::uno::XComponentContext
*,
3018 css::uno::Sequence
<css::uno::Any
> const &)
3020 return cppu::acquire(new UnoListBoxControl());
3024 // class UnoControlComboBoxModel
3026 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
3027 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
3029 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox
);
3032 OUString
UnoControlComboBoxModel::getImplementationName()
3034 return OUString("stardiv.Toolkit.UnoControlComboBoxModel");
3037 css::uno::Sequence
<OUString
> UnoControlComboBoxModel::getSupportedServiceNames()
3039 auto s(UnoControlModel::getSupportedServiceNames());
3040 s
.realloc(s
.getLength() + 2);
3041 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBoxModel";
3042 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ComboBox";
3046 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( )
3048 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3052 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
3054 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3057 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3058 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3064 OUString
UnoControlComboBoxModel::getServiceName()
3066 return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel
);
3068 void SAL_CALL
UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
)
3070 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
3072 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
&& !m_xData
->m_bSettingLegacyProperty
)
3074 // synchronize the legacy StringItemList property with our list items
3075 Sequence
< OUString
> aStringItemList
;
3077 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
3078 OSL_VERIFY( aPropValue
>>= aStringItemList
);
3080 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
3082 aStringItemList
.begin(),
3083 aStringItemList
.end(),
3087 m_xData
->setAllItems( aItems
);
3089 // since an XItemListListener does not have a "all items modified" or some such method,
3090 // we simulate this by notifying removal of all items, followed by insertion of all new
3092 lang::EventObject aEvent
;
3093 aEvent
.Source
= *this;
3094 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
3095 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
3096 // which is wrong for the above notifications ...
3100 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3102 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3104 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlComboBox
) );
3106 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3109 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3110 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
3111 css::uno::XComponentContext
*context
,
3112 css::uno::Sequence
<css::uno::Any
> const &)
3114 return cppu::acquire(new UnoControlComboBoxModel(context
));
3118 // class UnoComboBoxControl
3120 UnoComboBoxControl::UnoComboBoxControl()
3122 ,maActionListeners( *this )
3123 ,maItemListeners( *this )
3125 maComponentInfos
.nWidth
= 100;
3126 maComponentInfos
.nHeight
= 12;
3129 OUString
UnoComboBoxControl::getImplementationName()
3131 return OUString( "stardiv.Toolkit.UnoComboBoxControl");
3134 css::uno::Sequence
<OUString
> UnoComboBoxControl::getSupportedServiceNames()
3136 auto s(UnoEditControl::getSupportedServiceNames());
3137 s
.realloc(s
.getLength() + 2);
3138 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBox";
3139 s
[s
.getLength() - 1] = "stardiv.vcl.control.ComboBox";
3143 OUString
UnoComboBoxControl::GetComponentServiceName()
3145 return OUString("combobox");
3148 void UnoComboBoxControl::dispose()
3150 lang::EventObject aEvt
;
3151 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
3152 maActionListeners
.disposeAndClear( aEvt
);
3153 maItemListeners
.disposeAndClear( aEvt
);
3154 UnoControl::dispose();
3156 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
)
3158 uno::Any aRet
= ::cppu::queryInterface( rType
,
3159 static_cast< awt::XComboBox
* >(this) );
3160 if ( !aRet
.hasValue() )
3162 aRet
= ::cppu::queryInterface( rType
,
3163 static_cast< awt::XItemListener
* >(this) );
3164 if ( !aRet
.hasValue() )
3166 aRet
= ::cppu::queryInterface( rType
,
3167 static_cast< awt::XItemListListener
* >(this) );
3170 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3172 // lang::XTypeProvider
3173 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl
)
3174 cppu::UnoType
<awt::XComboBox
>::get(),
3175 cppu::UnoType
<awt::XItemListener
>::get(),
3176 cppu::UnoType
<awt::XItemListListener
>::get(),
3177 UnoEditControl::getTypes()
3178 IMPL_XTYPEPROVIDER_END
3180 void UnoComboBoxControl::updateFromModel()
3182 UnoEditControl::updateFromModel();
3184 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
3185 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3187 EventObject
aEvent( getModel() );
3188 xItemListListener
->itemListChanged( aEvent
);
3190 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
3192 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
3193 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3194 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3195 // will be forwarded to the peer, which will update itself accordingly.
3198 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
3200 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3202 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3204 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3205 if ( maActionListeners
.getLength() )
3206 xComboBox
->addActionListener( &maActionListeners
);
3207 if ( maItemListeners
.getLength() )
3208 xComboBox
->addItemListener( &maItemListeners
);
3211 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3213 maActionListeners
.addInterface( l
);
3214 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3216 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3217 xComboBox
->addActionListener( &maActionListeners
);
3221 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3223 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3225 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3226 xComboBox
->removeActionListener( &maActionListeners
);
3228 maActionListeners
.removeInterface( l
);
3231 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3233 maItemListeners
.addInterface( l
);
3234 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3236 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3237 xComboBox
->addItemListener( &maItemListeners
);
3241 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3243 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3245 // This call is prettier than creating a Ref and calling query
3246 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3247 xComboBox
->removeItemListener( &maItemListeners
);
3249 maItemListeners
.removeInterface( l
);
3251 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
3253 if ( maItemListeners
.getLength() )
3257 maItemListeners
.itemStateChanged( rEvent
);
3259 catch( const Exception
& e
)
3261 SAL_WARN( "toolkit", "UnoComboBoxControl::itemStateChanged: caught " << e
);
3265 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
3267 ::osl::MutexGuard
aGuard( GetMutex() );
3269 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3270 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3271 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3272 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3274 if ( !UnoEditControl::setModel( i_rModel
) )
3277 if ( xOldItems
.is() )
3278 xOldItems
->removeItemListListener( this );
3279 if ( xNewItems
.is() )
3280 xNewItems
->addItemListListener( this );
3285 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
3287 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3288 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3289 if ( xPeerListener
.is() )
3290 xPeerListener
->listItemInserted( i_rEvent
);
3293 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
3295 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3296 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3297 if ( xPeerListener
.is() )
3298 xPeerListener
->listItemRemoved( i_rEvent
);
3301 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
3303 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3304 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3305 if ( xPeerListener
.is() )
3306 xPeerListener
->listItemModified( i_rEvent
);
3309 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3311 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3312 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3313 if ( xPeerListener
.is() )
3314 xPeerListener
->allItemsRemoved( i_rEvent
);
3317 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3319 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3320 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3321 if ( xPeerListener
.is() )
3322 xPeerListener
->itemListChanged( i_rEvent
);
3325 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
3327 uno::Sequence
<OUString
> aSeq
{ aItem
};
3328 addItems( aSeq
, nPos
);
3331 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
3333 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3334 uno::Sequence
< OUString
> aSeq
;
3336 sal_uInt16 nNewItems
= static_cast<sal_uInt16
>(aItems
.getLength());
3337 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3338 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3340 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3341 OUString
* pNewData
= aNewSeq
.getArray();
3342 const OUString
* pOldData
= aSeq
.getConstArray();
3344 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3348 // items before the insert position
3349 for ( n
= 0; n
< nPos
; n
++ )
3350 pNewData
[n
] = pOldData
[n
];
3353 for ( n
= 0; n
< nNewItems
; n
++ )
3354 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
3356 // remainder of old items
3357 for ( n
= nPos
; n
< nOldLen
; n
++ )
3358 pNewData
[nNewItems
+n
] = pOldData
[n
];
3360 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), Any(aNewSeq
), true );
3363 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
3365 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3366 uno::Sequence
< OUString
> aSeq
;
3368 sal_uInt16 nOldLen
= static_cast<sal_uInt16
>(aSeq
.getLength());
3369 if ( nOldLen
&& ( nPos
< nOldLen
) )
3371 if ( nCount
> ( nOldLen
-nPos
) )
3372 nCount
= nOldLen
-nPos
;
3374 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3376 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3377 OUString
* pNewData
= aNewSeq
.getArray();
3378 OUString
* pOldData
= aSeq
.getArray();
3381 // items before the deletion position
3382 for ( n
= 0; n
< nPos
; n
++ )
3383 pNewData
[n
] = pOldData
[n
];
3385 // remainder of old items
3386 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
3387 pNewData
[n
] = pOldData
[n
+nCount
];
3389 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
3393 sal_Int16
UnoComboBoxControl::getItemCount()
3395 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3396 uno::Sequence
< OUString
> aSeq
;
3398 return static_cast<sal_Int16
>(aSeq
.getLength());
3401 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
)
3404 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3405 uno::Sequence
< OUString
> aSeq
;
3407 if ( nPos
< aSeq
.getLength() )
3408 aItem
= aSeq
.getConstArray()[nPos
];
3412 uno::Sequence
< OUString
> UnoComboBoxControl::getItems()
3414 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3415 uno::Sequence
< OUString
> aSeq
;
3420 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
)
3422 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
3425 sal_Int16
UnoComboBoxControl::getDropDownLineCount()
3427 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3430 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3431 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3432 css::uno::XComponentContext
*,
3433 css::uno::Sequence
<css::uno::Any
> const &)
3435 return cppu::acquire(new UnoComboBoxControl());
3439 // UnoSpinFieldControl
3441 UnoSpinFieldControl::UnoSpinFieldControl()
3443 ,maSpinListeners( *this )
3449 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
)
3451 uno::Any aRet
= ::cppu::queryInterface( rType
,
3452 static_cast< awt::XSpinField
* >(this) );
3453 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3456 // lang::XTypeProvider
3457 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl
)
3458 cppu::UnoType
<awt::XSpinField
>::get(),
3459 UnoEditControl::getTypes()
3460 IMPL_XTYPEPROVIDER_END
3462 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3464 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3466 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3467 xField
->enableRepeat( mbRepeat
);
3468 if ( maSpinListeners
.getLength() )
3469 xField
->addSpinListener( &maSpinListeners
);
3472 // css::awt::XSpinField
3473 void UnoSpinFieldControl::addSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3475 maSpinListeners
.addInterface( l
);
3476 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3478 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3479 xField
->addSpinListener( &maSpinListeners
);
3483 void UnoSpinFieldControl::removeSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3485 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3487 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3488 xField
->removeSpinListener( &maSpinListeners
);
3490 maSpinListeners
.removeInterface( l
);
3493 void UnoSpinFieldControl::up()
3495 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3500 void UnoSpinFieldControl::down()
3502 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3507 void UnoSpinFieldControl::first()
3509 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3514 void UnoSpinFieldControl::last()
3516 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3521 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
)
3525 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3527 xField
->enableRepeat( bRepeat
);
3531 // class UnoControlDateFieldModel
3533 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3534 :UnoControlModel( rxContext
)
3536 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField
);
3539 OUString
UnoControlDateFieldModel::getServiceName()
3541 return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel
);
3544 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3546 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3548 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlDateField
) );
3550 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3554 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3556 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3559 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3560 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3565 // beans::XMultiPropertySet
3566 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( )
3568 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3572 OUString
UnoControlDateFieldModel::getImplementationName()
3574 return OUString("stardiv.Toolkit.UnoControlDateFieldModel");
3577 css::uno::Sequence
<OUString
>
3578 UnoControlDateFieldModel::getSupportedServiceNames()
3580 auto s(UnoControlModel::getSupportedServiceNames());
3581 s
.realloc(s
.getLength() + 2);
3582 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateFieldModel";
3583 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.DateField";
3587 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3588 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3589 css::uno::XComponentContext
*context
,
3590 css::uno::Sequence
<css::uno::Any
> const &)
3592 return cppu::acquire(new UnoControlDateFieldModel(context
));
3596 // class UnoDateFieldControl
3598 UnoDateFieldControl::UnoDateFieldControl()
3599 :UnoSpinFieldControl()
3601 mnFirst
= util::Date( 1, 1, 1900 );
3602 mnLast
= util::Date( 31, 12, 2200 );
3603 mbLongFormat
= TRISTATE_INDET
;
3606 OUString
UnoDateFieldControl::GetComponentServiceName()
3608 return OUString("datefield");
3612 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
)
3614 uno::Any aRet
= ::cppu::queryInterface( rType
,
3615 static_cast< awt::XDateField
* >(this) );
3616 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3619 // lang::XTypeProvider
3620 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl
)
3621 cppu::UnoType
<awt::XDateField
>::get(),
3622 UnoSpinFieldControl::getTypes()
3623 IMPL_XTYPEPROVIDER_END
3625 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3627 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3629 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3630 xField
->setFirst( mnFirst
);
3631 xField
->setLast( mnLast
);
3632 if ( mbLongFormat
!= TRISTATE_INDET
)
3633 xField
->setLongFormat( mbLongFormat
!= TRISTATE_FALSE
);
3637 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
)
3639 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3641 // also change the text property (#i25106#)
3644 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3645 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3648 // re-calc the Date property
3649 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3651 if ( xField
->isEmpty() )
3653 // the field says it's empty
3654 bool bEnforceFormat
= true;
3656 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3657 if ( !bEnforceFormat
)
3659 // and it also says that it is currently accepting invalid inputs, without
3660 // forcing it to a valid date
3661 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3662 if ( xText
.is() && xText
->getText().getLength() )
3663 // and in real, the text of the peer is *not* empty
3664 // -> simulate an invalid date, which is different from "no date"
3665 aValue
<<= util::Date();
3669 aValue
<<= xField
->getDate();
3671 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, false );
3673 // multiplex the event
3674 if ( GetTextListeners().getLength() )
3675 GetTextListeners().textChanged( e
);
3678 void UnoDateFieldControl::setDate( const util::Date
& Date
)
3680 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), uno::Any(Date
), true );
3683 util::Date
UnoDateFieldControl::getDate()
3685 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3688 void UnoDateFieldControl::setMin( const util::Date
& Date
)
3690 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), uno::Any(Date
), true );
3693 util::Date
UnoDateFieldControl::getMin()
3695 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3698 void UnoDateFieldControl::setMax( const util::Date
& Date
)
3700 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), uno::Any(Date
), true );
3703 util::Date
UnoDateFieldControl::getMax()
3705 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3708 void UnoDateFieldControl::setFirst( const util::Date
& Date
)
3711 if ( getPeer().is() )
3713 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3714 xField
->setFirst( Date
);
3718 util::Date
UnoDateFieldControl::getFirst()
3723 void UnoDateFieldControl::setLast( const util::Date
& Date
)
3726 if ( getPeer().is() )
3728 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3729 xField
->setLast( Date
);
3733 util::Date
UnoDateFieldControl::getLast()
3738 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
)
3740 mbLongFormat
= bLong
? TRISTATE_TRUE
: TRISTATE_FALSE
;
3741 if ( getPeer().is() )
3743 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3744 xField
->setLongFormat( bLong
);
3748 sal_Bool
UnoDateFieldControl::isLongFormat()
3750 return mbLongFormat
== TRISTATE_TRUE
;
3753 void UnoDateFieldControl::setEmpty()
3755 if ( getPeer().is() )
3757 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3762 sal_Bool
UnoDateFieldControl::isEmpty()
3764 bool bEmpty
= false;
3765 if ( getPeer().is() )
3767 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3768 bEmpty
= xField
->isEmpty();
3773 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
)
3775 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3778 sal_Bool
UnoDateFieldControl::isStrictFormat()
3780 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3783 OUString
UnoDateFieldControl::getImplementationName()
3785 return OUString("stardiv.Toolkit.UnoDateFieldControl");
3788 css::uno::Sequence
<OUString
> UnoDateFieldControl::getSupportedServiceNames()
3790 auto s(UnoSpinFieldControl::getSupportedServiceNames());
3791 s
.realloc(s
.getLength() + 2);
3792 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateField";
3793 s
[s
.getLength() - 1] = "stardiv.vcl.control.DateField";
3797 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3798 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3799 css::uno::XComponentContext
*,
3800 css::uno::Sequence
<css::uno::Any
> const &)
3802 return cppu::acquire(new UnoDateFieldControl());
3806 // class UnoControlTimeFieldModel
3808 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3809 :UnoControlModel( rxContext
)
3811 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField
);
3814 OUString
UnoControlTimeFieldModel::getServiceName()
3816 return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel
);
3819 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3821 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3823 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlTimeField
) );
3825 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3829 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3831 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3834 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3835 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3840 // beans::XMultiPropertySet
3841 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( )
3843 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3847 OUString
UnoControlTimeFieldModel::getImplementationName()
3849 return OUString("stardiv.Toolkit.UnoControlTimeFieldModel");
3852 css::uno::Sequence
<OUString
>
3853 UnoControlTimeFieldModel::getSupportedServiceNames()
3855 auto s(UnoControlModel::getSupportedServiceNames());
3856 s
.realloc(s
.getLength() + 2);
3857 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeFieldModel";
3858 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.TimeField";
3862 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
3863 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
3864 css::uno::XComponentContext
*context
,
3865 css::uno::Sequence
<css::uno::Any
> const &)
3867 return cppu::acquire(new UnoControlTimeFieldModel(context
));
3871 // class UnoTimeFieldControl
3873 UnoTimeFieldControl::UnoTimeFieldControl()
3874 :UnoSpinFieldControl()
3876 mnFirst
= util::Time( 0, 0, 0, 0, false );
3877 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3880 OUString
UnoTimeFieldControl::GetComponentServiceName()
3882 return OUString("timefield");
3886 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
)
3888 uno::Any aRet
= ::cppu::queryInterface( rType
,
3889 static_cast< awt::XTimeField
* >(this) );
3890 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3893 // lang::XTypeProvider
3894 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl
)
3895 cppu::UnoType
<awt::XTimeField
>::get(),
3896 UnoSpinFieldControl::getTypes()
3897 IMPL_XTYPEPROVIDER_END
3899 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3901 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3903 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3904 xField
->setFirst( mnFirst
);
3905 xField
->setLast( mnLast
);
3908 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
)
3910 // also change the text property (#i25106#)
3911 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3912 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3913 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3915 // re-calc the Time property
3916 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3918 if ( !xField
->isEmpty() )
3919 aValue
<<= xField
->getTime();
3920 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, false );
3922 // multiplex the event
3923 if ( GetTextListeners().getLength() )
3924 GetTextListeners().textChanged( e
);
3927 void UnoTimeFieldControl::setTime( const util::Time
& Time
)
3929 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), Any(Time
), true );
3932 util::Time
UnoTimeFieldControl::getTime()
3934 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3937 void UnoTimeFieldControl::setMin( const util::Time
& Time
)
3939 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), uno::Any(Time
), true );
3942 util::Time
UnoTimeFieldControl::getMin()
3944 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
3947 void UnoTimeFieldControl::setMax( const util::Time
& Time
)
3949 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), uno::Any(Time
), true );
3952 util::Time
UnoTimeFieldControl::getMax()
3954 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
3957 void UnoTimeFieldControl::setFirst( const util::Time
& Time
)
3960 if ( getPeer().is() )
3962 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3963 xField
->setFirst( mnFirst
);
3967 util::Time
UnoTimeFieldControl::getFirst()
3972 void UnoTimeFieldControl::setLast( const util::Time
& Time
)
3975 if ( getPeer().is() )
3977 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3978 xField
->setFirst( mnLast
);
3982 util::Time
UnoTimeFieldControl::getLast()
3987 void UnoTimeFieldControl::setEmpty()
3989 if ( getPeer().is() )
3991 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3996 sal_Bool
UnoTimeFieldControl::isEmpty()
3998 bool bEmpty
= false;
3999 if ( getPeer().is() )
4001 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4002 bEmpty
= xField
->isEmpty();
4007 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
)
4009 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4012 sal_Bool
UnoTimeFieldControl::isStrictFormat()
4014 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4017 OUString
UnoTimeFieldControl::getImplementationName()
4019 return OUString("stardiv.Toolkit.UnoTimeFieldControl");
4022 css::uno::Sequence
<OUString
> UnoTimeFieldControl::getSupportedServiceNames()
4024 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4025 s
.realloc(s
.getLength() + 2);
4026 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeField";
4027 s
[s
.getLength() - 1] = "stardiv.vcl.control.TimeField";
4031 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4032 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
4033 css::uno::XComponentContext
*,
4034 css::uno::Sequence
<css::uno::Any
> const &)
4036 return cppu::acquire(new UnoTimeFieldControl());
4040 // class UnoControlNumericFieldModel
4042 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
4043 :UnoControlModel( rxContext
)
4045 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField
);
4048 OUString
UnoControlNumericFieldModel::getServiceName()
4050 return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel
);
4053 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4055 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4057 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlNumericField
) );
4059 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4063 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
4065 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4068 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4069 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4074 // beans::XMultiPropertySet
4075 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( )
4077 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4081 OUString
UnoControlNumericFieldModel::getImplementationName()
4083 return OUString("stardiv.Toolkit.UnoControlNumericFieldModel");
4086 css::uno::Sequence
<OUString
>
4087 UnoControlNumericFieldModel::getSupportedServiceNames()
4089 auto s(UnoControlModel::getSupportedServiceNames());
4090 s
.realloc(s
.getLength() + 2);
4091 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericFieldModel";
4092 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.NumericField";
4096 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4097 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
4098 css::uno::XComponentContext
*context
,
4099 css::uno::Sequence
<css::uno::Any
> const &)
4101 return cppu::acquire(new UnoControlNumericFieldModel(context
));
4105 // class UnoNumericFieldControl
4107 UnoNumericFieldControl::UnoNumericFieldControl()
4108 :UnoSpinFieldControl()
4111 mnLast
= 0x7FFFFFFF;
4114 OUString
UnoNumericFieldControl::GetComponentServiceName()
4116 return OUString("numericfield");
4120 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
)
4122 uno::Any aRet
= ::cppu::queryInterface( rType
,
4123 static_cast< awt::XNumericField
* >(this) );
4124 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4127 // lang::XTypeProvider
4128 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl
)
4129 cppu::UnoType
<awt::XNumericField
>::get(),
4130 UnoSpinFieldControl::getTypes()
4131 IMPL_XTYPEPROVIDER_END
4133 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4135 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4137 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4138 xField
->setFirst( mnFirst
);
4139 xField
->setLast( mnLast
);
4143 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
)
4145 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4146 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4148 if ( GetTextListeners().getLength() )
4149 GetTextListeners().textChanged( e
);
4152 void UnoNumericFieldControl::setValue( double Value
)
4154 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(Value
), true );
4157 double UnoNumericFieldControl::getValue()
4159 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4162 void UnoNumericFieldControl::setMin( double Value
)
4164 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4167 double UnoNumericFieldControl::getMin()
4169 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4172 void UnoNumericFieldControl::setMax( double Value
)
4174 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4177 double UnoNumericFieldControl::getMax()
4179 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4182 void UnoNumericFieldControl::setFirst( double Value
)
4185 if ( getPeer().is() )
4187 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4188 xField
->setFirst( mnFirst
);
4192 double UnoNumericFieldControl::getFirst()
4197 void UnoNumericFieldControl::setLast( double Value
)
4200 if ( getPeer().is() )
4202 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4203 xField
->setLast( mnLast
);
4207 double UnoNumericFieldControl::getLast()
4212 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
)
4214 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4217 sal_Bool
UnoNumericFieldControl::isStrictFormat()
4219 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4222 OUString
UnoNumericFieldControl::getImplementationName()
4224 return OUString("stardiv.Toolkit.UnoNumericFieldControl");
4227 css::uno::Sequence
<OUString
> UnoNumericFieldControl::getSupportedServiceNames()
4229 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4230 s
.realloc(s
.getLength() + 2);
4231 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericField";
4232 s
[s
.getLength() - 1] = "stardiv.vcl.control.NumericField";
4236 void UnoNumericFieldControl::setSpinSize( double Digits
)
4238 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4241 double UnoNumericFieldControl::getSpinSize()
4243 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4246 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
)
4248 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4251 sal_Int16
UnoNumericFieldControl::getDecimalDigits()
4253 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4256 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4257 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4258 css::uno::XComponentContext
*,
4259 css::uno::Sequence
<css::uno::Any
> const &)
4261 return cppu::acquire(new UnoNumericFieldControl());
4265 // class UnoControlCurrencyFieldModel
4267 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
4268 :UnoControlModel( rxContext
)
4270 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField
);
4273 OUString
UnoControlCurrencyFieldModel::getServiceName()
4275 return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel
);
4278 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4280 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4282 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlCurrencyField
) );
4284 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
4286 return uno::Any(false);
4289 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4292 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
4294 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4297 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4298 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4303 // beans::XMultiPropertySet
4304 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( )
4306 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4310 OUString
UnoControlCurrencyFieldModel::getImplementationName()
4312 return OUString("stardiv.Toolkit.UnoControlCurrencyFieldModel");
4315 css::uno::Sequence
<OUString
>
4316 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4318 auto s(UnoControlModel::getSupportedServiceNames());
4319 s
.realloc(s
.getLength() + 2);
4320 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyFieldModel";
4321 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CurrencyField";
4325 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4326 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4327 css::uno::XComponentContext
*context
,
4328 css::uno::Sequence
<css::uno::Any
> const &)
4330 return cppu::acquire(new UnoControlCurrencyFieldModel(context
));
4334 // class UnoCurrencyFieldControl
4336 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4337 :UnoSpinFieldControl()
4340 mnLast
= 0x7FFFFFFF;
4343 OUString
UnoCurrencyFieldControl::GetComponentServiceName()
4345 return OUString("longcurrencyfield");
4349 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
)
4351 uno::Any aRet
= ::cppu::queryInterface( rType
,
4352 static_cast< awt::XCurrencyField
* >(this) );
4353 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4356 // lang::XTypeProvider
4357 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl
)
4358 cppu::UnoType
<awt::XCurrencyField
>::get(),
4359 UnoSpinFieldControl::getTypes()
4360 IMPL_XTYPEPROVIDER_END
4362 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4364 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4366 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4367 xField
->setFirst( mnFirst
);
4368 xField
->setLast( mnLast
);
4371 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
)
4373 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4374 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4376 if ( GetTextListeners().getLength() )
4377 GetTextListeners().textChanged( e
);
4380 void UnoCurrencyFieldControl::setValue( double Value
)
4382 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), Any(Value
), true );
4385 double UnoCurrencyFieldControl::getValue()
4387 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4390 void UnoCurrencyFieldControl::setMin( double Value
)
4392 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4395 double UnoCurrencyFieldControl::getMin()
4397 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4400 void UnoCurrencyFieldControl::setMax( double Value
)
4402 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4405 double UnoCurrencyFieldControl::getMax()
4407 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4410 void UnoCurrencyFieldControl::setFirst( double Value
)
4413 if ( getPeer().is() )
4415 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4416 xField
->setFirst( mnFirst
);
4420 double UnoCurrencyFieldControl::getFirst()
4425 void UnoCurrencyFieldControl::setLast( double Value
)
4428 if ( getPeer().is() )
4430 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4431 xField
->setLast( mnLast
);
4435 double UnoCurrencyFieldControl::getLast()
4440 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
)
4442 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4445 sal_Bool
UnoCurrencyFieldControl::isStrictFormat()
4447 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4450 OUString
UnoCurrencyFieldControl::getImplementationName()
4452 return OUString("stardiv.Toolkit.UnoCurrencyFieldControl");
4455 css::uno::Sequence
<OUString
>
4456 UnoCurrencyFieldControl::getSupportedServiceNames()
4458 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4459 s
.realloc(s
.getLength() + 2);
4460 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyField";
4461 s
[s
.getLength() - 1] = "stardiv.vcl.control.CurrencyField";
4465 void UnoCurrencyFieldControl::setSpinSize( double Digits
)
4467 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4470 double UnoCurrencyFieldControl::getSpinSize()
4472 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4475 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
)
4477 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4480 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits()
4482 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4485 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4486 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4487 css::uno::XComponentContext
*,
4488 css::uno::Sequence
<css::uno::Any
> const &)
4490 return cppu::acquire(new UnoCurrencyFieldControl());
4494 // class UnoControlPatternFieldModel
4496 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4497 :UnoControlModel( rxContext
)
4499 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField
);
4502 OUString
UnoControlPatternFieldModel::getServiceName()
4504 return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel
);
4507 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4509 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4511 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlPatternField
) );
4513 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4516 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4518 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4521 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4522 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4527 // beans::XMultiPropertySet
4528 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( )
4530 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4534 OUString
UnoControlPatternFieldModel::getImplementationName()
4536 return OUString("stardiv.Toolkit.UnoControlPatternFieldModel");
4539 css::uno::Sequence
<OUString
>
4540 UnoControlPatternFieldModel::getSupportedServiceNames()
4542 auto s(UnoControlModel::getSupportedServiceNames());
4543 s
.realloc(s
.getLength() + 2);
4544 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternFieldModel";
4545 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.PatternField";
4549 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4550 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4551 css::uno::XComponentContext
*context
,
4552 css::uno::Sequence
<css::uno::Any
> const &)
4554 return cppu::acquire(new UnoControlPatternFieldModel(context
));
4558 // class UnoPatternFieldControl
4560 UnoPatternFieldControl::UnoPatternFieldControl()
4561 :UnoSpinFieldControl()
4565 OUString
UnoPatternFieldControl::GetComponentServiceName()
4567 return OUString("patternfield");
4570 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4572 sal_uInt16 nType
= GetPropertyId( rPropName
);
4573 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4575 // These masks cannot be set consecutively
4576 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4577 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4578 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4580 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4583 // same comment as in UnoControl::ImplSetPeerProperty - see there
4584 OUString
sText( Text
);
4585 ImplCheckLocalize( sText
);
4586 xPF
->setString( sText
);
4587 xPF
->setMasks( EditMask
, LiteralMask
);
4591 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4596 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
)
4598 uno::Any aRet
= ::cppu::queryInterface( rType
,
4599 static_cast< awt::XPatternField
* >(this) );
4600 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4603 // lang::XTypeProvider
4604 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl
)
4605 cppu::UnoType
<awt::XPatternField
>::get(),
4606 UnoSpinFieldControl::getTypes()
4607 IMPL_XTYPEPROVIDER_END
4609 void UnoPatternFieldControl::setString( const OUString
& rString
)
4614 OUString
UnoPatternFieldControl::getString()
4619 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
)
4621 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), uno::Any(EditMask
), true );
4622 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), uno::Any(LiteralMask
), true );
4625 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
)
4627 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4628 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4631 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
)
4633 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4636 sal_Bool
UnoPatternFieldControl::isStrictFormat()
4638 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4641 OUString
UnoPatternFieldControl::getImplementationName()
4643 return OUString("stardiv.Toolkit.UnoPatternFieldControl");
4646 css::uno::Sequence
<OUString
> UnoPatternFieldControl::getSupportedServiceNames()
4648 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4649 s
.realloc(s
.getLength() + 2);
4650 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternField";
4651 s
[s
.getLength() - 1] = "stardiv.vcl.control.PatternField";
4655 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4656 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4657 css::uno::XComponentContext
*,
4658 css::uno::Sequence
<css::uno::Any
> const &)
4660 return cppu::acquire(new UnoPatternFieldControl());
4664 // class UnoControlProgressBarModel
4666 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4667 :UnoControlModel( rxContext
)
4669 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4670 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4671 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4672 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4673 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4674 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4675 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4676 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4677 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4678 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4679 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4680 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4681 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4684 OUString
UnoControlProgressBarModel::getServiceName( )
4686 return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel
);
4689 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4691 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4693 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlProgressBar
) );
4696 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4699 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4701 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4704 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4705 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4710 // beans::XMultiPropertySet
4711 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( )
4713 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4717 OUString
UnoControlProgressBarModel::getImplementationName()
4719 return OUString("stardiv.Toolkit.UnoControlProgressBarModel");
4722 css::uno::Sequence
<OUString
>
4723 UnoControlProgressBarModel::getSupportedServiceNames()
4725 auto s(UnoControlModel::getSupportedServiceNames());
4726 s
.realloc(s
.getLength() + 2);
4727 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBarModel";
4728 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ProgressBar";
4732 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4733 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4734 css::uno::XComponentContext
*context
,
4735 css::uno::Sequence
<css::uno::Any
> const &)
4737 return cppu::acquire(new UnoControlProgressBarModel(context
));
4741 // class UnoProgressBarControl
4743 UnoProgressBarControl::UnoProgressBarControl()
4748 OUString
UnoProgressBarControl::GetComponentServiceName()
4750 return OUString("ProgressBar");
4754 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
)
4756 uno::Any aRet
= ::cppu::queryInterface( rType
,
4757 static_cast< awt::XProgressBar
* >(this) );
4758 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4761 // lang::XTypeProvider
4762 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl
)
4763 cppu::UnoType
<awt::XProgressBar
>::get(),
4764 UnoControlBase::getTypes()
4765 IMPL_XTYPEPROVIDER_END
4767 // css::awt::XProgressBar
4768 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
)
4770 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), uno::Any(nColor
), true );
4773 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
)
4775 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), uno::Any(nColor
), true );
4778 void UnoProgressBarControl::setValue( sal_Int32 nValue
)
4780 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), uno::Any(nValue
), true );
4783 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
)
4790 // take correct min and max
4796 // change min and max
4801 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, true );
4802 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, true );
4805 sal_Int32
UnoProgressBarControl::getValue()
4807 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4810 OUString
UnoProgressBarControl::getImplementationName()
4812 return OUString("stardiv.Toolkit.UnoProgressBarControl");
4815 css::uno::Sequence
<OUString
> UnoProgressBarControl::getSupportedServiceNames()
4817 auto s(UnoControlBase::getSupportedServiceNames());
4818 s
.realloc(s
.getLength() + 2);
4819 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBar";
4820 s
[s
.getLength() - 1] = "stardiv.vcl.control.ProgressBar";
4824 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4825 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
4826 css::uno::XComponentContext
*,
4827 css::uno::Sequence
<css::uno::Any
> const &)
4829 return cppu::acquire(new UnoProgressBarControl());
4833 // class UnoControlFixedLineModel
4835 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4836 :UnoControlModel( rxContext
)
4838 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4839 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4840 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4841 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4842 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4843 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4844 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4845 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4846 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4847 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4850 OUString
UnoControlFixedLineModel::getServiceName( )
4852 return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel
);
4855 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4857 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4859 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedLine
) );
4861 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4864 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4866 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4869 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4870 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4875 // beans::XMultiPropertySet
4876 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( )
4878 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4882 OUString
UnoControlFixedLineModel::getImplementationName()
4884 return OUString("stardiv.Toolkit.UnoControlFixedLineModel");
4887 css::uno::Sequence
<OUString
>
4888 UnoControlFixedLineModel::getSupportedServiceNames()
4890 auto s(UnoControlModel::getSupportedServiceNames());
4891 s
.realloc(s
.getLength() + 2);
4892 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLineModel";
4893 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedLine";
4897 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4898 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
4899 css::uno::XComponentContext
*context
,
4900 css::uno::Sequence
<css::uno::Any
> const &)
4902 return cppu::acquire(new UnoControlFixedLineModel(context
));
4906 // class UnoFixedLineControl
4908 UnoFixedLineControl::UnoFixedLineControl()
4911 maComponentInfos
.nWidth
= 100; // ??
4912 maComponentInfos
.nHeight
= 100; // ??
4915 OUString
UnoFixedLineControl::GetComponentServiceName()
4917 return OUString("FixedLine");
4920 sal_Bool
UnoFixedLineControl::isTransparent()
4925 OUString
UnoFixedLineControl::getImplementationName()
4927 return OUString("stardiv.Toolkit.UnoFixedLineControl");
4930 css::uno::Sequence
<OUString
> UnoFixedLineControl::getSupportedServiceNames()
4932 auto s(UnoControlBase::getSupportedServiceNames());
4933 s
.realloc(s
.getLength() + 2);
4934 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLine";
4935 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedLine";
4939 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
4940 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
4941 css::uno::XComponentContext
*,
4942 css::uno::Sequence
<css::uno::Any
> const &)
4944 return cppu::acquire(new UnoFixedLineControl());
4947 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */