sw/inc/frmfmt.hxx | 2 sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 3 sw/source/core/access/AccessibilityIssue.cxx | 66 ++++++++++--- sw/source/core/layout/atrfrm.cxx | 12 ++ 5 files changed, 66 insertions(+), 17 deletions(-)
New commits: commit f3f5ad60fbd75f70e7bb5b8bb5444098ff2581eb Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Mon Aug 14 09:44:35 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Aug 16 11:21:04 2023 +0200 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.mehrbr...@allotropia.de> (cherry picked from commit e027ef6c0534b7ce50dc5f8b74e27ce85b9eb97b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155696 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> 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 index 6b55335e773d..405fd6647a08 100644 Binary files a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt and b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index ee2ba0aa8bef..f0d211d40069 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -1469,8 +1469,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 adc52b0dfea2..e0b66391c022 100644 --- a/sw/source/core/access/AccessibilityIssue.cxx +++ b/sw/source/core/access/AccessibilityIssue.cxx @@ -23,6 +23,7 @@ #include <comphelper/lok.hxx> #include <cui/dlgname.hxx> #include <svx/svdpage.hxx> +#include <svx/svxdlg.hxx> namespace sw { @@ -155,29 +156,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 596ae8d93fe4..f988cfa95912 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();