[Libreoffice-commits] core.git: chart2/qa compilerplugins/clang connectivity/source cui/source dbaccess/source desktop/qa filter/source forms/source framework/qa oox/source reportdesign/source sc/qa sd/qa sfx2/qa solenv/CompilerTest_compilerplugins_clang.mk svx/source sw/qa sw/source writerfilter/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 25 06:19:38 UTC 2019


 chart2/qa/extras/chart2dump/chart2dump.cxx               |    2 
 compilerplugins/clang/test/unoquery.cxx                  |   19 +++
 compilerplugins/clang/unoquery.cxx                       |   87 +++++++++++++++
 connectivity/source/drivers/component/CTable.cxx         |    2 
 connectivity/source/drivers/dbase/DTable.cxx             |    4 
 connectivity/source/drivers/file/FConnection.cxx         |    2 
 connectivity/source/drivers/file/FStatement.cxx          |    6 -
 connectivity/source/drivers/file/fcomp.cxx               |    2 
 connectivity/source/drivers/flat/ETable.cxx              |    2 
 connectivity/source/drivers/postgresql/pq_connection.cxx |    5 
 cui/source/dialogs/SignatureLineDialog.cxx               |    2 
 dbaccess/source/core/api/CacheSet.cxx                    |    6 -
 dbaccess/source/core/api/KeySet.cxx                      |    2 
 dbaccess/source/core/api/OptimisticSet.cxx               |    2 
 dbaccess/source/core/api/RowSetCache.cxx                 |    4 
 dbaccess/source/core/api/TableDeco.cxx                   |    4 
 dbaccess/source/core/api/callablestatement.cxx           |   44 +++----
 dbaccess/source/core/api/querycomposer.cxx               |    6 -
 dbaccess/source/core/api/querycontainer.cxx              |    4 
 dbaccess/source/core/api/resultset.cxx                   |   22 +--
 dbaccess/source/core/api/statement.cxx                   |   42 +++----
 dbaccess/source/ui/app/AppController.cxx                 |    2 
 dbaccess/source/ui/dlg/queryfilter.cxx                   |    6 -
 dbaccess/source/ui/dlg/queryorder.cxx                    |    2 
 dbaccess/source/ui/misc/RowSetDrop.cxx                   |    2 
 dbaccess/source/ui/misc/TokenWriter.cxx                  |    2 
 dbaccess/source/ui/misc/UITools.cxx                      |    2 
 dbaccess/source/ui/relationdesign/RelationTableView.cxx  |    2 
 desktop/qa/desktop_lib/test_desktop_lib.cxx              |    2 
 filter/source/pdf/impdialog.cxx                          |    2 
 forms/source/component/DatabaseForm.cxx                  |    6 -
 forms/source/component/Filter.cxx                        |    4 
 forms/source/component/clickableimage.cxx                |    4 
 framework/qa/cppunit/dispatchtest.cxx                    |    2 
 oox/source/export/shapes.cxx                             |    2 
 oox/source/ole/vbaproject.cxx                            |    2 
 reportdesign/source/core/api/ReportEngineJFree.cxx       |    2 
 sc/qa/unit/tiledrendering/tiledrendering.cxx             |    2 
 sd/qa/unit/import-tests.cxx                              |    4 
 sd/qa/unit/sdmodeltestbase.hxx                           |    2 
 sfx2/qa/cppunit/test_classification.cxx                  |    2 
 solenv/CompilerTest_compilerplugins_clang.mk             |    1 
 svx/source/fmcomp/fmgridif.cxx                           |    8 -
 svx/source/fmcomp/gridctrl.cxx                           |    2 
 svx/source/form/formcontroller.cxx                       |    2 
 sw/qa/core/macros-test.cxx                               |    4 
 sw/qa/extras/layout/layout.cxx                           |    2 
 sw/qa/extras/odfexport/odfexport.cxx                     |    8 -
 sw/qa/extras/odfimport/odfimport.cxx                     |    4 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx               |   12 +-
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx                |    2 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx                |    2 
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx                |    4 
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx                |    6 -
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |    2 
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx                |    2 
 sw/qa/extras/rtfexport/rtfexport.cxx                     |   12 +-
 sw/qa/extras/rtfexport/rtfexport2.cxx                    |    6 -
 sw/qa/extras/rtfexport/rtfexport5.cxx                    |   11 +
 sw/qa/extras/rtfimport/rtfimport.cxx                     |    9 -
 sw/qa/extras/uiwriter/uiwriter.cxx                       |    2 
 sw/qa/extras/uiwriter/uiwriter2.cxx                      |    2 
 sw/qa/extras/ww8export/ww8export.cxx                     |    2 
 sw/source/core/unocore/unotbl.cxx                        |    2 
 writerfilter/source/dmapper/ModelEventListener.cxx       |    6 -
 writerfilter/source/rtftok/rtfdispatchdestination.cxx    |    2 
 66 files changed, 275 insertions(+), 163 deletions(-)

New commits:
commit b1cfdb7bee4f7af97af54e6abbc5d04aed4ba082
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Mar 11 11:06:57 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Mar 25 07:19:13 2019 +0100

    new loplugin:unoquery
    
    look for places we are doing code like:
    
        Reference<XProperty>(model, css::uno::UNO_QUERY)->getAsProperty()
    
    which might result in a SIGSEGV is the query fails
    
    Change-Id: I5cbdbc9e64bd0bed588297c512bf60cbacb9442e
    Reviewed-on: https://gerrit.libreoffice.org/69044
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx
index 698782988434..5341c5eab929 100644
--- a/chart2/qa/extras/chart2dump/chart2dump.cxx
+++ b/chart2/qa/extras/chart2dump/chart2dump.cxx
@@ -479,7 +479,7 @@ DECLARE_DUMP_TEST(LegendTest, Chart2DumpTest, false)
 
             if (sShapeType == "com.sun.star.drawing.TextShape")
             {
-                uno::Reference<text::XText> xLegendEntryText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+                uno::Reference<text::XText> xLegendEntryText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
                 CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(xLegendEntryText->getString());
             }
         }
