diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-26 12:47:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-27 09:06:10 +0200 |
commit | 595309903211ed5986ba0d2ef4d3b21bdfad10d9 (patch) | |
tree | cfcf597d2008a974be1365ad9e9ca9da1d188f07 /xmlscript | |
parent | cdd211d0a3f8bf977ecca67e72afbc63d53a72ee (diff) |
loplugin:flatten in vcl..xmlsecurity
Change-Id: I730fc0b3b6b7ac1803d75b5d9e007b15395888c6
Reviewed-on: https://gerrit.libreoffice.org/42826
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/source/xml_helper/xml_impctx.cxx | 11 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 175 | ||||
-rw-r--r-- | xmlscript/source/xmlflat_imexp/xmlbas_export.cxx | 16 |
3 files changed, 85 insertions, 117 deletions
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index 79d7889698b7..a51a99a57ed9 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -375,16 +375,13 @@ void DocumentHandlerImpl::initialize( { MGuard guard( m_pMutex ); Reference< xml::input::XRoot > xRoot; - if (arguments.getLength() == 1 && - (arguments[ 0 ] >>= xRoot) && - xRoot.is()) - { - m_xRoot = xRoot; - } - else + if (arguments.getLength() != 1 || + !(arguments[ 0 ] >>= xRoot) || + !xRoot.is()) { throw RuntimeException( "missing root instance!" ); } + m_xRoot = xRoot; } // XNamespaceMapping diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 5135761f8d49..4bc7152f957b 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -216,16 +216,15 @@ Reference< xml::input::XElement > ProgressBarElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( - nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( + nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void ProgressBarElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlProgressBarModel" ); @@ -258,15 +257,14 @@ Reference< xml::input::XElement > ScrollBarElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void ScrollBarElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlScrollBarModel" , _xAttributes ) ); @@ -308,14 +306,12 @@ Reference< xml::input::XElement > SpinButtonElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } void SpinButtonElement::endElement() @@ -356,15 +352,14 @@ Reference< xml::input::XElement > FixedLineElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void FixedLineElement::endElement() { ControlImportContext ctx(m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFixedLineModel" ); @@ -396,15 +391,14 @@ Reference< xml::input::XElement > PatternFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void PatternFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlPatternFieldModel" ); @@ -444,14 +438,12 @@ Reference< xml::input::XElement > FormattedFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } void FormattedFieldElement::endElement() @@ -572,15 +564,14 @@ Reference< xml::input::XElement > TimeFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void TimeFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlTimeFieldModel" ); @@ -626,15 +617,14 @@ Reference< xml::input::XElement > NumericFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void NumericFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlNumericFieldModel" ); @@ -682,15 +672,14 @@ Reference< xml::input::XElement > DateFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void DateFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlDateFieldModel" ); @@ -737,15 +726,14 @@ Reference< xml::input::XElement > CurrencyFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void CurrencyFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlCurrencyFieldModel" ); @@ -793,15 +781,14 @@ Reference< xml::input::XElement > FileControlElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void FileControlElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFileControlModel" ); @@ -837,15 +824,14 @@ Reference< xml::input::XElement > TreeControlElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void TreeControlElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.tree.TreeControlModel" ); @@ -883,14 +869,12 @@ Reference< xml::input::XElement > ImageControlElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } void ImageControlElement::endElement() @@ -925,14 +909,12 @@ Reference< xml::input::XElement > TextElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } void TextElement::endElement() @@ -972,15 +954,14 @@ Reference< xml::input::XElement > FixedHyperLinkElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void FixedHyperLinkElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFixedHyperlinkModel" ); @@ -1021,15 +1002,14 @@ Reference< xml::input::XElement > TextFieldElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void TextFieldElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlEditModel" ); @@ -1203,14 +1183,12 @@ Reference< xml::input::XElement > RadioElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } // radiogroup @@ -1484,15 +1462,14 @@ Reference< xml::input::XElement > CheckBoxElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } + void CheckBoxElement::endElement() { ControlImportContext ctx( m_xImport.get(), getControlId( _xAttributes ), "com.sun.star.awt.UnoControlCheckBoxModel" ); @@ -1550,14 +1527,12 @@ Reference< xml::input::XElement > ButtonElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) { // event - if (m_xImport->isEventElement( nUid, rLocalName )) - { - return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); - } - else + if (!m_xImport->isEventElement( nUid, rLocalName )) { throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() ); } + + return new EventElement( nUid, rLocalName, xAttributes, this, m_xImport.get() ); } void ButtonElement::endElement() @@ -1777,14 +1752,12 @@ Reference< xml::input::XElement > StyleElement::startChildElement( void StyleElement::endElement() { OUString aStyleId( _xAttributes->getValueByUidName( m_xImport->XMLNS_DIALOGS_UID, "style-id" ) ); - if (!aStyleId.isEmpty()) - { - m_xImport->addStyle( aStyleId, this ); - } - else + if (aStyleId.isEmpty()) { throw xml::sax::SAXException( "missing style-id attribute!", Reference< XInterface >(), Any() ); } + + m_xImport->addStyle( aStyleId, this ); } // styles diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx index 48e14115ea8e..a0793905a54c 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx @@ -62,18 +62,16 @@ namespace xmlscript { ::osl::MutexGuard aGuard( m_aMutex ); - if ( aArguments.getLength() == 1 ) + if ( aArguments.getLength() != 1 ) { - aArguments[0] >>= m_xHandler; - - if ( !m_xHandler.is() ) - { - throw RuntimeException( "XMLBasicExporterBase::initialize: invalid argument format!" ); - } + throw RuntimeException( "XMLBasicExporterBase::initialize: invalid number of arguments!" ); } - else + + aArguments[0] >>= m_xHandler; + + if ( !m_xHandler.is() ) { - throw RuntimeException( "XMLBasicExporterBase::initialize: invalid number of arguments!" ); + throw RuntimeException( "XMLBasicExporterBase::initialize: invalid argument format!" ); } } |