a11y: Use OAccessible in AccessibleContextBase et al.
Switch from using the abstract XAccessible UNO interface to using the more concrete OAccessible base class in editeng's AccessibleContextBase and related classes: 1) extract the AccessibleContextBase:getAccessibleParent logic to a new AccessibleContextBase::implGetAccessibleParent helper that returns an OAccessible instead of an XAccessible 2) mark AccessibleContextBase:getAccessibleParent as final to prevent it from being overriden in any child class and ensure the new helper is equivalent, but gives the more concrete OAccessible type 3) switch callers of AccessibleContextBase:getAccessibleParent to call the new AccessibleContextBase::implGetAccessibleParent instead and switch related local variables and class members from XAccessible to OAccessible Change-Id: I570d21fc98dd76bfd198384bf84d1f8407757fab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210928 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -42,9 +42,9 @@ namespace accessibility {
|
||||
// internal
|
||||
|
||||
AccessibleContextBase::AccessibleContextBase (
|
||||
uno::Reference<XAccessible> xParent,
|
||||
const rtl::Reference<comphelper::OAccessible>& rpParent,
|
||||
const sal_Int16 aRole)
|
||||
: mxParent(std::move(xParent)),
|
||||
: mpParent(rpParent),
|
||||
meDescriptionOrigin(NotSet),
|
||||
meNameOrigin(NotSet),
|
||||
maRole(aRole)
|
||||
@@ -170,12 +170,16 @@ uno::Reference<XAccessible> SAL_CALL
|
||||
nullptr);
|
||||
}
|
||||
|
||||
rtl::Reference<comphelper::OAccessible> AccessibleContextBase::implGetAccessibleParent()
|
||||
{
|
||||
ensureAlive();
|
||||
return mpParent;
|
||||
}
|
||||
|
||||
uno::Reference<XAccessible> SAL_CALL
|
||||
AccessibleContextBase::getAccessibleParent()
|
||||
{
|
||||
ensureAlive();
|
||||
return mxParent;
|
||||
return implGetAccessibleParent();
|
||||
}
|
||||
|
||||
sal_Int16 SAL_CALL
|
||||
@@ -256,10 +260,9 @@ lang::Locale SAL_CALL
|
||||
{
|
||||
ensureAlive();
|
||||
// Delegate request to parent.
|
||||
if (mxParent.is())
|
||||
if (mpParent.is())
|
||||
{
|
||||
uno::Reference<XAccessibleContext> xParentContext (
|
||||
mxParent->getAccessibleContext());
|
||||
uno::Reference<XAccessibleContext> xParentContext(mpParent->getAccessibleContext());
|
||||
if (xParentContext.is())
|
||||
return xParentContext->getLocale ();
|
||||
}
|
||||
@@ -309,7 +312,7 @@ void SAL_CALL AccessibleContextBase::disposing()
|
||||
|
||||
comphelper::OAccessible::disposing();
|
||||
|
||||
mxParent.clear();
|
||||
mpParent.clear();
|
||||
mxRelationSet.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,8 @@ public:
|
||||
NotSet
|
||||
};
|
||||
|
||||
AccessibleContextBase (
|
||||
css::uno::Reference< css::accessibility::XAccessible> xParent,
|
||||
const sal_Int16 aRole);
|
||||
AccessibleContextBase(const rtl::Reference<comphelper::OAccessible>& rpParent,
|
||||
const sal_Int16 aRole);
|
||||
virtual ~AccessibleContextBase() override;
|
||||
|
||||
|
||||
@@ -149,8 +148,8 @@ public:
|
||||
getAccessibleChild (sal_Int64 nIndex) override;
|
||||
|
||||
/// Return a reference to the parent.
|
||||
virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
|
||||
getAccessibleParent() override;
|
||||
virtual css::uno::Reference<css::accessibility::XAccessible>
|
||||
SAL_CALL getAccessibleParent() override final;
|
||||
|
||||
/// Return this object's role.
|
||||
virtual sal_Int16 SAL_CALL
|
||||
@@ -204,6 +203,8 @@ public:
|
||||
*/
|
||||
bool IsDisposed() const;
|
||||
|
||||
rtl::Reference<comphelper::OAccessible> implGetAccessibleParent();
|
||||
|
||||
protected:
|
||||
/** The state set.
|
||||
*/
|
||||
@@ -236,7 +237,7 @@ protected:
|
||||
|
||||
private:
|
||||
/// Reference to the parent object.
|
||||
css::uno::Reference< css::accessibility::XAccessible> mxParent;
|
||||
rtl::Reference<comphelper::OAccessible> mpParent;
|
||||
|
||||
/** Description of this object. This is not a constant because it can
|
||||
be set from the outside. Furthermore, it changes according to the
|
||||
|
||||
@@ -56,8 +56,7 @@ public:
|
||||
|
||||
/** The accessible parent object of the shape.
|
||||
*/
|
||||
css::uno::Reference<
|
||||
css::accessibility::XAccessible> mxParent;
|
||||
rtl::Reference<comphelper::OAccessible> mpParent;
|
||||
|
||||
/** This object that may be realized by the same implementation as that
|
||||
of that of <member>mxParent</member> can be used to modify
|
||||
@@ -68,12 +67,9 @@ public:
|
||||
|
||||
/** Copy the given values into the members described above.
|
||||
*/
|
||||
AccessibleShapeInfo (
|
||||
css::uno::Reference<
|
||||
css::drawing::XShape> xShape,
|
||||
css::uno::Reference<
|
||||
css::accessibility::XAccessible> xParent,
|
||||
IAccessibleParent* pChildrenManager);
|
||||
AccessibleShapeInfo(css::uno::Reference<css::drawing::XShape> xShape,
|
||||
const rtl::Reference<comphelper::OAccessible>& rpParent,
|
||||
IAccessibleParent* pChildrenManager);
|
||||
|
||||
/** Copy the given values into the members described above.
|
||||
The accessible parent implementation object is set to NULL.
|
||||
|
||||
@@ -417,7 +417,7 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC
|
||||
{
|
||||
// create the new child
|
||||
rtl::Reference< ::accessibility::AccessibleShape > pReplacement(::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject (
|
||||
::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this ),
|
||||
::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->implGetAccessibleParent(), this ),
|
||||
_rShapeTreeInfo
|
||||
));
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ OUString GetOptionalProperty (
|
||||
// internal
|
||||
AccessibleShape::AccessibleShape(const AccessibleShapeInfo& rShapeInfo,
|
||||
const AccessibleShapeTreeInfo& rShapeTreeInfo)
|
||||
: ImplInheritanceHelper(rShapeInfo.mxParent, AccessibleRole::SHAPE)
|
||||
: ImplInheritanceHelper(rShapeInfo.mpParent, AccessibleRole::SHAPE)
|
||||
, mxShape(rShapeInfo.mxShape)
|
||||
, maShapeTreeInfo(rShapeTreeInfo)
|
||||
, m_nIndexInParent(-1)
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace accessibility {
|
||||
|
||||
AccessibleShapeInfo::AccessibleShapeInfo (
|
||||
css::uno::Reference<css::drawing::XShape> xShape,
|
||||
css::uno::Reference<css::accessibility::XAccessible> xParent,
|
||||
const rtl::Reference<comphelper::OAccessible>& rpParent,
|
||||
IAccessibleParent* pChildrenManager)
|
||||
: mxShape (std::move(xShape)),
|
||||
mxParent (std::move(xParent)),
|
||||
mpParent (rpParent),
|
||||
mpChildrenManager (pChildrenManager)
|
||||
{
|
||||
// empty.
|
||||
@@ -37,7 +37,7 @@ AccessibleShapeInfo::AccessibleShapeInfo (
|
||||
AccessibleShapeInfo::AccessibleShapeInfo(css::uno::Reference<css::drawing::XShape> xShape,
|
||||
const rtl::Reference<comphelper::OAccessible>& rpParent)
|
||||
: mxShape(std::move(xShape))
|
||||
, mxParent(rpParent)
|
||||
, mpParent(rpParent)
|
||||
, mpChildrenManager(nullptr)
|
||||
{
|
||||
// empty.
|
||||
@@ -45,7 +45,7 @@ AccessibleShapeInfo::AccessibleShapeInfo(css::uno::Reference<css::drawing::XShap
|
||||
|
||||
AccessibleShapeInfo::AccessibleShapeInfo (const AccessibleShapeInfo &rOther)
|
||||
: mxShape (rOther.mxShape),
|
||||
mxParent (rOther.mxParent),
|
||||
mpParent (rOther.mpParent),
|
||||
mpChildrenManager (rOther.mpChildrenManager)
|
||||
{
|
||||
// empty.
|
||||
|
||||
@@ -774,7 +774,7 @@ bool ChildrenManagerImpl::ReplaceChild (
|
||||
|
||||
// Replace with replacement and send an event about existence
|
||||
// of the new child.
|
||||
AccessibleShapeInfo aShapeInfo( _rxShape, pCurrentChild->getAccessibleParent(), this );
|
||||
AccessibleShapeInfo aShapeInfo(_rxShape, pCurrentChild->implGetAccessibleParent(), this);
|
||||
// create the new child
|
||||
rtl::Reference<AccessibleShape> pNewChild(ShapeTypeHandler::Instance().CreateAccessibleObject (
|
||||
aShapeInfo,
|
||||
|
||||
@@ -2785,7 +2785,7 @@ bool SwAccessibleMap::ReplaceChild (
|
||||
// we might be the only one that
|
||||
// holds it.
|
||||
// Also get keep parent.
|
||||
uno::Reference < XAccessible > xParent( pCurrentChild->getAccessibleParent() );
|
||||
rtl::Reference<comphelper::OAccessible> pParent = pCurrentChild->implGetAccessibleParent();
|
||||
pCurrentChild = nullptr; // will be released by dispose
|
||||
A11yDispose( nullptr, pObj, nullptr );
|
||||
|
||||
@@ -2795,8 +2795,7 @@ bool SwAccessibleMap::ReplaceChild (
|
||||
// create the new child
|
||||
::accessibility::ShapeTypeHandler& rShapeTypeHandler =
|
||||
::accessibility::ShapeTypeHandler::Instance();
|
||||
::accessibility::AccessibleShapeInfo aShapeInfo(
|
||||
xShape, xParent, this );
|
||||
::accessibility::AccessibleShapeInfo aShapeInfo(xShape, pParent, this);
|
||||
rtl::Reference< ::accessibility::AccessibleShape> pReplacement(
|
||||
rShapeTypeHandler.CreateAccessibleObject (
|
||||
aShapeInfo, mpShapeMap->GetInfo() ));
|
||||
|
||||
Reference in New Issue
Block a user