sw/source/uibase/inc/glosdoc.hxx | 3 ++- sw/source/uibase/inc/unoatxt.hxx | 9 +-------- sw/source/uibase/misc/glosdoc.cxx | 12 ++++++------ sw/source/uibase/uno/unoatxt.cxx | 11 ----------- 4 files changed, 9 insertions(+), 26 deletions(-)
New commits: commit 78bef23cc49a3a328f9e9ef38f7c0d0cd05f2ef8 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 20 10:45:34 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Jan 22 11:48:35 2023 +0000 XUnoTunnel->dynamic_cast in SwXAutoTextGroup we can store the underlying type here, which does away with the need for dynamic_cast Change-Id: I9b545f7eb6cbd1d2a81773bc1d80127422a0ed3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145926 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/uibase/inc/glosdoc.hxx b/sw/source/uibase/inc/glosdoc.hxx index 9206a7d02011..f879dc1c7bc5 100644 --- a/sw/source/uibase/inc/glosdoc.hxx +++ b/sw/source/uibase/inc/glosdoc.hxx @@ -37,8 +37,9 @@ typedef tools::SvRef<SwDocShell> SwDocShellRef; #include <swdllapi.h> class SwXAutoTextEntry; +class SwXAutoTextGroup; -typedef std::vector< css::uno::WeakReference< css::text::XAutoTextGroup > > UnoAutoTextGroups; +typedef std::vector< unotools::WeakReference< SwXAutoTextGroup > > UnoAutoTextGroups; typedef std::vector< unotools::WeakReference< SwXAutoTextEntry > > UnoAutoTextEntries; #define GLOS_DELIM u'*' diff --git a/sw/source/uibase/inc/unoatxt.hxx b/sw/source/uibase/inc/unoatxt.hxx index 15e66d063095..48f0c8137994 100644 --- a/sw/source/uibase/inc/unoatxt.hxx +++ b/sw/source/uibase/inc/unoatxt.hxx @@ -23,7 +23,6 @@ #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/text/XAutoTextGroup.hpp> #include <com/sun/star/text/XAutoTextEntry.hpp> #include <com/sun/star/text/XAutoTextContainer2.hpp> @@ -90,8 +89,7 @@ class SwXAutoTextGroup final : public cppu::WeakImplHelper css::beans::XPropertySet, css::lang::XServiceInfo, css::container::XIndexAccess, - css::container::XNamed, - css::lang::XUnoTunnel + css::container::XNamed > { const SfxItemPropertySet* m_pPropSet; @@ -104,11 +102,6 @@ class SwXAutoTextGroup final : public cppu::WeakImplHelper public: SwXAutoTextGroup(const OUString& rName, SwGlossaries* pGloss); - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - //XAutoTextGroup virtual css::uno::Sequence< OUString > SAL_CALL getTitles() override; virtual void SAL_CALL renameByName(const OUString& aElementName, const OUString& aNewElementName, const OUString& aNewElementTitle) override; diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 474d643acf97..119646d7f6d5 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -436,14 +436,14 @@ void SwGlossaries::RemoveFileFromList( const OUString& rGroup ) aLoop != m_aGlossaryGroups.end(); ) { - Reference< container::XNamed > xNamed( aLoop->get(), UNO_QUERY ); + rtl::Reference< SwXAutoTextGroup > xNamed( aLoop->get() ); if ( !xNamed.is() ) { aLoop = m_aGlossaryGroups.erase(aLoop); } else if ( xNamed->getName() == rGroup ) { - static_cast< SwXAutoTextGroup* >( xNamed.get() )->Invalidate(); + xNamed->Invalidate(); // note that this static_cast works because we know that the array only // contains SwXAutoTextGroup implementation m_aGlossaryGroups.erase( aLoop ); @@ -502,9 +502,9 @@ void SwGlossaries::InvalidateUNOOjects() // invalidate all the AutoTextGroup-objects for (const auto& rGroup : m_aGlossaryGroups) { - Reference< text::XAutoTextGroup > xGroup( rGroup.get(), UNO_QUERY ); + rtl::Reference< SwXAutoTextGroup > xGroup( rGroup.get() ); if ( xGroup.is() ) - static_cast< SwXAutoTextGroup* >( xGroup.get() )->Invalidate(); + xGroup->Invalidate(); } UnoAutoTextGroups().swap(m_aGlossaryGroups); @@ -524,13 +524,13 @@ Reference< text::XAutoTextGroup > SwGlossaries::GetAutoTextGroup( std::u16string // first, find the name with path-extension const OUString sCompleteGroupName = GetCompleteGroupName( _rGroupName ); - Reference< text::XAutoTextGroup > xGroup; + rtl::Reference< SwXAutoTextGroup > xGroup; // look up the group in the cache UnoAutoTextGroups::iterator aSearch = m_aGlossaryGroups.begin(); for ( ; aSearch != m_aGlossaryGroups.end(); ) { - auto pSwGroup = comphelper::getFromUnoTunnel<SwXAutoTextGroup>(aSearch->get()); + rtl::Reference<SwXAutoTextGroup> pSwGroup = aSearch->get(); if ( !pSwGroup ) { // the object is dead in the meantime -> remove from cache diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index cb0166062af2..3f11446ab59e 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -205,17 +205,6 @@ uno::Sequence< OUString > SwXAutoTextContainer::getSupportedServiceNames() return { "com.sun.star.text.AutoTextContainer" }; } -const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSwXAutoTextGroupUnoTunnelId; - return theSwXAutoTextGroupUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - SwXAutoTextGroup::SwXAutoTextGroup(const OUString& rName, SwGlossaries* pGlos) : m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_AUTO_TEXT_GROUP)),