diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-01-07 13:01:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-07 17:45:03 +0100 |
commit | e1383444c6d00f5d0b1d507670517f45988b9cc7 (patch) | |
tree | 5304b99014f1b2236456923a3e98b2c0dbf31511 /xmloff | |
parent | 0f4dd820ee433932d9d9237b676292d31c4ba913 (diff) |
extract some common code from ImportContext classes
which reduces code bloat, and lets us log when elements are ignored
Change-Id: I5ca12bc1fcbfa3bea49ebde819fd80bd233a96a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86338
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
49 files changed, 43 insertions, 212 deletions
diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx index 766f2f5e81a3..962fec96e6df 100644 --- a/xmloff/source/chart/SchXMLAxisContext.cxx +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -697,12 +697,10 @@ SvXMLImportContextRef SchXMLAxisContext::CreateChildContext( CreateGrid( sAutoStyleName, bIsMajor ); // don't create a context => use default context. grid elements are empty - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); } break; default: - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); break; } diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index e5f677f3fa0e..f3bc2fa9e840 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -1121,9 +1121,6 @@ SvXMLImportContextRef SchXMLChartContext::CreateChildContext( break; } - if( ! pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - return pContext; } @@ -1238,8 +1235,6 @@ SvXMLImportContextRef SchXMLTitleContext::CreateChildContext( { pContext = new SchXMLParagraphContext( GetImport(), rLocalName, mrTitle ); } - else - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index d0cd1f99c33e..9f8a59e0fe52 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -86,7 +86,7 @@ SchXMLImportHelper::SchXMLImportHelper() : SvXMLImportContext* SchXMLImportHelper::CreateChartContext( SvXMLImport& rImport, - sal_uInt16 nPrefix, const OUString& rLocalName, + sal_uInt16 /*nPrefix*/, const OUString& rLocalName, const Reference< frame::XModel >& rChartModel, const Reference< xml::sax::XAttributeList >& ) { @@ -101,7 +101,6 @@ SvXMLImportContext* SchXMLImportHelper::CreateChartContext( else { SAL_WARN("xmloff.chart", "No valid XChartDocument given as XModel" ); - pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName ); } return pContext; @@ -553,8 +552,7 @@ SvXMLImportContext *SchXMLImport::CreateFastContext( sal_Int32 nElement, } } break; - default: - pContext = new SvXMLImportContext( *this ); + default: break; } return pContext; } diff --git a/xmloff/source/chart/SchXMLParagraphContext.cxx b/xmloff/source/chart/SchXMLParagraphContext.cxx index 65fcee594d77..9161cfad0e24 100644 --- a/xmloff/source/chart/SchXMLParagraphContext.cxx +++ b/xmloff/source/chart/SchXMLParagraphContext.cxx @@ -99,7 +99,7 @@ SvXMLImportContextRef SchXMLParagraphContext::CreateChildContext( } } - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } void SchXMLParagraphContext::Characters( const OUString& rChars ) diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index f488244e142f..b83998b708cc 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -494,9 +494,6 @@ SvXMLImportContextRef SchXMLPlotAreaContext::CreateChildContext( pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram, SchXMLStockContext::CONTEXT_TYPE_RANGE ); break; - - default: - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } return pContext; diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 86c67f8834fa..a571430c28d0 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -696,9 +696,6 @@ SvXMLImportContextRef SchXMLSeries2Context::CreateChildContext( GetImport(), rLocalName, mrLSequencesPerIndex, m_xSeries ); break; - - default: - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } return pContext; diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index ca52090960cc..69b738a66688 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -244,9 +244,6 @@ SvXMLImportContextRef SchXMLTableContext::CreateChildContext( case XML_TOK_TABLE_ROW: pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), rLocalName, mrTable ); break; - - default: - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } return pContext; @@ -413,8 +410,6 @@ SvXMLImportContextRef SchXMLTableColumnsContext::CreateChildContext( { pContext = new SchXMLTableColumnContext( GetImport(), rLocalName, mrTable ); } - else - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } @@ -507,10 +502,6 @@ SvXMLImportContextRef SchXMLTableRowsContext::CreateChildContext( { pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), rLocalName, mrTable ); } - else - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } @@ -553,7 +544,7 @@ SvXMLImportContextRef SchXMLTableRowContext::CreateChildContext( } else { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + assert(false); } return pContext; @@ -683,10 +674,6 @@ SvXMLImportContextRef SchXMLTableCellContext::CreateChildContext( //so we need to find an alternative to save that range info for copy/paste scenario ... -> use description at an empty group element for now pContext = new SchXMLRangeSomewhereContext( GetImport(), nPrefix, rLocalName, maRangeId ); } - else - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } @@ -1076,7 +1063,7 @@ SvXMLImportContextRef SchXMLRangeSomewhereContext::CreateChildContext( return new XMLStringBufferImportContext( GetImport(), nPrefix, rLocalName, maRangeStringBuffer ); } - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } void SchXMLRangeSomewhereContext::EndElement() diff --git a/xmloff/source/chart/SchXMLTextListContext.cxx b/xmloff/source/chart/SchXMLTextListContext.cxx index 7f65edb2cd30..a494c79a0cb3 100644 --- a/xmloff/source/chart/SchXMLTextListContext.cxx +++ b/xmloff/source/chart/SchXMLTextListContext.cxx @@ -74,8 +74,6 @@ SvXMLImportContextRef SchXMLListItemContext::CreateChildContext( if( (nPrefix == XML_NAMESPACE_TEXT || nPrefix == XML_NAMESPACE_LO_EXT) && IsXMLToken( rLocalName, XML_P ) ) pContext = new SchXMLParagraphContext( GetImport(), rLocalName, m_rText ); - else - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } @@ -115,8 +113,6 @@ SvXMLImportContextRef SchXMLTextListContext::CreateChildContext( m_aTextVector.emplace_back( ); pContext = new SchXMLListItemContext( GetImport(), rLocalName, m_aTextVector.back() ); } - else - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/chart/XMLLabelSeparatorContext.cxx b/xmloff/source/chart/XMLLabelSeparatorContext.cxx index 2ef83157e82d..dec08c2ad3da 100644 --- a/xmloff/source/chart/XMLLabelSeparatorContext.cxx +++ b/xmloff/source/chart/XMLLabelSeparatorContext.cxx @@ -45,7 +45,7 @@ void XMLLabelSeparatorContext::StartElement( const uno::Reference< xml::sax::XAt } SvXMLImportContextRef XMLLabelSeparatorContext::CreateChildContext( - sal_uInt16 nPrefix, const OUString& rLocalName, + sal_uInt16 /*nPrefix*/, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) { SvXMLImportContext* pContext = nullptr; @@ -54,8 +54,6 @@ SvXMLImportContextRef XMLLabelSeparatorContext::CreateChildContext( pContext = new SchXMLParagraphContext( GetImport(), rLocalName, m_aSeparator ); } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/chart/XMLSymbolImageContext.cxx b/xmloff/source/chart/XMLSymbolImageContext.cxx index 36fd0eafa6e9..be661375cff0 100644 --- a/xmloff/source/chart/XMLSymbolImageContext.cxx +++ b/xmloff/source/chart/XMLSymbolImageContext.cxx @@ -109,10 +109,6 @@ SvXMLImportContextRef XMLSymbolImageContext::CreateChildContext( mxBase64Stream ); } } - if( ! pContext ) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx index 62bebf34ded9..9f4a178590cf 100644 --- a/xmloff/source/chart/contexts.cxx +++ b/xmloff/source/chart/contexts.cxx @@ -142,7 +142,7 @@ SvXMLImportContextRef SchXMLDocContext::CreateChildContext( uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SchXMLDocContext::createFastChildContext( sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { - return new SvXMLImportContext( GetImport() ); + return nullptr; } SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl( diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx index 13bb5e1214db..249f1c554d0d 100644 --- a/xmloff/source/core/DocumentSettingsContext.cxx +++ b/xmloff/source/core/DocumentSettingsContext.cxx @@ -248,9 +248,6 @@ static SvXMLImportContext *CreateSettingsContext(SvXMLImport& rImport, sal_uInt1 pContext = new XMLConfigItemMapIndexedContext(rImport, p_nPrefix, rLocalName, xAttrList, rProp.Value, rProp.Name, pBaseContext); } - if( !pContext ) - pContext = new SvXMLImportContext( rImport, p_nPrefix, rLocalName ); - return pContext; } @@ -343,9 +340,6 @@ SvXMLImportContextRef XMLDocumentSettingsContext::CreateChildContext( sal_uInt16 } } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - return pContext; } diff --git a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx index 57403644aea4..abb6601cb9cb 100644 --- a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx +++ b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx @@ -234,8 +234,7 @@ SvXMLImportContextRef XMLEmbeddedObjectImportContext::CreateChildContext( return new XMLEmbeddedObjectImportContext_Impl( GetImport(), nPrefix, rLocalName, xHandler ); - else - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } void XMLEmbeddedObjectImportContext::StartElement( diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index b05a76b39969..d3647f1faa44 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -49,11 +49,11 @@ SvXMLImportContext::~SvXMLImportContext() { } -SvXMLImportContextRef SvXMLImportContext::CreateChildContext( sal_uInt16 nPrefix, - const OUString& rLocalName, +SvXMLImportContextRef SvXMLImportContext::CreateChildContext( sal_uInt16 /*nPrefix*/, + const OUString& /*rLocalName*/, const uno::Reference<xml::sax::XAttributeList>& ) { - return new SvXMLImportContext(mrImport, nPrefix, rLocalName); + return nullptr; } void SvXMLImportContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& ) @@ -134,8 +134,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::cre // Call CreateFastContext only if it's the first element of the document if ( mrImport.maFastContexts.empty() ) return mrImport.CreateFastContext( Element, Attribs ); - else - return new SvXMLImportContext( GetImport() ); + return nullptr; } uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLImportContext::createUnknownChildContext diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 578bef43a82c..65016341d2de 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -327,12 +327,14 @@ SvXMLImportContext *SvXMLImport::CreateDocumentContext(sal_uInt16 const nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList >& ) { + SAL_WARN( "xmloff.core", "CreateDocumentContext should be overridden, for element " << rLocalName); return new SvXMLImportContext( *this, nPrefix, rLocalName ); } -SvXMLImportContext *SvXMLImport::CreateFastContext( sal_Int32 /*Element*/, +SvXMLImportContext *SvXMLImport::CreateFastContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { + SAL_WARN( "xmloff.core", "CreateFastContext should be overridden, for element " << nElement); return new SvXMLImportContext( *this ); } @@ -746,7 +748,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, } } - SAL_WARN_IF( !xContext.is(), "xmloff.core", "SvXMLImport::startElement: missing context" ); + SAL_WARN_IF( !xContext.is(), "xmloff.core", "SvXMLImport::startElement: missing context for element " << aLocalName ); if( !xContext.is() ) xContext.set(new SvXMLImportContext( *this, nPrefix, aLocalName )); @@ -875,6 +877,7 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element, else xContext.set( CreateFastContext( Element, Attribs ) ); + SAL_WARN_IF(!xContext.is(), "xmloff.core", "No fast context for element " << getNameFromToken(Element)); if ( !xContext.is() ) xContext.set( new SvXMLImportContext( *this ) ); @@ -916,6 +919,7 @@ void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rPrefix, const else xContext.set( CreateFastContext( -1, Attribs ) ); + SAL_WARN_IF(!xContext.is(), "xmloff.core", "No context for unknown-element " << rLocalName); if ( !xContext.is() ) xContext.set( new SvXMLImportContext( *this ) ); diff --git a/xmloff/source/draw/XMLReplacementImageContext.cxx b/xmloff/source/draw/XMLReplacementImageContext.cxx index 32ad125c9514..1f9f077fbddf 100644 --- a/xmloff/source/draw/XMLReplacementImageContext.cxx +++ b/xmloff/source/draw/XMLReplacementImageContext.cxx @@ -118,9 +118,6 @@ SvXMLImportContextRef XMLReplacementImageContext::CreateChildContext( m_xBase64Stream ); } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - return pContext; } diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index 5da1b3466321..fea0eac29ece 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -1201,8 +1201,7 @@ SvXMLImportContextRef AnimationNodeContext::CreateChildContext( sal_uInt16 nPref { if( mxNode.is()) return new AnimationNodeContext( mxNode, GetImport(), nPrefix, rLocalName, xAttrList, mpHelper ); - else - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } namespace { diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx index c0826cbec25b..50c6d39061d7 100644 --- a/xmloff/source/draw/layerimp.cxx +++ b/xmloff/source/draw/layerimp.cxx @@ -106,10 +106,7 @@ SvXMLImportContextRef SdXMLLayerContext::CreateChildContext( sal_uInt16 nPrefix, { return new XMLStringBufferImportContext( GetImport(), nPrefix, rLocalName, sDescriptionBuffer); } - else - { - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } + return nullptr; } void SdXMLLayerContext::EndElement() diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 3a7d52b880ab..dfa68e100629 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -203,7 +203,7 @@ SvXMLImportContextRef SdXMLDocContext_Impl::CreateChildContext( uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLDocContext_Impl::createFastChildContext( sal_Int32 /*nElement*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { - return new SvXMLImportContext( GetImport() ); + return nullptr; } namespace { @@ -706,11 +706,6 @@ SvXMLImportContext *SdXMLImport::CreateMetaContext(const sal_Int32 /*nElement*/, pContext = new SvXMLMetaDocumentContext(*this, xDocProps); } - if(!pContext) - { - pContext = new SvXMLImportContext(*this); - } - return pContext; } diff --git a/xmloff/source/draw/ximpshow.cxx b/xmloff/source/draw/ximpshow.cxx index 4b33fa22bc56..42d3589d17b1 100644 --- a/xmloff/source/draw/ximpshow.cxx +++ b/xmloff/source/draw/ximpshow.cxx @@ -250,7 +250,7 @@ SvXMLImportContextRef SdXMLShowsContext::CreateChildContext( sal_uInt16 p_nPrefi } } - return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); + return nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index 7bf0ed4177b1..9d6909c6bc54 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -461,13 +461,6 @@ SvXMLImportContext* OFormLayerXMLImport_Impl::createContext(const sal_uInt16 _nP pContext = createXFormsModelContext( m_rImporter, _nPrefix, _rLocalName ); } - if ( !pContext ) - { - OSL_FAIL( "unknown element" ); - pContext = - new SvXMLImportContext(m_rImporter, _nPrefix, _rLocalName); - } - return pContext; } diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index d14f0afefa81..0f296930aee8 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -363,13 +363,7 @@ SvXMLImportContextRef OPropertyElementsContext::CreateChildContext(sal_uInt16 _n { return new OListPropertyContext( GetImport(), _nPrefix, _rLocalName, m_xPropertyImporter ); } - else - { - OSL_FAIL(OStringBuffer("OPropertyElementsContext::CreateChildContext: unknown child element (\""). - append(OUStringToOString(_rLocalName, RTL_TEXTENCODING_ASCII_US)). - append("\")!").getStr()); - return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName); - } + return nullptr; } #if OSL_DEBUG_LEVEL > 0 @@ -395,13 +389,10 @@ OSinglePropertyContext::OSinglePropertyContext(SvXMLImport& _rImport, sal_uInt16 { } -SvXMLImportContextRef OSinglePropertyContext::CreateChildContext(sal_uInt16 _nPrefix, const OUString& _rLocalName, +SvXMLImportContextRef OSinglePropertyContext::CreateChildContext(sal_uInt16 /*_nPrefix*/, const OUString& /*_rLocalName*/, const Reference< XAttributeList >&) { - OSL_FAIL(OStringBuffer("OSinglePropertyContext::CreateChildContext: unknown child element (\""). - append(OUStringToOString(_rLocalName, RTL_TEXTENCODING_ASCII_US)). - append("\")!").getStr()); - return new SvXMLImportContext(GetImport(), _nPrefix, _rLocalName); + return nullptr; } void OSinglePropertyContext::StartElement(const Reference< XAttributeList >& _rxAttrList) @@ -531,12 +522,7 @@ SvXMLImportContextRef OListPropertyContext::CreateChildContext( sal_uInt16 _nPre m_aListValues.emplace_back(); return new OListValueContext( GetImport(), _nPrefix, _rLocalName, *m_aListValues.rbegin() ); } - else - { - SAL_WARN( "xmloff", "OListPropertyContext::CreateChildContext: unknown child element (\"" - << _rLocalName << "\")!" ); - return new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName ); - } + return nullptr; } //= OListValueContext diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx index 533cc761d55c..a24a6f8c31b9 100644 --- a/xmloff/source/meta/xmlmetai.cxx +++ b/xmloff/source/meta/xmlmetai.cxx @@ -218,8 +218,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLMetaDocumentContex if ( nElement == ( NAMESPACE_TOKEN( XML_NAMESPACE_OFFICE ) | XML_META ) ) return new XMLDocumentBuilderContext( GetImport(), nElement, xAttrList, mxDocBuilder); - else - return new SvXMLImportContext( GetImport() ); + return nullptr; } void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo ) diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx index fc7bbe824f95..dba5e8d4f4cd 100644 --- a/xmloff/source/meta/xmlversion.cxx +++ b/xmloff/source/meta/xmlversion.cxx @@ -147,10 +147,6 @@ XMLVersionListContext::createFastChildContext(sal_Int32 nElement, { pContext = new XMLVersionContext( GetImport(), xAttrList ); } - else - { - pContext = new SvXMLImportContext( GetImport() ); - } return pContext; } diff --git a/xmloff/source/script/xmlbasici.cxx b/xmloff/source/script/xmlbasici.cxx index da38c060b7a3..0a69889f7218 100644 --- a/xmloff/source/script/xmlbasici.cxx +++ b/xmloff/source/script/xmlbasici.cxx @@ -53,9 +53,6 @@ SvXMLImportContextRef XMLBasicImportContext::CreateChildContext( pContext = new XMLBasicImportChildContext( GetImport(), nPrefix, rLocalName, Reference<xml::sax::XDocumentHandler>(m_xHandler, UNO_QUERY_THROW) ); - if ( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - return pContext; } diff --git a/xmloff/source/style/FillStyleContext.cxx b/xmloff/source/style/FillStyleContext.cxx index 1cb513ce6b50..bc81cd92d5da 100644 --- a/xmloff/source/style/FillStyleContext.cxx +++ b/xmloff/source/style/FillStyleContext.cxx @@ -148,10 +148,6 @@ SvXMLImportContextRef XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPre mxBase64Stream ); } } - if( !pContext ) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } diff --git a/xmloff/source/style/PageHeaderFooterContext.cxx b/xmloff/source/style/PageHeaderFooterContext.cxx index b4c95261e0ad..fe9689ae3f5f 100644 --- a/xmloff/source/style/PageHeaderFooterContext.cxx +++ b/xmloff/source/style/PageHeaderFooterContext.cxx @@ -67,9 +67,6 @@ SvXMLImportContextRef PageHeaderFooterContext::CreateChildContext( sal_uInt16 nP rMap, nStartIndex, nEndIndex, aType); } - if (!xContext) - xContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - return xContext; } diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx index b9ccb73c9c1a..a2c48e00a5b8 100644 --- a/xmloff/source/style/XMLBackgroundImageContext.cxx +++ b/xmloff/source/style/XMLBackgroundImageContext.cxx @@ -365,10 +365,6 @@ SvXMLImportContextRef XMLBackgroundImageContext::CreateChildContext( m_xBase64Stream ); } } - if( !pContext ) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index d014b658750a..d74353bcf314 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -604,11 +604,11 @@ SvXMLNumFmtMapContext::SvXMLNumFmtMapContext( SvXMLImport& rImport, } SvXMLImportContextRef SvXMLNumFmtMapContext::CreateChildContext( - sal_uInt16 nPrfx, const OUString& rLName, + sal_uInt16 /*nPrfx*/, const OUString& /*rLName*/, const uno::Reference<xml::sax::XAttributeList>& ) { // no elements supported - use default context - return new SvXMLImportContext( GetImport(), nPrfx, rLName ); + return nullptr; } void SvXMLNumFmtMapContext::Characters( const OUString& ) @@ -1055,8 +1055,7 @@ SvXMLImportContextRef SvXMLNumFmtElementContext::CreateChildContext( { return new SvXMLNumFmtEmbeddedTextContext( GetImport(), nPrfx, rLName, *this, xAttrList ); } - else - return new SvXMLImportContext( GetImport(), nPrfx, rLName ); + return nullptr; } void SvXMLNumFmtElementContext::Characters( const OUString& rChars ) @@ -1551,8 +1550,6 @@ SvXMLImportContextRef SvXMLNumFormatContext::CreateChildContext( break; } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrfx, rLName ); return pContext; } diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 1ea6831d07b8..c1cea0e9cf0c 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -390,10 +390,6 @@ SvXMLImportContextRef SvxXMLListLevelStyleContext_Impl::CreateChildContext( xBase64Stream ); } } - if( !pContext ) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } @@ -912,10 +908,6 @@ SvXMLImportContextRef SvxXMLListLevelStyleAttrContext_Impl::CreateChildContext( xAttrList, rListLevel ); } - if( !pContext ) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } @@ -1070,10 +1062,6 @@ SvXMLImportContextRef SvxXMLListStyleContext::CreateChildContext( xContext = xLevelStyle.get(); } - else - { - xContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return xContext; } diff --git a/xmloff/source/style/xmlprcon.cxx b/xmloff/source/style/xmlprcon.cxx index 0ff6b531c697..813dcb3b3dcd 100644 --- a/xmloff/source/style/xmlprcon.cxx +++ b/xmloff/source/style/xmlprcon.cxx @@ -70,10 +70,7 @@ SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( return CreateChildContext( nPrefix, rLocalName, xAttrList, mrProperties, aProp ); } - else - { - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } + return nullptr; } /** This method is called from this instance implementation of @@ -81,13 +78,13 @@ SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( SvXMLImportItemMapper with the mid flag MID_FLAG_ELEMENT */ SvXMLImportContextRef SvXMLPropertySetContext::CreateChildContext( - sal_uInt16 nPrefix, - const OUString& rLocalName, + sal_uInt16 /*nPrefix*/, + const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList >&, ::std::vector< XMLPropertyState > &, const XMLPropertyState& ) { - return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 8d32d38396f2..352eba7cee7f 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -772,11 +772,6 @@ SvXMLImportContextRef SvXMLStylesContext::CreateChildContext( sal_uInt16 nPrefix mpImpl->AddStyle( pStyle ); pContext = pStyle; } - else - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, - rLocalName ); - } return pContext; } diff --git a/xmloff/source/style/xmltabi.cxx b/xmloff/source/style/xmltabi.cxx index 1ad85eb3cfb3..27880a177e91 100644 --- a/xmloff/source/style/xmltabi.cxx +++ b/xmloff/source/style/xmltabi.cxx @@ -181,10 +181,6 @@ SvXMLImportContextRef SvxXMLTabStopImportContext::CreateChildContext( pContext = xTabStopContext.get(); } - else - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } diff --git a/xmloff/source/text/XMLAutoTextContainerEventImport.cxx b/xmloff/source/text/XMLAutoTextContainerEventImport.cxx index 70729096ad03..39164f5960b7 100644 --- a/xmloff/source/text/XMLAutoTextContainerEventImport.cxx +++ b/xmloff/source/text/XMLAutoTextContainerEventImport.cxx @@ -61,8 +61,7 @@ SvXMLImportContextRef XMLAutoTextContainerEventImport::CreateChildContext( return new XMLEventsImportContext(GetImport(), nPrefix, rLocalName, rEvents); } - else - return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); + return nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLFootnoteBodyImportContext.cxx b/xmloff/source/text/XMLFootnoteBodyImportContext.cxx index 0eeb831eb81a..dc560f624c10 100644 --- a/xmloff/source/text/XMLFootnoteBodyImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteBodyImportContext.cxx @@ -48,8 +48,6 @@ SvXMLImportContextRef XMLFootnoteBodyImportContext::CreateChildContext( rLocalName, xAttrList, XMLTextType::Footnote); - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index 4361417f28f6..b77b740528b6 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -201,8 +201,6 @@ SvXMLImportContextRef XMLFootnoteImportContext::CreateChildContext( } // ignore content: return default context - xContext = new SvXMLImportContext(GetImport(), - p_nPrefix, rLocalName); break; } diff --git a/xmloff/source/text/XMLIndexBodyContext.cxx b/xmloff/source/text/XMLIndexBodyContext.cxx index b739093b595d..25c01a7db135 100644 --- a/xmloff/source/text/XMLIndexBodyContext.cxx +++ b/xmloff/source/text/XMLIndexBodyContext.cxx @@ -48,11 +48,7 @@ SvXMLImportContextRef XMLIndexBodyContext::CreateChildContext( // return text content (if possible) SvXMLImportContext* pContext = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList, XMLTextType::Section ); - if (nullptr == pContext) - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } - else + if (pContext) bHasContent = true; return pContext; diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index d34bd224f248..9f0b0eb50e80 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -358,12 +358,7 @@ SvXMLImportContextRef XMLSectionImportContext::CreateChildContext( XMLTextType::Section ); // if that fails, default context - if (nullptr == pContext) - { - pContext = new SvXMLImportContext( GetImport(), - nPrefix, rLocalName ); - } - else + if (pContext) bHasContent = true; } diff --git a/xmloff/source/text/XMLTextColumnsContext.cxx b/xmloff/source/text/XMLTextColumnsContext.cxx index b8f3d55e4884..622e1f38957d 100644 --- a/xmloff/source/text/XMLTextColumnsContext.cxx +++ b/xmloff/source/text/XMLTextColumnsContext.cxx @@ -320,10 +320,6 @@ SvXMLImportContextRef XMLTextColumnsContext::CreateChildContext( pContext = mxColumnSep.get(); } - else - { - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - } return pContext; } diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index c7e98d6791fc..d9819994e790 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1203,8 +1203,6 @@ SvXMLImportContextRef XMLTextFrameContext_Impl::CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, XMLTextType::TextBox ); - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } @@ -1696,9 +1694,6 @@ SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( m_xImplContext.get(), p_nPrefix, rLocalName, xAttrList ); } - if (!xContext) - xContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); - return xContext; } diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx index bd4bdd52be7a..e92d4656f47a 100644 --- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx +++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx @@ -123,8 +123,6 @@ SvXMLImportContextRef XMLTextFrameHyperlinkContext::CreateChildContext( pContext = pTextFrameContext; xFrameContext = pContext; } - else - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx index afc499d85a35..50414bd78b65 100644 --- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx +++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx @@ -172,8 +172,6 @@ SvXMLImportContextRef XMLTextHeaderFooterContext::CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, XMLTextType::HeaderFooter ); } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index 62b6c250949e..0ed4fb91d1be 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -271,8 +271,6 @@ SvXMLImportContextRef XMLTextListBlockContext::CreateChildContext( break; } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); return pContext; } diff --git a/xmloff/source/text/XMLTextListItemContext.cxx b/xmloff/source/text/XMLTextListItemContext.cxx index 7964d37aa310..a6050686e652 100644 --- a/xmloff/source/text/XMLTextListItemContext.cxx +++ b/xmloff/source/text/XMLTextListItemContext.cxx @@ -161,9 +161,6 @@ SvXMLImportContextRef XMLTextListItemContext::CreateChildContext( break; } - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); - return pContext; } diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index e44771a224a9..e836017f9396 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -696,9 +696,6 @@ SvXMLImportContextRef XMLImpRubyContext_Impl::CreateChildContext( rLocalName, xAttrList, *this ); - else - xContext = new SvXMLImportContext( - GetImport(), nPrefix, rLocalName ); } else xContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, @@ -1770,12 +1767,6 @@ SvXMLImportContextRef XMLImpSpanContext_Impl::CreateChildContext( rHints.push_back( std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos)); } - if( !pContext ) - { - // ignore unknown content - pContext = - new SvXMLImportContext( rImport, nPrefix, rLocalName ); - } // Behind fields, shapes and any unknown content blanks aren't ignored rIgnoreLeadingSpace = false; } diff --git a/xmloff/source/xforms/SchemaContext.cxx b/xmloff/source/xforms/SchemaContext.cxx index 210133a4868c..6c19cbfa019a 100644 --- a/xmloff/source/xforms/SchemaContext.cxx +++ b/xmloff/source/xforms/SchemaContext.cxx @@ -67,10 +67,10 @@ SvXMLImportContext* SchemaContext::HandleChild( const OUString& rLocalName, const Reference<XAttributeList>& ) { - return ( nToken == XML_SIMPLETYPE ) - ? new SchemaSimpleTypeContext( GetImport(), nPrefix, rLocalName, - mxRepository ) - : new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + if ( nToken == XML_SIMPLETYPE ) + return new SchemaSimpleTypeContext( GetImport(), nPrefix, rLocalName, + mxRepository ); + return nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx index dcff58b5675d..0c01874efbf5 100644 --- a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx +++ b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx @@ -72,21 +72,16 @@ SvXMLImportContext* SchemaSimpleTypeContext::HandleChild( const OUString& rLocalName, const Reference<XAttributeList>& ) { - SvXMLImportContext* pContext = nullptr; switch( nToken ) { case XML_RESTRICTION: - pContext = new SchemaRestrictionContext( GetImport(), + return new SchemaRestrictionContext( GetImport(), nPrefix, rLocalName, mxRepository, msTypeName ); break; - default: - OSL_FAIL( "Booo!" ); } - return ( pContext != nullptr ) - ? pContext - : new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); + return nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/xforms/TokenContext.cxx b/xmloff/source/xforms/TokenContext.cxx index 2178b38c4805..71215c4395d7 100644 --- a/xmloff/source/xforms/TokenContext.cxx +++ b/xmloff/source/xforms/TokenContext.cxx @@ -107,7 +107,6 @@ SvXMLImportContextRef TokenContext::CreateChildContext( if( pContext == nullptr ) { GetImport().SetError( XMLERROR_UNKNOWN_ELEMENT, rLocalName ); - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } return pContext; } diff --git a/xmloff/source/xforms/XFormsInstanceContext.cxx b/xmloff/source/xforms/XFormsInstanceContext.cxx index d8ea98e5d5b2..e1a81a3f6c37 100644 --- a/xmloff/source/xforms/XFormsInstanceContext.cxx +++ b/xmloff/source/xforms/XFormsInstanceContext.cxx @@ -77,7 +77,6 @@ SvXMLImportContextRef XFormsInstanceContext::CreateChildContext( if( mxInstance.is() ) { GetImport().SetError( XMLERROR_XFORMS_ONLY_ONE_INSTANCE_ELEMENT, rLocalName ); - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } else { |