sc/qa/extras/scpdfexport.cxx                      |    7 +---
 sc/qa/unit/copy_paste_test.cxx                    |    9 ++---
 sc/source/core/data/documen5.cxx                  |    5 +--
 sc/source/core/tool/address.cxx                   |    2 -
 sc/source/core/tool/charthelper.cxx               |    7 +---
 sc/source/core/tool/webservicelink.cxx            |    5 +--
 sc/source/filter/excel/xeescher.cxx               |    3 -
 sc/source/filter/excel/xichart.cxx                |    4 +-
 sc/source/filter/excel/xltoolbar.cxx              |    2 -
 sc/source/filter/oox/excelfilter.cxx              |    2 -
 sc/source/filter/oox/pagesettings.cxx             |    2 -
 sc/source/filter/oox/richstring.cxx               |    2 -
 sc/source/filter/xml/XMLTrackedChangesContext.cxx |    4 --
 sc/source/filter/xml/xmlcelli.cxx                 |   13 +++----
 sc/source/filter/xml/xmlexprt.cxx                 |   18 ++++-------
 sc/source/filter/xml/xmlsubti.cxx                 |    6 +--
 sc/source/filter/xml/xmlwrap.cxx                  |   11 ++----
 sc/source/ui/Accessibility/AccessibleDocument.cxx |   21 +++++-------
 sc/source/ui/dataprovider/dataprovider.cxx        |    2 -
 sc/source/ui/docshell/docsh8.cxx                  |    3 -
 sc/source/ui/drawfunc/fuins2.cxx                  |   10 ++----
 sc/source/ui/unoobj/TablePivotCharts.cxx          |    5 +--
 sc/source/ui/unoobj/chartuno.cxx                  |    5 +--
 sc/source/ui/unoobj/docuno.cxx                    |   36 +++++++++-------------
 sc/source/ui/unoobj/fielduno.cxx                  |    3 -
 sc/source/ui/unoobj/textuno.cxx                   |    9 +----
 sc/source/ui/vba/vbaapplication.cxx               |    8 ++--
 sc/source/ui/vba/vbarange.cxx                     |    5 +--
 sc/source/ui/vba/vbaworkbook.cxx                  |    2 -
 sc/source/ui/vba/vbaworksheet.cxx                 |    9 +----
 sc/source/ui/view/drawvie4.cxx                    |    8 +---
 31 files changed, 94 insertions(+), 134 deletions(-)

New commits:
commit 8239e13dac39741003dfbce7099c3197080aafa8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 19 20:09:55 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jul 20 07:56:54 2019 +0200

    loplugin:referencecasting in sc
    
    Change-Id: Ife30500d1ff67e06afc4d64634febfb4c161c702
    Reviewed-on: https://gerrit.libreoffice.org/75976
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx
index c21cdaa2dde7..059401f86340 100644
--- a/sc/qa/extras/scpdfexport.cxx
+++ b/sc/qa/extras/scpdfexport.cxx
@@ -88,8 +88,8 @@ void ScPDFExportTest::setUp()
         uno::Reference<frame::XModel2> xModel2(xModel, UNO_QUERY);
         CPPUNIT_ASSERT(xModel2.is());
 
-        Reference<frame::XController2> xController(
-            xModel2->createDefaultViewController(xTargetFrame), UNO_QUERY);
+        Reference<frame::XController2> xController
+            = xModel2->createDefaultViewController(xTargetFrame);
         CPPUNIT_ASSERT(xController.is());
 
         // introduce model/view/controller to each other
