diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2022-03-01 16:19:07 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-03-04 12:30:38 +0100 |
commit | b350a9a3f36282be41a2fb8ea9016f4ccfd4128d (patch) | |
tree | de0c66a1be87253b9b44859156cea86b5a16903a /vcl | |
parent | a8b43900d60c8bb060a3c04b4beb9f3619e1aeca (diff) |
jsdialog: enable Accessibility Check dialog
- fix crash due to wrong type for label
- deduplicate widgets with the same id in one dialog/builder
- refresh on box reordering
Change-Id: I6993552342a3f139de40c3f87243bdf4e0617fc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130797
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130951
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 8 | ||||
-rw-r--r-- | vcl/jsdialog/enabled.cxx | 3 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 39 | ||||
-rw-r--r-- | vcl/source/control/fixed.cxx | 7 |
4 files changed, 47 insertions, 10 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index ca45a53c1e76..7aac0d4e25dd 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -224,7 +224,7 @@ class JSInstanceBuilder final : public SalInstanceBuilder, public JSDialogSender static std::map<std::string, WidgetMap>& GetLOKWeldWidgetsMap(); static void InsertWindowToMap(const std::string& nWindowId); - void RememberWidget(const OString& id, weld::Widget* pWidget); + void RememberWidget(OString id, weld::Widget* pWidget); static void RememberWidget(const std::string& nWindowId, const OString& id, weld::Widget* pWidget); static weld::Widget* FindWeldWidgetsMap(const std::string& nWindowId, const OString& rWidget); @@ -459,10 +459,10 @@ public: bool bTakeOwnership); }; -class JSLabel final : public JSWidget<SalInstanceLabel, FixedText> +class JSLabel final : public JSWidget<SalInstanceLabel, Control> { public: - JSLabel(JSDialogSender* pSender, FixedText* pLabel, SalInstanceBuilder* pBuilder, + JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership); virtual void set_label(const OUString& rText) override; }; @@ -705,6 +705,8 @@ class JSBox : public JSWidget<SalInstanceBox, VclBox> { public: JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + void reorder_child(weld::Widget* pWidget, int nNewPosition) override; }; class JSWidgetInstance : public JSWidget<SalInstanceWidget, vcl::Window> diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 14fc9610c356..31b18a3ae347 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -54,7 +54,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"modules/scalc/ui/textimportcsv.ui" || rUIFile == u"xmlsec/ui/digitalsignaturesdialog.ui" || rUIFile == u"xmlsec/ui/viewcertdialog.ui" || rUIFile == u"xmlsec/ui/certgeneral.ui" - || rUIFile == u"xmlsec/ui/certpage.ui") + || rUIFile == u"xmlsec/ui/certpage.ui" || rUIFile == u"svx/ui/accessibilitycheckdialog.ui" + || rUIFile == u"svx/ui/accessibilitycheckentry.ui") { return true; } diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index b6eac0bf126a..0a49f20a9b82 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -701,10 +701,31 @@ void JSInstanceBuilder::InsertWindowToMap(const std::string& nWindowId) GetLOKWeldWidgetsMap().insert(std::map<std::string, WidgetMap>::value_type(nWindowId, map)); } -void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget) +void JSInstanceBuilder::RememberWidget(OString sId, weld::Widget* pWidget) { - RememberWidget(getMapIdFromWindowId(), id, pWidget); - m_aRememberedWidgets.push_back(id.getStr()); + // do not use the same id for two widgets inside one builder + // exception is sidebar where we base our full invalidation on that "Panel" id sharing + if (m_sTypeOfJSON != "sidebar") + { + static std::atomic<unsigned long long int> nNotRepeatIndex = 0; + auto aWindowIt = GetLOKWeldWidgetsMap().find(getMapIdFromWindowId()); + if (aWindowIt != GetLOKWeldWidgetsMap().end()) + { + auto aWidgetIt = aWindowIt->second.find(sId); + if (aWidgetIt != aWindowIt->second.end()) + { + unsigned long long int nIndex = nNotRepeatIndex++; + // found duplicated it -> add some number to the id and apply to the widget + sId = sId + OString::number(nIndex); + SalInstanceWidget* pSalWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + vcl::Window* pVclWidget = pSalWidget->getWidget(); + pVclWidget->set_id(pVclWidget->get_id() + OUString::number(nIndex)); + } + } + } + + RememberWidget(getMapIdFromWindowId(), sId, pWidget); + m_aRememberedWidgets.push_back(sId.getStr()); } void JSInstanceBuilder::RememberWidget(const std::string& nWindowId, const OString& id, @@ -822,7 +843,7 @@ std::unique_ptr<weld::Container> JSInstanceBuilder::weld_container(const OString std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id) { - ::FixedText* pLabel = m_xBuilder->get<FixedText>(id); + Control* pLabel = m_xBuilder->get<Control>(id); auto pWeldWidget = std::make_unique<JSLabel>(this, pLabel, this, false); if (pWeldWidget) @@ -1155,9 +1176,9 @@ JSContainer::JSContainer(JSDialogSender* pSender, vcl::Window* pContainer, { } -JSLabel::JSLabel(JSDialogSender* pSender, FixedText* pLabel, SalInstanceBuilder* pBuilder, +JSLabel::JSLabel(JSDialogSender* pSender, Control* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : JSWidget<SalInstanceLabel, FixedText>(pSender, pLabel, pBuilder, bTakeOwnership) + : JSWidget<SalInstanceLabel, Control>(pSender, pLabel, pBuilder, bTakeOwnership) { } @@ -1742,6 +1763,12 @@ JSBox::JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder { } +void JSBox::reorder_child(weld::Widget* pWidget, int nNewPosition) +{ + SalInstanceBox::reorder_child(pWidget, nNewPosition); + sendUpdate(); +} + JSImage::JSImage(JSDialogSender* pSender, FixedImage* pImage, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceImage, FixedImage>(pSender, pImage, pBuilder, bTakeOwnership) diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 3ba251d271ce..5b7038bbe633 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -454,6 +454,13 @@ void SelectableFixedText::LoseFocus() Invalidate(); } +void SelectableFixedText::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) +{ + Edit::DumpAsPropertyTree(rJsonWriter); + rJsonWriter.put("type", "fixedtext"); + rJsonWriter.put("selectable", "true"); +} + void FixedLine::ImplInit( vcl::Window* pParent, WinBits nStyle ) { nStyle = ImplInitStyle( nStyle ); |