diff --git a/compilerplugins/clang/test/unoquery.cxx b/compilerplugins/clang/test/unoquery.cxx
new file mode 100644
index 000000000000..a80786a176c3
--- /dev/null
+++ b/compilerplugins/clang/test/unoquery.cxx
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sal/config.h"
+#include "com/sun/star/beans/XProperty.hpp"
+
+void foo(css::uno::Reference<css::uno::XInterface> model)
+{
+    css::uno::Reference<css::beans::XProperty>(model, css::uno::UNO_QUERY)->getAsProperty();
+    // expected-error at -1 {{calling UNO_QUERY followed by unconditional method call might result in SIGSEGV, rather use UNO_QUERY_THROW [loplugin:unoquery]}}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/unoquery.cxx b/compilerplugins/clang/unoquery.cxx
new file mode 100644
index 000000000000..ad9d2aada4e9
--- /dev/null
+++ b/compilerplugins/clang/unoquery.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "check.hxx"
+#include "plugin.hxx"
+
+// TODO it would be better if we were running some kind of nullability analysis here, where we marked
+// the results of expressions like Reference(..UNO_QUERY) as being nullable, and then looked for
+// places where we unconditionally deference the results of that expression.
+
+namespace
+{
+class UnoQuery : public loplugin::FilteringPlugin<UnoQuery>
+{
+public:
+    explicit UnoQuery(loplugin::InstantiationData const& data)
+        : FilteringPlugin(data)
+    {
+    }
+
+    void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+    bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*);
+};
+
+bool UnoQuery::VisitCXXMemberCallExpr(CXXMemberCallExpr const* memberCallExpr)
+{
+    if (ignoreLocation(memberCallExpr))
+        return true;
+
+    memberCallExpr->dump();
+
+    auto isXInterface = [](Decl const* decl) -> bool {
+        return bool(loplugin::DeclCheck(decl)
+                        .Class("XInterface")
+                        .Namespace("uno")
+                        .Namespace("star")
+                        .Namespace("sun")
+                        .Namespace("com")
+                        .GlobalNamespace());
+    };
+    if (!loplugin::isDerivedFrom(memberCallExpr->getRecordDecl(), isXInterface))
+        return true;
+    auto operatorCallExpr = dyn_cast<CXXOperatorCallExpr>(
+        memberCallExpr->getImplicitObjectArgument()->IgnoreImplicit());
+    if (!operatorCallExpr)
+        return true;
+
+    Expr const* expr = operatorCallExpr->getArg(0)->IgnoreImplicit();
+    // depending on the version of clang, the IgnoreImplicit may or may not look through these nodes
+    if (auto matTemp = dyn_cast<MaterializeTemporaryExpr>(expr))
+        expr = matTemp->GetTemporaryExpr();
+    if (auto bindTemp = dyn_cast<CXXBindTemporaryExpr>(expr))
+        expr = bindTemp->getSubExpr();
+
+    auto temporaryExpr = dyn_cast<CXXTemporaryObjectExpr>(expr);
+    if (!temporaryExpr)
+        return true;
+    if (temporaryExpr->getNumArgs() < 2)
+        return true;
+    auto declRefExpr = dyn_cast<DeclRefExpr>(temporaryExpr->getArg(1)->IgnoreImplicit());
+    if (!declRefExpr)
+        return true;
+    auto enumConstant = dyn_cast<EnumConstantDecl>(declRefExpr->getDecl());
+    if (!enumConstant)
+        return true;
+    if (enumConstant->getName() != "UNO_QUERY")
+        return true;
+
+    report(DiagnosticsEngine::Warning,
+           "calling UNO_QUERY followed by unconditional method call might result in SIGSEGV, "
+           "rather use UNO_QUERY_THROW",
+           memberCallExpr->getExprLoc())
+        << memberCallExpr->getSourceRange();
+
+    return true;
+}
+
+loplugin::Plugin::Registration<UnoQuery> unoquery("unoquery", true);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/connectivity/source/drivers/component/CTable.cxx b/connectivity/source/drivers/component/CTable.cxx
index b260843b7c16..2bc92ecfae6d 100644
--- a/connectivity/source/drivers/component/CTable.cxx
+++ b/connectivity/source/drivers/component/CTable.cxx
@@ -84,7 +84,7 @@ void OComponentTable::refreshColumns()
     ::std::vector< OUString> aVector;
 
     for(const auto& rxColumn : m_aColumns->get())
-        aVector.push_back(Reference< XNamed>(rxColumn,UNO_QUERY)->getName());
+        aVector.push_back(Reference< XNamed>(rxColumn,UNO_QUERY_THROW)->getName());
 
     if(m_xColumns)
         m_xColumns->reFill(aVector);
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 1f901f363d9b..d8a65d0cd241 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -641,7 +641,7 @@ void ODbaseTable::refreshColumns()
     aVector.reserve(m_aColumns->get().size());
 
     for (auto const& column : m_aColumns->get())
-        aVector.push_back(Reference< XNamed>(column,UNO_QUERY)->getName());
+        aVector.push_back(Reference< XNamed>(column,UNO_QUERY_THROW)->getName());
 
     if(m_xColumns)
         m_xColumns->reFill(aVector);
@@ -1605,7 +1605,7 @@ Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(sal_Int32 _nColumnPos)
             xIndex.set(m_xIndexes->getByIndex(i), css::uno::UNO_QUERY);
             if(xIndex.is() && getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
             {
-                Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns());
+                Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY_THROW)->getColumns());
                 if(xCols->hasByName(sColName))
                     return xIndex;
 
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
index c7ca89eec114..afa6cc598668 100644
--- a/connectivity/source/drivers/file/FConnection.cxx
+++ b/connectivity/source/drivers/file/FConnection.cxx
@@ -179,7 +179,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
             }
             else if (aFile.isDocument())
             {
-                Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY)->getParent(),UNO_QUERY);
+                Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY_THROW)->getParent(),UNO_QUERY_THROW);
                 Reference<XContentIdentifier> xIdent = xParent->getIdentifier();
                 m_xContent = xParent;
 
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index 5cd6bb8267e1..975b0d12d7a0 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -478,7 +478,7 @@ void OStatement_Base::GetAssignValues()
         // Create Row for the values to be set (Reference through new)
         if(m_aAssignValues.is())
             m_aAssignValues->get().clear();
-        sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+        sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY_THROW)->getCount();
         m_aAssignValues = new OAssignValues(nCount);
         // unbound all
         std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(false));
@@ -565,7 +565,7 @@ void OStatement_Base::GetAssignValues()
     {
         if(m_aAssignValues.is())
             m_aAssignValues->get().clear();
-        sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+        sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY_THROW)->getCount();
         m_aAssignValues = new OAssignValues(nCount);
         // unbound all
         std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(false));
@@ -642,7 +642,7 @@ void OStatement_Base::SetAssignValue(const OUString& aColumnName,
 {
     Reference<XPropertySet> xCol;
     m_xColNames->getByName(aColumnName) >>= xCol;
-    sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName);
+    sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY_THROW)->findColumn(aColumnName);
     // does this column actually exist in the file?
 
     if (!xCol.is())
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index 63cbd0abb9b2..7de9c5fb60dc 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -439,7 +439,7 @@ OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode const * pPredicateNo
         {
             if (m_orgColumns->getByName(aColumnName) >>= xCol)
             {
-                pOperand = OSQLAnalyzer::createOperandAttr(Reference< XColumnLocate>(m_orgColumns,UNO_QUERY)->findColumn(aColumnName),xCol);
+                pOperand = OSQLAnalyzer::createOperandAttr(Reference< XColumnLocate>(m_orgColumns,UNO_QUERY_THROW)->findColumn(aColumnName),xCol);
             }
             else
             {// Column doesn't exist in the Result-set
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index 1d4d3baafd63..8dc7903cd11c 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -501,7 +501,7 @@ void OFlatTable::refreshColumns()
     aVector.reserve(m_aColumns->get().size());
 
     for (auto const& column : m_aColumns->get())
-        aVector.push_back(Reference< XNamed>(column,UNO_QUERY)->getName());
+        aVector.push_back(Reference< XNamed>(column,UNO_QUERY_THROW)->getName());
 
     if(m_xColumns)
         m_xColumns->reFill(aVector);
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index 74afc570154d..a950bde8b051 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -81,6 +81,7 @@ using com::sun::star::uno::Sequence;
 using com::sun::star::uno::Reference;
 using com::sun::star::uno::XInterface;
 using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::UNO_QUERY_THROW;
 using com::sun::star::uno::XComponentContext;
 using com::sun::star::uno::Any;
 
@@ -607,7 +608,7 @@ Reference< XNameAccess > Connection::getTables()
         m_settings.tables = Tables::create( m_xMutex, this, &m_settings , &m_settings.pTablesImpl);
     else
         // TODO: how to overcome the performance problem ?
-        Reference< css::util::XRefreshable > ( m_settings.tables, UNO_QUERY )->refresh();
+        Reference< css::util::XRefreshable > ( m_settings.tables, UNO_QUERY_THROW )->refresh();
     return m_settings.tables;
 }
 
@@ -622,7 +623,7 @@ Reference< XNameAccess > Connection::getViews()
         m_settings.views = Views::create( m_xMutex, this, &m_settings, &(m_settings.pViewsImpl) );
     else
         // TODO: how to overcome the performance problem ?
-        Reference< css::util::XRefreshable > ( m_settings.views, UNO_QUERY )->refresh();
+        Reference< css::util::XRefreshable > ( m_settings.views, UNO_QUERY_THROW )->refresh();
     return m_settings.views;
 }
 
