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