sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx | 59 ++++++-------- sd/source/ui/inc/AccessibleDocumentViewBase.hxx | 3 2 files changed, 29 insertions(+), 33 deletions(-)
New commits: commit 3f5a3b89ecb437315e50d87bf155483e79c64ec1 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Mar 5 14:03:16 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Mar 6 07:16:42 2026 +0100 sd a11y: Switch to override new extended attr helper Override the OAccessible::implGetExtendedAttributes base class method newly introduced in Change-Id: Ie66f135fbf6cdc98c7cdca27fa3f5fe7db7f9a74 Author: Michael Weghorn <[email protected]> Date: Thu Mar 5 12:12:45 2026 +0100 a11y: Introduce helper to implement XAccessibleExtendedAttributes logic instead of manually implementing XAccessibleExtendedAttributes::getExtendedAttributes, to unify/deduplicate the string concatenation and locking logic by having it implemented (only) in the base class implementation. The handling for the "note" attribute looks a bit suspicious because it uses a semicolon as a separate for the different paragraphs (see the "//to divide each paragraph" comment), but that is also the character used to separate attributes in the string returned by XAccessibleExtendedAttributes::getExtendedAttributes. For now, leave the semicolon as is, but consider the whole concatenated string the value for the "note" attribute anyway. Change-Id: I1a9d9c8c5545edd526229855302dbeab1b06dc7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201040 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx index a28fbf8d62c2..a8f2f2c71eb2 100644 --- a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx +++ b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx @@ -573,15 +573,12 @@ void { } -OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() +std::unordered_map<OUString, OUString> AccessibleDocumentViewBase::implGetExtendedAttributes() { - ::osl::MutexGuard aGuard (m_aMutex); - - OUStringBuffer sValue; + std::unordered_map<OUString, OUString> aAttributes; if (auto pDrViewSh = dynamic_cast<::sd::DrawViewShell* > (mpViewShell)) { OUString sDisplay; - static constexpr OUString sName = u"page-name:"_ustr; // MT IA2: Not used... // SdPage* pCurrPge = pDrViewSh->getCurrentPage(); SdDrawDocument* pDoc = pDrViewSh->GetDoc(); @@ -591,15 +588,16 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() sDisplay = sDisplay.replaceFirst( ";", "\;" ); sDisplay = sDisplay.replaceFirst( ",", "\," ); sDisplay = sDisplay.replaceFirst( ":", "\:" ); - sValue = sName + sDisplay - + ";page-number:" - + OUString::number(static_cast<sal_Int32>(static_cast<sal_uInt16>((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) - + ";total-pages:" - + OUString::number(static_cast<sal_Int32>(pDrViewSh->GetPageTabControl().GetPageCount())) - + ";"; + aAttributes + = { { u"page-name"_ustr, sDisplay }, + { u"page-number"_ustr, + OUString::number(static_cast<sal_Int32>( + static_cast<sal_uInt16>((pDrViewSh->getCurrentPage()->GetPageNum() - 1) >> 1) + + 1)) }, + { u"total-pages"_ustr, OUString::number(static_cast<sal_Int32>( + pDrViewSh->GetPageTabControl().GetPageCount())) } }; if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #i87182# { - sValue = sName; OUString sLayerName(pDrViewSh->GetLayerTabControl()->GetLayerName(pDrViewSh->GetLayerTabControl()->GetCurPageId()) ); sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId()); if( pDoc ) @@ -620,12 +618,12 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() sDisplay = sDisplay.replaceFirst( ";", "\;" ); sDisplay = sDisplay.replaceFirst( ",", "\," ); sDisplay = sDisplay.replaceFirst( ":", "\:" ); - sValue.append(sDisplay - + ";page-number:" - + OUString::number(static_cast<sal_Int32>(pDrViewSh->GetActiveTabLayerIndex()+1)) - + ";total-pages:" - + OUString::number(static_cast<sal_Int32>(pDrViewSh->GetLayerTabControl()->GetPageCount())) - + ";"); + aAttributes = { { u"page-name"_ustr, sDisplay }, + { u"page-number"_ustr, OUString::number(static_cast<sal_Int32>( + pDrViewSh->GetActiveTabLayerIndex() + 1)) }, + { u"total-pages"_ustr, + OUString::number(static_cast<sal_Int32>( + pDrViewSh->GetLayerTabControl()->GetPageCount())) } }; } } if (auto pPresViewSh = dynamic_cast<::sd::PresentationViewShell* >(mpViewShell)) @@ -641,7 +639,7 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject(); if (pPara) { - sValue.append("note:"); + OUStringBuffer aNoteValue; const EditTextObject& rEdit = pPara->GetTextObject(); for (sal_Int32 i=0;i<rEdit.GetParagraphCount();i++) { @@ -651,9 +649,9 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() strNote = strNote.replaceFirst( ";", "\;" ); strNote = strNote.replaceFirst( ",", "\," ); strNote = strNote.replaceFirst( ":", "\:" ); - sValue.append(strNote - + ";");//to divide each paragraph + aNoteValue.append(strNote + ";"); //to divide each paragraph } + aAttributes.emplace(u"note"_ustr, aNoteValue.makeStringAndClear()); } } } @@ -670,16 +668,17 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() sDisplay = sDisplay.replaceFirst( ";", "\;" ); sDisplay = sDisplay.replaceFirst( ",", "\," ); sDisplay = sDisplay.replaceFirst( ":", "\:" ); - sValue = "page-name:" + sDisplay - + ";page-number:" - + OUString::number(static_cast<sal_Int32>(static_cast<sal_uInt16>((pCurrPge->GetPageNum()-1)>>1) + 1)) - + ";total-pages:" - + OUString::number(static_cast<sal_Int32>(pDoc->GetSdPageCount(PageKind::Standard))) - + ";"; + aAttributes + = { { u"page-name"_ustr, sDisplay }, + { u"page-number"_ustr, + OUString::number(static_cast<sal_Int32>( + static_cast<sal_uInt16>((pCurrPge->GetPageNum() - 1) >> 1) + 1)) }, + { u"total-pages"_ustr, OUString::number(static_cast<sal_Int32>( + pDoc->GetSdPageCount(PageKind::Standard))) } }; } } - return sValue.makeStringAndClear(); + return aAttributes; } sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground( ) diff --git a/sd/source/ui/inc/AccessibleDocumentViewBase.hxx b/sd/source/ui/inc/AccessibleDocumentViewBase.hxx index 9c9d1fc969e1..77d7c620c729 100644 --- a/sd/source/ui/inc/AccessibleDocumentViewBase.hxx +++ b/sd/source/ui/inc/AccessibleDocumentViewBase.hxx @@ -143,6 +143,7 @@ public: // OAccessible virtual css::awt::Rectangle implGetBounds() override; + virtual std::unordered_map<OUString, OUString> implGetExtendedAttributes() override; //===== XAccessibleComponent ============================================ @@ -190,8 +191,6 @@ public: virtual void SAL_CALL focusGained (const css::awt::FocusEvent& e) override; virtual void SAL_CALL focusLost (const css::awt::FocusEvent& e) override; - //----------------------------xAttribute---------------------------- - virtual OUString SAL_CALL getExtendedAttributes() override; ::sd::ViewShell* mpViewShell; private: commit 897c4bcad9e049e2c41d61166583f550befca70f Author: Michael Weghorn <[email protected]> AuthorDate: Thu Mar 5 13:41:53 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Mar 6 07:16:34 2026 +0100 sd a11y: Avoid unnecessarily reassigning to local string var Avoid reassigning to local var sName without reason. (Initial motivation was to avoid confusion/make this more readable). The first reassignment assigns the same value "page-name:" that the variable already has. The second reassignment isn't needed either because the " " string can just be used as is; it seems completely unrelated to what sName is there for otherwise. Change-Id: Iaf0667ea0170570659c49c4495fec5b0c905f53d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201039 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx index 8716ea2adc2c..a28fbf8d62c2 100644 --- a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx +++ b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx @@ -581,7 +581,7 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() if (auto pDrViewSh = dynamic_cast<::sd::DrawViewShell* > (mpViewShell)) { OUString sDisplay; - OUString sName = u"page-name:"_ustr; + static constexpr OUString sName = u"page-name:"_ustr; // MT IA2: Not used... // SdPage* pCurrPge = pDrViewSh->getCurrentPage(); SdDrawDocument* pDoc = pDrViewSh->GetDoc(); @@ -599,7 +599,6 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() + ";"; if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #i87182# { - sName = "page-name:"; sValue = sName; OUString sLayerName(pDrViewSh->GetLayerTabControl()->GetLayerName(pDrViewSh->GetLayerTabControl()->GetCurPageId()) ); sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId()); @@ -612,8 +611,7 @@ OUString SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes() const OUString& layerAltText = aSdrLayer->GetTitle(); if (!layerAltText.isEmpty()) { - sName = " "; - sDisplay += sName + layerAltText; + sDisplay += u" " + layerAltText; } } }