@@ -161,8 +161,7 @@ std::shared_ptr<utl::TempFile> 
ScPDFExportTest::exportToPdf(uno::Reference<frame
 
     // select requested cells to print
     // query for the XCellRange interface
-    uno::Reference<table::XCellRange> rCellRange(rSheet, UNO_QUERY);
-    uno::Reference<table::XCellRange> xCellRange = 
rCellRange->getCellRangeByPosition(
+    uno::Reference<table::XCellRange> xCellRange = 
rSheet->getCellRangeByPosition(
         range.aStart.Col(), range.aStart.Row(), range.aEnd.Col(), 
range.aEnd.Row());
     {
         uno::Reference<frame::XController> xController = 
xModel->getCurrentController();
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 6d4e0fb3f6bf..4087b9d48946 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -64,7 +64,7 @@ void ScCopyPasteTest::testCopyPasteXLS()
     uno::Reference< frame::XModel2 > xModel2 ( xDocSh->GetModel(), UNO_QUERY );
     CPPUNIT_ASSERT( xModel2.is() );
 
-    Reference< frame::XController2 > xController ( 
xModel2->createDefaultViewController( xTargetFrame ), UNO_QUERY );
+    Reference< frame::XController2 > xController = 
xModel2->createDefaultViewController( xTargetFrame );
     CPPUNIT_ASSERT( xController.is() );
 
     // introduce model/view/controller to each other
@@ -187,7 +187,7 @@ void ScCopyPasteTest::testTdf84411()
     uno::Reference< frame::XModel2 > xModel2 ( xDocSh->GetModel(), UNO_QUERY );
     CPPUNIT_ASSERT( xModel2.is() );
 
-    Reference< frame::XController2 > xController ( 
xModel2->createDefaultViewController( xTargetFrame ), UNO_QUERY );
+    Reference< frame::XController2 > xController = 
xModel2->createDefaultViewController( xTargetFrame );
     CPPUNIT_ASSERT( xController.is() );
 
     // introduce model/view/controller to each other
@@ -256,7 +256,7 @@ void ScCopyPasteTest::testTdf124565()
     uno::Reference< frame::XModel2 > xModel2 ( xDocSh->GetModel(), UNO_QUERY );
     CPPUNIT_ASSERT( xModel2.is() );
 
-    Reference< frame::XController2 > xController ( 
xModel2->createDefaultViewController( xTargetFrame ), UNO_QUERY );
+    Reference< frame::XController2 > xController = 
xModel2->createDefaultViewController( xTargetFrame );
     CPPUNIT_ASSERT( xController.is() );
 
     // introduce model/view/controller to each other
@@ -327,8 +327,7 @@ void ScCopyPasteTest::testTdf126421()
     uno::Reference<frame::XModel2> xModel2(xDocSh->GetModel(), UNO_QUERY);
     CPPUNIT_ASSERT(xModel2.is());
 
-    Reference<frame::XController2> 
xController(xModel2->createDefaultViewController(xTargetFrame),
-                                               UNO_QUERY);
+    Reference<frame::XController2> xController = 
xModel2->createDefaultViewController(xTargetFrame);
     CPPUNIT_ASSERT(xController.is());
 
     // introduce model/view/controller to each other
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 76598f887443..ea449fc6cdda 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -613,9 +613,8 @@ void ScDocument::UpdateChartListenerCollection()
                 uno::Reference< embed::XEmbeddedObject > xIPObj = 
static_cast<SdrOle2Obj*>(pObject)->GetObjRef();
                 OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
                 uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
-                uno::Reference< embed::XComponentSupplier > xCompSupp( xIPObj, 
uno::UNO_QUERY );
-                if( xCompSupp.is())
-                    xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+                if( xIPObj.is())
+                    xReceiver.set( xIPObj->getComponent(), uno::UNO_QUERY );
 
                 // if the object is a chart2::XDataReceiver, we must attach as 
XDataProvider
                 if( xReceiver.is() &&
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 3b3a997050df..0c715ff84806 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1974,7 +1974,7 @@ static OUString getFileNameFromDoc( const ScDocument* 
pDoc )
     if( nullptr != pDoc &&
         nullptr != (pShell = pDoc->GetDocumentShell() ) )
     {
-        uno::Reference< frame::XModel > xModel( pShell->GetModel(), 
uno::UNO_QUERY );
+        uno::Reference< frame::XModel > xModel = pShell->GetModel();
         if( xModel.is() )
         {
             if( !xModel->getURL().isEmpty() )
diff --git a/sc/source/core/tool/charthelper.cxx 
b/sc/source/core/tool/charthelper.cxx
index ff2636bfb230..f6e065152d5d 100644
--- a/sc/source/core/tool/charthelper.cxx
+++ b/sc/source/core/tool/charthelper.cxx
@@ -228,9 +228,7 @@ void ScChartHelper::SetChartRanges( const uno::Reference< 
chart2::XChartDocument
     if( !xDataProvider.is() )
         return;
 
-    uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
-    if( xModel.is() )
-        xModel->lockControllers();
+    xChartDoc->lockControllers();
 
     try
     {
@@ -279,8 +277,7 @@ void ScChartHelper::SetChartRanges( const uno::Reference< 
chart2::XChartDocument
         OSL_FAIL("Exception in ScChartHelper::SetChartRanges - invalid range 
string?");
     }
 
-    if( xModel.is() )
-        xModel->unlockControllers();
+    xChartDoc->unlockControllers();
 }
 
 void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& 
rRangesVector, const ScDocument* pDocument, SdrObject* pObject )
diff --git a/sc/source/core/tool/webservicelink.cxx 
b/sc/source/core/tool/webservicelink.cxx
index 6acd9ccaa06a..f5e621867d16 100644
--- a/sc/source/core/tool/webservicelink.cxx
+++ b/sc/source/core/tool/webservicelink.cxx
@@ -41,9 +41,8 @@ sfx2::SvBaseLink::UpdateResult 
ScWebServiceLink::DataChanged(const OUString&, co
     aResult.clear();
     bHasResult = false;
 
-    css::uno::Reference<css::ucb::XSimpleFileAccess3> xFileAccess(
-        
css::ucb::SimpleFileAccess::create(comphelper::getProcessComponentContext()),
-        css::uno::UNO_QUERY);
+    css::uno::Reference<css::ucb::XSimpleFileAccess3> xFileAccess
+        = 
css::ucb::SimpleFileAccess::create(comphelper::getProcessComponentContext());
     if (!xFileAccess.is())
         return ERROR_GENERAL;
 
diff --git a/sc/source/filter/excel/xeescher.cxx 
b/sc/source/filter/excel/xeescher.cxx
index c1d139a629e3..3787b75ad6f8 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1125,8 +1125,7 @@ void XclExpChartObj::SaveXml( XclExpXmlStream& rStrm )
     if (xPropSet.is())
     {
         XclObjAny::WriteFromTo( rStrm, mxShape, GetTab() );
-        Reference< XModel > xModel( mxChartDoc, UNO_QUERY );
-        ChartExport aChartExport(XML_xdr, pDrawing, xModel, &rStrm, 
drawingml::DOCUMENT_XLSX);
+        ChartExport aChartExport(XML_xdr, pDrawing, mxChartDoc, &rStrm, 
drawingml::DOCUMENT_XLSX);
         std::shared_ptr<oox::drawingml::URLTransformer> pURLTransformer(new 
ScURLTransformer(*mpDoc));
         aChartExport.SetURLTranslator(pURLTransformer);
         static sal_Int32 nChartCount = 0;
diff --git a/sc/source/filter/excel/xichart.cxx 
b/sc/source/filter/excel/xichart.cxx
index cbdedcaa09bc..c7a1e965c6f1 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -289,7 +289,7 @@ void XclImpChRoot::FinishConversion( XclImpDffConverter& 
rDffConv ) const
 {
     rDffConv.Progress( EXC_CHART_PROGRESS_SIZE );
     // unlock the model
-    Reference< XModel > xModel( mxChData->mxChartDoc, UNO_QUERY );
+    Reference< XModel > xModel = mxChData->mxChartDoc;
     if( xModel.is() )
         xModel->unlockControllers();
     rDffConv.Progress( EXC_CHART_PROGRESS_SIZE );
@@ -715,7 +715,7 @@ Reference< XLabeledDataSequence > 
lclCreateLabeledDataSequence(
     // create the labeled data sequence, if values or title are present
     Reference< XLabeledDataSequence > xLabeledSeq;
     if( xValueSeq.is() || xTitleSeq.is() )
-        xLabeledSeq.set( 
LabeledDataSequence::create(comphelper::getProcessComponentContext()), 
UNO_QUERY );
+        xLabeledSeq = 
LabeledDataSequence::create(comphelper::getProcessComponentContext());
     if( xLabeledSeq.is() )
     {
         if( xValueSeq.is() )
diff --git a/sc/source/filter/excel/xltoolbar.cxx 
b/sc/source/filter/excel/xltoolbar.cxx
index ff71859ebb6d..db8a7142e9e6 100644
--- a/sc/source/filter/excel/xltoolbar.cxx
+++ b/sc/source/filter/excel/xltoolbar.cxx
@@ -268,7 +268,7 @@ bool ScTBC::ImportToolBarControl( ScCTBWrapper& rWrapper, 
const css::uno::Refere
                      return false;
                  if ( !bIsMenuToolbar )
                  {
-                     if ( !helper.createMenu( pMenu->Name(), uno::Reference< 
container::XIndexAccess >( xMenuDesc, uno::UNO_QUERY ) ) )
+                     if ( !helper.createMenu( pMenu->Name(), xMenuDesc ) )
                          return false;
                  }
                  else
diff --git a/sc/source/filter/oox/excelfilter.cxx 
b/sc/source/filter/oox/excelfilter.cxx
index 418d45c1efdc..fcf582a5bc26 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -228,7 +228,7 @@ sal_Bool SAL_CALL ExcelFilter::filter( const 
css::uno::Sequence< css::beans::Pro
         Reference< XExporter > xExporter(
             new XclExpXmlStream( getComponentContext(), bExportVBA, 
isExportTemplate() ) );
 
-        Reference< XComponent > xDocument( getModel(), UNO_QUERY );
+        Reference< XComponent > xDocument = getModel();
         Reference< XFilter > xFilter( xExporter, UNO_QUERY );
 
         if ( xFilter.is() )
diff --git a/sc/source/filter/oox/pagesettings.cxx 
b/sc/source/filter/oox/pagesettings.cxx
index 7afa498e828e..f52d4f638d74 100644
--- a/sc/source/filter/oox/pagesettings.cxx
+++ b/sc/source/filter/oox/pagesettings.cxx
@@ -746,7 +746,7 @@ void HeaderFooterParser::updateCurrHeight()
 
 void HeaderFooterParser::setAttributes()
 {
-    Reference<text::XTextRange> xRange( getStartPos(), UNO_QUERY );
+    Reference<text::XTextRange> xRange = getStartPos();
     getEndPos()->gotoRange( xRange, false );
     getEndPos()->gotoEnd( true );
     if( !getEndPos()->isCollapsed() )
diff --git a/sc/source/filter/oox/richstring.cxx 
b/sc/source/filter/oox/richstring.cxx
index f1c82e04ed86..4f2e937ffc3e 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -89,7 +89,7 @@ void RichStringPortion::convert( const Reference< XText >& 
rxText, bool bReplace
 
     Reference< XTextRange > xRange;
     if( bReplace )
-        xRange.set( rxText, UNO_QUERY );
+        xRange = rxText;
     else
         xRange = rxText->getEnd();
     OSL_ENSURE( xRange.is(), "RichStringPortion::convert - cannot get text 
range interface" );
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx 
b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index b9eef7c55d76..0c75444d925c 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -884,9 +884,7 @@ void ScXMLChangeCellContext::CreateTextPContext(bool 
bIsNewParagraph)
             {
                 xText->setString(sText);
                 xTextCursor->gotoEnd(false);
-                uno::Reference < text::XTextRange > xTextRange (xTextCursor, 
uno::UNO_QUERY);
-                if (xTextRange.is())
-                    xText->insertControlCharacter(xTextRange, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
+                xText->insertControlCharacter(xTextCursor, 
text::ControlCharacter::PARAGRAPH_BREAK, false);
             }
             GetScImport().GetTextImport()->SetCursor(xTextCursor);
         }
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 586ecf3222c1..8a862e221057 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -854,8 +854,7 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
     ScPostIt* pNote = nullptr;
 
     uno::Reference< drawing::XShapes > xShapes = 
rXMLImport.GetTables().GetCurrentXShapes();
-    uno::Reference< container::XIndexAccess > xShapesIA( xShapes, 
uno::UNO_QUERY );
-    sal_Int32 nOldShapeCount = xShapesIA.is() ? xShapesIA->getCount() : 0;
+    sal_Int32 nOldShapeCount = xShapes.is() ? xShapes->getCount() : 0;
 
     OSL_ENSURE( !mxAnnotationData->mxShape.is() || 
mxAnnotationData->mxShapes.is(),
         "ScXMLTableRowCellContext::SetAnnotation - shape without drawing page" 
);
@@ -894,8 +893,8 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
             mxAnnotationData->mxShapes->remove( mxAnnotationData->mxShape );
             pObject = nullptr;
             // update current number of existing objects
-            if( xShapesIA.is() )
-                nOldShapeCount = xShapesIA->getCount();
+            if( xShapes.is() )
+                nOldShapeCount = xShapes->getCount();
 
             // an outliner object is required (empty note captions not allowed)
             if (xOutlinerObj)
@@ -932,10 +931,10 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
     }
 
     // register a shape that has been newly created in the ScNoteUtil functions
-    if( xShapesIA.is() && (nOldShapeCount < xShapesIA->getCount()) )
+    if( xShapes.is() && (nOldShapeCount < xShapes->getCount()) )
     {
         uno::Reference< drawing::XShape > xShape;
-        rXMLImport.GetShapeImport()->shapeWithZIndexAdded( xShape, 
xShapesIA->getCount() );
+        rXMLImport.GetShapeImport()->shapeWithZIndexAdded( xShape, 
xShapes->getCount() );
     }
 
     // store the style names for stream copying
@@ -955,7 +954,7 @@ void ScXMLTableRowCellContext::SetDetectiveObj( const 
ScAddress& rPosition )
     {
         LockSolarMutex();
         ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Tab() );
-        uno::Reference<container::XIndexAccess> xShapesIndex 
(rXMLImport.GetTables().GetCurrentXShapes(), uno::UNO_QUERY); // make draw page
+        uno::Reference<container::XIndexAccess> xShapesIndex = 
rXMLImport.GetTables().GetCurrentXShapes(); // make draw page
         for(const auto& rDetectiveObj : *pDetectiveObjVec)
         {
             aDetFunc.InsertObject( rDetectiveObj.eObjType, rPosition, 
rDetectiveObj.aSourceRange, rDetectiveObj.bHasError );
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 77d8bd7cd048..79bc36d1a097 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -499,14 +499,13 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, 
sal_Int32& nShapesCount)
         aDrawPage.bHasForms = false;
         aDrawPage.xDrawPage.set(xDrawPage);
         pSharedData->AddDrawPage(aDrawPage, nTable);
-        uno::Reference<container::XIndexAccess> xShapesIndex(xDrawPage, 
uno::UNO_QUERY);
-        if (!xShapesIndex.is())
+        if (!xDrawPage.is())
             continue;
 
-        sal_Int32 nShapes = xShapesIndex->getCount();
+        sal_Int32 nShapes = xDrawPage->getCount();
         for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
         {
-            uno::Reference<drawing::XShape> 
xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY);
+            uno::Reference<drawing::XShape> 
xShape(xDrawPage->getByIndex(nShape), uno::UNO_QUERY);
             if (!xShape.is())
                 continue;
 
@@ -579,11 +578,10 @@ void ScXMLExport::CollectShapesAutoStyles(SCTAB 
nTableCount)
         for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
         {
             uno::Reference<drawing::XDrawPage> 
xDrawPage(pSharedData->GetDrawPage(nTable));
-            uno::Reference<drawing::XShapes> xShapes (xDrawPage, 
uno::UNO_QUERY);
 
-            if (xShapes.is())
+            if (xDrawPage.is())
             {
-                GetShapeExport()->seekShapes(xShapes);
+                GetShapeExport()->seekShapes(xDrawPage);
                 uno::Reference< form::XFormsSupplier2 > xFormsSupplier( 
xDrawPage, uno::UNO_QUERY );
                 if( xFormsSupplier.is() && xFormsSupplier->hasForms() )
                 {
@@ -2797,7 +2795,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const 
uno::Reference<sheet::XSpre
         return;
 
     xCurrentTable.set(xTable);
-    xCurrentTableCellRange.set(xTable, uno::UNO_QUERY);
+    xCurrentTableCellRange = xTable;
     uno::Reference<container::XNamed> xName (xTable, uno::UNO_QUERY );
     if (!xName.is())
         return;
@@ -2906,7 +2904,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const 
uno::Reference<sheet::XSpre
     {
         // store sheet events
         uno::Reference<document::XEventsSupplier> xSupplier(xTable, 
uno::UNO_QUERY);
-        uno::Reference<container::XNameAccess> xEvents(xSupplier->getEvents(), 
uno::UNO_QUERY);
+        uno::Reference<container::XNameAccess> xEvents = 
xSupplier->getEvents();
         GetEventExport().ExportExt( xEvents );
     }
 
@@ -2922,7 +2920,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const 
uno::Reference<sheet::XSpre
     }
     if (pSharedData->HasDrawPage())
     {
-        
GetShapeExport()->seekShapes(uno::Reference<drawing::XShapes>(pSharedData->GetDrawPage(nTable),
 uno::UNO_QUERY));
+        GetShapeExport()->seekShapes(pSharedData->GetDrawPage(nTable));
         WriteTableShapes();
     }
     table::CellRangeAddress aRange(GetEndAddress(xTable));
diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index 7e7455dc1477..72335f8a913d 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -119,7 +119,7 @@ void ScMyTables::NewSheet(const OUString& sTableName, const 
OUString& sStyleName
         {
             // We need to set the current cell range here regardless of
             // presence of style name.
-            xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY);
+            xCurrentCellRange = xCurrentSheet;
             SetTableStyle(sStyleName);
         }
     }
@@ -141,7 +141,7 @@ void ScMyTables::SetTableStyle(const OUString& sStyleName)
 
         if ( xCurrentSheet.is() )
         {
-            xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY);
+            xCurrentCellRange = xCurrentSheet;
             uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, 
uno::UNO_QUERY);
             if ( xProperties.is() )
             {
@@ -234,7 +234,7 @@ uno::Reference< drawing::XShapes > const & 
ScMyTables::GetCurrentXShapes()
 {
     if( (maCurrentCellPos.Tab() != nCurrentXShapes) || !xShapes.is() )
     {
-        xShapes.set(GetCurrentXDrawPage(), uno::UNO_QUERY);
+        xShapes = GetCurrentXDrawPage();
         rImport.GetShapeImport()->startPage(xShapes);
         rImport.GetShapeImport()->pushGroupForSorting ( xShapes );
         nCurrentXShapes = 
sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab());
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 5c0fcf636046..57aa6d71d4cc 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -120,10 +120,9 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
     {
         try
         {
-            uno::Reference < container::XNameAccess > xAccess( xStorage, 
uno::UNO_QUERY );
-            if ( xAccess->hasByName(sDocName) && xStorage->isStreamElement( 
sDocName) )
+            if ( xStorage->hasByName(sDocName) && xStorage->isStreamElement( 
sDocName) )
                 xDocStream = xStorage->openStreamElement( sDocName, 
embed::ElementModes::READ );
-            else if (!sOldDocName.isEmpty() && xAccess->hasByName(sOldDocName) 
&& xStorage->isStreamElement( sOldDocName) )
+            else if (!sOldDocName.isEmpty() && 
xStorage->hasByName(sOldDocName) && xStorage->isStreamElement( sOldDocName) )
             {
                 xDocStream = xStorage->openStreamElement( sOldDocName, 
embed::ElementModes::READ );
                 sStream = sOldDocName;
@@ -172,9 +171,8 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const 
uno::Reference<uno::XCompo
         uno::UNO_QUERY );
     OSL_ENSURE( xDocHandler.is(), "can't get Calc importer" );
     uno::Reference<document::XImporter> xImporter( xDocHandler, uno::UNO_QUERY 
);
-    uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY );
     if (xImporter.is())
-        xImporter->setTargetDocument( xComponent );
+        xImporter->setTargetDocument( xModel );
 
     ScXMLImport* pImporterImpl = dynamic_cast<ScXMLImport*>(xImporter.get());
     if (pImporterImpl)
@@ -666,9 +664,8 @@ bool ScXMLImportWrapper::ExportToComponent(const 
uno::Reference<uno::XComponentC
         uno::UNO_QUERY );
     OSL_ENSURE( xFilter.is(), "can't get exporter" );
     uno::Reference<document::XExporter> xExporter( xFilter, uno::UNO_QUERY );
-    uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY );
     if (xExporter.is())
-        xExporter->setSourceDocument( xComponent );
+        xExporter->setSourceDocument( xModel );
 
     if ( xFilter.is() )
     {
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx 
b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 856ef70b88c4..e947b655a9cb 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -615,11 +615,10 @@ bool ScChildrenShapes::IsSelected(sal_Int32 nIndex,
     uno::Reference< drawing::XShape > xReturnShape;
     bool bDebugResult(false);
     uno::Reference<drawing::XShapes> 
xShapes(mpViewShell->getSelectedXShapes());
-    uno::Reference<container::XIndexAccess> xIndexAccess(xShapes, 
uno::UNO_QUERY);
 
-    if (xIndexAccess.is())
+    if (xShapes.is())
     {
-        sal_Int32 nCount(xIndexAccess->getCount());
+        sal_Int32 nCount(xShapes->getCount());
         if (nCount)
         {
             uno::Reference< drawing::XShape > xShape;
@@ -627,7 +626,7 @@ bool ScChildrenShapes::IsSelected(sal_Int32 nIndex,
             sal_Int32 i(0);
             while (!bDebugResult && (i < nCount))
             {
-                xIndexAccess->getByIndex(i) >>= xShape;
+                xShapes->getByIndex(i) >>= xShape;
                 if (xShape.is() && (xIndexShape.get() == xShape.get()))
                 {
                     bDebugResult = true;
@@ -763,14 +762,13 @@ void ScChildrenShapes::SelectAll()
 void ScChildrenShapes::FillShapes(std::vector < uno::Reference < 
drawing::XShape > >& rShapes) const
 {
     uno::Reference<drawing::XShapes> 
xShapes(mpViewShell->getSelectedXShapes());
-    uno::Reference<container::XIndexAccess> xIndexAccess(xShapes, 
uno::UNO_QUERY);
-    if (xIndexAccess.is())
+    if (xShapes.is())
     {
-        sal_uInt32 nCount(xIndexAccess->getCount());
+        sal_uInt32 nCount(xShapes->getCount());
         for (sal_uInt32 i = 0; i < nCount; ++i)
         {
             uno::Reference<drawing::XShape> xShape;
-            xIndexAccess->getByIndex(i) >>= xShape;
+            xShapes->getByIndex(i) >>= xShape;
             if (xShape.is())
                 rShapes.push_back(xShape);
         }
@@ -905,14 +903,13 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const 
uno::Reference<drawing::X
 {
     bool bResult(false);
     SortedShapes aShapesList;
-    uno::Reference<container::XIndexAccess> xIndexAcc(xShapes, uno::UNO_QUERY);
-    if (xIndexAcc.is())
+    if (xShapes.is())
     {
-        mnShapesSelected = xIndexAcc->getCount();
+        mnShapesSelected = xShapes->getCount();
         for (sal_uInt32 i = 0; i < mnShapesSelected; ++i)
         {
             uno::Reference< drawing::XShape > xShape;
-            xIndexAcc->getByIndex(i) >>= xShape;
+            xShapes->getByIndex(i) >>= xShape;
             if (xShape.is())
             {
                 ScAccessibleShapeData* pShapeData = new 
ScAccessibleShapeData();
diff --git a/sc/source/ui/dataprovider/dataprovider.cxx 
b/sc/source/ui/dataprovider/dataprovider.cxx
index f87e006618ec..24e6a07b62d8 100644
--- a/sc/source/ui/dataprovider/dataprovider.cxx
+++ b/sc/source/ui/dataprovider/dataprovider.cxx
@@ -32,7 +32,7 @@ std::unique_ptr<SvStream> 
DataProvider::FetchStreamFromURL(const OUString& rURL,
 {
     try
     {
-        uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( 
ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), 
uno::UNO_QUERY );
+        uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess = 
ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() );
 
         uno::Reference< io::XInputStream > xStream = 
xFileAccess->openFileRead( rURL );
 
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 8705b5bc8c3b..33390347f944 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -789,8 +789,7 @@ ErrCode ScDocShell::DBaseExport( const OUString& 
rFullFileName, rtl_TextEncoding
         ::utl::DisposableComponent aConnectionHelper(xConnection);
 
         // get dBase driver
-        uno::Reference< sdbc::XDriverAccess> xAccess(xDrvMan,uno::UNO_QUERY);
-        uno::Reference< sdbcx::XDataDefinitionSupplier > xDDSup( 
xAccess->getDriverByURL( xConnection->getMetaData()->getURL() ), uno::UNO_QUERY 
);
+        uno::Reference< sdbcx::XDataDefinitionSupplier > xDDSup( 
xDrvMan->getDriverByURL( xConnection->getMetaData()->getURL() ), uno::UNO_QUERY 
);
         if ( !xDDSup.is() )
             return SCERR_EXPORT_CONNECT;
 
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 21a541285cc1..9123a8ecfc6b 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -117,9 +117,8 @@ void lcl_ChartInit(const uno::Reference 
<embed::XEmbeddedObject>& xObj, ScViewDa
         // connect to Calc data (if no range string, leave chart alone, with 
its own data)
 
         uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
-        uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, 
uno::UNO_QUERY );
-        if( xCompSupp.is())
-            xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+        if( xObj.is())
+            xReceiver.set( xObj->getComponent(), uno::UNO_QUERY );
         OSL_ASSERT( xReceiver.is());
         if( xReceiver.is() )
         {
@@ -478,9 +477,8 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, 
vcl::Window* pWin, ScDrawV
         
rViewShell.GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( 
SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName );
 
     uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
-    uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, 
uno::UNO_QUERY );
-    if( xCompSupp.is())
-        xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+    if( xObj.is())
+        xReceiver.set( xObj->getComponent(), uno::UNO_QUERY );
 
     uno::Reference<chart2::XChartDocument> xChartDoc(xReceiver, 
uno::UNO_QUERY);
     if (xChartDoc.is())
diff --git a/sc/source/ui/unoobj/TablePivotCharts.cxx 
b/sc/source/ui/unoobj/TablePivotCharts.cxx
index e5e8a88f03fa..a15250afdb62 100644
--- a/sc/source/ui/unoobj/TablePivotCharts.cxx
+++ b/sc/source/ui/unoobj/TablePivotCharts.cxx
@@ -130,10 +130,9 @@ void SAL_CALL TablePivotCharts::addNewByName(OUString 
const & rName,
             uno::Reference<chart2::data::XDataProvider> 
xDataProvider(pPivotTableDataProvider.release());
 
             uno::Reference<chart2::data::XDataReceiver> xReceiver;
-            uno::Reference<embed::XComponentSupplier> xCompSupp(xObject, 
uno::UNO_QUERY);
 
-            if (xCompSupp.is())
-                xReceiver.set(xCompSupp->getComponent(), uno::UNO_QUERY);
+            if (xObject.is())
+                xReceiver.set(xObject->getComponent(), uno::UNO_QUERY);
 
             if (xReceiver.is())
             {
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index b7464631cee5..405cc31ec55c 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -207,9 +207,8 @@ void SAL_CALL ScChartsObj::addNewByName( const OUString& 
rName,
                 ScChart2DataProvider( &rDoc );
             // Chart -> DataReceiver
             uno::Reference< chart2::data::XDataReceiver > xReceiver;
-            uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, 
uno::UNO_QUERY );
-            if( xCompSupp.is())
-                xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+            if( xObj.is())
+                xReceiver.set( xObj->getComponent(), uno::UNO_QUERY );
             if( xReceiver.is())
             {
                 OUString sRangeStr;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 953c977454da..700a099fd4fb 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1506,30 +1506,26 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& 
aSelection,
         else if( xShapes.is() )
         {
             //print a selected ole object
-            uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, 
uno::UNO_QUERY );
-            if( xIndexAccess.is() )
+            // multi selection isn't supported yet
+            uno::Reference< drawing::XShape > xShape( xShapes->getByIndex(0), 
uno::UNO_QUERY );
+            SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
+            if( pShape )
             {
-                // multi selection isn't supported yet
-                uno::Reference< drawing::XShape > xShape( 
xIndexAccess->getByIndex(0), uno::UNO_QUERY );
-                SvxShape* pShape = 
comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
-                if( pShape )
+                SdrObject *pSdrObj = pShape->GetSdrObject();
+                if( pDocShell )
                 {
-                    SdrObject *pSdrObj = pShape->GetSdrObject();
-                    if( pDocShell )
+                    ScDocument& rDoc = pDocShell->GetDocument();
+                    if( pSdrObj )
                     {
-                        ScDocument& rDoc = pDocShell->GetDocument();
-                        if( pSdrObj )
+                        tools::Rectangle aObjRect = 
pSdrObj->GetCurrentBoundRect();
+                        SCTAB nCurrentTab = ScDocShell::GetCurTab();
+                        ScRange aRange = rDoc.GetRange( nCurrentTab, aObjRect 
);
+                        rMark.SetMarkArea( aRange );
+
+                        if( rMark.IsMarked() && !rMark.IsMultiMarked() )
                         {
-                            tools::Rectangle aObjRect = 
pSdrObj->GetCurrentBoundRect();
-                            SCTAB nCurrentTab = ScDocShell::GetCurTab();
-                            ScRange aRange = rDoc.GetRange( nCurrentTab, 
aObjRect );
-                            rMark.SetMarkArea( aRange );
-
-                            if( rMark.IsMarked() && !rMark.IsMultiMarked() )
-                            {
-                                rStatus.SetMode( 
SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
-                                bDone = true;
-                            }
+                            rStatus.SetMode( 
SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
+                            bDone = true;
                         }
                     }
                 }
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index c3b49d99c734..8ee9d4374ee0 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -473,8 +473,7 @@ uno::Reference<text::XTextField> 
ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_In
         break;
     }
 
-    uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
-    xTextRange = xTemp;
+    xTextRange = xText;
 
     sal_Int32 nPar = aTempEngine.GetFieldPar();
     sal_Int32 nPos = aTempEngine.GetFieldPos();
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index a294d8edade7..3ef1645d2542 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -424,16 +424,13 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
             switch ( aTextData.GetPart() )
             {
                 case ScHeaderFooterPart::LEFT:
-                    xTextRange = uno::Reference<text::XTextRange>(
-                                  aTextData.GetContentObj()->getLeftText(), 
uno::UNO_QUERY);
+                    xTextRange = aTextData.GetContentObj()->getLeftText();
                 break;
                 case ScHeaderFooterPart::CENTER:
-                    xTextRange = uno::Reference<text::XTextRange>(
-                                  aTextData.GetContentObj()->getCenterText(), 
uno::UNO_QUERY);
+                    xTextRange = aTextData.GetContentObj()->getCenterText();
                 break;
                 case ScHeaderFooterPart::RIGHT:
-                    xTextRange = uno::Reference<text::XTextRange>(
-                                  aTextData.GetContentObj()->getRightText(), 
uno::UNO_QUERY);
+                    xTextRange = aTextData.GetContentObj()->getRightText();
                 break;
             }
 
diff --git a/sc/source/ui/vba/vbaapplication.cxx 
b/sc/source/ui/vba/vbaapplication.cxx
index ba821eb5d131..c7a46c3c74c2 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -568,11 +568,11 @@ uno::Reference< excel::XWorksheet > SAL_CALL
 ScVbaApplication::getActiveSheet()
 {
     uno::Reference< excel::XWorksheet > result;
-    uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), 
uno::UNO_QUERY );
+    uno::Reference< excel::XWorkbook > xWorkbook = getActiveWorkbook();
     if ( xWorkbook.is() )
     {
-        uno::Reference< excel::XWorksheet > xWorksheet(
-            xWorkbook->getActiveSheet(), uno::UNO_QUERY );
+        uno::Reference< excel::XWorksheet > xWorksheet =
+            xWorkbook->getActiveSheet();
         if ( xWorksheet.is() )
         {
             result = xWorksheet;
@@ -1376,7 +1376,7 @@ ScVbaApplication::MenuBars( const uno::Any& aIndex )
 uno::Any SAL_CALL
 ScVbaApplication::Rows( const uno::Any& aIndex )
 {
-    uno::Reference< excel::XWorksheet > xWorksheet( getActiveSheet(), 
uno::UNO_QUERY );
+    uno::Reference< excel::XWorksheet > xWorksheet = getActiveSheet();
     if ( xWorksheet.is() )
         return uno::Any( xWorksheet->Rows( aIndex ) );
     return uno::Any();
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 1836cbdd5088..a97729b16d12 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -3094,9 +3094,8 @@ ScVbaRange::Replace( const OUString& What, const 
OUString& Replacement, const un
         // ignore MatchByte for the moment, it's not supported in
         // OOo.org afaik
 
-        uno::Reference< util::XSearchDescriptor > xSearch( xDescriptor, 
uno::UNO_QUERY );
-        uno::Reference< container::XIndexAccess > xIndexAccess = 
xReplace->findAll( xSearch );
-        xReplace->replaceAll( xSearch );
+        uno::Reference< container::XIndexAccess > xIndexAccess = 
xReplace->findAll( xDescriptor );
+        xReplace->replaceAll( xDescriptor );
         if ( xIndexAccess.is() && xIndexAccess->getCount() > 0 )
         {
             for ( sal_Int32 i = 0; i < xIndexAccess->getCount(); ++i )
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 8f33e00c4c37..b6e45af532f5 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -200,7 +200,7 @@ ScVbaWorkbook::init()
 {
     if ( !ColorData.hasElements() )
         ResetColors();
-    uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY );
+    uno::Reference< frame::XModel > xModel = getModel();
     if ( xModel.is() )
         excel::getDocShell( xModel )->RegisterAutomationWorkbookObject( this );
 }
diff --git a/sc/source/ui/vba/vbaworksheet.cxx 
b/sc/source/ui/vba/vbaworksheet.cxx
index 83cddb7c6246..81ed54728e60 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -203,8 +203,7 @@ ScVbaWorksheet::createSheetCopyInNewDoc(const OUString& 
aCurrSheetName)
 {
     uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = 
getSheet()->createCursor( );
     uno::Reference<sheet::XUsedAreaCursor> 
xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
-    uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, 
uno::UNO_QUERY);
-    uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, mxContext, 
xRange1);
+    uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, mxContext, 
xSheetCellCursor);
     if (xRange.is())
         xRange->Select();
     excel::implnCopy(mxModel);
@@ -431,8 +430,7 @@ ScVbaWorksheet::getUsedRange()
     uno::Reference<sheet::XUsedAreaCursor> 
xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
     xUsedCursor->gotoStartOfUsedArea( false );
     xUsedCursor->gotoEndOfUsedArea( true );
-    uno::Reference< table::XCellRange > xRange( xSheetCellCursor, 
uno::UNO_QUERY);
-    return new ScVbaRange(this, mxContext, xRange);
+    return new ScVbaRange(this, mxContext, xSheetCellCursor);
 }
 
 uno::Reference< excel::XOutline >
@@ -541,9 +539,8 @@ ScVbaWorksheet::Move( const uno::Any& Before, const 
uno::Any& After )
     {
         uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = 
getSheet()->createCursor( );
         uno::Reference<sheet::XUsedAreaCursor> 
xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
-        uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, 
uno::UNO_QUERY);
         // #FIXME needs worksheet as parent
-        uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, 
mxContext, xRange1);
+        uno::Reference<excel::XRange> xRange =  new ScVbaRange( this, 
mxContext, xSheetCellCursor);
         if (xRange.is())
             xRange->Select();
         excel::implnCopy(mxModel);
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index a516f71bc64e..3a9755e528fb 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -180,11 +180,7 @@ void getRangeFromOle2Object(const SdrOle2Obj& rObj, 
std::vector<OUString>& rRang
     if (!xObj.is())
         return;
 
-    uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY);
-    if (!xCompSupp.is())
-        return;
-
-    uno::Reference<chart2::XChartDocument> 
xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY);
+    uno::Reference<chart2::XChartDocument> xChartDoc(xObj->getComponent(), 
uno::UNO_QUERY);
     if (!xChartDoc.is())
         return;
 
@@ -457,7 +453,7 @@ void ScDrawView::SetMarkedOriginalSize()
         if (nIdent == OBJ_OLE2)
         {
             // TODO/LEAN: working with visual area can switch object to 
running state
-            uno::Reference < embed::XEmbeddedObject > xObj( 
static_cast<SdrOle2Obj*>(pObj)->GetObjRef(), uno::UNO_QUERY );
+            uno::Reference < embed::XEmbeddedObject > xObj = 
static_cast<SdrOle2Obj*>(pObj)->GetObjRef();
             if ( xObj.is() )    // NULL for an invalid object that couldn't be 
loaded
             {
                 sal_Int64 nAspect = 
static_cast<SdrOle2Obj*>(pObj)->GetAspect();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to