tdf#155041 - A11Y sidebar: fix warning about missing form control description
Add form control objects to "Go to" and "Fix" functions.
In case of "Go to" a warning dialoge shows up if it is not in Design mode
and ask to switch on Design mode or not.
Change-Id: I79b6d67568e2ddfd121081d4c47ce7588f5d51b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152698
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
(cherry picked from commit c5cde93cd4327f55fdd23e6230c2cb101192374d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152973
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 4165079..766e504 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -637,6 +637,13 @@ public:
return true;
}
/// Switch to Design mode for Forms
virtual bool WarnSwitchToDesignModeDialog() const
{
// override in SwWrtShell
return false;
}
/** Query text within selection. */
void GetSelectedText( OUString &rBuf,
ParaBreakType nHndlParaBreak = ParaBreakType::ToBlank );
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index c18aff4..38ae2f6 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1469,6 +1469,10 @@
// in order to change %PRODUCTNAME at runtime is expensive, so limit doing that as much as possible.
#define STR_A11Y_DESC_AUTO NC_("insertcaption|extended_tip|auto", "Opens the Caption dialog. It has the same information as the dialog you get by menu %PRODUCTNAME Writer - AutoCaption in the Options dialog box.")
#define STR_A11Y_DESIGN_MODE_TITLE NC_("STR_A11Y_DESIGN_MODE_TITLE", "The Forms are not editable")
#define STR_A11Y_DESIGN_MODE_PRIMARY NC_("STR_A11Y_DESIGN_MODE_PRIMARY", "Would you like to switch to Design mode?")
#define STR_A11Y_DESIGN_MODE_SECONDARY NC_("STR_A11Y_DESIGN_MODE_SECONDARY", "You need to switch to design mode to edit Forms.")
#define STR_MARK_COPY NC_("STR_MARK_COPY", "%1 Copy ")
#define STR_INFORODLG_FOLDED_PRIMARY NC_("STR_INFORODLG_FOLDED_PRIMARY", "You are trying to delete folded (hidden) content.")
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index 302d26c..05d2634 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -1360,9 +1360,11 @@ void AccessibilityCheck::checkObject(SdrObject* pObject)
lclAddIssue(m_aIssueCollection, SwResId(STR_FLOATING_TEXT));
const SdrObjKind nObjId = pObject->GetObjIdentifier();
const SdrInventor nInv = pObject->GetObjInventor();
if (nObjId == SdrObjKind::CustomShape || nObjId == SdrObjKind::Text
|| nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group)
|| nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group
|| nInv == SdrInventor::FmForm)
{
OUString sAlternative = pObject->GetTitle();
if (sAlternative.isEmpty())
@@ -1371,7 +1373,12 @@ void AccessibilityCheck::checkObject(SdrObject* pObject)
OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName);
auto pIssue = lclAddIssue(m_aIssueCollection, sIssueText,
sfx::AccessibilityIssueID::NO_ALT_SHAPE);
pIssue->setIssueObject(IssueObject::SHAPE);
// Set FORM Issue for Form objects because of the design mode
if (nInv == SdrInventor::FmForm)
pIssue->setIssueObject(IssueObject::FORM);
else
pIssue->setIssueObject(IssueObject::SHAPE);
pIssue->setObjectID(pObject->GetName());
pIssue->setDoc(*m_pDoc);
}
diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx
index 7f09b9d..d1ebb53 100644
--- a/sw/source/core/access/AccessibilityIssue.cxx
+++ b/sw/source/core/access/AccessibilityIssue.cxx
@@ -71,6 +71,20 @@ void AccessibilityIssue::gotoIssue() const
pWrtShell->ShowCursor();
}
break;
case IssueObject::FORM:
{
SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
bool bIsDesignMode = pWrtShell->GetView().GetFormShell()->IsDesignMode();
if (bIsDesignMode || (!bIsDesignMode && pWrtShell->WarnSwitchToDesignModeDialog()))
{
if (!bIsDesignMode)
pWrtShell->GetView().GetFormShell()->SetDesignMode(true);
pWrtShell->GotoDrawingObject(m_sObjectID);
if (comphelper::LibreOfficeKit::isActive())
pWrtShell->ShowCursor();
}
}
break;
case IssueObject::TABLE:
{
SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell();
@@ -105,7 +119,7 @@ void AccessibilityIssue::gotoIssue() const
bool AccessibilityIssue::canQuickFixIssue() const
{
return m_eIssueObject == IssueObject::GRAPHIC || m_eIssueObject == IssueObject::OLE
|| m_eIssueObject == IssueObject::SHAPE;
|| m_eIssueObject == IssueObject::SHAPE || m_eIssueObject == IssueObject::FORM;
}
void AccessibilityIssue::quickFixIssue() const
@@ -130,6 +144,7 @@ void AccessibilityIssue::quickFixIssue() const
}
break;
case IssueObject::SHAPE:
case IssueObject::FORM:
{
OUString aDesc = SwResId(STR_ENTER_ALT);
SvxNameDialog aNameDialog(m_pParent, "", aDesc);
diff --git a/sw/source/core/inc/AccessibilityIssue.hxx b/sw/source/core/inc/AccessibilityIssue.hxx
index 208f265..5a51ba2 100644
--- a/sw/source/core/inc/AccessibilityIssue.hxx
+++ b/sw/source/core/inc/AccessibilityIssue.hxx
@@ -22,6 +22,7 @@ enum class IssueObject
GRAPHIC,
OLE,
SHAPE,
FORM,
TABLE,
TEXT,
};
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index b183409..4edbca9 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -516,6 +516,7 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
bool HasFoldedOutlineContentSelected() const;
virtual void InfoReadOnlyDialog(bool bAsync) const override;
virtual bool WarnHiddenSectionDialog() const override;
virtual bool WarnSwitchToDesignModeDialog() const override;
std::optional<OString> getLOKPayload(int nType, int nViewId) const;
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 9ffab76..7a39048 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2710,4 +2710,15 @@ bool SwWrtShell::WarnHiddenSectionDialog() const
return (RET_YES == xQuery->run());
}
bool SwWrtShell::WarnSwitchToDesignModeDialog() const
{
std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(nullptr,
VclMessageType::Question, VclButtonsType::YesNo, SwResId(STR_A11Y_DESIGN_MODE_PRIMARY)));
xQuery->set_default_response(RET_YES);
xQuery->set_title(SwResId(STR_A11Y_DESIGN_MODE_TITLE));
xQuery->set_secondary_text(SwResId(STR_A11Y_DESIGN_MODE_SECONDARY));
return (RET_YES == xQuery->run());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */