loplugin:referencecasting in avmedia..basic

Change-Id: I6790b2e3902d64fb6f714f031affa221dbaba014
Reviewed-on: https://gerrit.libreoffice.org/75934
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2019-07-19 09:49:23 +02:00
parent 1f6c4328bf
commit ee2bb23103
14 changed files with 62 additions and 98 deletions

View File

@ -152,11 +152,7 @@ void MediaWindowImpl::dispose()
mxPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( pEventsIf, uno::UNO_QUERY ) );
mxPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( pEventsIf, uno::UNO_QUERY ) );
mxPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( pEventsIf, uno::UNO_QUERY ) );
uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY );
if (xComponent.is())
xComponent->dispose();
mxPlayerWindow->dispose();
mxPlayerWindow.clear();
}
@ -222,7 +218,7 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer(
xContext->getServiceManager()->createInstanceWithContext(rManagerServName, xContext),
uno::UNO_QUERY );
if( xManager.is() )
xPlayer.set( xManager->createPlayer( rURL ), uno::UNO_QUERY );
xPlayer = xManager->createPlayer( rURL );
else
SAL_INFO( "avmedia", "failed to create media player service " << rManagerServName );
} catch ( const uno::Exception & )

View File

@ -169,7 +169,7 @@ vcl::Window* AccessibleDialogControlShape::GetWindow() const
vcl::Window* pWindow = nullptr;
if ( m_pDlgEdObj )
{
Reference< awt::XControl > xControl( m_pDlgEdObj->GetControl(), UNO_QUERY );
Reference< awt::XControl > xControl = m_pDlgEdObj->GetControl();
if ( xControl.is() )
pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() ).get();
}

View File

@ -1034,16 +1034,14 @@ bool implImportDialog(weld::Window* pWin, const OUString& rCurPath, const Script
}
else if( !bLibLocalized )
{
Reference< resource::XStringResourceManager > xImportStringResourceManager( xImportStringResource, UNO_QUERY );
LocalizationMgr::resetResourceForDialog( xDialogModel, xImportStringResourceManager );
LocalizationMgr::resetResourceForDialog( xDialogModel, xImportStringResource );
bCopyResourcesForDialog = false;
}
if( bCopyResourcesForDialog )
{
Reference< resource::XStringResourceResolver > xImportStringResourceResolver( xImportStringResource, UNO_QUERY );
LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, aXmlDlgName,
xLibStringResourceManager, xImportStringResourceResolver );
xLibStringResourceManager, xImportStringResource );
}
}
else if( bLibLocalized )

View File

@ -696,20 +696,16 @@ void TreeListBox::GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& r
try
{
OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
if ( xModuleConfig.is() )
Sequence< beans::PropertyValue > aModuleDescr;
xModuleManager->getByName( sModule ) >>= aModuleDescr;
sal_Int32 nCount = aModuleDescr.getLength();
const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
Sequence< beans::PropertyValue > aModuleDescr;
xModuleConfig->getByName( sModule ) >>= aModuleDescr;
sal_Int32 nCount = aModuleDescr.getLength();
const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
for ( sal_Int32 i = 0; i < nCount; ++i )
if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
{
if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
{
pModuleDescr[ i ].Value >>= sFactoryURL;
break;
}
pModuleDescr[ i ].Value >>= sFactoryURL;
break;
}
}
}
@ -1392,20 +1388,16 @@ OUString SbTreeListBox::GetRootEntryBitmaps(const ScriptDocument& rDocument)
try
{
OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
if ( xModuleConfig.is() )
Sequence< beans::PropertyValue > aModuleDescr;
xModuleManager->getByName( sModule ) >>= aModuleDescr;
sal_Int32 nCount = aModuleDescr.getLength();
const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
Sequence< beans::PropertyValue > aModuleDescr;
xModuleConfig->getByName( sModule ) >>= aModuleDescr;
sal_Int32 nCount = aModuleDescr.getLength();
const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
for ( sal_Int32 i = 0; i < nCount; ++i )
if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
{
if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
{
pModuleDescr[ i ].Value >>= sFactoryURL;
break;
}
pModuleDescr[ i ].Value >>= sFactoryURL;
break;
}
}
}

View File

