[Libreoffice-commits] core.git: dbaccess/source sc/source xmloff/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Wed Feb 3 02:18:12 UTC 2016


 dbaccess/source/filter/xml/xmlfilter.cxx       |   17 ++++----
 sc/source/filter/xml/XMLTableShapesContext.cxx |   19 ++++-----
 sc/source/filter/xml/xmlcoli.cxx               |    7 ---
 sc/source/filter/xml/xmlconti.cxx              |    7 ---
 sc/source/filter/xml/xmldpimp.cxx              |   49 +++----------------------
 sc/source/filter/xml/xmldrani.cxx              |   21 +---------
 xmloff/source/draw/ximpnote.cxx                |   13 +-----
 7 files changed, 30 insertions(+), 103 deletions(-)

New commits:
commit bd76d319bbda17f242e64b042027077e84c0f1d9
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Tue Feb 2 19:19:19 2016 +0100

    remove bogus nullprt checks for pContext
    
    reported by Cppcheck
    
    Change-Id: I737c2bd7be197ef9d0b29b922acd8021fefb7af6
    Signed-off-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
    Reviewed-on: https://gerrit.libreoffice.org/22059
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx
index 702ac84..5453f39 100644
--- a/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -700,15 +700,14 @@ const SvXMLTokenMap& ODBFilter::GetColumnElemTokenMap() const
 SvXMLImportContext* ODBFilter::CreateStylesContext(sal_uInt16 _nPrefix,const OUString& rLocalName,
                                      const uno::Reference< XAttributeList>& xAttrList, bool bIsAutoStyle )
 {
-    SvXMLImportContext *pContext = nullptr;
-    if (!pContext)
-    {
-        pContext = new OTableStylesContext(*this, _nPrefix, rLocalName, xAttrList, bIsAutoStyle);
-        if (bIsAutoStyle)
-            SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext));
-        else
-            SetStyles(static_cast<SvXMLStylesContext*>(pContext));
-    }
+    SvXMLImportContext *pContext;
+
+    pContext = new OTableStylesContext(*this, _nPrefix, rLocalName, xAttrList, bIsAutoStyle);
+    if (bIsAutoStyle)
+        SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext));
+    else
+        SetStyles(static_cast<SvXMLStylesContext*>(pContext));
+
     return pContext;
 }
 
diff --git a/sc/source/filter/xml/XMLTableShapesContext.cxx b/sc/source/filter/xml/XMLTableShapesContext.cxx
index 05530fcf..53389bb 100644
--- a/sc/source/filter/xml/XMLTableShapesContext.cxx
+++ b/sc/source/filter/xml/XMLTableShapesContext.cxx
@@ -42,19 +42,16 @@ SvXMLImportContext *ScXMLTableShapesContext::CreateChildContext( sal_uInt16 nPre
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
 {
-    SvXMLImportContext *pContext(nullptr);
+    SvXMLImportContext *pContext = nullptr;
 
-    if (!pContext)
+    ScXMLImport& rXMLImport(GetScImport());
+    uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
+    if (xShapes.is())
     {
-        ScXMLImport& rXMLImport(GetScImport());
-        uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
-        if (xShapes.is())
-        {
-            XMLTableShapeImportHelper* pTableShapeImport(static_cast<XMLTableShapeImportHelper*>(rXMLImport.GetShapeImport().get()));
-            pTableShapeImport->SetOnTable(true);
-            pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
-                rXMLImport, nPrefix, rLName, xAttrList, xShapes);
-        }
+        XMLTableShapeImportHelper* pTableShapeImport(static_cast<XMLTableShapeImportHelper*>(rXMLImport.GetShapeImport().get()));
+        pTableShapeImport->SetOnTable(true);
+        pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
+            rXMLImport, nPrefix, rLName, xAttrList, xShapes);
     }
 
     if( !pContext )
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 2f88e64..bd1de55 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -94,12 +94,7 @@ SvXMLImportContext *ScXMLTableColContext::CreateChildContext( sal_uInt16 nPrefix
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLTableColContext::EndElement()
diff --git a/sc/source/filter/xml/xmlconti.cxx b/sc/source/filter/xml/xmlconti.cxx
index de74e81..800cfd4 100644
--- a/sc/source/filter/xml/xmlconti.cxx
+++ b/sc/source/filter/xml/xmlconti.cxx
@@ -48,8 +48,6 @@ SvXMLImportContext *ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefix,
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList )
 {
-    SvXMLImportContext *pContext = nullptr;
-
     if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S))
     {
         sal_Int32 nRepeat(0);
@@ -71,10 +69,7 @@ SvXMLImportContext *ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefix,
             sOUText.append(' ');
     }
 
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
 }
 
 void ScXMLContentContext::Characters( const OUString& rChars )
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 61e3db8..891db22 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -634,12 +634,7 @@ SvXMLImportContext *ScXMLDPSourceSQLContext::CreateChildContext( sal_uInt16 nPre
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDPSourceSQLContext::EndElement()
@@ -688,12 +683,7 @@ SvXMLImportContext *ScXMLDPSourceTableContext::CreateChildContext( sal_uInt16 nP
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDPSourceTableContext::EndElement()
@@ -742,12 +732,7 @@ SvXMLImportContext *ScXMLDPSourceQueryContext::CreateChildContext( sal_uInt16 nP
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDPSourceQueryContext::EndElement()
@@ -811,12 +796,7 @@ SvXMLImportContext *ScXMLSourceServiceContext::CreateChildContext( sal_uInt16 nP
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLSourceServiceContext::EndElement()
@@ -1567,12 +1547,7 @@ SvXMLImportContext *ScXMLDataPilotSubTotalContext::CreateChildContext( sal_uInt1
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDataPilotSubTotalContext::EndElement()
@@ -1676,12 +1651,7 @@ SvXMLImportContext *ScXMLDataPilotMemberContext::CreateChildContext( sal_uInt16
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDataPilotMemberContext::EndElement()
@@ -1905,12 +1875,7 @@ SvXMLImportContext *ScXMLDataPilotGroupMemberContext::CreateChildContext( sal_uI
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLDataPilotGroupMemberContext::EndElement()
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 22a4f76..476ec86 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -723,12 +723,7 @@ SvXMLImportContext *ScXMLConResContext::CreateChildContext( sal_uInt16 nPrefix,
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLConResContext::EndElement()
@@ -881,12 +876,7 @@ SvXMLImportContext *ScXMLSortGroupsContext::CreateChildContext( sal_uInt16 nPref
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLSortGroupsContext::EndElement()
@@ -997,12 +987,7 @@ SvXMLImportContext *ScXMLSubTotalFieldContext::CreateChildContext( sal_uInt16 nP
                                             const OUString& rLName,
                                             const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ )
 {
-    SvXMLImportContext *pContext = nullptr;
-
-    if( !pContext )
-        pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
-    return pContext;
+    return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
 void ScXMLSubTotalFieldContext::EndElement()
diff --git a/xmloff/source/draw/ximpnote.cxx b/xmloff/source/draw/ximpnote.cxx
index 7f82c1f..23272f3 100644
--- a/xmloff/source/draw/ximpnote.cxx
+++ b/xmloff/source/draw/ximpnote.cxx
@@ -96,17 +96,8 @@ SvXMLImportContext *SdXMLNotesContext::CreateChildContext( sal_uInt16 nPrefix,
     const OUString& rLocalName,
     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
 {
-    // OK, notes page is set on base class, objects can be imported on notes page
-    SvXMLImportContext *pContext = nullptr;
-
-    // some special objects inside presentation:notes context
-
-
-    // call parent when no own context was created
-    if(!pContext)
-        pContext = SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
-
-    return pContext;
+    // no own context in notes, call parent
+    return SdXMLGenericPageContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
 }
 
 void SdXMLNotesContext::EndElement()


More information about the Libreoffice-commits mailing list