diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-09-22 18:20:39 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-09-23 15:47:12 +0200 |
commit | 1d398fb983d8f8b53a78e7c47b588fc1f1e7f748 (patch) | |
tree | 89e11384ea13d73b3c1dc198c5fee8675036abbe /sw | |
parent | cd6780aae1392d4c1af0b15b311a4966834a9602 (diff) |
tdf#39593 use getUnoTunnelImplementation
Change-Id: I78eb67913a568c610e38e5002f914773c4906dfd
Reviewed-on: https://gerrit.libreoffice.org/79350
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sw')
24 files changed, 67 insertions, 221 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 41a4e79655ec..b03a2a03b8f7 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -1102,14 +1102,7 @@ bool SwFormatCol::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 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 4078784fef11..7e26bceb4397 100644 --- a/sw/source/core/layout/dumpfilter.cxx +++ b/sw/source/core/layout/dumpfilter.cxx @@ -87,8 +87,7 @@ namespace sw 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 895cf5b7e5c3..11efa6a692ec 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1602,37 +1602,30 @@ void SwChartDataProvider::AddRowCols( 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) + { + // add rows: extend affected columns by newly added row cells + pDataSeq->ExtendTo( true, nFirstNewRow, nLines ); + } + else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS) { - 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 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 5ac8ff1a5a45..0b0555b94c11 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -772,15 +772,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) 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 be29668a6b40..35d35b635ee0 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -898,11 +898,7 @@ SwXShape::SwXShape( 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 @@ void SwXShape::AddExistingShapeToFormat( SdrObject const & _rObj ) 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 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a 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 @@ uno::Sequence< OUString > SwXShape::getSupportedServiceNames() 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 @@ void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition ) // #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 77eeb295e189..81906e1c4c60 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1729,10 +1729,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& 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 2c5766ecebf9..dc47a6d5dac2 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2921,13 +2921,7 @@ SwXTextCursor::createEnumeration() 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 2230e40d014c..004de650992d 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1035,10 +1035,8 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, { 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 24cb9c5213bc..d69f7ab1ad10 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -710,9 +710,8 @@ SwXMeta::CreateXMeta(::sw::Meta & rMeta, { 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 34060acf60e1..02c07eac0b1e 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1025,13 +1025,9 @@ void XStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement 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 @@ const uno::Sequence<sal_Int8>& SwXStyle::getUnoTunnelId() 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 65ca22480557..e012e630198f 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -634,10 +634,8 @@ SwXText::insertTextContentBefore( 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 @@ SwXText::insertTextContentAfter( 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 @@ bool SwXText::Impl::CheckForOwnMember( { 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 @@ SwXText::convertToTextFrame( 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 @@ SwXText::convertToTextFrame( { 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 74ae9f78b1a9..9e83aae9cd13 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -496,11 +496,7 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height ) // 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 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha } } - 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 1c633585c8d1..f940c8eb3ff1 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1710,9 +1710,7 @@ void SwXMLImport::initialize( 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 @@ SwDoc* SwImport::GetDocFromXMLImport( SvXMLImport const & rImport ) 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 83e4f1f0868d..2738f470821c 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -610,8 +610,7 @@ IMPL_LINK_NOARG(SwMailMergeLayoutPage, PreviewLoadedHdl_Impl, SwOneExampleFrame& //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 1401f8a6b1fd..12f8ad5abd1f 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -99,8 +99,7 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame&, void 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 c8cc0ea74d9d..6e787fc8a323 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -3908,18 +3908,7 @@ sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId ) 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 fcaf11b7e126..d64a39456d45 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 @@ void SwGlossaries::RemoveFileFromList( const OUString& rGroup ) 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 @@ void SwGlossaries::InvalidateUNOOjects() // 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 @@ Reference< text::XAutoTextGroup > SwGlossaries::GetAutoTextGroup( const OUString 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 cf1b2296ca80..8aeba7910d5c 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -674,8 +674,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) 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 7b2130939798..6f0a0db5f938 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(SwView* pShell) 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 @@ void SwView_Impl::Invalidate() 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 1d7f2d403acb..2e53ca270d03 100644 --- a/sw/source/uibase/uno/SwXFilterOptions.cxx +++ b/sw/source/uibase/uno/SwXFilterOptions.cxx @@ -80,14 +80,10 @@ sal_Int16 SwXFilterOptions::execute() 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 d5231fa826ce..8ea1a82934d6 100644 --- a/sw/source/uibase/uno/unomailmerge.cxx +++ b/sw/source/uibase/uno/unomailmerge.cxx @@ -151,13 +151,8 @@ static bool LoadFromURL_impl( // 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 2759922dd303..dad23f90c389 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -820,13 +820,11 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > 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 dd96cea07bcc..89390a6735a4 100644 --- a/sw/source/uibase/utlui/uiitems.cxx +++ b/sw/source/uibase/utlui/uiitems.cxx @@ -248,9 +248,7 @@ bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) 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 0e529d0b8bb1..4023a4bb1847 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 @@ void SwOneExampleFrame::Paint(vcl::RenderContext& rRenderContext, const tools::R 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 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void ) //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) |