sw/source/core/access/accdoc.cxx | 296 +++++++++++++++++++------------------- sw/source/core/access/accpara.cxx | 37 ---- sw/source/core/access/accpara.hxx | 8 - 3 files changed, 149 insertions(+), 192 deletions(-)
New commits: commit 9bfcceff0055a2a6e3d1a07cb79a0414e995bd5f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 23 16:17:28 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 24 07:56:12 2025 +0200 sw a11y: Return early in SwAccessibleDocument::getExtendedAttributes ... if `pFeShell` is null. (`git show --ignore-space-change shows the "actual" change more clearly.) Change-Id: I6d5f5b5bf26363fdc97e1868e4f1bf6cf1ceb9a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184511 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index 2b0d48169d23..95798872349c 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -430,192 +430,192 @@ uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes() return anyAttribute; SwFEShell* pFEShell = dynamic_cast<SwFEShell*>(pCursorShell); - if( pFEShell ) + if (!pFEShell) + return anyAttribute; + + OUString sDisplay; + sal_uInt16 nPage, nLogPage; + pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay); + + OUString sValue = "page-name:" + sDisplay + + ";page-number:" + + OUString::number( nPage ) + + ";total-pages:" + + OUString::number( pCursorShell->GetPageCnt() ) + ";"; + + // cursor position relative to the page + Point aCursorPagePos = pFEShell->GetCursorPagePos(); + sValue += "cursor-position-in-page-horizontal:" + OUString::number(aCursorPagePos.getX()) + + ";cursor-position-in-page-vertical:" + OUString::number(aCursorPagePos.getY()) + ";"; + + SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame(); + SwPageFrame* pCurrPage=static_cast<SwFrame*>(pCurrFrame)->FindPageFrame(); + sal_Int32 nLineNum = 0; + SwTextFrame* pTextFrame = nullptr; + SwTextFrame* pCurrTextFrame = nullptr; + pTextFrame = static_cast< SwTextFrame* >(pCurrPage->ContainsContent()); + if (pCurrFrame->IsInFly())//such as, graphic,chart { - OUString sDisplay; - sal_uInt16 nPage, nLogPage; - pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay); - - OUString sValue = "page-name:" + sDisplay + - ";page-number:" + - OUString::number( nPage ) + - ";total-pages:" + - OUString::number( pCursorShell->GetPageCnt() ) + ";"; - - // cursor position relative to the page - Point aCursorPagePos = pFEShell->GetCursorPagePos(); - sValue += "cursor-position-in-page-horizontal:" + OUString::number(aCursorPagePos.getX()) - + ";cursor-position-in-page-vertical:" + OUString::number(aCursorPagePos.getY()) + ";"; - - SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame(); - SwPageFrame* pCurrPage=static_cast<SwFrame*>(pCurrFrame)->FindPageFrame(); - sal_Int32 nLineNum = 0; - SwTextFrame* pTextFrame = nullptr; - SwTextFrame* pCurrTextFrame = nullptr; - pTextFrame = static_cast< SwTextFrame* >(pCurrPage->ContainsContent()); - if (pCurrFrame->IsInFly())//such as, graphic,chart + SwFlyFrame *pFlyFrame = pCurrFrame->FindFlyFrame(); + const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor(); + RndStdIds eAnchorId = rAnchor.GetAnchorId(); + if(eAnchorId == RndStdIds::FLY_AS_CHAR) { - SwFlyFrame *pFlyFrame = pCurrFrame->FindFlyFrame(); - const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor(); - RndStdIds eAnchorId = rAnchor.GetAnchorId(); - if(eAnchorId == RndStdIds::FLY_AS_CHAR) - { - const SwFrame *pSwFrame = pFlyFrame->GetAnchorFrame(); - if(pSwFrame->IsTextFrame()) - pCurrTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pSwFrame)); - } + const SwFrame *pSwFrame = pFlyFrame->GetAnchorFrame(); + if(pSwFrame->IsTextFrame()) + pCurrTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pSwFrame)); } - else + } + else + { + assert(dynamic_cast<SwTextFrame*>(pCurrFrame)); + pCurrTextFrame = static_cast<SwTextFrame* >(pCurrFrame); + } + //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer + SwFrame* pFrame = pCurrTextFrame; + while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() ) + pFrame = pFrame->GetUpper(); + if ( pFrame ) + pCurrTextFrame = nullptr; + //check shape + if(pCursorShell->Imp()->GetDrawView()) + { + const SdrMarkList &rMrkList = pCursorShell->Imp()->GetDrawView()->GetMarkedObjectList(); + for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i ) { - assert(dynamic_cast<SwTextFrame*>(pCurrFrame)); - pCurrTextFrame = static_cast<SwTextFrame* >(pCurrFrame); + SdrObject *pObj = rMrkList.GetMark(i)->GetMarkedSdrObj(); + SwFrameFormat* pFormat = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat(); + const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); + if( RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId() ) + pCurrTextFrame = nullptr; } - //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer - SwFrame* pFrame = pCurrTextFrame; - while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() ) - pFrame = pFrame->GetUpper(); - if ( pFrame ) - pCurrTextFrame = nullptr; - //check shape - if(pCursorShell->Imp()->GetDrawView()) + } + //calculate line number + if (pCurrTextFrame && pTextFrame) + { + if (!(pCurrTextFrame->IsInTab() || pCurrTextFrame->IsInFootnote())) { - const SdrMarkList &rMrkList = pCursorShell->Imp()->GetDrawView()->GetMarkedObjectList(); - for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i ) + while( pTextFrame && pTextFrame != pCurrTextFrame ) { - SdrObject *pObj = rMrkList.GetMark(i)->GetMarkedSdrObj(); - SwFrameFormat* pFormat = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat(); - const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - if( RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId() ) - pCurrTextFrame = nullptr; + //check header/footer + pFrame = pTextFrame; + while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() ) + pFrame = pFrame->GetUpper(); + if ( pFrame ) + { + pTextFrame = static_cast< SwTextFrame*>(pTextFrame->GetNextContentFrame()); + continue; + } + if (!(pTextFrame->IsInTab() || pTextFrame->IsInFootnote() || pTextFrame->IsInFly())) + nLineNum += pTextFrame->GetThisLines(); + pTextFrame = static_cast< SwTextFrame* >(pTextFrame ->GetNextContentFrame()); } - } - //calculate line number - if (pCurrTextFrame && pTextFrame) - { - if (!(pCurrTextFrame->IsInTab() || pCurrTextFrame->IsInFootnote())) + SwPaM* pCaret = pCursorShell->GetCursor(); + if (!pCurrTextFrame->IsEmpty() && pCaret) { - while( pTextFrame && pTextFrame != pCurrTextFrame ) + assert(pCurrTextFrame->IsTextFrame()); + const SwPosition* pPoint = nullptr; + if (pCurrTextFrame->IsInFly()) { - //check header/footer - pFrame = pTextFrame; - while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() ) - pFrame = pFrame->GetUpper(); - if ( pFrame ) - { - pTextFrame = static_cast< SwTextFrame*>(pTextFrame->GetNextContentFrame()); - continue; - } - if (!(pTextFrame->IsInTab() || pTextFrame->IsInFootnote() || pTextFrame->IsInFly())) - nLineNum += pTextFrame->GetThisLines(); - pTextFrame = static_cast< SwTextFrame* >(pTextFrame ->GetNextContentFrame()); + SwFlyFrame *pFlyFrame = pCurrTextFrame->FindFlyFrame(); + const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor(); + pPoint = rAnchor.GetContentAnchor(); + SwContentNode *const pNode(pPoint->GetNode().GetContentNode()); + pCurrTextFrame = pNode + ? static_cast<SwTextFrame*>(pNode->getLayoutFrame( + pCurrTextFrame->getRootFrame(), pPoint)) + : nullptr; } - SwPaM* pCaret = pCursorShell->GetCursor(); - if (!pCurrTextFrame->IsEmpty() && pCaret) + else + pPoint = pCaret->GetPoint(); + if (pCurrTextFrame) { - assert(pCurrTextFrame->IsTextFrame()); - const SwPosition* pPoint = nullptr; - if (pCurrTextFrame->IsInFly()) - { - SwFlyFrame *pFlyFrame = pCurrTextFrame->FindFlyFrame(); - const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor(); - pPoint = rAnchor.GetContentAnchor(); - SwContentNode *const pNode(pPoint->GetNode().GetContentNode()); - pCurrTextFrame = pNode - ? static_cast<SwTextFrame*>(pNode->getLayoutFrame( - pCurrTextFrame->getRootFrame(), pPoint)) - : nullptr; - } - else - pPoint = pCaret->GetPoint(); - if (pCurrTextFrame) - { - TextFrameIndex const nActPos(pCurrTextFrame->MapModelToViewPos(*pPoint)); - nLineNum += pCurrTextFrame->GetLineCount( nActPos ); - } + TextFrameIndex const nActPos(pCurrTextFrame->MapModelToViewPos(*pPoint)); + nLineNum += pCurrTextFrame->GetLineCount( nActPos ); } - else - ++nLineNum; } + else + ++nLineNum; } + } - sValue += "line-number:" + OUString::number( nLineNum ) + ";"; + sValue += "line-number:" + OUString::number( nLineNum ) + ";"; - SwFrame* pCurrCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame(); + SwFrame* pCurrCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame(); - sValue += "column-number:"; + sValue += "column-number:"; - int nCurrCol = 1; - if(pCurrCol!=nullptr) + int nCurrCol = 1; + if(pCurrCol!=nullptr) + { + //SwLayoutFrame* pParent = pCurrCol->GetUpper(); + SwFrame* pCurrPageCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame(); + while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrame()) { - //SwLayoutFrame* pParent = pCurrCol->GetUpper(); - SwFrame* pCurrPageCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame(); - while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrame()) - { - pCurrPageCol = pCurrPageCol->GetUpper(); - } + pCurrPageCol = pCurrPageCol->GetUpper(); + } - SwLayoutFrame* pParent = pCurrPageCol->GetUpper(); + SwLayoutFrame* pParent = pCurrPageCol->GetUpper(); - if(pParent!=nullptr) + if(pParent!=nullptr) + { + SwFrame* pCol = pParent->Lower(); + while(pCol&&(pCol!=pCurrPageCol)) { - SwFrame* pCol = pParent->Lower(); - while(pCol&&(pCol!=pCurrPageCol)) - { - pCol = pCol->GetNext(); - ++nCurrCol; - } + pCol = pCol->GetNext(); + ++nCurrCol; } } - sValue += OUString::number( nCurrCol ) + ";"; + } + sValue += OUString::number( nCurrCol ) + ";"; - const SwFormatCol &rFormatCol=pCurrPage->GetAttrSet()->GetCol(); - sal_uInt16 nColCount=rFormatCol.GetNumCols(); - nColCount = nColCount>0?nColCount:1; - sValue += "total-columns:" + OUString::number( nColCount ) + ";"; + const SwFormatCol &rFormatCol=pCurrPage->GetAttrSet()->GetCol(); + sal_uInt16 nColCount=rFormatCol.GetNumCols(); + nColCount = nColCount>0?nColCount:1; + sValue += "total-columns:" + OUString::number( nColCount ) + ";"; - SwSectionFrame* pCurrSctFrame=static_cast<SwFrame*>(pCurrFrame)->FindSctFrame(); - if(pCurrSctFrame!=nullptr && pCurrSctFrame->GetSection()!=nullptr ) - { - OUString sectionName = pCurrSctFrame->GetSection()->GetSectionName().toString(); + SwSectionFrame* pCurrSctFrame=static_cast<SwFrame*>(pCurrFrame)->FindSctFrame(); + if(pCurrSctFrame!=nullptr && pCurrSctFrame->GetSection()!=nullptr ) + { + OUString sectionName = pCurrSctFrame->GetSection()->GetSectionName().toString(); - sectionName = sectionName.replaceFirst( "\" , "\\" ); - sectionName = sectionName.replaceFirst( "=" , "\=" ); - sectionName = sectionName.replaceFirst( ";" , "\;" ); - sectionName = sectionName.replaceFirst( "," , "\," ); - sectionName = sectionName.replaceFirst( ":" , "\:" ); + sectionName = sectionName.replaceFirst( "\" , "\\" ); + sectionName = sectionName.replaceFirst( "=" , "\=" ); + sectionName = sectionName.replaceFirst( ";" , "\;" ); + sectionName = sectionName.replaceFirst( "," , "\," ); + sectionName = sectionName.replaceFirst( ":" , "\:" ); - sValue += "section-name:" + sectionName + ";"; + sValue += "section-name:" + sectionName + ";"; - //section-columns-number + //section-columns-number - nCurrCol = 1; + nCurrCol = 1; - if(pCurrCol!=nullptr) + if(pCurrCol!=nullptr) + { + SwLayoutFrame* pParent = pCurrCol->GetUpper(); + if(pParent!=nullptr) { - SwLayoutFrame* pParent = pCurrCol->GetUpper(); - if(pParent!=nullptr) + SwFrame* pCol = pParent->Lower(); + while(pCol&&(pCol!=pCurrCol)) { - SwFrame* pCol = pParent->Lower(); - while(pCol&&(pCol!=pCurrCol)) - { - pCol = pCol->GetNext(); - nCurrCol +=1; - } + pCol = pCol->GetNext(); + nCurrCol +=1; } } - sValue += "section-columns-number:" + - OUString::number( nCurrCol ) + ";"; - - //section-total-columns - const SwFormatCol &rFormatSctCol=pCurrSctFrame->GetAttrSet()->GetCol(); - sal_uInt16 nSctColCount=rFormatSctCol.GetNumCols(); - nSctColCount = nSctColCount>0?nSctColCount:1; - sValue += "section-total-columns:" + - OUString::number( nSctColCount ) + ";"; } - - anyAttribute <<= sValue; + sValue += "section-columns-number:" + + OUString::number( nCurrCol ) + ";"; + + //section-total-columns + const SwFormatCol &rFormatSctCol=pCurrSctFrame->GetAttrSet()->GetCol(); + sal_uInt16 nSctColCount=rFormatSctCol.GetNumCols(); + nSctColCount = nSctColCount>0?nSctColCount:1; + sValue += "section-total-columns:" + + OUString::number( nSctColCount ) + ";"; } + + anyAttribute <<= sValue; return anyAttribute; } commit 78ccf4461adcf063cb5a01fa79238577d9ee5174 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 23 16:00:03 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 24 07:56:06 2025 +0200 sw a11y: Drop some unnecessary a11y description handling Apparently since commit f70324bf6e546dc722d518bc09c8cfe98ed8cff6 Author: Jens-Heiner Rechtien <h...@openoffice.org> Date: Tue Nov 9 12:43:28 2004 +0000 INTEGRATION: CWS swqbugfixes08 (1.57.406); FILE MERGED 2004/09/29 07:56:06 od 1.57.406.2: #117970# <SwAccessibleParagraph::GetDescription()> - provide empty description of paragraphs. 2004/09/27 15:00:02 od 1.57.406.1: #117970# <SwAccessibleParagraph::SwAccessibleParagraph()> - set an empty accessible name for paragraphs , the accessible description of Writer paragraphs is always empty. Therefore, drop some code that would only be relevant if it wasn't. Change-Id: I8a1820f9a59ce978754e3b14ba907470680b84b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184510 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 5fe5ca342d58..15451f44b90a 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -123,11 +123,6 @@ OUString const & SwAccessibleParagraph::GetString() return GetPortionData().GetAccessibleString(); } -const OUString & SwAccessibleParagraph::GetDescription() -{ - return EMPTY_OUSTRING; // provide empty description for paragraphs -} - sal_Int32 SwAccessibleParagraph::GetCaretPos() { sal_Int32 nRet = -1; @@ -302,25 +297,6 @@ void SwAccessibleParagraph::InvalidateContent_( bool bVisibleDataFired ) // The role has changed FireAccessibleEvent(AccessibleEventId::ROLE_CHANGED, uno::Any(), uno::Any()); } - - if( sText == sOldText ) - return; - - OUString sNewDesc( GetDescription() ); - OUString sOldDesc; - { - std::scoped_lock aGuard( m_Mutex ); - sOldDesc = m_sDesc; - if( m_sDesc != sNewDesc ) - m_sDesc = sNewDesc; - } - - if( sNewDesc != sOldDesc ) - { - // The text is changed - FireAccessibleEvent(AccessibleEventId::DESCRIPTION_CHANGED, uno::Any(sOldDesc), - uno::Any(sNewDesc)); - } } void SwAccessibleParagraph::InvalidateCursorPos_() @@ -694,14 +670,9 @@ bool SwAccessibleParagraph::GetTextBoundary( OUString SAL_CALL SwAccessibleParagraph::getAccessibleDescription() { SolarMutexGuard aGuard; - ThrowIfDisposed(); - std::scoped_lock aGuard2( m_Mutex ); - if( m_sDesc.isEmpty() ) - m_sDesc = GetDescription(); - - return m_sDesc; + return OUString(); } lang::Locale SAL_CALL SwAccessibleParagraph::getLocale() diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 6265ba52f4b6..38612a586ae8 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -65,8 +65,6 @@ class SwAccessibleParagraph : { friend class SwAccessibleHyperlink; - OUString m_sDesc; // protected by base classes mutex - // data for this paragraph's text portions; this contains the // mapping from the core 'model string' to the accessible text // string. @@ -96,8 +94,6 @@ class SwAccessibleParagraph : /// get the (accessible) text string (requires frame; check before) OUString const & GetString(); - static const OUString & GetDescription(); - // get the current care position sal_Int32 GetCaretPos(); commit 4ad7bd90b20d2f689af3543b32dbec76e78550aa Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Apr 23 15:49:28 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Apr 24 07:55:59 2025 +0200 sw a11y: Drop SwAccessibleParagraph::supportsService The base class implementation SwAccessibleContext::supportsService already does the same. Change-Id: I33595e5922d0658663fce89c6ae55d20188c8642 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184509 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 2fe51641cbf4..5fe5ca342d58 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -859,12 +859,6 @@ OUString SAL_CALL SwAccessibleParagraph::getImplementationName() return sImplementationName; } -sal_Bool SAL_CALL SwAccessibleParagraph::supportsService( - const OUString& sTestServiceName) -{ - return cppu::supportsService(this, sTestServiceName); -} - uno::Sequence< OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames() { return { sServiceName, sAccessibleServiceName }; diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 260b6236db50..6265ba52f4b6 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -269,10 +269,6 @@ public: virtual OUString SAL_CALL getImplementationName() override; - // Return whether the specified service is supported by this class. - virtual sal_Bool SAL_CALL - supportsService (const OUString& sServiceName) override; - // Returns a list of all supported services. In this case that is just // the AccessibleContext service. virtual css::uno::Sequence< OUString> SAL_CALL