From ff7e960701ccacbd62bd2251f26561eeba8ebe8a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 2 Apr 2020 12:06:45 +0200 Subject: loplugin:flatten in reportdesign Change-Id: I6d8b2730cede4453e7afd581cc24ed101ca6c81b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91557 Tested-by: Noel Grandin Reviewed-by: Noel Grandin --- reportdesign/source/core/api/Section.cxx | 32 +- reportdesign/source/core/sdr/PropertyForward.cxx | 92 ++-- reportdesign/source/core/sdr/RptObject.cxx | 222 ++++----- reportdesign/source/core/sdr/UndoActions.cxx | 122 ++--- reportdesign/source/filter/xml/xmlAutoStyle.cxx | 36 +- reportdesign/source/filter/xml/xmlColumn.cxx | 76 +-- .../source/filter/xml/xmlControlProperty.cxx | 22 +- reportdesign/source/filter/xml/xmlExport.cxx | 494 +++++++++---------- .../source/filter/xml/xmlExportDocumentHandler.cxx | 20 +- reportdesign/source/filter/xml/xmlFixedContent.cxx | 46 +- reportdesign/source/filter/xml/xmlHelper.cxx | 112 ++--- .../source/filter/xml/xmlImportDocumentHandler.cxx | 66 +-- reportdesign/source/filter/xml/xmlSubDocument.cxx | 63 ++- reportdesign/source/ui/dlg/AddField.cxx | 92 ++-- reportdesign/source/ui/dlg/CondFormat.cxx | 22 +- reportdesign/source/ui/dlg/Condition.cxx | 44 +- reportdesign/source/ui/dlg/GroupsSorting.cxx | 238 ++++----- reportdesign/source/ui/dlg/Navigator.cxx | 56 +-- .../source/ui/inspection/DataProviderHandler.cxx | 34 +- .../source/ui/inspection/GeometryHandler.cxx | 146 +++--- reportdesign/source/ui/misc/RptUndo.cxx | 86 ++-- .../source/ui/misc/statusbarcontroller.cxx | 94 ++-- reportdesign/source/ui/report/DesignView.cxx | 30 +- reportdesign/source/ui/report/ReportController.cxx | 531 ++++++++++----------- .../source/ui/report/ReportControllerObserver.cxx | 48 +- reportdesign/source/ui/report/ReportSection.cxx | 316 ++++++------ reportdesign/source/ui/report/ReportWindow.cxx | 50 +- reportdesign/source/ui/report/SectionView.cxx | 52 +- reportdesign/source/ui/report/StartMarker.cxx | 30 +- reportdesign/source/ui/report/ViewsWindow.cxx | 42 +- reportdesign/source/ui/report/dlgedfunc.cxx | 102 ++-- reportdesign/source/ui/report/propbrw.cxx | 30 +- 32 files changed, 1722 insertions(+), 1724 deletions(-) (limited to 'reportdesign/source') 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 pModel = OReportDefinition::getSdrModel(xReport); assert(pModel && "No model set at the report definition!"); - if ( pModel ) - { - uno::Reference 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 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 xProp = bDest ? m_xSource : m_xDest; + Reference xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; + if ( xProp.is() && xPropInfo.is() ) { - bool bDest = (evt.Source == m_xDest); - Reference xProp = bDest ? m_xSource : m_xDest; - Reference 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 xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) { - Reference 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 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 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 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 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( 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( 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( diff --git a/reportdesign/source/filter/xml/xmlAutoStyle.cxx b/reportdesign/source/filter/xml/xmlAutoStyle.cxx index 0c4ad550a3f4..0e2fbb5a4f78 100644 --- a/reportdesign/source/filter/xml/xmlAutoStyle.cxx +++ b/reportdesign/source/filter/xml/xmlAutoStyle.cxx @@ -36,32 +36,32 @@ void OXMLAutoStylePoolP::exportStyleAttributes( ) const { SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties, rPropExp, rUnitConverter, rNamespaceMap ); - if ( nFamily == XmlStyleFamily::TABLE_CELL ) + if ( nFamily != XmlStyleFamily::TABLE_CELL ) + return; + + rtl::Reference< XMLPropertySetMapper > aPropMapper = rORptExport.GetCellStylePropertyMapper(); + for (const auto& rProp : rProperties) { - rtl::Reference< XMLPropertySetMapper > aPropMapper = rORptExport.GetCellStylePropertyMapper(); - for (const auto& rProp : rProperties) + sal_Int16 nContextID = aPropMapper->GetEntryContextId(rProp.mnIndex); + switch (nContextID) { - sal_Int16 nContextID = aPropMapper->GetEntryContextId(rProp.mnIndex); - switch (nContextID) + case CTF_RPT_NUMBERFORMAT : { - case CTF_RPT_NUMBERFORMAT : + OUString sAttrValue; + if ( rProp.maValue >>= sAttrValue ) { - OUString sAttrValue; - if ( rProp.maValue >>= sAttrValue ) + if ( !sAttrValue.isEmpty() ) { - if ( !sAttrValue.isEmpty() ) - { - rORptExport.AddAttribute( - aPropMapper->GetEntryNameSpace(rProp.mnIndex), - aPropMapper->GetEntryXMLName(rProp.mnIndex), - sAttrValue ); - } + rORptExport.AddAttribute( + aPropMapper->GetEntryNameSpace(rProp.mnIndex), + aPropMapper->GetEntryXMLName(rProp.mnIndex), + sAttrValue ); } - break; } - default: - break; + break; } + default: + break; } } } diff --git a/reportdesign/source/filter/xml/xmlColumn.cxx b/reportdesign/source/filter/xml/xmlColumn.cxx index 92bf2e01da1e..753dfbe1b35c 100644 --- a/reportdesign/source/filter/xml/xmlColumn.cxx +++ b/reportdesign/source/filter/xml/xmlColumn.cxx @@ -112,50 +112,50 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLRowColumn::createF void OXMLRowColumn::fillStyle(const OUString& _sStyleName) { - if ( !_sStyleName.isEmpty() ) + if ( _sStyleName.isEmpty() ) + return; + + const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles(); + if ( !pAutoStyles ) + return; + + PropertySetInfo* pInfo = new PropertySetInfo(); + static PropertyMapEntry const pMap[] = + { + {OUString(PROPERTY_WIDTH), PROPERTY_ID_WIDTH, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_HEIGHT), PROPERTY_ID_HEIGHT, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0 }, + {OUString(PROPERTY_MINHEIGHT), PROPERTY_ID_MINHEIGHT, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0 }, + {OUString(), 0, css::uno::Type(), 0, 0 } + }; + pInfo->add(pMap); + Reference xProp = GenericPropertySet_CreateInstance(pInfo); + XMLPropStyleContext* pAutoStyle = const_cast(dynamic_cast< const XMLPropStyleContext*>(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_COLUMN,_sStyleName))); + if ( pAutoStyle ) { - const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles(); - if ( pAutoStyles ) + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nWidth = 0; + xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth; + m_pContainer->addWidth(nWidth); + } + else + { + pAutoStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_ROW,_sStyleName))); + if ( pAutoStyle ) { - PropertySetInfo* pInfo = new PropertySetInfo(); - static PropertyMapEntry const pMap[] = - { - {OUString(PROPERTY_WIDTH), PROPERTY_ID_WIDTH, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_HEIGHT), PROPERTY_ID_HEIGHT, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0 }, - {OUString(PROPERTY_MINHEIGHT), PROPERTY_ID_MINHEIGHT, ::cppu::UnoType::get() ,PropertyAttribute::BOUND,0 }, - {OUString(), 0, css::uno::Type(), 0, 0 } - }; - pInfo->add(pMap); - Reference xProp = GenericPropertySet_CreateInstance(pInfo); - XMLPropStyleContext* pAutoStyle = const_cast(dynamic_cast< const XMLPropStyleContext*>(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_COLUMN,_sStyleName))); - if ( pAutoStyle ) + pAutoStyle->FillPropertySet(xProp); + sal_Int32 nHeight = 0; + sal_Int32 nMinHeight = 0; + xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight; + xProp->getPropertyValue(PROPERTY_MINHEIGHT) >>= nMinHeight; + if (nHeight == 0 && nMinHeight > 0) { - pAutoStyle->FillPropertySet(xProp); - sal_Int32 nWidth = 0; - xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth; - m_pContainer->addWidth(nWidth); + m_pContainer->addHeight(nMinHeight); + m_pContainer->addAutoHeight(true); } else { - pAutoStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_ROW,_sStyleName))); - if ( pAutoStyle ) - { - pAutoStyle->FillPropertySet(xProp); - sal_Int32 nHeight = 0; - sal_Int32 nMinHeight = 0; - xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight; - xProp->getPropertyValue(PROPERTY_MINHEIGHT) >>= nMinHeight; - if (nHeight == 0 && nMinHeight > 0) - { - m_pContainer->addHeight(nMinHeight); - m_pContainer->addAutoHeight(true); - } - else - { - m_pContainer->addHeight(nHeight); - m_pContainer->addAutoHeight(false); - } - } + m_pContainer->addHeight(nHeight); + m_pContainer->addAutoHeight(false); } } } diff --git a/reportdesign/source/filter/xml/xmlControlProperty.cxx b/reportdesign/source/filter/xml/xmlControlProperty.cxx index cf91373a369f..b4d6175f400e 100644 --- a/reportdesign/source/filter/xml/xmlControlProperty.cxx +++ b/reportdesign/source/filter/xml/xmlControlProperty.cxx @@ -140,18 +140,18 @@ void OXMLControlProperty::endFastElement(sal_Int32 ) { if ( m_pContainer ) m_pContainer->addValue(m_aCharBuffer.makeStringAndClear()); - if ( !m_aSetting.Name.isEmpty() && m_xControl.is() ) + if ( !(!m_aSetting.Name.isEmpty() && m_xControl.is()) ) + return; + + if ( m_bIsList && !m_aSequence.hasElements() ) + m_aSetting.Value <<= m_aSequence; + try { - if ( m_bIsList && !m_aSequence.hasElements() ) - m_aSetting.Value <<= m_aSequence; - try - { - m_xControl->setPropertyValue(m_aSetting.Name,m_aSetting.Value); - } - catch(const Exception&) - { - OSL_FAIL("Unknown property found!"); - } + m_xControl->setPropertyValue(m_aSetting.Name,m_aSetting.Value); + } + catch(const Exception&) + { + OSL_FAIL("Unknown property found!"); } } diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index a980e05d90ac..5db11193c8e9 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -350,66 +350,66 @@ void ORptExport::exportFunction(const uno::Reference< XFunction>& _xFunction) void ORptExport::exportMasterDetailFields(const Reference& _xReportComponet) { const uno::Sequence< OUString> aMasterFields = _xReportComponet->getMasterFields(); - if ( aMasterFields.hasElements() ) - { - SvXMLElementExport aElement(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, true, true); - const uno::Sequence< OUString> aDetailFields = _xReportComponet->getDetailFields(); + if ( !aMasterFields.hasElements() ) + return; - OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for master and detail fields!"); + SvXMLElementExport aElement(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELDS, true, true); + const uno::Sequence< OUString> aDetailFields = _xReportComponet->getDetailFields(); - const OUString* pDetailFieldsIter = aDetailFields.getConstArray(); - for(const OUString& rMasterField : aMasterFields) - { - AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , rMasterField ); - if ( !pDetailFieldsIter->isEmpty() ) - AddAttribute( XML_NAMESPACE_REPORT, XML_DETAIL , *pDetailFieldsIter ); - SvXMLElementExport aPair(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, true, true); - ++pDetailFieldsIter; - } + OSL_ENSURE(aDetailFields.getLength() == aMasterFields.getLength(),"not equal length for master and detail fields!"); + + const OUString* pDetailFieldsIter = aDetailFields.getConstArray(); + for(const OUString& rMasterField : aMasterFields) + { + AddAttribute( XML_NAMESPACE_REPORT, XML_MASTER , rMasterField ); + if ( !pDetailFieldsIter->isEmpty() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_DETAIL , *pDetailFieldsIter ); + SvXMLElementExport aPair(*this,XML_NAMESPACE_REPORT, XML_MASTER_DETAIL_FIELD, true, true); + ++pDetailFieldsIter; } } void ORptExport::exportReport(const Reference& _xReportDefinition) { - if ( _xReportDefinition.is() ) - { - exportFunctions(_xReportDefinition->getFunctions().get()); - exportGroupsExpressionAsFunction(_xReportDefinition->getGroups()); + if ( !_xReportDefinition.is() ) + return; - if ( _xReportDefinition->getReportHeaderOn() ) - { - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_HEADER, true, true); - exportSection(_xReportDefinition->getReportHeader()); - } - if ( _xReportDefinition->getPageHeaderOn() ) - { - OUStringBuffer sValue; - sal_Int16 nRet = _xReportDefinition->getPageHeaderOption(); - const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); - if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) - AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); + exportFunctions(_xReportDefinition->getFunctions().get()); + exportGroupsExpressionAsFunction(_xReportDefinition->getGroups()); - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_HEADER, true, true); - exportSection(_xReportDefinition->getPageHeader(),true); - } + if ( _xReportDefinition->getReportHeaderOn() ) + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_HEADER, true, true); + exportSection(_xReportDefinition->getReportHeader()); + } + if ( _xReportDefinition->getPageHeaderOn() ) + { + OUStringBuffer sValue; + sal_Int16 nRet = _xReportDefinition->getPageHeaderOption(); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); - exportGroup(_xReportDefinition,0); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_HEADER, true, true); + exportSection(_xReportDefinition->getPageHeader(),true); + } - if ( _xReportDefinition->getPageFooterOn() ) - { - OUStringBuffer sValue; - sal_Int16 nRet = _xReportDefinition->getPageFooterOption(); - const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); - if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) - AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_FOOTER, true, true); - exportSection(_xReportDefinition->getPageFooter(),true); - } - if ( _xReportDefinition->getReportFooterOn() ) - { - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_FOOTER, true, true); - exportSection(_xReportDefinition->getReportFooter()); - } + exportGroup(_xReportDefinition,0); + + if ( _xReportDefinition->getPageFooterOn() ) + { + OUStringBuffer sValue; + sal_Int16 nRet = _xReportDefinition->getPageFooterOption(); + const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetReportPrintOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet,aXML_EnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION,sValue.makeStringAndClear()); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_PAGE_FOOTER, true, true); + exportSection(_xReportDefinition->getPageFooter(),true); + } + if ( _xReportDefinition->getReportFooterOn() ) + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_REPORT_FOOTER, true, true); + exportSection(_xReportDefinition->getReportFooter()); } } @@ -1047,90 +1047,90 @@ void ORptExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt, void ORptExport::exportGroup(const Reference& _xReportDefinition,sal_Int32 _nPos,bool _bExportAutoStyle) { - if ( _xReportDefinition.is() ) + if ( !_xReportDefinition.is() ) + return; + + Reference< XGroups > xGroups = _xReportDefinition->getGroups(); + if ( !xGroups.is() ) + return; + + sal_Int32 nCount = xGroups->getCount(); + if ( _nPos >= 0 && _nPos < nCount ) { - Reference< XGroups > xGroups = _xReportDefinition->getGroups(); - if ( xGroups.is() ) + Reference xGroup(xGroups->getByIndex(_nPos),uno::UNO_QUERY); + OSL_ENSURE(xGroup.is(),"No Group prepare for GPF"); + if ( _bExportAutoStyle ) + { + if ( xGroup->getHeaderOn() ) + exportSectionAutoStyle(xGroup->getHeader()); + exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); + if ( xGroup->getFooterOn() ) + exportSectionAutoStyle(xGroup->getFooter()); + } + else { - sal_Int32 nCount = xGroups->getCount(); - if ( _nPos >= 0 && _nPos < nCount ) + if ( xGroup->getSortAscending() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_ASCENDING, XML_TRUE ); + + if ( xGroup->getStartNewColumn() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN, XML_TRUE); + if ( xGroup->getResetPageNumber() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER, XML_TRUE ); + + const OUString sField = xGroup->getExpression(); + OUString sExpression = sField; + if ( !sExpression.isEmpty() ) { - Reference xGroup(xGroups->getByIndex(_nPos),uno::UNO_QUERY); - OSL_ENSURE(xGroup.is(),"No Group prepare for GPF"); - if ( _bExportAutoStyle ) + sal_Int32 nIndex = sExpression.indexOf('"'); + while ( nIndex > -1 ) { - if ( xGroup->getHeaderOn() ) - exportSectionAutoStyle(xGroup->getHeader()); - exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); - if ( xGroup->getFooterOn() ) - exportSectionAutoStyle(xGroup->getFooter()); + sExpression = sExpression.replaceAt(nIndex, 1, "\"\""); + nIndex = sExpression.indexOf('"',nIndex+2); } - else - { - if ( xGroup->getSortAscending() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_ASCENDING, XML_TRUE ); - - if ( xGroup->getStartNewColumn() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN, XML_TRUE); - if ( xGroup->getResetPageNumber() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER, XML_TRUE ); - const OUString sField = xGroup->getExpression(); - OUString sExpression = sField; - if ( !sExpression.isEmpty() ) - { - sal_Int32 nIndex = sExpression.indexOf('"'); - while ( nIndex > -1 ) - { - sExpression = sExpression.replaceAt(nIndex, 1, "\"\""); - nIndex = sExpression.indexOf('"',nIndex+2); - } - - TGroupFunctionMap::const_iterator aGroupFind = m_aGroupFunctionMap.find(xGroup); - if ( aGroupFind != m_aGroupFunctionMap.end() ) - sExpression = aGroupFind->second->getName(); - sExpression = "rpt:HASCHANGED(\"" + sExpression + "\")"; - } - AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_EXPRESSION, sField); - AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sExpression); - sal_Int16 nRet = xGroup->getKeepTogether(); - OUStringBuffer sValue; - const SvXMLEnumMapEntry* aXML_KeepTogetherEnumMap = OXMLHelper::GetKeepTogetherOptions(); - if ( SvXMLUnitConverter::convertEnum( sValue, nRet, aXML_KeepTogetherEnumMap ) ) - AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER,sValue.makeStringAndClear()); - - SvXMLElementExport aGroup(*this,XML_NAMESPACE_REPORT, XML_GROUP, true, true); - exportFunctions(xGroup->getFunctions().get()); - if ( xGroup->getHeaderOn() ) - { - Reference xSection = xGroup->getHeader(); - if ( xSection->getRepeatSection() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_HEADER, true, true); - exportSection(xSection); - } - exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); - if ( xGroup->getFooterOn() ) - { - Reference xSection = xGroup->getFooter(); - if ( xSection->getRepeatSection() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_FOOTER, true, true); - exportSection(xSection); - } - } + TGroupFunctionMap::const_iterator aGroupFind = m_aGroupFunctionMap.find(xGroup); + if ( aGroupFind != m_aGroupFunctionMap.end() ) + sExpression = aGroupFind->second->getName(); + sExpression = "rpt:HASCHANGED(\"" + sExpression + "\")"; } - else if ( _bExportAutoStyle ) + AddAttribute(XML_NAMESPACE_REPORT, XML_SORT_EXPRESSION, sField); + AddAttribute(XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION,sExpression); + sal_Int16 nRet = xGroup->getKeepTogether(); + OUStringBuffer sValue; + const SvXMLEnumMapEntry* aXML_KeepTogetherEnumMap = OXMLHelper::GetKeepTogetherOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, nRet, aXML_KeepTogetherEnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER,sValue.makeStringAndClear()); + + SvXMLElementExport aGroup(*this,XML_NAMESPACE_REPORT, XML_GROUP, true, true); + exportFunctions(xGroup->getFunctions().get()); + if ( xGroup->getHeaderOn() ) { - exportSectionAutoStyle(_xReportDefinition->getDetail()); + Reference xSection = xGroup->getHeader(); + if ( xSection->getRepeatSection() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_HEADER, true, true); + exportSection(xSection); } - else + exportGroup(_xReportDefinition,_nPos+1,_bExportAutoStyle); + if ( xGroup->getFooterOn() ) { - SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_DETAIL, true, true); - exportSection(_xReportDefinition->getDetail()); + Reference xSection = xGroup->getFooter(); + if ( xSection->getRepeatSection() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_REPEAT_SECTION,XML_TRUE ); + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_GROUP_FOOTER, true, true); + exportSection(xSection); } } } + else if ( _bExportAutoStyle ) + { + exportSectionAutoStyle(_xReportDefinition->getDetail()); + } + else + { + SvXMLElementExport aGroupSection(*this,XML_NAMESPACE_REPORT, XML_DETAIL, true, true); + exportSection(_xReportDefinition->getDetail()); + } } void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference& _xParentFormattedField) @@ -1273,34 +1273,34 @@ void ORptExport::SetBodyAttributes() void ORptExport::exportReportAttributes(const Reference& _xReport) { - if ( _xReport.is() ) - { - OUStringBuffer sValue; - const SvXMLEnumMapEntry* aXML_CommnadTypeEnumMap = OXMLHelper::GetCommandTypeOptions(); - if ( SvXMLUnitConverter::convertEnum( sValue, _xReport->getCommandType(), aXML_CommnadTypeEnumMap ) ) - AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND_TYPE,sValue.makeStringAndClear()); - - OUString sComamnd = _xReport->getCommand(); - if ( !sComamnd.isEmpty() ) - AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND, sComamnd); - - OUString sFilter( _xReport->getFilter() ); - if ( !sFilter.isEmpty() ) - AddAttribute( XML_NAMESPACE_REPORT, XML_FILTER, sFilter ); - - AddAttribute(XML_NAMESPACE_OFFICE, XML_MIMETYPE,_xReport->getMimeType()); - - bool bEscapeProcessing( _xReport->getEscapeProcessing() ); - if ( !bEscapeProcessing ) - AddAttribute( XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, ::xmloff::token::GetXMLToken( XML_FALSE ) ); - - OUString sName = _xReport->getCaption(); - if ( !sName.isEmpty() ) - AddAttribute(XML_NAMESPACE_OFFICE, XML_CAPTION,sName); - sName = _xReport->getName(); - if ( !sName.isEmpty() ) - AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,sName); - } + if ( !_xReport.is() ) + return; + + OUStringBuffer sValue; + const SvXMLEnumMapEntry* aXML_CommnadTypeEnumMap = OXMLHelper::GetCommandTypeOptions(); + if ( SvXMLUnitConverter::convertEnum( sValue, _xReport->getCommandType(), aXML_CommnadTypeEnumMap ) ) + AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND_TYPE,sValue.makeStringAndClear()); + + OUString sComamnd = _xReport->getCommand(); + if ( !sComamnd.isEmpty() ) + AddAttribute(XML_NAMESPACE_REPORT, XML_COMMAND, sComamnd); + + OUString sFilter( _xReport->getFilter() ); + if ( !sFilter.isEmpty() ) + AddAttribute( XML_NAMESPACE_REPORT, XML_FILTER, sFilter ); + + AddAttribute(XML_NAMESPACE_OFFICE, XML_MIMETYPE,_xReport->getMimeType()); + + bool bEscapeProcessing( _xReport->getEscapeProcessing() ); + if ( !bEscapeProcessing ) + AddAttribute( XML_NAMESPACE_REPORT, XML_ESCAPE_PROCESSING, ::xmloff::token::GetXMLToken( XML_FALSE ) ); + + OUString sName = _xReport->getCaption(); + if ( !sName.isEmpty() ) + AddAttribute(XML_NAMESPACE_OFFICE, XML_CAPTION,sName); + sName = _xReport->getName(); + if ( !sName.isEmpty() ) + AddAttribute(XML_NAMESPACE_DRAW, XML_NAME,sName); } void ORptExport::ExportContent_() @@ -1320,24 +1320,24 @@ void ORptExport::collectComponentStyles() m_bAllreadyFilled = true; Reference xProp(getReportDefinition()); - if ( xProp.is() ) - { - uno::Reference< report::XSection> xParent(xProp->getParent(),uno::UNO_QUERY); - if ( xParent.is() ) - exportAutoStyle(xProp.get()); + if ( !xProp.is() ) + return; - if ( xProp->getReportHeaderOn() ) - exportSectionAutoStyle(xProp->getReportHeader()); - if ( xProp->getPageHeaderOn() ) - exportSectionAutoStyle(xProp->getPageHeader()); + uno::Reference< report::XSection> xParent(xProp->getParent(),uno::UNO_QUERY); + if ( xParent.is() ) + exportAutoStyle(xProp.get()); - exportGroup(xProp,0,true); + if ( xProp->getReportHeaderOn() ) + exportSectionAutoStyle(xProp->getReportHeader()); + if ( xProp->getPageHeaderOn() ) + exportSectionAutoStyle(xProp->getPageHeader()); - if ( xProp->getPageFooterOn() ) - exportSectionAutoStyle(xProp->getPageFooter()); - if ( xProp->getReportFooterOn() ) - exportSectionAutoStyle(xProp->getReportFooter()); - } + exportGroup(xProp,0,true); + + if ( xProp->getPageFooterOn() ) + exportSectionAutoStyle(xProp->getPageFooter()); + if ( xProp->getReportFooterOn() ) + exportSectionAutoStyle(xProp->getReportFooter()); } void ORptExport::ExportAutoStyles_() @@ -1480,93 +1480,93 @@ void ORptExport::exportShapes(const Reference< XSection>& _xSection,bool _bAddPa void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups) { - if ( _xGroups.is() ) + if ( !_xGroups.is() ) + return; + + uno::Reference< XFunctions> xFunctions = _xGroups->getReportDefinition()->getFunctions(); + const sal_Int32 nCount = _xGroups->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) { - uno::Reference< XFunctions> xFunctions = _xGroups->getReportDefinition()->getFunctions(); - const sal_Int32 nCount = _xGroups->getCount(); - for (sal_Int32 i = 0; i < nCount; ++i) + uno::Reference< XGroup> xGroup(_xGroups->getByIndex(i),uno::UNO_QUERY_THROW); + const ::sal_Int16 nGroupOn = xGroup->getGroupOn(); + if ( nGroupOn != report::GroupOn::DEFAULT ) { - uno::Reference< XGroup> xGroup(_xGroups->getByIndex(i),uno::UNO_QUERY_THROW); - const ::sal_Int16 nGroupOn = xGroup->getGroupOn(); - if ( nGroupOn != report::GroupOn::DEFAULT ) + uno::Reference< XFunction> xFunction = xFunctions->createFunction(); + OUString sFunction,sPrefix,sPostfix; + OUString sExpression = xGroup->getExpression(); + OUString sFunctionName; + OUString sInitialFormula; + switch(nGroupOn) { - uno::Reference< XFunction> xFunction = xFunctions->createFunction(); - OUString sFunction,sPrefix,sPostfix; - OUString sExpression = xGroup->getExpression(); - OUString sFunctionName; - OUString sInitialFormula; - switch(nGroupOn) - { - case report::GroupOn::PREFIX_CHARACTERS: - sFunction = "LEFT"; - sPrefix = ";" + OUString::number(xGroup->getGroupInterval()); - break; - case report::GroupOn::YEAR: - sFunction = "YEAR"; - break; - case report::GroupOn::QUARTAL: - sFunction = "INT((MONTH"; - sPostfix = "-1)/3)+1"; - sFunctionName = "QUARTAL_" + sExpression; - break; - case report::GroupOn::MONTH: - sFunction = "MONTH"; - break; - case report::GroupOn::WEEK: - sFunction = "WEEK"; - break; - case report::GroupOn::DAY: - sFunction = "DAY"; - break; - case report::GroupOn::HOUR: - sFunction = "HOUR"; - break; - case report::GroupOn::MINUTE: - sFunction = "MINUTE"; - break; - case report::GroupOn::INTERVAL: - { - sFunction = "INT"; - uno::Reference< XFunction> xCountFunction = xFunctions->createFunction(); - xCountFunction->setInitialFormula(beans::Optional< OUString>(true,OUString("rpt:0"))); - OUString sCountName = sFunction + "_count_" + sExpression; - xCountFunction->setName(sCountName); - xCountFunction->setFormula( "rpt:[" + sCountName + "] + 1" ); - exportFunction(xCountFunction); - sExpression = sCountName; - // The reference to sCountName in the formula of sFunctionName refers to the *old* value - // so we need to expand the formula of sCountName - sPrefix = " + 1) / " + OUString::number(xGroup->getGroupInterval()); - sFunctionName = sFunction + "_" + sExpression; - sFunction += "("; - sInitialFormula = "rpt:0"; - } - break; - default: - ; - } - if ( sFunctionName.isEmpty() ) - sFunctionName = sFunction + "_" + sExpression; - if ( !sFunction.isEmpty() ) - { - const sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'}; - for(sal_Unicode ch : pReplaceChars) - sFunctionName = sFunctionName.replace(ch,'_'); - - xFunction->setName(sFunctionName); - if ( !sInitialFormula.isEmpty() ) - xFunction->setInitialFormula(beans::Optional< OUString>(true, sInitialFormula)); - sFunction = "rpt:" + sFunction + "([" + sExpression + "]"; - - if ( !sPrefix.isEmpty() ) - sFunction += sPrefix; - sFunction += ")"; - if ( !sPostfix.isEmpty() ) - sFunction += sPostfix; - xFunction->setFormula(sFunction); - exportFunction(xFunction); - m_aGroupFunctionMap.emplace(xGroup,xFunction); - } + case report::GroupOn::PREFIX_CHARACTERS: + sFunction = "LEFT"; + sPrefix = ";" + OUString::number(xGroup->getGroupInterval()); + break; + case report::GroupOn::YEAR: + sFunction = "YEAR"; + break; + case report::GroupOn::QUARTAL: + sFunction = "INT((MONTH"; + sPostfix = "-1)/3)+1"; + sFunctionName = "QUARTAL_" + sExpression; + break; + case report::GroupOn::MONTH: + sFunction = "MONTH"; + break; + case report::GroupOn::WEEK: + sFunction = "WEEK"; + break; + case report::GroupOn::DAY: + sFunction = "DAY"; + break; + case report::GroupOn::HOUR: + sFunction = "HOUR"; + break; + case report::GroupOn::MINUTE: + sFunction = "MINUTE"; + break; + case report::GroupOn::INTERVAL: + { + sFunction = "INT"; + uno::Reference< XFunction> xCountFunction = xFunctions->createFunction(); + xCountFunction->setInitialFormula(beans::Optional< OUString>(true,OUString("rpt:0"))); + OUString sCountName = sFunction + "_count_" + sExpression; + xCountFunction->setName(sCountName); + xCountFunction->setFormula( "rpt:[" + sCountName + "] + 1" ); + exportFunction(xCountFunction); + sExpression = sCountName; + // The reference to sCountName in the formula of sFunctionName refers to the *old* value + // so we need to expand the formula of sCountName + sPrefix = " + 1) / " + OUString::number(xGroup->getGroupInterval()); + sFunctionName = sFunction + "_" + sExpression; + sFunction += "("; + sInitialFormula = "rpt:0"; + } + break; + default: + ; + } + if ( sFunctionName.isEmpty() ) + sFunctionName = sFunction + "_" + sExpression; + if ( !sFunction.isEmpty() ) + { + const sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'}; + for(sal_Unicode ch : pReplaceChars) + sFunctionName = sFunctionName.replace(ch,'_'); + + xFunction->setName(sFunctionName); + if ( !sInitialFormula.isEmpty() ) + xFunction->setInitialFormula(beans::Optional< OUString>(true, sInitialFormula)); + sFunction = "rpt:" + sFunction + "([" + sExpression + "]"; + + if ( !sPrefix.isEmpty() ) + sFunction += sPrefix; + sFunction += ")"; + if ( !sPostfix.isEmpty() ) + sFunction += sPostfix; + xFunction->setFormula(sFunction); + exportFunction(xFunction); + m_aGroupFunctionMap.emplace(xGroup,xFunction); } } } diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx index 4d8f8356f6be..7ba132baf335 100644 --- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx @@ -317,18 +317,18 @@ void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any > ,sCommand); uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xDatabaseDataProvider,uno::UNO_QUERY); - if ( xDataProvider.is() ) + if ( !xDataProvider.is() ) + return; + + m_aColumns.realloc(1); + const uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions(); + for(const auto& rColumnName : aColumnNames) { - m_aColumns.realloc(1); - const uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions(); - for(const auto& rColumnName : aColumnNames) + if ( !rColumnName.isEmpty() ) { - if ( !rColumnName.isEmpty() ) - { - sal_Int32 nCount = m_aColumns.getLength(); - m_aColumns.realloc(nCount+1); - m_aColumns[nCount] = rColumnName; - } + sal_Int32 nCount = m_aColumns.getLength(); + m_aColumns.realloc(nCount+1); + m_aColumns[nCount] = rColumnName; } } } diff --git a/reportdesign/source/filter/xml/xmlFixedContent.cxx b/reportdesign/source/filter/xml/xmlFixedContent.cxx index b5514c08ca16..805a15edb3bd 100644 --- a/reportdesign/source/filter/xml/xmlFixedContent.cxx +++ b/reportdesign/source/filter/xml/xmlFixedContent.cxx @@ -165,32 +165,32 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLFixedContent::crea void OXMLFixedContent::endFastElement(sal_Int32 nElement) { - if ( m_pInP ) + if ( !m_pInP ) + return; + + const Reference xFactor(m_rImport.GetModel(),uno::UNO_QUERY); + if ( m_bFormattedField ) { - const Reference xFactor(m_rImport.GetModel(),uno::UNO_QUERY); - if ( m_bFormattedField ) - { - uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD); - Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY); - xControl->setDataField("rpt:" + m_sPageText); - OSL_ENSURE(xControl.is(),"Could not create FormattedField!"); - m_pInP->m_xReportComponent = xControl.get(); - m_xReportComponent = xControl.get(); - } - else - { - Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY); - OSL_ENSURE(xControl.is(),"Could not create FixedContent!"); - m_pInP->m_xReportComponent = xControl.get(); - m_xReportComponent = xControl.get(); - xControl->setLabel(m_sLabel); - } + uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD); + Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY); + xControl->setDataField("rpt:" + m_sPageText); + OSL_ENSURE(xControl.is(),"Could not create FormattedField!"); + m_pInP->m_xReportComponent = xControl.get(); + m_xReportComponent = xControl.get(); + } + else + { + Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY); + OSL_ENSURE(xControl.is(),"Could not create FixedContent!"); + m_pInP->m_xReportComponent = xControl.get(); + m_xReportComponent = xControl.get(); + xControl->setLabel(m_sLabel); + } - m_pContainer->addCell(m_xReportComponent); - m_rCell.setComponent(m_xReportComponent); + m_pContainer->addCell(m_xReportComponent); + m_rCell.setComponent(m_xReportComponent); - OXMLReportElementBase::endFastElement(nElement); - } + OXMLReportElementBase::endFastElement(nElement); } void OXMLFixedContent::characters( const OUString& rChars ) diff --git a/reportdesign/source/filter/xml/xmlHelper.cxx b/reportdesign/source/filter/xml/xmlHelper.cxx index 2372db278137..01ae9744f446 100644 --- a/reportdesign/source/filter/xml/xmlHelper.cxx +++ b/reportdesign/source/filter/xml/xmlHelper.cxx @@ -256,67 +256,67 @@ void OXMLHelper::copyStyleElements(const bool _bOld,const OUString& _sStyleName, if ( !_xProp.is() || _sStyleName.isEmpty() || !_pAutoStyles ) return; XMLPropStyleContext* pAutoStyle = const_cast(dynamic_cast< const XMLPropStyleContext *>(_pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_CELL,_sStyleName))); - if ( pAutoStyle ) + if ( !pAutoStyle ) + return; + + css::awt::FontDescriptor aFont; + static comphelper::PropertyMapEntry const pMap[] = { - css::awt::FontDescriptor aFont; - static comphelper::PropertyMapEntry const pMap[] = - { - {OUString(PROPERTY_FONTNAME), PROPERTY_ID_FONTNAME, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARFONTHEIGHT), PROPERTY_ID_FONTHEIGHT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTWIDTH), PROPERTY_ID_FONTWIDTH, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTSTYLENAME), PROPERTY_ID_FONTSTYLENAME, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTFAMILY), PROPERTY_ID_FONTFAMILY, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTCHARSET), PROPERTY_ID_FONTCHARSET, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTPITCH), PROPERTY_ID_FONTPITCH, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTCHARWIDTH), PROPERTY_ID_FONTCHARWIDTH, cppu::UnoType::get(),PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTWEIGHT), PROPERTY_ID_FONTWEIGHT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARPOSTURE), PROPERTY_ID_FONTSLANT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTUNDERLINE), PROPERTY_ID_FONTUNDERLINE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARSTRIKEOUT), PROPERTY_ID_FONTSTRIKEOUT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTORIENTATION), PROPERTY_ID_FONTORIENTATION, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTKERNING), PROPERTY_ID_FONTKERNING, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARWORDMODE), PROPERTY_ID_FONTWORDLINEMODE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTTYPE), PROPERTY_ID_FONTTYPE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, - { OUString(), 0, css::uno::Type(), 0, 0 } - }; - try - { - pAutoStyle->FillPropertySet(_xProp); - if ( _bOld && _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_CHARHIDDEN) ) - _xProp->setPropertyValue(PROPERTY_CHARHIDDEN,uno::makeAny(false)); + {OUString(PROPERTY_FONTNAME), PROPERTY_ID_FONTNAME, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARFONTHEIGHT), PROPERTY_ID_FONTHEIGHT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTWIDTH), PROPERTY_ID_FONTWIDTH, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTSTYLENAME), PROPERTY_ID_FONTSTYLENAME, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTFAMILY), PROPERTY_ID_FONTFAMILY, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTCHARSET), PROPERTY_ID_FONTCHARSET, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTPITCH), PROPERTY_ID_FONTPITCH, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTCHARWIDTH), PROPERTY_ID_FONTCHARWIDTH, cppu::UnoType::get(),PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTWEIGHT), PROPERTY_ID_FONTWEIGHT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARPOSTURE), PROPERTY_ID_FONTSLANT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTUNDERLINE), PROPERTY_ID_FONTUNDERLINE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARSTRIKEOUT), PROPERTY_ID_FONTSTRIKEOUT, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTORIENTATION), PROPERTY_ID_FONTORIENTATION, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTKERNING), PROPERTY_ID_FONTKERNING, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARWORDMODE), PROPERTY_ID_FONTWORDLINEMODE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTTYPE), PROPERTY_ID_FONTTYPE, cppu::UnoType::get() ,PropertyAttribute::BOUND,0}, + { OUString(), 0, css::uno::Type(), 0, 0 } + }; + try + { + pAutoStyle->FillPropertySet(_xProp); + if ( _bOld && _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_CHARHIDDEN) ) + _xProp->setPropertyValue(PROPERTY_CHARHIDDEN,uno::makeAny(false)); - uno::Reference xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap)); - pAutoStyle->FillPropertySet(xProp); - xProp->getPropertyValue(PROPERTY_FONTNAME) >>= aFont.Name; - xProp->getPropertyValue(PROPERTY_CHARFONTHEIGHT) >>= aFont.Height; - xProp->getPropertyValue(PROPERTY_FONTWIDTH) >>= aFont.Width; - xProp->getPropertyValue(PROPERTY_FONTSTYLENAME) >>= aFont.StyleName; - xProp->getPropertyValue(PROPERTY_FONTFAMILY) >>= aFont.Family; - xProp->getPropertyValue(PROPERTY_FONTCHARSET) >>= aFont.CharSet; - xProp->getPropertyValue(PROPERTY_FONTPITCH) >>= aFont.Pitch; - xProp->getPropertyValue(PROPERTY_FONTCHARWIDTH) >>= aFont.CharacterWidth; - xProp->getPropertyValue(PROPERTY_FONTWEIGHT) >>= aFont.Weight; - xProp->getPropertyValue(PROPERTY_CHARPOSTURE) >>= aFont.Slant; - xProp->getPropertyValue(PROPERTY_FONTUNDERLINE) >>= aFont.Underline; - xProp->getPropertyValue(PROPERTY_CHARSTRIKEOUT) >>= aFont.Strikeout; - xProp->getPropertyValue(PROPERTY_FONTORIENTATION) >>= aFont.Orientation; - xProp->getPropertyValue(PROPERTY_FONTKERNING) >>= aFont.Kerning; - xProp->getPropertyValue(PROPERTY_CHARWORDMODE) >>= aFont.WordLineMode; - xProp->getPropertyValue(PROPERTY_FONTTYPE) >>= aFont.Type; - uno::Reference xReportControlModel(_xProp,uno::UNO_QUERY); - if ( xReportControlModel.is() && !aFont.Name.isEmpty() ) + uno::Reference xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap)); + pAutoStyle->FillPropertySet(xProp); + xProp->getPropertyValue(PROPERTY_FONTNAME) >>= aFont.Name; + xProp->getPropertyValue(PROPERTY_CHARFONTHEIGHT) >>= aFont.Height; + xProp->getPropertyValue(PROPERTY_FONTWIDTH) >>= aFont.Width; + xProp->getPropertyValue(PROPERTY_FONTSTYLENAME) >>= aFont.StyleName; + xProp->getPropertyValue(PROPERTY_FONTFAMILY) >>= aFont.Family; + xProp->getPropertyValue(PROPERTY_FONTCHARSET) >>= aFont.CharSet; + xProp->getPropertyValue(PROPERTY_FONTPITCH) >>= aFont.Pitch; + xProp->getPropertyValue(PROPERTY_FONTCHARWIDTH) >>= aFont.CharacterWidth; + xProp->getPropertyValue(PROPERTY_FONTWEIGHT) >>= aFont.Weight; + xProp->getPropertyValue(PROPERTY_CHARPOSTURE) >>= aFont.Slant; + xProp->getPropertyValue(PROPERTY_FONTUNDERLINE) >>= aFont.Underline; + xProp->getPropertyValue(PROPERTY_CHARSTRIKEOUT) >>= aFont.Strikeout; + xProp->getPropertyValue(PROPERTY_FONTORIENTATION) >>= aFont.Orientation; + xProp->getPropertyValue(PROPERTY_FONTKERNING) >>= aFont.Kerning; + xProp->getPropertyValue(PROPERTY_CHARWORDMODE) >>= aFont.WordLineMode; + xProp->getPropertyValue(PROPERTY_FONTTYPE) >>= aFont.Type; + uno::Reference xReportControlModel(_xProp,uno::UNO_QUERY); + if ( xReportControlModel.is() && !aFont.Name.isEmpty() ) + { + try { - try - { - xReportControlModel->setFontDescriptor(aFont); - } - catch(const beans::UnknownPropertyException &){} + xReportControlModel->setFontDescriptor(aFont); } - } - catch(uno::Exception&) - { - OSL_FAIL("OXMLHelper::copyStyleElements -> exception caught"); + catch(const beans::UnknownPropertyException &){} } + } + catch(uno::Exception&) + { + OSL_FAIL("OXMLHelper::copyStyleElements -> exception caught"); } } diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index c3559667869c..17310b206e20 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -108,49 +108,49 @@ void SAL_CALL ImportDocumentHandler::endDocument() { m_xDelegatee->endDocument(); uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW); - if ( m_bImportedChart ) - { - // this fills the chart again - ::comphelper::NamedValueCollection aArgs; - aArgs.put( "CellRangeRepresentation", OUString("all") ); - aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); - aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + if ( !m_bImportedChart ) + return; + + // this fills the chart again + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", OUString("all") ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); - bool bHasCategories = false; + bool bHasCategories = false; - uno::Reference< chart2::data::XDataSource > xDataSource(m_xModel, uno::UNO_QUERY); - if( xDataSource.is()) + uno::Reference< chart2::data::XDataSource > xDataSource(m_xModel, uno::UNO_QUERY); + if( xDataSource.is()) + { + const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(xDataSource->getDataSequences()); + for( const auto& rSequence : aSequences ) { - const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(xDataSource->getDataSequences()); - for( const auto& rSequence : aSequences ) + if( rSequence.is() ) { - if( rSequence.is() ) + uno::Reference< beans::XPropertySet > xSeqProp( rSequence->getValues(), uno::UNO_QUERY ); + OUString aRole; + if ( xSeqProp.is() + && ( xSeqProp->getPropertyValue( "Role" ) >>= aRole ) + && aRole == "categories" + ) { - uno::Reference< beans::XPropertySet > xSeqProp( rSequence->getValues(), uno::UNO_QUERY ); - OUString aRole; - if ( xSeqProp.is() - && ( xSeqProp->getPropertyValue( "Role" ) >>= aRole ) - && aRole == "categories" - ) - { - bHasCategories = true; - break; - } + bHasCategories = true; + break; } } } - aArgs.put( "HasCategories", uno::makeAny( bHasCategories ) ); - - uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY); - if ( xDataProvider.is() ) - { - const uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions(); - aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) ); - } + } + aArgs.put( "HasCategories", uno::makeAny( bHasCategories ) ); - xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() ); - xReceiver->setArguments( aArgs.getPropertyValues() ); + uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY); + if ( xDataProvider.is() ) + { + const uno::Sequence< OUString > aColumnNames = xDataProvider->getColumnDescriptions(); + aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) ); } + + xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() ); + xReceiver->setArguments( aArgs.getPropertyValues() ); } void SAL_CALL ImportDocumentHandler::startElement(const OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & _xAttrList) diff --git a/reportdesign/source/filter/xml/xmlSubDocument.cxx b/reportdesign/source/filter/xml/xmlSubDocument.cxx index fabbb67f2187..041cd7a44406 100644 --- a/reportdesign/source/filter/xml/xmlSubDocument.cxx +++ b/reportdesign/source/filter/xml/xmlSubDocument.cxx @@ -111,42 +111,41 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLSubDocument::creat void OXMLSubDocument::endFastElement(sal_Int32 ) { - if ( m_bContainsShape ) + if ( !m_bContainsShape ) + return; + + m_xReportComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY); + if ( !m_xReportComponent.is() ) + return; + + if ( !m_aMasterFields.empty() ) + m_xReportComponent->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size())); + if ( !m_aDetailFields.empty() ) + m_xReportComponent->setDetailFields(Sequence< OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size())); + + m_xReportComponent->setName(m_xFake->getName()); + m_xReportComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues()); + uno::Reference< report::XReportControlModel > xFakeModel(m_xFake,uno::UNO_QUERY); + uno::Reference< report::XReportControlModel > xComponentModel(m_xReportComponent,uno::UNO_QUERY); + if ( !(xComponentModel.is() && xFakeModel.is()) ) + return; + + xComponentModel->setPrintWhenGroupChange(xFakeModel->getPrintWhenGroupChange()); + const sal_Int32 nCount = xFakeModel->getCount(); + try { - m_xReportComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY); - if ( m_xReportComponent.is() ) + for (sal_Int32 i = 0; i < nCount ; ++i) { - if ( !m_aMasterFields.empty() ) - m_xReportComponent->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size())); - if ( !m_aDetailFields.empty() ) - m_xReportComponent->setDetailFields(Sequence< OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size())); - - m_xReportComponent->setName(m_xFake->getName()); - m_xReportComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues()); - uno::Reference< report::XReportControlModel > xFakeModel(m_xFake,uno::UNO_QUERY); - uno::Reference< report::XReportControlModel > xComponentModel(m_xReportComponent,uno::UNO_QUERY); - if ( xComponentModel.is() && xFakeModel.is() ) - { - xComponentModel->setPrintWhenGroupChange(xFakeModel->getPrintWhenGroupChange()); - const sal_Int32 nCount = xFakeModel->getCount(); - try - { - for (sal_Int32 i = 0; i < nCount ; ++i) - { - uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY); - uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition(); - ::comphelper::copyProperties(xCond.get(),xNewCond.get()); - xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond)); - } - } - catch(uno::Exception&) - { - OSL_FAIL("Can not access format condition!"); - } - - } + uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY); + uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition(); + ::comphelper::copyProperties(xCond.get(),xNewCond.get()); + xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond)); } } + catch(uno::Exception&) + { + OSL_FAIL("Can not access format condition!"); + } } void OXMLSubDocument::addMasterDetailPair(const ::std::pair< OUString,OUString >& _aPair) diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx index 895ea2b9ed77..72cfb01f1c30 100644 --- a/reportdesign/source/ui/dlg/AddField.cxx +++ b/reportdesign/source/ui/dlg/AddField.cxx @@ -99,21 +99,21 @@ OAddFieldWindow::OAddFieldWindow(weld::Window* pParent, const uno::Reference< be m_xListBox->connect_changed(LINK( this, OAddFieldWindow, OnSelectHdl ) ); m_xListBox->set_size_request(m_xListBox->get_approximate_digit_width() * 45, m_xListBox->get_height_rows(8)); - if (m_xRowSet.is()) + if (!m_xRowSet.is()) + return; + + try { - try - { - // be notified when the settings of report definition change - m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer( this, m_xRowSet ); - m_pChangeListener->addProperty( PROPERTY_COMMAND ); - m_pChangeListener->addProperty( PROPERTY_COMMANDTYPE ); - m_pChangeListener->addProperty( PROPERTY_ESCAPEPROCESSING ); - m_pChangeListener->addProperty( PROPERTY_FILTER ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } + // be notified when the settings of report definition change + m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer( this, m_xRowSet ); + m_pChangeListener->addProperty( PROPERTY_COMMAND ); + m_pChangeListener->addProperty( PROPERTY_COMMANDTYPE ); + m_pChangeListener->addProperty( PROPERTY_ESCAPEPROCESSING ); + m_pChangeListener->addProperty( PROPERTY_FILTER ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } @@ -261,48 +261,48 @@ uno::Reference< sdbc::XConnection> OAddFieldWindow::getConnection() const void OAddFieldWindow::fillDescriptor(const weld::TreeIter& rSelected, svx::ODataAccessDescriptor& rDescriptor) { - if (m_xColumns.is()) + if (!m_xColumns.is()) + return; + + uno::Reference xChild(getConnection(),uno::UNO_QUERY); + if ( xChild.is( ) ) { - uno::Reference xChild(getConnection(),uno::UNO_QUERY); - if ( xChild.is( ) ) + uno::Reference xDocument( xChild->getParent(), uno::UNO_QUERY ); + if ( xDocument.is() ) { - uno::Reference xDocument( xChild->getParent(), uno::UNO_QUERY ); - if ( xDocument.is() ) - { - uno::Reference xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY); - if ( xModel.is() ) - rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] <<= xModel->getURL(); - } + uno::Reference xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY); + if ( xModel.is() ) + rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] <<= xModel->getURL(); } + } - rDescriptor[ svx::DataAccessDescriptorProperty::Command ] <<= GetCommand(); - rDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] <<= GetCommandType(); - rDescriptor[ svx::DataAccessDescriptorProperty::EscapeProcessing ] <<= m_bEscapeProcessing; - rDescriptor[ svx::DataAccessDescriptorProperty::Connection ] <<= getConnection(); + rDescriptor[ svx::DataAccessDescriptorProperty::Command ] <<= GetCommand(); + rDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] <<= GetCommandType(); + rDescriptor[ svx::DataAccessDescriptorProperty::EscapeProcessing ] <<= m_bEscapeProcessing; + rDescriptor[ svx::DataAccessDescriptorProperty::Connection ] <<= getConnection(); - ColumnInfo* pInfo = reinterpret_cast(m_xListBox->get_id(rSelected).toInt64()); - rDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] <<= pInfo->sColumnName; - if ( m_xColumns->hasByName( pInfo->sColumnName ) ) - rDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ] = m_xColumns->getByName(pInfo->sColumnName); - } + ColumnInfo* pInfo = reinterpret_cast(m_xListBox->get_id(rSelected).toInt64()); + rDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] <<= pInfo->sColumnName; + if ( m_xColumns->hasByName( pInfo->sColumnName ) ) + rDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ] = m_xColumns->getByName(pInfo->sColumnName); } void OAddFieldWindow::_elementInserted( const container::ContainerEvent& _rEvent ) { OUString sName; - if ( (_rEvent.Accessor >>= sName) && m_xColumns->hasByName(sName) ) - { - uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(sName),UNO_QUERY_THROW); - OUString sLabel; - if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) - xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; - m_aListBoxData.emplace_back(new ColumnInfo(sName, sLabel)); - OUString sId(OUString::number(reinterpret_cast(m_aListBoxData.back().get()))); - if (!sLabel.isEmpty()) - m_xListBox->append(sId, sLabel); - else - m_xListBox->append(sId, sName); - } + if ( !((_rEvent.Accessor >>= sName) && m_xColumns->hasByName(sName)) ) + return; + + uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(sName),UNO_QUERY_THROW); + OUString sLabel; + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + m_aListBoxData.emplace_back(new ColumnInfo(sName, sLabel)); + OUString sId(OUString::number(reinterpret_cast(m_aListBoxData.back().get()))); + if (!sLabel.isEmpty()) + m_xListBox->append(sId, sLabel); + else + m_xListBox->append(sId, sName); } void OAddFieldWindow::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index c7a64b297d46..b15e6ae3fc64 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -65,18 +65,18 @@ namespace rptui //allow dialog to resize itself size_t nCount = impl_getConditionCount(); - if (nCount) + if (!nCount) + return; + + auto nHeight = m_aConditions[0]->get_preferred_size().Height(); + size_t nVisibleConditions = ::std::min(nCount, MAX_CONDITIONS); + nHeight *= nVisibleConditions; + nHeight += 2; + if (nHeight != m_xScrollWindow->get_size_request().Height()) { - auto nHeight = m_aConditions[0]->get_preferred_size().Height(); - size_t nVisibleConditions = ::std::min(nCount, MAX_CONDITIONS); - nHeight *= nVisibleConditions; - nHeight += 2; - if (nHeight != m_xScrollWindow->get_size_request().Height()) - { - m_xScrollWindow->set_size_request(-1, nHeight); - if (!bFirst) - m_xDialog->resize_to_request(); - } + m_xScrollWindow->set_size_request(-1, nHeight); + if (!bFirst) + m_xDialog->resize_to_request(); } } diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 50a28cb405f6..129ee1c7a6f3 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -321,30 +321,30 @@ void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat OString aItems[] = { "bold", "italic", "underline", "fontdialog" }; OSL_ENSURE(_xReportControlFormat.is(),"XReportControlFormat is NULL!"); - if ( _xReportControlFormat.is() ) + if ( !_xReportControlFormat.is() ) + return; + + for (size_t j = 0; j < SAL_N_ELEMENTS(aItems); ++j) { - for (size_t j = 0; j < SAL_N_ELEMENTS(aItems); ++j) - { - m_xActions->set_item_active(aItems[j], OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(aItems[j]), - _xReportControlFormat)); - } + m_xActions->set_item_active(aItems[j], OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(aItems[j]), + _xReportControlFormat)); + } - try - { - vcl::Font aBaseFont( Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont() ); - SvxFont aFont( VCLUnoHelper::CreateFont( _xReportControlFormat->getFontDescriptor(), aBaseFont ) ); - aFont.SetFontHeight(OutputDevice::LogicToLogic(Size(0, aFont.GetFontHeight()), MapMode(MapUnit::MapPoint), MapMode(MapUnit::MapTwip)).Height()); - aFont.SetEmphasisMark( static_cast< FontEmphasisMark >( _xReportControlFormat->getControlTextEmphasis() ) ); - aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) ); - aFont.SetColor( Color(_xReportControlFormat->getCharColor()) ); - m_aPreview.SetFont( aFont, aFont, aFont ); - m_aPreview.SetBackColor( Color(_xReportControlFormat->getControlBackground()) ); - m_aPreview.SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } + try + { + vcl::Font aBaseFont( Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont() ); + SvxFont aFont( VCLUnoHelper::CreateFont( _xReportControlFormat->getFontDescriptor(), aBaseFont ) ); + aFont.SetFontHeight(OutputDevice::LogicToLogic(Size(0, aFont.GetFontHeight()), MapMode(MapUnit::MapPoint), MapMode(MapUnit::MapTwip)).Height()); + aFont.SetEmphasisMark( static_cast< FontEmphasisMark >( _xReportControlFormat->getControlTextEmphasis() ) ); + aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) ); + aFont.SetColor( Color(_xReportControlFormat->getCharColor()) ); + m_aPreview.SetFont( aFont, aFont, aFont ); + m_aPreview.SetBackColor( Color(_xReportControlFormat->getControlBackground()) ); + m_aPreview.SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index f9702f0385bc..bd3ad95fa456 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -306,40 +306,40 @@ sal_Int8 OFieldExpressionControl::ExecuteDrop( const BrowserExecuteDropEvent& rE void OFieldExpressionControl::moveGroups(const uno::Sequence& _aGroups,sal_Int32 _nRow,bool _bSelect) { - if ( _aGroups.hasElements() ) + if ( !_aGroups.hasElements() ) + return; + + m_bIgnoreEvent = true; { - m_bIgnoreEvent = true; - { - sal_Int32 nRow = _nRow; - const OUString sUndoAction(RptResId(RID_STR_UNDO_MOVE_GROUP)); - const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction ); + sal_Int32 nRow = _nRow; + const OUString sUndoAction(RptResId(RID_STR_UNDO_MOVE_GROUP)); + const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction ); - uno::Reference< report::XGroups> xGroups = m_pParent->getGroups(); - for(const uno::Any& rGroup : _aGroups) + uno::Reference< report::XGroups> xGroups = m_pParent->getGroups(); + for(const uno::Any& rGroup : _aGroups) + { + uno::Reference< report::XGroup> xGroup(rGroup,uno::UNO_QUERY); + if ( xGroup.is() ) { - uno::Reference< report::XGroup> xGroup(rGroup,uno::UNO_QUERY); - if ( xGroup.is() ) - { - uno::Sequence< beans::PropertyValue > aArgs(1); - aArgs[0].Name = PROPERTY_GROUP; - aArgs[0].Value <<= xGroup; - // we use this way to create undo actions - m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs); - aArgs.realloc(2); - if ( nRow > xGroups->getCount() ) - nRow = xGroups->getCount(); - if ( _bSelect ) - SelectRow(nRow); - aArgs[1].Name = PROPERTY_POSITIONY; - aArgs[1].Value <<= nRow; - m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs); - ++nRow; - } + uno::Sequence< beans::PropertyValue > aArgs(1); + aArgs[0].Name = PROPERTY_GROUP; + aArgs[0].Value <<= xGroup; + // we use this way to create undo actions + m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs); + aArgs.realloc(2); + if ( nRow > xGroups->getCount() ) + nRow = xGroups->getCount(); + if ( _bSelect ) + SelectRow(nRow); + aArgs[1].Name = PROPERTY_POSITIONY; + aArgs[1].Value <<= nRow; + m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs); + ++nRow; } } - m_bIgnoreEvent = false; - Invalidate(); } + m_bIgnoreEvent = false; + Invalidate(); } void OFieldExpressionControl::fillColumns(const uno::Reference< container::XNameAccess>& _xColumns) @@ -596,37 +596,37 @@ void OFieldExpressionControl::elementInserted(const container::ContainerEvent& e SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( m_aMutex ); sal_Int32 nGroupPos = 0; - if ( evt.Accessor >>= nGroupPos ) + if ( !(evt.Accessor >>= nGroupPos) ) + return; + + if ( nGroupPos >= GetRowCount() ) { - if ( nGroupPos >= GetRowCount() ) - { - sal_Int32 nAddedRows = nGroupPos - GetRowCount(); - RowInserted(nAddedRows); - for (sal_Int32 i = 0; i < nAddedRows; ++i) - m_aGroupPositions.push_back(NO_GROUP); - m_aGroupPositions[nGroupPos] = nGroupPos; - } - else + sal_Int32 nAddedRows = nGroupPos - GetRowCount(); + RowInserted(nAddedRows); + for (sal_Int32 i = 0; i < nAddedRows; ++i) + m_aGroupPositions.push_back(NO_GROUP); + m_aGroupPositions[nGroupPos] = nGroupPos; + } + else + { + ::std::vector::iterator aFind = m_aGroupPositions.begin()+ nGroupPos; + if ( aFind == m_aGroupPositions.end() ) + aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),NO_GROUP); + + if ( aFind != m_aGroupPositions.end() ) { - ::std::vector::iterator aFind = m_aGroupPositions.begin()+ nGroupPos; - if ( aFind == m_aGroupPositions.end() ) - aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),NO_GROUP); + if ( *aFind != NO_GROUP ) + aFind = m_aGroupPositions.insert(aFind,nGroupPos); + else + *aFind = nGroupPos; - if ( aFind != m_aGroupPositions.end() ) - { + ::std::vector::const_iterator aEnd = m_aGroupPositions.end(); + for(++aFind;aFind != aEnd;++aFind) if ( *aFind != NO_GROUP ) - aFind = m_aGroupPositions.insert(aFind,nGroupPos); - else - *aFind = nGroupPos; - - ::std::vector::const_iterator aEnd = m_aGroupPositions.end(); - for(++aFind;aFind != aEnd;++aFind) - if ( *aFind != NO_GROUP ) - ++*aFind; - } + ++*aFind; } - Invalidate(); } + Invalidate(); } void OFieldExpressionControl::elementRemoved(const container::ContainerEvent& evt) @@ -638,18 +638,18 @@ void OFieldExpressionControl::elementRemoved(const container::ContainerEvent& ev return; sal_Int32 nGroupPos = 0; - if ( evt.Accessor >>= nGroupPos ) + if ( !(evt.Accessor >>= nGroupPos) ) + return; + + std::vector::iterator aEnd = m_aGroupPositions.end(); + std::vector::iterator aFind = std::find(m_aGroupPositions.begin(), aEnd, nGroupPos); + if (aFind != aEnd) { - std::vector::iterator aEnd = m_aGroupPositions.end(); - std::vector::iterator aFind = std::find(m_aGroupPositions.begin(), aEnd, nGroupPos); - if (aFind != aEnd) - { - *aFind = NO_GROUP; - for(++aFind;aFind != aEnd;++aFind) - if ( *aFind != NO_GROUP ) - --*aFind; - Invalidate(); - } + *aFind = NO_GROUP; + for(++aFind;aFind != aEnd;++aFind) + if ( *aFind != NO_GROUP ) + --*aFind; + Invalidate(); } } @@ -978,72 +978,72 @@ IMPL_LINK_NOARG(OGroupsSortingDialog, OnWidgetFocusLost, weld::Widget&, void) IMPL_LINK(OGroupsSortingDialog, OnFormatAction, const OString&, rCommand, void) { - if ( m_xFieldExpression ) + if ( !m_xFieldExpression ) + return; + + long nIndex = m_xFieldExpression->GetCurrRow(); + sal_Int32 nGroupPos = m_xFieldExpression->getGroupPosition(nIndex); + uno::Sequence aClipboardList; + if ( nIndex >= 0 && nGroupPos != NO_GROUP ) { - long nIndex = m_xFieldExpression->GetCurrRow(); - sal_Int32 nGroupPos = m_xFieldExpression->getGroupPosition(nIndex); - uno::Sequence aClipboardList; - if ( nIndex >= 0 && nGroupPos != NO_GROUP ) - { - aClipboardList.realloc(1); - aClipboardList[0] = m_xGroups->getByIndex(nGroupPos); - } - if (rCommand == "up") - { - --nIndex; - } - if (rCommand == "down") - { - ++nIndex; - } - if (rCommand == "delete") - { - Application::PostUserEvent(LINK(m_xFieldExpression, OFieldExpressionControl, DelayedDelete)); - } - else + aClipboardList.realloc(1); + aClipboardList[0] = m_xGroups->getByIndex(nGroupPos); + } + if (rCommand == "up") + { + --nIndex; + } + if (rCommand == "down") + { + ++nIndex; + } + if (rCommand == "delete") + { + Application::PostUserEvent(LINK(m_xFieldExpression, OFieldExpressionControl, DelayedDelete)); + } + else + { + if ( nIndex >= 0 && aClipboardList.hasElements() ) { - if ( nIndex >= 0 && aClipboardList.hasElements() ) - { - m_xFieldExpression->SetNoSelection(); - m_xFieldExpression->moveGroups(aClipboardList,nIndex,false); - m_xFieldExpression->DeactivateCell(); - m_xFieldExpression->GoToRow(nIndex); - m_xFieldExpression->ActivateCell(nIndex, m_xFieldExpression->GetCurColumnId()); - DisplayData(nIndex); - } + m_xFieldExpression->SetNoSelection(); + m_xFieldExpression->moveGroups(aClipboardList,nIndex,false); + m_xFieldExpression->DeactivateCell(); + m_xFieldExpression->GoToRow(nIndex); + m_xFieldExpression->ActivateCell(nIndex, m_xFieldExpression->GetCurColumnId()); + DisplayData(nIndex); } } } IMPL_LINK( OGroupsSortingDialog, LBChangeHdl, weld::ComboBox&, rListBox, void ) { - if ( rListBox.get_value_changed_from_saved() ) + if ( !rListBox.get_value_changed_from_saved() ) + return; + + sal_Int32 nRow = m_xFieldExpression->GetCurRow(); + sal_Int32 nGroupPos = m_xFieldExpression->getGroupPosition(nRow); + if (&rListBox != m_xHeaderLst.get() && &rListBox != m_xFooterLst.get()) { - sal_Int32 nRow = m_xFieldExpression->GetCurRow(); - sal_Int32 nGroupPos = m_xFieldExpression->getGroupPosition(nRow); - if (&rListBox != m_xHeaderLst.get() && &rListBox != m_xFooterLst.get()) - { - if ( rListBox.get_value_changed_from_saved() ) - SaveData(nRow); - if ( &rListBox == m_xGroupOnLst.get() ) - m_xGroupIntervalEd->set_sensitive(rListBox.get_active() != 0); - } - else if ( nGroupPos != NO_GROUP ) - { - uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos); - uno::Sequence< beans::PropertyValue > aArgs(2); - aArgs[1].Name = PROPERTY_GROUP; - aArgs[1].Value <<= xGroup; + if ( rListBox.get_value_changed_from_saved() ) + SaveData(nRow); + if ( &rListBox == m_xGroupOnLst.get() ) + m_xGroupIntervalEd->set_sensitive(rListBox.get_active() != 0); + } + else if ( nGroupPos != NO_GROUP ) + { + uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos); + uno::Sequence< beans::PropertyValue > aArgs(2); + aArgs[1].Name = PROPERTY_GROUP; + aArgs[1].Value <<= xGroup; - if ( m_xHeaderLst.get() == &rListBox ) - aArgs[0].Name = PROPERTY_HEADERON; - else - aArgs[0].Name = PROPERTY_FOOTERON; + if ( m_xHeaderLst.get() == &rListBox ) + aArgs[0].Name = PROPERTY_HEADERON; + else + aArgs[0].Name = PROPERTY_FOOTERON; - aArgs[0].Value <<= rListBox.get_active() == 0; - m_pController->executeChecked(m_xHeaderLst.get() == &rListBox ? SID_GROUPHEADER : SID_GROUPFOOTER, aArgs); - m_xFieldExpression->InvalidateHandleColumn(); - } + aArgs[0].Value <<= rListBox.get_active() == 0; + m_pController->executeChecked(m_xHeaderLst.get() == &rListBox ? SID_GROUPHEADER : SID_GROUPFOOTER, aArgs); + m_xFieldExpression->InvalidateHandleColumn(); } } diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx index 8b68f9adf6e4..ce2120c97fa6 100644 --- a/reportdesign/source/ui/dlg/Navigator.cxx +++ b/reportdesign/source/ui/dlg/Navigator.cxx @@ -563,35 +563,35 @@ void NavigatorTree::traverseDetail(const uno::Reference< report::XSection>& xSec void NavigatorTree::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) { uno::Reference< report::XReportDefinition> xReport(_rEvent.Source,uno::UNO_QUERY); - if ( xReport.is() ) + if ( !xReport.is() ) + return; + + bool bEnabled = false; + _rEvent.NewValue >>= bEnabled; + if ( !bEnabled ) + return; + + std::unique_ptr xParent = m_xTreeView->make_iterator(); + bool bParent = find(xReport, *xParent); + if (!bParent) + xParent.reset(); + if ( _rEvent.PropertyName == PROPERTY_REPORTHEADERON ) { - bool bEnabled = false; - _rEvent.NewValue >>= bEnabled; - if ( bEnabled ) - { - std::unique_ptr xParent = m_xTreeView->make_iterator(); - bool bParent = find(xReport, *xParent); - if (!bParent) - xParent.reset(); - if ( _rEvent.PropertyName == PROPERTY_REPORTHEADERON ) - { - sal_uLong nPos = xReport->getReportHeaderOn() ? 2 : 1; - traverseSection(xReport->getReportHeader(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,nPos); - } - else if ( _rEvent.PropertyName == PROPERTY_PAGEHEADERON ) - { - traverseSection(xReport->getPageHeader(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER,1); - } - else if ( _rEvent.PropertyName == PROPERTY_PAGEFOOTERON ) - traverseSection(xReport->getPageFooter(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER); - else if ( _rEvent.PropertyName == PROPERTY_REPORTFOOTERON ) - { - int nPos = -1; - if (xReport->getPageFooterOn() && xParent) - nPos = m_xTreeView->iter_n_children(*xParent) - 1; - traverseSection(xReport->getReportFooter(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,nPos); - } - } + sal_uLong nPos = xReport->getReportHeaderOn() ? 2 : 1; + traverseSection(xReport->getReportHeader(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,nPos); + } + else if ( _rEvent.PropertyName == PROPERTY_PAGEHEADERON ) + { + traverseSection(xReport->getPageHeader(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER,1); + } + else if ( _rEvent.PropertyName == PROPERTY_PAGEFOOTERON ) + traverseSection(xReport->getPageFooter(),xParent.get(), RID_SVXBMP_PAGEHEADERFOOTER); + else if ( _rEvent.PropertyName == PROPERTY_REPORTFOOTERON ) + { + int nPos = -1; + if (xReport->getPageFooterOn() && xParent) + nPos = m_xTreeView->iter_n_children(*xParent) - 1; + traverseSection(xReport->getReportFooter(),xParent.get(),RID_SVXBMP_REPORTHEADERFOOTER,nPos); } } diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx index c6ed5b1836d9..52677c9a79f7 100644 --- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx +++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx @@ -230,24 +230,24 @@ void SAL_CALL DataProviderHandler::setPropertyValue(const OUString & PropertyNam void DataProviderHandler::impl_updateChartTitle_throw(const uno::Any& _aValue) { uno::Reference xTitled(m_xChartModel,uno::UNO_QUERY); - if ( xTitled.is() ) + if ( !xTitled.is() ) + return; + + uno::Reference xTitle = xTitled->getTitleObject(); + if ( !xTitle.is() ) { - uno::Reference xTitle = xTitled->getTitleObject(); - if ( !xTitle.is() ) - { - xTitle.set(m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.chart2.Title",m_xContext),uno::UNO_QUERY); - xTitled->setTitleObject(xTitle); - } - if ( xTitle.is() ) - { - uno::Reference< chart2::XFormattedString2> xFormatted = chart2::FormattedString::create(m_xContext); - OUString sStr; - _aValue >>= sStr; - xFormatted->setString(sStr); - uno::Sequence< uno::Reference< chart2::XFormattedString> > aArgs(1); - aArgs[0] = xFormatted; - xTitle->setText(aArgs); - } + xTitle.set(m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.chart2.Title",m_xContext),uno::UNO_QUERY); + xTitled->setTitleObject(xTitle); + } + if ( xTitle.is() ) + { + uno::Reference< chart2::XFormattedString2> xFormatted = chart2::FormattedString::create(m_xContext); + OUString sStr; + _aValue >>= sStr; + xFormatted->setString(sStr); + uno::Sequence< uno::Reference< chart2::XFormattedString> > aArgs(1); + aArgs[0] = xFormatted; + xTitle->setText(aArgs); } } diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx index 34458e378756..71b88359b66b 100644 --- a/reportdesign/source/ui/inspection/GeometryHandler.cxx +++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx @@ -1915,40 +1915,40 @@ bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference< repo void GeometryHandler::loadDefaultFunctions() { - if ( m_aDefaultFunctions.empty() ) - { - m_aCounterFunction.m_bPreEvaluated = false; - m_aCounterFunction.m_sName = RptResId(RID_STR_F_COUNTER); - m_aCounterFunction.m_sFormula = "rpt:[%FunctionName] + 1"; - m_aCounterFunction.m_sSearchString = "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*"; - m_aCounterFunction.m_sInitialFormula.IsPresent = true; - m_aCounterFunction.m_sInitialFormula.Value = "rpt:1"; - - DefaultFunction aDefault; - - aDefault.m_bPreEvaluated = true; - - aDefault.m_sName = RptResId(RID_STR_F_ACCUMULATION); - aDefault.m_sFormula = "rpt:[%Column] + [%FunctionName]"; - aDefault.m_sSearchString = "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"; - aDefault.m_sInitialFormula.IsPresent = true; - aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; - m_aDefaultFunctions.push_back(aDefault); - - aDefault.m_sName = RptResId(RID_STR_F_MINIMUM); - aDefault.m_sFormula = "rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])"; - aDefault.m_sSearchString = "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"; - aDefault.m_sInitialFormula.IsPresent = true; - aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; - m_aDefaultFunctions.push_back(aDefault); - - aDefault.m_sName = RptResId(RID_STR_F_MAXIMUM); - aDefault.m_sFormula = "rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])"; - aDefault.m_sSearchString = "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"; - aDefault.m_sInitialFormula.IsPresent = true; - aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; - m_aDefaultFunctions.push_back(aDefault); - } + if ( !m_aDefaultFunctions.empty() ) + return; + + m_aCounterFunction.m_bPreEvaluated = false; + m_aCounterFunction.m_sName = RptResId(RID_STR_F_COUNTER); + m_aCounterFunction.m_sFormula = "rpt:[%FunctionName] + 1"; + m_aCounterFunction.m_sSearchString = "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*"; + m_aCounterFunction.m_sInitialFormula.IsPresent = true; + m_aCounterFunction.m_sInitialFormula.Value = "rpt:1"; + + DefaultFunction aDefault; + + aDefault.m_bPreEvaluated = true; + + aDefault.m_sName = RptResId(RID_STR_F_ACCUMULATION); + aDefault.m_sFormula = "rpt:[%Column] + [%FunctionName]"; + aDefault.m_sSearchString = "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"; + aDefault.m_sInitialFormula.IsPresent = true; + aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; + m_aDefaultFunctions.push_back(aDefault); + + aDefault.m_sName = RptResId(RID_STR_F_MINIMUM); + aDefault.m_sFormula = "rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])"; + aDefault.m_sSearchString = "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"; + aDefault.m_sInitialFormula.IsPresent = true; + aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; + m_aDefaultFunctions.push_back(aDefault); + + aDefault.m_sName = RptResId(RID_STR_F_MAXIMUM); + aDefault.m_sFormula = "rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])"; + aDefault.m_sSearchString = "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"; + aDefault.m_sInitialFormula.IsPresent = true; + aDefault.m_sInitialFormula.Value = "rpt:[%Column]"; + m_aDefaultFunctions.push_back(aDefault); } void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const OUString& _sFunction,const OUString& _sDataField) @@ -1999,22 +1999,22 @@ void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard& _aGuard void GeometryHandler::removeFunction() { - if ( m_xFunction.is() ) + if ( !m_xFunction.is() ) + return; + + const OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction)); + ::std::pair aFind = m_aFunctionNames.equal_range(sQuotedFunctionName); + while ( aFind.first != aFind.second ) { - const OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction)); - ::std::pair aFind = m_aFunctionNames.equal_range(sQuotedFunctionName); - while ( aFind.first != aFind.second ) + if ( aFind.first->second.first == m_xFunction ) { - if ( aFind.first->second.first == m_xFunction ) - { - uno::Reference< report::XFunctions> xFunctions = aFind.first->second.second->getFunctions(); - xFunctions->removeByIndex(xFunctions->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction) - m_aFunctionNames.erase(aFind.first); - m_bNewFunction = false; - break; - } - ++(aFind.first); + uno::Reference< report::XFunctions> xFunctions = aFind.first->second.second->getFunctions(); + xFunctions->removeByIndex(xFunctions->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction) + m_aFunctionNames.erase(aFind.first); + m_bNewFunction = false; + break; } + ++(aFind.first); } } @@ -2207,34 +2207,34 @@ void SAL_CALL GeometryHandler::disposing(const lang::EventObject& ) void SAL_CALL GeometryHandler::propertyChange(const beans::PropertyChangeEvent& /*evt*/) { ::osl::ResettableMutexGuard aGuard( m_aMutex ); - if ( !m_bIn ) - { - const sal_uInt32 nOldDataFieldType = m_nDataFieldType; - const OUString sOldFunctionName = m_sDefaultFunction; - const OUString sOldScope = m_sScope; - m_sDefaultFunction.clear(); - m_sScope.clear(); - m_nDataFieldType = impl_getDataFieldType_throw(); - if ( UNDEF_DATA == m_nDataFieldType ) - m_nDataFieldType = nOldDataFieldType; - uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ); - lcl_convertFormulaTo(aDataField,aDataField); - OUString sDataField; - aDataField >>= sDataField; - switch(m_nDataFieldType) - { - case FUNCTION: - isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true); - break; - case COUNTER: - impl_isCounterFunction_throw(sDataField,m_sScope); - break; - default: - ; - } + if ( m_bIn ) + return; - resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType); + const sal_uInt32 nOldDataFieldType = m_nDataFieldType; + const OUString sOldFunctionName = m_sDefaultFunction; + const OUString sOldScope = m_sScope; + m_sDefaultFunction.clear(); + m_sScope.clear(); + m_nDataFieldType = impl_getDataFieldType_throw(); + if ( UNDEF_DATA == m_nDataFieldType ) + m_nDataFieldType = nOldDataFieldType; + uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ); + lcl_convertFormulaTo(aDataField,aDataField); + OUString sDataField; + aDataField >>= sDataField; + switch(m_nDataFieldType) + { + case FUNCTION: + isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true); + break; + case COUNTER: + impl_isCounterFunction_throw(sDataField,m_sScope); + break; + default: + ; } + + resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType); } } // namespace rptui diff --git a/reportdesign/source/ui/misc/RptUndo.cxx b/reportdesign/source/ui/misc/RptUndo.cxx index 43ff9cc1d1ac..ce4ba4c4c950 100644 --- a/reportdesign/source/ui/misc/RptUndo.cxx +++ b/reportdesign/source/ui/misc/RptUndo.cxx @@ -69,42 +69,42 @@ namespace void lcl_insertElements(const uno::Reference< report::XSection >& _xSection,const ::std::vector< uno::Reference< drawing::XShape> >& _aControls) { - if ( _xSection.is() ) + if ( !_xSection.is() ) + return; + + ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aIter = _aControls.rbegin(); + ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aEnd = _aControls.rend(); + for (; aIter != aEnd; ++aIter) { - ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aIter = _aControls.rbegin(); - ::std::vector< uno::Reference< drawing::XShape> >::const_reverse_iterator aEnd = _aControls.rend(); - for (; aIter != aEnd; ++aIter) + try { - try - { - const awt::Point aPos = (*aIter)->getPosition(); - const awt::Size aSize = (*aIter)->getSize(); - _xSection->add(*aIter); - (*aIter)->setPosition( aPos ); - (*aIter)->setSize( aSize ); - } - catch(const uno::Exception&) - { - OSL_FAIL("lcl_insertElements:Exception caught!"); - } + const awt::Point aPos = (*aIter)->getPosition(); + const awt::Size aSize = (*aIter)->getSize(); + _xSection->add(*aIter); + (*aIter)->setPosition( aPos ); + (*aIter)->setSize( aSize ); + } + catch(const uno::Exception&) + { + OSL_FAIL("lcl_insertElements:Exception caught!"); } } } void lcl_setValues(const uno::Reference< report::XSection >& _xSection,const ::std::vector< ::std::pair< OUString ,uno::Any> >& _aValues) { - if ( _xSection.is() ) + if ( !_xSection.is() ) + return; + + for (const auto& [rPropName, rValue] : _aValues) { - for (const auto& [rPropName, rValue] : _aValues) + try { - try - { - _xSection->setPropertyValue(rPropName, rValue); - } - catch(const uno::Exception&) - { - OSL_FAIL("lcl_setValues:Exception caught!"); - } + _xSection->setPropertyValue(rPropName, rValue); + } + catch(const uno::Exception&) + { + OSL_FAIL("lcl_setValues:Exception caught!"); } } } @@ -124,27 +124,27 @@ OSectionUndo::OSectionUndo(OReportModel& _rMod OSectionUndo::~OSectionUndo() { - if ( !m_bInserted ) + if ( m_bInserted ) + return; + + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + for (uno::Reference& xShape : m_aControls) { - OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); - for (uno::Reference& xShape : m_aControls) - { - rEnv.RemoveElement(xShape); + rEnv.RemoveElement(xShape); #if OSL_DEBUG_LEVEL > 0 - SvxShape* pShape = comphelper::getUnoTunnelImplementation( xShape ); - SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; - OSL_ENSURE( pShape && pShape->HasSdrObjectOwnership() && pObject && !pObject->IsInserted(), - "OSectionUndo::~OSectionUndo: inconsistency in the shape/object ownership!" ); + SvxShape* pShape = comphelper::getUnoTunnelImplementation( xShape ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; + OSL_ENSURE( pShape && pShape->HasSdrObjectOwnership() && pObject && !pObject->IsInserted(), + "OSectionUndo::~OSectionUndo: inconsistency in the shape/object ownership!" ); #endif - try - { - comphelper::disposeComponent(xShape); - } - catch(const uno::Exception &) - { - OSL_FAIL("Exception caught!"); - } + try + { + comphelper::disposeComponent(xShape); + } + catch(const uno::Exception &) + { + OSL_FAIL("Exception caught!"); } } } diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx index ca66d2062715..4f5e9e1dd12e 100644 --- a/reportdesign/source/ui/misc/statusbarcontroller.cxx +++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx @@ -88,44 +88,44 @@ void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArgumen ::osl::MutexGuard aGuard(m_aMutex); VclPtr< StatusBar > pStatusBar = static_cast(VCLUnoHelper::GetWindow(m_xParentWindow).get()); - if ( pStatusBar ) + if ( !pStatusBar ) + return; + + const sal_uInt16 nCount = pStatusBar->GetItemCount(); + for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos) { - const sal_uInt16 nCount = pStatusBar->GetItemCount(); - for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos) + const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos); + if ( pStatusBar->GetItemCommand(nItemId) == m_aCommandURL ) { - const sal_uInt16 nItemId = pStatusBar->GetItemId(nPos); - if ( pStatusBar->GetItemCommand(nItemId) == m_aCommandURL ) - { - m_nId = nItemId; - break; - } + m_nId = nItemId; + break; } + } - SfxStatusBarControl *pController = nullptr; - if ( m_aCommandURL == ".uno:ZoomSlider" ) - { - m_nSlotId = SID_ATTR_ZOOMSLIDER; - pController = new SvxZoomSliderControl(m_nSlotId,m_nId,*pStatusBar); - } - else if ( m_aCommandURL == ".uno:Zoom" ) - { - m_nSlotId = SID_ATTR_ZOOM; - pController = new SvxZoomStatusBarControl(m_nSlotId,m_nId,*pStatusBar); - } + SfxStatusBarControl *pController = nullptr; + if ( m_aCommandURL == ".uno:ZoomSlider" ) + { + m_nSlotId = SID_ATTR_ZOOMSLIDER; + pController = new SvxZoomSliderControl(m_nSlotId,m_nId,*pStatusBar); + } + else if ( m_aCommandURL == ".uno:Zoom" ) + { + m_nSlotId = SID_ATTR_ZOOM; + pController = new SvxZoomStatusBarControl(m_nSlotId,m_nId,*pStatusBar); + } - if ( pController ) + if ( pController ) + { + m_rController.set( pController ); + if ( m_rController.is() ) { - m_rController.set( pController ); - if ( m_rController.is() ) - { - m_rController->initialize(_rArguments); - m_rController->update(); - } + m_rController->initialize(_rArguments); + m_rController->update(); } - - addStatusListener(m_aCommandURL); - update(); } + + addStatusListener(m_aCommandURL); + update(); } // XStatusListener void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEvent) @@ -133,27 +133,27 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard(m_aMutex); - if ( m_rController.is() ) + if ( !m_rController.is() ) + return; + + if ( m_aCommandURL == ".uno:ZoomSlider" ) { - if ( m_aCommandURL == ".uno:ZoomSlider" ) + Sequence< PropertyValue > aSeq; + if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) { - Sequence< PropertyValue > aSeq; - if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) - { - SvxZoomSliderItem aZoomSlider(100,20,400); - aZoomSlider.PutValue(_aEvent.State, 0); - static_cast(m_rController.get())->StateChanged(m_nSlotId,SfxItemState::DEFAULT,&aZoomSlider); - } + SvxZoomSliderItem aZoomSlider(100,20,400); + aZoomSlider.PutValue(_aEvent.State, 0); + static_cast(m_rController.get())->StateChanged(m_nSlotId,SfxItemState::DEFAULT,&aZoomSlider); } - else if ( m_aCommandURL == ".uno:Zoom" ) + } + else if ( m_aCommandURL == ".uno:Zoom" ) + { + Sequence< PropertyValue > aSeq; + if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) { - Sequence< PropertyValue > aSeq; - if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) - { - SvxZoomItem aZoom; - aZoom.PutValue(_aEvent.State, 0 ); - static_cast(m_rController.get())->StateChanged(m_nSlotId,SfxItemState::DEFAULT,&aZoom); - } + SvxZoomItem aZoom; + aZoom.PutValue(_aEvent.State, 0 ); + static_cast(m_rController.get())->StateChanged(m_nSlotId,SfxItemState::DEFAULT,&aZoom); } } } diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index 0f54a3203e6f..dbec63a37101 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -432,24 +432,24 @@ void ODesignView::togglePropertyBrowser(bool _bToggleOn) static_cast(m_pTaskPane.get())->setPropertyBrowser(m_pPropWin); notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::AddWindow)); } - if ( m_pPropWin && _bToggleOn != m_pPropWin->IsVisible() ) - { - if ( !m_pCurrentView && !m_xReportComponent.is() ) - m_xReportComponent = getController().getReportDefinition(); + if ( !(m_pPropWin && _bToggleOn != m_pPropWin->IsVisible()) ) + return; - const bool bWillBeVisible = _bToggleOn; - m_pPropWin->Show(bWillBeVisible); - m_pTaskPane->Show(bWillBeVisible); - m_pTaskPane->Invalidate(); + if ( !m_pCurrentView && !m_xReportComponent.is() ) + m_xReportComponent = getController().getReportDefinition(); - if ( bWillBeVisible ) - m_aSplitWin->InsertItem( TASKPANE_ID, m_pTaskPane,START_SIZE_TASKPANE, SPLITWINDOW_APPEND, COLSET_ID, SplitWindowItemFlags::PercentSize); - else - m_aSplitWin->RemoveItem(TASKPANE_ID); + const bool bWillBeVisible = _bToggleOn; + m_pPropWin->Show(bWillBeVisible); + m_pTaskPane->Show(bWillBeVisible); + m_pTaskPane->Invalidate(); - if ( bWillBeVisible ) - m_aMarkIdle.Start(); - } + if ( bWillBeVisible ) + m_aSplitWin->InsertItem( TASKPANE_ID, m_pTaskPane,START_SIZE_TASKPANE, SPLITWINDOW_APPEND, COLSET_ID, SplitWindowItemFlags::PercentSize); + else + m_aSplitWin->RemoveItem(TASKPANE_ID); + + if ( bWillBeVisible ) + m_aMarkIdle.Start(); } void ODesignView::showProperties(const uno::Reference< uno::XInterface>& _xReportComponent) diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index c3b761e4fce8..ee1e90d4cf83 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -188,32 +188,32 @@ namespace { void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId) { - if ( _xReportControlFormat.is() ) - { - try - { - awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor(); - switch(_nId) - { - case SID_ATTR_CHAR_WEIGHT: - aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight; - break; - case SID_ATTR_CHAR_POSTURE: - aFontDescriptor.Slant = static_cast(static_cast(awt::FontSlant_ITALIC) - static_cast(aFontDescriptor.Slant)); - break; - case SID_ATTR_CHAR_UNDERLINE: - aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline; - break; - default: - OSL_FAIL("Illegal value in default!"); - break; - } + if ( !_xReportControlFormat.is() ) + return; - _xReportControlFormat->setFontDescriptor(aFontDescriptor); - } - catch(const beans::UnknownPropertyException&) + try + { + awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor(); + switch(_nId) { + case SID_ATTR_CHAR_WEIGHT: + aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight; + break; + case SID_ATTR_CHAR_POSTURE: + aFontDescriptor.Slant = static_cast(static_cast(awt::FontSlant_ITALIC) - static_cast(aFontDescriptor.Slant)); + break; + case SID_ATTR_CHAR_UNDERLINE: + aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline; + break; + default: + OSL_FAIL("Illegal value in default!"); + break; } + + _xReportControlFormat->setFontDescriptor(aFontDescriptor); + } + catch(const beans::UnknownPropertyException&) + { } } } @@ -2063,70 +2063,70 @@ void OReportController::impl_onModifyChanged() void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager) { - if ( _xLayoutManager.is() ) + if ( !_xLayoutManager.is() ) + return; + + static const OUStringLiteral s_sMenu[] = { + "private:resource/statusbar/statusbar" + ,"private:resource/toolbar/reportcontrols" + ,"private:resource/toolbar/drawbar" + ,"private:resource/toolbar/Formatting" + ,"private:resource/toolbar/alignmentbar" + ,"private:resource/toolbar/sectionalignmentbar" + ,"private:resource/toolbar/resizebar" + ,"private:resource/toolbar/sectionshrinkbar" + }; + for (const auto & i : s_sMenu) { - static const OUStringLiteral s_sMenu[] = { - "private:resource/statusbar/statusbar" - ,"private:resource/toolbar/reportcontrols" - ,"private:resource/toolbar/drawbar" - ,"private:resource/toolbar/Formatting" - ,"private:resource/toolbar/alignmentbar" - ,"private:resource/toolbar/sectionalignmentbar" - ,"private:resource/toolbar/resizebar" - ,"private:resource/toolbar/sectionshrinkbar" - }; - for (const auto & i : s_sMenu) - { - _xLayoutManager->createElement( i ); - _xLayoutManager->requestElement( i ); - } + _xLayoutManager->createElement( i ); + _xLayoutManager->requestElement( i ); } } void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow) { uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY); - if ( xGroup.is() ) + if ( !xGroup.is() ) + return; + + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( getMutex() ); + sal_Int32 nGroupPos = 0; + _rEvent.Accessor >>= nGroupPos; + + if ( _bShow ) { - SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( getMutex() ); - sal_Int32 nGroupPos = 0; - _rEvent.Accessor >>= nGroupPos; + xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast(this)); + xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast(this)); + } + else + { + xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast(this)); + xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast(this)); + } - if ( _bShow ) + if ( xGroup->getHeaderOn() ) + { + groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow); + if (_bShow) { - xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast(this)); - xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast(this)); + m_pReportControllerObserver->AddSection(xGroup->getHeader()); } else { - xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast(this)); - xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast(this)); + m_pReportControllerObserver->RemoveSection(xGroup->getHeader()); } - - if ( xGroup->getHeaderOn() ) + } + if ( xGroup->getFooterOn() ) + { + groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow); + if (_bShow) { - groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow); - if (_bShow) - { - m_pReportControllerObserver->AddSection(xGroup->getHeader()); - } - else - { - m_pReportControllerObserver->RemoveSection(xGroup->getHeader()); - } + m_pReportControllerObserver->AddSection(xGroup->getFooter()); } - if ( xGroup->getFooterOn() ) + else { - groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow); - if (_bShow) - { - m_pReportControllerObserver->AddSection(xGroup->getFooter()); - } - else - { - m_pReportControllerObserver->RemoveSection(xGroup->getFooter()); - } + m_pReportControllerObserver->RemoveSection(xGroup->getFooter()); } } } @@ -2570,21 +2570,20 @@ sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGro void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint) { const DlgEdHint* pDlgEdHint = dynamic_cast(&_rHint); - if (pDlgEdHint && pDlgEdHint->GetKind() == RPTUI_HINT_SELECTIONCHANGED) - { - const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount(); - if ( m_nSelectionCount != nSelectionCount ) - { - m_nSelectionCount = nSelectionCount; - InvalidateAll(); - } - lang::EventObject aEvent(*this); - m_aSelectionListeners.forEach( - [&aEvent] (uno::Reference const& xListener) { - return xListener->selectionChanged(aEvent); - }); + if (!(pDlgEdHint && pDlgEdHint->GetKind() == RPTUI_HINT_SELECTIONCHANGED)) + return; + const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount(); + if ( m_nSelectionCount != nSelectionCount ) + { + m_nSelectionCount = nSelectionCount; + InvalidateAll(); } + lang::EventObject aEvent(*this); + m_aSelectionListeners.forEach( + [&aEvent] (uno::Reference const& xListener) { + return xListener->selectionChanged(aEvent); + }); } void OReportController::executeMethodWithUndo(const char* pUndoStrId,const ::std::function& _pMemfun) @@ -3641,30 +3640,30 @@ OSectionView* OReportController::getCurrentSectionView() const void OReportController::changeZOrder(sal_Int32 _nId) { OSectionView* pSectionView = getCurrentSectionView(); - if ( pSectionView ) + if ( !pSectionView ) + return; + + switch(_nId) { - switch(_nId) - { - case SID_FRAME_TO_BOTTOM: - pSectionView->PutMarkedToBtm(); - break; - case SID_FRAME_TO_TOP: - pSectionView->PutMarkedToTop(); - break; - case SID_FRAME_DOWN: - pSectionView->MovMarkedToBtm(); - break; - case SID_FRAME_UP: - pSectionView->MovMarkedToTop(); - break; + case SID_FRAME_TO_BOTTOM: + pSectionView->PutMarkedToBtm(); + break; + case SID_FRAME_TO_TOP: + pSectionView->PutMarkedToTop(); + break; + case SID_FRAME_DOWN: + pSectionView->MovMarkedToBtm(); + break; + case SID_FRAME_UP: + pSectionView->MovMarkedToTop(); + break; - case SID_OBJECT_HEAVEN: - pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT ); - break; - case SID_OBJECT_HELL: - pSectionView->SetMarkedToLayer( RPT_LAYER_BACK ); - break; - } + case SID_OBJECT_HEAVEN: + pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT ); + break; + case SID_OBJECT_HELL: + pSectionView->SetMarkedToLayer( RPT_LAYER_BACK ); + break; } } @@ -3774,95 +3773,95 @@ void OReportController::switchReportSection(const sal_Int16 _nId) { OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!"); - if ( m_xReportDefinition.is() ) - { - const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); - const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn(); + if ( !m_xReportDefinition.is() ) + return; - std::unique_ptr< UndoContext > pUndoContext; - if ( SID_REPORTHEADERFOOTER == _nId ) - { - const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); - pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); - - addUndoAction(std::make_unique(*m_aReportModel,SID_REPORTHEADER_WITHOUT_UNDO - ,::std::mem_fn(&OReportHelper::getReportHeader) - ,m_xReportDefinition - ,bSwitchOn ? Inserted : Removed - )); - - addUndoAction(std::make_unique(*m_aReportModel,SID_REPORTFOOTER_WITHOUT_UNDO - ,::std::mem_fn(&OReportHelper::getReportFooter) - ,m_xReportDefinition - ,bSwitchOn ? Inserted : Removed - )); - } + const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn(); - switch( _nId ) - { - case SID_REPORTHEADER_WITHOUT_UNDO: - m_xReportDefinition->setReportHeaderOn( bSwitchOn ); - break; - case SID_REPORTFOOTER_WITHOUT_UNDO: - m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() ); - break; - case SID_REPORTHEADERFOOTER: - m_xReportDefinition->setReportHeaderOn( bSwitchOn ); - m_xReportDefinition->setReportFooterOn( bSwitchOn ); - break; - } + std::unique_ptr< UndoContext > pUndoContext; + if ( SID_REPORTHEADERFOOTER == _nId ) + { + const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); + pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); + + addUndoAction(std::make_unique(*m_aReportModel,SID_REPORTHEADER_WITHOUT_UNDO + ,::std::mem_fn(&OReportHelper::getReportHeader) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + )); + + addUndoAction(std::make_unique(*m_aReportModel,SID_REPORTFOOTER_WITHOUT_UNDO + ,::std::mem_fn(&OReportHelper::getReportFooter) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + )); + } - if ( SID_REPORTHEADERFOOTER == _nId ) - pUndoContext.reset(); - getView()->Resize(); + switch( _nId ) + { + case SID_REPORTHEADER_WITHOUT_UNDO: + m_xReportDefinition->setReportHeaderOn( bSwitchOn ); + break; + case SID_REPORTFOOTER_WITHOUT_UNDO: + m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() ); + break; + case SID_REPORTHEADERFOOTER: + m_xReportDefinition->setReportHeaderOn( bSwitchOn ); + m_xReportDefinition->setReportFooterOn( bSwitchOn ); + break; } + + if ( SID_REPORTHEADERFOOTER == _nId ) + pUndoContext.reset(); + getView()->Resize(); } void OReportController::switchPageSection(const sal_Int16 _nId) { OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!"); - if ( m_xReportDefinition.is() ) - { - const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); - const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn(); + if ( !m_xReportDefinition.is() ) + return; - std::unique_ptr< UndoContext > pUndoContext; - if ( SID_PAGEHEADERFOOTER == _nId ) - { - const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); - pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); - - addUndoAction(std::make_unique(*m_aReportModel - ,SID_PAGEHEADER_WITHOUT_UNDO - ,::std::mem_fn(&OReportHelper::getPageHeader) - ,m_xReportDefinition - ,bSwitchOn ? Inserted : Removed - )); - - addUndoAction(std::make_unique(*m_aReportModel - ,SID_PAGEFOOTER_WITHOUT_UNDO - ,::std::mem_fn(&OReportHelper::getPageFooter) - ,m_xReportDefinition - ,bSwitchOn ? Inserted : Removed - )); - } - switch( _nId ) - { - case SID_PAGEHEADER_WITHOUT_UNDO: - m_xReportDefinition->setPageHeaderOn( bSwitchOn ); - break; - case SID_PAGEFOOTER_WITHOUT_UNDO: - m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() ); - break; - case SID_PAGEHEADERFOOTER: - m_xReportDefinition->setPageHeaderOn( bSwitchOn ); - m_xReportDefinition->setPageFooterOn( bSwitchOn ); - break; - } - if ( SID_PAGEHEADERFOOTER == _nId ) - pUndoContext.reset(); - getView()->Resize(); + const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn(); + + std::unique_ptr< UndoContext > pUndoContext; + if ( SID_PAGEHEADERFOOTER == _nId ) + { + const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); + pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) ); + + addUndoAction(std::make_unique(*m_aReportModel + ,SID_PAGEHEADER_WITHOUT_UNDO + ,::std::mem_fn(&OReportHelper::getPageHeader) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + )); + + addUndoAction(std::make_unique(*m_aReportModel + ,SID_PAGEFOOTER_WITHOUT_UNDO + ,::std::mem_fn(&OReportHelper::getPageFooter) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + )); + } + switch( _nId ) + { + case SID_PAGEHEADER_WITHOUT_UNDO: + m_xReportDefinition->setPageHeaderOn( bSwitchOn ); + break; + case SID_PAGEFOOTER_WITHOUT_UNDO: + m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() ); + break; + case SID_PAGEHEADERFOOTER: + m_xReportDefinition->setPageHeaderOn( bSwitchOn ); + m_xReportDefinition->setPageFooterOn( bSwitchOn ); + break; } + if ( SID_PAGEHEADERFOOTER == _nId ) + pUndoContext.reset(); + getView()->Resize(); } void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs) @@ -3911,32 +3910,32 @@ void OReportController::modifyGroup(const bool _bAppend, const Sequence< Propert void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs) { - if ( m_xReportDefinition.is() ) - { - const SequenceAsHashMap aMap(_aArgs); - const bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? OUString(PROPERTY_HEADERON) : OUString(PROPERTY_FOOTERON), false); - uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>()); - if ( xGroup.is() ) - { - const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv()); - if ( _bUndo ) - addUndoAction(std::make_unique(*m_aReportModel - ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO - ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter) - ,xGroup - ,bSwitchOn ? Inserted : Removed - , ( _bHeader ? - (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER) - :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER) - ) - )); - - if ( _bHeader ) - xGroup->setHeaderOn( bSwitchOn ); - else - xGroup->setFooterOn( bSwitchOn ); - } - } + if ( !m_xReportDefinition.is() ) + return; + + const SequenceAsHashMap aMap(_aArgs); + const bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? OUString(PROPERTY_HEADERON) : OUString(PROPERTY_FOOTERON), false); + uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>()); + if ( !xGroup.is() ) + return; + + const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv()); + if ( _bUndo ) + addUndoAction(std::make_unique(*m_aReportModel + ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO + ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter) + ,xGroup + ,bSwitchOn ? Inserted : Removed + , ( _bHeader ? + (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER) + :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER) + ) + )); + + if ( _bHeader ) + xGroup->setHeaderOn( bSwitchOn ); + else + xGroup->setFooterOn( bSwitchOn ); } void OReportController::collapseSection(const bool _bCollapse) @@ -3974,47 +3973,47 @@ void OReportController::createDefaultControl(const uno::Sequence< beans::Propert if ( !xSection.is() ) xSection = m_xReportDefinition->getDetail(); - if ( xSection.is() ) + if ( !xSection.is() ) + return; + + const OUString sKeyModifier("KeyModifier"); + const beans::PropertyValue* pIter = _aArgs.getConstArray(); + const beans::PropertyValue* pEnd = pIter + _aArgs.getLength(); + const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter, pEnd, + [&sKeyModifier] (const beans::PropertyValue& x) -> bool { + return x.Name == sKeyModifier; + }); + sal_Int16 nKeyModifier = 0; + if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) ) { - const OUString sKeyModifier("KeyModifier"); - const beans::PropertyValue* pIter = _aArgs.getConstArray(); - const beans::PropertyValue* pEnd = pIter + _aArgs.getLength(); - const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter, pEnd, - [&sKeyModifier] (const beans::PropertyValue& x) -> bool { - return x.Name == sKeyModifier; - }); - sal_Int16 nKeyModifier = 0; - if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) ) - { - Sequence< PropertyValue > aCreateArgs; - getDesignView()->unmarkAllObjects(); - createControl(aCreateArgs,xSection,OUString(),getDesignView()->GetInsertObj()); - } + Sequence< PropertyValue > aCreateArgs; + getDesignView()->unmarkAllObjects(); + createControl(aCreateArgs,xSection,OUString(),getDesignView()->GetInsertObj()); } } void OReportController::checkChartEnabled() { - if ( !m_bChartEnabledAsked ) - { - m_bChartEnabledAsked = true; - const OUString sConfigName( "/org.openoffice.Office.ReportDesign" ); - const OUString sPropertyName( "UserData/Chart" ); + if ( m_bChartEnabledAsked ) + return; - try - { - ::utl::OConfigurationTreeRoot aConfiguration( - ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, sConfigName ) ); + m_bChartEnabledAsked = true; + const OUString sConfigName( "/org.openoffice.Office.ReportDesign" ); + const OUString sPropertyName( "UserData/Chart" ); - bool bChartEnabled = false; - if ( aConfiguration.hasByHierarchicalName(sPropertyName) ) - aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled; - m_bChartEnabled = bChartEnabled; - } - catch(const Exception&) - { - } + try + { + ::utl::OConfigurationTreeRoot aConfiguration( + ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, sConfigName ) ); + + bool bChartEnabled = false; + if ( aConfiguration.hasByHierarchicalName(sPropertyName) ) + aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled; + m_bChartEnabled = bChartEnabled; + } + catch(const Exception&) + { } } @@ -4086,37 +4085,37 @@ bool OReportController::isUiVisible() const void OReportController::impl_fillState_nothrow(const OUString& _sProperty,dbaui::FeatureState& _rState) const { _rState.bEnabled = isEditable(); - if ( _rState.bEnabled ) + if ( !_rState.bEnabled ) + return; + + ::std::vector< uno::Reference< uno::XInterface > > aSelection; + getDesignView()->fillControlModelSelection(aSelection); + _rState.bEnabled = !aSelection.empty(); + if ( !_rState.bEnabled ) + return; + + uno::Any aTemp; + ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin(); + for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter) { - ::std::vector< uno::Reference< uno::XInterface > > aSelection; - getDesignView()->fillControlModelSelection(aSelection); - _rState.bEnabled = !aSelection.empty(); - if ( _rState.bEnabled ) + uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY); + try { - uno::Any aTemp; - ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin(); - for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter) + uno::Any aTemp2 = xProp->getPropertyValue(_sProperty); + if ( aIter == aSelection.begin() ) { - uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY); - try - { - uno::Any aTemp2 = xProp->getPropertyValue(_sProperty); - if ( aIter == aSelection.begin() ) - { - aTemp = aTemp2; - } - else if ( aTemp != aTemp2 ) - break; - } - catch(const beans::UnknownPropertyException&) - { - _rState.bEnabled = false; - } + aTemp = aTemp2; } - if ( aIter == aSelection.end() ) - _rState.aValue = aTemp; + else if ( aTemp != aTemp2 ) + break; + } + catch(const beans::UnknownPropertyException&) + { + _rState.bEnabled = false; } } + if ( aIter == aSelection.end() ) + _rState.aValue = aTemp; } void OReportController::impl_zoom_nothrow() diff --git a/reportdesign/source/ui/report/ReportControllerObserver.cxx b/reportdesign/source/ui/report/ReportControllerObserver.cxx index d388239cb626..d379c859d09b 100644 --- a/reportdesign/source/ui/report/ReportControllerObserver.cxx +++ b/reportdesign/source/ui/report/ReportControllerObserver.cxx @@ -83,35 +83,35 @@ public: { VclEventId nEvent = _rEvt.GetId(); - if (nEvent == VclEventId::ApplicationDataChanged ) + if (nEvent != VclEventId::ApplicationDataChanged ) + return; + + DataChangedEvent* pData = static_cast(static_cast(_rEvt).GetData()); + if ( !(pData && ((( pData->GetType() == DataChangedEventType::SETTINGS ) || + ( pData->GetType() == DataChangedEventType::DISPLAY )) && + ( pData->GetFlags() & AllSettingsFlags::STYLE )))) + return; + + OEnvLock aLock(*this); + + // send all Section Objects a 'tingle' + // maybe they need a change in format, color, etc + for (const uno::Reference& xChild : m_pImpl->m_aSections) { - DataChangedEvent* pData = static_cast(static_cast(_rEvt).GetData()); - if ( pData && ((( pData->GetType() == DataChangedEventType::SETTINGS ) || - ( pData->GetType() == DataChangedEventType::DISPLAY )) && - ( pData->GetFlags() & AllSettingsFlags::STYLE ))) + if (xChild.is()) { - OEnvLock aLock(*this); - - // send all Section Objects a 'tingle' - // maybe they need a change in format, color, etc - for (const uno::Reference& xChild : m_pImpl->m_aSections) + uno::Reference xSection(xChild, uno::UNO_QUERY); + if (xSection.is()) { - if (xChild.is()) + const sal_Int32 nCount = xSection->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) { - uno::Reference xSection(xChild, uno::UNO_QUERY); - if (xSection.is()) + const uno::Any aObj = xSection->getByIndex(i); + uno::Reference < report::XReportComponent > xReportComponent(aObj, uno::UNO_QUERY); + if (xReportComponent.is()) { - const sal_Int32 nCount = xSection->getCount(); - for (sal_Int32 i = 0; i < nCount; ++i) - { - const uno::Any aObj = xSection->getByIndex(i); - uno::Reference < report::XReportComponent > xReportComponent(aObj, uno::UNO_QUERY); - if (xReportComponent.is()) - { - m_aFormattedFieldBeautifier.handle(xReportComponent); - m_aFixedTextColor.handle(xReportComponent); - } - } + m_aFormattedFieldBeautifier.handle(xReportComponent); + m_aFixedTextColor.handle(xReportComponent); } } } diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 7991fea3f1b5..689f0a0c67f3 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -139,33 +139,33 @@ void OReportSection::Paint( vcl::RenderContext& rRenderContext, const tools::Rec { Window::Paint(rRenderContext, rRect); - if ( m_pView && m_nPaintEntranceCount == 0) - { - ++m_nPaintEntranceCount; - // repaint, get PageView and prepare Region - SdrPageView* pPgView = m_pView->GetSdrPageView(); - const vcl::Region aPaintRectRegion(rRect); + if ( !(m_pView && m_nPaintEntranceCount == 0)) + return; - // #i74769# - SdrPaintWindow* pTargetPaintWindow = nullptr; + ++m_nPaintEntranceCount; + // repaint, get PageView and prepare Region + SdrPageView* pPgView = m_pView->GetSdrPageView(); + const vcl::Region aPaintRectRegion(rRect); - // mark repaint start - if (pPgView) - { - pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(this, aPaintRectRegion); - OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)"); - // draw background self using wallpaper - OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice(); - rTargetOutDev.DrawWallpaper(rRect, Wallpaper(pPgView->GetApplicationDocumentColor())); - - // do paint (unbuffered) and mark repaint end - pPgView->DrawLayer(RPT_LAYER_FRONT, &rRenderContext); - pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true); - } + // #i74769# + SdrPaintWindow* pTargetPaintWindow = nullptr; - m_pView->CompleteRedraw(&rRenderContext, aPaintRectRegion); - --m_nPaintEntranceCount; + // mark repaint start + if (pPgView) + { + pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(this, aPaintRectRegion); + OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)"); + // draw background self using wallpaper + OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice(); + rTargetOutDev.DrawWallpaper(rRect, Wallpaper(pPgView->GetApplicationDocumentColor())); + + // do paint (unbuffered) and mark repaint end + pPgView->DrawLayer(RPT_LAYER_FRONT, &rRenderContext); + pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true); } + + m_pView->CompleteRedraw(&rRenderContext, aPaintRectRegion); + --m_nPaintEntranceCount; } void OReportSection::fill() @@ -236,58 +236,58 @@ void OReportSection::fill() void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce) { OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!"); - if ( m_xSection.is() && _aAllreadyCopiedObjects.hasElements() ) - { - // stop all drawing actions - m_pView->BrkAction(); + if ( !(m_xSection.is() && _aAllreadyCopiedObjects.hasElements()) ) + return; - // unmark all objects - m_pView->UnmarkAll(); - const OUString sSectionName = m_xSection->getName(); - for(const beans::NamedValue& rObject : _aAllreadyCopiedObjects) + // stop all drawing actions + m_pView->BrkAction(); + + // unmark all objects + m_pView->UnmarkAll(); + const OUString sSectionName = m_xSection->getName(); + for(const beans::NamedValue& rObject : _aAllreadyCopiedObjects) + { + if ( _bForce || rObject.Name == sSectionName) { - if ( _bForce || rObject.Name == sSectionName) + try { - try + uno::Sequence< uno::Reference > aCopies; + rObject.Value >>= aCopies; + for (const uno::Reference& rCopy : std::as_const(aCopies)) { - uno::Sequence< uno::Reference > aCopies; - rObject.Value >>= aCopies; - for (const uno::Reference& rCopy : std::as_const(aCopies)) + SvxShape* pShape = comphelper::getUnoTunnelImplementation( rCopy ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; + if ( pObject ) { - SvxShape* pShape = comphelper::getUnoTunnelImplementation( rCopy ); - SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; - if ( pObject ) + // Clone to target SdrModel + SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel)); + m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE); + tools::Rectangle aRet(VCLPoint(rCopy->getPosition()),VCLSize(rCopy->getSize())); + aRet.setHeight(aRet.getHeight() + 1); + aRet.setWidth(aRet.getWidth() + 1); + bool bOverlapping = true; + while ( bOverlapping ) { - // Clone to target SdrModel - SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel)); - m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE); - tools::Rectangle aRet(VCLPoint(rCopy->getPosition()),VCLSize(rCopy->getSize())); - aRet.setHeight(aRet.getHeight() + 1); - aRet.setWidth(aRet.getWidth() + 1); - bool bOverlapping = true; - while ( bOverlapping ) + bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj) != nullptr; + if ( bOverlapping ) { - bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj) != nullptr; - if ( bOverlapping ) - { - aRet.Move(0,aRet.getHeight()+1); - pNewObj->SetLogicRect(aRet); - } + aRet.Move(0,aRet.getHeight()+1); + pNewObj->SetLogicRect(aRet); } - m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) ); - m_pView->MarkObj( pNewObj, m_pView->GetSdrPageView() ); - if ( m_xSection.is() && (o3tl::make_unsigned(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) ) - m_xSection->setHeight(aRet.getHeight() + aRet.Top()); } + m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) ); + m_pView->MarkObj( pNewObj, m_pView->GetSdrPageView() ); + if ( m_xSection.is() && (o3tl::make_unsigned(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) ) + m_xSection->setHeight(aRet.getHeight() + aRet.Top()); } } - catch(uno::Exception&) - { - OSL_FAIL("Exception caught while pasting a new object!"); - } - if ( !_bForce ) - break; } + catch(uno::Exception&) + { + OSL_FAIL("Exception caught while pasting a new object!"); + } + if ( !_bForce ) + break; } } } @@ -303,20 +303,20 @@ void OReportSection::Delete() void OReportSection::SetMode( DlgEdMode eNewMode ) { - if ( eNewMode != m_eMode ) + if ( eNewMode == m_eMode ) + return; + + if ( eNewMode == DlgEdMode::Insert ) { - if ( eNewMode == DlgEdMode::Insert ) - { - m_pFunc.reset(new DlgEdFuncInsert( this )); - } - else - { - m_pFunc.reset(new DlgEdFuncSelect( this )); - } - m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) ); - m_pModel->SetReadOnly(false); - m_eMode = eNewMode; + m_pFunc.reset(new DlgEdFuncInsert( this )); + } + else + { + m_pFunc.reset(new DlgEdFuncSelect( this )); } + m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) ); + m_pModel->SetReadOnly(false); + m_eMode = eNewMode; } void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects) @@ -402,20 +402,20 @@ void OReportSection::SetGridVisible(bool _bVisible) void OReportSection::SelectAll(const sal_uInt16 _nObjectType) { - if ( m_pView ) + if ( !m_pView ) + return; + + if ( _nObjectType == OBJ_NONE ) + m_pView->MarkAllObj(); + else { - if ( _nObjectType == OBJ_NONE ) - m_pView->MarkAllObj(); - else + m_pView->UnmarkAll(); + SdrObjListIter aIter(m_pPage,SdrIterMode::DeepNoGroups); + SdrObject* pObjIter = nullptr; + while( (pObjIter = aIter.Next()) != nullptr ) { - m_pView->UnmarkAll(); - SdrObjListIter aIter(m_pPage,SdrIterMode::DeepNoGroups); - SdrObject* pObjIter = nullptr; - while( (pObjIter = aIter.Next()) != nullptr ) - { - if ( pObjIter->GetObjIdentifier() == _nObjectType ) - m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() ); - } + if ( pObjIter->GetObjIdentifier() == _nObjectType ) + m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() ); } } } @@ -423,74 +423,74 @@ void OReportSection::SelectAll(const sal_uInt16 _nObjectType) void OReportSection::Command( const CommandEvent& _rCEvt ) { Window::Command(_rCEvt); - if (_rCEvt.GetCommand() == CommandEventId::ContextMenu) - { - OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController(); - uno::Reference xFrame = rController.getFrame(); - css::uno::Sequence aArgs { - css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("report"))), - css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame)), - css::uno::makeAny(comphelper::makePropertyValue("IsContextMenu", true)) - }; - - css::uno::Reference xContext(rController.getORB()); - css::uno::Reference xMenuController( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY); - - if (!xMenuController.is()) - return; - - rtl::Reference xPopupMenu(new VCLXPopupMenu); - xMenuController->setPopupMenu(xPopupMenu.get()); - - Point aPos = _rCEvt.GetMousePosPixel(); - m_pView->EndAction(); - static_cast(xPopupMenu->GetMenu())->Execute(this, aPos); - - css::uno::Reference xComponent(xMenuController, css::uno::UNO_QUERY); - xComponent->dispose(); - } + if (_rCEvt.GetCommand() != CommandEventId::ContextMenu) + return; + + OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController(); + uno::Reference xFrame = rController.getFrame(); + css::uno::Sequence aArgs { + css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("report"))), + css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame)), + css::uno::makeAny(comphelper::makePropertyValue("IsContextMenu", true)) + }; + + css::uno::Reference xContext(rController.getORB()); + css::uno::Reference xMenuController( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY); + + if (!xMenuController.is()) + return; + + rtl::Reference xPopupMenu(new VCLXPopupMenu); + xMenuController->setPopupMenu(xPopupMenu.get()); + + Point aPos = _rCEvt.GetMousePosPixel(); + m_pView->EndAction(); + static_cast(xPopupMenu->GetMenu())->Execute(this, aPos); + + css::uno::Reference xComponent(xMenuController, css::uno::UNO_QUERY); + xComponent->dispose(); } void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) { - if ( m_xSection.is() ) + if ( !m_xSection.is() ) + return; + + if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName ) { - if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName ) + sal_Int32 nColor = m_xSection->getBackColor(); + if ( nColor == static_cast(COL_TRANSPARENT) ) + nColor = getStyleProperty(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); + m_pView->SetApplicationDocumentColor(Color(nColor)); + Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase); + } + else + { + uno::Reference xReportDefinition = m_xSection->getReportDefinition(); + const sal_Int32 nLeftMargin = getStyleProperty(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty(xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty(xReportDefinition,PROPERTY_PAPERSIZE).Width; + + if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN ) { - sal_Int32 nColor = m_xSection->getBackColor(); - if ( nColor == static_cast(COL_TRANSPARENT) ) - nColor = getStyleProperty(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); - m_pView->SetApplicationDocumentColor(Color(nColor)); - Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase); + m_pPage->SetLeftBorder(nLeftMargin); } - else + else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN ) { - uno::Reference xReportDefinition = m_xSection->getReportDefinition(); - const sal_Int32 nLeftMargin = getStyleProperty(xReportDefinition,PROPERTY_LEFTMARGIN); - const sal_Int32 nRightMargin = getStyleProperty(xReportDefinition,PROPERTY_RIGHTMARGIN); - const sal_Int32 nPaperWidth = getStyleProperty(xReportDefinition,PROPERTY_PAPERSIZE).Width; - - if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN ) - { - m_pPage->SetLeftBorder(nLeftMargin); - } - else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN ) - { - m_pPage->SetRightBorder(nRightMargin); - } - const Size aOldPageSize = m_pPage->GetSize(); - sal_Int32 nNewHeight = 5*m_xSection->getHeight(); - if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != aOldPageSize.Width() ) - { - m_pPage->SetSize( Size( nPaperWidth,nNewHeight) ); - const Size aPageSize = m_pPage->GetSize(); - m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) ); - } - impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin); - m_pParent->Invalidate(InvalidateFlags::Update | InvalidateFlags::Transparent); + m_pPage->SetRightBorder(nRightMargin); + } + const Size aOldPageSize = m_pPage->GetSize(); + sal_Int32 nNewHeight = 5*m_xSection->getHeight(); + if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != aOldPageSize.Width() ) + { + m_pPage->SetSize( Size( nPaperWidth,nNewHeight) ); + const Size aPageSize = m_pPage->GetSize(); + m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) ); } + impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin); + m_pParent->Invalidate(InvalidateFlags::Update | InvalidateFlags::Transparent); } } void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin) @@ -655,20 +655,20 @@ uno::Reference< report::XReportComponent > OReportSection::getCurrentControlMode void OReportSection::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const { - if ( m_pView ) - { - const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList(); - const size_t nMarkCount = rMarkList.GetMarkCount(); + if ( !m_pView ) + return; + + const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList(); + const size_t nMarkCount = rMarkList.GetMarkCount(); - for (size_t i=0; i < nMarkCount; ++i) + for (size_t i=0; i < nMarkCount; ++i) + { + const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); + const OObjectBase* pObj = dynamic_cast(pDlgEdObj); + if ( pObj ) { - const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); - const OObjectBase* pObj = dynamic_cast(pDlgEdObj); - if ( pObj ) - { - uno::Reference xInterface(pObj->getReportComponent()); - _rSelection.push_back(xInterface); - } + uno::Reference xInterface(pObj->getReportComponent()); + _rSelection.push_back(xInterface); } } } diff --git a/reportdesign/source/ui/report/ReportWindow.cxx b/reportdesign/source/ui/report/ReportWindow.cxx index fb26a4a77b83..c96498f54b37 100644 --- a/reportdesign/source/ui/report/ReportWindow.cxx +++ b/reportdesign/source/ui/report/ReportWindow.cxx @@ -166,38 +166,38 @@ sal_Int32 OReportWindow::GetTotalWidth() const void OReportWindow::Resize() { Window::Resize(); - if ( !m_aViewsWindow->empty() ) - { - const Size aTotalOutputSize = GetOutputSizePixel(); - Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100); + if ( m_aViewsWindow->empty() ) + return; - const Point aOffset = LogicToPixel(Point(SECTION_OFFSET, 0), MapMode(MapUnit::MapAppFont)); - Point aStartPoint(static_cast(aStartWidth) + aOffset.X(),0); - uno::Reference xReportDefinition = getReportView()->getController().getReportDefinition(); - const sal_Int32 nPaperWidth = getStyleProperty(xReportDefinition,PROPERTY_PAPERSIZE).Width; - sal_Int32 nLeftMargin = getStyleProperty(xReportDefinition,PROPERTY_LEFTMARGIN); - sal_Int32 nRightMargin = getStyleProperty(xReportDefinition,PROPERTY_RIGHTMARGIN); - Size aPageSize = m_aViewsWindow->LogicToPixel(Size(nPaperWidth ,0)); - nLeftMargin = m_aViewsWindow->LogicToPixel(Size(nLeftMargin,0)).Width(); - nRightMargin = m_aViewsWindow->LogicToPixel(Size(nRightMargin,0)).Width(); + const Size aTotalOutputSize = GetOutputSizePixel(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100); - aPageSize.setHeight( m_aHRuler->GetSizePixel().Height() ); + const Point aOffset = LogicToPixel(Point(SECTION_OFFSET, 0), MapMode(MapUnit::MapAppFont)); + Point aStartPoint(static_cast(aStartWidth) + aOffset.X(),0); + uno::Reference xReportDefinition = getReportView()->getController().getReportDefinition(); + const sal_Int32 nPaperWidth = getStyleProperty(xReportDefinition,PROPERTY_PAPERSIZE).Width; + sal_Int32 nLeftMargin = getStyleProperty(xReportDefinition,PROPERTY_LEFTMARGIN); + sal_Int32 nRightMargin = getStyleProperty(xReportDefinition,PROPERTY_RIGHTMARGIN); + Size aPageSize = m_aViewsWindow->LogicToPixel(Size(nPaperWidth ,0)); + nLeftMargin = m_aViewsWindow->LogicToPixel(Size(nLeftMargin,0)).Width(); + nRightMargin = m_aViewsWindow->LogicToPixel(Size(nRightMargin,0)).Width(); - const long nTermp(m_aViewsWindow->getTotalHeight() + aPageSize.Height()); - long nSectionsHeight = ::std::max(nTermp,aTotalOutputSize.Height()); + aPageSize.setHeight( m_aHRuler->GetSizePixel().Height() ); - m_aHRuler->SetPosSizePixel(aStartPoint,aPageSize); - m_aHRuler->SetNullOffset(nLeftMargin); - m_aHRuler->SetMargin1(0); - m_aHRuler->SetMargin2(aPageSize.Width() - nLeftMargin - nRightMargin); + const long nTermp(m_aViewsWindow->getTotalHeight() + aPageSize.Height()); + long nSectionsHeight = ::std::max(nTermp,aTotalOutputSize.Height()); - aStartPoint.AdjustY(aPageSize.Height() ); - nSectionsHeight -= aStartPoint.Y(); + m_aHRuler->SetPosSizePixel(aStartPoint,aPageSize); + m_aHRuler->SetNullOffset(nLeftMargin); + m_aHRuler->SetMargin1(0); + m_aHRuler->SetMargin2(aPageSize.Width() - nLeftMargin - nRightMargin); - aStartPoint.setX( aOffset.X() ); + aStartPoint.AdjustY(aPageSize.Height() ); + nSectionsHeight -= aStartPoint.Y(); - m_aViewsWindow->SetPosSizePixel(aStartPoint,Size(aTotalOutputSize.Width(),nSectionsHeight)); - } + aStartPoint.setX( aOffset.X() ); + + m_aViewsWindow->SetPosSizePixel(aStartPoint,Size(aTotalOutputSize.Width(),nSectionsHeight)); } Point OReportWindow::getThumbPos() const diff --git a/reportdesign/source/ui/report/SectionView.cxx b/reportdesign/source/ui/report/SectionView.cxx index 100703eef03e..cd9f455d7829 100644 --- a/reportdesign/source/ui/report/SectionView.cxx +++ b/reportdesign/source/ui/report/SectionView.cxx @@ -161,39 +161,39 @@ void OSectionView::ObjectRemovedInAliveMode( const SdrObject* _pObject ) void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo ) { - if (AreObjectsMarked()) - { - // #i11702# use SdrUndoObjectLayerChange for undo - // STR_UNDO_SELATTR is "Attributes" - should use a different text later - BegUndo( ); + if (!AreObjectsMarked()) + return; + + // #i11702# use SdrUndoObjectLayerChange for undo + // STR_UNDO_SELATTR is "Attributes" - should use a different text later + BegUndo( ); - const SdrMarkList& rMark = GetMarkedObjectList(); - const size_t nCount = rMark.GetMarkCount(); - for (size_t i = 0; iGetMarkedSdrObj(); + if ( dynamic_cast< const OCustomShape *>( pObj ) != nullptr ) { - SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); - if ( dynamic_cast< const OCustomShape *>( pObj ) != nullptr ) + AddUndo( std::make_unique( *pObj, pObj->GetLayer(), _nLayerNo) ); + pObj->SetLayer( _nLayerNo ); + OObjectBase& rBaseObj = dynamic_cast(*pObj); + try + { + rBaseObj.getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT)); + } + catch(const uno::Exception&) { - AddUndo( std::make_unique( *pObj, pObj->GetLayer(), _nLayerNo) ); - pObj->SetLayer( _nLayerNo ); - OObjectBase& rBaseObj = dynamic_cast(*pObj); - try - { - rBaseObj.getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT)); - } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } + } - EndUndo(); + EndUndo(); - // check mark list now instead of later in a timer - CheckMarked(); - MarkListHasChanged(); - } + // check mark list now instead of later in a timer + CheckMarked(); + MarkListHasChanged(); } bool OSectionView::OnlyShapesMarked() const diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx index 9ef341bacd1c..b9adb1767e85 100644 --- a/reportdesign/source/ui/report/StartMarker.cxx +++ b/reportdesign/source/ui/report/StartMarker.cxx @@ -267,21 +267,21 @@ void OStartMarker::showRuler(bool _bShow) void OStartMarker::RequestHelp( const HelpEvent& rHEvt ) { - if( !m_aText->GetText().isEmpty()) - { - // show help - tools::Rectangle aItemRect(rHEvt.GetMousePosPixel(),Size(GetSizePixel().Width(),getMinHeight())); - Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); - aItemRect.SetLeft( aPt.X() ); - aItemRect.SetTop( aPt.Y() ); - aPt = OutputToScreenPixel( aItemRect.BottomRight() ); - aItemRect.SetRight( aPt.X() ); - aItemRect.SetBottom( aPt.Y() ); - if( rHEvt.GetMode() == HelpEventMode::BALLOON ) - Help::ShowBalloon( this, aItemRect.Center(), aItemRect, m_aText->GetText()); - else - Help::ShowQuickHelp( this, aItemRect, m_aText->GetText() ); - } + if( m_aText->GetText().isEmpty()) + return; + + // show help + tools::Rectangle aItemRect(rHEvt.GetMousePosPixel(),Size(GetSizePixel().Width(),getMinHeight())); + Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); + aItemRect.SetLeft( aPt.X() ); + aItemRect.SetTop( aPt.Y() ); + aPt = OutputToScreenPixel( aItemRect.BottomRight() ); + aItemRect.SetRight( aPt.X() ); + aItemRect.SetBottom( aPt.Y() ); + if( rHEvt.GetMode() == HelpEventMode::BALLOON ) + Help::ShowBalloon( this, aItemRect.Center(), aItemRect, m_aText->GetText()); + else + Help::ShowQuickHelp( this, aItemRect, m_aText->GetText() ); } void OStartMarker::setCollapsed(bool _bCollapsed) diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index d68cba1a27b2..e4c82dd07a91 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -493,19 +493,19 @@ void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType) void OViewsWindow::unmarkAllObjects(OSectionView const * _pSectionView) { - if ( !m_bInUnmark ) + if ( m_bInUnmark ) + return; + + m_bInUnmark = true; + for (const auto& rxSection : m_aSections) { - m_bInUnmark = true; - for (const auto& rxSection : m_aSections) + if ( &rxSection->getReportSection().getSectionView() != _pSectionView ) { - if ( &rxSection->getReportSection().getSectionView() != _pSectionView ) - { - rxSection->getReportSection().deactivateOle(); - rxSection->getReportSection().getSectionView().UnmarkAllObj(); - } + rxSection->getReportSection().deactivateOle(); + rxSection->getReportSection().getSectionView().UnmarkAllObj(); } - m_bInUnmark = false; } + m_bInUnmark = false; } void OViewsWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints) @@ -539,20 +539,20 @@ void OViewsWindow::showRuler(bool _bShow) void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() ) + if ( !rMEvt.IsLeft() ) + return; + + auto aIter = std::find_if(m_aSections.begin(), m_aSections.end(), + [](const VclPtr& rxSection) { return rxSection->getReportSection().getSectionView().AreObjectsMarked(); }); + if (aIter != m_aSections.end()) { - auto aIter = std::find_if(m_aSections.begin(), m_aSections.end(), - [](const VclPtr& rxSection) { return rxSection->getReportSection().getSectionView().AreObjectsMarked(); }); - if (aIter != m_aSections.end()) - { - (*aIter)->getReportSection().MouseButtonUp(rMEvt); - } + (*aIter)->getReportSection().MouseButtonUp(rMEvt); + } - // remove special insert mode - for (const auto& rxSection : m_aSections) - { - rxSection->getReportSection().getPage()->resetSpecialMode(); - } + // remove special insert mode + for (const auto& rxSection : m_aSections) + { + rxSection->getReportSection().getPage()->resetSpecialMode(); } } diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index 10eb3b4a1d11..a7f82f7c5bb8 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -227,17 +227,17 @@ void DlgEdFunc::checkTwoCklicks(const MouseEvent& rMEvt) deactivateOle(); const sal_uInt16 nClicks = rMEvt.GetClicks(); - if ( nClicks == 2 && rMEvt.IsLeft() ) + if ( !(nClicks == 2 && rMEvt.IsLeft()) ) + return; + + if ( m_rView.AreObjectsMarked() ) { - if ( m_rView.AreObjectsMarked() ) + const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) { - const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); - if (rMarkList.GetMarkCount() == 1) - { - const SdrMark* pMark = rMarkList.GetMark(0); - SdrObject* pObj = pMark->GetMarkedSdrObj(); - activateOle(pObj); - } + const SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + activateOle(pObj); } } } @@ -376,39 +376,39 @@ bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent) void DlgEdFunc::activateOle(SdrObject* _pObj) { - if ( _pObj ) - { - const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier(); + if ( !_pObj ) + return; - // OLE: activate + const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier(); - if (nSdrObjKind == OBJ_OLE2) - { - SdrOle2Obj* pOleObj = dynamic_cast(_pObj); - if (pOleObj && pOleObj->GetObjRef().is()) - { - if (m_rView.IsTextEdit()) - { - m_rView.SdrEndTextEdit(); - } + // OLE: activate - pOleObj->AddOwnLightClient(); - pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent)); - try - { - pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE ); - m_bUiActive = true; - OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); - m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER); - if ( m_bShowPropertyBrowser ) - rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >()); - } - catch( uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } - } - } + if (nSdrObjKind != OBJ_OLE2) + return; + + SdrOle2Obj* pOleObj = dynamic_cast(_pObj); + if (!(pOleObj && pOleObj->GetObjRef().is())) + return; + + if (m_rView.IsTextEdit()) + { + m_rView.SdrEndTextEdit(); + } + + pOleObj->AddOwnLightClient(); + pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent)); + try + { + pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE ); + m_bUiActive = true; + OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); + m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER); + if ( m_bShowPropertyBrowser ) + rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >()); + } + catch( uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } @@ -445,21 +445,21 @@ void DlgEdFunc::deactivateOle(bool _bSelect) void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj) { OObjectBase* pObj = dynamic_cast(_pOverlappedObj); - if ( pObj ) + if ( !pObj ) + return; + + const uno::Reference& xComponent = pObj->getReportComponent(); + if (xComponent.is() && xComponent != m_xOverlappingObj) { - const uno::Reference& xComponent = pObj->getReportComponent(); - if (xComponent.is() && xComponent != m_xOverlappingObj) - { - OReportModel& rRptModel(static_cast< OReportModel& >(_pOverlappedObj->getSdrModelFromSdrObject())); - OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(_pOverlappedObj->getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); - // uncolorize an old object, if there is one - unColorizeOverlappedObj(); + // uncolorize an old object, if there is one + unColorizeOverlappedObj(); - m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor); - m_xOverlappingObj = xComponent; - m_pOverlappingObj = _pOverlappedObj; - } + m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor); + m_xOverlappingObj = xComponent; + m_pOverlappingObj = _pOverlappedObj; } } diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index a99b87b9d019..3afeb3bb904a 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -502,24 +502,24 @@ void PropBrw::Update( OSectionView* pNewView ) void PropBrw::Update( const uno::Reference< uno::XInterface>& _xReportComponent) { - if ( m_xLastSection != _xReportComponent ) - { - m_xLastSection = _xReportComponent; - try - { - if ( m_pView ) - { - EndListening( *(m_pView->GetModel()) ); - m_pView = nullptr; - } + if ( m_xLastSection == _xReportComponent ) + return; - uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent)); - implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); - } - catch ( Exception& ) + m_xLastSection = _xReportComponent; + try + { + if ( m_pView ) { - OSL_FAIL( "PropBrw::Update: Exception occurred!" ); + EndListening( *(m_pView->GetModel()) ); + m_pView = nullptr; } + + uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent)); + implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); + } + catch ( Exception& ) + { + OSL_FAIL( "PropBrw::Update: Exception occurred!" ); } } -- cgit