From e1983485a83bb81d3675c429a2525f7969cc6169 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 19 Jul 2019 20:10:45 +0200 Subject: loplugin:referencecasting in sdext Change-Id: I4599375fae2516da20df0bdfc09f391e0189fc46 Reviewed-on: https://gerrit.libreoffice.org/75978 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sdext/source/minimizer/impoptimizer.cxx | 3 +-- sdext/source/presenter/PresenterAccessibility.cxx | 10 ++++------ sdext/source/presenter/PresenterBitmapContainer.cxx | 4 ++-- sdext/source/presenter/PresenterButton.cxx | 2 +- sdext/source/presenter/PresenterCanvasHelper.cxx | 4 ++-- sdext/source/presenter/PresenterController.cxx | 6 +++--- sdext/source/presenter/PresenterGeometryHelper.cxx | 21 +++++++++------------ sdext/source/presenter/PresenterHelpView.cxx | 2 +- sdext/source/presenter/PresenterNotesView.cxx | 13 ++++++------- sdext/source/presenter/PresenterPane.cxx | 4 ++-- sdext/source/presenter/PresenterPaneBase.cxx | 4 ++-- .../source/presenter/PresenterPaneBorderPainter.cxx | 2 +- sdext/source/presenter/PresenterScreen.cxx | 5 ++--- sdext/source/presenter/PresenterScrollBar.cxx | 2 +- sdext/source/presenter/PresenterSlidePreview.cxx | 2 +- sdext/source/presenter/PresenterSlideShowView.cxx | 2 +- sdext/source/presenter/PresenterSlideSorter.cxx | 4 ++-- sdext/source/presenter/PresenterTextView.cxx | 8 ++++---- sdext/source/presenter/PresenterTimer.cxx | 4 ++-- sdext/source/presenter/PresenterViewFactory.cxx | 7 ++----- sdext/source/presenter/PresenterWindowManager.cxx | 2 +- 21 files changed, 50 insertions(+), 61 deletions(-) (limited to 'sdext') diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index 3c7e0561c960..1105c027cb44 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -709,8 +709,7 @@ void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments ) } else { - Reference< XComponent > xComponent( mxModel, UNO_QUERY ); - xComponent->dispose(); + mxModel->dispose(); } } if ( nSourceSize && nDestSize ) diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx index 8eccf5ff63e3..bf2ed293cac5 100644 --- a/sdext/source/presenter/PresenterAccessibility.cxx +++ b/sdext/source/presenter/PresenterAccessibility.cxx @@ -660,7 +660,7 @@ Reference SAL_CALL PresenterAccessible::getAccessibleContext Reference xMainPane (mxMainPane, UNO_QUERY); if (xMainPane.is()) { - mxMainWindow.set(xMainPane->getWindow(), UNO_QUERY); + mxMainWindow = xMainPane->getWindow(); mxMainWindow->addFocusListener(this); } mpAccessibleConsole = AccessibleConsole::Create( @@ -1606,8 +1606,8 @@ awt::Point PresenterAccessible::AccessibleParagraph::GetAbsoluteParentLocation() { if (mxParentAccessible.is()) { - Reference xParentContext( - mxParentAccessible->getAccessibleContext(), UNO_QUERY); + Reference xParentContext = + mxParentAccessible->getAccessibleContext(); if (xParentContext.is()) { Reference xGrandParentComponent( @@ -1703,9 +1703,7 @@ void AccessibleNotes::SetTextView ( rpTextView->GetParagraph(nIndex), nIndex)); pParagraph->LateInitialization(); - pParagraph->SetWindow( - Reference(mxContentWindow, UNO_QUERY), - Reference(mxBorderWindow, UNO_QUERY)); + pParagraph->SetWindow(mxContentWindow, mxBorderWindow); pParagraph->SetAccessibleParent(this); aChildren.emplace_back(pParagraph.get()); } diff --git a/sdext/source/presenter/PresenterBitmapContainer.cxx b/sdext/source/presenter/PresenterBitmapContainer.cxx index 148bf24131ea..fde12ceb0919 100644 --- a/sdext/source/presenter/PresenterBitmapContainer.cxx +++ b/sdext/source/presenter/PresenterBitmapContainer.cxx @@ -84,8 +84,8 @@ void PresenterBitmapContainer::Initialize ( // Create an object that is able to load the bitmaps in a format that is // supported by the canvas. - Reference xFactory ( - rxComponentContext->getServiceManager(), UNO_QUERY); + Reference xFactory = + rxComponentContext->getServiceManager(); if ( ! xFactory.is()) return; mxPresenterHelper.set( diff --git a/sdext/source/presenter/PresenterButton.cxx b/sdext/source/presenter/PresenterButton.cxx index 26206dbc28ec..961e4ff5b425 100644 --- a/sdext/source/presenter/PresenterButton.cxx +++ b/sdext/source/presenter/PresenterButton.cxx @@ -160,7 +160,7 @@ void SAL_CALL PresenterButton::disposing() mxWindow->removePaintListener(this); mxWindow->removeMouseListener(this); mxWindow->removeMouseMotionListener(this); - Reference xComponent (mxWindow, UNO_QUERY); + Reference xComponent = mxWindow; mxWindow = nullptr; if (xComponent.is()) xComponent->dispose(); diff --git a/sdext/source/presenter/PresenterCanvasHelper.cxx b/sdext/source/presenter/PresenterCanvasHelper.cxx index 4903a87e1afe..e8ced956af52 100644 --- a/sdext/source/presenter/PresenterCanvasHelper.cxx +++ b/sdext/source/presenter/PresenterCanvasHelper.cxx @@ -94,7 +94,7 @@ void PresenterCanvasHelper::PaintRectangle ( || rpBitmap->meVerticalTexturingMode == PresenterBitmapDescriptor::Repeat) { PaintTiledBitmap( - Reference(rpBitmap->GetNormalBitmap(), UNO_QUERY), + rpBitmap->GetNormalBitmap(), rxCanvas, rRepaintBox, xPolyPolygon, @@ -105,7 +105,7 @@ void PresenterCanvasHelper::PaintRectangle ( else { PaintBitmap( - Reference(rpBitmap->GetNormalBitmap(), UNO_QUERY), + rpBitmap->GetNormalBitmap(), awt::Point(rOuterBoundingBox.X, rOuterBoundingBox.Y), rxCanvas, rRepaintBox, diff --git a/sdext/source/presenter/PresenterController.cxx b/sdext/source/presenter/PresenterController.cxx index 99600638cf8d..5c438eb32eb0 100644 --- a/sdext/source/presenter/PresenterController.cxx +++ b/sdext/source/presenter/PresenterController.cxx @@ -160,8 +160,8 @@ PresenterController::PresenterController ( // Create an object that is able to load the bitmaps in a format that is // supported by the canvas. - Reference xFactory ( - rxContext->getServiceManager(), UNO_QUERY); + Reference xFactory = + rxContext->getServiceManager(); if ( ! xFactory.is()) return; mxPresenterHelper.set( @@ -1157,7 +1157,7 @@ void PresenterController::UpdatePendingSlideNumber (const sal_Int32 nPendingSlid if (pFont.get() == nullptr) return; - pFont->PrepareFont(Reference(mxCanvas, UNO_QUERY)); + pFont->PrepareFont(mxCanvas); if ( ! pFont->mxFont.is()) return; diff --git a/sdext/source/presenter/PresenterGeometryHelper.cxx b/sdext/source/presenter/PresenterGeometryHelper.cxx index 8126e5c9639d..afa401988c8a 100644 --- a/sdext/source/presenter/PresenterGeometryHelper.cxx +++ b/sdext/source/presenter/PresenterGeometryHelper.cxx @@ -191,11 +191,10 @@ Reference PresenterGeometryHelper::CreatePolygon( aPoints[0][3] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y); Reference xPolygon ( rxDevice->createCompatibleLinePolyPolygon(aPoints)); - Reference xRectangle (xPolygon, UNO_QUERY); - if (xRectangle.is()) - xRectangle->setClosed(0, true); + if (xPolygon.is()) + xPolygon->setClosed(0, true); - return xRectangle; + return xPolygon; } Reference PresenterGeometryHelper::CreatePolygon( @@ -213,11 +212,10 @@ Reference PresenterGeometryHelper::CreatePolygon( aPoints[0][3] = geometry::RealPoint2D(rBox.X2, rBox.Y1); Reference xPolygon ( rxDevice->createCompatibleLinePolyPolygon(aPoints)); - Reference xRectangle (xPolygon, UNO_QUERY); - if (xRectangle.is()) - xRectangle->setClosed(0, true); + if (xPolygon.is()) + xPolygon->setClosed(0, true); - return xRectangle; + return xPolygon; } Reference PresenterGeometryHelper::CreatePolygon( @@ -241,12 +239,11 @@ Reference PresenterGeometryHelper::CreatePolygon( Reference xPolygon ( rxDevice->createCompatibleLinePolyPolygon(aPoints)); - Reference xRectangle (xPolygon, UNO_QUERY); - if (xRectangle.is()) + if (xPolygon.is()) for (sal_Int32 nIndex=0; nIndexsetClosed(nIndex, true); + xPolygon->setClosed(nIndex, true); - return xRectangle; + return xPolygon; } } } diff --git a/sdext/source/presenter/PresenterHelpView.cxx b/sdext/source/presenter/PresenterHelpView.cxx index 03df1dcd3797..d145eb893c47 100644 --- a/sdext/source/presenter/PresenterHelpView.cxx +++ b/sdext/source/presenter/PresenterHelpView.cxx @@ -263,7 +263,7 @@ void PresenterHelpView::Paint (const awt::Rectangle& rUpdateBox) const awt::Rectangle aWindowBox (mxWindow->getPosSize()); mpPresenterController->GetCanvasHelper()->Paint( mpPresenterController->GetViewBackground(mxViewId->getResourceURL()), - Reference(mxCanvas, UNO_QUERY), + mxCanvas, rUpdateBox, awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height), awt::Rectangle()); diff --git a/sdext/source/presenter/PresenterNotesView.cxx b/sdext/source/presenter/PresenterNotesView.cxx index dcf4fa51ba73..5f85ed07525e 100644 --- a/sdext/source/presenter/PresenterNotesView.cxx +++ b/sdext/source/presenter/PresenterNotesView.cxx @@ -160,7 +160,7 @@ void SAL_CALL PresenterNotesView::disposing() xComponent->dispose(); } { - Reference xComponent (mxToolBarWindow, UNO_QUERY); + Reference xComponent = mxToolBarWindow; mxToolBarWindow = nullptr; if (xComponent.is()) xComponent->dispose(); @@ -225,17 +225,16 @@ void PresenterNotesView::SetSlide (const Reference& rxNotesP static const OUString sTextShapeName ( "com.sun.star.drawing.TextShape"); - Reference xIndexAccess (rxNotesPage, UNO_QUERY); - if (!xIndexAccess.is()) + if (!rxNotesPage.is()) return; // Iterate over all shapes and find the one that holds the text. - sal_Int32 nCount (xIndexAccess->getCount()); + sal_Int32 nCount (rxNotesPage->getCount()); for (sal_Int32 nIndex=0; nIndex xServiceName ( - xIndexAccess->getByIndex(nIndex), UNO_QUERY); + rxNotesPage->getByIndex(nIndex), UNO_QUERY); if (xServiceName.is() && xServiceName->getServiceName() == sNotesShapeName) { @@ -243,14 +242,14 @@ void PresenterNotesView::SetSlide (const Reference& rxNotesP else { Reference xShapeDescriptor ( - xIndexAccess->getByIndex(nIndex), UNO_QUERY); + rxNotesPage->getByIndex(nIndex), UNO_QUERY); if (xShapeDescriptor.is()) { OUString sType (xShapeDescriptor->getShapeType()); if (sType == sNotesShapeName || sType == sTextShapeName) { Reference xText ( - xIndexAccess->getByIndex(nIndex), UNO_QUERY); + rxNotesPage->getByIndex(nIndex), UNO_QUERY); if (xText.is()) { mpTextView->SetText(Reference(xText, UNO_QUERY)); diff --git a/sdext/source/presenter/PresenterPane.cxx b/sdext/source/presenter/PresenterPane.cxx index 91b5bcdbac3f..7299ee267ee8 100644 --- a/sdext/source/presenter/PresenterPane.cxx +++ b/sdext/source/presenter/PresenterPane.cxx @@ -140,13 +140,13 @@ void PresenterPane::CreateCanvases ( mxBorderCanvas = mxPresenterHelper->createSharedCanvas( rxParentCanvas, mxParentWindow, - Reference(rxParentCanvas, UNO_QUERY), + rxParentCanvas, mxParentWindow, mxBorderWindow); mxContentCanvas = mxPresenterHelper->createSharedCanvas( rxParentCanvas, mxParentWindow, - Reference(rxParentCanvas, UNO_QUERY), + rxParentCanvas, mxParentWindow, mxContentWindow); diff --git a/sdext/source/presenter/PresenterPaneBase.cxx b/sdext/source/presenter/PresenterPaneBase.cxx index cbf78989e94e..fd8e1ea30cc1 100644 --- a/sdext/source/presenter/PresenterPaneBase.cxx +++ b/sdext/source/presenter/PresenterPaneBase.cxx @@ -79,7 +79,7 @@ void PresenterPaneBase::disposing() } { - Reference xComponent (mxContentWindow, UNO_QUERY); + Reference xComponent = mxContentWindow; mxContentWindow = nullptr; if (xComponent.is()) xComponent->dispose(); @@ -93,7 +93,7 @@ void PresenterPaneBase::disposing() } { - Reference xComponent (mxBorderWindow, UNO_QUERY); + Reference xComponent = mxBorderWindow; mxBorderWindow = nullptr; if (xComponent.is()) xComponent->dispose(); diff --git a/sdext/source/presenter/PresenterPaneBorderPainter.cxx b/sdext/source/presenter/PresenterPaneBorderPainter.cxx index 53b820109fcc..1dbda5128e08 100644 --- a/sdext/source/presenter/PresenterPaneBorderPainter.cxx +++ b/sdext/source/presenter/PresenterPaneBorderPainter.cxx @@ -605,7 +605,7 @@ void PresenterPaneBorderPainter::Renderer::PaintBitmap( if (rpBitmap->mnWidth<=0 || rpBitmap->mnHeight<=0) return; - Reference xBitmap (rpBitmap->GetNormalBitmap(), UNO_QUERY); + Reference xBitmap = rpBitmap->GetNormalBitmap(); if ( ! xBitmap.is()) return; diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx index 847919e720bc..9e73456ff1bd 100644 --- a/sdext/source/presenter/PresenterScreen.cxx +++ b/sdext/source/presenter/PresenterScreen.cxx @@ -432,14 +432,13 @@ sal_Int32 PresenterScreen::GetPresenterScreenNumber ( sal_Int32 nScreenCount (1); try { - Reference xProperties (rxPresentation, UNO_QUERY); - if ( ! xProperties.is()) + if ( ! rxPresentation.is()) return -1; // Determine the screen on which the full screen presentation is being // displayed. sal_Int32 nDisplayNumber (-1); - if ( ! (xProperties->getPropertyValue("Display") >>= nDisplayNumber)) + if ( ! (rxPresentation->getPropertyValue("Display") >>= nDisplayNumber)) return -1; if (nDisplayNumber == -1) { diff --git a/sdext/source/presenter/PresenterScrollBar.cxx b/sdext/source/presenter/PresenterScrollBar.cxx index 01b71c3e99cf..2d7eb268713b 100644 --- a/sdext/source/presenter/PresenterScrollBar.cxx +++ b/sdext/source/presenter/PresenterScrollBar.cxx @@ -150,7 +150,7 @@ void SAL_CALL PresenterScrollBar::disposing() mxWindow->removeMouseListener(this); mxWindow->removeMouseMotionListener(this); - Reference xComponent (mxWindow, UNO_QUERY); + Reference xComponent = mxWindow; mxWindow = nullptr; if (xComponent.is()) xComponent->dispose(); diff --git a/sdext/source/presenter/PresenterSlidePreview.cxx b/sdext/source/presenter/PresenterSlidePreview.cxx index b81c42660b50..b1f0b137a3e4 100644 --- a/sdext/source/presenter/PresenterSlidePreview.cxx +++ b/sdext/source/presenter/PresenterSlidePreview.cxx @@ -89,7 +89,7 @@ PresenterSlidePreview::PresenterSlidePreview ( if (mpPresenterController.get() != nullptr) mnSlideAspectRatio = mpPresenterController->GetSlideAspectRatio(); - Reference xFactory (rxContext->getServiceManager(), UNO_QUERY); + Reference xFactory = rxContext->getServiceManager(); if (xFactory.is()) mxPreviewRenderer.set( xFactory->createInstanceWithContext( diff --git a/sdext/source/presenter/PresenterSlideShowView.cxx b/sdext/source/presenter/PresenterSlideShowView.cxx index 5dbea9683bca..d9d20909ebb0 100644 --- a/sdext/source/presenter/PresenterSlideShowView.cxx +++ b/sdext/source/presenter/PresenterSlideShowView.cxx @@ -209,7 +209,7 @@ void PresenterSlideShowView::disposing() } if (mxViewWindow.is()) { - Reference xComponent (mxViewWindow, UNO_QUERY); + Reference xComponent = mxViewWindow; mxViewWindow = nullptr; if (xComponent.is()) xComponent->dispose(); diff --git a/sdext/source/presenter/PresenterSlideSorter.cxx b/sdext/source/presenter/PresenterSlideSorter.cxx index c965ef004e32..9231627b264b 100644 --- a/sdext/source/presenter/PresenterSlideSorter.cxx +++ b/sdext/source/presenter/PresenterSlideSorter.cxx @@ -1495,7 +1495,7 @@ void PresenterSlideSorter::MouseOverManager::SetCanvas ( { mxCanvas = rxCanvas; if (mpFont.get() != nullptr) - mpFont->PrepareFont(Reference(mxCanvas, UNO_QUERY)); + mpFont->PrepareFont(mxCanvas); } void PresenterSlideSorter::MouseOverManager::SetSlide ( @@ -1697,7 +1697,7 @@ void PresenterSlideSorter::MouseOverManager::PaintButtonBackground ( xRightLabelBitmap = mpRightLabelBitmap->GetNormalBitmap(); PresenterUIPainter::PaintHorizontalBitmapComposite ( - Reference(rxCanvas, UNO_QUERY), + rxCanvas, awt::Rectangle(0,0, rSize.Width,rSize.Height), awt::Rectangle(0,0, rSize.Width,rSize.Height), xLeftLabelBitmap, diff --git a/sdext/source/presenter/PresenterTextView.cxx b/sdext/source/presenter/PresenterTextView.cxx index 3aa30753bc4b..db244d4a520a 100644 --- a/sdext/source/presenter/PresenterTextView.cxx +++ b/sdext/source/presenter/PresenterTextView.cxx @@ -86,8 +86,8 @@ PresenterTextView::PresenterTextView ( mbIsFormatPending(false), maTextChangeBroadcaster() { - Reference xFactory ( - rxContext->getServiceManager(), UNO_QUERY); + Reference xFactory = + rxContext->getServiceManager(); if ( ! xFactory.is()) return; @@ -111,8 +111,8 @@ void PresenterTextView::SetText (const Reference& rxText) if ( ! xParagraphAccess.is()) return; - Reference xParagraphs ( - xParagraphAccess->createEnumeration() , UNO_QUERY); + Reference xParagraphs = + xParagraphAccess->createEnumeration(); if ( ! xParagraphs.is()) return; diff --git a/sdext/source/presenter/PresenterTimer.cxx b/sdext/source/presenter/PresenterTimer.cxx index 7a1d74217a4e..88accf971f47 100644 --- a/sdext/source/presenter/PresenterTimer.cxx +++ b/sdext/source/presenter/PresenterTimer.cxx @@ -449,8 +449,8 @@ PresenterClockTimer::PresenterClockTimer (const Reference& rx , m_xContext(rxContext) { assert(m_xContext.is()); - Reference xFactory ( - rxContext->getServiceManager(), UNO_QUERY); + Reference xFactory = + rxContext->getServiceManager(); if (xFactory.is()) mxRequestCallback.set( xFactory->createInstanceWithContext( diff --git a/sdext/source/presenter/PresenterViewFactory.cxx b/sdext/source/presenter/PresenterViewFactory.cxx index 27a2f55f650d..20afc1c0eb68 100644 --- a/sdext/source/presenter/PresenterViewFactory.cxx +++ b/sdext/source/presenter/PresenterViewFactory.cxx @@ -89,8 +89,7 @@ public: { for (sal_Int32 nIndex=0; nIndex( - xSlideShowController->getSlideByIndex(nIndex), UNO_QUERY)) + if (rxSlide == xSlideShowController->getSlideByIndex(nIndex)) { nNextSlideIndex = nIndex + 1; } @@ -100,9 +99,7 @@ public: { if (nNextSlideIndex < nCount) { - xSlide.set( - xSlideShowController->getSlideByIndex(nNextSlideIndex), - UNO_QUERY); + xSlide = xSlideShowController->getSlideByIndex(nNextSlideIndex); } } } diff --git a/sdext/source/presenter/PresenterWindowManager.cxx b/sdext/source/presenter/PresenterWindowManager.cxx index a4ea38e65516..f9d22ca0a548 100644 --- a/sdext/source/presenter/PresenterWindowManager.cxx +++ b/sdext/source/presenter/PresenterWindowManager.cxx @@ -988,7 +988,7 @@ void PresenterWindowManager::ProvideBackgroundBitmap() } else { - mxScaledBackgroundBitmap.set(xBitmap, UNO_QUERY); + mxScaledBackgroundBitmap = xBitmap; } } -- cgit