diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-02-11 09:02:13 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-02-12 09:04:54 +0100 |
commit | cfbd830e9c4d1877989bc4ad93109551a0a4b0b7 (patch) | |
tree | a050319e1167c816ac284894de0c2d4a535ee23a | |
parent | 294b9a415929f25982373e91cba9254686074b19 (diff) |
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: I5fee1c4bebd1972fbb5e43da37149d4e2ff6ce0d
Reviewed-on: https://gerrit.libreoffice.org/67664
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | accessibility/source/helper/acc_factory.cxx | 8 | ||||
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 2 | ||||
-rw-r--r-- | desktop/source/deployment/misc/dp_descriptioninfoset.cxx | 4 | ||||
-rw-r--r-- | eventattacher/source/eventattacher.cxx | 12 | ||||
-rw-r--r-- | scripting/source/basprov/baslibnode.cxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basmodnode.cxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basprov.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.cxx | 2 | ||||
-rw-r--r-- | stoc/source/defaultregistry/defaultregistry.cxx | 14 | ||||
-rw-r--r-- | ucb/source/core/FileAccess.cxx | 4 | ||||
-rw-r--r-- | ucb/source/core/cmdenv.cxx | 3 | ||||
-rw-r--r-- | unoxml/source/dom/document.cxx | 36 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificateviewer.cxx | 4 |
13 files changed, 43 insertions, 57 deletions
diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index aeca8b5d40ad..48458e8b62d3 100644 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -309,12 +309,12 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX else if ( nType == WindowType::STATUSBAR ) { - xContext = static_cast<XAccessibleContext*>(new VCLXAccessibleStatusBar( _pXWindow )); + xContext = new VCLXAccessibleStatusBar(_pXWindow); } else if ( nType == WindowType::TABCONTROL ) { - xContext = static_cast<XAccessibleContext*>(new VCLXAccessibleTabControl( _pXWindow )); + xContext = new VCLXAccessibleTabControl(_pXWindow); } else if ( nType == WindowType::TABPAGE && pWindow->GetAccessibleParentWindow() && pWindow->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL ) @@ -346,11 +346,11 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX else if ( ( nType == WindowType::HELPTEXTWINDOW ) || ( nType == WindowType::FIXEDLINE ) ) { - xContext = static_cast<XAccessibleContext*>(new VCLXAccessibleFixedText( _pXWindow )); + xContext = new VCLXAccessibleFixedText(_pXWindow); } else { - xContext = static_cast<XAccessibleContext*>(new VCLXAccessibleComponent( _pXWindow )); + xContext = new VCLXAccessibleComponent(_pXWindow); } } return xContext; diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 8a88185516b7..48eb1c8cf3e4 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -1243,7 +1243,7 @@ void DialogWindow::InitSettings() css::uno::Reference< css::accessibility::XAccessible > DialogWindow::CreateAccessible() { - return static_cast<css::accessibility::XAccessible*>(new AccessibleDialogWindow( this )); + return new AccessibleDialogWindow(this); } char const* DialogWindow::GetHid () const diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 55b73c2d0b26..2179d377957b 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -171,9 +171,7 @@ ExtensionDescription::ExtensionDescription( //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv //and filter the respective exception out. OUString sDescriptionUri(installDir + "/description.xml"); - Reference<css::ucb::XCommandEnvironment> xFilter = - static_cast<css::ucb::XCommandEnvironment*>( - new FileDoesNotExistFilter(xCmdEnv)); + Reference<css::ucb::XCommandEnvironment> xFilter = new FileDoesNotExistFilter(xCmdEnv); ::ucbhelper::Content descContent(sDescriptionUri, xFilter, xContext); //throws an css::uno::Exception if the file is not available diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx index 09d51b4843dd..2711dd28a01a 100644 --- a/eventattacher/source/eventattacher.cxx +++ b/eventattacher/source/eventattacher.cxx @@ -96,7 +96,7 @@ static Reference< XInterface > createAllListenerAdapter if( xInvocationAdapterFactory.is() && xListenerType.is() && xListener.is() ) { Reference< XInvocation > xInvocationToAllListenerMapper = - static_cast<XInvocation*>(new InvocationToAllListenerMapper( xListenerType, xListener, Helper )); + new InvocationToAllListenerMapper(xListenerType, xListener, Helper); Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName()); Sequence<Type> arg2(1); arg2[0] = aListenerType; @@ -278,7 +278,7 @@ EventAttacherImpl::EventAttacherImpl( const Reference< XComponentContext >& rxCo /// @throws Exception static Reference< XInterface > EventAttacherImpl_CreateInstance( const Reference< XMultiServiceFactory >& rSMgr ) { - XEventAttacher *pEventAttacher = static_cast<XEventAttacher*>(new EventAttacherImpl( comphelper::getComponentContext(rSMgr) )); + XEventAttacher* pEventAttacher = new EventAttacherImpl(comphelper::getComponentContext(rSMgr)); Reference< XInterface > xRet(pEventAttacher, UNO_QUERY); @@ -730,8 +730,8 @@ Reference< XEventListener > EventAttacherImpl::attachSingleEventListener ) { // Subscribe FilterListener - Reference< XAllListener > aFilterListener = static_cast<XAllListener*>( - new FilterAllListenerImpl( this, EventMethod, AllListener )); + Reference<XAllListener> aFilterListener + = new FilterAllListenerImpl(this, EventMethod, AllListener); return attachListener( xObject, aFilterListener, Helper, ListenerType, AddListenerParam); } @@ -846,8 +846,8 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachMultipleEventList Sequence< Reference<XAllListener> > aFilterListeners(nCount); for (sal_Int32 i = 0; i < nCount; ++i) { - aFilterListeners[i] = static_cast<XAllListener*>( - new FilterAllListenerImpl(this, aListeners[i].EventMethod, aListeners[i].AllListener)); + aFilterListeners[i] + = new FilterAllListenerImpl(this, aListeners[i].EventMethod, aListeners[i].AllListener); } return attachListeners(xObject, aFilterListeners, aListeners); diff --git a/scripting/source/basprov/baslibnode.cxx b/scripting/source/basprov/baslibnode.cxx index 0ace13a90dc9..015334f97ae0 100644 --- a/scripting/source/basprov/baslibnode.cxx +++ b/scripting/source/basprov/baslibnode.cxx @@ -96,7 +96,8 @@ namespace basprov { SbModule* pModule = pBasic->FindModule( pNames[i] ); if ( pModule ) - aChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicModuleNodeImpl( m_xContext, m_sScriptingContext, pModule, m_bIsAppScript ) ); + aChildNodes[i] = new BasicModuleNodeImpl(m_xContext, m_sScriptingContext, + pModule, m_bIsAppScript); } } } diff --git a/scripting/source/basprov/basmodnode.cxx b/scripting/source/basprov/basmodnode.cxx index b44416a479a2..684d5b1c67b1 100644 --- a/scripting/source/basprov/basmodnode.cxx +++ b/scripting/source/basprov/basmodnode.cxx @@ -97,7 +97,8 @@ namespace basprov { SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); if ( pMethod && !pMethod->IsHidden() ) - pChildNodes[iTarget++] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) ); + pChildNodes[iTarget++] = new BasicMethodNodeImpl( + m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript); } } } diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index 1055b57bd7d0..796b7ba391bd 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -448,8 +448,9 @@ namespace basprov } if ( bCreate ) { - pChildNodes[childrenFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( - m_xContext, m_sScriptingContext, pBasicManager, xLibContainer, pLibNames[i], m_bIsAppScriptCtx ) ); + pChildNodes[childrenFound++] + = new BasicLibraryNodeImpl(m_xContext, m_sScriptingContext, pBasicManager, + xLibContainer, pLibNames[i], m_bIsAppScriptCtx); } } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index f91bf1a547ee..dad65336ab45 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -2207,7 +2207,7 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) if( pDescriptor.get() && ( !pDescriptor->isTextOnly() || bHasText ) ) { sal_Int32 nPos = mpLBAnimation->InsertEntry( pDescriptor->getLabel() ); - mpLBAnimation->SetEntryData( nPos, static_cast<void*>( new CustomAnimationPresetPtr( pDescriptor ) ) ); + mpLBAnimation->SetEntryData(nPos, new CustomAnimationPresetPtr(pDescriptor)); if( nFirstEffect == LISTBOX_ENTRY_NOTFOUND ) nFirstEffect = nPos; diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx index 0e605fed9298..db6327353b53 100644 --- a/stoc/source/defaultregistry/defaultregistry.cxx +++ b/stoc/source/defaultregistry/defaultregistry.cxx @@ -641,7 +641,7 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::openKey( const OUString& aKeyN if ( localKey.is() || defaultKey.is() ) { - return static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey)); + return new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey); } else { @@ -678,7 +678,7 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKe m_state = m_xRegistry->m_state++; - return static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey)); + return new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey); } } else @@ -698,7 +698,7 @@ Reference< XRegistryKey > SAL_CALL NestedKeyImpl::createKey( const OUString& aKe m_state = m_xRegistry->m_state++; - return static_cast<XRegistryKey*>(new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey)); + return new NestedKeyImpl(m_xRegistry.get(), localKey, defaultKey); } } } @@ -786,8 +786,7 @@ Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( ) name = localSeq.getConstArray()[i]; lastIndex = name.lastIndexOf('/'); name = name.copy(lastIndex); - retSeq.getArray()[i] = - static_cast<XRegistryKey*>(new NestedKeyImpl(name, this)); + retSeq.getArray()[i] = new NestedKeyImpl(name, this); } sal_uInt32 k = local; @@ -810,8 +809,7 @@ Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( ) name = defaultSeq.getConstArray()[i]; lastIndex = name.lastIndexOf('/'); name = name.copy(lastIndex); - retSeq.getArray()[k++] = - static_cast<XRegistryKey*>(new NestedKeyImpl(name, this)); + retSeq.getArray()[k++] = new NestedKeyImpl(name, this); } } @@ -1236,7 +1234,7 @@ Reference< XRegistryKey > SAL_CALL NestedRegistryImpl::getRootKey( ) defaultKey = m_defaultReg->getRootKey(); } - return static_cast<XRegistryKey*>(new NestedKeyImpl(this, localKey, defaultKey)); + return new NestedKeyImpl(this, localKey, defaultKey); } return Reference<XRegistryKey>(); diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx index 98ac5260817d..21d4e0b9fbf0 100644 --- a/ucb/source/core/FileAccess.cxx +++ b/ucb/source/core/FileAccess.cxx @@ -492,7 +492,7 @@ Reference< XInputStream > OFileAccess::openFileRead( const OUString& FileURL ) INetURLObject aObj( FileURL, INetProtocol::File ); ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() ); - Reference< XActiveDataSink > xSink = static_cast<XActiveDataSink*>(new OActiveDataSink); + Reference<XActiveDataSink> xSink = new OActiveDataSink; try { @@ -519,7 +519,7 @@ Reference< XOutputStream > OFileAccess::openFileWrite( const OUString& FileURL ) Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL ) { - Reference< XActiveDataStreamer > xSink = static_cast<XActiveDataStreamer*>(new OActiveDataStreamer); + Reference<XActiveDataStreamer> xSink = new OActiveDataStreamer; OpenCommandArgument2 aArg; aArg.Mode = OpenMode::DOCUMENT; diff --git a/ucb/source/core/cmdenv.cxx b/ucb/source/core/cmdenv.cxx index 8c84e37a90cb..b49ebc3d4f51 100644 --- a/ucb/source/core/cmdenv.cxx +++ b/ucb/source/core/cmdenv.cxx @@ -129,8 +129,7 @@ static uno::Reference< uno::XInterface > UcbCommandEnvironment_CreateInstance( const uno::Reference< lang::XMultiServiceFactory> & /*rSMgr*/ ) { - lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( - new UcbCommandEnvironment ); + lang::XServiceInfo* pX = new UcbCommandEnvironment; return uno::Reference< uno::XInterface >::query( pX ); } diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index 7380bcdc4a9b..94dce24255ac 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -187,66 +187,54 @@ namespace DOM { case XML_ELEMENT_NODE: // m_aNodeType = NodeType::ELEMENT_NODE; - pCNode = static_cast< CNode* >( - new CElement(*this, m_Mutex, pNode)); + pCNode = new CElement(*this, m_Mutex, pNode); break; case XML_TEXT_NODE: // m_aNodeType = NodeType::TEXT_NODE; - pCNode = static_cast< CNode* >( - new CText(*this, m_Mutex, pNode)); + pCNode = new CText(*this, m_Mutex, pNode); break; case XML_CDATA_SECTION_NODE: // m_aNodeType = NodeType::CDATA_SECTION_NODE; - pCNode = static_cast< CNode* >( - new CCDATASection(*this, m_Mutex, pNode)); + pCNode = new CCDATASection(*this, m_Mutex, pNode); break; case XML_ENTITY_REF_NODE: // m_aNodeType = NodeType::ENTITY_REFERENCE_NODE; - pCNode = static_cast< CNode* >( - new CEntityReference(*this, m_Mutex, pNode)); + pCNode = new CEntityReference(*this, m_Mutex, pNode); break; case XML_ENTITY_NODE: // m_aNodeType = NodeType::ENTITY_NODE; - pCNode = static_cast< CNode* >(new CEntity(*this, m_Mutex, - reinterpret_cast<xmlEntityPtr>(pNode))); + pCNode = new CEntity(*this, m_Mutex, reinterpret_cast<xmlEntityPtr>(pNode)); break; case XML_PI_NODE: // m_aNodeType = NodeType::PROCESSING_INSTRUCTION_NODE; - pCNode = static_cast< CNode* >( - new CProcessingInstruction(*this, m_Mutex, pNode)); + pCNode = new CProcessingInstruction(*this, m_Mutex, pNode); break; case XML_COMMENT_NODE: // m_aNodeType = NodeType::COMMENT_NODE; - pCNode = static_cast< CNode* >( - new CComment(*this, m_Mutex, pNode)); + pCNode = new CComment(*this, m_Mutex, pNode); break; case XML_DOCUMENT_NODE: // m_aNodeType = NodeType::DOCUMENT_NODE; OSL_ENSURE(false, "CDocument::GetCNode is not supposed to" " create a CDocument!!!"); - pCNode = static_cast< CNode* >(new CDocument( - reinterpret_cast<xmlDocPtr>(pNode))); + pCNode = new CDocument(reinterpret_cast<xmlDocPtr>(pNode)); break; case XML_DOCUMENT_TYPE_NODE: case XML_DTD_NODE: // m_aNodeType = NodeType::DOCUMENT_TYPE_NODE; - pCNode = static_cast< CNode* >(new CDocumentType(*this, m_Mutex, - reinterpret_cast<xmlDtdPtr>(pNode))); + pCNode = new CDocumentType(*this, m_Mutex, reinterpret_cast<xmlDtdPtr>(pNode)); break; case XML_DOCUMENT_FRAG_NODE: // m_aNodeType = NodeType::DOCUMENT_FRAGMENT_NODE; - pCNode = static_cast< CNode* >( - new CDocumentFragment(*this, m_Mutex, pNode)); + pCNode = new CDocumentFragment(*this, m_Mutex, pNode); break; case XML_NOTATION_NODE: // m_aNodeType = NodeType::NOTATION_NODE; - pCNode = static_cast< CNode* >(new CNotation(*this, m_Mutex, - reinterpret_cast<xmlNotationPtr>(pNode))); + pCNode = new CNotation(*this, m_Mutex, reinterpret_cast<xmlNotationPtr>(pNode)); break; case XML_ATTRIBUTE_NODE: // m_aNodeType = NodeType::ATTRIBUTE_NODE; - pCNode = static_cast< CNode* >(new CAttr(*this, m_Mutex, - reinterpret_cast<xmlAttrPtr>(pNode))); + pCNode = new CAttr(*this, m_Mutex, reinterpret_cast<xmlAttrPtr>(pNode)); break; // unsupported node types case XML_HTML_DOCUMENT_NODE: diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx index df5d6b0f68c1..0731a01cf0c1 100644 --- a/xmlsecurity/source/dialogs/certificateviewer.cxx +++ b/xmlsecurity/source/dialogs/certificateviewer.cxx @@ -229,7 +229,7 @@ void CertificateViewerDetailsTP::InsertElement( const OUString& _rField, const O { SvTreeListEntry* pEntry = m_pElementsLB->InsertEntry( _rField ); m_pElementsLB->SetEntryText( _rValue, pEntry, 1 ); - pEntry->SetUserData( static_cast<void*>(new Details_UserDatat( _rDetails, _bFixedWidthFont )) ); + pEntry->SetUserData(new Details_UserDatat(_rDetails, _bFixedWidthFont)); } CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, CertificateViewer* _pDlg ) @@ -500,7 +500,7 @@ SvTreeListEntry* CertificateViewerCertPathTP::InsertCert( { Image aImage = bValid ? maCertImage : maCertNotValidatedImage; SvTreeListEntry* pEntry = mpCertPathLB->InsertEntry( _rName, aImage, aImage, _pParent ); - pEntry->SetUserData( static_cast<void*>(new CertPath_UserData( rxCert, bValid )) ); + pEntry->SetUserData(new CertPath_UserData(rxCert, bValid)); return pEntry; } |