diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 20:22:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-22 07:43:35 +0100 |
commit | 494b3e69fd4bef0af19627cf31da98da376019d0 (patch) | |
tree | f0c9f434cfcc5775c45c79e8dba93453ec0ac8d0 /reportdesign | |
parent | 968b64d054eb164cee9fb92b6bf7dd93f478bf24 (diff) |
loplugin:flatten in package..reportdesign
Change-Id: I2da242fcb59709ebdd0819ec04d051d794da71e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127277
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/core/sdr/RptObject.cxx | 39 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlfilter.cxx | 102 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/GroupsSorting.cxx | 124 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 46 |
4 files changed, 154 insertions, 157 deletions
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index 8bb3246639db..e3cfb19d9037 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -62,28 +62,27 @@ SdrObjKind OObjectBase::getObjectType(const uno::Reference< report::XReportCompo { uno::Reference< lang::XServiceInfo > xServiceInfo( _xComponent , uno::UNO_QUERY ); OSL_ENSURE(xServiceInfo.is(),"Who deletes the XServiceInfo interface!"); - if ( xServiceInfo.is() ) + if ( !xServiceInfo ) + return OBJ_NONE; + + if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT )) + return OBJ_RD_FIXEDTEXT; + if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE )) { - if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT )) - return OBJ_RD_FIXEDTEXT; - if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE )) - { - uno::Reference< report::XFixedLine> xFixedLine(_xComponent,uno::UNO_QUERY); - return xFixedLine->getOrientation() ? OBJ_RD_HFIXEDLINE : OBJ_RD_VFIXEDLINE; - } - if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL)) - return OBJ_RD_IMAGECONTROL; - if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD )) - return OBJ_RD_FORMATTEDFIELD; - if ( xServiceInfo->supportsService("com.sun.star.drawing.OLE2Shape") ) - return OBJ_OLE2; - if ( xServiceInfo->supportsService( SERVICE_SHAPE )) - return OBJ_CUSTOMSHAPE; - if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) ) - return OBJ_RD_SUBREPORT; - return OBJ_OLE2; + uno::Reference< report::XFixedLine> xFixedLine(_xComponent,uno::UNO_QUERY); + return xFixedLine->getOrientation() ? OBJ_RD_HFIXEDLINE : OBJ_RD_VFIXEDLINE; } - return OBJ_NONE; + if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL)) + return OBJ_RD_IMAGECONTROL; + if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD )) + return OBJ_RD_FORMATTEDFIELD; + if ( xServiceInfo->supportsService("com.sun.star.drawing.OLE2Shape") ) + return OBJ_OLE2; + if ( xServiceInfo->supportsService( SERVICE_SHAPE )) + return OBJ_CUSTOMSHAPE; + if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) ) + return OBJ_RD_SUBREPORT; + return OBJ_OLE2; } SdrObject* OObjectBase::createObject( diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index b725e57259ee..49bba943ffa8 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -178,65 +178,63 @@ static ErrCode ReadThroughComponent( OSL_ENSURE( xStorage.is(), "Need storage!"); OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!"); - if ( xStorage.is() ) - { - uno::Reference< io::XStream > xDocStream; + if ( !xStorage ) + // TODO/LATER: better error handling + return ErrCode(1); - try - { - // open stream (and set parser input) - OUString sStreamName = OUString::createFromAscii(pStreamName); - if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) - { - // stream name not found! return immediately with OK signal - return ERRCODE_NONE; - } + uno::Reference< io::XStream > xDocStream; - // get input stream - xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); - } - catch (const packages::WrongPasswordException&) - { - return ERRCODE_SFX_WRONGPASSWORD; - } - catch (const uno::Exception&) + try + { + // open stream (and set parser input) + OUString sStreamName = OUString::createFromAscii(pStreamName); + if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) { - return ErrCode(1); // TODO/LATER: error handling + // stream name not found! return immediately with OK signal + return ERRCODE_NONE; } - sal_Int32 nArgs = 0; - if (rxGraphicStorageHandler.is()) - nArgs++; - if( _xEmbeddedObjectResolver.is()) - nArgs++; - if ( _xProp.is() ) - nArgs++; - - uno::Sequence< uno::Any > aFilterCompArgs( nArgs ); - auto aFilterCompArgsRange = asNonConstRange(aFilterCompArgs); - - nArgs = 0; - if (rxGraphicStorageHandler.is()) - aFilterCompArgsRange[nArgs++] <<= rxGraphicStorageHandler; - if( _xEmbeddedObjectResolver.is()) - aFilterCompArgsRange[ nArgs++ ] <<= _xEmbeddedObjectResolver; - if ( _xProp.is() ) - aFilterCompArgsRange[ nArgs++ ] <<= _xProp; - - // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler - Reference< XFastParser > xFastParser( - rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext), - uno::UNO_QUERY_THROW ); - uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); - // read from the stream - return ReadThroughComponent( xInputStream - ,xModelComponent - ,rxContext - ,xFastParser ); + // get input stream + xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + } + catch (const packages::WrongPasswordException&) + { + return ERRCODE_SFX_WRONGPASSWORD; + } + catch (const uno::Exception&) + { + return ErrCode(1); // TODO/LATER: error handling } - // TODO/LATER: better error handling - return ErrCode(1); + sal_Int32 nArgs = 0; + if (rxGraphicStorageHandler.is()) + nArgs++; + if( _xEmbeddedObjectResolver.is()) + nArgs++; + if ( _xProp.is() ) + nArgs++; + + uno::Sequence< uno::Any > aFilterCompArgs( nArgs ); + auto aFilterCompArgsRange = asNonConstRange(aFilterCompArgs); + + nArgs = 0; + if (rxGraphicStorageHandler.is()) + aFilterCompArgsRange[nArgs++] <<= rxGraphicStorageHandler; + if( _xEmbeddedObjectResolver.is()) + aFilterCompArgsRange[ nArgs++ ] <<= _xEmbeddedObjectResolver; + if ( _xProp.is() ) + aFilterCompArgsRange[ nArgs++ ] <<= _xProp; + + // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler + Reference< XFastParser > xFastParser( + rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext), + uno::UNO_QUERY_THROW ); + uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); + // read from the stream + return ReadThroughComponent( xInputStream + ,xModelComponent + ,rxContext + ,xFastParser ); } diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 5bb161d8b5d4..38036939adda 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -407,78 +407,78 @@ bool OFieldExpressionControl::IsTabAllowed(bool /*bForward*/) const bool OFieldExpressionControl::SaveModified() { sal_Int32 nRow = GetCurRow(); - if ( nRow != BROWSER_ENDOFSELECTION ) + if ( nRow == BROWSER_ENDOFSELECTION ) + return true; + + try { - try + bool bAppend = false; + uno::Reference< report::XGroup> xGroup; + if ( m_aGroupPositions[nRow] == NO_GROUP ) { - bool bAppend = false; - uno::Reference< report::XGroup> xGroup; - if ( m_aGroupPositions[nRow] == NO_GROUP ) - { - bAppend = true; - OUString sUndoAction(RptResId(RID_STR_UNDO_APPEND_GROUP)); - m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, OUString(), 0, ViewShellId(-1) ); - xGroup = m_pParent->getGroups()->createGroup(); - xGroup->setHeaderOn(true); - - // find position where to insert the new group - sal_Int32 nGroupPos = 0; - ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin(); - ::std::vector<sal_Int32>::const_iterator aEnd = m_aGroupPositions.begin() + nRow; - for(;aIter != aEnd;++aIter) - if ( *aIter != NO_GROUP ) - nGroupPos = *aIter + 1; - uno::Sequence< beans::PropertyValue > aArgs{ - comphelper::makePropertyValue(PROPERTY_GROUP, xGroup), - comphelper::makePropertyValue(PROPERTY_POSITIONY, nGroupPos) - }; - m_bIgnoreEvent = true; - m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs); - m_bIgnoreEvent = false; - OSL_ENSURE(*aIter == NO_GROUP ,"Illegal iterator!"); - *aIter++ = nGroupPos; - - aEnd = m_aGroupPositions.end(); - for(;aIter != aEnd;++aIter) - if ( *aIter != NO_GROUP ) - ++*aIter; - } + bAppend = true; + OUString sUndoAction(RptResId(RID_STR_UNDO_APPEND_GROUP)); + m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, OUString(), 0, ViewShellId(-1) ); + xGroup = m_pParent->getGroups()->createGroup(); + xGroup->setHeaderOn(true); + + // find position where to insert the new group + sal_Int32 nGroupPos = 0; + ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin(); + ::std::vector<sal_Int32>::const_iterator aEnd = m_aGroupPositions.begin() + nRow; + for(;aIter != aEnd;++aIter) + if ( *aIter != NO_GROUP ) + nGroupPos = *aIter + 1; + uno::Sequence< beans::PropertyValue > aArgs{ + comphelper::makePropertyValue(PROPERTY_GROUP, xGroup), + comphelper::makePropertyValue(PROPERTY_POSITIONY, nGroupPos) + }; + m_bIgnoreEvent = true; + m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs); + m_bIgnoreEvent = false; + OSL_ENSURE(*aIter == NO_GROUP ,"Illegal iterator!"); + *aIter++ = nGroupPos; + + aEnd = m_aGroupPositions.end(); + for(;aIter != aEnd;++aIter) + if ( *aIter != NO_GROUP ) + ++*aIter; + } + else + xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]); + if ( xGroup.is() ) + { + weld::ComboBox& rComboBox = m_pComboCell->get_widget(); + sal_Int32 nPos = rComboBox.get_active(); + OUString sExpression; + if (nPos == -1) + sExpression = rComboBox.get_active_text(); else - xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]); - if ( xGroup.is() ) { - weld::ComboBox& rComboBox = m_pComboCell->get_widget(); - sal_Int32 nPos = rComboBox.get_active(); - OUString sExpression; - if (nPos == -1) - sExpression = rComboBox.get_active_text(); - else - { - sExpression = m_aColumnInfo[nPos].sColumnName; - } - xGroup->setExpression( sExpression ); - - ::rptui::adjustSectionName(xGroup,nPos); - - if ( bAppend ) - m_pParent->m_pController->getUndoManager().LeaveListAction(); + sExpression = m_aColumnInfo[nPos].sColumnName; } + xGroup->setExpression( sExpression ); - if (Controller().is()) - Controller()->SaveValue(); - if ( GetRowCount() == m_pParent->getGroups()->getCount() ) - { - RowInserted( GetRowCount()-1); - m_aGroupPositions.push_back(NO_GROUP); - } + ::rptui::adjustSectionName(xGroup,nPos); - GoToRow(nRow); - m_pParent->DisplayData(nRow); + if ( bAppend ) + m_pParent->m_pController->getUndoManager().LeaveListAction(); } - catch(uno::Exception&) + + if (Controller().is()) + Controller()->SaveValue(); + if ( GetRowCount() == m_pParent->getGroups()->getCount() ) { - TOOLS_WARN_EXCEPTION( "reportdesign", "OFieldExpressionControl::SaveModified"); + RowInserted( GetRowCount()-1); + m_aGroupPositions.push_back(NO_GROUP); } + + GoToRow(nRow); + m_pParent->DisplayData(nRow); + } + catch(uno::Exception&) + { + TOOLS_WARN_EXCEPTION( "reportdesign", "OFieldExpressionControl::SaveModified"); } return true; diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index af893f91d253..d81d100bc129 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -3023,38 +3023,38 @@ void OReportController::insertGraphic() sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) { ::osl::MutexGuard aGuard( getMutex() ); - if ( getDesignView() ) - { - getDesignView()->unmarkAllObjects(); - getDesignView()->SetMode(DlgEdMode::Select); + if ( !getDesignView() ) + return true; - uno::Sequence< uno::Reference<report::XReportComponent> > aElements; - if ( aSelection >>= aElements ) + getDesignView()->unmarkAllObjects(); + getDesignView()->SetMode(DlgEdMode::Select); + + uno::Sequence< uno::Reference<report::XReportComponent> > aElements; + if ( aSelection >>= aElements ) + { + if ( aElements.hasElements() ) + getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY)); + getDesignView()->setMarked(aElements, true); + } + else + { + uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY); + uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY); + if ( xProp.is() ) { - if ( aElements.hasElements() ) - getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY)); + getDesignView()->showProperties(xObject); + aElements = { xProp }; getDesignView()->setMarked(aElements, true); } else { - uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY); - uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY); - if ( xProp.is() ) - { + uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY); + if ( !xSection.is() && xObject.is() ) getDesignView()->showProperties(xObject); - aElements = { xProp }; - getDesignView()->setMarked(aElements, true); - } - else - { - uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY); - if ( !xSection.is() && xObject.is() ) - getDesignView()->showProperties(xObject); - getDesignView()->setMarked(xSection,xSection.is()); - } + getDesignView()->setMarked(xSection,xSection.is()); } - InvalidateAll(); } + InvalidateAll(); return true; } |