filter/inc/strings.hrc           |    9 ++++++++
 filter/source/pdf/impdialog.cxx  |   40 ++++++++++++++++++++++++++++++---------
 include/sfx2/sfxsids.hrc         |    1 
 include/sfx2/sidebar/Sidebar.hxx |    3 +-
 sfx2/sdi/sfx.sdi                 |    2 -
 sfx2/source/sidebar/Sidebar.cxx  |    4 +--
 sfx2/source/view/viewfrm.cxx     |    4 ++-
 7 files changed, 49 insertions(+), 14 deletions(-)

New commits:
commit 53fc5fa0fed077b7d11e39b710280f0a84b631ff
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Mon Mar 20 16:50:55 2023 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Thu Mar 23 21:51:12 2023 +0000

    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.mehrbr...@allotropia.de>

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
             {
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 97b9c2c71e06..fab797e41ff4 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -350,6 +350,7 @@ class SvxZoomItem;
 #define SID_STYLE_DESIGNER                  
TypedWhichId<SfxBoolItem>(SID_SFX_START + 539)
 
 #define SID_SIDEBAR_DECK                    (SID_SFX_START + 850)
+#define SID_SIDEBAR_DECK_TOGGLE             
TypedWhichId<SfxBoolItem>(SID_SFX_START + 851)
 
 #define SID_TEMPLATE_ADDRESSBOOKSOURCE      (SID_SFX_START + 1655)
 
diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx
index 2520a80a4be4..f4d0c1cc9bcb 100644
--- a/include/sfx2/sidebar/Sidebar.hxx
+++ b/include/sfx2/sidebar/Sidebar.hxx
@@ -35,7 +35,8 @@ namespace sfx2::sidebar {
 class SFX2_DLLPUBLIC Sidebar
 {
 public:
-    static void ToggleDeck(std::u16string_view rsDeckId, SfxViewFrame 
*pViewFrame);
+    static void ShowDeck(std::u16string_view rsDeckId, SfxViewFrame* 
pViewFrame,
+                         bool bToggle);
 
     /** Switch to the deck that contains the specified panel and make
         sure that the panel is visible (expanded and scrolled into the
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 750cf6825d31..16e75ded94dc 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4336,7 +4336,7 @@ SfxVoidItem StylePreview SID_STYLE_PREVIEW
 ]
 
 SfxVoidItem SidebarDeck SID_SIDEBAR_DECK
-(SfxStringItem SidebarDeck SID_SIDEBAR_DECK)
+(SfxStringItem SidebarDeck SID_SIDEBAR_DECK, SfxBoolItem SidebarDeckToggle 
SID_SIDEBAR_DECK_TOGGLE)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
index ca48542d5403..e56a259c5e7c 100644
--- a/sfx2/source/sidebar/Sidebar.cxx
+++ b/sfx2/source/sidebar/Sidebar.cxx
@@ -31,7 +31,7 @@ using namespace css;
 
 namespace sfx2::sidebar {
 
-void Sidebar::ToggleDeck(std::u16string_view rsDeckId, SfxViewFrame* 
pViewFrame)
+void Sidebar::ShowDeck(std::u16string_view rsDeckId, SfxViewFrame* pViewFrame, 
bool bToggle)
 {
     if (!pViewFrame)
         return;
@@ -46,7 +46,7 @@ void Sidebar::ToggleDeck(std::u16string_view rsDeckId, 
SfxViewFrame* pViewFrame)
     if (!pController)
         return;
 
-    if (bInitiallyVisible && pController->IsDeckVisible(rsDeckId))
+    if (bToggle && bInitiallyVisible && pController->IsDeckVisible(rsDeckId))
     {
         // close the sidebar if it was already visible and showing this 
sidebar deck
         const util::URL aURL(Tools::GetURL(".uno:Sidebar"));
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 8d4cb75f531b..a5f7c0a8a3c1 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3346,7 +3346,9 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
         if (pDeckIdItem)
         {
             const OUString aDeckId(pDeckIdItem->GetValue());
-            ::sfx2::sidebar::Sidebar::ToggleDeck(aDeckId, this);
+            const SfxBoolItem* pToggleItem = 
rReq.GetArg<SfxBoolItem>(SID_SIDEBAR_DECK_TOGGLE);
+            bool bToggle = pToggleItem && pToggleItem->GetValue();
+            ::sfx2::sidebar::Sidebar::ShowDeck(aDeckId, this, bToggle);
         }
         rReq.Done();
         return;

Reply via email to