icon-themes/colibre/svx/res/a11y_check_issues_found.png |binary icon-themes/colibre/svx/res/a11y_check_issues_not_found.png |binary icon-themes/colibre_svg/svx/res/a11y_check_issues_found.svg | 1 icon-themes/colibre_svg/svx/res/a11y_check_issues_not_found.svg | 1 sw/inc/OnlineAccessibilityCheck.hxx | 1 sw/inc/bitmaps.hlst | 4 sw/inc/strings.hrc | 2 sw/source/core/txtnode/OnlineAccessibilityCheck.cxx | 17 ++- sw/source/uibase/inc/AccessibilityStatusBarControl.hxx | 3 sw/source/uibase/uiview/view0.cxx | 7 + sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx | 50 +++++----- 11 files changed, 57 insertions(+), 29 deletions(-)
New commits: commit c1bf0277736ebd2e9b31bbbbac08ecb111e894cb Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Nov 14 22:27:50 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Feb 17 05:16:27 2023 +0000 sw: change statusbar to use an icon, fix statusbar updating Change-Id: I98e862c4c1124b1db8eb3e0ea7ff96effd629185 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142721 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit f8b990aaac155f0b45de3a4452bc300dcf2bb49b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144499 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/icon-themes/colibre/svx/res/a11y_check_issues_found.png b/icon-themes/colibre/svx/res/a11y_check_issues_found.png new file mode 100644 index 000000000000..a46aa9152f75 Binary files /dev/null and b/icon-themes/colibre/svx/res/a11y_check_issues_found.png differ diff --git a/icon-themes/colibre/svx/res/a11y_check_issues_not_found.png b/icon-themes/colibre/svx/res/a11y_check_issues_not_found.png new file mode 100644 index 000000000000..8e4ff8edd750 Binary files /dev/null and b/icon-themes/colibre/svx/res/a11y_check_issues_not_found.png differ diff --git a/icon-themes/colibre_svg/svx/res/a11y_check_issues_found.svg b/icon-themes/colibre_svg/svx/res/a11y_check_issues_found.svg new file mode 100644 index 000000000000..706a4735af16 --- /dev/null +++ b/icon-themes/colibre_svg/svx/res/a11y_check_issues_found.svg @@ -0,0 +1 @@ +<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1v14h4.2636719c-.8150834-.984409-1.2618955-2.221947-1.2636719-3.5 0-3.0375661 2.4624339-5.5 5.5-5.5.507518.00206 1.012307.074365 1.5.2148438v-2.2148438l-3-3z" fill="#fafafa"/><path d="m3 0c-.554 0-1 .446-1 1v14c0 .554.446 1 1 1h2 1.0292969 2.3144531a5.5 5.5 0 0 1 -1.0800781-1h-1.0625-1.2011719-2v-14h6v3.5c0 .277.223.5.5.5h3.5v1.2148438a5.5 5.5 0 0 1 1 .3925781v-2.1074219-.8632812l-3.636719-3.6367188h-.863281zm7 1 3 3h-3z" fill="#3a3a38"/><path d="m11.5 7a4.5 4.5 0 0 0 -4.5 4.5 4.5 4.5 0 0 0 4.5 4.5 4.5 4.5 0 0 0 4.5-4.5 4.5 4.5 0 0 0 -4.5-4.5zm-2 1.9902344a.50005.50005 0 0 1 .359375.1503906l1.646484 1.646484 1.646485-1.646484a.50005.50005 0 0 1 .34375-.1503906.50005.50005 0 0 1 .363281.8574218l-1.646484 1.6464848 1.646484 1.646484a.50005.50005 0 1 1 -.707031.707031l-1.646485-1.646484-1.646484 1.646484a.50005.50005 0 1 1 -.7070312-.707031l1.6464842-1.646484-1.6464842-1.6464848a.50005.50005 0 0 1 .3476562-.8574218 z" fill="#ed3d3b"/><path d="m9.5 8.9902344a.50005.50005 0 0 0 -.3476562.8574218l1.6464842 1.6464848-1.6464842 1.646484a.50005.50005 0 1 0 .7070312.707031l1.646484-1.646484 1.646485 1.646484a.50005.50005 0 1 0 .707031-.707031l-1.646484-1.646484 1.646484-1.6464848a.50005.50005 0 0 0 -.363281-.8574218.50005.50005 0 0 0 -.34375.1503906l-1.646485 1.646484-1.646484-1.646484a.50005.50005 0 0 0 -.359375-.1503906z" fill="#fafafa"/></svg> \ No newline at end of file diff --git a/icon-themes/colibre_svg/svx/res/a11y_check_issues_not_found.svg b/icon-themes/colibre_svg/svx/res/a11y_check_issues_not_found.svg new file mode 100644 index 000000000000..f847ab83c834 --- /dev/null +++ b/icon-themes/colibre_svg/svx/res/a11y_check_issues_not_found.svg @@ -0,0 +1 @@ +<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">/&gt;<path d="m1.9743325 9.6823561 4.0175137 3.3539119 8.0350288-10.0617323" fill="none" stroke="#18ab50" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.927546"/></svg> \ No newline at end of file diff --git a/sw/inc/OnlineAccessibilityCheck.hxx b/sw/inc/OnlineAccessibilityCheck.hxx index 5e1da9b77c99..e87f24d61d44 100644 --- a/sw/inc/OnlineAccessibilityCheck.hxx +++ b/sw/inc/OnlineAccessibilityCheck.hxx @@ -67,6 +67,7 @@ public: OnlineAccessibilityCheck(SwDoc& rDocument); void update(SwPosition const& rNewPos); void resetAndQueue(SwNode* pNode); + void updateCheckerActivity(); sal_Int32 getNumberOfAccessibilityIssues() { return m_nAccessibilityIssues; } }; diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst index 2e52f1e47352..b0acb7420db9 100644 --- a/sw/inc/bitmaps.hlst +++ b/sw/inc/bitmaps.hlst @@ -111,6 +111,10 @@ #define RID_BMP_PREVIEW_FALLBACK "sw/res/image-example.png" +#define RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND "svx/res/a11y_check_issues_not_found.png" +#define RID_BMP_A11Y_CHECK_ISSUES_FOUND "svx/res/a11y_check_issues_found.png" + #endif + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 8ec74176c6a8..45d448f373e9 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1089,7 +1089,7 @@ #define STR_BOOKCTRL_HINT NC_("STR_BOOKCTRL_HINT", "Page number in document. Click to open Go to Page dialog or right-click for bookmark list.") #define STR_BOOKCTRL_HINT_EXTENDED NC_("STR_BOOKCTRL_HINT_EXTENDED", "Page number in document (Page number on printed document). Click to open Go to Page dialog.") #define STR_TMPLCTRL_HINT NC_("STR_TMPLCTRL_HINT", "Page Style. Right-click to change style or click to open Style dialog.") -#define STR_ACCESSIBILITY_CHECK_HINT NC_("STR_ACCESSIBILITY_CHECK_HINT", "Status of the accessibility check.") +#define STR_ACCESSIBILITY_CHECK_HINT NC_("STR_ACCESSIBILITY_CHECK_HINT", "Status of the accessibility check.\nNumber of issues found: %issues%.") // Strings for textual attributes. #define STR_DROP_OVER NC_("STR_DROP_OVER", "Drop Caps over") diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx index d162e1a661ba..97f63c7276ab 100644 --- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx +++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx @@ -167,7 +167,7 @@ void OnlineAccessibilityCheck::initialCheck() m_bInitialCheck = true; } -void OnlineAccessibilityCheck::update(const SwPosition& rNewPos) +void OnlineAccessibilityCheck::updateCheckerActivity() { bool bOnlineCheckStatus = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get(); @@ -182,13 +182,24 @@ void OnlineAccessibilityCheck::update(const SwPosition& rNewPos) if (!bOnlineCheckStatus) { clearAccessibilityIssuesFromAllNodes(); // cleanup all accessibility check data on nodes - updateStatusbar(); + m_nAccessibilityIssues = -1; + } + else + { + m_nAccessibilityIssues = 0; } m_bOnlineCheckStatus = bOnlineCheckStatus; + + updateStatusbar(); } +} - if (!bOnlineCheckStatus) +void OnlineAccessibilityCheck::update(const SwPosition& rNewPos) +{ + updateCheckerActivity(); + + if (!m_bOnlineCheckStatus) return; initialCheck(); diff --git a/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx b/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx index 63744499d083..72940cdbce8a 100644 --- a/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx +++ b/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx @@ -10,12 +10,15 @@ #pragma once #include <sfx2/stbitem.hxx> +#include <vcl/image.hxx> namespace sw { class AccessibilityStatusBarControl final : public SfxStatusBarControl { sal_Int32 mnIssues; + Image maImageIssuesFound; + Image maImageIssuesNotFound; public: SFX_DECL_STATUSBAR_CONTROL(); diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index 992579d50f5b..06dca639f718 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -33,6 +33,7 @@ #include <svx/srchdlg.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> #include <sfx2/sidebar/SidebarChildWindow.hxx> #include <uivwimp.hxx> #include <avmedia/mediaplayer.hxx> @@ -50,6 +51,7 @@ #include <cmdid.h> #include <globdoc.hxx> #include <wview.hxx> +#include <OnlineAccessibilityCheck.hxx> #define ShellClass_SwView #define ShellClass_Text @@ -593,6 +595,11 @@ void SwView::ExecViewOptions(SfxRequest &rReq) std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(bSet, batch); batch->commit(); + + SwDocShell *pDocSh = GetDocShell(); + SwDoc* pDocument = pDocSh? pDocSh->GetDoc() : nullptr; + if (pDocument) + pDocument->getOnlineAccessibilityCheck()->updateCheckerActivity(); } break; diff --git a/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx index 100313f709b1..d0ce67fc2349 100644 --- a/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx +++ b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx @@ -13,6 +13,8 @@ #include <svl/intitem.hxx> #include <vcl/status.hxx> #include <vcl/event.hxx> +#include <officecfg/Office/Common.hxx> +#include <bitmaps.hlst> SFX_IMPL_STATUSBAR_CONTROL(sw::AccessibilityStatusBarControl, SfxInt32Item); @@ -22,6 +24,8 @@ AccessibilityStatusBarControl::AccessibilityStatusBarControl(sal_uInt16 _nSlotId StatusBar& rStb) : SfxStatusBarControl(_nSlotId, _nId, rStb) , mnIssues(0) + , maImageIssuesFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_FOUND)) + , maImageIssuesNotFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND)) { } @@ -31,49 +35,45 @@ void AccessibilityStatusBarControl::StateChangedAtStatusBarControl(sal_uInt16 /* SfxItemState eState, const SfxPoolItem* pState) { - if (eState != SfxItemState::DEFAULT) - { - mnIssues = -1; - } - else if (auto pItem = dynamic_cast<const SfxInt32Item*>(pState)) - { - mnIssues = pItem->GetValue(); - } - else - { - mnIssues = -1; - } + mnIssues = -1; - GetStatusBar().SetItemData(GetId(), nullptr); // necessary ? - GetStatusBar().SetItemText(GetId(), ""); // necessary ? + bool bOnlineCheckStatus + = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get(); - if (eState == SfxItemState::DEFAULT) // Can access pState + if (eState == SfxItemState::DEFAULT && bOnlineCheckStatus) { - GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_ACCESSIBILITY_CHECK_HINT)); + if (auto pItem = dynamic_cast<const SfxInt32Item*>(pState)) + mnIssues = pItem->GetValue(); + OUString aString = SwResId(STR_ACCESSIBILITY_CHECK_HINT) + .replaceFirst("%issues%", OUString::number(mnIssues)); + GetStatusBar().SetQuickHelpText(GetId(), aString); } else { GetStatusBar().SetQuickHelpText(GetId(), u""); } + + GetStatusBar().Invalidate(); } void AccessibilityStatusBarControl::Paint(const UserDrawEvent& rUserEvent) { + if (mnIssues < 0) + return; + vcl::RenderContext* pRenderContext = rUserEvent.GetRenderContext(); tools::Rectangle aRect = rUserEvent.GetRect(); - Color aOldLineColor = pRenderContext->GetLineColor(); - Color aOldFillColor = pRenderContext->GetFillColor(); + const tools::Rectangle aControlRect = getControlRect(); - if (mnIssues > 0) - pRenderContext->SetFillColor(COL_RED); - else - pRenderContext->SetFillColor(COL_GREEN); + Image aImage = mnIssues > 0 ? maImageIssuesFound : maImageIssuesNotFound; + + Size aSize(aImage.GetSizePixel()); - pRenderContext->DrawRect(aRect); + auto aPosition = Point(aRect.Left() + (aControlRect.GetWidth() - aSize.Width()) / 2, + aRect.Top() + (aControlRect.GetHeight() - aSize.Height()) / 2); - pRenderContext->SetLineColor(aOldLineColor); - pRenderContext->SetFillColor(aOldFillColor); + pRenderContext->DrawImage(aPosition, aImage); } } // end sw