diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-19 20:08:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 07:56:19 +0200 |
commit | 84abf28e05fc55be867028f3d3a59220ca2669f0 (patch) | |
tree | ebf1c6c90f89b4aa9a5a6b516ec89121026bfe03 | |
parent | defdd8bebe40b48d8abc4d893ac9a82b550c5d19 (diff) |
loplugin:referencecasting in oox..pyuno
Change-Id: Ie920c154aef3074016704c632b15d99110b219aa
Reviewed-on: https://gerrit.libreoffice.org/75974
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | oox/source/crypto/DocumentDecryption.cxx | 6 | ||||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/textparagraphproperties.cxx | 5 | ||||
-rw-r--r-- | oox/source/drawingml/textrun.cxx | 2 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 34 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 2 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 3 | ||||
-rw-r--r-- | oox/source/ole/vbaproject.cxx | 2 | ||||
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 2 | ||||
-rw-r--r-- | oox/source/ppt/timenode.cxx | 2 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 2 | ||||
-rw-r--r-- | package/qa/cppunit/test_package.cxx | 2 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 13 | ||||
-rw-r--r-- | pyuno/source/module/pyuno.cxx | 6 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_module.cxx | 2 |
16 files changed, 40 insertions, 47 deletions
diff --git a/oox/source/crypto/DocumentDecryption.cxx b/oox/source/crypto/DocumentDecryption.cxx index 88f2a7287d71..6ccbfc18d225 100644 --- a/oox/source/crypto/DocumentDecryption.cxx +++ b/oox/source/crypto/DocumentDecryption.cxx @@ -44,7 +44,7 @@ bool DocumentDecryption::readEncryptionInfo() if (!mrOleStorage.isStorage()) return false; - uno::Reference<io::XInputStream> xEncryptionInfo(mrOleStorage.openInputStream("EncryptionInfo"), uno::UNO_QUERY); + uno::Reference<io::XInputStream> xEncryptionInfo = mrOleStorage.openInputStream("EncryptionInfo"); BinaryXInputStream aBinaryInputStream(xEncryptionInfo, true); sal_uInt32 aVersion = aBinaryInputStream.readuInt32(); @@ -93,10 +93,10 @@ bool DocumentDecryption::decrypt(const uno::Reference<io::XStream>& xDocumentStr return false; // open the required input streams in the encrypted package - uno::Reference<io::XInputStream> xEncryptedPackage(mrOleStorage.openInputStream("EncryptedPackage"), uno::UNO_QUERY); + uno::Reference<io::XInputStream> xEncryptedPackage = mrOleStorage.openInputStream("EncryptedPackage"); // create temporary file for unencrypted package - uno::Reference<io::XOutputStream> xDecryptedPackage(xDocumentStream->getOutputStream(), uno::UNO_QUERY); + uno::Reference<io::XOutputStream> xDecryptedPackage = xDocumentStream->getOutputStream(); BinaryXOutputStream aDecryptedPackage(xDecryptedPackage, true); BinaryXInputStream aEncryptedPackage(xEncryptedPackage, true); diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 01e1d72562c5..a310549e0535 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -114,7 +114,7 @@ Reference< XLabeledDataSequence > lclCreateLabeledDataSequence( Reference< XLabeledDataSequence > xLabeledSeq; if( xValueSeq.is() || xTitleSeq.is() ) { - xLabeledSeq.set( LabeledDataSequence::create(rParent.getComponentContext()), UNO_QUERY ); + xLabeledSeq = LabeledDataSequence::create(rParent.getComponentContext()); if( xLabeledSeq.is() ) { xLabeledSeq->setValues( xValueSeq ); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 9431a71f46a5..41b264c16a8e 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1703,7 +1703,7 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& if( !xChartDoc->hasInternalDataProvider() ) { Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY ); - Reference< chart2::data::XDataSource > xData( xDataRec->getUsedData(), UNO_QUERY ); + Reference< chart2::data::XDataSource > xData = xDataRec->getUsedData(); if( !xData->getDataSequences().hasElements() || !xData->getDataSequences()[0]->getValues().is() || !xData->getDataSequences()[0]->getValues()->getData().hasElements() ) { diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 48e3b486e8b8..f1c966deeaa4 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -515,10 +515,9 @@ void TextParagraphProperties::dump() const const OUString sText = "debug"; xText->setString( sText ); - Reference< css::text::XTextCursor > xStart( xText->createTextCursor(), UNO_QUERY ); - Reference< css::text::XTextRange > xRange( xStart, UNO_QUERY ); + Reference< css::text::XTextCursor > xStart = xText->createTextCursor(); xStart->gotoEnd( true ); - Reference< XPropertySet > xPropSet( xRange, UNO_QUERY ); + Reference< XPropertySet > xPropSet( xStart, UNO_QUERY ); pushToPropSet( nullptr, xPropSet, emptyMap, nullptr, false, 0 ); PropertySet aPropSet( xPropSet ); aPropSet.dump(); diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index 9d80e0517816..cda8521cf338 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -59,7 +59,7 @@ sal_Int32 TextRun::insertAt( { sal_Int32 nCharHeight = 0; try { - Reference< XTextRange > xStart( xAt, UNO_QUERY ); + Reference< XTextRange > xStart = xAt; PropertySet aPropSet( xStart ); TextCharacterProperties aTextCharacterProps( rTextCharacterStyle ); diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 5e0d67ba3d3c..1acf1795373c 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -543,7 +543,7 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt //sort the categories name Sequence<Sequence<OUString>>aFinalSplitSource(aCategories.getLength()); for (sal_Int32 i = 0; i < aFinalSplitSource.getLength(); i++) { - const uno::Reference< chart2::data::XDataSequence > xCategories(aCategories[i]->getValues(), uno::UNO_QUERY); + const uno::Reference< chart2::data::XDataSequence > xCategories = aCategories[i]->getValues(); aFinalSplitSource[aFinalSplitSource.getLength() - i - 1] = lcl_getLabelSequence(xCategories); } return aFinalSplitSource; @@ -565,7 +565,7 @@ OUString ChartExport::parseFormula( const OUString& rRange ) { OUString aResult; Reference< XFormulaParser > xParser; - uno::Reference< lang::XMultiServiceFactory > xSF( GetFB()->getModelFactory(), uno::UNO_QUERY ); + uno::Reference< lang::XMultiServiceFactory > xSF = GetFB()->getModelFactory(); if( xSF.is() ) { try @@ -804,7 +804,7 @@ void ChartExport::exportChartSpace( const Reference< css::chart::XChartDocument // TODO: style // TODO: text properties // TODO: shape properties - Reference< XPropertySet > xPropSet( xChartDoc->getArea(), uno::UNO_QUERY ); + Reference< XPropertySet > xPropSet = xChartDoc->getArea(); if( xPropSet.is() ) exportShapeProps( xPropSet ); @@ -911,7 +911,7 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC exportView3D(); // floor - Reference< beans::XPropertySet > xFloor( mxNewDiagram->getFloor(), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xFloor = mxNewDiagram->getFloor(); if( xFloor.is() ) { pFS->startElement(FSNS(XML_c, XML_floor)); @@ -921,7 +921,7 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC // LibreOffice doesn't distinguish between sideWall and backWall (both are using the same color). // It is controlled by the same Wall property. - Reference< beans::XPropertySet > xWall( mxNewDiagram->getWall(), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xWall = mxNewDiagram->getWall(); if( xWall.is() ) { // sideWall @@ -1304,7 +1304,7 @@ void ChartExport::exportPlotArea( const Reference< css::chart::XChartDocument >& // We cannot write Wall attributes into Plot Area for 3D charts, because Wall us used as background wall. if( !mbIs3DChart && xWallFloorSupplier.is() ) { - Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY ); + Reference< beans::XPropertySet > xWallPropSet = xWallFloorSupplier->getWall(); if( xWallPropSet.is() ) { uno::Any aAny = xWallPropSet->getPropertyValue("LineStyle"); @@ -2559,11 +2559,11 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) if( xAxisXSupp.is()) xAxisProp = xAxisXSupp->getXAxis(); if( bHasXAxisTitle ) - xAxisTitle.set( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY ); + xAxisTitle = xAxisXSupp->getXAxisTitle(); if( bHasXAxisMajorGrid ) - xMajorGrid.set( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY ); + xMajorGrid = xAxisXSupp->getXMainGrid(); if( bHasXAxisMinorGrid ) - xMinorGrid.set( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY ); + xMinorGrid = xAxisXSupp->getXHelpGrid(); sal_Int32 eChartType = getChartType(); nAxisType = getXAxisType(eChartType); @@ -2577,11 +2577,11 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) if( xAxisYSupp.is()) xAxisProp = xAxisYSupp->getYAxis(); if( bHasYAxisTitle ) - xAxisTitle.set( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY ); + xAxisTitle = xAxisYSupp->getYAxisTitle(); if( bHasYAxisMajorGrid ) - xMajorGrid.set( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY ); + xMajorGrid = xAxisYSupp->getYMainGrid(); if( bHasYAxisMinorGrid ) - xMinorGrid.set( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); + xMinorGrid = xAxisYSupp->getYHelpGrid(); nAxisType = XML_valAx; // FIXME: axPos, need to check axis direction @@ -2594,11 +2594,11 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) if( xAxisZSupp.is()) xAxisProp = xAxisZSupp->getZAxis(); if( bHasZAxisTitle ) - xAxisTitle.set( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY ); + xAxisTitle = xAxisZSupp->getZAxisTitle(); if( bHasZAxisMajorGrid ) - xMajorGrid.set( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY ); + xMajorGrid = xAxisZSupp->getZMainGrid(); if( bHasZAxisMinorGrid ) - xMinorGrid.set( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY ); + xMinorGrid = xAxisZSupp->getZHelpGrid(); sal_Int32 eChartType = getChartType( ); if( (eChartType == chart::TYPEID_SCATTER) @@ -2620,7 +2620,7 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) if( bHasSecondaryXAxisTitle ) { Reference< css::chart::XSecondAxisTitleSupplier > xAxisSupp( mxDiagram, uno::UNO_QUERY ); - xAxisTitle.set( xAxisSupp->getSecondXAxisTitle(), uno::UNO_QUERY ); + xAxisTitle = xAxisSupp->getSecondXAxisTitle(); } sal_Int32 eChartType = getChartType(); @@ -2637,7 +2637,7 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) if( bHasSecondaryYAxisTitle ) { Reference< css::chart::XSecondAxisTitleSupplier > xAxisSupp( mxDiagram, uno::UNO_QUERY ); - xAxisTitle.set( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY ); + xAxisTitle = xAxisSupp->getSecondYAxisTitle(); } nAxisType = XML_valAx; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index be4ee5225a6b..920e8c589e26 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1619,7 +1619,7 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect, bool& rbOverridingCharHeight, sal_Int32& rnCharHeight ) { - Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); + Reference< XPropertySet > rXPropSet = rRun; Reference< XPropertyState > rXPropState( rRun, UNO_QUERY ); OUString usLanguage; PropertyState eState; diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 14e5b848558f..2c0fb1627bbb 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1961,8 +1961,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape ) xPropSet->getPropertyValue("Model") >>= xChartDoc; assert(xChartDoc.is()); //export the chart - Reference< XModel > xModel( xChartDoc, UNO_QUERY ); - ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() ); + ChartExport aChartExport( mnXmlNamespace, GetFS(), xChartDoc, GetFB(), GetDocumentType() ); static sal_Int32 nChartCount = 0; aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), ++nChartCount ); return *this; diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index b1591a2fb7f5..db8de0abf9c3 100644 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -187,7 +187,7 @@ void VbaProject::importVbaProject( StorageBase& rVbaPrjStrg, const GraphicHelper void VbaProject::importVbaData(const uno::Reference<io::XInputStream>& xInputStream) { uno::Reference<document::XStorageBasedDocument> xStorageBasedDoc(mxDocModel, uno::UNO_QUERY); - uno::Reference<embed::XStorage> xDocStorage(xStorageBasedDoc->getDocumentStorage(), uno::UNO_QUERY); + uno::Reference<embed::XStorage> xDocStorage = xStorageBasedDoc->getDocumentStorage(); { const sal_Int32 nOpenMode = ElementModes::SEEKABLE | ElementModes::WRITE | ElementModes::TRUNCATE; uno::Reference<io::XOutputStream> xDocStream(xDocStorage->openStreamElement("_MS_VBA_Macros_XML", nOpenMode), uno::UNO_QUERY); diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 5fc2e802f82b..cf0bdfed9659 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -147,7 +147,7 @@ static void ResolveTextFields( XmlFilterBase const & rFilter ) aURL = "#" + xNamed->getName(); xPropSet->setPropertyValue( sURL, Any( aURL ) ); Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY); - Reference< text::XTextRange > xTextRange( rTextField.xTextCursor, UNO_QUERY ); + Reference< text::XTextRange > xTextRange = rTextField.xTextCursor; rTextField.xText->insertTextContent( xTextRange, xContent, true ); } catch( uno::Exception& ) diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 8d61a078ec77..6a2fcce8f469 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -136,7 +136,7 @@ namespace oox { namespace ppt { // with node xE2->nextElement() >>= xEA2; if( xEA2.is() ) - xE2.set(xEA2->createEnumeration(), css::uno::UNO_QUERY); + xE2 = xEA2->createEnumeration(); else xE2.clear(); diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 41cf6973b492..e2eacd35b322 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -398,7 +398,7 @@ uno::Reference< drawing::XShape > SAL_CALL ShapeContextHandler::getShape() { uno::Reference< drawing::XShape > xResult; - uno::Reference< drawing::XShapes > xShapes( mxDrawPage, uno::UNO_QUERY ); + uno::Reference< drawing::XShapes > xShapes = mxDrawPage; if (mxFilterBase.is() && xShapes.is()) { diff --git a/package/qa/cppunit/test_package.cxx b/package/qa/cppunit/test_package.cxx index acd2b5c795a6..ec65d7a88351 100644 --- a/package/qa/cppunit/test_package.cxx +++ b/package/qa/cppunit/test_package.cxx @@ -70,7 +70,7 @@ namespace CPPUNIT_ASSERT(xZip.is()); - mxNA = uno::Reference<container::XNameAccess>(xZip, uno::UNO_QUERY); + mxNA = xZip; CPPUNIT_ASSERT(mxNA.is()); } diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 3c26f052b665..041363cb5142 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -1320,12 +1320,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre else m_pAntiImpl = new OWriteStream( this, xStream, bHierarchyAccess ); - uno::Reference< io::XStream > xWriteStream( static_cast< ::cppu::OWeakObject* >( m_pAntiImpl ), - uno::UNO_QUERY ); - - SAL_WARN_IF( !xWriteStream.is(), "package.xstor", "OWriteStream MUST implement XStream && XComponent interfaces!" ); - - return xWriteStream; + return m_pAntiImpl; } throw lang::IllegalArgumentException(); // TODO @@ -1380,7 +1375,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io: { uno::Reference < io::XStream > xTempFile; if ( !xTargetStream.is() ) - xTempFile.set( io::TempFile::create(m_xContext), uno::UNO_QUERY ); + xTempFile = io::TempFile::create(m_xContext); else xTempFile = xTargetStream; @@ -2069,7 +2064,7 @@ uno::Reference< io::XInputStream > SAL_CALL OWriteStream::getInputStream() if ( !m_bInitOnDemand && ( m_bInStreamDisconnected || !m_xInStream.is() ) ) return uno::Reference< io::XInputStream >(); - return uno::Reference< io::XInputStream >( static_cast< io::XInputStream* >( this ), uno::UNO_QUERY ); + return this; } uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream() @@ -2095,7 +2090,7 @@ uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream() if ( !m_xOutStream.is() ) return uno::Reference< io::XOutputStream >(); - return uno::Reference< io::XOutputStream >( static_cast< io::XOutputStream* >( this ), uno::UNO_QUERY ); + return this; } void SAL_CALL OWriteStream::writeBytes( const uno::Sequence< sal_Int8 >& aData ) diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index e59319030eb8..d0db3674d7b3 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -933,7 +933,7 @@ static int lcl_setitem_index( PyUNO const *me, PyObject *pKey, PyObject *pValue xIndexContainer.set( me->members->xInvocation, UNO_QUERY ); if ( xIndexContainer.is() ) - xIndexReplace.set( xIndexContainer, UNO_QUERY ); + xIndexReplace = xIndexContainer; else xIndexReplace.set( me->members->xInvocation, UNO_QUERY ); @@ -980,7 +980,7 @@ static int lcl_setitem_slice( PyUNO const *me, PyObject *pKey, PyObject *pValue xIndexContainer.set( me->members->xInvocation, UNO_QUERY ); if ( xIndexContainer.is() ) - xIndexReplace.set( xIndexContainer, UNO_QUERY ); + xIndexReplace = xIndexContainer; else xIndexReplace.set( me->members->xInvocation, UNO_QUERY ); @@ -1114,7 +1114,7 @@ static int lcl_setitem_string( PyUNO const *me, PyObject *pKey, PyObject *pValue Reference< XNameContainer > xNameContainer( me->members->xInvocation, UNO_QUERY ); Reference< XNameReplace > xNameReplace; if ( xNameContainer.is() ) - xNameReplace.set( xNameContainer, UNO_QUERY ); + xNameReplace = xNameContainer; else xNameReplace.set( me->members->xInvocation, UNO_QUERY ); diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index d088e33d616e..a6566182b546 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -430,7 +430,7 @@ static PyObject *createUnoStructHelper( { OUString typeName( OUString::createFromAscii(PyStr_AsString(structName))); RuntimeCargo *c = runtime.getImpl()->cargo; - Reference<XIdlClass> idl_class ( c->xCoreReflection->forName (typeName),UNO_QUERY); + Reference<XIdlClass> idl_class = c->xCoreReflection->forName (typeName); if (idl_class.is ()) { idl_class->createObject (IdlStruct); |