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 - reportdesign/source/filter/xml/xmlControlProperty.cxx | 22 reportdesign/source/filter/xml/xmlExport.cxx | 494 +++++------ reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx | 20 reportdesign/source/filter/xml/xmlFixedContent.cxx | 46 - reportdesign/source/filter/xml/xmlHelper.cxx | 112 +- reportdesign/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 - reportdesign/source/ui/inspection/DataProviderHandler.cxx | 34 reportdesign/source/ui/inspection/GeometryHandler.cxx | 146 +-- reportdesign/source/ui/misc/RptUndo.cxx | 86 - reportdesign/source/ui/misc/statusbarcontroller.cxx | 94 +- reportdesign/source/ui/report/DesignView.cxx | 30 reportdesign/source/ui/report/ReportController.cxx | 531 +++++------- reportdesign/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(-)
New commits: commit ff7e960701ccacbd62bd2251f26561eeba8ebe8a Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Apr 2 12:06:45 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Apr 2 20:07:00 2020 +0200 loplugin:flatten in reportdesign Change-Id: I6d8b2730cede4453e7afd581cc24ed101ca6c81b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91557 Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index 6aa10a6acaa2..761ed63e5c67 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -194,22 +194,22 @@ void OSection::init() uno::Reference< report::XReportDefinition> xReport = getReportDefinition(); std::shared_ptr<rptui::OReportModel> pModel = OReportDefinition::getSdrModel(xReport); assert(pModel && "No model set at the report definition!"); - if ( pModel ) - { - uno::Reference<report::XSection> const xSection(this); - SdrPage & rSdrPage(*pModel->createNewPage(xSection)); - m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW); - m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW); - // apparently we may also get OReportDrawPage which doesn't support this - m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY); - m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW); - // fdo#53872: now also exchange the XDrawPage in the SdrPage so that - // rSdrPage.getUnoPage returns this - rSdrPage.SetUnoPage(this); - // createNewPage _should_ have stored away 2 uno::References to this, - // so our ref count cannot be 1 here, so this isn't destroyed here - assert(m_refCount > 1); - } + if ( !pModel ) + return; + + uno::Reference<report::XSection> const xSection(this); + SdrPage & rSdrPage(*pModel->createNewPage(xSection)); + m_xDrawPage.set(rSdrPage.getUnoPage(), uno::UNO_QUERY_THROW); + m_xDrawPage_ShapeGrouper.set(m_xDrawPage, uno::UNO_QUERY_THROW); + // apparently we may also get OReportDrawPage which doesn't support this + m_xDrawPage_FormSupplier.set(m_xDrawPage, uno::UNO_QUERY); + m_xDrawPage_Tunnel.set(m_xDrawPage, uno::UNO_QUERY_THROW); + // fdo#53872: now also exchange the XDrawPage in the SdrPage so that + // rSdrPage.getUnoPage returns this + rSdrPage.SetUnoPage(this); + // createNewPage _should_ have stored away 2 uno::References to this, + // so our ref count cannot be 1 here, so this isn't destroyed here + assert(m_refCount > 1); } // XSection diff --git a/reportdesign/source/core/sdr/PropertyForward.cxx b/reportdesign/source/core/sdr/PropertyForward.cxx index e0837cfe3794..09beffed51e2 100644 --- a/reportdesign/source/core/sdr/PropertyForward.cxx +++ b/reportdesign/source/core/sdr/PropertyForward.cxx @@ -87,62 +87,62 @@ OPropertyMediator::~OPropertyMediator() void SAL_CALL OPropertyMediator::propertyChange( const PropertyChangeEvent& evt ) { ::osl::MutexGuard aGuard(m_aMutex); - if ( !m_bInChange ) + if ( m_bInChange ) + return; + + m_bInChange = true; + try { - m_bInChange = true; - try + bool bDest = (evt.Source == m_xDest); + Reference<XPropertySet> xProp = bDest ? m_xSource : m_xDest; + Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; + if ( xProp.is() && xPropInfo.is() ) { - bool bDest = (evt.Source == m_xDest); - Reference<XPropertySet> xProp = bDest ? m_xSource : m_xDest; - Reference<XPropertySetInfo> xPropInfo = bDest ? m_xSourceInfo : m_xDestInfo; - if ( xProp.is() && xPropInfo.is() ) + if ( xPropInfo->hasPropertyByName(evt.PropertyName) ) + xProp->setPropertyValue(evt.PropertyName,evt.NewValue); + else { - if ( xPropInfo->hasPropertyByName(evt.PropertyName) ) - xProp->setPropertyValue(evt.PropertyName,evt.NewValue); + TPropertyNamePair::const_iterator aFind = m_aNameMap.find(evt.PropertyName); + OUString sPropName; + if ( aFind != m_aNameMap.end() ) + sPropName = aFind->second.first; else { - TPropertyNamePair::const_iterator aFind = m_aNameMap.find(evt.PropertyName); - OUString sPropName; + aFind = ::std::find_if( + m_aNameMap.begin(), + m_aNameMap.end(), + [&evt] (const TPropertyNamePair::value_type& namePair) { + return namePair.second.first == evt.PropertyName; + }); if ( aFind != m_aNameMap.end() ) - sPropName = aFind->second.first; - else - { - aFind = ::std::find_if( - m_aNameMap.begin(), - m_aNameMap.end(), - [&evt] (const TPropertyNamePair::value_type& namePair) { - return namePair.second.first == evt.PropertyName; - }); - if ( aFind != m_aNameMap.end() ) - sPropName = aFind->first; - } - if (aFind != m_aNameMap.end() && !sPropName.isEmpty() && xPropInfo->hasPropertyByName(sPropName)) - xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue)); - else if ( evt.PropertyName == PROPERTY_CHARFONTNAME - || evt.PropertyName == PROPERTY_CHARFONTSTYLENAME - || evt.PropertyName == PROPERTY_CHARSTRIKEOUT - || evt.PropertyName == PROPERTY_CHARWORDMODE - || evt.PropertyName == PROPERTY_CHARROTATION - || evt.PropertyName == PROPERTY_CHARSCALEWIDTH - || evt.PropertyName == PROPERTY_CHARFONTFAMILY - || evt.PropertyName == PROPERTY_CHARFONTCHARSET - || evt.PropertyName == PROPERTY_CHARFONTPITCH - || evt.PropertyName == PROPERTY_CHARHEIGHT - || evt.PropertyName == PROPERTY_CHARUNDERLINE - || evt.PropertyName == PROPERTY_CHARWEIGHT - || evt.PropertyName == PROPERTY_CHARPOSTURE) - { - xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR)); - } + sPropName = aFind->first; + } + if (aFind != m_aNameMap.end() && !sPropName.isEmpty() && xPropInfo->hasPropertyByName(sPropName)) + xProp->setPropertyValue(sPropName,aFind->second.second->operator()(sPropName,evt.NewValue)); + else if ( evt.PropertyName == PROPERTY_CHARFONTNAME + || evt.PropertyName == PROPERTY_CHARFONTSTYLENAME + || evt.PropertyName == PROPERTY_CHARSTRIKEOUT + || evt.PropertyName == PROPERTY_CHARWORDMODE + || evt.PropertyName == PROPERTY_CHARROTATION + || evt.PropertyName == PROPERTY_CHARSCALEWIDTH + || evt.PropertyName == PROPERTY_CHARFONTFAMILY + || evt.PropertyName == PROPERTY_CHARFONTCHARSET + || evt.PropertyName == PROPERTY_CHARFONTPITCH + || evt.PropertyName == PROPERTY_CHARHEIGHT + || evt.PropertyName == PROPERTY_CHARUNDERLINE + || evt.PropertyName == PROPERTY_CHARWEIGHT + || evt.PropertyName == PROPERTY_CHARPOSTURE) + { + xProp->setPropertyValue(PROPERTY_FONTDESCRIPTOR,m_xSource->getPropertyValue(PROPERTY_FONTDESCRIPTOR)); } } } - catch(Exception&) - { - OSL_FAIL("Exception caught!"); - } - m_bInChange = false; } + catch(Exception&) + { + OSL_FAIL("Exception caught!"); + } + m_bInChange = false; } void SAL_CALL OPropertyMediator::disposing( const css::lang::EventObject& /*_rSource*/ ) diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index ab478828dd7d..157ed10b7ca6 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -779,113 +779,113 @@ OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj) void OUnoObject::_propertyChange( const beans::PropertyChangeEvent& evt ) { OObjectBase::_propertyChange(evt); - if (isListening()) + if (!isListening()) + return; + + if ( evt.PropertyName == PROPERTY_CHARCOLOR ) { - if ( evt.PropertyName == PROPERTY_CHARCOLOR ) + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() ) { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - if ( xControlModel.is() ) + OObjectBase::EndListening(); + try { + xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue); + } + catch(uno::Exception&) + { + } + OObjectBase::StartListening(); + } + } + else if ( evt.PropertyName == PROPERTY_NAME ) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) + { + // get old name + OUString aOldName; + evt.OldValue >>= aOldName; + + // get new name + OUString aNewName; + evt.NewValue >>= aNewName; + + if ( aNewName != aOldName ) + { + // set old name property OObjectBase::EndListening(); + if ( m_xMediator.is() ) + m_xMediator->stopListening(); try { - xControlModel->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue); + xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue ); } catch(uno::Exception&) { } + if ( m_xMediator.is() ) + m_xMediator->startListening(); OObjectBase::StartListening(); } } - else if ( evt.PropertyName == PROPERTY_NAME ) - { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - if ( xControlModel.is() && xControlModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) - { - // get old name - OUString aOldName; - evt.OldValue >>= aOldName; - - // get new name - OUString aNewName; - evt.NewValue >>= aNewName; - - if ( aNewName != aOldName ) - { - // set old name property - OObjectBase::EndListening(); - if ( m_xMediator.is() ) - m_xMediator->stopListening(); - try - { - xControlModel->setPropertyValue( PROPERTY_NAME, evt.NewValue ); - } - catch(uno::Exception&) - { - } - if ( m_xMediator.is() ) - m_xMediator->startListening(); - OObjectBase::StartListening(); - } - } - } } } void OUnoObject::CreateMediator(bool _bReverse) { - if ( !m_xMediator.is() ) + if ( m_xMediator.is() ) + return; + + // tdf#118730 Directly do things formerly done in + // OUnoObject::impl_setReportComponent_nothrow here + if(!m_xReportComponent.is()) { - // tdf#118730 Directly do things formerly done in - // OUnoObject::impl_setReportComponent_nothrow here - if(!m_xReportComponent.is()) - { - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - OXUndoEnvironment::OUndoEnvLock aLock( rRptModel.GetUndoEnv() ); - m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock( rRptModel.GetUndoEnv() ); + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); - impl_initializeModel_nothrow(); - } + impl_initializeModel_nothrow(); + } - if(m_xReportComponent.is() && m_bSetDefaultLabel) - { - // tdf#118730 Directly do things formerly done in - // OUnoObject::EndCreate here - // tdf#119067 ...but *only* if result of interactive - // creation in Report DesignView - m_bSetDefaultLabel = false; + if(m_xReportComponent.is() && m_bSetDefaultLabel) + { + // tdf#118730 Directly do things formerly done in + // OUnoObject::EndCreate here + // tdf#119067 ...but *only* if result of interactive + // creation in Report DesignView + m_bSetDefaultLabel = false; - try - { - if ( supportsService( SERVICE_FIXEDTEXT ) ) - { - m_xReportComponent->setPropertyValue( - PROPERTY_LABEL, - uno::makeAny(GetDefaultName(this))); - } - } - catch(const uno::Exception&) + try + { + if ( supportsService( SERVICE_FIXEDTEXT ) ) { - DBG_UNHANDLED_EXCEPTION("reportdesign"); + m_xReportComponent->setPropertyValue( + PROPERTY_LABEL, + uno::makeAny(GetDefaultName(this))); } } - - if(!m_xMediator.is() && m_xReportComponent.is()) + catch(const uno::Exception&) { - Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); - - if(xControlModel.is()) - { - m_xMediator = new OPropertyMediator( - m_xReportComponent.get(), - xControlModel, - getPropertyNameMap(GetObjIdentifier()), - _bReverse); - } + DBG_UNHANDLED_EXCEPTION("reportdesign"); } + } - OObjectBase::StartListening(); + if(!m_xMediator.is() && m_xReportComponent.is()) + { + Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY); + + if(xControlModel.is()) + { + m_xMediator = new OPropertyMediator( + m_xReportComponent.get(), + xControlModel, + getPropertyNameMap(GetObjIdentifier()), + _bReverse); + } } + + OObjectBase::StartListening(); } uno::Reference< beans::XPropertySet> OUnoObject::getAwtComponent() @@ -1160,21 +1160,21 @@ void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XMod void OOle2Obj::initializeOle() { - if ( m_bOnlyOnce ) - { - m_bOnlyOnce = false; - uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + if ( !m_bOnlyOnce ) + return; - uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); - if( xCompSupp.is() ) - { - uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY ); - if ( xChartProps.is() ) - xChartProps->setPropertyValue("NullDate", - uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false))); - } + m_bOnlyOnce = false; + uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is() ) + { + uno::Reference< beans::XPropertySet > xChartProps( xCompSupp->getComponent(), uno::UNO_QUERY ); + if ( xChartProps.is() ) + xChartProps->setPropertyValue("NullDate", + uno::makeAny(util::DateTime(0,0,0,0,30,12,1899,false))); } } @@ -1186,29 +1186,29 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) if( xCompSupp.is()) xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); OSL_ASSERT( xReceiver.is()); - if( xReceiver.is() ) - { - // lock the model to suppress any internal updates - uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); - if( xChartModel.is() ) - xChartModel->lockControllers(); + if( !xReceiver.is() ) + return; - if ( !lcl_getDataProvider(xObj).is() ) - impl_createDataProvider_nothrow(_xModel); + // lock the model to suppress any internal updates + uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); + if( xChartModel.is() ) + xChartModel->lockControllers(); - OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); - rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + if ( !lcl_getDataProvider(xObj).is() ) + impl_createDataProvider_nothrow(_xModel); + + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); - ::comphelper::NamedValueCollection aArgs; - aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) ); - aArgs.put( "HasCategories", uno::makeAny( true ) ); - aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); - aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); - xReceiver->setArguments( aArgs.getPropertyValues() ); + ::comphelper::NamedValueCollection aArgs; + aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) ); + aArgs.put( "HasCategories", uno::makeAny( true ) ); + aArgs.put( "FirstCellAsLabel", uno::makeAny( true ) ); + aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) ); + xReceiver->setArguments( aArgs.getPropertyValues() ); - if( xChartModel.is() ) - xChartModel->unlockControllers(); - } + if( xChartModel.is() ) + xChartModel->unlockControllers(); } uno::Reference< style::XStyle> getUsedStyle(const uno::Reference< report::XReportDefinition>& _xReport) diff --git a/reportdesign/source/core/sdr/UndoActions.cxx b/reportdesign/source/core/sdr/UndoActions.cxx index 836e8ed0a3d1..edca93c9e507 100644 --- a/reportdesign/source/core/sdr/UndoActions.cxx +++ b/reportdesign/source/core/sdr/UndoActions.cxx @@ -119,31 +119,31 @@ OUndoContainerAction::~OUndoContainerAction() { // if we own the object... Reference< XComponent > xComp( m_xOwnElement, UNO_QUERY ); - if ( xComp.is() ) - { - // and the object does not have a parent - Reference< XChild > xChild( m_xOwnElement, UNO_QUERY ); - if ( xChild.is() && !xChild->getParent().is() ) - { - OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); - rEnv.RemoveElement( m_xOwnElement ); + if ( !xComp.is() ) + return; + + // and the object does not have a parent + Reference< XChild > xChild( m_xOwnElement, UNO_QUERY ); + if ( !(xChild.is() && !xChild->getParent().is()) ) + return; + + OXUndoEnvironment& rEnv = static_cast< OReportModel& >( rMod ).GetUndoEnv(); + rEnv.RemoveElement( m_xOwnElement ); #if OSL_DEBUG_LEVEL > 0 - SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xChild ); - SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; - OSL_ENSURE( pObject == nullptr || (pShape->HasSdrObjectOwnership() && !pObject->IsInserted()), - "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" ); + SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xChild ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; + OSL_ENSURE( pObject == nullptr || (pShape->HasSdrObjectOwnership() && !pObject->IsInserted()), + "OUndoContainerAction::~OUndoContainerAction: inconsistency in the shape/object ownership!" ); #endif - // -> dispose it - try - { - comphelper::disposeComponent( xComp ); - } - catch ( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("reportdesign"); - } - } + // -> dispose it + try + { + comphelper::disposeComponent( xComp ); + } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("reportdesign"); } } @@ -187,58 +187,58 @@ void OUndoContainerAction::implReRemove( ) void OUndoContainerAction::Undo() { - if ( m_xElement.is() ) + if ( !m_xElement.is() ) + return; + + // prevents that an undo action will be created for elementInserted + try { - // prevents that an undo action will be created for elementInserted - try + switch ( m_eAction ) { - switch ( m_eAction ) - { - case Inserted: - implReRemove(); - break; - - case Removed: - implReInsert(); - break; - default: - OSL_FAIL("Illegal case value"); - break; - } - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Undo" ); + case Inserted: + implReRemove(); + break; + + case Removed: + implReInsert(); + break; + default: + OSL_FAIL("Illegal case value"); + break; } } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Undo" ); + } } void OUndoContainerAction::Redo() { - if ( m_xElement.is() ) + if ( !m_xElement.is() ) + return; + + try { - try - { - switch ( m_eAction ) - { - case Inserted: - implReInsert(); - break; - - case Removed: - implReRemove(); - break; - default: - OSL_FAIL("Illegal case value"); - break; - } - } - catch( const Exception& ) + switch ( m_eAction ) { - TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Redo" ); + case Inserted: + implReInsert(); + break; + + case Removed: + implReRemove(); + break; + default: + OSL_FAIL("Illegal case value"); + break; } } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "reportdesign", "OUndoContainerAction::Redo" ); + } } OUndoGroupSectionAction::OUndoGroupSectionAction( 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<sal_Int32>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_HEIGHT), PROPERTY_ID_HEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 }, + {OUString(PROPERTY_MINHEIGHT), PROPERTY_ID_MINHEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 }, + {OUString(), 0, css::uno::Type(), 0, 0 } + }; + pInfo->add(pMap); + Reference<XPropertySet> xProp = GenericPropertySet_CreateInstance(pInfo); + XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(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<XMLPropStyleContext*>(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<sal_Int32>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_HEIGHT), PROPERTY_ID_HEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 }, - {OUString(PROPERTY_MINHEIGHT), PROPERTY_ID_MINHEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 }, - {OUString(), 0, css::uno::Type(), 0, 0 } - }; - pInfo->add(pMap); - Reference<XPropertySet> xProp = GenericPropertySet_CreateInstance(pInfo); - XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(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<XMLPropStyleContext*>(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<XReportComponent>& _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>& _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<sal_Int16>* 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<sal_Int16>* 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<sal_Int16>* 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<sal_Int16>* 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>& _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> 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> 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<sal_Int16>* 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> 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> 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<sal_Int16>* 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> 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> 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<XFormattedField>& _xParentFormattedField) @@ -1273,34 +1273,34 @@ void ORptExport::SetBodyAttributes() void ORptExport::exportReportAttributes(const Reference<XReportDefinition>& _xReport) { - if ( _xReport.is() ) - { - OUStringBuffer sValue; - const SvXMLEnumMapEntry<sal_Int32>* 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<sal_Int32>* 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<XReportDefinition> 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<XMultiServiceFactory> xFactor(m_rImport.GetModel(),uno::UNO_QUERY); + if ( m_bFormattedField ) { - const Reference<XMultiServiceFactory> 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<XMLPropStyleContext*>(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<decltype(aFont.Name)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARFONTHEIGHT), PROPERTY_ID_FONTHEIGHT, cppu::UnoType<decltype(aFont.Height)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTWIDTH), PROPERTY_ID_FONTWIDTH, cppu::UnoType<decltype(aFont.Width)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTSTYLENAME), PROPERTY_ID_FONTSTYLENAME, cppu::UnoType<decltype(aFont.StyleName)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTFAMILY), PROPERTY_ID_FONTFAMILY, cppu::UnoType<decltype(aFont.Family)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTCHARSET), PROPERTY_ID_FONTCHARSET, cppu::UnoType<decltype(aFont.CharSet)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTPITCH), PROPERTY_ID_FONTPITCH, cppu::UnoType<decltype(aFont.Pitch)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTCHARWIDTH), PROPERTY_ID_FONTCHARWIDTH, cppu::UnoType<decltype(aFont.CharacterWidth)>::get(),PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTWEIGHT), PROPERTY_ID_FONTWEIGHT, cppu::UnoType<decltype(aFont.Weight)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARPOSTURE), PROPERTY_ID_FONTSLANT, cppu::UnoType<decltype(aFont.Slant)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTUNDERLINE), PROPERTY_ID_FONTUNDERLINE, cppu::UnoType<decltype(aFont.Underline)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARSTRIKEOUT), PROPERTY_ID_FONTSTRIKEOUT, cppu::UnoType<decltype(aFont.Strikeout)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTORIENTATION), PROPERTY_ID_FONTORIENTATION, cppu::UnoType<decltype(aFont.Orientation)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTKERNING), PROPERTY_ID_FONTKERNING, cppu::UnoType<decltype(aFont.Kerning)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_CHARWORDMODE), PROPERTY_ID_FONTWORDLINEMODE, cppu::UnoType<decltype(aFont.WordLineMode)>::get() ,PropertyAttribute::BOUND,0}, - {OUString(PROPERTY_FONTTYPE), PROPERTY_ID_FONTTYPE, cppu::UnoType<decltype(aFont.Type)>::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<decltype(aFont.Name)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARFONTHEIGHT), PROPERTY_ID_FONTHEIGHT, cppu::UnoType<decltype(aFont.Height)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTWIDTH), PROPERTY_ID_FONTWIDTH, cppu::UnoType<decltype(aFont.Width)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTSTYLENAME), PROPERTY_ID_FONTSTYLENAME, cppu::UnoType<decltype(aFont.StyleName)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTFAMILY), PROPERTY_ID_FONTFAMILY, cppu::UnoType<decltype(aFont.Family)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTCHARSET), PROPERTY_ID_FONTCHARSET, cppu::UnoType<decltype(aFont.CharSet)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTPITCH), PROPERTY_ID_FONTPITCH, cppu::UnoType<decltype(aFont.Pitch)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTCHARWIDTH), PROPERTY_ID_FONTCHARWIDTH, cppu::UnoType<decltype(aFont.CharacterWidth)>::get(),PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTWEIGHT), PROPERTY_ID_FONTWEIGHT, cppu::UnoType<decltype(aFont.Weight)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARPOSTURE), PROPERTY_ID_FONTSLANT, cppu::UnoType<decltype(aFont.Slant)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTUNDERLINE), PROPERTY_ID_FONTUNDERLINE, cppu::UnoType<decltype(aFont.Underline)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARSTRIKEOUT), PROPERTY_ID_FONTSTRIKEOUT, cppu::UnoType<decltype(aFont.Strikeout)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTORIENTATION), PROPERTY_ID_FONTORIENTATION, cppu::UnoType<decltype(aFont.Orientation)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTKERNING), PROPERTY_ID_FONTKERNING, cppu::UnoType<decltype(aFont.Kerning)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_CHARWORDMODE), PROPERTY_ID_FONTWORDLINEMODE, cppu::UnoType<decltype(aFont.WordLineMode)>::get() ,PropertyAttribute::BOUND,0}, + {OUString(PROPERTY_FONTTYPE), PROPERTY_ID_FONTTYPE, cppu::UnoType<decltype(aFont.Type)>::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<beans::XPropertySet> 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<report::XReportControlFormat> xReportControlModel(_xProp,uno::UNO_QUERY); - if ( xReportControlModel.is() && !aFont.Name.isEmpty() ) + uno::Reference<beans::XPropertySet> 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<report::XReportControlFormat> 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<container::XChild> xChild(getConnection(),uno::UNO_QUERY); + if ( xChild.is( ) ) { - uno::Reference<container::XChild> xChild(getConnection(),uno::UNO_QUERY); - if ( xChild.is( ) ) + uno::Reference<sdb::XDocumentDataSource> xDocument( xChild->getParent(), uno::UNO_QUERY ); + if ( xDocument.is() ) { - uno::Reference<sdb::XDocumentDataSource> xDocument( xChild->getParent(), uno::UNO_QUERY ); - if ( xDocument.is() ) - { - uno::Reference<frame::XModel> xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY); - if ( xModel.is() ) - rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] <<= xModel->getURL(); - } + uno::Reference<frame::XModel> 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<ColumnInfo*>(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<ColumnInfo*>(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<sal_Int64>(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<sal_Int64>(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<uno::Any>& _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<sal_Int32>::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<sal_Int32>::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<sal_Int32>::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<sal_Int32>::const_iterator aEnd = m_aGroupPositions.end(); - for(++aFind;aFind != aEnd;++aFind) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits