diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 13:30:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-20 17:59:32 +0200 |
commit | 586cfef1df9fb99aaf018029b7f06363e96bc72b (patch) | |
tree | dc4be0619ab5fccdf1e8e8780ddcdfa022e2f0eb /sw/source | |
parent | f44bd7bb0ce23535f5e0ced7966677f4fff943fc (diff) |
loplugin:referencecasting in sw
Change-Id: Ib5de4377b22815ba718559ff6fcfd6ab5a0547a6
Reviewed-on: https://gerrit.libreoffice.org/75999
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
49 files changed, 112 insertions, 156 deletions
diff --git a/sw/source/core/docnode/finalthreadmanager.cxx b/sw/source/core/docnode/finalthreadmanager.cxx index 537ab6f08cb6..495c1b1041a3 100644 --- a/sw/source/core/docnode/finalthreadmanager.cxx +++ b/sw/source/core/docnode/finalthreadmanager.cxx @@ -205,7 +205,7 @@ void TerminateOfficeThread::PerformOfficeTermination() { css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(mxContext); - css::uno::Reference< css::container::XElementAccess > xList( xDesktop->getFrames(), css::uno::UNO_QUERY ); + css::uno::Reference< css::container::XElementAccess > xList = xDesktop->getFrames(); if ( !xList.is() ) { OSL_FAIL( "<TerminateOfficeThread::PerformOfficeTermination()> - no XElementAccess!" ); diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index a61964900a1d..cd9bdd6281eb 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -527,10 +527,8 @@ bool lcl_UpdateParagraphSignatureField(SwDoc* pDoc, void lcl_RemoveParagraphMetadataField(const uno::Reference<css::text::XTextField>& xField) { - uno::Reference<css::text::XTextContent> xFieldTextContent(xField, uno::UNO_QUERY); - uno::Reference<css::text::XTextRange> xParagraph(xFieldTextContent->getAnchor()); - uno::Reference<css::text::XText> xParagraphText(xParagraph->getText(), uno::UNO_QUERY); - xParagraphText->removeTextContent(xFieldTextContent); + uno::Reference<css::text::XTextRange> xParagraph(xField->getAnchor()); + xParagraph->getText()->removeTextContent(xField); } /// Returns true iff the field in question is paragraph classification. @@ -784,7 +782,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY); @@ -962,7 +960,7 @@ std::vector<svx::ClassificationResult> SwEditShell::CollectAdvancedClassificatio uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); std::vector<OUString> aPageStyles = lcl_getUsedPageStyles(this); @@ -1095,7 +1093,7 @@ void SwEditShell::SetClassification(const OUString& rName, SfxClassificationPoli uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); @@ -1390,7 +1388,7 @@ SfxWatermarkItem SwEditShell::GetWatermark() uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); std::vector<OUString> aUsedPageStyles = lcl_getUsedPageStyles(this); for (const OUString& rPageStyleName : aUsedPageStyles) @@ -1616,7 +1614,7 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark) uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); @@ -1893,7 +1891,7 @@ static uno::Reference<text::XTextField> lcl_GetParagraphMetadataFieldAtIndex(con SwFormatMeta& rFormatMeta(static_cast<SwFormatMeta&>(pTextMeta->GetAttr())); if (::sw::Meta* pMeta = rFormatMeta.GetMeta()) { - const css::uno::Reference<css::rdf::XResource> xSubject(pMeta->MakeUnoObject(), uno::UNO_QUERY); + const css::uno::Reference<css::rdf::XResource> xSubject = pMeta->MakeUnoObject(); uno::Reference<frame::XModel> xModel = pDocSh->GetBaseModel(); const std::map<OUString, OUString> aStatements = lcl_getRDFStatements(xModel, xSubject); if (aStatements.find(ParagraphSignatureIdRDFName) != aStatements.end() || diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 78ff47515f5f..0ad5a1d4bd45 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -165,9 +165,8 @@ void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong, ErrCode SwXMLTextBlocks::Delete( sal_uInt16 n ) { const OUString aPckName (m_aNames[n]->aPackageName); - uno::Reference < container::XNameAccess > xAccess( xBlkRoot, uno::UNO_QUERY ); - if ( xAccess.is() && - xAccess->hasByName( aPckName ) && xBlkRoot->isStreamElement( aPckName ) ) + if ( xBlkRoot.is() && + xBlkRoot->hasByName( aPckName ) && xBlkRoot->isStreamElement( aPckName ) ) { try { diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx index 0a064945be94..843e545a39a0 100644 --- a/sw/source/core/swg/SwXMLTextBlocks1.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx @@ -277,8 +277,7 @@ ErrCode SwXMLTextBlocks::GetBlockText( const OUString& rShort, OUString& rText ) bool bTextOnly = true; xRoot = xBlkRoot->openStorageElement( aFolderName, embed::ElementModes::READ ); - uno::Reference < container::XNameAccess > xAccess( xRoot, uno::UNO_QUERY ); - if ( !xAccess->hasByName( aStreamName ) || !xRoot->isStreamElement( aStreamName ) ) + if ( !xRoot->hasByName( aStreamName ) || !xRoot->isStreamElement( aStreamName ) ) { bTextOnly = false; aStreamName = "content.xml"; @@ -360,13 +359,9 @@ ErrCode SwXMLTextBlocks::PutBlockText( const OUString& rShort, uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY ); xSet->setPropertyValue("MediaType", Any(OUString( "text/xml" )) ); uno::Reference < io::XOutputStream > xOut = xDocStream->getOutputStream(); - uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); - xSrc->setOutputStream(xOut); + xWriter->setOutputStream(xOut); - uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, - uno::UNO_QUERY); - - rtl::Reference<SwXMLTextBlockExport> xExp( new SwXMLTextBlockExport( xContext, *this, GetXMLToken ( XML_UNFORMATTED_TEXT ), xHandler) ); + rtl::Reference<SwXMLTextBlockExport> xExp( new SwXMLTextBlockExport( xContext, *this, GetXMLToken ( XML_UNFORMATTED_TEXT ), xWriter) ); xExp->exportDoc( rText ); @@ -408,8 +403,7 @@ void SwXMLTextBlocks::ReadInfo() try { const OUString sDocName( XMLN_BLOCKLIST ); - uno::Reference < container::XNameAccess > xAccess( xBlkRoot, uno::UNO_QUERY ); - if ( xAccess.is() && xAccess->hasByName( sDocName ) && xBlkRoot->isStreamElement( sDocName ) ) + if ( xBlkRoot.is() && xBlkRoot->hasByName( sDocName ) && xBlkRoot->isStreamElement( sDocName ) ) { uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); @@ -479,12 +473,9 @@ void SwXMLTextBlocks::WriteInfo() uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY ); xSet->setPropertyValue("MediaType", Any(OUString( "text/xml" )) ); uno::Reference < io::XOutputStream > xOut = xDocStream->getOutputStream(); - uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); - xSrc->setOutputStream(xOut); - - uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); + xWriter->setOutputStream(xOut); - rtl::Reference<SwXMLBlockListExport> xExp(new SwXMLBlockListExport( xContext, *this, XMLN_BLOCKLIST, xHandler) ); + rtl::Reference<SwXMLBlockListExport> xExp(new SwXMLBlockListExport( xContext, *this, XMLN_BLOCKLIST, xWriter) ); xExp->exportDoc( XML_BLOCK_LIST ); @@ -517,8 +508,8 @@ ErrCode SwXMLTextBlocks::SetMacroTable( comphelper::getProcessComponentContext(); // Get model - uno::Reference< lang::XComponent > xModelComp( - m_xDoc->GetDocShell()->GetModel(), UNO_QUERY ); + uno::Reference< lang::XComponent > xModelComp = + m_xDoc->GetDocShell()->GetModel(); OSL_ENSURE( xModelComp.is(), "XMLWriter::Write: got no model" ); if( !xModelComp.is() ) return ERR_SWG_WRITE_ERROR; @@ -547,8 +538,6 @@ ErrCode SwXMLTextBlocks::SetMacroTable( // connect XML writer to output stream xSaxWriter->setOutputStream( xOutputStream ); - uno::Reference<xml::sax::XDocumentHandler> xDocHandler( - xSaxWriter, UNO_QUERY); // construct events object uno::Reference<XNameAccess> xEvents = @@ -556,7 +545,7 @@ ErrCode SwXMLTextBlocks::SetMacroTable( // prepare arguments (prepend doc handler to given arguments) Sequence<Any> aParams(2); - aParams[0] <<= xDocHandler; + aParams[0] <<= xSaxWriter; aParams[1] <<= xEvents; // get filter component diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 3d55ed251f2b..b155c0f98e4b 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1203,7 +1203,7 @@ void SwTextNode::DestroyAttr( SwTextAttr* pAttr ) if (SwDocShell* pDocSh = pDoc->GetDocShell()) { static const OUString metaNS("urn:bails"); - const css::uno::Reference<css::rdf::XResource> xSubject(pMeta->MakeUnoObject(), uno::UNO_QUERY); + const css::uno::Reference<css::rdf::XResource> xSubject = pMeta->MakeUnoObject(); uno::Reference<frame::XModel> xModel = pDocSh->GetBaseModel(); SwRDFHelper::clearStatements(xModel, metaNS, xSubject); } diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index eb81443bf984..b8b4cf4a7148 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1016,8 +1016,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume OSL_FAIL("got NULL for XLabeledDataSequence from Data source"); continue; } - const uno::Reference< chart2::data::XDataSequence > xCurLabel( xLabeledDataSequence->getLabel(), uno::UNO_QUERY ); - const uno::Reference< chart2::data::XDataSequence > xCurValues( xLabeledDataSequence->getValues(), uno::UNO_QUERY ); + const uno::Reference< chart2::data::XDataSequence > xCurLabel = xLabeledDataSequence->getLabel(); + const uno::Reference< chart2::data::XDataSequence > xCurValues = xLabeledDataSequence->getValues(); // get sequence lengths for label and values. // (0 length is Ok) @@ -1475,12 +1475,11 @@ void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox &rB bool bSeqDisposed = false; // check if weak reference is still valid... - uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5 - uno::Reference< chart2::data::XDataSequence > xRef( xTemp, uno::UNO_QUERY ); - if (xRef.is()) + uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); + if (xTemp.is()) { // then delete that table box (check if implementation cursor needs to be adjusted) - pDataSeq = static_cast< SwChartDataSequence * >( xRef.get() ); + pDataSeq = static_cast< SwChartDataSequence * >( xTemp.get() ); if (pDataSeq) { try diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 712342578872..cc7b7e79ea5d 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -267,8 +267,7 @@ const SdrMarkList& SwFmDrawPage::PreGroup(const uno::Reference< drawing::XShape void SwFmDrawPage::PreUnGroup(const uno::Reference< drawing::XShapeGroup >& rShapeGroup) { - uno::Reference< drawing::XShape > xShape( rShapeGroup, uno::UNO_QUERY); - SelectObjectInView( xShape, GetPageView() ); + SelectObjectInView( rShapeGroup, GetPageView() ); } SdrPageView* SwFmDrawPage::GetPageView() diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 9660d3187754..2152029a3972 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -537,9 +537,8 @@ lcl_CreateTOXMarkPortion( SwDoc* pDoc = pUnoCursor->GetDoc(); SwTOXMark & rTOXMark = static_cast<SwTOXMark&>(rAttr.GetAttr()); - const Reference<XTextContent> xContent( - SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, & rTOXMark), - uno::UNO_QUERY); + const Reference<XTextContent> xContent = + SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, & rTOXMark); SwXTextPortion* pPortion = nullptr; if (!bEnd) diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 204a3a737358..ab7e4f7adc3e 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -4766,7 +4766,7 @@ sal_Bool SAL_CALL SwXTextCellStyle::isInUse() if (!xFamiliesSupplier.is()) return false; - uno::Reference<container::XNameAccess> xFamilies(xFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xFamilies = xFamiliesSupplier->getStyleFamilies(); if (!xFamilies.is()) return false; diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 992c8be80532..040291d51652 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -877,8 +877,7 @@ SwXText::getStart() throw aRuntime; } xRef->gotoStart(false); - const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); - return xRet; + return xRef; } uno::Reference< text::XTextRange > SAL_CALL @@ -894,8 +893,7 @@ SwXText::getEnd() throw aRuntime; } xRef->gotoEnd(false); - const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); - return xRet; + return xRef; } OUString SAL_CALL SwXText::getString() diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx index 9750ff7f07a0..482fce55732e 100644 --- a/sw/source/filter/html/htmlbas.cxx +++ b/sw/source/filter/html/htmlbas.cxx @@ -119,7 +119,7 @@ void SwHTMLParser::EndScript() aLibName = "Standard"; // get module library container - Reference< script::XLibraryContainer > xModLibContainer( pDocSh->GetBasicContainer(), UNO_QUERY ); + Reference< script::XLibraryContainer > xModLibContainer = pDocSh->GetBasicContainer(); if ( xModLibContainer.is() ) { @@ -161,7 +161,7 @@ void SwHTMLParser::EndScript() } // get dialog library container - Reference< script::XLibraryContainer > xDlgLibContainer( pDocSh->GetDialogContainer(), UNO_QUERY ); + Reference< script::XLibraryContainer > xDlgLibContainer = pDocSh->GetDialogContainer(); if ( xDlgLibContainer.is() ) { diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index f0e14faa4471..78c8d820df34 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -321,7 +321,7 @@ const uno::Reference< drawing::XShapes > & SwHTMLForm_Impl::GetShapes() GetDrawPage(); if( m_xDrawPage.is() ) { - m_xShapes.set( m_xDrawPage, UNO_QUERY ); + m_xShapes = m_xDrawPage; OSL_ENSURE( m_xShapes.is(), "XShapes not received from drawing::XDrawPage" ); } diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index eb8697d99291..87a190b322c0 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -88,8 +88,7 @@ static void lcl_html_outEvents( SvStream& rStrm, rtl_TextEncoding eDestEnc, OUString *pNonConvertableChars ) { - uno::Reference< container::XChild > xChild( rFormComp, uno::UNO_QUERY ); - uno::Reference< uno::XInterface > xParentIfc = xChild->getParent(); + uno::Reference< uno::XInterface > xParentIfc = rFormComp->getParent(); OSL_ENSURE( xParentIfc.is(), "lcl_html_outEvents: no parent interface" ); if( !xParentIfc.is() ) return; diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index f6a60aff7962..222ca88667c0 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1158,7 +1158,7 @@ sal_uInt16 SwHTMLWriter::GuessOLENodeFrameType( const SwNode& rNode ) SwHTMLFrameType eType = HTML_FRMTYPE_OLE; - uno::Reference < embed::XClassifiedObject > xClass ( rObj.GetOleRef(), uno::UNO_QUERY ); + uno::Reference < embed::XClassifiedObject > xClass = rObj.GetOleRef(); SvGlobalName aClass( xClass->getClassID() ); if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) ) { diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 1e5b7ccc9a9c..c67971cc86b6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5044,8 +5044,7 @@ void DocxAttributeOutput::WritePostponedChart() OString aRelId; m_nChartCount++; - uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY ); - aRelId = m_rExport.OutputChart( xModel, m_nChartCount, m_pSerializer ); + aRelId = m_rExport.OutputChart( xChartDoc, m_nChartCount, m_pSerializer ); m_pSerializer->singleElementNS( XML_c, XML_chart, FSNS( XML_xmlns, XML_c ), GetExport().GetFilter().getNamespaceURL(OOX_NS(dmlChart)).toUtf8(), diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 813839e4b84a..9a3d37c47b5b 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1322,13 +1322,13 @@ void DocxExport::WriteVBA() if (!xStorageBasedDocument.is()) return; - uno::Reference<embed::XStorage> xDocumentStorage(xStorageBasedDocument->getDocumentStorage(), uno::UNO_QUERY); + uno::Reference<embed::XStorage> xDocumentStorage = xStorageBasedDocument->getDocumentStorage(); OUString aMacrosName("_MS_VBA_Macros"); if (!xDocumentStorage.is() || !xDocumentStorage->hasByName(aMacrosName)) return; const sal_Int32 nOpenMode = embed::ElementModes::READ; - uno::Reference<io::XStream> xMacrosStream(xDocumentStorage->openStreamElement(aMacrosName, nOpenMode), uno::UNO_QUERY); + uno::Reference<io::XStream> xMacrosStream = xDocumentStorage->openStreamElement(aMacrosName, nOpenMode); uno::Reference<io::XOutputStream> xProjectStream; if (xMacrosStream.is()) { @@ -1352,7 +1352,7 @@ void DocxExport::WriteVBA() if (!xDocumentStorage.is() || !xDocumentStorage->hasByName(aDataName)) return; - uno::Reference<io::XStream> xDataStream(xDocumentStorage->openStreamElement(aDataName, nOpenMode), uno::UNO_QUERY); + uno::Reference<io::XStream> xDataStream = xDocumentStorage->openStreamElement(aDataName, nOpenMode); if (xDataStream.is()) { // Then the data stream, which wants to work with an already set diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 11c99b5f29d1..b7a6141f60a7 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3920,7 +3920,7 @@ bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrameFormat* pFlyFrameFormat return false; m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATH " "); - uno::Reference<util::XCloseable> xClosable(xObj->getComponent(), uno::UNO_QUERY); + uno::Reference<util::XCloseable> xClosable = xObj->getComponent(); if (!xClosable.is()) return false; // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class, diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index d3b2789b4333..c013515899ae 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -328,9 +328,7 @@ namespace sw OSL_ENSURE( !mrPers.GetEmbeddedObjectContainer().HasEmbeddedObject( mxIPRef ), "Object in adaptor is inserted?!" ); try { - uno::Reference < css::util::XCloseable > xClose( mxIPRef, uno::UNO_QUERY ); - if ( xClose.is() ) - xClose->close(true); + mxIPRef->close(true); } catch ( const css::util::CloseVetoException& ) { diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 1a76791f8e3c..dd0fad0b0421 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1866,9 +1866,8 @@ void SwWW8ImplReader::ImportDop() uno::Reference< uno::XComponentContext > xComponentContext(comphelper::getProcessComponentContext()); uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(xComponentContext); xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps)); - uno::Reference<container::XIndexAccess> xIndexAccess(xBox, uno::UNO_QUERY); uno::Reference<document::XViewDataSupplier> xViewDataSupplier(m_pDocShell->GetModel(), uno::UNO_QUERY); - xViewDataSupplier->setViewData(xIndexAccess); + xViewDataSupplier->setViewData(xBox); } m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_VIRTUAL_DEVICE, !m_xWDop->fUsePrinterMetrics); diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index 6beddecc3691..9bb3521e51ea 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -210,7 +210,7 @@ SwFlyFrameFormat* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject, SwFlyFrameFormat *pRet = nullptr; std::unique_ptr<SfxItemSet> pMathFlySet; - uno::Reference < embed::XClassifiedObject > xClass( rObject.GetObjRef(), uno::UNO_QUERY ); + uno::Reference < embed::XClassifiedObject > xClass = rObject.GetObjRef(); if( xClass.is() ) { SvGlobalName aClassName( xClass->getClassID() ); diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index c03777bbbdf8..a2406cf34d11 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -579,7 +579,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference< return false; if ( !bIsMenuBar ) { - 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/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 25c415d65fcd..f82b4709c406 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -529,7 +529,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con OSL_ENSURE( pDocSh, "XMLReader::Read: got no doc shell" ); if( !pDocSh ) return ERR_SWG_READ_ERROR; - uno::Reference< lang::XComponent > xModelComp( pDocSh->GetModel(), UNO_QUERY ); + uno::Reference< lang::XComponent > xModelComp = pDocSh->GetModel(); OSL_ENSURE( xModelComp.is(), "XMLReader::Read: got no model" ); if( !xModelComp.is() ) diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 5ca7e7212be6..e4cef6663a15 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -543,9 +543,8 @@ bool SwXMLWriter::WriteThroughComponent( xSaxWriter->setOutputStream( xOutputStream ); // prepare arguments (prepend doc handler to given arguments) - uno::Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY); Sequence<Any> aArgs( 1 + rArguments.getLength() ); - aArgs[0] <<= xDocHandler; + aArgs[0] <<= xSaxWriter; std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); // get filter component diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index da4020083fbc..20457677a024 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -314,7 +314,7 @@ XMLShapeExport* SwXMLExport::CreateShapeExport() Reference < XDrawPageSupplier > xDPS( GetModel(), UNO_QUERY ); if( xDPS.is() ) { - Reference < XShapes > xShapes( xDPS->getDrawPage(), UNO_QUERY ); + Reference < XShapes > xShapes = xDPS->getDrawPage(); pShapeExport->seekShapes( xShapes ); } diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 0c9f5e84ae84..aee43cb6f1ae 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1186,8 +1186,7 @@ SvTextShapeImportHelper::SvTextShapeImportHelper(SvXMLImport& rImp) : } xPage = xSupplier->getDrawPage(); - Reference<XShapes> xShapes( xPage, UNO_QUERY ); - XMLShapeImportHelper::startPage( xShapes ); + XMLShapeImportHelper::startPage( xPage ); } } @@ -1197,8 +1196,7 @@ SvTextShapeImportHelper::~SvTextShapeImportHelper() if (xPage.is()) { - Reference<XShapes> xShapes( xPage, UNO_QUERY ); - XMLShapeImportHelper::endPage(xShapes); + XMLShapeImportHelper::endPage(xPage); } } diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx index 21c2a19dfef1..fc1475647b82 100644 --- a/sw/source/ui/dbui/addresslistdialog.cxx +++ b/sw/source/ui/dbui/addresslistdialog.cxx @@ -295,8 +295,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void) const OUString sURL = aDlg.GetURL(); try { - uno::Reference<XSingleServiceFactory> xFact( m_xDBContext, UNO_QUERY); - uno::Reference<XInterface> xNewInstance = xFact->createInstance(); + uno::Reference<XInterface> xNewInstance = m_xDBContext->createInstance(); INetURLObject aURL( sURL ); const OUString sNewName = aURL.getBase(); //find a unique name if sNewName already exists @@ -342,8 +341,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void) } xStore->storeAsURL(sTmpName, Sequence< PropertyValue >()); - uno::Reference<XNamingService> xNaming(m_xDBContext, UNO_QUERY); - xNaming->registerObject( sFind, xNewInstance ); + m_xDBContext->registerObject( sFind, xNewInstance ); //now insert the new source into the ListBox m_xListLB->append(m_xIter.get()); m_xListLB->set_text(*m_xIter, sFind, 0); @@ -449,7 +447,7 @@ void SwAddressListDialog::DetectTablesAndQueries( pUserData->xSource.set(xComplConnection, UNO_QUERY); uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - uno::Reference< XInteractionHandler > xHandler( InteractionHandler::createWithParent(xContext, nullptr), UNO_QUERY ); + uno::Reference< XInteractionHandler > xHandler = InteractionHandler::createWithParent(xContext, nullptr); pUserData->xConnection = SharedConnection( xComplConnection->connectWithCompletion( xHandler ) ); } if(pUserData->xConnection.is()) diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx b/sw/source/ui/dbui/createaddresslistdialog.cxx index 62b04be87fca..7edb7911cf88 100644 --- a/sw/source/ui/dbui/createaddresslistdialog.cxx +++ b/sw/source/ui/dbui/createaddresslistdialog.cxx @@ -421,9 +421,8 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, OkHdl_Impl, weld::Button&, void) const OUString sPath( SvtPathOptions().SubstituteVariable("$(userurl)/database") ); aDlgHelper.SetDisplayDirectory( sPath ); - uno::Reference< XFilterManager > xFltMgr(xFP, uno::UNO_QUERY); - xFltMgr->appendFilter( m_sAddressListFilterName, "*.csv" ); - xFltMgr->setCurrentFilter( m_sAddressListFilterName ) ; + xFP->appendFilter( m_sAddressListFilterName, "*.csv" ); + xFP->setCurrentFilter( m_sAddressListFilterName ) ; if( ERRCODE_NONE == aDlgHelper.Execute() ) { diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx index fd2e3544639c..fb3e05110330 100644 --- a/sw/source/ui/dbui/mmdocselectpage.cxx +++ b/sw/source/ui/dbui/mmdocselectpage.cxx @@ -133,18 +133,17 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, weld::Button&, rButton, void) SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory(); SfxFilterMatcher aMatcher( rFact.GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); - Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); std::shared_ptr<const SfxFilter> pFlt = aIter.First(); while( pFlt ) { if( pFlt && pFlt->IsAllowedAsTemplate() ) { const OUString sWild = pFlt->GetWildcard().getGlob(); - xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); + xFP->appendFilter( pFlt->GetUIName(), sWild ); // #i40125 if(pFlt->GetFilterFlags() & SfxFilterFlags::DEFAULT) - xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ; + xFP->setCurrentFilter( pFlt->GetUIName() ) ; } pFlt = aIter.Next(); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 361bf7520d37..1401f8a6b1fd 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -173,9 +173,8 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( OUString sIndexTypeName(OUString::createFromAscii( IndexServiceNames[ nTOXIndex <= TOX_AUTHORITIES ? nTOXIndex : TOX_USER] )); m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex.set(xFact->createInstance(sIndexTypeName), uno::UNO_QUERY); - uno::Reference< text::XTextContent > xContent(m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex, uno::UNO_QUERY); - uno::Reference< text::XTextRange > xRg(xCursor, uno::UNO_QUERY); - xCursor->getText()->insertTextContent(xRg, xContent, false); + uno::Reference< text::XTextContent > xContent = m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex; + xCursor->getText()->insertTextContent(xCursor, xContent, false); } for(sal_uInt16 i = 0 ; i <= TOX_AUTHORITIES; i++) { diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 5b1f6c53d099..8bd225fde246 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -101,9 +101,8 @@ static OUString lcl_CreateAutoMarkFileDlg(weld::Window* pParent, const OUString& FileDialogFlags::NONE, pParent); uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); - xFltMgr->appendFilter( rFileString, "*.sdi" ); - xFltMgr->setCurrentFilter( rFileString ) ; + xFP->appendFilter( rFileString, "*.sdi" ); + xFP->setCurrentFilter( rFileString ) ; if( !rURL.isEmpty() ) xFP->setDisplayDirectory( rURL ); diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index bd72af29a284..9f69596083c4 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -575,7 +575,6 @@ IMPL_LINK(SwGlossaryDlg, MenuHdl, const OString&, rItemIdent, void) SvtPathOptions aPathOpt; xFP->setDisplayDirectory(aPathOpt.GetWorkPath() ); - uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); std::shared_ptr<const SfxFilter> pFilter = aIter.First(); @@ -583,15 +582,15 @@ IMPL_LINK(SwGlossaryDlg, MenuHdl, const OString&, rItemIdent, void) { if( pFilter->GetUserData() == FILTER_WW8 ) { - xFltMgr->appendFilter( pFilter->GetUIName(), + xFP->appendFilter( pFilter->GetUIName(), pFilter->GetWildcard().getGlob() ); - xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ; + xFP->setCurrentFilter( pFilter->GetUIName() ) ; } else if( pFilter->GetUserData() == FILTER_DOCX ) { - xFltMgr->appendFilter( pFilter->GetUIName(), + xFP->appendFilter( pFilter->GetUIName(), pFilter->GetWildcard().getGlob() ); - xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ; + xFP->setCurrentFilter( pFilter->GetUIName() ) ; } pFilter = aIter.Next(); @@ -934,8 +933,7 @@ void SwGlossaryDlg::ResumeShowAutoText() uno::Any aEntry(xGroup->getByName(sShortName)); uno::Reference< XAutoTextEntry > xEntry; aEntry >>= xEntry; - uno::Reference< XTextRange > xRange(xCursor, uno::UNO_QUERY); - xEntry->applyTo(xRange); + xEntry->applyTo(xCursor); } } } diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx index 785c48a45057..857ca1231f89 100644 --- a/sw/source/ui/vba/vbaapplication.cxx +++ b/sw/source/ui/vba/vbaapplication.cxx @@ -388,13 +388,13 @@ void SAL_CALL SwVbaApplication::setCustomizationContext(const uno::Any& /*_custo void SAL_CALL SwVbaApplication::setStatusBar( const OUString& _statusbar ) { // ScVbaAppSettings::setStatusBar() also uses the XStatusIndicator to show this, so maybe that is OK? - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY ); + uno::Reference< frame::XModel > xModel = getCurrentDocument(); if (xModel.is()) { uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY ); if (xStatusIndicatorSupplier.is()) { - uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY ); + uno::Reference< task::XStatusIndicator > xStatusIndicator = xStatusIndicatorSupplier->getStatusIndicator(); if (xStatusIndicator.is()) xStatusIndicator->start( _statusbar, 100 ); } diff --git a/sw/source/ui/vba/vbacolumns.cxx b/sw/source/ui/vba/vbacolumns.cxx index e2049400efa6..2fbad7d3dccd 100644 --- a/sw/source/ui/vba/vbacolumns.cxx +++ b/sw/source/ui/vba/vbacolumns.cxx @@ -39,7 +39,7 @@ class ColumnsEnumWrapper : public EnumerationHelper_BASE public: ColumnsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 ) { - mxIndexAccess.set( mxTextTable->getColumns(), uno::UNO_QUERY ); + mxIndexAccess = mxTextTable->getColumns(); } virtual sal_Bool SAL_CALL hasMoreElements( ) override { diff --git a/sw/source/ui/vba/vbadocuments.cxx b/sw/source/ui/vba/vbadocuments.cxx index bdf0f45e3722..0609817cc103 100644 --- a/sw/source/ui/vba/vbadocuments.cxx +++ b/sw/source/ui/vba/vbadocuments.cxx @@ -44,11 +44,10 @@ static uno::Any getDocument( uno::Reference< uno::XComponentContext > const & xContext, const uno::Reference< text::XTextDocument > &xDoc, const uno::Any& aApplication ) { // FIXME: fine as long as SwVbaDocument is stateless ... - uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); - if( !xModel.is() ) + if( !xDoc.is() ) return uno::Any(); - SwVbaDocument *pWb = new SwVbaDocument( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); + SwVbaDocument *pWb = new SwVbaDocument( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xDoc ); return uno::Any( uno::Reference< word::XDocument > (pWb) ); } diff --git a/sw/source/ui/vba/vbarows.cxx b/sw/source/ui/vba/vbarows.cxx index 839a5021e870..65cdec698ef2 100644 --- a/sw/source/ui/vba/vbarows.cxx +++ b/sw/source/ui/vba/vbarows.cxx @@ -42,7 +42,7 @@ class RowsEnumWrapper : public EnumerationHelper_BASE public: RowsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 ) { - mxIndexAccess.set( mxTextTable->getRows(), uno::UNO_QUERY ); + mxIndexAccess = mxTextTable->getRows(); } virtual sal_Bool SAL_CALL hasMoreElements( ) override { diff --git a/sw/source/ui/vba/wordvbahelper.cxx b/sw/source/ui/vba/wordvbahelper.cxx index 776067ff79b5..b54fb6ef3103 100644 --- a/sw/source/ui/vba/wordvbahelper.cxx +++ b/sw/source/ui/vba/wordvbahelper.cxx @@ -134,7 +134,7 @@ uno::Reference< text::XText > getCurrentXText( const uno::Reference< frame::XMod } if( xTextContent.is() ) - xTextRange.set( xTextContent->getAnchor(), uno::UNO_QUERY ); + xTextRange = xTextContent->getAnchor(); if( !xTextRange.is() ) xTextRange.set( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW ); @@ -142,7 +142,7 @@ uno::Reference< text::XText > getCurrentXText( const uno::Reference< frame::XMod uno::Reference< text::XText > xText; try { - xText.set( xTextRange->getText(), uno::UNO_QUERY ); + xText = xTextRange->getText(); } catch (const uno::RuntimeException&) { diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index b6c0df359aa8..481dd8e7a2c1 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -649,7 +649,7 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium ) SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get(); if( !rHtmlOpt.IsStarBasic() && rHtmlOpt.IsStarBasicWarning() && HasBasic() ) { - uno::Reference< XLibraryContainer > xLibCont(GetBasicContainer(), UNO_QUERY); + uno::Reference< XLibraryContainer > xLibCont = GetBasicContainer(); uno::Reference< XNameAccess > xLib; Sequence<OUString> aNames = xLibCont->getElementNames(); for(const OUString& rName : aNames) diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 771972fb63d5..408ec26170bd 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -582,7 +582,6 @@ void SwDocShell::Execute(SfxRequest& rReq) SfxObjectFactory &rFact = GetFactory(); SfxFilterMatcher aMatcher( rFact.GetFactoryName() ); SfxFilterMatcherIter aIter( aMatcher ); - uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); std::shared_ptr<const SfxFilter> pFlt = aIter.First(); while( pFlt ) { @@ -592,7 +591,7 @@ void SwDocShell::Execute(SfxRequest& rReq) pFlt->GetUserData() == "CXMLV" ) ) { const OUString sWild = pFlt->GetWildcard().getGlob(); - xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); + xFP->appendFilter( pFlt->GetUIName(), sWild ); } pFlt = aIter.Next(); } @@ -605,14 +604,14 @@ void SwDocShell::Execute(SfxRequest& rReq) if(bWeb) { const OUString sWild = pOwnFlt->GetWildcard().getGlob(); - xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild ); + xFP->appendFilter( pOwnFlt->GetUIName(), sWild ); } bool bError = false; // catch exception if wrong filter is selected - should not happen anymore try { - xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() ); + xFP->setCurrentFilter( pOwnFlt->GetUIName() ); } catch (const uno::Exception&) { @@ -1013,12 +1012,11 @@ void SwDocShell::Execute(SfxRequest& rReq) if( pFlt ) { - uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); const OUString sWild = pFlt->GetWildcard().getGlob(); - xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); + xFP->appendFilter( pFlt->GetUIName(), sWild ); try { - xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ; + xFP->setCurrentFilter( pFlt->GetUIName() ) ; } catch (const uno::Exception&) { diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index 5bbc20421fbc..4f9690818f65 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -597,7 +597,7 @@ bool SwDocShell::LoadFrom( SfxMedium& rMedium ) do { // middle check loop ErrCode nErr = ERR_SWG_READ_ERROR; OUString aStreamName = "styles.xml"; - uno::Reference < container::XNameAccess > xAccess( rMedium.GetStorage(), uno::UNO_QUERY ); + uno::Reference < container::XNameAccess > xAccess = rMedium.GetStorage(); if ( xAccess->hasByName( aStreamName ) && rMedium.GetStorage()->isStreamElement( aStreamName ) ) { // Loading diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx index 80439b19031d..653bd737bd0c 100644 --- a/sw/source/uibase/config/StoredChapterNumbering.cxx +++ b/sw/source/uibase/config/StoredChapterNumbering.cxx @@ -413,8 +413,7 @@ void ExportStoredChapterNumberingRules(SwChapterNumRules & rRules, uno::Reference<xml::sax::XWriter> const xWriter( xml::sax::Writer::create(xContext)); - uno::Reference<io::XActiveDataSource> const xADS(xWriter, uno::UNO_QUERY); - xADS->setOutputStream(xOutStream); + xWriter->setOutputStream(xOutStream); rtl::Reference<StoredChapterNumberingExport> exp(new StoredChapterNumberingExport(xContext, rFileName, xWriter)); diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 48ce4dc80a5a..77a2439990d1 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -327,7 +327,7 @@ struct SwDBManager::SwDBManager_Impl static void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<sdbc::XDataSource> const & xSource) { uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); - rParam.xFormatter.set(util::NumberFormatter::create(xContext), uno::UNO_QUERY); + rParam.xFormatter = util::NumberFormatter::create(xContext); uno::Reference<beans::XPropertySet> xSourceProps( (xSource.is() ? xSource @@ -2882,8 +2882,6 @@ OUString SwDBManager::LoadAndRegisterDataSource(weld::Window* pParent, SwDocShel OUString sHomePath(SvtPathOptions().GetWorkPath()); aDlgHelper.SetDisplayDirectory( sHomePath ); - uno::Reference<ui::dialogs::XFilterManager> xFltMgr(xFP, uno::UNO_QUERY); - OUString sFilterAll(SwResId(STR_FILTER_ALL)); OUString sFilterAllData(SwResId(STR_FILTER_ALL_DATA)); OUString sFilterSXB(SwResId(STR_FILTER_SXB)); @@ -2898,23 +2896,23 @@ OUString SwDBManager::LoadAndRegisterDataSource(weld::Window* pParent, SwDocShel OUString sFilterMDB(SwResId(STR_FILTER_MDB)); OUString sFilterACCDB(SwResId(STR_FILTER_ACCDB)); #endif - xFltMgr->appendFilter( sFilterAll, "*" ); - xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.odt;*.sxw;*.dbf;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.csv"); - - xFltMgr->appendFilter( sFilterSXB, "*.odb" ); - xFltMgr->appendFilter( sFilterSXC, "*.ods;*.sxc" ); - xFltMgr->appendFilter( sFilterSXW, "*.odt;*.sxw" ); - xFltMgr->appendFilter( sFilterDBF, "*.dbf" ); - xFltMgr->appendFilter( sFilterXLS, "*.xls;*.xlsx" ); - xFltMgr->appendFilter( sFilterDOC, "*.doc;*.docx" ); - xFltMgr->appendFilter( sFilterTXT, "*.txt" ); - xFltMgr->appendFilter( sFilterCSV, "*.csv" ); + xFP->appendFilter( sFilterAll, "*" ); + xFP->appendFilter( sFilterAllData, "*.ods;*.sxc;*.odt;*.sxw;*.dbf;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.csv"); + + xFP->appendFilter( sFilterSXB, "*.odb" ); + xFP->appendFilter( sFilterSXC, "*.ods;*.sxc" ); + xFP->appendFilter( sFilterSXW, "*.odt;*.sxw" ); + xFP->appendFilter( sFilterDBF, "*.dbf" ); + xFP->appendFilter( sFilterXLS, "*.xls;*.xlsx" ); + xFP->appendFilter( sFilterDOC, "*.doc;*.docx" ); + xFP->appendFilter( sFilterTXT, "*.txt" ); + xFP->appendFilter( sFilterCSV, "*.csv" ); #ifdef _WIN32 - xFltMgr->appendFilter(sFilterMDB, "*.mdb;*.mde"); - xFltMgr->appendFilter(sFilterACCDB, "*.accdb;*.accde"); + xFP->appendFilter(sFilterMDB, "*.mdb;*.mde"); + xFP->appendFilter(sFilterACCDB, "*.accdb;*.accde"); #endif - xFltMgr->setCurrentFilter( sFilterAll ) ; + xFP->setCurrentFilter( sFilterAll ) ; OUString sFind; if( ERRCODE_NONE == aDlgHelper.Execute() ) { diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index cd01bbfb9e19..f65eb9c96620 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -152,7 +152,7 @@ uno::Reference< mail::XSmtpService > ConnectToSmtpServer( rConfigItem.GetMailPort(), rConfigItem.IsSecureConnection() ? OUString("Ssl") : OUString("Insecure") ); xSmtpServer->connect(xConnectionContext, xAuthenticator); - rxInMailService.set( xSmtpServer, uno::UNO_QUERY ); + rxInMailService = xSmtpServer; } catch (const uno::Exception&) { diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 75a5fd240168..2fd02b3e0ab6 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1968,8 +1968,7 @@ bool SwTransferable::PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh, default: try { - uno::Reference < lang::XComponent > xComp( xStore, uno::UNO_QUERY ); - xComp->dispose(); + xStore->dispose(); xStore = nullptr; } catch (const uno::Exception&) diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index a8ff226fce6f..f7e6a7b69272 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -162,7 +162,7 @@ void SwSpellPopup::fillLangPopupMenu( //6--all languages used in current document uno::Reference< css::frame::XModel > xModel; - uno::Reference< css::frame::XController > xController( pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(), uno::UNO_QUERY ); + uno::Reference< css::frame::XController > xController = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(); if ( xController.is() ) xModel = xController->getModel(); uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY ); @@ -336,7 +336,7 @@ SwSpellPopup::SwSpellPopup( for( const uno::Reference< linguistic2::XDictionary >& rDic : m_aDics ) { - uno::Reference< linguistic2::XDictionary > xDicTmp( rDic, uno::UNO_QUERY ); + uno::Reference< linguistic2::XDictionary > xDicTmp = rDic; if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp) continue; @@ -715,7 +715,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) } else if (nId == m_nIgnoreWordId) { - uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY ); + uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); if (m_bGrammarResults) { try { diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index b361136fde6d..2c70670b23b8 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -295,7 +295,6 @@ void SwSrcView::Execute(SfxRequest& rReq) TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, aEditWin->GetFrameWeld()); uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker(); - uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); // search for an html filter for export SfxFilterContainer* pFilterCont = GetObjectShell()->GetFactory().GetFilterContainer(); @@ -306,15 +305,15 @@ void SwSrcView::Execute(SfxRequest& rReq) // filter found -> use its uiname and wildcard const OUString& rUIName = pFilter->GetUIName(); const WildCard& rCard = pFilter->GetWildcard(); - xFltMgr->appendFilter( rUIName, rCard.getGlob() ); - xFltMgr->setCurrentFilter( rUIName ) ; + xFP->appendFilter( rUIName, rCard.getGlob() ); + xFP->setCurrentFilter( rUIName ) ; } else { // filter not found OUString sHtml("HTML"); - xFltMgr->appendFilter( sHtml, "*.html;*.htm" ); - xFltMgr->setCurrentFilter( sHtml ) ; + xFP->appendFilter( sHtml, "*.html;*.htm" ); + xFP->setCurrentFilter( sHtml ) ; } xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 26244630a1cc..b94db6f5b633 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -1146,7 +1146,7 @@ void SwView::Execute(SfxRequest &rReq) // reset ignore lists pDoc->SpellItAgainSam( true, false, false ); // clear ignore dictionary - uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY ); + uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); if( xDictionary.is() ) xDictionary->clear(); // put cursor to the start of the document diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx index f960d95c95a6..748f875831d3 100644 --- a/sw/source/uibase/uno/unomailmerge.cxx +++ b/sw/source/uibase/uno/unomailmerge.cxx @@ -637,7 +637,7 @@ uno::Any SAL_CALL SwXMailMerge::execute( xRowSet->execute(); // build ResultSet from properties if( !xCurConnection.is() ) xCurConnection.set( xRowSetPropSet->getPropertyValue( "ActiveConnection" ), UNO_QUERY ); - xCurResultSet.set( xRowSet, UNO_QUERY ); + xCurResultSet = xRowSet; OSL_ENSURE( xCurResultSet.is(), "failed to build ResultSet" ); } } diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index e4069815e527..0a050a6f56fb 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -197,7 +197,6 @@ void SwOneExampleFrame::CreateControl() sTempURL = m_sArgumentURL; uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext()); - uno::Reference<frame::XComponentLoader> xLoader(xDesktop, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> args( comphelper::InitPropertySequence({ { "DocumentService", uno::Any(OUString("com.sun.star.text.TextDocument")) }, { "OpenFlags", uno::Any(OUString("-RB")) }, @@ -206,7 +205,7 @@ void SwOneExampleFrame::CreateControl() { "Hidden", uno::Any(true) } })); - m_xModel.set(xLoader->loadComponentFromURL(sTempURL, "_blank", 0, args), uno::UNO_QUERY); + m_xModel.set(xDesktop->loadComponentFromURL(sTempURL, "_blank", 0, args), uno::UNO_QUERY); m_aLoadedIdle.Start(); } @@ -232,7 +231,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void ) if (m_xController.is()) { - uno::Reference<frame::XFrame> xFrame(m_xController->getFrame(), uno::UNO_QUERY); + uno::Reference<frame::XFrame> xFrame = m_xController->getFrame(); uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY ); if ( xPropSet.is() ) { diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index fa1db7f69e70..a2de7b9c1bcb 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -553,7 +553,7 @@ bool SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrame if ( SotExchange::IsChart( aCLSID ) ) { - uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY ); + uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = xRef.GetObject(); if ( xEmbeddedObj.is() ) { bool bDisableDataTableDialog = false; |