sw/inc/AccessibilityCheckStrings.hrc | 2 sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx | 164 +++++++++++++- sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx | 29 ++ sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui | 251 +++++++++++++++++++++- 4 files changed, 432 insertions(+), 14 deletions(-)
New commits: commit ee8405d7567c35ae240e014fe1da289b4bb1abe2 Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Mon Jun 5 14:20:37 2023 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Thu Jun 8 07:56:16 2023 +0200 tdf#155505 Group issues by type in a11y sidebar panel Change-Id: I87349e9d3f5680751a91264e055e4579c97fa93e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152617 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index cb461b1013f8..12e2e1fa2b8d 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -13,7 +13,7 @@ #define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String)) -#define STR_NO_ALT NC_("STR_NO_ALT", "No alt or description text for graphic “%OBJECT_NAME%”.") +#define STR_NO_ALT NC_("STR_NO_ALT", "%OBJECT_NAME%") #define STR_TABLE_MERGE_SPLIT NC_("STR_TABLE_MERGE_SPLIT", "Table “%OBJECT_NAME%” contains merges or splits.") #define STR_FAKE_NUMBERING NC_("STR_FAKE_NUMBERING", "Simulated numbering “%NUMBERING%”.") #define STR_HYPERLINK_TEXT_IS_LINK NC_("STR_HYPERLINK_TEXT_IS_LINK", "Hyperlink text is the same as the link address “%LINK%”.") diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx index c0c8595408c6..1728ed58e266 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx @@ -69,7 +69,24 @@ std::unique_ptr<PanelLayout> A11yCheckIssuesPanel::Create(weld::Widget* pParent, A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* pBindings) : PanelLayout(pParent, "A11yCheckIssuesPanel", "modules/swriter/ui/a11ycheckissuespanel.ui") - , m_xAccessibilityCheckBox(m_xBuilder->weld_box("accessibilityCheckBox")) + , m_xExpanderDocument(m_xBuilder->weld_expander("expand_document")) + , m_xExpanderStyles(m_xBuilder->weld_expander("expand_styles")) + , m_xExpanderNoAlt(m_xBuilder->weld_expander("expand_no_alt")) + , m_xExpanderTable(m_xBuilder->weld_expander("expand_table")) + , m_xExpanderFormatting(m_xBuilder->weld_expander("expand_formatting")) + , m_xExpanderHyperlink(m_xBuilder->weld_expander("expand_hyperlink")) + , m_xExpanderFakes(m_xBuilder->weld_expander("expand_fakes")) + , m_xExpanderNumbering(m_xBuilder->weld_expander("expand_numbering")) + , m_xExpanderOther(m_xBuilder->weld_expander("expand_other")) + , m_xBoxDocument(m_xBuilder->weld_box("box_document")) + , m_xBoxStyles(m_xBuilder->weld_box("box_styles")) + , m_xBoxNoAlt(m_xBuilder->weld_box("box_no_alt")) + , m_xBoxTable(m_xBuilder->weld_box("box_table")) + , m_xBoxFormatting(m_xBuilder->weld_box("box_formatting")) + , m_xBoxHyperlink(m_xBuilder->weld_box("box_hyperlink")) + , m_xBoxFakes(m_xBuilder->weld_box("box_fakes")) + , m_xBoxNumbering(m_xBuilder->weld_box("box_numbering")) + , m_xBoxOther(m_xBuilder->weld_box("box_other")) , mpBindings(pBindings) , mpDoc(nullptr) , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this) @@ -108,7 +125,24 @@ void A11yCheckIssuesPanel::ImplDestroy() batch->commit(); mpBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE); } - m_xAccessibilityCheckBox.reset(); + m_xExpanderDocument.reset(); + m_xExpanderStyles.reset(); + m_xExpanderNoAlt.reset(); + m_xExpanderTable.reset(); + m_xExpanderFormatting.reset(); + m_xExpanderHyperlink.reset(); + m_xExpanderFakes.reset(); + m_xExpanderNumbering.reset(); + m_xExpanderOther.reset(); + m_xBoxDocument.reset(); + m_xBoxStyles.reset(); + m_xBoxNoAlt.reset(); + m_xBoxTable.reset(); + m_xBoxFormatting.reset(); + m_xBoxHyperlink.reset(); + m_xBoxFakes.reset(); + m_xBoxNumbering.reset(); + m_xBoxOther.reset(); } A11yCheckIssuesPanel::~A11yCheckIssuesPanel() { suppress_fun_call_w_exception(ImplDestroy()); } @@ -122,23 +156,133 @@ void A11yCheckIssuesPanel::populateIssues() m_aIssueCollection = aCheck.getIssueCollection(); // Remove old issue widgets - for (auto const& xEntry : m_aAccessibilityCheckEntries) - m_xAccessibilityCheckBox->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aDocumentEntries) + m_xBoxDocument->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aStylesEntries) + m_xBoxStyles->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aNoAltEntries) + m_xBoxNoAlt->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aTableEntries) + m_xBoxTable->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aFormattingEntries) + m_xBoxFormatting->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aHyperlinkEntries) + m_xBoxHyperlink->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aFakesEntries) + m_xBoxFakes->move(xEntry->get_widget(), nullptr); + for (auto const& xEntry : m_aNumberingEntries) + m_xBoxNumbering->move(xEntry->get_widget(), nullptr); - sal_Int32 i = 0; + sal_Int32 iDocument = 0; + sal_Int32 iStyles = 0; + sal_Int32 iNoAlt = 0; + sal_Int32 iTable = 0; + sal_Int32 iFormatting = 0; + sal_Int32 iHyperlink = 0; + sal_Int32 iFakes = 0; + sal_Int32 iNumbering = 0; + sal_Int32 iOther = 0; for (std::shared_ptr<sfx::AccessibilityIssue> const& pIssue : m_aIssueCollection.getIssues()) { - auto xEntry - = std::make_unique<AccessibilityCheckEntry>(m_xAccessibilityCheckBox.get(), pIssue); - m_xAccessibilityCheckBox->reorder_child(xEntry->get_widget(), i++); - m_aAccessibilityCheckEntries.push_back(std::move(xEntry)); + switch (pIssue->m_eIssueID) + { + case sfx::AccessibilityIssueID::DOCUMENT_TITLE: + case sfx::AccessibilityIssueID::DOCUMENT_LANGUAGE: + case sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND: + { + auto xEntry + = std::make_unique<AccessibilityCheckEntry>(m_xBoxDocument.get(), pIssue); + m_xBoxDocument->reorder_child(xEntry->get_widget(), iDocument++); + m_xExpanderDocument->set_visible(true); + m_aDocumentEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::STYLE_LANGUAGE: + { + auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxStyles.get(), pIssue); + m_xBoxStyles->reorder_child(xEntry->get_widget(), iStyles++); + m_xExpanderStyles->set_visible(true); + m_aStylesEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::NO_ALT_OLE: + case sfx::AccessibilityIssueID::NO_ALT_GRAPHIC: + case sfx::AccessibilityIssueID::NO_ALT_SHAPE: + { + auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxNoAlt.get(), pIssue); + m_xBoxNoAlt->reorder_child(xEntry->get_widget(), iNoAlt++); + m_xExpanderNoAlt->set_visible(true); + m_aNoAltEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::TABLE_MERGE_SPLIT: + { + auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxTable.get(), pIssue); + m_xBoxTable->reorder_child(xEntry->get_widget(), iTable++); + m_xExpanderTable->set_visible(true); + m_aTableEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::TEXT_FORMATTING: + case sfx::AccessibilityIssueID::TABLE_FORMATTING: + { + auto xEntry + = std::make_unique<AccessibilityCheckEntry>(m_xBoxFormatting.get(), pIssue); + m_xBoxFormatting->reorder_child(xEntry->get_widget(), iFormatting++); + m_xExpanderFormatting->set_visible(true); + m_aFormattingEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::HYPERLINK_IS_TEXT: + case sfx::AccessibilityIssueID::HYPERLINK_SHORT: + { + auto xEntry + = std::make_unique<AccessibilityCheckEntry>(m_xBoxHyperlink.get(), pIssue); + m_xBoxHyperlink->reorder_child(xEntry->get_widget(), iHyperlink++); + m_xExpanderHyperlink->set_visible(true); + m_aHyperlinkEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::FAKE_FOOTNOTE: + case sfx::AccessibilityIssueID::FAKE_CAPTION: + { + auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxFakes.get(), pIssue); + m_xBoxFakes->reorder_child(xEntry->get_widget(), iFakes++); + m_xExpanderFakes->set_visible(true); + m_aFakesEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::MANUAL_NUMBERING: + { + auto xEntry + = std::make_unique<AccessibilityCheckEntry>(m_xBoxNumbering.get(), pIssue); + m_xBoxNumbering->reorder_child(xEntry->get_widget(), iNumbering++); + m_xExpanderNumbering->set_visible(true); + m_aNumberingEntries.push_back(std::move(xEntry)); + } + break; + case sfx::AccessibilityIssueID::UNSPECIFIED: + { + auto xEntry = std::make_unique<AccessibilityCheckEntry>(m_xBoxOther.get(), pIssue); + m_xBoxOther->reorder_child(xEntry->get_widget(), iOther++); + m_xExpanderOther->set_visible(true); + m_aOtherEntries.push_back(std::move(xEntry)); + } + break; + default: + { + SAL_WARN("sw.a11y", "Invalid issue ID."); + continue; + } + break; + }; } } void A11yCheckIssuesPanel::NotifyItemUpdate(const sal_uInt16 nSid, const SfxItemState /* eState */, const SfxPoolItem* pState) { - if (!m_xAccessibilityCheckBox || !pState) //disposed + if (!pState) //disposed return; switch (nSid) diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx index e13760135c25..1bea8eee98d9 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx @@ -60,8 +60,33 @@ public: virtual ~A11yCheckIssuesPanel() override; private: - std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aAccessibilityCheckEntries; - std::unique_ptr<weld::Box> m_xAccessibilityCheckBox; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aDocumentEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aStylesEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aNoAltEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aTableEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aFormattingEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aHyperlinkEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aFakesEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aNumberingEntries; + std::vector<std::unique_ptr<AccessibilityCheckEntry>> m_aOtherEntries; + std::unique_ptr<weld::Expander> m_xExpanderDocument; + std::unique_ptr<weld::Expander> m_xExpanderStyles; + std::unique_ptr<weld::Expander> m_xExpanderNoAlt; + std::unique_ptr<weld::Expander> m_xExpanderTable; + std::unique_ptr<weld::Expander> m_xExpanderFormatting; + std::unique_ptr<weld::Expander> m_xExpanderHyperlink; + std::unique_ptr<weld::Expander> m_xExpanderFakes; + std::unique_ptr<weld::Expander> m_xExpanderNumbering; + std::unique_ptr<weld::Expander> m_xExpanderOther; + std::unique_ptr<weld::Box> m_xBoxDocument; + std::unique_ptr<weld::Box> m_xBoxStyles; + std::unique_ptr<weld::Box> m_xBoxNoAlt; + std::unique_ptr<weld::Box> m_xBoxTable; + std::unique_ptr<weld::Box> m_xBoxFormatting; + std::unique_ptr<weld::Box> m_xBoxHyperlink; + std::unique_ptr<weld::Box> m_xBoxFakes; + std::unique_ptr<weld::Box> m_xBoxNumbering; + std::unique_ptr<weld::Box> m_xBoxOther; sfx::AccessibilityIssueCollection m_aIssueCollection; std::function<sfx::AccessibilityIssueCollection()> m_getIssueCollection; void populateIssues(); diff --git a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui index 5a55d382a3cd..317897eeb3b3 100644 --- a/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui +++ b/sw/uiconfig/swriter/ui/a11ycheckissuespanel.ui @@ -20,7 +20,256 @@ <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <placeholder/> + <object class="GtkExpander" id="expand_document"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_document"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_document_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_document_label">Document</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_styles"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_styles"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_styles_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_styles_label">Styles</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_no_alt"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_no_alt"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_no_alt_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_no_alt_label">Missing alternative or description text</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_table"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_table"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_table_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_table_label">Table</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_formatting"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_formatting"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_formatting_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_formatting_label">Formatting</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_hyperlink"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_hyperlink"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_hyperlink_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_hyperlink_label">Hyperlink</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_fakes"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_fakes"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_fakes_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_fakes_label">Fakes</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_numbering"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_numbering"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_numbering_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_numbering_label">Numbering</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">7</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expand_other"> + <property name="can-focus">True</property> + <property name="expanded">True</property> + <child> + <object class="GtkBox" id="box_other"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="expand_other_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="a11ycheckissuespanel|expand_other_label">Other</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">8</property> + </packing> </child> </object> <packing>