framework/inc/helper/statusindicator.hxx | 5 ++-- framework/source/helper/statusindicator.cxx | 35 ++++++++-------------------- package/source/xstor/ohierarchyholder.cxx | 26 ++++++++++---------- package/source/xstor/ohierarchyholder.hxx | 16 +++++++----- package/source/xstor/xstorage.cxx | 20 ++++++++-------- package/source/xstor/xstorage.hxx | 5 +++- 6 files changed, 50 insertions(+), 57 deletions(-)
New commits: commit 91955babdb99cddef764a8467ee7e2e5bfa6f7d3 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 11:40:36 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 19:54:38 2024 +0200 use more concrete UNO types in OStorage Change-Id: Iab01137ad1ad8ea68b5a98ae4c251389a1748da1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168778 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx index b2fb66cfc29e..d8dcb1e70723 100644 --- a/package/source/xstor/ohierarchyholder.cxx +++ b/package/source/xstor/ohierarchyholder.cxx @@ -31,6 +31,7 @@ #include <o3tl/string_view.hxx> #include "ohierarchyholder.hxx" +#include "xstorage.hxx" using namespace ::com::sun::star; @@ -38,7 +39,7 @@ using namespace ::com::sun::star; uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStreamHierarchically( sal_Int32 nStorageMode, std::vector<OUString>& aListPath, sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap& aEncryptionData ) { - uno::Reference< embed::XStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); if ( !( nStorageMode & embed::ElementModes::WRITE ) && ( nStreamMode & embed::ElementModes::WRITE ) ) throw io::IOException(u"invalid storage/stream mode combo"_ustr); @@ -53,7 +54,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStream void OHierarchyHolder_Impl::RemoveStreamHierarchically( std::vector<OUString>& aListPath ) { - uno::Reference< embed::XStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); m_xChild->RemoveStreamHierarchically( aListPath ); } @@ -93,19 +94,19 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea uno::Reference< embed::XExtendedStorageStream > xResult; - uno::Reference< embed::XStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage - : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage + : rtl::Reference< OStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); if ( aListPath.empty() ) { if ( aEncryptionData.empty() ) { - uno::Reference< embed::XHierarchicalStorageAccess > xHStorage( xOwnStor, uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xHStorage( xOwnStor, uno::UNO_QUERY_THROW ); xResult = xHStorage->openStreamElementByHierarchicalName( aNextName, nStreamMode ); } else { - uno::Reference< embed::XHierarchicalStorageAccess2 > xHStorage( xOwnStor, uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xHStorage( xOwnStor, uno::UNO_QUERY_THROW ); xResult = xHStorage->openEncryptedStreamByHierarchicalName( aNextName, nStreamMode, aEncryptionData.getAsConstNamedValueList() ); } @@ -136,7 +137,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea if ( !aElement.is() ) { bNewElement = true; - uno::Reference< embed::XStorage > xChildStorage = xOwnStor->openStorageElement( aNextName, nStorageMode ); + rtl::Reference< OStorage > xChildStorage = xOwnStor->openStorageElement2( aNextName, nStorageMode ); if ( !xChildStorage.is() ) throw uno::RuntimeException(); @@ -170,8 +171,8 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( std::vector<OUString>& OUString aNextName = *(aListPath.begin()); aListPath.erase( aListPath.begin() ); - uno::Reference< embed::XStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage - : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); + rtl::Reference< OStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage + : rtl::Reference< OStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW ); if ( aListPath.empty() ) { @@ -186,7 +187,7 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( std::vector<OUString>& if ( !aElement.is() ) { - uno::Reference< embed::XStorage > xChildStorage = xOwnStor->openStorageElement( aNextName, + rtl::Reference< OStorage > xChildStorage = xOwnStor->openStorageElement2( aNextName, embed::ElementModes::READWRITE ); if ( !xChildStorage.is() ) throw uno::RuntimeException(); @@ -197,9 +198,8 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( std::vector<OUString>& aElement->RemoveStreamHierarchically( aListPath ); } - uno::Reference< embed::XTransactedObject > xTransact( xOwnStor, uno::UNO_QUERY ); - if ( xTransact.is() ) - xTransact->commit(); + if ( xOwnStor.is() ) + xOwnStor->commit(); TestForClosing(); } diff --git a/package/source/xstor/ohierarchyholder.hxx b/package/source/xstor/ohierarchyholder.hxx index c3ceddabd1b1..6ab833870507 100644 --- a/package/source/xstor/ohierarchyholder.hxx +++ b/package/source/xstor/ohierarchyholder.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/embed/XExtendedStorageStream.hpp> #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -35,6 +36,7 @@ #include <vector> class OHierarchyElement_Impl; +class OStorage; typedef std::unordered_map< OUString, ::rtl::Reference< OHierarchyElement_Impl > > OHierarchyElementList_Impl; @@ -47,19 +49,19 @@ class OHierarchyElement_Impl : public cppu::WeakImplHelper< css::embed::XTransac std::mutex m_aMutex; ::rtl::Reference< OHierarchyElement_Impl > m_rParent; - css::uno::Reference< css::embed::XStorage > m_xOwnStorage; - css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage; + rtl::Reference< OStorage > m_xOwnStorage; + unotools::WeakReference< OStorage > m_xWeakOwnStorage; OHierarchyElementList_Impl m_aChildren; OWeakStorRefVector_Impl m_aOpenStreams; public: - explicit OHierarchyElement_Impl( css::uno::Reference< css::embed::XStorage > xStorage ) + explicit OHierarchyElement_Impl(rtl::Reference< OStorage > xStorage ) : m_xOwnStorage(std::move( xStorage )) {} - explicit OHierarchyElement_Impl( css::uno::WeakReference< css::embed::XStorage > xWeakStorage ) + explicit OHierarchyElement_Impl( unotools::WeakReference< OStorage > xWeakStorage ) : m_xWeakOwnStorage(std::move( xWeakStorage )) {} @@ -92,12 +94,12 @@ public: class OHierarchyHolder_Impl : public ::cppu::OWeakObject { - css::uno::WeakReference< css::embed::XStorage > m_xWeakOwnStorage; + unotools::WeakReference< OStorage > m_xWeakOwnStorage; ::rtl::Reference< OHierarchyElement_Impl > m_xChild; public: - explicit OHierarchyHolder_Impl( const css::uno::Reference< css::embed::XStorage >& xOwnStorage ) + explicit OHierarchyHolder_Impl( const rtl::Reference< OStorage >& xOwnStorage ) : m_xWeakOwnStorage( xOwnStorage ) - , m_xChild( new OHierarchyElement_Impl( css::uno::WeakReference< css::embed::XStorage >( xOwnStorage ) ) ) + , m_xChild( new OHierarchyElement_Impl( unotools::WeakReference< OStorage >( xOwnStorage ) ) ) {} static std::vector<OUString> GetListPathFromString( std::u16string_view aPath ); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 1abfdf89be4a..9f72b0fd458a 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -2298,6 +2298,12 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStreamElement( uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement( const OUString& aStorName, sal_Int32 nStorageMode ) +{ + return openStorageElement2(aStorName, nStorageMode); +} + +rtl::Reference< OStorage > OStorage::openStorageElement2( + const OUString& aStorName, sal_Int32 nStorageMode ) { ::osl::MutexGuard aGuard( m_xSharedMutex->GetMutex() ); @@ -2323,7 +2329,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement( // it's always possible to read written storage in this implementation nStorageMode |= embed::ElementModes::READ; - uno::Reference< embed::XStorage > xResult; + rtl::Reference< OStorage > xResult; try { SotElement_Impl *pElement = m_pImpl->FindElement( aStorName ); @@ -2386,8 +2392,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement( pElement->m_xStorage->SetReadOnlyWrap(*pResultStorage); // before the storage disposes the stream it must deregister itself as listener - uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY_THROW ); - MakeLinkToSubComponent_Impl( xStorageComponent ); + MakeLinkToSubComponent_Impl( xResult ); } } catch( const embed::InvalidStorageException& ) @@ -5384,8 +5389,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openStreamEle { // there are still storages in between if ( !m_rHierarchyHolder.is() ) - m_rHierarchyHolder = new OHierarchyHolder_Impl( - uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) ); + m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< OStorage >( this ) ); xResult = m_rHierarchyHolder->GetStreamHierarchically( ( m_pImpl->m_nStorageMode & embed::ElementModes::READWRITE ), @@ -5424,8 +5428,7 @@ void SAL_CALL OStorage::removeStreamElementByHierarchicalName( const OUString& a OSL_ENSURE( aListPath.size(), "The result list must not be empty!" ); if ( !m_rHierarchyHolder.is() ) - m_rHierarchyHolder = new OHierarchyHolder_Impl( - uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) ); + m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< OStorage >( this ) ); m_rHierarchyHolder->RemoveStreamHierarchically( aListPath ); } @@ -5473,8 +5476,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted { // there are still storages in between if ( !m_rHierarchyHolder.is() ) - m_rHierarchyHolder = new OHierarchyHolder_Impl( - uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) ); + m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< OStorage >( this ) ); xResult = m_rHierarchyHolder->GetStreamHierarchically( ( m_pImpl->m_nStorageMode & embed::ElementModes::READWRITE ), diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index 54fe49a9d9ca..3d6186106de1 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -346,7 +346,10 @@ public: const OUString& aStreamName, sal_Int32 nOpenMode, const OUString& aPass ) override; virtual css::uno::Reference< css::embed::XStorage > SAL_CALL openStorageElement( - const OUString& aStorName, sal_Int32 nStorageMode ) override; + const OUString& aStorName, sal_Int32 nStorageMode ) override final; + + rtl::Reference< OStorage > openStorageElement2( + const OUString& aStorName, sal_Int32 nStorageMode ); virtual css::uno::Reference< css::io::XStream > SAL_CALL cloneStreamElement( const OUString& aStreamName ) override; commit 5dc1d4453738876c0576c45b826b9f01d29e8905 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jun 13 11:20:50 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jun 13 19:54:24 2024 +0200 use more concrete UNO types in StatusIndicator Change-Id: I7266cded882bb2d4eb00bdfe565b7c4085c1459d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168777 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/inc/helper/statusindicator.hxx b/framework/inc/helper/statusindicator.hxx index 8d97738d0008..a60a89c1b182 100644 --- a/framework/inc/helper/statusindicator.hxx +++ b/framework/inc/helper/statusindicator.hxx @@ -27,9 +27,10 @@ // include all others #include <cppuhelper/implbase.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace framework{ +class StatusIndicatorFactory; /** @short implement a status indicator object @@ -61,7 +62,7 @@ class StatusIndicator final : public ::cppu::WeakImplHelper< css::task::XStatus will be owned by him. If the frame will be closed he close our factory too ... */ - css::uno::WeakReference< css::task::XStatusIndicatorFactory > m_xFactory; + unotools::WeakReference< StatusIndicatorFactory > m_xFactory; sal_Int32 m_nRange; // We want the callback percentages to increase monotonically diff --git a/framework/source/helper/statusindicator.cxx b/framework/source/helper/statusindicator.cxx index 2deb4a0ae5b2..31c1da7d3e9a 100644 --- a/framework/source/helper/statusindicator.cxx +++ b/framework/source/helper/statusindicator.cxx @@ -41,12 +41,9 @@ void SAL_CALL StatusIndicator::start(const OUString& sText, sal_Int32 nRange) comphelper::LibreOfficeKit::statusIndicatorStart(sText); } #if !defined(IOS) && !defined(ANDROID) - css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory); + rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); if (xFactory.is()) - { - StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get()); - pFactory->start(this, sText, nRange); - } + xFactory->start(this, sText, nRange); #else (void)sText; #endif @@ -59,12 +56,9 @@ void SAL_CALL StatusIndicator::end() comphelper::LibreOfficeKit::statusIndicatorFinish(); } #if !defined(IOS) && !defined(ANDROID) - css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory); + rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); if (xFactory.is()) - { - StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get()); - pFactory->end(this); - } + xFactory->end(this); #endif } @@ -73,12 +67,9 @@ void SAL_CALL StatusIndicator::reset() if (comphelper::LibreOfficeKit::isActive()) return; #if !defined(IOS) && !defined(ANDROID) - css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory); + rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); if (xFactory.is()) - { - StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get()); - pFactory->reset(this); - } + xFactory->reset(this); #endif } @@ -87,12 +78,9 @@ void SAL_CALL StatusIndicator::setText(const OUString& sText) if (comphelper::LibreOfficeKit::isActive()) return; #if !defined(IOS) && !defined(ANDROID) - css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory); + rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); if (xFactory.is()) - { - StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get()); - pFactory->setText(this, sText); - } + xFactory->setText(this, sText); #else (void)sText; #endif @@ -114,12 +102,9 @@ void SAL_CALL StatusIndicator::setValue(sal_Int32 nValue) return; } #if !defined(IOS) && !defined(ANDROID) - css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory); + rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); if (xFactory.is()) - { - StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get()); - pFactory->setValue(this, nValue); - } + xFactory->setValue(this, nValue); #endif }