diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-14 08:19:47 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-15 06:07:36 +0200 |
commit | 05bc93db2de56000f65764d7e394d03747cac23d (patch) | |
tree | 975de9ae83572aac8a5c3ea8db281e1017ee5be0 /editeng | |
parent | 8cbb414ed737f9ffc76e1258e6671769bf63fc6c (diff) |
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 1
The header got some changes:
1. Move UnoTunnelIdInit and isUnoTunnelId into 'comphelper' namespace
2. Rename UnoTunnelIdInit to UnoIdInit, as a precondition to replace
of uses of OImplementationId with it, including in XTypeProvider
3. Introduce convenience functions 'getSomething_cast' to cast between
sal_Int64 and object pointers uniformly.
4. Rename getUnoTunnelImplementation to getFromUnoTunnel, both to make
it a bit shorter, and to reflect its function better. Templatize it
to take also css::uno::Any for convenience.
5. Introduce getSomethingImpl, inspired by sw::UnoTunnelImpl; allow it
handle cases both with and without fallback to parent.
6. Adjust UNO3_GETIMPLEMENTATION_* macros
TODO (in separate commits):
- Drop sw::UnoTunnelImpl and sw::UnoTunnelGetImplementation
- Replace all uses of OImplementationId in core with UnoIdInit
- Deprecate OImplementationId in <cppuhelper/typeprovider.hxx>
- Change implementations of getSomething to use getSomethingImpl
- Revise uses of getSomething to use getFromUnoTunnel
Change-Id: If4a3cb024130f1f552f988f0479589da1cd066e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122022
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/uno/unofield.cxx | 6 | ||||
-rw-r--r-- | editeng/source/uno/unonrule.cxx | 6 | ||||
-rw-r--r-- | editeng/source/uno/unotext.cxx | 28 | ||||
-rw-r--r-- | editeng/source/uno/unotext2.cxx | 2 |
4 files changed, 21 insertions, 21 deletions
diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index c2b0aa5bdd8d..efe9165ea647 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -231,13 +231,13 @@ static tools::Time setTime( util::DateTime const & rDate ) const css::uno::Sequence< sal_Int8 > & SvxUnoTextField::getUnoTunnelId() noexcept { - static const UnoTunnelIdInit theSvxUnoTextFieldUnoTunnelId; + static const comphelper::UnoIdInit theSvxUnoTextFieldUnoTunnelId; return theSvxUnoTextFieldUnoTunnelId.getSeq(); } sal_Int64 SAL_CALL SvxUnoTextField::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { - if( isUnoTunnelId<SvxUnoTextField>(rId) ) + if( comphelper::isUnoTunnelId<SvxUnoTextField>(rId) ) { return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); } @@ -654,7 +654,7 @@ OUString SAL_CALL SvxUnoTextField::getPresentation( sal_Bool bShowCommand ) // Interface text::XTextContent void SAL_CALL SvxUnoTextField::attach( const uno::Reference< text::XTextRange >& xTextRange ) { - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRange>( xTextRange ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xTextRange ); if(pRange == nullptr) throw lang::IllegalArgumentException(); diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index 9f861b7f9c2a..5ac7c4c1ba41 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -474,7 +474,7 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex(const Sequence<beans::Propert const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > const & xRule ) { - SvxUnoNumberingRules* pRule = comphelper::getUnoTunnelImplementation<SvxUnoNumberingRules>( xRule ); + SvxUnoNumberingRules* pRule = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( xRule ); if( pRule == nullptr ) throw IllegalArgumentException(); @@ -509,10 +509,10 @@ sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 ) if( x1.get() == x2.get() ) return 0; - SvxUnoNumberingRules* pRule1 = comphelper::getUnoTunnelImplementation<SvxUnoNumberingRules>( x1 ); + SvxUnoNumberingRules* pRule1 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x1 ); if( pRule1 ) { - SvxUnoNumberingRules* pRule2 = comphelper::getUnoTunnelImplementation<SvxUnoNumberingRules>( x2 ); + SvxUnoNumberingRules* pRule2 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x2 ); if( pRule2 ) { const SvxNumRule& rRule1 = pRule1->getNumRule(); diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 76537f8b425b..7696a5dbd648 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -312,7 +312,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart() { CheckSelection( maSelection, pForwarder ); - SvxUnoTextBase* pText = comphelper::getUnoTunnelImplementation<SvxUnoTextBase>( getText() ); + SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() ); if(pText == nullptr) throw uno::RuntimeException(); @@ -340,7 +340,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd() { CheckSelection( maSelection, pForwarder ); - SvxUnoTextBase* pText = comphelper::getUnoTunnelImplementation<SvxUnoTextBase>( getText() ); + SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() ); if(pText == nullptr) throw uno::RuntimeException(); @@ -1453,8 +1453,8 @@ uno::Sequence< OUString > SvxUnoTextRangeBase::getSupportedServiceNames_Static() // XTextRangeCompare sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) { - SvxUnoTextRangeBase* pR1 = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( xR1 ); - SvxUnoTextRangeBase* pR2 = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( xR2 ); + SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 ); + SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 ); if( (pR1 == nullptr) || (pR2 == nullptr) ) throw lang::IllegalArgumentException(); @@ -1477,8 +1477,8 @@ sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Referenc sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) { - SvxUnoTextRangeBase* pR1 = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( xR1 ); - SvxUnoTextRangeBase* pR2 = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( xR2 ); + SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 ); + SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 ); if( (pR1 == nullptr) || (pR2 == nullptr) ) throw lang::IllegalArgumentException(); @@ -1688,7 +1688,7 @@ uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByR if( aTextPosition.is() ) { - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( aTextPosition ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( aTextPosition ); if(pRange) xCursor = createTextCursorBySelection( pRange->GetSelection() ); } @@ -1703,7 +1703,7 @@ void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRan if( !xRange.is() ) return; - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRange>( xRange ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); if(!pRange) return; @@ -1750,7 +1750,7 @@ void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text } case text::ControlCharacter::LINE_BREAK: { - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRange>( xRange ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); if(pRange) { ESelection aRange = pRange->GetSelection(); @@ -1781,7 +1781,7 @@ void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text } case text::ControlCharacter::APPEND_PARAGRAPH: { - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRange>( xRange ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); if(pRange) { ESelection aRange = pRange->GetSelection(); @@ -2135,13 +2135,13 @@ uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Stat const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() noexcept { - static const UnoTunnelIdInit theSvxUnoTextBaseUnoTunnelId; + static const comphelper::UnoIdInit theSvxUnoTextBaseUnoTunnelId; return theSvxUnoTextBaseUnoTunnelId.getSeq(); } sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) { - if( isUnoTunnelId<SvxUnoTextBase>(rId) ) + if( comphelper::isUnoTunnelId<SvxUnoTextBase>(rId) ) { return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); } @@ -2209,13 +2209,13 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId( ) const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() noexcept { - static const UnoTunnelIdInit theSvxUnoTextUnoTunnelId; + static const comphelper::UnoIdInit theSvxUnoTextUnoTunnelId; return theSvxUnoTextUnoTunnelId.getSeq(); } sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) { - if( isUnoTunnelId<SvxUnoText>(rId) ) + if( comphelper::isUnoTunnelId<SvxUnoText>(rId) ) { return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); } diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx index 8ff342d915bb..12b56ca4c68e 100644 --- a/editeng/source/uno/unotext2.cxx +++ b/editeng/source/uno/unotext2.cxx @@ -554,7 +554,7 @@ void SAL_CALL SvxUnoTextCursor::gotoRange( const uno::Reference< text::XTextRang if( !xRange.is() ) return; - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( xRange ); + SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xRange ); if( !pRange ) return; |