summaryrefslogtreecommitdiff
path: root/toolkit/source/controls
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-03 23:36:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 01:40:24 +0200
commit714d907d304fae5cc8613eced127060199639af6 (patch)
tree31e495ddd9e12b32220dacbceabfca56ea7cf99e /toolkit/source/controls
parent8c4a24092bd9ccd1d577d10ae0559cef406e8fae (diff)
loplugin:flatten in toolkit
Change-Id: I8f4b29620134566f256f05bbab677e83baf20ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100031 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit/source/controls')
-rw-r--r--toolkit/source/controls/controlmodelcontainerbase.cxx120
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx97
-rw-r--r--toolkit/source/controls/roadmapcontrol.cxx28
-rw-r--r--toolkit/source/controls/tree/treedatamodel.cxx60
-rw-r--r--toolkit/source/controls/unocontrol.cxx54
-rw-r--r--toolkit/source/controls/unocontrolbase.cxx56
-rw-r--r--toolkit/source/controls/unocontrolcontainer.cxx80
-rw-r--r--toolkit/source/controls/unocontrolmodel.cxx172
-rw-r--r--toolkit/source/controls/unocontrols.cxx164
9 files changed, 415 insertions, 416 deletions
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 05b9edb18643..880b25c53a82 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -1100,24 +1100,24 @@ void ResourceListener::startListening(
// --- SAFE ---
}
- if ( rResource.is() )
+ if ( !rResource.is() )
+ return;
+
+ try
{
- try
- {
- rResource->addModifyListener( this );
+ rResource->addModifyListener( this );
- // --- SAFE ---
- ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
- m_bListening = true;
- // --- SAFE ---
- }
- catch (const RuntimeException&)
- {
- throw;
- }
- catch (const Exception&)
- {
- }
+ // --- SAFE ---
+ ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex );
+ m_bListening = true;
+ // --- SAFE ---
+ }
+ catch (const RuntimeException&)
+ {
+ throw;
+ }
+ catch (const Exception&)
+ {
}
}
@@ -1132,26 +1132,26 @@ void ResourceListener::stopListening()
aGuard.clear();
// --- SAFE ---
- if ( xModifyBroadcaster.is() )
+ if ( !xModifyBroadcaster.is() )
+ return;
+
+ try
+ {
+ // --- SAFE ---
+ aGuard.reset();
+ m_bListening = false;
+ m_xResource.clear();
+ aGuard.clear();
+ // --- SAFE ---
+
+ xModifyBroadcaster->removeModifyListener( this );
+ }
+ catch (const RuntimeException&)
+ {
+ throw;
+ }
+ catch (const Exception&)
{
- try
- {
- // --- SAFE ---
- aGuard.reset();
- m_bListening = false;
- m_xResource.clear();
- aGuard.clear();
- // --- SAFE ---
-
- xModifyBroadcaster->removeModifyListener( this );
- }
- catch (const RuntimeException&)
- {
- throw;
- }
- catch (const Exception&)
- {
- }
}
}
@@ -1167,19 +1167,19 @@ void SAL_CALL ResourceListener::modified(
aGuard.clear();
// --- SAFE ---
- if ( xListener.is() )
+ if ( !xListener.is() )
+ return;
+
+ try
+ {
+ xListener->modified( aEvent );
+ }
+ catch (const RuntimeException&)
+ {
+ throw;
+ }
+ catch (const Exception&)
{
- try
- {
- xListener->modified( aEvent );
- }
- catch (const RuntimeException&)
- {
- throw;
- }
- catch (const Exception&)
- {
- }
}
}
@@ -1610,20 +1610,20 @@ void ControlContainerBase::addingControl( const Reference< XControl >& _rxContro
SolarMutexGuard aGuard;
UnoControlContainer::addingControl( _rxControl );
- if ( _rxControl.is() )
+ if ( !_rxControl.is() )
+ return;
+
+ Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
+ if ( xProps.is() )
{
- Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- const Sequence< OUString > aNames {
- "PositionX",
- "PositionY",
- "Width",
- "Height"
- };
-
- xProps->addPropertiesChangeListener( aNames, this );
- }
+ const Sequence< OUString > aNames {
+ "PositionX",
+ "PositionY",
+ "Width",
+ "Height"
+ };
+
+ xProps->addPropertiesChangeListener( aNames, this );
}
}
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index a4c695223f57..bf035e3bcfa6 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -349,26 +349,25 @@ void UnoDialogControl::createPeer( const Reference< XToolkit > & rxToolkit, cons
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
Reference < XTopWindow > xTW( getPeer(), UNO_QUERY );
- if ( xTW.is() )
- {
- xTW->setMenuBar( mxMenuBar );
-
- if ( !mbWindowListener )
- {
- Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
- addWindowListener( xWL );
- mbWindowListener = true;
- }
+ if ( !xTW.is() )
+ return;
- if ( maTopWindowListeners.getLength() )
- xTW->addTopWindowListener( &maTopWindowListeners );
- // there must be a better way than doing this, we can't
- // process the scrolltop & scrollleft in XDialog because
- // the children haven't been added when those props are applied
- ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLTOP ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLTOP ) ) );
- ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLLEFT ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLLEFT ) ) );
+ xTW->setMenuBar( mxMenuBar );
+ if ( !mbWindowListener )
+ {
+ Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY );
+ addWindowListener( xWL );
+ mbWindowListener = true;
}
+
+ if ( maTopWindowListeners.getLength() )
+ xTW->addTopWindowListener( &maTopWindowListeners );
+ // there must be a better way than doing this, we can't
+ // process the scrolltop & scrollleft in XDialog because
+ // the children haven't been added when those props are applied
+ ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLTOP ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLTOP ) ) );
+ ImplSetPeerProperty( GetPropertyName( BASEPROPERTY_SCROLLLEFT ), ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_SCROLLLEFT ) ) );
}
OUString UnoDialogControl::getImplementationName()
@@ -1046,46 +1045,46 @@ void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
ControlContainerBase::ImplSetPosSize( rxCtrl );
Reference < XWindow > xW( rxCtrl, UNO_QUERY );
- if ( !bOwnCtrl && xW.is() && !sTitle.isEmpty() )
+ if ( bOwnCtrl || !xW.is() || sTitle.isEmpty() )
+ return;
+
+ awt::Rectangle aSizePos = xW->getPosSize();
+
+ sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
+ // Retrieve the values set by the base class
+ OutputDevice*pOutDev = Application::GetDefaultDevice();
+ if ( pOutDev )
{
- awt::Rectangle aSizePos = xW->getPosSize();
+ // Adjust Y based on height of Title
+ ::tools::Rectangle aRect = pOutDev->GetTextRect( {}, sTitle );
+ nY = nY + ( aRect.GetHeight() / 2 );
+ }
+ else
+ {
+ Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer();
+ Reference< XDevice > xD( xPeer, UNO_QUERY );
- sal_Int32 nX = aSizePos.X, nY = aSizePos.Y, nWidth = aSizePos.Width, nHeight = aSizePos.Height;
- // Retrieve the values set by the base class
- OutputDevice*pOutDev = Application::GetDefaultDevice();
- if ( pOutDev )
+ SimpleFontMetric aFM;
+ FontDescriptor aFD;
+ Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
+
+ aVal >>= aFD;
+ if ( !aFD.StyleName.isEmpty() )
{
- // Adjust Y based on height of Title
- ::tools::Rectangle aRect = pOutDev->GetTextRect( {}, sTitle );
- nY = nY + ( aRect.GetHeight() / 2 );
+ Reference< XFont > xFont = xD->getFont( aFD );
+ aFM = xFont->getFontMetric();
}
else
{
- Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer();
- Reference< XDevice > xD( xPeer, UNO_QUERY );
-
- SimpleFontMetric aFM;
- FontDescriptor aFD;
- Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) );
-
- aVal >>= aFD;
- if ( !aFD.StyleName.isEmpty() )
- {
- Reference< XFont > xFont = xD->getFont( aFD );
- aFM = xFont->getFontMetric();
- }
- else
- {
- Reference< XGraphics > xG = xD->createGraphics();
- aFM = xG->getFontMetric();
- }
-
- sal_Int16 nH = aFM.Ascent + aFM.Descent;
- // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
- nY = nY + ( nH / 8); // how do I test this
+ Reference< XGraphics > xG = xD->createGraphics();
+ aFM = xG->getFontMetric();
}
- xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
+
+ sal_Int16 nH = aFM.Ascent + aFM.Descent;
+ // offset y based on height of font ( not sure if my guess at the correct calculation is correct here )
+ nY = nY + ( nH / 8); // how do I test this
}
+ xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE );
}
// ------------- UnoFrameModel -----------------
diff --git a/toolkit/source/controls/roadmapcontrol.cxx b/toolkit/source/controls/roadmapcontrol.cxx
index 9bc540593742..0a0006014981 100644
--- a/toolkit/source/controls/roadmapcontrol.cxx
+++ b/toolkit/source/controls/roadmapcontrol.cxx
@@ -297,22 +297,22 @@ static void lcl_throwIndexOutOfBoundsException( )
Reference< XPropertySet > xPropertySet( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY );
sal_Int16 n_CurrentItemID = GetCurrentItemID( xPropertySet );
Any aAny;
- if ( Index <= n_CurrentItemID )
+ if ( Index > n_CurrentItemID )
+ return;
+
+ if ( n_CurrentItemID >= static_cast<sal_Int32>(maRoadmapItems.size()) )
{
- if ( n_CurrentItemID >= static_cast<sal_Int32>(maRoadmapItems.size()) )
- {
- n_CurrentItemID = sal::static_int_cast< sal_Int16 >(
- maRoadmapItems.size()-1);
- if ( n_CurrentItemID < 0 )
- return;
- aAny <<= n_CurrentItemID;
- }
- else if (Index == n_CurrentItemID)
- aAny <<= sal_Int16(-1);
- else if( Index < n_CurrentItemID)
- aAny <<= static_cast<sal_Int16>( n_CurrentItemID - 1 );
- xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), aAny );
+ n_CurrentItemID = sal::static_int_cast< sal_Int16 >(
+ maRoadmapItems.size()-1);
+ if ( n_CurrentItemID < 0 )
+ return;
+ aAny <<= n_CurrentItemID;
}
+ else if (Index == n_CurrentItemID)
+ aAny <<= sal_Int16(-1);
+ else if( Index < n_CurrentItemID)
+ aAny <<= static_cast<sal_Int16>( n_CurrentItemID - 1 );
+ xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), aAny );
}
diff --git a/toolkit/source/controls/tree/treedatamodel.cxx b/toolkit/source/controls/tree/treedatamodel.cxx
index c4fa7c6e34f3..34d3bf4ab67b 100644
--- a/toolkit/source/controls/tree/treedatamodel.cxx
+++ b/toolkit/source/controls/tree/treedatamodel.cxx
@@ -143,23 +143,23 @@ MutableTreeDataModel::MutableTreeDataModel()
void MutableTreeDataModel::broadcast( broadcast_type eType, const Reference< XTreeNode >& xParentNode, const Reference< XTreeNode >& rNode )
{
::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( cppu::UnoType<XTreeDataModelListener>::get() );
- if( pIter )
- {
- Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
- const Sequence< Reference< XTreeNode > > aNodes { rNode };
- TreeDataModelEvent aEvent( xSource, aNodes, xParentNode );
+ if( !pIter )
+ return;
+
+ Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ const Sequence< Reference< XTreeNode > > aNodes { rNode };
+ TreeDataModelEvent aEvent( xSource, aNodes, xParentNode );
- ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
- while(aListIter.hasMoreElements())
+ ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
+ while(aListIter.hasMoreElements())
+ {
+ XTreeDataModelListener* pListener = static_cast<XTreeDataModelListener*>(aListIter.next());
+ switch( eType )
{
- XTreeDataModelListener* pListener = static_cast<XTreeDataModelListener*>(aListIter.next());
- switch( eType )
- {
- case nodes_changed: pListener->treeNodesChanged(aEvent); break;
- case nodes_inserted: pListener->treeNodesInserted(aEvent); break;
- case nodes_removed: pListener->treeNodesRemoved(aEvent); break;
- case structure_changed: pListener->treeStructureChanged(aEvent); break;
- }
+ case nodes_changed: pListener->treeNodesChanged(aEvent); break;
+ case nodes_inserted: pListener->treeNodesInserted(aEvent); break;
+ case nodes_removed: pListener->treeNodesRemoved(aEvent); break;
+ case structure_changed: pListener->treeStructureChanged(aEvent); break;
}
}
}
@@ -175,25 +175,25 @@ void SAL_CALL MutableTreeDataModel::setRoot( const Reference< XMutableTreeNode >
throw IllegalArgumentException();
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- if( xNode != mxRootNode )
+ if( xNode == mxRootNode )
+ return;
+
+ if( mxRootNode.is() )
{
- if( mxRootNode.is() )
- {
- MutableTreeNodeRef xOldImpl( dynamic_cast< MutableTreeNode* >( mxRootNode.get() ) );
- if( xOldImpl.is() )
- xOldImpl->mbIsInserted = false;
- }
+ MutableTreeNodeRef xOldImpl( dynamic_cast< MutableTreeNode* >( mxRootNode.get() ) );
+ if( xOldImpl.is() )
+ xOldImpl->mbIsInserted = false;
+ }
- MutableTreeNodeRef xImpl( dynamic_cast< MutableTreeNode* >( xNode.get() ) );
- if( !xImpl.is() || xImpl->mbIsInserted )
- throw IllegalArgumentException();
+ MutableTreeNodeRef xImpl( dynamic_cast< MutableTreeNode* >( xNode.get() ) );
+ if( !xImpl.is() || xImpl->mbIsInserted )
+ throw IllegalArgumentException();
- xImpl->mbIsInserted = true;
- mxRootNode.set(xImpl.get());
+ xImpl->mbIsInserted = true;
+ mxRootNode.set(xImpl.get());
- Reference< XTreeNode > xParentNode;
- broadcast( structure_changed, xParentNode, mxRootNode );
- }
+ Reference< XTreeNode > xParentNode;
+ broadcast( structure_changed, xParentNode, mxRootNode );
}
Reference< XTreeNode > SAL_CALL MutableTreeDataModel::getRoot( )
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index aeb84bd8139a..e38a68ff8322 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -250,39 +250,39 @@ void UnoControl::ImplSetPeerProperty( const OUString& rPropName, const Any& rVal
// releases our mutex before calling here in)
// That's why this additional check
- if ( mxVclWindowPeer.is() )
- {
- Any aConvertedValue( rVal );
+ if ( !mxVclWindowPeer.is() )
+ return;
+
+ Any aConvertedValue( rVal );
- if ( mpData->bLocalizationSupport )
+ if ( mpData->bLocalizationSupport )
+ {
+ // We now support a mapping for language dependent properties. This is the
+ // central method to implement it.
+ if( rPropName == "Text" ||
+ rPropName == "Label" ||
+ rPropName == "Title" ||
+ rPropName == "HelpText" ||
+ rPropName == "CurrencySymbol" ||
+ rPropName == "StringItemList" )
{
- // We now support a mapping for language dependent properties. This is the
- // central method to implement it.
- if( rPropName == "Text" ||
- rPropName == "Label" ||
- rPropName == "Title" ||
- rPropName == "HelpText" ||
- rPropName == "CurrencySymbol" ||
- rPropName == "StringItemList" )
+ OUString aValue;
+ uno::Sequence< OUString > aSeqValue;
+ if ( aConvertedValue >>= aValue )
{
- OUString aValue;
- uno::Sequence< OUString > aSeqValue;
- if ( aConvertedValue >>= aValue )
- {
- if ( ImplCheckLocalize( aValue ) )
- aConvertedValue <<= aValue;
- }
- else if ( aConvertedValue >>= aSeqValue )
- {
- for ( auto& rValue : aSeqValue )
- ImplCheckLocalize( rValue );
- aConvertedValue <<= aSeqValue;
- }
+ if ( ImplCheckLocalize( aValue ) )
+ aConvertedValue <<= aValue;
+ }
+ else if ( aConvertedValue >>= aSeqValue )
+ {
+ for ( auto& rValue : aSeqValue )
+ ImplCheckLocalize( rValue );
+ aConvertedValue <<= aSeqValue;
}
}
-
- mxVclWindowPeer->setProperty( rPropName, aConvertedValue );
}
+
+ mxVclWindowPeer->setProperty( rPropName, aConvertedValue );
}
void UnoControl::PrepareWindowDescriptor( WindowDescriptor& )
diff --git a/toolkit/source/controls/unocontrolbase.cxx b/toolkit/source/controls/unocontrolbase.cxx
index 86a5a65686f6..8b9732bb1425 100644
--- a/toolkit/source/controls/unocontrolbase.cxx
+++ b/toolkit/source/controls/unocontrolbase.cxx
@@ -57,47 +57,47 @@ void UnoControlBase::ImplSetPropertyValues( const css::uno::Sequence< OUString >
return;
DBG_ASSERT( xMPS.is(), "UnoControlBase::ImplSetPropertyValues: no multi property set interface!" );
- if ( xMPS.is() )
+ if ( !xMPS.is() )
+ return;
+
+ if ( !bUpdateThis )
+ ImplLockPropertyChangeNotifications( aPropertyNames, true );
+
+ try
+ {
+ xMPS->setPropertyValues( aPropertyNames, aValues );
+ }
+ catch( const css::uno::Exception& )
{
- if ( !bUpdateThis )
- ImplLockPropertyChangeNotifications( aPropertyNames, true );
-
- try
- {
- xMPS->setPropertyValues( aPropertyNames, aValues );
- }
- catch( const css::uno::Exception& )
- {
- if ( !bUpdateThis )
- ImplLockPropertyChangeNotifications( aPropertyNames, false );
- }
if ( !bUpdateThis )
ImplLockPropertyChangeNotifications( aPropertyNames, false );
}
+ if ( !bUpdateThis )
+ ImplLockPropertyChangeNotifications( aPropertyNames, false );
}
void UnoControlBase::ImplSetPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue, bool bUpdateThis )
{
// Model might be logged off already but an event still fires
- if ( mxModel.is() )
+ if ( !mxModel.is() )
+ return;
+
+ css::uno::Reference< css::beans::XPropertySet > xPSet( mxModel, css::uno::UNO_QUERY );
+ if ( !bUpdateThis )
+ ImplLockPropertyChangeNotification( aPropertyName, true );
+
+ try
+ {
+ xPSet->setPropertyValue( aPropertyName, aValue );
+ }
+ catch( const css::uno::Exception& )
{
- css::uno::Reference< css::beans::XPropertySet > xPSet( mxModel, css::uno::UNO_QUERY );
- if ( !bUpdateThis )
- ImplLockPropertyChangeNotification( aPropertyName, true );
-
- try
- {
- xPSet->setPropertyValue( aPropertyName, aValue );
- }
- catch( const css::uno::Exception& )
- {
- if ( !bUpdateThis )
- ImplLockPropertyChangeNotification( aPropertyName, false );
- throw;
- }
if ( !bUpdateThis )
ImplLockPropertyChangeNotification( aPropertyName, false );
+ throw;
}
+ if ( !bUpdateThis )
+ ImplLockPropertyChangeNotification( aPropertyName, false );
}
css::uno::Any UnoControlBase::ImplGetPropertyValue( const OUString& aPropertyName )
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index 48e69247ba05..552b9ee52af8 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -717,52 +717,52 @@ void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxT
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- if( !getPeer().is() )
- {
- bool bVis = maComponentInfos.bVisible;
- if( bVis )
- UnoControl::setVisible( false );
+ if( getPeer().is() )
+ return;
- // Create a new peer
- UnoControl::createPeer( rxToolkit, rParent );
+ bool bVis = maComponentInfos.bVisible;
+ if( bVis )
+ UnoControl::setVisible( false );
- // Create all children's peers
- if ( !mbCreatingCompatiblePeer )
- {
- // Evaluate "Step" property
- uno::Reference< awt::XControlModel > xModel( getModel() );
- uno::Reference< beans::XPropertySet > xPSet
- ( xModel, uno::UNO_QUERY );
- uno::Reference< beans::XPropertySetInfo >
- xInfo = xPSet->getPropertySetInfo();
- OUString aPropName( "Step" );
- if ( xInfo->hasPropertyByName( aPropName ) )
- {
- css::uno::Any aVal = xPSet->getPropertyValue( aPropName );
- sal_Int32 nDialogStep = 0;
- aVal >>= nDialogStep;
- uno::Reference< awt::XControlContainer > xContainer =
- static_cast< awt::XControlContainer* >(this);
- implUpdateVisibility( nDialogStep, xContainer );
-
- uno::Reference< beans::XPropertyChangeListener > xListener =
- new DialogStepChangedListener(xContainer);
- xPSet->addPropertyChangeListener( aPropName, xListener );
- }
+ // Create a new peer
+ UnoControl::createPeer( rxToolkit, rParent );
- uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
- for( auto& rCtrl : aCtrls )
- rCtrl->createPeer( rxToolkit, getPeer() );
-
- uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
- if ( xC.is() )
- xC->enableDialogControl( true );
- ImplActivateTabControllers();
+ // Create all children's peers
+ if ( !mbCreatingCompatiblePeer )
+ {
+ // Evaluate "Step" property
+ uno::Reference< awt::XControlModel > xModel( getModel() );
+ uno::Reference< beans::XPropertySet > xPSet
+ ( xModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySetInfo >
+ xInfo = xPSet->getPropertySetInfo();
+ OUString aPropName( "Step" );
+ if ( xInfo->hasPropertyByName( aPropName ) )
+ {
+ css::uno::Any aVal = xPSet->getPropertyValue( aPropName );
+ sal_Int32 nDialogStep = 0;
+ aVal >>= nDialogStep;
+ uno::Reference< awt::XControlContainer > xContainer =
+ static_cast< awt::XControlContainer* >(this);
+ implUpdateVisibility( nDialogStep, xContainer );
+
+ uno::Reference< beans::XPropertyChangeListener > xListener =
+ new DialogStepChangedListener(xContainer);
+ xPSet->addPropertyChangeListener( aPropName, xListener );
}
- if( bVis && !isDesignMode() )
- UnoControl::setVisible( true );
+ uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
+ for( auto& rCtrl : aCtrls )
+ rCtrl->createPeer( rxToolkit, getPeer() );
+
+ uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
+ if ( xC.is() )
+ xC->enableDialogControl( true );
+ ImplActivateTabControllers();
}
+
+ if( bVis && !isDesignMode() )
+ UnoControl::setVisible( true );
}
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index a735178bdca1..695b6fcb00e5 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -709,60 +709,60 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
xMark->deleteMark(nPropDataBeginMark);
}
- if ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() )
- {
- const css::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
- // Until 5.0 export arrives, write old format...
- css::awt::FontDescriptor aFD;
- (*pProp) >>= aFD;
+ if ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) == aProps.end() )
+ return;
- for ( sal_uInt16 n = BASEPROPERTY_FONT_TYPE; n <= BASEPROPERTY_FONT_ATTRIBS; n++ )
- {
- sal_Int32 nPropDataBeginMark = xMark->createMark();
- OutStream->writeLong( 0 ); // DataLen
- OutStream->writeShort( n ); // PropId
- OutStream->writeBoolean( false ); // Void
+ const css::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
+ // Until 5.0 export arrives, write old format...
+ css::awt::FontDescriptor aFD;
+ (*pProp) >>= aFD;
- if ( n == BASEPROPERTY_FONT_TYPE )
- {
- OutStream->writeUTF( aFD.Name );
- OutStream->writeUTF( aFD.StyleName );
- OutStream->writeShort( aFD.Family );
- OutStream->writeShort( aFD.CharSet );
- OutStream->writeShort( aFD.Pitch );
- }
- else if ( n == BASEPROPERTY_FONT_SIZE )
- {
- OutStream->writeLong( aFD.Width );
- OutStream->writeLong( aFD.Height );
- OutStream->writeShort(
- sal::static_int_cast< sal_Int16 >(
- vcl::unohelper::ConvertFontWidth(aFD.CharacterWidth)) );
- }
- else if ( n == BASEPROPERTY_FONT_ATTRIBS )
- {
- OutStream->writeShort(
- sal::static_int_cast< sal_Int16 >(
- vcl::unohelper::ConvertFontWeight(aFD.Weight)) );
- OutStream->writeShort(
- sal::static_int_cast< sal_Int16 >(aFD.Slant) );
- OutStream->writeShort( aFD.Underline );
- OutStream->writeShort( aFD.Strikeout );
- OutStream->writeShort( static_cast<short>(aFD.Orientation * 10) );
- OutStream->writeBoolean( aFD.Kerning );
- OutStream->writeBoolean( aFD.WordLineMode );
- }
- else
- {
- OSL_FAIL( "Property?!" );
- }
+ for ( sal_uInt16 n = BASEPROPERTY_FONT_TYPE; n <= BASEPROPERTY_FONT_ATTRIBS; n++ )
+ {
+ sal_Int32 nPropDataBeginMark = xMark->createMark();
+ OutStream->writeLong( 0 ); // DataLen
+ OutStream->writeShort( n ); // PropId
+ OutStream->writeBoolean( false ); // Void
- sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
- xMark->jumpToMark( nPropDataBeginMark );
- OutStream->writeLong( nPropDataLen );
- xMark->jumpToFurthest();
- xMark->deleteMark(nPropDataBeginMark);
+ if ( n == BASEPROPERTY_FONT_TYPE )
+ {
+ OutStream->writeUTF( aFD.Name );
+ OutStream->writeUTF( aFD.StyleName );
+ OutStream->writeShort( aFD.Family );
+ OutStream->writeShort( aFD.CharSet );
+ OutStream->writeShort( aFD.Pitch );
+ }
+ else if ( n == BASEPROPERTY_FONT_SIZE )
+ {
+ OutStream->writeLong( aFD.Width );
+ OutStream->writeLong( aFD.Height );
+ OutStream->writeShort(
+ sal::static_int_cast< sal_Int16 >(
+ vcl::unohelper::ConvertFontWidth(aFD.CharacterWidth)) );
+ }
+ else if ( n == BASEPROPERTY_FONT_ATTRIBS )
+ {
+ OutStream->writeShort(
+ sal::static_int_cast< sal_Int16 >(
+ vcl::unohelper::ConvertFontWeight(aFD.Weight)) );
+ OutStream->writeShort(
+ sal::static_int_cast< sal_Int16 >(aFD.Slant) );
+ OutStream->writeShort( aFD.Underline );
+ OutStream->writeShort( aFD.Strikeout );
+ OutStream->writeShort( static_cast<short>(aFD.Orientation * 10) );
+ OutStream->writeBoolean( aFD.Kerning );
+ OutStream->writeBoolean( aFD.WordLineMode );
+ }
+ else
+ {
+ OSL_FAIL( "Property?!" );
}
+
+ sal_Int32 nPropDataLen = xMark->offsetToMark( nPropDataBeginMark );
+ xMark->jumpToMark( nPropDataBeginMark );
+ OutStream->writeLong( nPropDataLen );
+ xMark->jumpToFurthest();
+ xMark->deleteMark(nPropDataBeginMark);
}
}
@@ -1308,49 +1308,49 @@ void UnoControlModel::setPropertyValues( const css::uno::Sequence< OUString >& r
sal_Int32 nValidHandles = getInfoHelper().fillHandles( pHandles, rPropertyNames );
- if ( nValidHandles )
+ if ( !nValidHandles )
+ return;
+
+ // if somebody sets properties which are single aspects of a font descriptor,
+ // remove them, and build a font descriptor instead
+ std::unique_ptr< awt::FontDescriptor > pFD;
+ for ( sal_Int32 n = 0; n < nProps; ++n )
{
- // if somebody sets properties which are single aspects of a font descriptor,
- // remove them, and build a font descriptor instead
- std::unique_ptr< awt::FontDescriptor > pFD;
- for ( sal_Int32 n = 0; n < nProps; ++n )
+ if ( ( pHandles[n] >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( pHandles[n] <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
{
- if ( ( pHandles[n] >= BASEPROPERTY_FONTDESCRIPTORPART_START ) && ( pHandles[n] <= BASEPROPERTY_FONTDESCRIPTORPART_END ) )
+ if (!pFD)
{
- if (!pFD)
- {
- css::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
- pFD.reset( new awt::FontDescriptor );
- (*pProp) >>= *pFD;
- }
- lcl_ImplMergeFontProperty( *pFD, static_cast<sal_uInt16>(pHandles[n]), pValues[n] );
- pHandles[n] = -1;
- nValidHandles--;
+ css::uno::Any* pProp = &maData[ BASEPROPERTY_FONTDESCRIPTOR ];
+ pFD.reset( new awt::FontDescriptor );
+ (*pProp) >>= *pFD;
}
+ lcl_ImplMergeFontProperty( *pFD, static_cast<sal_uInt16>(pHandles[n]), pValues[n] );
+ pHandles[n] = -1;
+ nValidHandles--;
}
+ }
- if ( nValidHandles )
- {
- ImplNormalizePropertySequence( nProps, pHandles, pValues, &nValidHandles );
- aGuard.clear();
- // clear our guard before calling into setFastPropertyValues - this method
- // will implicitly call property listeners, and this should not happen with
- // our mutex locked
- // #i23451#
- setFastPropertyValues( nProps, pHandles, pValues, nValidHandles );
- }
- else
- aGuard.clear();
- // same as a few lines above
+ if ( nValidHandles )
+ {
+ ImplNormalizePropertySequence( nProps, pHandles, pValues, &nValidHandles );
+ aGuard.clear();
+ // clear our guard before calling into setFastPropertyValues - this method
+ // will implicitly call property listeners, and this should not happen with
+ // our mutex locked
+ // #i23451#
+ setFastPropertyValues( nProps, pHandles, pValues, nValidHandles );
+ }
+ else
+ aGuard.clear();
+ // same as a few lines above
- // Don't merge FD property into array, as it is sorted
- if (pFD)
- {
- css::uno::Any aValue;
- aValue <<= *pFD;
- sal_Int32 nHandle = BASEPROPERTY_FONTDESCRIPTOR;
- setFastPropertyValues( 1, &nHandle, &aValue, 1 );
- }
+ // Don't merge FD property into array, as it is sorted
+ if (pFD)
+ {
+ css::uno::Any aValue;
+ aValue <<= *pFD;
+ sal_Int32 nHandle = BASEPROPERTY_FONTDESCRIPTOR;
+ setFastPropertyValues( 1, &nHandle, &aValue, 1 );
}
}
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index 8a9988f386f2..fde094051708 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -2122,39 +2122,39 @@ void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int3
{
UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
- if ( nHandle == BASEPROPERTY_STRINGITEMLIST )
- {
- // reset selection
- uno::Sequence<sal_Int16> aSeq;
- setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, uno::Any(aSeq) );
+ if ( nHandle != BASEPROPERTY_STRINGITEMLIST )
+ return;
- if ( !m_xData->m_bSettingLegacyProperty )
- {
- // synchronize the legacy StringItemList property with our list items
- Sequence< OUString > aStringItemList;
- Any aPropValue;
- getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
- OSL_VERIFY( aPropValue >>= aStringItemList );
-
- ::std::vector< ListItem > aItems( aStringItemList.getLength() );
- ::std::transform(
- aStringItemList.begin(),
- aStringItemList.end(),
- aItems.begin(),
- CreateListItem()
- );
- m_xData->setAllItems( aItems );
-
- // since an XItemListListener does not have a "all items modified" or some such method,
- // we simulate this by notifying removal of all items, followed by insertion of all new
- // items
- lang::EventObject aEvent;
- aEvent.Source = *this;
- m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
- // TODO: OPropertySetHelper calls into this method with the mutex locked ...
- // which is wrong for the above notifications ...
- }
- }
+ // reset selection
+ uno::Sequence<sal_Int16> aSeq;
+ setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, uno::Any(aSeq) );
+
+ if ( m_xData->m_bSettingLegacyProperty )
+ return;
+
+ // synchronize the legacy StringItemList property with our list items
+ Sequence< OUString > aStringItemList;
+ Any aPropValue;
+ getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
+ OSL_VERIFY( aPropValue >>= aStringItemList );
+
+ ::std::vector< ListItem > aItems( aStringItemList.getLength() );
+ ::std::transform(
+ aStringItemList.begin(),
+ aStringItemList.end(),
+ aItems.begin(),
+ CreateListItem()
+ );
+ m_xData->setAllItems( aItems );
+
+ // since an XItemListListener does not have a "all items modified" or some such method,
+ // we simulate this by notifying removal of all items, followed by insertion of all new
+ // items
+ lang::EventObject aEvent;
+ aEvent.Source = *this;
+ m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
+ // TODO: OPropertySetHelper calls into this method with the mutex locked ...
+ // which is wrong for the above notifications ...
}
@@ -2638,23 +2638,23 @@ void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
uno::Sequence< OUString> aSeq;
aVal >>= aSeq;
sal_uInt16 nOldLen = static_cast<sal_uInt16>(aSeq.getLength());
- if ( nOldLen && ( nPos < nOldLen ) )
- {
- if ( nCount > ( nOldLen-nPos ) )
- nCount = nOldLen-nPos;
+ if ( !(nOldLen && ( nPos < nOldLen )) )
+ return;
- sal_uInt16 nNewLen = nOldLen - nCount;
+ if ( nCount > ( nOldLen-nPos ) )
+ nCount = nOldLen-nPos;
- uno::Sequence< OUString> aNewSeq( nNewLen );
+ sal_uInt16 nNewLen = nOldLen - nCount;
- // Items before the Remove-Position
- std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
+ uno::Sequence< OUString> aNewSeq( nNewLen );
- // Rest of Items
- std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
+ // Items before the Remove-Position
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
- }
+ // Rest of Items
+ std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
+
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
}
sal_Int16 UnoListBoxControl::getItemCount()
@@ -2937,32 +2937,32 @@ void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int
{
UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
- if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_xData->m_bSettingLegacyProperty)
- {
- // synchronize the legacy StringItemList property with our list items
- Sequence< OUString > aStringItemList;
- Any aPropValue;
- getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
- OSL_VERIFY( aPropValue >>= aStringItemList );
-
- ::std::vector< ListItem > aItems( aStringItemList.getLength() );
- ::std::transform(
- aStringItemList.begin(),
- aStringItemList.end(),
- aItems.begin(),
- CreateListItem()
- );
- m_xData->setAllItems( aItems );
-
- // since an XItemListListener does not have a "all items modified" or some such method,
- // we simulate this by notifying removal of all items, followed by insertion of all new
- // items
- lang::EventObject aEvent;
- aEvent.Source = *this;
- m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
- // TODO: OPropertySetHelper calls into this method with the mutex locked ...
- // which is wrong for the above notifications ...
- }
+ if (nHandle != BASEPROPERTY_STRINGITEMLIST || m_xData->m_bSettingLegacyProperty)
+ return;
+
+ // synchronize the legacy StringItemList property with our list items
+ Sequence< OUString > aStringItemList;
+ Any aPropValue;
+ getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
+ OSL_VERIFY( aPropValue >>= aStringItemList );
+
+ ::std::vector< ListItem > aItems( aStringItemList.getLength() );
+ ::std::transform(
+ aStringItemList.begin(),
+ aStringItemList.end(),
+ aItems.begin(),
+ CreateListItem()
+ );
+ m_xData->setAllItems( aItems );
+
+ // since an XItemListListener does not have a "all items modified" or some such method,
+ // we simulate this by notifying removal of all items, followed by insertion of all new
+ // items
+ lang::EventObject aEvent;
+ aEvent.Source = *this;
+ m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
+ // TODO: OPropertySetHelper calls into this method with the mutex locked ...
+ // which is wrong for the above notifications ...
}
uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
@@ -3231,23 +3231,23 @@ void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
uno::Sequence< OUString> aSeq;
aVal >>= aSeq;
sal_uInt16 nOldLen = static_cast<sal_uInt16>(aSeq.getLength());
- if ( nOldLen && ( nPos < nOldLen ) )
- {
- if ( nCount > ( nOldLen-nPos ) )
- nCount = nOldLen-nPos;
+ if ( !nOldLen || ( nPos >= nOldLen ) )
+ return;
- sal_uInt16 nNewLen = nOldLen - nCount;
+ if ( nCount > ( nOldLen-nPos ) )
+ nCount = nOldLen-nPos;
- uno::Sequence< OUString> aNewSeq( nNewLen );
+ sal_uInt16 nNewLen = nOldLen - nCount;
- // items before the deletion position
- std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
+ uno::Sequence< OUString> aNewSeq( nNewLen );
- // remainder of old items
- std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
+ // items before the deletion position
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
- ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
- }
+ // remainder of old items
+ std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
+
+ ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
}
sal_Int16 UnoComboBoxControl::getItemCount()