From 714d907d304fae5cc8613eced127060199639af6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 3 Aug 2020 23:36:47 +0200 Subject: loplugin:flatten in toolkit Change-Id: I8f4b29620134566f256f05bbab677e83baf20ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100031 Tested-by: Jenkins Reviewed-by: Noel Grandin --- toolkit/source/awt/vclxaccessiblecomponent.cxx | 38 +- toolkit/source/awt/vclxgraphics.cxx | 108 +- toolkit/source/awt/vclxmenu.cxx | 126 +- toolkit/source/awt/vclxspinbutton.cxx | 76 +- toolkit/source/awt/vclxtabpagecontainer.cxx | 26 +- toolkit/source/awt/vclxtoolkit.cxx | 110 +- toolkit/source/awt/vclxwindow.cxx | 241 ++-- toolkit/source/awt/vclxwindows.cxx | 1538 ++++++++++++------------ 8 files changed, 1131 insertions(+), 1132 deletions(-) (limited to 'toolkit/source/awt') diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index b046e9280768..b70a0dbb9bfc 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -352,28 +352,28 @@ VclPtr VCLXAccessibleComponent::GetWindow() const void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) { VclPtr pWindow = GetWindow(); - if ( pWindow ) + if ( !pWindow ) + return; + + vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); + if ( pLabeledBy && pLabeledBy != pWindow ) { - vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); - if ( pLabeledBy && pLabeledBy != pWindow ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() }; - rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); - } + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabeledBy->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); + } - vcl::Window* pLabelFor = pWindow->GetAccessibleRelationLabelFor(); - if ( pLabelFor && pLabelFor != pWindow ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabelFor->GetAccessible() }; - rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABEL_FOR, aSequence ) ); - } + vcl::Window* pLabelFor = pWindow->GetAccessibleRelationLabelFor(); + if ( pLabelFor && pLabelFor != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pLabelFor->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABEL_FOR, aSequence ) ); + } - vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); - if ( pMemberOf && pMemberOf != pWindow ) - { - uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; - rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); - } + vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); + if ( pMemberOf && pMemberOf != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; + rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); } } diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx index 9fcb527a0970..958817053663 100644 --- a/toolkit/source/awt/vclxgraphics.cxx +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -98,30 +98,30 @@ void VCLXGraphics::initAttrs() void VCLXGraphics::InitOutputDevice( InitOutDevFlags nFlags ) { - if(mpOutputDevice) - { - SolarMutexGuard aVclGuard; + if(!mpOutputDevice) + return; - if ( nFlags & InitOutDevFlags::FONT ) - { - mpOutputDevice->SetFont( maFont ); - mpOutputDevice->SetTextColor( maTextColor ); - mpOutputDevice->SetTextFillColor( maTextFillColor ); - } + SolarMutexGuard aVclGuard; - if ( nFlags & InitOutDevFlags::COLORS ) - { - mpOutputDevice->SetLineColor( maLineColor ); - mpOutputDevice->SetFillColor( maFillColor ); - } - - mpOutputDevice->SetRasterOp( meRasterOp ); + if ( nFlags & InitOutDevFlags::FONT ) + { + mpOutputDevice->SetFont( maFont ); + mpOutputDevice->SetTextColor( maTextColor ); + mpOutputDevice->SetTextFillColor( maTextFillColor ); + } - if( mpClipRegion ) - mpOutputDevice->SetClipRegion( *mpClipRegion ); - else - mpOutputDevice->SetClipRegion(); + if ( nFlags & InitOutDevFlags::COLORS ) + { + mpOutputDevice->SetLineColor( maLineColor ); + mpOutputDevice->SetFillColor( maFillColor ); } + + mpOutputDevice->SetRasterOp( meRasterOp ); + + if( mpClipRegion ) + mpOutputDevice->SetClipRegion( *mpClipRegion ); + else + mpOutputDevice->SetClipRegion(); } uno::Reference< awt::XDevice > VCLXGraphics::getDevice() @@ -274,32 +274,32 @@ void VCLXGraphics::draw( const uno::Reference< awt::XDisplayBitmap >& rxBitmapHa { SolarMutexGuard aGuard; - if( mpOutputDevice ) - { - InitOutputDevice( InitOutDevFlags::NONE); - uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY ); - BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap ); - - Point aPos(nDestX - nSourceX, nDestY - nSourceY); - Size aSz = aBmpEx.GetSizePixel(); + if( !mpOutputDevice ) + return; - if(nDestWidth != nSourceWidth) - { - float zoomX = static_cast(nDestWidth) / static_cast(nSourceWidth); - aSz.setWidth( static_cast(static_cast(aSz.Width()) * zoomX) ); - } + InitOutputDevice( InitOutDevFlags::NONE); + uno::Reference< awt::XBitmap > xBitmap( rxBitmapHandle, uno::UNO_QUERY ); + BitmapEx aBmpEx = VCLUnoHelper::GetBitmap( xBitmap ); - if(nDestHeight != nSourceHeight) - { - float zoomY = static_cast(nDestHeight) / static_cast(nSourceHeight); - aSz.setHeight( static_cast(static_cast(aSz.Height()) * zoomY) ); - } + Point aPos(nDestX - nSourceX, nDestY - nSourceY); + Size aSz = aBmpEx.GetSizePixel(); - if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight) - mpOutputDevice->IntersectClipRegion(vcl::Region(tools::Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1))); + if(nDestWidth != nSourceWidth) + { + float zoomX = static_cast(nDestWidth) / static_cast(nSourceWidth); + aSz.setWidth( static_cast(static_cast(aSz.Width()) * zoomX) ); + } - mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx ); + if(nDestHeight != nSourceHeight) + { + float zoomY = static_cast(nDestHeight) / static_cast(nSourceHeight); + aSz.setHeight( static_cast(static_cast(aSz.Height()) * zoomY) ); } + + if(nSourceX || nSourceY || aSz.Width() != nSourceWidth || aSz.Height() != nSourceHeight) + mpOutputDevice->IntersectClipRegion(vcl::Region(tools::Rectangle(nDestX, nDestY, nDestX + nDestWidth - 1, nDestY + nDestHeight - 1))); + + mpOutputDevice->DrawBitmapEx( aPos, aSz, aBmpEx ); } void VCLXGraphics::drawPixel( sal_Int32 x, sal_Int32 y ) @@ -432,19 +432,19 @@ void VCLXGraphics::drawGradient( sal_Int32 x, sal_Int32 y, sal_Int32 width, sal_ { SolarMutexGuard aGuard; - if( mpOutputDevice ) - { - InitOutputDevice( InitOutDevFlags::COLORS ); - Gradient aGradient(static_cast(rGradient.Style), Color(rGradient.StartColor), Color(rGradient.EndColor)); - aGradient.SetAngle(rGradient.Angle); - aGradient.SetBorder(rGradient.Border); - aGradient.SetOfsX(rGradient.XOffset); - aGradient.SetOfsY(rGradient.YOffset); - aGradient.SetStartIntensity(rGradient.StartIntensity); - aGradient.SetEndIntensity(rGradient.EndIntensity); - aGradient.SetSteps(rGradient.StepCount); - mpOutputDevice->DrawGradient( tools::Rectangle( Point( x, y ), Size( width, height ) ), aGradient ); - } + if( !mpOutputDevice ) + return; + + InitOutputDevice( InitOutDevFlags::COLORS ); + Gradient aGradient(static_cast(rGradient.Style), Color(rGradient.StartColor), Color(rGradient.EndColor)); + aGradient.SetAngle(rGradient.Angle); + aGradient.SetBorder(rGradient.Border); + aGradient.SetOfsX(rGradient.XOffset); + aGradient.SetOfsY(rGradient.YOffset); + aGradient.SetStartIntensity(rGradient.StartIntensity); + aGradient.SetEndIntensity(rGradient.EndIntensity); + aGradient.SetSteps(rGradient.StepCount); + mpOutputDevice->DrawGradient( tools::Rectangle( Point( x, y ), Size( width, height ) ), aGradient ); } void VCLXGraphics::drawText( sal_Int32 x, sal_Int32 y, const OUString& rText ) diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 0ba38df421c2..93d154a92ed2 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -88,79 +88,79 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclMenuEvent&, rMenuEvent, void ) { DBG_ASSERT( rMenuEvent.GetMenu() && mpMenu, "Menu???" ); - if ( rMenuEvent.GetMenu() == mpMenu ) // Also called for the root menu + if ( rMenuEvent.GetMenu() != mpMenu ) // Also called for the root menu + return; + + switch ( rMenuEvent.GetId() ) { - switch ( rMenuEvent.GetId() ) + case VclEventId::MenuSelect: { - case VclEventId::MenuSelect: - { - if ( maMenuListeners.getLength() ) - { - css::awt::MenuEvent aEvent; - aEvent.Source = static_cast(this); - aEvent.MenuId = mpMenu->GetCurItemId(); - maMenuListeners.itemSelected( aEvent ); - } - } - break; - case VclEventId::ObjectDying: + if ( maMenuListeners.getLength() ) { - mpMenu = nullptr; + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemSelected( aEvent ); } - break; - case VclEventId::MenuHighlight: + } + break; + case VclEventId::ObjectDying: + { + mpMenu = nullptr; + } + break; + case VclEventId::MenuHighlight: + { + if ( maMenuListeners.getLength() ) { - if ( maMenuListeners.getLength() ) - { - css::awt::MenuEvent aEvent; - aEvent.Source = static_cast(this); - aEvent.MenuId = mpMenu->GetCurItemId(); - maMenuListeners.itemHighlighted( aEvent ); - } + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemHighlighted( aEvent ); } - break; - case VclEventId::MenuActivate: + } + break; + case VclEventId::MenuActivate: + { + if ( maMenuListeners.getLength() ) { - if ( maMenuListeners.getLength() ) - { - css::awt::MenuEvent aEvent; - aEvent.Source = static_cast(this); - aEvent.MenuId = mpMenu->GetCurItemId(); - maMenuListeners.itemActivated( aEvent ); - } + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemActivated( aEvent ); } - break; - case VclEventId::MenuDeactivate: + } + break; + case VclEventId::MenuDeactivate: + { + if ( maMenuListeners.getLength() ) { - if ( maMenuListeners.getLength() ) - { - css::awt::MenuEvent aEvent; - aEvent.Source = static_cast(this); - aEvent.MenuId = mpMenu->GetCurItemId(); - maMenuListeners.itemDeactivated( aEvent ); - } + css::awt::MenuEvent aEvent; + aEvent.Source = static_cast(this); + aEvent.MenuId = mpMenu->GetCurItemId(); + maMenuListeners.itemDeactivated( aEvent ); } - break; - - // ignore accessibility events - case VclEventId::MenuEnable: - case VclEventId::MenuInsertItem: - case VclEventId::MenuRemoveItem: - case VclEventId::MenuSubmenuActivate: - case VclEventId::MenuSubmenuDeactivate: - case VclEventId::MenuSubmenuChanged: - case VclEventId::MenuDehighlight: - case VclEventId::MenuDisable: - case VclEventId::MenuItemTextChanged: - case VclEventId::MenuItemChecked: - case VclEventId::MenuItemUnchecked: - case VclEventId::MenuShow: - case VclEventId::MenuHide: - break; - - default: OSL_FAIL( "MenuEventListener - Unknown event!" ); - } - } + } + break; + + // ignore accessibility events + case VclEventId::MenuEnable: + case VclEventId::MenuInsertItem: + case VclEventId::MenuRemoveItem: + case VclEventId::MenuSubmenuActivate: + case VclEventId::MenuSubmenuDeactivate: + case VclEventId::MenuSubmenuChanged: + case VclEventId::MenuDehighlight: + case VclEventId::MenuDisable: + case VclEventId::MenuItemTextChanged: + case VclEventId::MenuItemChecked: + case VclEventId::MenuItemUnchecked: + case VclEventId::MenuShow: + case VclEventId::MenuHide: + break; + + default: OSL_FAIL( "MenuEventListener - Unknown event!" ); + } } diff --git a/toolkit/source/awt/vclxspinbutton.cxx b/toolkit/source/awt/vclxspinbutton.cxx index 197997a12652..7941f3760c9a 100644 --- a/toolkit/source/awt/vclxspinbutton.cxx +++ b/toolkit/source/awt/vclxspinbutton.cxx @@ -234,45 +234,45 @@ namespace toolkit sal_Int32 nValue = 0; bool bIsLongValue = ( Value >>= nValue ); - if ( GetWindow() ) - { - sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); - switch ( nPropertyId ) - { - case BASEPROPERTY_BACKGROUNDCOLOR: - // the default implementation of the base class doesn't work here, since our - // interpretation for this property is slightly different - setButtonLikeFaceColor( GetWindow(), Value); - break; - - case BASEPROPERTY_SPINVALUE: - if ( bIsLongValue ) - setValue( nValue ); - break; - - case BASEPROPERTY_SPINVALUE_MIN: - if ( bIsLongValue ) - setMinimum( nValue ); - break; - - case BASEPROPERTY_SPINVALUE_MAX: - if ( bIsLongValue ) - setMaximum( nValue ); - break; - - case BASEPROPERTY_SPININCREMENT: - if ( bIsLongValue ) - setSpinIncrement( nValue ); - break; - - case BASEPROPERTY_ORIENTATION: - if ( bIsLongValue ) - lcl_modifyStyle( GetWindow(), WB_HSCROLL, nValue == ScrollBarOrientation::HORIZONTAL ); - break; + if ( !GetWindow() ) + return; - default: - VCLXWindow::setProperty( PropertyName, Value ); - } + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_BACKGROUNDCOLOR: + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + setButtonLikeFaceColor( GetWindow(), Value); + break; + + case BASEPROPERTY_SPINVALUE: + if ( bIsLongValue ) + setValue( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MIN: + if ( bIsLongValue ) + setMinimum( nValue ); + break; + + case BASEPROPERTY_SPINVALUE_MAX: + if ( bIsLongValue ) + setMaximum( nValue ); + break; + + case BASEPROPERTY_SPININCREMENT: + if ( bIsLongValue ) + setSpinIncrement( nValue ); + break; + + case BASEPROPERTY_ORIENTATION: + if ( bIsLongValue ) + lcl_modifyStyle( GetWindow(), WB_HSCROLL, nValue == ScrollBarOrientation::HORIZONTAL ); + break; + + default: + VCLXWindow::setProperty( PropertyName, Value ); } } diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx index d51fedcff6a2..42751be785cf 100644 --- a/toolkit/source/awt/vclxtabpagecontainer.cxx +++ b/toolkit/source/awt/vclxtabpagecontainer.cxx @@ -140,22 +140,22 @@ void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindow { SolarMutexClearableGuard aGuard; VclPtr pTabControl = GetAs(); - if ( pTabControl ) + if ( !pTabControl ) + return; + + switch ( _rVclWindowEvent.GetId() ) { - switch ( _rVclWindowEvent.GetId() ) + case VclEventId::TabpageActivate: { - case VclEventId::TabpageActivate: - { - sal_uLong page = reinterpret_cast(_rVclWindowEvent.GetData()); - awt::tab::TabPageActivatedEvent aEvent(nullptr,page); - m_aTabPageListeners.tabPageActivated(aEvent); - break; - } - default: - aGuard.clear(); - VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); - break; + sal_uLong page = reinterpret_cast(_rVclWindowEvent.GetData()); + awt::tab::TabPageActivatedEvent aEvent(nullptr,page); + m_aTabPageListeners.tabPageActivated(aEvent); + break; } + default: + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; } } void SAL_CALL VCLXTabPageContainer::disposing( const css::lang::EventObject& /*Source*/ ) diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 25d28ed823e1..95c43c643a45 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -2396,27 +2396,27 @@ void VCLXToolkit::callTopWindowListeners( { vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); - if (pWindow->IsTopWindow()) + if (!pWindow->IsTopWindow()) + return; + + std::vector< css::uno::Reference< css::uno::XInterface > > + aListeners(m_aTopWindowListeners.getElements()); + if (aListeners.empty()) + return; + + css::lang::EventObject aAwtEvent( + static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer())); + for (const css::uno::Reference & i : aListeners) { - std::vector< css::uno::Reference< css::uno::XInterface > > - aListeners(m_aTopWindowListeners.getElements()); - if (!aListeners.empty()) + css::uno::Reference< css::awt::XTopWindowListener > + xListener(i, css::uno::UNO_QUERY); + try { - css::lang::EventObject aAwtEvent( - static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer())); - for (const css::uno::Reference & i : aListeners) - { - css::uno::Reference< css::awt::XTopWindowListener > - xListener(i, css::uno::UNO_QUERY); - try - { - (xListener.get()->*pFn)(aAwtEvent); - } - catch (const css::uno::RuntimeException &) - { - DBG_UNHANDLED_EXCEPTION("toolkit"); - } - } + (xListener.get()->*pFn)(aAwtEvent); + } + catch (const css::uno::RuntimeException &) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); } } } @@ -2471,43 +2471,43 @@ void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent, { vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow(); - if (pWindow->IsTopWindow()) - { - std::vector< css::uno::Reference< css::uno::XInterface > > - aListeners(m_aFocusListeners.getElements()); - if (!aListeners.empty()) + if (!pWindow->IsTopWindow()) + return; + + std::vector< css::uno::Reference< css::uno::XInterface > > + aListeners(m_aFocusListeners.getElements()); + if (aListeners.empty()) + return; + + // Ignore the interior of compound controls when determining the + // window that gets the focus next (see implementation in + // vclxwindow.cxx for mapping between VCL and UNO AWT event): + css::uno::Reference< css::uno::XInterface > xNext; + vcl::Window * pFocus = ::Application::GetFocusWindow(); + for (vcl::Window * p = pFocus; p != nullptr; p = p->GetParent()) + if (!p->IsCompoundControl()) { - // Ignore the interior of compound controls when determining the - // window that gets the focus next (see implementation in - // vclxwindow.cxx for mapping between VCL and UNO AWT event): - css::uno::Reference< css::uno::XInterface > xNext; - vcl::Window * pFocus = ::Application::GetFocusWindow(); - for (vcl::Window * p = pFocus; p != nullptr; p = p->GetParent()) - if (!p->IsCompoundControl()) - { - pFocus = p; - break; - } - if (pFocus != nullptr) - xNext = pFocus->GetComponentInterface(); - css::awt::FocusEvent aAwtEvent( - static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), - static_cast(pWindow->GetGetFocusFlags()), - xNext, false); - for (const css::uno::Reference & i : aListeners) - { - css::uno::Reference< css::awt::XFocusListener > xListener( - i, css::uno::UNO_QUERY); - try - { - bGained ? xListener->focusGained(aAwtEvent) - : xListener->focusLost(aAwtEvent); - } - catch (const css::uno::RuntimeException &) - { - DBG_UNHANDLED_EXCEPTION("toolkit"); - } - } + pFocus = p; + break; + } + if (pFocus != nullptr) + xNext = pFocus->GetComponentInterface(); + css::awt::FocusEvent aAwtEvent( + static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()), + static_cast(pWindow->GetGetFocusFlags()), + xNext, false); + for (const css::uno::Reference & i : aListeners) + { + css::uno::Reference< css::awt::XFocusListener > xListener( + i, css::uno::UNO_QUERY); + try + { + bGained ? xListener->focusGained(aAwtEvent) + : xListener->focusLost(aAwtEvent); + } + catch (const css::uno::RuntimeException &) + { + DBG_UNHANDLED_EXCEPTION("toolkit"); } } } diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index dbeeb20f0cdd..18ce820ab417 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -905,37 +905,37 @@ void VCLXWindow::dispose( ) mpImpl->mxViewGraphics = nullptr; - if ( !mpImpl->mbDisposing ) - { - mpImpl->mbDisposing = true; + if ( mpImpl->mbDisposing ) + return; - mpImpl->disposing(); + mpImpl->mbDisposing = true; - if ( GetWindow() ) - { - VclPtr pOutDev = GetOutputDevice(); - SetWindow( nullptr ); // so that handlers are logged off, if necessary (virtual) - SetOutputDevice( nullptr ); - pOutDev.disposeAndClear(); - } + mpImpl->disposing(); - // #i14103# dispose the accessible context after the window has been destroyed, - // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent() - // for VclEventId::WindowChildDestroyed contains a reference to an already disposed accessible object - try - { - css::uno::Reference< css::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, css::uno::UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } - catch ( const css::uno::Exception& ) - { - OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" ); - } - mpImpl->mxAccessibleContext.clear(); + if ( GetWindow() ) + { + VclPtr pOutDev = GetOutputDevice(); + SetWindow( nullptr ); // so that handlers are logged off, if necessary (virtual) + SetOutputDevice( nullptr ); + pOutDev.disposeAndClear(); + } - mpImpl->mbDisposing = false; + // #i14103# dispose the accessible context after the window has been destroyed, + // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent() + // for VclEventId::WindowChildDestroyed contains a reference to an already disposed accessible object + try + { + css::uno::Reference< css::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, css::uno::UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } + catch ( const css::uno::Exception& ) + { + OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" ); + } + mpImpl->mxAccessibleContext.clear(); + + mpImpl->mbDisposing = false; } void VCLXWindow::addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) @@ -1123,19 +1123,19 @@ void VCLXWindow::setBackground( sal_Int32 nColor ) { SolarMutexGuard aGuard; - if ( GetWindow() ) - { - Color aColor(nColor); - GetWindow()->SetBackground( aColor ); - GetWindow()->SetControlBackground( aColor ); + if ( !GetWindow() ) + return; - WindowType eWinType = GetWindow()->GetType(); - if ( ( eWinType == WindowType::WINDOW ) || - ( eWinType == WindowType::WORKWINDOW ) || - ( eWinType == WindowType::FLOATINGWINDOW ) ) - { - GetWindow()->Invalidate(); - } + Color aColor(nColor); + GetWindow()->SetBackground( aColor ); + GetWindow()->SetControlBackground( aColor ); + + WindowType eWinType = GetWindow()->GetType(); + if ( ( eWinType == WindowType::WINDOW ) || + ( eWinType == WindowType::WORKWINDOW ) || + ( eWinType == WindowType::FLOATINGWINDOW ) ) + { + GetWindow()->Invalidate(); } } @@ -1215,29 +1215,28 @@ void VCLXWindow::getStyles( sal_Int16 nType, css::awt::FontDescriptor& Font, sal { SolarMutexGuard aGuard; - if ( GetWindow() ) - { - const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); + if ( !GetWindow() ) + return; - switch ( nType ) + const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings(); + + switch ( nType ) + { + case css::awt::Style::FRAME: { - case css::awt::Style::FRAME: - { - Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); - ForegroundColor = sal_Int32(rStyleSettings.GetWindowTextColor()); - BackgroundColor = sal_Int32(rStyleSettings.GetWindowColor()); - } - break; - case css::awt::Style::DIALOG: - { - Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); - ForegroundColor = sal_Int32(rStyleSettings.GetDialogTextColor()); - BackgroundColor = sal_Int32(rStyleSettings.GetDialogColor()); - } - break; - default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" ); + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = sal_Int32(rStyleSettings.GetWindowTextColor()); + BackgroundColor = sal_Int32(rStyleSettings.GetWindowColor()); } - + break; + case css::awt::Style::DIALOG: + { + Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() ); + ForegroundColor = sal_Int32(rStyleSettings.GetDialogTextColor()); + BackgroundColor = sal_Int32(rStyleSettings.GetDialogColor()); + } + break; + default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" ); } } @@ -2208,82 +2207,82 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) if ( !pWindow ) return; - if ( isDesignMode() || mpImpl->isEnableVisible() ) - { - OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); - if (!pDev) - pDev = pWindow->GetParent(); - TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow.get() ); - if ( pTabPage ) - { - Point aPos( nX, nY ); - aPos = pDev->PixelToLogic( aPos ); - pTabPage->Draw( pDev, aPos, DrawFlags::NONE ); - return; - } + if ( !(isDesignMode() || mpImpl->isEnableVisible()) ) + return; + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics ); + if (!pDev) + pDev = pWindow->GetParent(); + TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow.get() ); + if ( pTabPage ) + { Point aPos( nX, nY ); + aPos = pDev->PixelToLogic( aPos ); + pTabPage->Draw( pDev, aPos, DrawFlags::NONE ); + return; + } - if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) ) + Point aPos( nX, nY ); + + if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) ) + { + // #i40647# don't draw here if this is a recursive call + // sometimes this is called recursively, because the Update call on the parent + // (strangely) triggers another paint. Prevent a stack overflow here + // Yes, this is only fixing symptoms for the moment... + // #i40647# / 2005-01-18 / frank.schoenheit@sun.com + if ( !mpImpl->getDrawingOntoParent_ref() ) { - // #i40647# don't draw here if this is a recursive call - // sometimes this is called recursively, because the Update call on the parent - // (strangely) triggers another paint. Prevent a stack overflow here - // Yes, this is only fixing symptoms for the moment... - // #i40647# / 2005-01-18 / frank.schoenheit@sun.com - if ( !mpImpl->getDrawingOntoParent_ref() ) - { - ::comphelper::FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); + ::comphelper::FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); - bool bWasVisible = pWindow->IsVisible(); - Point aOldPos( pWindow->GetPosPixel() ); + bool bWasVisible = pWindow->IsVisible(); + Point aOldPos( pWindow->GetPosPixel() ); - if ( bWasVisible && aOldPos == aPos ) - { - pWindow->PaintImmediately(); - return; - } + if ( bWasVisible && aOldPos == aPos ) + { + pWindow->PaintImmediately(); + return; + } + + pWindow->SetPosPixel( aPos ); - pWindow->SetPosPixel( aPos ); + // Update parent first to avoid painting the parent upon the update + // of this window, as it may otherwise cause the parent + // to hide this window again + if( pWindow->GetParent() ) + pWindow->GetParent()->PaintImmediately(); - // Update parent first to avoid painting the parent upon the update - // of this window, as it may otherwise cause the parent - // to hide this window again - if( pWindow->GetParent() ) - pWindow->GetParent()->PaintImmediately(); + pWindow->Show(); + pWindow->PaintImmediately(); + pWindow->SetParentUpdateMode( false ); + pWindow->Hide(); + pWindow->SetParentUpdateMode( true ); + pWindow->SetPosPixel( aOldPos ); + if ( bWasVisible ) pWindow->Show(); - pWindow->PaintImmediately(); - pWindow->SetParentUpdateMode( false ); - pWindow->Hide(); - pWindow->SetParentUpdateMode( true ); + } + } + else if ( pDev ) + { + Point aP = pDev->PixelToLogic( aPos ); - pWindow->SetPosPixel( aOldPos ); - if ( bWasVisible ) - pWindow->Show(); - } + vcl::PDFExtOutDevData* pPDFExport = dynamic_cast(pDev->GetExtOutDevData()); + bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER ) + || ( pDev->GetOutDevViewType() == OutDevViewType::PrintPreview ) + || ( pPDFExport != nullptr ); + if ( bDrawSimple ) + { + pWindow->Draw( pDev, aP, DrawFlags::NoControls ); } - else if ( pDev ) + else { - Point aP = pDev->PixelToLogic( aPos ); - - vcl::PDFExtOutDevData* pPDFExport = dynamic_cast(pDev->GetExtOutDevData()); - bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER ) - || ( pDev->GetOutDevViewType() == OutDevViewType::PrintPreview ) - || ( pPDFExport != nullptr ); - if ( bDrawSimple ) - { - pWindow->Draw( pDev, aP, DrawFlags::NoControls ); - } - else - { - bool bOldNW =pWindow->IsNativeWidgetEnabled(); - if( bOldNW ) - pWindow->EnableNativeWidget(false); - pWindow->PaintToDevice( pDev, aP ); - if( bOldNW ) - pWindow->EnableNativeWidget(); - } + bool bOldNW =pWindow->IsNativeWidgetEnabled(); + if( bOldNW ) + pWindow->EnableNativeWidget(false); + pWindow->PaintToDevice( pDev, aP ); + if( bOldNW ) + pWindow->EnableNativeWidget(); } } } diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index f3a29af6465b..6475fbd4062e 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -489,43 +489,43 @@ void VCLXButton::setProperty( const OUString& PropertyName, const css::uno::Any& SolarMutexGuard aGuard; VclPtr< Button > pButton = GetAs< Button >(); - if ( pButton ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_FOCUSONCLICK: - ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true ); - break; - - case BASEPROPERTY_TOGGLE: - ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false ); - break; + if ( !pButton ) + return; - case BASEPROPERTY_DEFAULTBUTTON: - { - WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON; - bool b = bool(); - if ( ( Value >>= b ) && !b ) - nStyle &= ~WB_DEFBUTTON; - pButton->SetStyle( nStyle ); - } + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_FOCUSONCLICK: + ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_NOPOINTERFOCUS, true ); break; - case BASEPROPERTY_STATE: - { - if ( GetWindow()->GetType() == WindowType::PUSHBUTTON ) - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - static_cast(pButton.get())->SetState( static_cast(n) ); - } - } + + case BASEPROPERTY_TOGGLE: + ::toolkit::adjustBooleanWindowStyle( Value, pButton, WB_TOGGLE, false ); break; - default: + + case BASEPROPERTY_DEFAULTBUTTON: + { + WinBits nStyle = pButton->GetStyle() | WB_DEFBUTTON; + bool b = bool(); + if ( ( Value >>= b ) && !b ) + nStyle &= ~WB_DEFBUTTON; + pButton->SetStyle( nStyle ); + } + break; + case BASEPROPERTY_STATE: + { + if ( GetWindow()->GetType() == WindowType::PUSHBUTTON ) { - VCLXGraphicControl::setProperty( PropertyName, Value ); + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + static_cast(pButton.get())->SetState( static_cast(n) ); } } + break; + default: + { + VCLXGraphicControl::setProperty( PropertyName, Value ); + } } } @@ -864,27 +864,27 @@ void VCLXCheckBox::setState( sal_Int16 n ) SolarMutexGuard aGuard; VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >(); - if ( pCheckBox) + if ( !pCheckBox) + return; + + TriState eState; + switch ( n ) { - TriState eState; - switch ( n ) - { - case 0: eState = TRISTATE_FALSE; break; - case 1: eState = TRISTATE_TRUE; break; - case 2: eState = TRISTATE_INDET; break; - default: eState = TRISTATE_FALSE; - } - pCheckBox->SetState( eState ); + case 0: eState = TRISTATE_FALSE; break; + case 1: eState = TRISTATE_TRUE; break; + case 2: eState = TRISTATE_INDET; break; + default: eState = TRISTATE_FALSE; + } + pCheckBox->SetState( eState ); - // #105198# call C++ click listeners (needed for accessibility) - // pCheckBox->GetClickHdl().Call( pCheckBox ); + // #105198# call C++ click listeners (needed for accessibility) + // pCheckBox->GetClickHdl().Call( pCheckBox ); - // #107218# Call same virtual methods and listeners like VCL would do after user interaction - SetSynthesizingVCLEvent( true ); - pCheckBox->Toggle(); - pCheckBox->Click(); - SetSynthesizingVCLEvent( false ); - } + // #107218# Call same virtual methods and listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( true ); + pCheckBox->Toggle(); + pCheckBox->Click(); + SetSynthesizingVCLEvent( false ); } sal_Int16 VCLXCheckBox::getState() @@ -954,33 +954,33 @@ void VCLXCheckBox::setProperty( const OUString& PropertyName, const css::uno::An SolarMutexGuard aGuard; VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >(); - if ( pCheckBox ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_VISUALEFFECT: - ::toolkit::setVisualEffect( Value, pCheckBox ); - break; + if ( !pCheckBox ) + return; - case BASEPROPERTY_TRISTATE: - { - bool b = bool(); - if ( Value >>= b ) - pCheckBox->EnableTriState( b ); - } - break; - case BASEPROPERTY_STATE: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - setState( n ); - } + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + ::toolkit::setVisualEffect( Value, pCheckBox ); break; - default: - { - VCLXGraphicControl::setProperty( PropertyName, Value ); - } + + case BASEPROPERTY_TRISTATE: + { + bool b = bool(); + if ( Value >>= b ) + pCheckBox->EnableTriState( b ); + } + break; + case BASEPROPERTY_STATE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + setState( n ); + } + break; + default: + { + VCLXGraphicControl::setProperty( PropertyName, Value ); } } } @@ -1132,40 +1132,40 @@ void VCLXRadioButton::setProperty( const OUString& PropertyName, const css::uno: SolarMutexGuard aGuard; VclPtr< RadioButton > pButton = GetAs< RadioButton >(); - if ( pButton ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_VISUALEFFECT: - ::toolkit::setVisualEffect( Value, pButton ); - break; + if ( !pButton ) + return; - case BASEPROPERTY_STATE: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - { - bool b = n != 0; - if ( pButton->IsRadioCheckEnabled() ) - pButton->Check( b ); - else - pButton->SetState( b ); - } - } - break; - case BASEPROPERTY_AUTOTOGGLE: - { - bool b = bool(); - if ( Value >>= b ) - pButton->EnableRadioCheck( b ); - } + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VISUALEFFECT: + ::toolkit::setVisualEffect( Value, pButton ); break; - default: + + case BASEPROPERTY_STATE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) { - VCLXGraphicControl::setProperty( PropertyName, Value ); + bool b = n != 0; + if ( pButton->IsRadioCheckEnabled() ) + pButton->Check( b ); + else + pButton->SetState( b ); } } + break; + case BASEPROPERTY_AUTOTOGGLE: + { + bool b = bool(); + if ( Value >>= b ) + pButton->EnableRadioCheck( b ); + } + break; + default: + { + VCLXGraphicControl::setProperty( PropertyName, Value ); + } } } @@ -1570,20 +1570,20 @@ void VCLXListBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_Int { SolarMutexGuard aGuard; VclPtr< ListBox > pBox = GetAs< ListBox >(); - if ( pBox ) + if ( !pBox ) + return; + + sal_uInt16 nP = nPos; + for ( auto const & item : aItems ) { - sal_uInt16 nP = nPos; - for ( auto const & item : aItems ) + if ( nP == 0xFFFF ) { - if ( nP == 0xFFFF ) - { - OSL_FAIL( "VCLXListBox::addItems: too many entries!" ); - // skip remaining entries, list cannot hold them, anyway - break; - } - - pBox->InsertEntry( item, nP++ ); + OSL_FAIL( "VCLXListBox::addItems: too many entries!" ); + // skip remaining entries, list cannot hold them, anyway + break; } + + pBox->InsertEntry( item, nP++ ); } } @@ -1710,40 +1710,40 @@ void VCLXListBox::selectItemsPos( const css::uno::Sequence& aPosition SolarMutexGuard aGuard; VclPtr< ListBox > pBox = GetAs< ListBox >(); - if ( pBox ) - { - std::vector aPositionVec; - aPositionVec.reserve(aPositions.getLength()); + if ( !pBox ) + return; + + std::vector aPositionVec; + aPositionVec.reserve(aPositions.getLength()); - bool bChanged = false; - for ( auto n = aPositions.getLength(); n; ) + bool bChanged = false; + for ( auto n = aPositions.getLength(); n; ) + { + const auto nPos = aPositions.getConstArray()[--n]; + if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) { - const auto nPos = aPositions.getConstArray()[--n]; - if ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) - { - aPositionVec.push_back(nPos); - bChanged = true; - } + aPositionVec.push_back(nPos); + bChanged = true; } + } - if ( bChanged ) - { - bool bOrigUpdateMode = pBox->IsUpdateMode(); - pBox->SetUpdateMode(false); + if ( !bChanged ) + return; - pBox->SelectEntriesPos(aPositionVec, bSelect); + bool bOrigUpdateMode = pBox->IsUpdateMode(); + pBox->SetUpdateMode(false); - pBox->SetUpdateMode(bOrigUpdateMode); + pBox->SelectEntriesPos(aPositionVec, bSelect); - // VCL doesn't call select handler after API call. - // ImplCallItemListeners(); + pBox->SetUpdateMode(bOrigUpdateMode); - // #107218# Call same listeners like VCL would do after user interaction - SetSynthesizingVCLEvent( true ); - pBox->Select(); - SetSynthesizingVCLEvent( false ); - } - } + // VCL doesn't call select handler after API call. + // ImplCallItemListeners(); + + // #107218# Call same listeners like VCL would do after user interaction + SetSynthesizingVCLEvent( true ); + pBox->Select(); + SetSynthesizingVCLEvent( false ); } void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) @@ -1861,75 +1861,75 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const css::uno::Any { SolarMutexGuard aGuard; VclPtr< ListBox > pListBox = GetAs< ListBox >(); - if ( pListBox ) + if ( !pListBox ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_ITEM_SEPARATOR_POS: { - case BASEPROPERTY_ITEM_SEPARATOR_POS: - { - sal_Int16 nSeparatorPos(0); - if ( Value >>= nSeparatorPos ) - pListBox->SetSeparatorPos( nSeparatorPos ); - } - break; - case BASEPROPERTY_READONLY: - { - bool b = false; - if ( Value >>= b ) - pListBox->SetReadOnly( b); - } - break; - case BASEPROPERTY_MULTISELECTION: - { - bool b = false; - if ( Value >>= b ) - pListBox->EnableMultiSelection( b ); - } - break; - case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: - ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false ); - break; - case BASEPROPERTY_LINECOUNT: - { - sal_Int16 n = 0; - if ( Value >>= n ) - pListBox->SetDropDownLineCount( n ); - } + sal_Int16 nSeparatorPos(0); + if ( Value >>= nSeparatorPos ) + pListBox->SetSeparatorPos( nSeparatorPos ); + } + break; + case BASEPROPERTY_READONLY: + { + bool b = false; + if ( Value >>= b ) + pListBox->SetReadOnly( b); + } + break; + case BASEPROPERTY_MULTISELECTION: + { + bool b = false; + if ( Value >>= b ) + pListBox->EnableMultiSelection( b ); + } + break; + case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: + ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, false ); break; - case BASEPROPERTY_STRINGITEMLIST: + case BASEPROPERTY_LINECOUNT: + { + sal_Int16 n = 0; + if ( Value >>= n ) + pListBox->SetDropDownLineCount( n ); + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + css::uno::Sequence< OUString> aItems; + if ( Value >>= aItems ) { - css::uno::Sequence< OUString> aItems; - if ( Value >>= aItems ) - { - pListBox->Clear(); - addItems( aItems, 0 ); - } + pListBox->Clear(); + addItems( aItems, 0 ); } - break; - case BASEPROPERTY_SELECTEDITEMS: + } + break; + case BASEPROPERTY_SELECTEDITEMS: + { + css::uno::Sequence aItems; + if ( Value >>= aItems ) { - css::uno::Sequence aItems; - if ( Value >>= aItems ) - { - for ( auto n = pListBox->GetEntryCount(); n; ) - pListBox->SelectEntryPos( --n, false ); + for ( auto n = pListBox->GetEntryCount(); n; ) + pListBox->SelectEntryPos( --n, false ); - if ( aItems.hasElements() ) - selectItemsPos( aItems, true ); - else - pListBox->SetNoSelection(); + if ( aItems.hasElements() ) + selectItemsPos( aItems, true ); + else + pListBox->SetNoSelection(); - if ( !pListBox->GetSelectedEntryCount() ) - pListBox->SetTopEntry( 0 ); - } - } - break; - default: - { - VCLXWindow::setProperty( PropertyName, Value ); + if ( !pListBox->GetSelectedEntryCount() ) + pListBox->SetTopEntry( 0 ); } } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } } } @@ -2409,41 +2409,41 @@ void SAL_CALL VCLXDialog::setProperty( { SolarMutexGuard aGuard; VclPtr< Dialog > pDialog = GetAs< Dialog >(); - if ( pDialog ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !pDialog ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: { - case BASEPROPERTY_GRAPHIC: + Reference< XGraphic > xGraphic; + if (( Value >>= xGraphic ) && xGraphic.is() ) { - Reference< XGraphic > xGraphic; - if (( Value >>= xGraphic ) && xGraphic.is() ) - { - Graphic aImage(xGraphic); - - Wallpaper aWallpaper(aImage.GetBitmapEx()); - aWallpaper.SetStyle( WallpaperStyle::Scale ); - pDialog->SetBackground( aWallpaper ); - } - else if ( bVoid || !xGraphic.is() ) - { - Color aColor = pDialog->GetControlBackground(); - if ( aColor == COL_AUTO ) - aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor(); + Graphic aImage(xGraphic); - Wallpaper aWallpaper( aColor ); - pDialog->SetBackground( aWallpaper ); - } + Wallpaper aWallpaper(aImage.GetBitmapEx()); + aWallpaper.SetStyle( WallpaperStyle::Scale ); + pDialog->SetBackground( aWallpaper ); } - break; - - default: + else if ( bVoid || !xGraphic.is() ) { - VCLXContainer::setProperty( PropertyName, Value ); + Color aColor = pDialog->GetControlBackground(); + if ( aColor == COL_AUTO ) + aColor = pDialog->GetSettings().GetStyleSettings().GetDialogColor(); + + Wallpaper aWallpaper( aColor ); + pDialog->SetBackground( aWallpaper ); } } + break; + + default: + { + VCLXContainer::setProperty( PropertyName, Value ); + } } } @@ -2540,51 +2540,51 @@ void SAL_CALL VCLXMultiPage::setProperty( SolarMutexGuard aGuard; VclPtr< TabControl > pTabControl = GetAs< TabControl >(); - if ( pTabControl ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !pTabControl ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_MULTIPAGEVALUE: { - case BASEPROPERTY_MULTIPAGEVALUE: + SAL_INFO("toolkit", "***MULTIPAGE VALUE"); + sal_Int32 nId(0); + Value >>= nId; + // when the multipage is created we attempt to set the activepage + // but no pages created + if ( nId && nId <= getWindows().getLength() ) + activateTab( nId ); + break; + } + case BASEPROPERTY_GRAPHIC: + { + Reference< XGraphic > xGraphic; + if (( Value >>= xGraphic ) && xGraphic.is() ) { - SAL_INFO("toolkit", "***MULTIPAGE VALUE"); - sal_Int32 nId(0); - Value >>= nId; - // when the multipage is created we attempt to set the activepage - // but no pages created - if ( nId && nId <= getWindows().getLength() ) - activateTab( nId ); - break; + Graphic aImage(xGraphic); + + Wallpaper aWallpaper(aImage.GetBitmapEx()); + aWallpaper.SetStyle( WallpaperStyle::Scale ); + pTabControl->SetBackground( aWallpaper ); } - case BASEPROPERTY_GRAPHIC: + else if ( bVoid || !xGraphic.is() ) { - Reference< XGraphic > xGraphic; - if (( Value >>= xGraphic ) && xGraphic.is() ) - { - Graphic aImage(xGraphic); + Color aColor = pTabControl->GetControlBackground(); + if ( aColor == COL_AUTO ) + aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor(); - Wallpaper aWallpaper(aImage.GetBitmapEx()); - aWallpaper.SetStyle( WallpaperStyle::Scale ); - pTabControl->SetBackground( aWallpaper ); - } - else if ( bVoid || !xGraphic.is() ) - { - Color aColor = pTabControl->GetControlBackground(); - if ( aColor == COL_AUTO ) - aColor = pTabControl->GetSettings().GetStyleSettings().GetDialogColor(); - - Wallpaper aWallpaper( aColor ); - pTabControl->SetBackground( aWallpaper ); - } + Wallpaper aWallpaper( aColor ); + pTabControl->SetBackground( aWallpaper ); } - break; + } + break; - default: - { - VCLXContainer::setProperty( PropertyName, Value ); - } + default: + { + VCLXContainer::setProperty( PropertyName, Value ); } } } @@ -2763,49 +2763,49 @@ void SAL_CALL VCLXTabPage::setProperty( { SolarMutexGuard aGuard; VclPtr< TabPage > pTabPage = GetAs< TabPage >(); - if ( pTabPage ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !pTabPage ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_GRAPHIC: { - case BASEPROPERTY_GRAPHIC: + Reference< XGraphic > xGraphic; + if (( Value >>= xGraphic ) && xGraphic.is() ) { - Reference< XGraphic > xGraphic; - if (( Value >>= xGraphic ) && xGraphic.is() ) - { - Graphic aImage(xGraphic); + Graphic aImage(xGraphic); - Wallpaper aWallpaper(aImage.GetBitmapEx()); - aWallpaper.SetStyle( WallpaperStyle::Scale ); - pTabPage->SetBackground( aWallpaper ); - } - else if ( bVoid || !xGraphic.is() ) - { - Color aColor = pTabPage->GetControlBackground(); - if ( aColor == COL_AUTO ) - aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor(); + Wallpaper aWallpaper(aImage.GetBitmapEx()); + aWallpaper.SetStyle( WallpaperStyle::Scale ); + pTabPage->SetBackground( aWallpaper ); + } + else if ( bVoid || !xGraphic.is() ) + { + Color aColor = pTabPage->GetControlBackground(); + if ( aColor == COL_AUTO ) + aColor = pTabPage->GetSettings().GetStyleSettings().GetDialogColor(); - Wallpaper aWallpaper( aColor ); - pTabPage->SetBackground( aWallpaper ); - } + Wallpaper aWallpaper( aColor ); + pTabPage->SetBackground( aWallpaper ); } - break; - case BASEPROPERTY_TITLE: + } + break; + case BASEPROPERTY_TITLE: + { + OUString sTitle; + if ( Value >>= sTitle ) { - OUString sTitle; - if ( Value >>= sTitle ) - { - pTabPage->SetText(sTitle); - } + pTabPage->SetText(sTitle); } - break; - - default: - { - VCLXContainer::setProperty( PropertyName, Value ); } + break; + + default: + { + VCLXContainer::setProperty( PropertyName, Value ); } } } @@ -2953,20 +2953,20 @@ void VCLXFixedHyperlink::setAlignment( sal_Int16 nAlign ) SolarMutexGuard aGuard; VclPtr< vcl::Window > pWindow = GetWindow(); - if ( pWindow ) - { - WinBits nNewBits = 0; - if ( nAlign == css::awt::TextAlign::LEFT ) - nNewBits = WB_LEFT; - else if ( nAlign == css::awt::TextAlign::CENTER ) - nNewBits = WB_CENTER; - else - nNewBits = WB_RIGHT; + if ( !pWindow ) + return; - WinBits nStyle = pWindow->GetStyle(); - nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); - pWindow->SetStyle( nStyle | nNewBits ); - } + WinBits nNewBits = 0; + if ( nAlign == css::awt::TextAlign::LEFT ) + nNewBits = WB_LEFT; + else if ( nAlign == css::awt::TextAlign::CENTER ) + nNewBits = WB_CENTER; + else + nNewBits = WB_RIGHT; + + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + pWindow->SetStyle( nStyle | nNewBits ); } sal_Int16 VCLXFixedHyperlink::getAlignment() @@ -3037,31 +3037,31 @@ void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const css::u SolarMutexGuard aGuard; VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); - if ( pBase ) + if ( !pBase ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_LABEL: { - case BASEPROPERTY_LABEL: - { - OUString sNewLabel; - if ( Value >>= sNewLabel ) - pBase->SetText(sNewLabel); - break; - } + OUString sNewLabel; + if ( Value >>= sNewLabel ) + pBase->SetText(sNewLabel); + break; + } - case BASEPROPERTY_URL: - { - OUString sNewURL; - if ( Value >>= sNewURL ) - pBase->SetURL( sNewURL ); - break; - } + case BASEPROPERTY_URL: + { + OUString sNewURL; + if ( Value >>= sNewURL ) + pBase->SetURL( sNewURL ); + break; + } - default: - { - VCLXWindow::setProperty( PropertyName, Value ); - } + default: + { + VCLXWindow::setProperty( PropertyName, Value ); } } } @@ -3205,20 +3205,20 @@ void VCLXFixedText::setAlignment( sal_Int16 nAlign ) SolarMutexGuard aGuard; VclPtr< vcl::Window > pWindow = GetWindow(); - if ( pWindow ) - { - WinBits nNewBits = 0; - if ( nAlign == css::awt::TextAlign::LEFT ) - nNewBits = WB_LEFT; - else if ( nAlign == css::awt::TextAlign::CENTER ) - nNewBits = WB_CENTER; - else - nNewBits = WB_RIGHT; + if ( !pWindow ) + return; - WinBits nStyle = pWindow->GetStyle(); - nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); - pWindow->SetStyle( nStyle | nNewBits ); - } + WinBits nNewBits = 0; + if ( nAlign == css::awt::TextAlign::LEFT ) + nNewBits = WB_LEFT; + else if ( nAlign == css::awt::TextAlign::CENTER ) + nNewBits = WB_CENTER; + else + nNewBits = WB_RIGHT; + + WinBits nStyle = pWindow->GetStyle(); + nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT); + pWindow->SetStyle( nStyle | nNewBits ); } sal_Int16 VCLXFixedText::getAlignment() @@ -3510,112 +3510,112 @@ void VCLXScrollBar::setProperty( const OUString& PropertyName, const css::uno::A SolarMutexGuard aGuard; VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); - if ( pScrollBar ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !pScrollBar ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_LIVE_SCROLL: { - case BASEPROPERTY_LIVE_SCROLL: + bool bDo = false; + if ( !bVoid ) { - bool bDo = false; - if ( !bVoid ) - { - OSL_VERIFY( Value >>= bDo ); - } - AllSettings aSettings( pScrollBar->GetSettings() ); - StyleSettings aStyle( aSettings.GetStyleSettings() ); - DragFullOptions nDragOptions = aStyle.GetDragFullOptions(); - if ( bDo ) - nDragOptions |= DragFullOptions::Scroll; - else - nDragOptions &= ~DragFullOptions::Scroll; - aStyle.SetDragFullOptions( nDragOptions ); - aSettings.SetStyleSettings( aStyle ); - pScrollBar->SetSettings( aSettings ); + OSL_VERIFY( Value >>= bDo ); } - break; + AllSettings aSettings( pScrollBar->GetSettings() ); + StyleSettings aStyle( aSettings.GetStyleSettings() ); + DragFullOptions nDragOptions = aStyle.GetDragFullOptions(); + if ( bDo ) + nDragOptions |= DragFullOptions::Scroll; + else + nDragOptions &= ~DragFullOptions::Scroll; + aStyle.SetDragFullOptions( nDragOptions ); + aSettings.SetStyleSettings( aStyle ); + pScrollBar->SetSettings( aSettings ); + } + break; - case BASEPROPERTY_SCROLLVALUE: + case BASEPROPERTY_SCROLLVALUE: + { + if ( !bVoid ) { - if ( !bVoid ) - { - sal_Int32 n = 0; - if ( Value >>= n ) - setValue( n ); - } + sal_Int32 n = 0; + if ( Value >>= n ) + setValue( n ); } - break; - case BASEPROPERTY_SCROLLVALUE_MAX: - case BASEPROPERTY_SCROLLVALUE_MIN: + } + break; + case BASEPROPERTY_SCROLLVALUE_MAX: + case BASEPROPERTY_SCROLLVALUE_MIN: + { + if ( !bVoid ) { - if ( !bVoid ) + sal_Int32 n = 0; + if ( Value >>= n ) { - sal_Int32 n = 0; - if ( Value >>= n ) - { - if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX ) - setMaximum( n ); - else - setMinimum( n ); - } + if ( nPropType == BASEPROPERTY_SCROLLVALUE_MAX ) + setMaximum( n ); + else + setMinimum( n ); } } - break; - case BASEPROPERTY_LINEINCREMENT: + } + break; + case BASEPROPERTY_LINEINCREMENT: + { + if ( !bVoid ) { - if ( !bVoid ) - { - sal_Int32 n = 0; - if ( Value >>= n ) - setLineIncrement( n ); - } + sal_Int32 n = 0; + if ( Value >>= n ) + setLineIncrement( n ); } - break; - case BASEPROPERTY_BLOCKINCREMENT: + } + break; + case BASEPROPERTY_BLOCKINCREMENT: + { + if ( !bVoid ) { - if ( !bVoid ) - { - sal_Int32 n = 0; - if ( Value >>= n ) - setBlockIncrement( n ); - } + sal_Int32 n = 0; + if ( Value >>= n ) + setBlockIncrement( n ); } - break; - case BASEPROPERTY_VISIBLESIZE: + } + break; + case BASEPROPERTY_VISIBLESIZE: + { + if ( !bVoid ) { - if ( !bVoid ) - { - sal_Int32 n = 0; - if ( Value >>= n ) - setVisibleSize( n ); - } + sal_Int32 n = 0; + if ( Value >>= n ) + setVisibleSize( n ); } - break; - case BASEPROPERTY_ORIENTATION: + } + break; + case BASEPROPERTY_ORIENTATION: + { + if ( !bVoid ) { - if ( !bVoid ) - { - sal_Int32 n = 0; - if ( Value >>= n ) - setOrientation( n ); - } + sal_Int32 n = 0; + if ( Value >>= n ) + setOrientation( n ); } - break; + } + break; - case BASEPROPERTY_BACKGROUNDCOLOR: - { - // the default implementation of the base class doesn't work here, since our - // interpretation for this property is slightly different - ::toolkit::setButtonLikeFaceColor( pScrollBar, Value); - } - break; + case BASEPROPERTY_BACKGROUNDCOLOR: + { + // the default implementation of the base class doesn't work here, since our + // interpretation for this property is slightly different + ::toolkit::setButtonLikeFaceColor( pScrollBar, Value); + } + break; - default: - { - VCLXWindow::setProperty( PropertyName, Value ); - } + default: + { + VCLXWindow::setProperty( PropertyName, Value ); } } } @@ -3970,42 +3970,42 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const css::uno::Any& V SolarMutexGuard aGuard; VclPtr< Edit > pEdit = GetAs< Edit >(); - if ( pEdit ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_HIDEINACTIVESELECTION: - ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true ); - if ( pEdit->GetSubEdit() ) - ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true ); - break; + if ( !pEdit ) + return; - case BASEPROPERTY_READONLY: - { - bool b = bool(); - if ( Value >>= b ) - pEdit->SetReadOnly( b ); - } - break; - case BASEPROPERTY_ECHOCHAR: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pEdit->SetEchoChar( n ); - } - break; - case BASEPROPERTY_MAXTEXTLEN: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pEdit->SetMaxTextLen( n ); - } + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_HIDEINACTIVESELECTION: + ::toolkit::adjustBooleanWindowStyle( Value, pEdit, WB_NOHIDESELECTION, true ); + if ( pEdit->GetSubEdit() ) + ::toolkit::adjustBooleanWindowStyle( Value, pEdit->GetSubEdit(), WB_NOHIDESELECTION, true ); break; - default: - { - VCLXWindow::setProperty( PropertyName, Value ); - } + + case BASEPROPERTY_READONLY: + { + bool b = bool(); + if ( Value >>= b ) + pEdit->SetReadOnly( b ); + } + break; + case BASEPROPERTY_ECHOCHAR: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pEdit->SetEchoChar( n ); + } + break; + case BASEPROPERTY_MAXTEXTLEN: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pEdit->SetMaxTextLen( n ); + } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); } } } @@ -4237,18 +4237,18 @@ void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_In SolarMutexGuard aGuard; VclPtr< ComboBox > pBox = GetAs< ComboBox >(); - if ( pBox ) + if ( !pBox ) + return; + + sal_uInt16 nP = nPos; + for ( const auto& rItem : aItems ) { - sal_uInt16 nP = nPos; - for ( const auto& rItem : aItems ) + pBox->InsertEntry( rItem, nP ); + if ( nP == 0xFFFF ) { - pBox->InsertEntry( rItem, nP ); - if ( nP == 0xFFFF ) - { - OSL_FAIL( "VCLXComboBox::addItems: too many entries!" ); - // skip remaining entries, list cannot hold them, anyway - break; - } + OSL_FAIL( "VCLXComboBox::addItems: too many entries!" ); + // skip remaining entries, list cannot hold them, anyway + break; } } } @@ -4328,52 +4328,52 @@ void VCLXComboBox::setProperty( const OUString& PropertyName, const css::uno::An SolarMutexGuard aGuard; VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); - if ( pComboBox ) + if ( !pComboBox ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_LINECOUNT: { - case BASEPROPERTY_LINECOUNT: + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pComboBox->SetDropDownLineCount( n ); + } + break; + case BASEPROPERTY_AUTOCOMPLETE: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pComboBox->EnableAutocomplete( n != 0 ); + else { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pComboBox->SetDropDownLineCount( n ); + bool b = bool(); + if ( Value >>= b ) + pComboBox->EnableAutocomplete( b ); } - break; - case BASEPROPERTY_AUTOCOMPLETE: + } + break; + case BASEPROPERTY_STRINGITEMLIST: + { + css::uno::Sequence< OUString> aItems; + if ( Value >>= aItems ) { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pComboBox->EnableAutocomplete( n != 0 ); - else - { - bool b = bool(); - if ( Value >>= b ) - pComboBox->EnableAutocomplete( b ); - } + pComboBox->Clear(); + addItems( aItems, 0 ); } - break; - case BASEPROPERTY_STRINGITEMLIST: - { - css::uno::Sequence< OUString> aItems; - if ( Value >>= aItems ) - { - pComboBox->Clear(); - addItems( aItems, 0 ); - } - } - break; - default: - { - VCLXEdit::setProperty( PropertyName, Value ); + } + break; + default: + { + VCLXEdit::setProperty( PropertyName, Value ); - // #109385# SetBorderStyle is not virtual - if ( nPropType == BASEPROPERTY_BORDER ) - { - sal_uInt16 nBorder = sal_uInt16(); - if ( (Value >>= nBorder) && nBorder != 0 ) - pComboBox->SetBorderStyle( static_cast(nBorder) ); - } + // #109385# SetBorderStyle is not virtual + if ( nPropType == BASEPROPERTY_BORDER ) + { + sal_uInt16 nBorder = sal_uInt16(); + if ( (Value >>= nBorder) && nBorder != 0 ) + pComboBox->SetBorderStyle( static_cast(nBorder) ); } } } @@ -4666,37 +4666,37 @@ void VCLXFormattedSpinField::setProperty( const OUString& PropertyName, const cs SolarMutexGuard aGuard; FormatterBase* pFormatter = GetFormatter(); - if ( pFormatter ) + if ( !pFormatter ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_SPIN: { - case BASEPROPERTY_SPIN: - { - bool b = bool(); - if ( Value >>= b ) - { - WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN; - if ( !b ) - nStyle &= ~WB_SPIN; - GetWindow()->SetStyle( nStyle ); - } - } - break; - case BASEPROPERTY_STRICTFORMAT: + bool b = bool(); + if ( Value >>= b ) { - bool b = bool(); - if ( Value >>= b ) - { - pFormatter->SetStrictFormat( b ); - } + WinBits nStyle = GetWindow()->GetStyle() | WB_SPIN; + if ( !b ) + nStyle &= ~WB_SPIN; + GetWindow()->SetStyle( nStyle ); } - break; - default: + } + break; + case BASEPROPERTY_STRICTFORMAT: + { + bool b = bool(); + if ( Value >>= b ) { - VCLXSpinField::setProperty( PropertyName, Value ); + pFormatter->SetStrictFormat( b ); } } + break; + default: + { + VCLXSpinField::setProperty( PropertyName, Value ); + } } } @@ -4814,68 +4814,68 @@ void VCLXDateField::setProperty( const OUString& PropertyName, const css::uno::A { SolarMutexGuard aGuard; - if ( GetWindow() ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !(GetWindow()) ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_DATE: { - case BASEPROPERTY_DATE: + if ( bVoid ) { - if ( bVoid ) - { - GetAs< DateField >()->EnableEmptyFieldValue( true ); - GetAs< DateField >()->SetEmptyFieldValue(); - } - else - { - util::Date d; - if ( Value >>= d ) - setDate( d ); - } + GetAs< DateField >()->EnableEmptyFieldValue( true ); + GetAs< DateField >()->SetEmptyFieldValue(); } - break; - case BASEPROPERTY_DATEMIN: - { - util::Date d; - if ( Value >>= d ) - setMin( d ); - } - break; - case BASEPROPERTY_DATEMAX: + else { util::Date d; if ( Value >>= d ) - setMax( d ); - } - break; - case BASEPROPERTY_EXTDATEFORMAT: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - GetAs< DateField >()->SetExtDateFormat( static_cast(n) ); - } - break; - case BASEPROPERTY_DATESHOWCENTURY: - { - bool b = bool(); - if ( Value >>= b ) - GetAs< DateField >()->SetShowDateCentury( b ); - } - break; - case BASEPROPERTY_ENFORCE_FORMAT: - { - bool bEnforce( true ); - OSL_VERIFY( Value >>= bEnforce ); - GetAs< DateField >()->EnforceValidValue( bEnforce ); - } - break; - default: - { - VCLXFormattedSpinField::setProperty( PropertyName, Value ); + setDate( d ); } } + break; + case BASEPROPERTY_DATEMIN: + { + util::Date d; + if ( Value >>= d ) + setMin( d ); + } + break; + case BASEPROPERTY_DATEMAX: + { + util::Date d; + if ( Value >>= d ) + setMax( d ); + } + break; + case BASEPROPERTY_EXTDATEFORMAT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + GetAs< DateField >()->SetExtDateFormat( static_cast(n) ); + } + break; + case BASEPROPERTY_DATESHOWCENTURY: + { + bool b = bool(); + if ( Value >>= b ) + GetAs< DateField >()->SetShowDateCentury( b ); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + bool bEnforce( true ); + OSL_VERIFY( Value >>= bEnforce ); + GetAs< DateField >()->EnforceValidValue( bEnforce ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } } } @@ -5303,61 +5303,61 @@ void VCLXTimeField::setProperty( const OUString& PropertyName, const css::uno::A { SolarMutexGuard aGuard; - if ( GetWindow() ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !(GetWindow()) ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_TIME: { - case BASEPROPERTY_TIME: - { - if ( bVoid ) - { - GetAs< TimeField >()->EnableEmptyFieldValue( true ); - GetAs< TimeField >()->SetEmptyFieldValue(); - } - else - { - util::Time t; - if ( Value >>= t ) - setTime( t ); - } - } - break; - case BASEPROPERTY_TIMEMIN: + if ( bVoid ) { - util::Time t; - if ( Value >>= t ) - setMin( t ); + GetAs< TimeField >()->EnableEmptyFieldValue( true ); + GetAs< TimeField >()->SetEmptyFieldValue(); } - break; - case BASEPROPERTY_TIMEMAX: + else { util::Time t; if ( Value >>= t ) - setMax( t ); - } - break; - case BASEPROPERTY_EXTTIMEFORMAT: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - GetAs< TimeField >()->SetExtFormat( static_cast(n) ); - } - break; - case BASEPROPERTY_ENFORCE_FORMAT: - { - bool bEnforce( true ); - OSL_VERIFY( Value >>= bEnforce ); - GetAs< TimeField >()->EnforceValidValue( bEnforce ); - } - break; - default: - { - VCLXFormattedSpinField::setProperty( PropertyName, Value ); + setTime( t ); } } + break; + case BASEPROPERTY_TIMEMIN: + { + util::Time t; + if ( Value >>= t ) + setMin( t ); + } + break; + case BASEPROPERTY_TIMEMAX: + { + util::Time t; + if ( Value >>= t ) + setMax( t ); + } + break; + case BASEPROPERTY_EXTTIMEFORMAT: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + GetAs< TimeField >()->SetExtFormat( static_cast(n) ); + } + break; + case BASEPROPERTY_ENFORCE_FORMAT: + { + bool bEnforce( true ); + OSL_VERIFY( Value >>= bEnforce ); + GetAs< TimeField >()->EnforceValidValue( bEnforce ); + } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } } } @@ -5473,23 +5473,23 @@ void VCLXNumericField::setValue( double Value ) SolarMutexGuard aGuard; NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); - if ( pNumericFormatter ) - { - // shift long value using decimal digits - // (e.g., input 105 using 2 digits returns 1,05) - // Thus, to set a value of 1,05, insert 105 and 2 digits - pNumericFormatter->SetValue( - static_cast(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) ); + if ( !pNumericFormatter ) + return; - // #107218# Call same listeners like VCL would do after user interaction - VclPtr< Edit > pEdit = GetAs< Edit >(); - if ( pEdit ) - { - SetSynthesizingVCLEvent( true ); - pEdit->SetModifyFlag(); - pEdit->Modify(); - SetSynthesizingVCLEvent( false ); - } + // shift long value using decimal digits + // (e.g., input 105 using 2 digits returns 1,05) + // Thus, to set a value of 1,05, insert 105 and 2 digits + pNumericFormatter->SetValue( + static_cast(ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() )) ); + + // #107218# Call same listeners like VCL would do after user interaction + VclPtr< Edit > pEdit = GetAs< Edit >(); + if ( pEdit ) + { + SetSynthesizingVCLEvent( true ); + pEdit->SetModifyFlag(); + pEdit->Modify(); + SetSynthesizingVCLEvent( false ); } } @@ -5638,76 +5638,76 @@ void VCLXNumericField::setProperty( const OUString& PropertyName, const css::uno { SolarMutexGuard aGuard; - if ( GetWindow() ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + if ( !(GetWindow()) ) + return; - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_VALUE_DOUBLE: { - case BASEPROPERTY_VALUE_DOUBLE: - { - if ( bVoid ) - { - NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); - if (!pNumericFormatter) - return; - pNumericFormatter->EnableEmptyFieldValue( true ); - pNumericFormatter->SetEmptyFieldValue(); - } - else - { - double d = 0; - if ( Value >>= d ) - setValue( d ); - } - } - break; - case BASEPROPERTY_VALUEMIN_DOUBLE: + if ( bVoid ) { - double d = 0; - if ( Value >>= d ) - setMin( d ); - } - break; - case BASEPROPERTY_VALUEMAX_DOUBLE: - { - double d = 0; - if ( Value >>= d ) - setMax( d ); + NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); + if (!pNumericFormatter) + return; + pNumericFormatter->EnableEmptyFieldValue( true ); + pNumericFormatter->SetEmptyFieldValue(); } - break; - case BASEPROPERTY_VALUESTEP_DOUBLE: + else { double d = 0; if ( Value >>= d ) - setSpinSize( d ); - } - break; - case BASEPROPERTY_DECIMALACCURACY: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - setDecimalDigits( n ); + setValue( d ); } - break; - case BASEPROPERTY_NUMSHOWTHOUSANDSEP: - { - bool b = bool(); - if ( Value >>= b ) - { - NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); - if (!pNumericFormatter) - return; - pNumericFormatter->SetUseThousandSep( b ); - } - } - break; - default: + } + break; + case BASEPROPERTY_VALUEMIN_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMin( d ); + } + break; + case BASEPROPERTY_VALUEMAX_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setMax( d ); + } + break; + case BASEPROPERTY_VALUESTEP_DOUBLE: + { + double d = 0; + if ( Value >>= d ) + setSpinSize( d ); + } + break; + case BASEPROPERTY_DECIMALACCURACY: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + setDecimalDigits( n ); + } + break; + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + bool b = bool(); + if ( Value >>= b ) { - VCLXFormattedSpinField::setProperty( PropertyName, Value ); + NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); + if (!pNumericFormatter) + return; + pNumericFormatter->SetUseThousandSep( b ); } } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } } } @@ -5940,50 +5940,50 @@ void VCLXMetricField::setProperty( const OUString& PropertyName, const css::uno: { SolarMutexGuard aGuard; - if ( GetWindow() ) + if ( !(GetWindow()) ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_DECIMALACCURACY: { - case BASEPROPERTY_DECIMALACCURACY: - { - sal_Int16 n = 0; - if ( Value >>= n ) - setDecimalDigits( n ); - break; - } - case BASEPROPERTY_NUMSHOWTHOUSANDSEP: - { - bool b = false; - if ( Value >>= b ) - { - NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); - if (!pNumericFormatter) - return; - pNumericFormatter->SetUseThousandSep( b ); - } - } + sal_Int16 n = 0; + if ( Value >>= n ) + setDecimalDigits( n ); break; - case BASEPROPERTY_UNIT: - { - sal_uInt16 nVal = 0; - if ( Value >>= nVal ) - GetAs< MetricField >()->SetUnit( static_cast(nVal) ); - break; - } - case BASEPROPERTY_CUSTOMUNITTEXT: - { - OUString aStr; - if ( Value >>= aStr ) - GetAs< MetricField >()->SetCustomUnitText( aStr ); - break; - } - default: + } + case BASEPROPERTY_NUMSHOWTHOUSANDSEP: + { + bool b = false; + if ( Value >>= b ) { - VCLXFormattedSpinField::setProperty( PropertyName, Value ); - break; + NumericFormatter* pNumericFormatter = static_cast(GetFormatter()); + if (!pNumericFormatter) + return; + pNumericFormatter->SetUseThousandSep( b ); } } + break; + case BASEPROPERTY_UNIT: + { + sal_uInt16 nVal = 0; + if ( Value >>= nVal ) + GetAs< MetricField >()->SetUnit( static_cast(nVal) ); + break; + } + case BASEPROPERTY_CUSTOMUNITTEXT: + { + OUString aStr; + if ( Value >>= aStr ) + GetAs< MetricField >()->SetCustomUnitText( aStr ); + break; + } + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + break; + } } } @@ -6135,32 +6135,32 @@ void VCLXPatternField::setProperty( const OUString& PropertyName, const css::uno { SolarMutexGuard aGuard; - if ( GetWindow() ) + if ( !(GetWindow()) ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_EDITMASK: + case BASEPROPERTY_LITERALMASK: { - case BASEPROPERTY_EDITMASK: - case BASEPROPERTY_LITERALMASK: + OUString aString; + if ( Value >>= aString ) { - OUString aString; - if ( Value >>= aString ) - { - OUString aEditMask, aLiteralMask; - getMasks( aEditMask, aLiteralMask ); - if ( nPropType == BASEPROPERTY_EDITMASK ) - aEditMask = aString; - else - aLiteralMask = aString; - setMasks( aEditMask, aLiteralMask ); - } - } - break; - default: - { - VCLXFormattedSpinField::setProperty( PropertyName, Value ); + OUString aEditMask, aLiteralMask; + getMasks( aEditMask, aLiteralMask ); + if ( nPropType == BASEPROPERTY_EDITMASK ) + aEditMask = aString; + else + aLiteralMask = aString; + setMasks( aEditMask, aLiteralMask ); } } + break; + default: + { + VCLXFormattedSpinField::setProperty( PropertyName, Value ); + } } } -- cgit