[Libreoffice-commits] core.git: include/svx sd/source svx/source

Stephan Bergmann sbergman at redhat.com
Thu Nov 28 06:27:48 PST 2013


 include/svx/ChildrenManager.hxx                           |    7 -
 sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx |   57 +++-----------
 sd/source/ui/inc/AccessibleDrawDocumentView.hxx           |    2 
 svx/source/accessibility/ChildrenManager.cxx              |    4 
 svx/source/accessibility/ChildrenManagerImpl.cxx          |    9 +-
 svx/source/accessibility/ChildrenManagerImpl.hxx          |    8 -
 6 files changed, 31 insertions(+), 56 deletions(-)

New commits:
commit 6014e3c98d7f1f767297ff0f0b6f1a3be18b32d0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Nov 28 15:19:55 2013 +0100

    Use rtl::Reference instead of std::auto_ptr
    
    Change-Id: I4402b0b259c0dcd03a222993c861114028d6fb75

diff --git a/include/svx/ChildrenManager.hxx b/include/svx/ChildrenManager.hxx
index c2e6df8..2049ab7 100644
--- a/include/svx/ChildrenManager.hxx
+++ b/include/svx/ChildrenManager.hxx
@@ -24,13 +24,11 @@
 #include <svx/AccessibleShapeTreeInfo.hxx>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
-#include <memory>
 #include <svx/svxdllapi.h>
 
 namespace accessibility {
 
 class AccessibleContextBase;
-class AccessibleShape;
 class ChildrenManagerImpl;
 
 /** The AccessibleChildrenManager class acts as a cache of the
@@ -154,10 +152,9 @@ public:
         be created by the shape factory.  This gives the caller full control
         over object creation.
 
-        @param pShape
-            This class <em>does</em> take ownership of the argument.
+        @param shape must be non-null
     */
-    void AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape);
+    void AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape);
 
     /** Clear the list of accessible shapes which have been added by
         previous calls to <member>AddAccessibleShape</member>.
diff --git a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
index 5dd336d..2c4558a 100644
--- a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
+++ b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
@@ -122,20 +122,11 @@ void AccessibleDrawDocumentView::Init (void)
     mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
     if (mpChildrenManager != NULL)
     {
-        // Create the page shape and initialize it.  The shape is acquired
-        // before initialization and released after transferring ownership
-        // to the children manager to prevent premature disposing of the
-        // shape.
-        AccessiblePageShape* pPage = CreateDrawPageShape();
-        if (pPage != NULL)
+        rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape());
+        if (xPage.is())
         {
-            pPage->acquire();
-            pPage->Init();
-            SAL_WNODEPRECATED_DECLARATIONS_PUSH
-            mpChildrenManager->AddAccessibleShape (
-                std::auto_ptr<AccessibleShape>(pPage));
-            SAL_WNODEPRECATED_DECLARATIONS_POP
-            pPage->release();
+            xPage->Init();
+            mpChildrenManager->AddAccessibleShape (xPage.get());
             mpChildrenManager->Update ();
         }
         mpChildrenManager->UpdateSelection ();
@@ -159,9 +150,9 @@ void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
 /**  The page shape is created on every call at the moment (provided that
      every thing goes well).
 */
-AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
+rtl::Reference<AccessiblePageShape> AccessibleDrawDocumentView::CreateDrawPageShape (void)
 {
-    AccessiblePageShape* pShape = NULL;
+    rtl::Reference<AccessiblePageShape> xShape;
 
     // Create a shape that represents the actual draw page.
     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
@@ -201,12 +192,12 @@ AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
 
                 // Create the accessible object for the shape and
                 // initialize it.
-                pShape = new AccessiblePageShape (
+                xShape = new AccessiblePageShape (
                     xView->getCurrentPage(), this, maShapeTreeInfo);
             }
         }
     }
-    return pShape;
+    return xShape;
 }
 
 
@@ -351,21 +342,12 @@ void SAL_CALL
             mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
                 xView->getCurrentPage(), uno::UNO_QUERY));
 
-            // Create the page shape and initialize it.  The shape is
-            // acquired before initialization and released after
-            // transferring ownership to the children manager to prevent
-            // premature disposing of the shape.
-            AccessiblePageShape* pPage = CreateDrawPageShape ();
-            if (pPage != NULL)
+            rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape ());
+            if (xPage.is())
             {
-                pPage->acquire();
-                pPage->Init();
-                SAL_WNODEPRECATED_DECLARATIONS_PUSH
-                mpChildrenManager->AddAccessibleShape (
-                    std::auto_ptr<AccessibleShape>(pPage));
-                SAL_WNODEPRECATED_DECLARATIONS_POP
+                xPage->Init();
+                mpChildrenManager->AddAccessibleShape (xPage.get());
                 mpChildrenManager->Update (false);
-                pPage->release();
             }
         }
         else
