Kaydet (Commit) 6014e3c9 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use rtl::Reference instead of std::auto_ptr

Change-Id: I4402b0b259c0dcd03a222993c861114028d6fb75
üst dc664990
...@@ -24,13 +24,11 @@ ...@@ -24,13 +24,11 @@
#include <svx/AccessibleShapeTreeInfo.hxx> #include <svx/AccessibleShapeTreeInfo.hxx>
#include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/XShapes.hpp>
#include <memory>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
namespace accessibility { namespace accessibility {
class AccessibleContextBase; class AccessibleContextBase;
class AccessibleShape;
class ChildrenManagerImpl; class ChildrenManagerImpl;
/** The AccessibleChildrenManager class acts as a cache of the /** The AccessibleChildrenManager class acts as a cache of the
...@@ -154,10 +152,9 @@ public: ...@@ -154,10 +152,9 @@ public:
be created by the shape factory. This gives the caller full control be created by the shape factory. This gives the caller full control
over object creation. over object creation.
@param pShape @param shape must be non-null
This class <em>does</em> take ownership of the argument.
*/ */
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 /** Clear the list of accessible shapes which have been added by
previous calls to <member>AddAccessibleShape</member>. previous calls to <member>AddAccessibleShape</member>.
......
...@@ -122,20 +122,11 @@ void AccessibleDrawDocumentView::Init (void) ...@@ -122,20 +122,11 @@ void AccessibleDrawDocumentView::Init (void)
mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this); mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
if (mpChildrenManager != NULL) if (mpChildrenManager != NULL)
{ {
// Create the page shape and initialize it. The shape is acquired rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape());
// before initialization and released after transferring ownership if (xPage.is())
// to the children manager to prevent premature disposing of the {
// shape. xPage->Init();
AccessiblePageShape* pPage = CreateDrawPageShape(); mpChildrenManager->AddAccessibleShape (xPage.get());
if (pPage != NULL)
{
pPage->acquire();
pPage->Init();
SAL_WNODEPRECATED_DECLARATIONS_PUSH
mpChildrenManager->AddAccessibleShape (
std::auto_ptr<AccessibleShape>(pPage));
SAL_WNODEPRECATED_DECLARATIONS_POP
pPage->release();
mpChildrenManager->Update (); mpChildrenManager->Update ();
} }
mpChildrenManager->UpdateSelection (); mpChildrenManager->UpdateSelection ();
...@@ -159,9 +150,9 @@ void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType, ...@@ -159,9 +150,9 @@ void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
/** The page shape is created on every call at the moment (provided that /** The page shape is created on every call at the moment (provided that
every thing goes well). 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. // Create a shape that represents the actual draw page.
uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
...@@ -201,12 +192,12 @@ AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void) ...@@ -201,12 +192,12 @@ AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
// Create the accessible object for the shape and // Create the accessible object for the shape and
// initialize it. // initialize it.
pShape = new AccessiblePageShape ( xShape = new AccessiblePageShape (
xView->getCurrentPage(), this, maShapeTreeInfo); xView->getCurrentPage(), this, maShapeTreeInfo);
} }
} }
} }
return pShape; return xShape;
} }
...@@ -351,21 +342,12 @@ void SAL_CALL ...@@ -351,21 +342,12 @@ void SAL_CALL
mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> ( mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
xView->getCurrentPage(), uno::UNO_QUERY)); xView->getCurrentPage(), uno::UNO_QUERY));
// Create the page shape and initialize it. The shape is rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape ());
// acquired before initialization and released after if (xPage.is())
// transferring ownership to the children manager to prevent {
// premature disposing of the shape. xPage->Init();
AccessiblePageShape* pPage = CreateDrawPageShape (); mpChildrenManager->AddAccessibleShape (xPage.get());
if (pPage != NULL)
{
pPage->acquire();
pPage->Init();
SAL_WNODEPRECATED_DECLARATIONS_PUSH
mpChildrenManager->AddAccessibleShape (
std::auto_ptr<AccessibleShape>(pPage));
SAL_WNODEPRECATED_DECLARATIONS_POP
mpChildrenManager->Update (false); mpChildrenManager->Update (false);
pPage->release();
} }
} }
else else
...@@ -415,19 +397,12 @@ void SAL_CALL ...@@ -415,19 +397,12 @@ void SAL_CALL
} }
} }
} }
// Create the page shape and initialize it. The shape is rtl::Reference<AccessiblePageShape> xPage(CreateDrawPageShape ());
// acquired before initialization and released after if (xPage.is())
// transferring ownership to the children manager to prevent
// premature disposing of the shape.
AccessiblePageShape* pPage = CreateDrawPageShape ();
if (pPage != NULL)
{ {
pPage->acquire(); xPage->Init();
pPage->Init(); mpChildrenManager->AddAccessibleShape (xPage.get());
mpChildrenManager->AddAccessibleShape (
std::auto_ptr<AccessibleShape>(pPage));
mpChildrenManager->Update (false); mpChildrenManager->Update (false);
pPage->release();
} }
} }
} }
......
...@@ -158,7 +158,7 @@ protected: ...@@ -158,7 +158,7 @@ protected:
/** Create a shape the represents the page as seen on the screen. /** 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. /// Create an accessible name that contains the current view mode.
virtual OUString virtual OUString
......
...@@ -111,10 +111,10 @@ void ChildrenManager::SetShapeList (const ::com::sun::star::uno::Reference< ...@@ -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); OSL_ASSERT (mpImpl != NULL);
mpImpl->AddAccessibleShape (pShape); mpImpl->AddAccessibleShape (shape);
} }
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <sal/config.h>
#include <cassert>
#include "ChildrenManagerImpl.hxx" #include "ChildrenManagerImpl.hxx"
#include <svx/ShapeTypeHandler.hxx> #include <svx/ShapeTypeHandler.hxx>
...@@ -536,10 +539,10 @@ void ChildrenManagerImpl::SetShapeList (const ::com::sun::star::uno::Reference< ...@@ -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) assert(shape.is());
maAccessibleShapes.push_back (pShape.release()); maAccessibleShapes.push_back (shape);
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <cppuhelper/compbase2.hxx> #include <cppuhelper/compbase2.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <vector> #include <vector>
#include <memory>
#include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventListener.hpp>
...@@ -204,10 +203,11 @@ public: ...@@ -204,10 +203,11 @@ public:
or the list of visible shapes. Accessible shapes are, at the or the list of visible shapes. Accessible shapes are, at the
moment, not tested against the visible area but are always appended moment, not tested against the visible area but are always appended
to the list of visible children. to the list of visible children.
@param pShape @param shape
The new shape that is added to the list of accessible shapes. 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 /** Clear the lists of accessible shapes and that of visible accessible
shapes. The list of UNO shapes is not modified. shapes. The list of UNO shapes is not modified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment