loplugin:referencecasting in filter

Change-Id: Ia437fa8f18052afa2b70dfedc1b4badcfd165d6a
Reviewed-on: https://gerrit.libreoffice.org/75956
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-07-19 15:32:24 +02:00
parent 9b122d23e3
commit c3741a89a9
12 changed files with 28 additions and 41 deletions

View File

@@ -1518,7 +1518,6 @@ void FilterCache::impl_savePatchUINames(const css::uno::Reference< css::containe
const CacheItem& rItem) const CacheItem& rItem)
{ {
css::uno::Reference< css::container::XNameContainer > xAdd (xNode, css::uno::UNO_QUERY); css::uno::Reference< css::container::XNameContainer > xAdd (xNode, css::uno::UNO_QUERY);
css::uno::Reference< css::container::XNameAccess > xCheck(xNode, css::uno::UNO_QUERY);
css::uno::Sequence< css::beans::PropertyValue > lUINames = rItem.getUnpackedValueOrDefault(PROPNAME_UINAMES, css::uno::Sequence< css::beans::PropertyValue >()); css::uno::Sequence< css::beans::PropertyValue > lUINames = rItem.getUnpackedValueOrDefault(PROPNAME_UINAMES, css::uno::Sequence< css::beans::PropertyValue >());
sal_Int32 c = lUINames.getLength(); sal_Int32 c = lUINames.getLength();
@@ -1526,7 +1525,7 @@ void FilterCache::impl_savePatchUINames(const css::uno::Reference< css::containe
for (sal_Int32 i=0; i<c; ++i) for (sal_Int32 i=0; i<c; ++i)
{ {
if (xCheck->hasByName(pUINames[i].Name)) if (xNode->hasByName(pUINames[i].Name))
xNode->replaceByName(pUINames[i].Name, pUINames[i].Value); xNode->replaceByName(pUINames[i].Name, pUINames[i].Value);
else else
xAdd->insertByName(pUINames[i].Name, pUINames[i].Value); xAdd->insertByName(pUINames[i].Name, pUINames[i].Value);

View File

@@ -121,7 +121,7 @@ bool FlashExporter::exportAll( const Reference< XComponent >& xDoc, Reference< X
if(!xDrawPagesSupplier.is()) if(!xDrawPagesSupplier.is())
return false; return false;
Reference< XIndexAccess > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY ); Reference< XIndexAccess > xDrawPages = xDrawPagesSupplier->getDrawPages();
if(!xDrawPages.is()) if(!xDrawPages.is())
return false; return false;
@@ -451,9 +451,7 @@ sal_uInt16 FlashExporter::exportDrawPageBackground(sal_uInt16 nPage, Reference<
sal_uInt16 FlashExporter::exportMasterPageObjects(sal_uInt16 nPage, Reference< XDrawPage > const & xMasterPage) sal_uInt16 FlashExporter::exportMasterPageObjects(sal_uInt16 nPage, Reference< XDrawPage > const & xMasterPage)
{ {
Reference< XShapes > xShapes( xMasterPage, UNO_QUERY ); BitmapChecksum shapesum = ActionSummer(xMasterPage);
BitmapChecksum shapesum = ActionSummer(xShapes);
ChecksumCache::iterator it = gObjectCache.find(shapesum); ChecksumCache::iterator it = gObjectCache.find(shapesum);
@@ -481,8 +479,7 @@ sal_uInt16 FlashExporter::exportMasterPageObjects(sal_uInt16 nPage, Reference< X
shape infos to the current PageInfo */ shape infos to the current PageInfo */
void FlashExporter::exportDrawPageContents( const Reference< XDrawPage >& xPage, bool bStream, bool bMaster ) void FlashExporter::exportDrawPageContents( const Reference< XDrawPage >& xPage, bool bStream, bool bMaster )
{ {
Reference< XShapes > xShapes( xPage, UNO_QUERY ); exportShapes(xPage, bStream, bMaster);
exportShapes(xShapes, bStream, bMaster);
} }

View File

@@ -308,7 +308,7 @@ void FlashExportFilter::ExportAsMultipleFiles(const Sequence< PropertyValue >& a
if(!xDrawPagesSupplier.is()) if(!xDrawPagesSupplier.is())
return; return;
Reference< XIndexAccess > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY ); Reference< XIndexAccess > xDrawPages = xDrawPagesSupplier->getDrawPages();
if(!xDrawPages.is()) if(!xDrawPages.is())
return; return;

View File

@@ -95,7 +95,7 @@ bool CGMImpressOutAct::ImplInitPage()
bool bStatRet = false; bool bStatRet = false;
if( maXDrawPage.is() ) if( maXDrawPage.is() )
{ {
maXShapes = uno::Reference< drawing::XShapes >( maXDrawPage, uno::UNO_QUERY ); maXShapes = maXDrawPage;
if ( maXShapes.is() ) if ( maXShapes.is() )
{ {
bStatRet = true; bStatRet = true;
@@ -381,7 +381,7 @@ void CGMImpressOutAct::InsertPage()
{ {
if ( mnCurrentPage ) // one side is always existing, therefore the first side will be left out if ( mnCurrentPage ) // one side is always existing, therefore the first side will be left out
{ {
uno::Reference< drawing::XDrawPage > xPage( maXDrawPages->insertNewByIndex( 0xffff ), uno::UNO_QUERY ); uno::Reference< drawing::XDrawPage > xPage = maXDrawPages->insertNewByIndex( 0xffff );
maXDrawPage = xPage; maXDrawPage = xPage;
if ( !ImplInitPage() ) if ( !ImplInitPage() )
mpCGM->mbStatus = false; mpCGM->mbStatus = false;

View File

@@ -171,7 +171,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
if( const SdrObject* pSdrObj = rObj.GetSdrObject() ) if( const SdrObject* pSdrObj = rObj.GetSdrObject() )
if (!pSdrObj->GetName().isEmpty()) if (!pSdrObj->GetName().isEmpty())
aShapeName = pSdrObj->GetName(); aShapeName = pSdrObj->GetName();
uno::Reference< drawing::XShape> xShape(rObj.GetShapeRef(), uno::UNO_QUERY); uno::Reference< drawing::XShape> xShape = rObj.GetShapeRef();
if (xShape.is()) if (xShape.is())
{ {
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
@@ -414,7 +414,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
} }
else if ( rObj.GetType() == "drawing.Control" ) else if ( rObj.GetType() == "drawing.Control" )
{ {
const Reference< XPropertySet > xPropSet(rObj.mXPropSet, UNO_QUERY); const Reference< XPropertySet > xPropSet = rObj.mXPropSet;
const Reference<XPropertySetInfo> xPropInfo = xPropSet.is() ? xPropSet->getPropertySetInfo() : Reference<XPropertySetInfo>(); const Reference<XPropertySetInfo> xPropInfo = xPropSet.is() ? xPropSet->getPropertySetInfo() : Reference<XPropertySetInfo>();
// This code is expected to be called only for DOCX format. // This code is expected to be called only for DOCX format.
if (xPropInfo.is() && xPropInfo->hasPropertyByName("AnchorType") && bOOxmlExport) if (xPropInfo.is() && xPropInfo->hasPropertyByName("AnchorType") && bOOxmlExport)
@@ -868,7 +868,7 @@ bool ImplEESdrWriter::ImplInitPage( const SdrPage& rPage )
if (xOldDrawPage.is()) if (xOldDrawPage.is())
xOldDrawPage->dispose(); xOldDrawPage->dispose();
mXDrawPage = pSvxDrawPage = new SvxFmDrawPage( const_cast<SdrPage*>(&rPage) ); mXDrawPage = pSvxDrawPage = new SvxFmDrawPage( const_cast<SdrPage*>(&rPage) );
mXShapes.set( mXDrawPage, UNO_QUERY ); mXShapes = mXDrawPage;
if ( !mXShapes.is() ) if ( !mXShapes.is() )
return false; return false;
ImplInitPageValues(); ImplInitPageValues();

View File

@@ -74,9 +74,7 @@ const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
GetDrawPage(); GetDrawPage();
if( xDrawPage.is() ) if( xDrawPage.is() )
{ {
xShapes = xDrawPage;
xShapes.set(xDrawPage, uno::UNO_QUERY);
OSL_ENSURE( xShapes.is(), "UNO_QUERY failed for XShapes from XDrawPage" );
} }
} }
return xShapes; return xShapes;

View File

@@ -147,7 +147,7 @@ CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Referen
aPopupMenu[3].Value <<= sal_Int32( 0 ); aPopupMenu[3].Value <<= sal_Int32( 0 );
xPopup->insertByIndex( xPopup->getCount(), uno::makeAny( aPopupMenu ) ); xPopup->insertByIndex( xPopup->getCount(), uno::makeAny( aPopupMenu ) );
xCfgManager->insertSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xPopup, uno::UNO_QUERY ) ); xCfgManager->insertSettings( sMenuBar, xPopup );
uno::Reference< ui::XUIConfigurationPersistence > xPersistence( xCfgManager, uno::UNO_QUERY_THROW ); uno::Reference< ui::XUIConfigurationPersistence > xPersistence( xCfgManager, uno::UNO_QUERY_THROW );
xPersistence->store(); xPersistence->store();
} }

View File

@@ -92,7 +92,7 @@ OUString SAL_CALL StorageFilterDetect::detect(uno::Sequence<beans::PropertyValue
if ( !xInStream.is() ) if ( !xInStream.is() )
return OUString(); return OUString();
uno::Reference< embed::XStorage > xStorage( ::comphelper::OStorageHelper::GetStorageFromInputStream( xInStream, mxCxt ), uno::UNO_QUERY ); uno::Reference< embed::XStorage > xStorage = ::comphelper::OStorageHelper::GetStorageFromInputStream( xInStream, mxCxt );
if ( !xStorage.is() ) if ( !xStorage.is() )
return OUString(); return OUString();

View File

@@ -553,7 +553,7 @@ bool SVGFilter::implExportImpressOrDraw( const Reference< XOutputStream >& rxOSt
{ {
if( !mSelectedPages.empty() && !mMasterPageTargets.empty() ) if( !mSelectedPages.empty() && !mMasterPageTargets.empty() )
{ {
Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( rxOStm ), UNO_QUERY ); Reference< XDocumentHandler > xDocHandler = implCreateExportDocumentHandler( rxOStm );
if( xDocHandler.is() ) if( xDocHandler.is() )
{ {
@@ -643,7 +643,7 @@ bool SVGFilter::implExportWriterOrCalc( const Reference< XOutputStream >& rxOStm
if( rxOStm.is() ) if( rxOStm.is() )
{ {
Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( rxOStm ), UNO_QUERY ); Reference< XDocumentHandler > xDocHandler = implCreateExportDocumentHandler( rxOStm );
if( xDocHandler.is() ) if( xDocHandler.is() )
{ {
@@ -1114,7 +1114,7 @@ void SVGFilter::implGenerateMetaData()
{ {
const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[i]; const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[i];
Reference< css::drawing::XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY ); Reference< css::drawing::XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
Reference< css::drawing::XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY ); Reference< css::drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
OUString aSlideId(aId + "_" + OUString::number( i )); OUString aSlideId(aId + "_" + OUString::number( i ));
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId );

View File

@@ -186,7 +186,7 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto
} }
// get the DrawPages // get the DrawPages
uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), uno::UNO_QUERY ); uno::Reference< drawing::XDrawPages > xDrawPages = xDrawPagesSupplier->getDrawPages();
if(!xDrawPages.is()) if(!xDrawPages.is())
{ {
@@ -469,8 +469,8 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto
if( xMasterPagesSupplier.is() && xDrawPagesSupplier.is() ) if( xMasterPagesSupplier.is() && xDrawPagesSupplier.is() )
{ {
uno::Reference< drawing::XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), uno::UNO_QUERY ); uno::Reference< drawing::XDrawPages > xMasterPages = xMasterPagesSupplier->getMasterPages();
uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), uno::UNO_QUERY ); uno::Reference< drawing::XDrawPages > xDrawPages = xDrawPagesSupplier->getDrawPages();
if( xMasterPages.is() && xMasterPages->getCount() && if( xMasterPages.is() && xMasterPages->getCount() &&
xDrawPages.is() && xDrawPages->getCount() ) xDrawPages.is() && xDrawPages->getCount() )
{ {

View File

@@ -53,7 +53,7 @@ using namespace ::com::sun::star::embed;
namespace XSLT namespace XSLT
{ {
Reference<XStream> OleHandler::createTempFile() { Reference<XStream> OleHandler::createTempFile() {
Reference<XStream> tempFile( TempFile::create(m_xContext), UNO_QUERY); Reference<XStream> tempFile = TempFile::create(m_xContext);
OSL_ASSERT(tempFile.is()); OSL_ASSERT(tempFile.is());
return tempFile; return tempFile;
} }

View File

@@ -334,19 +334,15 @@ namespace XSLT
this)); this));
// connect input to transformer // connect input to transformer
css::uno::Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY); m_tcontrol->setInputStream(xInputStream);
tsink->setInputStream(xInputStream);
// create pipe // create pipe
css::uno::Reference<XOutputStream> pipeout( css::uno::Reference<XOutputStream> pipeout =
Pipe::create(m_xContext), Pipe::create(m_xContext);
UNO_QUERY);
css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY); css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY);
//connect transformer to pipe //connect transformer to pipe
css::uno::Reference<XActiveDataSource> tsource(m_tcontrol, m_tcontrol->setOutputStream(pipeout);
UNO_QUERY);
tsource->setOutputStream(pipeout);
// connect pipe to sax parser // connect pipe to sax parser
InputSource aInput; InputSource aInput;
@@ -477,9 +473,8 @@ namespace XSLT
m_tcontrol->addListener(css::uno::Reference<XStreamListener> (this)); m_tcontrol->addListener(css::uno::Reference<XStreamListener> (this));
// create pipe // create pipe
css::uno::Reference<XOutputStream> pipeout( css::uno::Reference<XOutputStream> pipeout =
Pipe::create(m_xContext), Pipe::create(m_xContext);
UNO_QUERY);
css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY); css::uno::Reference<XInputStream> pipein(pipeout, UNO_QUERY);
// connect sax writer to pipe // connect sax writer to pipe
@@ -488,12 +483,10 @@ namespace XSLT
xmlsource->setOutputStream(pipeout); xmlsource->setOutputStream(pipeout);
// connect pipe to transformer // connect pipe to transformer
css::uno::Reference<XActiveDataSink> tsink(m_tcontrol, UNO_QUERY); m_tcontrol->setInputStream(pipein);
tsink->setInputStream(pipein);
// connect transformer to output // connect transformer to output
css::uno::Reference<XActiveDataSource> tsource(m_tcontrol, UNO_QUERY); m_tcontrol->setOutputStream(m_rOutputStream);
tsource->setOutputStream(m_rOutputStream);
// we will start receiving events after returning 'true'. // we will start receiving events after returning 'true'.
// we will start the transformation as soon as we receive the startDocument // we will start the transformation as soon as we receive the startDocument