Simplify SwAccessible*

Change-Id: I2994161bfa8fa3a88b3e66a9f4f12e4de6d5b025
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178096
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-12-08 21:07:07 +05:00
parent 76cf7c6fc0
commit 045a98c9ee
10 changed files with 33 additions and 358 deletions

View file

@ -98,7 +98,7 @@ void SwAccessibleCell::GetStates( sal_Int64& rStateSet )
SwAccessibleCell::SwAccessibleCell(std::shared_ptr<SwAccessibleMap> const& pInitMap,
const SwCellFrame *pCellFrame )
: SwAccessibleContext( pInitMap, AccessibleRole::TABLE_CELL, pCellFrame )
: SwAccessibleCell_BASE(pInitMap, AccessibleRole::TABLE_CELL, pCellFrame)
, m_aSelectionHelper( *this )
, m_bIsSelected( false )
{
@ -271,49 +271,6 @@ void SwAccessibleCell::InvalidatePosOrSize( const SwRect& rOldBox )
SwAccessibleContext::InvalidatePosOrSize( rOldBox );
}
// XAccessibleInterface
uno::Any SwAccessibleCell::queryInterface( const uno::Type& rType )
{
if (rType == cppu::UnoType<XAccessibleExtendedAttributes>::get())
{
uno::Any aR;
aR <<= uno::Reference<XAccessibleExtendedAttributes>(this);
return aR;
}
if (rType == cppu::UnoType<XAccessibleSelection>::get())
{
uno::Any aR;
aR <<= uno::Reference<XAccessibleSelection>(this);
return aR;
}
if ( rType == ::cppu::UnoType<XAccessibleValue>::get() )
{
uno::Reference<XAccessibleValue> xValue = this;
uno::Any aRet;
aRet <<= xValue;
return aRet;
}
else
{
return SwAccessibleContext::queryInterface( rType );
}
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SwAccessibleCell::getTypes()
{
return cppu::OTypeCollection(
::cppu::UnoType<XAccessibleValue>::get(),
SwAccessibleContext::getTypes() ).getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleCell::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
// XAccessibleValue
SwFrameFormat* SwAccessibleCell::GetTableBoxFormat() const

View file

@ -27,10 +27,11 @@ class SwCellFrame;
class SwAccessibleTable;
class SwFrameFormat;
class SwAccessibleCell : public SwAccessibleContext,
public css::accessibility::XAccessibleValue,
public css::accessibility::XAccessibleSelection,
public css::accessibility::XAccessibleExtendedAttributes
using SwAccessibleCell_BASE = cppu::ImplInheritanceHelper<SwAccessibleContext,
css::accessibility::XAccessibleValue,
css::accessibility::XAccessibleSelection,
css::accessibility::XAccessibleExtendedAttributes>;
class SwAccessibleCell : public SwAccessibleCell_BASE
{
// Implementation for XAccessibleSelection interface
SwAccessibleSelectionHelper m_aSelectionHelper;
@ -83,24 +84,6 @@ public:
virtual void InvalidatePosOrSize( const SwRect& rFrame ) override;
// XInterface
// (XInterface methods need to be implemented to disambiguate
// between those inherited through SwAccessibleContext and
// XAccessibleValue).
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) noexcept override
{ SwAccessibleContext::acquire(); };
virtual void SAL_CALL release( ) noexcept override
{ SwAccessibleContext::release(); };
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
// XAccessibleExtendedAttributes
css::uno::Any SAL_CALL getExtendedAttributes() override ;
private:

View file

@ -346,7 +346,7 @@ void SwAccessibleDocument::GetStates( sal_Int64& rStateSet )
SwAccessibleDocument::SwAccessibleDocument(
std::shared_ptr<SwAccessibleMap> const& pInitMap)
: SwAccessibleDocumentBase(pInitMap)
: SwAccessibleDocument_BASE(pInitMap)
, maSelectionHelper(*this)
{
SetName(pInitMap->GetDocName());
@ -433,40 +433,6 @@ uno::Sequence< OUString > SAL_CALL SwAccessibleDocument::getSupportedServiceName
return { sServiceName, sAccessibleServiceName };
}
// XInterface
uno::Any SwAccessibleDocument::queryInterface(
const uno::Type& rType )
{
uno::Any aRet;
if ( rType == cppu::UnoType<XAccessibleSelection>::get() )
{
uno::Reference<XAccessibleSelection> aSelect = this;
aRet <<= aSelect;
}
else if ( rType == cppu::UnoType<XAccessibleExtendedAttributes>::get())
{
uno::Reference<XAccessibleExtendedAttributes> aAttribute = this;
aRet <<= aAttribute;
}
else
aRet = SwAccessibleContext::queryInterface( rType );
return aRet;
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SwAccessibleDocument::getTypes()
{
return cppu::OTypeCollection(
cppu::UnoType<XAccessibleSelection>::get(),
SwAccessibleDocumentBase::getTypes() ).getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleDocument::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
// XAccessibleSelection
void SwAccessibleDocument::selectAccessibleChild(

View file

@ -86,12 +86,13 @@ public:
virtual css::awt::Size SAL_CALL getSize() override;
};
using SwAccessibleDocument_BASE = cppu::ImplInheritanceHelper<SwAccessibleDocumentBase,
css::accessibility::XAccessibleSelection,
css::accessibility::XAccessibleExtendedAttributes>;
/**
* access to an accessible Writer document
*/
class SwAccessibleDocument : public SwAccessibleDocumentBase,
public css::accessibility::XAccessibleSelection,
public css::accessibility::XAccessibleExtendedAttributes
class SwAccessibleDocument : public SwAccessibleDocument_BASE
{
// Implementation for XAccessibleSelection interface
SwAccessibleSelectionHelper maSelectionHelper;
@ -123,25 +124,6 @@ public:
virtual css::uno::Sequence< OUString> SAL_CALL
getSupportedServiceNames() override;
// XInterface
// XInterface is inherited through SwAccessibleContext and
// XAccessibleSelection. These methods are needed to avoid
// ambiguities.
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) noexcept override
{ SwAccessibleContext::acquire(); };
virtual void SAL_CALL release( ) noexcept override
{ SwAccessibleContext::release(); };
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
// XAccessibleSelection
virtual void SAL_CALL selectAccessibleChild(

View file

@ -58,7 +58,7 @@ SwAccessibleNoTextFrame::SwAccessibleNoTextFrame(
std::shared_ptr<SwAccessibleMap> const& pInitMap,
sal_Int16 nInitRole,
const SwFlyFrame* pFlyFrame ) :
SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrame )
SwAccessibleNoTextFrame_BASE( pInitMap, nInitRole, pFlyFrame )
{
const SwNoTextNode* pNd = GetNoTextNode();
// #i73249#
@ -157,34 +157,6 @@ OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription()
return msDesc;
}
// XInterface
uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType )
{
if( aType ==
::cppu::UnoType<XAccessibleImage>::get() )
{
uno::Reference<XAccessibleImage> xImage = this;
return uno::Any(xImage);
}
else if ( aType == cppu::UnoType<XAccessibleHypertext>::get())
{
uno::Reference<XAccessibleHypertext> aAccHypertext = this;
return uno::Any( aAccHypertext );
}
else
return SwAccessibleContext::queryInterface( aType );
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes()
{
return cppu::OTypeCollection(
::cppu::UnoType<XAccessibleImage>::get(),
SwAccessibleFrameBase::getTypes() ).getTypes();
}
/// XAccessibleImage
/** implementation of the XAccessibleImage methods is a no-brainer, as
all relevant information is already accessible through other

View file

@ -29,9 +29,10 @@ class SwFlyFrame;
class SwNoTextNode;
class SwAccessibleNoTextHyperlink;
class SwAccessibleNoTextFrame : public SwAccessibleFrameBase,
public css::accessibility::XAccessibleImage,
public css::accessibility::XAccessibleHypertext//Added by yangzhh for HyperLink
using SwAccessibleNoTextFrame_BASE = cppu::ImplInheritanceHelper<SwAccessibleFrameBase,
css::accessibility::XAccessibleImage,
css::accessibility::XAccessibleHypertext>;
class SwAccessibleNoTextFrame : public SwAccessibleNoTextFrame_BASE
{
friend class SwAccessibleNoTextHyperlink;
rtl::Reference< SwAccessibleNoTextHyperlink > m_xHyperlink;
@ -60,22 +61,6 @@ public:
virtual OUString SAL_CALL
getAccessibleDescription() override;
// XInterface methods need to be implemented to disambiguate
// between those inherited through SwAccessibleContext and
// XAccessibleImage.
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) noexcept override
{ SwAccessibleContext::acquire(); };
virtual void SAL_CALL release( ) noexcept override
{ SwAccessibleContext::release(); };
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
// XAccessibleImage
virtual OUString SAL_CALL
getAccessibleImageDescription( ) override;

View file

@ -403,7 +403,7 @@ void SwAccessibleParagraph::InvalidateFocus_()
SwAccessibleParagraph::SwAccessibleParagraph(
std::shared_ptr<SwAccessibleMap> const& pInitMap,
const SwTextFrame& rTextFrame )
: SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
: SwAccessibleParagraph_BASE(pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame)
, m_nOldCaretPos( -1 )
, m_bIsBlockQuote(false)
, m_bIsHeading( false )
@ -931,89 +931,6 @@ static uno::Sequence< OUString > const & getSupplementalAttributeNames()
return aNames;
}
// XInterface
uno::Any SwAccessibleParagraph::queryInterface( const uno::Type& rType )
{
uno::Any aRet;
if ( rType == cppu::UnoType<XAccessibleText>::get())
{
uno::Reference<XAccessibleText> aAccText = static_cast<XAccessibleText *>(*this); // resolve ambiguity
aRet <<= aAccText;
}
else if ( rType == cppu::UnoType<XAccessibleEditableText>::get())
{
uno::Reference<XAccessibleEditableText> aAccEditText = this;
aRet <<= aAccEditText;
}
else if ( rType == cppu::UnoType<XAccessibleSelection>::get())
{
uno::Reference<XAccessibleSelection> aAccSel = this;
aRet <<= aAccSel;
}
else if ( rType == cppu::UnoType<XAccessibleHypertext>::get())
{
uno::Reference<XAccessibleHypertext> aAccHyp = this;
aRet <<= aAccHyp;
}
// #i63870#
// add interface com::sun:star:accessibility::XAccessibleTextAttributes
else if ( rType == cppu::UnoType<XAccessibleTextAttributes>::get())
{
uno::Reference<XAccessibleTextAttributes> aAccTextAttr = this;
aRet <<= aAccTextAttr;
}
// #i89175#
// add interface com::sun:star:accessibility::XAccessibleTextMarkup
else if ( rType == cppu::UnoType<XAccessibleTextMarkup>::get())
{
uno::Reference<XAccessibleTextMarkup> aAccTextMarkup = this;
aRet <<= aAccTextMarkup;
}
// add interface com::sun:star:accessibility::XAccessibleMultiLineText
else if ( rType == cppu::UnoType<XAccessibleMultiLineText>::get())
{
uno::Reference<XAccessibleMultiLineText> aAccMultiLineText = this;
aRet <<= aAccMultiLineText;
}
else if ( rType == cppu::UnoType<XAccessibleTextSelection>::get())
{
uno::Reference< css::accessibility::XAccessibleTextSelection > aTextExtension = this;
aRet <<= aTextExtension;
}
else if ( rType == cppu::UnoType<XAccessibleExtendedAttributes>::get())
{
uno::Reference<XAccessibleExtendedAttributes> xAttr = this;
aRet <<= xAttr;
}
else
{
aRet = SwAccessibleContext::queryInterface(rType);
}
return aRet;
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SwAccessibleParagraph::getTypes()
{
// #i63870# - add type accessibility::XAccessibleTextAttributes
// #i89175# - add type accessibility::XAccessibleTextMarkup and
return cppu::OTypeCollection(
cppu::UnoType<XAccessibleEditableText>::get(),
cppu::UnoType<XAccessibleTextAttributes>::get(),
::cppu::UnoType<XAccessibleSelection>::get(),
cppu::UnoType<XAccessibleTextMarkup>::get(),
cppu::UnoType<XAccessibleMultiLineText>::get(),
cppu::UnoType<XAccessibleHypertext>::get(),
SwAccessibleContext::getTypes() ).getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleParagraph::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
// XAccessibleText
sal_Int32 SwAccessibleParagraph::getCaretPosition()

View file

@ -50,17 +50,18 @@ namespace com::sun::star {
typedef std::unordered_map< OUString,
css::beans::PropertyValue > tAccParaPropValMap;
using SwAccessibleParagraph_BASE = cppu::ImplInheritanceHelper<SwAccessibleContext,
css::accessibility::XAccessibleEditableText,
css::accessibility::XAccessibleSelection,
css::accessibility::XAccessibleHypertext,
css::accessibility::XAccessibleTextMarkup,
css::accessibility::XAccessibleMultiLineText,
css::accessibility::XAccessibleTextAttributes,
css::accessibility::XAccessibleTextSelection,
css::accessibility::XAccessibleExtendedAttributes>;
class SwAccessibleParagraph :
public SfxListener,
public SwAccessibleContext,
public css::accessibility::XAccessibleEditableText,
public css::accessibility::XAccessibleSelection,
public css::accessibility::XAccessibleHypertext,
public css::accessibility::XAccessibleTextMarkup,
public css::accessibility::XAccessibleMultiLineText,
public css::accessibility::XAccessibleTextAttributes,
public css::accessibility::XAccessibleTextSelection,
public css::accessibility::XAccessibleExtendedAttributes
public SwAccessibleParagraph_BASE
{
friend class SwAccessibleHyperlink;
@ -279,25 +280,6 @@ public:
virtual css::uno::Sequence< OUString> SAL_CALL
getSupportedServiceNames() override;
// XInterface
// (XInterface methods need to be implemented to disambiguate
// between those inherited through SwAccessibleContext and
// XAccessibleEditableText).
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) noexcept override
{ SwAccessibleContext::acquire(); };
virtual void SAL_CALL release( ) noexcept override
{ SwAccessibleContext::release(); };
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
// XAccessibleText
virtual sal_Int32 SAL_CALL getCaretPosition() override;
virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override;

View file

@ -608,7 +608,7 @@ void SwAccessibleTable::GetStates( sal_Int64& rStateSet )
SwAccessibleTable::SwAccessibleTable(
std::shared_ptr<SwAccessibleMap> const& pInitMap,
const SwTabFrame* pTabFrame ) :
SwAccessibleContext( pInitMap, AccessibleRole::TABLE, pTabFrame )
SwAccessibleTable_BASE( pInitMap, AccessibleRole::TABLE, pTabFrame )
{
const SwFrameFormat* pFrameFormat = pTabFrame->GetFormat();
StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier());
@ -667,46 +667,6 @@ void SwAccessibleTable::Notify(const SfxHint& rHint)
}
}
uno::Any SwAccessibleTable::queryInterface( const uno::Type& rType )
{
uno::Any aRet;
if ( rType == cppu::UnoType<XAccessibleTable>::get() )
{
uno::Reference<XAccessibleTable> xThis( this );
aRet <<= xThis;
}
else if ( rType == cppu::UnoType<XAccessibleSelection>::get() )
{
uno::Reference<XAccessibleSelection> xSelection( this );
aRet <<= xSelection;
}
else if ( rType == cppu::UnoType<XAccessibleTableSelection>::get() )
{
uno::Reference<XAccessibleTableSelection> xTableExtent( this );
aRet <<= xTableExtent;
}
else
{
aRet = SwAccessibleContext::queryInterface(rType);
}
return aRet;
}
// XTypeProvider
uno::Sequence< uno::Type > SAL_CALL SwAccessibleTable::getTypes()
{
return cppu::OTypeCollection(
cppu::UnoType<XAccessibleSelection>::get(),
cppu::UnoType<XAccessibleTable>::get(),
SwAccessibleContext::getTypes() ).getTypes();
}
uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTable::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
// #i77106#
std::unique_ptr<SwAccessibleTableData_Impl> SwAccessibleTable::CreateNewTableData()
{
@ -1647,12 +1607,6 @@ void SwAccessibleTableColHeaders::Notify(const SfxHint& )
{
}
// XInterface
uno::Any SAL_CALL SwAccessibleTableColHeaders::queryInterface( const uno::Type& aType )
{
return SwAccessibleTable::queryInterface( aType );
}
// XAccessibleContext
sal_Int64 SAL_CALL SwAccessibleTableColHeaders::getAccessibleChildCount()
{

View file

@ -38,11 +38,12 @@ namespace sw::access {
class SwAccessibleChild;
}
using SwAccessibleTable_BASE = cppu::ImplInheritanceHelper<SwAccessibleContext,
css::accessibility::XAccessibleTable,
css::accessibility::XAccessibleSelection,
css::accessibility::XAccessibleTableSelection>;
class SwAccessibleTable :
public SwAccessibleContext,
public css::accessibility::XAccessibleTable,
public css::accessibility::XAccessibleSelection,
public css::accessibility::XAccessibleTableSelection,
public SwAccessibleTable_BASE,
public SvtListener
{
std::unique_ptr<SwAccessibleTableData_Impl> mpTableData; // the table's data, protected by SolarMutex
@ -95,25 +96,6 @@ public:
SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
const SwTabFrame* pTableFrame);
// XInterface
// (XInterface methods need to be implemented to disambiguate
// between those inherited through SwAccessibleContext and
// XAccessibleTable).
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType ) override;
virtual void SAL_CALL acquire( ) noexcept override
{ SwAccessibleContext::acquire(); };
virtual void SAL_CALL release( ) noexcept override
{ SwAccessibleContext::release(); };
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
// XAccessibleContext
/// Return this object's description.
@ -244,11 +226,6 @@ public:
SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,
const SwTabFrame *pTabFrame);
// XInterface
virtual css::uno::Any SAL_CALL queryInterface(
const css::uno::Type& aType ) override;
// XAccessibleContext
/// Return the number of currently visible children.