@ -89,7 +89,7 @@ void TreeListBox::RequestingChildren( SvTreeListEntry* pEntry )
// load dialog library
bool bDlgLibLoaded = false;
Reference< script::XLibraryContainer > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer > xDlgLibContainer = aDocument.getLibraryContainer( E_DIALOGS );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
{
if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
@ -178,7 +178,7 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b
// load dialog library
bool bDlgLibLoaded = false;
Reference< script::XLibraryContainer > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
Reference< script::XLibraryContainer > xDlgLibContainer = aDocument.getLibraryContainer( E_DIALOGS );
if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
{
if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) )

View File

@ -179,7 +179,7 @@ IMPL_STATIC_LINK(ExtraData, GlobalBasicBreakHdl, StarBASIC *, pBasic, BasicDebug
if ( aDocument.isValid() )
{
OUString aOULibName( pBasic->GetName() );
Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer > xModLibContainer = aDocument.getLibraryContainer( E_SCRIPTS );
if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
{
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );

View File

@ -271,8 +271,7 @@ IMPL_LINK(LibPage, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
{
OUString aPassword;
Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
}
if ( !bOK )
return false;
@ -613,13 +612,13 @@ void LibPage::InsertLib()
OUString aModURL( aModURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
if ( xSFA->exists( aModURL ) )
{
xModLibContImport.set( script::DocumentScriptLibraryContainer::createWithURL(xContext, aModURL), UNO_QUERY );
xModLibContImport = script::DocumentScriptLibraryContainer::createWithURL(xContext, aModURL);
}
OUString aDlgURL( aDlgURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
if ( xSFA->exists( aDlgURL ) )
{
xDlgLibContImport.set( script::DocumentDialogLibraryContainer::createWithURL(xContext, aDlgURL), UNO_QUERY );
xDlgLibContImport = script::DocumentDialogLibraryContainer::createWithURL(xContext, aDlgURL);
}
if ( !xModLibContImport.is() && !xDlgLibContImport.is() )
@ -627,9 +626,7 @@ void LibPage::InsertLib()
std::shared_ptr<LibDialog> xLibDlg;
Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY );
Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY );
Sequence< OUString > aLibNames = GetMergedLibraryNames( xModLibContImp, xDlgLibContImp );
Sequence< OUString > aLibNames = GetMergedLibraryNames( xModLibContImport, xDlgLibContImport );
sal_Int32 nLibCount = aLibNames.getLength();
const OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
@ -672,7 +669,7 @@ void LibPage::InsertLib()
if ( aExtension != aLibExtension && aExtension != aContExtension )
xLibDlg->EnableReference(false);
weld::DialogController::runAsync(xLibDlg, [aContExtension, aDlgURLObj, aExtension, aLibExtension, aModURLObj, xLibDlg, xDlgLibContImport, xModLibContImp, xModLibContImport, this](sal_Int32 nResult)
weld::DialogController::runAsync(xLibDlg, [aContExtension, aDlgURLObj, aExtension, aLibExtension, aModURLObj, xLibDlg, xDlgLibContImport, xModLibContImport, this](sal_Int32 nResult)
{
if (!nResult )
return;
@ -744,7 +741,7 @@ void LibPage::InsertLib()
Reference< script::XLibraryContainerPassword > xPasswd( xModLibContImport, UNO_QUERY );
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) && !bReference )
{
bOK = QueryPassword( xModLibContImp, aLibName, aPassword, true, true );
bOK = QueryPassword( xModLibContImport, aLibName, aPassword, true, true );
if ( !bOK )
{
@ -928,8 +925,7 @@ void LibPage::Export()
if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
{
OUString aPassword;
Reference< script::XLibraryContainer > xModLibContainer1( xModLibContainer, UNO_QUERY );
bOK = QueryPassword( xModLibContainer1, aLibName, aPassword );
bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
}
if ( !bOK )
return;
@ -1052,10 +1048,7 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
implExportLib( aLibName, aTmpPath, xDummyHandler );
Reference< XCommandEnvironment > xCmdEnv =
new OLibCommandEnvironment(
Reference< task::XInteractionHandler >(
xHandler, UNO_QUERY));
Reference< XCommandEnvironment > xCmdEnv = new OLibCommandEnvironment(xHandler);
::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv, comphelper::getProcessComponentContext() );

View File

@ -165,8 +165,7 @@ void Shell::CopyDialogResources(
{
if( bSourceLocalized && bDestLocalized )
{
Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY );
LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver );
LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr );
}
else if( bSourceLocalized )
{

View File

@ -362,11 +362,10 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
pDlgEdForm->StartListening();
// create controls
Reference< css::container::XNameAccess > xNameAcc( m_xUnoControlDialogModel, UNO_QUERY );
if ( xNameAcc.is() )
if ( m_xUnoControlDialogModel.is() )
{
// get sequence of control names
Sequence< OUString > aNames = xNameAcc->getElementNames();
Sequence< OUString > aNames = m_xUnoControlDialogModel->getElementNames();
const OUString* pNames = aNames.getConstArray();
sal_Int32 nCtrls = aNames.getLength();
@ -379,7 +378,7 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
// get tab index
sal_Int16 nTabIndex = -1;
Any aCtrl = xNameAcc->getByName( aName );
Any aCtrl = m_xUnoControlDialogModel->getByName( aName );
Reference< css::beans::XPropertySet > xPSet;
aCtrl >>= xPSet;
if ( xPSet.is() )
@ -392,7 +391,7 @@ void DlgEditor::SetDialog( const uno::Reference< container::XNameContainer >& xU
// create controls and insert them into drawing page
for (auto const& indexToName : aIndexToNameMap)
{
Any aCtrl = xNameAcc->getByName( indexToName.second );
Any aCtrl = m_xUnoControlDialogModel->getByName( indexToName.second );
Reference< css::awt::XControlModel > xCtrlModel;
aCtrl >>= xCtrlModel;
DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
@ -679,10 +678,9 @@ void DlgEditor::Copy()
Reference< util::XCloneable > xNewClone = xClone->createClone();
Reference< container::XNameContainer > xClipDialogModel( xNewClone, UNO_QUERY );
Reference< container::XNameAccess > xNAcc( xClipDialogModel, UNO_QUERY );
if ( xNAcc.is() )
if ( xClipDialogModel.is() )
{
Sequence< OUString > aNames = xNAcc->getElementNames();
Sequence< OUString > aNames = xClipDialogModel->getElementNames();
const OUString* pNames = aNames.getConstArray();
sal_uInt32 nCtrls = aNames.getLength();
@ -708,10 +706,9 @@ void DlgEditor::Copy()
xMarkPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
}
Reference< container::XNameAccess > xNameAcc(m_xUnoControlDialogModel, UNO_QUERY );
if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
if ( m_xUnoControlDialogModel.is() && m_xUnoControlDialogModel->hasByName(aName) )
{
Any aCtrl = xNameAcc->getByName( aName );
Any aCtrl = m_xUnoControlDialogModel->getByName( aName );
// clone control model
Reference< util::XCloneable > xCtrl;
@ -759,9 +756,7 @@ void DlgEditor::Copy()
// With resource, support old and new format
// Export xClipDialogModel another time with ids replaced by current language string
uno::Reference< resource::XStringResourceManager >
xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY );
LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager );
LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourcePersistence );
Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
Reference< XInputStream > xStream2( xISP2->createInputStream() );
Sequence< sal_Int8 > NoResourceDialogModelBytes;
@ -906,10 +901,9 @@ void DlgEditor::Paste()
}
// get control models from clipboard dialog model
Reference< css::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY );
if ( xNameAcc.is() )
if ( xClipDialogModel.is() )
{
Sequence< OUString > aNames = xNameAcc->getElementNames();
Sequence< OUString > aNames = xClipDialogModel->getElementNames();
const OUString* pNames = aNames.getConstArray();
sal_uInt32 nCtrls = aNames.getLength();
@ -921,7 +915,7 @@ void DlgEditor::Paste()
}
for( sal_uInt32 n = 0; n < nCtrls; n++ )
{
Any aA = xNameAcc->getByName( pNames[n] );
Any aA = xClipDialogModel->getByName( pNames[n] );
Reference< css::awt::XControlModel > xCM;
aA >>= xCM;
@ -940,8 +934,7 @@ void DlgEditor::Paste()
xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOUniqueName) );
// set tabindex
Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY );
Sequence< OUString > aNames_ = xNA->getElementNames();
Sequence< OUString > aNames_ = m_xUnoControlDialogModel->getElementNames();
xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames_.getLength())) );
if( bLocalized )
@ -950,10 +943,8 @@ void DlgEditor::Paste()
aControlAny <<= xCtrlModel;
if( bSourceIsLocalized && xStringResourcePersistence.is() )
{
Reference< resource::XStringResourceResolver >
xSourceStringResolver( xStringResourcePersistence, UNO_QUERY );
LocalizationMgr::copyResourcesForPastedEditorObject( this,
aControlAny, aOUniqueName, xSourceStringResolver );
aControlAny, aOUniqueName, xStringResourcePersistence );
}
else
{

View File

@ -464,7 +464,7 @@ void DlgEdObj::NameChange( const css::beans::PropertyChangeEvent& evt )
Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
if ( xCont.is() )
{
Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), UNO_QUERY);
Reference< awt::XControlModel > xCtrl = GetUnoControlModel();
Any aAny;
aAny <<= xCtrl;
xCont->removeByName( aOldName );
@ -1521,7 +1521,7 @@ void DlgEdForm::UpdateGroups()
sal_uInt32 nSize = aChildList.size();
Sequence< Reference< awt::XControl > > aSeqControls( nSize );
for ( sal_uInt32 i = 0; i < nSize; ++i )
aSeqControls.getArray()[i].set( aChildList[i]->GetControl(), UNO_QUERY );
aSeqControls.getArray()[i] = aChildList[i]->GetControl();
sal_Int32 nGroupCount = xTabModel->getGroupCount();
for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
@ -1557,7 +1557,7 @@ void DlgEdForm::UpdateGroups()
}
// set the group at the dialog peer
Reference< awt::XControl > xDlg( GetControl(), UNO_QUERY );
Reference< awt::XControl > xDlg = GetControl();
if ( xDlg.is() )
{
Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );

View File

@ -137,16 +137,14 @@ namespace basegfx
uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( 1 );
outputSequence[0] = bezierSequenceFromB2DPolygon( rPoly );
xRes.set( xGraphicDevice->createCompatibleBezierPolyPolygon( outputSequence ),
uno::UNO_QUERY );
xRes = xGraphicDevice->createCompatibleBezierPolyPolygon( outputSequence );
}
else
{
uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( 1 );
outputSequence[0] = pointSequenceFromB2DPolygon( rPoly );
xRes.set( xGraphicDevice->createCompatibleLinePolyPolygon( outputSequence ),
uno::UNO_QUERY );
xRes = xGraphicDevice->createCompatibleLinePolyPolygon( outputSequence );
}
if( xRes.is() && rPoly.isClosed() )
@ -168,15 +166,13 @@ namespace basegfx
if( rPolyPoly.areControlPointsUsed() )
{
xRes.set( xGraphicDevice->createCompatibleBezierPolyPolygon(
bezierSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) ),
uno::UNO_QUERY );
xRes = xGraphicDevice->createCompatibleBezierPolyPolygon(
bezierSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) );
}
else
{
xRes.set( xGraphicDevice->createCompatibleLinePolyPolygon(
pointSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) ),
uno::UNO_QUERY );
xRes = xGraphicDevice->createCompatibleLinePolyPolygon(
pointSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) );
}
for( i=0; i<nNumPolies; ++i )

