include/vcl/toolkit/fixed.hxx        |    1 
 vcl/inc/jsdialog/jsdialogbuilder.hxx |    8 ++++---
 vcl/jsdialog/enabled.cxx             |    3 +-
 vcl/jsdialog/jsdialogbuilder.cxx     |   39 +++++++++++++++++++++++++++++------
 vcl/source/control/fixed.cxx         |    7 ++++++
 5 files changed, 48 insertions(+), 10 deletions(-)

New commits:
commit e9ddfd06fc706b4be2955c6aa462a41ec22bce93
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Mar 1 16:19:07 2022 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Mon Mar 14 16:19:54 2022 +0100

    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 <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131120
    Tested-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/include/vcl/toolkit/fixed.hxx b/include/vcl/toolkit/fixed.hxx
index afa0004f7ec8..238d1cbdfafb 100644
--- a/include/vcl/toolkit/fixed.hxx
+++ b/include/vcl/toolkit/fixed.hxx
@@ -83,6 +83,7 @@ public:
 
     virtual void    LoseFocus() override;
     virtual void    ApplySettings(vcl::RenderContext&) override;
+    virtual void    DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) 
override;
 };
 
 class VCL_DLLPUBLIC FixedLine final : public Control
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index b3beba7d14a7..db010df11d21 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -225,7 +225,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);
@@ -460,10 +460,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;
 };
@@ -706,6 +706,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 6de05a65c9eb..9aa8d19db108 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 693ddd6232c4..7ca9cceb16c9 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -704,10 +704,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,
@@ -825,7 +846,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)
@@ -1158,9 +1179,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)
 {
 }
 
@@ -1745,6 +1766,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 d06eeecc292e..647a1e96c506 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 );

Reply via email to