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 @@
#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>.
......
......@@ -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();
}
}
}
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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.
......
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