@@ -415,19 +397,12 @@ void SAL_CALL
                     }
                 }
             }
-            // Create the page shape and initialize it.  The shape is
-            // acquired before initialization and released after
-            // transferring ownership to the children manager to prevent
-            // premature disposing of the shape.
-            AccessiblePageShape* pPage = CreateDrawPageShape ();
-            if (pPage != NULL)
+            rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape ());
+            if (xPage.is())
             {
-                pPage->acquire();
-                pPage->Init();
-                mpChildrenManager->AddAccessibleShape (
-                    std::auto_ptr<AccessibleShape>(pPage));
+                xPage->Init();
+                mpChildrenManager->AddAccessibleShape (xPage.get());
                 mpChildrenManager->Update (false);
-                pPage->release();
             }
         }
     }
diff --git a/sd/source/ui/inc/AccessibleDrawDocumentView.hxx b/sd/source/ui/inc/AccessibleDrawDocumentView.hxx
index e82275c..d6a3d02 100644
--- a/sd/source/ui/inc/AccessibleDrawDocumentView.hxx
+++ b/sd/source/ui/inc/AccessibleDrawDocumentView.hxx
@@ -158,7 +158,7 @@ protected:
 
     /** Create a shape the represents the page as seen on the screen.
     */
-    AccessiblePageShape* CreateDrawPageShape (void);
+    rtl::Reference<AccessiblePageShape> CreateDrawPageShape (void);
 
     /// Create an accessible name that contains the current view mode.
     virtual OUString
diff --git a/svx/source/accessibility/ChildrenManager.cxx b/svx/source/accessibility/ChildrenManager.cxx
index 658e1cb..958c08d 100644
--- a/svx/source/accessibility/ChildrenManager.cxx
+++ b/svx/source/accessibility/ChildrenManager.cxx
@@ -111,10 +111,10 @@ void ChildrenManager::SetShapeList (const ::com::sun::star::uno::Reference<
 
 
 
-void ChildrenManager::AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape)
+void ChildrenManager::AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape)
 {
     OSL_ASSERT (mpImpl != NULL);
-    mpImpl->AddAccessibleShape (pShape);
+    mpImpl->AddAccessibleShape (shape);
 }
 
 
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
index 3abce2e..5fe9aef 100644
--- a/svx/source/accessibility/ChildrenManagerImpl.cxx
+++ b/svx/source/accessibility/ChildrenManagerImpl.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cassert>
 
 #include "ChildrenManagerImpl.hxx"
 #include <svx/ShapeTypeHandler.hxx>
@@ -536,10 +539,10 @@ void ChildrenManagerImpl::SetShapeList (const ::com::sun::star::uno::Reference<
 
 
 
-void ChildrenManagerImpl::AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape)
+void ChildrenManagerImpl::AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape)
 {
-    if (pShape.get() != NULL)
-        maAccessibleShapes.push_back (pShape.release());
+    assert(shape.is());
+    maAccessibleShapes.push_back (shape);
 }
 
 
diff --git a/svx/source/accessibility/ChildrenManagerImpl.hxx b/svx/source/accessibility/ChildrenManagerImpl.hxx
index fcc9d7b..30cb9c3 100644
--- a/svx/source/accessibility/ChildrenManagerImpl.hxx
+++ b/svx/source/accessibility/ChildrenManagerImpl.hxx
@@ -26,7 +26,6 @@
 #include <cppuhelper/compbase2.hxx>
 #include <osl/mutex.hxx>
 #include <vector>
-#include <memory>
 #include <com/sun/star/drawing/XShape.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/document/XEventListener.hpp>
@@ -204,10 +203,11 @@ public:
         or the list of visible shapes.  Accessible shapes are, at the
         moment, not tested against the visible area but are always appended
         to the list of visible children.
-        @param pShape
-            The new shape that is added to the list of accessible shapes.
+        @param shape
+            The new shape that is added to the list of accessible shapes; must
+            be non-null.
     */
-    void AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape);
+    void AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape);
 
     /** Clear the lists of accessible shapes and that of visible accessible
         shapes.  The list of UNO shapes is not modified.


More information about the Libreoffice-commits mailing list