From b350a9a3f36282be41a2fb8ea9016f4ccfd4128d Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Tue, 1 Mar 2022 16:19:07 +0100 Subject: jsdialog: enable Accessibility Check dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Reviewed-by: Henry Castro Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130951 Tested-by: Jenkins Reviewed-by: Szymon Kłos --- vcl/inc/jsdialog/jsdialogbuilder.hxx | 8 +++++--- vcl/jsdialog/enabled.cxx | 3 ++- vcl/jsdialog/jsdialogbuilder.cxx | 39 ++++++++++++++++++++++++++++++------ vcl/source/control/fixed.cxx | 7 +++++++ 4 files changed, 47 insertions(+), 10 deletions(-) (limited to 'vcl') 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& 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 +class JSLabel final : public JSWidget { 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 { public: JSBox(JSDialogSender* pSender, VclBox* pBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + void reorder_child(weld::Widget* pWidget, int nNewPosition) override; }; class JSWidgetInstance : public JSWidget 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::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 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(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 JSInstanceBuilder::weld_container(const OString std::unique_ptr JSInstanceBuilder::weld_label(const OString& id) { - ::FixedText* pLabel = m_xBuilder->get(id); + Control* pLabel = m_xBuilder->get(id); auto pWeldWidget = std::make_unique(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(pSender, pLabel, pBuilder, bTakeOwnership) + : JSWidget(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(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 ); -- cgit v1.2.3