1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_toolkit.hxx"
26 #include <com/sun/star/awt/XTextArea.hpp>
27 #include <com/sun/star/awt/XVclWindowPeer.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/awt/PosSize.hpp>
30 #include <com/sun/star/awt/VisualEffect.hpp>
31 #include <com/sun/star/awt/LineEndFormat.hpp>
32 #include <com/sun/star/graphic/XGraphicProvider.hpp>
33 #include <com/sun/star/graphic/GraphicObject.hpp>
34 #include <com/sun/star/util/Date.hpp>
35 #include <com/sun/star/awt/ImageScaleMode.hpp>
36 
37 
38 #include <toolkit/controls/formattedcontrol.hxx>
39 #include <toolkit/controls/roadmapcontrol.hxx>
40 #include <toolkit/controls/unocontrols.hxx>
41 #include <toolkit/controls/stdtabcontroller.hxx>
42 #include <toolkit/helper/property.hxx>
43 #include <toolkit/helper/unopropertyarrayhelper.hxx>
44 #include <toolkit/helper/unomemorystream.hxx>
45 #include <toolkit/helper/servicenames.hxx>
46 #include <toolkit/helper/macros.hxx>
47 #include <toolkit/helper/imagealign.hxx>
48 
49 // for introspection
50 #include <toolkit/awt/vclxwindows.hxx>
51 #include <cppuhelper/typeprovider.hxx>
52 #include <comphelper/componentcontext.hxx>
53 #include <comphelper/processfactory.hxx>
54 #include <comphelper/extract.hxx>
55 #include <vcl/wrkwin.hxx>
56 #include <vcl/svapp.hxx>
57 #include <vcl/edit.hxx>
58 #ifndef _SV_BUTTON_HXX
59 #include <vcl/button.hxx>
60 #endif
61 #include <vcl/group.hxx>
62 #include <vcl/fixed.hxx>
63 #include <vcl/lstbox.hxx>
64 #include <vcl/combobox.hxx>
65 #include <tools/debug.hxx>
66 #include <tools/diagnose_ex.h>
67 #include <tools/date.hxx>
68 #include <tools/time.hxx>
69 
70 #include <algorithm>
71 #include <functional>
72 
73 using namespace ::com::sun::star;
74 using ::com::sun::star::graphic::XGraphic;
75 using ::com::sun::star::uno::Reference;
76 using namespace ::toolkit;
77 
78 #define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \
79     ::rtl::OUString SAL_CALL ImplName::getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException) { return ::rtl::OUString::createFromAscii( "stardiv.Toolkit." #ImplName ); } \
80     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)	\
81 							{ \
82 								::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = BaseClass::getSupportedServiceNames( ); \
83 								aNames.realloc( aNames.getLength() + 1 ); \
84 								aNames[ aNames.getLength() - 1 ] = ::rtl::OUString::createFromAscii( ServiceName ); \
85 								return aNames; \
86 							} \
87 
88 
89 
90 //	----------------------------------------------------
91 //	class UnoControlEditModel
92 //	----------------------------------------------------
UnoControlEditModel(const Reference<XMultiServiceFactory> & i_factory)93 UnoControlEditModel::UnoControlEditModel( const Reference< XMultiServiceFactory >& i_factory )
94     :UnoControlModel( i_factory )
95 {
96     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit );
97 }
98 
getServiceName()99 ::rtl::OUString UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
100 {
101 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlEditModel );
102 }
103 
ImplGetDefaultValue(sal_uInt16 nPropId) const104 uno::Any UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
105 {
106     uno::Any aReturn;
107 
108     switch ( nPropId )
109     {
110     case BASEPROPERTY_LINE_END_FORMAT:
111         aReturn <<= (sal_Int16)awt::LineEndFormat::LINE_FEED;   // LF
112         break;
113     case BASEPROPERTY_DEFAULTCONTROL:
114         aReturn <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlEdit );
115         break;
116     default:
117         aReturn = UnoControlModel::ImplGetDefaultValue( nPropId );
118         break;
119     }
120 	return aReturn;
121 }
122 
getInfoHelper()123 ::cppu::IPropertyArrayHelper& UnoControlEditModel::getInfoHelper()
124 {
125 	static UnoPropertyArrayHelper* pHelper = NULL;
126 	if ( !pHelper )
127 	{
128 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
129 		pHelper = new UnoPropertyArrayHelper( aIDs );
130 	}
131 	return *pHelper;
132 }
133 
134 // beans::XMultiPropertySet
getPropertySetInfo()135 uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
136 {
137 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
138 	return xInfo;
139 }
140 
141 
142 //	----------------------------------------------------
143 //	class UnoEditControl
144 //	----------------------------------------------------
UnoEditControl(const Reference<XMultiServiceFactory> & i_factory)145 UnoEditControl::UnoEditControl( const Reference< XMultiServiceFactory >& i_factory )
146 	:UnoControlBase( i_factory )
147     ,maTextListeners( *this )
148 	,mnMaxTextLen( 0 )
149 	,mbSetTextInPeer( sal_False )
150 	,mbSetMaxTextLenInPeer( sal_False )
151     ,mbHasTextProperty( sal_False )
152 {
153 	maComponentInfos.nWidth = 100;
154 	maComponentInfos.nHeight = 12;
155 	mnMaxTextLen = 0;
156 	mbSetMaxTextLenInPeer = sal_False;
157 }
158 
queryAggregation(const uno::Type & rType)159 uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
160 {
161     uno::Any aReturn = UnoControlBase::queryAggregation( rType );
162     if ( !aReturn.hasValue() )
163         aReturn = UnoEditControl_Base::queryInterface( rType );
164     return aReturn;
165 }
166 
queryInterface(const uno::Type & rType)167 uno::Any SAL_CALL UnoEditControl::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
168 {
169     return UnoControlBase::queryInterface( rType );
170 }
171 
acquire()172 void SAL_CALL UnoEditControl::acquire(  ) throw ()
173 {
174     UnoControlBase::acquire();
175 }
176 
release()177 void SAL_CALL UnoEditControl::release(  ) throw ()
178 {
179     UnoControlBase::release();
180 }
181 
IMPLEMENT_FORWARD_XTYPEPROVIDER2(UnoEditControl,UnoControlBase,UnoEditControl_Base)182 IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl, UnoControlBase, UnoEditControl_Base )
183 
184 ::rtl::OUString UnoEditControl::GetComponentServiceName()
185 {
186     // by default, we want a simple edit field
187 	::rtl::OUString sName( ::rtl::OUString::createFromAscii( "Edit" ) );
188 
189     // but maybe we are to display multi-line text?
190 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE ) );
191 	sal_Bool b = sal_Bool();
192 	if ( ( aVal >>= b ) && b )
193 		sName= ::rtl::OUString::createFromAscii( "MultiLineEdit" );
194 
195 	return sName;
196 }
197 
setModel(const uno::Reference<awt::XControlModel> & _rModel)198 sal_Bool SAL_CALL UnoEditControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException )
199 {
200     sal_Bool bReturn = UnoControlBase::setModel( _rModel );
201     mbHasTextProperty = ImplHasProperty( BASEPROPERTY_TEXT );
202     return bReturn;
203 }
204 
ImplSetPeerProperty(const::rtl::OUString & rPropName,const uno::Any & rVal)205 void UnoEditControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
206 {
207     sal_Bool bDone = sal_False;
208     if ( GetPropertyId( rPropName ) == BASEPROPERTY_TEXT )
209 	{
210         // #96986# use setText(), or text listener will not be called.
211         uno::Reference < awt::XTextComponent > xTextComponent( getPeer(), uno::UNO_QUERY );
212         if ( xTextComponent.is() )
213         {
214             ::rtl::OUString sText;
215             rVal >>= sText;
216             ImplCheckLocalize( sText );
217             xTextComponent->setText( sText );
218             bDone = sal_True;
219         }
220 	}
221 
222     if ( !bDone )
223 		UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
224 }
225 
dispose()226 void UnoEditControl::dispose() throw(uno::RuntimeException)
227 {
228 	lang::EventObject aEvt( *this );
229 	maTextListeners.disposeAndClear( aEvt );
230 	UnoControl::dispose();
231 }
232 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)233 void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
234 {
235 	UnoControl::createPeer( rxToolkit, rParentPeer );
236 
237 	uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
238     if ( xText.is() )
239     {
240 	xText->addTextListener( this );
241 
242 	if ( mbSetMaxTextLenInPeer )
243 		xText->setMaxTextLen( mnMaxTextLen );
244 	if ( mbSetTextInPeer )
245 		xText->setText( maText );
246     }
247 }
248 
textChanged(const awt::TextEvent & e)249 void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException)
250 {
251 	uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
252 
253 	if ( mbHasTextProperty )
254 	{
255 		uno::Any aAny;
256 		aAny <<= xText->getText();
257 		ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_False );
258 	}
259 	else
260 	{
261 		maText = xText->getText();
262 	}
263 
264 	if ( maTextListeners.getLength() )
265 		maTextListeners.textChanged( e );
266 }
267 
addTextListener(const uno::Reference<awt::XTextListener> & l)268 void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
269 {
270 	maTextListeners.addInterface( l );
271 }
272 
removeTextListener(const uno::Reference<awt::XTextListener> & l)273 void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
274 {
275 	maTextListeners.removeInterface( l );
276 }
277 
setText(const::rtl::OUString & aText)278 void UnoEditControl::setText( const ::rtl::OUString& aText ) throw(uno::RuntimeException)
279 {
280 	if ( mbHasTextProperty )
281 	{
282 		uno::Any aAny;
283 		aAny <<= aText;
284 		ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_True );
285 	}
286 	else
287 	{
288 		maText = aText;
289 		mbSetTextInPeer = sal_True;
290 			uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
291 		if ( xText.is() )
292 			xText->setText( maText );
293 		}
294 
295     // Setting the property to the VCLXWindow doesn't call textChanged
296     if ( maTextListeners.getLength() )
297     {
298         awt::TextEvent aEvent;
299         aEvent.Source = *this;
300 		maTextListeners.textChanged( aEvent );
301     }
302 }
303 
304 namespace
305 {
lcl_normalize(awt::Selection & _rSel)306     static void lcl_normalize( awt::Selection& _rSel )
307     {
308         if ( _rSel.Min > _rSel.Max )
309             ::std::swap( _rSel.Min, _rSel.Max );
310     }
311 
312 /*
313     static bool lcl_intersect( const awt::Selection& _rLHS, const awt::Selection& _rRHS )
314     {
315         OSL_PRECOND( _rLHS.Min <= _rLHS.Max, "lcl_intersect: LHS to be normalized!" );
316         OSL_PRECOND( _rRHS.Min <= _rRHS.Max, "lcl_intersect: RHS to be normalized!" );
317         return !( ( _rLHS.Max < _rRHS.Min ) || ( _rLHS.Min > _rRHS.Max ) );
318     }
319 */
320 }
321 
insertText(const awt::Selection & rSel,const::rtl::OUString & rNewText)322 void UnoEditControl::insertText( const awt::Selection& rSel, const ::rtl::OUString& rNewText ) throw(uno::RuntimeException)
323 {
324     // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
325     awt::Selection aSelection( rSel );
326     lcl_normalize( aSelection );
327 
328     // preserve the selection resp. cursor position
329     awt::Selection aNewSelection( getSelection() );
330 #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
331         // (not sure - looks uglier ...)
332     sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength();
333     if ( aNewSelection.Min > aSelection.Min )
334         aNewSelection.Min -= nDeletedCharacters;
335     if ( aNewSelection.Max > aSelection.Max )
336         aNewSelection.Max -= nDeletedCharacters;
337 #else
338     aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength();
339     aNewSelection.Min = aNewSelection.Max;
340 #endif
341 
342     ::rtl::OUString aOldText = getText();
343     ::rtl::OUString  aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
344     setText( aNewText );
345 
346     setSelection( aNewSelection );
347 }
348 
getText()349 ::rtl::OUString UnoEditControl::getText() throw(uno::RuntimeException)
350 {
351 	::rtl::OUString aText = maText;
352 
353 	if ( mbHasTextProperty )
354 		aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
355     else
356     {
357 		uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
358         if ( xText.is() )
359             aText = xText->getText();
360     }
361 
362 	return aText;
363 }
364 
getSelectedText(void)365 ::rtl::OUString UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException)
366 {
367 	::rtl::OUString sSelected;
368 		uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
369 	if ( xText.is() )
370 		sSelected = xText->getSelectedText();
371 
372     return sSelected;
373 }
374 
setSelection(const awt::Selection & aSelection)375 void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException)
376 {
377 		uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
378 	if ( xText.is() )
379 		xText->setSelection( aSelection );
380 }
381 
getSelection(void)382 awt::Selection UnoEditControl::getSelection( void ) throw(uno::RuntimeException)
383 {
384 	awt::Selection aSel;
385 		uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
386 	if ( xText.is() )
387 		aSel = xText->getSelection();
388 	return aSel;
389 }
390 
isEditable(void)391 sal_Bool UnoEditControl::isEditable( void ) throw(uno::RuntimeException)
392 {
393 	return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY );
394 }
395 
setEditable(sal_Bool bEditable)396 void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException)
397 {
398 	uno::Any aAny;
399 	aAny <<= (sal_Bool)!bEditable;
400 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, sal_True );
401 }
402 
getMaxTextLen()403 sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException)
404 {
405 	sal_Int16 nMaxLen = mnMaxTextLen;
406 
407 	if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) )
408 		nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN );
409 
410 	return nMaxLen;
411 }
412 
setMaxTextLen(sal_Int16 nLen)413 void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException)
414 {
415 	if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) )
416 	{
417 		uno::Any aAny;
418 		aAny <<= (sal_Int16)nLen;
419 		ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, sal_True );
420 	}
421 	else
422 	{
423 		mnMaxTextLen = nLen;
424 		mbSetMaxTextLenInPeer = sal_True;
425 			uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
426 		if ( xText.is() )
427 			xText->setMaxTextLen( mnMaxTextLen );
428 	}
429 }
430 
getMinimumSize()431 awt::Size UnoEditControl::getMinimumSize(  ) throw(uno::RuntimeException)
432 {
433 	return Impl_getMinimumSize();
434 }
435 
getPreferredSize()436 awt::Size UnoEditControl::getPreferredSize(  ) throw(uno::RuntimeException)
437 {
438 	return Impl_getPreferredSize();
439 }
440 
calcAdjustedSize(const awt::Size & rNewSize)441 awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
442 {
443 	return Impl_calcAdjustedSize( rNewSize );
444 }
445 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)446 awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
447 {
448 	return Impl_getMinimumSize( nCols, nLines );
449 }
450 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)451 void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
452 {
453 	Impl_getColumnsAndLines( nCols, nLines );
454 }
455 
456 
457 //	----------------------------------------------------
458 //	class UnoControlFileControlModel
459 //	----------------------------------------------------
UnoControlFileControlModel(const Reference<XMultiServiceFactory> & i_factory)460 UnoControlFileControlModel::UnoControlFileControlModel( const Reference< XMultiServiceFactory >& i_factory )
461     :UnoControlModel( i_factory )
462 {
463 	ImplRegisterProperty( BASEPROPERTY_ALIGN );
464 	ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
465 	ImplRegisterProperty( BASEPROPERTY_BORDER );
466 	ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
467 	ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
468 	ImplRegisterProperty( BASEPROPERTY_ENABLED );
469 	ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
470 	ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
471 	ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
472 	ImplRegisterProperty( BASEPROPERTY_HELPURL );
473 	ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
474 	ImplRegisterProperty( BASEPROPERTY_READONLY );
475 	ImplRegisterProperty( BASEPROPERTY_TABSTOP );
476 	ImplRegisterProperty( BASEPROPERTY_TEXT );
477 	ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN );
478 	ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
479     ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
480 	ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
481 }
482 
getServiceName()483 ::rtl::OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
484 {
485 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControlModel );
486 }
487 
ImplGetDefaultValue(sal_uInt16 nPropId) const488 uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
489 {
490 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
491 	{
492 		uno::Any aAny;
493 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFileControl );
494 		return aAny;
495 	}
496 	return UnoControlModel::ImplGetDefaultValue( nPropId );
497 }
498 
getInfoHelper()499 ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper()
500 {
501 	static UnoPropertyArrayHelper* pHelper = NULL;
502 	if ( !pHelper )
503 	{
504 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
505 		pHelper = new UnoPropertyArrayHelper( aIDs );
506 	}
507 	return *pHelper;
508 }
509 
510 // beans::XMultiPropertySet
getPropertySetInfo()511 uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
512 {
513 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
514 	return xInfo;
515 }
516 
517 //	----------------------------------------------------
518 //	class UnoFileControl
519 //	----------------------------------------------------
UnoFileControl(const Reference<XMultiServiceFactory> & i_factory)520 UnoFileControl::UnoFileControl( const Reference< XMultiServiceFactory >& i_factory )
521 	:UnoEditControl( i_factory )
522 {
523 }
524 
GetComponentServiceName()525 ::rtl::OUString UnoFileControl::GetComponentServiceName()
526 {
527 	return ::rtl::OUString::createFromAscii( "filecontrol" );
528 }
529 
530 //	----------------------------------------------------
531 //	class GraphicControlModel
532 //	----------------------------------------------------
ImplGetDefaultValue(sal_uInt16 nPropId) const533 uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
534 {
535     if ( nPropId == BASEPROPERTY_GRAPHIC )
536         return uno::makeAny( uno::Reference< graphic::XGraphic >() );
537 
538     return UnoControlModel::ImplGetDefaultValue( nPropId );
539 }
getGraphicFromURL_nothrow(const::rtl::OUString & _rURL)540     uno::Reference< graphic::XGraphic > GraphicControlModel::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL )
541     {
542         uno::Reference< graphic::XGraphic > xGraphic;
543 
544         if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) )
545         {
546             // graphic manager uniqueid
547             rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
548             // get the DefaultContext
549             mxGrfObj = graphic::GraphicObject::createWithId( maContext.getUNOContext(), sID );
550         }
551         else // linked
552             mxGrfObj = NULL; // release the GraphicObject
553 
554         if ( !_rURL.getLength() )
555             return xGraphic;
556 
557         try
558         {
559             uno::Reference< graphic::XGraphicProvider > xProvider;
560             if ( maContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) )
561             {
562                 uno::Sequence< beans::PropertyValue > aMediaProperties(1);
563                 aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
564                 aMediaProperties[0].Value <<= _rURL;
565                 xGraphic = xProvider->queryGraphic( aMediaProperties );
566             }
567         }
568         catch( const Exception& )
569         {
570         	DBG_UNHANDLED_EXCEPTION();
571         }
572 
573         return xGraphic;
574     }
575 
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const::com::sun::star::uno::Any & rValue)576 void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
577 {
578     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
579 
580     // - ImageAlign and ImagePosition need to correspond to each other
581     // - Graphic and ImageURL need to correspond to each other
582     try
583     {
584         switch ( nHandle )
585         {
586         case BASEPROPERTY_IMAGEURL:
587             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
588             {
589                 mbAdjustingGraphic = true;
590                 ::rtl::OUString sImageURL;
591                 OSL_VERIFY( rValue >>= sImageURL );
592                 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( getGraphicFromURL_nothrow( sImageURL ) ) );
593                 mbAdjustingGraphic = false;
594             }
595             break;
596 
597         case BASEPROPERTY_GRAPHIC:
598             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
599             {
600                 mbAdjustingGraphic = true;
601                 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL, uno::makeAny( ::rtl::OUString() ) );
602                 mbAdjustingGraphic = false;
603             }
604             break;
605 
606         case BASEPROPERTY_IMAGEALIGN:
607             if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) )
608             {
609                 mbAdjustingImagePosition = true;
610                 sal_Int16 nUNOValue = 0;
611                 OSL_VERIFY( rValue >>= nUNOValue );
612                 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION, uno::makeAny( getExtendedImagePosition( nUNOValue ) ) );
613                 mbAdjustingImagePosition = false;
614             }
615             break;
616         case BASEPROPERTY_IMAGEPOSITION:
617             if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) )
618             {
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;
624             }
625             break;
626         }
627     }
628     catch( const ::com::sun::star::uno::Exception& )
629     {
630         OSL_ENSURE( sal_False, "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
631         mbAdjustingImagePosition = sal_False;
632     }
633 }
634 
635 //	----------------------------------------------------
636 //	class UnoControlButtonModel
637 //	----------------------------------------------------
UnoControlButtonModel(const Reference<XMultiServiceFactory> & i_factory)638 UnoControlButtonModel::UnoControlButtonModel( const Reference< XMultiServiceFactory >& i_factory )
639     :GraphicControlModel( i_factory )
640 {
641     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton );
642 
643     osl_incrementInterlockedCount( &m_refCount );
644     {
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
648     }
649     osl_decrementInterlockedCount( &m_refCount );
650 }
651 
getServiceName()652 ::rtl::OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
653 {
654 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlButtonModel );
655 }
656 
ImplGetDefaultValue(sal_uInt16 nPropId) const657 uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
658 {
659     switch ( nPropId )
660     {
661     case BASEPROPERTY_DEFAULTCONTROL:
662         return uno::makeAny( ::rtl::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 );
669     }
670 
671     return GraphicControlModel::ImplGetDefaultValue( nPropId );
672 }
673 
getInfoHelper()674 ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper()
675 {
676 	static UnoPropertyArrayHelper* pHelper = NULL;
677 	if ( !pHelper )
678 	{
679 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
680 		pHelper = new UnoPropertyArrayHelper( aIDs );
681 	}
682 	return *pHelper;
683 }
684 
685 // beans::XMultiPropertySet
getPropertySetInfo()686 uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
687 {
688 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
689 	return xInfo;
690 }
691 
692 //	----------------------------------------------------
693 //	class UnoButtonControl
694 //	----------------------------------------------------
UnoButtonControl(const uno::Reference<lang::XMultiServiceFactory> & i_factory)695 UnoButtonControl::UnoButtonControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
696 	:UnoButtonControl_Base( i_factory )
697     ,maActionListeners( *this )
698 	,maItemListeners( *this )
699 {
700 	maComponentInfos.nWidth = 50;
701 	maComponentInfos.nHeight = 14;
702 }
703 
GetComponentServiceName()704 ::rtl::OUString UnoButtonControl::GetComponentServiceName()
705 {
706 	::rtl::OUString aName( ::rtl::OUString::createFromAscii( "pushbutton" ) );
707 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) );
708 	sal_Int16 n = sal_Int16();
709 	if ( ( aVal >>= n ) && n )
710     {
711         // Use PushButtonType later when available...
712         switch ( n )
713         {
714             case 1 /*PushButtonType::OK*/:      aName= ::rtl::OUString::createFromAscii( "okbutton" );
715                                                 break;
716             case 2 /*PushButtonType::CANCEL*/:  aName= ::rtl::OUString::createFromAscii( "cancelbutton" );
717                                                 break;
718             case 3 /*PushButtonType::HELP*/:    aName= ::rtl::OUString::createFromAscii( "helpbutton" );
719                                                 break;
720             default:
721             {
722                 DBG_ERROR( "Unknown Button Type!" );
723             }
724 		}
725 	}
726 	return aName;
727 }
728 
dispose()729 void UnoButtonControl::dispose() throw(uno::RuntimeException)
730 {
731 	lang::EventObject aEvt;
732 	aEvt.Source = (::cppu::OWeakObject*)this;
733 	maActionListeners.disposeAndClear( aEvt );
734 	maItemListeners.disposeAndClear( aEvt );
735 	UnoControlBase::dispose();
736 }
737 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)738 void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
739 {
740 	UnoControlBase::createPeer( rxToolkit, rParentPeer );
741 
742     uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
743 	xButton->setActionCommand( maActionCommand );
744 	if ( maActionListeners.getLength() )
745 		xButton->addActionListener( &maActionListeners );
746 
747     uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY );
748     if ( xPushButton.is() )
749         xPushButton->addItemListener( this );
750 }
751 
addActionListener(const uno::Reference<awt::XActionListener> & l)752 void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
753 {
754 	maActionListeners.addInterface( l );
755 	if( getPeer().is() && maActionListeners.getLength() == 1 )
756 	{
757 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
758 		xButton->addActionListener( &maActionListeners );
759 	}
760 }
761 
removeActionListener(const uno::Reference<awt::XActionListener> & l)762 void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
763 {
764 	if( getPeer().is() && maActionListeners.getLength() == 1 )
765 	{
766 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
767 		xButton->removeActionListener( &maActionListeners );
768 	}
769 	maActionListeners.removeInterface( l );
770 }
771 
addItemListener(const uno::Reference<awt::XItemListener> & l)772 void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
773 {
774 	maItemListeners.addInterface( l );
775 }
776 
removeItemListener(const uno::Reference<awt::XItemListener> & l)777 void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
778 {
779 	maItemListeners.removeInterface( l );
780 }
781 
disposing(const lang::EventObject & Source)782 void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException)
783 {
784     UnoControlBase::disposing( Source );
785 }
786 
itemStateChanged(const awt::ItemEvent & rEvent)787 void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException)
788 {
789     // forward to model
790 	uno::Any aAny;
791 	aAny <<= (sal_Int16)rEvent.Selected;
792 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
793 
794     // multiplex
795     ItemEvent aEvent( rEvent );
796     aEvent.Source = *this;
797     maItemListeners.itemStateChanged( aEvent );
798 }
799 
setLabel(const::rtl::OUString & rLabel)800 void UnoButtonControl::setLabel( const ::rtl::OUString&  rLabel ) throw(uno::RuntimeException)
801 {
802 	uno::Any aAny;
803 	aAny <<= rLabel;
804 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
805 }
806 
setActionCommand(const::rtl::OUString & rCommand)807 void UnoButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
808 {
809 	maActionCommand = rCommand;
810 	if ( getPeer().is() )
811 	{
812 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
813 		xButton->setActionCommand( rCommand );
814 	}
815 }
816 
getMinimumSize()817 awt::Size UnoButtonControl::getMinimumSize(  ) throw(uno::RuntimeException)
818 {
819 	return Impl_getMinimumSize();
820 }
821 
getPreferredSize()822 awt::Size UnoButtonControl::getPreferredSize(  ) throw(uno::RuntimeException)
823 {
824 	return Impl_getPreferredSize();
825 }
826 
calcAdjustedSize(const awt::Size & rNewSize)827 awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
828 {
829 	return Impl_calcAdjustedSize( rNewSize );
830 }
831 
832 //	----------------------------------------------------
833 //	class UnoControlImageControlModel
834 //	----------------------------------------------------
UnoControlImageControlModel(const Reference<XMultiServiceFactory> & i_factory)835 UnoControlImageControlModel::UnoControlImageControlModel( const Reference< XMultiServiceFactory >& i_factory )
836     :GraphicControlModel( i_factory )
837     ,mbAdjustingImageScaleMode( false )
838 {
839     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl );
840 }
841 
getServiceName()842 ::rtl::OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
843 {
844 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControlModel );
845 }
846 
ImplGetDefaultValue(sal_uInt16 nPropId) const847 uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
848 {
849     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
850         return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl ) );
851 
852     if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE )
853         return makeAny( awt::ImageScaleMode::ANISOTROPIC );
854 
855 	return GraphicControlModel::ImplGetDefaultValue( nPropId );
856 }
857 
getInfoHelper()858 ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper()
859 {
860 	static UnoPropertyArrayHelper* pHelper = NULL;
861 	if ( !pHelper )
862 	{
863 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
864 		pHelper = new UnoPropertyArrayHelper( aIDs );
865 	}
866 	return *pHelper;
867 }
868 
869 // beans::XMultiPropertySet
getPropertySetInfo()870 uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
871 {
872 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
873 	return xInfo;
874 }
875 
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const::com::sun::star::uno::Any & _rValue)876 void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception)
877 {
878     GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
879 
880     // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
881     try
882     {
883         switch ( _nHandle )
884         {
885         case BASEPROPERTY_IMAGE_SCALE_MODE:
886             if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) )
887             {
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;
893             }
894             break;
895         case BASEPROPERTY_SCALEIMAGE:
896             if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) )
897             {
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;
903             }
904             break;
905         }
906     }
907     catch( const Exception& )
908     {
909         mbAdjustingImageScaleMode = false;
910         throw;
911     }
912 }
913 
914 //	----------------------------------------------------
915 //	class UnoImageControlControl
916 //	----------------------------------------------------
UnoImageControlControl(const Reference<XMultiServiceFactory> & i_factory)917 UnoImageControlControl::UnoImageControlControl( const Reference< XMultiServiceFactory >& i_factory )
918 	:UnoImageControlControl_Base( i_factory )
919     ,maActionListeners( *this )
920 {
921 	// Woher die Defaults nehmen?
922 	maComponentInfos.nWidth = 100;
923 	maComponentInfos.nHeight = 100;
924 }
925 
GetComponentServiceName()926 ::rtl::OUString UnoImageControlControl::GetComponentServiceName()
927 {
928 	return ::rtl::OUString::createFromAscii( "fixedimage" );
929 }
930 
dispose()931 void UnoImageControlControl::dispose() throw(uno::RuntimeException)
932 {
933 	lang::EventObject aEvt;
934 	aEvt.Source = (::cppu::OWeakObject*)this;
935 	maActionListeners.disposeAndClear( aEvt );
936 	UnoControl::dispose();
937 }
938 
isTransparent()939 sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException)
940 {
941 	return sal_True;
942 }
943 
getMinimumSize()944 awt::Size UnoImageControlControl::getMinimumSize(  ) throw(uno::RuntimeException)
945 {
946 	return Impl_getMinimumSize();
947 }
948 
getPreferredSize()949 awt::Size UnoImageControlControl::getPreferredSize(  ) throw(uno::RuntimeException)
950 {
951 	return Impl_getPreferredSize();
952 }
953 
calcAdjustedSize(const awt::Size & rNewSize)954 awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
955 {
956 	return Impl_calcAdjustedSize( rNewSize );
957 }
958 
959 //	----------------------------------------------------
960 //	class UnoControlRadioButtonModel
961 //	----------------------------------------------------
UnoControlRadioButtonModel(const Reference<XMultiServiceFactory> & i_factory)962 UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference< XMultiServiceFactory >& i_factory )
963     :GraphicControlModel( i_factory )
964 {
965     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton );
966 }
967 
getServiceName()968 ::rtl::OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
969 {
970 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel );
971 }
972 
ImplGetDefaultValue(sal_uInt16 nPropId) const973 uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
974 {
975     switch ( nPropId )
976     {
977     case BASEPROPERTY_DEFAULTCONTROL:
978         return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRadioButton ) );
979 
980     case BASEPROPERTY_VISUALEFFECT:
981         return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
982     }
983 
984     return GraphicControlModel::ImplGetDefaultValue( nPropId );
985 }
986 
getInfoHelper()987 ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper()
988 {
989 	static UnoPropertyArrayHelper* pHelper = NULL;
990 	if ( !pHelper )
991 	{
992 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
993 		pHelper = new UnoPropertyArrayHelper( aIDs );
994 	}
995 	return *pHelper;
996 }
997 
998 // beans::XMultiPropertySet
getPropertySetInfo()999 uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1000 {
1001 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1002 	return xInfo;
1003 }
1004 
1005 
1006 
1007 //	----------------------------------------------------
1008 //	class UnoRadioButtonControl
1009 //	----------------------------------------------------
UnoRadioButtonControl(const Reference<XMultiServiceFactory> & i_factory)1010 UnoRadioButtonControl::UnoRadioButtonControl( const Reference< XMultiServiceFactory >& i_factory )
1011 	:UnoRadioButtonControl_Base( i_factory )
1012     ,maItemListeners( *this )
1013     ,maActionListeners( *this )
1014 {
1015 	maComponentInfos.nWidth = 100;
1016 	maComponentInfos.nHeight = 12;
1017 }
1018 
GetComponentServiceName()1019 ::rtl::OUString UnoRadioButtonControl::GetComponentServiceName()
1020 {
1021 	return ::rtl::OUString::createFromAscii( "radiobutton" );
1022 }
1023 
dispose()1024 void UnoRadioButtonControl::dispose() throw(uno::RuntimeException)
1025 {
1026 	lang::EventObject aEvt;
1027 	aEvt.Source = (::cppu::OWeakObject*)this;
1028 	maItemListeners.disposeAndClear( aEvt );
1029 	UnoControlBase::dispose();
1030 }
1031 
1032 
isTransparent()1033 sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException)
1034 {
1035 	return sal_True;
1036 }
1037 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)1038 void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
1039 {
1040 	UnoControlBase::createPeer( rxToolkit, rParentPeer );
1041 
1042 	uno::Reference < awt::XRadioButton >  xRadioButton( getPeer(), uno::UNO_QUERY );
1043 	xRadioButton->addItemListener( this );
1044 
1045 	uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1046 	xButton->setActionCommand( maActionCommand );
1047 	if ( maActionListeners.getLength() )
1048 		xButton->addActionListener( &maActionListeners );
1049 
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 ) );
1056 }
1057 
addItemListener(const uno::Reference<awt::XItemListener> & l)1058 void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1059 {
1060 	maItemListeners.addInterface( l );
1061 }
1062 
removeItemListener(const uno::Reference<awt::XItemListener> & l)1063 void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1064 {
1065 	maItemListeners.removeInterface( l );
1066 }
1067 
addActionListener(const uno::Reference<awt::XActionListener> & l)1068 void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1069 {
1070 	maActionListeners.addInterface( l );
1071 	if( getPeer().is() && maActionListeners.getLength() == 1 )
1072 	{
1073 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
1074 		xButton->addActionListener( &maActionListeners );
1075 	}
1076 }
1077 
removeActionListener(const uno::Reference<awt::XActionListener> & l)1078 void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1079 {
1080 	if( getPeer().is() && maActionListeners.getLength() == 1 )
1081 	{
1082 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
1083 		xButton->removeActionListener( &maActionListeners );
1084 	}
1085 	maActionListeners.removeInterface( l );
1086 }
1087 
setLabel(const::rtl::OUString & rLabel)1088 void UnoRadioButtonControl::setLabel( const ::rtl::OUString&  rLabel ) throw(uno::RuntimeException)
1089 {
1090 	uno::Any aAny;
1091 	aAny <<= rLabel;
1092 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1093 }
1094 
setActionCommand(const::rtl::OUString & rCommand)1095 void UnoRadioButtonControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1096 {
1097 	maActionCommand = rCommand;
1098 	if ( getPeer().is() )
1099 	{
1100 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
1101 		xButton->setActionCommand( rCommand );
1102 	}
1103 }
1104 
setState(sal_Bool bOn)1105 void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException)
1106 {
1107 	sal_Int16 nState = bOn ? 1 : 0;
1108 	uno::Any aAny;
1109 	aAny <<= nState;
1110 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1111 }
1112 
getState()1113 sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException)
1114 {
1115 	sal_Int16 nState = 0;
1116 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1117 	aVal >>= nState;
1118 	return nState ? sal_True : sal_False;
1119 }
1120 
itemStateChanged(const awt::ItemEvent & rEvent)1121 void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1122 {
1123 	uno::Any aAny;
1124 	aAny <<= (sal_Int16)rEvent.Selected;
1125 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1126 
1127     // compatibility:
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
1130     // "0" to "1".
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.
1138     // #i14703# - 2003-05-23 - fs@openoffice.org
1139     if ( 1 == rEvent.Selected )
1140     {
1141     	if ( maItemListeners.getLength() )
1142 	    	maItemListeners.itemStateChanged( rEvent );
1143     }
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.
1147         //
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.
1152 }
1153 
getMinimumSize()1154 awt::Size UnoRadioButtonControl::getMinimumSize(  ) throw(uno::RuntimeException)
1155 {
1156 	return Impl_getMinimumSize();
1157 }
1158 
getPreferredSize()1159 awt::Size UnoRadioButtonControl::getPreferredSize(  ) throw(uno::RuntimeException)
1160 {
1161 	return Impl_getPreferredSize();
1162 }
1163 
calcAdjustedSize(const awt::Size & rNewSize)1164 awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1165 {
1166 	return Impl_calcAdjustedSize( rNewSize );
1167 }
1168 
1169 //	----------------------------------------------------
1170 //	class UnoControlCheckBoxModel
1171 //	----------------------------------------------------
UnoControlCheckBoxModel(const Reference<XMultiServiceFactory> & i_factory)1172 UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference< XMultiServiceFactory >& i_factory )
1173     :GraphicControlModel( i_factory )
1174 {
1175     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox );
1176 }
1177 
getServiceName()1178 ::rtl::OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1179 {
1180 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel );
1181 }
1182 
ImplGetDefaultValue(sal_uInt16 nPropId) const1183 uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1184 {
1185     switch ( nPropId )
1186     {
1187     case BASEPROPERTY_DEFAULTCONTROL:
1188         return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlCheckBox ) );
1189 
1190     case BASEPROPERTY_VISUALEFFECT:
1191         return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
1192     }
1193 
1194     return GraphicControlModel::ImplGetDefaultValue( nPropId );
1195 }
1196 
getInfoHelper()1197 ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper()
1198 {
1199 	static UnoPropertyArrayHelper* pHelper = NULL;
1200 	if ( !pHelper )
1201 	{
1202 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
1203 		pHelper = new UnoPropertyArrayHelper( aIDs );
1204 	}
1205 	return *pHelper;
1206 }
1207 
1208 // beans::XMultiPropertySet
getPropertySetInfo()1209 uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1210 {
1211 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1212 	return xInfo;
1213 }
1214 
1215 
1216 
1217 //	----------------------------------------------------
1218 //	class UnoCheckBoxControl
1219 //	----------------------------------------------------
UnoCheckBoxControl(const uno::Reference<lang::XMultiServiceFactory> & i_factory)1220 UnoCheckBoxControl::UnoCheckBoxControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory )
1221 	:UnoCheckBoxControl_Base( i_factory )
1222     ,maItemListeners( *this ), maActionListeners( *this )
1223 {
1224 	maComponentInfos.nWidth = 100;
1225 	maComponentInfos.nHeight = 12;
1226 }
1227 
GetComponentServiceName()1228 ::rtl::OUString UnoCheckBoxControl::GetComponentServiceName()
1229 {
1230 	return ::rtl::OUString::createFromAscii( "checkbox" );
1231 }
1232 
dispose()1233 void UnoCheckBoxControl::dispose() throw(uno::RuntimeException)
1234 {
1235 	lang::EventObject aEvt;
1236 	aEvt.Source = (::cppu::OWeakObject*)this;
1237 	maItemListeners.disposeAndClear( aEvt );
1238 	UnoControlBase::dispose();
1239 }
1240 
isTransparent()1241 sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException)
1242 {
1243 	return sal_True;
1244 }
1245 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)1246 void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
1247 {
1248 	UnoControlBase::createPeer( rxToolkit, rParentPeer );
1249 
1250 	uno::Reference < awt::XCheckBox >  xCheckBox( getPeer(), uno::UNO_QUERY );
1251 	xCheckBox->addItemListener( this );
1252 
1253 	uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1254 	xButton->setActionCommand( maActionCommand );
1255 	if ( maActionListeners.getLength() )
1256 		xButton->addActionListener( &maActionListeners );
1257 }
1258 
addItemListener(const uno::Reference<awt::XItemListener> & l)1259 void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1260 {
1261 	maItemListeners.addInterface( l );
1262 }
1263 
removeItemListener(const uno::Reference<awt::XItemListener> & l)1264 void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
1265 {
1266 	maItemListeners.removeInterface( l );
1267 }
1268 
addActionListener(const uno::Reference<awt::XActionListener> & l)1269 void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1270 {
1271 	maActionListeners.addInterface( l );
1272 	if( getPeer().is() && maActionListeners.getLength() == 1 )
1273 	{
1274 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
1275 		xButton->addActionListener( &maActionListeners );
1276 	}
1277 }
1278 
removeActionListener(const uno::Reference<awt::XActionListener> & l)1279 void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1280 {
1281 	if( getPeer().is() && maActionListeners.getLength() == 1 )
1282 	{
1283 		uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
1284 		xButton->removeActionListener( &maActionListeners );
1285 	}
1286 	maActionListeners.removeInterface( l );
1287 }
1288 
setActionCommand(const::rtl::OUString & rCommand)1289 void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException)
1290 {
1291 	maActionCommand = rCommand;
1292 	if ( getPeer().is() )
1293 	{
1294 		uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
1295 		xButton->setActionCommand( rCommand );
1296 	}
1297 }
1298 
1299 
setLabel(const::rtl::OUString & rLabel)1300 void UnoCheckBoxControl::setLabel( const ::rtl::OUString&  rLabel ) throw(uno::RuntimeException)
1301 {
1302 	uno::Any aAny;
1303 	aAny <<= rLabel;
1304 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1305 }
1306 
setState(short n)1307 void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException)
1308 {
1309 	uno::Any aAny;
1310 	aAny <<= (sal_Int16)n;
1311 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
1312 }
1313 
getState()1314 short UnoCheckBoxControl::getState() throw(uno::RuntimeException)
1315 {
1316 	short nState = 0;
1317 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
1318 	aVal >>= nState;
1319 	return nState;
1320 }
1321 
enableTriState(sal_Bool b)1322 void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException)
1323 {
1324 	uno::Any aAny;
1325 	aAny <<= b;
1326 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, sal_True );
1327 }
1328 
itemStateChanged(const awt::ItemEvent & rEvent)1329 void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
1330 {
1331 	uno::Any aAny;
1332 	aAny <<= (sal_Int16)rEvent.Selected;
1333 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
1334 
1335 	if ( maItemListeners.getLength() )
1336 		maItemListeners.itemStateChanged( rEvent );
1337 }
1338 
getMinimumSize()1339 awt::Size UnoCheckBoxControl::getMinimumSize(  ) throw(uno::RuntimeException)
1340 {
1341 	return Impl_getMinimumSize();
1342 }
1343 
getPreferredSize()1344 awt::Size UnoCheckBoxControl::getPreferredSize(  ) throw(uno::RuntimeException)
1345 {
1346 	return Impl_getPreferredSize();
1347 }
1348 
calcAdjustedSize(const awt::Size & rNewSize)1349 awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1350 {
1351 	return Impl_calcAdjustedSize( rNewSize );
1352 }
1353 
1354 //	----------------------------------------------------
1355 //  class UnoControlFixedHyperlinkModel
1356 //	----------------------------------------------------
UnoControlFixedHyperlinkModel(const Reference<XMultiServiceFactory> & i_factory)1357 UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference< XMultiServiceFactory >& i_factory )
1358     :UnoControlModel( i_factory )
1359 {
1360     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink );
1361 }
1362 
getServiceName()1363 ::rtl::OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1364 {
1365     return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel );
1366 }
1367 
ImplGetDefaultValue(sal_uInt16 nPropId) const1368 uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1369 {
1370 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1371 	{
1372 		uno::Any aAny;
1373         aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink );
1374 		return aAny;
1375 	}
1376 	else if ( nPropId == BASEPROPERTY_BORDER )
1377 	{
1378 		uno::Any aAny;
1379 		aAny <<= (sal_Int16)0;
1380 		return aAny;
1381 	}
1382     else if ( nPropId == BASEPROPERTY_URL )
1383     {
1384         uno::Any aAny;
1385         aAny <<= ::rtl::OUString();
1386         return aAny;
1387     }
1388 
1389 	return UnoControlModel::ImplGetDefaultValue( nPropId );
1390 }
1391 
getInfoHelper()1392 ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper()
1393 {
1394 	static UnoPropertyArrayHelper* pHelper = NULL;
1395 	if ( !pHelper )
1396 	{
1397 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
1398 		pHelper = new UnoPropertyArrayHelper( aIDs );
1399 	}
1400 	return *pHelper;
1401 }
1402 
1403 // beans::XMultiPropertySet
getPropertySetInfo()1404 uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1405 {
1406 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1407 	return xInfo;
1408 }
1409 
1410 //	----------------------------------------------------
1411 //  class UnoFixedHyperlinkControl
1412 //	----------------------------------------------------
UnoFixedHyperlinkControl(const Reference<XMultiServiceFactory> & i_factory)1413 UnoFixedHyperlinkControl::UnoFixedHyperlinkControl( const Reference< XMultiServiceFactory >& i_factory )
1414 	:UnoControlBase( i_factory )
1415     ,maActionListeners( *this )
1416 {
1417 	maComponentInfos.nWidth = 100;
1418 	maComponentInfos.nHeight = 12;
1419 }
1420 
GetComponentServiceName()1421 ::rtl::OUString UnoFixedHyperlinkControl::GetComponentServiceName()
1422 {
1423     return ::rtl::OUString::createFromAscii( "fixedhyperlink" );
1424 }
1425 
1426 // uno::XInterface
queryAggregation(const uno::Type & rType)1427 uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1428 {
1429 	uno::Any aRet = ::cppu::queryInterface( rType,
1430                                         SAL_STATIC_CAST( awt::XFixedHyperlink*, this ),
1431 										SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1432 	return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1433 }
1434 
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
1441 
1442 sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException)
1443 {
1444 	return sal_True;
1445 }
1446 
setText(const::rtl::OUString & Text)1447 void UnoFixedHyperlinkControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1448 {
1449 	uno::Any aAny;
1450 	aAny <<= Text;
1451 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1452 }
1453 
getText()1454 ::rtl::OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException)
1455 {
1456 	return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1457 }
1458 
setURL(const::rtl::OUString & URL)1459 void UnoFixedHyperlinkControl::setURL( const ::rtl::OUString& URL ) throw(::com::sun::star::uno::RuntimeException)
1460 {
1461     uno::Any aAny;
1462     aAny <<= URL;
1463     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, sal_True );
1464 }
1465 
getURL()1466 ::rtl::OUString UnoFixedHyperlinkControl::getURL(  ) throw(::com::sun::star::uno::RuntimeException)
1467 {
1468     return ImplGetPropertyValue_UString( BASEPROPERTY_URL );
1469 }
1470 
setAlignment(short nAlign)1471 void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1472 {
1473 	uno::Any aAny;
1474 	aAny <<= (sal_Int16)nAlign;
1475 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1476 }
1477 
getAlignment()1478 short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException)
1479 {
1480 	short nAlign = 0;
1481 	if ( mxModel.is() )
1482 	{
1483 		uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1484 		aVal >>= nAlign;
1485 	}
1486 	return nAlign;
1487 }
1488 
getMinimumSize()1489 awt::Size UnoFixedHyperlinkControl::getMinimumSize(  ) throw(uno::RuntimeException)
1490 {
1491 	return Impl_getMinimumSize();
1492 }
1493 
getPreferredSize()1494 awt::Size UnoFixedHyperlinkControl::getPreferredSize(  ) throw(uno::RuntimeException)
1495 {
1496 	return Impl_getPreferredSize();
1497 }
1498 
calcAdjustedSize(const awt::Size & rNewSize)1499 awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1500 {
1501 	return Impl_calcAdjustedSize( rNewSize );
1502 }
1503 
dispose()1504 void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException)
1505 {
1506     lang::EventObject aEvt;
1507     aEvt.Source = (::cppu::OWeakObject*)this;
1508     maActionListeners.disposeAndClear( aEvt );
1509     UnoControlBase::dispose();
1510 }
1511 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)1512 void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
1513 {
1514     UnoControlBase::createPeer( rxToolkit, rParentPeer );
1515 
1516     uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1517     if ( maActionListeners.getLength() )
1518         xFixedHyperlink->addActionListener( &maActionListeners );
1519 }
1520 
addActionListener(const uno::Reference<awt::XActionListener> & l)1521 void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1522 {
1523     maActionListeners.addInterface( l );
1524     if( getPeer().is() && maActionListeners.getLength() == 1 )
1525     {
1526         uno::Reference < awt::XFixedHyperlink >  xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1527         xFixedHyperlink->addActionListener( &maActionListeners );
1528     }
1529 }
1530 
removeActionListener(const uno::Reference<awt::XActionListener> & l)1531 void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
1532 {
1533     if( getPeer().is() && maActionListeners.getLength() == 1 )
1534     {
1535         uno::Reference < awt::XFixedHyperlink >  xFixedHyperlink( getPeer(), uno::UNO_QUERY );
1536         xFixedHyperlink->removeActionListener( &maActionListeners );
1537     }
1538     maActionListeners.removeInterface( l );
1539 }
1540 
1541 //  ----------------------------------------------------
1542 //  class UnoControlFixedTextModel
1543 //  ----------------------------------------------------
UnoControlFixedTextModel(const Reference<XMultiServiceFactory> & i_factory)1544 UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference< XMultiServiceFactory >& i_factory )
1545     :UnoControlModel( i_factory )
1546 {
1547     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText );
1548 }
1549 
getServiceName()1550 ::rtl::OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1551 {
1552     return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedTextModel );
1553 }
1554 
ImplGetDefaultValue(sal_uInt16 nPropId) const1555 uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1556 {
1557     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1558     {
1559         uno::Any aAny;
1560         aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedText );
1561         return aAny;
1562     }
1563     else if ( nPropId == BASEPROPERTY_BORDER )
1564     {
1565         uno::Any aAny;
1566         aAny <<= (sal_Int16)0;
1567         return aAny;
1568     }
1569 
1570     return UnoControlModel::ImplGetDefaultValue( nPropId );
1571 }
1572 
getInfoHelper()1573 ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper()
1574 {
1575     static UnoPropertyArrayHelper* pHelper = NULL;
1576     if ( !pHelper )
1577     {
1578         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
1579         pHelper = new UnoPropertyArrayHelper( aIDs );
1580     }
1581     return *pHelper;
1582 }
1583 
1584 // beans::XMultiPropertySet
getPropertySetInfo()1585 uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1586 {
1587     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1588     return xInfo;
1589 }
1590 
1591 
1592 //  ----------------------------------------------------
1593 //  class UnoFixedTextControl
1594 //  ----------------------------------------------------
UnoFixedTextControl(const Reference<XMultiServiceFactory> & i_factory)1595 UnoFixedTextControl::UnoFixedTextControl( const Reference< XMultiServiceFactory >& i_factory )
1596 	:UnoControlBase( i_factory )
1597 {
1598     maComponentInfos.nWidth = 100;
1599     maComponentInfos.nHeight = 12;
1600 }
1601 
GetComponentServiceName()1602 ::rtl::OUString UnoFixedTextControl::GetComponentServiceName()
1603 {
1604     return ::rtl::OUString::createFromAscii( "fixedtext" );
1605 }
1606 
1607 // uno::XInterface
queryAggregation(const uno::Type & rType)1608 uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
1609 {
1610     uno::Any aRet = ::cppu::queryInterface( rType,
1611                                         SAL_STATIC_CAST( awt::XFixedText*, this ),
1612                                         SAL_STATIC_CAST( awt::XLayoutConstrains*, this ) );
1613     return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
1614 }
1615 
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
1622 
1623 sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException)
1624 {
1625     return sal_True;
1626 }
1627 
setText(const::rtl::OUString & Text)1628 void UnoFixedTextControl::setText( const ::rtl::OUString& Text ) throw(uno::RuntimeException)
1629 {
1630     uno::Any aAny;
1631     aAny <<= Text;
1632     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
1633 }
1634 
getText()1635 ::rtl::OUString UnoFixedTextControl::getText() throw(uno::RuntimeException)
1636 {
1637     return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
1638 }
1639 
setAlignment(short nAlign)1640 void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
1641 {
1642     uno::Any aAny;
1643     aAny <<= (sal_Int16)nAlign;
1644     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
1645 }
1646 
getAlignment()1647 short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException)
1648 {
1649     short nAlign = 0;
1650     if ( mxModel.is() )
1651     {
1652         uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
1653         aVal >>= nAlign;
1654     }
1655     return nAlign;
1656 }
1657 
getMinimumSize()1658 awt::Size UnoFixedTextControl::getMinimumSize(  ) throw(uno::RuntimeException)
1659 {
1660     return Impl_getMinimumSize();
1661 }
1662 
getPreferredSize()1663 awt::Size UnoFixedTextControl::getPreferredSize(  ) throw(uno::RuntimeException)
1664 {
1665     return Impl_getPreferredSize();
1666 }
1667 
calcAdjustedSize(const awt::Size & rNewSize)1668 awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
1669 {
1670     return Impl_calcAdjustedSize( rNewSize );
1671 }
1672 
1673 //	----------------------------------------------------
1674 //	class UnoControlGroupBoxModel
1675 //	----------------------------------------------------
UnoControlGroupBoxModel(const Reference<XMultiServiceFactory> & i_factory)1676 UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference< XMultiServiceFactory >& i_factory )
1677     :UnoControlModel( i_factory )
1678 {
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 );
1689 }
1690 
getServiceName()1691 ::rtl::OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1692 {
1693 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel );
1694 }
1695 
ImplGetDefaultValue(sal_uInt16 nPropId) const1696 uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1697 {
1698 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1699 	{
1700 		uno::Any aAny;
1701 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlGroupBox );
1702 		return aAny;
1703 	}
1704 	return UnoControlModel::ImplGetDefaultValue( nPropId );
1705 }
1706 
getInfoHelper()1707 ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper()
1708 {
1709 	static UnoPropertyArrayHelper* pHelper = NULL;
1710 	if ( !pHelper )
1711 	{
1712 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
1713 		pHelper = new UnoPropertyArrayHelper( aIDs );
1714 	}
1715 	return *pHelper;
1716 }
1717 
1718 // beans::XMultiPropertySet
getPropertySetInfo()1719 uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1720 {
1721 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1722 	return xInfo;
1723 }
1724 
1725 //	----------------------------------------------------
1726 //	class UnoGroupBoxControl
1727 //	----------------------------------------------------
UnoGroupBoxControl(const Reference<XMultiServiceFactory> & i_factory)1728 UnoGroupBoxControl::UnoGroupBoxControl( const Reference< XMultiServiceFactory >& i_factory )
1729 	:UnoControlBase( i_factory )
1730 {
1731 	maComponentInfos.nWidth = 100;
1732 	maComponentInfos.nHeight = 100;
1733 }
1734 
GetComponentServiceName()1735 ::rtl::OUString UnoGroupBoxControl::GetComponentServiceName()
1736 {
1737 	return ::rtl::OUString::createFromAscii( "groupbox" );
1738 }
1739 
isTransparent()1740 sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException)
1741 {
1742 	return sal_True;
1743 }
1744 
1745 // =====================================================================================================================
1746 // = UnoControlListBoxModel_Data
1747 // =====================================================================================================================
1748 struct ListItem
1749 {
1750     ::rtl::OUString ItemText;
1751     ::rtl::OUString ItemImageURL;
1752     Any             ItemData;
1753 
ListItemListItem1754     ListItem()
1755         :ItemText()
1756         ,ItemImageURL()
1757         ,ItemData()
1758     {
1759     }
1760 
ListItemListItem1761     ListItem( const ::rtl::OUString& i_rItemText )
1762         :ItemText( i_rItemText )
1763         ,ItemImageURL()
1764         ,ItemData()
1765     {
1766     }
1767 };
1768 
1769 typedef beans::Pair< ::rtl::OUString, ::rtl::OUString > UnoListItem;
1770 
1771 struct StripItemData : public ::std::unary_function< ListItem, UnoListItem >
1772 {
operator ()StripItemData1773     UnoListItem operator()( const ListItem& i_rItem )
1774     {
1775         return UnoListItem( i_rItem.ItemText, i_rItem.ItemImageURL );
1776     }
1777 };
1778 
1779 struct UnoControlListBoxModel_Data
1780 {
UnoControlListBoxModel_DataUnoControlListBoxModel_Data1781     UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl )
1782         :m_bSettingLegacyProperty( false )
1783         ,m_rAntiImpl( i_rAntiImpl )
1784         ,m_aListItems()
1785     {
1786     }
1787 
getItemCountUnoControlListBoxModel_Data1788     sal_Int32 getItemCount() const { return sal_Int32( m_aListItems.size() ); }
1789 
getItemUnoControlListBoxModel_Data1790     const ListItem& getItem( const sal_Int32 i_nIndex ) const
1791     {
1792         if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
1793             throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl );
1794         return m_aListItems[ i_nIndex ];
1795     }
1796 
getItemUnoControlListBoxModel_Data1797     ListItem& getItem( const sal_Int32 i_nIndex )
1798     {
1799         return const_cast< ListItem& >( static_cast< const UnoControlListBoxModel_Data* >( this )->getItem( i_nIndex ) );
1800     }
1801 
insertItemUnoControlListBoxModel_Data1802     ListItem& insertItem( const sal_Int32 i_nIndex )
1803     {
1804         if ( ( i_nIndex < 0 ) || ( i_nIndex > sal_Int32( m_aListItems.size() ) ) )
1805             throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl );
1806         return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() );
1807     }
1808 
getAllItemsUnoControlListBoxModel_Data1809     Sequence< UnoListItem > getAllItems() const
1810     {
1811         Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) );
1812         ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() );
1813         return aItems;
1814     }
1815 
copyItemsUnoControlListBoxModel_Data1816     void copyItems( const UnoControlListBoxModel_Data& i_copySource )
1817     {
1818         m_aListItems = i_copySource.m_aListItems;
1819     }
1820 
setAllItemsUnoControlListBoxModel_Data1821     void    setAllItems( const ::std::vector< ListItem >& i_rItems )
1822     {
1823         m_aListItems = i_rItems;
1824     }
1825 
removeItemUnoControlListBoxModel_Data1826     void    removeItem( const sal_Int32 i_nIndex )
1827     {
1828         if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
1829             throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl );
1830         m_aListItems.erase( m_aListItems.begin() + i_nIndex );
1831     }
1832 
removeAllItemsUnoControlListBoxModel_Data1833     void removeAllItems()
1834     {
1835         ::std::vector< ListItem > aEmpty;
1836         m_aListItems.swap( aEmpty );
1837     }
1838 
1839 public:
1840     bool                        m_bSettingLegacyProperty;
1841 
1842 private:
1843     UnoControlListBoxModel&     m_rAntiImpl;
1844     ::std::vector< ListItem >   m_aListItems;
1845 };
1846 
1847 // =====================================================================================================================
1848 // = UnoControlListBoxModel
1849 // =====================================================================================================================
1850 // ---------------------------------------------------------------------------------------------------------------------
UnoControlListBoxModel(const Reference<XMultiServiceFactory> & i_factory,ConstructorMode const i_mode)1851 UnoControlListBoxModel::UnoControlListBoxModel( const Reference< XMultiServiceFactory >& i_factory, ConstructorMode const i_mode )
1852     :UnoControlListBoxModel_Base( i_factory )
1853     ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1854     ,m_aItemListListeners( GetMutex() )
1855 {
1856     if ( i_mode == ConstructDefault )
1857     {
1858         UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox );
1859     }
1860 }
1861 // ---------------------------------------------------------------------------------------------------------------------
UnoControlListBoxModel(const UnoControlListBoxModel & i_rSource)1862 UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource )
1863     :UnoControlListBoxModel_Base( i_rSource )
1864     ,m_pData( new UnoControlListBoxModel_Data( *this ) )
1865     ,m_aItemListListeners( GetMutex() )
1866 {
1867     m_pData->copyItems( *i_rSource.m_pData );
1868 }
~UnoControlListBoxModel()1869 UnoControlListBoxModel::~UnoControlListBoxModel()
1870 {
1871 }
IMPL_SERVICEINFO_DERIVED(UnoControlListBoxModel,UnoControlModel,szServiceName2_UnoControlListBoxModel)1872 IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel )
1873 // ---------------------------------------------------------------------------------------------------------------------
1874 ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
1875 {
1876 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel );
1877 }
1878 
1879 // ---------------------------------------------------------------------------------------------------------------------
ImplGetDefaultValue(sal_uInt16 nPropId) const1880 uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
1881 {
1882 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
1883 	{
1884 		uno::Any aAny;
1885 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBox );
1886 		return aAny;
1887 	}
1888 	return UnoControlModel::ImplGetDefaultValue( nPropId );
1889 }
1890 
1891 // ---------------------------------------------------------------------------------------------------------------------
getInfoHelper()1892 ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper()
1893 {
1894 	static UnoPropertyArrayHelper* pHelper = NULL;
1895 	if ( !pHelper )
1896 	{
1897 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
1898 		pHelper = new UnoPropertyArrayHelper( aIDs );
1899 	}
1900 	return *pHelper;
1901 }
1902 
1903 // ---------------------------------------------------------------------------------------------------------------------
1904 // beans::XMultiPropertySet
getPropertySetInfo()1905 uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
1906 {
1907 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1908 	return xInfo;
1909 }
1910 
1911 // ---------------------------------------------------------------------------------------------------------------------
1912 namespace
1913 {
1914     struct CreateListItem : public ::std::unary_function< ::rtl::OUString, ListItem >
1915     {
operator ()__anon0bbb5a550211::CreateListItem1916         ListItem operator()( const ::rtl::OUString& i_rItemText )
1917         {
1918             return ListItem( i_rItemText );
1919         }
1920     };
1921 }
1922 
1923 // ---------------------------------------------------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const uno::Any & rValue)1924 void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception)
1925 {
1926     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
1927 
1928     if ( nHandle == BASEPROPERTY_STRINGITEMLIST )
1929 	{
1930         // reset selection
1931 		uno::Sequence<sal_Int16> aSeq;
1932 		uno::Any aAny;
1933 		aAny <<= aSeq;
1934 		setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, aAny );
1935 
1936         if ( !m_pData->m_bSettingLegacyProperty )
1937         {
1938             // synchronize the legacy StringItemList property with our list items
1939             Sequence< ::rtl::OUString > aStringItemList;
1940             Any aPropValue;
1941             getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
1942             OSL_VERIFY( aPropValue >>= aStringItemList );
1943 
1944             ::std::vector< ListItem > aItems( aStringItemList.getLength() );
1945             ::std::transform(
1946                 aStringItemList.getConstArray(),
1947                 aStringItemList.getConstArray() + aStringItemList.getLength(),
1948                 aItems.begin(),
1949                 CreateListItem()
1950             );
1951             m_pData->setAllItems( aItems );
1952 
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
1955             // items
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 ...
1961         }
1962 	}
1963 }
1964 
1965 // ---------------------------------------------------------------------------------------------------------------------
ImplNormalizePropertySequence(const sal_Int32 _nCount,sal_Int32 * _pHandles,uno::Any * _pValues,sal_Int32 * _pValidHandles) const1966 void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
1967 	uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(())
1968 {
1969 	// dependencies we know:
1970 	// BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
1971     ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS );
1972 
1973 	UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
1974 }
1975 
1976 // ---------------------------------------------------------------------------------------------------------------------
getItemCount()1977 ::sal_Int32 SAL_CALL UnoControlListBoxModel::getItemCount() throw (RuntimeException)
1978 {
1979 	::osl::MutexGuard aGuard( GetMutex() );
1980     return m_pData->getItemCount();
1981 }
1982 
1983 // ---------------------------------------------------------------------------------------------------------------------
insertItem(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemText,const::rtl::OUString & i_rItemImageURL)1984 void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
1985 {
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;
1991 
1992     impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
1993     // <----- SYNCHRONIZED
1994 }
1995 
1996 // ---------------------------------------------------------------------------------------------------------------------
insertItemText(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemText)1997 void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException)
1998 {
1999 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2000     // SYNCHRONIZED ----->
2001     ListItem& rItem( m_pData->insertItem( i_nPosition ) );
2002     rItem.ItemText = i_rItemText;
2003 
2004     impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard );
2005     // <----- SYNCHRONIZED
2006 }
2007 
2008 // ---------------------------------------------------------------------------------------------------------------------
insertItemImage(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemImageURL)2009 void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
2010 {
2011 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2012     // SYNCHRONIZED ----->
2013     ListItem& rItem( m_pData->insertItem( i_nPosition ) );
2014     rItem.ItemImageURL = i_rItemImageURL;
2015 
2016     impl_handleInsert( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard );
2017     // <----- SYNCHRONIZED
2018 }
2019 
2020 // ---------------------------------------------------------------------------------------------------------------------
removeItem(::sal_Int32 i_nPosition)2021 void SAL_CALL UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
2022 {
2023 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2024     // SYNCHRONIZED ----->
2025     m_pData->removeItem( i_nPosition );
2026 
2027     impl_handleRemove( i_nPosition, aGuard );
2028     // <----- SYNCHRONIZED
2029 }
2030 
2031 // ---------------------------------------------------------------------------------------------------------------------
removeAllItems()2032 void SAL_CALL UnoControlListBoxModel::removeAllItems(  ) throw (::com::sun::star::uno::RuntimeException)
2033 {
2034 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2035     // SYNCHRONIZED ----->
2036     m_pData->removeAllItems();
2037 
2038     impl_handleRemove( -1, aGuard );
2039     // <----- SYNCHRONIZED
2040 }
2041 
2042 // ---------------------------------------------------------------------------------------------------------------------
setItemText(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemText)2043 void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException)
2044 {
2045 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2046     // SYNCHRONIZED ----->
2047     ListItem& rItem( m_pData->getItem( i_nPosition ) );
2048     rItem.ItemText = i_rItemText;
2049 
2050     impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard );
2051     // <----- SYNCHRONIZED
2052 }
2053 
2054 // ---------------------------------------------------------------------------------------------------------------------
setItemImage(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemImageURL)2055 void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
2056 {
2057 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2058     // SYNCHRONIZED ----->
2059     ListItem& rItem( m_pData->getItem( i_nPosition ) );
2060     rItem.ItemImageURL = i_rItemImageURL;
2061 
2062     impl_handleModify( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard );
2063     // <----- SYNCHRONIZED
2064 }
2065 
2066 // ---------------------------------------------------------------------------------------------------------------------
setItemTextAndImage(::sal_Int32 i_nPosition,const::rtl::OUString & i_rItemText,const::rtl::OUString & i_rItemImageURL)2067 void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
2068 {
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;
2074 
2075     impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
2076     // <----- SYNCHRONIZED
2077 }
2078 
2079 // ---------------------------------------------------------------------------------------------------------------------
setItemData(::sal_Int32 i_nPosition,const Any & i_rDataValue)2080 void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException)
2081 {
2082 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2083     ListItem& rItem( m_pData->getItem( i_nPosition ) );
2084     rItem.ItemData = i_rDataValue;
2085 }
2086 
2087 // ---------------------------------------------------------------------------------------------------------------------
getItemText(::sal_Int32 i_nPosition)2088 ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
2089 {
2090     ::osl::MutexGuard aGuard( GetMutex() );
2091     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
2092     return rItem.ItemText;
2093 }
2094 
2095 // ---------------------------------------------------------------------------------------------------------------------
getItemImage(::sal_Int32 i_nPosition)2096 ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
2097 {
2098 	::osl::MutexGuard aGuard( GetMutex() );
2099     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
2100     return rItem.ItemImageURL;
2101 }
2102 
2103 // ---------------------------------------------------------------------------------------------------------------------
getItemTextAndImage(::sal_Int32 i_nPosition)2104 beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
2105 {
2106 	::osl::MutexGuard aGuard( GetMutex() );
2107     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
2108     return beans::Pair< ::rtl::OUString, ::rtl::OUString >( rItem.ItemText, rItem.ItemImageURL );
2109 }
2110 
2111 // ---------------------------------------------------------------------------------------------------------------------
getItemData(::sal_Int32 i_nPosition)2112 Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
2113 {
2114 	::osl::ClearableMutexGuard aGuard( GetMutex() );
2115     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
2116     return rItem.ItemData;
2117 }
2118 
2119 // ---------------------------------------------------------------------------------------------------------------------
getAllItems()2120 Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL UnoControlListBoxModel::getAllItems(  ) throw (RuntimeException)
2121 {
2122 	::osl::MutexGuard aGuard( GetMutex() );
2123     return m_pData->getAllItems();
2124 }
2125 
2126 // ---------------------------------------------------------------------------------------------------------------------
addItemListListener(const uno::Reference<awt::XItemListListener> & i_Listener)2127 void SAL_CALL UnoControlListBoxModel::addItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException)
2128 {
2129     if ( i_Listener.is() )
2130         m_aItemListListeners.addInterface( i_Listener );
2131 }
2132 
2133 // ---------------------------------------------------------------------------------------------------------------------
removeItemListListener(const uno::Reference<awt::XItemListListener> & i_Listener)2134 void SAL_CALL UnoControlListBoxModel::removeItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException)
2135 {
2136     if ( i_Listener.is() )
2137         m_aItemListListeners.removeInterface( i_Listener );
2138 }
2139 
2140 // ---------------------------------------------------------------------------------------------------------------------
impl_getStringItemList(::std::vector<::rtl::OUString> & o_rStringItems) const2141 void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< ::rtl::OUString >& o_rStringItems ) const
2142 {
2143     Sequence< ::rtl::OUString > aStringItemList;
2144     Any aPropValue;
2145     getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
2146     OSL_VERIFY( aPropValue >>= aStringItemList );
2147 
2148     o_rStringItems.resize( size_t( aStringItemList.getLength() ) );
2149     ::std::copy(
2150         aStringItemList.getConstArray(),
2151         aStringItemList.getConstArray() + aStringItemList.getLength(),
2152         o_rStringItems.begin()
2153     );
2154 }
2155 
2156 // ---------------------------------------------------------------------------------------------------------------------
impl_setStringItemList_nolck(const::std::vector<::rtl::OUString> & i_rStringItems)2157 void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< ::rtl::OUString >& i_rStringItems )
2158 {
2159     Sequence< ::rtl::OUString > aStringItems( i_rStringItems.size() );
2160     ::std::copy(
2161         i_rStringItems.begin(),
2162         i_rStringItems.end(),
2163         aStringItems.getArray()
2164     );
2165     m_pData->m_bSettingLegacyProperty = true;
2166     try
2167     {
2168         setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST, uno::makeAny( aStringItems ) );
2169     }
2170     catch( const Exception& )
2171     {
2172         m_pData->m_bSettingLegacyProperty = false;
2173         throw;
2174     }
2175     m_pData->m_bSettingLegacyProperty = false;
2176 }
2177 
2178 // ---------------------------------------------------------------------------------------------------------------------
impl_handleInsert(const sal_Int32 i_nItemPosition,const::boost::optional<::rtl::OUString> & i_rItemText,const::boost::optional<::rtl::OUString> & i_rItemImageURL,::osl::ClearableMutexGuard & i_rClearBeforeNotify)2179 void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText,
2180         const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2181 {
2182     // SYNCHRONIZED ----->
2183     // sync with legacy StringItemList property
2184     ::std::vector< ::rtl::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() )
2188     {
2189         const ::rtl::OUString sItemText( !!i_rItemText ? *i_rItemText : ::rtl::OUString() );
2190         aStringItems.insert( aStringItems.begin() + i_nItemPosition, sItemText );
2191     }
2192 
2193     i_rClearBeforeNotify.clear();
2194     // <----- SYNCHRONIZED
2195     impl_setStringItemList_nolck( aStringItems );
2196 
2197     // notify ItemListListeners
2198     impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemInserted );
2199 }
2200 
2201 // ---------------------------------------------------------------------------------------------------------------------
impl_handleRemove(const sal_Int32 i_nItemPosition,::osl::ClearableMutexGuard & i_rClearBeforeNotify)2202 void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2203 {
2204     // SYNCHRONIZED ----->
2205     const bool bAllItems = ( i_nItemPosition < 0 );
2206     // sync with legacy StringItemList property
2207     ::std::vector< ::rtl::OUString > aStringItems;
2208     impl_getStringItemList( aStringItems );
2209     if ( !bAllItems )
2210     {
2211         OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleRemove" );
2212         if ( size_t( i_nItemPosition ) < aStringItems.size() )
2213         {
2214             aStringItems.erase( aStringItems.begin() + i_nItemPosition );
2215         }
2216     }
2217     else
2218     {
2219         aStringItems.resize(0);
2220     }
2221 
2222     i_rClearBeforeNotify.clear();
2223     // <----- SYNCHRONIZED
2224     impl_setStringItemList_nolck( aStringItems );
2225 
2226     // notify ItemListListeners
2227     if ( bAllItems )
2228     {
2229         EventObject aEvent( *this );
2230         m_aItemListListeners.notifyEach( &XItemListListener::allItemsRemoved, aEvent );
2231     }
2232     else
2233     {
2234         impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< ::rtl::OUString >(), ::boost::optional< ::rtl::OUString >(),
2235             &XItemListListener::listItemRemoved );
2236     }
2237 }
2238 
2239 // ---------------------------------------------------------------------------------------------------------------------
impl_handleModify(const sal_Int32 i_nItemPosition,const::boost::optional<::rtl::OUString> & i_rItemText,const::boost::optional<::rtl::OUString> & i_rItemImageURL,::osl::ClearableMutexGuard & i_rClearBeforeNotify)2240 void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText,
2241         const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
2242 {
2243     // SYNCHRONIZED ----->
2244     if ( !!i_rItemText )
2245     {
2246         // sync with legacy StringItemList property
2247         ::std::vector< ::rtl::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() )
2251         {
2252             aStringItems[ i_nItemPosition] = *i_rItemText;
2253         }
2254 
2255         i_rClearBeforeNotify.clear();
2256         // <----- SYNCHRONIZED
2257         impl_setStringItemList_nolck( aStringItems );
2258     }
2259     else
2260     {
2261         i_rClearBeforeNotify.clear();
2262         // <----- SYNCHRONIZED
2263     }
2264 
2265     // notify ItemListListeners
2266     impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemModified );
2267 }
2268 
2269 // ---------------------------------------------------------------------------------------------------------------------
impl_notifyItemListEvent_nolck(const sal_Int32 i_nItemPosition,const::boost::optional<::rtl::OUString> & i_rItemText,const::boost::optional<::rtl::OUString> & i_rItemImageURL,void (SAL_CALL XItemListListener::* NotificationMethod)(const ItemListEvent &))2270 void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText,
2271     const ::boost::optional< ::rtl::OUString >& i_rItemImageURL,
2272     void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) )
2273 {
2274     ItemListEvent aEvent;
2275     aEvent.Source = *this;
2276     aEvent.ItemPosition = i_nItemPosition;
2277     if ( !!i_rItemText )
2278     {
2279         aEvent.ItemText.IsPresent = sal_True;
2280         aEvent.ItemText.Value = *i_rItemText;
2281     }
2282     if ( !!i_rItemImageURL )
2283     {
2284         aEvent.ItemImageURL.IsPresent = sal_True;
2285         aEvent.ItemImageURL.Value = *i_rItemImageURL;
2286     }
2287 
2288     m_aItemListListeners.notifyEach( NotificationMethod, aEvent );
2289 }
2290 
2291 //	----------------------------------------------------
2292 //	class UnoListBoxControl
2293 //	----------------------------------------------------
UnoListBoxControl(const Reference<XMultiServiceFactory> & i_factory)2294 UnoListBoxControl::UnoListBoxControl( const Reference< XMultiServiceFactory >& i_factory )
2295 	:UnoListBoxControl_Base( i_factory )
2296     ,maActionListeners( *this )
2297 	,maItemListeners( *this )
2298 {
2299 	maComponentInfos.nWidth = 100;
2300 	maComponentInfos.nHeight = 12;
2301 }
2302 
GetComponentServiceName()2303 ::rtl::OUString UnoListBoxControl::GetComponentServiceName()
2304 {
2305 	return ::rtl::OUString::createFromAscii( "listbox" );
2306 }
IMPL_SERVICEINFO_DERIVED(UnoListBoxControl,UnoControlBase,szServiceName2_UnoControlListBox)2307 IMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox )
2308 
2309 void UnoListBoxControl::dispose() throw(uno::RuntimeException)
2310 {
2311 	lang::EventObject aEvt;
2312 	aEvt.Source = (::cppu::OWeakObject*)this;
2313 	maActionListeners.disposeAndClear( aEvt );
2314 	maItemListeners.disposeAndClear( aEvt );
2315 	UnoControl::dispose();
2316 }
2317 
ImplUpdateSelectedItemsProperty()2318 void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
2319 {
2320     if ( getPeer().is() )
2321     {
2322     	uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
2323     	DBG_ASSERT( xListBox.is(), "XListBox?" );
2324 
2325     	uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos();
2326     	uno::Any aAny;
2327     	aAny <<= aSeq;
2328     	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, sal_False );
2329     }
2330 }
2331 
updateFromModel()2332 void UnoListBoxControl::updateFromModel()
2333 {
2334     UnoControlBase::updateFromModel();
2335 
2336     Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
2337     ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2338 
2339     EventObject aEvent( getModel() );
2340     xItemListListener->itemListChanged( aEvent );
2341 
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 ::rtl::OUString sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ) );
2346     ImplSetPeerProperty( sSelectedItemsPropName, ImplGetPropertyValue( sSelectedItemsPropName ) );
2347 }
2348 
ImplSetPeerProperty(const::rtl::OUString & rPropName,const uno::Any & rVal)2349 void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
2350 {
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.
2355         return;
2356 
2357 	UnoControl::ImplSetPeerProperty( rPropName, rVal );
2358 }
2359 
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)2360 void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
2361 {
2362 	UnoControl::createPeer( rxToolkit, rParentPeer );
2363 
2364 	uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2365 	xListBox->addItemListener( this );
2366 
2367 	if ( maActionListeners.getLength() )
2368 		xListBox->addActionListener( &maActionListeners );
2369 }
2370 
addActionListener(const uno::Reference<awt::XActionListener> & l)2371 void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2372 {
2373 	maActionListeners.addInterface( l );
2374 	if( getPeer().is() && maActionListeners.getLength() == 1 )
2375 	{
2376 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2377 		xListBox->addActionListener( &maActionListeners );
2378 	}
2379 }
2380 
removeActionListener(const uno::Reference<awt::XActionListener> & l)2381 void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2382 {
2383 	if( getPeer().is() && maActionListeners.getLength() == 1 )
2384 	{
2385 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2386 		xListBox->removeActionListener( &maActionListeners );
2387 	}
2388 	maActionListeners.removeInterface( l );
2389 }
2390 
addItemListener(const uno::Reference<awt::XItemListener> & l)2391 void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2392 {
2393 	maItemListeners.addInterface( l );
2394 }
2395 
removeItemListener(const uno::Reference<awt::XItemListener> & l)2396 void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2397 {
2398 	maItemListeners.removeInterface( l );
2399 }
2400 
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)2401 void UnoListBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
2402 {
2403 	uno::Sequence< ::rtl::OUString> aSeq( 1 );
2404 	aSeq.getArray()[0] = aItem;
2405 	addItems( aSeq, nPos );
2406 }
2407 
addItems(const uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)2408 void UnoListBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
2409 {
2410 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2411 	uno::Sequence< ::rtl::OUString> aSeq;
2412 	aVal >>= aSeq;
2413 	sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
2414 	sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2415 	sal_uInt16 nNewLen = nOldLen + nNewItems;
2416 
2417 	uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2418 	::rtl::OUString* pNewData = aNewSeq.getArray();
2419 	::rtl::OUString* pOldData = aSeq.getArray();
2420 
2421 	if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
2422 		nPos = (sal_uInt16) nOldLen;
2423 
2424 	sal_uInt16 n;
2425 	// Items vor der Einfuege-Position
2426 	for ( n = 0; n < nPos; n++ )
2427 		pNewData[n] = pOldData[n];
2428 
2429 	// Neue Items
2430 	for ( n = 0; n < nNewItems; n++ )
2431 		pNewData[nPos+n] = aItems.getConstArray()[n];
2432 
2433 	// Rest der alten Items
2434 	for ( n = nPos; n < nOldLen; n++ )
2435 		pNewData[nNewItems+n] = pOldData[n];
2436 
2437 	uno::Any aAny;
2438 	aAny <<= aNewSeq;
2439 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2440 }
2441 
removeItems(sal_Int16 nPos,sal_Int16 nCount)2442 void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
2443 {
2444 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2445 	uno::Sequence< ::rtl::OUString> aSeq;
2446 	aVal >>= aSeq;
2447 	sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
2448 	if ( nOldLen && ( nPos < nOldLen ) )
2449 	{
2450 		if ( nCount > ( nOldLen-nPos ) )
2451 			nCount = nOldLen-nPos;
2452 
2453 		sal_uInt16 nNewLen = nOldLen - nCount;
2454 
2455 		uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
2456 		::rtl::OUString* pNewData = aNewSeq.getArray();
2457 		::rtl::OUString* pOldData = aSeq.getArray();
2458 
2459 		sal_uInt16 n;
2460 		// Items vor der Entfern-Position
2461 		for ( n = 0; n < nPos; n++ )
2462 			pNewData[n] = pOldData[n];
2463 
2464 		// Rest der Items
2465 		for ( n = nPos; n < (nOldLen-nCount); n++ )
2466 			pNewData[n] = pOldData[n+nCount];
2467 
2468 		uno::Any aAny;
2469 		aAny <<= aNewSeq;
2470 		ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
2471 	}
2472 }
2473 
getItemCount()2474 sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException)
2475 {
2476 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2477 	uno::Sequence< ::rtl::OUString> aSeq;
2478 	aVal >>= aSeq;
2479 	return (sal_Int16)aSeq.getLength();
2480 }
2481 
getItem(sal_Int16 nPos)2482 ::rtl::OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
2483 {
2484 	::rtl::OUString aItem;
2485 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2486 	uno::Sequence< ::rtl::OUString> aSeq;
2487 	aVal >>= aSeq;
2488 	if ( nPos < aSeq.getLength() )
2489 		aItem = aSeq.getConstArray()[nPos];
2490 	return aItem;
2491 }
2492 
getItems()2493 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException)
2494 {
2495 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
2496 	uno::Sequence< ::rtl::OUString> aSeq;
2497 	aVal >>= aSeq;
2498 	return aSeq;
2499 }
2500 
getSelectedItemPos()2501 sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException)
2502 {
2503 	sal_Int16 n = -1;
2504 	if ( getPeer().is() )
2505 	{
2506 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2507 		n = xListBox->getSelectedItemPos();
2508 	}
2509 	return n;
2510 }
2511 
getSelectedItemsPos()2512 uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException)
2513 {
2514 	uno::Sequence<sal_Int16> aSeq;
2515 	if ( getPeer().is() )
2516 	{
2517 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2518 		aSeq = xListBox->getSelectedItemsPos();
2519 	}
2520 	return aSeq;
2521 }
2522 
getSelectedItem()2523 ::rtl::OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException)
2524 {
2525 	::rtl::OUString aItem;
2526 	if ( getPeer().is() )
2527 	{
2528 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2529 		aItem = xListBox->getSelectedItem();
2530 	}
2531 	return aItem;
2532 }
2533 
getSelectedItems()2534 uno::Sequence< ::rtl::OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException)
2535 {
2536 	uno::Sequence< ::rtl::OUString> aSeq;
2537 	if ( getPeer().is() )
2538 	{
2539 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2540 		aSeq = xListBox->getSelectedItems();
2541 	}
2542 	return aSeq;
2543 }
2544 
selectItemPos(sal_Int16 nPos,sal_Bool bSelect)2545 void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException)
2546 {
2547 	if ( getPeer().is() )
2548 	{
2549 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2550 		xListBox->selectItemPos( nPos, bSelect );
2551 	}
2552 	ImplUpdateSelectedItemsProperty();
2553 }
2554 
selectItemsPos(const uno::Sequence<sal_Int16> & aPositions,sal_Bool bSelect)2555 void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException)
2556 {
2557 	if ( getPeer().is() )
2558 	{
2559 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2560 		xListBox->selectItemsPos( aPositions, bSelect );
2561 	}
2562 	ImplUpdateSelectedItemsProperty();
2563 }
2564 
selectItem(const::rtl::OUString & aItem,sal_Bool bSelect)2565 void UnoListBoxControl::selectItem( const ::rtl::OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException)
2566 {
2567 	if ( getPeer().is() )
2568 	{
2569 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2570 		xListBox->selectItem( aItem, bSelect );
2571 	}
2572 	ImplUpdateSelectedItemsProperty();
2573 }
2574 
makeVisible(sal_Int16 nEntry)2575 void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException)
2576 {
2577 	if ( getPeer().is() )
2578 	{
2579 		uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
2580 		xListBox->makeVisible( nEntry );
2581 	}
2582 }
2583 
setDropDownLineCount(sal_Int16 nLines)2584 void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
2585 {
2586 	uno::Any aAny;
2587 	aAny <<= (sal_Int16)nLines;
2588 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
2589 }
2590 
getDropDownLineCount()2591 sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
2592 {
2593 	return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
2594 }
2595 
isMutipleMode()2596 sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException)
2597 {
2598 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION );
2599 }
2600 
setMultipleMode(sal_Bool bMulti)2601 void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException)
2602 {
2603 	uno::Any aAny;
2604 	aAny <<= bMulti;
2605 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, sal_True );
2606 }
2607 
itemStateChanged(const awt::ItemEvent & rEvent)2608 void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
2609 {
2610     ImplUpdateSelectedItemsProperty();
2611 	if ( maItemListeners.getLength() )
2612     {
2613         try
2614         {
2615 		    maItemListeners.itemStateChanged( rEvent );
2616         }
2617         catch( const Exception& e )
2618         {
2619 #if OSL_DEBUG_LEVEL == 0
2620             (void) e; // suppress warning
2621 #else
2622             ::rtl::OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
2623             sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
2624         	OSL_ENSURE( sal_False, sMessage.getStr() );
2625 #endif
2626         }
2627     }
2628 }
2629 
getMinimumSize()2630 awt::Size UnoListBoxControl::getMinimumSize(  ) throw(uno::RuntimeException)
2631 {
2632 	return Impl_getMinimumSize();
2633 }
2634 
getPreferredSize()2635 awt::Size UnoListBoxControl::getPreferredSize(  ) throw(uno::RuntimeException)
2636 {
2637 	return Impl_getPreferredSize();
2638 }
2639 
calcAdjustedSize(const awt::Size & rNewSize)2640 awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
2641 {
2642 	return Impl_calcAdjustedSize( rNewSize );
2643 }
2644 
getMinimumSize(sal_Int16 nCols,sal_Int16 nLines)2645 awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
2646 {
2647 	return Impl_getMinimumSize( nCols, nLines );
2648 }
2649 
getColumnsAndLines(sal_Int16 & nCols,sal_Int16 & nLines)2650 void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
2651 {
2652 	Impl_getColumnsAndLines( nCols, nLines );
2653 }
2654 
setModel(const uno::Reference<awt::XControlModel> & i_rModel)2655 sal_Bool SAL_CALL UnoListBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException )
2656 {
2657 	::osl::MutexGuard aGuard( GetMutex() );
2658 
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!" );
2663 
2664     if ( !UnoListBoxControl_Base::setModel( i_rModel ) )
2665         return sal_False;
2666 
2667     if ( xOldItems.is() )
2668         xOldItems->removeItemListListener( this );
2669     if ( xNewItems.is() )
2670         xNewItems->addItemListListener( this );
2671 
2672     return sal_True;
2673 }
2674 
listItemInserted(const awt::ItemListEvent & i_rEvent)2675 void SAL_CALL UnoListBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2676 {
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 );
2681 }
2682 
listItemRemoved(const awt::ItemListEvent & i_rEvent)2683 void SAL_CALL UnoListBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2684 {
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 );
2689 }
2690 
listItemModified(const awt::ItemListEvent & i_rEvent)2691 void SAL_CALL UnoListBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2692 {
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 );
2697 }
2698 
allItemsRemoved(const lang::EventObject & i_rEvent)2699 void SAL_CALL UnoListBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
2700 {
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 );
2705 }
2706 
itemListChanged(const lang::EventObject & i_rEvent)2707 void SAL_CALL UnoListBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
2708 {
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 );
2713 }
getActionListeners()2714 ActionListenerMultiplexer& 	UnoListBoxControl::getActionListeners()
2715 {
2716     return maActionListeners;
2717 }
getItemListeners()2718 ItemListenerMultiplexer& 	UnoListBoxControl::getItemListeners()
2719 {
2720     return maItemListeners;
2721 }
2722 //	----------------------------------------------------
2723 //	class UnoControlComboBoxModel
2724 //	----------------------------------------------------
UnoControlComboBoxModel(const Reference<XMultiServiceFactory> & i_factory)2725 UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference< XMultiServiceFactory >& i_factory )
2726     :UnoControlListBoxModel( i_factory, ConstructWithoutProperties )
2727 {
2728     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox );
2729 }
2730 
IMPL_SERVICEINFO_DERIVED(UnoControlComboBoxModel,UnoControlModel,szServiceName2_UnoControlComboBoxModel)2731 IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel )
2732 
2733 uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
2734 {
2735 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
2736 	return xInfo;
2737 }
2738 // ---------------------------------------------------------------------------------------------------------------------
getInfoHelper()2739 ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper()
2740 {
2741 	static UnoPropertyArrayHelper* pHelper = NULL;
2742 	if ( !pHelper )
2743 	{
2744 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
2745 		pHelper = new UnoPropertyArrayHelper( aIDs );
2746 	}
2747 	return *pHelper;
2748 }
2749 
2750 
getServiceName()2751 ::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
2752 {
2753 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel );
2754 }
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const uno::Any & rValue)2755 void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception)
2756 {
2757     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
2758 
2759     if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_pData->m_bSettingLegacyProperty)
2760 	{
2761         // synchronize the legacy StringItemList property with our list items
2762         Sequence< ::rtl::OUString > aStringItemList;
2763         Any aPropValue;
2764         getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
2765         OSL_VERIFY( aPropValue >>= aStringItemList );
2766 
2767         ::std::vector< ListItem > aItems( aStringItemList.getLength() );
2768         ::std::transform(
2769             aStringItemList.getConstArray(),
2770             aStringItemList.getConstArray() + aStringItemList.getLength(),
2771             aItems.begin(),
2772             CreateListItem()
2773         );
2774         m_pData->setAllItems( aItems );
2775 
2776         // since an XItemListListener does not have a "all items modified" or some such method,
2777         // we simulate this by notifying removal of all items, followed by insertion of all new
2778         // items
2779         lang::EventObject aEvent;
2780         aEvent.Source = *this;
2781         m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
2782         // TODO: OPropertySetHelper calls into this method with the mutex locked ...
2783         // which is wrong for the above notifications ...
2784 	}
2785 }
2786 
ImplGetDefaultValue(sal_uInt16 nPropId) const2787 uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
2788 {
2789 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
2790 	{
2791 		uno::Any aAny;
2792 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox );
2793 		return aAny;
2794 	}
2795 	return UnoControlModel::ImplGetDefaultValue( nPropId );
2796 }
2797 
2798 //	----------------------------------------------------
2799 //	class UnoComboBoxControl
2800 //	----------------------------------------------------
UnoComboBoxControl(const Reference<XMultiServiceFactory> & i_factory)2801 UnoComboBoxControl::UnoComboBoxControl( const Reference< XMultiServiceFactory >& i_factory )
2802 	:UnoEditControl( i_factory )
2803 	,maActionListeners( *this )
2804     ,maItemListeners( *this )
2805 {
2806 	maComponentInfos.nWidth = 100;
2807 	maComponentInfos.nHeight = 12;
2808 }
IMPL_SERVICEINFO_DERIVED(UnoComboBoxControl,UnoEditControl,szServiceName2_UnoControlComboBox)2809 IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox )
2810 
2811 ::rtl::OUString UnoComboBoxControl::GetComponentServiceName()
2812 {
2813 	return ::rtl::OUString::createFromAscii( "combobox" );
2814 }
2815 
dispose()2816 void UnoComboBoxControl::dispose() throw(uno::RuntimeException)
2817 {
2818 	lang::EventObject aEvt;
2819 	aEvt.Source = (::cppu::OWeakObject*)this;
2820 	maActionListeners.disposeAndClear( aEvt );
2821 	maItemListeners.disposeAndClear( aEvt );
2822 	UnoControl::dispose();
2823 }
queryAggregation(const uno::Type & rType)2824 uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
2825 {
2826 	uno::Any aRet = ::cppu::queryInterface( rType,
2827 										SAL_STATIC_CAST( awt::XComboBox*, this ) );
2828     if ( !aRet.hasValue() )
2829     {
2830         aRet = ::cppu::queryInterface( rType,
2831 										SAL_STATIC_CAST( awt::XItemListener*, this ) );
2832         if ( !aRet.hasValue() )
2833         {
2834             aRet = ::cppu::queryInterface( rType,
2835 										    SAL_STATIC_CAST( awt::XItemListListener*, this ) );
2836         }
2837     }
2838 	return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
2839 }
2840 // lang::XTypeProvider
2841 IMPL_XTYPEPROVIDER_START( UnoComboBoxControl )
2842 	getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ),
2843     getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ),
2844     getCppuType( ( uno::Reference< awt::XItemListListener>* ) NULL ),
2845 	UnoEditControl::getTypes()
2846 IMPL_XTYPEPROVIDER_END
2847 
2848 void UnoComboBoxControl::updateFromModel()
2849 {
2850     UnoEditControl::updateFromModel();
2851 
2852     Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
2853     ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
2854 
2855     EventObject aEvent( getModel() );
2856     xItemListListener->itemListChanged( aEvent );
2857 }
ImplSetPeerProperty(const::rtl::OUString & rPropName,const uno::Any & rVal)2858 void UnoComboBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
2859 {
2860     if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
2861         // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
2862         // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
2863         // will be forwarded to the peer, which will update itself accordingly.
2864         return;
2865 
2866 	UnoEditControl::ImplSetPeerProperty( rPropName, rVal );
2867 }
createPeer(const uno::Reference<awt::XToolkit> & rxToolkit,const uno::Reference<awt::XWindowPeer> & rParentPeer)2868 void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
2869 {
2870 	UnoEditControl::createPeer( rxToolkit, rParentPeer );
2871 
2872 	uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
2873 	if ( maActionListeners.getLength() )
2874 		xComboBox->addActionListener( &maActionListeners );
2875 	if ( maItemListeners.getLength() )
2876 		xComboBox->addItemListener( &maItemListeners );
2877 }
2878 
addActionListener(const uno::Reference<awt::XActionListener> & l)2879 void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2880 {
2881 	maActionListeners.addInterface( l );
2882 	if( getPeer().is() && maActionListeners.getLength() == 1 )
2883 	{
2884 		uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
2885 		xComboBox->addActionListener( &maActionListeners );
2886 	}
2887 }
2888 
removeActionListener(const uno::Reference<awt::XActionListener> & l)2889 void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
2890 {
2891 	if( getPeer().is() && maActionListeners.getLength() == 1 )
2892 	{
2893 		uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
2894 		xComboBox->removeActionListener( &maActionListeners );
2895 	}
2896 	maActionListeners.removeInterface( l );
2897 }
2898 
addItemListener(const uno::Reference<awt::XItemListener> & l)2899 void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2900 {
2901 	maItemListeners.addInterface( l );
2902 	if( getPeer().is() && maItemListeners.getLength() == 1 )
2903 	{
2904 		uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
2905 		xComboBox->addItemListener( &maItemListeners );
2906 	}
2907 }
2908 
removeItemListener(const uno::Reference<awt::XItemListener> & l)2909 void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
2910 {
2911 	if( getPeer().is() && maItemListeners.getLength() == 1 )
2912 	{
2913 		uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );	// MT: Mal alles so umstellen, schoener als Ref anlegen und query rufen
2914 		xComboBox->removeItemListener( &maItemListeners );
2915 	}
2916 	maItemListeners.removeInterface( l );
2917 }
itemStateChanged(const awt::ItemEvent & rEvent)2918 void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
2919 {
2920 	if ( maItemListeners.getLength() )
2921     {
2922         try
2923         {
2924 		    maItemListeners.itemStateChanged( rEvent );
2925         }
2926         catch( const Exception& e )
2927         {
2928 #if OSL_DEBUG_LEVEL == 0
2929             (void) e; // suppress warning
2930 #else
2931             ::rtl::OString sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
2932             sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
2933         	OSL_ENSURE( sal_False, sMessage.getStr() );
2934 #endif
2935         }
2936     }
2937 }
setModel(const uno::Reference<awt::XControlModel> & i_rModel)2938 sal_Bool SAL_CALL UnoComboBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException )
2939 {
2940 	::osl::MutexGuard aGuard( GetMutex() );
2941 
2942     const Reference< XItemList > xOldItems( getModel(), UNO_QUERY );
2943     OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
2944     const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY );
2945     OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoComboBoxControl::setModel: illegal new model!" );
2946 
2947     if ( !UnoEditControl::setModel( i_rModel ) )
2948         return sal_False;
2949 
2950     if ( xOldItems.is() )
2951         xOldItems->removeItemListListener( this );
2952     if ( xNewItems.is() )
2953         xNewItems->addItemListListener( this );
2954 
2955     return sal_True;
2956 }
2957 
listItemInserted(const awt::ItemListEvent & i_rEvent)2958 void SAL_CALL UnoComboBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2959 {
2960     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
2961     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
2962     if ( xPeerListener.is() )
2963         xPeerListener->listItemInserted( i_rEvent );
2964 }
2965 
listItemRemoved(const awt::ItemListEvent & i_rEvent)2966 void SAL_CALL UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2967 {
2968     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
2969     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
2970     if ( xPeerListener.is() )
2971         xPeerListener->listItemRemoved( i_rEvent );
2972 }
2973 
listItemModified(const awt::ItemListEvent & i_rEvent)2974 void SAL_CALL UnoComboBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
2975 {
2976     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
2977     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
2978     if ( xPeerListener.is() )
2979         xPeerListener->listItemModified( i_rEvent );
2980 }
2981 
allItemsRemoved(const lang::EventObject & i_rEvent)2982 void SAL_CALL UnoComboBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
2983 {
2984     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
2985     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
2986     if ( xPeerListener.is() )
2987         xPeerListener->allItemsRemoved( i_rEvent );
2988 }
2989 
itemListChanged(const lang::EventObject & i_rEvent)2990 void SAL_CALL UnoComboBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
2991 {
2992     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
2993     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
2994     if ( xPeerListener.is() )
2995         xPeerListener->itemListChanged( i_rEvent );
2996 }
getActionListeners()2997 ActionListenerMultiplexer& 	UnoComboBoxControl::getActionListeners()
2998 {
2999     return maActionListeners;
3000 }
getItemListeners()3001 ItemListenerMultiplexer& 	UnoComboBoxControl::getItemListeners()
3002 {
3003     return maItemListeners;
3004 }
3005 
addItem(const::rtl::OUString & aItem,sal_Int16 nPos)3006 void UnoComboBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
3007 {
3008 	uno::Sequence< ::rtl::OUString> aSeq( 1 );
3009 	aSeq.getArray()[0] = aItem;
3010 	addItems( aSeq, nPos );
3011 }
3012 
addItems(const uno::Sequence<::rtl::OUString> & aItems,sal_Int16 nPos)3013 void UnoComboBoxControl::addItems( const uno::Sequence< ::rtl::OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
3014 {
3015 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3016 	uno::Sequence< ::rtl::OUString> aSeq;
3017 	aVal >>= aSeq;
3018 	sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
3019 	sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
3020 	sal_uInt16 nNewLen = nOldLen + nNewItems;
3021 
3022 	uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
3023 	::rtl::OUString* pNewData = aNewSeq.getArray();
3024 	const ::rtl::OUString* pOldData = aSeq.getConstArray();
3025 
3026 	if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
3027 		nPos = (sal_uInt16) nOldLen;
3028 
3029 	sal_uInt16 n;
3030 	// Items vor der Einfuege-Position
3031 	for ( n = 0; n < nPos; n++ )
3032 		pNewData[n] = pOldData[n];
3033 
3034 	// Neue Items
3035 	for ( n = 0; n < nNewItems; n++ )
3036 		pNewData[nPos+n] = aItems.getConstArray()[n];
3037 
3038 	// Rest der alten Items
3039 	for ( n = nPos; n < nOldLen; n++ )
3040 		pNewData[nNewItems+n] = pOldData[n];
3041 
3042 	uno::Any aAny;
3043 	aAny <<= aNewSeq;
3044 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
3045 }
3046 
removeItems(sal_Int16 nPos,sal_Int16 nCount)3047 void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
3048 {
3049 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3050 	uno::Sequence< ::rtl::OUString> aSeq;
3051 	aVal >>= aSeq;
3052 	sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
3053 	if ( nOldLen && ( nPos < nOldLen ) )
3054 	{
3055 		if ( nCount > ( nOldLen-nPos ) )
3056 			nCount = nOldLen-nPos;
3057 
3058 		sal_uInt16 nNewLen = nOldLen - nCount;
3059 
3060 		uno::Sequence< ::rtl::OUString> aNewSeq( nNewLen );
3061 		::rtl::OUString* pNewData = aNewSeq.getArray();
3062 		::rtl::OUString* pOldData = aSeq.getArray();
3063 
3064 		sal_uInt16 n;
3065 		// Items vor der Entfern-Position
3066 		for ( n = 0; n < nPos; n++ )
3067 			pNewData[n] = pOldData[n];
3068 
3069 		// Rest der Items
3070 		for ( n = nPos; n < (nOldLen-nCount); n++ )
3071 			pNewData[n] = pOldData[n+nCount];
3072 
3073 		uno::Any aAny;
3074 		aAny <<= aNewSeq;
3075 		ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
3076 	}
3077 }
3078 
getItemCount()3079 sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException)
3080 {
3081 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3082 	uno::Sequence< ::rtl::OUString> aSeq;
3083 	aVal >>= aSeq;
3084 	return (sal_Int16)aSeq.getLength();
3085 }
3086 
getItem(sal_Int16 nPos)3087 ::rtl::OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
3088 {
3089 	::rtl::OUString aItem;
3090 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3091 	uno::Sequence< ::rtl::OUString> aSeq;
3092 	aVal >>= aSeq;
3093 	if ( nPos < aSeq.getLength() )
3094 		aItem = aSeq.getConstArray()[nPos];
3095 	return aItem;
3096 }
3097 
getItems()3098 uno::Sequence< ::rtl::OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException)
3099 {
3100 	uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
3101 	uno::Sequence< ::rtl::OUString> aSeq;
3102 	aVal >>= aSeq;
3103 	return aSeq;
3104 }
3105 
setDropDownLineCount(sal_Int16 nLines)3106 void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
3107 {
3108 	uno::Any aAny;
3109 	aAny <<= nLines;
3110 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
3111 }
3112 
getDropDownLineCount()3113 sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
3114 {
3115 	return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
3116 }
3117 
3118 
3119 //	----------------------------------------------------
3120 //	UnoSpinFieldControl
3121 //	----------------------------------------------------
UnoSpinFieldControl(const Reference<XMultiServiceFactory> & i_factory)3122 UnoSpinFieldControl::UnoSpinFieldControl( const Reference< XMultiServiceFactory >& i_factory )
3123 	:UnoEditControl( i_factory )
3124     ,maSpinListeners( *this )
3125 {
3126     mbRepeat = sal_False;
3127 }
3128 
3129 // uno::XInterface
queryAggregation(const uno::Type & rType)3130 uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3131 {
3132 	uno::Any aRet = ::cppu::queryInterface( rType,
3133 										SAL_STATIC_CAST( awt::XSpinField*, this ) );
3134 	return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
3135 }
3136 
3137 // lang::XTypeProvider
3138 IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl )
3139 	getCppuType( ( uno::Reference< awt::XSpinField>* ) NULL ),
3140 	UnoEditControl::getTypes()
3141 IMPL_XTYPEPROVIDER_END
3142 
3143 void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
3144 {
3145 	UnoEditControl::createPeer( rxToolkit, rParentPeer );
3146 
3147     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3148     xField->enableRepeat( mbRepeat );
3149 	if ( maSpinListeners.getLength() )
3150 		xField->addSpinListener( &maSpinListeners );
3151 }
3152 
3153 	// ::com::sun::star::awt::XSpinField
addSpinListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XSpinListener> & l)3154 void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
3155 {
3156 	maSpinListeners.addInterface( l );
3157 	if( getPeer().is() && maSpinListeners.getLength() == 1 )
3158 	{
3159 		uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3160 		xField->addSpinListener( &maSpinListeners );
3161 	}
3162 }
3163 
removeSpinListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XSpinListener> & l)3164 void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
3165 {
3166 	if( getPeer().is() && maSpinListeners.getLength() == 1 )
3167 	{
3168 		uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3169 		xField->removeSpinListener( &maSpinListeners );
3170 	}
3171 	maSpinListeners.removeInterface( l );
3172 }
3173 
up()3174 void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException)
3175 {
3176     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3177 	if ( xField.is() )
3178         xField->up();
3179 }
3180 
down()3181 void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException)
3182 {
3183     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3184 	if ( xField.is() )
3185         xField->down();
3186 }
3187 
first()3188 void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException)
3189 {
3190     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3191 	if ( xField.is() )
3192         xField->first();
3193 }
3194 
last()3195 void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException)
3196 {
3197     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3198 	if ( xField.is() )
3199         xField->last();
3200 }
3201 
enableRepeat(sal_Bool bRepeat)3202 void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException)
3203 {
3204     mbRepeat = bRepeat;
3205 
3206     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
3207 	if ( xField.is() )
3208         xField->enableRepeat( bRepeat );
3209 }
3210 
3211 //	----------------------------------------------------
3212 //	class UnoControlDateFieldModel
3213 //	----------------------------------------------------
UnoControlDateFieldModel(const Reference<XMultiServiceFactory> & i_factory)3214 UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference< XMultiServiceFactory >& i_factory )
3215     :UnoControlModel( i_factory )
3216 {
3217     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField );
3218 }
3219 
getServiceName()3220 ::rtl::OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3221 {
3222 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateFieldModel );
3223 }
3224 
ImplGetDefaultValue(sal_uInt16 nPropId) const3225 uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3226 {
3227 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3228 	{
3229 		uno::Any aAny;
3230 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDateField );
3231 		return aAny;
3232 	}
3233 	return UnoControlModel::ImplGetDefaultValue( nPropId );
3234 }
3235 
3236 
getInfoHelper()3237 ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper()
3238 {
3239 	static UnoPropertyArrayHelper* pHelper = NULL;
3240 	if ( !pHelper )
3241 	{
3242 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
3243 		pHelper = new UnoPropertyArrayHelper( aIDs );
3244 	}
3245 	return *pHelper;
3246 }
3247 
3248 // beans::XMultiPropertySet
getPropertySetInfo()3249 uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
3250 {
3251 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3252 	return xInfo;
3253 }
3254 
3255 
3256 
3257 //	----------------------------------------------------
3258 //	class UnoDateFieldControl
3259 //	----------------------------------------------------
UnoDateFieldControl(const Reference<XMultiServiceFactory> & i_factory)3260 UnoDateFieldControl::UnoDateFieldControl( const Reference< XMultiServiceFactory >& i_factory )
3261     :UnoSpinFieldControl( i_factory )
3262 {
3263     mnFirst = Date( 1, 1, 1900 ).GetDate();
3264     mnLast = Date( 31, 12, 2200 ).GetDate();
3265     mbLongFormat = 2;
3266 }
3267 
GetComponentServiceName()3268 ::rtl::OUString UnoDateFieldControl::GetComponentServiceName()
3269 {
3270 	return ::rtl::OUString::createFromAscii( "datefield" );
3271 }
3272 
3273 // uno::XInterface
queryAggregation(const uno::Type & rType)3274 uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3275 {
3276 	uno::Any aRet = ::cppu::queryInterface( rType,
3277 										SAL_STATIC_CAST( awt::XDateField*, this ) );
3278 	return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3279 }
3280 
3281 // lang::XTypeProvider
3282 IMPL_XTYPEPROVIDER_START( UnoDateFieldControl )
3283 	getCppuType( ( uno::Reference< awt::XDateField>* ) NULL ),
3284 	UnoSpinFieldControl::getTypes()
3285 IMPL_XTYPEPROVIDER_END
3286 
3287 void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
3288 {
3289 	UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3290 
3291 	uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3292 	xField->setFirst( mnFirst );
3293     xField->setLast( mnLast );
3294     if ( mbLongFormat != 2 )    // not set
3295         xField->setLongFormat( mbLongFormat );
3296 }
3297 
3298 
textChanged(const awt::TextEvent & e)3299 void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3300 {
3301     uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
3302 
3303     // also change the text property (#i25106#)
3304     if ( xPeer.is() )
3305     {
3306         ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
3307         ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
3308     }
3309 
3310     // re-calc the Date property
3311     uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3312 	uno::Any aValue;
3313     if ( xField->isEmpty() )
3314     {
3315         // the field says it's empty
3316         sal_Bool bEnforceFormat = sal_True;
3317         if ( xPeer.is() )
3318             xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat;
3319         if ( !bEnforceFormat )
3320         {
3321             // and it also says that it is currently accepting invalid inputs, without
3322             // forcing it to a valid date
3323             uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY );
3324             if ( xText.is() && xText->getText().getLength() )
3325                 // and in real, the text of the peer is *not* empty
3326                 // -> simulate an invalid date, which is different from "no date"
3327                 aValue <<= util::Date( 0, 0, 0 );
3328         }
3329     }
3330     else
3331 		aValue <<= xField->getDate();
3332 
3333 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, sal_False );
3334 
3335     // multiplex the event
3336     if ( GetTextListeners().getLength() )
3337 		GetTextListeners().textChanged( e );
3338 }
3339 
setDate(sal_Int32 Date)3340 void UnoDateFieldControl::setDate( sal_Int32 Date ) throw(uno::RuntimeException)
3341 {
3342 	uno::Any aAny;
3343 	aAny <<= Date;
3344 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, sal_True );
3345 }
3346 
getDate()3347 sal_Int32 UnoDateFieldControl::getDate() throw(uno::RuntimeException)
3348 {
3349 	return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE );
3350 }
3351 
setMin(sal_Int32 Date)3352 void UnoDateFieldControl::setMin( sal_Int32 Date ) throw(uno::RuntimeException)
3353 {
3354 	uno::Any aAny;
3355 	aAny <<= Date;
3356 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, sal_True );
3357 }
3358 
getMin()3359 sal_Int32 UnoDateFieldControl::getMin() throw(uno::RuntimeException)
3360 {
3361 	return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN );
3362 }
3363 
setMax(sal_Int32 Date)3364 void UnoDateFieldControl::setMax( sal_Int32 Date ) throw(uno::RuntimeException)
3365 {
3366 	uno::Any aAny;
3367 	aAny <<= Date;
3368 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, sal_True );
3369 }
3370 
getMax()3371 sal_Int32 UnoDateFieldControl::getMax() throw(uno::RuntimeException)
3372 {
3373 	return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX );
3374 }
3375 
setFirst(sal_Int32 Date)3376 void UnoDateFieldControl::setFirst( sal_Int32 Date ) throw(uno::RuntimeException)
3377 {
3378 	mnFirst = Date;
3379 	if ( getPeer().is() )
3380 	{
3381 		uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3382         xField->setFirst( Date );
3383     }
3384 }
3385 
getFirst()3386 sal_Int32 UnoDateFieldControl::getFirst() throw(uno::RuntimeException)
3387 {
3388 	return mnFirst;
3389 }
3390 
setLast(sal_Int32 Date)3391 void UnoDateFieldControl::setLast( sal_Int32 Date ) throw(uno::RuntimeException)
3392 {
3393 	mnLast = Date;
3394 	if ( getPeer().is() )
3395 	{
3396 		uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3397         xField->setLast( Date );
3398     }
3399 }
3400 
getLast()3401 sal_Int32 UnoDateFieldControl::getLast() throw(uno::RuntimeException)
3402 {
3403 	return mnLast;
3404 }
3405 
setLongFormat(sal_Bool bLong)3406 void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException)
3407 {
3408 	mbLongFormat = bLong;
3409 	if ( getPeer().is() )
3410 	{
3411 		uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3412         xField->setLongFormat( bLong );
3413     }
3414 }
3415 
isLongFormat()3416 sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException)
3417 {
3418 	return ( mbLongFormat != 2 ) ? mbLongFormat : sal_False;
3419 }
3420 
setEmpty()3421 void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException)
3422 {
3423 	if ( getPeer().is() )
3424 	{
3425 		uno::Reference < awt::XDateField >  xField( getPeer(), uno::UNO_QUERY );
3426 		xField->setEmpty();
3427 	}
3428 }
3429 
isEmpty()3430 sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException)
3431 {
3432 	sal_Bool bEmpty = sal_False;
3433 	if ( getPeer().is() )
3434 	{
3435 		uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
3436 		bEmpty = xField->isEmpty();
3437 	}
3438 	return bEmpty;
3439 }
3440 
setStrictFormat(sal_Bool bStrict)3441 void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3442 {
3443 	uno::Any aAny;
3444 	aAny <<= bStrict;
3445 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3446 }
3447 
isStrictFormat()3448 sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException)
3449 {
3450 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3451 }
3452 
3453 //	----------------------------------------------------
3454 //	class UnoControlTimeFieldModel
3455 //	----------------------------------------------------
UnoControlTimeFieldModel(const Reference<XMultiServiceFactory> & i_factory)3456 UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference< XMultiServiceFactory >& i_factory )
3457     :UnoControlModel( i_factory )
3458 {
3459     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField );
3460 }
3461 
getServiceName()3462 ::rtl::OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3463 {
3464 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel );
3465 }
3466 
ImplGetDefaultValue(sal_uInt16 nPropId) const3467 uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3468 {
3469 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3470 	{
3471 		uno::Any aAny;
3472 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTimeField );
3473 		return aAny;
3474 	}
3475 	return UnoControlModel::ImplGetDefaultValue( nPropId );
3476 }
3477 
3478 
getInfoHelper()3479 ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper()
3480 {
3481 	static UnoPropertyArrayHelper* pHelper = NULL;
3482 	if ( !pHelper )
3483 	{
3484 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
3485 		pHelper = new UnoPropertyArrayHelper( aIDs );
3486 	}
3487 	return *pHelper;
3488 }
3489 
3490 // beans::XMultiPropertySet
getPropertySetInfo()3491 uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
3492 {
3493 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3494 	return xInfo;
3495 }
3496 
3497 
3498 
3499 //	----------------------------------------------------
3500 //	class UnoTimeFieldControl
3501 //	----------------------------------------------------
UnoTimeFieldControl(const Reference<XMultiServiceFactory> & i_factory)3502 UnoTimeFieldControl::UnoTimeFieldControl( const Reference< XMultiServiceFactory >& i_factory )
3503     :UnoSpinFieldControl( i_factory )
3504 {
3505     mnFirst = Time( 0, 0 ).GetTime();
3506     mnLast = Time( 23, 59, 59, 99 ).GetTime();
3507 }
3508 
GetComponentServiceName()3509 ::rtl::OUString UnoTimeFieldControl::GetComponentServiceName()
3510 {
3511 	return ::rtl::OUString::createFromAscii( "timefield" );
3512 }
3513 
3514 // uno::XInterface
queryAggregation(const uno::Type & rType)3515 uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3516 {
3517 	uno::Any aRet = ::cppu::queryInterface( rType,
3518 										SAL_STATIC_CAST( awt::XTimeField*, this ) );
3519 	return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3520 }
3521 
3522 // lang::XTypeProvider
3523 IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl )
3524 	getCppuType( ( uno::Reference< awt::XTimeField>* ) NULL ),
3525 	UnoSpinFieldControl::getTypes()
3526 IMPL_XTYPEPROVIDER_END
3527 
3528 void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
3529 {
3530 	UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3531 
3532 	uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3533 	xField->setFirst( mnFirst );
3534     xField->setLast( mnLast );
3535 }
3536 
textChanged(const awt::TextEvent & e)3537 void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3538 {
3539     // also change the text property (#i25106#)
3540     uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
3541     ::rtl::OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
3542     ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
3543 
3544     // re-calc the Time property
3545 	uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
3546 	uno::Any aValue;
3547 	if ( !xField->isEmpty() )
3548 		aValue <<= xField->getTime();
3549 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, sal_False );
3550 
3551     // multiplex the event
3552     if ( GetTextListeners().getLength() )
3553 		GetTextListeners().textChanged( e );
3554 }
3555 
setTime(sal_Int32 Time)3556 void UnoTimeFieldControl::setTime( sal_Int32 Time ) throw(uno::RuntimeException)
3557 {
3558 	uno::Any aAny;
3559 	aAny <<= Time;
3560 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, sal_True );
3561 }
3562 
getTime()3563 sal_Int32 UnoTimeFieldControl::getTime() throw(uno::RuntimeException)
3564 {
3565 	return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME );
3566 }
3567 
setMin(sal_Int32 Time)3568 void UnoTimeFieldControl::setMin( sal_Int32 Time ) throw(uno::RuntimeException)
3569 {
3570 	uno::Any aAny;
3571 	aAny <<= Time;
3572 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, sal_True );
3573 }
3574 
getMin()3575 sal_Int32 UnoTimeFieldControl::getMin() throw(uno::RuntimeException)
3576 {
3577 	return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN );
3578 }
3579 
setMax(sal_Int32 Time)3580 void UnoTimeFieldControl::setMax( sal_Int32 Time ) throw(uno::RuntimeException)
3581 {
3582 	uno::Any aAny;
3583 	aAny <<= Time;
3584 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, sal_True );
3585 }
3586 
getMax()3587 sal_Int32 UnoTimeFieldControl::getMax() throw(uno::RuntimeException)
3588 {
3589 	return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX );
3590 }
3591 
setFirst(sal_Int32 Time)3592 void UnoTimeFieldControl::setFirst( sal_Int32 Time ) throw(uno::RuntimeException)
3593 {
3594 	mnFirst = Time;
3595 	if ( getPeer().is() )
3596 	{
3597 		uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3598         xField->setFirst( mnFirst );
3599     }
3600 }
3601 
getFirst()3602 sal_Int32 UnoTimeFieldControl::getFirst() throw(uno::RuntimeException)
3603 {
3604 	return mnFirst;
3605 }
3606 
setLast(sal_Int32 Time)3607 void UnoTimeFieldControl::setLast( sal_Int32 Time ) throw(uno::RuntimeException)
3608 {
3609 	mnLast = Time;
3610 	if ( getPeer().is() )
3611 	{
3612 		uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
3613         xField->setFirst( mnLast );
3614     }
3615 }
3616 
getLast()3617 sal_Int32 UnoTimeFieldControl::getLast() throw(uno::RuntimeException)
3618 {
3619 	return mnLast;
3620 }
3621 
setEmpty()3622 void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException)
3623 {
3624 	if ( getPeer().is() )
3625 	{
3626 		uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
3627 		xField->setEmpty();
3628 	}
3629 }
3630 
isEmpty()3631 sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException)
3632 {
3633 	sal_Bool bEmpty = sal_False;
3634 	if ( getPeer().is() )
3635 	{
3636 		uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
3637 		bEmpty = xField->isEmpty();
3638 	}
3639 	return bEmpty;
3640 }
3641 
setStrictFormat(sal_Bool bStrict)3642 void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3643 {
3644 	uno::Any aAny;
3645 	aAny <<= bStrict;
3646 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3647 }
3648 
isStrictFormat()3649 sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException)
3650 {
3651 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3652 }
3653 
3654 //	----------------------------------------------------
3655 //	class UnoControlNumericFieldModel
3656 //	----------------------------------------------------
UnoControlNumericFieldModel(const Reference<XMultiServiceFactory> & i_factory)3657 UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference< XMultiServiceFactory >& i_factory )
3658     :UnoControlModel( i_factory )
3659 {
3660     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField );
3661 }
3662 
getServiceName()3663 ::rtl::OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3664 {
3665 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel );
3666 }
3667 
ImplGetDefaultValue(sal_uInt16 nPropId) const3668 uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3669 {
3670 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3671 	{
3672 		uno::Any aAny;
3673 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlNumericField );
3674 		return aAny;
3675 	}
3676 	return UnoControlModel::ImplGetDefaultValue( nPropId );
3677 }
3678 
3679 
getInfoHelper()3680 ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper()
3681 {
3682 	static UnoPropertyArrayHelper* pHelper = NULL;
3683 	if ( !pHelper )
3684 	{
3685 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
3686 		pHelper = new UnoPropertyArrayHelper( aIDs );
3687 	}
3688 	return *pHelper;
3689 }
3690 
3691 // beans::XMultiPropertySet
getPropertySetInfo()3692 uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
3693 {
3694 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3695 	return xInfo;
3696 }
3697 
3698 
3699 
3700 //	----------------------------------------------------
3701 //	class UnoNumericFieldControl
3702 //	----------------------------------------------------
UnoNumericFieldControl(const Reference<XMultiServiceFactory> & i_factory)3703 UnoNumericFieldControl::UnoNumericFieldControl( const Reference< XMultiServiceFactory >& i_factory )
3704     :UnoSpinFieldControl( i_factory )
3705 {
3706     mnFirst = 0;
3707     mnLast = 0x7FFFFFFF;
3708 }
3709 
GetComponentServiceName()3710 ::rtl::OUString UnoNumericFieldControl::GetComponentServiceName()
3711 {
3712 	return ::rtl::OUString::createFromAscii( "numericfield" );
3713 }
3714 
3715 // uno::XInterface
queryAggregation(const uno::Type & rType)3716 uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3717 {
3718 	uno::Any aRet = ::cppu::queryInterface( rType,
3719 										SAL_STATIC_CAST( awt::XNumericField*, this ) );
3720 	return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3721 }
3722 
3723 // lang::XTypeProvider
3724 IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl )
3725 	getCppuType( ( uno::Reference< awt::XNumericField>* ) NULL ),
3726 	UnoSpinFieldControl::getTypes()
3727 IMPL_XTYPEPROVIDER_END
3728 
3729 void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
3730 {
3731 	UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3732 
3733 	uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3734 	xField->setFirst( mnFirst );
3735     xField->setLast( mnLast );
3736 }
3737 
3738 
textChanged(const awt::TextEvent & e)3739 void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3740 {
3741 	uno::Reference < awt::XNumericField >  xField( getPeer(), uno::UNO_QUERY );
3742 	uno::Any aAny;
3743 	aAny <<= xField->getValue();
3744 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3745 
3746 	if ( GetTextListeners().getLength() )
3747 		GetTextListeners().textChanged( e );
3748 }
3749 
setValue(double Value)3750 void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3751 {
3752 	uno::Any aAny;
3753 	aAny <<= Value;
3754 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3755 }
3756 
getValue()3757 double UnoNumericFieldControl::getValue() throw(uno::RuntimeException)
3758 {
3759 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3760 }
3761 
setMin(double Value)3762 void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3763 {
3764 	uno::Any aAny;
3765 	aAny <<= Value;
3766 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3767 }
3768 
getMin()3769 double UnoNumericFieldControl::getMin() throw(uno::RuntimeException)
3770 {
3771 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3772 }
3773 
setMax(double Value)3774 void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3775 {
3776 	uno::Any aAny;
3777 	aAny <<= Value;
3778 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3779 }
3780 
getMax()3781 double UnoNumericFieldControl::getMax() throw(uno::RuntimeException)
3782 {
3783 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3784 }
3785 
setFirst(double Value)3786 void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3787 {
3788 	mnFirst = Value;
3789 	if ( getPeer().is() )
3790 	{
3791 		uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3792         xField->setFirst( mnFirst );
3793     }
3794 }
3795 
getFirst()3796 double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException)
3797 {
3798 	return mnFirst;
3799 }
3800 
setLast(double Value)3801 void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException)
3802 {
3803 	mnLast = Value;
3804 	if ( getPeer().is() )
3805 	{
3806 		uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
3807         xField->setLast( mnLast );
3808     }
3809 }
3810 
getLast()3811 double UnoNumericFieldControl::getLast() throw(uno::RuntimeException)
3812 {
3813 	return mnLast;
3814 }
3815 
setStrictFormat(sal_Bool bStrict)3816 void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
3817 {
3818 	uno::Any aAny;
3819 	aAny <<= bStrict;
3820 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
3821 }
3822 
isStrictFormat()3823 sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException)
3824 {
3825 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
3826 }
3827 
setSpinSize(double Digits)3828 void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
3829 {
3830 	uno::Any aAny;
3831 	aAny <<= Digits;
3832 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
3833 }
3834 
getSpinSize()3835 double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException)
3836 {
3837 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
3838 }
3839 
setDecimalDigits(sal_Int16 Digits)3840 void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
3841 {
3842 	uno::Any aAny;
3843 	aAny <<= Digits;
3844     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
3845 }
3846 
getDecimalDigits()3847 sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException)
3848 {
3849 	return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
3850 }
3851 
3852 //	----------------------------------------------------
3853 //	class UnoControlCurrencyFieldModel
3854 //	----------------------------------------------------
UnoControlCurrencyFieldModel(const Reference<XMultiServiceFactory> & i_factory)3855 UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference< XMultiServiceFactory >& i_factory )
3856     :UnoControlModel( i_factory )
3857 {
3858     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField );
3859 }
3860 
getServiceName()3861 ::rtl::OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
3862 {
3863 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel );
3864 }
3865 
ImplGetDefaultValue(sal_uInt16 nPropId) const3866 uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
3867 {
3868 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
3869 	{
3870 		uno::Any aAny;
3871 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlCurrencyField );
3872 		return aAny;
3873 	}
3874 	if ( nPropId == BASEPROPERTY_CURSYM_POSITION )
3875 	{
3876 		uno::Any aAny;
3877 		aAny <<= (sal_Bool)sal_False;
3878 		return aAny;
3879 	}
3880 
3881 	return UnoControlModel::ImplGetDefaultValue( nPropId );
3882 }
3883 
getInfoHelper()3884 ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper()
3885 {
3886 	static UnoPropertyArrayHelper* pHelper = NULL;
3887 	if ( !pHelper )
3888 	{
3889 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
3890 		pHelper = new UnoPropertyArrayHelper( aIDs );
3891 	}
3892 	return *pHelper;
3893 }
3894 
3895 // beans::XMultiPropertySet
getPropertySetInfo()3896 uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
3897 {
3898 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3899 	return xInfo;
3900 }
3901 
3902 //	----------------------------------------------------
3903 //	class UnoCurrencyFieldControl
3904 //	----------------------------------------------------
UnoCurrencyFieldControl(const Reference<XMultiServiceFactory> & i_factory)3905 UnoCurrencyFieldControl::UnoCurrencyFieldControl( const Reference< XMultiServiceFactory >& i_factory )
3906     :UnoSpinFieldControl( i_factory )
3907 {
3908     mnFirst = 0;
3909     mnLast = 0x7FFFFFFF;
3910 }
3911 
GetComponentServiceName()3912 ::rtl::OUString UnoCurrencyFieldControl::GetComponentServiceName()
3913 {
3914 	return ::rtl::OUString::createFromAscii( "longcurrencyfield" );
3915 }
3916 
3917 // uno::XInterface
queryAggregation(const uno::Type & rType)3918 uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
3919 {
3920 	uno::Any aRet = ::cppu::queryInterface( rType,
3921 										SAL_STATIC_CAST( awt::XCurrencyField*, this ) );
3922 	return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
3923 }
3924 
3925 // lang::XTypeProvider
3926 IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl )
3927 	getCppuType( ( uno::Reference< awt::XCurrencyField>* ) NULL ),
3928 	UnoSpinFieldControl::getTypes()
3929 IMPL_XTYPEPROVIDER_END
3930 
3931 void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
3932 {
3933 	UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
3934 
3935 	uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3936 	xField->setFirst( mnFirst );
3937     xField->setLast( mnLast );
3938 }
3939 
textChanged(const awt::TextEvent & e)3940 void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
3941 {
3942 	uno::Reference < awt::XCurrencyField >  xField( getPeer(), uno::UNO_QUERY );
3943 	uno::Any aAny;
3944 	aAny <<= xField->getValue();
3945 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
3946 
3947 	if ( GetTextListeners().getLength() )
3948 		GetTextListeners().textChanged( e );
3949 }
3950 
setValue(double Value)3951 void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException)
3952 {
3953 	uno::Any aAny;
3954 	aAny <<= Value;
3955 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
3956 }
3957 
getValue()3958 double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException)
3959 {
3960 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
3961 }
3962 
setMin(double Value)3963 void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException)
3964 {
3965 	uno::Any aAny;
3966 	aAny <<= Value;
3967 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
3968 }
3969 
getMin()3970 double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException)
3971 {
3972 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
3973 }
3974 
setMax(double Value)3975 void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException)
3976 {
3977 	uno::Any aAny;
3978 	aAny <<= Value;
3979 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
3980 }
3981 
getMax()3982 double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException)
3983 {
3984 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
3985 }
3986 
setFirst(double Value)3987 void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
3988 {
3989 	mnFirst = Value;
3990 	if ( getPeer().is() )
3991 	{
3992 		uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
3993         xField->setFirst( mnFirst );
3994     }
3995 }
3996 
getFirst()3997 double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException)
3998 {
3999 	return mnFirst;
4000 }
4001 
setLast(double Value)4002 void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException)
4003 {
4004 	mnLast = Value;
4005 	if ( getPeer().is() )
4006 	{
4007 		uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
4008         xField->setLast( mnLast );
4009     }
4010 }
4011 
getLast()4012 double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException)
4013 {
4014 	return mnLast;
4015 }
4016 
setStrictFormat(sal_Bool bStrict)4017 void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
4018 {
4019 	uno::Any aAny;
4020 	aAny <<= bStrict;
4021 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
4022 }
4023 
isStrictFormat()4024 sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException)
4025 {
4026 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4027 }
4028 
setSpinSize(double Digits)4029 void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
4030 {
4031 	uno::Any aAny;
4032 	aAny <<= Digits;
4033 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
4034 }
4035 
getSpinSize()4036 double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException)
4037 {
4038 	return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
4039 }
4040 
setDecimalDigits(sal_Int16 Digits)4041 void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
4042 {
4043 	uno::Any aAny;
4044 	aAny <<= Digits;
4045     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
4046 }
4047 
getDecimalDigits()4048 sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException)
4049 {
4050 	return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
4051 }
4052 
4053 //	----------------------------------------------------
4054 //	class UnoControlPatternFieldModel
4055 //	----------------------------------------------------
UnoControlPatternFieldModel(const Reference<XMultiServiceFactory> & i_factory)4056 UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference< XMultiServiceFactory >& i_factory )
4057     :UnoControlModel( i_factory )
4058 {
4059     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField );
4060 }
4061 
getServiceName()4062 ::rtl::OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
4063 {
4064 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel );
4065 }
4066 
ImplGetDefaultValue(sal_uInt16 nPropId) const4067 uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4068 {
4069 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4070 	{
4071 		uno::Any aAny;
4072 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlPatternField );
4073 		return aAny;
4074 	}
4075 	return UnoControlModel::ImplGetDefaultValue( nPropId );
4076 }
4077 
getInfoHelper()4078 ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper()
4079 {
4080 	static UnoPropertyArrayHelper* pHelper = NULL;
4081 	if ( !pHelper )
4082 	{
4083 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
4084 		pHelper = new UnoPropertyArrayHelper( aIDs );
4085 	}
4086 	return *pHelper;
4087 }
4088 
4089 // beans::XMultiPropertySet
getPropertySetInfo()4090 uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
4091 {
4092 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4093 	return xInfo;
4094 }
4095 
4096 
4097 //	----------------------------------------------------
4098 //	class UnoPatternFieldControl
4099 //	----------------------------------------------------
UnoPatternFieldControl(const Reference<XMultiServiceFactory> & i_factory)4100 UnoPatternFieldControl::UnoPatternFieldControl( const Reference< XMultiServiceFactory >& i_factory )
4101     :UnoSpinFieldControl( i_factory )
4102 {
4103 }
4104 
GetComponentServiceName()4105 ::rtl::OUString UnoPatternFieldControl::GetComponentServiceName()
4106 {
4107 	return ::rtl::OUString::createFromAscii( "patternfield" );
4108 }
4109 
ImplSetPeerProperty(const::rtl::OUString & rPropName,const uno::Any & rVal)4110 void UnoPatternFieldControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal )
4111 {
4112 	sal_uInt16 nType = GetPropertyId( rPropName );
4113 	if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) )
4114 	{
4115 		// Die Masken koennen nicht nacheinander gesetzt werden.
4116 		::rtl::OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
4117 		::rtl::OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
4118 		::rtl::OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
4119 
4120 		uno::Reference < awt::XPatternField >  xPF( getPeer(), uno::UNO_QUERY );
4121 		if (xPF.is())
4122 		{
4123             // same comment as in UnoControl::ImplSetPeerProperty - see there
4124             ::rtl::OUString sText( Text );
4125             ImplCheckLocalize( sText );
4126 			xPF->setString( sText );
4127 			xPF->setMasks( EditMask, LiteralMask );
4128 		}
4129 	}
4130 	else
4131 		UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal );
4132 }
4133 
4134 
4135 // uno::XInterface
queryAggregation(const uno::Type & rType)4136 uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
4137 {
4138 	uno::Any aRet = ::cppu::queryInterface( rType,
4139 										SAL_STATIC_CAST( awt::XPatternField*, this ) );
4140 	return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
4141 }
4142 
4143 // lang::XTypeProvider
4144 IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl )
4145 	getCppuType( ( uno::Reference< awt::XPatternField>* ) NULL ),
4146 	UnoSpinFieldControl::getTypes()
4147 IMPL_XTYPEPROVIDER_END
4148 
4149 void UnoPatternFieldControl::setString( const ::rtl::OUString& rString ) throw(uno::RuntimeException)
4150 {
4151 	setText( rString );
4152 }
4153 
getString()4154 ::rtl::OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException)
4155 {
4156 	return getText();
4157 }
4158 
setMasks(const::rtl::OUString & EditMask,const::rtl::OUString & LiteralMask)4159 void UnoPatternFieldControl::setMasks( const ::rtl::OUString& EditMask, const ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
4160 {
4161 	uno::Any aAny;
4162 	aAny <<= EditMask;
4163 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, sal_True );
4164 	aAny <<= LiteralMask;
4165 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, sal_True );
4166 }
4167 
getMasks(::rtl::OUString & EditMask,::rtl::OUString & LiteralMask)4168 void UnoPatternFieldControl::getMasks( ::rtl::OUString& EditMask, ::rtl::OUString& LiteralMask ) throw(uno::RuntimeException)
4169 {
4170 	EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
4171 	LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
4172 }
4173 
setStrictFormat(sal_Bool bStrict)4174 void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
4175 {
4176 	uno::Any aAny;
4177 	aAny <<= bStrict;
4178 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
4179 }
4180 
isStrictFormat()4181 sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException)
4182 {
4183 	return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
4184 }
4185 
4186 
4187 //	----------------------------------------------------
4188 //	class UnoControlProgressBarModel
4189 //	----------------------------------------------------
UnoControlProgressBarModel(const Reference<XMultiServiceFactory> & i_factory)4190 UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference< XMultiServiceFactory >& i_factory )
4191     :UnoControlModel( i_factory )
4192 {
4193 	ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
4194     ImplRegisterProperty( BASEPROPERTY_BORDER );
4195 	ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
4196     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
4197 	ImplRegisterProperty( BASEPROPERTY_ENABLED );
4198 	ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
4199 	ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
4200     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
4201 	ImplRegisterProperty( BASEPROPERTY_HELPURL );
4202     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
4203     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
4204     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
4205     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN );
4206 }
4207 
getServiceName()4208 ::rtl::OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
4209 {
4210 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBarModel );
4211 }
4212 
ImplGetDefaultValue(sal_uInt16 nPropId) const4213 uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4214 {
4215 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4216 	{
4217 		uno::Any aAny;
4218 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlProgressBar );
4219 		return aAny;
4220 	}
4221 
4222 	return UnoControlModel::ImplGetDefaultValue( nPropId );
4223 }
4224 
getInfoHelper()4225 ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper()
4226 {
4227 	static UnoPropertyArrayHelper* pHelper = NULL;
4228 	if ( !pHelper )
4229 	{
4230 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
4231 		pHelper = new UnoPropertyArrayHelper( aIDs );
4232 	}
4233 	return *pHelper;
4234 }
4235 
4236 // beans::XMultiPropertySet
getPropertySetInfo()4237 uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
4238 {
4239 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4240 	return xInfo;
4241 }
4242 
4243 
4244 //	----------------------------------------------------
4245 //	class UnoProgressBarControl
4246 //	----------------------------------------------------
UnoProgressBarControl(const Reference<XMultiServiceFactory> & i_factory)4247 UnoProgressBarControl::UnoProgressBarControl( const Reference< XMultiServiceFactory >& i_factory )
4248 	:UnoControlBase( i_factory )
4249 {
4250 }
4251 
GetComponentServiceName()4252 ::rtl::OUString UnoProgressBarControl::GetComponentServiceName()
4253 {
4254 	return ::rtl::OUString::createFromAscii( "ProgressBar" );
4255 }
4256 
4257 // uno::XInterface
queryAggregation(const uno::Type & rType)4258 uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
4259 {
4260 	uno::Any aRet = ::cppu::queryInterface( rType,
4261 										SAL_STATIC_CAST( awt::XProgressBar*, this ) );
4262 	return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
4263 }
4264 
4265 // lang::XTypeProvider
4266 IMPL_XTYPEPROVIDER_START( UnoProgressBarControl )
4267 	getCppuType( ( uno::Reference< awt::XProgressBar>* ) NULL ),
4268 	UnoControlBase::getTypes()
4269 IMPL_XTYPEPROVIDER_END
4270 
4271 // ::com::sun::star::awt::XProgressBar
4272 void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
4273 {
4274 	uno::Any aAny;
4275 	aAny <<= nColor;
4276 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, sal_True );
4277 }
4278 
setBackgroundColor(sal_Int32 nColor)4279 void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
4280 {
4281 	uno::Any aAny;
4282 	aAny <<= nColor;
4283 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, sal_True );
4284 }
4285 
setValue(sal_Int32 nValue)4286 void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
4287 {
4288 	uno::Any aAny;
4289 	aAny <<= nValue;
4290 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, sal_True );
4291 }
4292 
setRange(sal_Int32 nMin,sal_Int32 nMax)4293 void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
4294 {
4295 	uno::Any aMin;
4296 	uno::Any aMax;
4297 
4298 	if ( nMin < nMax )
4299 	{
4300 		// take correct min and max
4301 		aMin <<= nMin;
4302 		aMax <<= nMax;
4303 	}
4304 	else
4305 	{
4306 		// change min and max
4307 		aMin <<= nMax;
4308 		aMax <<= nMin;
4309 	}
4310 
4311 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, sal_True );
4312 	ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, sal_True );
4313 }
4314 
getValue()4315 sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException)
4316 {
4317 	return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE );
4318 }
4319 
4320 
4321 //	----------------------------------------------------
4322 //	class UnoControlFixedLineModel
4323 //	----------------------------------------------------
UnoControlFixedLineModel(const Reference<XMultiServiceFactory> & i_factory)4324 UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference< XMultiServiceFactory >& i_factory )
4325     :UnoControlModel( i_factory )
4326 {
4327 	ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
4328 	ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
4329 	ImplRegisterProperty( BASEPROPERTY_ENABLED );
4330 	ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
4331 	ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
4332 	ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
4333 	ImplRegisterProperty( BASEPROPERTY_HELPURL );
4334 	ImplRegisterProperty( BASEPROPERTY_LABEL );
4335     ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
4336 	ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
4337 }
4338 
getServiceName()4339 ::rtl::OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
4340 {
4341 	return ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLineModel );
4342 }
4343 
ImplGetDefaultValue(sal_uInt16 nPropId) const4344 uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
4345 {
4346 	if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
4347 	{
4348 		uno::Any aAny;
4349 		aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlFixedLine );
4350 		return aAny;
4351 	}
4352 	return UnoControlModel::ImplGetDefaultValue( nPropId );
4353 }
4354 
getInfoHelper()4355 ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper()
4356 {
4357 	static UnoPropertyArrayHelper* pHelper = NULL;
4358 	if ( !pHelper )
4359 	{
4360 		uno::Sequence<sal_Int32>	aIDs = ImplGetPropertyIds();
4361 		pHelper = new UnoPropertyArrayHelper( aIDs );
4362 	}
4363 	return *pHelper;
4364 }
4365 
4366 // beans::XMultiPropertySet
getPropertySetInfo()4367 uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
4368 {
4369 	static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
4370 	return xInfo;
4371 }
4372 
4373 //	----------------------------------------------------
4374 //	class UnoFixedLineControl
4375 //	----------------------------------------------------
UnoFixedLineControl(const Reference<XMultiServiceFactory> & i_factory)4376 UnoFixedLineControl::UnoFixedLineControl( const Reference< XMultiServiceFactory >& i_factory )
4377 	:UnoControlBase( i_factory )
4378 {
4379 	maComponentInfos.nWidth = 100;		// ??
4380 	maComponentInfos.nHeight = 100;		// ??
4381 }
4382 
GetComponentServiceName()4383 ::rtl::OUString UnoFixedLineControl::GetComponentServiceName()
4384 {
4385 	return ::rtl::OUString::createFromAscii( "FixedLine" );
4386 }
4387 
isTransparent()4388 sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException)
4389 {
4390 	return sal_True;
4391 }
4392 
4393