diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2023-08-14 09:44:35 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2023-08-15 08:56:40 +0200 |
commit | e027ef6c0534b7ce50dc5f8b74e27ce85b9eb97b (patch) | |
tree | 5caa8cc32365fc6ae4af91f372f82ea03b96fd8f /sw | |
parent | 751104215e6c4b42b68dd255e48d771e319555b4 (diff) |
tdf#156670 - A11Y - Open the Format->Description dialog with the fix button
The Fix button will open the Format->Description dialog in case of shapes,
textBox, graphic, OLE objects.
(Remove Description text from (AccessibilityTests1.odt) the shape for proper
testing of no_alt_text.)
Change-Id: I6678fa44a0a47bab60558f770cc709012f02d83b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155653
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/frmfmt.hxx | 2 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt | bin | 19334 -> 25882 bytes | |||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/access/AccessibilityIssue.cxx | 66 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 12 |
5 files changed, 66 insertions, 17 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index cb9846f969c4..6a0c6e8c2276 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -256,6 +256,8 @@ public: OUString GetObjDescription() const; void SetObjDescription( const OUString& rDescription, bool bBroadcast = false ); + + bool IsDecorative() const; void SetObjDecorative(bool isDecorative); /** SwFlyFrameFormat::IsBackgroundTransparent diff --git a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt Binary files differindex 6b55335e773d..405fd6647a08 100644 --- a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt +++ b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index eace70ef7cfc..c73de2bccfc6 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -1517,8 +1517,7 @@ void AccessibilityCheck::checkObject(SwNode* pCurrent, SdrObject* pObject) || nObjId == SdrObjKind::Media || nObjId == SdrObjKind::Group || nObjId == SdrObjKind::Graphic || nInv == SdrInventor::FmForm) { - OUString sAlternative = pObject->GetTitle(); - if (sAlternative.isEmpty()) + if (pObject->GetTitle().isEmpty() && pObject->GetDescription().isEmpty()) { OUString sName = pObject->GetName(); OUString sIssueText = SwResId(STR_NO_ALT).replaceAll("%OBJECT_NAME%", sName); diff --git a/sw/source/core/access/AccessibilityIssue.cxx b/sw/source/core/access/AccessibilityIssue.cxx index 2ec8b5f02e20..9da1952f95bc 100644 --- a/sw/source/core/access/AccessibilityIssue.cxx +++ b/sw/source/core/access/AccessibilityIssue.cxx @@ -26,6 +26,7 @@ #include <comphelper/lok.hxx> #include <cui/dlgname.hxx> #include <svx/svdpage.hxx> +#include <svx/svxdlg.hxx> namespace sw { @@ -160,29 +161,64 @@ void AccessibilityIssue::quickFixIssue() const 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)); + if (pFlyFormat) { - SwFlyFrameFormat* pFlyFormat - = const_cast<SwFlyFrameFormat*>(m_pDoc->FindFlyByName(m_sObjectID)); - if (pFlyFormat) - m_pDoc->SetFlyFrameTitle(*pFlyFormat, aNameDialog.GetName()); + OUString aDescription(pFlyFormat->GetObjDescription()); + OUString aTitle(pFlyFormat->GetObjTitle()); + bool isDecorative(pFlyFormat->IsDecorative()); + + SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell(); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg( + pFact->CreateSvxObjectTitleDescDialog(pWrtShell->GetView().GetFrameWeld(), + aTitle, aDescription, isDecorative)); + + if (pDlg->Execute() == RET_OK) + { + pDlg->GetTitle(aTitle); + pDlg->GetDescription(aDescription); + pDlg->IsDecorative(isDecorative); + + m_pDoc->SetFlyFrameTitle(*pFlyFormat, aTitle); + m_pDoc->SetFlyFrameDescription(*pFlyFormat, aDescription); + m_pDoc->SetFlyFrameDecorative(*pFlyFormat, isDecorative); + + pWrtShell->SetModified(); + } } } break; case IssueObject::SHAPE: case IssueObject::FORM: { - OUString aDesc = SwResId(STR_ENTER_ALT); - SvxNameDialog aNameDialog(m_pParent, "", aDesc); - if (aNameDialog.run() == RET_OK) + SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell(); + auto pPage = pWrtShell->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObj = pPage->GetObjByName(m_sObjectID); + if (pObj) { - SwWrtShell* pWrtShell = m_pDoc->GetDocShell()->GetWrtShell(); - auto pPage = pWrtShell->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); - SdrObject* pObj = pPage->GetObjByName(m_sObjectID); - if (pObj) - pObj->SetTitle(aNameDialog.GetName()); + OUString aTitle(pObj->GetTitle()); + OUString aDescription(pObj->GetDescription()); + bool isDecorative(pObj->IsDecorative()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg( + pFact->CreateSvxObjectTitleDescDialog(pWrtShell->GetView().GetFrameWeld(), + aTitle, aDescription, isDecorative)); + + if (RET_OK == pDlg->Execute()) + { + pDlg->GetTitle(aTitle); + pDlg->GetDescription(aDescription); + pDlg->IsDecorative(isDecorative); + + pObj->SetTitle(aTitle); + pObj->SetDescription(aDescription); + pObj->SetDecorative(isDecorative); + + pWrtShell->SetModified(); + } } } break; diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index c6b975827737..5a48a3965545 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3237,6 +3237,18 @@ OUString SwFlyFrameFormat::GetObjDescription() const return msDesc; } +bool SwFlyFrameFormat::IsDecorative() const +{ + const SdrObject* pMasterObject = FindSdrObject(); + OSL_ENSURE(pMasterObject, "<SwFlyFrameFormat::SetDescription(..)> - missing <SdrObject> instance"); + if (!pMasterObject) + { + return false; + } + + return pMasterObject->IsDecorative(); +} + void SwFlyFrameFormat::SetObjDecorative(bool const isDecorative) { SdrObject* pMasterObject = FindSdrObject(); |