View File

@ -90,7 +90,7 @@ void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Refere
Any aCtx;
aCtx <<= OUString("user");
xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
xScriptProvider = xFactory->createScriptProvider( aCtx );
}
if ( !xScriptProvider.is() )
@ -483,10 +483,10 @@ void RTL_Impl_CreateUnoDialog( SbxArray& rPar )
{
Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( xContext );
Reference< container::XEnumeration > xModels;
Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
Reference< container::XEnumerationAccess > xComponents = xDesktop->getComponents();
if ( xComponents.is() )
{
xModels.set( xComponents->createEnumeration(), UNO_QUERY );
xModels = xComponents->createEnumeration();
}
if ( xModels.is() )
{

View File

@ -560,8 +560,7 @@ Reference< resource::XStringResourceResolver >
if( !m_xStringResourcePersistence.is() )
m_xStringResourcePersistence = m_pParent->implCreateStringResource( this );
Reference< resource::XStringResourceResolver > xRet( m_xStringResourcePersistence, UNO_QUERY );
return xRet;
return m_xStringResourcePersistence;
}
bool SfxDialogLibrary::containsValidDialog( const css::uno::Any& aElement )

View File

@ -34,8 +34,8 @@ ModuleSizeExceeded::ModuleSizeExceeded( const std::vector< OUString >& sModules
m_aRequest <<= aReq;
m_xAbort.set( uno::Reference< task::XInteractionAbort >(new comphelper::OInteractionAbort), uno::UNO_QUERY );
m_xApprove.set( uno::Reference< task::XInteractionApprove >(new comphelper::OInteractionApprove ), uno::UNO_QUERY );
m_xAbort = new comphelper::OInteractionAbort;
m_xApprove = new comphelper::OInteractionApprove;
m_lContinuations.realloc( 2 );
m_lContinuations[0] = m_xApprove;
m_lContinuations[1] = m_xAbort;