1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/awt/XTextArea.hpp>
21 #include <com/sun/star/awt/XVclWindowPeer.hpp>
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/awt/PosSize.hpp>
24 #include <com/sun/star/awt/VisualEffect.hpp>
25 #include <com/sun/star/awt/LineEndFormat.hpp>
26 #include <com/sun/star/graphic/GraphicProvider.hpp>
27 #include <com/sun/star/graphic/XGraphicProvider.hpp>
28 #include <com/sun/star/graphic/GraphicObject.hpp>
29 #include <com/sun/star/util/Date.hpp>
30 #include <com/sun/star/awt/ImageScaleMode.hpp>
33 #include <toolkit/controls/formattedcontrol.hxx>
34 #include <toolkit/controls/roadmapcontrol.hxx>
35 #include <toolkit/controls/unocontrols.hxx>
36 #include <toolkit/controls/stdtabcontroller.hxx>
37 #include <toolkit/helper/property.hxx>
38 #include <toolkit/helper/unopropertyarrayhelper.hxx>
39 #include <toolkit/helper/servicenames.hxx>
40 #include <toolkit/helper/macros.hxx>
41 #include <toolkit/helper/imagealign.hxx>
44 #include <toolkit/awt/vclxwindows.hxx>
45 #include <cppuhelper/typeprovider.hxx>
46 #include <comphelper/componentcontext.hxx>
47 #include <comphelper/processfactory.hxx>
48 #include <comphelper/extract.hxx>
49 #include <vcl/wrkwin.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vcl/edit.hxx>
52 #include <vcl/button.hxx>
53 #include <vcl/group.hxx>
54 #include <vcl/fixed.hxx>
55 #include <vcl/lstbox.hxx>
56 #include <vcl/combobox.hxx>
57 #include <tools/debug.hxx>
58 #include <tools/diagnose_ex.h>
59 #include <tools/date.hxx>
60 #include <tools/time.hxx>
65 using namespace ::com::sun::star
;
66 using ::com::sun::star::graphic::XGraphic
;
67 using ::com::sun::star::uno::Reference
;
68 using namespace ::toolkit
;
70 #define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \
71 ::rtl::OUString SAL_CALL ImplName::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) { return ::rtl::OUString( "stardiv.Toolkit." #ImplName ); } \
72 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) \
74 ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = BaseClass::getSupportedServiceNames( ); \
75 aNames.realloc( aNames.getLength() + 1 ); \
76 aNames[ aNames.getLength() - 1 ] = ::rtl::OUString::createFromAscii( ServiceName ); \
81 uno::Reference< graphic::XGraphic >
82 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const ::rtl::OUString
& _rURL
)
84 if( ( _rURL
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX
, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX
) ) == 0 ) )
86 // graphic manager uniqueid
87 rtl::OUString sID
= _rURL
.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX
) - 1 );
88 // get the DefaultContext
89 ::comphelper::ComponentContext
aContext( ::comphelper::getProcessServiceFactory() );
90 xOutGraphicObj
= graphic::GraphicObject::createWithId( aContext
.getUNOContext(), sID
);
93 xOutGraphicObj
= NULL
; // release the GraphicObject
95 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
98 ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
>
99 ImageHelper::getGraphicFromURL_nothrow( const ::rtl::OUString
& _rURL
)
101 uno::Reference
< graphic::XGraphic
> xGraphic
;
102 if ( _rURL
.isEmpty() )
107 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
108 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
109 uno::Sequence
< beans::PropertyValue
> aMediaProperties(1);
110 aMediaProperties
[0].Name
= ::rtl::OUString( "URL" );
111 aMediaProperties
[0].Value
<<= _rURL
;
112 xGraphic
= xProvider
->queryGraphic( aMediaProperties
);
114 catch (const Exception
&)
116 DBG_UNHANDLED_EXCEPTION();
121 // ----------------------------------------------------
122 // class UnoControlEditModel
123 // ----------------------------------------------------
124 UnoControlEditModel::UnoControlEditModel( const Reference
< XMultiServiceFactory
>& i_factory
)
125 :UnoControlModel( i_factory
)
127 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit
);
130 ::rtl::OUString
UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
132 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlEditModel
);
135 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
141 case BASEPROPERTY_LINE_END_FORMAT
:
142 aReturn
<<= (sal_Int16
)awt::LineEndFormat::LINE_FEED
; // LF
144 case BASEPROPERTY_DEFAULTCONTROL
:
145 aReturn
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlEdit
);
148 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
154 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
156 static UnoPropertyArrayHelper
* pHelper
= NULL
;
159 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
160 pHelper
= new UnoPropertyArrayHelper( aIDs
);
165 // beans::XMultiPropertySet
166 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
168 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
173 // ----------------------------------------------------
174 // class UnoEditControl
175 // ----------------------------------------------------
176 UnoEditControl::UnoEditControl( const Reference
< XMultiServiceFactory
>& i_factory
)
177 :UnoControlBase( i_factory
)
178 ,maTextListeners( *this )
180 ,mbSetTextInPeer( sal_False
)
181 ,mbSetMaxTextLenInPeer( sal_False
)
182 ,mbHasTextProperty( sal_False
)
184 maComponentInfos
.nWidth
= 100;
185 maComponentInfos
.nHeight
= 12;
187 mbSetMaxTextLenInPeer
= sal_False
;
190 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
192 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
193 if ( !aReturn
.hasValue() )
194 aReturn
= UnoEditControl_Base::queryInterface( rType
);
198 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
200 return UnoControlBase::queryInterface( rType
);
203 void SAL_CALL
UnoEditControl::acquire( ) throw ()
205 UnoControlBase::acquire();
208 void SAL_CALL
UnoEditControl::release( ) throw ()
210 UnoControlBase::release();
213 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
215 ::rtl::OUString
UnoEditControl::GetComponentServiceName()
217 // by default, we want a simple edit field
218 ::rtl::OUString
sName( "Edit" );
220 // but maybe we are to display multi-line text?
221 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
222 sal_Bool b
= sal_Bool();
223 if ( ( aVal
>>= b
) && b
)
224 sName
= ::rtl::OUString("MultiLineEdit");
229 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
) throw ( uno::RuntimeException
)
231 sal_Bool bReturn
= UnoControlBase::setModel( _rModel
);
232 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
236 void UnoEditControl::ImplSetPeerProperty( const ::rtl::OUString
& rPropName
, const uno::Any
& rVal
)
238 sal_Bool bDone
= sal_False
;
239 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
241 // #96986# use setText(), or text listener will not be called.
242 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
243 if ( xTextComponent
.is() )
245 ::rtl::OUString sText
;
247 ImplCheckLocalize( sText
);
248 xTextComponent
->setText( sText
);
254 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
257 void UnoEditControl::dispose() throw(uno::RuntimeException
)
259 lang::EventObject
aEvt( *this );
260 maTextListeners
.disposeAndClear( aEvt
);
261 UnoControl::dispose();
264 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
266 UnoControl::createPeer( rxToolkit
, rParentPeer
);
268 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
271 xText
->addTextListener( this );
273 if ( mbSetMaxTextLenInPeer
)
274 xText
->setMaxTextLen( mnMaxTextLen
);
275 if ( mbSetTextInPeer
)
276 xText
->setText( maText
);
280 void UnoEditControl::textChanged(const awt::TextEvent
& e
) throw(uno::RuntimeException
)
282 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
284 if ( mbHasTextProperty
)
287 aAny
<<= xText
->getText();
288 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), aAny
, sal_False
);
292 maText
= xText
->getText();
295 if ( maTextListeners
.getLength() )
296 maTextListeners
.textChanged( e
);
299 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
)
301 maTextListeners
.addInterface( l
);
304 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
)
306 maTextListeners
.removeInterface( l
);
309 void UnoEditControl::setText( const ::rtl::OUString
& aText
) throw(uno::RuntimeException
)
311 if ( mbHasTextProperty
)
315 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), aAny
, sal_True
);
320 mbSetTextInPeer
= sal_True
;
321 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
323 xText
->setText( maText
);
326 // Setting the property to the VCLXWindow doesn't call textChanged
327 if ( maTextListeners
.getLength() )
329 awt::TextEvent aEvent
;
330 aEvent
.Source
= *this;
331 maTextListeners
.textChanged( aEvent
);
337 static void lcl_normalize( awt::Selection
& _rSel
)
339 if ( _rSel
.Min
> _rSel
.Max
)
340 ::std::swap( _rSel
.Min
, _rSel
.Max
);
344 void UnoEditControl::insertText( const awt::Selection
& rSel
, const ::rtl::OUString
& rNewText
) throw(uno::RuntimeException
)
346 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
347 awt::Selection
aSelection( rSel
);
348 lcl_normalize( aSelection
);
350 // preserve the selection resp. cursor position
351 awt::Selection
aNewSelection( getSelection() );
352 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
353 // (not sure - looks uglier ...)
354 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
355 if ( aNewSelection
.Min
> aSelection
.Min
)
356 aNewSelection
.Min
-= nDeletedCharacters
;
357 if ( aNewSelection
.Max
> aSelection
.Max
)
358 aNewSelection
.Max
-= nDeletedCharacters
;
360 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
361 aNewSelection
.Min
= aNewSelection
.Max
;
364 ::rtl::OUString aOldText
= getText();
365 ::rtl::OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
368 setSelection( aNewSelection
);
371 ::rtl::OUString
UnoEditControl::getText() throw(uno::RuntimeException
)
373 ::rtl::OUString aText
= maText
;
375 if ( mbHasTextProperty
)
376 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
379 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
381 aText
= xText
->getText();
387 ::rtl::OUString
UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException
)
389 ::rtl::OUString sSelected
;
390 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
392 sSelected
= xText
->getSelectedText();
397 void UnoEditControl::setSelection( const awt::Selection
& aSelection
) throw(uno::RuntimeException
)
399 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
401 xText
->setSelection( aSelection
);
404 awt::Selection
UnoEditControl::getSelection( void ) throw(uno::RuntimeException
)
407 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
409 aSel
= xText
->getSelection();
413 sal_Bool
UnoEditControl::isEditable( void ) throw(uno::RuntimeException
)
415 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
418 void UnoEditControl::setEditable( sal_Bool bEditable
) throw(uno::RuntimeException
)
421 aAny
<<= (sal_Bool
)!bEditable
;
422 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), aAny
, sal_True
);
425 sal_Int16
UnoEditControl::getMaxTextLen() throw(uno::RuntimeException
)
427 sal_Int16 nMaxLen
= mnMaxTextLen
;
429 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
430 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
435 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
) throw(uno::RuntimeException
)
437 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
440 aAny
<<= (sal_Int16
)nLen
;
441 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), aAny
, sal_True
);
446 mbSetMaxTextLenInPeer
= sal_True
;
447 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
449 xText
->setMaxTextLen( mnMaxTextLen
);
453 awt::Size
UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException
)
455 return Impl_getMinimumSize();
458 awt::Size
UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException
)
460 return Impl_getPreferredSize();
463 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
465 return Impl_calcAdjustedSize( rNewSize
);
468 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
)
470 return Impl_getMinimumSize( nCols
, nLines
);
473 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
)
475 Impl_getColumnsAndLines( nCols
, nLines
);
478 ::rtl::OUString
UnoEditControl::getImplementationName( ) throw(uno::RuntimeException
)
480 return ::rtl::OUString( "stardiv.Toolkit.UnoEditControl" );
483 uno::Sequence
< ::rtl::OUString
> UnoEditControl::getSupportedServiceNames() throw(uno::RuntimeException
)
485 uno::Sequence
< ::rtl::OUString
> aNames
= UnoControlBase::getSupportedServiceNames( );
486 aNames
.realloc( aNames
.getLength() + 1 );
487 aNames
[ aNames
.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlEdit
);
491 // ----------------------------------------------------
492 // class UnoControlFileControlModel
493 // ----------------------------------------------------
494 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XMultiServiceFactory
>& i_factory
)
495 :UnoControlModel( i_factory
)
497 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
498 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
499 ImplRegisterProperty( BASEPROPERTY_BORDER
);
500 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
501 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
502 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
503 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
504 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
505 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
506 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
507 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
508 ImplRegisterProperty( BASEPROPERTY_READONLY
);
509 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
510 ImplRegisterProperty( BASEPROPERTY_TEXT
);
511 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
512 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
513 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
514 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
517 ::rtl::OUString
UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
519 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControlModel
);
522 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
524 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
527 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControl
);
530 return UnoControlModel::ImplGetDefaultValue( nPropId
);
533 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
535 static UnoPropertyArrayHelper
* pHelper
= NULL
;
538 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
539 pHelper
= new UnoPropertyArrayHelper( aIDs
);
544 // beans::XMultiPropertySet
545 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
547 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
551 // ----------------------------------------------------
552 // class UnoFileControl
553 // ----------------------------------------------------
554 UnoFileControl::UnoFileControl( const Reference
< XMultiServiceFactory
>& i_factory
)
555 :UnoEditControl( i_factory
)
559 ::rtl::OUString
UnoFileControl::GetComponentServiceName()
561 return ::rtl::OUString("filecontrol");
564 // ----------------------------------------------------
565 // class GraphicControlModel
566 // ----------------------------------------------------
567 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
569 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
570 return uno::makeAny( uno::Reference
< graphic::XGraphic
>() );
572 return UnoControlModel::ImplGetDefaultValue( nPropId
);
575 void SAL_CALL
GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
)
577 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
579 // - ImageAlign and ImagePosition need to correspond to each other
580 // - Graphic and ImageURL need to correspond to each other
585 case BASEPROPERTY_IMAGEURL
:
586 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
588 mbAdjustingGraphic
= true;
589 ::rtl::OUString sImageURL
;
590 OSL_VERIFY( rValue
>>= sImageURL
);
591 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC
, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
592 mbAdjustingGraphic
= false;
596 case BASEPROPERTY_GRAPHIC
:
597 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
599 mbAdjustingGraphic
= true;
600 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL
, uno::makeAny( ::rtl::OUString() ) );
601 mbAdjustingGraphic
= false;
605 case BASEPROPERTY_IMAGEALIGN
:
606 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
608 mbAdjustingImagePosition
= true;
609 sal_Int16 nUNOValue
= 0;
610 OSL_VERIFY( rValue
>>= nUNOValue
);
611 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION
, uno::makeAny( getExtendedImagePosition( nUNOValue
) ) );
612 mbAdjustingImagePosition
= false;
615 case BASEPROPERTY_IMAGEPOSITION
:
616 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
618 mbAdjustingImagePosition
= true;
619 sal_Int16 nUNOValue
= 0;
620 OSL_VERIFY( rValue
>>= nUNOValue
);
621 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN
, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
622 mbAdjustingImagePosition
= false;
627 catch( const ::com::sun::star::uno::Exception
& )
629 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
630 mbAdjustingImagePosition
= sal_False
;
634 // ----------------------------------------------------
635 // class UnoControlButtonModel
636 // ----------------------------------------------------
637 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XMultiServiceFactory
>& i_factory
)
638 :GraphicControlModel( i_factory
)
640 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton
);
642 osl_atomic_increment( &m_refCount
);
644 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
645 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
646 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
648 osl_atomic_decrement( &m_refCount
);
651 ::rtl::OUString
UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
653 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel
);
656 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
660 case BASEPROPERTY_DEFAULTCONTROL
:
661 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlButton
) );
662 case BASEPROPERTY_TOGGLE
:
663 return uno::makeAny( (sal_Bool
)sal_False
);
664 case BASEPROPERTY_ALIGN
:
665 return uno::makeAny( (sal_Int16
)PROPERTY_ALIGN_CENTER
);
666 case BASEPROPERTY_FOCUSONCLICK
:
667 return uno::makeAny( (sal_Bool
)sal_True
);
670 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
673 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
675 static UnoPropertyArrayHelper
* pHelper
= NULL
;
678 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
679 pHelper
= new UnoPropertyArrayHelper( aIDs
);
684 // beans::XMultiPropertySet
685 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
687 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
691 // ----------------------------------------------------
692 // class UnoButtonControl
693 // ----------------------------------------------------
694 UnoButtonControl::UnoButtonControl( const uno::Reference
< lang::XMultiServiceFactory
>& i_factory
)
695 :UnoButtonControl_Base( i_factory
)
696 ,maActionListeners( *this )
697 ,maItemListeners( *this )
699 maComponentInfos
.nWidth
= 50;
700 maComponentInfos
.nHeight
= 14;
703 ::rtl::OUString
UnoButtonControl::GetComponentServiceName()
705 ::rtl::OUString
aName( "pushbutton" );
706 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
707 sal_Int16 n
= sal_Int16();
708 if ( ( aVal
>>= n
) && n
)
710 // Use PushButtonType later when available...
713 case 1 /*PushButtonType::OK*/: aName
= ::rtl::OUString("okbutton");
715 case 2 /*PushButtonType::CANCEL*/: aName
= ::rtl::OUString("cancelbutton");
717 case 3 /*PushButtonType::HELP*/: aName
= ::rtl::OUString("helpbutton");
721 OSL_FAIL( "Unknown Button Type!" );
728 void UnoButtonControl::dispose() throw(uno::RuntimeException
)
730 lang::EventObject aEvt
;
731 aEvt
.Source
= (::cppu::OWeakObject
*)this;
732 maActionListeners
.disposeAndClear( aEvt
);
733 maItemListeners
.disposeAndClear( aEvt
);
734 UnoControlBase::dispose();
737 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
739 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
741 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
742 xButton
->setActionCommand( maActionCommand
);
743 if ( maActionListeners
.getLength() )
744 xButton
->addActionListener( &maActionListeners
);
746 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
747 if ( xPushButton
.is() )
748 xPushButton
->addItemListener( this );
751 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
753 maActionListeners
.addInterface( l
);
754 if( getPeer().is() && maActionListeners
.getLength() == 1 )
756 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
757 xButton
->addActionListener( &maActionListeners
);
761 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
763 if( getPeer().is() && maActionListeners
.getLength() == 1 )
765 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
766 xButton
->removeActionListener( &maActionListeners
);
768 maActionListeners
.removeInterface( l
);
771 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
773 maItemListeners
.addInterface( l
);
776 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
778 maItemListeners
.removeInterface( l
);
781 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
) throw (uno::RuntimeException
)
783 UnoControlBase::disposing( Source
);
786 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw (uno::RuntimeException
)
790 aAny
<<= (sal_Int16
)rEvent
.Selected
;
791 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
794 ItemEvent
aEvent( rEvent
);
795 aEvent
.Source
= *this;
796 maItemListeners
.itemStateChanged( aEvent
);
799 void UnoButtonControl::setLabel( const ::rtl::OUString
& rLabel
) throw(uno::RuntimeException
)
803 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
806 void UnoButtonControl::setActionCommand( const ::rtl::OUString
& rCommand
) throw(uno::RuntimeException
)
808 maActionCommand
= rCommand
;
809 if ( getPeer().is() )
811 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
812 xButton
->setActionCommand( rCommand
);
816 awt::Size
UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException
)
818 return Impl_getMinimumSize();
821 awt::Size
UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException
)
823 return Impl_getPreferredSize();
826 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
828 return Impl_calcAdjustedSize( rNewSize
);
831 // ----------------------------------------------------
832 // class UnoControlImageControlModel
833 // ----------------------------------------------------
834 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XMultiServiceFactory
>& i_factory
)
835 :GraphicControlModel( i_factory
)
836 ,mbAdjustingImageScaleMode( false )
838 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl
);
841 ::rtl::OUString
UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
843 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControlModel
);
846 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
848 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
849 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl
) );
851 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
852 return makeAny( awt::ImageScaleMode::Anisotropic
);
854 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
857 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
859 static UnoPropertyArrayHelper
* pHelper
= NULL
;
862 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
863 pHelper
= new UnoPropertyArrayHelper( aIDs
);
868 // beans::XMultiPropertySet
869 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
871 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
875 void SAL_CALL
UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
) throw (::com::sun::star::uno::Exception
)
877 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
879 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
884 case BASEPROPERTY_IMAGE_SCALE_MODE
:
885 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
887 mbAdjustingImageScaleMode
= true;
888 sal_Int16
nScaleMode( awt::ImageScaleMode::Anisotropic
);
889 OSL_VERIFY( _rValue
>>= nScaleMode
);
890 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE
, uno::makeAny( sal_Bool( nScaleMode
!= awt::ImageScaleMode::None
) ) );
891 mbAdjustingImageScaleMode
= false;
894 case BASEPROPERTY_SCALEIMAGE
:
895 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
897 mbAdjustingImageScaleMode
= true;
898 sal_Bool bScale
= sal_True
;
899 OSL_VERIFY( _rValue
>>= bScale
);
900 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE
, uno::makeAny( bScale
? awt::ImageScaleMode::Anisotropic
: awt::ImageScaleMode::None
) );
901 mbAdjustingImageScaleMode
= false;
906 catch( const Exception
& )
908 mbAdjustingImageScaleMode
= false;
913 // ----------------------------------------------------
914 // class UnoImageControlControl
915 // ----------------------------------------------------
916 UnoImageControlControl::UnoImageControlControl( const Reference
< XMultiServiceFactory
>& i_factory
)
917 :UnoImageControlControl_Base( i_factory
)
918 ,maActionListeners( *this )
920 // TODO: Where should I look for defaults?
921 maComponentInfos
.nWidth
= 100;
922 maComponentInfos
.nHeight
= 100;
925 ::rtl::OUString
UnoImageControlControl::GetComponentServiceName()
927 return ::rtl::OUString("fixedimage");
930 void UnoImageControlControl::dispose() throw(uno::RuntimeException
)
932 lang::EventObject aEvt
;
933 aEvt
.Source
= (::cppu::OWeakObject
*)this;
934 maActionListeners
.disposeAndClear( aEvt
);
935 UnoControl::dispose();
938 sal_Bool
UnoImageControlControl::isTransparent() throw(uno::RuntimeException
)
943 awt::Size
UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException
)
945 return Impl_getMinimumSize();
948 awt::Size
UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException
)
950 return Impl_getPreferredSize();
953 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
955 return Impl_calcAdjustedSize( rNewSize
);
958 // ----------------------------------------------------
959 // class UnoControlRadioButtonModel
960 // ----------------------------------------------------
961 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XMultiServiceFactory
>& i_factory
)
962 :GraphicControlModel( i_factory
)
964 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton
);
967 ::rtl::OUString
UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
969 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel
);
972 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
976 case BASEPROPERTY_DEFAULTCONTROL
:
977 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButton
) );
979 case BASEPROPERTY_VISUALEFFECT
:
980 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
983 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
986 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
988 static UnoPropertyArrayHelper
* pHelper
= NULL
;
991 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
992 pHelper
= new UnoPropertyArrayHelper( aIDs
);
997 // beans::XMultiPropertySet
998 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1000 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1006 // ----------------------------------------------------
1007 // class UnoRadioButtonControl
1008 // ----------------------------------------------------
1009 UnoRadioButtonControl::UnoRadioButtonControl( const Reference
< XMultiServiceFactory
>& i_factory
)
1010 :UnoRadioButtonControl_Base( i_factory
)
1011 ,maItemListeners( *this )
1012 ,maActionListeners( *this )
1014 maComponentInfos
.nWidth
= 100;
1015 maComponentInfos
.nHeight
= 12;
1018 ::rtl::OUString
UnoRadioButtonControl::GetComponentServiceName()
1020 return ::rtl::OUString("radiobutton");
1023 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException
)
1025 lang::EventObject aEvt
;
1026 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1027 maItemListeners
.disposeAndClear( aEvt
);
1028 UnoControlBase::dispose();
1032 sal_Bool
UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException
)
1037 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1039 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1041 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1042 xRadioButton
->addItemListener( this );
1044 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1045 xButton
->setActionCommand( maActionCommand
);
1046 if ( maActionListeners
.getLength() )
1047 xButton
->addActionListener( &maActionListeners
);
1049 // as default, set the "AutoToggle" to true
1050 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1051 // have it enabled by default because of 85071)
1052 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1053 if ( xVclWindowPeer
.is() )
1054 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), ::cppu::bool2any( sal_True
) );
1057 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1059 maItemListeners
.addInterface( l
);
1062 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1064 maItemListeners
.removeInterface( l
);
1067 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1069 maActionListeners
.addInterface( l
);
1070 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1072 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1073 xButton
->addActionListener( &maActionListeners
);
1077 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1079 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1081 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1082 xButton
->removeActionListener( &maActionListeners
);
1084 maActionListeners
.removeInterface( l
);
1087 void UnoRadioButtonControl::setLabel( const ::rtl::OUString
& rLabel
) throw(uno::RuntimeException
)
1091 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1094 void UnoRadioButtonControl::setActionCommand( const ::rtl::OUString
& rCommand
) throw(uno::RuntimeException
)
1096 maActionCommand
= rCommand
;
1097 if ( getPeer().is() )
1099 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1100 xButton
->setActionCommand( rCommand
);
1104 void UnoRadioButtonControl::setState( sal_Bool bOn
) throw(uno::RuntimeException
)
1106 sal_Int16 nState
= bOn
? 1 : 0;
1109 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_True
);
1112 sal_Bool
UnoRadioButtonControl::getState() throw(uno::RuntimeException
)
1114 sal_Int16 nState
= 0;
1115 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1117 return nState
? sal_True
: sal_False
;
1120 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
1123 aAny
<<= (sal_Int16
)rEvent
.Selected
;
1124 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
1127 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1128 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1130 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1131 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1132 // isn't the case anymore: For instance, this method here gets called for the radio button
1133 // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
1134 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1135 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1136 // all which matters here.
1138 if ( 1 == rEvent
.Selected
)
1140 if ( maItemListeners
.getLength() )
1141 maItemListeners
.itemStateChanged( rEvent
);
1143 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1144 // a radio button _without_ selecing another one, this would have caused a notification.
1145 // With the change done here, this today won't cause a notification anymore.
1147 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1148 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1149 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1150 // to be inconsistent with.
1153 awt::Size
UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException
)
1155 return Impl_getMinimumSize();
1158 awt::Size
UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException
)
1160 return Impl_getPreferredSize();
1163 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1165 return Impl_calcAdjustedSize( rNewSize
);
1168 // ----------------------------------------------------
1169 // class UnoControlCheckBoxModel
1170 // ----------------------------------------------------
1171 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XMultiServiceFactory
>& i_factory
)
1172 :GraphicControlModel( i_factory
)
1174 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox
);
1177 ::rtl::OUString
UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1179 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel
);
1182 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1186 case BASEPROPERTY_DEFAULTCONTROL
:
1187 return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBox
) );
1189 case BASEPROPERTY_VISUALEFFECT
:
1190 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1193 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1196 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1198 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1201 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1202 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1207 // beans::XMultiPropertySet
1208 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1210 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1216 // ----------------------------------------------------
1217 // class UnoCheckBoxControl
1218 // ----------------------------------------------------
1219 UnoCheckBoxControl::UnoCheckBoxControl( const uno::Reference
< lang::XMultiServiceFactory
>& i_factory
)
1220 :UnoCheckBoxControl_Base( i_factory
)
1221 ,maItemListeners( *this ), maActionListeners( *this )
1223 maComponentInfos
.nWidth
= 100;
1224 maComponentInfos
.nHeight
= 12;
1227 ::rtl::OUString
UnoCheckBoxControl::GetComponentServiceName()
1229 return ::rtl::OUString("checkbox");
1232 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException
)
1234 lang::EventObject aEvt
;
1235 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1236 maItemListeners
.disposeAndClear( aEvt
);
1237 UnoControlBase::dispose();
1240 sal_Bool
UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException
)
1245 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1247 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1249 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1250 xCheckBox
->addItemListener( this );
1252 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1253 xButton
->setActionCommand( maActionCommand
);
1254 if ( maActionListeners
.getLength() )
1255 xButton
->addActionListener( &maActionListeners
);
1258 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1260 maItemListeners
.addInterface( l
);
1263 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1265 maItemListeners
.removeInterface( l
);
1268 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1270 maActionListeners
.addInterface( l
);
1271 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1273 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1274 xButton
->addActionListener( &maActionListeners
);
1278 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1280 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1282 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1283 xButton
->removeActionListener( &maActionListeners
);
1285 maActionListeners
.removeInterface( l
);
1288 void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString
& rCommand
) throw(uno::RuntimeException
)
1290 maActionCommand
= rCommand
;
1291 if ( getPeer().is() )
1293 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1294 xButton
->setActionCommand( rCommand
);
1299 void UnoCheckBoxControl::setLabel( const ::rtl::OUString
& rLabel
) throw(uno::RuntimeException
)
1303 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1306 void UnoCheckBoxControl::setState( short n
) throw(uno::RuntimeException
)
1309 aAny
<<= (sal_Int16
)n
;
1310 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_True
);
1313 short UnoCheckBoxControl::getState() throw(uno::RuntimeException
)
1316 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1321 void UnoCheckBoxControl::enableTriState( sal_Bool b
) throw(uno::RuntimeException
)
1325 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), aAny
, sal_True
);
1328 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
1331 aAny
<<= (sal_Int16
)rEvent
.Selected
;
1332 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
1334 if ( maItemListeners
.getLength() )
1335 maItemListeners
.itemStateChanged( rEvent
);
1338 awt::Size
UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException
)
1340 return Impl_getMinimumSize();
1343 awt::Size
UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException
)
1345 return Impl_getPreferredSize();
1348 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1350 return Impl_calcAdjustedSize( rNewSize
);
1353 // ----------------------------------------------------
1354 // class UnoControlFixedHyperlinkModel
1355 // ----------------------------------------------------
1356 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XMultiServiceFactory
>& i_factory
)
1357 :UnoControlModel( i_factory
)
1359 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink
);
1362 ::rtl::OUString
UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1364 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel
);
1367 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1369 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1372 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink
);
1375 else if ( nPropId
== BASEPROPERTY_BORDER
)
1378 aAny
<<= (sal_Int16
)0;
1381 else if ( nPropId
== BASEPROPERTY_URL
)
1384 aAny
<<= ::rtl::OUString();
1388 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1391 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1393 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1396 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1397 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1402 // beans::XMultiPropertySet
1403 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1405 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1409 // ----------------------------------------------------
1410 // class UnoFixedHyperlinkControl
1411 // ----------------------------------------------------
1412 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl( const Reference
< XMultiServiceFactory
>& i_factory
)
1413 :UnoControlBase( i_factory
)
1414 ,maActionListeners( *this )
1416 maComponentInfos
.nWidth
= 100;
1417 maComponentInfos
.nHeight
= 12;
1420 ::rtl::OUString
UnoFixedHyperlinkControl::GetComponentServiceName()
1422 return ::rtl::OUString("fixedhyperlink");
1426 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
1428 uno::Any aRet
= ::cppu::queryInterface( rType
,
1429 (static_cast< awt::XFixedHyperlink
* >(this)),
1430 (static_cast< awt::XLayoutConstrains
* >(this)) );
1431 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1434 // lang::XTypeProvider
1435 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl
)
1436 getCppuType( ( uno::Reference
< awt::XFixedHyperlink
>* ) NULL
),
1437 getCppuType( ( uno::Reference
< awt::XLayoutConstrains
>* ) NULL
),
1438 UnoControlBase::getTypes()
1439 IMPL_XTYPEPROVIDER_END
1441 sal_Bool
UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException
)
1446 void UnoFixedHyperlinkControl::setText( const ::rtl::OUString
& Text
) throw(uno::RuntimeException
)
1450 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1453 ::rtl::OUString
UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException
)
1455 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1458 void UnoFixedHyperlinkControl::setURL( const ::rtl::OUString
& URL
) throw(::com::sun::star::uno::RuntimeException
)
1462 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), aAny
, sal_True
);
1465 ::rtl::OUString
UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException
)
1467 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1470 void UnoFixedHyperlinkControl::setAlignment( short nAlign
) throw(uno::RuntimeException
)
1473 aAny
<<= (sal_Int16
)nAlign
;
1474 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), aAny
, sal_True
);
1477 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException
)
1482 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1488 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException
)
1490 return Impl_getMinimumSize();
1493 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException
)
1495 return Impl_getPreferredSize();
1498 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1500 return Impl_calcAdjustedSize( rNewSize
);
1503 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException
)
1505 lang::EventObject aEvt
;
1506 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1507 maActionListeners
.disposeAndClear( aEvt
);
1508 UnoControlBase::dispose();
1511 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1513 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1515 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1516 if ( maActionListeners
.getLength() )
1517 xFixedHyperlink
->addActionListener( &maActionListeners
);
1520 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1522 maActionListeners
.addInterface( l
);
1523 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1525 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1526 xFixedHyperlink
->addActionListener( &maActionListeners
);
1530 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1532 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1534 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1535 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1537 maActionListeners
.removeInterface( l
);
1540 // ----------------------------------------------------
1541 // class UnoControlFixedTextModel
1542 // ----------------------------------------------------
1543 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XMultiServiceFactory
>& i_factory
)
1544 :UnoControlModel( i_factory
)
1546 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText
);
1549 ::rtl::OUString
UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1551 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedTextModel
);
1554 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1556 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1559 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedText
);
1562 else if ( nPropId
== BASEPROPERTY_BORDER
)
1565 aAny
<<= (sal_Int16
)0;
1569 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1572 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1574 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1577 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1578 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1583 // beans::XMultiPropertySet
1584 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1586 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1591 // ----------------------------------------------------
1592 // class UnoFixedTextControl
1593 // ----------------------------------------------------
1594 UnoFixedTextControl::UnoFixedTextControl( const Reference
< XMultiServiceFactory
>& i_factory
)
1595 :UnoControlBase( i_factory
)
1597 maComponentInfos
.nWidth
= 100;
1598 maComponentInfos
.nHeight
= 12;
1601 ::rtl::OUString
UnoFixedTextControl::GetComponentServiceName()
1603 return ::rtl::OUString("fixedtext");
1607 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
1609 uno::Any aRet
= ::cppu::queryInterface( rType
,
1610 (static_cast< awt::XFixedText
* >(this)),
1611 (static_cast< awt::XLayoutConstrains
* >(this)) );
1612 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1615 // lang::XTypeProvider
1616 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl
)
1617 getCppuType( ( uno::Reference
< awt::XFixedText
>* ) NULL
),
1618 getCppuType( ( uno::Reference
< awt::XLayoutConstrains
>* ) NULL
),
1619 UnoControlBase::getTypes()
1620 IMPL_XTYPEPROVIDER_END
1622 sal_Bool
UnoFixedTextControl::isTransparent() throw(uno::RuntimeException
)
1627 void UnoFixedTextControl::setText( const ::rtl::OUString
& Text
) throw(uno::RuntimeException
)
1631 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1634 ::rtl::OUString
UnoFixedTextControl::getText() throw(uno::RuntimeException
)
1636 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1639 void UnoFixedTextControl::setAlignment( short nAlign
) throw(uno::RuntimeException
)
1642 aAny
<<= (sal_Int16
)nAlign
;
1643 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), aAny
, sal_True
);
1646 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException
)
1651 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1657 awt::Size
UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException
)
1659 return Impl_getMinimumSize();
1662 awt::Size
UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException
)
1664 return Impl_getPreferredSize();
1667 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1669 return Impl_calcAdjustedSize( rNewSize
);
1672 // ----------------------------------------------------
1673 // class UnoControlGroupBoxModel
1674 // ----------------------------------------------------
1675 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XMultiServiceFactory
>& i_factory
)
1676 :UnoControlModel( i_factory
)
1678 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1679 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1680 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1681 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1682 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1683 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1684 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1685 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1686 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1687 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1690 ::rtl::OUString
UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1692 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel
);
1695 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1697 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1700 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox
);
1703 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1706 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1708 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1711 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1712 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1717 // beans::XMultiPropertySet
1718 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1720 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1724 // ----------------------------------------------------
1725 // class UnoGroupBoxControl
1726 // ----------------------------------------------------
1727 UnoGroupBoxControl::UnoGroupBoxControl( const Reference
< XMultiServiceFactory
>& i_factory
)
1728 :UnoControlBase( i_factory
)
1730 maComponentInfos
.nWidth
= 100;
1731 maComponentInfos
.nHeight
= 100;
1734 ::rtl::OUString
UnoGroupBoxControl::GetComponentServiceName()
1736 return ::rtl::OUString("groupbox");
1739 sal_Bool
UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException
)
1744 // =====================================================================================================================
1745 // = UnoControlListBoxModel_Data
1746 // =====================================================================================================================
1749 ::rtl::OUString ItemText
;
1750 ::rtl::OUString ItemImageURL
;
1760 ListItem( const ::rtl::OUString
& i_rItemText
)
1761 :ItemText( i_rItemText
)
1768 typedef beans::Pair
< ::rtl::OUString
, ::rtl::OUString
> UnoListItem
;
1770 struct StripItemData
: public ::std::unary_function
< ListItem
, UnoListItem
>
1772 UnoListItem
operator()( const ListItem
& i_rItem
)
1774 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
1778 struct UnoControlListBoxModel_Data
1780 UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
1781 :m_bSettingLegacyProperty( false )
1782 ,m_rAntiImpl( i_rAntiImpl
)
1787 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
1789 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
1791 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
1792 throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl
);
1793 return m_aListItems
[ i_nIndex
];
1796 ListItem
& getItem( const sal_Int32 i_nIndex
)
1798 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
1801 ListItem
& insertItem( const sal_Int32 i_nIndex
)
1803 if ( ( i_nIndex
< 0 ) || ( i_nIndex
> sal_Int32( m_aListItems
.size() ) ) )
1804 throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl
);
1805 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
1808 Sequence
< UnoListItem
> getAllItems() const
1810 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
1811 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
1815 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
1817 m_aListItems
= i_copySource
.m_aListItems
;
1820 void setAllItems( const ::std::vector
< ListItem
>& i_rItems
)
1822 m_aListItems
= i_rItems
;
1825 void removeItem( const sal_Int32 i_nIndex
)
1827 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
1828 throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl
);
1829 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
1832 void removeAllItems()
1834 ::std::vector
< ListItem
> aEmpty
;
1835 m_aListItems
.swap( aEmpty
);
1839 bool m_bSettingLegacyProperty
;
1842 UnoControlListBoxModel
& m_rAntiImpl
;
1843 ::std::vector
< ListItem
> m_aListItems
;
1846 // =====================================================================================================================
1847 // = UnoControlListBoxModel
1848 // =====================================================================================================================
1849 // ---------------------------------------------------------------------------------------------------------------------
1850 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XMultiServiceFactory
>& i_factory
, ConstructorMode
const i_mode
)
1851 :UnoControlListBoxModel_Base( i_factory
)
1852 ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1853 ,m_aItemListListeners( GetMutex() )
1855 if ( i_mode
== ConstructDefault
)
1857 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox
);
1860 // ---------------------------------------------------------------------------------------------------------------------
1861 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
1862 :UnoControlListBoxModel_Base( i_rSource
)
1863 ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1864 ,m_aItemListListeners( GetMutex() )
1866 m_pData
->copyItems( *i_rSource
.m_pData
);
1868 UnoControlListBoxModel::~UnoControlListBoxModel()
1871 IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel
, UnoControlModel
, szServiceName2_UnoControlListBoxModel
)
1872 // ---------------------------------------------------------------------------------------------------------------------
1873 ::rtl::OUString
UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1875 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel
);
1878 // ---------------------------------------------------------------------------------------------------------------------
1879 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1881 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1884 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBox
);
1887 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1890 // ---------------------------------------------------------------------------------------------------------------------
1891 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
1893 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1896 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1897 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1902 // ---------------------------------------------------------------------------------------------------------------------
1903 // beans::XMultiPropertySet
1904 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1906 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1910 // ---------------------------------------------------------------------------------------------------------------------
1913 struct CreateListItem
: public ::std::unary_function
< ::rtl::OUString
, ListItem
>
1915 ListItem
operator()( const ::rtl::OUString
& i_rItemText
)
1917 return ListItem( i_rItemText
);
1922 // ---------------------------------------------------------------------------------------------------------------------
1923 void SAL_CALL
UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
)
1925 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
1927 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
)
1930 uno::Sequence
<sal_Int16
> aSeq
;
1933 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS
, aAny
);
1935 if ( !m_pData
->m_bSettingLegacyProperty
)
1937 // synchronize the legacy StringItemList property with our list items
1938 Sequence
< ::rtl::OUString
> aStringItemList
;
1940 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
1941 OSL_VERIFY( aPropValue
>>= aStringItemList
);
1943 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
1945 aStringItemList
.getConstArray(),
1946 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
1950 m_pData
->setAllItems( aItems
);
1952 // since an XItemListListener does not have a "all items modified" or some such method,
1953 // we simulate this by notifying removal of all items, followed by insertion of all new
1955 lang::EventObject aEvent
;
1956 aEvent
.Source
= *this;
1957 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
1958 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
1959 // which is wrong for the above notifications ...
1964 // ---------------------------------------------------------------------------------------------------------------------
1965 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
1966 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const SAL_THROW(())
1968 // dependencies we know:
1969 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
1970 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
1972 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
1975 // ---------------------------------------------------------------------------------------------------------------------
1976 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount() throw (RuntimeException
)
1978 ::osl::MutexGuard
aGuard( GetMutex() );
1979 return m_pData
->getItemCount();
1982 // ---------------------------------------------------------------------------------------------------------------------
1983 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemText
, const ::rtl::OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
1985 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
1986 // SYNCHRONIZED ----->
1987 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
1988 rItem
.ItemText
= i_rItemText
;
1989 rItem
.ItemImageURL
= i_rItemImageURL
;
1991 impl_handleInsert( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
1992 // <----- SYNCHRONIZED
1995 // ---------------------------------------------------------------------------------------------------------------------
1996 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
)
1998 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
1999 // SYNCHRONIZED ----->
2000 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
2001 rItem
.ItemText
= i_rItemText
;
2003 impl_handleInsert( i_nPosition
, i_rItemText
, ::boost::optional
< ::rtl::OUString
>(), aGuard
);
2004 // <----- SYNCHRONIZED
2007 // ---------------------------------------------------------------------------------------------------------------------
2008 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2010 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2011 // SYNCHRONIZED ----->
2012 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
2013 rItem
.ItemImageURL
= i_rItemImageURL
;
2015 impl_handleInsert( i_nPosition
, ::boost::optional
< ::rtl::OUString
>(), i_rItemImageURL
, aGuard
);
2016 // <----- SYNCHRONIZED
2019 // ---------------------------------------------------------------------------------------------------------------------
2020 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2022 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2023 // SYNCHRONIZED ----->
2024 m_pData
->removeItem( i_nPosition
);
2026 impl_handleRemove( i_nPosition
, aGuard
);
2027 // <----- SYNCHRONIZED
2030 // ---------------------------------------------------------------------------------------------------------------------
2031 void SAL_CALL
UnoControlListBoxModel::removeAllItems( ) throw (::com::sun::star::uno::RuntimeException
)
2033 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2034 // SYNCHRONIZED ----->
2035 m_pData
->removeAllItems();
2037 impl_handleRemove( -1, aGuard
);
2038 // <----- SYNCHRONIZED
2041 // ---------------------------------------------------------------------------------------------------------------------
2042 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
)
2044 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2045 // SYNCHRONIZED ----->
2046 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2047 rItem
.ItemText
= i_rItemText
;
2049 impl_handleModify( i_nPosition
, i_rItemText
, ::boost::optional
< ::rtl::OUString
>(), aGuard
);
2050 // <----- SYNCHRONIZED
2053 // ---------------------------------------------------------------------------------------------------------------------
2054 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2056 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2057 // SYNCHRONIZED ----->
2058 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2059 rItem
.ItemImageURL
= i_rItemImageURL
;
2061 impl_handleModify( i_nPosition
, ::boost::optional
< ::rtl::OUString
>(), i_rItemImageURL
, aGuard
);
2062 // <----- SYNCHRONIZED
2065 // ---------------------------------------------------------------------------------------------------------------------
2066 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const ::rtl::OUString
& i_rItemText
, const ::rtl::OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2068 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2069 // SYNCHRONIZED ----->
2070 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2071 rItem
.ItemText
= i_rItemText
;
2072 rItem
.ItemImageURL
= i_rItemImageURL
;
2074 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2075 // <----- SYNCHRONIZED
2078 // ---------------------------------------------------------------------------------------------------------------------
2079 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
) throw (IndexOutOfBoundsException
, RuntimeException
)
2081 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2082 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2083 rItem
.ItemData
= i_rDataValue
;
2086 // ---------------------------------------------------------------------------------------------------------------------
2087 ::rtl::OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2089 ::osl::MutexGuard
aGuard( GetMutex() );
2090 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2091 return rItem
.ItemText
;
2094 // ---------------------------------------------------------------------------------------------------------------------
2095 ::rtl::OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2097 ::osl::MutexGuard
aGuard( GetMutex() );
2098 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2099 return rItem
.ItemImageURL
;
2102 // ---------------------------------------------------------------------------------------------------------------------
2103 beans::Pair
< ::rtl::OUString
, ::rtl::OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2105 ::osl::MutexGuard
aGuard( GetMutex() );
2106 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2107 return beans::Pair
< ::rtl::OUString
, ::rtl::OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2110 // ---------------------------------------------------------------------------------------------------------------------
2111 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2113 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2114 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2115 return rItem
.ItemData
;
2118 // ---------------------------------------------------------------------------------------------------------------------
2119 Sequence
< beans::Pair
< ::rtl::OUString
, ::rtl::OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( ) throw (RuntimeException
)
2121 ::osl::MutexGuard
aGuard( GetMutex() );
2122 return m_pData
->getAllItems();
2125 // ---------------------------------------------------------------------------------------------------------------------
2126 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
)
2128 if ( i_Listener
.is() )
2129 m_aItemListListeners
.addInterface( i_Listener
);
2132 // ---------------------------------------------------------------------------------------------------------------------
2133 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
)
2135 if ( i_Listener
.is() )
2136 m_aItemListListeners
.removeInterface( i_Listener
);
2139 // ---------------------------------------------------------------------------------------------------------------------
2140 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector
< ::rtl::OUString
>& o_rStringItems
) const
2142 Sequence
< ::rtl::OUString
> aStringItemList
;
2144 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2145 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2147 o_rStringItems
.resize( size_t( aStringItemList
.getLength() ) );
2149 aStringItemList
.getConstArray(),
2150 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2151 o_rStringItems
.begin()
2155 // ---------------------------------------------------------------------------------------------------------------------
2156 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector
< ::rtl::OUString
>& i_rStringItems
)
2158 Sequence
< ::rtl::OUString
> aStringItems( i_rStringItems
.size() );
2160 i_rStringItems
.begin(),
2161 i_rStringItems
.end(),
2162 aStringItems
.getArray()
2164 m_pData
->m_bSettingLegacyProperty
= true;
2167 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST
, uno::makeAny( aStringItems
) );
2169 catch( const Exception
& )
2171 m_pData
->m_bSettingLegacyProperty
= false;
2174 m_pData
->m_bSettingLegacyProperty
= false;
2177 // ---------------------------------------------------------------------------------------------------------------------
2178 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition
, const ::boost::optional
< ::rtl::OUString
>& i_rItemText
,
2179 const ::boost::optional
< ::rtl::OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2181 // SYNCHRONIZED ----->
2182 // sync with legacy StringItemList property
2183 ::std::vector
< ::rtl::OUString
> aStringItems
;
2184 impl_getStringItemList( aStringItems
);
2185 OSL_ENSURE( size_t( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2186 if ( size_t( i_nItemPosition
) <= aStringItems
.size() )
2188 const ::rtl::OUString
sItemText( !!i_rItemText
? *i_rItemText
: ::rtl::OUString() );
2189 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2192 i_rClearBeforeNotify
.clear();
2193 // <----- SYNCHRONIZED
2194 impl_setStringItemList_nolck( aStringItems
);
2196 // notify ItemListListeners
2197 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2200 // ---------------------------------------------------------------------------------------------------------------------
2201 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2203 // SYNCHRONIZED ----->
2204 const bool bAllItems
= ( i_nItemPosition
< 0 );
2205 // sync with legacy StringItemList property
2206 ::std::vector
< ::rtl::OUString
> aStringItems
;
2207 impl_getStringItemList( aStringItems
);
2210 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2211 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2213 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2218 aStringItems
.resize(0);
2221 i_rClearBeforeNotify
.clear();
2222 // <----- SYNCHRONIZED
2223 impl_setStringItemList_nolck( aStringItems
);
2225 // notify ItemListListeners
2228 EventObject
aEvent( *this );
2229 m_aItemListListeners
.notifyEach( &XItemListListener::allItemsRemoved
, aEvent
);
2233 impl_notifyItemListEvent_nolck( i_nItemPosition
, ::boost::optional
< ::rtl::OUString
>(), ::boost::optional
< ::rtl::OUString
>(),
2234 &XItemListListener::listItemRemoved
);
2238 // ---------------------------------------------------------------------------------------------------------------------
2239 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition
, const ::boost::optional
< ::rtl::OUString
>& i_rItemText
,
2240 const ::boost::optional
< ::rtl::OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2242 // SYNCHRONIZED ----->
2243 if ( !!i_rItemText
)
2245 // sync with legacy StringItemList property
2246 ::std::vector
< ::rtl::OUString
> aStringItems
;
2247 impl_getStringItemList( aStringItems
);
2248 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2249 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2251 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2254 i_rClearBeforeNotify
.clear();
2255 // <----- SYNCHRONIZED
2256 impl_setStringItemList_nolck( aStringItems
);
2260 i_rClearBeforeNotify
.clear();
2261 // <----- SYNCHRONIZED
2264 // notify ItemListListeners
2265 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2268 // ---------------------------------------------------------------------------------------------------------------------
2269 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition
, const ::boost::optional
< ::rtl::OUString
>& i_rItemText
,
2270 const ::boost::optional
< ::rtl::OUString
>& i_rItemImageURL
,
2271 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2273 ItemListEvent aEvent
;
2274 aEvent
.Source
= *this;
2275 aEvent
.ItemPosition
= i_nItemPosition
;
2276 if ( !!i_rItemText
)
2278 aEvent
.ItemText
.IsPresent
= sal_True
;
2279 aEvent
.ItemText
.Value
= *i_rItemText
;
2281 if ( !!i_rItemImageURL
)
2283 aEvent
.ItemImageURL
.IsPresent
= sal_True
;
2284 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2287 m_aItemListListeners
.notifyEach( NotificationMethod
, aEvent
);
2290 // ----------------------------------------------------
2291 // class UnoListBoxControl
2292 // ----------------------------------------------------
2293 UnoListBoxControl::UnoListBoxControl( const Reference
< XMultiServiceFactory
>& i_factory
)
2294 :UnoListBoxControl_Base( i_factory
)
2295 ,maActionListeners( *this )
2296 ,maItemListeners( *this )
2298 maComponentInfos
.nWidth
= 100;
2299 maComponentInfos
.nHeight
= 12;
2302 ::rtl::OUString
UnoListBoxControl::GetComponentServiceName()
2304 return ::rtl::OUString("listbox");
2306 IMPL_SERVICEINFO_DERIVED( UnoListBoxControl
, UnoControlBase
, szServiceName2_UnoControlListBox
)
2308 void UnoListBoxControl::dispose() throw(uno::RuntimeException
)
2310 lang::EventObject aEvt
;
2311 aEvt
.Source
= (::cppu::OWeakObject
*)this;
2312 maActionListeners
.disposeAndClear( aEvt
);
2313 maItemListeners
.disposeAndClear( aEvt
);
2314 UnoControl::dispose();
2317 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2319 if ( getPeer().is() )
2321 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2322 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2324 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2327 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), aAny
, sal_False
);
2331 void UnoListBoxControl::updateFromModel()
2333 UnoControlBase::updateFromModel();
2335 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2336 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2338 EventObject
aEvent( getModel() );
2339 xItemListListener
->itemListChanged( aEvent
);
2341 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2342 // already did this, our peer(s) can only legitimately set the selection after they have the string
2343 // item list, which we just notified with the itemListChanged call.
2344 const ::rtl::OUString
sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2345 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2348 void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString
& rPropName
, const uno::Any
& rVal
)
2350 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2351 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2352 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2353 // will be forwarded to the peer, which will update itself accordingly.
2356 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2359 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
2361 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2363 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2364 xListBox
->addItemListener( this );
2366 if ( maActionListeners
.getLength() )
2367 xListBox
->addActionListener( &maActionListeners
);
2370 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2372 maActionListeners
.addInterface( l
);
2373 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2375 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2376 xListBox
->addActionListener( &maActionListeners
);
2380 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2382 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2384 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2385 xListBox
->removeActionListener( &maActionListeners
);
2387 maActionListeners
.removeInterface( l
);
2390 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2392 maItemListeners
.addInterface( l
);
2395 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2397 maItemListeners
.removeInterface( l
);
2400 void UnoListBoxControl::addItem( const ::rtl::OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2402 uno::Sequence
< ::rtl::OUString
> aSeq( 1 );
2403 aSeq
.getArray()[0] = aItem
;
2404 addItems( aSeq
, nPos
);
2407 void UnoListBoxControl::addItems( const uno::Sequence
< ::rtl::OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2409 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2410 uno::Sequence
< ::rtl::OUString
> aSeq
;
2412 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
2413 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2414 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2416 uno::Sequence
< ::rtl::OUString
> aNewSeq( nNewLen
);
2417 ::rtl::OUString
* pNewData
= aNewSeq
.getArray();
2418 ::rtl::OUString
* pOldData
= aSeq
.getArray();
2420 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2421 nPos
= (sal_uInt16
) nOldLen
;
2424 // Items vor der Einfuege-Position
2425 for ( n
= 0; n
< nPos
; n
++ )
2426 pNewData
[n
] = pOldData
[n
];
2429 for ( n
= 0; n
< nNewItems
; n
++ )
2430 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
2432 // Rest der alten Items
2433 for ( n
= nPos
; n
< nOldLen
; n
++ )
2434 pNewData
[nNewItems
+n
] = pOldData
[n
];
2438 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
2441 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
)
2443 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2444 uno::Sequence
< ::rtl::OUString
> aSeq
;
2446 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2447 if ( nOldLen
&& ( nPos
< nOldLen
) )
2449 if ( nCount
> ( nOldLen
-nPos
) )
2450 nCount
= nOldLen
-nPos
;
2452 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2454 uno::Sequence
< ::rtl::OUString
> aNewSeq( nNewLen
);
2455 ::rtl::OUString
* pNewData
= aNewSeq
.getArray();
2456 ::rtl::OUString
* pOldData
= aSeq
.getArray();
2459 // Items vor der Entfern-Position
2460 for ( n
= 0; n
< nPos
; n
++ )
2461 pNewData
[n
] = pOldData
[n
];
2464 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
2465 pNewData
[n
] = pOldData
[n
+nCount
];
2469 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
2473 sal_Int16
UnoListBoxControl::getItemCount() throw(uno::RuntimeException
)
2475 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2476 uno::Sequence
< ::rtl::OUString
> aSeq
;
2478 return (sal_Int16
)aSeq
.getLength();
2481 ::rtl::OUString
UnoListBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
)
2483 ::rtl::OUString aItem
;
2484 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2485 uno::Sequence
< ::rtl::OUString
> aSeq
;
2487 if ( nPos
< aSeq
.getLength() )
2488 aItem
= aSeq
.getConstArray()[nPos
];
2492 uno::Sequence
< ::rtl::OUString
> UnoListBoxControl::getItems() throw(uno::RuntimeException
)
2494 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2495 uno::Sequence
< ::rtl::OUString
> aSeq
;
2500 sal_Int16
UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException
)
2503 if ( getPeer().is() )
2505 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2506 n
= xListBox
->getSelectedItemPos();
2511 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException
)
2513 uno::Sequence
<sal_Int16
> aSeq
;
2514 if ( getPeer().is() )
2516 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2517 aSeq
= xListBox
->getSelectedItemsPos();
2522 ::rtl::OUString
UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException
)
2524 ::rtl::OUString aItem
;
2525 if ( getPeer().is() )
2527 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2528 aItem
= xListBox
->getSelectedItem();
2533 uno::Sequence
< ::rtl::OUString
> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException
)
2535 uno::Sequence
< ::rtl::OUString
> aSeq
;
2536 if ( getPeer().is() )
2538 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2539 aSeq
= xListBox
->getSelectedItems();
2544 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2546 if ( getPeer().is() )
2548 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2549 xListBox
->selectItemPos( nPos
, bSelect
);
2551 ImplUpdateSelectedItemsProperty();
2554 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2556 if ( getPeer().is() )
2558 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2559 xListBox
->selectItemsPos( aPositions
, bSelect
);
2561 ImplUpdateSelectedItemsProperty();
2564 void UnoListBoxControl::selectItem( const ::rtl::OUString
& aItem
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2566 if ( getPeer().is() )
2568 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2569 xListBox
->selectItem( aItem
, bSelect
);
2571 ImplUpdateSelectedItemsProperty();
2574 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
) throw(uno::RuntimeException
)
2576 if ( getPeer().is() )
2578 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2579 xListBox
->makeVisible( nEntry
);
2583 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
)
2586 aAny
<<= (sal_Int16
)nLines
;
2587 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), aAny
, sal_True
);
2590 sal_Int16
UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException
)
2592 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2595 sal_Bool
UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException
)
2597 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2600 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
) throw(uno::RuntimeException
)
2604 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), aAny
, sal_True
);
2607 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
2609 ImplUpdateSelectedItemsProperty();
2610 if ( maItemListeners
.getLength() )
2614 maItemListeners
.itemStateChanged( rEvent
);
2616 catch( const Exception
& e
)
2618 #if OSL_DEBUG_LEVEL == 0
2619 (void) e
; // suppress warning
2621 ::rtl::OString
sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2622 sMessage
+= ::rtl::OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2623 OSL_FAIL( sMessage
.getStr() );
2629 awt::Size
UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException
)
2631 return Impl_getMinimumSize();
2634 awt::Size
UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException
)
2636 return Impl_getPreferredSize();
2639 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
2641 return Impl_calcAdjustedSize( rNewSize
);
2644 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
)
2646 return Impl_getMinimumSize( nCols
, nLines
);
2649 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
)
2651 Impl_getColumnsAndLines( nCols
, nLines
);
2654 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
)
2656 ::osl::MutexGuard
aGuard( GetMutex() );
2658 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2659 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2660 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2661 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2663 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2666 if ( xOldItems
.is() )
2667 xOldItems
->removeItemListListener( this );
2668 if ( xNewItems
.is() )
2669 xNewItems
->addItemListListener( this );
2674 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2676 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2677 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2678 if ( xPeerListener
.is() )
2679 xPeerListener
->listItemInserted( i_rEvent
);
2682 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2684 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2685 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
2686 if ( xPeerListener
.is() )
2687 xPeerListener
->listItemRemoved( i_rEvent
);
2690 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2692 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2693 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
2694 if ( xPeerListener
.is() )
2695 xPeerListener
->listItemModified( i_rEvent
);
2698 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2700 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2701 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
2702 if ( xPeerListener
.is() )
2703 xPeerListener
->allItemsRemoved( i_rEvent
);
2706 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2708 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2709 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
2710 if ( xPeerListener
.is() )
2711 xPeerListener
->itemListChanged( i_rEvent
);
2714 // ----------------------------------------------------
2715 // class UnoControlComboBoxModel
2716 // ----------------------------------------------------
2717 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XMultiServiceFactory
>& i_factory
)
2718 :UnoControlListBoxModel( i_factory
, ConstructWithoutProperties
)
2720 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox
);
2723 IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel
, UnoControlModel
, szServiceName2_UnoControlComboBoxModel
)
2725 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
2727 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2730 // ---------------------------------------------------------------------------------------------------------------------
2731 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
2733 static UnoPropertyArrayHelper
* pHelper
= NULL
;
2736 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
2737 pHelper
= new UnoPropertyArrayHelper( aIDs
);
2743 ::rtl::OUString
UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
2745 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel
);
2747 void SAL_CALL
UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
)
2749 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
2751 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
&& !m_pData
->m_bSettingLegacyProperty
)
2753 // synchronize the legacy StringItemList property with our list items
2754 Sequence
< ::rtl::OUString
> aStringItemList
;
2756 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2757 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2759 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2761 aStringItemList
.getConstArray(),
2762 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2766 m_pData
->setAllItems( aItems
);
2768 // since an XItemListListener does not have a "all items modified" or some such method,
2769 // we simulate this by notifying removal of all items, followed by insertion of all new
2771 lang::EventObject aEvent
;
2772 aEvent
.Source
= *this;
2773 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
2774 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2775 // which is wrong for the above notifications ...
2779 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2781 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2784 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox
);
2787 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2790 // ----------------------------------------------------
2791 // class UnoComboBoxControl
2792 // ----------------------------------------------------
2793 UnoComboBoxControl::UnoComboBoxControl( const Reference
< XMultiServiceFactory
>& i_factory
)
2794 :UnoEditControl( i_factory
)
2795 ,maActionListeners( *this )
2796 ,maItemListeners( *this )
2798 maComponentInfos
.nWidth
= 100;
2799 maComponentInfos
.nHeight
= 12;
2801 IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl
, UnoEditControl
, szServiceName2_UnoControlComboBox
)
2803 ::rtl::OUString
UnoComboBoxControl::GetComponentServiceName()
2805 return ::rtl::OUString("combobox");
2808 void UnoComboBoxControl::dispose() throw(uno::RuntimeException
)
2810 lang::EventObject aEvt
;
2811 aEvt
.Source
= (::cppu::OWeakObject
*)this;
2812 maActionListeners
.disposeAndClear( aEvt
);
2813 maItemListeners
.disposeAndClear( aEvt
);
2814 UnoControl::dispose();
2816 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
2818 uno::Any aRet
= ::cppu::queryInterface( rType
,
2819 (static_cast< awt::XComboBox
* >(this)) );
2820 if ( !aRet
.hasValue() )
2822 aRet
= ::cppu::queryInterface( rType
,
2823 (static_cast< awt::XItemListener
* >(this)) );
2824 if ( !aRet
.hasValue() )
2826 aRet
= ::cppu::queryInterface( rType
,
2827 (static_cast< awt::XItemListListener
* >(this)) );
2830 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
2832 // lang::XTypeProvider
2833 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl
)
2834 getCppuType( ( uno::Reference
< awt::XComboBox
>* ) NULL
),
2835 getCppuType( ( uno::Reference
< awt::XItemListener
>* ) NULL
),
2836 getCppuType( ( uno::Reference
< awt::XItemListListener
>* ) NULL
),
2837 UnoEditControl::getTypes()
2838 IMPL_XTYPEPROVIDER_END
2840 void UnoComboBoxControl::updateFromModel()
2842 UnoEditControl::updateFromModel();
2844 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2845 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2847 EventObject
aEvent( getModel() );
2848 xItemListListener
->itemListChanged( aEvent
);
2850 void UnoComboBoxControl::ImplSetPeerProperty( const ::rtl::OUString
& rPropName
, const uno::Any
& rVal
)
2852 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2853 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2854 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2855 // will be forwarded to the peer, which will update itself accordingly.
2858 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
2860 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
2862 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
2864 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2865 if ( maActionListeners
.getLength() )
2866 xComboBox
->addActionListener( &maActionListeners
);
2867 if ( maItemListeners
.getLength() )
2868 xComboBox
->addItemListener( &maItemListeners
);
2871 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2873 maActionListeners
.addInterface( l
);
2874 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2876 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2877 xComboBox
->addActionListener( &maActionListeners
);
2881 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2883 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2885 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2886 xComboBox
->removeActionListener( &maActionListeners
);
2888 maActionListeners
.removeInterface( l
);
2891 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2893 maItemListeners
.addInterface( l
);
2894 if( getPeer().is() && maItemListeners
.getLength() == 1 )
2896 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2897 xComboBox
->addItemListener( &maItemListeners
);
2901 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2903 if( getPeer().is() && maItemListeners
.getLength() == 1 )
2905 // This call is prettier than creating a Ref and calling query
2906 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2907 xComboBox
->removeItemListener( &maItemListeners
);
2909 maItemListeners
.removeInterface( l
);
2911 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
2913 if ( maItemListeners
.getLength() )
2917 maItemListeners
.itemStateChanged( rEvent
);
2919 catch( const Exception
& e
)
2921 #if OSL_DEBUG_LEVEL == 0
2922 (void) e
; // suppress warning
2924 ::rtl::OString
sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
2925 sMessage
+= ::rtl::OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2926 OSL_FAIL( sMessage
.getStr() );
2931 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
)
2933 ::osl::MutexGuard
aGuard( GetMutex() );
2935 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2936 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
2937 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2938 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
2940 if ( !UnoEditControl::setModel( i_rModel
) )
2943 if ( xOldItems
.is() )
2944 xOldItems
->removeItemListListener( this );
2945 if ( xNewItems
.is() )
2946 xNewItems
->addItemListListener( this );
2951 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2953 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2954 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
2955 if ( xPeerListener
.is() )
2956 xPeerListener
->listItemInserted( i_rEvent
);
2959 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2961 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2962 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
2963 if ( xPeerListener
.is() )
2964 xPeerListener
->listItemRemoved( i_rEvent
);
2967 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2969 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2970 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
2971 if ( xPeerListener
.is() )
2972 xPeerListener
->listItemModified( i_rEvent
);
2975 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2977 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2978 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
2979 if ( xPeerListener
.is() )
2980 xPeerListener
->allItemsRemoved( i_rEvent
);
2983 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2985 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2986 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
2987 if ( xPeerListener
.is() )
2988 xPeerListener
->itemListChanged( i_rEvent
);
2991 void UnoComboBoxControl::addItem( const ::rtl::OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2993 uno::Sequence
< ::rtl::OUString
> aSeq( 1 );
2994 aSeq
.getArray()[0] = aItem
;
2995 addItems( aSeq
, nPos
);
2998 void UnoComboBoxControl::addItems( const uno::Sequence
< ::rtl::OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
)
3000 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3001 uno::Sequence
< ::rtl::OUString
> aSeq
;
3003 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
3004 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3005 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3007 uno::Sequence
< ::rtl::OUString
> aNewSeq( nNewLen
);
3008 ::rtl::OUString
* pNewData
= aNewSeq
.getArray();
3009 const ::rtl::OUString
* pOldData
= aSeq
.getConstArray();
3011 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3012 nPos
= (sal_uInt16
) nOldLen
;
3015 // items before the insert position
3016 for ( n
= 0; n
< nPos
; n
++ )
3017 pNewData
[n
] = pOldData
[n
];
3020 for ( n
= 0; n
< nNewItems
; n
++ )
3021 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
3023 // remainder of old items
3024 for ( n
= nPos
; n
< nOldLen
; n
++ )
3025 pNewData
[nNewItems
+n
] = pOldData
[n
];
3029 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
3032 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
)
3034 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3035 uno::Sequence
< ::rtl::OUString
> aSeq
;
3037 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3038 if ( nOldLen
&& ( nPos
< nOldLen
) )
3040 if ( nCount
> ( nOldLen
-nPos
) )
3041 nCount
= nOldLen
-nPos
;
3043 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3045 uno::Sequence
< ::rtl::OUString
> aNewSeq( nNewLen
);
3046 ::rtl::OUString
* pNewData
= aNewSeq
.getArray();
3047 ::rtl::OUString
* pOldData
= aSeq
.getArray();
3050 // items before the deletion position
3051 for ( n
= 0; n
< nPos
; n
++ )
3052 pNewData
[n
] = pOldData
[n
];
3054 // remainder of old items
3055 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
3056 pNewData
[n
] = pOldData
[n
+nCount
];
3060 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
3064 sal_Int16
UnoComboBoxControl::getItemCount() throw(uno::RuntimeException
)
3066 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3067 uno::Sequence
< ::rtl::OUString
> aSeq
;
3069 return (sal_Int16
)aSeq
.getLength();
3072 ::rtl::OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
)
3074 ::rtl::OUString aItem
;
3075 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3076 uno::Sequence
< ::rtl::OUString
> aSeq
;
3078 if ( nPos
< aSeq
.getLength() )
3079 aItem
= aSeq
.getConstArray()[nPos
];
3083 uno::Sequence
< ::rtl::OUString
> UnoComboBoxControl::getItems() throw(uno::RuntimeException
)
3085 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3086 uno::Sequence
< ::rtl::OUString
> aSeq
;
3091 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
)
3095 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), aAny
, sal_True
);
3098 sal_Int16
UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException
)
3100 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3104 // ----------------------------------------------------
3105 // UnoSpinFieldControl
3106 // ----------------------------------------------------
3107 UnoSpinFieldControl::UnoSpinFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
3108 :UnoEditControl( i_factory
)
3109 ,maSpinListeners( *this )
3111 mbRepeat
= sal_False
;
3115 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3117 uno::Any aRet
= ::cppu::queryInterface( rType
,
3118 (static_cast< awt::XSpinField
* >(this)) );
3119 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3122 // lang::XTypeProvider
3123 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl
)
3124 getCppuType( ( uno::Reference
< awt::XSpinField
>* ) NULL
),
3125 UnoEditControl::getTypes()
3126 IMPL_XTYPEPROVIDER_END
3128 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3130 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3132 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3133 xField
->enableRepeat( mbRepeat
);
3134 if ( maSpinListeners
.getLength() )
3135 xField
->addSpinListener( &maSpinListeners
);
3138 // ::com::sun::star::awt::XSpinField
3139 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
>& l
) throw(::com::sun::star::uno::RuntimeException
)
3141 maSpinListeners
.addInterface( l
);
3142 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3144 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3145 xField
->addSpinListener( &maSpinListeners
);
3149 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
>& l
) throw(::com::sun::star::uno::RuntimeException
)
3151 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3153 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3154 xField
->removeSpinListener( &maSpinListeners
);
3156 maSpinListeners
.removeInterface( l
);
3159 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException
)
3161 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3166 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException
)
3168 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3173 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException
)
3175 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3180 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException
)
3182 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3187 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
) throw(::com::sun::star::uno::RuntimeException
)
3191 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3193 xField
->enableRepeat( bRepeat
);
3196 // ----------------------------------------------------
3197 // class UnoControlDateFieldModel
3198 // ----------------------------------------------------
3199 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XMultiServiceFactory
>& i_factory
)
3200 :UnoControlModel( i_factory
)
3202 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField
);
3205 ::rtl::OUString
UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3207 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateFieldModel
);
3210 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3212 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3215 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateField
);
3218 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3222 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3224 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3227 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3228 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3233 // beans::XMultiPropertySet
3234 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3236 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3242 // ----------------------------------------------------
3243 // class UnoDateFieldControl
3244 // ----------------------------------------------------
3245 UnoDateFieldControl::UnoDateFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
3246 :UnoSpinFieldControl( i_factory
)
3248 mnFirst
= Date( 1, 1, 1900 ).GetDate();
3249 mnLast
= Date( 31, 12, 2200 ).GetDate();
3253 ::rtl::OUString
UnoDateFieldControl::GetComponentServiceName()
3255 return ::rtl::OUString("datefield");
3259 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3261 uno::Any aRet
= ::cppu::queryInterface( rType
,
3262 (static_cast< awt::XDateField
* >(this)) );
3263 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3266 // lang::XTypeProvider
3267 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl
)
3268 getCppuType( ( uno::Reference
< awt::XDateField
>* ) NULL
),
3269 UnoSpinFieldControl::getTypes()
3270 IMPL_XTYPEPROVIDER_END
3272 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3274 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3276 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3277 xField
->setFirst( mnFirst
);
3278 xField
->setLast( mnLast
);
3279 if ( mbLongFormat
!= 2 ) // not set
3280 xField
->setLongFormat( mbLongFormat
);
3284 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3286 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3288 // also change the text property (#i25106#)
3291 ::rtl::OUString sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3292 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), sal_False
);
3295 // re-calc the Date property
3296 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3298 if ( xField
->isEmpty() )
3300 // the field says it's empty
3301 sal_Bool bEnforceFormat
= sal_True
;
3303 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3304 if ( !bEnforceFormat
)
3306 // and it also says that it is currently accepting invalid inputs, without
3307 // forcing it to a valid date
3308 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3309 if ( xText
.is() && xText
->getText().getLength() )
3310 // and in real, the text of the peer is *not* empty
3311 // -> simulate an invalid date, which is different from "no date"
3312 aValue
<<= util::Date( 0, 0, 0 );
3316 aValue
<<= xField
->getDate();
3318 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, sal_False
);
3320 // multiplex the event
3321 if ( GetTextListeners().getLength() )
3322 GetTextListeners().textChanged( e
);
3325 void UnoDateFieldControl::setDate( sal_Int32 Date
) throw(uno::RuntimeException
)
3329 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aAny
, sal_True
);
3332 sal_Int32
UnoDateFieldControl::getDate() throw(uno::RuntimeException
)
3334 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE
);
3337 void UnoDateFieldControl::setMin( sal_Int32 Date
) throw(uno::RuntimeException
)
3341 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), aAny
, sal_True
);
3344 sal_Int32
UnoDateFieldControl::getMin() throw(uno::RuntimeException
)
3346 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN
);
3349 void UnoDateFieldControl::setMax( sal_Int32 Date
) throw(uno::RuntimeException
)
3353 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), aAny
, sal_True
);
3356 sal_Int32
UnoDateFieldControl::getMax() throw(uno::RuntimeException
)
3358 return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX
);
3361 void UnoDateFieldControl::setFirst( sal_Int32 Date
) throw(uno::RuntimeException
)
3364 if ( getPeer().is() )
3366 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3367 xField
->setFirst( Date
);
3371 sal_Int32
UnoDateFieldControl::getFirst() throw(uno::RuntimeException
)
3376 void UnoDateFieldControl::setLast( sal_Int32 Date
) throw(uno::RuntimeException
)
3379 if ( getPeer().is() )
3381 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3382 xField
->setLast( Date
);
3386 sal_Int32
UnoDateFieldControl::getLast() throw(uno::RuntimeException
)
3391 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
) throw(uno::RuntimeException
)
3393 mbLongFormat
= bLong
;
3394 if ( getPeer().is() )
3396 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3397 xField
->setLongFormat( bLong
);
3401 sal_Bool
UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException
)
3403 return ( mbLongFormat
!= 2 ) ? mbLongFormat
: sal_False
;
3406 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException
)
3408 if ( getPeer().is() )
3410 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3415 sal_Bool
UnoDateFieldControl::isEmpty() throw(uno::RuntimeException
)
3417 sal_Bool bEmpty
= sal_False
;
3418 if ( getPeer().is() )
3420 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3421 bEmpty
= xField
->isEmpty();
3426 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3430 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3433 sal_Bool
UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3435 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3438 // ----------------------------------------------------
3439 // class UnoControlTimeFieldModel
3440 // ----------------------------------------------------
3441 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XMultiServiceFactory
>& i_factory
)
3442 :UnoControlModel( i_factory
)
3444 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField
);
3447 ::rtl::OUString
UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3449 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel
);
3452 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3454 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3457 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeField
);
3460 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3464 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3466 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3469 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3470 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3475 // beans::XMultiPropertySet
3476 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3478 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3484 // ----------------------------------------------------
3485 // class UnoTimeFieldControl
3486 // ----------------------------------------------------
3487 UnoTimeFieldControl::UnoTimeFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
3488 :UnoSpinFieldControl( i_factory
)
3490 mnFirst
= Time( 0, 0 ).GetTime();
3491 mnLast
= Time( 23, 59, 59, 99 ).GetTime();
3494 ::rtl::OUString
UnoTimeFieldControl::GetComponentServiceName()
3496 return ::rtl::OUString("timefield");
3500 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3502 uno::Any aRet
= ::cppu::queryInterface( rType
,
3503 (static_cast< awt::XTimeField
* >(this)) );
3504 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3507 // lang::XTypeProvider
3508 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl
)
3509 getCppuType( ( uno::Reference
< awt::XTimeField
>* ) NULL
),
3510 UnoSpinFieldControl::getTypes()
3511 IMPL_XTYPEPROVIDER_END
3513 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3515 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3517 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3518 xField
->setFirst( mnFirst
);
3519 xField
->setLast( mnLast
);
3522 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3524 // also change the text property (#i25106#)
3525 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3526 ::rtl::OUString sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3527 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), sal_False
);
3529 // re-calc the Time property
3530 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3532 if ( !xField
->isEmpty() )
3533 aValue
<<= xField
->getTime();
3534 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, sal_False
);
3536 // multiplex the event
3537 if ( GetTextListeners().getLength() )
3538 GetTextListeners().textChanged( e
);
3541 void UnoTimeFieldControl::setTime( sal_Int32 Time
) throw(uno::RuntimeException
)
3545 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aAny
, sal_True
);
3548 sal_Int32
UnoTimeFieldControl::getTime() throw(uno::RuntimeException
)
3550 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME
);
3553 void UnoTimeFieldControl::setMin( sal_Int32 Time
) throw(uno::RuntimeException
)
3557 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), aAny
, sal_True
);
3560 sal_Int32
UnoTimeFieldControl::getMin() throw(uno::RuntimeException
)
3562 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN
);
3565 void UnoTimeFieldControl::setMax( sal_Int32 Time
) throw(uno::RuntimeException
)
3569 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), aAny
, sal_True
);
3572 sal_Int32
UnoTimeFieldControl::getMax() throw(uno::RuntimeException
)
3574 return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX
);
3577 void UnoTimeFieldControl::setFirst( sal_Int32 Time
) throw(uno::RuntimeException
)
3580 if ( getPeer().is() )
3582 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3583 xField
->setFirst( mnFirst
);
3587 sal_Int32
UnoTimeFieldControl::getFirst() throw(uno::RuntimeException
)
3592 void UnoTimeFieldControl::setLast( sal_Int32 Time
) throw(uno::RuntimeException
)
3595 if ( getPeer().is() )
3597 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3598 xField
->setFirst( mnLast
);
3602 sal_Int32
UnoTimeFieldControl::getLast() throw(uno::RuntimeException
)
3607 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException
)
3609 if ( getPeer().is() )
3611 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3616 sal_Bool
UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException
)
3618 sal_Bool bEmpty
= sal_False
;
3619 if ( getPeer().is() )
3621 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3622 bEmpty
= xField
->isEmpty();
3627 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3631 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3634 sal_Bool
UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3636 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3639 // ----------------------------------------------------
3640 // class UnoControlNumericFieldModel
3641 // ----------------------------------------------------
3642 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XMultiServiceFactory
>& i_factory
)
3643 :UnoControlModel( i_factory
)
3645 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField
);
3648 ::rtl::OUString
UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3650 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel
);
3653 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3655 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3658 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericField
);
3661 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3665 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
3667 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3670 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3671 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3676 // beans::XMultiPropertySet
3677 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3679 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3685 // ----------------------------------------------------
3686 // class UnoNumericFieldControl
3687 // ----------------------------------------------------
3688 UnoNumericFieldControl::UnoNumericFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
3689 :UnoSpinFieldControl( i_factory
)
3692 mnLast
= 0x7FFFFFFF;
3695 ::rtl::OUString
UnoNumericFieldControl::GetComponentServiceName()
3697 return ::rtl::OUString("numericfield");
3701 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3703 uno::Any aRet
= ::cppu::queryInterface( rType
,
3704 (static_cast< awt::XNumericField
* >(this)) );
3705 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3708 // lang::XTypeProvider
3709 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl
)
3710 getCppuType( ( uno::Reference
< awt::XNumericField
>* ) NULL
),
3711 UnoSpinFieldControl::getTypes()
3712 IMPL_XTYPEPROVIDER_END
3714 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3716 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3718 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3719 xField
->setFirst( mnFirst
);
3720 xField
->setLast( mnLast
);
3724 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3726 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3728 aAny
<<= xField
->getValue();
3729 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_False
);
3731 if ( GetTextListeners().getLength() )
3732 GetTextListeners().textChanged( e
);
3735 void UnoNumericFieldControl::setValue( double Value
) throw(uno::RuntimeException
)
3739 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_True
);
3742 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException
)
3744 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
3747 void UnoNumericFieldControl::setMin( double Value
) throw(uno::RuntimeException
)
3751 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), aAny
, sal_True
);
3754 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException
)
3756 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
3759 void UnoNumericFieldControl::setMax( double Value
) throw(uno::RuntimeException
)
3763 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), aAny
, sal_True
);
3766 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException
)
3768 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
3771 void UnoNumericFieldControl::setFirst( double Value
) throw(uno::RuntimeException
)
3774 if ( getPeer().is() )
3776 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3777 xField
->setFirst( mnFirst
);
3781 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException
)
3786 void UnoNumericFieldControl::setLast( double Value
) throw(uno::RuntimeException
)
3789 if ( getPeer().is() )
3791 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3792 xField
->setLast( mnLast
);
3796 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException
)
3801 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3805 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3808 sal_Bool
UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3810 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3813 void UnoNumericFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
)
3817 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), aAny
, sal_True
);
3820 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException
)
3822 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
3825 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
)
3829 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), aAny
, sal_True
);
3832 sal_Int16
UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException
)
3834 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
3837 // ----------------------------------------------------
3838 // class UnoControlCurrencyFieldModel
3839 // ----------------------------------------------------
3840 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XMultiServiceFactory
>& i_factory
)
3841 :UnoControlModel( i_factory
)
3843 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField
);
3846 ::rtl::OUString
UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3848 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel
);
3851 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3853 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3856 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyField
);
3859 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
3862 aAny
<<= (sal_Bool
)sal_False
;
3866 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3869 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
3871 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3874 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3875 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3880 // beans::XMultiPropertySet
3881 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3883 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3887 // ----------------------------------------------------
3888 // class UnoCurrencyFieldControl
3889 // ----------------------------------------------------
3890 UnoCurrencyFieldControl::UnoCurrencyFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
3891 :UnoSpinFieldControl( i_factory
)
3894 mnLast
= 0x7FFFFFFF;
3897 ::rtl::OUString
UnoCurrencyFieldControl::GetComponentServiceName()
3899 return ::rtl::OUString("longcurrencyfield");
3903 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3905 uno::Any aRet
= ::cppu::queryInterface( rType
,
3906 (static_cast< awt::XCurrencyField
* >(this)) );
3907 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3910 // lang::XTypeProvider
3911 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl
)
3912 getCppuType( ( uno::Reference
< awt::XCurrencyField
>* ) NULL
),
3913 UnoSpinFieldControl::getTypes()
3914 IMPL_XTYPEPROVIDER_END
3916 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3918 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3920 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3921 xField
->setFirst( mnFirst
);
3922 xField
->setLast( mnLast
);
3925 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3927 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3929 aAny
<<= xField
->getValue();
3930 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_False
);
3932 if ( GetTextListeners().getLength() )
3933 GetTextListeners().textChanged( e
);
3936 void UnoCurrencyFieldControl::setValue( double Value
) throw(uno::RuntimeException
)
3940 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_True
);
3943 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException
)
3945 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
3948 void UnoCurrencyFieldControl::setMin( double Value
) throw(uno::RuntimeException
)
3952 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), aAny
, sal_True
);
3955 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException
)
3957 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
3960 void UnoCurrencyFieldControl::setMax( double Value
) throw(uno::RuntimeException
)
3964 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), aAny
, sal_True
);
3967 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException
)
3969 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
3972 void UnoCurrencyFieldControl::setFirst( double Value
) throw(uno::RuntimeException
)
3975 if ( getPeer().is() )
3977 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3978 xField
->setFirst( mnFirst
);
3982 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException
)
3987 void UnoCurrencyFieldControl::setLast( double Value
) throw(uno::RuntimeException
)
3990 if ( getPeer().is() )
3992 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3993 xField
->setLast( mnLast
);
3997 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException
)
4002 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
4006 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
4009 sal_Bool
UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException
)
4011 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4014 void UnoCurrencyFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
)
4018 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), aAny
, sal_True
);
4021 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException
)
4023 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4026 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
)
4030 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), aAny
, sal_True
);
4033 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException
)
4035 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4038 // ----------------------------------------------------
4039 // class UnoControlPatternFieldModel
4040 // ----------------------------------------------------
4041 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XMultiServiceFactory
>& i_factory
)
4042 :UnoControlModel( i_factory
)
4044 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField
);
4047 ::rtl::OUString
UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
4049 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel
);
4052 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4054 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4057 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternField
);
4060 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4063 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4065 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4068 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4069 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4074 // beans::XMultiPropertySet
4075 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4077 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4082 // ----------------------------------------------------
4083 // class UnoPatternFieldControl
4084 // ----------------------------------------------------
4085 UnoPatternFieldControl::UnoPatternFieldControl( const Reference
< XMultiServiceFactory
>& i_factory
)
4086 :UnoSpinFieldControl( i_factory
)
4090 ::rtl::OUString
UnoPatternFieldControl::GetComponentServiceName()
4092 return ::rtl::OUString("patternfield");
4095 void UnoPatternFieldControl::ImplSetPeerProperty( const ::rtl::OUString
& rPropName
, const uno::Any
& rVal
)
4097 sal_uInt16 nType
= GetPropertyId( rPropName
);
4098 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4100 // These masks cannot be set consecutively
4101 ::rtl::OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4102 ::rtl::OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4103 ::rtl::OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4105 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4108 // same comment as in UnoControl::ImplSetPeerProperty - see there
4109 ::rtl::OUString
sText( Text
);
4110 ImplCheckLocalize( sText
);
4111 xPF
->setString( sText
);
4112 xPF
->setMasks( EditMask
, LiteralMask
);
4116 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4121 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
4123 uno::Any aRet
= ::cppu::queryInterface( rType
,
4124 (static_cast< awt::XPatternField
* >(this)) );
4125 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4128 // lang::XTypeProvider
4129 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl
)
4130 getCppuType( ( uno::Reference
< awt::XPatternField
>* ) NULL
),
4131 UnoSpinFieldControl::getTypes()
4132 IMPL_XTYPEPROVIDER_END
4134 void UnoPatternFieldControl::setString( const ::rtl::OUString
& rString
) throw(uno::RuntimeException
)
4139 ::rtl::OUString
UnoPatternFieldControl::getString() throw(uno::RuntimeException
)
4144 void UnoPatternFieldControl::setMasks( const ::rtl::OUString
& EditMask
, const ::rtl::OUString
& LiteralMask
) throw(uno::RuntimeException
)
4148 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), aAny
, sal_True
);
4149 aAny
<<= LiteralMask
;
4150 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), aAny
, sal_True
);
4153 void UnoPatternFieldControl::getMasks( ::rtl::OUString
& EditMask
, ::rtl::OUString
& LiteralMask
) throw(uno::RuntimeException
)
4155 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4156 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4159 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
4163 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
4166 sal_Bool
UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException
)
4168 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4172 // ----------------------------------------------------
4173 // class UnoControlProgressBarModel
4174 // ----------------------------------------------------
4175 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XMultiServiceFactory
>& i_factory
)
4176 :UnoControlModel( i_factory
)
4178 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4179 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4180 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4181 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4182 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4183 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4184 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4185 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4186 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4187 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4188 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4189 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4190 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4193 ::rtl::OUString
UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
4195 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBarModel
);
4198 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4200 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4203 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBar
);
4207 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4210 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4212 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4215 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4216 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4221 // beans::XMultiPropertySet
4222 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4224 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4229 // ----------------------------------------------------
4230 // class UnoProgressBarControl
4231 // ----------------------------------------------------
4232 UnoProgressBarControl::UnoProgressBarControl( const Reference
< XMultiServiceFactory
>& i_factory
)
4233 :UnoControlBase( i_factory
)
4237 ::rtl::OUString
UnoProgressBarControl::GetComponentServiceName()
4239 return ::rtl::OUString("ProgressBar");
4243 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
4245 uno::Any aRet
= ::cppu::queryInterface( rType
,
4246 (static_cast< awt::XProgressBar
* >(this)) );
4247 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4250 // lang::XTypeProvider
4251 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl
)
4252 getCppuType( ( uno::Reference
< awt::XProgressBar
>* ) NULL
),
4253 UnoControlBase::getTypes()
4254 IMPL_XTYPEPROVIDER_END
4256 // ::com::sun::star::awt::XProgressBar
4257 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
)
4261 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), aAny
, sal_True
);
4264 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
)
4268 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), aAny
, sal_True
);
4271 void UnoProgressBarControl::setValue( sal_Int32 nValue
) throw(::com::sun::star::uno::RuntimeException
)
4275 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), aAny
, sal_True
);
4278 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
) throw(::com::sun::star::uno::RuntimeException
)
4285 // take correct min and max
4291 // change min and max
4296 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, sal_True
);
4297 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, sal_True
);
4300 sal_Int32
UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException
)
4302 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4306 // ----------------------------------------------------
4307 // class UnoControlFixedLineModel
4308 // ----------------------------------------------------
4309 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XMultiServiceFactory
>& i_factory
)
4310 :UnoControlModel( i_factory
)
4312 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4313 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4314 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4315 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4316 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4317 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4318 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4319 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4320 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4321 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4324 ::rtl::OUString
UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
4326 return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLineModel
);
4329 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4331 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4334 aAny
<<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLine
);
4337 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4340 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4342 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4345 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4346 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4351 // beans::XMultiPropertySet
4352 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4354 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4358 // ----------------------------------------------------
4359 // class UnoFixedLineControl
4360 // ----------------------------------------------------
4361 UnoFixedLineControl::UnoFixedLineControl( const Reference
< XMultiServiceFactory
>& i_factory
)
4362 :UnoControlBase( i_factory
)
4364 maComponentInfos
.nWidth
= 100; // ??
4365 maComponentInfos
.nHeight
= 100; // ??
4368 ::rtl::OUString
UnoFixedLineControl::GetComponentServiceName()
4370 return ::rtl::OUString("FixedLine");
4373 sal_Bool
UnoFixedLineControl::isTransparent() throw(uno::RuntimeException
)
4378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */