tdf#39593 use getUnoTunnelImplementation

Change-Id: I78eb67913a568c610e38e5002f914773c4906dfd
Reviewed-on: https://gerrit.libreoffice.org/79350
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 046f8bd..406df92 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -47,6 +47,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <vcl/settings.hxx>

#include <com/sun/star/drawing/ShapeCollection.hpp>
@@ -1026,15 +1027,10 @@

uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const uno::Reference<uno::XInterface>& xChartView)
{
    Reference< lang::XUnoTunnel> xUnoTunnel(xChartView,uno::UNO_QUERY);
    if(xUnoTunnel.is())
    {
        ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(xUnoTunnel->getSomething(
                    ExplicitValueProvider::getUnoTunnelId() ));
        if( pProvider )
            return pProvider->getDrawModelWrapper()->getShapeFactory();
    auto pProvider = comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(xChartView);
    if( pProvider )
        return pProvider->getDrawModelWrapper()->getShapeFactory();

    }
    return uno::Reference< lang::XMultiServiceFactory >();
}

diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
index f09f403..2141c4f 100644
--- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
+++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
@@ -371,11 +371,10 @@
                    drawing::XShape >& xShape )
{
    SdrObject* pRet = nullptr;
    uno::Reference< lang::XUnoTunnel > xUnoTunnel( xShape, uno::UNO_QUERY );
    uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, uno::UNO_QUERY );
    if(xUnoTunnel.is()&&xTypeProvider.is())
    if(xTypeProvider.is())
    {
        SvxShape* pSvxShape = reinterpret_cast<SvxShape*>(xUnoTunnel->getSomething( SvxShape::getUnoTunnelId() ));
        SvxShape* pSvxShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
        if(pSvxShape)
            pRet = pSvxShape->GetSdrObject();
    }
diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index ffce05a..fec07e8 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -204,11 +204,10 @@
static E3dScene* lcl_getE3dScene( const uno::Reference< drawing::XShape >& xShape )
{
    E3dScene* pRet=nullptr;
    uno::Reference< lang::XUnoTunnel > xUnoTunnel( xShape, uno::UNO_QUERY );
    uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, uno::UNO_QUERY );
    if(xUnoTunnel.is()&&xTypeProvider.is())
    if(xTypeProvider.is())
    {
        SvxShape* pSvxShape = reinterpret_cast<SvxShape*>(xUnoTunnel->getSomething( SvxShape::getUnoTunnelId() ));
        SvxShape* pSvxShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
        if(pSvxShape)
        {
            SdrObject* pObj = pSvxShape->GetSdrObject();
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index ab3b10d7..200b4b4 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1747,18 +1747,11 @@

SdrPage* ChartView::getSdrPage()
{
    SdrPage* pPage=nullptr;
    Reference< lang::XUnoTunnel> xUnoTunnel(m_xDrawPage,uno::UNO_QUERY);
    if(xUnoTunnel.is())
    {
        SvxDrawPage* pSvxDrawPage = reinterpret_cast<SvxDrawPage*>(xUnoTunnel->getSomething(
            SvxDrawPage::getUnoTunnelId() ));
        if(pSvxDrawPage)
        {
            pPage = pSvxDrawPage->GetSdrPage();
        }
    }
    return pPage;
    auto pSvxDrawPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>(m_xDrawPage);
    if(pSvxDrawPage)
        return pSvxDrawPage->GetSdrPage();

    return nullptr;
}

uno::Reference< drawing::XShape > ChartView::getShapeForCID( const OUString& rObjectCID )
diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx
index 1db6508..cc5f12b 100644
--- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx
@@ -31,6 +31,7 @@
#include <dbase/DIndex.hxx>
#include <connectivity/FValue.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <ucbhelper/content.hxx>

@@ -296,15 +297,11 @@
        aRow[4] = new ORowSetValueDecorator(getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))));
        aRow[6] = new ORowSetValueDecorator(*pBegin);

        Reference< XUnoTunnel> xTunnel(xIndex,UNO_QUERY);
        if(xTunnel.is())
        auto pIndex = comphelper::getUnoTunnelImplementation<ODbaseIndex>(xIndex);
        if(pIndex)
        {
            ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) );
            if(pIndex)
            {
                aRow[11] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_maxkeys));
                aRow[12] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_pagecount));
            }
            aRow[11] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_maxkeys));
            aRow[12] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_pagecount));
        }

        Reference<XColumnsSupplier> xColumnsSup(xIndex,UNO_QUERY);
diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx
index 3758330..1ebce26 100644
--- a/connectivity/source/drivers/dbase/DIndexes.cxx
+++ b/connectivity/source/drivers/dbase/DIndexes.cxx
@@ -19,6 +19,7 @@

#include <dbase/DIndexes.hxx>
#include <dbase/DIndex.hxx>
#include <comphelper/servicehelper.hxx>
#include <connectivity/dbexception.hxx>
#include <unotools/ucbhelper.hxx>
#include <strings.hrc>
@@ -106,14 +107,9 @@
// XDrop
void ODbaseIndexes::dropObject(sal_Int32 _nPos, const OUString& /*_sElementName*/)
{
    Reference< XUnoTunnel> xTunnel(getObject(_nPos),UNO_QUERY);
    if ( xTunnel.is() )
    {
        ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) );
        if ( pIndex )
            pIndex->DropImpl();
    }

    auto pIndex = comphelper::getUnoTunnelImplementation<ODbaseIndex>(getObject(_nPos));
    if ( pIndex )
        pIndex->DropImpl();
}


diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx
index 260e009..22826ec 100644
--- a/connectivity/source/drivers/dbase/DResultSet.cxx
+++ b/connectivity/source/drivers/dbase/DResultSet.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <dbase/DIndex.hxx>
#include <dbase/DIndexIter.hxx>
@@ -155,25 +156,21 @@

bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
{
    Reference<XUnoTunnel> xTunnel(_xIndex,UNO_QUERY);
    if(xTunnel.is())
    auto pIndex = comphelper::getUnoTunnelImplementation<dbase::ODbaseIndex>(_xIndex);
    if(pIndex)
    {
        dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelId()) );
        if(pIndex)
        {
            std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
        std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();

            if (pIter)
        if (pIter)
        {
            sal_uInt32 nRec = pIter->First();
            while (nRec != NODE_NOTFOUND)
            {
                sal_uInt32 nRec = pIter->First();
                while (nRec != NODE_NOTFOUND)
                {
                    m_pFileSet->get().push_back(nRec);
                    nRec = pIter->Next();
                }
                m_pFileSet->setFrozen();
                return true;
                m_pFileSet->get().push_back(nRec);
                nRec = pIter->Next();
            }
            m_pFileSet->setFrozen();
            return true;
        }
    }
    return false;
diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx
index d72061b..0054f3f 100644
--- a/connectivity/source/drivers/dbase/DTables.cxx
+++ b/connectivity/source/drivers/dbase/DTables.cxx
@@ -31,6 +31,7 @@
#include <file/FConnection.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <dbase/DCatalog.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <strings.hrc>
#include <connectivity/dbexception.hxx>
@@ -69,27 +70,23 @@
// XAppend
sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
    Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
    if(xTunnel.is())
    auto pTable = comphelper::getUnoTunnelImplementation<ODbaseTable>(descriptor);
    if(pTable)
    {
        ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelId()) );
        if(pTable)
        pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
        try
        {
            pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
            try
            {
                if(!pTable->CreateImpl())
                    throw SQLException();
            }
            catch(SQLException&)
            {
                throw;
            }
            catch(Exception& ex)
            {
                css::uno::Any anyEx = cppu::getCaughtException();
                throw SQLException( ex.Message, nullptr, "", 0, anyEx );
            }
            if(!pTable->CreateImpl())
                throw SQLException();
        }
        catch(SQLException&)
        {
            throw;
        }
        catch(Exception& ex)
        {
            css::uno::Any anyEx = cppu::getCaughtException();
            throw SQLException( ex.Message, nullptr, "", 0, anyEx );
        }
    }
    return createObject( _rForName );
diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
index c5fdadb..44404f9 100644
--- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
@@ -32,6 +32,7 @@
#include <file/FDriver.hxx>
#include <file/FTable.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <tools/diagnose_ex.h>
#include <ucbhelper/content.hxx>

@@ -401,30 +402,26 @@
                    xNames->getByName(*pBegin), css::uno::UNO_QUERY);
                if(xTable.is())
                {
                    Reference<XUnoTunnel> xTunnel(xTable,UNO_QUERY);
                    if(xTunnel.is())
                    auto pTable = comphelper::getUnoTunnelImplementation<OFileTable>(xTable);
                    if(pTable && !pTable->isReadOnly())
                    {
                        OFileTable* pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelId()) );
                        if(pTable && !pTable->isReadOnly())
                        aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
                        aRows.push_back(aRow);
                        if(!m_pConnection->showDeleted())
                        {
                            aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
                            aRows.push_back(aRow);
                            if(!m_pConnection->showDeleted())
                            {
                                aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue();
                                aRows.push_back(aRow);
                            }
                            aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue();
                            aRows.push_back(aRow);
                            aRow[6] = ODatabaseMetaDataResultSet::getCreateValue();
                            aRows.push_back(aRow);
                            aRow[6] = ODatabaseMetaDataResultSet::getReadValue();
                            aRows.push_back(aRow);
                            aRow[6] = ODatabaseMetaDataResultSet::getAlterValue();
                            aRows.push_back(aRow);
                            aRow[6] = ODatabaseMetaDataResultSet::getDropValue();
                            aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue();
                            aRows.push_back(aRow);
                        }
                        aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue();
                        aRows.push_back(aRow);
                        aRow[6] = ODatabaseMetaDataResultSet::getCreateValue();
                        aRows.push_back(aRow);
                        aRow[6] = ODatabaseMetaDataResultSet::getReadValue();
                        aRows.push_back(aRow);
                        aRow[6] = ODatabaseMetaDataResultSet::getAlterValue();
                        aRows.push_back(aRow);
                        aRow[6] = ODatabaseMetaDataResultSet::getDropValue();
                        aRows.push_back(aRow);
                    }
                }
            }
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index 5ab48b1..1a03f16 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -47,6 +47,7 @@
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/types.hxx>
#include <unotools/confignode.hxx>
@@ -342,13 +343,9 @@
                if ( xOrig.is() )
                {
                    // now we have to set the URL to get the correct answer for metadata()->getURL()
                    Reference< XUnoTunnel> xTunnel(xOrig,UNO_QUERY);
                    if ( xTunnel.is() )
                    {
                        OMetaConnection* pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelId() ));
                        if ( pMetaConnection )
                            pMetaConnection->setURL(url);
                    }
                    auto pMetaConnection = comphelper::getUnoTunnelImplementation<OMetaConnection>(xOrig);
                    if ( pMetaConnection )
                        pMetaConnection->setURL(url);

                    Reference<XComponent> xComp(xOrig,UNO_QUERY);
                    if ( xComp.is() )
diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
index 06631ed..727a8f2 100644
--- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
+++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
@@ -21,6 +21,7 @@
#include <mysql/YCatalog.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
@@ -265,16 +266,11 @@
            xConnection = xDriver->connect(sCuttedUrl, aConvertedProperties);
            if (xConnection.is())
            {
                OMetaConnection* pMetaConnection = nullptr;
                // now we have to set the URL to get the correct answer for metadata()->getURL()
                Reference<XUnoTunnel> xTunnel(xConnection, UNO_QUERY);
                if (xTunnel.is())
                {
                    pMetaConnection = reinterpret_cast<OMetaConnection*>(
                        xTunnel->getSomething(OMetaConnection::getUnoTunnelId()));
                    if (pMetaConnection)
                        pMetaConnection->setURL(url);
                }
                auto pMetaConnection
                    = comphelper::getUnoTunnelImplementation<OMetaConnection>(xConnection);
                if (pMetaConnection)
                    pMetaConnection->setURL(url);
                m_aConnections.push_back(
                    TWeakPair(WeakReferenceHelper(xConnection),
                              TWeakConnectionPair(WeakReferenceHelper(), pMetaConnection)));
@@ -340,29 +336,24 @@
    checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);

    Reference<XTablesSupplier> xTab;
    Reference<XUnoTunnel> xTunnel(connection, UNO_QUERY);
    if (xTunnel.is())
    auto pConnection = comphelper::getUnoTunnelImplementation<OMetaConnection>(connection);
    if (pConnection)
    {
        OMetaConnection* pConnection = reinterpret_cast<OMetaConnection*>(
            xTunnel->getSomething(OMetaConnection::getUnoTunnelId()));
        if (pConnection)
        TWeakPairVector::iterator i
            = std::find_if(m_aConnections.begin(), m_aConnections.end(),
                           [&pConnection](const TWeakPairVector::value_type& rConnection) {
                               return rConnection.second.second == pConnection;
                           });
        if (i != m_aConnections.end())
        {
            TWeakPairVector::iterator i
                = std::find_if(m_aConnections.begin(), m_aConnections.end(),
                               [&pConnection](const TWeakPairVector::value_type& rConnection) {
                                   return rConnection.second.second == pConnection;
                               });
            if (i != m_aConnections.end())
            xTab.set(i->second.first.get(), UNO_QUERY);
            if (!xTab.is())
            {
                xTab.set(i->second.first.get(), UNO_QUERY);
                if (!xTab.is())
                {
                    xTab = new OMySQLCatalog(connection);
                    i->second.first = WeakReferenceHelper(xTab);
                }
                xTab = new OMySQLCatalog(connection);
                i->second.first = WeakReferenceHelper(xTab);
            }
        }
    } // if ( xTunnel.is() )
    } // if (pConnection)
    if (!xTab.is())
    {
        TWeakPairVector::iterator i
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 99c6e56..2130d6b 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2144,13 +2144,9 @@
    // notify the clones
    for (auto const& elem : m_aClones)
    {
        Reference< XUnoTunnel > xTunnel(elem.get(),UNO_QUERY);
        if(xTunnel.is())
        {
            ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelId()));
            if(pClone)
                pClone->onDeleteRow( _rBookmark );
        }
        auto pClone = comphelper::getUnoTunnelImplementation<ORowSetClone>(elem.get());
        if(pClone)
            pClone->onDeleteRow( _rBookmark );
    }
}

@@ -2161,13 +2157,9 @@
    // notify the clones
    for (auto const& clone : m_aClones)
    {
        Reference< XUnoTunnel > xTunnel(clone.get(),UNO_QUERY);
        if(xTunnel.is())
        {
            ORowSetClone* pClone = reinterpret_cast<ORowSetClone*>(xTunnel->getSomething(ORowSetClone::getUnoTunnelId()));
            if(pClone)
                pClone->onDeletedRow( _rBookmark, _nPos );
        }
        auto pClone = comphelper::getUnoTunnelImplementation<ORowSetClone>(clone.get());
        if(pClone)
            pClone->onDeletedRow( _rBookmark, _nPos );
    }
}

diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index 78117ef..e64ab80 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -786,8 +786,7 @@
    if ( !m_pFormatter )
    {
        Reference< XNumberFormatsSupplier >  xSupplier = m_xFormatter->getNumberFormatsSupplier();
        Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
        SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
        auto pSupplierImpl = comphelper::getUnoTunnelImplementation<SvNumberFormatsSupplierObj>(xSupplier);
        m_pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : nullptr;
        Reference<XPropertySet> xNumberFormatSettings = xSupplier->getNumberFormatSettings();
        xNumberFormatSettings->getPropertyValue("NullDate") >>= m_aNullDate;
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 31decd1..417b42e 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -1080,8 +1080,7 @@
    {
        Reference< css::util::XNumberFormatsSupplier >  xSupplier = _rxFormatter->getNumberFormatsSupplier();

        Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
        SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
        auto pSupplierImpl = comphelper::getUnoTunnelImplementation<SvNumberFormatsSupplierObj>(xSupplier);
        OSL_ENSURE(pSupplierImpl,"No Supplier!");

        if ( pSupplierImpl )
diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx
index a22ec38..9681fdf 100644
--- a/dbaccess/source/ui/querydesign/JoinExchange.cxx
+++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx
@@ -68,13 +68,9 @@
    OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
    {
        OJoinExchangeData aReturn;
        Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
        if (xTunnel.is())
        {
            OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelId()));
            if (pImplementation)
                aReturn = pImplementation->m_jxdSourceDescription;
        }
        auto pImplementation = comphelper::getUnoTunnelImplementation<OJoinExchObj>(_rxObject);
        if (pImplementation)
            aReturn = pImplementation->m_jxdSourceDescription;
        return aReturn;
    }

diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index e3ef88a..166e58e 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1979,12 +1979,9 @@
std::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::Reference< report::XReportDefinition >& _xReportDefinition)
{
    std::shared_ptr<rptui::OReportModel> pReportModel;
    uno::Reference< lang::XUnoTunnel > xUT( _xReportDefinition, uno::UNO_QUERY );
    if( xUT.is() )
        pReportModel = reinterpret_cast<OReportDefinition*>(
                           sal::static_int_cast<sal_uIntPtr>(
                               xUT->getSomething( OReportDefinition::getUnoTunnelId()))
                        )->m_pImpl->m_pReportModel;
    auto pReportDefinition = comphelper::getUnoTunnelImplementation<OReportDefinition>(_xReportDefinition);
    if (pReportDefinition)
        pReportModel = pReportDefinition->m_pImpl->m_pReportModel;
    return pReportModel;
}

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index fa2a8fc..f0e2be87 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -5244,8 +5244,7 @@
            uno::Reference< frame::XModel > xModel = GetModel();
            if ( xModel.is() )
            {
                uno::Reference< lang::XUnoTunnel >  xObjShellTunnel( xModel, uno::UNO_QUERY );
                SfxObjectShell* pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel.is() ? xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()) : 0 );
                auto pFoundShell = comphelper::getUnoTunnelImplementation<SfxObjectShell>(xModel);
                if ( pFoundShell && ooo::vba::isAlienExcelDoc( *pFoundShell ) )
                {
                    xRowStylesPropertySetMapper = new XMLPropertySetMapper(aXMLScFromXLSRowStylesProperties, xScPropHdlFactory, true);
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 59f1b72..914a398 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -157,11 +157,7 @@
rtl::Reference<ScHeaderFooterContentObj> ScHeaderFooterContentObj::getImplementation(
                                const uno::Reference<sheet::XHeaderFooterContent>& rObj)
{
    rtl::Reference<ScHeaderFooterContentObj> pRet;
    uno::Reference<lang::XUnoTunnel> xUT(rObj, uno::UNO_QUERY);
    if (xUT.is())
        pRet = reinterpret_cast<ScHeaderFooterContentObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
    return pRet;
    return comphelper::getUnoTunnelImplementation<ScHeaderFooterContentObj>(rObj);
}

void ScHeaderFooterContentObj::Init( const EditTextObject* pLeft,
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 0ffc108..667fb7e 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2675,13 +2675,9 @@
{
    try
    {
        css::uno::Reference< css::lang::XUnoTunnel > xUnoTunnel( xPage, css::uno::UNO_QUERY );
        if( xUnoTunnel.is() )
        {
            SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
            if( pUnoPage )
                return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
        }
        auto pUnoPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>(xPage);
        if( pUnoPage )
            return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
    }
    catch( css::uno::Exception& )
    {
diff --git a/sd/source/ui/framework/factories/PresentationFactory.cxx b/sd/source/ui/framework/factories/PresentationFactory.cxx
index 42df2c9..7647a35 100644
--- a/sd/source/ui/framework/factories/PresentationFactory.cxx
+++ b/sd/source/ui/framework/factories/PresentationFactory.cxx
@@ -22,6 +22,7 @@
#include <DrawController.hxx>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/XView.hpp>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/compbase.hxx>
#include <tools/diagnose_ex.h>
#include <slideshow.hxx>
@@ -121,17 +122,12 @@
{
    ThrowIfDisposed();

    Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY);
    if (xTunnel.is())
    auto pController = comphelper::getUnoTunnelImplementation<sd::DrawController>(mxController);
    if (pController != nullptr)
    {
        ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
            xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
        if (pController != nullptr)
        {
            ViewShellBase* pBase = pController->GetViewShellBase();
            if (pBase != nullptr)
                SlideShow::Stop( *pBase );
        }
        ViewShellBase* pBase = pController->GetViewShellBase();
        if (pBase != nullptr)
            SlideShow::Stop( *pBase );
    }
}

diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.cxx b/sd/source/ui/framework/module/CenterViewFocusModule.cxx
index d462489..3db156d 100644
--- a/sd/source/ui/framework/module/CenterViewFocusModule.cxx
+++ b/sd/source/ui/framework/module/CenterViewFocusModule.cxx
@@ -27,6 +27,7 @@
#include <ViewShellManager.hxx>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
#include <comphelper/servicehelper.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -51,14 +52,9 @@
        mxConfigurationController = xControllerManager->getConfigurationController();

        // Tunnel through the controller to obtain a ViewShellBase.
        Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
        if (xTunnel.is())
        {
            ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
                xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
            if (pController != nullptr)
                mpBase = pController->GetViewShellBase();
        }
        auto pController = comphelper::getUnoTunnelImplementation<sd::DrawController>(rxController);
        if (pController != nullptr)
            mpBase = pController->GetViewShellBase();

        // Check, if all required objects do exist.
        if (mxConfigurationController.is() && mpBase!=nullptr)
@@ -128,11 +124,9 @@
    Reference<XView> xView;
    if (xViewIds.hasElements())
        xView.set( mxConfigurationController->getResource(xViewIds[0]),UNO_QUERY);
    Reference<lang::XUnoTunnel> xTunnel (xView, UNO_QUERY);
    if (xTunnel.is() && mpBase!=nullptr)
    if (mpBase!=nullptr)
    {
        ViewShellWrapper* pViewShellWrapper = reinterpret_cast<ViewShellWrapper*>(
            xTunnel->getSomething(ViewShellWrapper::getUnoTunnelId()));
        auto pViewShellWrapper = comphelper::getUnoTunnelImplementation<ViewShellWrapper>(xView);
        if (pViewShellWrapper != nullptr)
        {
            std::shared_ptr<ViewShell> pViewShell = pViewShellWrapper->GetViewShell();
diff --git a/sd/source/ui/framework/module/ShellStackGuard.cxx b/sd/source/ui/framework/module/ShellStackGuard.cxx
index 877a66f..0340b85 100644
--- a/sd/source/ui/framework/module/ShellStackGuard.cxx
+++ b/sd/source/ui/framework/module/ShellStackGuard.cxx
@@ -27,6 +27,7 @@
#include <sfx2/printer.hxx>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
#include <comphelper/servicehelper.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -51,14 +52,9 @@
        mxConfigurationController = xControllerManager->getConfigurationController();

        // Tunnel through the controller to obtain a ViewShellBase.
        Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
        if (xTunnel.is())
        {
            ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
                xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
            if (pController != nullptr)
                mpBase = pController->GetViewShellBase();
        }
        auto pController = comphelper::getUnoTunnelImplementation<sd::DrawController>(rxController);
        if (pController != nullptr)
            mpBase = pController->GetViewShellBase();
    }

    if (mxConfigurationController.is())
diff --git a/sd/source/ui/framework/module/ToolBarModule.cxx b/sd/source/ui/framework/module/ToolBarModule.cxx
index d4f3932..a14bac5 100644
--- a/sd/source/ui/framework/module/ToolBarModule.cxx
+++ b/sd/source/ui/framework/module/ToolBarModule.cxx
@@ -20,6 +20,7 @@
#include "ToolBarModule.hxx"
#include <ViewShellBase.hxx>
#include <DrawController.hxx>
#include <comphelper/servicehelper.hxx>
#include <framework/FrameworkHelper.hxx>

using namespace ::com::sun::star;
@@ -48,14 +49,9 @@
      mbMainViewSwitchUpdatePending(false)
{
    // Tunnel through the controller to obtain a ViewShellBase.
    Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
    if (xTunnel.is())
    {
        ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
            xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
        if (pController != nullptr)
            mpBase = pController->GetViewShellBase();
    }
    auto pController = comphelper::getUnoTunnelImplementation<sd::DrawController>(rxController);
    if (pController != nullptr)
        mpBase = pController->GetViewShellBase();

    Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
    if (!xControllerManager.is())
diff --git a/sd/source/ui/sidebar/PanelFactory.cxx b/sd/source/ui/sidebar/PanelFactory.cxx
index 226e820..e3489ac 100644
--- a/sd/source/ui/sidebar/PanelFactory.cxx
+++ b/sd/source/ui/sidebar/PanelFactory.cxx
@@ -33,6 +33,7 @@

#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/servicehelper.hxx>
#include <vcl/window.hxx>
#include <toolkit/helper/vclunohelper.hxx>

@@ -82,14 +83,9 @@

    // Tunnel through the controller to obtain a ViewShellBase.
    ViewShellBase* pBase = nullptr;
    Reference<lang::XUnoTunnel> xTunnel (xFrame->getController(), UNO_QUERY);
    if (xTunnel.is())
    {
        ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
            xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
        if (pController != nullptr)
            pBase = pController->GetViewShellBase();
    }
    auto pController = comphelper::getUnoTunnelImplementation<sd::DrawController>(xFrame->getController());
    if (pController != nullptr)
        pBase = pController->GetViewShellBase();
    if (pBase == nullptr)
        throw RuntimeException("can not get ViewShellBase for frame");

diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index afb4974..bc1b3b7 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -86,8 +86,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ? reinterpret_cast<ThumbnailViewAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ThumbnailViewAcc::getUnoTunnelId() ))) : nullptr );
        return comphelper::getUnoTunnelImplementation<ThumbnailViewAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
@@ -1041,11 +1040,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ?
                reinterpret_cast<ThumbnailViewItemAcc*>(sal::static_int_cast<sal_IntPtr>(
                        xUnoTunnel->getSomething( ThumbnailViewItemAcc::getUnoTunnelId() ))) :
                nullptr );
        return comphelper::getUnoTunnelImplementation<ThumbnailViewItemAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 3c0d3ff..bfeab01 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -98,9 +98,7 @@
    uno::Reference< lang::XComponent > xModelComp = xModel;

    bool bEmbedded = false;
    uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
    SmModel *pModel = reinterpret_cast<SmModel *>
        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
    SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

    SmDocShell *pDocShell = pModel ?
            static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr;
@@ -285,10 +283,7 @@
    uno::Sequence< PropertyValue > aProps(0);
    xFilter->filter( aProps );

    uno::Reference<lang::XUnoTunnel> xFilterTunnel( xFilter, uno::UNO_QUERY );
    SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >(
                sal::static_int_cast< sal_uIntPtr >(
                xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() )));
    auto pFilter = comphelper::getUnoTunnelImplementation<SmXMLExport>(xFilter);
    return pFilter == nullptr || pFilter->GetSuccess();
}

@@ -413,9 +408,7 @@
    else
    {
        uno::Reference <frame::XModel> xModel = GetModel();
        uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
        SmModel *pModel = reinterpret_cast<SmModel *>
            (xTunnel->getSomething(SmModel::getUnoTunnelId()));
        SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

        if (pModel)
        {
@@ -451,9 +444,7 @@
void SmXMLExport::ExportContent_()
{
    uno::Reference <frame::XModel> xModel = GetModel();
    uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
    SmModel *pModel = reinterpret_cast<SmModel *>
        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
    SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);
    SmDocShell *pDocShell = pModel ?
        static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr;
    OSL_ENSURE( pDocShell, "doc shell missing" );
@@ -504,9 +495,7 @@
    if ( !xModel.is() )
        return;

    uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
    SmModel *pModel = reinterpret_cast<SmModel *>
        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
    SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

    if ( !pModel )
        return;
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 946c8e2..808a235 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -107,9 +107,7 @@
    uno::Reference<task::XStatusIndicator> xStatusIndicator;

    bool bEmbedded = false;
    uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
    SmModel *pModel = reinterpret_cast<SmModel *>
        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
    SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

    SmDocShell *pDocShell = pModel ?
            static_cast<SmDocShell*>(pModel->GetObjectShell()) : nullptr;
@@ -298,10 +296,7 @@
        else
            xParser->parseStream( aParserInput );

        uno::Reference<lang::XUnoTunnel> xFilterTunnel( xFilter, uno::UNO_QUERY );
        SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
                sal::static_int_cast< sal_uIntPtr >(
                xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
        auto pFilter = comphelper::getUnoTunnelImplementation<SmXMLImport>(xFilter);
        if ( pFilter && pFilter->GetSuccess() )
            nError = ERRCODE_NONE;
    }
@@ -471,9 +466,7 @@
    if (pTree && pTree->GetType() == SmNodeType::Table)
    {
        uno::Reference <frame::XModel> xModel = GetModel();
        uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
        SmModel *pModel = reinterpret_cast<SmModel *>
            (xTunnel->getSomething(SmModel::getUnoTunnelId()));
        SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

        if (pModel)
        {
@@ -3063,9 +3056,7 @@
    if ( !xModel.is() )
        return;

    uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
    SmModel *pModel = reinterpret_cast<SmModel *>
        (xTunnel->getSomething(SmModel::getUnoTunnelId()));
    SmModel *pModel = comphelper::getUnoTunnelImplementation<SmModel>(xModel);

    if ( !pModel )
        return;
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 3a513cd..68a4368 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/container/XChild.hpp>

#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/string.hxx>
#include <i18nutil/unicode.hxx>
@@ -1446,15 +1447,9 @@
            Reference< datatransfer::XTransferable > xTrans( GetDoc()->GetModel(), uno::UNO_QUERY );
            if( xTrans.is() )
            {
                Reference< lang::XUnoTunnel> xTnnl( xTrans, uno::UNO_QUERY);
                if( xTnnl.is() )
                {
                    TransferableHelper* pTrans = reinterpret_cast< TransferableHelper * >(
                            sal::static_int_cast< sal_uIntPtr >(
                            xTnnl->getSomething( TransferableHelper::getUnoTunnelId() )));
                    if( pTrans )
                        pTrans->CopyToClipboard(GetEditWindow());
                }
                auto pTrans = comphelper::getUnoTunnelImplementation<TransferableHelper>(xTrans);
                if( pTrans )
                    pTrans->CopyToClipboard(GetEditWindow());
            }
        }
        break;
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 5651b8b..6a8b255 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -914,11 +914,7 @@
{
    SfxUnoStyleSheet* pRet = dynamic_cast< SfxUnoStyleSheet* >( xStyle.get() );
    if( !pRet )
    {
        css::uno::Reference< css::lang::XUnoTunnel > xUT( xStyle, css::uno::UNO_QUERY );
        if( xUT.is() )
            pRet = reinterpret_cast<SfxUnoStyleSheet*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SfxUnoStyleSheet::getUnoTunnelId())));
    }
        pRet = comphelper::getUnoTunnelImplementation<SfxUnoStyleSheet>(xStyle);
    return pRet;
}

diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
index 08838f3..869dc81 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -144,8 +144,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ? reinterpret_cast<ValueSetAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueSetAcc::getUnoTunnelId() ))) : nullptr );
        return comphelper::getUnoTunnelImplementation<ValueSetAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
@@ -747,8 +746,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ? reinterpret_cast<ValueItemAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueItemAcc::getUnoTunnelId() ))) : nullptr );
        return comphelper::getUnoTunnelImplementation<ValueItemAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
@@ -1096,8 +1094,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ? reinterpret_cast<SvtValueItemAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( SvtValueItemAcc::getUnoTunnelId() ))) : nullptr );
        return comphelper::getUnoTunnelImplementation<SvtValueItemAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
@@ -1486,8 +1483,7 @@
{
    try
    {
        uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
        return( xUnoTunnel.is() ? reinterpret_cast<SvtValueSetAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( SvtValueSetAcc::getUnoTunnelId() ))) : nullptr );
        return comphelper::getUnoTunnelImplementation<SvtValueSetAcc>(rxData);
    }
    catch(const css::uno::Exception&)
    {
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 41a4e79..b03a2a0 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1102,14 +1102,7 @@
            m_nWidth = nWidthSum;
            m_bOrtho = false;

            uno::Reference<lang::XUnoTunnel> xNumTunnel(xCols, uno::UNO_QUERY);
            SwXTextColumns* pSwColums = nullptr;
            if(xNumTunnel.is())
            {
                pSwColums = reinterpret_cast< SwXTextColumns * >(
                    sal::static_int_cast< sal_IntPtr >(
                    xNumTunnel->getSomething( SwXTextColumns::getUnoTunnelId() )));
            }
            auto pSwColums = comphelper::getUnoTunnelImplementation<SwXTextColumns>(xCols);
            if(pSwColums)
            {
                m_bOrtho = pSwColums->IsAutomaticWidth();
diff --git a/sw/source/core/layout/dumpfilter.cxx b/sw/source/core/layout/dumpfilter.cxx
index 4078784..7e26bce 100644
--- a/sw/source/core/layout/dumpfilter.cxx
+++ b/sw/source/core/layout/dumpfilter.cxx
@@ -87,8 +87,7 @@
                uno::Reference< io::XOutputStream >() );

        // Actually get the SwRootFrame to call dumpAsXml
        uno::Reference< lang::XUnoTunnel > xDocTunnel( m_xSrcDoc, uno::UNO_QUERY );
        SwXTextDocument* pXDoc = UnoTunnelGetImplementation< SwXTextDocument >( xDocTunnel );
        auto pXDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(m_xSrcDoc);
        if ( pXDoc )
        {
            SwRootFrame* pLayout = pXDoc->GetDocShell()->GetWrtShell()->GetLayout();
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 895cf5b..11efa6a 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1602,37 +1602,30 @@
                    const sal_Int32 nLen = xRef->getTextualData().getLength();
                    if (nLen > 1) // value data-sequence ?
                    {
                        uno::Reference< lang::XUnoTunnel > xTunnel( xRef, uno::UNO_QUERY );
                        if(xTunnel.is())
                        auto pDataSeq = comphelper::getUnoTunnelImplementation<SwChartDataSequence>(xRef);
                        if (pDataSeq)
                        {
                            SwChartDataSequence *pDataSeq = reinterpret_cast< SwChartDataSequence * >(
                                    sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwChartDataSequence::getUnoTunnelId() )));
                            SwRangeDescriptor aDesc;
                            pDataSeq->FillRangeDesc( aDesc );

                            if (pDataSeq)
                            chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS;
                            if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
                                eDRSource = chart::ChartDataRowSource_ROWS;

                            if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS)
                            {
                                SwRangeDescriptor aDesc;
                                pDataSeq->FillRangeDesc( aDesc );

                                chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS;
                                if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
                                    eDRSource = chart::ChartDataRowSource_ROWS;

                                if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS)
                                {
                                    // add rows: extend affected columns by newly added row cells
                                    pDataSeq->ExtendTo( true, nFirstNewRow, nLines );
                                }
                                else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS)
                                {
                                    // add cols: extend affected rows by newly added column cells
                                    pDataSeq->ExtendTo( false, nFirstNewCol, nLines );
                                }
                                // add rows: extend affected columns by newly added row cells
                                pDataSeq->ExtendTo( true, nFirstNewRow, nLines );
                            }
                            else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS)
                            {
                                // add cols: extend affected rows by newly added column cells
                                pDataSeq->ExtendTo( false, nFirstNewCol, nLines );
                            }
                        }
                    }
                }
            }

        }
    }
}
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 5ac8ff1..0b0555b 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -772,15 +772,7 @@
    uno::Reference<XIndexReplace> xIndexReplace;
    if(rValue >>= xIndexReplace)
    {
        SwXNumberingRules* pSwNum = nullptr;

        uno::Reference<XUnoTunnel> xNumTunnel(xIndexReplace, UNO_QUERY);
        if(xNumTunnel.is())
        {
            pSwNum = reinterpret_cast< SwXNumberingRules * >(
                sal::static_int_cast< sal_IntPtr >( xNumTunnel->getSomething( SwXNumberingRules::getUnoTunnelId() )));
        }

        auto pSwNum = comphelper::getUnoTunnelImplementation<SwXNumberingRules>(xIndexReplace);
        if(pSwNum)
        {
            SwDoc* pDoc = rPam.GetDoc();
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index be29668..35d35b6 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -898,11 +898,7 @@
        xShapeAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
    osl_atomic_decrement(&m_refCount);

    uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
    SvxShape* pShape = nullptr;
    if(xShapeTunnel.is())
        pShape = reinterpret_cast< SvxShape * >(
                sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShapeAgg);

    SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
    if(pObj)
@@ -927,11 +923,7 @@
        if ( !pCurrent )
            continue;

        SwXShape* pSwShape = nullptr;
        uno::Reference< lang::XUnoTunnel > xShapeTunnel( pCurrent->getWeakUnoShape(), uno::UNO_QUERY );
        if ( xShapeTunnel.is() )
            pSwShape = reinterpret_cast< SwXShape * >(
                    sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething( SwXShape::getUnoTunnelId() ) ) );
        auto pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(pCurrent->getWeakUnoShape());
        if ( pSwShape )
        {
            if ( pSwShape->m_bDescriptor )
@@ -1051,11 +1043,7 @@
                    uno::Reference<text::XTextFrame> xFrame;
                    if(aValue >>= xFrame)
                    {
                        uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
                        SwXFrame* pFrame = xTunnel.is() ?
                                reinterpret_cast< SwXFrame * >(
                                    sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
                                : nullptr;
                        SwXFrame* pFrame = comphelper::getUnoTunnelImplementation<SwXFrame>(xFrame);
                        if(pFrame && pFrame->GetFrameFormat() &&
                            pFrame->GetFrameFormat()->GetDoc() == pDoc)
                        {
@@ -2165,15 +2153,9 @@

SvxShape*   SwXShape::GetSvxShape()
{
    SvxShape* pSvxShape = nullptr;
    if(xShapeAgg.is())
    {
        uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShapeAgg, uno::UNO_QUERY);
        if(xShapeTunnel.is())
            pSvxShape = reinterpret_cast< SvxShape * >(
                    sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
    }
    return pSvxShape;
        return comphelper::getUnoTunnelImplementation<SvxShape>(xShapeAgg);
    return nullptr;
}

// #i31698#
@@ -2288,11 +2270,7 @@
            // #i34750#
            // use method <SvxShape->getPosition()> to get the correct
            // 'Drawing layer' position of the top group shape.
            uno::Reference< lang::XUnoTunnel > xGrpShapeTunnel(
                                                    pTopGroupObj->getUnoShape(),
                                                    uno::UNO_QUERY );
            SvxShape* pSvxGroupShape = reinterpret_cast< SvxShape * >(
                    sal::static_int_cast< sal_IntPtr >( xGrpShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
            auto pSvxGroupShape = comphelper::getUnoTunnelImplementation<SvxShape>(pTopGroupObj->getUnoShape());
            const awt::Point aGroupPos = pSvxGroupShape->getPosition();
            aNewPos.X = o3tl::saturating_add(aNewPos.X, aGroupPos.X);
            aNewPos.Y = o3tl::saturating_add(aNewPos.Y, aGroupPos.Y);
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 77eeb29..81906e1 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1729,10 +1729,7 @@
            uno::Reference<text::XTextFrame> xFrame;
            if(aValue >>= xFrame)
            {
                uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY);
                SwXFrame* pFrame = xTunnel.is() ?
                        reinterpret_cast< SwXFrame * >( sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) ))
                        : nullptr;
                SwXFrame* pFrame = comphelper::getUnoTunnelImplementation<SwXFrame>(xFrame);
                if(pFrame && this != pFrame && pFrame->GetFrameFormat() && pFrame->GetFrameFormat()->GetDoc() == pDoc)
                {
                    SfxItemSet aSet( pDoc->GetAttrPool(),
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 2c5766e..dc47a6d 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2921,13 +2921,7 @@

    SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );

    const uno::Reference<lang::XUnoTunnel> xTunnel(
            m_pImpl->m_xParentText, uno::UNO_QUERY);
    SwXText* pParentText = nullptr;
    if (xTunnel.is())
    {
        pParentText = ::sw::UnoTunnelGetImplementation<SwXText>(xTunnel);
    }
    SwXText* pParentText = comphelper::getUnoTunnelImplementation<SwXText>(m_pImpl->m_xParentText);
    OSL_ENSURE(pParentText, "parent is not a SwXText");
    if (!pParentText)
    {
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 2230e40..004de65 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1035,10 +1035,8 @@
    {
        xTextCursor.set( pText->CreateCursor() );
        xTextCursor->gotoEnd(true);
        const uno::Reference<lang::XUnoTunnel> xCursorTunnel(
                xTextCursor, uno::UNO_QUERY);
        pCursor =
            ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel);
            comphelper::getUnoTunnelImplementation<OTextCursorHelper>(xTextCursor);
    }
    if(pRange && &pRange->GetDoc() == rToFill.GetDoc())
    {
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index 24cb9c5..d69f7ab 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -710,9 +710,8 @@
    {
        if (pPortions) // set cache in the XMeta to the given portions
        {
            const uno::Reference<lang::XUnoTunnel> xUT(xMeta, uno::UNO_QUERY);
            SwXMeta *const pXMeta(
                ::sw::UnoTunnelGetImplementation<SwXMeta>(xUT));
                comphelper::getUnoTunnelImplementation<SwXMeta>(xMeta));
            assert(pXMeta);
            // NB: the meta must always be created with the complete content
            // if SwXTextPortionEnumeration is created for a selection,
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 34060ac..02c07ea 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1025,13 +1025,9 @@
        uno::Reference<style::XStyle> xStyle = FindStyle(pBase->GetName());
        if(xStyle.is())
        {
            uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
            if(xTunnel.is())
            {
                SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
                        sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
            SwXStyle* pStyle = comphelper::getUnoTunnelImplementation<SwXStyle>(xStyle);
            if(pStyle)
                pStyle->Invalidate();
            }
        }
        m_pBasePool->Remove(pBase);
        insertByName(rName, rElement);
@@ -1195,9 +1191,7 @@

sal_Int64 SAL_CALL SwXStyle::getSomething(const uno::Sequence<sal_Int8>& rId)
{
    if(rId.getLength() != 16)
        return 0;
    if(0 == memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16))
    if(isUnoTunnelId<SwXStyle>(rId))
    {
        return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
    }
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 65ca224..e012e63 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -634,10 +634,8 @@
        throw aRuntime;
    }

    const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
            uno::UNO_QUERY);
    SwXParagraph *const pPara =
            ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
            comphelper::getUnoTunnelImplementation<SwXParagraph>(xNewContent);
    if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is())
    {
        throw lang::IllegalArgumentException();
@@ -692,10 +690,8 @@
        throw uno::RuntimeException();
    }

    const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent,
            uno::UNO_QUERY);
    SwXParagraph *const pPara =
            ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel);
            comphelper::getUnoTunnelImplementation<SwXParagraph>(xNewContent);
    if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is())
    {
        throw lang::IllegalArgumentException();
@@ -986,9 +982,8 @@
{
    const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor());

    const uno::Reference<lang::XUnoTunnel> xTunnel(xOwnCursor, uno::UNO_QUERY);
    OTextCursorHelper *const pOwnCursor =
            ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel);
            comphelper::getUnoTunnelImplementation<OTextCursorHelper>(xOwnCursor);
    OSL_ENSURE(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? ");
    const SwStartNode* pOwnStartNode =
        pOwnCursor->GetPaM()->GetNode().StartOfSectionNode();
@@ -1522,14 +1517,10 @@
        throw lang::IllegalArgumentException();
    }

    const uno::Reference<lang::XUnoTunnel> xStartRangeTunnel(xStart,
            uno::UNO_QUERY);
    SwXTextRange *const pStartRange =
        ::sw::UnoTunnelGetImplementation<SwXTextRange>(xStartRangeTunnel);
    const uno::Reference<lang::XUnoTunnel> xEndRangeTunnel(xEnd,
            uno::UNO_QUERY);
        comphelper::getUnoTunnelImplementation<SwXTextRange>(xStart);
    SwXTextRange *const pEndRange   =
        ::sw::UnoTunnelGetImplementation<SwXTextRange>(xEndRangeTunnel);
        comphelper::getUnoTunnelImplementation<SwXTextRange>(xEnd);
    // bookmarks have to be removed before the referenced text node
    // is deleted in DelFullPara
    if (pStartRange)
@@ -1735,10 +1726,8 @@
    {
        const uno::Reference<text::XTextCursor> xFrameTextCursor =
            rNewFrame.createTextCursor();
        const uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor,
                uno::UNO_QUERY);
        SwXTextCursor *const pFrameCursor =
            ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xTunnel);
            comphelper::getUnoTunnelImplementation<SwXTextCursor>(xFrameTextCursor);
        if (bParaBeforeInserted)
        {
            // todo: remove paragraph before frame
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index 74ae9f7..9e83aae 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -496,11 +496,7 @@
        // To get to the SwXShape* we need an interface that is implemented by SwXShape

        uno::Reference< beans::XPropertySet > xPropSet( xShape, UNO_QUERY );
        uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
        SwXShape *pSwShape = xTunnel.is() ?
                    reinterpret_cast< SwXShape * >( sal::static_int_cast< sal_IntPtr>(
                    xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
                : nullptr;
        SwXShape *pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(xPropSet);

        OSL_ENSURE( pSwShape, "Where is SW-Shape?" );
        if( pSwShape )
@@ -650,11 +646,7 @@
        }
    }

    uno::Reference< XUnoTunnel> xTunnel( xPropSet, UNO_QUERY );
    SwXShape *pSwShape = xTunnel.is() ?
        reinterpret_cast< SwXShape *>( sal::static_int_cast< sal_IntPtr >(
            xTunnel->getSomething(SwXShape::getUnoTunnelId()) ))
        : nullptr;
    SwXShape *pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(xPropSet);

    OSL_ENSURE( pSwShape, "Where is SW-Shape?" );

diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 1c63358..f940c8e 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1710,9 +1710,7 @@

SwDoc* SwImport::GetDocFromXMLImport( SvXMLImport const & rImport )
{
    uno::Reference<lang::XUnoTunnel> xModelTunnel( rImport.GetModel(), uno::UNO_QUERY );
    SwXTextDocument *pTextDoc = reinterpret_cast< SwXTextDocument *>(
            sal::static_int_cast< sal_IntPtr >(  xModelTunnel->getSomething(SwXTextDocument::getUnoTunnelId() )));
    auto pTextDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(rImport.GetModel());
    assert( pTextDoc );
    assert( pTextDoc->GetDocShell() );
    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
@@ -1723,11 +1721,7 @@
void SwXMLImport::initXForms()
{
    // obtain SwDoc
    Reference<XUnoTunnel> xDocTunnel( GetModel(), UNO_QUERY );
    if( ! xDocTunnel.is() )
        return;
    SwXTextDocument* pXTextDocument = reinterpret_cast<SwXTextDocument*>(
        xDocTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ) );
    auto pXTextDocument = comphelper::getUnoTunnelImplementation<SwXTextDocument>(GetModel());
    if( pXTextDocument == nullptr )
        return;

diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 83e4f1f..2738f47 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -610,8 +610,7 @@
    //now the ViewOptions should be set properly
    Reference< XViewSettingsSupplier >  xSettings(xModel->getCurrentController(), UNO_QUERY);
    m_xViewProperties = xSettings->getViewSettings();
    Reference< XUnoTunnel > xDocTunnel(xModel, UNO_QUERY);
    SwXTextDocument* pXDoc = reinterpret_cast<SwXTextDocument*>(xDocTunnel->getSomething(SwXTextDocument::getUnoTunnelId()));
    auto pXDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel);
    SwDocShell* pDocShell = pXDoc->GetDocShell();
    m_pExampleWrtShell = pDocShell->GetWrtShell();
    OSL_ENSURE(m_pExampleWrtShell, "No SwWrtShell found!");
diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx
index 1401f8a..12f8ad5 100644
--- a/sw/source/ui/index/cntex.cxx
+++ b/sw/source/ui/index/cntex.cxx
@@ -99,8 +99,7 @@
    try
    {
        uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel();
        uno::Reference< lang::XUnoTunnel > xDocTunnel(xModel, uno::UNO_QUERY);
        SwXTextDocument* pDoc = reinterpret_cast<SwXTextDocument*>(xDocTunnel->getSomething(SwXTextDocument::getUnoTunnelId()));
        auto pDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel);

        if( pDoc )
            pDoc->GetDocShell()->LoadStyles_( *m_rWrtShell.GetView().GetDocShell(), true );
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index c8cc0ea..6e787fc 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3908,18 +3908,7 @@

SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData )
{
    SwTransferable* pSwTransferable = nullptr;

    uno::Reference<XUnoTunnel> xTunnel( rData.GetTransferable(), UNO_QUERY );
    if ( xTunnel.is() )
    {
        sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
        if ( nHandle )
            pSwTransferable = reinterpret_cast<SwTransferable*>( static_cast<sal_IntPtr>(nHandle) );
    }

    return pSwTransferable;

    return comphelper::getUnoTunnelImplementation<SwTransferable>(rData.GetTransferable());
}

SwTransferDdeLink::SwTransferDdeLink( SwTransferable& rTrans, SwWrtShell& rSh )
diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx
index fcaf11b..d64a394 100644
--- a/sw/source/uibase/misc/glosdoc.cxx
+++ b/sw/source/uibase/misc/glosdoc.cxx
@@ -20,6 +20,7 @@
#include <algorithm>

#include <com/sun/star/container/XNamed.hpp>
#include <comphelper/servicehelper.hxx>

#include <unotools/transliterationwrapper.hxx>

@@ -457,13 +458,7 @@
                        aLoop != m_aGlossaryEntries.end();
                    )
                {
                    Reference< lang::XUnoTunnel > xEntryTunnel( aLoop->get(), UNO_QUERY );

                    SwXAutoTextEntry* pEntry = nullptr;
                    if ( xEntryTunnel.is() )
                        pEntry = reinterpret_cast< SwXAutoTextEntry* >(
                            xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );

                    auto pEntry = comphelper::getUnoTunnelImplementation<SwXAutoTextEntry>(aLoop->get());
                    if ( pEntry && ( pEntry->GetGroupName() == rGroup ) )
                    {
                        pEntry->Invalidate();
@@ -518,12 +513,7 @@
    // invalidate all the AutoTextEntry-objects
    for (const auto& rEntry : m_aGlossaryEntries)
    {
        Reference< lang::XUnoTunnel > xEntryTunnel( rEntry.get(), UNO_QUERY );
        SwXAutoTextEntry* pEntry = nullptr;
        if ( xEntryTunnel.is() )
            pEntry = reinterpret_cast< SwXAutoTextEntry* >(
                xEntryTunnel->getSomething( SwXAutoTextEntry::getUnoTunnelId() ) );

        auto pEntry = comphelper::getUnoTunnelImplementation<SwXAutoTextEntry>(rEntry.get());
        if ( pEntry )
            pEntry->Invalidate();
    }
@@ -543,12 +533,7 @@
    UnoAutoTextGroups::iterator aSearch = m_aGlossaryGroups.begin();
    for ( ; aSearch != m_aGlossaryGroups.end(); )
    {
        Reference< lang::XUnoTunnel > xGroupTunnel( aSearch->get(), UNO_QUERY );

        SwXAutoTextGroup* pSwGroup = nullptr;
        if ( xGroupTunnel.is() )
            pSwGroup = reinterpret_cast< SwXAutoTextGroup* >( xGroupTunnel->getSomething( SwXAutoTextGroup::getUnoTunnelId() ) );

        auto pSwGroup = comphelper::getUnoTunnelImplementation<SwXAutoTextGroup>(aSearch->get());
        if ( !pSwGroup )
        {
            // the object is dead in the meantime -> remove from cache
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index cf1b229..8aeba791 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -674,8 +674,7 @@
        case FN_REPAGINATE:
            {
                Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
                Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY );
                SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) );
                auto pDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel);
                pDoc->NotifyRefreshListeners();
                rSh.CalcLayout();
            }
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index 7b21309..6f0a0db 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/scanner/XScannerManager2.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <comphelper/propertysequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
@@ -66,15 +67,9 @@

SwView_Impl::~SwView_Impl()
{
    Reference<XUnoTunnel> xDispTunnel(xDisProvInterceptor, UNO_QUERY);
    SwXDispatchProviderInterceptor* pInterceptor = nullptr;
    if(xDispTunnel.is() &&
        nullptr != (pInterceptor = reinterpret_cast< SwXDispatchProviderInterceptor * >(
                    sal::static_int_cast< sal_IntPtr >(
                    xDispTunnel->getSomething(SwXDispatchProviderInterceptor::getUnoTunnelId())))))
    {
    auto pInterceptor = comphelper::getUnoTunnelImplementation<SwXDispatchProviderInterceptor>(xDisProvInterceptor);
    if(pInterceptor)
        pInterceptor->Invalidate();
    }
    view::XSelectionSupplier* pTextView = mxXTextView.get();
    static_cast<SwXTextView*>(pTextView)->Invalidate();
    mxXTextView.clear();
@@ -223,16 +218,9 @@
    GetUNOObject_Impl()->Invalidate();
    for (const auto& xTransferable: mxTransferables)
    {
        Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
        if(xTunnel.is())

        {
            SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
                    sal::static_int_cast< sal_IntPtr >(
                    xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
            if(pTransferable)
                pTransferable->Invalidate();
        }
        auto pTransferable = comphelper::getUnoTunnelImplementation<SwTransferable>(xTransferable.get());
        if(pTransferable)
            pTransferable->Invalidate();
    }
}

diff --git a/sw/source/uibase/uno/SwXFilterOptions.cxx b/sw/source/uibase/uno/SwXFilterOptions.cxx
index 1d7f2d4..2e53ca2 100644
--- a/sw/source/uibase/uno/SwXFilterOptions.cxx
+++ b/sw/source/uibase/uno/SwXFilterOptions.cxx
@@ -80,14 +80,10 @@
    if ( xInputStream.is() )
        pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );

    uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
    SwDocShell* pDocShell = nullptr;
    if(xTunnel.is())
    {
        SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
                sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
        pDocShell = pXDoc ? pXDoc->GetDocShell() : nullptr;
    }
    if (auto pXDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel); pXDoc)
        pDocShell = pXDoc->GetDocShell();

    if(pDocShell)
    {
        SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx
index d5231fa..8ea1a82 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -151,13 +151,8 @@

    // try to get the DocShell
    SwDocShell *pTmpDocShell = nullptr;
    Reference < XUnoTunnel > xTunnel( xTmpModel, UNO_QUERY );
    if (xTunnel.is())
    {
        SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument *>(
                xTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ));
        pTmpDocShell = pTextDoc ? pTextDoc->GetDocShell() : nullptr;
    }
    if (auto pTextDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xTmpModel); pTextDoc)
        pTmpDocShell = pTextDoc->GetDocShell();

    bool bRes = false;
    if (xTmpModel.is() && pTmpDocShell)    // everything available?
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 2759922..dad23f9 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -820,13 +820,11 @@
                                     sal_Int32& nResult,
                                     Reference< XInterface > const & xLastResult)
{
    Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
    if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
    const auto pSearch = comphelper::getUnoTunnelImplementation<SwXTextSearch>(xDesc);
    if(!IsValid() || !pSearch)
        return nullptr;

    auto pUnoCursor(CreateCursorForSearch(xCursor));
    const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
        xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));

    bool bParentInExtra = false;
    if(xLastResult.is())
diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx
index dd96cea..89390a6 100644
--- a/sw/source/uibase/utlui/uiitems.cxx
+++ b/sw/source/uibase/utlui/uiitems.cxx
@@ -248,9 +248,7 @@
    uno::Reference< container::XIndexReplace> xRulesRef;
    if(rVal >>= xRulesRef)
    {
        uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
        SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
                    xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : nullptr;
        auto pSwXRules = comphelper::getUnoTunnelImplementation<SwXNumberingRules>(xRulesRef);
        if(pSwXRules)
        {
            *pRule = *pSwXRules->GetNumRule();
diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx
index 0e529d0b..4023a4b 100644
--- a/sw/source/uibase/utlui/unotools.cxx
+++ b/sw/source/uibase/utlui/unotools.cxx
@@ -46,6 +46,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <sfx2/dispatch.hxx>
#include <svl/stritem.hxx>
#include <shellio.hxx>
@@ -153,14 +154,7 @@
    Color aBgColor = SW_MOD()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor;
    m_xVirDev->DrawWallpaper(tools::Rectangle(Point(), aSize), aBgColor);

    OTextCursorHelper* pCursor = nullptr;
    uno::Reference<lang::XUnoTunnel> xTunnel(m_xCursor, uno::UNO_QUERY);
    if (xTunnel.is())
    {
        pCursor = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething(
                                    OTextCursorHelper::getUnoTunnelId()));
    }

    auto pCursor = comphelper::getUnoTunnelImplementation<OTextCursorHelper>(m_xCursor);
    if (pCursor)
    {
        uno::Reference<view::XViewSettingsSupplier> xSettings(m_xController, uno::UNO_QUERY);
@@ -307,13 +301,7 @@
        //From here, a cursor is defined, which goes through the template,
        //and overwrites the template words where it is necessary.

        OTextCursorHelper* pCursor = nullptr;
        uno::Reference< lang::XUnoTunnel> xTunnel( m_xCursor, uno::UNO_QUERY);
        if (xTunnel.is())
        {
            pCursor = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething(
                                        OTextCursorHelper::getUnoTunnelId()));
        }
        auto pCursor = comphelper::getUnoTunnelImplementation<OTextCursorHelper>(m_xCursor);

        SwDoc *pDoc = pCursor ? pCursor->GetDoc() : nullptr;
        if (pDoc)
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 45a562d..e8b377c 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -24,6 +24,7 @@
#include <impgraph.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <graphic/UnoGraphic.hxx>
#include <vcl/GraphicExternalLink.hxx>
@@ -228,10 +229,7 @@

Graphic::Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic )
{
    uno::Reference< lang::XUnoTunnel >      xTunnel( rxGraphic, uno::UNO_QUERY );
    const ::Graphic*                        pGraphic = ( xTunnel.is() ?
                                                         reinterpret_cast< ::Graphic* >( xTunnel->getSomething( getUnoTunnelId() ) ) :
                                                          nullptr );
    const ::Graphic* pGraphic = comphelper::getUnoTunnelImplementation<::Graphic>(rxGraphic);

    if( pGraphic )
    {