diff --git a/cui/source/dialogs/SignatureLineDialog.cxx b/cui/source/dialogs/SignatureLineDialog.cxx
index c582df2d8d59..b5f7e846512c 100644
--- a/cui/source/dialogs/SignatureLineDialog.cxx
+++ b/cui/source/dialogs/SignatureLineDialog.cxx
@@ -138,7 +138,7 @@ void SignatureLineDialog::Apply()
     if (bIsExistingSignatureLine)
         xShapeProps = m_xExistingShapeProperties;
     else
-        xShapeProps.set(Reference<lang::XMultiServiceFactory>(m_xModel, UNO_QUERY)
+        xShapeProps.set(Reference<lang::XMultiServiceFactory>(m_xModel, UNO_QUERY_THROW)
                             ->createInstance("com.sun.star.drawing.GraphicObjectShape"),
                         UNO_QUERY);
 
diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx
index dcfdb71266ff..62020e68d4db 100644
--- a/dbaccess/source/core/api/CacheSet.cxx
+++ b/dbaccess/source/core/api/CacheSet.cxx
@@ -85,7 +85,7 @@ void OCacheSet::construct(  const Reference< XResultSet>& _xDriverSet,const OUSt
     {
         m_xDriverSet = _xDriverSet;
         m_xDriverRow.set(_xDriverSet,UNO_QUERY);
-        m_xSetMetaData = Reference<XResultSetMetaDataSupplier>(_xDriverSet,UNO_QUERY)->getMetaData();
+        m_xSetMetaData = Reference<XResultSetMetaDataSupplier>(_xDriverSet,UNO_QUERY_THROW)->getMetaData();
         if ( m_xSetMetaData.is() )
         {
             const sal_Int32 nCount = m_xSetMetaData->getColumnCount();
@@ -218,7 +218,7 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow
                 && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
                 && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
               )
-                aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+                aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY_THROW)->getColumns());
         }
     }
 
@@ -342,7 +342,7 @@ void OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQ
                 && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
                 && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
               )
-                aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+                aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY_THROW)->getColumns());
         }
     }
 
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index f057b3de14e6..3c9b62b5d0ab 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -81,7 +81,7 @@ namespace
                     && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
                     && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
                 )
-                    _rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
+                    _rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY_THROW)->getColumns());
             }
         }
     }
diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx
index bf272f18471a..614c540e115d 100644
--- a/dbaccess/source/core/api/OptimisticSet.cxx
+++ b/dbaccess/source/core/api/OptimisticSet.cxx
@@ -91,7 +91,7 @@ OptimisticSet::OptimisticSet(const Reference<XComponentContext>& _rContext,
                              sal_Int32& o_nRowCount)
             :OKeySet(nullptr,nullptr,OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows,o_nRowCount)
             ,m_aSqlParser( _rContext )
-            ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser )
+            ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY_THROW)->getTables(), m_aSqlParser )
             ,m_bResultSetChanged(false)
 {
 }
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index f05caa68c3c1..544d9269bcd8 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -90,7 +90,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
                            const OUString& i_sRowSetFilter,
                            sal_Int32 i_nMaxRows)
     :m_xSet(_xRs)
-    ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData())
+    ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY_THROW)->getMetaData())
     ,m_aContext( _rContext )
     ,m_nFetchSize(0)
     ,m_nRowCount(0)
@@ -1693,7 +1693,7 @@ bool ORowSetCache::isResultSetChanged() const
 void ORowSetCache::reset(const Reference< XResultSet>& _xDriverSet)
 {
     m_xSet = _xDriverSet;
-    m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY)->getMetaData());
+    m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY_THROW)->getMetaData());
     m_xCacheSet->reset(_xDriverSet);
 
     m_bRowCountFinal = false;
diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx
index 0744d7fcff5d..1c229802b43d 100644
--- a/dbaccess/source/core/api/TableDeco.cxx
+++ b/dbaccess/source/core/api/TableDeco.cxx
@@ -420,14 +420,14 @@ Reference< XNameAccess> ODBTableDecorator::getIndexes()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
-    return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY)->getIndexes();
+    return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY_THROW)->getIndexes();
 }
 
 Reference< XIndexAccess> ODBTableDecorator::getKeys()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
-    return Reference< XKeysSupplier>(m_xTable,UNO_QUERY)->getKeys();
+    return Reference< XKeysSupplier>(m_xTable,UNO_QUERY_THROW)->getKeys();
 }
 
 Reference< XNameAccess> ODBTableDecorator::getColumns()
diff --git a/dbaccess/source/core/api/callablestatement.cxx b/dbaccess/source/core/api/callablestatement.cxx
index cbf9ad8ab874..2f888596d026 100644
--- a/dbaccess/source/core/api/callablestatement.cxx
+++ b/dbaccess/source/core/api/callablestatement.cxx
@@ -91,7 +91,7 @@ void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex
 
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName );
+    Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY_THROW)->registerOutParameter( parameterIndex, sqlType, typeName );
 }
 
 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale )
@@ -99,7 +99,7 @@ void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 paramet
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale );
+    Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY_THROW)->registerNumericOutParameter( parameterIndex, sqlType, scale );
 }
 
 // XRow
@@ -108,7 +108,7 @@ sal_Bool SAL_CALL OCallableStatement::wasNull(  )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull();
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->wasNull();
 }
 
 OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex )
@@ -116,7 +116,7 @@ OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getString( columnIndex );
 }
 
 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex )
@@ -124,7 +124,7 @@ sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBoolean( columnIndex );
 }
 
 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex )
@@ -132,63 +132,63 @@ sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getByte( columnIndex );
 }
 
 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getShort( columnIndex );
 }
 
 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getInt( columnIndex );
 }
 
 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getLong( columnIndex );
 }
 
 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getFloat( columnIndex );
 }
 
 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getDouble( columnIndex );
 }
 
 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBytes( columnIndex );
 }
 
 css::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getDate( columnIndex );
 }
 
 css::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getTime( columnIndex );
 }
 
 css::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex )
@@ -196,7 +196,7 @@ css::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnI
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getTimestamp( columnIndex );
 }
 
 Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex )
@@ -204,7 +204,7 @@ Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream(
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBinaryStream( columnIndex );
 }
 
 Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex )
@@ -212,7 +212,7 @@ Reference< css::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStre
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getCharacterStream( columnIndex );
 }
 
 Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap )
@@ -220,35 +220,35 @@ Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Referen
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getObject( columnIndex, typeMap );
 }
 
 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getRef( columnIndex );
 }
 
 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getBlob( columnIndex );
 }
 
 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getClob( columnIndex );
 }
 
 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex )
 {
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex );
+    return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY_THROW)->getArray( columnIndex );
 }
 
 
diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx
index d000aabe3329..41a0c628ba47 100644
--- a/dbaccess/source/core/api/querycomposer.cxx
+++ b/dbaccess/source/core/api/querycomposer.cxx
@@ -247,7 +247,7 @@ Reference< XNameAccess > SAL_CALL OQueryComposer::getTables(  )
     ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
 
     ::osl::MutexGuard aGuard( m_aMutex );
-    return Reference<XTablesSupplier>(m_xComposer,UNO_QUERY)->getTables();
+    return Reference<XTablesSupplier>(m_xComposer,UNO_QUERY_THROW)->getTables();
 }
 
 // XColumnsSupplier
@@ -256,7 +256,7 @@ Reference< XNameAccess > SAL_CALL OQueryComposer::getColumns(  )
     ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
 
     ::osl::MutexGuard aGuard( m_aMutex );
-    return Reference<XColumnsSupplier>(m_xComposer,UNO_QUERY)->getColumns();
+    return Reference<XColumnsSupplier>(m_xComposer,UNO_QUERY_THROW)->getColumns();
 }
 
 Reference< XIndexAccess > SAL_CALL OQueryComposer::getParameters(  )
@@ -264,7 +264,7 @@ Reference< XIndexAccess > SAL_CALL OQueryComposer::getParameters(  )
     ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
 
     ::osl::MutexGuard aGuard( m_aMutex );
-    return Reference<XParametersSupplier>(m_xComposer,UNO_QUERY)->getParameters();
+    return Reference<XParametersSupplier>(m_xComposer,UNO_QUERY_THROW)->getParameters();
 }
 
 void SAL_CALL OQueryComposer::acquire() throw()
diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx
index dea302029dce..4e5ba761398b 100644
--- a/dbaccess/source/core/api/querycontainer.cxx
+++ b/dbaccess/source/core/api/querycontainer.cxx
@@ -221,7 +221,7 @@ void SAL_CALL OQueryContainer::dropByIndex( sal_Int32 _nIndex )
         throw DisposedException( OUString(), *this );
 
     OUString sName;
-    Reference<XPropertySet> xProp(Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getByIndex(_nIndex),UNO_QUERY);
+    Reference<XPropertySet> xProp(Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY_THROW)->getByIndex(_nIndex),UNO_QUERY);
     if ( xProp.is() )
         xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
 
@@ -401,7 +401,7 @@ sal_Bool SAL_CALL OQueryContainer::hasElements( )
 sal_Int32 SAL_CALL OQueryContainer::getCount(  )
 {
     MutexGuard aGuard(m_aMutex);
-    return Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getCount();
+    return Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY_THROW)->getCount();
 }
 
 Sequence< OUString > SAL_CALL OQueryContainer::getElementNames(  )
diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx
index 715f4465ff22..9eb66c68a1a4 100644
--- a/dbaccess/source/core/api/resultset.cxx
+++ b/dbaccess/source/core/api/resultset.cxx
@@ -147,7 +147,7 @@ void OResultSet::disposing()
     m_pColumns->disposing();
 
     // close the pending result set
-    Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
+    Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY_THROW)->close();
 
     m_xDelegatorResultSet = nullptr;
     m_xDelegatorRow = nullptr;
@@ -253,7 +253,7 @@ void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
             OSL_ENSURE(!aPropName.isEmpty(), "property not found?");
 
             // now read the value
-            rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
+            rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY_THROW)->getPropertyValue(aPropName);
         }
     }
 }
@@ -279,7 +279,7 @@ Reference< XResultSetMetaData > OResultSet::getMetaData()
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
 
-    return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
+    return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY_THROW)->getMetaData();
 }
 
 // css::sdbc::XColumnLocate
@@ -288,7 +288,7 @@ sal_Int32 OResultSet::findColumn(const OUString& columnName)
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
 
-    return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
+    return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->findColumn(columnName);
 }
 
 namespace
@@ -326,7 +326,7 @@ Reference< css::container::XNameAccess > OResultSet::getColumns()
     if (!m_pColumns->isInitialized())
     {
         // get the metadata
-        Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
+        Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY_THROW)->getMetaData();
 
         sal_Int32 nColCount = 0;
         // do we have columns
@@ -868,7 +868,7 @@ Any OResultSet::getBookmark()
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->getBookmark();
 }
 
 sal_Bool OResultSet::moveToBookmark(const Any& bookmark)
@@ -878,7 +878,7 @@ sal_Bool OResultSet::moveToBookmark(const Any& bookmark)
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->moveToBookmark(bookmark);
 }
 
 sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows)
@@ -888,7 +888,7 @@ sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows)
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->moveRelativeToBookmark(bookmark, rows);
 }
 
 sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second)
@@ -898,7 +898,7 @@ sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second)
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->compareBookmarks(_first, _second);
 }
 
 sal_Bool OResultSet::hasOrderedBookmarks()
@@ -908,7 +908,7 @@ sal_Bool OResultSet::hasOrderedBookmarks()
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->hasOrderedBookmarks();
 }
 
 sal_Int32 OResultSet::hashBookmark(const Any& bookmark)
@@ -918,7 +918,7 @@ sal_Int32 OResultSet::hashBookmark(const Any& bookmark)
 
     checkBookmarkable();
 
-    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
+    return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY_THROW)->hashBookmark(bookmark);
 }
 
 // css::sdbc::XResultSetUpdate
diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx
index 7cc74ed3ef6e..3bad447db85f 100644
--- a/dbaccess/source/core/api/statement.cxx
+++ b/dbaccess/source/core/api/statement.cxx
@@ -147,7 +147,7 @@ void OStatementBase::disposing()
     {
         try
         {
-            Reference< XCloseable > (m_xAggregateAsSet, UNO_QUERY)->close();
+            Reference< XCloseable > (m_xAggregateAsSet, UNO_QUERY_THROW)->close();
         }
         catch(RuntimeException& )
         {// don't care for anymore
@@ -292,7 +292,7 @@ Any OStatementBase::getWarnings()
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    return Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->getWarnings();
+    return Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY_THROW)->getWarnings();
 }
 
 void OStatementBase::clearWarnings()
@@ -300,7 +300,7 @@ void OStatementBase::clearWarnings()
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
-    Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->clearWarnings();
+    Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY_THROW)->clearWarnings();
 }
 
 // css::util::XCancellable
@@ -320,11 +320,11 @@ Reference< XResultSet > SAL_CALL OStatementBase::getResultSet(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsMultipleResultSets())
         throwFunctionSequenceException(*this);
 
-    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getResultSet();
+    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY_THROW)->getResultSet();
 }
 
 sal_Int32 SAL_CALL OStatementBase::getUpdateCount(  )
@@ -333,11 +333,11 @@ sal_Int32 SAL_CALL OStatementBase::getUpdateCount(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsMultipleResultSets())
         throwFunctionSequenceException(*this);
 
-    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getUpdateCount();
+    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY_THROW)->getUpdateCount();
 }
 
 sal_Bool SAL_CALL OStatementBase::getMoreResults(  )
@@ -346,14 +346,14 @@ sal_Bool SAL_CALL OStatementBase::getMoreResults(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsMultipleResultSets())
         throwFunctionSequenceException(*this);
 
     // free the previous results
     disposeResultSet();
 
-    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getMoreResults();
+    return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY_THROW)->getMoreResults();
 }
 
 // XPreparedBatchExecution
@@ -363,11 +363,11 @@ void SAL_CALL OStatementBase::addBatch(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
 
-    Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch();
+    Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->addBatch();
 }
 
 void SAL_CALL OStatementBase::clearBatch(  )
@@ -376,11 +376,11 @@ void SAL_CALL OStatementBase::clearBatch(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
 
-    Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
+    Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->clearBatch();
 }
 
 Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch(  )
@@ -389,14 +389,14 @@ Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch(  )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
 
     // free the previous results
     disposeResultSet();
 
-    return Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch();
+    return Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->executeBatch();
 }
 
 Reference< XResultSet > SAL_CALL OStatementBase::getGeneratedValues(  )
@@ -495,12 +495,12 @@ void OStatement::addBatch( const OUString& _rSQL )
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
 
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
 
     OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
-    Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch( sSQL );
+    Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->addBatch( sSQL );
 }
 
 void OStatement::clearBatch( )
@@ -508,11 +508,11 @@ void OStatement::clearBatch( )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
 
-    Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
+    Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->clearBatch();
 }
 
 Sequence< sal_Int32 > OStatement::executeBatch( )
@@ -520,10 +520,10 @@ Sequence< sal_Int32 > OStatement::executeBatch( )
     MutexGuard aGuard(m_aMutex);
     ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
     // first check the meta data
-    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
+    Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY_THROW)->getMetaData();
     if (!xMeta.is() || !xMeta->supportsBatchUpdates())
         throwFunctionSequenceException(*this);
-    return Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch( );
+    return Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY_THROW)->executeBatch( );
 }
 
 
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index efa5f95d8453..f36f9b2e860d 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2042,7 +2042,7 @@ void OApplicationController::renameEntry()
                                     if ( xParent.is() )
                                     {
                                         xHNames = xParent;
-                                        Reference<XPropertySet>(xRename,UNO_QUERY)->getPropertyValue(PROPERTY_NAME) >>= sName;
+                                        Reference<XPropertySet>(xRename,UNO_QUERY_THROW)->getPropertyValue(PROPERTY_NAME) >>= sName;
                                     }
                                 }
                                 pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), OUString() ) );
diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx
index 7f05fda7f8ec..3286ecf8c420 100644
--- a/dbaccess/source/ui/dlg/queryfilter.cxx
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -130,7 +130,7 @@ DlgFilterCrit::DlgFilterCrit(weld::Window * pParent,
         m_xLB_WHEREFIELD3->append_text( *pIter );
     }
 
-    Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY)->getColumns();
+    Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY_THROW)->getColumns();
     aNames = xSelectColumns->getElementNames();
     pIter = aNames.getConstArray();
     pEnd   = pIter + aNames.getLength();
@@ -357,7 +357,7 @@ Reference< XPropertySet > DlgFilterCrit::getColumn( const OUString& _rFieldName
         if ( m_xColumns.is() && m_xColumns->hasByName( _rFieldName ) )
             m_xColumns->getByName( _rFieldName ) >>= xColumn;
 
-        Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+        Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY_THROW)->getColumns();
         if ( xColumns.is() && !xColumn.is() )
         {
             Sequence< OUString> aSeq = xColumns->getElementNames();
@@ -393,7 +393,7 @@ Reference< XPropertySet > DlgFilterCrit::getQueryColumn( const OUString& _rField
     Reference< XPropertySet > xColumn;
     try
     {
-        Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+        Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY_THROW)->getColumns();
         if ( xColumns.is() && xColumns->hasByName( _rFieldName ) )
             xColumns->getByName( _rFieldName ) >>= xColumn;
     }
diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx
index 1bd9d3692591..af788f258ba0 100644
--- a/dbaccess/source/ui/dlg/queryorder.cxx
+++ b/dbaccess/source/ui/dlg/queryorder.cxx
@@ -196,7 +196,7 @@ OUString DlgOrderCrit::GetOrderList( ) const
     Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
     OUString sQuote  = xMetaData.is() ? xMetaData->getIdentifierQuoteString() : OUString();
 
-    Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+    Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY_THROW)->getColumns();
 
     OUStringBuffer sOrder;
     for( sal_uInt16 i=0 ; i<DOG_ROWS; i++ )
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
index 8b596b137839..99d0d7a622b4 100644
--- a/dbaccess/source/ui/misc/RowSetDrop.cxx
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -61,7 +61,7 @@ void ORowSetImportExport::initialize()
     Reference<XColumnLocate> xColumnLocate(m_xResultSet,UNO_QUERY);
     OSL_ENSURE(xColumnLocate.is(),"The rowset normally should support this");
 
-    m_xTargetResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xTargetResultSetUpdate,UNO_QUERY)->getMetaData();
+    m_xTargetResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xTargetResultSetUpdate,UNO_QUERY_THROW)->getMetaData();
     if(!m_xTargetResultSetMetaData.is() || !xColumnLocate.is() || !m_xResultSetMetaData.is() )
         throw SQLException(DBA_RES(STR_UNEXPECTED_ERROR),*this,"S1000",0,Any());
 
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index a30614e5b82f..c862af65969a 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -270,7 +270,7 @@ void ODatabaseImportExport::initialize()
             {
                 m_xRow.set( m_xResultSet, UNO_QUERY );
                 m_xRowLocate.set( m_xResultSet, UNO_QUERY );
-                m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData();
+                m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY_THROW)->getMetaData();
                 Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW);
                 m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW);
             }
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 47e5c9933a4b..75c318d0787c 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -430,7 +430,7 @@ void fillTypeInfo(  const Reference< css::sdbc::XConnection>& _rxConnection,
     // Information for a single SQL type
     if(xRs.is())
     {
-        Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
+        Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY_THROW)->getMetaData();
         ::connectivity::ORowSetValue aValue;
         std::vector<sal_Int32> aTypes;
         std::vector<bool> aNullable;
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
index ad1cbb401eee..5a6c1568688d 100644
--- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -189,7 +189,7 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const
 
     // the number of PKey-Fields in the source
     const Reference< XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(pSourceWin->GetData()->getTable());
-    bool bAskUser = xPrimaryKeyColumns.is() && Reference< XIndexAccess>(xPrimaryKeyColumns,UNO_QUERY)->getCount() > 1;
+    bool bAskUser = xPrimaryKeyColumns.is() && Reference< XIndexAccess>(xPrimaryKeyColumns,UNO_QUERY_THROW)->getCount() > 1;
 
     pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 331877503775..445901108ed4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -597,7 +597,7 @@ void DesktopLOKTest::testPasteWriterJPEG()
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
 
     // Delete the pasted picture, and paste again with a custom anchor type.
-    uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY)->dispose();
+    uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY_THROW)->dispose();
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
     {
         {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AT_CHARACTER))},
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 50d846914ab6..52e22cf01a28 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -123,7 +123,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue
     // check for selection
     try
     {
-        Reference< frame::XController > xController( Reference< frame::XModel >( rxDoc, UNO_QUERY )->getCurrentController() );
+        Reference< frame::XController > xController( Reference< frame::XModel >( rxDoc, UNO_QUERY_THROW )->getCurrentController() );
         if( xController.is() )
         {
             Reference< view::XSelectionSupplier > xView( xController, UNO_QUERY );
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 18d96af1364a..39bbcbf411de 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -2084,7 +2084,7 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT
     aURL.Complete = aURLStr;
     xTransformer->parseStrict(aURL);
 
-    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
+    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch(aURL, aTargetName,
         FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
         FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
 
@@ -2175,7 +2175,7 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a
             if (xTransformer.is())
                 xTransformer->parseStrict(aURL);
 
-            Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
+            Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch(aURL, aTargetName,
                     FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
                     FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
 
@@ -2199,7 +2199,7 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a
         aURL.Complete = aURLStr;
         xTransformer->parseStrict(aURL);
 
-        Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aURL, aTargetName,
+        Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch(aURL, aTargetName,
                 FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN |
                 FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS);
 
diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx
index 5db86e93d7a8..fb56cbdd3c8a 100644
--- a/forms/source/component/Filter.cxx
+++ b/forms/source/component/Filter.cxx
@@ -352,7 +352,7 @@ namespace frm
             case FormComponentType::RADIOBUTTON:
             {
                 if ( rEvent.Selected == TRISTATE_TRUE )
-                    aText.append( ::comphelper::getString( Reference< XPropertySet >( getModel(), UNO_QUERY )->getPropertyValue( PROPERTY_REFVALUE ) ) );
+                    aText.append( ::comphelper::getString( Reference< XPropertySet >( getModel(), UNO_QUERY_THROW )->getPropertyValue( PROPERTY_REFVALUE ) ) );
             }
             break;
         }
@@ -598,7 +598,7 @@ namespace frm
                 Reference< XVclWindowPeer >  xVclWindow( getPeer(), UNO_QUERY );
                 if (xVclWindow.is())
                 {
-                    OUString aRefText = ::comphelper::getString(css::uno::Reference< XPropertySet > (getModel(), UNO_QUERY)->getPropertyValue(PROPERTY_REFVALUE));
+                    OUString aRefText = ::comphelper::getString(css::uno::Reference< XPropertySet > (getModel(), UNO_QUERY_THROW)->getPropertyValue(PROPERTY_REFVALUE));
                     Any aValue;
                     if (aText == aRefText)
                         aValue <<= sal_Int32(TRISTATE_TRUE);
diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index d5cae9c185e1..f3803d275bb7 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -298,7 +298,7 @@ namespace frm
                     OUString aTargetFrame;
                     xSet->getPropertyValue(PROPERTY_TARGET_FRAME) >>= aTargetFrame;
 
-                    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch( aURL, aTargetFrame,
+                    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch( aURL, aTargetFrame,
                             FrameSearchFlag::SELF | FrameSearchFlag::PARENT |
                             FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE );
 
@@ -314,7 +314,7 @@ namespace frm
                 {
                     URL aHyperLink = m_pFeatureInterception->getTransformer().getStrictURLFromAscii( ".uno:OpenHyperlink" );
 
-                    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY)->queryDispatch(aHyperLink, OUString() , 0);
+                    Reference< XDispatch >  xDisp = Reference< XDispatchProvider > (xFrame,UNO_QUERY_THROW)->queryDispatch(aHyperLink, OUString() , 0);
 
                     if ( xDisp.is() )
                     {
diff --git a/framework/qa/cppunit/dispatchtest.cxx b/framework/qa/cppunit/dispatchtest.cxx
index 66a0123f6e5c..7903715e4113 100644
--- a/framework/qa/cppunit/dispatchtest.cxx
+++ b/framework/qa/cppunit/dispatchtest.cxx
@@ -158,7 +158,7 @@ void DispatchTest::tearDown()
 
 void DispatchTest::dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
-    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 856aef4b3f9e..d94183a207b2 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1954,7 +1954,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
 
         xParent->getPropertyValue("InteropGrabBag") >>= grabBag;
 
-        entryName = uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY)->getEntryName();
+        entryName = uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY_THROW)->getEntryName();
     }
     catch (uno::Exception const& e)
     {
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index bba778658ae5..26b037563495 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -193,7 +193,7 @@ void VbaProject::importVbaData(const uno::Reference<io::XInputStream>& xInputStr
         uno::Reference<io::XOutputStream> xDocStream(xDocStorage->openStreamElement("_MS_VBA_Macros_XML", nOpenMode), uno::UNO_QUERY);
         comphelper::OStorageHelper::CopyInputToOutput(xInputStream, xDocStream);
     }
-    uno::Reference<embed::XTransactedObject>(xDocStorage, uno::UNO_QUERY)->commit();
+    uno::Reference<embed::XTransactedObject>(xDocStorage, uno::UNO_QUERY_THROW)->commit();
 }
 
 void VbaProject::registerMacroAttacher( const VbaMacroAttacherRef& rxAttacher )
diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx b/reportdesign/source/core/api/ReportEngineJFree.cxx
index 8b5f67f2968c..3c712d8f1878 100644
--- a/reportdesign/source/core/api/ReportEngineJFree.cxx
+++ b/reportdesign/source/core/api/ReportEngineJFree.cxx
@@ -277,7 +277,7 @@ uno::Reference< frame::XModel > OReportEngineJFree::createDocumentAlive( const u
             // if there is no frame given, find the right
             xFrameLoad.set( frame::Desktop::create(m_xContext), uno::UNO_QUERY);
             sal_Int32 const nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
-            uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY)->findFrame("_blank",nFrameSearchFlag);
+            uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame("_blank",nFrameSearchFlag);
             xFrameLoad.set( xFrame,uno::UNO_QUERY);
         }
 
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 5525e558e7a2..ba7b9041421a 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -546,7 +546,7 @@ void ScTiledRenderingTest::testViewCursors()
 
 void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rArguments)
 {
-    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 696a4e5ded83..578746844ddc 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1791,7 +1791,7 @@ void SdImportTest::testTdf104445()
     // First shape should not have bullet
     {
         uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef));
-        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
         CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
         uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
 
@@ -1812,7 +1812,7 @@ void SdImportTest::testTdf104445()
     // Second shape should have bullet set
     {
         uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(1, 0, xDocShRef));
-        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
         CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
         uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
 
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 922ed9df6285..9d79126905df 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -396,7 +396,7 @@ protected:
     // Nth paragraph of text in given text shape
     uno::Reference< text::XTextRange > getParagraphFromShape( int nPara, uno::Reference< beans::XPropertySet > const & xShape )
     {
-        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>( xShape, uno::UNO_QUERY )->getText();
+        uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>( xShape, uno::UNO_QUERY_THROW )->getText();
         CPPUNIT_ASSERT_MESSAGE( "Not a text shape", xText.is() );
 
         uno::Reference< container::XEnumerationAccess > paraEnumAccess( xText, uno::UNO_QUERY );
diff --git a/sfx2/qa/cppunit/test_classification.cxx b/sfx2/qa/cppunit/test_classification.cxx
index 3cfc01d99541..060e4adece32 100644
--- a/sfx2/qa/cppunit/test_classification.cxx
+++ b/sfx2/qa/cppunit/test_classification.cxx
@@ -63,7 +63,7 @@ void ClassificationTest::tearDown()
 
 void ClassificationTest::dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
-    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index 23e1da6c801b..02a6d299039a 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -68,6 +68,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
     compilerplugins/clang/test/unnecessaryoverride-dtor \
     compilerplugins/clang/test/unnecessaryparen \
     compilerplugins/clang/test/unoany \
+    compilerplugins/clang/test/unoquery \
     compilerplugins/clang/test/unreffun \
     compilerplugins/clang/test/unusedindex \
     compilerplugins/clang/test/unusedenumconstants \
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
index 6108564cea87..cf061a1697a8 100644
--- a/svx/source/fmcomp/fmgridif.cxx
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -559,10 +559,10 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< css::awt::XToolkit >&
                     Reference< css::sdbcx::XColumnsSupplier >  xColumnsSupplier(xForm, UNO_QUERY);
                     if (xColumnsSupplier.is())
                     {
-                        if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY)->getCount())
+                        if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY_THROW)->getCount())
                         {
                             // we get only a new bookmark if the resultset is not forwardonly
-                            if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY)
+                            if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY_THROW)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY)
                             {
                                 // as the FmGridControl touches the data source it is connected to we have to remember the current
                                 // cursor position (and restore afterwards)
@@ -572,7 +572,7 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< css::awt::XToolkit >&
                                 {
                                     try
                                     {
-                                        aOldCursorBookmark = Reference< css::sdbcx::XRowLocate > (xForm, UNO_QUERY)->getBookmark();
+                                        aOldCursorBookmark = Reference< css::sdbcx::XRowLocate > (xForm, UNO_QUERY_THROW)->getBookmark();
                                     }
                                     catch( const Exception& )
                                     {
@@ -1512,7 +1512,7 @@ void FmXGridPeer::cursorMoved(const EventObject& _rEvent)
     VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >();
     // we are not interested in move to insert row only in the resetted event
     // which is fired after positioning an the insert row
-    if (pGrid && pGrid->IsOpen() && !::comphelper::getBOOL(Reference< XPropertySet > (_rEvent.Source, UNO_QUERY)->getPropertyValue(FM_PROP_ISNEW)))
+    if (pGrid && pGrid->IsOpen() && !::comphelper::getBOOL(Reference< XPropertySet > (_rEvent.Source, UNO_QUERY_THROW)->getPropertyValue(FM_PROP_ISNEW)))
         pGrid->positioned();
 }
 
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 6ea74294722e..ef8b5d0e4cce 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -1419,7 +1419,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridCo
     // is the new cursor valid ?
     // the cursor is only valid if it contains some columns
     // if there is no cursor or the cursor is not valid we have to clean up an leave
-    if (!_xCursor.is() || !Reference< XColumnsSupplier > (_xCursor, UNO_QUERY)->getColumns()->hasElements())
+    if (!_xCursor.is() || !Reference< XColumnsSupplier > (_xCursor, UNO_QUERY_THROW)->getColumns()->hasElements())
     {
         RemoveRows();
         return;
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index eb9b9303497e..a5dc8c9073f1 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -1156,7 +1156,7 @@ void FormController::disposing()
             }
         }
 
-        Reference< XComponent > (rpChild, UNO_QUERY)->dispose();
+        Reference< XComponent > (rpChild, UNO_QUERY_THROW)->dispose();
     }
     m_aChildren.clear();
 
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 187a82e93f77..db544178b194 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -376,7 +376,7 @@ void SwMacrosTest::testFdo55289()
     uno::Reference<drawing::XShapes> const xShapes(xDPS->getDrawPage(),
             UNO_QUERY);
     uno::Reference<beans::XPropertySet> const xShape(
-        uno::Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY)->
+        uno::Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY_THROW)->
             createInstance("com.sun.star.drawing.GraphicObjectShape"),
         UNO_QUERY);
     xShape->setPropertyValue("AnchorType",
@@ -391,7 +391,7 @@ void SwMacrosTest::testFdo55289()
     xShape->setPropertyValue("AnchorType",
             makeAny(text::TextContentAnchorType_AS_CHARACTER));
     uno::Reference<text::XTextRange> const xEnd =
-        uno::Reference<text::XTextDocument>(xModel, UNO_QUERY)->getText()->getEnd();
+        uno::Reference<text::XTextDocument>(xModel, UNO_QUERY_THROW)->getText()->getEnd();
     uno::Reference<text::XTextContent> const xShapeContent(xShape, UNO_QUERY);
     xShapeContent->attach(xEnd);
 }
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index ea0eaac86c61..79a67296fe13 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -134,7 +134,7 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone
                                 const uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
     uno::Reference<frame::XController> xController
-        = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+        = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 8ac8f1c81edd..5579c802833b 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -629,7 +629,7 @@ DECLARE_ODFEXPORT_TEST(testDuplicateCrossRefHeadingBookmark, "CrossRefHeadingBoo
     CPPUNIT_ASSERT_THROW(xBookmarks->getByName("__RefHeading__1673_25705824"), container::NoSuchElementException);
 
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
-    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
 
     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -1058,7 +1058,7 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
     CPPUNIT_ASSERT_EQUAL(OUString("round-rectangle"), aCustomShapeGeometry["Type"].get<OUString>());
 
     // The shape text should start with a table, with "a" in its A1 cell.
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
@@ -1975,7 +1975,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt")
         "Az (5)", "az 1", "A 2", "az 1" };
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     // update "A (4)" to "Az (5)"
-    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
 
     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -2045,7 +2045,7 @@ DECLARE_ODFEXPORT_TEST(testSpellOutNumberingTypes, "spellout-numberingtypes.odt"
     static const char* const aFieldTextFallbacks[] = { "Ordinal-number 1", "Ordinal 1", "1" };
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     // update text field content
-    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
 
     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 0eaae316a22c..3065d64c4935 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -56,7 +56,7 @@ DECLARE_ODFIMPORT_TEST(testHideAllSections, "fdo53210.odt")
     uno::Reference<beans::XPropertySet> xMaster(xMasters->getByName("com.sun.star.text.fieldmaster.User._CS_Allgemein"), uno::UNO_QUERY);
     xMaster->setPropertyValue("Content", uno::makeAny(OUString("0")));
     // This used to crash
-    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
 }
 
 DECLARE_ODFIMPORT_TEST(testOdtBorders, "borders_ooo33.odt")
@@ -482,7 +482,7 @@ DECLARE_ODFIMPORT_TEST(testFdo55814, "fdo55814.odt")
     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY);
     xField->setPropertyValue("Content", uno::makeAny(OUString("Yes")));
-    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
+    uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
     uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
     // This was "0".
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 991ab0616cec..768ab16c8a48 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -212,7 +212,7 @@ DECLARE_OOXMLEXPORT_TEST(textboxWpgOnly, "textbox-wpg-only.docx")
 
     // Character escapement was enabled by default, this was 58.
     uno::Reference<container::XIndexAccess> xGroup(xShape, uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText();
     CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xText), 1), "CharEscapementHeight"));
 }
 
@@ -220,7 +220,7 @@ DECLARE_OOXMLEXPORT_TEST(testMceWpg, "mce-wpg.docx")
 {
     // Make sure that we read the primary branch, if wpg is requested as a feature.
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText();
     // This was VML1.
     getParagraphOfText(1, xText, "DML1");
 }
@@ -240,7 +240,7 @@ DECLARE_OOXMLEXPORT_TEST(testMceNested, "mce-nested.docx")
 
     // Now check the top right textbox.
     uno::Reference<container::XIndexAccess> xGroup(getShape(2), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "[Year]");
     CPPUNIT_ASSERT_EQUAL(48.f, getProperty<float>(getRun(xParagraph, 1), "CharHeight"));
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
@@ -372,7 +372,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx")
 {
     uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
     // The text in the groupshape was missing due to the w:sdt and w:sdtContent wrapper around it.
-    CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW)->getString());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testDmlCharheightDefault, "dml-charheight-default.docx")
@@ -387,7 +387,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capita
 {
     // Capitalization inside a group shape was not imported
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
     // 2nd line is written with uppercase letters
     CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "CharCaseMap"));
     // 3rd line has no capitalization
@@ -450,7 +450,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.doc
 {
     // Fonts defined by w:rFonts was not imported and so the font specified by a:fontRef was used.
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText    = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText    = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
     CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
     CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex"));
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 4d62de086506..a00179292cc5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -950,7 +950,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo60990, "fdo60990.odt")
     // The shape had no background, no paragraph adjust and no font color.
     uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty<sal_Int32>(xShape, "FillColor"));
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust")));
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 08d239ed3567..30c6b849ce6e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -378,7 +378,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing, "dml-groupshape-paraspaci
 {
     // Paragraph spacing (top/bottom margin and line spacing) inside a group shape was not imported
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
 
     // 1st paragraph has 1.5x line spacing but it has no spacing before/after.
     uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index 4dc0203fd7bc..82139b936f16 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -70,7 +70,7 @@ DECLARE_OOXMLEXPORT_TEST(testGroupshapeThemeFont, "groupshape-theme-font.docx")
 {
     // Font was specified using a theme reference, which wasn't handled.
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
     // This was Calibri.
     CPPUNIT_ASSERT_EQUAL(OUString("Cambria"), getProperty<OUString>(xRun, "CharFontName"));
@@ -874,7 +874,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.doc
     CPPUNIT_ASSERT_EQUAL(OUString("ooxml-roundRect"), aCustomShapeGeometry["Type"].get<OUString>());
 
     // The shape text should start with a table, with "a" in its A1 cell.
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index b0bd7bf349c5..9ab8a3f11731 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -1038,16 +1038,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo46361, "fdo46361.docx")
     uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
     // This was CENTER.
     CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust"));
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
     uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
     // This was LEFT.
     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust")));
     // This was black, not green.
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x008000), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
     // \n char was missing due to unhandled w:br.
