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>
66 using namespace css::awt
;
67 using namespace css::lang
;
68 using namespace css::uno
;
69 using ::com::sun::star::graphic::XGraphic
;
70 using ::com::sun::star::uno::Reference
;
71 using namespace ::toolkit
;
73 #define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \
74 OUString SAL_CALL ImplName::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) { return OUString( "stardiv.Toolkit." #ImplName ); } \
75 ::com::sun::star::uno::Sequence< OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) \
77 ::com::sun::star::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \
78 aNames.realloc( aNames.getLength() + 1 ); \
79 aNames[ aNames.getLength() - 1 ] = OUString::createFromAscii( ServiceName ); \
84 uno::Reference< graphic::XGraphic >
85 ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference
< graphic::XGraphicObject
>& xOutGraphicObj
, const OUString
& _rURL
)
87 if ( _rURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX
) )
89 // graphic manager uniqueid
90 OUString sID
= _rURL
.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX
) - 1 );
91 xOutGraphicObj
= graphic::GraphicObject::createWithId( ::comphelper::getProcessComponentContext(), sID
);
94 xOutGraphicObj
= NULL
; // release the GraphicObject
96 return ImageHelper::getGraphicFromURL_nothrow( _rURL
);
99 ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
>
100 ImageHelper::getGraphicFromURL_nothrow( const OUString
& _rURL
)
102 uno::Reference
< graphic::XGraphic
> xGraphic
;
103 if ( _rURL
.isEmpty() )
108 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
109 uno::Reference
< graphic::XGraphicProvider
> xProvider( graphic::GraphicProvider::create(xContext
) );
110 uno::Sequence
< beans::PropertyValue
> aMediaProperties(1);
111 aMediaProperties
[0].Name
= OUString( "URL" );
112 aMediaProperties
[0].Value
<<= _rURL
;
113 xGraphic
= xProvider
->queryGraphic( aMediaProperties
);
115 catch (const Exception
&)
117 DBG_UNHANDLED_EXCEPTION();
122 // ----------------------------------------------------
123 // class UnoControlEditModel
124 // ----------------------------------------------------
125 UnoControlEditModel::UnoControlEditModel( const Reference
< XComponentContext
>& rxContext
)
126 :UnoControlModel( rxContext
)
128 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit
);
131 OUString
UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
133 return OUString::createFromAscii( szServiceName_UnoControlEditModel
);
136 uno::Any
UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
142 case BASEPROPERTY_LINE_END_FORMAT
:
143 aReturn
<<= (sal_Int16
)awt::LineEndFormat::LINE_FEED
; // LF
145 case BASEPROPERTY_DEFAULTCONTROL
:
146 aReturn
<<= OUString::createFromAscii( szServiceName_UnoControlEdit
);
149 aReturn
= UnoControlModel::ImplGetDefaultValue( nPropId
);
155 ::cppu::IPropertyArrayHelper
& UnoControlEditModel::getInfoHelper()
157 static UnoPropertyArrayHelper
* pHelper
= NULL
;
160 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
161 pHelper
= new UnoPropertyArrayHelper( aIDs
);
166 // beans::XMultiPropertySet
167 uno::Reference
< beans::XPropertySetInfo
> UnoControlEditModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
169 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
174 // ----------------------------------------------------
175 // class UnoEditControl
176 // ----------------------------------------------------
177 UnoEditControl::UnoEditControl()
179 ,maTextListeners( *this )
181 ,mbSetTextInPeer( sal_False
)
182 ,mbSetMaxTextLenInPeer( sal_False
)
183 ,mbHasTextProperty( sal_False
)
185 maComponentInfos
.nWidth
= 100;
186 maComponentInfos
.nHeight
= 12;
188 mbSetMaxTextLenInPeer
= sal_False
;
191 uno::Any SAL_CALL
UnoEditControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
193 uno::Any aReturn
= UnoControlBase::queryAggregation( rType
);
194 if ( !aReturn
.hasValue() )
195 aReturn
= UnoEditControl_Base::queryInterface( rType
);
199 uno::Any SAL_CALL
UnoEditControl::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
201 return UnoControlBase::queryInterface( rType
);
204 void SAL_CALL
UnoEditControl::acquire( ) throw ()
206 UnoControlBase::acquire();
209 void SAL_CALL
UnoEditControl::release( ) throw ()
211 UnoControlBase::release();
214 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl
, UnoControlBase
, UnoEditControl_Base
)
216 OUString
UnoEditControl::GetComponentServiceName()
218 // by default, we want a simple edit field
219 OUString
sName( "Edit" );
221 // but maybe we are to display multi-line text?
222 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE
) );
223 sal_Bool b
= sal_Bool();
224 if ( ( aVal
>>= b
) && b
)
225 sName
= OUString("MultiLineEdit");
230 sal_Bool SAL_CALL
UnoEditControl::setModel(const uno::Reference
< awt::XControlModel
>& _rModel
) throw ( uno::RuntimeException
)
232 sal_Bool bReturn
= UnoControlBase::setModel( _rModel
);
233 mbHasTextProperty
= ImplHasProperty( BASEPROPERTY_TEXT
);
237 void UnoEditControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
239 sal_Bool bDone
= sal_False
;
240 if ( GetPropertyId( rPropName
) == BASEPROPERTY_TEXT
)
242 // #96986# use setText(), or text listener will not be called.
243 uno::Reference
< awt::XTextComponent
> xTextComponent( getPeer(), uno::UNO_QUERY
);
244 if ( xTextComponent
.is() )
248 ImplCheckLocalize( sText
);
249 xTextComponent
->setText( sText
);
255 UnoControlBase::ImplSetPeerProperty( rPropName
, rVal
);
258 void UnoEditControl::dispose() throw(uno::RuntimeException
)
260 lang::EventObject
aEvt( *this );
261 maTextListeners
.disposeAndClear( aEvt
);
262 UnoControl::dispose();
265 void UnoEditControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
267 UnoControl::createPeer( rxToolkit
, rParentPeer
);
269 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
272 xText
->addTextListener( this );
274 if ( mbSetMaxTextLenInPeer
)
275 xText
->setMaxTextLen( mnMaxTextLen
);
276 if ( mbSetTextInPeer
)
277 xText
->setText( maText
);
281 void UnoEditControl::textChanged(const awt::TextEvent
& e
) throw(uno::RuntimeException
)
283 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
285 if ( mbHasTextProperty
)
288 aAny
<<= xText
->getText();
289 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), aAny
, sal_False
);
293 maText
= xText
->getText();
296 if ( maTextListeners
.getLength() )
297 maTextListeners
.textChanged( e
);
300 void UnoEditControl::addTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
)
302 maTextListeners
.addInterface( l
);
305 void UnoEditControl::removeTextListener(const uno::Reference
< awt::XTextListener
> & l
) throw(uno::RuntimeException
)
307 maTextListeners
.removeInterface( l
);
310 void UnoEditControl::setText( const OUString
& aText
) throw(uno::RuntimeException
)
312 if ( mbHasTextProperty
)
316 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT
), aAny
, sal_True
);
321 mbSetTextInPeer
= sal_True
;
322 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
324 xText
->setText( maText
);
327 // Setting the property to the VCLXWindow doesn't call textChanged
328 if ( maTextListeners
.getLength() )
330 awt::TextEvent aEvent
;
331 aEvent
.Source
= *this;
332 maTextListeners
.textChanged( aEvent
);
338 static void lcl_normalize( awt::Selection
& _rSel
)
340 if ( _rSel
.Min
> _rSel
.Max
)
341 ::std::swap( _rSel
.Min
, _rSel
.Max
);
345 void UnoEditControl::insertText( const awt::Selection
& rSel
, const OUString
& rNewText
) throw(uno::RuntimeException
)
347 // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
348 awt::Selection
aSelection( rSel
);
349 lcl_normalize( aSelection
);
351 // preserve the selection resp. cursor position
352 awt::Selection
aNewSelection( getSelection() );
353 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
354 // (not sure - looks uglier ...)
355 sal_Int32 nDeletedCharacters
= ( aSelection
.Max
- aSelection
.Min
) - rNewText
.getLength();
356 if ( aNewSelection
.Min
> aSelection
.Min
)
357 aNewSelection
.Min
-= nDeletedCharacters
;
358 if ( aNewSelection
.Max
> aSelection
.Max
)
359 aNewSelection
.Max
-= nDeletedCharacters
;
361 aNewSelection
.Max
= ::std::min( aNewSelection
.Min
, aNewSelection
.Max
) + rNewText
.getLength();
362 aNewSelection
.Min
= aNewSelection
.Max
;
365 OUString aOldText
= getText();
366 OUString aNewText
= aOldText
.replaceAt( aSelection
.Min
, aSelection
.Max
- aSelection
.Min
, rNewText
);
369 setSelection( aNewSelection
);
372 OUString
UnoEditControl::getText() throw(uno::RuntimeException
)
374 OUString aText
= maText
;
376 if ( mbHasTextProperty
)
377 aText
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
380 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
382 aText
= xText
->getText();
388 OUString
UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException
)
391 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
393 sSelected
= xText
->getSelectedText();
398 void UnoEditControl::setSelection( const awt::Selection
& aSelection
) throw(uno::RuntimeException
)
400 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
402 xText
->setSelection( aSelection
);
405 awt::Selection
UnoEditControl::getSelection( void ) throw(uno::RuntimeException
)
408 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
410 aSel
= xText
->getSelection();
414 sal_Bool
UnoEditControl::isEditable( void ) throw(uno::RuntimeException
)
416 return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY
);
419 void UnoEditControl::setEditable( sal_Bool bEditable
) throw(uno::RuntimeException
)
422 aAny
<<= (sal_Bool
)!bEditable
;
423 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY
), aAny
, sal_True
);
426 sal_Int16
UnoEditControl::getMaxTextLen() throw(uno::RuntimeException
)
428 sal_Int16 nMaxLen
= mnMaxTextLen
;
430 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
431 nMaxLen
= ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN
);
436 void UnoEditControl::setMaxTextLen( sal_Int16 nLen
) throw(uno::RuntimeException
)
438 if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN
) )
441 aAny
<<= (sal_Int16
)nLen
;
442 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN
), aAny
, sal_True
);
447 mbSetMaxTextLenInPeer
= sal_True
;
448 uno::Reference
< awt::XTextComponent
> xText( getPeer(), uno::UNO_QUERY
);
450 xText
->setMaxTextLen( mnMaxTextLen
);
454 awt::Size
UnoEditControl::getMinimumSize( ) throw(uno::RuntimeException
)
456 return Impl_getMinimumSize();
459 awt::Size
UnoEditControl::getPreferredSize( ) throw(uno::RuntimeException
)
461 return Impl_getPreferredSize();
464 awt::Size
UnoEditControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
466 return Impl_calcAdjustedSize( rNewSize
);
469 awt::Size
UnoEditControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
)
471 return Impl_getMinimumSize( nCols
, nLines
);
474 void UnoEditControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
)
476 Impl_getColumnsAndLines( nCols
, nLines
);
479 OUString
UnoEditControl::getImplementationName( ) throw(uno::RuntimeException
)
481 return OUString( "stardiv.Toolkit.UnoEditControl" );
484 uno::Sequence
< OUString
> UnoEditControl::getSupportedServiceNames() throw(uno::RuntimeException
)
486 uno::Sequence
< OUString
> aNames
= UnoControlBase::getSupportedServiceNames( );
487 aNames
.realloc( aNames
.getLength() + 1 );
488 aNames
[ aNames
.getLength() - 1 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit
);
492 // ----------------------------------------------------
493 // class UnoControlFileControlModel
494 // ----------------------------------------------------
495 UnoControlFileControlModel::UnoControlFileControlModel( const Reference
< XComponentContext
>& rxContext
)
496 :UnoControlModel( rxContext
)
498 ImplRegisterProperty( BASEPROPERTY_ALIGN
);
499 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
500 ImplRegisterProperty( BASEPROPERTY_BORDER
);
501 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
502 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
503 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
504 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
505 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
506 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
507 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
508 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
509 ImplRegisterProperty( BASEPROPERTY_READONLY
);
510 ImplRegisterProperty( BASEPROPERTY_TABSTOP
);
511 ImplRegisterProperty( BASEPROPERTY_TEXT
);
512 ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN
);
513 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
514 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
515 ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION
);
518 OUString
UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
520 return OUString::createFromAscii( szServiceName_UnoControlFileControlModel
);
523 uno::Any
UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
525 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
528 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlFileControl
);
531 return UnoControlModel::ImplGetDefaultValue( nPropId
);
534 ::cppu::IPropertyArrayHelper
& UnoControlFileControlModel::getInfoHelper()
536 static UnoPropertyArrayHelper
* pHelper
= NULL
;
539 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
540 pHelper
= new UnoPropertyArrayHelper( aIDs
);
545 // beans::XMultiPropertySet
546 uno::Reference
< beans::XPropertySetInfo
> UnoControlFileControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
548 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
552 // ----------------------------------------------------
553 // class UnoFileControl
554 // ----------------------------------------------------
555 UnoFileControl::UnoFileControl()
560 OUString
UnoFileControl::GetComponentServiceName()
562 return OUString("filecontrol");
565 // ----------------------------------------------------
566 // class GraphicControlModel
567 // ----------------------------------------------------
568 uno::Any
GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
570 if ( nPropId
== BASEPROPERTY_GRAPHIC
)
571 return uno::makeAny( uno::Reference
< graphic::XGraphic
>() );
573 return UnoControlModel::ImplGetDefaultValue( nPropId
);
576 void SAL_CALL
GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
)
578 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
580 // - ImageAlign and ImagePosition need to correspond to each other
581 // - Graphic and ImageURL need to correspond to each other
586 case BASEPROPERTY_IMAGEURL
:
587 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_GRAPHIC
) )
589 mbAdjustingGraphic
= true;
591 OSL_VERIFY( rValue
>>= sImageURL
);
592 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC
, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL
) ) );
593 mbAdjustingGraphic
= false;
597 case BASEPROPERTY_GRAPHIC
:
598 if ( !mbAdjustingGraphic
&& ImplHasProperty( BASEPROPERTY_IMAGEURL
) )
600 mbAdjustingGraphic
= true;
601 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL
, uno::makeAny( OUString() ) );
602 mbAdjustingGraphic
= false;
606 case BASEPROPERTY_IMAGEALIGN
:
607 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEPOSITION
) )
609 mbAdjustingImagePosition
= true;
610 sal_Int16 nUNOValue
= 0;
611 OSL_VERIFY( rValue
>>= nUNOValue
);
612 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION
, uno::makeAny( getExtendedImagePosition( nUNOValue
) ) );
613 mbAdjustingImagePosition
= false;
616 case BASEPROPERTY_IMAGEPOSITION
:
617 if ( !mbAdjustingImagePosition
&& ImplHasProperty( BASEPROPERTY_IMAGEALIGN
) )
619 mbAdjustingImagePosition
= true;
620 sal_Int16 nUNOValue
= 0;
621 OSL_VERIFY( rValue
>>= nUNOValue
);
622 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN
, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue
) ) ) );
623 mbAdjustingImagePosition
= false;
628 catch( const ::com::sun::star::uno::Exception
& )
630 OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
631 mbAdjustingImagePosition
= sal_False
;
635 // ----------------------------------------------------
636 // class UnoControlButtonModel
637 // ----------------------------------------------------
638 UnoControlButtonModel::UnoControlButtonModel( const Reference
< XComponentContext
>& rxContext
)
639 :GraphicControlModel( rxContext
)
641 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton
);
643 osl_atomic_increment( &m_refCount
);
645 setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION
, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION
) );
646 // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
647 // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
649 osl_atomic_decrement( &m_refCount
);
652 OUString
UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
654 return OUString::createFromAscii( szServiceName_UnoControlButtonModel
);
657 uno::Any
UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
661 case BASEPROPERTY_DEFAULTCONTROL
:
662 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton
) );
663 case BASEPROPERTY_TOGGLE
:
664 return uno::makeAny( (sal_Bool
)sal_False
);
665 case BASEPROPERTY_ALIGN
:
666 return uno::makeAny( (sal_Int16
)PROPERTY_ALIGN_CENTER
);
667 case BASEPROPERTY_FOCUSONCLICK
:
668 return uno::makeAny( (sal_Bool
)sal_True
);
671 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
674 ::cppu::IPropertyArrayHelper
& UnoControlButtonModel::getInfoHelper()
676 static UnoPropertyArrayHelper
* pHelper
= NULL
;
679 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
680 pHelper
= new UnoPropertyArrayHelper( aIDs
);
685 // beans::XMultiPropertySet
686 uno::Reference
< beans::XPropertySetInfo
> UnoControlButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
688 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
692 // ----------------------------------------------------
693 // class UnoButtonControl
694 // ----------------------------------------------------
695 UnoButtonControl::UnoButtonControl()
696 :UnoButtonControl_Base()
697 ,maActionListeners( *this )
698 ,maItemListeners( *this )
700 maComponentInfos
.nWidth
= 50;
701 maComponentInfos
.nHeight
= 14;
704 OUString
UnoButtonControl::GetComponentServiceName()
706 OUString
aName( "pushbutton" );
707 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE
) );
708 sal_Int16 n
= sal_Int16();
709 if ( ( aVal
>>= n
) && n
)
711 // Use PushButtonType later when available...
714 case 1 /*PushButtonType::OK*/: aName
= OUString("okbutton");
716 case 2 /*PushButtonType::CANCEL*/: aName
= OUString("cancelbutton");
718 case 3 /*PushButtonType::HELP*/: aName
= OUString("helpbutton");
722 OSL_FAIL( "Unknown Button Type!" );
729 void UnoButtonControl::dispose() throw(uno::RuntimeException
)
731 lang::EventObject aEvt
;
732 aEvt
.Source
= (::cppu::OWeakObject
*)this;
733 maActionListeners
.disposeAndClear( aEvt
);
734 maItemListeners
.disposeAndClear( aEvt
);
735 UnoControlBase::dispose();
738 void UnoButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
740 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
742 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
743 xButton
->setActionCommand( maActionCommand
);
744 if ( maActionListeners
.getLength() )
745 xButton
->addActionListener( &maActionListeners
);
747 uno::Reference
< XToggleButton
> xPushButton( getPeer(), uno::UNO_QUERY
);
748 if ( xPushButton
.is() )
749 xPushButton
->addItemListener( this );
752 void UnoButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
754 maActionListeners
.addInterface( l
);
755 if( getPeer().is() && maActionListeners
.getLength() == 1 )
757 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
758 xButton
->addActionListener( &maActionListeners
);
762 void UnoButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
764 if( getPeer().is() && maActionListeners
.getLength() == 1 )
766 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
767 xButton
->removeActionListener( &maActionListeners
);
769 maActionListeners
.removeInterface( l
);
772 void UnoButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
774 maItemListeners
.addInterface( l
);
777 void UnoButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
779 maItemListeners
.removeInterface( l
);
782 void SAL_CALL
UnoButtonControl::disposing( const lang::EventObject
& Source
) throw (uno::RuntimeException
)
784 UnoControlBase::disposing( Source
);
787 void SAL_CALL
UnoButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw (uno::RuntimeException
)
791 aAny
<<= (sal_Int16
)rEvent
.Selected
;
792 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
795 ItemEvent
aEvent( rEvent
);
796 aEvent
.Source
= *this;
797 maItemListeners
.itemStateChanged( aEvent
);
800 void UnoButtonControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
)
804 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
807 void UnoButtonControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
)
809 maActionCommand
= rCommand
;
810 if ( getPeer().is() )
812 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
813 xButton
->setActionCommand( rCommand
);
817 awt::Size
UnoButtonControl::getMinimumSize( ) throw(uno::RuntimeException
)
819 return Impl_getMinimumSize();
822 awt::Size
UnoButtonControl::getPreferredSize( ) throw(uno::RuntimeException
)
824 return Impl_getPreferredSize();
827 awt::Size
UnoButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
829 return Impl_calcAdjustedSize( rNewSize
);
832 // ----------------------------------------------------
833 // class UnoControlImageControlModel
834 // ----------------------------------------------------
835 UnoControlImageControlModel::UnoControlImageControlModel( const Reference
< XComponentContext
>& rxContext
)
836 :GraphicControlModel( rxContext
)
837 ,mbAdjustingImageScaleMode( false )
839 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl
);
842 OUString
UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
844 return OUString::createFromAscii( szServiceName_UnoControlImageControlModel
);
847 uno::Any
UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
849 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
850 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl
) );
852 if ( nPropId
== BASEPROPERTY_IMAGE_SCALE_MODE
)
853 return makeAny( awt::ImageScaleMode::Anisotropic
);
855 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
858 ::cppu::IPropertyArrayHelper
& UnoControlImageControlModel::getInfoHelper()
860 static UnoPropertyArrayHelper
* pHelper
= NULL
;
863 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
864 pHelper
= new UnoPropertyArrayHelper( aIDs
);
869 // beans::XMultiPropertySet
870 uno::Reference
< beans::XPropertySetInfo
> UnoControlImageControlModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
872 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
876 void SAL_CALL
UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
) throw (::com::sun::star::uno::Exception
)
878 GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
880 // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
885 case BASEPROPERTY_IMAGE_SCALE_MODE
:
886 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_SCALEIMAGE
) )
888 mbAdjustingImageScaleMode
= true;
889 sal_Int16
nScaleMode( awt::ImageScaleMode::Anisotropic
);
890 OSL_VERIFY( _rValue
>>= nScaleMode
);
891 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE
, uno::makeAny( sal_Bool( nScaleMode
!= awt::ImageScaleMode::None
) ) );
892 mbAdjustingImageScaleMode
= false;
895 case BASEPROPERTY_SCALEIMAGE
:
896 if ( !mbAdjustingImageScaleMode
&& ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE
) )
898 mbAdjustingImageScaleMode
= true;
899 sal_Bool bScale
= sal_True
;
900 OSL_VERIFY( _rValue
>>= bScale
);
901 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE
, uno::makeAny( bScale
? awt::ImageScaleMode::Anisotropic
: awt::ImageScaleMode::None
) );
902 mbAdjustingImageScaleMode
= false;
907 catch( const Exception
& )
909 mbAdjustingImageScaleMode
= false;
914 // ----------------------------------------------------
915 // class UnoImageControlControl
916 // ----------------------------------------------------
917 UnoImageControlControl::UnoImageControlControl()
918 :UnoImageControlControl_Base()
919 ,maActionListeners( *this )
921 // TODO: Where should I look for defaults?
922 maComponentInfos
.nWidth
= 100;
923 maComponentInfos
.nHeight
= 100;
926 OUString
UnoImageControlControl::GetComponentServiceName()
928 return OUString("fixedimage");
931 void UnoImageControlControl::dispose() throw(uno::RuntimeException
)
933 lang::EventObject aEvt
;
934 aEvt
.Source
= (::cppu::OWeakObject
*)this;
935 maActionListeners
.disposeAndClear( aEvt
);
936 UnoControl::dispose();
939 sal_Bool
UnoImageControlControl::isTransparent() throw(uno::RuntimeException
)
944 awt::Size
UnoImageControlControl::getMinimumSize( ) throw(uno::RuntimeException
)
946 return Impl_getMinimumSize();
949 awt::Size
UnoImageControlControl::getPreferredSize( ) throw(uno::RuntimeException
)
951 return Impl_getPreferredSize();
954 awt::Size
UnoImageControlControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
956 return Impl_calcAdjustedSize( rNewSize
);
959 // ----------------------------------------------------
960 // class UnoControlRadioButtonModel
961 // ----------------------------------------------------
962 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference
< XComponentContext
>& rxContext
)
963 :GraphicControlModel( rxContext
)
965 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton
);
968 OUString
UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
970 return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel
);
973 uno::Any
UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
977 case BASEPROPERTY_DEFAULTCONTROL
:
978 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton
) );
980 case BASEPROPERTY_VISUALEFFECT
:
981 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
984 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
987 ::cppu::IPropertyArrayHelper
& UnoControlRadioButtonModel::getInfoHelper()
989 static UnoPropertyArrayHelper
* pHelper
= NULL
;
992 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
993 pHelper
= new UnoPropertyArrayHelper( aIDs
);
998 // beans::XMultiPropertySet
999 uno::Reference
< beans::XPropertySetInfo
> UnoControlRadioButtonModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1001 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1007 // ----------------------------------------------------
1008 // class UnoRadioButtonControl
1009 // ----------------------------------------------------
1010 UnoRadioButtonControl::UnoRadioButtonControl()
1011 :UnoRadioButtonControl_Base()
1012 ,maItemListeners( *this )
1013 ,maActionListeners( *this )
1015 maComponentInfos
.nWidth
= 100;
1016 maComponentInfos
.nHeight
= 12;
1019 OUString
UnoRadioButtonControl::GetComponentServiceName()
1021 return OUString("radiobutton");
1024 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException
)
1026 lang::EventObject aEvt
;
1027 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1028 maItemListeners
.disposeAndClear( aEvt
);
1029 UnoControlBase::dispose();
1033 sal_Bool
UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException
)
1038 void UnoRadioButtonControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1040 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1042 uno::Reference
< awt::XRadioButton
> xRadioButton( getPeer(), uno::UNO_QUERY
);
1043 xRadioButton
->addItemListener( this );
1045 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1046 xButton
->setActionCommand( maActionCommand
);
1047 if ( maActionListeners
.getLength() )
1048 xButton
->addActionListener( &maActionListeners
);
1050 // as default, set the "AutoToggle" to true
1051 // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
1052 // have it enabled by default because of 85071)
1053 uno::Reference
< awt::XVclWindowPeer
> xVclWindowPeer( getPeer(), uno::UNO_QUERY
);
1054 if ( xVclWindowPeer
.is() )
1055 xVclWindowPeer
->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE
), ::cppu::bool2any( sal_True
) );
1058 void UnoRadioButtonControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1060 maItemListeners
.addInterface( l
);
1063 void UnoRadioButtonControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1065 maItemListeners
.removeInterface( l
);
1068 void UnoRadioButtonControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1070 maActionListeners
.addInterface( l
);
1071 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1073 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1074 xButton
->addActionListener( &maActionListeners
);
1078 void UnoRadioButtonControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1080 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1082 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1083 xButton
->removeActionListener( &maActionListeners
);
1085 maActionListeners
.removeInterface( l
);
1088 void UnoRadioButtonControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
)
1092 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1095 void UnoRadioButtonControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
)
1097 maActionCommand
= rCommand
;
1098 if ( getPeer().is() )
1100 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1101 xButton
->setActionCommand( rCommand
);
1105 void UnoRadioButtonControl::setState( sal_Bool bOn
) throw(uno::RuntimeException
)
1107 sal_Int16 nState
= bOn
? 1 : 0;
1110 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_True
);
1113 sal_Bool
UnoRadioButtonControl::getState() throw(uno::RuntimeException
)
1115 sal_Int16 nState
= 0;
1116 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1118 return nState
? sal_True
: sal_False
;
1121 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
1124 aAny
<<= (sal_Int16
)rEvent
.Selected
;
1125 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
1128 // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
1129 // in _one_ itemStateChanged call for exactly the radio button which's state changed from
1131 // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
1132 // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
1133 // isn't the case anymore: For instance, this method here gets called for the radio button
1134 // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
1135 // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
1136 // from a pure API perspective, but it's _compatible_ with older product versions, and this is
1137 // all which matters here.
1139 if ( 1 == rEvent
.Selected
)
1141 if ( maItemListeners
.getLength() )
1142 maItemListeners
.itemStateChanged( rEvent
);
1144 // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
1145 // a radio button _without_ selecing another one, this would have caused a notification.
1146 // With the change done here, this today won't cause a notification anymore.
1148 // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
1149 // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
1150 // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
1151 // to be inconsistent with.
1154 awt::Size
UnoRadioButtonControl::getMinimumSize( ) throw(uno::RuntimeException
)
1156 return Impl_getMinimumSize();
1159 awt::Size
UnoRadioButtonControl::getPreferredSize( ) throw(uno::RuntimeException
)
1161 return Impl_getPreferredSize();
1164 awt::Size
UnoRadioButtonControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1166 return Impl_calcAdjustedSize( rNewSize
);
1169 // ----------------------------------------------------
1170 // class UnoControlCheckBoxModel
1171 // ----------------------------------------------------
1172 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference
< XComponentContext
>& rxContext
)
1173 :GraphicControlModel( rxContext
)
1175 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox
);
1178 OUString
UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1180 return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel
);
1183 uno::Any
UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1187 case BASEPROPERTY_DEFAULTCONTROL
:
1188 return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox
) );
1190 case BASEPROPERTY_VISUALEFFECT
:
1191 return uno::makeAny( (sal_Int16
)awt::VisualEffect::LOOK3D
);
1194 return GraphicControlModel::ImplGetDefaultValue( nPropId
);
1197 ::cppu::IPropertyArrayHelper
& UnoControlCheckBoxModel::getInfoHelper()
1199 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1202 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1203 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1208 // beans::XMultiPropertySet
1209 uno::Reference
< beans::XPropertySetInfo
> UnoControlCheckBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1211 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1217 // ----------------------------------------------------
1218 // class UnoCheckBoxControl
1219 // ----------------------------------------------------
1220 UnoCheckBoxControl::UnoCheckBoxControl()
1221 :UnoCheckBoxControl_Base()
1222 ,maItemListeners( *this ), maActionListeners( *this )
1224 maComponentInfos
.nWidth
= 100;
1225 maComponentInfos
.nHeight
= 12;
1228 OUString
UnoCheckBoxControl::GetComponentServiceName()
1230 return OUString("checkbox");
1233 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException
)
1235 lang::EventObject aEvt
;
1236 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1237 maItemListeners
.disposeAndClear( aEvt
);
1238 UnoControlBase::dispose();
1241 sal_Bool
UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException
)
1246 void UnoCheckBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1248 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1250 uno::Reference
< awt::XCheckBox
> xCheckBox( getPeer(), uno::UNO_QUERY
);
1251 xCheckBox
->addItemListener( this );
1253 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1254 xButton
->setActionCommand( maActionCommand
);
1255 if ( maActionListeners
.getLength() )
1256 xButton
->addActionListener( &maActionListeners
);
1259 void UnoCheckBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1261 maItemListeners
.addInterface( l
);
1264 void UnoCheckBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
1266 maItemListeners
.removeInterface( l
);
1269 void UnoCheckBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1271 maActionListeners
.addInterface( l
);
1272 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1274 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1275 xButton
->addActionListener( &maActionListeners
);
1279 void UnoCheckBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1281 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1283 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1284 xButton
->removeActionListener( &maActionListeners
);
1286 maActionListeners
.removeInterface( l
);
1289 void UnoCheckBoxControl::setActionCommand( const OUString
& rCommand
) throw(uno::RuntimeException
)
1291 maActionCommand
= rCommand
;
1292 if ( getPeer().is() )
1294 uno::Reference
< awt::XButton
> xButton( getPeer(), uno::UNO_QUERY
);
1295 xButton
->setActionCommand( rCommand
);
1300 void UnoCheckBoxControl::setLabel( const OUString
& rLabel
) throw(uno::RuntimeException
)
1304 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1307 void UnoCheckBoxControl::setState( short n
) throw(uno::RuntimeException
)
1310 aAny
<<= (sal_Int16
)n
;
1311 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_True
);
1314 short UnoCheckBoxControl::getState() throw(uno::RuntimeException
)
1317 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
) );
1322 void UnoCheckBoxControl::enableTriState( sal_Bool b
) throw(uno::RuntimeException
)
1326 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE
), aAny
, sal_True
);
1329 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
1332 aAny
<<= (sal_Int16
)rEvent
.Selected
;
1333 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE
), aAny
, sal_False
);
1335 if ( maItemListeners
.getLength() )
1336 maItemListeners
.itemStateChanged( rEvent
);
1339 awt::Size
UnoCheckBoxControl::getMinimumSize( ) throw(uno::RuntimeException
)
1341 return Impl_getMinimumSize();
1344 awt::Size
UnoCheckBoxControl::getPreferredSize( ) throw(uno::RuntimeException
)
1346 return Impl_getPreferredSize();
1349 awt::Size
UnoCheckBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1351 return Impl_calcAdjustedSize( rNewSize
);
1354 // ----------------------------------------------------
1355 // class UnoControlFixedHyperlinkModel
1356 // ----------------------------------------------------
1357 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference
< XComponentContext
>& rxContext
)
1358 :UnoControlModel( rxContext
)
1360 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink
);
1363 OUString
UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1365 return OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel
);
1368 uno::Any
UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1370 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1373 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink
);
1376 else if ( nPropId
== BASEPROPERTY_BORDER
)
1379 aAny
<<= (sal_Int16
)0;
1382 else if ( nPropId
== BASEPROPERTY_URL
)
1385 aAny
<<= OUString();
1389 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1392 ::cppu::IPropertyArrayHelper
& UnoControlFixedHyperlinkModel::getInfoHelper()
1394 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1397 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1398 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1403 // beans::XMultiPropertySet
1404 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedHyperlinkModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1406 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1410 // ----------------------------------------------------
1411 // class UnoFixedHyperlinkControl
1412 // ----------------------------------------------------
1413 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
1415 ,maActionListeners( *this )
1417 maComponentInfos
.nWidth
= 100;
1418 maComponentInfos
.nHeight
= 12;
1421 OUString
UnoFixedHyperlinkControl::GetComponentServiceName()
1423 return OUString("fixedhyperlink");
1427 uno::Any
UnoFixedHyperlinkControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
1429 uno::Any aRet
= ::cppu::queryInterface( rType
,
1430 (static_cast< awt::XFixedHyperlink
* >(this)),
1431 (static_cast< awt::XLayoutConstrains
* >(this)) );
1432 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1435 // lang::XTypeProvider
1436 IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl
)
1437 getCppuType( ( uno::Reference
< awt::XFixedHyperlink
>* ) NULL
),
1438 getCppuType( ( uno::Reference
< awt::XLayoutConstrains
>* ) NULL
),
1439 UnoControlBase::getTypes()
1440 IMPL_XTYPEPROVIDER_END
1442 sal_Bool
UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException
)
1447 void UnoFixedHyperlinkControl::setText( const OUString
& Text
) throw(uno::RuntimeException
)
1451 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1454 OUString
UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException
)
1456 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1459 void UnoFixedHyperlinkControl::setURL( const OUString
& URL
) throw(::com::sun::star::uno::RuntimeException
)
1463 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL
), aAny
, sal_True
);
1466 OUString
UnoFixedHyperlinkControl::getURL( ) throw(::com::sun::star::uno::RuntimeException
)
1468 return ImplGetPropertyValue_UString( BASEPROPERTY_URL
);
1471 void UnoFixedHyperlinkControl::setAlignment( short nAlign
) throw(uno::RuntimeException
)
1474 aAny
<<= (sal_Int16
)nAlign
;
1475 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), aAny
, sal_True
);
1478 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException
)
1483 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1489 awt::Size
UnoFixedHyperlinkControl::getMinimumSize( ) throw(uno::RuntimeException
)
1491 return Impl_getMinimumSize();
1494 awt::Size
UnoFixedHyperlinkControl::getPreferredSize( ) throw(uno::RuntimeException
)
1496 return Impl_getPreferredSize();
1499 awt::Size
UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1501 return Impl_calcAdjustedSize( rNewSize
);
1504 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException
)
1506 lang::EventObject aEvt
;
1507 aEvt
.Source
= (::cppu::OWeakObject
*)this;
1508 maActionListeners
.disposeAndClear( aEvt
);
1509 UnoControlBase::dispose();
1512 void UnoFixedHyperlinkControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
1514 UnoControlBase::createPeer( rxToolkit
, rParentPeer
);
1516 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1517 if ( maActionListeners
.getLength() )
1518 xFixedHyperlink
->addActionListener( &maActionListeners
);
1521 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1523 maActionListeners
.addInterface( l
);
1524 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1526 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1527 xFixedHyperlink
->addActionListener( &maActionListeners
);
1531 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
1533 if( getPeer().is() && maActionListeners
.getLength() == 1 )
1535 uno::Reference
< awt::XFixedHyperlink
> xFixedHyperlink( getPeer(), uno::UNO_QUERY
);
1536 xFixedHyperlink
->removeActionListener( &maActionListeners
);
1538 maActionListeners
.removeInterface( l
);
1541 // ----------------------------------------------------
1542 // class UnoControlFixedTextModel
1543 // ----------------------------------------------------
1544 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference
< XComponentContext
>& rxContext
)
1545 :UnoControlModel( rxContext
)
1547 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText
);
1550 OUString
UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1552 return OUString::createFromAscii( szServiceName_UnoControlFixedTextModel
);
1555 uno::Any
UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1557 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1560 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlFixedText
);
1563 else if ( nPropId
== BASEPROPERTY_BORDER
)
1566 aAny
<<= (sal_Int16
)0;
1570 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1573 ::cppu::IPropertyArrayHelper
& UnoControlFixedTextModel::getInfoHelper()
1575 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1578 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1579 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1584 // beans::XMultiPropertySet
1585 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedTextModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1587 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1592 // ----------------------------------------------------
1593 // class UnoFixedTextControl
1594 // ----------------------------------------------------
1595 UnoFixedTextControl::UnoFixedTextControl()
1598 maComponentInfos
.nWidth
= 100;
1599 maComponentInfos
.nHeight
= 12;
1602 OUString
UnoFixedTextControl::GetComponentServiceName()
1604 return OUString("fixedtext");
1608 uno::Any
UnoFixedTextControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
1610 uno::Any aRet
= ::cppu::queryInterface( rType
,
1611 (static_cast< awt::XFixedText
* >(this)),
1612 (static_cast< awt::XLayoutConstrains
* >(this)) );
1613 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
1616 // lang::XTypeProvider
1617 IMPL_XTYPEPROVIDER_START( UnoFixedTextControl
)
1618 getCppuType( ( uno::Reference
< awt::XFixedText
>* ) NULL
),
1619 getCppuType( ( uno::Reference
< awt::XLayoutConstrains
>* ) NULL
),
1620 UnoControlBase::getTypes()
1621 IMPL_XTYPEPROVIDER_END
1623 sal_Bool
UnoFixedTextControl::isTransparent() throw(uno::RuntimeException
)
1628 void UnoFixedTextControl::setText( const OUString
& Text
) throw(uno::RuntimeException
)
1632 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL
), aAny
, sal_True
);
1635 OUString
UnoFixedTextControl::getText() throw(uno::RuntimeException
)
1637 return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL
);
1640 void UnoFixedTextControl::setAlignment( short nAlign
) throw(uno::RuntimeException
)
1643 aAny
<<= (sal_Int16
)nAlign
;
1644 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
), aAny
, sal_True
);
1647 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException
)
1652 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN
) );
1658 awt::Size
UnoFixedTextControl::getMinimumSize( ) throw(uno::RuntimeException
)
1660 return Impl_getMinimumSize();
1663 awt::Size
UnoFixedTextControl::getPreferredSize( ) throw(uno::RuntimeException
)
1665 return Impl_getPreferredSize();
1668 awt::Size
UnoFixedTextControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
1670 return Impl_calcAdjustedSize( rNewSize
);
1673 // ----------------------------------------------------
1674 // class UnoControlGroupBoxModel
1675 // ----------------------------------------------------
1676 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference
< XComponentContext
>& rxContext
)
1677 :UnoControlModel( rxContext
)
1679 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
1680 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
1681 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
1682 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
1683 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
1684 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
1685 ImplRegisterProperty( BASEPROPERTY_LABEL
);
1686 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
1687 ImplRegisterProperty( BASEPROPERTY_WRITING_MODE
);
1688 ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE
);
1691 OUString
UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1693 return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel
);
1696 uno::Any
UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1698 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1701 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlGroupBox
);
1704 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1707 ::cppu::IPropertyArrayHelper
& UnoControlGroupBoxModel::getInfoHelper()
1709 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1712 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1713 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1718 // beans::XMultiPropertySet
1719 uno::Reference
< beans::XPropertySetInfo
> UnoControlGroupBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1721 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1725 // ----------------------------------------------------
1726 // class UnoGroupBoxControl
1727 // ----------------------------------------------------
1728 UnoGroupBoxControl::UnoGroupBoxControl()
1731 maComponentInfos
.nWidth
= 100;
1732 maComponentInfos
.nHeight
= 100;
1735 OUString
UnoGroupBoxControl::GetComponentServiceName()
1737 return OUString("groupbox");
1740 sal_Bool
UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException
)
1745 // =====================================================================================================================
1746 // = UnoControlListBoxModel_Data
1747 // =====================================================================================================================
1751 OUString ItemImageURL
;
1761 ListItem( const OUString
& i_rItemText
)
1762 :ItemText( i_rItemText
)
1769 typedef beans::Pair
< OUString
, OUString
> UnoListItem
;
1771 struct StripItemData
: public ::std::unary_function
< ListItem
, UnoListItem
>
1773 UnoListItem
operator()( const ListItem
& i_rItem
)
1775 return UnoListItem( i_rItem
.ItemText
, i_rItem
.ItemImageURL
);
1779 struct UnoControlListBoxModel_Data
1781 UnoControlListBoxModel_Data( UnoControlListBoxModel
& i_rAntiImpl
)
1782 :m_bSettingLegacyProperty( false )
1783 ,m_rAntiImpl( i_rAntiImpl
)
1788 sal_Int32
getItemCount() const { return sal_Int32( m_aListItems
.size() ); }
1790 const ListItem
& getItem( const sal_Int32 i_nIndex
) const
1792 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
1793 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
1794 return m_aListItems
[ i_nIndex
];
1797 ListItem
& getItem( const sal_Int32 i_nIndex
)
1799 return const_cast< ListItem
& >( static_cast< const UnoControlListBoxModel_Data
* >( this )->getItem( i_nIndex
) );
1802 ListItem
& insertItem( const sal_Int32 i_nIndex
)
1804 if ( ( i_nIndex
< 0 ) || ( i_nIndex
> sal_Int32( m_aListItems
.size() ) ) )
1805 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
1806 return *m_aListItems
.insert( m_aListItems
.begin() + i_nIndex
, ListItem() );
1809 Sequence
< UnoListItem
> getAllItems() const
1811 Sequence
< UnoListItem
> aItems( sal_Int32( m_aListItems
.size() ) );
1812 ::std::transform( m_aListItems
.begin(), m_aListItems
.end(), aItems
.getArray(), StripItemData() );
1816 void copyItems( const UnoControlListBoxModel_Data
& i_copySource
)
1818 m_aListItems
= i_copySource
.m_aListItems
;
1821 void setAllItems( const ::std::vector
< ListItem
>& i_rItems
)
1823 m_aListItems
= i_rItems
;
1826 void removeItem( const sal_Int32 i_nIndex
)
1828 if ( ( i_nIndex
< 0 ) || ( i_nIndex
>= sal_Int32( m_aListItems
.size() ) ) )
1829 throw IndexOutOfBoundsException( OUString(), m_rAntiImpl
);
1830 m_aListItems
.erase( m_aListItems
.begin() + i_nIndex
);
1833 void removeAllItems()
1835 ::std::vector
< ListItem
> aEmpty
;
1836 m_aListItems
.swap( aEmpty
);
1840 bool m_bSettingLegacyProperty
;
1843 UnoControlListBoxModel
& m_rAntiImpl
;
1844 ::std::vector
< ListItem
> m_aListItems
;
1847 // =====================================================================================================================
1848 // = UnoControlListBoxModel
1849 // =====================================================================================================================
1850 // ---------------------------------------------------------------------------------------------------------------------
1851 UnoControlListBoxModel::UnoControlListBoxModel( const Reference
< XComponentContext
>& rxContext
, ConstructorMode
const i_mode
)
1852 :UnoControlListBoxModel_Base( rxContext
)
1853 ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1854 ,m_aItemListListeners( GetMutex() )
1856 if ( i_mode
== ConstructDefault
)
1858 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox
);
1861 // ---------------------------------------------------------------------------------------------------------------------
1862 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel
& i_rSource
)
1863 :UnoControlListBoxModel_Base( i_rSource
)
1864 ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1865 ,m_aItemListListeners( GetMutex() )
1867 m_pData
->copyItems( *i_rSource
.m_pData
);
1869 UnoControlListBoxModel::~UnoControlListBoxModel()
1872 IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel
, UnoControlModel
, szServiceName2_UnoControlListBoxModel
)
1873 // ---------------------------------------------------------------------------------------------------------------------
1874 OUString
UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
1876 return OUString::createFromAscii( szServiceName_UnoControlListBoxModel
);
1879 // ---------------------------------------------------------------------------------------------------------------------
1880 uno::Any
UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
1882 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
1885 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlListBox
);
1888 return UnoControlModel::ImplGetDefaultValue( nPropId
);
1891 // ---------------------------------------------------------------------------------------------------------------------
1892 ::cppu::IPropertyArrayHelper
& UnoControlListBoxModel::getInfoHelper()
1894 static UnoPropertyArrayHelper
* pHelper
= NULL
;
1897 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
1898 pHelper
= new UnoPropertyArrayHelper( aIDs
);
1903 // ---------------------------------------------------------------------------------------------------------------------
1904 // beans::XMultiPropertySet
1905 uno::Reference
< beans::XPropertySetInfo
> UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
1907 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
1911 // ---------------------------------------------------------------------------------------------------------------------
1914 struct CreateListItem
: public ::std::unary_function
< OUString
, ListItem
>
1916 ListItem
operator()( const OUString
& i_rItemText
)
1918 return ListItem( i_rItemText
);
1923 // ---------------------------------------------------------------------------------------------------------------------
1924 void SAL_CALL
UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
)
1926 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
1928 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
)
1931 uno::Sequence
<sal_Int16
> aSeq
;
1934 setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS
, aAny
);
1936 if ( !m_pData
->m_bSettingLegacyProperty
)
1938 // synchronize the legacy StringItemList property with our list items
1939 Sequence
< OUString
> aStringItemList
;
1941 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
1942 OSL_VERIFY( aPropValue
>>= aStringItemList
);
1944 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
1946 aStringItemList
.getConstArray(),
1947 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
1951 m_pData
->setAllItems( aItems
);
1953 // since an XItemListListener does not have a "all items modified" or some such method,
1954 // we simulate this by notifying removal of all items, followed by insertion of all new
1956 lang::EventObject aEvent
;
1957 aEvent
.Source
= *this;
1958 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
1959 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
1960 // which is wrong for the above notifications ...
1965 // ---------------------------------------------------------------------------------------------------------------------
1966 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount
, sal_Int32
* _pHandles
,
1967 uno::Any
* _pValues
, sal_Int32
* _pValidHandles
) const SAL_THROW(())
1969 // dependencies we know:
1970 // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
1971 ImplEnsureHandleOrder( _nCount
, _pHandles
, _pValues
, BASEPROPERTY_STRINGITEMLIST
, BASEPROPERTY_SELECTEDITEMS
);
1973 UnoControlModel::ImplNormalizePropertySequence( _nCount
, _pHandles
, _pValues
, _pValidHandles
);
1976 // ---------------------------------------------------------------------------------------------------------------------
1977 ::sal_Int32 SAL_CALL
UnoControlListBoxModel::getItemCount() throw (RuntimeException
)
1979 ::osl::MutexGuard
aGuard( GetMutex() );
1980 return m_pData
->getItemCount();
1983 // ---------------------------------------------------------------------------------------------------------------------
1984 void SAL_CALL
UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
1986 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
1987 // SYNCHRONIZED ----->
1988 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
1989 rItem
.ItemText
= i_rItemText
;
1990 rItem
.ItemImageURL
= i_rItemImageURL
;
1992 impl_handleInsert( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
1993 // <----- SYNCHRONIZED
1996 // ---------------------------------------------------------------------------------------------------------------------
1997 void SAL_CALL
UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
)
1999 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2000 // SYNCHRONIZED ----->
2001 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
2002 rItem
.ItemText
= i_rItemText
;
2004 impl_handleInsert( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2005 // <----- SYNCHRONIZED
2008 // ---------------------------------------------------------------------------------------------------------------------
2009 void SAL_CALL
UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2011 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2012 // SYNCHRONIZED ----->
2013 ListItem
& rItem( m_pData
->insertItem( i_nPosition
) );
2014 rItem
.ItemImageURL
= i_rItemImageURL
;
2016 impl_handleInsert( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2017 // <----- SYNCHRONIZED
2020 // ---------------------------------------------------------------------------------------------------------------------
2021 void SAL_CALL
UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2023 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2024 // SYNCHRONIZED ----->
2025 m_pData
->removeItem( i_nPosition
);
2027 impl_handleRemove( i_nPosition
, aGuard
);
2028 // <----- SYNCHRONIZED
2031 // ---------------------------------------------------------------------------------------------------------------------
2032 void SAL_CALL
UnoControlListBoxModel::removeAllItems( ) throw (::com::sun::star::uno::RuntimeException
)
2034 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2035 // SYNCHRONIZED ----->
2036 m_pData
->removeAllItems();
2038 impl_handleRemove( -1, aGuard
);
2039 // <----- SYNCHRONIZED
2042 // ---------------------------------------------------------------------------------------------------------------------
2043 void SAL_CALL
UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
) throw (IndexOutOfBoundsException
, RuntimeException
)
2045 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2046 // SYNCHRONIZED ----->
2047 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2048 rItem
.ItemText
= i_rItemText
;
2050 impl_handleModify( i_nPosition
, i_rItemText
, ::boost::optional
< OUString
>(), aGuard
);
2051 // <----- SYNCHRONIZED
2054 // ---------------------------------------------------------------------------------------------------------------------
2055 void SAL_CALL
UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2057 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2058 // SYNCHRONIZED ----->
2059 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2060 rItem
.ItemImageURL
= i_rItemImageURL
;
2062 impl_handleModify( i_nPosition
, ::boost::optional
< OUString
>(), i_rItemImageURL
, aGuard
);
2063 // <----- SYNCHRONIZED
2066 // ---------------------------------------------------------------------------------------------------------------------
2067 void SAL_CALL
UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition
, const OUString
& i_rItemText
, const OUString
& i_rItemImageURL
) throw (IndexOutOfBoundsException
, RuntimeException
)
2069 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2070 // SYNCHRONIZED ----->
2071 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2072 rItem
.ItemText
= i_rItemText
;
2073 rItem
.ItemImageURL
= i_rItemImageURL
;
2075 impl_handleModify( i_nPosition
, i_rItemText
, i_rItemImageURL
, aGuard
);
2076 // <----- SYNCHRONIZED
2079 // ---------------------------------------------------------------------------------------------------------------------
2080 void SAL_CALL
UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition
, const Any
& i_rDataValue
) throw (IndexOutOfBoundsException
, RuntimeException
)
2082 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2083 ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2084 rItem
.ItemData
= i_rDataValue
;
2087 // ---------------------------------------------------------------------------------------------------------------------
2088 OUString SAL_CALL
UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2090 ::osl::MutexGuard
aGuard( GetMutex() );
2091 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2092 return rItem
.ItemText
;
2095 // ---------------------------------------------------------------------------------------------------------------------
2096 OUString SAL_CALL
UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2098 ::osl::MutexGuard
aGuard( GetMutex() );
2099 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2100 return rItem
.ItemImageURL
;
2103 // ---------------------------------------------------------------------------------------------------------------------
2104 beans::Pair
< OUString
, OUString
> SAL_CALL
UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2106 ::osl::MutexGuard
aGuard( GetMutex() );
2107 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2108 return beans::Pair
< OUString
, OUString
>( rItem
.ItemText
, rItem
.ItemImageURL
);
2111 // ---------------------------------------------------------------------------------------------------------------------
2112 Any SAL_CALL
UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition
) throw (IndexOutOfBoundsException
, RuntimeException
)
2114 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
2115 const ListItem
& rItem( m_pData
->getItem( i_nPosition
) );
2116 return rItem
.ItemData
;
2119 // ---------------------------------------------------------------------------------------------------------------------
2120 Sequence
< beans::Pair
< OUString
, OUString
> > SAL_CALL
UnoControlListBoxModel::getAllItems( ) throw (RuntimeException
)
2122 ::osl::MutexGuard
aGuard( GetMutex() );
2123 return m_pData
->getAllItems();
2126 // ---------------------------------------------------------------------------------------------------------------------
2127 void SAL_CALL
UnoControlListBoxModel::addItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
)
2129 if ( i_Listener
.is() )
2130 m_aItemListListeners
.addInterface( i_Listener
);
2133 // ---------------------------------------------------------------------------------------------------------------------
2134 void SAL_CALL
UnoControlListBoxModel::removeItemListListener( const uno::Reference
< awt::XItemListListener
>& i_Listener
) throw (uno::RuntimeException
)
2136 if ( i_Listener
.is() )
2137 m_aItemListListeners
.removeInterface( i_Listener
);
2140 // ---------------------------------------------------------------------------------------------------------------------
2141 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector
< OUString
>& o_rStringItems
) const
2143 Sequence
< OUString
> aStringItemList
;
2145 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2146 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2148 o_rStringItems
.resize( size_t( aStringItemList
.getLength() ) );
2150 aStringItemList
.getConstArray(),
2151 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2152 o_rStringItems
.begin()
2156 // ---------------------------------------------------------------------------------------------------------------------
2157 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector
< OUString
>& i_rStringItems
)
2159 Sequence
< OUString
> aStringItems( i_rStringItems
.size() );
2161 i_rStringItems
.begin(),
2162 i_rStringItems
.end(),
2163 aStringItems
.getArray()
2165 m_pData
->m_bSettingLegacyProperty
= true;
2168 setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST
, uno::makeAny( aStringItems
) );
2170 catch( const Exception
& )
2172 m_pData
->m_bSettingLegacyProperty
= false;
2175 m_pData
->m_bSettingLegacyProperty
= false;
2178 // ---------------------------------------------------------------------------------------------------------------------
2179 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2180 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2182 // SYNCHRONIZED ----->
2183 // sync with legacy StringItemList property
2184 ::std::vector
< OUString
> aStringItems
;
2185 impl_getStringItemList( aStringItems
);
2186 OSL_ENSURE( size_t( i_nItemPosition
) <= aStringItems
.size(), "UnoControlListBoxModel::impl_handleInsert" );
2187 if ( size_t( i_nItemPosition
) <= aStringItems
.size() )
2189 const OUString
sItemText( !!i_rItemText
? *i_rItemText
: OUString() );
2190 aStringItems
.insert( aStringItems
.begin() + i_nItemPosition
, sItemText
);
2193 i_rClearBeforeNotify
.clear();
2194 // <----- SYNCHRONIZED
2195 impl_setStringItemList_nolck( aStringItems
);
2197 // notify ItemListListeners
2198 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemInserted
);
2201 // ---------------------------------------------------------------------------------------------------------------------
2202 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2204 // SYNCHRONIZED ----->
2205 const bool bAllItems
= ( i_nItemPosition
< 0 );
2206 // sync with legacy StringItemList property
2207 ::std::vector
< OUString
> aStringItems
;
2208 impl_getStringItemList( aStringItems
);
2211 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleRemove" );
2212 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2214 aStringItems
.erase( aStringItems
.begin() + i_nItemPosition
);
2219 aStringItems
.resize(0);
2222 i_rClearBeforeNotify
.clear();
2223 // <----- SYNCHRONIZED
2224 impl_setStringItemList_nolck( aStringItems
);
2226 // notify ItemListListeners
2229 EventObject
aEvent( *this );
2230 m_aItemListListeners
.notifyEach( &XItemListListener::allItemsRemoved
, aEvent
);
2234 impl_notifyItemListEvent_nolck( i_nItemPosition
, ::boost::optional
< OUString
>(), ::boost::optional
< OUString
>(),
2235 &XItemListListener::listItemRemoved
);
2239 // ---------------------------------------------------------------------------------------------------------------------
2240 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2241 const ::boost::optional
< OUString
>& i_rItemImageURL
, ::osl::ClearableMutexGuard
& i_rClearBeforeNotify
)
2243 // SYNCHRONIZED ----->
2244 if ( !!i_rItemText
)
2246 // sync with legacy StringItemList property
2247 ::std::vector
< OUString
> aStringItems
;
2248 impl_getStringItemList( aStringItems
);
2249 OSL_ENSURE( size_t( i_nItemPosition
) < aStringItems
.size(), "UnoControlListBoxModel::impl_handleModify" );
2250 if ( size_t( i_nItemPosition
) < aStringItems
.size() )
2252 aStringItems
[ i_nItemPosition
] = *i_rItemText
;
2255 i_rClearBeforeNotify
.clear();
2256 // <----- SYNCHRONIZED
2257 impl_setStringItemList_nolck( aStringItems
);
2261 i_rClearBeforeNotify
.clear();
2262 // <----- SYNCHRONIZED
2265 // notify ItemListListeners
2266 impl_notifyItemListEvent_nolck( i_nItemPosition
, i_rItemText
, i_rItemImageURL
, &XItemListListener::listItemModified
);
2269 // ---------------------------------------------------------------------------------------------------------------------
2270 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition
, const ::boost::optional
< OUString
>& i_rItemText
,
2271 const ::boost::optional
< OUString
>& i_rItemImageURL
,
2272 void ( SAL_CALL
XItemListListener::*NotificationMethod
)( const ItemListEvent
& ) )
2274 ItemListEvent aEvent
;
2275 aEvent
.Source
= *this;
2276 aEvent
.ItemPosition
= i_nItemPosition
;
2277 if ( !!i_rItemText
)
2279 aEvent
.ItemText
.IsPresent
= sal_True
;
2280 aEvent
.ItemText
.Value
= *i_rItemText
;
2282 if ( !!i_rItemImageURL
)
2284 aEvent
.ItemImageURL
.IsPresent
= sal_True
;
2285 aEvent
.ItemImageURL
.Value
= *i_rItemImageURL
;
2288 m_aItemListListeners
.notifyEach( NotificationMethod
, aEvent
);
2291 // ----------------------------------------------------
2292 // class UnoListBoxControl
2293 // ----------------------------------------------------
2294 UnoListBoxControl::UnoListBoxControl()
2295 :UnoListBoxControl_Base()
2296 ,maActionListeners( *this )
2297 ,maItemListeners( *this )
2299 maComponentInfos
.nWidth
= 100;
2300 maComponentInfos
.nHeight
= 12;
2303 OUString
UnoListBoxControl::GetComponentServiceName()
2305 return OUString("listbox");
2307 IMPL_SERVICEINFO_DERIVED( UnoListBoxControl
, UnoControlBase
, szServiceName2_UnoControlListBox
)
2309 void UnoListBoxControl::dispose() throw(uno::RuntimeException
)
2311 lang::EventObject aEvt
;
2312 aEvt
.Source
= (::cppu::OWeakObject
*)this;
2313 maActionListeners
.disposeAndClear( aEvt
);
2314 maItemListeners
.disposeAndClear( aEvt
);
2315 UnoControl::dispose();
2318 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2320 if ( getPeer().is() )
2322 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2323 DBG_ASSERT( xListBox
.is(), "XListBox?" );
2325 uno::Sequence
<sal_Int16
> aSeq
= xListBox
->getSelectedItemsPos();
2328 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
), aAny
, sal_False
);
2332 void UnoListBoxControl::updateFromModel()
2334 UnoControlBase::updateFromModel();
2336 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2337 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2339 EventObject
aEvent( getModel() );
2340 xItemListListener
->itemListChanged( aEvent
);
2342 // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
2343 // already did this, our peer(s) can only legitimately set the selection after they have the string
2344 // item list, which we just notified with the itemListChanged call.
2345 const OUString
sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS
) );
2346 ImplSetPeerProperty( sSelectedItemsPropName
, ImplGetPropertyValue( sSelectedItemsPropName
) );
2349 void UnoListBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2351 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2352 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2353 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2354 // will be forwarded to the peer, which will update itself accordingly.
2357 UnoControl::ImplSetPeerProperty( rPropName
, rVal
);
2360 void UnoListBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
2362 UnoControl::createPeer( rxToolkit
, rParentPeer
);
2364 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2365 xListBox
->addItemListener( this );
2367 if ( maActionListeners
.getLength() )
2368 xListBox
->addActionListener( &maActionListeners
);
2371 void UnoListBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2373 maActionListeners
.addInterface( l
);
2374 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2376 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2377 xListBox
->addActionListener( &maActionListeners
);
2381 void UnoListBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2383 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2385 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2386 xListBox
->removeActionListener( &maActionListeners
);
2388 maActionListeners
.removeInterface( l
);
2391 void UnoListBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2393 maItemListeners
.addInterface( l
);
2396 void UnoListBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2398 maItemListeners
.removeInterface( l
);
2401 void UnoListBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2403 uno::Sequence
< OUString
> aSeq( 1 );
2404 aSeq
.getArray()[0] = aItem
;
2405 addItems( aSeq
, nPos
);
2408 void UnoListBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2410 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2411 uno::Sequence
< OUString
> aSeq
;
2413 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
2414 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2415 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
2417 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2418 OUString
* pNewData
= aNewSeq
.getArray();
2419 OUString
* pOldData
= aSeq
.getArray();
2421 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
2422 nPos
= (sal_uInt16
) nOldLen
;
2425 // Items vor der Einfuege-Position
2426 for ( n
= 0; n
< nPos
; n
++ )
2427 pNewData
[n
] = pOldData
[n
];
2430 for ( n
= 0; n
< nNewItems
; n
++ )
2431 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
2433 // Rest der alten Items
2434 for ( n
= nPos
; n
< nOldLen
; n
++ )
2435 pNewData
[nNewItems
+n
] = pOldData
[n
];
2439 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
2442 void UnoListBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
)
2444 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2445 uno::Sequence
< OUString
> aSeq
;
2447 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
2448 if ( nOldLen
&& ( nPos
< nOldLen
) )
2450 if ( nCount
> ( nOldLen
-nPos
) )
2451 nCount
= nOldLen
-nPos
;
2453 sal_uInt16 nNewLen
= nOldLen
- nCount
;
2455 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
2456 OUString
* pNewData
= aNewSeq
.getArray();
2457 OUString
* pOldData
= aSeq
.getArray();
2460 // Items vor der Entfern-Position
2461 for ( n
= 0; n
< nPos
; n
++ )
2462 pNewData
[n
] = pOldData
[n
];
2465 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
2466 pNewData
[n
] = pOldData
[n
+nCount
];
2470 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
2474 sal_Int16
UnoListBoxControl::getItemCount() throw(uno::RuntimeException
)
2476 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2477 uno::Sequence
< OUString
> aSeq
;
2479 return (sal_Int16
)aSeq
.getLength();
2482 OUString
UnoListBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
)
2485 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2486 uno::Sequence
< OUString
> aSeq
;
2488 if ( nPos
< aSeq
.getLength() )
2489 aItem
= aSeq
.getConstArray()[nPos
];
2493 uno::Sequence
< OUString
> UnoListBoxControl::getItems() throw(uno::RuntimeException
)
2495 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
2496 uno::Sequence
< OUString
> aSeq
;
2501 sal_Int16
UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException
)
2504 if ( getPeer().is() )
2506 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2507 n
= xListBox
->getSelectedItemPos();
2512 uno::Sequence
<sal_Int16
> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException
)
2514 uno::Sequence
<sal_Int16
> aSeq
;
2515 if ( getPeer().is() )
2517 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2518 aSeq
= xListBox
->getSelectedItemsPos();
2523 OUString
UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException
)
2526 if ( getPeer().is() )
2528 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2529 aItem
= xListBox
->getSelectedItem();
2534 uno::Sequence
< OUString
> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException
)
2536 uno::Sequence
< OUString
> aSeq
;
2537 if ( getPeer().is() )
2539 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2540 aSeq
= xListBox
->getSelectedItems();
2545 void UnoListBoxControl::selectItemPos( sal_Int16 nPos
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2547 if ( getPeer().is() )
2549 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2550 xListBox
->selectItemPos( nPos
, bSelect
);
2552 ImplUpdateSelectedItemsProperty();
2555 void UnoListBoxControl::selectItemsPos( const uno::Sequence
<sal_Int16
>& aPositions
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2557 if ( getPeer().is() )
2559 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2560 xListBox
->selectItemsPos( aPositions
, bSelect
);
2562 ImplUpdateSelectedItemsProperty();
2565 void UnoListBoxControl::selectItem( const OUString
& aItem
, sal_Bool bSelect
) throw(uno::RuntimeException
)
2567 if ( getPeer().is() )
2569 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2570 xListBox
->selectItem( aItem
, bSelect
);
2572 ImplUpdateSelectedItemsProperty();
2575 void UnoListBoxControl::makeVisible( sal_Int16 nEntry
) throw(uno::RuntimeException
)
2577 if ( getPeer().is() )
2579 uno::Reference
< awt::XListBox
> xListBox( getPeer(), uno::UNO_QUERY
);
2580 xListBox
->makeVisible( nEntry
);
2584 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
)
2587 aAny
<<= (sal_Int16
)nLines
;
2588 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), aAny
, sal_True
);
2591 sal_Int16
UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException
)
2593 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
2596 sal_Bool
UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException
)
2598 return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION
);
2601 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti
) throw(uno::RuntimeException
)
2605 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION
), aAny
, sal_True
);
2608 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
2610 ImplUpdateSelectedItemsProperty();
2611 if ( maItemListeners
.getLength() )
2615 maItemListeners
.itemStateChanged( rEvent
);
2617 catch( const Exception
& e
)
2619 #if OSL_DEBUG_LEVEL == 0
2620 (void) e
; // suppress warning
2622 OString
sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2623 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2624 OSL_FAIL( sMessage
.getStr() );
2630 awt::Size
UnoListBoxControl::getMinimumSize( ) throw(uno::RuntimeException
)
2632 return Impl_getMinimumSize();
2635 awt::Size
UnoListBoxControl::getPreferredSize( ) throw(uno::RuntimeException
)
2637 return Impl_getPreferredSize();
2640 awt::Size
UnoListBoxControl::calcAdjustedSize( const awt::Size
& rNewSize
) throw(uno::RuntimeException
)
2642 return Impl_calcAdjustedSize( rNewSize
);
2645 awt::Size
UnoListBoxControl::getMinimumSize( sal_Int16 nCols
, sal_Int16 nLines
) throw(uno::RuntimeException
)
2647 return Impl_getMinimumSize( nCols
, nLines
);
2650 void UnoListBoxControl::getColumnsAndLines( sal_Int16
& nCols
, sal_Int16
& nLines
) throw(uno::RuntimeException
)
2652 Impl_getColumnsAndLines( nCols
, nLines
);
2655 sal_Bool SAL_CALL
UnoListBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
)
2657 ::osl::MutexGuard
aGuard( GetMutex() );
2659 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2660 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
2661 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2662 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoListBoxControl::setModel: illegal new model!" );
2664 if ( !UnoListBoxControl_Base::setModel( i_rModel
) )
2667 if ( xOldItems
.is() )
2668 xOldItems
->removeItemListListener( this );
2669 if ( xNewItems
.is() )
2670 xNewItems
->addItemListListener( this );
2675 void SAL_CALL
UnoListBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2677 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2678 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
2679 if ( xPeerListener
.is() )
2680 xPeerListener
->listItemInserted( i_rEvent
);
2683 void SAL_CALL
UnoListBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2685 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2686 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
2687 if ( xPeerListener
.is() )
2688 xPeerListener
->listItemRemoved( i_rEvent
);
2691 void SAL_CALL
UnoListBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2693 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2694 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
2695 if ( xPeerListener
.is() )
2696 xPeerListener
->listItemModified( i_rEvent
);
2699 void SAL_CALL
UnoListBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2701 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2702 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
2703 if ( xPeerListener
.is() )
2704 xPeerListener
->allItemsRemoved( i_rEvent
);
2707 void SAL_CALL
UnoListBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2709 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2710 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
2711 if ( xPeerListener
.is() )
2712 xPeerListener
->itemListChanged( i_rEvent
);
2715 // ----------------------------------------------------
2716 // class UnoControlComboBoxModel
2717 // ----------------------------------------------------
2718 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference
< XComponentContext
>& rxContext
)
2719 :UnoControlListBoxModel( rxContext
, ConstructWithoutProperties
)
2721 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox
);
2724 IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel
, UnoControlModel
, szServiceName2_UnoControlComboBoxModel
)
2726 uno::Reference
< beans::XPropertySetInfo
> UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
2728 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
2731 // ---------------------------------------------------------------------------------------------------------------------
2732 ::cppu::IPropertyArrayHelper
& UnoControlComboBoxModel::getInfoHelper()
2734 static UnoPropertyArrayHelper
* pHelper
= NULL
;
2737 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
2738 pHelper
= new UnoPropertyArrayHelper( aIDs
);
2744 OUString
UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
2746 return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel
);
2748 void SAL_CALL
UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
) throw (uno::Exception
)
2750 UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle
, rValue
);
2752 if ( nHandle
== BASEPROPERTY_STRINGITEMLIST
&& !m_pData
->m_bSettingLegacyProperty
)
2754 // synchronize the legacy StringItemList property with our list items
2755 Sequence
< OUString
> aStringItemList
;
2757 getFastPropertyValue( aPropValue
, BASEPROPERTY_STRINGITEMLIST
);
2758 OSL_VERIFY( aPropValue
>>= aStringItemList
);
2760 ::std::vector
< ListItem
> aItems( aStringItemList
.getLength() );
2762 aStringItemList
.getConstArray(),
2763 aStringItemList
.getConstArray() + aStringItemList
.getLength(),
2767 m_pData
->setAllItems( aItems
);
2769 // since an XItemListListener does not have a "all items modified" or some such method,
2770 // we simulate this by notifying removal of all items, followed by insertion of all new
2772 lang::EventObject aEvent
;
2773 aEvent
.Source
= *this;
2774 m_aItemListListeners
.notifyEach( &XItemListListener::itemListChanged
, aEvent
);
2775 // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2776 // which is wrong for the above notifications ...
2780 uno::Any
UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
2782 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
2785 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlComboBox
);
2788 return UnoControlModel::ImplGetDefaultValue( nPropId
);
2791 // ----------------------------------------------------
2792 // class UnoComboBoxControl
2793 // ----------------------------------------------------
2794 UnoComboBoxControl::UnoComboBoxControl()
2796 ,maActionListeners( *this )
2797 ,maItemListeners( *this )
2799 maComponentInfos
.nWidth
= 100;
2800 maComponentInfos
.nHeight
= 12;
2802 IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl
, UnoEditControl
, szServiceName2_UnoControlComboBox
)
2804 OUString
UnoComboBoxControl::GetComponentServiceName()
2806 return OUString("combobox");
2809 void UnoComboBoxControl::dispose() throw(uno::RuntimeException
)
2811 lang::EventObject aEvt
;
2812 aEvt
.Source
= (::cppu::OWeakObject
*)this;
2813 maActionListeners
.disposeAndClear( aEvt
);
2814 maItemListeners
.disposeAndClear( aEvt
);
2815 UnoControl::dispose();
2817 uno::Any
UnoComboBoxControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
2819 uno::Any aRet
= ::cppu::queryInterface( rType
,
2820 (static_cast< awt::XComboBox
* >(this)) );
2821 if ( !aRet
.hasValue() )
2823 aRet
= ::cppu::queryInterface( rType
,
2824 (static_cast< awt::XItemListener
* >(this)) );
2825 if ( !aRet
.hasValue() )
2827 aRet
= ::cppu::queryInterface( rType
,
2828 (static_cast< awt::XItemListListener
* >(this)) );
2831 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
2833 // lang::XTypeProvider
2834 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl
)
2835 getCppuType( ( uno::Reference
< awt::XComboBox
>* ) NULL
),
2836 getCppuType( ( uno::Reference
< awt::XItemListener
>* ) NULL
),
2837 getCppuType( ( uno::Reference
< awt::XItemListListener
>* ) NULL
),
2838 UnoEditControl::getTypes()
2839 IMPL_XTYPEPROVIDER_END
2841 void UnoComboBoxControl::updateFromModel()
2843 UnoEditControl::updateFromModel();
2845 Reference
< XItemListListener
> xItemListListener( getPeer(), UNO_QUERY
);
2846 ENSURE_OR_RETURN_VOID( xItemListListener
.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2848 EventObject
aEvent( getModel() );
2849 xItemListListener
->itemListChanged( aEvent
);
2851 void UnoComboBoxControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
2853 if ( rPropName
== GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) )
2854 // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2855 // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2856 // will be forwarded to the peer, which will update itself accordingly.
2859 UnoEditControl::ImplSetPeerProperty( rPropName
, rVal
);
2861 void UnoComboBoxControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
2863 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
2865 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2866 if ( maActionListeners
.getLength() )
2867 xComboBox
->addActionListener( &maActionListeners
);
2868 if ( maItemListeners
.getLength() )
2869 xComboBox
->addItemListener( &maItemListeners
);
2872 void UnoComboBoxControl::addActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2874 maActionListeners
.addInterface( l
);
2875 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2877 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2878 xComboBox
->addActionListener( &maActionListeners
);
2882 void UnoComboBoxControl::removeActionListener(const uno::Reference
< awt::XActionListener
> & l
) throw(uno::RuntimeException
)
2884 if( getPeer().is() && maActionListeners
.getLength() == 1 )
2886 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2887 xComboBox
->removeActionListener( &maActionListeners
);
2889 maActionListeners
.removeInterface( l
);
2892 void UnoComboBoxControl::addItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2894 maItemListeners
.addInterface( l
);
2895 if( getPeer().is() && maItemListeners
.getLength() == 1 )
2897 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2898 xComboBox
->addItemListener( &maItemListeners
);
2902 void UnoComboBoxControl::removeItemListener(const uno::Reference
< awt::XItemListener
> & l
) throw(uno::RuntimeException
)
2904 if( getPeer().is() && maItemListeners
.getLength() == 1 )
2906 // This call is prettier than creating a Ref and calling query
2907 uno::Reference
< awt::XComboBox
> xComboBox( getPeer(), uno::UNO_QUERY
);
2908 xComboBox
->removeItemListener( &maItemListeners
);
2910 maItemListeners
.removeInterface( l
);
2912 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent
& rEvent
) throw(uno::RuntimeException
)
2914 if ( maItemListeners
.getLength() )
2918 maItemListeners
.itemStateChanged( rEvent
);
2920 catch( const Exception
& e
)
2922 #if OSL_DEBUG_LEVEL == 0
2923 (void) e
; // suppress warning
2925 OString
sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
2926 sMessage
+= OString( e
.Message
.getStr(), e
.Message
.getLength(), RTL_TEXTENCODING_ASCII_US
);
2927 OSL_FAIL( sMessage
.getStr() );
2932 sal_Bool SAL_CALL
UnoComboBoxControl::setModel( const uno::Reference
< awt::XControlModel
>& i_rModel
) throw ( uno::RuntimeException
)
2934 ::osl::MutexGuard
aGuard( GetMutex() );
2936 const Reference
< XItemList
> xOldItems( getModel(), UNO_QUERY
);
2937 OSL_ENSURE( xOldItems
.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
2938 const Reference
< XItemList
> xNewItems( i_rModel
, UNO_QUERY
);
2939 OSL_ENSURE( xNewItems
.is() || !i_rModel
.is(), "UnoComboBoxControl::setModel: illegal new model!" );
2941 if ( !UnoEditControl::setModel( i_rModel
) )
2944 if ( xOldItems
.is() )
2945 xOldItems
->removeItemListListener( this );
2946 if ( xNewItems
.is() )
2947 xNewItems
->addItemListListener( this );
2952 void SAL_CALL
UnoComboBoxControl::listItemInserted( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2954 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2955 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
2956 if ( xPeerListener
.is() )
2957 xPeerListener
->listItemInserted( i_rEvent
);
2960 void SAL_CALL
UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2962 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2963 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
2964 if ( xPeerListener
.is() )
2965 xPeerListener
->listItemRemoved( i_rEvent
);
2968 void SAL_CALL
UnoComboBoxControl::listItemModified( const awt::ItemListEvent
& i_rEvent
) throw (uno::RuntimeException
)
2970 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2971 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
2972 if ( xPeerListener
.is() )
2973 xPeerListener
->listItemModified( i_rEvent
);
2976 void SAL_CALL
UnoComboBoxControl::allItemsRemoved( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2978 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2979 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
2980 if ( xPeerListener
.is() )
2981 xPeerListener
->allItemsRemoved( i_rEvent
);
2984 void SAL_CALL
UnoComboBoxControl::itemListChanged( const lang::EventObject
& i_rEvent
) throw (uno::RuntimeException
)
2986 const Reference
< XItemListListener
> xPeerListener( getPeer(), UNO_QUERY
);
2987 OSL_ENSURE( xPeerListener
.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
2988 if ( xPeerListener
.is() )
2989 xPeerListener
->itemListChanged( i_rEvent
);
2992 void UnoComboBoxControl::addItem( const OUString
& aItem
, sal_Int16 nPos
) throw(uno::RuntimeException
)
2994 uno::Sequence
< OUString
> aSeq( 1 );
2995 aSeq
.getArray()[0] = aItem
;
2996 addItems( aSeq
, nPos
);
2999 void UnoComboBoxControl::addItems( const uno::Sequence
< OUString
>& aItems
, sal_Int16 nPos
) throw(uno::RuntimeException
)
3001 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3002 uno::Sequence
< OUString
> aSeq
;
3004 sal_uInt16 nNewItems
= (sal_uInt16
)aItems
.getLength();
3005 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3006 sal_uInt16 nNewLen
= nOldLen
+ nNewItems
;
3008 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3009 OUString
* pNewData
= aNewSeq
.getArray();
3010 const OUString
* pOldData
= aSeq
.getConstArray();
3012 if ( ( nPos
< 0 ) || ( nPos
> nOldLen
) )
3013 nPos
= (sal_uInt16
) nOldLen
;
3016 // items before the insert position
3017 for ( n
= 0; n
< nPos
; n
++ )
3018 pNewData
[n
] = pOldData
[n
];
3021 for ( n
= 0; n
< nNewItems
; n
++ )
3022 pNewData
[nPos
+n
] = aItems
.getConstArray()[n
];
3024 // remainder of old items
3025 for ( n
= nPos
; n
< nOldLen
; n
++ )
3026 pNewData
[nNewItems
+n
] = pOldData
[n
];
3030 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
3033 void UnoComboBoxControl::removeItems( sal_Int16 nPos
, sal_Int16 nCount
) throw(uno::RuntimeException
)
3035 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3036 uno::Sequence
< OUString
> aSeq
;
3038 sal_uInt16 nOldLen
= (sal_uInt16
)aSeq
.getLength();
3039 if ( nOldLen
&& ( nPos
< nOldLen
) )
3041 if ( nCount
> ( nOldLen
-nPos
) )
3042 nCount
= nOldLen
-nPos
;
3044 sal_uInt16 nNewLen
= nOldLen
- nCount
;
3046 uno::Sequence
< OUString
> aNewSeq( nNewLen
);
3047 OUString
* pNewData
= aNewSeq
.getArray();
3048 OUString
* pOldData
= aSeq
.getArray();
3051 // items before the deletion position
3052 for ( n
= 0; n
< nPos
; n
++ )
3053 pNewData
[n
] = pOldData
[n
];
3055 // remainder of old items
3056 for ( n
= nPos
; n
< (nOldLen
-nCount
); n
++ )
3057 pNewData
[n
] = pOldData
[n
+nCount
];
3061 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
), aAny
, sal_True
);
3065 sal_Int16
UnoComboBoxControl::getItemCount() throw(uno::RuntimeException
)
3067 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3068 uno::Sequence
< OUString
> aSeq
;
3070 return (sal_Int16
)aSeq
.getLength();
3073 OUString
UnoComboBoxControl::getItem( sal_Int16 nPos
) throw(uno::RuntimeException
)
3076 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3077 uno::Sequence
< OUString
> aSeq
;
3079 if ( nPos
< aSeq
.getLength() )
3080 aItem
= aSeq
.getConstArray()[nPos
];
3084 uno::Sequence
< OUString
> UnoComboBoxControl::getItems() throw(uno::RuntimeException
)
3086 uno::Any aVal
= ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST
) );
3087 uno::Sequence
< OUString
> aSeq
;
3092 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines
) throw(uno::RuntimeException
)
3096 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT
), aAny
, sal_True
);
3099 sal_Int16
UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException
)
3101 return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT
);
3105 // ----------------------------------------------------
3106 // UnoSpinFieldControl
3107 // ----------------------------------------------------
3108 UnoSpinFieldControl::UnoSpinFieldControl()
3110 ,maSpinListeners( *this )
3112 mbRepeat
= sal_False
;
3116 uno::Any
UnoSpinFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3118 uno::Any aRet
= ::cppu::queryInterface( rType
,
3119 (static_cast< awt::XSpinField
* >(this)) );
3120 return (aRet
.hasValue() ? aRet
: UnoEditControl::queryAggregation( rType
));
3123 // lang::XTypeProvider
3124 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl
)
3125 getCppuType( ( uno::Reference
< awt::XSpinField
>* ) NULL
),
3126 UnoEditControl::getTypes()
3127 IMPL_XTYPEPROVIDER_END
3129 void UnoSpinFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3131 UnoEditControl::createPeer( rxToolkit
, rParentPeer
);
3133 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3134 xField
->enableRepeat( mbRepeat
);
3135 if ( maSpinListeners
.getLength() )
3136 xField
->addSpinListener( &maSpinListeners
);
3139 // ::com::sun::star::awt::XSpinField
3140 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
>& l
) throw(::com::sun::star::uno::RuntimeException
)
3142 maSpinListeners
.addInterface( l
);
3143 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3145 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3146 xField
->addSpinListener( &maSpinListeners
);
3150 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XSpinListener
>& l
) throw(::com::sun::star::uno::RuntimeException
)
3152 if( getPeer().is() && maSpinListeners
.getLength() == 1 )
3154 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3155 xField
->removeSpinListener( &maSpinListeners
);
3157 maSpinListeners
.removeInterface( l
);
3160 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException
)
3162 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3167 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException
)
3169 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3174 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException
)
3176 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3181 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException
)
3183 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3188 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat
) throw(::com::sun::star::uno::RuntimeException
)
3192 uno::Reference
< awt::XSpinField
> xField( getPeer(), uno::UNO_QUERY
);
3194 xField
->enableRepeat( bRepeat
);
3197 // ----------------------------------------------------
3198 // class UnoControlDateFieldModel
3199 // ----------------------------------------------------
3200 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference
< XComponentContext
>& rxContext
)
3201 :UnoControlModel( rxContext
)
3203 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField
);
3206 OUString
UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3208 return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel
);
3211 uno::Any
UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3213 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3216 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlDateField
);
3219 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3223 ::cppu::IPropertyArrayHelper
& UnoControlDateFieldModel::getInfoHelper()
3225 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3228 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3229 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3234 // beans::XMultiPropertySet
3235 uno::Reference
< beans::XPropertySetInfo
> UnoControlDateFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3237 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3243 // ----------------------------------------------------
3244 // class UnoDateFieldControl
3245 // ----------------------------------------------------
3246 UnoDateFieldControl::UnoDateFieldControl()
3247 :UnoSpinFieldControl()
3249 mnFirst
= util::Date( 1, 1, 1900 );
3250 mnLast
= util::Date( 31, 12, 2200 );
3254 OUString
UnoDateFieldControl::GetComponentServiceName()
3256 return OUString("datefield");
3260 uno::Any
UnoDateFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3262 uno::Any aRet
= ::cppu::queryInterface( rType
,
3263 (static_cast< awt::XDateField
* >(this)) );
3264 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3267 // lang::XTypeProvider
3268 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl
)
3269 getCppuType( ( uno::Reference
< awt::XDateField
>* ) NULL
),
3270 UnoSpinFieldControl::getTypes()
3271 IMPL_XTYPEPROVIDER_END
3273 void UnoDateFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3275 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3277 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3278 xField
->setFirst( mnFirst
);
3279 xField
->setLast( mnLast
);
3280 if ( mbLongFormat
!= 2 ) // not set
3281 xField
->setLongFormat( mbLongFormat
);
3285 void UnoDateFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3287 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3289 // also change the text property (#i25106#)
3292 OUString sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3293 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), sal_False
);
3296 // re-calc the Date property
3297 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3299 if ( xField
->isEmpty() )
3301 // the field says it's empty
3302 sal_Bool bEnforceFormat
= sal_True
;
3304 xPeer
->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT
) ) >>= bEnforceFormat
;
3305 if ( !bEnforceFormat
)
3307 // and it also says that it is currently accepting invalid inputs, without
3308 // forcing it to a valid date
3309 uno::Reference
< awt::XTextComponent
> xText( xPeer
, uno::UNO_QUERY
);
3310 if ( xText
.is() && xText
->getText().getLength() )
3311 // and in real, the text of the peer is *not* empty
3312 // -> simulate an invalid date, which is different from "no date"
3313 aValue
<<= util::Date();
3317 aValue
<<= xField
->getDate();
3319 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aValue
, sal_False
);
3321 // multiplex the event
3322 if ( GetTextListeners().getLength() )
3323 GetTextListeners().textChanged( e
);
3326 void UnoDateFieldControl::setDate( const util::Date
& Date
) throw(uno::RuntimeException
)
3330 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE
), aAny
, sal_True
);
3333 util::Date
UnoDateFieldControl::getDate() throw(uno::RuntimeException
)
3335 return ImplGetPropertyValue_Date( BASEPROPERTY_DATE
);
3338 void UnoDateFieldControl::setMin( const util::Date
& Date
) throw(uno::RuntimeException
)
3342 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN
), aAny
, sal_True
);
3345 util::Date
UnoDateFieldControl::getMin() throw(uno::RuntimeException
)
3347 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMIN
);
3350 void UnoDateFieldControl::setMax( const util::Date
& Date
) throw(uno::RuntimeException
)
3354 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX
), aAny
, sal_True
);
3357 util::Date
UnoDateFieldControl::getMax() throw(uno::RuntimeException
)
3359 return ImplGetPropertyValue_Date( BASEPROPERTY_DATEMAX
);
3362 void UnoDateFieldControl::setFirst( const util::Date
& Date
) throw(uno::RuntimeException
)
3365 if ( getPeer().is() )
3367 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3368 xField
->setFirst( Date
);
3372 util::Date
UnoDateFieldControl::getFirst() throw(uno::RuntimeException
)
3377 void UnoDateFieldControl::setLast( const util::Date
& Date
) throw(uno::RuntimeException
)
3380 if ( getPeer().is() )
3382 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3383 xField
->setLast( Date
);
3387 util::Date
UnoDateFieldControl::getLast() throw(uno::RuntimeException
)
3392 void UnoDateFieldControl::setLongFormat( sal_Bool bLong
) throw(uno::RuntimeException
)
3394 mbLongFormat
= bLong
;
3395 if ( getPeer().is() )
3397 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3398 xField
->setLongFormat( bLong
);
3402 sal_Bool
UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException
)
3404 return ( mbLongFormat
!= 2 ) ? mbLongFormat
: sal_False
;
3407 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException
)
3409 if ( getPeer().is() )
3411 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3416 sal_Bool
UnoDateFieldControl::isEmpty() throw(uno::RuntimeException
)
3418 sal_Bool bEmpty
= sal_False
;
3419 if ( getPeer().is() )
3421 uno::Reference
< awt::XDateField
> xField( getPeer(), uno::UNO_QUERY
);
3422 bEmpty
= xField
->isEmpty();
3427 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3431 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3434 sal_Bool
UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3436 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3439 // ----------------------------------------------------
3440 // class UnoControlTimeFieldModel
3441 // ----------------------------------------------------
3442 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference
< XComponentContext
>& rxContext
)
3443 :UnoControlModel( rxContext
)
3445 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField
);
3448 OUString
UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3450 return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel
);
3453 uno::Any
UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3455 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3458 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlTimeField
);
3461 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3465 ::cppu::IPropertyArrayHelper
& UnoControlTimeFieldModel::getInfoHelper()
3467 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3470 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3471 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3476 // beans::XMultiPropertySet
3477 uno::Reference
< beans::XPropertySetInfo
> UnoControlTimeFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3479 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3485 // ----------------------------------------------------
3486 // class UnoTimeFieldControl
3487 // ----------------------------------------------------
3488 UnoTimeFieldControl::UnoTimeFieldControl()
3489 :UnoSpinFieldControl()
3491 mnFirst
= util::Time( 0, 0, 0, 0, false );
3492 mnLast
= util::Time( 999999999, 59, 59, 23, false );
3495 OUString
UnoTimeFieldControl::GetComponentServiceName()
3497 return OUString("timefield");
3501 uno::Any
UnoTimeFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3503 uno::Any aRet
= ::cppu::queryInterface( rType
,
3504 (static_cast< awt::XTimeField
* >(this)) );
3505 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3508 // lang::XTypeProvider
3509 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl
)
3510 getCppuType( ( uno::Reference
< awt::XTimeField
>* ) NULL
),
3511 UnoSpinFieldControl::getTypes()
3512 IMPL_XTYPEPROVIDER_END
3514 void UnoTimeFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3516 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3518 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3519 xField
->setFirst( mnFirst
);
3520 xField
->setLast( mnLast
);
3523 void UnoTimeFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3525 // also change the text property (#i25106#)
3526 uno::Reference
< awt::XVclWindowPeer
> xPeer( getPeer(), uno::UNO_QUERY
);
3527 OUString sTextPropertyName
= GetPropertyName( BASEPROPERTY_TEXT
);
3528 ImplSetPropertyValue( sTextPropertyName
, xPeer
->getProperty( sTextPropertyName
), sal_False
);
3530 // re-calc the Time property
3531 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3533 if ( !xField
->isEmpty() )
3534 aValue
<<= xField
->getTime();
3535 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aValue
, sal_False
);
3537 // multiplex the event
3538 if ( GetTextListeners().getLength() )
3539 GetTextListeners().textChanged( e
);
3542 void UnoTimeFieldControl::setTime( const util::Time
& Time
) throw(uno::RuntimeException
)
3546 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME
), aAny
, sal_True
);
3549 util::Time
UnoTimeFieldControl::getTime() throw(uno::RuntimeException
)
3551 return ImplGetPropertyValue_Time( BASEPROPERTY_TIME
);
3554 void UnoTimeFieldControl::setMin( const util::Time
& Time
) throw(uno::RuntimeException
)
3558 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN
), aAny
, sal_True
);
3561 util::Time
UnoTimeFieldControl::getMin() throw(uno::RuntimeException
)
3563 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMIN
);
3566 void UnoTimeFieldControl::setMax( const util::Time
& Time
) throw(uno::RuntimeException
)
3570 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX
), aAny
, sal_True
);
3573 util::Time
UnoTimeFieldControl::getMax() throw(uno::RuntimeException
)
3575 return ImplGetPropertyValue_Time( BASEPROPERTY_TIMEMAX
);
3578 void UnoTimeFieldControl::setFirst( const util::Time
& Time
) throw(uno::RuntimeException
)
3581 if ( getPeer().is() )
3583 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3584 xField
->setFirst( mnFirst
);
3588 util::Time
UnoTimeFieldControl::getFirst() throw(uno::RuntimeException
)
3593 void UnoTimeFieldControl::setLast( const util::Time
& Time
) throw(uno::RuntimeException
)
3596 if ( getPeer().is() )
3598 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3599 xField
->setFirst( mnLast
);
3603 util::Time
UnoTimeFieldControl::getLast() throw(uno::RuntimeException
)
3608 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException
)
3610 if ( getPeer().is() )
3612 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3617 sal_Bool
UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException
)
3619 sal_Bool bEmpty
= sal_False
;
3620 if ( getPeer().is() )
3622 uno::Reference
< awt::XTimeField
> xField( getPeer(), uno::UNO_QUERY
);
3623 bEmpty
= xField
->isEmpty();
3628 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3632 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3635 sal_Bool
UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3637 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3640 // ----------------------------------------------------
3641 // class UnoControlNumericFieldModel
3642 // ----------------------------------------------------
3643 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference
< XComponentContext
>& rxContext
)
3644 :UnoControlModel( rxContext
)
3646 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField
);
3649 OUString
UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3651 return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel
);
3654 uno::Any
UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3656 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3659 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlNumericField
);
3662 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3666 ::cppu::IPropertyArrayHelper
& UnoControlNumericFieldModel::getInfoHelper()
3668 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3671 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3672 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3677 // beans::XMultiPropertySet
3678 uno::Reference
< beans::XPropertySetInfo
> UnoControlNumericFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3680 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3686 // ----------------------------------------------------
3687 // class UnoNumericFieldControl
3688 // ----------------------------------------------------
3689 UnoNumericFieldControl::UnoNumericFieldControl()
3690 :UnoSpinFieldControl()
3693 mnLast
= 0x7FFFFFFF;
3696 OUString
UnoNumericFieldControl::GetComponentServiceName()
3698 return OUString("numericfield");
3702 uno::Any
UnoNumericFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3704 uno::Any aRet
= ::cppu::queryInterface( rType
,
3705 (static_cast< awt::XNumericField
* >(this)) );
3706 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3709 // lang::XTypeProvider
3710 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl
)
3711 getCppuType( ( uno::Reference
< awt::XNumericField
>* ) NULL
),
3712 UnoSpinFieldControl::getTypes()
3713 IMPL_XTYPEPROVIDER_END
3715 void UnoNumericFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3717 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3719 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3720 xField
->setFirst( mnFirst
);
3721 xField
->setLast( mnLast
);
3725 void UnoNumericFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3727 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3729 aAny
<<= xField
->getValue();
3730 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_False
);
3732 if ( GetTextListeners().getLength() )
3733 GetTextListeners().textChanged( e
);
3736 void UnoNumericFieldControl::setValue( double Value
) throw(uno::RuntimeException
)
3740 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_True
);
3743 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException
)
3745 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
3748 void UnoNumericFieldControl::setMin( double Value
) throw(uno::RuntimeException
)
3752 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), aAny
, sal_True
);
3755 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException
)
3757 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
3760 void UnoNumericFieldControl::setMax( double Value
) throw(uno::RuntimeException
)
3764 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), aAny
, sal_True
);
3767 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException
)
3769 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
3772 void UnoNumericFieldControl::setFirst( double Value
) throw(uno::RuntimeException
)
3775 if ( getPeer().is() )
3777 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3778 xField
->setFirst( mnFirst
);
3782 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException
)
3787 void UnoNumericFieldControl::setLast( double Value
) throw(uno::RuntimeException
)
3790 if ( getPeer().is() )
3792 uno::Reference
< awt::XNumericField
> xField( getPeer(), uno::UNO_QUERY
);
3793 xField
->setLast( mnLast
);
3797 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException
)
3802 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
3806 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
3809 sal_Bool
UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException
)
3811 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
3814 void UnoNumericFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
)
3818 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), aAny
, sal_True
);
3821 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException
)
3823 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
3826 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
)
3830 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), aAny
, sal_True
);
3833 sal_Int16
UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException
)
3835 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
3838 // ----------------------------------------------------
3839 // class UnoControlCurrencyFieldModel
3840 // ----------------------------------------------------
3841 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference
< XComponentContext
>& rxContext
)
3842 :UnoControlModel( rxContext
)
3844 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField
);
3847 OUString
UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
3849 return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel
);
3852 uno::Any
UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
3854 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
3857 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlCurrencyField
);
3860 if ( nPropId
== BASEPROPERTY_CURSYM_POSITION
)
3863 aAny
<<= (sal_Bool
)sal_False
;
3867 return UnoControlModel::ImplGetDefaultValue( nPropId
);
3870 ::cppu::IPropertyArrayHelper
& UnoControlCurrencyFieldModel::getInfoHelper()
3872 static UnoPropertyArrayHelper
* pHelper
= NULL
;
3875 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
3876 pHelper
= new UnoPropertyArrayHelper( aIDs
);
3881 // beans::XMultiPropertySet
3882 uno::Reference
< beans::XPropertySetInfo
> UnoControlCurrencyFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
3884 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3888 // ----------------------------------------------------
3889 // class UnoCurrencyFieldControl
3890 // ----------------------------------------------------
3891 UnoCurrencyFieldControl::UnoCurrencyFieldControl()
3892 :UnoSpinFieldControl()
3895 mnLast
= 0x7FFFFFFF;
3898 OUString
UnoCurrencyFieldControl::GetComponentServiceName()
3900 return OUString("longcurrencyfield");
3904 uno::Any
UnoCurrencyFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
3906 uno::Any aRet
= ::cppu::queryInterface( rType
,
3907 (static_cast< awt::XCurrencyField
* >(this)) );
3908 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
3911 // lang::XTypeProvider
3912 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl
)
3913 getCppuType( ( uno::Reference
< awt::XCurrencyField
>* ) NULL
),
3914 UnoSpinFieldControl::getTypes()
3915 IMPL_XTYPEPROVIDER_END
3917 void UnoCurrencyFieldControl::createPeer( const uno::Reference
< awt::XToolkit
> & rxToolkit
, const uno::Reference
< awt::XWindowPeer
> & rParentPeer
) throw(uno::RuntimeException
)
3919 UnoSpinFieldControl::createPeer( rxToolkit
, rParentPeer
);
3921 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3922 xField
->setFirst( mnFirst
);
3923 xField
->setLast( mnLast
);
3926 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent
& e
) throw(uno::RuntimeException
)
3928 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3930 aAny
<<= xField
->getValue();
3931 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_False
);
3933 if ( GetTextListeners().getLength() )
3934 GetTextListeners().textChanged( e
);
3937 void UnoCurrencyFieldControl::setValue( double Value
) throw(uno::RuntimeException
)
3941 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE
), aAny
, sal_True
);
3944 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException
)
3946 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE
);
3949 void UnoCurrencyFieldControl::setMin( double Value
) throw(uno::RuntimeException
)
3953 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE
), aAny
, sal_True
);
3956 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException
)
3958 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE
);
3961 void UnoCurrencyFieldControl::setMax( double Value
) throw(uno::RuntimeException
)
3965 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE
), aAny
, sal_True
);
3968 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException
)
3970 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE
);
3973 void UnoCurrencyFieldControl::setFirst( double Value
) throw(uno::RuntimeException
)
3976 if ( getPeer().is() )
3978 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3979 xField
->setFirst( mnFirst
);
3983 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException
)
3988 void UnoCurrencyFieldControl::setLast( double Value
) throw(uno::RuntimeException
)
3991 if ( getPeer().is() )
3993 uno::Reference
< awt::XCurrencyField
> xField( getPeer(), uno::UNO_QUERY
);
3994 xField
->setLast( mnLast
);
3998 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException
)
4003 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
4007 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
4010 sal_Bool
UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException
)
4012 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4015 void UnoCurrencyFieldControl::setSpinSize( double Digits
) throw(uno::RuntimeException
)
4019 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE
), aAny
, sal_True
);
4022 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException
)
4024 return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE
);
4027 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits
) throw(uno::RuntimeException
)
4031 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY
), aAny
, sal_True
);
4034 sal_Int16
UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException
)
4036 return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY
);
4039 // ----------------------------------------------------
4040 // class UnoControlPatternFieldModel
4041 // ----------------------------------------------------
4042 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference
< XComponentContext
>& rxContext
)
4043 :UnoControlModel( rxContext
)
4045 UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField
);
4048 OUString
UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException
)
4050 return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel
);
4053 uno::Any
UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4055 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4058 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlPatternField
);
4061 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4064 ::cppu::IPropertyArrayHelper
& UnoControlPatternFieldModel::getInfoHelper()
4066 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4069 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4070 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4075 // beans::XMultiPropertySet
4076 uno::Reference
< beans::XPropertySetInfo
> UnoControlPatternFieldModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4078 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4083 // ----------------------------------------------------
4084 // class UnoPatternFieldControl
4085 // ----------------------------------------------------
4086 UnoPatternFieldControl::UnoPatternFieldControl()
4087 :UnoSpinFieldControl()
4091 OUString
UnoPatternFieldControl::GetComponentServiceName()
4093 return OUString("patternfield");
4096 void UnoPatternFieldControl::ImplSetPeerProperty( const OUString
& rPropName
, const uno::Any
& rVal
)
4098 sal_uInt16 nType
= GetPropertyId( rPropName
);
4099 if ( ( nType
== BASEPROPERTY_TEXT
) || ( nType
== BASEPROPERTY_EDITMASK
) || ( nType
== BASEPROPERTY_LITERALMASK
) )
4101 // These masks cannot be set consecutively
4102 OUString Text
= ImplGetPropertyValue_UString( BASEPROPERTY_TEXT
);
4103 OUString EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4104 OUString LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4106 uno::Reference
< awt::XPatternField
> xPF( getPeer(), uno::UNO_QUERY
);
4109 // same comment as in UnoControl::ImplSetPeerProperty - see there
4110 OUString
sText( Text
);
4111 ImplCheckLocalize( sText
);
4112 xPF
->setString( sText
);
4113 xPF
->setMasks( EditMask
, LiteralMask
);
4117 UnoSpinFieldControl::ImplSetPeerProperty( rPropName
, rVal
);
4122 uno::Any
UnoPatternFieldControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
4124 uno::Any aRet
= ::cppu::queryInterface( rType
,
4125 (static_cast< awt::XPatternField
* >(this)) );
4126 return (aRet
.hasValue() ? aRet
: UnoSpinFieldControl::queryAggregation( rType
));
4129 // lang::XTypeProvider
4130 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl
)
4131 getCppuType( ( uno::Reference
< awt::XPatternField
>* ) NULL
),
4132 UnoSpinFieldControl::getTypes()
4133 IMPL_XTYPEPROVIDER_END
4135 void UnoPatternFieldControl::setString( const OUString
& rString
) throw(uno::RuntimeException
)
4140 OUString
UnoPatternFieldControl::getString() throw(uno::RuntimeException
)
4145 void UnoPatternFieldControl::setMasks( const OUString
& EditMask
, const OUString
& LiteralMask
) throw(uno::RuntimeException
)
4149 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK
), aAny
, sal_True
);
4150 aAny
<<= LiteralMask
;
4151 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK
), aAny
, sal_True
);
4154 void UnoPatternFieldControl::getMasks( OUString
& EditMask
, OUString
& LiteralMask
) throw(uno::RuntimeException
)
4156 EditMask
= ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK
);
4157 LiteralMask
= ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK
);
4160 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict
) throw(uno::RuntimeException
)
4164 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT
), aAny
, sal_True
);
4167 sal_Bool
UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException
)
4169 return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT
);
4173 // ----------------------------------------------------
4174 // class UnoControlProgressBarModel
4175 // ----------------------------------------------------
4176 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference
< XComponentContext
>& rxContext
)
4177 :UnoControlModel( rxContext
)
4179 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4180 ImplRegisterProperty( BASEPROPERTY_BORDER
);
4181 ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR
);
4182 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4183 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4184 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4185 ImplRegisterProperty( BASEPROPERTY_FILLCOLOR
);
4186 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4187 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4188 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4189 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE
);
4190 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX
);
4191 ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN
);
4194 OUString
UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
4196 return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel
);
4199 uno::Any
UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4201 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4204 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlProgressBar
);
4208 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4211 ::cppu::IPropertyArrayHelper
& UnoControlProgressBarModel::getInfoHelper()
4213 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4216 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4217 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4222 // beans::XMultiPropertySet
4223 uno::Reference
< beans::XPropertySetInfo
> UnoControlProgressBarModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4225 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4230 // ----------------------------------------------------
4231 // class UnoProgressBarControl
4232 // ----------------------------------------------------
4233 UnoProgressBarControl::UnoProgressBarControl()
4238 OUString
UnoProgressBarControl::GetComponentServiceName()
4240 return OUString("ProgressBar");
4244 uno::Any
UnoProgressBarControl::queryAggregation( const uno::Type
& rType
) throw(uno::RuntimeException
)
4246 uno::Any aRet
= ::cppu::queryInterface( rType
,
4247 (static_cast< awt::XProgressBar
* >(this)) );
4248 return (aRet
.hasValue() ? aRet
: UnoControlBase::queryAggregation( rType
));
4251 // lang::XTypeProvider
4252 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl
)
4253 getCppuType( ( uno::Reference
< awt::XProgressBar
>* ) NULL
),
4254 UnoControlBase::getTypes()
4255 IMPL_XTYPEPROVIDER_END
4257 // ::com::sun::star::awt::XProgressBar
4258 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
)
4262 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR
), aAny
, sal_True
);
4265 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
)
4269 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR
), aAny
, sal_True
);
4272 void UnoProgressBarControl::setValue( sal_Int32 nValue
) throw(::com::sun::star::uno::RuntimeException
)
4276 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE
), aAny
, sal_True
);
4279 void UnoProgressBarControl::setRange( sal_Int32 nMin
, sal_Int32 nMax
) throw(::com::sun::star::uno::RuntimeException
)
4286 // take correct min and max
4292 // change min and max
4297 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN
), aMin
, sal_True
);
4298 ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX
), aMax
, sal_True
);
4301 sal_Int32
UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException
)
4303 return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE
);
4307 // ----------------------------------------------------
4308 // class UnoControlFixedLineModel
4309 // ----------------------------------------------------
4310 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference
< XComponentContext
>& rxContext
)
4311 :UnoControlModel( rxContext
)
4313 ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR
);
4314 ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL
);
4315 ImplRegisterProperty( BASEPROPERTY_ENABLED
);
4316 ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE
);
4317 ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR
);
4318 ImplRegisterProperty( BASEPROPERTY_HELPTEXT
);
4319 ImplRegisterProperty( BASEPROPERTY_HELPURL
);
4320 ImplRegisterProperty( BASEPROPERTY_LABEL
);
4321 ImplRegisterProperty( BASEPROPERTY_ORIENTATION
);
4322 ImplRegisterProperty( BASEPROPERTY_PRINTABLE
);
4325 OUString
UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException
)
4327 return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel
);
4330 uno::Any
UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId
) const
4332 if ( nPropId
== BASEPROPERTY_DEFAULTCONTROL
)
4335 aAny
<<= OUString::createFromAscii( szServiceName_UnoControlFixedLine
);
4338 return UnoControlModel::ImplGetDefaultValue( nPropId
);
4341 ::cppu::IPropertyArrayHelper
& UnoControlFixedLineModel::getInfoHelper()
4343 static UnoPropertyArrayHelper
* pHelper
= NULL
;
4346 uno::Sequence
<sal_Int32
> aIDs
= ImplGetPropertyIds();
4347 pHelper
= new UnoPropertyArrayHelper( aIDs
);
4352 // beans::XMultiPropertySet
4353 uno::Reference
< beans::XPropertySetInfo
> UnoControlFixedLineModel::getPropertySetInfo( ) throw(uno::RuntimeException
)
4355 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
4359 // ----------------------------------------------------
4360 // class UnoFixedLineControl
4361 // ----------------------------------------------------
4362 UnoFixedLineControl::UnoFixedLineControl()
4365 maComponentInfos
.nWidth
= 100; // ??
4366 maComponentInfos
.nHeight
= 100; // ??
4369 OUString
UnoFixedLineControl::GetComponentServiceName()
4371 return OUString("FixedLine");
4374 sal_Bool
UnoFixedLineControl::isTransparent() throw(uno::RuntimeException
)
4379 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */