Kaydet (Commit) cfbd830e authored tarafından Mike Kaganski's avatar Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 294b9a41
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
}
}
}
......
......@@ -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);
}
}
}
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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>();
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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:
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment