tdf#120703 PVS: remove redundant static casts

V572 It is odd that the object which was created using 'new' operator
     is immediately cast to another type.

Change-Id: I6d1523e71b3e06be1cf41abaabb44e49fe11cd8e
Reviewed-on: https://gerrit.libreoffice.org/69369
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 8ccae47..5a763aa 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -1194,10 +1194,9 @@
        implExportLib( aLibName, aTmpPath, xDummyHandler );

        Reference< XCommandEnvironment > xCmdEnv =
            static_cast<XCommandEnvironment*>(
                new OLibCommandEnvironment(
                    Reference< task::XInteractionHandler >(
                        xHandler, UNO_QUERY ) ) );
                        xHandler, UNO_QUERY));

        ::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv, comphelper::getProcessComponentContext() );

diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx
index fa8343c..0f905fa 100644
--- a/comphelper/source/container/namecontainer.cxx
+++ b/comphelper/source/container/namecontainer.cxx
@@ -155,7 +155,7 @@

Reference< XNameContainer > comphelper::NameContainer_createInstance( const Type& aType )
{
    return static_cast<XNameContainer*>(new NameContainer( aType ));
    return new NameContainer(aType);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
index bd1cbe6..312ad44 100644
--- a/cppuhelper/source/propshlp.cxx
+++ b/cppuhelper/source/propshlp.cxx
@@ -248,7 +248,7 @@
Reference < XPropertySetInfo > OPropertySetHelper::createPropertySetInfo(
    IPropertyArrayHelper & rProperties )
{
    return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) );
    return new OPropertySetHelperInfo_Impl(rProperties);
}

// XPropertySet
diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx
index 6fe1bc4..879d0b0 100644
--- a/embeddedobj/source/msole/olevisual.cxx
+++ b/embeddedobj/source/msole/olevisual.cxx
@@ -367,8 +367,8 @@
            if ( aVisReplSeq.getLength() )
            {
                m_xCachedVisualRepresentation = GetNewFilledTempStream_Impl(
                        uno::Reference< io::XInputStream > ( static_cast< io::XInputStream* > (
                            new ::comphelper::SequenceInputStream( aVisReplSeq ) ) ) );
                    uno::Reference< io::XInputStream >(
                        new ::comphelper::SequenceInputStream(aVisReplSeq)));
            }

            return aVisualRepr;
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 5b271de..5f27ba5 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -806,7 +806,7 @@
        uno::Reference< io::XInputStream > xInStream;
        try
        {
            xInStream.set( static_cast< io::XInputStream* >( new OSelfTerminateFileStream( m_xContext, m_aTempURL ) ), uno::UNO_QUERY );
            xInStream = new OSelfTerminateFileStream(m_xContext, m_aTempURL);
        }
        catch( const uno::Exception& )
        {
diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx
index 3cc3cc0..844fd7a 100644
--- a/sfx2/source/notify/globalevents.cxx
+++ b/sfx2/source/notify/globalevents.cxx
@@ -319,9 +319,7 @@
    {
        models[i] <<= m_lModels[i];
    }
    uno::Reference< container::XEnumeration > xEnum(
        static_cast<container::XEnumeration*>(
            new ::comphelper::OAnyEnumeration(models)));
    uno::Reference<container::XEnumeration> xEnum(new ::comphelper::OAnyEnumeration(models));
    aLock.clear();
    // <- SAFE

diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index d3eae55..c1727b9 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -369,7 +369,7 @@

            ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext() );
            uno::Reference< io::XInputStream > xInStream = aResultContent.openStream();
            xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) );
            xResult = new OFSInputStreamContainer(xInStream);
        }
    }
    catch( embed::InvalidStorageException& )
@@ -1124,7 +1124,7 @@
                uno::Reference< io::XStream > xStream =
                    xSimpleFileAccess->openFileReadWrite( aFileURL );

                xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) );
                xResult = new OFSStreamContainer(xStream);
            }
            else
            {
@@ -1135,7 +1135,7 @@
                {
                    uno::Reference< io::XStream > xStream =
                        uno::Reference < io::XStream >( new ::utl::OStreamWrapper( std::move(pStream) ) );
                    xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) );
                    xResult = new OFSStreamContainer(xStream);
                }
            }

@@ -1156,7 +1156,7 @@

            ::ucbhelper::Content aResultContent( aFileURL, xDummyEnv, comphelper::getProcessComponentContext() );
            uno::Reference< io::XInputStream > xInStream = aResultContent.openStream();
            xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) );
            xResult = new OFSInputStreamContainer(xInStream);
        }
    }
    catch( embed::InvalidStorageException& )
diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx
index 8f576dc..fedcd4d 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -420,7 +420,7 @@
    Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents()
    {
        if( !mxEventContainer.is() )
            mxEventContainer = static_cast<XNameContainer*>(new toolkit::ScriptEventContainer());
            mxEventContainer = new toolkit::ScriptEventContainer();
        return mxEventContainer;
    }

diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index a5b4c0d..197f452 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -154,7 +154,7 @@
FileProvider::CreateInstance(
    const Reference< XMultiServiceFactory >& xMultiServiceFactory )
{
    XServiceInfo* xP = static_cast<XServiceInfo*>(new FileProvider( comphelper::getComponentContext(xMultiServiceFactory) ));
    XServiceInfo* xP = new FileProvider(comphelper::getComponentContext(xMultiServiceFactory));
    return Reference< XInterface >::query( xP );
}

diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx
index 82ee8dd..ef8fef5 100644
--- a/uui/source/passwordcontainer.cxx
+++ b/uui/source/passwordcontainer.cxx
@@ -406,8 +406,8 @@
PasswordContainerInteractionHandler_CreateInstance(
        const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
{
    lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
        new PasswordContainerInteractionHandler( comphelper::getComponentContext(rSMgr) ) );
    lang::XServiceInfo* pX
        = new PasswordContainerInteractionHandler(comphelper::getComponentContext(rSMgr));
    return uno::Reference< uno::XInterface >::query( pX );
}