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>
64 #include "helper/imagealign.hxx"
65 #include "helper/unopropertyarrayhelper.hxx"
68 using namespace css::awt
;
69 using namespace css::lang
;
70 using namespace css::uno
;
71 using ::com::sun::star::graphic::XGraphic
;
72 using ::com::sun::star::uno::Reference
;
73 using namespace ::toolkit
;
75 uno::Reference
< graphic::XGraphic
>
76 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const OUString
& _rURL
)
78 if ( _rURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX
) )
80 // graphic manager uniqueid
81 OUString sID
= _rURL
.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX
) - 1 );
82 xOutGraphicObj
= graphic::GraphicObject::createWithId( ::comphelper::getProcessComponentContext(), sID
);
85 xOutGraphicObj
= nullptr; // release the GraphicObject
87 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
90 css::uno::Reference
< css::graphic::XGraphic
>
91 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
)
93 uno::Reference
< graphic::XGraphic
> xGraphic
;
94 if ( _rURL
.isEmpty() )
99 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
100 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
101 uno::Sequence
< beans::PropertyValue
> aMediaProperties(1);
102 aMediaProperties
[0].Name
= "URL";
103 aMediaProperties
[0].Value
<<= _rURL
;
104 xGraphic
= xProvider
->queryGraphic( aMediaProperties
);
106 catch (const Exception
&)
108 DBG_UNHANDLED_EXCEPTION();
114 // class UnoControlEditModel
116 UnoControlEditModel::UnoControlEditModel( const Reference
< XComponentContext
>& rxContext
)
117 :UnoControlModel( rxContext
)
119 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit
);
122 OUString
UnoControlEditModel::getServiceName( )
124 return OUString::createFromAscii( szServiceName_UnoControlEditModel
);
127 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
133 case BASEPROPERTY_LINE_END_FORMAT
:
134 aReturn
<<= (sal_Int16
)awt::LineEndFormat::LINE_FEED
; // LF
136 case BASEPROPERTY_DEFAULTCONTROL
:
137 aReturn
<<= OUString::createFromAscii( szServiceName_UnoControlEdit
);
140 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
146 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
148 static UnoPropertyArrayHelper
* pHelper
= nullptr;
151 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
152 pHelper
= new UnoPropertyArrayHelper( aIDs
);
157 // beans::XMultiPropertySet
158 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( )
160 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
164 OUString
UnoControlEditModel::getImplementationName()
166 return OUString("stardiv.Toolkit.UnoControlEditModel");
169 css::uno::Sequence
<OUString
> UnoControlEditModel::getSupportedServiceNames()
171 auto s(UnoControlModel::getSupportedServiceNames());
172 s
.realloc(s
.getLength() + 2);
173 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlEditModel";
174 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Edit";
178 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
179 stardiv_Toolkit_UnoControlEditModel_get_implementation(
180 css::uno::XComponentContext
*context
,
181 css::uno::Sequence
<css::uno::Any
> const &)
183 return cppu::acquire(new UnoControlEditModel(context
));
187 // class UnoEditControl
189 UnoEditControl::UnoEditControl()
191 ,maTextListeners( *this )
193 ,mbSetTextInPeer( false )
194 ,mbSetMaxTextLenInPeer( false )
195 ,mbHasTextProperty( false )
197 maComponentInfos
.nWidth
= 100;
198 maComponentInfos
.nHeight
= 12;
200 mbSetMaxTextLenInPeer
= false;
203 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
)
205 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
206 if ( !aReturn
.hasValue() )
207 aReturn
= UnoEditControl_Base::queryInterface( rType
);
211 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
)
213 return UnoControlBase::queryInterface( rType
);
216 void SAL_CALL
UnoEditControl::acquire( ) throw ()
218 UnoControlBase::acquire();
221 void SAL_CALL
UnoEditControl::release( ) throw ()
223 UnoControlBase::release();
226 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
228 OUString
UnoEditControl::GetComponentServiceName()
230 // by default, we want a simple edit field
231 OUString
sName( "Edit" );
233 // but maybe we are to display multi-line text?
234 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
236 if ( ( aVal
>>= b
) && b
)
237 sName
= "MultiLineEdit";
242 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
)
244 bool bReturn
= UnoControlBase::setModel( _rModel
);
245 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
249 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
252 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
254 // #96986# use setText(), or text listener will not be called.
255 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
256 if ( xTextComponent
.is() )
260 ImplCheckLocalize( sText
);
261 xTextComponent
->setText( sText
);
267 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
270 void UnoEditControl::dispose()
272 lang::EventObject
aEvt( *this );
273 maTextListeners
.disposeAndClear( aEvt
);
274 UnoControl::dispose();
277 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
279 UnoControl::createPeer( rxToolkit
, rParentPeer
);
281 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
284 xText
->addTextListener( this );
286 if ( mbSetMaxTextLenInPeer
)
287 xText
->setMaxTextLen( mnMaxTextLen
);
288 if ( mbSetTextInPeer
)
289 xText
->setText( maText
);
293 void UnoEditControl::textChanged(const awt::TextEvent
& e
)
295 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
297 if ( mbHasTextProperty
)
299 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(xText
->getText()), false );
303 maText
= xText
->getText();
306 if ( maTextListeners
.getLength() )
307 maTextListeners
.textChanged( e
);
310 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
)
312 maTextListeners
.addInterface( l
);
315 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
)
317 maTextListeners
.removeInterface( l
);
320 void UnoEditControl::setText( const OUString
& aText
)
322 if ( mbHasTextProperty
)
324 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), uno::Any(aText
), true );
329 mbSetTextInPeer
= true;
330 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
332 xText
->setText( maText
);
335 // Setting the property to the VCLXWindow doesn't call textChanged
336 if ( maTextListeners
.getLength() )
338 awt::TextEvent aEvent
;
339 aEvent
.Source
= *this;
340 maTextListeners
.textChanged( aEvent
);
346 void lcl_normalize( awt::Selection
& _rSel
)
348 if ( _rSel
.Min
> _rSel
.Max
)
349 ::std::swap( _rSel
.Min
, _rSel
.Max
);
353 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
)
355 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
356 awt::Selection
aSelection( rSel
);
357 lcl_normalize( aSelection
);
359 // preserve the selection resp. cursor position
360 awt::Selection
aNewSelection( getSelection() );
361 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
362 // (not sure - looks uglier ...)
363 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
364 if ( aNewSelection
.Min
> aSelection
.Min
)
365 aNewSelection
.Min
-= nDeletedCharacters
;
366 if ( aNewSelection
.Max
> aSelection
.Max
)
367 aNewSelection
.Max
-= nDeletedCharacters
;
369 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
370 aNewSelection
.Min
= aNewSelection
.Max
;
373 OUString aOldText
= getText();
374 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
377 setSelection( aNewSelection
);
380 OUString
UnoEditControl::getText()
382 OUString aText
= maText
;
384 if ( mbHasTextProperty
)
385 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
388 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
390 aText
= xText
->getText();
396 OUString
UnoEditControl::getSelectedText()
399 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
401 sSelected
= xText
->getSelectedText();
406 void UnoEditControl::setSelection( const awt::Selection
& aSelection
)
408 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
410 xText
->setSelection( aSelection
);
413 awt::Selection
UnoEditControl::getSelection()
416 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
418 aSel
= xText
->getSelection();
422 sal_Bool
UnoEditControl::isEditable()
424 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
427 void UnoEditControl::setEditable( sal_Bool bEditable
)
429 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), uno::Any(!bEditable
), true );
432 sal_Int16
UnoEditControl::getMaxTextLen()
434 sal_Int16 nMaxLen
= mnMaxTextLen
;
436 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
437 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
442 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
)
444 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
446 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), uno::Any(nLen
), true );
451 mbSetMaxTextLenInPeer
= true;
452 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
454 xText
->setMaxTextLen( mnMaxTextLen
);
458 awt::Size
UnoEditControl::getMinimumSize( )
460 return Impl_getMinimumSize();
463 awt::Size
UnoEditControl::getPreferredSize( )
465 return Impl_getPreferredSize();
468 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
)
470 return Impl_calcAdjustedSize( rNewSize
);
473 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
475 return Impl_getMinimumSize( nCols
, nLines
);
478 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
480 Impl_getColumnsAndLines( nCols
, nLines
);
483 OUString
UnoEditControl::getImplementationName( )
485 return OUString( "stardiv.Toolkit.UnoEditControl" );
488 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames()
490 uno::Sequence
< OUString
> aNames
= UnoControlBase::getSupportedServiceNames( );
491 aNames
.realloc( aNames
.getLength() + 2 );
492 aNames
[ aNames
.getLength() - 2 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit
);
493 aNames
[ aNames
.getLength() - 1 ] = "stardiv.vcl.control.Edit";
497 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
498 stardiv_Toolkit_UnoEditControl_get_implementation(
499 css::uno::XComponentContext
*,
500 css::uno::Sequence
<css::uno::Any
> const &)
502 return cppu::acquire(new UnoEditControl());
506 // class UnoControlFileControlModel
508 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
509 :UnoControlModel( rxContext
)
511 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
512 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
513 ImplRegisterProperty( BASEPROPERTY_BORDER
);
514 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
515 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
516 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
517 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
518 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
519 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
520 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
521 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
522 ImplRegisterProperty( BASEPROPERTY_READONLY
);
523 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
524 ImplRegisterProperty( BASEPROPERTY_TEXT
);
525 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
526 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
527 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
528 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
531 OUString
UnoControlFileControlModel::getServiceName()
533 return OUString::createFromAscii( szServiceName_UnoControlFileControlModel
);
536 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
538 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
540 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFileControl
) );
542 return UnoControlModel::ImplGetDefaultValue( nPropId
);
545 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
547 static UnoPropertyArrayHelper
* pHelper
= nullptr;
550 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
551 pHelper
= new UnoPropertyArrayHelper( aIDs
);
556 // beans::XMultiPropertySet
557 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( )
559 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
563 OUString
UnoControlFileControlModel::getImplementationName()
565 return OUString("stardiv.Toolkit.UnoControlFileControlModel");
568 css::uno::Sequence
<OUString
>
569 UnoControlFileControlModel::getSupportedServiceNames()
571 auto s(UnoControlModel::getSupportedServiceNames());
572 s
.realloc(s
.getLength() + 2);
573 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControlModel";
574 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FileControl";
578 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
579 stardiv_Toolkit_UnoControlFileControlModel_get_implementation(
580 css::uno::XComponentContext
*context
,
581 css::uno::Sequence
<css::uno::Any
> const &)
583 return cppu::acquire(new UnoControlFileControlModel(context
));
587 // class UnoFileControl
589 UnoFileControl::UnoFileControl()
594 OUString
UnoFileControl::GetComponentServiceName()
596 return OUString("filecontrol");
599 OUString
UnoFileControl::getImplementationName()
601 return OUString("stardiv.Toolkit.UnoFileControl");
604 css::uno::Sequence
<OUString
> UnoFileControl::getSupportedServiceNames()
606 auto s(UnoEditControl::getSupportedServiceNames());
607 s
.realloc(s
.getLength() + 2);
608 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFileControl";
609 s
[s
.getLength() - 1] = "stardiv.vcl.control.FileControl";
613 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
614 stardiv_Toolkit_UnoFileControl_get_implementation(
615 css::uno::XComponentContext
*,
616 css::uno::Sequence
<css::uno::Any
> const &)
618 return cppu::acquire(new UnoFileControl());
622 // class GraphicControlModel
624 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
626 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
627 return uno::makeAny( uno::Reference
< graphic::XGraphic
>() );
629 return UnoControlModel::ImplGetDefaultValue( nPropId
);
632 void SAL_CALL
GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
)
634 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
636 // - ImageAlign and ImagePosition need to correspond to each other
637 // - Graphic and ImageURL need to correspond to each other
642 case BASEPROPERTY_IMAGEURL
:
643 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
645 mbAdjustingGraphic
= true;
647 OSL_VERIFY( rValue
>>= sImageURL
);
648 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC
, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
649 mbAdjustingGraphic
= false;
653 case BASEPROPERTY_GRAPHIC
:
654 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
656 mbAdjustingGraphic
= true;
657 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL
, uno::makeAny( OUString() ) );
658 mbAdjustingGraphic
= false;
662 case BASEPROPERTY_IMAGEALIGN
:
663 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
665 mbAdjustingImagePosition
= true;
666 sal_Int16 nUNOValue
= 0;
667 OSL_VERIFY( rValue
>>= nUNOValue
);
668 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION
, uno::makeAny( getExtendedImagePosition( nUNOValue
) ) );
669 mbAdjustingImagePosition
= false;
672 case BASEPROPERTY_IMAGEPOSITION
:
673 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
675 mbAdjustingImagePosition
= true;
676 sal_Int16 nUNOValue
= 0;
677 OSL_VERIFY( rValue
>>= nUNOValue
);
678 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN
, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
679 mbAdjustingImagePosition
= false;
684 catch( const css::uno::Exception
& )
686 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
687 DBG_UNHANDLED_EXCEPTION();
688 mbAdjustingImagePosition
= false;
693 // class UnoControlButtonModel
695 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
696 :GraphicControlModel( rxContext
)
698 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton
);
700 osl_atomic_increment( &m_refCount
);
702 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
703 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
704 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
706 osl_atomic_decrement( &m_refCount
);
709 OUString
UnoControlButtonModel::getServiceName()
711 return OUString::createFromAscii( szServiceName_UnoControlButtonModel
);
714 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
718 case BASEPROPERTY_DEFAULTCONTROL
:
719 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton
) );
720 case BASEPROPERTY_TOGGLE
:
721 return uno::makeAny( false );
722 case BASEPROPERTY_ALIGN
:
723 return uno::makeAny( (sal_Int16
)PROPERTY_ALIGN_CENTER
);
724 case BASEPROPERTY_FOCUSONCLICK
:
725 return uno::makeAny( true );
728 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
731 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
733 static UnoPropertyArrayHelper
* pHelper
= nullptr;
736 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
737 pHelper
= new UnoPropertyArrayHelper( aIDs
);
742 // beans::XMultiPropertySet
743 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( )
745 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
749 OUString
UnoControlButtonModel::getImplementationName()
751 return OUString("stardiv.Toolkit.UnoControlButtonModel");
754 css::uno::Sequence
<OUString
> UnoControlButtonModel::getSupportedServiceNames()
756 auto s(GraphicControlModel::getSupportedServiceNames());
757 s
.realloc(s
.getLength() + 2);
758 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButtonModel";
759 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.Button";
763 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
764 stardiv_Toolkit_UnoControlButtonModel_get_implementation(
765 css::uno::XComponentContext
*context
,
766 css::uno::Sequence
<css::uno::Any
> const &)
768 return cppu::acquire(new UnoControlButtonModel(context
));
772 // class UnoButtonControl
774 UnoButtonControl::UnoButtonControl()
775 :UnoButtonControl_Base()
776 ,maActionListeners( *this )
777 ,maItemListeners( *this )
779 maComponentInfos
.nWidth
= 50;
780 maComponentInfos
.nHeight
= 14;
783 OUString
UnoButtonControl::GetComponentServiceName()
785 OUString
aName( "pushbutton" );
786 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
787 sal_Int16 n
= sal_Int16();
788 if ( ( aVal
>>= n
) && n
)
790 // Use PushButtonType later when available...
793 case 1 /*PushButtonType::OK*/: aName
= "okbutton";
795 case 2 /*PushButtonType::CANCEL*/: aName
= "cancelbutton";
797 case 3 /*PushButtonType::HELP*/: aName
= "helpbutton";
801 OSL_FAIL( "Unknown Button Type!" );
808 void UnoButtonControl::dispose()
810 lang::EventObject aEvt
;
811 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
812 maActionListeners
.disposeAndClear( aEvt
);
813 maItemListeners
.disposeAndClear( aEvt
);
814 UnoControlBase::dispose();
817 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
819 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
821 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
822 xButton
->setActionCommand( maActionCommand
);
823 if ( maActionListeners
.getLength() )
824 xButton
->addActionListener( &maActionListeners
);
826 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
827 if ( xPushButton
.is() )
828 xPushButton
->addItemListener( this );
831 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
833 maActionListeners
.addInterface( l
);
834 if( getPeer().is() && maActionListeners
.getLength() == 1 )
836 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
837 xButton
->addActionListener( &maActionListeners
);
841 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
843 if( getPeer().is() && maActionListeners
.getLength() == 1 )
845 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
846 xButton
->removeActionListener( &maActionListeners
);
848 maActionListeners
.removeInterface( l
);
851 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
853 maItemListeners
.addInterface( l
);
856 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
858 maItemListeners
.removeInterface( l
);
861 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
)
863 UnoControlBase::disposing( Source
);
866 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
869 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
)rEvent
.Selected
), false );
872 ItemEvent
aEvent( rEvent
);
873 aEvent
.Source
= *this;
874 maItemListeners
.itemStateChanged( aEvent
);
877 void UnoButtonControl::setLabel( const OUString
& rLabel
)
879 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
882 void UnoButtonControl::setActionCommand( const OUString
& rCommand
)
884 maActionCommand
= rCommand
;
885 if ( getPeer().is() )
887 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
888 xButton
->setActionCommand( rCommand
);
892 awt::Size
UnoButtonControl::getMinimumSize( )
894 return Impl_getMinimumSize();
897 awt::Size
UnoButtonControl::getPreferredSize( )
899 return Impl_getPreferredSize();
902 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
904 return Impl_calcAdjustedSize( rNewSize
);
907 OUString
UnoButtonControl::getImplementationName()
909 return OUString("stardiv.Toolkit.UnoButtonControl");
912 css::uno::Sequence
<OUString
> UnoButtonControl::getSupportedServiceNames()
914 auto s(UnoControlBase::getSupportedServiceNames());
915 s
.realloc(s
.getLength() + 2);
916 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlButton";
917 s
[s
.getLength() - 1] = "stardiv.vcl.control.Button";
921 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
922 stardiv_Toolkit_UnoButtonControl_get_implementation(
923 css::uno::XComponentContext
*,
924 css::uno::Sequence
<css::uno::Any
> const &)
926 return cppu::acquire(new UnoButtonControl());
930 // class UnoControlImageControlModel
932 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
933 :GraphicControlModel( rxContext
)
934 ,mbAdjustingImageScaleMode( false )
936 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl
);
939 OUString
UnoControlImageControlModel::getServiceName()
941 return OUString::createFromAscii( szServiceName_UnoControlImageControlModel
);
944 OUString
UnoControlImageControlModel::getImplementationName()
946 return OUString("stardiv.Toolkit.UnoControlImageControlModel");
949 css::uno::Sequence
<OUString
>
950 UnoControlImageControlModel::getSupportedServiceNames()
952 auto s(GraphicControlModel::getSupportedServiceNames());
953 s
.realloc(s
.getLength() + 4);
954 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButtonModel";
955 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControlModel";
956 s
[s
.getLength() - 2] = "stardiv.vcl.controlmodel.ImageButton";
957 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ImageControl";
961 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
963 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
964 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl
) );
966 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
967 return makeAny( awt::ImageScaleMode::ANISOTROPIC
);
969 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
972 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
974 static UnoPropertyArrayHelper
* pHelper
= nullptr;
977 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
978 pHelper
= new UnoPropertyArrayHelper( aIDs
);
983 // beans::XMultiPropertySet
984 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( )
986 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
990 void SAL_CALL
UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
992 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
994 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
999 case BASEPROPERTY_IMAGE_SCALE_MODE
:
1000 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
1002 mbAdjustingImageScaleMode
= true;
1003 sal_Int16
nScaleMode( awt::ImageScaleMode::ANISOTROPIC
);
1004 OSL_VERIFY( _rValue
>>= nScaleMode
);
1005 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE
, uno::makeAny( nScaleMode
!= awt::ImageScaleMode::NONE
) );
1006 mbAdjustingImageScaleMode
= false;
1009 case BASEPROPERTY_SCALEIMAGE
:
1010 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
1012 mbAdjustingImageScaleMode
= true;
1014 OSL_VERIFY( _rValue
>>= bScale
);
1015 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE
, uno::makeAny( bScale
? awt::ImageScaleMode::ANISOTROPIC
: awt::ImageScaleMode::NONE
) );
1016 mbAdjustingImageScaleMode
= false;
1021 catch( const Exception
& )
1023 mbAdjustingImageScaleMode
= false;
1028 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1029 stardiv_Toolkit_UnoControlImageControlModel_get_implementation(
1030 css::uno::XComponentContext
*context
,
1031 css::uno::Sequence
<css::uno::Any
> const &)
1033 return cppu::acquire(new UnoControlImageControlModel(context
));
1037 // class UnoImageControlControl
1039 UnoImageControlControl::UnoImageControlControl()
1040 :UnoImageControlControl_Base()
1041 ,maActionListeners( *this )
1043 // TODO: Where should I look for defaults?
1044 maComponentInfos
.nWidth
= 100;
1045 maComponentInfos
.nHeight
= 100;
1048 OUString
UnoImageControlControl::GetComponentServiceName()
1050 return OUString("fixedimage");
1053 void UnoImageControlControl::dispose()
1055 lang::EventObject aEvt
;
1056 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1057 maActionListeners
.disposeAndClear( aEvt
);
1058 UnoControl::dispose();
1061 sal_Bool
UnoImageControlControl::isTransparent()
1066 awt::Size
UnoImageControlControl::getMinimumSize( )
1068 return Impl_getMinimumSize();
1071 awt::Size
UnoImageControlControl::getPreferredSize( )
1073 return Impl_getPreferredSize();
1076 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1078 return Impl_calcAdjustedSize( rNewSize
);
1081 OUString
UnoImageControlControl::getImplementationName()
1083 return OUString("stardiv.Toolkit.UnoImageControlControl");
1086 css::uno::Sequence
<OUString
> UnoImageControlControl::getSupportedServiceNames()
1088 auto s(UnoControlBase::getSupportedServiceNames());
1089 s
.realloc(s
.getLength() + 4);
1090 s
[s
.getLength() - 4] = "com.sun.star.awt.UnoControlImageButton";
1091 s
[s
.getLength() - 3] = "com.sun.star.awt.UnoControlImageControl";
1092 s
[s
.getLength() - 2] = "stardiv.vcl.control.ImageButton";
1093 s
[s
.getLength() - 1] = "stardiv.vcl.control.ImageControl";
1097 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1098 stardiv_Toolkit_UnoImageControlControl_get_implementation(
1099 css::uno::XComponentContext
*,
1100 css::uno::Sequence
<css::uno::Any
> const &)
1102 return cppu::acquire(new UnoImageControlControl());
1106 // class UnoControlRadioButtonModel
1108 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
1109 :GraphicControlModel( rxContext
)
1111 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton
);
1114 OUString
UnoControlRadioButtonModel::getServiceName()
1116 return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel
);
1119 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1123 case BASEPROPERTY_DEFAULTCONTROL
:
1124 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton
) );
1126 case BASEPROPERTY_VISUALEFFECT
:
1127 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1130 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1133 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
1135 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1138 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1139 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1144 // beans::XMultiPropertySet
1145 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( )
1147 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1151 OUString
UnoControlRadioButtonModel::getImplementationName()
1153 return OUString("stardiv.Toolkit.UnoControlRadioButtonModel");
1156 css::uno::Sequence
<OUString
>
1157 UnoControlRadioButtonModel::getSupportedServiceNames()
1159 auto s(GraphicControlModel::getSupportedServiceNames());
1160 s
.realloc(s
.getLength() + 2);
1161 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButtonModel";
1162 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.RadioButton";
1166 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1167 stardiv_Toolkit_UnoControlRadioButtonModel_get_implementation(
1168 css::uno::XComponentContext
*context
,
1169 css::uno::Sequence
<css::uno::Any
> const &)
1171 return cppu::acquire(new UnoControlRadioButtonModel(context
));
1175 // class UnoRadioButtonControl
1177 UnoRadioButtonControl::UnoRadioButtonControl()
1178 :UnoRadioButtonControl_Base()
1179 ,maItemListeners( *this )
1180 ,maActionListeners( *this )
1182 maComponentInfos
.nWidth
= 100;
1183 maComponentInfos
.nHeight
= 12;
1186 OUString
UnoRadioButtonControl::GetComponentServiceName()
1188 return OUString("radiobutton");
1191 void UnoRadioButtonControl::dispose()
1193 lang::EventObject aEvt
;
1194 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1195 maItemListeners
.disposeAndClear( aEvt
);
1196 UnoControlBase::dispose();
1200 sal_Bool
UnoRadioButtonControl::isTransparent()
1205 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1207 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1209 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1210 xRadioButton
->addItemListener( this );
1212 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1213 xButton
->setActionCommand( maActionCommand
);
1214 if ( maActionListeners
.getLength() )
1215 xButton
->addActionListener( &maActionListeners
);
1217 // as default, set the "AutoToggle" to true
1218 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1219 // have it enabled by default because of 85071)
1220 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1221 if ( xVclWindowPeer
.is() )
1222 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), css::uno::Any(true) );
1225 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1227 maItemListeners
.addInterface( l
);
1230 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1232 maItemListeners
.removeInterface( l
);
1235 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1237 maActionListeners
.addInterface( l
);
1238 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1240 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1241 xButton
->addActionListener( &maActionListeners
);
1245 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1247 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1249 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1250 xButton
->removeActionListener( &maActionListeners
);
1252 maActionListeners
.removeInterface( l
);
1255 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
)
1257 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1260 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
)
1262 maActionCommand
= rCommand
;
1263 if ( getPeer().is() )
1265 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1266 xButton
->setActionCommand( rCommand
);
1270 void UnoRadioButtonControl::setState( sal_Bool bOn
)
1272 sal_Int16 nState
= bOn
? 1 : 0;
1273 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any(nState
), true );
1276 sal_Bool
UnoRadioButtonControl::getState()
1278 sal_Int16 nState
= 0;
1279 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1284 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1286 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
)rEvent
.Selected
), false );
1289 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1290 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1292 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1293 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1294 // isn't the case anymore: For instance, this method here gets called for the radio button
1295 // which is being implicitly _de_selected, too. This is pretty bad for compatibility.
1296 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1297 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1298 // all which matters here.
1300 if ( 1 == rEvent
.Selected
)
1302 if ( maItemListeners
.getLength() )
1303 maItemListeners
.itemStateChanged( rEvent
);
1305 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1306 // a radio button _without_ selecting another one, this would have caused a notification.
1307 // With the change done here, this today won't cause a notification anymore.
1309 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1310 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1311 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1312 // to be inconsistent with.
1315 awt::Size
UnoRadioButtonControl::getMinimumSize( )
1317 return Impl_getMinimumSize();
1320 awt::Size
UnoRadioButtonControl::getPreferredSize( )
1322 return Impl_getPreferredSize();
1325 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1327 return Impl_calcAdjustedSize( rNewSize
);
1330 OUString
UnoRadioButtonControl::getImplementationName()
1332 return OUString("stardiv.Toolkit.UnoRadioButtonControl");
1335 css::uno::Sequence
<OUString
> UnoRadioButtonControl::getSupportedServiceNames()
1337 auto s(UnoControlBase::getSupportedServiceNames());
1338 s
.realloc(s
.getLength() + 2);
1339 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlRadioButton";
1340 s
[s
.getLength() - 1] = "stardiv.vcl.control.RadioButton";
1344 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1345 stardiv_Toolkit_UnoRadioButtonControl_get_implementation(
1346 css::uno::XComponentContext
*,
1347 css::uno::Sequence
<css::uno::Any
> const &)
1349 return cppu::acquire(new UnoRadioButtonControl());
1353 // class UnoControlCheckBoxModel
1355 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1356 :GraphicControlModel( rxContext
)
1358 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox
);
1361 OUString
UnoControlCheckBoxModel::getServiceName()
1363 return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel
);
1366 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1370 case BASEPROPERTY_DEFAULTCONTROL
:
1371 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox
) );
1373 case BASEPROPERTY_VISUALEFFECT
:
1374 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1377 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1380 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1382 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1385 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1386 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1391 // beans::XMultiPropertySet
1392 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( )
1394 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1398 OUString
UnoControlCheckBoxModel::getImplementationName()
1400 return OUString( "stardiv.Toolkit.UnoControlCheckBoxModel");
1403 css::uno::Sequence
<OUString
> UnoControlCheckBoxModel::getSupportedServiceNames()
1405 auto s(GraphicControlModel::getSupportedServiceNames());
1406 s
.realloc(s
.getLength() + 2);
1407 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBoxModel";
1408 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CheckBox";
1412 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1413 stardiv_Toolkit_UnoControlCheckBoxModel_get_implementation(
1414 css::uno::XComponentContext
*context
,
1415 css::uno::Sequence
<css::uno::Any
> const &)
1417 return cppu::acquire(new UnoControlCheckBoxModel(context
));
1421 // class UnoCheckBoxControl
1423 UnoCheckBoxControl::UnoCheckBoxControl()
1424 :UnoCheckBoxControl_Base()
1425 ,maItemListeners( *this ), maActionListeners( *this )
1427 maComponentInfos
.nWidth
= 100;
1428 maComponentInfos
.nHeight
= 12;
1431 OUString
UnoCheckBoxControl::GetComponentServiceName()
1433 return OUString("checkbox");
1436 void UnoCheckBoxControl::dispose()
1438 lang::EventObject aEvt
;
1439 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1440 maItemListeners
.disposeAndClear( aEvt
);
1441 UnoControlBase::dispose();
1444 sal_Bool
UnoCheckBoxControl::isTransparent()
1449 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1451 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1453 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1454 xCheckBox
->addItemListener( this );
1456 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1457 xButton
->setActionCommand( maActionCommand
);
1458 if ( maActionListeners
.getLength() )
1459 xButton
->addActionListener( &maActionListeners
);
1462 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1464 maItemListeners
.addInterface( l
);
1467 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
1469 maItemListeners
.removeInterface( l
);
1472 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1474 maActionListeners
.addInterface( l
);
1475 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1477 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1478 xButton
->addActionListener( &maActionListeners
);
1482 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1484 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1486 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1487 xButton
->removeActionListener( &maActionListeners
);
1489 maActionListeners
.removeInterface( l
);
1492 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
)
1494 maActionCommand
= rCommand
;
1495 if ( getPeer().is() )
1497 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1498 xButton
->setActionCommand( rCommand
);
1503 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
)
1505 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(rLabel
), true );
1508 void UnoCheckBoxControl::setState( short n
)
1510 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
) n
), true );
1513 short UnoCheckBoxControl::getState()
1516 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1521 void UnoCheckBoxControl::enableTriState( sal_Bool b
)
1523 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), uno::Any(b
), true );
1526 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
1528 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), uno::Any((sal_Int16
) rEvent
.Selected
), false );
1530 if ( maItemListeners
.getLength() )
1531 maItemListeners
.itemStateChanged( rEvent
);
1534 awt::Size
UnoCheckBoxControl::getMinimumSize( )
1536 return Impl_getMinimumSize();
1539 awt::Size
UnoCheckBoxControl::getPreferredSize( )
1541 return Impl_getPreferredSize();
1544 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1546 return Impl_calcAdjustedSize( rNewSize
);
1549 OUString
UnoCheckBoxControl::getImplementationName()
1551 return OUString("stardiv.Toolkit.UnoCheckBoxControl");
1554 css::uno::Sequence
<OUString
> UnoCheckBoxControl::getSupportedServiceNames()
1556 auto s(UnoControlBase::getSupportedServiceNames());
1557 s
.realloc(s
.getLength() + 2);
1558 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCheckBox";
1559 s
[s
.getLength() - 1] = "stardiv.vcl.control.CheckBox";
1563 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1564 stardiv_Toolkit_UnoCheckBoxControl_get_implementation(
1565 css::uno::XComponentContext
*,
1566 css::uno::Sequence
<css::uno::Any
> const &)
1568 return cppu::acquire(new UnoCheckBoxControl());
1572 // class UnoControlFixedHyperlinkModel
1574 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1575 :UnoControlModel( rxContext
)
1577 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink
);
1580 OUString
UnoControlFixedHyperlinkModel::getServiceName()
1582 return OUString( "com.sun.star.awt.UnoControlFixedHyperlinkModel" );
1585 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1587 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1589 return uno::Any( OUString( "com.sun.star.awt.UnoControlFixedHyperlink" ) );
1591 else if ( nPropId
== BASEPROPERTY_BORDER
)
1593 return uno::Any((sal_Int16
) 0);
1595 else if ( nPropId
== BASEPROPERTY_URL
)
1597 return uno::Any( OUString() );
1600 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1603 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1605 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1608 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1609 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1614 // beans::XMultiPropertySet
1615 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( )
1617 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1621 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1622 stardiv_Toolkit_UnoControlFixedHyperlinkModel_get_implementation(
1623 css::uno::XComponentContext
*context
,
1624 css::uno::Sequence
<css::uno::Any
> const &)
1626 return cppu::acquire(new UnoControlFixedHyperlinkModel(context
));
1630 // class UnoFixedHyperlinkControl
1632 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1634 ,maActionListeners( *this )
1636 maComponentInfos
.nWidth
= 100;
1637 maComponentInfos
.nHeight
= 12;
1640 OUString
UnoFixedHyperlinkControl::GetComponentServiceName()
1642 return OUString("fixedhyperlink");
1646 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
)
1648 uno::Any aRet
= ::cppu::queryInterface( rType
,
1649 (static_cast< awt::XFixedHyperlink
* >(this)),
1650 (static_cast< awt::XLayoutConstrains
* >(this)) );
1651 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1654 // lang::XTypeProvider
1655 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl
)
1656 cppu::UnoType
<awt::XFixedHyperlink
>::get(),
1657 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1658 UnoControlBase::getTypes()
1659 IMPL_XTYPEPROVIDER_END
1661 sal_Bool
UnoFixedHyperlinkControl::isTransparent()
1666 void UnoFixedHyperlinkControl::setText( const OUString
& Text
)
1668 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1671 OUString
UnoFixedHyperlinkControl::getText()
1673 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1676 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
)
1678 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), uno::Any(URL
), true );
1681 OUString
UnoFixedHyperlinkControl::getURL( )
1683 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1686 void UnoFixedHyperlinkControl::setAlignment( short nAlign
)
1688 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any((sal_Int16
) nAlign
), true );
1691 short UnoFixedHyperlinkControl::getAlignment()
1696 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1702 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( )
1704 return Impl_getMinimumSize();
1707 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( )
1709 return Impl_getPreferredSize();
1712 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1714 return Impl_calcAdjustedSize( rNewSize
);
1717 void UnoFixedHyperlinkControl::dispose()
1719 lang::EventObject aEvt
;
1720 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
1721 maActionListeners
.disposeAndClear( aEvt
);
1722 UnoControlBase::dispose();
1725 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
1727 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1729 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1730 if ( maActionListeners
.getLength() )
1731 xFixedHyperlink
->addActionListener( &maActionListeners
);
1734 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1736 maActionListeners
.addInterface( l
);
1737 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1739 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1740 xFixedHyperlink
->addActionListener( &maActionListeners
);
1744 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
1746 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1748 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1749 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1751 maActionListeners
.removeInterface( l
);
1754 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1755 stardiv_Toolkit_UnoFixedHyperlinkControl_get_implementation(
1756 css::uno::XComponentContext
*,
1757 css::uno::Sequence
<css::uno::Any
> const &)
1759 return cppu::acquire(new UnoFixedHyperlinkControl());
1763 // class UnoControlFixedTextModel
1765 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1766 :UnoControlModel( rxContext
)
1768 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText
);
1771 OUString
UnoControlFixedTextModel::getServiceName()
1773 return OUString( "stardiv.vcl.controlmodel.FixedText" );
1776 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1778 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1780 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedText
) );
1782 else if ( nPropId
== BASEPROPERTY_BORDER
)
1784 return uno::Any((sal_Int16
)0);
1787 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1790 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1792 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1795 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1796 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1801 // beans::XMultiPropertySet
1802 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( )
1804 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1808 OUString
UnoControlFixedTextModel::getImplementationName()
1810 return OUString("stardiv.Toolkit.UnoControlFixedTextModel");
1813 css::uno::Sequence
<OUString
>
1814 UnoControlFixedTextModel::getSupportedServiceNames()
1816 auto s(UnoControlModel::getSupportedServiceNames());
1817 s
.realloc(s
.getLength() + 2);
1818 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedTextModel";
1819 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedText";
1823 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1824 stardiv_Toolkit_UnoControlFixedTextModel_get_implementation(
1825 css::uno::XComponentContext
*context
,
1826 css::uno::Sequence
<css::uno::Any
> const &)
1828 return cppu::acquire(new UnoControlFixedTextModel(context
));
1832 // class UnoFixedTextControl
1834 UnoFixedTextControl::UnoFixedTextControl()
1837 maComponentInfos
.nWidth
= 100;
1838 maComponentInfos
.nHeight
= 12;
1841 OUString
UnoFixedTextControl::GetComponentServiceName()
1843 return OUString("fixedtext");
1847 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
)
1849 uno::Any aRet
= ::cppu::queryInterface( rType
,
1850 (static_cast< awt::XFixedText
* >(this)),
1851 (static_cast< awt::XLayoutConstrains
* >(this)) );
1852 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1855 // lang::XTypeProvider
1856 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl
)
1857 cppu::UnoType
<awt::XFixedText
>::get(),
1858 cppu::UnoType
<awt::XLayoutConstrains
>::get(),
1859 UnoControlBase::getTypes()
1860 IMPL_XTYPEPROVIDER_END
1862 sal_Bool
UnoFixedTextControl::isTransparent()
1867 void UnoFixedTextControl::setText( const OUString
& Text
)
1869 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), uno::Any(Text
), true );
1872 OUString
UnoFixedTextControl::getText()
1874 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1877 void UnoFixedTextControl::setAlignment( short nAlign
)
1879 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), uno::Any((sal_Int16
) nAlign
), true );
1882 short UnoFixedTextControl::getAlignment()
1887 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1893 awt::Size
UnoFixedTextControl::getMinimumSize( )
1895 return Impl_getMinimumSize();
1898 awt::Size
UnoFixedTextControl::getPreferredSize( )
1900 return Impl_getPreferredSize();
1903 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
)
1905 return Impl_calcAdjustedSize( rNewSize
);
1908 OUString
UnoFixedTextControl::getImplementationName()
1910 return OUString("stardiv.Toolkit.UnoFixedTextControl");
1913 css::uno::Sequence
<OUString
> UnoFixedTextControl::getSupportedServiceNames()
1915 auto s(UnoControlBase::getSupportedServiceNames());
1916 s
.realloc(s
.getLength() + 2);
1917 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedText";
1918 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedText";
1922 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1923 stardiv_Toolkit_UnoFixedTextControl_get_implementation(
1924 css::uno::XComponentContext
*,
1925 css::uno::Sequence
<css::uno::Any
> const &)
1927 return cppu::acquire(new UnoFixedTextControl());
1931 // class UnoControlGroupBoxModel
1933 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1934 :UnoControlModel( rxContext
)
1936 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1937 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1938 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1939 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1940 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1941 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1942 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1943 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1944 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1945 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1948 OUString
UnoControlGroupBoxModel::getServiceName()
1950 return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel
);
1953 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1955 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1957 return uno::Any(OUString::createFromAscii( szServiceName_UnoControlGroupBox
) );
1959 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1962 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1964 static UnoPropertyArrayHelper
* pHelper
= nullptr;
1967 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1968 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1973 // beans::XMultiPropertySet
1974 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( )
1976 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1980 OUString
UnoControlGroupBoxModel::getImplementationName()
1982 return OUString("stardiv.Toolkit.UnoControlGroupBoxModel");
1985 css::uno::Sequence
<OUString
> UnoControlGroupBoxModel::getSupportedServiceNames()
1987 auto s(UnoControlModel::getSupportedServiceNames());
1988 s
.realloc(s
.getLength() + 2);
1989 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBoxModel";
1990 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.GroupBox";
1994 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
1995 stardiv_Toolkit_UnoControlGroupBoxModel_get_implementation(
1996 css::uno::XComponentContext
*context
,
1997 css::uno::Sequence
<css::uno::Any
> const &)
1999 return cppu::acquire(new UnoControlGroupBoxModel(context
));
2003 // class UnoGroupBoxControl
2005 UnoGroupBoxControl::UnoGroupBoxControl()
2008 maComponentInfos
.nWidth
= 100;
2009 maComponentInfos
.nHeight
= 100;
2012 OUString
UnoGroupBoxControl::GetComponentServiceName()
2014 return OUString("groupbox");
2017 sal_Bool
UnoGroupBoxControl::isTransparent()
2022 OUString
UnoGroupBoxControl::getImplementationName()
2024 return OUString("stardiv.Toolkit.UnoGroupBoxControl");
2027 css::uno::Sequence
<OUString
> UnoGroupBoxControl::getSupportedServiceNames()
2029 auto s(UnoControlBase::getSupportedServiceNames());
2030 s
.realloc(s
.getLength() + 2);
2031 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlGroupBox";
2032 s
[s
.getLength() - 1] = "stardiv.vcl.control.GroupBox";
2036 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
2037 stardiv_Toolkit_UnoGroupBoxControl_get_implementation(
2038 css::uno::XComponentContext
*,
2039 css::uno::Sequence
<css::uno::Any
> const &)
2041 return cppu::acquire(new UnoGroupBoxControl());
2045 // = UnoControlListBoxModel_Data
2050 OUString ItemImageURL
;
2060 explicit ListItem( const OUString
& i_rItemText
)
2061 :ItemText( i_rItemText
)
2068 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
2070 struct StripItemData
: public ::std::unary_function
< ListItem
, UnoListItem
>
2072 UnoListItem
operator()( const ListItem
& i_rItem
)
2074 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
2078 struct UnoControlListBoxModel_Data
2080 explicit UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
2081 :m_bSettingLegacyProperty( false )
2082 ,m_rAntiImpl( i_rAntiImpl
)
2087 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
2089 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
2091 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2092 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2093 return m_aListItems
[ i_nIndex
];
2096 ListItem
& getItem( const sal_Int32 i_nIndex
)
2098 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
2101 ListItem
& insertItem( const sal_Int32 i_nIndex
)
2103 if ( ( i_nIndex
< 0 ) || ( i_nIndex
> sal_Int32( m_aListItems
.size() ) ) )
2104 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2105 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
2108 Sequence
< UnoListItem
> getAllItems() const
2110 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
2111 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
2115 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
2117 m_aListItems
= i_copySource
.m_aListItems
;
2120 void setAllItems( const ::std::vector
< ListItem
>& i_rItems
)
2122 m_aListItems
= i_rItems
;
2125 void removeItem( const sal_Int32 i_nIndex
)
2127 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
2128 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
2129 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
2132 void removeAllItems()
2134 ::std::vector
< ListItem
> aEmpty
;
2135 m_aListItems
.swap( aEmpty
);
2139 bool m_bSettingLegacyProperty
;
2142 UnoControlListBoxModel
& m_rAntiImpl
;
2143 ::std::vector
< ListItem
> m_aListItems
;
2147 // = UnoControlListBoxModel
2150 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
2151 :UnoControlListBoxModel_Base( rxContext
)
2152 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2153 ,m_aItemListListeners( GetMutex() )
2155 if ( i_mode
== ConstructDefault
)
2157 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox
);
2161 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
2162 :UnoControlListBoxModel_Base( i_rSource
)
2163 ,m_xData( new UnoControlListBoxModel_Data( *this ) )
2164 ,m_aItemListListeners( GetMutex() )
2166 m_xData
->copyItems( *i_rSource
.m_xData
);
2168 UnoControlListBoxModel::~UnoControlListBoxModel()
2172 OUString
UnoControlListBoxModel::getImplementationName()
2174 return OUString("stardiv.Toolkit.UnoControlListBoxModel");
2177 css::uno::Sequence
<OUString
> UnoControlListBoxModel::getSupportedServiceNames()
2179 auto s(UnoControlModel::getSupportedServiceNames());
2180 s
.realloc(s
.getLength() + 2);
2181 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBoxModel";
2182 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ListBox";
2186 OUString
UnoControlListBoxModel::getServiceName()
2188 return OUString::createFromAscii( szServiceName_UnoControlListBoxModel
);
2192 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2194 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2196 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlListBox
) );
2198 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2202 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
2204 static UnoPropertyArrayHelper
* pHelper
= nullptr;
2207 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
2208 pHelper
= new UnoPropertyArrayHelper( aIDs
);
2214 // beans::XMultiPropertySet
2215 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( )
2217 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2224 struct CreateListItem
: public ::std::unary_function
< OUString
, ListItem
>
2226 ListItem
operator()( const OUString
& i_rItemText
)
2228 return ListItem( i_rItemText
);
2234 void SAL_CALL
UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
)
2236 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
2238 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
)
2241 uno::Sequence
<sal_Int16
> aSeq
;
2242 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS
, uno::Any(aSeq
) );
2244 if ( !m_xData
->m_bSettingLegacyProperty
)
2246 // synchronize the legacy StringItemList property with our list items
2247 Sequence
< OUString
> aStringItemList
;
2249 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2250 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2252 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2254 aStringItemList
.getConstArray(),
2255 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2259 m_xData
->setAllItems( aItems
);
2261 // since an XItemListListener does not have a "all items modified" or some such method,
2262 // we simulate this by notifying removal of all items, followed by insertion of all new
2264 lang::EventObject aEvent
;
2265 aEvent
.Source
= *this;
2266 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
2267 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2268 // which is wrong for the above notifications ...
2274 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
2275 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const
2277 // dependencies we know:
2278 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
2279 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
2280 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_TYPEDITEMLIST
2281 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_TYPEDITEMLIST
);
2283 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
2287 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount()
2289 ::osl::MutexGuard
aGuard( GetMutex() );
2290 return m_xData
->getItemCount();
2294 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2296 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2297 // SYNCHRONIZED ----->
2298 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2299 rItem
.ItemText
= i_rItemText
;
2300 rItem
.ItemImageURL
= i_rItemImageURL
;
2302 impl_handleInsert( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2303 // <----- SYNCHRONIZED
2307 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2309 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2310 // SYNCHRONIZED ----->
2311 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2312 rItem
.ItemText
= i_rItemText
;
2314 impl_handleInsert( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2315 // <----- SYNCHRONIZED
2319 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2321 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2322 // SYNCHRONIZED ----->
2323 ListItem
& rItem( m_xData
->insertItem( i_nPosition
) );
2324 rItem
.ItemImageURL
= i_rItemImageURL
;
2326 impl_handleInsert( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2327 // <----- SYNCHRONIZED
2331 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
)
2333 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2334 // SYNCHRONIZED ----->
2335 m_xData
->removeItem( i_nPosition
);
2337 impl_handleRemove( i_nPosition
, aGuard
);
2338 // <----- SYNCHRONIZED
2342 void SAL_CALL
UnoControlListBoxModel::removeAllItems( )
2344 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2345 // SYNCHRONIZED ----->
2346 m_xData
->removeAllItems();
2348 impl_handleRemove( -1, aGuard
);
2349 // <----- SYNCHRONIZED
2353 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
)
2355 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2356 // SYNCHRONIZED ----->
2357 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2358 rItem
.ItemText
= i_rItemText
;
2360 impl_handleModify( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2361 // <----- SYNCHRONIZED
2365 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
)
2367 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2368 // SYNCHRONIZED ----->
2369 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2370 rItem
.ItemImageURL
= i_rItemImageURL
;
2372 impl_handleModify( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2373 // <----- SYNCHRONIZED
2377 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
)
2379 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2380 // SYNCHRONIZED ----->
2381 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2382 rItem
.ItemText
= i_rItemText
;
2383 rItem
.ItemImageURL
= i_rItemImageURL
;
2385 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2386 // <----- SYNCHRONIZED
2390 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
)
2392 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2393 ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2394 rItem
.ItemData
= i_rDataValue
;
2398 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
)
2400 ::osl::MutexGuard
aGuard( GetMutex() );
2401 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2402 return rItem
.ItemText
;
2406 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
)
2408 ::osl::MutexGuard
aGuard( GetMutex() );
2409 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2410 return rItem
.ItemImageURL
;
2414 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
)
2416 ::osl::MutexGuard
aGuard( GetMutex() );
2417 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2418 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2422 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
)
2424 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2425 const ListItem
& rItem( m_xData
->getItem( i_nPosition
) );
2426 return rItem
.ItemData
;
2430 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( )
2432 ::osl::MutexGuard
aGuard( GetMutex() );
2433 return m_xData
->getAllItems();
2437 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2439 if ( i_Listener
.is() )
2440 m_aItemListListeners
.addInterface( i_Listener
);
2444 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
)
2446 if ( i_Listener
.is() )
2447 m_aItemListListeners
.removeInterface( i_Listener
);
2451 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector
< OUString
>& o_rStringItems
) const
2453 Sequence
< OUString
> aStringItemList
;
2455 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2456 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2458 o_rStringItems
.resize( size_t( aStringItemList
.getLength() ) );
2460 aStringItemList
.getConstArray(),
2461 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2462 o_rStringItems
.begin()
2467 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector
< OUString
>& i_rStringItems
)
2469 Sequence
< OUString
> aStringItems( comphelper::containerToSequence(i_rStringItems
) );
2470 m_xData
->m_bSettingLegacyProperty
= true;
2473 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST
, uno::makeAny( aStringItems
) );
2475 catch( const Exception
& )
2477 m_xData
->m_bSettingLegacyProperty
= false;
2480 m_xData
->m_bSettingLegacyProperty
= false;
2484 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2485 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2487 // SYNCHRONIZED ----->
2488 // sync with legacy StringItemList property
2489 ::std::vector
< OUString
> aStringItems
;
2490 impl_getStringItemList( aStringItems
);
2491 OSL_ENSURE( size_t( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2492 if ( size_t( i_nItemPosition
) <= aStringItems
.size() )
2494 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2495 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2498 i_rClearBeforeNotify
.clear();
2499 // <----- SYNCHRONIZED
2500 impl_setStringItemList_nolck( aStringItems
);
2502 // notify ItemListListeners
2503 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2507 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2509 // SYNCHRONIZED ----->
2510 const bool bAllItems
= ( i_nItemPosition
< 0 );
2511 // sync with legacy StringItemList property
2512 ::std::vector
< OUString
> aStringItems
;
2513 impl_getStringItemList( aStringItems
);
2516 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2517 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2519 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2524 aStringItems
.resize(0);
2527 i_rClearBeforeNotify
.clear();
2528 // <----- SYNCHRONIZED
2529 impl_setStringItemList_nolck( aStringItems
);
2531 // notify ItemListListeners
2534 EventObject
aEvent( *this );
2535 m_aItemListListeners
.notifyEach( &XItemListListener::allItemsRemoved
, aEvent
);
2539 impl_notifyItemListEvent_nolck( i_nItemPosition
, ::boost::optional
< OUString
>(), ::boost::optional
< OUString
>(),
2540 &XItemListListener::listItemRemoved
);
2545 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2546 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2548 // SYNCHRONIZED ----->
2549 if ( !!i_rItemText
)
2551 // sync with legacy StringItemList property
2552 ::std::vector
< OUString
> aStringItems
;
2553 impl_getStringItemList( aStringItems
);
2554 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2555 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2557 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2560 i_rClearBeforeNotify
.clear();
2561 // <----- SYNCHRONIZED
2562 impl_setStringItemList_nolck( aStringItems
);
2566 i_rClearBeforeNotify
.clear();
2567 // <----- SYNCHRONIZED
2570 // notify ItemListListeners
2571 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2575 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2576 const ::boost::optional
< OUString
>& i_rItemImageURL
,
2577 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2579 ItemListEvent aEvent
;
2580 aEvent
.Source
= *this;
2581 aEvent
.ItemPosition
= i_nItemPosition
;
2582 if ( !!i_rItemText
)
2584 aEvent
.ItemText
.IsPresent
= true;
2585 aEvent
.ItemText
.Value
= *i_rItemText
;
2587 if ( !!i_rItemImageURL
)
2589 aEvent
.ItemImageURL
.IsPresent
= true;
2590 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2593 m_aItemListListeners
.notifyEach( NotificationMethod
, aEvent
);
2596 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
2597 stardiv_Toolkit_UnoControlListBoxModel_get_implementation(
2598 css::uno::XComponentContext
*context
,
2599 css::uno::Sequence
<css::uno::Any
> const &)
2601 return cppu::acquire(new UnoControlListBoxModel(context
));
2605 // class UnoListBoxControl
2607 UnoListBoxControl::UnoListBoxControl()
2608 :UnoListBoxControl_Base()
2609 ,maActionListeners( *this )
2610 ,maItemListeners( *this )
2612 maComponentInfos
.nWidth
= 100;
2613 maComponentInfos
.nHeight
= 12;
2616 OUString
UnoListBoxControl::GetComponentServiceName()
2618 return OUString("listbox");
2621 OUString
UnoListBoxControl::getImplementationName()
2623 return OUString("stardiv.Toolkit.UnoListBoxControl");
2626 css::uno::Sequence
<OUString
> UnoListBoxControl::getSupportedServiceNames()
2628 auto s(UnoControlBase::getSupportedServiceNames());
2629 s
.realloc(s
.getLength() + 2);
2630 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlListBox";
2631 s
[s
.getLength() - 1] = "stardiv.vcl.control.ListBox";
2635 void UnoListBoxControl::dispose()
2637 lang::EventObject aEvt
;
2638 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
2639 maActionListeners
.disposeAndClear( aEvt
);
2640 maItemListeners
.disposeAndClear( aEvt
);
2641 UnoControl::dispose();
2644 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2646 if ( getPeer().is() )
2648 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2649 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2651 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2652 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), uno::Any(aSeq
), false );
2656 void UnoListBoxControl::updateFromModel()
2658 UnoControlBase::updateFromModel();
2660 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2661 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2663 EventObject
aEvent( getModel() );
2664 xItemListListener
->itemListChanged( aEvent
);
2666 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2667 // already did this, our peer(s) can only legitimately set the selection after they have the string
2668 // item list, which we just notified with the itemListChanged call.
2669 const OUString
& sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2670 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2673 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2675 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2676 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2677 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2678 // will be forwarded to the peer, which will update itself accordingly.
2681 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2684 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
2686 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2688 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2689 xListBox
->addItemListener( this );
2691 if ( maActionListeners
.getLength() )
2692 xListBox
->addActionListener( &maActionListeners
);
2695 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2697 maActionListeners
.addInterface( l
);
2698 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2700 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2701 xListBox
->addActionListener( &maActionListeners
);
2705 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
2707 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2709 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2710 xListBox
->removeActionListener( &maActionListeners
);
2712 maActionListeners
.removeInterface( l
);
2715 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2717 maItemListeners
.addInterface( l
);
2720 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
2722 maItemListeners
.removeInterface( l
);
2725 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
2727 uno::Sequence
<OUString
> aSeq
{ aItem
};
2728 addItems( aSeq
, nPos
);
2731 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
2733 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2734 uno::Sequence
< OUString
> aSeq
;
2736 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
2737 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2738 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2740 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2741 OUString
* pNewData
= aNewSeq
.getArray();
2742 OUString
* pOldData
= aSeq
.getArray();
2744 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2748 // Items before the Paste-Position
2749 for ( n
= 0; n
< nPos
; n
++ )
2750 pNewData
[n
] = pOldData
[n
];
2753 for ( n
= 0; n
< nNewItems
; n
++ )
2754 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
2756 // Rest of old Items
2757 for ( n
= nPos
; n
< nOldLen
; n
++ )
2758 pNewData
[nNewItems
+n
] = pOldData
[n
];
2760 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2763 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
2765 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2766 uno::Sequence
< OUString
> aSeq
;
2768 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2769 if ( nOldLen
&& ( nPos
< nOldLen
) )
2771 if ( nCount
> ( nOldLen
-nPos
) )
2772 nCount
= nOldLen
-nPos
;
2774 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2776 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2777 OUString
* pNewData
= aNewSeq
.getArray();
2778 OUString
* pOldData
= aSeq
.getArray();
2781 // Items before the Remove-Position
2782 for ( n
= 0; n
< nPos
; n
++ )
2783 pNewData
[n
] = pOldData
[n
];
2786 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
2787 pNewData
[n
] = pOldData
[n
+nCount
];
2789 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
2793 sal_Int16
UnoListBoxControl::getItemCount()
2795 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2796 uno::Sequence
< OUString
> aSeq
;
2798 return (sal_Int16
)aSeq
.getLength();
2801 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
)
2804 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2805 uno::Sequence
< OUString
> aSeq
;
2807 if ( nPos
< aSeq
.getLength() )
2808 aItem
= aSeq
.getConstArray()[nPos
];
2812 uno::Sequence
< OUString
> UnoListBoxControl::getItems()
2814 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2815 uno::Sequence
< OUString
> aSeq
;
2820 sal_Int16
UnoListBoxControl::getSelectedItemPos()
2823 if ( getPeer().is() )
2825 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2826 n
= xListBox
->getSelectedItemPos();
2831 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos()
2833 uno::Sequence
<sal_Int16
> aSeq
;
2834 if ( getPeer().is() )
2836 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2837 aSeq
= xListBox
->getSelectedItemsPos();
2842 OUString
UnoListBoxControl::getSelectedItem()
2845 if ( getPeer().is() )
2847 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2848 aItem
= xListBox
->getSelectedItem();
2853 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems()
2855 uno::Sequence
< OUString
> aSeq
;
2856 if ( getPeer().is() )
2858 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2859 aSeq
= xListBox
->getSelectedItems();
2864 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
)
2866 if ( getPeer().is() )
2868 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2869 xListBox
->selectItemPos( nPos
, bSelect
);
2871 ImplUpdateSelectedItemsProperty();
2874 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
)
2876 if ( getPeer().is() )
2878 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2879 xListBox
->selectItemsPos( aPositions
, bSelect
);
2881 ImplUpdateSelectedItemsProperty();
2884 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
)
2886 if ( getPeer().is() )
2888 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2889 xListBox
->selectItem( aItem
, bSelect
);
2891 ImplUpdateSelectedItemsProperty();
2894 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
)
2896 if ( getPeer().is() )
2898 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2899 xListBox
->makeVisible( nEntry
);
2903 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
)
2905 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
2908 sal_Int16
UnoListBoxControl::getDropDownLineCount()
2910 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2913 sal_Bool
UnoListBoxControl::isMutipleMode()
2915 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2918 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
)
2920 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), uno::Any(bMulti
), true );
2923 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
2925 ImplUpdateSelectedItemsProperty();
2926 if ( maItemListeners
.getLength() )
2930 maItemListeners
.itemStateChanged( rEvent
);
2932 catch( const Exception
& e
)
2934 #if OSL_DEBUG_LEVEL == 0
2935 (void) e
; // suppress warning
2937 OString
sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2938 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2939 OSL_FAIL( sMessage
.getStr() );
2945 awt::Size
UnoListBoxControl::getMinimumSize( )
2947 return Impl_getMinimumSize();
2950 awt::Size
UnoListBoxControl::getPreferredSize( )
2952 return Impl_getPreferredSize();
2955 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
)
2957 return Impl_calcAdjustedSize( rNewSize
);
2960 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
)
2962 return Impl_getMinimumSize( nCols
, nLines
);
2965 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
)
2967 Impl_getColumnsAndLines( nCols
, nLines
);
2970 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
2972 ::osl::MutexGuard
aGuard( GetMutex() );
2974 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2975 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2976 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2977 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2979 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2982 if ( xOldItems
.is() )
2983 xOldItems
->removeItemListListener( this );
2984 if ( xNewItems
.is() )
2985 xNewItems
->addItemListListener( this );
2990 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
2992 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2993 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2994 if ( xPeerListener
.is() )
2995 xPeerListener
->listItemInserted( i_rEvent
);
2998 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
3000 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3001 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
3002 if ( xPeerListener
.is() )
3003 xPeerListener
->listItemRemoved( i_rEvent
);
3006 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
3008 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3009 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
3010 if ( xPeerListener
.is() )
3011 xPeerListener
->listItemModified( i_rEvent
);
3014 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3016 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3017 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
3018 if ( xPeerListener
.is() )
3019 xPeerListener
->allItemsRemoved( i_rEvent
);
3022 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3024 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3025 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
3026 if ( xPeerListener
.is() )
3027 xPeerListener
->itemListChanged( i_rEvent
);
3030 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3031 stardiv_Toolkit_UnoListBoxControl_get_implementation(
3032 css::uno::XComponentContext
*,
3033 css::uno::Sequence
<css::uno::Any
> const &)
3035 return cppu::acquire(new UnoListBoxControl());
3039 // class UnoControlComboBoxModel
3041 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
3042 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
3044 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox
);
3047 OUString
UnoControlComboBoxModel::getImplementationName()
3049 return OUString("stardiv.Toolkit.UnoControlComboBoxModel");
3052 css::uno::Sequence
<OUString
> UnoControlComboBoxModel::getSupportedServiceNames()
3054 auto s(UnoControlModel::getSupportedServiceNames());
3055 s
.realloc(s
.getLength() + 2);
3056 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBoxModel";
3057 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ComboBox";
3061 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( )
3063 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3067 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
3069 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3072 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3073 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3079 OUString
UnoControlComboBoxModel::getServiceName()
3081 return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel
);
3083 void SAL_CALL
UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
)
3085 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
3087 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
&& !m_xData
->m_bSettingLegacyProperty
)
3089 // synchronize the legacy StringItemList property with our list items
3090 Sequence
< OUString
> aStringItemList
;
3092 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
3093 OSL_VERIFY( aPropValue
>>= aStringItemList
);
3095 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
3097 aStringItemList
.getConstArray(),
3098 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
3102 m_xData
->setAllItems( aItems
);
3104 // since an XItemListListener does not have a "all items modified" or some such method,
3105 // we simulate this by notifying removal of all items, followed by insertion of all new
3107 lang::EventObject aEvent
;
3108 aEvent
.Source
= *this;
3109 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
3110 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
3111 // which is wrong for the above notifications ...
3115 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3117 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3119 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlComboBox
) );
3121 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3124 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3125 stardiv_Toolkit_UnoControlComboBoxModel_get_implementation(
3126 css::uno::XComponentContext
*context
,
3127 css::uno::Sequence
<css::uno::Any
> const &)
3129 return cppu::acquire(new UnoControlComboBoxModel(context
));
3133 // class UnoComboBoxControl
3135 UnoComboBoxControl::UnoComboBoxControl()
3137 ,maActionListeners( *this )
3138 ,maItemListeners( *this )
3140 maComponentInfos
.nWidth
= 100;
3141 maComponentInfos
.nHeight
= 12;
3144 OUString
UnoComboBoxControl::getImplementationName()
3146 return OUString( "stardiv.Toolkit.UnoComboBoxControl");
3149 css::uno::Sequence
<OUString
> UnoComboBoxControl::getSupportedServiceNames()
3151 auto s(UnoEditControl::getSupportedServiceNames());
3152 s
.realloc(s
.getLength() + 2);
3153 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlComboBox";
3154 s
[s
.getLength() - 1] = "stardiv.vcl.control.ComboBox";
3158 OUString
UnoComboBoxControl::GetComponentServiceName()
3160 return OUString("combobox");
3163 void UnoComboBoxControl::dispose()
3165 lang::EventObject aEvt
;
3166 aEvt
.Source
= static_cast<cppu::OWeakObject
*>(this);
3167 maActionListeners
.disposeAndClear( aEvt
);
3168 maItemListeners
.disposeAndClear( aEvt
);
3169 UnoControl::dispose();
3171 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
)
3173 uno::Any aRet
= ::cppu::queryInterface( rType
,
3174 (static_cast< awt::XComboBox
* >(this)) );
3175 if ( !aRet
.hasValue() )
3177 aRet
= ::cppu::queryInterface( rType
,
3178 (static_cast< awt::XItemListener
* >(this)) );
3179 if ( !aRet
.hasValue() )
3181 aRet
= ::cppu::queryInterface( rType
,
3182 (static_cast< awt::XItemListListener
* >(this)) );
3185 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3187 // lang::XTypeProvider
3188 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl
)
3189 cppu::UnoType
<awt::XComboBox
>::get(),
3190 cppu::UnoType
<awt::XItemListener
>::get(),
3191 cppu::UnoType
<awt::XItemListListener
>::get(),
3192 UnoEditControl::getTypes()
3193 IMPL_XTYPEPROVIDER_END
3195 void UnoComboBoxControl::updateFromModel()
3197 UnoEditControl::updateFromModel();
3199 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
3200 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
3202 EventObject
aEvent( getModel() );
3203 xItemListListener
->itemListChanged( aEvent
);
3205 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
3207 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
3208 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
3209 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
3210 // will be forwarded to the peer, which will update itself accordingly.
3213 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
3215 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3217 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3219 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3220 if ( maActionListeners
.getLength() )
3221 xComboBox
->addActionListener( &maActionListeners
);
3222 if ( maItemListeners
.getLength() )
3223 xComboBox
->addItemListener( &maItemListeners
);
3226 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3228 maActionListeners
.addInterface( l
);
3229 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3231 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3232 xComboBox
->addActionListener( &maActionListeners
);
3236 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
)
3238 if( getPeer().is() && maActionListeners
.getLength() == 1 )
3240 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3241 xComboBox
->removeActionListener( &maActionListeners
);
3243 maActionListeners
.removeInterface( l
);
3246 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3248 maItemListeners
.addInterface( l
);
3249 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3251 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3252 xComboBox
->addItemListener( &maItemListeners
);
3256 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
)
3258 if( getPeer().is() && maItemListeners
.getLength() == 1 )
3260 // This call is prettier than creating a Ref and calling query
3261 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
3262 xComboBox
->removeItemListener( &maItemListeners
);
3264 maItemListeners
.removeInterface( l
);
3266 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
)
3268 if ( maItemListeners
.getLength() )
3272 maItemListeners
.itemStateChanged( rEvent
);
3274 catch( const Exception
& e
)
3276 #if OSL_DEBUG_LEVEL == 0
3277 (void) e
; // suppress warning
3279 OString
sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
3280 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
3281 OSL_FAIL( sMessage
.getStr() );
3286 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
)
3288 ::osl::MutexGuard
aGuard( GetMutex() );
3290 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
3291 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
3292 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
3293 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
3295 if ( !UnoEditControl::setModel( i_rModel
) )
3298 if ( xOldItems
.is() )
3299 xOldItems
->removeItemListListener( this );
3300 if ( xNewItems
.is() )
3301 xNewItems
->addItemListListener( this );
3306 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
)
3308 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3309 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
3310 if ( xPeerListener
.is() )
3311 xPeerListener
->listItemInserted( i_rEvent
);
3314 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
)
3316 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3317 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
3318 if ( xPeerListener
.is() )
3319 xPeerListener
->listItemRemoved( i_rEvent
);
3322 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
)
3324 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3325 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
3326 if ( xPeerListener
.is() )
3327 xPeerListener
->listItemModified( i_rEvent
);
3330 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
)
3332 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3333 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
3334 if ( xPeerListener
.is() )
3335 xPeerListener
->allItemsRemoved( i_rEvent
);
3338 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
)
3340 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
3341 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
3342 if ( xPeerListener
.is() )
3343 xPeerListener
->itemListChanged( i_rEvent
);
3346 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
)
3348 uno::Sequence
<OUString
> aSeq
{ aItem
};
3349 addItems( aSeq
, nPos
);
3352 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
)
3354 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3355 uno::Sequence
< OUString
> aSeq
;
3357 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
3358 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3359 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3361 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3362 OUString
* pNewData
= aNewSeq
.getArray();
3363 const OUString
* pOldData
= aSeq
.getConstArray();
3365 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3369 // items before the insert position
3370 for ( n
= 0; n
< nPos
; n
++ )
3371 pNewData
[n
] = pOldData
[n
];
3374 for ( n
= 0; n
< nNewItems
; n
++ )
3375 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
3377 // remainder of old items
3378 for ( n
= nPos
; n
< nOldLen
; n
++ )
3379 pNewData
[nNewItems
+n
] = pOldData
[n
];
3381 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), Any(aNewSeq
), true );
3384 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
)
3386 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3387 uno::Sequence
< OUString
> aSeq
;
3389 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3390 if ( nOldLen
&& ( nPos
< nOldLen
) )
3392 if ( nCount
> ( nOldLen
-nPos
) )
3393 nCount
= nOldLen
-nPos
;
3395 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3397 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3398 OUString
* pNewData
= aNewSeq
.getArray();
3399 OUString
* pOldData
= aSeq
.getArray();
3402 // items before the deletion position
3403 for ( n
= 0; n
< nPos
; n
++ )
3404 pNewData
[n
] = pOldData
[n
];
3406 // remainder of old items
3407 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
3408 pNewData
[n
] = pOldData
[n
+nCount
];
3410 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), uno::Any(aNewSeq
), true );
3414 sal_Int16
UnoComboBoxControl::getItemCount()
3416 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3417 uno::Sequence
< OUString
> aSeq
;
3419 return (sal_Int16
)aSeq
.getLength();
3422 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
)
3425 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3426 uno::Sequence
< OUString
> aSeq
;
3428 if ( nPos
< aSeq
.getLength() )
3429 aItem
= aSeq
.getConstArray()[nPos
];
3433 uno::Sequence
< OUString
> UnoComboBoxControl::getItems()
3435 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3436 uno::Sequence
< OUString
> aSeq
;
3441 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
)
3443 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), uno::Any(nLines
), true );
3446 sal_Int16
UnoComboBoxControl::getDropDownLineCount()
3448 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3451 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3452 stardiv_Toolkit_UnoComboBoxControl_get_implementation(
3453 css::uno::XComponentContext
*,
3454 css::uno::Sequence
<css::uno::Any
> const &)
3456 return cppu::acquire(new UnoComboBoxControl());
3460 // UnoSpinFieldControl
3462 UnoSpinFieldControl::UnoSpinFieldControl()
3464 ,maSpinListeners( *this )
3470 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
)
3472 uno::Any aRet
= ::cppu::queryInterface( rType
,
3473 (static_cast< awt::XSpinField
* >(this)) );
3474 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3477 // lang::XTypeProvider
3478 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl
)
3479 cppu::UnoType
<awt::XSpinField
>::get(),
3480 UnoEditControl::getTypes()
3481 IMPL_XTYPEPROVIDER_END
3483 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3485 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3487 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3488 xField
->enableRepeat( mbRepeat
);
3489 if ( maSpinListeners
.getLength() )
3490 xField
->addSpinListener( &maSpinListeners
);
3493 // css::awt::XSpinField
3494 void UnoSpinFieldControl::addSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3496 maSpinListeners
.addInterface( l
);
3497 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3499 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3500 xField
->addSpinListener( &maSpinListeners
);
3504 void UnoSpinFieldControl::removeSpinListener( const css::uno::Reference
< css::awt::XSpinListener
>& l
)
3506 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3508 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3509 xField
->removeSpinListener( &maSpinListeners
);
3511 maSpinListeners
.removeInterface( l
);
3514 void UnoSpinFieldControl::up()
3516 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3521 void UnoSpinFieldControl::down()
3523 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3528 void UnoSpinFieldControl::first()
3530 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3535 void UnoSpinFieldControl::last()
3537 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3542 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
)
3546 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3548 xField
->enableRepeat( bRepeat
);
3552 // class UnoControlDateFieldModel
3554 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3555 :UnoControlModel( rxContext
)
3557 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField
);
3560 OUString
UnoControlDateFieldModel::getServiceName()
3562 return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel
);
3565 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3567 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3569 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlDateField
) );
3571 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3575 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3577 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3580 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3581 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3586 // beans::XMultiPropertySet
3587 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( )
3589 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3593 OUString
UnoControlDateFieldModel::getImplementationName()
3595 return OUString("stardiv.Toolkit.UnoControlDateFieldModel");
3598 css::uno::Sequence
<OUString
>
3599 UnoControlDateFieldModel::getSupportedServiceNames()
3601 auto s(UnoControlModel::getSupportedServiceNames());
3602 s
.realloc(s
.getLength() + 2);
3603 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateFieldModel";
3604 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.DateField";
3608 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3609 stardiv_Toolkit_UnoControlDateFieldModel_get_implementation(
3610 css::uno::XComponentContext
*context
,
3611 css::uno::Sequence
<css::uno::Any
> const &)
3613 return cppu::acquire(new UnoControlDateFieldModel(context
));
3617 // class UnoDateFieldControl
3619 UnoDateFieldControl::UnoDateFieldControl()
3620 :UnoSpinFieldControl()
3622 mnFirst
= util::Date( 1, 1, 1900 );
3623 mnLast
= util::Date( 31, 12, 2200 );
3624 mbLongFormat
= TRISTATE_INDET
;
3627 OUString
UnoDateFieldControl::GetComponentServiceName()
3629 return OUString("datefield");
3633 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
)
3635 uno::Any aRet
= ::cppu::queryInterface( rType
,
3636 (static_cast< awt::XDateField
* >(this)) );
3637 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3640 // lang::XTypeProvider
3641 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl
)
3642 cppu::UnoType
<awt::XDateField
>::get(),
3643 UnoSpinFieldControl::getTypes()
3644 IMPL_XTYPEPROVIDER_END
3646 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3648 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3650 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3651 xField
->setFirst( mnFirst
);
3652 xField
->setLast( mnLast
);
3653 if ( mbLongFormat
!= TRISTATE_INDET
)
3654 xField
->setLongFormat( mbLongFormat
);
3658 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
)
3660 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3662 // also change the text property (#i25106#)
3665 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3666 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3669 // re-calc the Date property
3670 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3672 if ( xField
->isEmpty() )
3674 // the field says it's empty
3675 bool bEnforceFormat
= true;
3677 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3678 if ( !bEnforceFormat
)
3680 // and it also says that it is currently accepting invalid inputs, without
3681 // forcing it to a valid date
3682 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3683 if ( xText
.is() && xText
->getText().getLength() )
3684 // and in real, the text of the peer is *not* empty
3685 // -> simulate an invalid date, which is different from "no date"
3686 aValue
<<= util::Date();
3690 aValue
<<= xField
->getDate();
3692 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, false );
3694 // multiplex the event
3695 if ( GetTextListeners().getLength() )
3696 GetTextListeners().textChanged( e
);
3699 void UnoDateFieldControl::setDate( const util::Date
& Date
)
3701 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), uno::Any(Date
), true );
3704 util::Date
UnoDateFieldControl::getDate()
3706 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3709 void UnoDateFieldControl::setMin( const util::Date
& Date
)
3711 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), uno::Any(Date
), true );
3714 util::Date
UnoDateFieldControl::getMin()
3716 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3719 void UnoDateFieldControl::setMax( const util::Date
& Date
)
3721 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), uno::Any(Date
), true );
3724 util::Date
UnoDateFieldControl::getMax()
3726 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3729 void UnoDateFieldControl::setFirst( const util::Date
& Date
)
3732 if ( getPeer().is() )
3734 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3735 xField
->setFirst( Date
);
3739 util::Date
UnoDateFieldControl::getFirst()
3744 void UnoDateFieldControl::setLast( const util::Date
& Date
)
3747 if ( getPeer().is() )
3749 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3750 xField
->setLast( Date
);
3754 util::Date
UnoDateFieldControl::getLast()
3759 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
)
3761 mbLongFormat
= bLong
? TRISTATE_TRUE
: TRISTATE_FALSE
;
3762 if ( getPeer().is() )
3764 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3765 xField
->setLongFormat( bLong
);
3769 sal_Bool
UnoDateFieldControl::isLongFormat()
3771 return mbLongFormat
== TRISTATE_TRUE
;
3774 void UnoDateFieldControl::setEmpty()
3776 if ( getPeer().is() )
3778 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3783 sal_Bool
UnoDateFieldControl::isEmpty()
3785 bool bEmpty
= false;
3786 if ( getPeer().is() )
3788 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3789 bEmpty
= xField
->isEmpty();
3794 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
)
3796 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
3799 sal_Bool
UnoDateFieldControl::isStrictFormat()
3801 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3804 OUString
UnoDateFieldControl::getImplementationName()
3806 return OUString("stardiv.Toolkit.UnoDateFieldControl");
3809 css::uno::Sequence
<OUString
> UnoDateFieldControl::getSupportedServiceNames()
3811 auto s(UnoSpinFieldControl::getSupportedServiceNames());
3812 s
.realloc(s
.getLength() + 2);
3813 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlDateField";
3814 s
[s
.getLength() - 1] = "stardiv.vcl.control.DateField";
3818 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3819 stardiv_Toolkit_UnoDateFieldControl_get_implementation(
3820 css::uno::XComponentContext
*,
3821 css::uno::Sequence
<css::uno::Any
> const &)
3823 return cppu::acquire(new UnoDateFieldControl());
3827 // class UnoControlTimeFieldModel
3829 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3830 :UnoControlModel( rxContext
)
3832 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField
);
3835 OUString
UnoControlTimeFieldModel::getServiceName()
3837 return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel
);
3840 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3842 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3844 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlTimeField
) );
3846 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3850 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3852 static UnoPropertyArrayHelper
* pHelper
= nullptr;
3855 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3856 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3861 // beans::XMultiPropertySet
3862 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( )
3864 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3868 OUString
UnoControlTimeFieldModel::getImplementationName()
3870 return OUString("stardiv.Toolkit.UnoControlTimeFieldModel");
3873 css::uno::Sequence
<OUString
>
3874 UnoControlTimeFieldModel::getSupportedServiceNames()
3876 auto s(UnoControlModel::getSupportedServiceNames());
3877 s
.realloc(s
.getLength() + 2);
3878 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeFieldModel";
3879 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.TimeField";
3883 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3884 stardiv_Toolkit_UnoControlTimeFieldModel_get_implementation(
3885 css::uno::XComponentContext
*context
,
3886 css::uno::Sequence
<css::uno::Any
> const &)
3888 return cppu::acquire(new UnoControlTimeFieldModel(context
));
3892 // class UnoTimeFieldControl
3894 UnoTimeFieldControl::UnoTimeFieldControl()
3895 :UnoSpinFieldControl()
3897 mnFirst
= util::Time( 0, 0, 0, 0, false );
3898 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3901 OUString
UnoTimeFieldControl::GetComponentServiceName()
3903 return OUString("timefield");
3907 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
)
3909 uno::Any aRet
= ::cppu::queryInterface( rType
,
3910 (static_cast< awt::XTimeField
* >(this)) );
3911 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3914 // lang::XTypeProvider
3915 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl
)
3916 cppu::UnoType
<awt::XTimeField
>::get(),
3917 UnoSpinFieldControl::getTypes()
3918 IMPL_XTYPEPROVIDER_END
3920 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
3922 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3924 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3925 xField
->setFirst( mnFirst
);
3926 xField
->setLast( mnLast
);
3929 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
)
3931 // also change the text property (#i25106#)
3932 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3933 const OUString
& sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3934 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), false );
3936 // re-calc the Time property
3937 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3939 if ( !xField
->isEmpty() )
3940 aValue
<<= xField
->getTime();
3941 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, false );
3943 // multiplex the event
3944 if ( GetTextListeners().getLength() )
3945 GetTextListeners().textChanged( e
);
3948 void UnoTimeFieldControl::setTime( const util::Time
& Time
)
3950 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), Any(Time
), true );
3953 util::Time
UnoTimeFieldControl::getTime()
3955 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3958 void UnoTimeFieldControl::setMin( const util::Time
& Time
)
3960 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), uno::Any(Time
), true );
3963 util::Time
UnoTimeFieldControl::getMin()
3965 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
3968 void UnoTimeFieldControl::setMax( const util::Time
& Time
)
3970 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), uno::Any(Time
), true );
3973 util::Time
UnoTimeFieldControl::getMax()
3975 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
3978 void UnoTimeFieldControl::setFirst( const util::Time
& Time
)
3981 if ( getPeer().is() )
3983 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3984 xField
->setFirst( mnFirst
);
3988 util::Time
UnoTimeFieldControl::getFirst()
3993 void UnoTimeFieldControl::setLast( const util::Time
& Time
)
3996 if ( getPeer().is() )
3998 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3999 xField
->setFirst( mnLast
);
4003 util::Time
UnoTimeFieldControl::getLast()
4008 void UnoTimeFieldControl::setEmpty()
4010 if ( getPeer().is() )
4012 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4017 sal_Bool
UnoTimeFieldControl::isEmpty()
4019 bool bEmpty
= false;
4020 if ( getPeer().is() )
4022 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
4023 bEmpty
= xField
->isEmpty();
4028 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
)
4030 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4033 sal_Bool
UnoTimeFieldControl::isStrictFormat()
4035 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4038 OUString
UnoTimeFieldControl::getImplementationName()
4040 return OUString("stardiv.Toolkit.UnoTimeFieldControl");
4043 css::uno::Sequence
<OUString
> UnoTimeFieldControl::getSupportedServiceNames()
4045 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4046 s
.realloc(s
.getLength() + 2);
4047 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlTimeField";
4048 s
[s
.getLength() - 1] = "stardiv.vcl.control.TimeField";
4052 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4053 stardiv_Toolkit_UnoTimeFieldControl_get_implementation(
4054 css::uno::XComponentContext
*,
4055 css::uno::Sequence
<css::uno::Any
> const &)
4057 return cppu::acquire(new UnoTimeFieldControl());
4061 // class UnoControlNumericFieldModel
4063 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
4064 :UnoControlModel( rxContext
)
4066 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField
);
4069 OUString
UnoControlNumericFieldModel::getServiceName()
4071 return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel
);
4074 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4076 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4078 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlNumericField
) );
4080 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4084 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
4086 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4089 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4090 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4095 // beans::XMultiPropertySet
4096 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( )
4098 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4102 OUString
UnoControlNumericFieldModel::getImplementationName()
4104 return OUString("stardiv.Toolkit.UnoControlNumericFieldModel");
4107 css::uno::Sequence
<OUString
>
4108 UnoControlNumericFieldModel::getSupportedServiceNames()
4110 auto s(UnoControlModel::getSupportedServiceNames());
4111 s
.realloc(s
.getLength() + 2);
4112 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericFieldModel";
4113 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.NumericField";
4117 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4118 stardiv_Toolkit_UnoControlNumericFieldModel_get_implementation(
4119 css::uno::XComponentContext
*context
,
4120 css::uno::Sequence
<css::uno::Any
> const &)
4122 return cppu::acquire(new UnoControlNumericFieldModel(context
));
4126 // class UnoNumericFieldControl
4128 UnoNumericFieldControl::UnoNumericFieldControl()
4129 :UnoSpinFieldControl()
4132 mnLast
= 0x7FFFFFFF;
4135 OUString
UnoNumericFieldControl::GetComponentServiceName()
4137 return OUString("numericfield");
4141 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
)
4143 uno::Any aRet
= ::cppu::queryInterface( rType
,
4144 (static_cast< awt::XNumericField
* >(this)) );
4145 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4148 // lang::XTypeProvider
4149 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl
)
4150 cppu::UnoType
<awt::XNumericField
>::get(),
4151 UnoSpinFieldControl::getTypes()
4152 IMPL_XTYPEPROVIDER_END
4154 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4156 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4158 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4159 xField
->setFirst( mnFirst
);
4160 xField
->setLast( mnLast
);
4164 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
)
4166 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4167 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4169 if ( GetTextListeners().getLength() )
4170 GetTextListeners().textChanged( e
);
4173 void UnoNumericFieldControl::setValue( double Value
)
4175 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(Value
), true );
4178 double UnoNumericFieldControl::getValue()
4180 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4183 void UnoNumericFieldControl::setMin( double Value
)
4185 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4188 double UnoNumericFieldControl::getMin()
4190 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4193 void UnoNumericFieldControl::setMax( double Value
)
4195 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4198 double UnoNumericFieldControl::getMax()
4200 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4203 void UnoNumericFieldControl::setFirst( double Value
)
4206 if ( getPeer().is() )
4208 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4209 xField
->setFirst( mnFirst
);
4213 double UnoNumericFieldControl::getFirst()
4218 void UnoNumericFieldControl::setLast( double Value
)
4221 if ( getPeer().is() )
4223 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
4224 xField
->setLast( mnLast
);
4228 double UnoNumericFieldControl::getLast()
4233 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
)
4235 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4238 sal_Bool
UnoNumericFieldControl::isStrictFormat()
4240 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4243 OUString
UnoNumericFieldControl::getImplementationName()
4245 return OUString("stardiv.Toolkit.UnoNumericFieldControl");
4248 css::uno::Sequence
<OUString
> UnoNumericFieldControl::getSupportedServiceNames()
4250 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4251 s
.realloc(s
.getLength() + 2);
4252 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlNumericField";
4253 s
[s
.getLength() - 1] = "stardiv.vcl.control.NumericField";
4257 void UnoNumericFieldControl::setSpinSize( double Digits
)
4259 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4262 double UnoNumericFieldControl::getSpinSize()
4264 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4267 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
)
4269 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4272 sal_Int16
UnoNumericFieldControl::getDecimalDigits()
4274 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4277 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4278 stardiv_Toolkit_UnoNumericFieldControl_get_implementation(
4279 css::uno::XComponentContext
*,
4280 css::uno::Sequence
<css::uno::Any
> const &)
4282 return cppu::acquire(new UnoNumericFieldControl());
4286 // class UnoControlCurrencyFieldModel
4288 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
4289 :UnoControlModel( rxContext
)
4291 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField
);
4294 OUString
UnoControlCurrencyFieldModel::getServiceName()
4296 return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel
);
4299 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4301 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4303 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlCurrencyField
) );
4305 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
4307 return uno::Any(false);
4310 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4313 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
4315 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4318 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4319 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4324 // beans::XMultiPropertySet
4325 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( )
4327 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4331 OUString
UnoControlCurrencyFieldModel::getImplementationName()
4333 return OUString("stardiv.Toolkit.UnoControlCurrencyFieldModel");
4336 css::uno::Sequence
<OUString
>
4337 UnoControlCurrencyFieldModel::getSupportedServiceNames()
4339 auto s(UnoControlModel::getSupportedServiceNames());
4340 s
.realloc(s
.getLength() + 2);
4341 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyFieldModel";
4342 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.CurrencyField";
4346 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4347 stardiv_Toolkit_UnoControlCurrencyFieldModel_get_implementation(
4348 css::uno::XComponentContext
*context
,
4349 css::uno::Sequence
<css::uno::Any
> const &)
4351 return cppu::acquire(new UnoControlCurrencyFieldModel(context
));
4355 // class UnoCurrencyFieldControl
4357 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
4358 :UnoSpinFieldControl()
4361 mnLast
= 0x7FFFFFFF;
4364 OUString
UnoCurrencyFieldControl::GetComponentServiceName()
4366 return OUString("longcurrencyfield");
4370 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
)
4372 uno::Any aRet
= ::cppu::queryInterface( rType
,
4373 (static_cast< awt::XCurrencyField
* >(this)) );
4374 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4377 // lang::XTypeProvider
4378 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl
)
4379 cppu::UnoType
<awt::XCurrencyField
>::get(),
4380 UnoSpinFieldControl::getTypes()
4381 IMPL_XTYPEPROVIDER_END
4383 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
)
4385 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
4387 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4388 xField
->setFirst( mnFirst
);
4389 xField
->setLast( mnLast
);
4392 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
)
4394 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4395 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), uno::Any(xField
->getValue()), false );
4397 if ( GetTextListeners().getLength() )
4398 GetTextListeners().textChanged( e
);
4401 void UnoCurrencyFieldControl::setValue( double Value
)
4403 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), Any(Value
), true );
4406 double UnoCurrencyFieldControl::getValue()
4408 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
4411 void UnoCurrencyFieldControl::setMin( double Value
)
4413 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), uno::Any(Value
), true );
4416 double UnoCurrencyFieldControl::getMin()
4418 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
4421 void UnoCurrencyFieldControl::setMax( double Value
)
4423 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), uno::Any(Value
), true );
4426 double UnoCurrencyFieldControl::getMax()
4428 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
4431 void UnoCurrencyFieldControl::setFirst( double Value
)
4434 if ( getPeer().is() )
4436 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4437 xField
->setFirst( mnFirst
);
4441 double UnoCurrencyFieldControl::getFirst()
4446 void UnoCurrencyFieldControl::setLast( double Value
)
4449 if ( getPeer().is() )
4451 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
4452 xField
->setLast( mnLast
);
4456 double UnoCurrencyFieldControl::getLast()
4461 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
)
4463 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4466 sal_Bool
UnoCurrencyFieldControl::isStrictFormat()
4468 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4471 OUString
UnoCurrencyFieldControl::getImplementationName()
4473 return OUString("stardiv.Toolkit.UnoCurrencyFieldControl");
4476 css::uno::Sequence
<OUString
>
4477 UnoCurrencyFieldControl::getSupportedServiceNames()
4479 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4480 s
.realloc(s
.getLength() + 2);
4481 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlCurrencyField";
4482 s
[s
.getLength() - 1] = "stardiv.vcl.control.CurrencyField";
4486 void UnoCurrencyFieldControl::setSpinSize( double Digits
)
4488 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), uno::Any(Digits
), true );
4491 double UnoCurrencyFieldControl::getSpinSize()
4493 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4496 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
)
4498 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), uno::Any(Digits
), true );
4501 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits()
4503 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4506 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4507 stardiv_Toolkit_UnoCurrencyFieldControl_get_implementation(
4508 css::uno::XComponentContext
*,
4509 css::uno::Sequence
<css::uno::Any
> const &)
4511 return cppu::acquire(new UnoCurrencyFieldControl());
4515 // class UnoControlPatternFieldModel
4517 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4518 :UnoControlModel( rxContext
)
4520 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField
);
4523 OUString
UnoControlPatternFieldModel::getServiceName()
4525 return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel
);
4528 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4530 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4532 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlPatternField
) );
4534 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4537 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4539 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4542 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4543 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4548 // beans::XMultiPropertySet
4549 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( )
4551 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4555 OUString
UnoControlPatternFieldModel::getImplementationName()
4557 return OUString("stardiv.Toolkit.UnoControlPatternFieldModel");
4560 css::uno::Sequence
<OUString
>
4561 UnoControlPatternFieldModel::getSupportedServiceNames()
4563 auto s(UnoControlModel::getSupportedServiceNames());
4564 s
.realloc(s
.getLength() + 2);
4565 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternFieldModel";
4566 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.PatternField";
4570 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4571 stardiv_Toolkit_UnoControlPatternFieldModel_get_implementation(
4572 css::uno::XComponentContext
*context
,
4573 css::uno::Sequence
<css::uno::Any
> const &)
4575 return cppu::acquire(new UnoControlPatternFieldModel(context
));
4579 // class UnoPatternFieldControl
4581 UnoPatternFieldControl::UnoPatternFieldControl()
4582 :UnoSpinFieldControl()
4586 OUString
UnoPatternFieldControl::GetComponentServiceName()
4588 return OUString("patternfield");
4591 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4593 sal_uInt16 nType
= GetPropertyId( rPropName
);
4594 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4596 // These masks cannot be set consecutively
4597 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4598 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4599 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4601 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4604 // same comment as in UnoControl::ImplSetPeerProperty - see there
4605 OUString
sText( Text
);
4606 ImplCheckLocalize( sText
);
4607 xPF
->setString( sText
);
4608 xPF
->setMasks( EditMask
, LiteralMask
);
4612 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4617 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
)
4619 uno::Any aRet
= ::cppu::queryInterface( rType
,
4620 (static_cast< awt::XPatternField
* >(this)) );
4621 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4624 // lang::XTypeProvider
4625 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl
)
4626 cppu::UnoType
<awt::XPatternField
>::get(),
4627 UnoSpinFieldControl::getTypes()
4628 IMPL_XTYPEPROVIDER_END
4630 void UnoPatternFieldControl::setString( const OUString
& rString
)
4635 OUString
UnoPatternFieldControl::getString()
4640 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
)
4642 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), uno::Any(EditMask
), true );
4643 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), uno::Any(LiteralMask
), true );
4646 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
)
4648 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4649 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4652 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
)
4654 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), uno::Any(bStrict
), true );
4657 sal_Bool
UnoPatternFieldControl::isStrictFormat()
4659 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4662 OUString
UnoPatternFieldControl::getImplementationName()
4664 return OUString("stardiv.Toolkit.UnoPatternFieldControl");
4667 css::uno::Sequence
<OUString
> UnoPatternFieldControl::getSupportedServiceNames()
4669 auto s(UnoSpinFieldControl::getSupportedServiceNames());
4670 s
.realloc(s
.getLength() + 2);
4671 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlPatternField";
4672 s
[s
.getLength() - 1] = "stardiv.vcl.control.PatternField";
4676 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4677 stardiv_Toolkit_UnoPatternFieldControl_get_implementation(
4678 css::uno::XComponentContext
*,
4679 css::uno::Sequence
<css::uno::Any
> const &)
4681 return cppu::acquire(new UnoPatternFieldControl());
4685 // class UnoControlProgressBarModel
4687 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4688 :UnoControlModel( rxContext
)
4690 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4691 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4692 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4693 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4694 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4695 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4696 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4697 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4698 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4699 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4700 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4701 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4702 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4705 OUString
UnoControlProgressBarModel::getServiceName( )
4707 return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel
);
4710 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4712 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4714 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlProgressBar
) );
4717 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4720 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4722 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4725 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4726 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4731 // beans::XMultiPropertySet
4732 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( )
4734 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4738 OUString
UnoControlProgressBarModel::getImplementationName()
4740 return OUString("stardiv.Toolkit.UnoControlProgressBarModel");
4743 css::uno::Sequence
<OUString
>
4744 UnoControlProgressBarModel::getSupportedServiceNames()
4746 auto s(UnoControlModel::getSupportedServiceNames());
4747 s
.realloc(s
.getLength() + 2);
4748 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBarModel";
4749 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.ProgressBar";
4753 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4754 stardiv_Toolkit_UnoControlProgressBarModel_get_implementation(
4755 css::uno::XComponentContext
*context
,
4756 css::uno::Sequence
<css::uno::Any
> const &)
4758 return cppu::acquire(new UnoControlProgressBarModel(context
));
4762 // class UnoProgressBarControl
4764 UnoProgressBarControl::UnoProgressBarControl()
4769 OUString
UnoProgressBarControl::GetComponentServiceName()
4771 return OUString("ProgressBar");
4775 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
)
4777 uno::Any aRet
= ::cppu::queryInterface( rType
,
4778 (static_cast< awt::XProgressBar
* >(this)) );
4779 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4782 // lang::XTypeProvider
4783 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl
)
4784 cppu::UnoType
<awt::XProgressBar
>::get(),
4785 UnoControlBase::getTypes()
4786 IMPL_XTYPEPROVIDER_END
4788 // css::awt::XProgressBar
4789 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
)
4791 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), uno::Any(nColor
), true );
4794 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
)
4796 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), uno::Any(nColor
), true );
4799 void UnoProgressBarControl::setValue( sal_Int32 nValue
)
4801 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), uno::Any(nValue
), true );
4804 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
)
4811 // take correct min and max
4817 // change min and max
4822 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, true );
4823 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, true );
4826 sal_Int32
UnoProgressBarControl::getValue()
4828 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4831 OUString
UnoProgressBarControl::getImplementationName()
4833 return OUString("stardiv.Toolkit.UnoProgressBarControl");
4836 css::uno::Sequence
<OUString
> UnoProgressBarControl::getSupportedServiceNames()
4838 auto s(UnoControlBase::getSupportedServiceNames());
4839 s
.realloc(s
.getLength() + 2);
4840 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlProgressBar";
4841 s
[s
.getLength() - 1] = "stardiv.vcl.control.ProgressBar";
4845 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4846 stardiv_Toolkit_UnoProgressBarControl_get_implementation(
4847 css::uno::XComponentContext
*,
4848 css::uno::Sequence
<css::uno::Any
> const &)
4850 return cppu::acquire(new UnoProgressBarControl());
4854 // class UnoControlFixedLineModel
4856 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4857 :UnoControlModel( rxContext
)
4859 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4860 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4861 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4862 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4863 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4864 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4865 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4866 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4867 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4868 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4871 OUString
UnoControlFixedLineModel::getServiceName( )
4873 return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel
);
4876 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4878 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4880 return uno::Any( OUString::createFromAscii( szServiceName_UnoControlFixedLine
) );
4882 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4885 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4887 static UnoPropertyArrayHelper
* pHelper
= nullptr;
4890 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4891 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4896 // beans::XMultiPropertySet
4897 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( )
4899 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4903 OUString
UnoControlFixedLineModel::getImplementationName()
4905 return OUString("stardiv.Toolkit.UnoControlFixedLineModel");
4908 css::uno::Sequence
<OUString
>
4909 UnoControlFixedLineModel::getSupportedServiceNames()
4911 auto s(UnoControlModel::getSupportedServiceNames());
4912 s
.realloc(s
.getLength() + 2);
4913 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLineModel";
4914 s
[s
.getLength() - 1] = "stardiv.vcl.controlmodel.FixedLine";
4918 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4919 stardiv_Toolkit_UnoControlFixedLineModel_get_implementation(
4920 css::uno::XComponentContext
*context
,
4921 css::uno::Sequence
<css::uno::Any
> const &)
4923 return cppu::acquire(new UnoControlFixedLineModel(context
));
4927 // class UnoFixedLineControl
4929 UnoFixedLineControl::UnoFixedLineControl()
4932 maComponentInfos
.nWidth
= 100; // ??
4933 maComponentInfos
.nHeight
= 100; // ??
4936 OUString
UnoFixedLineControl::GetComponentServiceName()
4938 return OUString("FixedLine");
4941 sal_Bool
UnoFixedLineControl::isTransparent()
4946 OUString
UnoFixedLineControl::getImplementationName()
4948 return OUString("stardiv.Toolkit.UnoFixedLineControl");
4951 css::uno::Sequence
<OUString
> UnoFixedLineControl::getSupportedServiceNames()
4953 auto s(UnoControlBase::getSupportedServiceNames());
4954 s
.realloc(s
.getLength() + 2);
4955 s
[s
.getLength() - 2] = "com.sun.star.awt.UnoControlFixedLine";
4956 s
[s
.getLength() - 1] = "stardiv.vcl.control.FixedLine";
4960 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
4961 stardiv_Toolkit_UnoFixedLineControl_get_implementation(
4962 css::uno::XComponentContext
*,
4963 css::uno::Sequence
<css::uno::Any
> const &)
4965 return cppu::acquire(new UnoFixedLineControl());
4968 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */