summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-03-20 16:50:55 +0100
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-03-23 21:51:12 +0000
commit53fc5fa0fed077b7d11e39b710280f0a84b631ff (patch)
treeace6d975c020c5c2812a7a07dac6e42da51fb112 /filter
parente713d9be05b788d5da0fff59c6070cca95b73b37 (diff)
tdf#142978 Show a11y sidebar when finding issues on PDF export
Change-Id: I5234aca76153e1a781b7df1d3fbea8bb856af921 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149430 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'filter')
-rw-r--r--filter/inc/strings.hrc9
-rw-r--r--filter/source/pdf/impdialog.cxx40
2 files changed, 40 insertions, 9 deletions
diff --git a/filter/inc/strings.hrc b/filter/inc/strings.hrc
index a8454956f385..2bcbad6e88f3 100644
--- a/filter/inc/strings.hrc
+++ b/filter/inc/strings.hrc
@@ -23,6 +23,7 @@
#include <unotools/resmgr.hxx>
#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NNC_(Context, StringSingular, StringPlural) TranslateNId(Context, reinterpret_cast<char const *>(u8##StringSingular), reinterpret_cast<char const *>(u8##StringPlural))
#define STR_UNKNOWN_APPLICATION NC_("STR_UNKNOWN_APPLICATION", "Unknown")
#define STR_IMPORT_ONLY NC_("STR_IMPORT_ONLY", "import filter")
@@ -75,6 +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_PDFUA_IGNORE NC_("STR_PDFUA_IGNORE", "Continue")
+#define STR_PDFUA_INVESTIGATE NNC_("STR_PDFUA_INVESTIGATE", "Investigate issue", "Investigate issues")
// Progress bar status indicator when importing or exporting
#define STR_FILTER_DOC_LOADING NC_("STR_FILTER_DOC_LOADING", "Loading: ")
@@ -85,4 +89,9 @@ static inline OUString FilterResId(TranslateId aId)
return Translate::get(aId, Translate::Create("flt"));
}
+static inline OUString FilterResId(TranslateNId aContextSingularPlural, int nCardinality)
+{
+ return Translate::nget(aContextSingularPlural, nCardinality, Translate::Create("flt"));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index c43cde0cf6e1..d898a9f86df3 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -26,7 +26,10 @@
#include <sfx2/passwd.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <sfx2/objsh.hxx>
+#include <svl/stritem.hxx>
#include <svx/AccessibilityCheckDialog.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/sfxsids.hrc>
#include <comphelper/lok.hxx>
#include <comphelper/propertyvalue.hxx>
@@ -333,16 +336,35 @@ IMPL_LINK_NOARG(ImpPDFTabDialog, OkHdl, weld::Button&, void)
if (pShell)
{
sfx::AccessibilityIssueCollection aCollection = pShell->runAccessibilityCheck();
- if (!aCollection.getIssues().empty())
+ auto aIssues = aCollection.getIssues();
+ int nIssueCount(aIssues.size());
+ if (!aIssues.empty())
{
- mpAccessibilityCheckDialog = std::make_shared<svx::AccessibilityCheckDialog>(
- m_xDialog.get(), aCollection, [pShell]() -> sfx::AccessibilityIssueCollection {
- return pShell->runAccessibilityCheck();
- });
- mpAccessibilityCheckDialog->getDialog()->set_modal(true);
- weld::DialogController::runAsync(mpAccessibilityCheckDialog, [this](sal_Int32 retValue){
- m_xDialog->response(retValue);
- });
+ OUString aMessage(FilterResId(STR_WARN_PDFUA_ISSUES, nIssueCount));
+ aMessage = aMessage.replaceFirst("%1", OUString::number(nIssueCount));
+
+ std::unique_ptr<weld::MessageDialog> xPDFUADialog(Application::CreateMessageDialog(
+ getGeneralPage()->GetFrameWeld(), VclMessageType::Warning,
+ VclButtonsType::Cancel, aMessage));
+ xPDFUADialog->add_button(FilterResId(STR_PDFUA_INVESTIGATE, nIssueCount), RET_NO);
+ xPDFUADialog->add_button(FilterResId(STR_PDFUA_IGNORE), RET_YES);
+ xPDFUADialog->set_default_response(RET_YES);
+
+ int ret = xPDFUADialog->run();
+ if (ret == RET_YES)
+ m_xDialog->response(RET_OK);
+ else if (ret == RET_NO)
+ {
+ m_xDialog->response(RET_CANCEL);
+ // Show accessiblity check Sidebar deck
+ SfxDispatcher* pDispatcher = pShell->GetDispatcher();
+ if (pDispatcher)
+ {
+ const SfxStringItem sDeckName(SID_SIDEBAR_DECK, "A11yCheckDeck");
+ pDispatcher->ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::RECORD,
+ { &sDeckName });
+ }
+ }
}
else
{