diff --git a/filter/inc/strings.hrc b/filter/inc/strings.hrc index 3fd833352194..ab52e67b5d9e 100644 --- a/filter/inc/strings.hrc +++ b/filter/inc/strings.hrc @@ -76,9 +76,9 @@ #define STR_WARN_TRANSP_CONVERTED_SHORT NC_("STR_WARN_TRANSP_CONVERTED_SHORT", "Transparencies removed") #define STR_ERR_SIGNATURE_FAILED NC_("STR_ERR_SIGNATURE_FAILED", "Signature generation failed") #define STR_ERR_PDF_EXPORT_ABORTED NC_("STR_ERR_PDF_EXPORT_ABORTED", "PDF export aborted") -#define STR_WARN_PDFUA_ISSUES NNC_("STR_WARN_PDFUA_ISSUES", "One accessibility issue detected. Do you want to continue?", "%1 accessibility issues detected. Do you want to continue?") +#define STR_WARN_PDFUA_ISSUES NNC_("STR_WARN_PDFUA_ISSUES", "One accessibility error detected. Do you want to continue?", "%1 accessibility errors detected. Do you want to continue?") #define STR_PDFUA_IGNORE NC_("STR_PDFUA_IGNORE", "Continue") -#define STR_PDFUA_INVESTIGATE NNC_("STR_PDFUA_INVESTIGATE", "Investigate issue", "Investigate issues") +#define STR_PDFUA_INVESTIGATE NNC_("STR_PDFUA_INVESTIGATE", "Investigate error", "Investigate errors") // Progress bar status indicator when importing or exporting #define STR_FILTER_DOC_LOADING NC_("STR_FILTER_DOC_LOADING", "Loading: ") diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index fb9bab206a81..482d523bed63 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -279,7 +279,8 @@ IMPL_LINK_NOARG(ImpPDFTabDialog, OkHdl, weld::Button&, void) const int nIssueCount = std::count_if(aIssues.begin(), aIssues.end(), [](const std::shared_ptr& pIssues) { - return !pIssues->getHidden(); + return !pIssues->getHidden() && + pIssues->m_eIssueLvl == sfx::AccessibilityIssueLevel::ERRORLEV; }); if (nIssueCount) diff --git a/include/sfx2/AccessibilityIssue.hxx b/include/sfx2/AccessibilityIssue.hxx index 1aae578822f4..abb7a1318f05 100644 --- a/include/sfx2/AccessibilityIssue.hxx +++ b/include/sfx2/AccessibilityIssue.hxx @@ -54,10 +54,17 @@ enum class AccessibilityIssueID FONTWORKS, }; +enum class AccessibilityIssueLevel : size_t +{ + ERRORLEV = 0, + WARNLEV = 1, + LAST = WARNLEV +}; + class SFX2_DLLPUBLIC AccessibilityIssue { public: - AccessibilityIssue(AccessibilityIssueID eIssueID); + AccessibilityIssue(AccessibilityIssueID eIssueID, AccessibilityIssueLevel eIssueLvl); AccessibilityIssue(AccessibilityIssue const&) = default; virtual ~AccessibilityIssue(); @@ -75,6 +82,7 @@ public: AccessibilityIssue& operator=(const AccessibilityIssue&) = default; AccessibilityIssueID m_eIssueID; + AccessibilityIssueLevel m_eIssueLvl; OUString m_aIssueText; bool m_bHidden; diff --git a/sfx2/source/accessibility/AccessibilityIssue.cxx b/sfx2/source/accessibility/AccessibilityIssue.cxx index 44ff3adb1e8f..54124dc21275 100644 --- a/sfx2/source/accessibility/AccessibilityIssue.cxx +++ b/sfx2/source/accessibility/AccessibilityIssue.cxx @@ -12,8 +12,10 @@ namespace sfx { -AccessibilityIssue::AccessibilityIssue(AccessibilityIssueID eIssueID) +AccessibilityIssue::AccessibilityIssue(AccessibilityIssueID eIssueID, + AccessibilityIssueLevel eIssueLvl) : m_eIssueID(eIssueID) + , m_eIssueLvl(eIssueLvl) , m_bHidden(false) , m_pParent(nullptr) { diff --git a/static/CustomTarget_emscripten_fs_image.mk b/static/CustomTarget_emscripten_fs_image.mk index b83676900859..7e40f7eb1aae 100644 --- a/static/CustomTarget_emscripten_fs_image.mk +++ b/static/CustomTarget_emscripten_fs_image.mk @@ -1199,6 +1199,7 @@ gb_emscripten_fs_image_files += \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/absrecbox.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/acceptrejectchangesdialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/accessibilitycheckentry.ui \ + $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/accessibilitychecklevel.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/addconditiondialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/adddataitemdialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/svx/ui/addinstancedialog.ui \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index fdbf7027ab35..7268f7f526a5 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -13,6 +13,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/absrecbox \ svx/uiconfig/ui/acceptrejectchangesdialog \ svx/uiconfig/ui/accessibilitycheckentry \ + svx/uiconfig/ui/accessibilitychecklevel \ svx/uiconfig/ui/addconditiondialog \ svx/uiconfig/ui/adddataitemdialog \ svx/uiconfig/ui/addinstancedialog \ diff --git a/svx/uiconfig/ui/accessibilitychecklevel.ui b/svx/uiconfig/ui/accessibilitychecklevel.ui new file mode 100644 index 000000000000..20a277a8b448 --- /dev/null +++ b/svx/uiconfig/ui/accessibilitychecklevel.ui @@ -0,0 +1,322 @@ + + + + + + True + False + vertical + 6 + top + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Document + + + + + False + True + 0 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Styles + + + + + False + True + 1 + + + + + True + + + True + False + 6 + True + vertical + + + + + + + + True + False + Missing linked graphic + + + + + False + True + 2 + + + + + True + + + True + False + 6 + True + vertical + + + + + + + + True + False + Missing alternative or description text + + + + + False + True + 3 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Table + + + + + False + True + 4 + + + + + True + + + True + False + 6 + vertical + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Direct Formatting + + + + + False + True + 0 + + + + + + + + + + True + False + Formatting + + + + + False + True + 5 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Hyperlink + + + + + False + True + 7 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Simulated captions + + + + + False + True + 8 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Numbering + + + + + False + True + 9 + + + + + True + + + True + False + 6 + vertical + + + + + + + + True + False + Other + + + + + False + True + 10 + + + + diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 91295c1ce819..6bdba45e753c 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -36,6 +36,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckDocumentIssues) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_LANGUAGE, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[0]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_TITLE, aIssues[1]->m_eIssueID); } @@ -49,11 +50,14 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testTableSplitMergeAndAltText) CPPUNIT_ASSERT_EQUAL(size_t(6), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_GRAPHIC, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::ERRORLEV, aIssues[0]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, aIssues[1]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, aIssues[2]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, aIssues[3]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, aIssues[4]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[4]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::NO_ALT_SHAPE, aIssues[5]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::ERRORLEV, aIssues[5]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckParagraphIssues) @@ -78,6 +82,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[0]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckLinkedImage) @@ -89,6 +94,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckLinkedImage) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(4), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::LINKED_GRAPHIC, aIssues[1]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[1]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) @@ -103,6 +109,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[2]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[3]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[3]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace) @@ -127,9 +134,12 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testHyperlinks) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(5), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_SHORT, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[0]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_NO_NAME, aIssues[1]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT, aIssues[2]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[2]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::HYPERLINK_NO_NAME, aIssues[3]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[3]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[4]->m_eIssueID); } @@ -159,6 +169,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testNumberingCheck) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::MANUAL_NUMBERING, aIssues[2]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::MANUAL_NUMBERING, aIssues[3]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::MANUAL_NUMBERING, aIssues[4]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[4]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckFakeFootnote) @@ -171,10 +182,13 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckFakeFootnote) CPPUNIT_ASSERT_EQUAL(size_t(6), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[0]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::FAKE_FOOTNOTE, aIssues[1]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[1]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[2]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::FAKE_FOOTNOTE, aIssues[3]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[3]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[4]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DIRECT_FORMATTING, aIssues[5]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[5]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckFakeCaption) @@ -186,6 +200,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckFakeCaption) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::FAKE_CAPTION, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[0]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTableFormatting) @@ -197,6 +212,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTableFormatting) auto& aIssues = aCheck.getIssueCollection().getIssues(); CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_FORMATTING, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::WARNLEV, aIssues[0]->m_eIssueLvl); } CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTabsFormatting) @@ -244,6 +260,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testDeleteHeader) aCheck.check(); CPPUNIT_ASSERT_EQUAL(size_t(8), aIssues.size()); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_TITLE, aIssues[0]->m_eIssueID); + CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueLevel::ERRORLEV, aIssues[0]->m_eIssueLvl); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[2]->m_eIssueID); CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[3]->m_eIssueID); diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index bf54b7a3ea4d..39a4999f1965 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -271,9 +271,9 @@ void lcl_SetHiddenIssues(std::shared_ptr& pIssue) std::shared_ptr lclAddIssue(sfx::AccessibilityIssueCollection& rIssueCollection, OUString const& rText, - sfx::AccessibilityIssueID eIssue) + sfx::AccessibilityIssueID eIssueId, sfx::AccessibilityIssueLevel eIssueLvl) { - auto pIssue = std::make_shared(eIssue); + auto pIssue = std::make_shared(eIssueId, eIssueLvl); pIssue->m_aIssueText = rText; // check which a11y issue should be visible @@ -330,7 +330,8 @@ class NoTextNodeAltTextCheck : public NodeCheck .replaceFirst("%LINK%", sURL); auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::LINKED_GRAPHIC); + sfx::AccessibilityIssueID::LINKED_GRAPHIC, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setDoc(pNoTextNode->GetDoc()); pIssue->setIssueObject(IssueObject::LINKED); pIssue->setObjectID(pFrameFormat->GetName()); @@ -347,8 +348,9 @@ class NoTextNodeAltTextCheck : public NodeCheck if (pNoTextNode->IsOLENode()) { - auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::NO_ALT_OLE); + auto pIssue + = lclAddIssue(m_rIssueCollection, sIssueText, sfx::AccessibilityIssueID::NO_ALT_OLE, + sfx::AccessibilityIssueLevel::ERRORLEV); pIssue->setDoc(pNoTextNode->GetDoc()); pIssue->setIssueObject(IssueObject::OLE); pIssue->setObjectID(pFrameFormat->GetName()); @@ -359,7 +361,8 @@ class NoTextNodeAltTextCheck : public NodeCheck if (!(pIsDecorItem && pIsDecorItem->GetValue())) { auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::NO_ALT_GRAPHIC); + sfx::AccessibilityIssueID::NO_ALT_GRAPHIC, + sfx::AccessibilityIssueLevel::ERRORLEV); pIssue->setDoc(pNoTextNode->GetDoc()); pIssue->setIssueObject(IssueObject::GRAPHIC); pIssue->setObjectID(pFrameFormat->GetName()); @@ -395,7 +398,8 @@ private: OUString sName = pFormat->GetName(); OUString sIssueText = SwResId(STR_TABLE_MERGE_SPLIT).replaceAll("%OBJECT_NAME%", sName); auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT); + sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setDoc(rDoc); pIssue->setIssueObject(IssueObject::TABLE); pIssue->setObjectID(sName); @@ -493,7 +497,8 @@ private: if (nEmptyBoxes > nBoxCount / 2) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TABLE_FORMATTING), - sfx::AccessibilityIssueID::TABLE_FORMATTING); + sfx::AccessibilityIssueID::TABLE_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setDoc(pTableNode->GetDoc()); pIssue->setIssueObject(IssueObject::TABLE); @@ -558,7 +563,8 @@ public: OUString sIssueText = SwResId(STR_FAKE_NUMBERING).replaceAll("%NUMBERING%", sNumbering); auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::MANUAL_NUMBERING); + sfx::AccessibilityIssueID::MANUAL_NUMBERING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setDoc(pCurrent->GetDoc()); pIssue->setNode(pCurrent); @@ -593,13 +599,15 @@ private: OUString sIssueText = SwResId(STR_HYPERLINK_TEXT_IS_LINK) .replaceFirst("%LINK%", sHyperlink); pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT); + sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT, + sfx::AccessibilityIssueLevel::WARNLEV); } else if (sRunText.getLength() <= 5) { pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_HYPERLINK_TEXT_IS_SHORT), - sfx::AccessibilityIssueID::HYPERLINK_SHORT); + sfx::AccessibilityIssueID::HYPERLINK_SHORT, + sfx::AccessibilityIssueLevel::WARNLEV); } if (pIssue) @@ -619,7 +627,8 @@ private: { std::shared_ptr pNameIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_HYPERLINK_NO_NAME), - sfx::AccessibilityIssueID::HYPERLINK_NO_NAME); + sfx::AccessibilityIssueID::HYPERLINK_NO_NAME, + sfx::AccessibilityIssueLevel::WARNLEV); if (pNameIssue) { @@ -785,7 +794,8 @@ private: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), - sfx::AccessibilityIssueID::DIRECT_FORMATTING); + sfx::AccessibilityIssueID::DIRECT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -811,7 +821,8 @@ private: if (fContrastRatio < 4.5) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_CONTRAST), - sfx::AccessibilityIssueID::TEXT_CONTRAST); + sfx::AccessibilityIssueID::TEXT_CONTRAST, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); pIssue->setDoc(pTextNode->GetDoc()); @@ -1257,7 +1268,8 @@ public: o3tl::remove_duplicates(aFormattings); auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), - sfx::AccessibilityIssueID::DIRECT_FORMATTING); + sfx::AccessibilityIssueID::DIRECT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1597,7 +1609,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), - sfx::AccessibilityIssueID::DIRECT_FORMATTING); + sfx::AccessibilityIssueID::DIRECT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1616,7 +1629,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_FORMATTING_CONVEYS_MEANING), - sfx::AccessibilityIssueID::DIRECT_FORMATTING); + sfx::AccessibilityIssueID::DIRECT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1685,7 +1699,8 @@ public: if (pPrevTextNode->GetText().getLength() == 0) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_NEWLINES_SPACE), - sfx::AccessibilityIssueID::TEXT_FORMATTING); + sfx::AccessibilityIssueID::TEXT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); pIssue->setDoc(rDocument); @@ -1711,7 +1726,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_NEWLINES_SPACE), - sfx::AccessibilityIssueID::TEXT_FORMATTING); + sfx::AccessibilityIssueID::TEXT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); pIssue->setDoc(rDocument); @@ -1784,7 +1800,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_TABS_FORMATTING), - sfx::AccessibilityIssueID::TEXT_FORMATTING); + sfx::AccessibilityIssueID::TEXT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1801,7 +1818,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_SPACES_SPACE), - sfx::AccessibilityIssueID::TEXT_FORMATTING); + sfx::AccessibilityIssueID::TEXT_FORMATTING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1837,7 +1855,8 @@ private: && pTextAttr->GetStart() == 0 && pTextAttr->GetAnyEnd() == 1) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_FAKE_FOOTNOTES), - sfx::AccessibilityIssueID::FAKE_FOOTNOTE); + sfx::AccessibilityIssueID::FAKE_FOOTNOTE, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1867,7 +1886,8 @@ public: if (pTextNode->GetText()[0] == '*') { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_FAKE_FOOTNOTES), - sfx::AccessibilityIssueID::FAKE_FOOTNOTE); + sfx::AccessibilityIssueID::FAKE_FOOTNOTE, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1941,7 +1961,8 @@ public: || sText.startsWith(SwResId(STR_POOLCOLL_LABEL_FIGURE))) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_FAKE_CAPTIONS), - sfx::AccessibilityIssueID::FAKE_CAPTION); + sfx::AccessibilityIssueID::FAKE_CAPTION, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); SwDoc& rDocument = pTextNode->GetDoc(); @@ -1969,7 +1990,8 @@ private: if (bBlinking) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_TEXT_BLINKING), - sfx::AccessibilityIssueID::TEXT_BLINKING); + sfx::AccessibilityIssueID::TEXT_BLINKING, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); pIssue->setDoc(pTextNode->GetDoc()); @@ -2037,7 +2059,8 @@ public: if (nLevel > m_nPreviousLevel && std::abs(nLevel - m_nPreviousLevel) > 1) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_HEADINGS_NOT_IN_ORDER), - sfx::AccessibilityIssueID::HEADINGS_NOT_IN_ORDER); + sfx::AccessibilityIssueID::HEADINGS_NOT_IN_ORDER, + sfx::AccessibilityIssueLevel::ERRORLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setDoc(pCurrent->GetDoc()); pIssue->setNode(pCurrent); @@ -2083,7 +2106,8 @@ public: { sal_Int32 nStart = 0; auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_NON_INTERACTIVE_FORMS), - sfx::AccessibilityIssueID::NON_INTERACTIVE_FORMS); + sfx::AccessibilityIssueID::NON_INTERACTIVE_FORMS, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setNode(pTextNode); pIssue->setDoc(pTextNode->GetDoc()); @@ -2131,7 +2155,8 @@ public: if (aIdx == aCurrentIdx) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_FLOATING_TEXT), - sfx::AccessibilityIssueID::FLOATING_TEXT); + sfx::AccessibilityIssueID::FLOATING_TEXT, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXTFRAME); pIssue->setObjectID(pFormat->GetName()); pIssue->setDoc(pCurrent->GetDoc()); @@ -2175,7 +2200,8 @@ public: { m_bPrevPassed = false; auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_HEADING_IN_TABLE), - sfx::AccessibilityIssueID::HEADING_IN_TABLE); + sfx::AccessibilityIssueID::HEADING_IN_TABLE, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setDoc(pCurrent->GetDoc()); pIssue->setNode(pCurrent); @@ -2224,7 +2250,8 @@ public: } resultString = resultString.replaceAll("%LEVEL_CURRENT%", OUString::number(currentLevel)); - auto pIssue = lclAddIssue(m_rIssueCollection, resultString, eIssueID); + auto pIssue = lclAddIssue(m_rIssueCollection, resultString, eIssueID, + sfx::AccessibilityIssueLevel::ERRORLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setDoc(pCurrent->GetDoc()); pIssue->setNode(pCurrent); @@ -2269,7 +2296,8 @@ public: auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_CONTENT_CONTROL_IN_HEADER_OR_FOOTER), - sfx::AccessibilityIssueID::CONTENT_CONTROL); + sfx::AccessibilityIssueID::CONTENT_CONTROL, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXT); pIssue->setDoc(pCurrent->GetDoc()); pIssue->setNode(pCurrent); @@ -2310,7 +2338,8 @@ public: if (eLanguage == LANGUAGE_NONE) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_DEFAULT_LANGUAGE), - sfx::AccessibilityIssueID::DOCUMENT_LANGUAGE); + sfx::AccessibilityIssueID::DOCUMENT_LANGUAGE, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::LANGUAGE_NOT_SET); pIssue->setObjectID(OUString()); pIssue->setDoc(*pDoc); @@ -2327,7 +2356,8 @@ public: = SwResId(STR_STYLE_NO_LANGUAGE).replaceAll("%STYLE_NAME%", sName); auto pIssue = lclAddIssue(m_rIssueCollection, sIssueText, - sfx::AccessibilityIssueID::STYLE_LANGUAGE); + sfx::AccessibilityIssueID::STYLE_LANGUAGE, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::LANGUAGE_NOT_SET); pIssue->setObjectID(sName); pIssue->setDoc(*pDoc); @@ -2359,7 +2389,8 @@ public: if (o3tl::trim(sTitle).empty()) { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_DOCUMENT_TITLE), - sfx::AccessibilityIssueID::DOCUMENT_TITLE); + sfx::AccessibilityIssueID::DOCUMENT_TITLE, + sfx::AccessibilityIssueLevel::ERRORLEV); pIssue->setDoc(*pDoc); pIssue->setIssueObject(IssueObject::DOCUMENT_TITLE); } @@ -2384,7 +2415,8 @@ public: sfx::AccessibilityIssueID eIssueID = rFootnote.IsEndNote() ? sfx::AccessibilityIssueID::AVOID_FOOTNOTES : sfx::AccessibilityIssueID::AVOID_ENDNOTES; - auto pIssue = lclAddIssue(m_rIssueCollection, sError, eIssueID); + auto pIssue = lclAddIssue(m_rIssueCollection, sError, eIssueID, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setDoc(*pDoc); pIssue->setIssueObject(IssueObject::FOOTENDNOTE); pIssue->setTextFootnote(pTextFootnote); @@ -2427,7 +2459,8 @@ public: { auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_BACKGROUND_IMAGES), - sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND); + sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setDoc(*pDoc); pIssue->setIssueObject(IssueObject::DOCUMENT_BACKGROUND); @@ -2454,7 +2487,8 @@ void AccessibilityCheck::checkObject(SwNode* pCurrent, SdrObject* pObject) if (const uno::Any* pAny = rGeometryItem.GetPropertyValueByName(u"Type"_ustr)) if (pAny->get().startsWith("fontwork-")) lclAddIssue(m_aIssueCollection, SwResId(STR_FONTWORKS), - sfx::AccessibilityIssueID::FONTWORKS); + sfx::AccessibilityIssueID::FONTWORKS, + sfx::AccessibilityIssueLevel::WARNLEV); } // Checking if there is floating Writer text draw object and if so, throwing a warning. @@ -2463,7 +2497,8 @@ void AccessibilityCheck::checkObject(SwNode* pCurrent, SdrObject* pObject) && FindFrameFormat(pObject)->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) { auto pIssue = lclAddIssue(m_aIssueCollection, SwResId(STR_FLOATING_TEXT), - sfx::AccessibilityIssueID::FLOATING_TEXT); + sfx::AccessibilityIssueID::FLOATING_TEXT, + sfx::AccessibilityIssueLevel::WARNLEV); pIssue->setIssueObject(IssueObject::TEXTFRAME); pIssue->setObjectID(pObject->GetName()); pIssue->setDoc(*m_pDoc); @@ -2483,7 +2518,8 @@ void AccessibilityCheck::checkObject(SwNode* pCurrent, SdrObject* pObject) const OUString& sName = pObject->GetName(); OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName); auto pIssue = lclAddIssue(m_aIssueCollection, sIssueText, - sfx::AccessibilityIssueID::NO_ALT_SHAPE); + sfx::AccessibilityIssueID::NO_ALT_SHAPE, + sfx::AccessibilityIssueLevel::ERRORLEV); // Set FORM Issue for Form objects because of the design mode if (nInv == SdrInventor::FmForm) pIssue->setIssueObject(IssueObject::FORM); diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx index a6e02f9a8b67..2aabb968bb0a 100644 --- a/sw/source/core/access/AccessibilityIssue.cxx +++ b/sw/source/core/access/AccessibilityIssue.cxx @@ -35,8 +35,9 @@ namespace sw { -AccessibilityIssue::AccessibilityIssue(sfx::AccessibilityIssueID eIssueID) - : sfx::AccessibilityIssue(eIssueID) +AccessibilityIssue::AccessibilityIssue(sfx::AccessibilityIssueID eIssueID, + sfx::AccessibilityIssueLevel eIssueLvl) + : sfx::AccessibilityIssue(eIssueID, eIssueLvl) , m_eIssueObject(IssueObject::UNKNOWN) , m_pDoc(nullptr) , m_pNode(nullptr) diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx index eef014c5f7f3..647d51b66da7 100644 --- a/sw/source/core/inc/AccessibilityIssue.hxx +++ b/sw/source/core/inc/AccessibilityIssue.hxx @@ -49,7 +49,7 @@ private: sal_Int32 m_nEnd; public: - AccessibilityIssue(sfx::AccessibilityIssueID eIssueID); + AccessibilityIssue(sfx::AccessibilityIssueID eIssueID, sfx::AccessibilityIssueLevel eIssueLvl); AccessibilityIssue(AccessibilityIssue const&) = default; void setIssueObject(IssueObject eIssueObject); diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx index 5e6e934ee598..d5f5f264d657 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx @@ -97,28 +97,9 @@ IMPL_LINK_NOARG(AccessibilityCheckEntry, FixButtonClicked, weld::Button&, void) m_pAccessibilityIssue->quickFixIssue(); } -std::unique_ptr A11yCheckIssuesPanel::Create(weld::Widget* pParent, - SfxBindings* pBindings) -{ - if (pParent == nullptr) - throw css::lang::IllegalArgumentException( - u"no parent window given to A11yCheckIssuesPanel::Create"_ustr, nullptr, 0); - return std::make_unique(pParent, pBindings); -} - -A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* pBindings) - : PanelLayout(pParent, u"A11yCheckIssuesPanel"_ustr, - u"modules/swriter/ui/a11ycheckissuespanel.ui"_ustr) - , m_xOptionsButton(m_xBuilder->weld_button(u"bOptions"_ustr)) - , mxAccessibilityBox(m_xBuilder->weld_box(u"accessibilityCheckBox"_ustr)) - , mxUpdateBox(m_xBuilder->weld_box(u"updateBox"_ustr)) - , mxUpdateLinkButton(m_xBuilder->weld_link_button(u"updateLinkButton"_ustr)) - - , mpBindings(pBindings) - , mpDoc(nullptr) - , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this) - , mnIssueCount(0) - , mbAutomaticCheckEnabled(false) +AccessibilityCheckLevel::AccessibilityCheckLevel(weld::Box* pParent) + : m_xBuilder(Application::CreateBuilder(pParent, u"svx/ui/accessibilitychecklevel.ui"_ustr)) + , m_xContainer(m_xBuilder->weld_box(u"accessibilityCheckLevelBox"_ustr)) { m_xExpanders[0] = m_xBuilder->weld_expander(u"expand_document"_ustr); m_xExpanders[1] = m_xBuilder->weld_expander(u"expand_styles"_ustr); @@ -143,6 +124,84 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p m_xBoxes[8] = m_xBuilder->weld_box(u"box_fakes"_ustr); m_xBoxes[9] = m_xBuilder->weld_box(u"box_numbering"_ustr); m_xBoxes[10] = m_xBuilder->weld_box(u"box_other"_ustr); +} + +void AccessibilityCheckLevel::removeAllEntries() +{ + for (auto eGroup : o3tl::enumrange()) + { + auto nGroupIndex = size_t(eGroup); + for (auto const& xEntry : m_aEntries[nGroupIndex]) + m_xBoxes[nGroupIndex]->move(xEntry->get_widget(), nullptr); + } +} + +void AccessibilityCheckLevel::reset() +{ + for (auto& xExpander : m_xExpanders) + xExpander.reset(); + + for (auto& xBox : m_xBoxes) + xBox.reset(); +} + +void AccessibilityCheckLevel::addEntryForGroup( + AccessibilityCheckGroups eGroup, std::vector& rIndices, + std::shared_ptr const& pIssue) +{ + auto nGroupIndex = size_t(eGroup); + // prevent the UI locking up forever, this is effectively an O(n^2) situation, given the way the UI additions work + if (m_aEntries[nGroupIndex].size() > 500) + { + SAL_WARN("sw", "too many a11y issues, not adding to panel"); + return; + } + auto xEntry = std::make_unique(m_xBoxes[nGroupIndex].get(), pIssue); + m_xBoxes[nGroupIndex]->reorder_child(xEntry->get_widget(), rIndices[nGroupIndex]++); + m_aEntries[nGroupIndex].push_back(std::move(xEntry)); +} + +size_t AccessibilityCheckLevel::getEntrySize(AccessibilityCheckGroups eGroup) const +{ + auto nGroupIndex = size_t(eGroup); + return m_aEntries[nGroupIndex].size(); +} + +void AccessibilityCheckLevel::show(size_t nGroupIndex) { m_xExpanders[nGroupIndex]->show(); } + +void AccessibilityCheckLevel::hide(size_t nGroupIndex) { m_xExpanders[nGroupIndex]->hide(); } + +std::unique_ptr A11yCheckIssuesPanel::Create(weld::Widget* pParent, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw css::lang::IllegalArgumentException( + u"no parent window given to A11yCheckIssuesPanel::Create"_ustr, nullptr, 0); + return std::make_unique(pParent, pBindings); +} + +A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* pBindings) + : PanelLayout(pParent, u"A11yCheckIssuesPanel"_ustr, + u"modules/swriter/ui/a11ycheckissuespanel.ui"_ustr) + , m_xOptionsButton(m_xBuilder->weld_button(u"bOptions"_ustr)) + , mxUpdateBox(m_xBuilder->weld_box(u"updateBox"_ustr)) + , mxUpdateLinkButton(m_xBuilder->weld_link_button(u"updateLinkButton"_ustr)) + , m_xListSep(m_xBuilder->weld_widget(u"sep_level"_ustr)) + , mpBindings(pBindings) + , mpDoc(nullptr) + , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this) + , mnIssueCount(0) + , mbAutomaticCheckEnabled(false) +{ + // errors + m_xLevelExpanders[0] = m_xBuilder->weld_expander(u"expand_errors"_ustr); + mxAccessibilityBox[0] = m_xBuilder->weld_box(u"accessibilityBoxErr"_ustr); + m_aLevelEntries[0] = std::make_unique(mxAccessibilityBox[0].get()); + + // warnings + m_xLevelExpanders[1] = m_xBuilder->weld_expander(u"expand_warnings"_ustr); + mxAccessibilityBox[1] = m_xBuilder->weld_box(u"accessibilityBoxWrn"_ustr); + m_aLevelEntries[1] = std::make_unique(mxAccessibilityBox[1].get()); mxUpdateLinkButton->connect_activate_link( LINK(this, A11yCheckIssuesPanel, UpdateLinkButtonClicked)); @@ -171,12 +230,14 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p // In desktop don't show the update button and schedule to run the accessibility check async if (comphelper::LibreOfficeKit::isActive()) { - mxAccessibilityBox->hide(); + m_xLevelExpanders[0]->hide(); + m_xLevelExpanders[1]->hide(); mxUpdateBox->show(); } else { - mxAccessibilityBox->show(); + m_xLevelExpanders[0]->show(); + m_xLevelExpanders[1]->show(); mxUpdateBox->hide(); Application::PostUserEvent(LINK(this, A11yCheckIssuesPanel, PopulateIssuesHdl)); } @@ -191,7 +252,8 @@ IMPL_LINK_NOARG(A11yCheckIssuesPanel, OptionsButtonClicked, weld::Button&, void) IMPL_LINK_NOARG(A11yCheckIssuesPanel, UpdateLinkButtonClicked, weld::LinkButton&, bool) { - mxAccessibilityBox->show(); + m_xLevelExpanders[0]->show(); + m_xLevelExpanders[1]->show(); mxUpdateBox->hide(); Application::PostUserEvent(LINK(this, A11yCheckIssuesPanel, PopulateIssuesHdl)); return true; @@ -211,44 +273,41 @@ void A11yCheckIssuesPanel::ImplDestroy() mpBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE); } - for (auto& xExpander : m_xExpanders) - xExpander.reset(); - - for (auto& xBox : m_xBoxes) - xBox.reset(); + for (auto& aLevelEntry : m_aLevelEntries) + { + aLevelEntry->reset(); + aLevelEntry.reset(); + } } A11yCheckIssuesPanel::~A11yCheckIssuesPanel() { suppress_fun_call_w_exception(ImplDestroy()); } void A11yCheckIssuesPanel::removeAllEntries() { - for (auto eGroup : o3tl::enumrange()) + for (auto& aLevelEntry : m_aLevelEntries) { - auto nGroupIndex = size_t(eGroup); - for (auto const& xEntry : m_aEntries[nGroupIndex]) - m_xBoxes[nGroupIndex]->move(xEntry->get_widget(), nullptr); + aLevelEntry->removeAllEntries(); } } void A11yCheckIssuesPanel::addEntryForGroup(AccessibilityCheckGroups eGroup, - std::vector& rIndices, + std::vector>& rIndices, std::shared_ptr const& pIssue) { - auto nGroupIndex = size_t(eGroup); // prevent the UI locking up forever, this is effectively an O(n^2) situation, given the way the UI additions work - if (m_aEntries[nGroupIndex].size() > 500) + if (m_aLevelEntries[0]->getEntrySize(eGroup) + m_aLevelEntries[1]->getEntrySize(eGroup) > 500) { SAL_WARN("sw", "too many a11y issues, not adding to panel"); return; } - auto xEntry = std::make_unique(m_xBoxes[nGroupIndex].get(), pIssue); - m_xBoxes[nGroupIndex]->reorder_child(xEntry->get_widget(), rIndices[nGroupIndex]++); - m_aEntries[nGroupIndex].push_back(std::move(xEntry)); + + size_t nLevel = static_cast(pIssue->m_eIssueLvl); + m_aLevelEntries[nLevel]->addEntryForGroup(eGroup, rIndices[nLevel], pIssue); } void A11yCheckIssuesPanel::populateIssues() { - if (!mpDoc || !mxAccessibilityBox->is_visible()) + if (!mpDoc || !(m_xLevelExpanders[0]->is_visible() || m_xLevelExpanders[1]->is_visible())) return; SfxViewShell* pViewShell = SfxViewShell::Current(); @@ -263,7 +322,7 @@ void A11yCheckIssuesPanel::populateIssues() removeAllEntries(); - std::vector nIndices(11, 0); + std::vector> nIndices(2, std::vector(11, 0)); sal_Int32 nDirectFormats = 0; for (std::shared_ptr const& pIssue : m_aIssueCollection.getIssues()) @@ -368,23 +427,43 @@ void A11yCheckIssuesPanel::populateIssues() } } - // add DirectFormats (if have) as last element to Formatting AccessibilityCheckGroup + // add DirectFormats (if have) as last element to Formatting AccessibilityCheckGroup on the Warning level if (nDirectFormats > 0) { size_t nGroupFormatIndex = size_t(AccessibilityCheckGroups::Formatting); - nIndices[nGroupFormatIndex]++; + // Direct Formats are on the warning level + size_t nLevel = static_cast(sfx::AccessibilityIssueLevel::WARNLEV); + nIndices[nLevel][nGroupFormatIndex]++; } - size_t nGroupIndex = 0; - for (sal_Int32 nIndex : nIndices) + for (auto eLevel : o3tl::enumrange()) { - if (nIndex > 0) - m_xExpanders[nGroupIndex]->show(); + size_t nGroupIndex = 0; + auto nLevelIndex = size_t(eLevel); + bool bHaveIssue = false; + for (sal_Int32 nIndex : nIndices[nLevelIndex]) + { + if (nIndex > 0) + { + m_aLevelEntries[nLevelIndex]->show(nGroupIndex); + if (!bHaveIssue) + bHaveIssue = true; + } + else + m_aLevelEntries[nLevelIndex]->hide(nGroupIndex); + nGroupIndex++; + } + if (!bHaveIssue) + m_xLevelExpanders[nLevelIndex]->hide(); else - m_xExpanders[nGroupIndex]->hide(); - nGroupIndex++; + m_xLevelExpanders[nLevelIndex]->show(); } + if (m_xLevelExpanders[0]->is_visible() && m_xLevelExpanders[1]->is_visible()) + m_xListSep->set_visible(true); + else + m_xListSep->set_visible(false); + if (pWindow) pWindow->SetPointer(PointerStyle::Arrow); } diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx index f961778c4b27..b293cb937953 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx @@ -59,6 +59,29 @@ enum class AccessibilityCheckGroups : size_t LAST = Other }; +class AccessibilityCheckLevel +{ +private: + std::unique_ptr m_xBuilder; + std::unique_ptr m_xContainer; + std::array>, 11> m_aEntries; + std::array, 11> m_xExpanders; + std::array, 11> m_xBoxes; + +public: + AccessibilityCheckLevel(weld::Box* pParent); + + void removeAllEntries(); + void reset(); + + void addEntryForGroup(AccessibilityCheckGroups eGroup, std::vector& rIndices, + std::shared_ptr const& pIssue); + size_t getEntrySize(AccessibilityCheckGroups eGroup) const; + + void show(size_t nGroupIndex); + void hide(size_t nGroupIndex); +}; + class A11yCheckIssuesPanel : public PanelLayout, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { @@ -76,13 +99,13 @@ public: virtual ~A11yCheckIssuesPanel() override; private: - std::array>, 11> m_aEntries; - std::array, 11> m_xExpanders; - std::array, 11> m_xBoxes; std::unique_ptr m_xOptionsButton; - std::unique_ptr mxAccessibilityBox; + std::array, 2> m_xLevelExpanders; + std::array, 2> mxAccessibilityBox; + std::array, 2> m_aLevelEntries; std::unique_ptr mxUpdateBox; std::unique_ptr mxUpdateLinkButton; + std::unique_ptr m_xListSep; sfx::AccessibilityIssueCollection m_aIssueCollection; void removeAllEntries(); @@ -92,7 +115,8 @@ private: DECL_LINK(UpdateLinkButtonClicked, weld::LinkButton&, bool); DECL_LINK(PopulateIssuesHdl, void*, void); - void addEntryForGroup(AccessibilityCheckGroups eGroup, std::vector& rIndices, + void addEntryForGroup(AccessibilityCheckGroups eGroup, + std::vector>& rIndices, std::shared_ptr const& pIssue); SfxBindings* GetBindings() { return mpBindings; } diff --git a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui index 489f19e9683e..2dc86725159b 100644 --- a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui +++ b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui @@ -9,6 +9,7 @@ True True vertical + 3 @@ -20,7 +21,7 @@ False start True - Adjust accessibility check options + Adjust accessibility check options 0 @@ -67,334 +68,28 @@ - + True - False - start - True - True - vertical - 6 - top + True + True - - True - True + + True + False + 6 + 6 + vertical - - True - False - 6 - vertical - - - - - - - - True - False - Document - + - - False - True - 0 - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Styles - - + + + True + False + Accessibility errors - - False - True - 1 - - - - - True - True - - - True - False - 6 - True - vertical - - - - - - - - True - False - Missing linked graphic - - - - - False - True - 2 - - - - - True - True - - - True - False - 6 - True - vertical - - - - - - - - True - False - Missing alternative or description text - - - - - False - True - 3 - - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Table - - - - - False - True - 4 - - - - - True - True - - - True - False - 6 - vertical - - - True - - - True - False - 6 - vertical - - - - - - - - True - False - Direct Formatting - - - - - False - True - 0 - - - - - - - - - - True - False - Formatting - - - - - False - True - 5 - - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Hyperlink - - - - - False - True - 7 - - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Simulated captions - - - - - False - True - 8 - - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Numbering - - - - - False - True - 9 - - - - - True - True - - - True - False - 6 - vertical - - - - - - - - True - False - Other - - - - - False - True - 10 - @@ -403,6 +98,47 @@ 2 + + + False + + + False + True + 3 + + + + + True + True + True + + + True + False + 6 + 6 + vertical + + + + + + + + True + False + Accessibility warnings + + + + + False + True + 4 + + True @@ -426,7 +162,7 @@ False True - 3 + 5 diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 231c6fe2d3cf..172c4504ed92 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -255,6 +255,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"svx/ui/acceptrejectchangesdialog.ui" || rUIFile == u"svx/ui/accessibilitycheckdialog.ui" || rUIFile == u"svx/ui/accessibilitycheckentry.ui" + || rUIFile == u"svx/ui/accessibilitychecklevel.ui" || rUIFile == u"svx/ui/compressgraphicdialog.ui" || rUIFile == u"svx/ui/findreplacedialog.ui" || rUIFile == u"svx/ui/fontworkgallerydialog.ui"