editeng/source/accessibility/AccessibleContextBase.cxx | 2 editeng/source/accessibility/AccessibleEditableTextPara.cxx | 52 +++--------- editeng/source/accessibility/AccessibleImageBullet.cxx | 28 ++---- editeng/source/uno/unofield.cxx | 2 editeng/source/uno/unotext.cxx | 6 - editeng/source/xml/xmltxtexp.cxx | 4 6 files changed, 33 insertions(+), 61 deletions(-)
New commits: commit 678cb270a68efac78db790f6509ae4774e1d25bc Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Apr 23 20:13:31 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Jun 18 09:21:14 2023 +0200 Use getXWeak in editeng Change-Id: If68b80bae13b2e507f8286f6e316d86c0d0255f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150845 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx index 8dad5b1344b4..7143b7151bcf 100644 --- a/editeng/source/accessibility/AccessibleContextBase.cxx +++ b/editeng/source/accessibility/AccessibleContextBase.cxx @@ -494,7 +494,7 @@ void AccessibleContextBase::ThrowIfDisposed() if (rBHelper.bDisposed || rBHelper.bInDispose) { throw lang::DisposedException ("object has been already disposed", - static_cast<uno::XWeak*>(this)); + getXWeak()); } } diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 9ad4ce46de5a..d1e9e5baab52 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -351,16 +351,14 @@ namespace accessibility { if( nIndex < 0 || nIndex >= getCharacterCount() ) throw lang::IndexOutOfBoundsException("AccessibleEditableTextPara: character index out of bounds", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy + getXWeak() ); } void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) { if( nIndex < 0 || nIndex > getCharacterCount() ) throw lang::IndexOutOfBoundsException("AccessibleEditableTextPara: character position out of bounds", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy + getXWeak() ); } void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) @@ -426,9 +424,7 @@ namespace accessibility { if( !mpEditSource ) throw uno::RuntimeException("No edit source, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *mpEditSource; } @@ -439,15 +435,11 @@ namespace accessibility if( !pTextForwarder ) throw uno::RuntimeException("Unable to fetch text forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); if( !pTextForwarder->IsValid() ) throw uno::RuntimeException("Text forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *pTextForwarder; } @@ -459,16 +451,12 @@ namespace accessibility if( !pViewForwarder ) { throw uno::RuntimeException("Unable to fetch view forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } if( !pViewForwarder->IsValid() ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *pViewForwarder; } @@ -481,14 +469,10 @@ namespace accessibility { if( bCreate ) throw uno::RuntimeException("Unable to fetch view forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); else throw uno::RuntimeException("No view forwarder, object not in edit mode", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } if( pTextEditViewForwarder->IsValid() ) @@ -497,14 +481,10 @@ namespace accessibility { if( bCreate ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); else throw uno::RuntimeException("View forwarder is invalid, object not in edit mode", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } } @@ -653,13 +633,11 @@ namespace accessibility if( !HaveChildren() ) throw lang::IndexOutOfBoundsException("No children available", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy + getXWeak() ); if( i != 0 ) throw lang::IndexOutOfBoundsException("Invalid child index", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy + getXWeak() ); auto aChild( maImageBullet.get() ); @@ -759,7 +737,7 @@ namespace accessibility mpParaManager->IsReferencable( nMyParaIndex - 1 ) ) { uno::Sequence<uno::Reference<XInterface> > aSequence - { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().get()) }; + { cppu::getXWeak(mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().get()) }; AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM, aSequence ); pAccRelSetHelper->AddRelation( aAccRel ); @@ -770,7 +748,7 @@ namespace accessibility mpParaManager->IsReferencable( nMyParaIndex + 1 ) ) { uno::Sequence<uno::Reference<XInterface> > aSequence - { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().get()) }; + { cppu::getXWeak(mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().get()) }; AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO, aSequence ); pAccRelSetHelper->AddRelation( aAccRel ); diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx index 55c85d87ff17..c3a051cf01fd 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.cxx +++ b/editeng/source/accessibility/AccessibleImageBullet.cxx @@ -106,8 +106,7 @@ namespace accessibility uno::Reference< XAccessible > SAL_CALL AccessibleImageBullet::getAccessibleChild( sal_Int64 ) { throw lang::IndexOutOfBoundsException("No children available", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy + getXWeak() ); } uno::Reference< XAccessible > SAL_CALL AccessibleImageBullet::getAccessibleParent() @@ -469,9 +468,8 @@ namespace accessibility if( !mpEditSource ) throw uno::RuntimeException("No edit source, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + cppu::getXWeak + ( const_cast< AccessibleImageBullet* > (this) ) ); // disambiguate hierarchy return *mpEditSource; } @@ -483,15 +481,13 @@ namespace accessibility if( !pTextForwarder ) throw uno::RuntimeException("Unable to fetch text forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + cppu::getXWeak + ( const_cast< AccessibleImageBullet* > (this) ) ); // disambiguate hierarchy if( !pTextForwarder->IsValid() ) throw uno::RuntimeException("Text forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + cppu::getXWeak + ( const_cast< AccessibleImageBullet* > (this) ) ); // disambiguate hierarchy return *pTextForwarder; } @@ -504,16 +500,14 @@ namespace accessibility if( !pViewForwarder ) { throw uno::RuntimeException("Unable to fetch view forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + cppu::getXWeak + ( const_cast< AccessibleImageBullet* > (this) ) ); // disambiguate hierarchy } if( !pViewForwarder->IsValid() ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + cppu::getXWeak + ( const_cast< AccessibleImageBullet* > (this) ) ); // disambiguate hierarchy return *pViewForwarder; } diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index 0264e52f0319..237b336b68a1 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -931,7 +931,7 @@ uno::Reference< uno::XInterface > SvxUnoTextCreateTextField( std::u16string_view } if (nId != text::textfield::Type::UNSPECIFIED) - xRet = static_cast<cppu::OWeakObject *>(new SvxUnoTextField( nId )); + xRet = getXWeak(new SvxUnoTextField( nId )); } return xRet; diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index eb18d69903c4..881cfa32cd89 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -2035,7 +2035,7 @@ static void SvxPropertyValuesToItemSet( { const SfxItemPropertyMapEntry *pEntry = pPropSet->getPropertyMap().getByName( rProp.Name ); if (!pEntry) - throw beans::UnknownPropertyException( "Unknown property: " + rProp.Name, static_cast < cppu::OWeakObject * > ( nullptr ) ); + throw beans::UnknownPropertyException( "Unknown property: " + rProp.Name ); // Note: there is no need to take special care of the properties // TextField (EE_FEATURE_FIELD) and // TextPortionType (WID_PORTIONTYPE) @@ -2043,8 +2043,8 @@ static void SvxPropertyValuesToItemSet( if (pEntry->nFlags & beans::PropertyAttribute::READONLY) // should be PropertyVetoException which is not yet defined for the new import API's functions - throw uno::RuntimeException("Property is read-only: " + rProp.Name, static_cast < cppu::OWeakObject * > ( nullptr ) ); - //throw PropertyVetoException ("Property is read-only: " + rProp.Name, static_cast < cppu::OWeakObject * > ( 0 ) ); + throw uno::RuntimeException("Property is read-only: " + rProp.Name ); + //throw PropertyVetoException ("Property is read-only: " + rProp.Name ); if (pEntry->nWID == WID_FONTDESC) { diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index ba31002f9e12..40278457081f 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -135,12 +135,12 @@ uno::Reference< uno::XInterface > SAL_CALL SvxSimpleUnoModel::createInstance( co || aServiceSpecifier == "com.sun.star.text.TextField.DateTime" ) { - return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::DATE )); + return cppu::getXWeak(new SvxUnoTextField( text::textfield::Type::DATE )); } if( aServiceSpecifier == "com.sun.star.text.TextField.URL" ) { - return static_cast<cppu::OWeakObject *>(new SvxUnoTextField(text::textfield::Type::URL)); + return cppu::getXWeak(new SvxUnoTextField(text::textfield::Type::URL)); } return SvxUnoTextCreateTextField( aServiceSpecifier );