chart2/source/controller/dialogs/dlg_CreationWizard.cxx          |    2 
 chart2/source/controller/main/ChartController_EditData.cxx       |    3 
 include/rtl/ref.hxx                                              |   15 +---
 package/source/xstor/ohierarchyholder.cxx                        |   32 
+++-------
 package/source/xstor/ohierarchyholder.hxx                        |   10 +--
 package/source/xstor/xstorage.cxx                                |   18 ++---
 package/source/xstor/xstorage.hxx                                |    2 
 sd/source/ui/framework/configuration/ConfigurationController.cxx |    9 --
 8 files changed, 36 insertions(+), 55 deletions(-)

New commits:
commit 62992442e44787abd5d2fd14fcac9b46856d11d4
Author:     Mike Kaganski <[email protected]>
AuthorDate: Mon Jul 29 09:53:56 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Mon Jul 29 15:21:46 2024 +0200

    Simplify a bit
    
    Change-Id: I0aeb003cd1e1846da729514a39e9190751996fd1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171167
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/package/source/xstor/ohierarchyholder.hxx 
b/package/source/xstor/ohierarchyholder.hxx
index 10e6ca379800..4b6b27ee6e2a 100644
--- a/package/source/xstor/ohierarchyholder.hxx
+++ b/package/source/xstor/ohierarchyholder.hxx
@@ -61,7 +61,7 @@ public:
     : m_xOwnStorage(std::move( xStorage ))
     {}
 
-    explicit OHierarchyElement_Impl( unotools::WeakReference< OStorage > 
xWeakStorage )
+    explicit OHierarchyElement_Impl( unotools::WeakReference< OStorage >&& 
xWeakStorage )
     : m_xWeakOwnStorage(std::move( xWeakStorage ))
     {}
 
@@ -92,12 +92,12 @@ public:
 
 };
 
