sw/inc/AccessibilityCheckStrings.hrc | 1 sw/inc/OnlineAccessibilityCheck.hxx | 6 ++++ sw/source/core/access/AccessibilityCheck.cxx | 25 +++++++++-------- sw/source/core/access/AccessibilityIssue.cxx | 28 ++++++++++++++++++-- sw/source/core/inc/AccessibilityIssue.hxx | 1 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx | 24 ++++++++++++++++- sw/source/uibase/uiview/view2.cxx | 3 +- 7 files changed, 72 insertions(+), 16 deletions(-)
New commits: commit 24b0b51daa7ea6c3698dc80ef18aee1f65bb49f9 Author: Balazs Varga <[email protected]> AuthorDate: Tue Jun 20 15:38:40 2023 +0200 Commit: Samuel Mehrbrodt <[email protected]> CommitDate: Mon Jun 26 09:25:31 2023 +0200 tdf#155503 - A11Y sidebar: Add quick fix action to set document title Add fix button to set the document title. Fix updates issue of document level changes. Change-Id: Ibab5cab3b595de4df68c3022a5864b2d2d4bed2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153352 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <[email protected]> (cherry picked from commit 5f4f37dac2a4c95f0e164870c4b2dbfe30f8ec4a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153511 diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 12e2e1fa2b8d..0efaee64ca4b 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -40,6 +40,7 @@ #define STR_DOCUMENT_DEFAULT_LANGUAGE NC_("STR_DOCUMENT_DEFAULT_LANGUAGE", "Document default language is not set.") #define STR_STYLE_NO_LANGUAGE NC_("STR_STYLE_NO_LANGUAGE", "Style “%STYLE_NAME%” has no language set.") #define STR_DOCUMENT_TITLE NC_("STR_DOCUMENT_TITLE", "Document title is not set.") +#define STR_ENTER_DOCUMENT_TITLE NC_("STR_ENTER_DOCUMENT_TITLE", "Enter document title:") #define STR_ENTER_ALT NC_("STR_ENTER_ALT", "Enter alternative text:") diff --git a/sw/inc/OnlineAccessibilityCheck.hxx b/sw/inc/OnlineAccessibilityCheck.hxx index fc158e28db7e..1055c7e67d53 100644 --- a/sw/inc/OnlineAccessibilityCheck.hxx +++ b/sw/inc/OnlineAccessibilityCheck.hxx @@ -67,8 +67,14 @@ public: OnlineAccessibilityCheck(SwDoc& rDocument); void update(SwPosition const& rNewPos); void resetAndQueue(SwNode* pNode); + void resetAndQueueDocumentLevel(); void updateCheckerActivity(); sal_Int32 getNumberOfAccessibilityIssues() { return m_nAccessibilityIssues; } + sal_Int32 getNumberOfDocumentLevelAccessibilityIssues() + { + return m_pDocumentAccessibilityIssues ? m_pDocumentAccessibilityIssues->getIssues().size() + : sal_Int32(0); + } }; } // end sw diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 60c942d40cf7..b9eeaafc6171 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -1262,8 +1262,10 @@ public: OUString sTitle = xDocumentProperties->getTitle(); if (o3tl::trim(sTitle).empty()) { - lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE), - sfx::AccessibilityIssueID::DOCUMENT_TITLE); + auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE), + sfx::AccessibilityIssueID::DOCUMENT_TITLE); + pIssue->setDoc(*pDoc); + pIssue->setIssueObject(IssueObject::DOCUMENT_TITLE); } } }; diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx index d1ebb53bdeeb..d0366b1ef3e2 100644 --- a/sw/source/core/access/AccessibilityIssue.cxx +++ b/sw/source/core/access/AccessibilityIssue.cxx @@ -8,6 +8,8 @@ * */ +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> + #include <AccessibilityIssue.hxx> #include <AccessibilityCheckStrings.hrc> #include <drawdoc.hxx> @@ -42,7 +44,8 @@ void AccessibilityIssue::setObjectID(OUString const& rID) { m_sObjectID = rID; } bool AccessibilityIssue::canGotoIssue() const { - if (m_pDoc && m_eIssueObject != IssueObject::UNKNOWN) + if (m_pDoc && m_eIssueObject != IssueObject::UNKNOWN + && m_eIssueObject != IssueObject::DOCUMENT_TITLE) return true; return false; } @@ -119,7 +122,8 @@ void AccessibilityIssue::gotoIssue() const bool AccessibilityIssue::canQuickFixIssue() const { return m_eIssueObject == IssueObject::GRAPHIC || m_eIssueObject == IssueObject::OLE - || m_eIssueObject == IssueObject::SHAPE || m_eIssueObject == IssueObject::FORM; + || m_eIssueObject == IssueObject::SHAPE || m_eIssueObject == IssueObject::FORM + || m_eIssueObject == IssueObject::DOCUMENT_TITLE; } void AccessibilityIssue::quickFixIssue() const @@ -158,6 +162,26 @@ void AccessibilityIssue::quickFixIssue() const } } break; + case IssueObject::DOCUMENT_TITLE: + { + OUString aDesc = SwResId(STR_ENTER_DOCUMENT_TITLE); + SvxNameDialog aNameDialog(m_pParent, "", aDesc); + if (aNameDialog.run() == RET_OK) + { + SwDocShell* pShell = m_pDoc->GetDocShell(); + if (!pShell) + return; + + const uno::Reference<document::XDocumentPropertiesSupplier> xDPS( + pShell->GetModel(), uno::UNO_QUERY_THROW); + const uno::Reference<document::XDocumentProperties> xDocumentProperties( + xDPS->getDocumentProperties()); + xDocumentProperties->setTitle(aNameDialog.GetName()); + + m_pDoc->getOnlineAccessibilityCheck()->resetAndQueueDocumentLevel(); + } + } + break; default: break; } diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx index 5a51ba2110a1..f38457acf0b6 100644 --- a/sw/source/core/inc/AccessibilityIssue.hxx +++ b/sw/source/core/inc/AccessibilityIssue.hxx @@ -25,6 +25,7 @@ enum class IssueObject FORM, TABLE, TEXT, + DOCUMENT_TITLE, }; class SW_DLLPUBLIC AccessibilityIssue final : public sfx::AccessibilityIssue diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx index 0b4c61ebca76..c7da361e284f 100644 --- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx +++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx @@ -256,6 +256,7 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN if (pNode && (pNode->IsContentNode() || pNode->IsTableNode())) { + runDocumentLevelAccessibilityCheck(); runAccessibilityCheck(pNode); updateNodeStatus(pNode); @@ -308,6 +309,20 @@ void OnlineAccessibilityCheck::resetAndQueue(SwNode* pNode) updateStatusbar(); } +void OnlineAccessibilityCheck::resetAndQueueDocumentLevel() +{ + if (utl::ConfigManager::IsFuzzing()) + return; + + bool bOnlineCheckStatus + = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get(); + if (!bOnlineCheckStatus) + return; + + runDocumentLevelAccessibilityCheck(); + updateStatusbar(); +} + } // end sw /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 02823bb43b56..ed0982f037dc 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -1888,7 +1888,8 @@ void SwView::StateStatusLine(SfxItemSet &rSet) std::unique_ptr<sw::OnlineAccessibilityCheck> const& rOnlineAccessibilityCheck = rShell.GetDoc()->getOnlineAccessibilityCheck(); if (rOnlineAccessibilityCheck) { - sal_Int32 nIssues = rOnlineAccessibilityCheck->getNumberOfAccessibilityIssues(); + sal_Int32 nIssues = rOnlineAccessibilityCheck->getNumberOfAccessibilityIssues() + + rOnlineAccessibilityCheck->getNumberOfDocumentLevelAccessibilityIssues(); rSet.Put(SfxInt32Item(FN_STAT_ACCESSIBILITY_CHECK, nIssues)); } } commit 7a159bcaac6296d42811d7d08668f7bb8df88206 Author: Balazs Varga <[email protected]> AuthorDate: Thu Jun 22 18:48:10 2023 +0200 Commit: Samuel Mehrbrodt <[email protected]> CommitDate: Mon Jun 26 09:25:21 2023 +0200 tdf#152576 - A11Y sidebar: improving update of issues on sidebar Put the empty paragraph nodes to the correct WeakNodeContainer. Change-Id: I2db5608b0f7a625b6221d9290ea3d2502f4cadea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153469 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <[email protected]> (cherry picked from commit e0b94102f5f1d310c8974f44e0d2d255e7906729) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153513 diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 802ad2c8dea3..60c942d40cf7 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -683,21 +683,20 @@ public: class NewlineSpacingCheck : public NodeCheck { private: - static SwTextNode* getNextTextNode(SwNode* pCurrent) + static SwTextNode* getPrevTextNode(SwNode* pCurrent) { SwTextNode* pTextNode = nullptr; auto nIndex = pCurrent->GetIndex(); - auto nCount = pCurrent->GetNodes().Count(); - nIndex++; // go to next node + nIndex--; // go to previous node - while (pTextNode == nullptr && nIndex < nCount) + while (pTextNode == nullptr && nIndex >= SwNodeOffset(0)) { auto pNode = pCurrent->GetNodes()[nIndex]; if (pNode->IsTextNode()) pTextNode = pNode->GetTextNode(); - nIndex++; + nIndex--; } return pTextNode; @@ -721,16 +720,16 @@ public: auto nParagraphLength = pTextNode->GetText().getLength(); if (nParagraphLength == 0) { - SwTextNode* pNextTextNode = getNextTextNode(pCurrent); - if (!pNextTextNode) + SwTextNode* pPrevTextNode = getPrevTextNode(pCurrent); + if (!pPrevTextNode) return; - if (pNextTextNode->GetText().getLength() == 0) + if (pPrevTextNode->GetText().getLength() == 0) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_NEWLINES_SPACE), sfx::AccessibilityIssueID::TEXT_FORMATTING); pIssue->setIssueObject(IssueObject::TEXT); - pIssue->setNode(pNextTextNode); - SwDoc& rDocument = pNextTextNode->GetDoc(); + pIssue->setNode(pTextNode); + SwDoc& rDocument = pTextNode->GetDoc(); pIssue->setDoc(rDocument); } } diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx index 629497c50bac..0b4c61ebca76 100644 --- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx +++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx @@ -248,6 +248,9 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN return; } + // Run the docement level Accessibility Check + runDocumentLevelAccessibilityCheck(); + // Get the real previous node from index SwNode* pNode = pCurrentNode->GetNodes()[m_nPreviousNodeIndex]; @@ -255,7 +258,6 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN { runAccessibilityCheck(pNode); updateNodeStatus(pNode); - updateStatusbar(); // Assign previous node and index m_pPreviousNode = std::move(pCurrentWeak); @@ -263,9 +265,14 @@ void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rN } else { + runAccessibilityCheck(pCurrentNode); + updateNodeStatus(pCurrentNode); + m_pPreviousNode.reset(); m_nPreviousNodeIndex = SwNodeOffset(-1); } + + updateStatusbar(); } void OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()
