diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-17 11:18:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-18 07:41:51 +0100 |
commit | 5e69b3619d3a2b05930c5b8b8521d7f2938c709d (patch) | |
tree | 2bcfb4244223b7fe570e9b0bcee2f7dd3928e226 /toolkit | |
parent | 1d097883541b9d244e50ced7fe49a4d7a0f65cfd (diff) |
loplugin:flatten in toolkit..writerfilter
Change-Id: I4da2a768b6b55869c3a3d6f8a8d50dc018709acd
Reviewed-on: https://gerrit.libreoffice.org/44865
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxtabpagecontainer.cxx | 37 | ||||
-rw-r--r-- | toolkit/source/controls/dialogcontrol.cxx | 100 | ||||
-rw-r--r-- | toolkit/source/controls/tabpagemodel.cxx | 96 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrol.cxx | 704 |
4 files changed, 472 insertions, 465 deletions
diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx index df730e9adfcf..24d2d309665f 100644 --- a/toolkit/source/awt/vclxtabpagecontainer.cxx +++ b/toolkit/source/awt/vclxtabpagecontainer.cxx @@ -179,24 +179,25 @@ void SAL_CALL VCLXTabPageContainer::elementInserted( const css::container::Conta SolarMutexGuard aGuard; VclPtr<TabControl> pTabCtrl = GetAs<TabControl>(); Reference< css::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); - if ( pTabCtrl && xTabPage.is() ) - { - Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); - Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); - sal_Int16 nPageID = xP->getTabPageID(); - - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); - TabPage* pPage = static_cast<TabPage*>(pWindow.get()); - pTabCtrl->InsertPage(nPageID,pPage->GetText()); - - pPage->Hide(); - pTabCtrl->SetTabPage(nPageID,pPage); - pTabCtrl->SetHelpText(nPageID,xP->getToolTip()); - pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL())); - pTabCtrl->SelectTabPage(nPageID); - pTabCtrl->EnablePage(nPageID,xP->getEnabled()); - m_aTabPages.push_back(xTabPage); - } + if ( !pTabCtrl || !xTabPage.is() ) + return; + + Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + sal_Int16 nPageID = xP->getTabPageID(); + + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); + TabPage* pPage = static_cast<TabPage*>(pWindow.get()); + pTabCtrl->InsertPage(nPageID,pPage->GetText()); + + pPage->Hide(); + pTabCtrl->SetTabPage(nPageID,pPage); + pTabCtrl->SetHelpText(nPageID,xP->getToolTip()); + pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL())); + pTabCtrl->SelectTabPage(nPageID); + pTabCtrl->EnablePage(nPageID,xP->getEnabled()); + m_aTabPages.push_back(xTabPage); + } void SAL_CALL VCLXTabPageContainer::elementRemoved( const css::container::ContainerEvent& Event ) { diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index 2a27b237ee57..8ca31adf47d3 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -488,65 +488,67 @@ void SAL_CALL UnoDialogControl::windowResized( const css::awt::WindowEvent& e ) { OutputDevice*pOutDev = Application::GetDefaultDevice(); DBG_ASSERT( pOutDev, "Missing Default Device!" ); - if ( pOutDev && !mbSizeModified ) - { - // Currentley we are simply using MapUnit::MapAppFont - ::Size aAppFontSize( e.Width, e.Height ); + if ( !pOutDev || mbSizeModified ) + return; - Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); - Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); - OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); + // Currentley we are simply using MapUnit::MapAppFont + ::Size aAppFontSize( e.Width, e.Height ); - // #i87592 In design mode the drawing layer works with sizes with decoration. - // Therefore we have to subtract them before writing back to the properties (model). - if ( xDialogDevice.is() && mbDesignMode ) - { - DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); - aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; - aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; - } + Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); + Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); + OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); - aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); - - // Remember that changes have been done by listener. No need to - // update the position because of property change event. - mbSizeModified = true; - Sequence< OUString > aProps( 2 ); - Sequence< Any > aValues( 2 ); - // Properties in a sequence must be sorted! - aProps[0] = "Height"; - aProps[1] = "Width"; - aValues[0] <<= aAppFontSize.Height(); - aValues[1] <<= aAppFontSize.Width(); - - ImplSetPropertyValues( aProps, aValues, true ); - mbSizeModified = false; + // #i87592 In design mode the drawing layer works with sizes with decoration. + // Therefore we have to subtract them before writing back to the properties (model). + if ( xDialogDevice.is() && mbDesignMode ) + { + DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); + aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; + aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; } + + aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbSizeModified = true; + Sequence< OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + // Properties in a sequence must be sorted! + aProps[0] = "Height"; + aProps[1] = "Width"; + aValues[0] <<= aAppFontSize.Height(); + aValues[1] <<= aAppFontSize.Width(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbSizeModified = false; + } void SAL_CALL UnoDialogControl::windowMoved( const css::awt::WindowEvent& e ) { OutputDevice*pOutDev = Application::GetDefaultDevice(); DBG_ASSERT( pOutDev, "Missing Default Device!" ); - if ( pOutDev && !mbPosModified ) - { - // Currentley we are simply using MapUnit::MapAppFont - ::Size aTmp( e.X, e.Y ); - aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); - - // Remember that changes have been done by listener. No need to - // update the position because of property change event. - mbPosModified = true; - Sequence< OUString > aProps( 2 ); - Sequence< Any > aValues( 2 ); - aProps[0] = "PositionX"; - aProps[1] = "PositionY"; - aValues[0] <<= aTmp.Width(); - aValues[1] <<= aTmp.Height(); - - ImplSetPropertyValues( aProps, aValues, true ); - mbPosModified = false; - } + if ( !pOutDev || mbPosModified ) + return; + + // Currentley we are simply using MapUnit::MapAppFont + ::Size aTmp( e.X, e.Y ); + aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbPosModified = true; + Sequence< OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + aProps[0] = "PositionX"; + aProps[1] = "PositionY"; + aValues[0] <<= aTmp.Width(); + aValues[1] <<= aTmp.Height(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbPosModified = false; + } void SAL_CALL UnoDialogControl::windowShown( const EventObject& ) {} diff --git a/toolkit/source/controls/tabpagemodel.cxx b/toolkit/source/controls/tabpagemodel.cxx index c45c8daad700..90f22675da0f 100644 --- a/toolkit/source/controls/tabpagemodel.cxx +++ b/toolkit/source/controls/tabpagemodel.cxx @@ -235,62 +235,64 @@ void SAL_CALL UnoControlTabPage::windowResized( const css::awt::WindowEvent& e ) { OutputDevice*pOutDev = Application::GetDefaultDevice(); DBG_ASSERT( pOutDev, "Missing Default Device!" ); - if ( pOutDev && !mbSizeModified ) - { - // Currentley we are simply using MapUnit::MapAppFont - ::Size aAppFontSize( e.Width, e.Height ); + if ( !pOutDev || mbSizeModified ) + return; - Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); - Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); - OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); - if ( xDialogDevice.is() ) - { - DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); - aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; - aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; - } + // Currentley we are simply using MapUnit::MapAppFont + ::Size aAppFontSize( e.Width, e.Height ); - aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); - - // Remember that changes have been done by listener. No need to - // update the position because of property change event. - mbSizeModified = true; - Sequence< OUString > aProps( 2 ); - Sequence< Any > aValues( 2 ); - // Properties in a sequence must be sorted! - aProps[0] = "Height"; - aProps[1] = "Width"; - aValues[0] <<= aAppFontSize.Height(); - aValues[1] <<= aAppFontSize.Width(); - - ImplSetPropertyValues( aProps, aValues, true ); - mbSizeModified = false; + Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); + Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); + OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); + if ( xDialogDevice.is() ) + { + DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); + aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; + aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; } + + aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbSizeModified = true; + Sequence< OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + // Properties in a sequence must be sorted! + aProps[0] = "Height"; + aProps[1] = "Width"; + aValues[0] <<= aAppFontSize.Height(); + aValues[1] <<= aAppFontSize.Width(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbSizeModified = false; + } void SAL_CALL UnoControlTabPage::windowMoved( const css::awt::WindowEvent& e ) { OutputDevice*pOutDev = Application::GetDefaultDevice(); DBG_ASSERT( pOutDev, "Missing Default Device!" ); - if ( pOutDev && !mbPosModified ) - { - // Currentley we are simply using MapUnit::MapAppFont - ::Size aTmp( e.X, e.Y ); - aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); - - // Remember that changes have been done by listener. No need to - // update the position because of property change event. - mbPosModified = true; - Sequence< OUString > aProps( 2 ); - Sequence< Any > aValues( 2 ); - aProps[0] = "PositionX"; - aProps[1] = "PositionY"; - aValues[0] <<= aTmp.Width(); - aValues[1] <<= aTmp.Height(); - - ImplSetPropertyValues( aProps, aValues, true ); - mbPosModified = false; - } + if ( !pOutDev || mbPosModified ) + return; + + // Currentley we are simply using MapUnit::MapAppFont + ::Size aTmp( e.X, e.Y ); + aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbPosModified = true; + Sequence< OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + aProps[0] = "PositionX"; + aProps[1] = "PositionY"; + aValues[0] <<= aTmp.Width(); + aValues[1] <<= aTmp.Height(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbPosModified = false; + } void SAL_CALL UnoControlTabPage::windowShown( const css::lang::EventObject& ) {} diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 02e393f39af9..f07ff4d64251 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -462,199 +462,200 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent { ::osl::ClearableGuard< ::osl::Mutex > aGuard( GetMutex() ); - if( getPeer().is() ) - { - std::vector< PropertyValue > aPeerPropertiesToSet; - sal_Int32 nIndependentPos = 0; - bool bResourceResolverSet( false ); - // position where to insert the independent properties into aPeerPropertiesToSet, - // dependent ones are inserted at the end of the vector + if( !getPeer().is() ) + return; + + std::vector< PropertyValue > aPeerPropertiesToSet; + sal_Int32 nIndependentPos = 0; + bool bResourceResolverSet( false ); + // position where to insert the independent properties into aPeerPropertiesToSet, + // dependent ones are inserted at the end of the vector - bool bNeedNewPeer = false; - // some properties require a re-creation of the peer, 'cause they can't be changed on the fly + bool bNeedNewPeer = false; + // some properties require a re-creation of the peer, 'cause they can't be changed on the fly - Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY ); - // our own model for comparison - Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY ); - Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY ); - OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" ); + Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY ); + // our own model for comparison + Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY ); + Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY ); + OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" ); - const PropertyChangeEvent* pEvents = rEvents.getConstArray(); + const PropertyChangeEvent* pEvents = rEvents.getConstArray(); - sal_Int32 nLen = rEvents.getLength(); - aPeerPropertiesToSet.reserve(nLen); + sal_Int32 nLen = rEvents.getLength(); + aPeerPropertiesToSet.reserve(nLen); - for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents ) + for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents ) + { + Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY ); + bool bOwnModel = xModel.get() == xOwnModel.get(); + if ( !bOwnModel ) + continue; + + // Detect changes on our resource resolver which invalidates + // automatically some language dependent properties. + if ( pEvents->PropertyName == "ResourceResolver" ) { - Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY ); - bool bOwnModel = xModel.get() == xOwnModel.get(); - if ( !bOwnModel ) - continue; - - // Detect changes on our resource resolver which invalidates - // automatically some language dependent properties. - if ( pEvents->PropertyName == "ResourceResolver" ) - { - Reference< resource::XStringResourceResolver > xStrResolver; - if ( pEvents->NewValue >>= xStrResolver ) - bResourceResolverSet = xStrResolver.is(); - } + Reference< resource::XStringResourceResolver > xStrResolver; + if ( pEvents->NewValue >>= xStrResolver ) + bResourceResolverSet = xStrResolver.is(); + } - sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName ); - if ( mbDesignMode && mbDisposePeer && !mbRefeshingPeer && !mbCreatingPeer ) - { - // if we're in design mode, then some properties can change which - // require creating a *new* peer (since these properties cannot - // be switched at existing peers) - if ( nPType ) - bNeedNewPeer = ( nPType == BASEPROPERTY_BORDER ) - || ( nPType == BASEPROPERTY_MULTILINE ) - || ( nPType == BASEPROPERTY_DROPDOWN ) - || ( nPType == BASEPROPERTY_HSCROLL ) - || ( nPType == BASEPROPERTY_VSCROLL ) - || ( nPType == BASEPROPERTY_AUTOHSCROLL ) - || ( nPType == BASEPROPERTY_AUTOVSCROLL ) - || ( nPType == BASEPROPERTY_ORIENTATION ) - || ( nPType == BASEPROPERTY_SPIN ) - || ( nPType == BASEPROPERTY_ALIGN ) - || ( nPType == BASEPROPERTY_PAINTTRANSPARENT ); - else - bNeedNewPeer = requiresNewPeer( pEvents->PropertyName ); + sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName ); + if ( mbDesignMode && mbDisposePeer && !mbRefeshingPeer && !mbCreatingPeer ) + { + // if we're in design mode, then some properties can change which + // require creating a *new* peer (since these properties cannot + // be switched at existing peers) + if ( nPType ) + bNeedNewPeer = ( nPType == BASEPROPERTY_BORDER ) + || ( nPType == BASEPROPERTY_MULTILINE ) + || ( nPType == BASEPROPERTY_DROPDOWN ) + || ( nPType == BASEPROPERTY_HSCROLL ) + || ( nPType == BASEPROPERTY_VSCROLL ) + || ( nPType == BASEPROPERTY_AUTOHSCROLL ) + || ( nPType == BASEPROPERTY_AUTOVSCROLL ) + || ( nPType == BASEPROPERTY_ORIENTATION ) + || ( nPType == BASEPROPERTY_SPIN ) + || ( nPType == BASEPROPERTY_ALIGN ) + || ( nPType == BASEPROPERTY_PAINTTRANSPARENT ); + else + bNeedNewPeer = requiresNewPeer( pEvents->PropertyName ); - if ( bNeedNewPeer ) - break; - } + if ( bNeedNewPeer ) + break; + } - if ( nPType && ( nLen > 1 ) && DoesDependOnOthers( nPType ) ) + if ( nPType && ( nLen > 1 ) && DoesDependOnOthers( nPType ) ) + { + // Add properties with dependencies on other properties last + // since they're dependent on properties added later (such as + // VALUE dependency on VALUEMIN/MAX) + aPeerPropertiesToSet.emplace_back(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE); + } + else + { + if ( bResourceResolverSet ) { - // Add properties with dependencies on other properties last - // since they're dependent on properties added later (such as - // VALUE dependency on VALUEMIN/MAX) - aPeerPropertiesToSet.emplace_back(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE); + // The resource resolver property change should be one of the first ones. + // All language dependent properties are dependent on this property. + // As BASEPROPERTY_NATIVE_WIDGET_LOOK is not dependent on resource + // resolver. We don't need to handle a special order for these two props. + aPeerPropertiesToSet.insert( + aPeerPropertiesToSet.begin(), + PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) ); + ++nIndependentPos; + } + else if ( nPType == BASEPROPERTY_NATIVE_WIDGET_LOOK ) + { + // since *a lot* of other properties might be overruled by this one, we need + // a special handling: + // NativeWidgetLook needs to be set first: If it is set to ON, all other + // properties describing the look (e.g. BackgroundColor) are ignored, anyway. + // If it is switched OFF, then we need to do it first because else it will + // overrule other look-related properties, and re-initialize them from system + // defaults. + aPeerPropertiesToSet.insert( + aPeerPropertiesToSet.begin(), + PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) ); + ++nIndependentPos; } else { - if ( bResourceResolverSet ) - { - // The resource resolver property change should be one of the first ones. - // All language dependent properties are dependent on this property. - // As BASEPROPERTY_NATIVE_WIDGET_LOOK is not dependent on resource - // resolver. We don't need to handle a special order for these two props. - aPeerPropertiesToSet.insert( - aPeerPropertiesToSet.begin(), - PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) ); - ++nIndependentPos; - } - else if ( nPType == BASEPROPERTY_NATIVE_WIDGET_LOOK ) - { - // since *a lot* of other properties might be overruled by this one, we need - // a special handling: - // NativeWidgetLook needs to be set first: If it is set to ON, all other - // properties describing the look (e.g. BackgroundColor) are ignored, anyway. - // If it is switched OFF, then we need to do it first because else it will - // overrule other look-related properties, and re-initialize them from system - // defaults. - aPeerPropertiesToSet.insert( - aPeerPropertiesToSet.begin(), - PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) ); - ++nIndependentPos; - } - else - { - aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos, - PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE)); - ++nIndependentPos; - } + aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos, + PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE)); + ++nIndependentPos; } } + } - Reference< XWindow > xParent = getParentPeer(); - Reference< XControl > xThis( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY ); - // call createPeer via a interface got from queryInterface, so the aggregating class can intercept it + Reference< XWindow > xParent = getParentPeer(); + Reference< XControl > xThis( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY ); + // call createPeer via a interface got from queryInterface, so the aggregating class can intercept it - DBG_ASSERT( !bNeedNewPeer || xParent.is(), "Need new peer, but don't have a parent!" ); + DBG_ASSERT( !bNeedNewPeer || xParent.is(), "Need new peer, but don't have a parent!" ); - // Check if we have to update language dependent properties - if ( !bNeedNewPeer && bResourceResolverSet ) + // Check if we have to update language dependent properties + if ( !bNeedNewPeer && bResourceResolverSet ) + { + // Add language dependent properties into the peer property set. + // Our resource resolver has been changed and we must be sure + // that language dependent props use the new resolver. + const LanguageDependentProp* pLangDepProp = aLanguageDependentProp; + while ( pLangDepProp->pPropName != nullptr ) { - // Add language dependent properties into the peer property set. - // Our resource resolver has been changed and we must be sure - // that language dependent props use the new resolver. - const LanguageDependentProp* pLangDepProp = aLanguageDependentProp; - while ( pLangDepProp->pPropName != nullptr ) + bool bMustBeInserted( true ); + for (PropertyValue & i : aPeerPropertiesToSet) { - bool bMustBeInserted( true ); - for (PropertyValue & i : aPeerPropertiesToSet) + if ( i.Name.equalsAsciiL( + pLangDepProp->pPropName, pLangDepProp->nPropNameLength )) { - if ( i.Name.equalsAsciiL( - pLangDepProp->pPropName, pLangDepProp->nPropNameLength )) - { - bMustBeInserted = false; - break; - } + bMustBeInserted = false; + break; } + } - if ( bMustBeInserted ) + if ( bMustBeInserted ) + { + // Add language dependent props at the end + OUString aPropName( OUString::createFromAscii( pLangDepProp->pPropName )); + if ( xPSI.is() && xPSI->hasPropertyByName( aPropName ) ) { - // Add language dependent props at the end - OUString aPropName( OUString::createFromAscii( pLangDepProp->pPropName )); - if ( xPSI.is() && xPSI->hasPropertyByName( aPropName ) ) - { - aPeerPropertiesToSet.emplace_back( aPropName, 0, xPS->getPropertyValue( aPropName ), PropertyState_DIRECT_VALUE ); - } + aPeerPropertiesToSet.emplace_back( aPropName, 0, xPS->getPropertyValue( aPropName ), PropertyState_DIRECT_VALUE ); } - - ++pLangDepProp; } + + ++pLangDepProp; } - aGuard.clear(); + } + aGuard.clear(); - // clear the guard before creating a new peer - as usual, our peer implementations use the SolarMutex + // clear the guard before creating a new peer - as usual, our peer implementations use the SolarMutex - if (bNeedNewPeer && xParent.is()) - { - SolarMutexGuard aVclGuard; - // and now this is the final withdrawal: - // I have no other idea than locking the SolarMutex here.... - // I really hate the fact that VCL is not threadsafe.... - - // Doesn't work for Container! - getPeer()->dispose(); - mxPeer.clear(); - mxVclWindowPeer = nullptr; - mbRefeshingPeer = true; - Reference< XWindowPeer > xP( xParent, UNO_QUERY ); - xThis->createPeer( Reference< XToolkit > (), xP ); - mbRefeshingPeer = false; - aPeerPropertiesToSet.clear(); - } + if (bNeedNewPeer && xParent.is()) + { + SolarMutexGuard aVclGuard; + // and now this is the final withdrawal: + // I have no other idea than locking the SolarMutex here.... + // I really hate the fact that VCL is not threadsafe.... + + // Doesn't work for Container! + getPeer()->dispose(); + mxPeer.clear(); + mxVclWindowPeer = nullptr; + mbRefeshingPeer = true; + Reference< XWindowPeer > xP( xParent, UNO_QUERY ); + xThis->createPeer( Reference< XToolkit > (), xP ); + mbRefeshingPeer = false; + aPeerPropertiesToSet.clear(); + } - // lock the multiplexing of VCL events to our UNO listeners - // this is for compatibility reasons: in OOo 1.0.x, changes which were done at the - // model did not cause the listeners of the controls/peers to be called - // Since the implementations for the listeners changed a lot towards 1.1, this - // would not be the case anymore, if we would not do this listener-lock below - // #i14703# - VCLXWindow* pPeer; - { - SolarMutexGuard g; - VclPtr<vcl::Window> pVclPeer = VCLUnoHelper::GetWindow( getPeer() ); - pPeer = pVclPeer ? pVclPeer->GetWindowPeer() : nullptr; - } - VclListenerLock aNoVclEventMultiplexing( pPeer ); - - // setting peer properties may result in an attempt to acquire the solar mutex, 'cause the peers - // usually don't have an own mutex but use the SolarMutex instead. - // To prevent deadlocks resulting from this, we do this without our own mutex locked - std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end(); - for ( std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin(); - aLoop != aEnd; - ++aLoop - ) - { - ImplSetPeerProperty( aLoop->Name, aLoop->Value ); - } + // lock the multiplexing of VCL events to our UNO listeners + // this is for compatibility reasons: in OOo 1.0.x, changes which were done at the + // model did not cause the listeners of the controls/peers to be called + // Since the implementations for the listeners changed a lot towards 1.1, this + // would not be the case anymore, if we would not do this listener-lock below + // #i14703# + VCLXWindow* pPeer; + { + SolarMutexGuard g; + VclPtr<vcl::Window> pVclPeer = VCLUnoHelper::GetWindow( getPeer() ); + pPeer = pVclPeer ? pVclPeer->GetWindowPeer() : nullptr; + } + VclListenerLock aNoVclEventMultiplexing( pPeer ); + + // setting peer properties may result in an attempt to acquire the solar mutex, 'cause the peers + // usually don't have an own mutex but use the SolarMutex instead. + // To prevent deadlocks resulting from this, we do this without our own mutex locked + std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end(); + for ( std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin(); + aLoop != aEnd; + ++aLoop + ) + { + ImplSetPeerProperty( aLoop->Name, aLoop->Value ); } + } void UnoControl::disposing( const EventObject& rEvt ) @@ -1086,235 +1087,236 @@ void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Refer throw aException; } - if( !getPeer().is() ) - { - mbCreatingPeer = true; + if( getPeer().is() ) + return; - WindowClass eType; - Reference< XToolkit > xToolkit = rxToolkit; - if( rParentPeer.is() && mxContext.is() ) + mbCreatingPeer = true; + + WindowClass eType; + Reference< XToolkit > xToolkit = rxToolkit; + if( rParentPeer.is() && mxContext.is() ) + { + // no TopWindow + if ( !xToolkit.is() ) + xToolkit = rParentPeer->getToolkit(); + Any aAny = OWeakAggObject::queryInterface( cppu::UnoType<XControlContainer>::get()); + Reference< XControlContainer > xC; + aAny >>= xC; + if( xC.is() ) + // It's a container + eType = WindowClass_CONTAINER; + else + eType = WindowClass_SIMPLE; + } + else + { // This is only correct for Top Window + if( rParentPeer.is() ) { - // no TopWindow if ( !xToolkit.is() ) xToolkit = rParentPeer->getToolkit(); - Any aAny = OWeakAggObject::queryInterface( cppu::UnoType<XControlContainer>::get()); - Reference< XControlContainer > xC; - aAny >>= xC; - if( xC.is() ) - // It's a container - eType = WindowClass_CONTAINER; - else - eType = WindowClass_SIMPLE; + eType = WindowClass_CONTAINER; } else - { // This is only correct for Top Window - if( rParentPeer.is() ) - { - if ( !xToolkit.is() ) - xToolkit = rParentPeer->getToolkit(); - eType = WindowClass_CONTAINER; - } - else - { - if ( !xToolkit.is() ) - xToolkit = VCLUnoHelper::CreateToolkit(); - eType = WindowClass_TOP; - } - } - WindowDescriptor aDescr; - aDescr.Type = eType; - aDescr.WindowServiceName = GetComponentServiceName(); - aDescr.Parent = rParentPeer; - aDescr.Bounds = getPosSize(); - aDescr.WindowAttributes = 0; - - // Border - Reference< XPropertySet > xPSet( mxModel, UNO_QUERY ); - Reference< XPropertySetInfo > xInfo = xPSet->getPropertySetInfo(); - - Any aVal; - OUString aPropName = GetPropertyName( BASEPROPERTY_BORDER ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - sal_Int16 n = sal_Int16(); - if ( aVal >>= n ) - { - if ( n ) - aDescr.WindowAttributes |= WindowAttribute::BORDER; - else - aDescr.WindowAttributes |= VclWindowPeerAttribute::NOBORDER; - } - } - - // DESKTOP_AS_PARENT - if ( aDescr.Type == WindowClass_TOP ) { - aPropName = GetPropertyName( BASEPROPERTY_DESKTOP_AS_PARENT ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.ParentIndex = -1; - } + if ( !xToolkit.is() ) + xToolkit = VCLUnoHelper::CreateToolkit(); + eType = WindowClass_TOP; } - // Moveable - aPropName = GetPropertyName( BASEPROPERTY_MOVEABLE ); - if ( xInfo->hasPropertyByName( aPropName ) ) + } + WindowDescriptor aDescr; + aDescr.Type = eType; + aDescr.WindowServiceName = GetComponentServiceName(); + aDescr.Parent = rParentPeer; + aDescr.Bounds = getPosSize(); + aDescr.WindowAttributes = 0; + + // Border + Reference< XPropertySet > xPSet( mxModel, UNO_QUERY ); + Reference< XPropertySetInfo > xInfo = xPSet->getPropertySetInfo(); + + Any aVal; + OUString aPropName = GetPropertyName( BASEPROPERTY_BORDER ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + sal_Int16 n = sal_Int16(); + if ( aVal >>= n ) { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= WindowAttribute::MOVEABLE; + if ( n ) + aDescr.WindowAttributes |= WindowAttribute::BORDER; + else + aDescr.WindowAttributes |= VclWindowPeerAttribute::NOBORDER; } + } - // Closeable - aPropName = GetPropertyName( BASEPROPERTY_CLOSEABLE ); + // DESKTOP_AS_PARENT + if ( aDescr.Type == WindowClass_TOP ) + { + aPropName = GetPropertyName( BASEPROPERTY_DESKTOP_AS_PARENT ); if ( xInfo->hasPropertyByName( aPropName ) ) { aVal = xPSet->getPropertyValue( aPropName ); bool b = bool(); if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= WindowAttribute::CLOSEABLE; + aDescr.ParentIndex = -1; } + } + // Moveable + aPropName = GetPropertyName( BASEPROPERTY_MOVEABLE ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= WindowAttribute::MOVEABLE; + } - // Dropdown - aPropName = GetPropertyName( BASEPROPERTY_DROPDOWN ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN; - } + // Closeable + aPropName = GetPropertyName( BASEPROPERTY_CLOSEABLE ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= WindowAttribute::CLOSEABLE; + } - // Spin - aPropName = GetPropertyName( BASEPROPERTY_SPIN ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::SPIN; - } + // Dropdown + aPropName = GetPropertyName( BASEPROPERTY_DROPDOWN ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN; + } - // HScroll - aPropName = GetPropertyName( BASEPROPERTY_HSCROLL ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::HSCROLL; - } + // Spin + aPropName = GetPropertyName( BASEPROPERTY_SPIN ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::SPIN; + } - // VScroll - aPropName = GetPropertyName( BASEPROPERTY_VSCROLL ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::VSCROLL; - } + // HScroll + aPropName = GetPropertyName( BASEPROPERTY_HSCROLL ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::HSCROLL; + } - // AutoHScroll - aPropName = GetPropertyName( BASEPROPERTY_AUTOHSCROLL ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOHSCROLL; - } + // VScroll + aPropName = GetPropertyName( BASEPROPERTY_VSCROLL ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::VSCROLL; + } - // AutoVScroll - aPropName = GetPropertyName( BASEPROPERTY_AUTOVSCROLL ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>= b ) && b) - aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOVSCROLL; - } + // AutoHScroll + aPropName = GetPropertyName( BASEPROPERTY_AUTOHSCROLL ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOHSCROLL; + } - //added for issue79712 - //NoLabel - aPropName = GetPropertyName( BASEPROPERTY_NOLABEL ); - if ( xInfo->hasPropertyByName( aPropName ) ) - { - aVal = xPSet->getPropertyValue( aPropName ); - bool b = bool(); - if ( ( aVal >>=b ) && b ) - aDescr.WindowAttributes |= VclWindowPeerAttribute::NOLABEL; - } - //issue79712 ends + // AutoVScroll + aPropName = GetPropertyName( BASEPROPERTY_AUTOVSCROLL ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>= b ) && b) + aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOVSCROLL; + } - // Align - aPropName = GetPropertyName( BASEPROPERTY_ALIGN ); - if ( xInfo->hasPropertyByName( aPropName ) ) + //added for issue79712 + //NoLabel + aPropName = GetPropertyName( BASEPROPERTY_NOLABEL ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + bool b = bool(); + if ( ( aVal >>=b ) && b ) + aDescr.WindowAttributes |= VclWindowPeerAttribute::NOLABEL; + } + //issue79712 ends + + // Align + aPropName = GetPropertyName( BASEPROPERTY_ALIGN ); + if ( xInfo->hasPropertyByName( aPropName ) ) + { + aVal = xPSet->getPropertyValue( aPropName ); + sal_Int16 n = sal_Int16(); + if ( aVal >>= n ) { - aVal = xPSet->getPropertyValue( aPropName ); - sal_Int16 n = sal_Int16(); - if ( aVal >>= n ) - { - if ( n == PROPERTY_ALIGN_LEFT ) - aDescr.WindowAttributes |= VclWindowPeerAttribute::LEFT; - else if ( n == PROPERTY_ALIGN_CENTER ) - aDescr.WindowAttributes |= VclWindowPeerAttribute::CENTER; - else - aDescr.WindowAttributes |= VclWindowPeerAttribute::RIGHT; - } + if ( n == PROPERTY_ALIGN_LEFT ) + aDescr.WindowAttributes |= VclWindowPeerAttribute::LEFT; + else if ( n == PROPERTY_ALIGN_CENTER ) + aDescr.WindowAttributes |= VclWindowPeerAttribute::CENTER; + else + aDescr.WindowAttributes |= VclWindowPeerAttribute::RIGHT; } + } - // Allow derivates to manipulate attributes - PrepareWindowDescriptor(aDescr); + // Allow derivates to manipulate attributes + PrepareWindowDescriptor(aDescr); - // create the peer - setPeer( xToolkit->createWindow( aDescr ) ); + // create the peer + setPeer( xToolkit->createWindow( aDescr ) ); - // release the mutex guard (and work with copies of our members) - // this is necessary as our peer may lock the SolarMutex (actually, all currently known peers do), so calling - // into the peer with our own mutex locked may cause deadlocks - // (We _really_ need peers which do not use the SolarMutex. It's really pissing me off that from time to - // time deadlocks pop up because the low-level components like our peers use a mutex which usually - // is locked at the top of the stack (it protects the global message looping). This is always dangerous, and - // can not always be solved by tampering with other mutexes. - // Unfortunately, the VCL used in the peers is not threadsafe, and by definition needs a locked SolarMutex.) - // 82300 - 12/21/00 - FS - UnoControlComponentInfos aComponentInfos(maComponentInfos); - bool bDesignMode(mbDesignMode); + // release the mutex guard (and work with copies of our members) + // this is necessary as our peer may lock the SolarMutex (actually, all currently known peers do), so calling + // into the peer with our own mutex locked may cause deadlocks + // (We _really_ need peers which do not use the SolarMutex. It's really pissing me off that from time to + // time deadlocks pop up because the low-level components like our peers use a mutex which usually + // is locked at the top of the stack (it protects the global message looping). This is always dangerous, and + // can not always be solved by tampering with other mutexes. + // Unfortunately, the VCL used in the peers is not threadsafe, and by definition needs a locked SolarMutex.) + // 82300 - 12/21/00 - FS + UnoControlComponentInfos aComponentInfos(maComponentInfos); + bool bDesignMode(mbDesignMode); - Reference< XGraphics > xGraphics( mxGraphics ); - Reference< XView > xView ( getPeer(), UNO_QUERY_THROW ); - Reference< XWindow > xWindow ( getPeer(), UNO_QUERY_THROW ); + Reference< XGraphics > xGraphics( mxGraphics ); + Reference< XView > xView ( getPeer(), UNO_QUERY_THROW ); + Reference< XWindow > xWindow ( getPeer(), UNO_QUERY_THROW ); - aGuard.clear(); + aGuard.clear(); - // the updateFromModel is done without a locked mutex, too. - // The reason is that the only thing this method does is firing property changes, and this in general has - // to be done without locked mutexes (as every notification to external listeners). - // 82300 - 12/21/00 - FS - updateFromModel(); + // the updateFromModel is done without a locked mutex, too. + // The reason is that the only thing this method does is firing property changes, and this in general has + // to be done without locked mutexes (as every notification to external listeners). + // 82300 - 12/21/00 - FS + updateFromModel(); - xView->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY ); + xView->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY ); - setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, aComponentInfos.nFlags ); + setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, aComponentInfos.nFlags ); - if( aComponentInfos.bVisible && !bDesignMode ) - // Show only after setting the data - xWindow->setVisible( aComponentInfos.bVisible ); + if( aComponentInfos.bVisible && !bDesignMode ) + // Show only after setting the data + xWindow->setVisible( aComponentInfos.bVisible ); - if( !aComponentInfos.bEnable ) - xWindow->setEnable( aComponentInfos.bEnable ); + if( !aComponentInfos.bEnable ) + xWindow->setEnable( aComponentInfos.bEnable ); - xView->setGraphics( xGraphics ); + xView->setGraphics( xGraphics ); - peerCreated(); + peerCreated(); + + mbCreatingPeer = false; - mbCreatingPeer = false; - } } Reference< XWindowPeer > UnoControl::getPeer() |