-class OHierarchyHolder_Impl : public ::cppu::OWeakObject
+class OHierarchyHolder_Impl
 {
     ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
 public:
-    explicit OHierarchyHolder_Impl( const rtl::Reference< OStorage >& 
xOwnStorage )
-    : m_xChild( new OHierarchyElement_Impl( unotools::WeakReference< OStorage 
>( xOwnStorage ) ) )
+    explicit OHierarchyHolder_Impl(unotools::WeakReference<OStorage>&& 
xOwnStorage)
+    : m_xChild( new OHierarchyElement_Impl( std::move(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 9f72b0fd458a..38f713c883fb 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -5388,10 +5388,10 @@ uno::Reference< embed::XExtendedStorageStream > 
SAL_CALL OStorage::openStreamEle
     else
     {
         // there are still storages in between
-        if ( !m_rHierarchyHolder.is() )
-            m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< 
OStorage >( this ) );
+        if (!m_pHierarchyHolder)
+            m_pHierarchyHolder.reset(new OHierarchyHolder_Impl(this));
 
-        xResult = m_rHierarchyHolder->GetStreamHierarchically(
+        xResult = m_pHierarchyHolder->GetStreamHierarchically(
                                                 ( m_pImpl->m_nStorageMode & 
embed::ElementModes::READWRITE ),
                                                 aListPath,
                                                 nOpenMode );
@@ -5427,10 +5427,10 @@ void SAL_CALL 
OStorage::removeStreamElementByHierarchicalName( const OUString& a
     std::vector<OUString> aListPath = 
OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
     OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
 
-    if ( !m_rHierarchyHolder.is() )
-        m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< 
OStorage >( this ) );
+    if (!m_pHierarchyHolder)
+        m_pHierarchyHolder.reset(new OHierarchyHolder_Impl(this));
 
-    m_rHierarchyHolder->RemoveStreamHierarchically( aListPath );
+    m_pHierarchyHolder->RemoveStreamHierarchically(aListPath);
 }
 
 // XHierarchicalStorageAccess2
@@ -5475,10 +5475,10 @@ uno::Reference< embed::XExtendedStorageStream > 
SAL_CALL OStorage::openEncrypted
     else
     {
         // there are still storages in between
-        if ( !m_rHierarchyHolder.is() )
-            m_rHierarchyHolder = new OHierarchyHolder_Impl( rtl::Reference< 
OStorage >( this ) );
+        if (!m_pHierarchyHolder)
+            m_pHierarchyHolder.reset(new OHierarchyHolder_Impl(this));
 
-        xResult = m_rHierarchyHolder->GetStreamHierarchically(
+        xResult = m_pHierarchyHolder->GetStreamHierarchically(
                                                 ( m_pImpl->m_nStorageMode & 
embed::ElementModes::READWRITE ),
                                                 aListPath,
                                                 nOpenMode,
diff --git a/package/source/xstor/xstorage.hxx 
b/package/source/xstor/xstorage.hxx
index 3d6186106de1..93d5f8dd32ae 100644
--- a/package/source/xstor/xstorage.hxx
+++ b/package/source/xstor/xstorage.hxx
@@ -286,7 +286,7 @@ class OStorage final : public css::lang::XTypeProvider
     bool m_bReadOnlyWrap;
     ::rtl::Reference<OChildDispListener_Impl> m_pSubElDispListener;
     ::std::vector< css::uno::WeakReference< css::lang::XComponent > > 
m_aOpenSubComponentsVector;
-    ::rtl::Reference< OHierarchyHolder_Impl > m_rHierarchyHolder;
+    std::unique_ptr<OHierarchyHolder_Impl> m_pHierarchyHolder;
 
     SotElement_Impl* OpenStreamElement_Impl( const OUString& aStreamName, 
sal_Int32 nOpenMode, bool bEncr );
 
commit 18ed2be7f1406b879c1add35f8f86e68202d0876
Author:     Mike Kaganski <[email protected]>
AuthorDate: Mon Jul 29 09:23:41 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Mon Jul 29 15:21:39 2024 +0200

    Prevent rtl::Reference -> css::uno::Reference -> rtl::Reference implicit 
path
    
    Replace up-casting conversion constructor with respective conversion 
operator,
    similar to existing css::uno::Reference conversion operator. Thic change 
will
    not allow code like
    
      rtl::Reference<Foo> foo;
      rtl::Reference<Foo> bar(foo, uno::UNO_QUERY_THROW);
    
    which was possible because compiler could use temporary css::uno::Reference.
    
    Change-Id: I54b79af3e2508b26e9cd59f2cc7e2ae92f6efbbf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171166
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx 
b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
index 12d22805790f..c8e70ac142d2 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
@@ -49,7 +49,7 @@ namespace chart
 CreationWizard::CreationWizard(weld::Window* pParent, const 
rtl::Reference<::chart::ChartModel>& xChartModel,
                                uno::Reference<uno::XComponentContext> xContext)
     : vcl::RoadmapWizardMachine(pParent)
-    , m_xChartModel(xChartModel,uno::UNO_QUERY)
+    , m_xChartModel(xChartModel)
     , m_xComponentContext(std::move(xContext))
     , m_pTemplateProvider(nullptr)
     , m_aTimerTriggeredControllerLock(xChartModel)
diff --git a/chart2/source/controller/main/ChartController_EditData.cxx 
b/chart2/source/controller/main/ChartController_EditData.cxx
index 63577edf3920..1e0c8c3dc96f 100644
--- a/chart2/source/controller/main/ChartController_EditData.cxx
+++ b/chart2/source/controller/main/ChartController_EditData.cxx
@@ -34,8 +34,7 @@ namespace chart
 
 void ChartController::executeDispatch_EditData()
 {
-    rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel(), 
uno::UNO_QUERY );
-    if (xChartDoc.is())
+    if (rtl::Reference<::chart::ChartModel> xChartDoc = getChartModel())
     {
         SolarMutexGuard aSolarGuard;
         UndoLiveUpdateGuardWithData aUndoGuard(
diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx
index 99a7dfccce79..88e67824816e 100644
--- a/include/rtl/ref.hxx
+++ b/include/rtl/ref.hxx
@@ -95,20 +95,15 @@ public:
 #endif
 
 #if defined LIBO_INTERNAL_ONLY
-    /** Up-casting conversion constructor: Copies interface reference.
+    /** Up-casting conversion operator
 
         Does not work for up-casts to ambiguous bases.
-
-        @param rRef another reference
     */
-    template< class derived_type >
-    inline Reference(
-        const Reference< derived_type > & rRef,
-        std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> 
= 0 )
-        : m_pBody (rRef.get())
+    template <class super_type,
+              std::enable_if_t<std::is_base_of_v<super_type, reference_type>, 
int> = 0>
+    inline operator Reference<super_type>() const
     {
-        if (m_pBody)
-            m_pBody->acquire();
+        return Reference<super_type>(m_pBody);
     }
 
     /** Up-casting conversion operator to convert to css::uno::Interface
diff --git a/package/source/xstor/ohierarchyholder.cxx 
b/package/source/xstor/ohierarchyholder.cxx
index d8dcb1e70723..66b8043748ea 100644
--- a/package/source/xstor/ohierarchyholder.cxx
+++ b/package/source/xstor/ohierarchyholder.cxx
@@ -39,8 +39,6 @@ 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 )
 {
-    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);
 
@@ -54,8 +52,6 @@ uno::Reference< embed::XExtendedStorageStream > 
OHierarchyHolder_Impl::GetStream
 
 void OHierarchyHolder_Impl::RemoveStreamHierarchically( std::vector<OUString>& 
aListPath )
 {
-    rtl::Reference< OStorage > xOwnStor( m_xWeakOwnStorage.get(), 
uno::UNO_QUERY_THROW );
-
     m_xChild->RemoveStreamHierarchically( aListPath );
 }
 
@@ -95,20 +91,16 @@ uno::Reference< embed::XExtendedStorageStream > 
OHierarchyElement_Impl::GetStrea
     uno::Reference< embed::XExtendedStorageStream > xResult;
 
     rtl::Reference< OStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
-                : rtl::Reference< OStorage >( m_xWeakOwnStorage.get(), 
uno::UNO_QUERY_THROW );
+                : m_xWeakOwnStorage.get();
+    if (!xOwnStor)
+        throw uno::RuntimeException(u"no own storage"_ustr);
 
     if ( aListPath.empty() )
     {
         if ( aEncryptionData.empty() )
-        {
-            rtl::Reference< OStorage > xHStorage( xOwnStor, 
uno::UNO_QUERY_THROW );
-            xResult = xHStorage->openStreamElementByHierarchicalName( 
aNextName, nStreamMode );
-        }
+            xResult = xOwnStor->openStreamElementByHierarchicalName( 
aNextName, nStreamMode );
         else
-        {
-            rtl::Reference< OStorage > xHStorage( xOwnStor, 
uno::UNO_QUERY_THROW );
-            xResult = xHStorage->openEncryptedStreamByHierarchicalName( 
aNextName, nStreamMode, aEncryptionData.getAsConstNamedValueList() );
-        }
+            xResult = xOwnStor->openEncryptedStreamByHierarchicalName( 
aNextName, nStreamMode, aEncryptionData.getAsConstNamedValueList() );
 
         uno::Reference< embed::XTransactedObject > xTransact( xResult, 
uno::UNO_QUERY );
         if ( xTransact.is() )
@@ -156,7 +148,7 @@ uno::Reference< embed::XExtendedStorageStream > 
OHierarchyElement_Impl::GetStrea
     }
 
     // the subelement was opened successfully, remember the storage to let it 
be locked
-    m_xOwnStorage = xOwnStor;
+    m_xOwnStorage = std::move(xOwnStor);
 
     return xResult;
 }
@@ -172,7 +164,9 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( 
std::vector<OUString>&
     aListPath.erase( aListPath.begin() );
 
     rtl::Reference< OStorage > xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
-                : rtl::Reference< OStorage >( m_xWeakOwnStorage.get(), 
uno::UNO_QUERY_THROW );
+                : m_xWeakOwnStorage.get();
+    if (!xOwnStor)
+        throw uno::RuntimeException(u"no own storage"_ustr);
 
     if ( aListPath.empty() )
     {
@@ -198,8 +192,7 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( 
std::vector<OUString>&
         aElement->RemoveStreamHierarchically( aListPath );
     }
 
-    if ( xOwnStor.is() )
-        xOwnStor->commit();
+    xOwnStor->commit();
 
     TestForClosing();
 }
@@ -208,7 +201,7 @@ void OHierarchyElement_Impl::Commit()
 {
     ::rtl::Reference< OHierarchyElement_Impl > xKeepAlive( this );
     ::rtl::Reference< OHierarchyElement_Impl > aParent;
-    uno::Reference< embed::XStorage > xOwnStor;
+    rtl::Reference<OStorage> xOwnStor;
 
     {
         std::unique_lock aGuard( m_aMutex );
@@ -218,8 +211,7 @@ void OHierarchyElement_Impl::Commit()
 
     if ( xOwnStor.is() )
     {
-        uno::Reference< embed::XTransactedObject > xTransact( xOwnStor, 
uno::UNO_QUERY_THROW );
-        xTransact->commit();
+        xOwnStor->commit();
         if ( aParent.is() )
             aParent->Commit();
     }
diff --git a/package/source/xstor/ohierarchyholder.hxx 
b/package/source/xstor/ohierarchyholder.hxx
index 6ab833870507..10e6ca379800 100644
--- a/package/source/xstor/ohierarchyholder.hxx
+++ b/package/source/xstor/ohierarchyholder.hxx
@@ -94,12 +94,10 @@ public:
 
 class OHierarchyHolder_Impl : public ::cppu::OWeakObject
 {
-    unotools::WeakReference< OStorage > m_xWeakOwnStorage;
     ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
 public:
     explicit OHierarchyHolder_Impl( const rtl::Reference< OStorage >& 
xOwnStorage )
-    : m_xWeakOwnStorage( xOwnStorage )
-    , m_xChild( new OHierarchyElement_Impl( unotools::WeakReference< OStorage 
>( xOwnStorage ) ) )
+    : m_xChild( new OHierarchyElement_Impl( unotools::WeakReference< OStorage 
>( xOwnStorage ) ) )
     {}
 
     static std::vector<OUString> GetListPathFromString( std::u16string_view 
aPath );
diff --git a/sd/source/ui/framework/configuration/ConfigurationController.cxx 
b/sd/source/ui/framework/configuration/ConfigurationController.cxx
index fb8a320fdfc4..25102a5428a4 100644
--- a/sd/source/ui/framework/configuration/ConfigurationController.cxx
+++ b/sd/source/ui/framework/configuration/ConfigurationController.cxx
@@ -54,8 +54,6 @@ public:
         ConfigurationController& rController,
         const rtl::Reference<::sd::DrawController>& rxController);
 
-    rtl::Reference<::sd::DrawController> mxControllerManager;
-
     /** The Broadcaster class implements storing and calling of listeners.
     */
     std::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
@@ -502,14 +500,13 @@ void ConfigurationController::ThrowIfDisposed () const
 ConfigurationController::Implementation::Implementation (
     ConfigurationController& rController,
     const rtl::Reference<::sd::DrawController>& rxController)
-    : mxControllerManager(rxController, UNO_QUERY_THROW),
-      
mpBroadcaster(std::make_shared<ConfigurationControllerBroadcaster>(&rController)),
+    : 
mpBroadcaster(std::make_shared<ConfigurationControllerBroadcaster>(&rController)),
       mxRequestedConfiguration(new Configuration(&rController, true)),
-      
mpResourceFactoryContainer(std::make_shared<ResourceFactoryManager>(mxControllerManager)),
+      
mpResourceFactoryContainer(std::make_shared<ResourceFactoryManager>(rxController)),
       mpResourceManager(
           
std::make_shared<ConfigurationControllerResourceManager>(mpResourceFactoryContainer,mpBroadcaster)),
       mpConfigurationUpdater(
-          std::make_shared<ConfigurationUpdater>(mpBroadcaster, 
mpResourceManager,mxControllerManager)),
+          std::make_shared<ConfigurationUpdater>(mpBroadcaster, 
mpResourceManager,rxController)),
       mpQueueProcessor(new 
ChangeRequestQueueProcessor(mpConfigurationUpdater)),
       mnLockCount(0)
 {

Reply via email to