-    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW)->getString());
     // \n chars were missing, due to unhandled multiple w:p tags.
-    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW)->getString());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testFdo65632, "fdo65632.docx")
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 095d938fc37f..eca2260e8f96 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -823,7 +823,7 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust
 {
     // Paragraph adjustment inside a group shape was not imported
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
-    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
     // 2nd line is adjusted to the right
     CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "ParaAdjust"));
     // 3rd line has no adjustment
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 3ea6916e2839..213148db627e 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -90,7 +90,7 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
     // Font names inside a group shape were not imported
     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
     uno::Reference<text::XText> xText
-        = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+        = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText();
 
     CPPUNIT_ASSERT_EQUAL(
         OUString("Calibri"),
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 6fa603c60b8c..359144d5169e 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -642,12 +642,12 @@ DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf")
     uno::Reference<text::XText> xText = xTextRange->getText();
     CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString());
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(
-        OUString("A"),
-        uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
-    CPPUNIT_ASSERT_EQUAL(
-        OUString("B"),
-        uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
+                                            xTable->getCellByName("A1"), uno::UNO_QUERY_THROW)
+                                            ->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>(
+                                            xTable->getCellByName("B1"), uno::UNO_QUERY_THROW)
+                                            ->getString());
     CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString());
 }
 
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index a65ca6cc98aa..e363be008429 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -150,9 +150,11 @@ DECLARE_RTFEXPORT_TEST(testFdo45187, "fdo45187.rtf")
     uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(),
                                                               uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xAnchor0
-        = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor();
+        = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY_THROW)
+              ->getAnchor();
     uno::Reference<text::XTextRange> xAnchor1
-        = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY)->getAnchor();
+        = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY_THROW)
+              ->getAnchor();
     // Was 0 ("starts at the same position"), should be 1 ("starts before")
     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1));
 }
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index d4e9a68b7f14..a60eb485ccdf 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -206,9 +206,9 @@ DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf")
     uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XText> xText = xTextRange->getText();
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(
-        OUString("A"),
-        uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(
+                                            xTable->getCellByName("A1"), uno::UNO_QUERY_THROW)
+                                            ->getString());
 
     // Make sure the second shape has the correct position and size.
     uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY);
@@ -401,8 +401,9 @@ DECLARE_RTFEXPORT_TEST(testFooterPara, "footer-para.rtf")
     uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>(
         getStyles("PageStyles")->getByName("First Page"), "FooterText");
     uno::Reference<text::XTextContent> xParagraph = getParagraphOrTable(1, xFooterText);
-    CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."),
-                         uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("All Rights Reserved."),
+        uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY_THROW)->getString());
     CPPUNIT_ASSERT_EQUAL(
         sal_Int16(style::ParagraphAdjust_CENTER),
         getProperty</*style::ParagraphAdjust*/ sal_Int16>(xParagraph, "ParaAdjust"));
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 17c59501c34b..1adfef5f48b4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -767,7 +767,7 @@ DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt")
 
     // This was "Standard", causing an unwanted page break on next paste.
     CPPUNIT_ASSERT_EQUAL(uno::Any(),
-                         uno::Reference<beans::XPropertySet>(getParagraph(1), uno::UNO_QUERY)
+                         uno::Reference<beans::XPropertySet>(getParagraph(1), uno::UNO_QUERY_THROW)
                              ->getPropertyValue("PageDescName"));
 }
 
@@ -811,7 +811,7 @@ DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf")
     CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
                          getProperty<style::BreakType>(xParaSecond, "BreakType"));
     CPPUNIT_ASSERT_EQUAL(uno::Any(),
-                         uno::Reference<beans::XPropertySet>(xParaSecond, uno::UNO_QUERY)
+                         uno::Reference<beans::XPropertySet>(xParaSecond, uno::UNO_QUERY_THROW)
                              ->getPropertyValue("PageDescName"));
     // actually not sure how many paragraph there should be between
     // SECOND and THIRD - important is that the page break is on there
@@ -823,8 +823,9 @@ DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf")
     CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird->getString());
     CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE,
                          getProperty<style::BreakType>(xParaThird, "BreakType"));
-    CPPUNIT_ASSERT_EQUAL(uno::Any(), uno::Reference<beans::XPropertySet>(xParaThird, uno::UNO_QUERY)
-                                         ->getPropertyValue("PageDescName"));
+    CPPUNIT_ASSERT_EQUAL(uno::Any(),
+                         uno::Reference<beans::XPropertySet>(xParaThird, uno::UNO_QUERY_THROW)
+                             ->getPropertyValue("PageDescName"));
 
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c6c3dc1123c8..ea1091a93907 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3978,7 +3978,7 @@ void SwUiWriterTest::testShapeAnchorUndo()
 
 static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
-    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 28217c7a3281..ed5cdb8bb9e9 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -126,7 +126,7 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone
                                 const uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
     uno::Reference<frame::XController> xController
-        = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+        = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
     CPPUNIT_ASSERT(xController.is());
     uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xFrame.is());
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 0a22a05fa3ea..fbc504cb5d97 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -516,7 +516,7 @@ DECLARE_WW8EXPORT_TEST(testTdf95321, "tdf95321.doc")
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     uno::Reference<text::XTextTable> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
-    CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY_THROW)->getString());
 }
 
 DECLARE_WW8EXPORT_TEST(testFdo77844, "fdo77844.doc")
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 8badc4d54978..2bf04080a03d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3710,7 +3710,7 @@ SwXCellRange::setData(const uno::Sequence< uno::Sequence<double> >& rData)
             throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
         for(const auto& rValue : rRow)
         {
-            uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_QUERY)->setValue(rValue);
+            uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_QUERY_THROW)->setValue(rValue);
             ++pCurrentCell;
         }
     }
diff --git a/writerfilter/source/dmapper/ModelEventListener.cxx b/writerfilter/source/dmapper/ModelEventListener.cxx
index b3a73cc6b9de..bc2286d69dea 100644
--- a/writerfilter/source/dmapper/ModelEventListener.cxx
+++ b/writerfilter/source/dmapper/ModelEventListener.cxx
@@ -56,8 +56,8 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent )
         try
         {
             //remove listener
-            uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener(
-            uno::Reference<document::XEventListener>(this));
+            uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY_THROW )->removeEventListener(
+                uno::Reference<document::XEventListener>(this));
 
             // If we have PAGEREF fields, update fields as well.
             uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(rEvent.Source, uno::UNO_QUERY);
@@ -107,7 +107,7 @@ void ModelEventListener::disposing( const lang::EventObject& rEvent )
 {
     try
     {
-        uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener(
+        uno::Reference<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY_THROW )->removeEventListener(
             uno::Reference<document::XEventListener>(this));
     }
     catch( const uno::Exception& )
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index 773138c27e86..fa93abb624b3 100644

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list