Kaydet (Commit) 184be2d1 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: I54976062dc3f62eaaa79f89eff54454f0b24ac2c
Reviewed-on: https://gerrit.libreoffice.org/69989
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst f42d729e
......@@ -3892,7 +3892,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;
......
......@@ -81,10 +81,7 @@ uno::Reference< io::XInputStream > OSeekableInputWrapper::CheckSeekableCanWrap(
if ( xSeek.is() )
return xInStream;
uno::Reference< io::XInputStream > xNewStream(
static_cast< io::XInputStream* >(
new OSeekableInputWrapper( xInStream, rxContext ) ) );
return xNewStream;
return new OSeekableInputWrapper(xInStream, rxContext);
}
......
......@@ -42,7 +42,8 @@ namespace
Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
{
return Reference< XInterface >( static_cast< XClipboard* >( new CWinClipboard( comphelper::getComponentContext(rServiceManager), "" ) ) );
return static_cast<XClipboard*>(
new CWinClipboard(comphelper::getComponentContext(rServiceManager), ""));
}
}
......
......@@ -96,8 +96,7 @@ void DragSource::StartDragImpl(
// to the IDropSource interface implemented in this class (but only
// while this function executes). The source context is also used
// in DragSource::QueryContinueDrag.
m_currentContext= static_cast<XDragSourceContext*>( new SourceContext(
this, listener ) );
m_currentContext = new SourceContext(this, listener);
// Convert the XTransferable data object into an IDataObject object;
......
......@@ -312,8 +312,7 @@ HRESULT DropTarget::DragEnter( IDataObject *pDataObj,
// will be DROPEFFECT_NONE throughout
m_nLastDropAction= ACTION_DEFAULT | ACTION_MOVE;
m_currentDragContext= static_cast<XDropTargetDragContext*>( new TargetDragContext(
this ) );
m_currentDragContext = new TargetDragContext(this);
//--> TRA
......@@ -451,7 +450,7 @@ HRESULT DropTarget::Drop( IDataObject * /*pDataObj*/,
m_bDropComplete= false;
m_nCurrentDropAction= getFilteredActions( grfKeyState, *pdwEffect);
m_currentDropContext= static_cast<XDropTargetDropContext*>( new TargetDropContext( this ) );
m_currentDropContext = new TargetDropContext(this);
if( m_nCurrentDropAction)
{
DropTargetDropEvent e;
......
......@@ -2014,7 +2014,7 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp(
// connect parser and filter
uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create( xContext );
uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = static_cast< xml::sax::XFastTokenHandler* >( new SvXMLAutoCorrectTokenHandler );
uno::Reference<xml::sax::XFastTokenHandler> xTokenHandler = new SvXMLAutoCorrectTokenHandler;
xParser->setFastDocumentHandler( xFilter );
xParser->registerNamespace( "http://openoffice.org/2001/block-list", SvXMLAutoCorrectToken::NAMESPACE );
xParser->setTokenHandler( xTokenHandler );
......@@ -2124,7 +2124,7 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList()
uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext);
SAL_INFO("editeng", "AutoCorrect Import" );
uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xContext, pAutocorr_List.get(), rAutoCorrect, xStg );
uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = static_cast< xml::sax::XFastTokenHandler* >( new SvXMLAutoCorrectTokenHandler );
uno::Reference<xml::sax::XFastTokenHandler> xTokenHandler = new SvXMLAutoCorrectTokenHandler;
// connect parser and filter
xParser->setFastDocumentHandler( xFilter );
......
......@@ -1931,13 +1931,11 @@ uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumera
{
ESelection aSelection;
::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
uno::Reference< container::XEnumeration > xEnum( static_cast<container::XEnumeration*>( new SvxUnoTextContentEnumeration( *this, aSelection ) ) );
return xEnum;
return new SvxUnoTextContentEnumeration(*this, aSelection);
}
else
{
uno::Reference< container::XEnumeration > xEnum( static_cast<container::XEnumeration*>( new SvxUnoTextContentEnumeration( *this, maSelection ) ) );
return xEnum;
return new SvxUnoTextContentEnumeration(*this, maSelection);
}
}
......
......@@ -191,7 +191,7 @@ ShapeContextHandler::getDrawingShapeContext()
{
mpDrawing.reset( new oox::vml::Drawing( *mxFilterBase, mxDrawPage, oox::vml::VMLDRAWING_WORD ) );
mxDrawingFragmentHandler.set
(dynamic_cast<ContextHandler *>
(static_cast<ContextHandler *>
(new oox::vml::DrawingFragment
( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
}
......@@ -203,7 +203,7 @@ ShapeContextHandler::getDrawingShapeContext()
{
mxDrawingFragmentHandler.clear();
mxDrawingFragmentHandler.set
(dynamic_cast<ContextHandler *>
(static_cast<ContextHandler *>
(new oox::vml::DrawingFragment
( *mxFilterBase, msRelationFragmentPath, *mpDrawing )));
}
......
......@@ -92,13 +92,9 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstance()
io::TempFile::create(m_xContext),
uno::UNO_QUERY_THROW );
return uno::Reference< uno::XInterface >(
static_cast< OWeakObject* >( new OStorage( xTempStream,
embed::ElementModes::READWRITE,
uno::Sequence< beans::PropertyValue >(),
m_xContext,
embed::StorageFormats::PACKAGE ) ),
uno::UNO_QUERY );
return static_cast<OWeakObject*>(new OStorage(xTempStream, embed::ElementModes::READWRITE,
uno::Sequence<beans::PropertyValue>(), m_xContext,
embed::StorageFormats::PACKAGE));
}
uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithArguments(
......@@ -260,9 +256,8 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
if ( !CheckPackageSignature_Impl( xInputStream, xSeekable ) )
throw io::IOException(); // TODO: this is not a package file
return uno::Reference< uno::XInterface >(
static_cast< OWeakObject* >( new OStorage( xInputStream, nStorageMode, aPropsToSet, m_xContext, nStorageType ) ),
uno::UNO_QUERY );
return static_cast<OWeakObject*>(
new OStorage(xInputStream, nStorageMode, aPropsToSet, m_xContext, nStorageType));
}
else if ( xStream.is() )
{
......@@ -280,9 +275,8 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
if ( !CheckPackageSignature_Impl( xStream->getInputStream(), xSeekable ) )
throw io::IOException(); // TODO: this is not a package file
return uno::Reference< uno::XInterface >(
static_cast< OWeakObject* >( new OStorage( xStream, nStorageMode, aPropsToSet, m_xContext, nStorageType ) ),
uno::UNO_QUERY );
return static_cast<OWeakObject*>(
new OStorage(xStream, nStorageMode, aPropsToSet, m_xContext, nStorageType));
}
throw uno::Exception("no input stream or regular stream", nullptr); // general error during creation
......
......@@ -294,8 +294,8 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
// create a new package stream
uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY_THROW );
xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
new WrapStreamForShare( GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef() ) ) );
xNewPackStream->setDataStream(
new WrapStreamForShare(GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef()));
uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY_THROW );
......
......@@ -715,7 +715,7 @@ uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages(
if( !xDrawPages.is() )
{
initializeDocument();
mxDrawPagesAccess = xDrawPages = static_cast<drawing::XDrawPages*>(new SdDrawPagesAccess(*this));
mxDrawPagesAccess = xDrawPages = new SdDrawPagesAccess(*this);
}
return xDrawPages;
......
......@@ -343,7 +343,7 @@ uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages(
uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
if( !xDrawPages.is() )
mxDrawPagesAccess = xDrawPages = static_cast<drawing::XDrawPages*>(new SvxUnoDrawPagesAccess(*this));
mxDrawPagesAccess = xDrawPages = new SvxUnoDrawPagesAccess(*this);
return xDrawPages;
}
......
......@@ -754,8 +754,7 @@ void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxT
implUpdateVisibility( nDialogStep, xContainer );
uno::Reference< beans::XPropertyChangeListener > xListener =
static_cast< beans::XPropertyChangeListener* >(
new DialogStepChangedListener( xContainer ) );
new DialogStepChangedListener(xContainer);
xPSet->addPropertyChangeListener( aPropName, xListener );
}
......
......@@ -54,9 +54,7 @@ XSERVICEINFO_COMMOM_IMPL( UcbContentProviderProxyFactory,
static css::uno::Reference< css::uno::XInterface >
UcbContentProviderProxyFactory_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
{
css::lang::XServiceInfo* pX =
static_cast<css::lang::XServiceInfo*>(new UcbContentProviderProxyFactory( rSMgr ));
return css::uno::Reference< css::uno::XInterface >::query( pX );
return static_cast<css::lang::XServiceInfo*>(new UcbContentProviderProxyFactory(rSMgr));
}
css::uno::Sequence< OUString >
UcbContentProviderProxyFactory::getSupportedServiceNames_Static()
......
......@@ -200,9 +200,7 @@ XSERVICEINFO_COMMOM_IMPL( UcbPropertiesManager,
static css::uno::Reference< css::uno::XInterface >
UcbPropertiesManager_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & /*rSMgr*/ )
{
css::lang::XServiceInfo* pX =
static_cast<css::lang::XServiceInfo*>(new UcbPropertiesManager);
return css::uno::Reference< css::uno::XInterface >::query( pX );
return static_cast<css::lang::XServiceInfo*>(new UcbPropertiesManager);
}
css::uno::Sequence< OUString >
UcbPropertiesManager::getSupportedServiceNames_Static()
......
......@@ -163,9 +163,8 @@ XSERVICEINFO_COMMOM_IMPL( UcbStore,
static css::uno::Reference< css::uno::XInterface >
UcbStore_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
{
css::lang::XServiceInfo* pX =
static_cast<css::lang::XServiceInfo*>(new UcbStore( ucbhelper::getComponentContext(rSMgr) ));
return css::uno::Reference< css::uno::XInterface >::query( pX );
return static_cast<css::lang::XServiceInfo*>(
new UcbStore(ucbhelper::getComponentContext(rSMgr)));
}
css::uno::Sequence< OUString >
......
......@@ -443,9 +443,8 @@ static css::uno::Reference< css::uno::XInterface >
SortedDynamicResultSetFactory_CreateInstance( const css::uno::Reference<
css::lang::XMultiServiceFactory> & rSMgr )
{
css::lang::XServiceInfo* pX = static_cast<css::lang::XServiceInfo*>(
new SortedDynamicResultSetFactory( ucbhelper::getComponentContext(rSMgr) ));
return css::uno::Reference< css::uno::XInterface >::query( pX );
return static_cast<css::lang::XServiceInfo*>(
new SortedDynamicResultSetFactory(ucbhelper::getComponentContext(rSMgr)));
}
css::uno::Sequence< OUString > SortedDynamicResultSetFactory::getSupportedServiceNames_Static()
......
......@@ -126,9 +126,7 @@ static uno::Reference< uno::XInterface >
DocumentContentFactory_CreateInstance(
const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
{
lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
new DocumentContentFactory( rSMgr ) );
return uno::Reference< uno::XInterface >::query( pX );
return static_cast<lang::XServiceInfo*>(new DocumentContentFactory(rSMgr));
}
......
......@@ -1278,9 +1278,9 @@ UcbLockBytesRef UcbLockBytes::CreateLockBytes( const Reference < XContent >& xCo
xLockBytes->SetSynchronMode();
Reference< XActiveDataControl > xSink;
if ( eOpenMode & StreamMode::WRITE )
xSink = static_cast<XActiveDataControl*>(new UcbStreamer_Impl( xLockBytes.get() ));
xSink = new UcbStreamer_Impl(xLockBytes.get());
else
xSink = static_cast<XActiveDataControl*>(new UcbDataSink_Impl( xLockBytes.get() ));
xSink = new UcbDataSink_Impl(xLockBytes.get());
if ( rProps.getLength() )
{
......
......@@ -144,8 +144,7 @@ std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileNa
// create a specialized interaction handler to manages Web certificates and Web credentials when needed
Reference< XInteractionHandler > xIH(
css::task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr ) );
Reference < XInteractionHandler > xIHScoped( static_cast< XInteractionHandler *> (
new comphelper::SimpleFileAccessInteraction( xIH ) ) );
Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH));
return lcl_CreateStream( rFileName, eOpenMode, xIHScoped, true /* bEnsureFileExists */ );
}
......@@ -157,8 +156,7 @@ std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileNa
// create a specialized interaction handler to manages Web certificates and Web credentials when needed
Reference< XInteractionHandler > xIH(
css::task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr ) );
Reference < XInteractionHandler > xIHScoped( static_cast< XInteractionHandler *> (
new comphelper::SimpleFileAccessInteraction( xIH ) ) );
Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH));
return lcl_CreateStream( rFileName, eOpenMode, xIHScoped,!bFileExists );
}
......
......@@ -49,7 +49,7 @@ namespace XPath
// factory
Reference< XInterface > CXPathAPI::_getInstance(const Reference< XMultiServiceFactory >& rSMgr)
{
return Reference< XInterface >(static_cast<XXPathAPI*>(new CXPathAPI(rSMgr)));
return static_cast<XXPathAPI*>(new CXPathAPI(rSMgr));
}
// ctor
......
......@@ -574,7 +574,7 @@ zipOpen(SAL_UNUSED_PARAMETER const char *) {
OUString language,jar,path;
if( !ugblData->m_pInitial->get_eid().isEmpty() )
return static_cast<void*>(new Reference< XHierarchicalNameAccess >);
return new Reference<XHierarchicalNameAccess>;
else
{
jar = ugblData->m_pInitial->get_jar();
......
......@@ -153,8 +153,8 @@ Reference< XInterface > SAL_CALL
TVFactory::CreateInstance(
const Reference< XMultiServiceFactory >& xMultiServiceFactory )
{
XServiceInfo* xP = static_cast<XServiceInfo*>(new TVFactory( comphelper::getComponentContext(xMultiServiceFactory) ));
return Reference< XInterface >::query( xP );
return static_cast<XServiceInfo*>(
new TVFactory(comphelper::getComponentContext(xMultiServiceFactory)));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -506,10 +506,8 @@ void DocumentHandlerImpl::startElement(
}
pPrefixes.reset();
// ownership of arrays belongs to attribute list
xAttributes = static_cast< xml::input::XAttributes * >(
new ExtendedAttributes(
nAttribs, std::move(pUids), std::move(pLocalNames), std::move(pQNames),
xAttribs ) );
xAttributes = new ExtendedAttributes(nAttribs, std::move(pUids), std::move(pLocalNames),
std::move(pQNames), xAttribs);
getElementName( rQElementName, &nUid, &aLocalName );
......@@ -704,8 +702,7 @@ Reference< xml::sax::XDocumentHandler > createDocumentHandler(
SAL_WARN_IF( !xRoot.is(), "xmlscript.xmlhelper", "xRoot is NULL" );
if (xRoot.is())
{
return static_cast< xml::sax::XDocumentHandler * >(
new DocumentHandlerImpl( xRoot, true /* mt use */ ) );
return new DocumentHandlerImpl(xRoot, true /* mt use */);
}
return Reference< xml::sax::XDocumentHandler >();
}
......
......@@ -1767,8 +1767,7 @@ Reference< xml::sax::XDocumentHandler > importDialogModel(
std::shared_ptr< std::vector< OUString > > pStyleNames( new std::vector< OUString > );
std::shared_ptr< std::vector< css::uno::Reference< css::xml::input::XElement > > > pStyles( new std::vector< css::uno::Reference< css::xml::input::XElement > > );
return ::xmlscript::createDocumentHandler(
static_cast< xml::input::XRoot * >(
new DialogImport( xContext, xDialogModel, pStyleNames, pStyles, xDocument ) ) );
new DialogImport(xContext, xDialogModel, pStyleNames, pStyles, xDocument));
}
}
......
......@@ -233,15 +233,13 @@ void LibraryElement::endElement()
Reference< css::xml::sax::XDocumentHandler >
importLibraryContainer( LibDescriptorArray* pLibArray )
{
return ::xmlscript::createDocumentHandler(
static_cast< xml::input::XRoot * >( new LibraryImport( pLibArray ) ) );
return ::xmlscript::createDocumentHandler(new LibraryImport(pLibArray));
}
css::uno::Reference< css::xml::sax::XDocumentHandler >
importLibrary( LibDescriptor& rLib )
{
return ::xmlscript::createDocumentHandler(
static_cast< xml::input::XRoot * >( new LibraryImport( &rLib ) ) );
return ::xmlscript::createDocumentHandler(new LibraryImport(&rLib));
}
LibDescriptorArray::LibDescriptorArray( sal_Int32 nLibCount )
......
......@@ -146,8 +146,7 @@ ModuleImport::~ModuleImport()
Reference< xml::sax::XDocumentHandler >
importScriptModule( ModuleDescriptor& rMod )
{
return ::xmlscript::createDocumentHandler(
static_cast< xml::input::XRoot * >( new ModuleImport( rMod ) ) );
return ::xmlscript::createDocumentHandler(new ModuleImport(rMod));
}
}
......
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