summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-04-03 22:42:57 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-04-20 11:24:51 +0200
commitccd6415902ab2fd35658cb28258e0a7ce935d376 (patch)
tree4c11254e29e86116a1eb81676da131746748d5a9 /sw
parent61be351ac83acec75788d2f79a9038486163160f (diff)
tdf#142978 Add quick fix action for missing alt text
Change-Id: I09234e50def6b52b9a70081f31bb45b8d7e2cdd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150003 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_uwriter.mk1
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/inc/AccessibilityCheckStrings.hrc2
-rw-r--r--sw/source/core/access/AccessibilityIssue.cxx33
-rw-r--r--sw/source/core/inc/AccessibilityIssue.hxx3
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx10
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx2
7 files changed, 52 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk
index 7b328c998fe3..40e6db025fc6 100644
--- a/sw/CppunitTest_sw_uwriter.mk
+++ b/sw/CppunitTest_sw_uwriter.mk
@@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \
$(call gb_Helper_optional,AVMEDIA,avmedia) \
basegfx \
comphelper \
+ cui \
cppu \
cppuhelper \
$(call gb_Helper_optional,DBCONNECTIVITY, \
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 5abd6bb541d7..bc0067dcb8a8 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_use_libraries,sw,\
comphelper \
cppu \
cppuhelper \
+ cui \
$(call gb_Helper_optional,DBCONNECTIVITY, \
dbtools) \
docmodel \
diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc
index bfd0557d8a98..805f525b37e2 100644
--- a/sw/inc/AccessibilityCheckStrings.hrc
+++ b/sw/inc/AccessibilityCheckStrings.hrc
@@ -41,6 +41,8 @@
#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_ALT NC_("STR_ENTER_ALT", "Enter alternative text:")
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx
index f8b8e3858013..628a77e4f2ff 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -9,9 +9,12 @@
*/
#include <AccessibilityIssue.hxx>
+#include <AccessibilityCheckStrings.hrc>
+#include <swtypes.hxx>
#include <wrtsh.hxx>
#include <docsh.hxx>
#include <comphelper/lok.hxx>
+#include <cui/dlgname.hxx>
namespace sw
{
@@ -84,6 +87,36 @@ void AccessibilityIssue::gotoIssue() const
}
}
+bool AccessibilityIssue::canQuickFixIssue() const
+{
+ return m_eIssueObject == IssueObject::GRAPHIC || m_eIssueObject == IssueObject::OLE;
+}
+
+void AccessibilityIssue::quickFixIssue() const
+{
+ if (!m_pDoc)
+ return;
+
+ switch (m_eIssueObject)
+ {
+ case IssueObject::GRAPHIC:
+ case IssueObject::OLE:
+ {
+ OUString aDesc = SwResId(STR_ENTER_ALT);
+ SvxNameDialog aNameDialog(m_pParent, "", aDesc);
+ if (aNameDialog.run() == RET_OK)
+ {
+ SwFlyFrameFormat* pFlyFormat
+ = const_cast<SwFlyFrameFormat*>(m_pDoc->FindFlyByName(m_sObjectID));
+ m_pDoc->SetFlyFrameTitle(*pFlyFormat, aNameDialog.GetName());
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
} // end sw namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx
index 870ad2364692..9cffdd405b9a 100644
--- a/sw/source/core/inc/AccessibilityIssue.hxx
+++ b/sw/source/core/inc/AccessibilityIssue.hxx
@@ -59,6 +59,9 @@ public:
bool canGotoIssue() const override;
void gotoIssue() const override;
+ bool canQuickFixIssue() const override;
+ void quickFixIssue() const override;
+
sal_Int32 getStart() { return m_nStart; }
sal_Int32 getEnd() { return m_nEnd; }
SwNode* getNode() { return m_pNode; }
diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
index 82e7f903ac80..9392bad44ed3 100644
--- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
+++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx
@@ -31,6 +31,7 @@ AccessibilityCheckEntry::AccessibilityCheckEntry(
, m_xContainer(m_xBuilder->weld_container("accessibilityCheckEntryBox"))
, m_xLabel(m_xBuilder->weld_label("accessibilityCheckEntryLabel"))
, m_xGotoButton(m_xBuilder->weld_button("accessibilityCheckEntryGotoButton"))
+ , m_xFixButton(m_xBuilder->weld_button("accessibilityCheckEntryFixButton"))
, m_pAccessibilityIssue(rAccessibilityIssue)
{
m_xLabel->set_label(m_pAccessibilityIssue->m_aIssueText);
@@ -38,6 +39,10 @@ AccessibilityCheckEntry::AccessibilityCheckEntry(
m_xContainer->set_size_request(-1, m_xContainer->get_preferred_size().Height());
m_xGotoButton->set_visible(m_pAccessibilityIssue->canGotoIssue());
m_xGotoButton->connect_clicked(LINK(this, AccessibilityCheckEntry, GotoButtonClicked));
+ m_xFixButton->set_visible(m_pAccessibilityIssue->canQuickFixIssue());
+ m_xFixButton->connect_clicked(LINK(this, AccessibilityCheckEntry, FixButtonClicked));
+
+ m_pAccessibilityIssue->setParent(dynamic_cast<weld::Window*>(get_widget()));
}
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button&, void)
@@ -45,6 +50,11 @@ IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button&, void)
m_pAccessibilityIssue->gotoIssue();
}
+IMPL_LINK_NOARG(AccessibilityCheckEntry, FixButtonClicked, weld::Button&, void)
+{
+ m_pAccessibilityIssue->quickFixIssue();
+}
+
std::unique_ptr<PanelLayout> A11yCheckIssuesPanel::Create(weld::Widget* pParent,
SfxBindings* pBindings)
{
diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
index 23bf6468f196..21ffe9fbc057 100644
--- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
+++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx
@@ -29,6 +29,7 @@ private:
std::unique_ptr<weld::Container> m_xContainer;
std::unique_ptr<weld::Label> m_xLabel;
std::unique_ptr<weld::Button> m_xGotoButton;
+ std::unique_ptr<weld::Button> m_xFixButton;
std::shared_ptr<sfx::AccessibilityIssue> const& m_pAccessibilityIssue;
@@ -39,6 +40,7 @@ public:
weld::Widget* get_widget() const { return m_xContainer.get(); }
DECL_LINK(GotoButtonClicked, weld::Button&, void);
+ DECL_LINK(FixButtonClicked, weld::Button&, void);
};
class A11yCheckIssuesPanel : public PanelLayout,