diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-02 12:06:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-02 20:07:00 +0200 |
commit | ff7e960701ccacbd62bd2251f26561eeba8ebe8a (patch) | |
tree | 1adb4b20e453804203cb95721c7d5bc92795e1e6 /reportdesign/source/core | |
parent | 4acb0e7f05fa7fe05f990786e0483e20962af1d9 (diff) |
loplugin:flatten in reportdesign
Change-Id: I6d8b2730cede4453e7afd581cc24ed101ca6c81b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91557
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'reportdesign/source/core')
-rw-r--r-- | reportdesign/source/core/api/Section.cxx | 32 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/PropertyForward.cxx | 92 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/RptObject.cxx | 222 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/UndoActions.cxx | 122 |
4 files changed, 234 insertions, 234 deletions
diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index 6aa10a6acaa2..761ed63e5c67 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -194,22 +194,22 @@ void OSection::init() uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); std::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport); assert(pModel && "No model set at the report definition!"); - if ( pModel ) - { - uno::Reference<report::XSection> const xSection(this); - SdrPage & rSdrPage(*pModel->createNewPage(xSection)); - m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW); - m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW); - // apparently we may also get OReportDrawPage which doesn't support this - m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY); - m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW); - // fdo#53872: now also exchange the XDrawPage in the SdrPage so that - // rSdrPage.getUnoPage returns this - rSdrPage.SetUnoPage(this); - // createNewPage _should_ have stored away 2 uno::References to this, - // so our ref count cannot be 1 here, so this isn't destroyed here - assert(m_refCount > 1); - } + if ( !pModel ) + return; + + uno::Reference<report::XSection> const xSection(this); + SdrPage & rSdrPage(*pModel->createNewPage(xSection)); + m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW); + m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW); + // apparently we may also get OReportDrawPage which doesn't support this + m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY); + m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW); + // fdo#53872: now also exchange the XDrawPage in the SdrPage so that + // rSdrPage.getUnoPage returns this + rSdrPage.SetUnoPage(this); + // createNewPage _should_ have stored away 2 uno::References to this, + // so our ref count cannot be 1 here, so this isn't destroyed here + assert(m_refCount > 1); } // XSection diff --git a/reportdesign/source/core/sdr/PropertyForward.cxx b/reportdesign/source/core/sdr/PropertyForward.cxx index e0837cfe3794..09beffed51e2 100644 --- a/reportdesign/source/core/sdr/PropertyForward.cxx +++ b/reportdesign/source/core/sdr/PropertyForward.cxx @@ -87,62 +87,62 @@ OPropertyMediator::~OPropertyMediator() void SAL_CALL OPropertyMediator::propertyChange( const PropertyChangeEvent& evt ) { ::osl::MutexGuard aGuard(m_aMutex); - if ( !m_bInChange ) + if ( m_bInChange ) + return; + + m_bInChange = true; + try { - m_bInChange = true; - try + bool bDest = (evt.Source == m_xDest); + Reference<XPropertySet> xProp = bDest ? m_xSource : m_xDest; + Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; + if ( xProp.is() && xPropInfo.is() ) { - bool bDest = (evt.Source == m_xDest); - Reference<XPropertySet> xProp = bDest ? m_xSource : m_xDest; - Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; - if ( xProp.is() && xPropInfo.is() ) + if ( xPropInfo->hasPropertyByName(evt.PropertyName) ) + xProp->setPropertyValue(evt.PropertyName,evt.NewValue); + else { - if ( xPropInfo->hasPropertyByName(evt.PropertyName) ) - xProp->setPropertyValue(evt.PropertyName,evt.NewValue); + TPropertyNamePair::const_iterator aFind = m_aNameMap.find(evt.PropertyName); + OUString sPropName; + if ( aFind != m_aNameMap.end() ) + sPropName = aFind->second.first; else { - TPropertyNamePair::const_iterator aFind = m_aNameMap.find(evt.PropertyName); - OUString sPropName; + aFind = ::std::find_if( + m_aNameMap.begin(), + m_aNameMap.end(), + [&evt] (const TPropertyNamePair::value_type& namePair) { + return namePair.second.first == evt.PropertyName; + }); if ( aFind != m_aNameMap.end() ) - sPropName = aFind->second.first; - else - { - aFind = ::std::find_if( - m_aNameMap.begin(), - m_aNameMap.end(), - [&evt] (const TPropertyNamePair::value_type& namePair) { - return namePair.second.first == evt.PropertyName; - }); - if ( aFind != m_aNameMap.end() ) - sPropName = aFind->first; - } - if (aFind != m_aNameMap.end() && !sPropName.isEmpty() && xPropInfo->hasPropertyByName(sPropName)) - xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue)); - else if ( evt.PropertyName == PROPERTY_CHARFONTNAME - || evt.PropertyName == PROPERTY_CHARFONTSTYLENAME - || evt.PropertyName == PROPERTY_CHARSTRIKEOUT - || evt.PropertyName == PROPERTY_CHARWORDMODE - || evt.PropertyName == PROPERTY_CHARROTATION - || evt.PropertyName == PROPERTY_CHARSCALEWIDTH - || evt.PropertyName == PROPERTY_CHARFONTFAMILY - || evt.PropertyName == PROPERTY_CHARFONTCHARSET - || evt.PropertyName == PROPERTY_CHARFONTPITCH - || evt.PropertyName == PROPERTY_CHARHEIGHT - || evt.PropertyName == PROPERTY_CHARUNDERLINE - || evt.PropertyName == PROPERTY_CHARWEIGHT - || evt.PropertyName == PROPERTY_CHARPOSTURE) - { - xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR)); - } + sPropName = aFind->first; + } + if (aFind != m_aNameMap.end() && !sPropName.isEmpty() && xPropInfo->hasPropertyByName(sPropName)) + xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue)); + else if ( evt.PropertyName == PROPERTY_CHARFONTNAME + || evt.PropertyName == PROPERTY_CHARFONTSTYLENAME + || evt.PropertyName == PROPERTY_CHARSTRIKEOUT + || evt.PropertyName == PROPERTY_CHARWORDMODE + || evt.PropertyName == PROPERTY_CHARROTATION + || evt.PropertyName == PROPERTY_CHARSCALEWIDTH + || evt.PropertyName == PROPERTY_CHARFONTFAMILY + || evt.PropertyName == PROPERTY_CHARFONTCHARSET + || evt.PropertyName == PROPERTY_CHARFONTPITCH + || evt.PropertyName == PROPERTY_CHARHEIGHT + || evt.PropertyName == PROPERTY_CHARUNDERLINE + || evt.PropertyName == PROPERTY_CHARWEIGHT + || evt.PropertyName == PROPERTY_CHARPOSTURE) + { + xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR)); } } } - catch(Exception&) - { - OSL_FAIL("Exception caught!"); - } - m_bInChange = false; } + catch(Exception&) + { + OSL_FAIL("Exception caught!"); + } + m_bInChange = false; } void SAL_CALL OPropertyMediator::disposing( const css::lang::EventObject& /*_rSource*/ ) diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index ab478828dd7d..157ed10b7ca6 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -779,113 +779,113 @@ OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj) void OUnoObject::_propertyChange( const beans::PropertyChangeEvent& evt ) { OObjectBase::_propertyChange(evt); - if (isListening()) + if (!isListening()) + return; + + if ( evt.PropertyName == PROPERTY_CHARCOLOR ) { - if ( evt.PropertyName == PROPERTY_CHARCOLOR ) + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - if ( xControlModel.is() ) + OObjectBase::EndListening(); + try { + xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue); + } + catch(uno::Exception&) + { + } + OObjectBase::StartListening(); + } + } + else if ( evt.PropertyName == PROPERTY_NAME ) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) + { + // get old name + OUString aOldName; + evt.OldValue >>= aOldName; + + // get new name + OUString aNewName; + evt.NewValue >>= aNewName; + + if ( aNewName != aOldName ) + { + // set old name property OObjectBase::EndListening(); + if ( m_xMediator.is() ) + m_xMediator->stopListening(); try { - xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue); + xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue ); } catch(uno::Exception&) { } + if ( m_xMediator.is() ) + m_xMediator->startListening(); OObjectBase::StartListening(); } } - else if ( evt.PropertyName == PROPERTY_NAME ) - { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) - { - // get old name - OUString aOldName; - evt.OldValue >>= aOldName; - - // get new name - OUString aNewName; - evt.NewValue >>= aNewName; - - if ( aNewName != aOldName ) - { - // set old name property - OObjectBase::EndListening(); - if ( m_xMediator.is() ) - m_xMediator->stopListening(); - try - { - xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue ); - } - catch(uno::Exception&) - { - } - if ( m_xMediator.is() ) - m_xMediator->startListening(); - OObjectBase::StartListening(); - } - } - } } } void OUnoObject::CreateMediator(bool _bReverse) { - if ( !m_xMediator.is() ) + if ( m_xMediator.is() ) + return; + + // tdf#118730 Directly do things formerly done in + // OUnoObject::impl_setReportComponent_nothrow here + if(!m_xReportComponent.is()) { - // tdf#118730 Directly do things formerly done in - // OUnoObject::impl_setReportComponent_nothrow here - if(!m_xReportComponent.is()) - { - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - OXUndoEnvironment::OUndoEnvLock aLock( rRptModel.GetUndoEnv() ); - m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock( rRptModel.GetUndoEnv() ); + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); - impl_initializeModel_nothrow(); - } + impl_initializeModel_nothrow(); + } - if(m_xReportComponent.is() && m_bSetDefaultLabel) - { - // tdf#118730 Directly do things formerly done in - // OUnoObject::EndCreate here - // tdf#119067 ...but *only* if result of interactive - // creation in Report DesignView - m_bSetDefaultLabel = false; + if(m_xReportComponent.is() && m_bSetDefaultLabel) + { + // tdf#118730 Directly do things formerly done in + // OUnoObject::EndCreate here + // tdf#119067 ...but *only* if result of interactive + // creation in Report DesignView + m_bSetDefaultLabel = false; - try - { - if ( supportsService( SERVICE_FIXEDTEXT ) ) - { - m_xReportComponent->setPropertyValue( - PROPERTY_LABEL, - uno::makeAny(GetDefaultName(this))); - } - } - catch(const uno::Exception&) + try + { + if ( supportsService( SERVICE_FIXEDTEXT ) ) { - DBG_UNHANDLED_EXCEPTION("reportdesign"); + m_xReportComponent->setPropertyValue( + PROPERTY_LABEL, + uno::makeAny(GetDefaultName(this))); } } - - if(!m_xMediator.is() && m_xReportComponent.is()) + catch(const uno::Exception&) { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - - if(xControlModel.is()) - { - m_xMediator = new OPropertyMediator( - m_xReportComponent.get(), - xControlModel, - getPropertyNameMap(GetObjIdentifier()), - _bReverse); - } + DBG_UNHANDLED_EXCEPTION("reportdesign"); } + } - OObjectBase::StartListening(); + if(!m_xMediator.is() && m_xReportComponent.is()) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + + if(xControlModel.is()) + { + m_xMediator = new OPropertyMediator( + m_xReportComponent.get(), + xControlModel, + getPropertyNameMap(GetObjIdentifier()), + _bReverse); + } } + + OObjectBase::StartListening(); } uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent() @@ -1160,21 +1160,21 @@ void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XMod void OOle2Obj::initializeOle() { - if ( m_bOnlyOnce ) - { - m_bOnlyOnce = false; - uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + if ( !m_bOnlyOnce ) + return; - uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); - if( xCompSupp.is() ) - { - uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY ); - if ( xChartProps.is() ) - xChartProps->setPropertyValue("NullDate", - uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false))); - } + m_bOnlyOnce = false; + uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is() ) + { + uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY ); + if ( xChartProps.is() ) + xChartProps->setPropertyValue("NullDate", + uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false))); } } @@ -1186,29 +1186,29 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) if( xCompSupp.is()) xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); OSL_ASSERT( xReceiver.is()); - if( xReceiver.is() ) - { - // lock the model to suppress any internal updates - uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); - if( xChartModel.is() ) - xChartModel->lockControllers(); + if( !xReceiver.is() ) + return; - if ( !lcl_getDataProvider(xObj).is() ) - impl_createDataProvider_nothrow(_xModel); + // lock the model to suppress any internal updates + uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); + if( xChartModel.is() ) + xChartModel->lockControllers(); - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + if ( !lcl_getDataProvider(xObj).is() ) + impl_createDataProvider_nothrow(_xModel); + + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); - ::comphelper::NamedValueCollection aArgs; - aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) ); - aArgs.put( "HasCategories", uno::makeAny( true ) ); - aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); - aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); - xReceiver->setArguments( aArgs.getPropertyValues() ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) ); + aArgs.put( "HasCategories", uno::makeAny( true ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + xReceiver->setArguments( aArgs.getPropertyValues() ); - if( xChartModel.is() ) - xChartModel->unlockControllers(); - } + if( xChartModel.is() ) + xChartModel->unlockControllers(); } uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport) diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx index 836e8ed0a3d1..edca93c9e507 100644 --- a/reportdesign/source/core/sdr/UndoActions.cxx +++ b/reportdesign/source/core/sdr/UndoActions.cxx @@ -119,31 +119,31 @@ OUndoContainerAction::~OUndoContainerAction() { // if we own the object... Reference< XComponent > xComp( m_xOwnElement, UNO_QUERY ); - if ( xComp.is() ) - { - // and the object does not have a parent - Reference< XChild > xChild( m_xOwnElement, UNO_QUERY ); - if ( xChild.is() && !xChild->getParent().is() ) - { - OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); - rEnv.RemoveElement( m_xOwnElement ); + if ( !xComp.is() ) + return; + + // and the object does not have a parent + Reference< XChild > xChild( m_xOwnElement, UNO_QUERY ); + if ( !(xChild.is() && !xChild->getParent().is()) ) + return; + + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + rEnv.RemoveElement( m_xOwnElement ); #if OSL_DEBUG_LEVEL > 0 - SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xChild ); - SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; - OSL_ENSURE( pObject == nullptr || (pShape->HasSdrObjectOwnership() && !pObject->IsInserted()), - "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" ); + SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xChild ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; + OSL_ENSURE( pObject == nullptr || (pShape->HasSdrObjectOwnership() && !pObject->IsInserted()), + "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" ); #endif - // -> dispose it - try - { - comphelper::disposeComponent( xComp ); - } - catch ( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } - } + // -> dispose it + try + { + comphelper::disposeComponent( xComp ); + } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } @@ -187,58 +187,58 @@ void OUndoContainerAction::implReRemove( ) void OUndoContainerAction::Undo() { - if ( m_xElement.is() ) + if ( !m_xElement.is() ) + return; + + // prevents that an undo action will be created for elementInserted + try { - // prevents that an undo action will be created for elementInserted - try + switch ( m_eAction ) { - switch ( m_eAction ) - { - case Inserted: - implReRemove(); - break; - - case Removed: - implReInsert(); - break; - default: - OSL_FAIL("Illegal case value"); - break; - } - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Undo" ); + case Inserted: + implReRemove(); + break; + + case Removed: + implReInsert(); + break; + default: + OSL_FAIL("Illegal case value"); + break; } } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Undo" ); + } } void OUndoContainerAction::Redo() { - if ( m_xElement.is() ) + if ( !m_xElement.is() ) + return; + + try { - try - { - switch ( m_eAction ) - { - case Inserted: - implReInsert(); - break; - - case Removed: - implReRemove(); - break; - default: - OSL_FAIL("Illegal case value"); - break; - } - } - catch( const Exception& ) + switch ( m_eAction ) { - TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Redo" ); + case Inserted: + implReInsert(); + break; + + case Removed: + implReRemove(); + break; + default: + OSL_FAIL("Illegal case value"); + break; } } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Redo" ); + } } OUndoGroupSectionAction::OUndoGroupSectionAction( |