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

New commits:
commit c80a42e7103d5e282a9e7afd7a50f6996c12eaf1
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Mar 1 16:19:07 2022 +0100
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Mar 1 20:37:49 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>

diff --git a/include/vcl/toolkit/fixed.hxx b/include/vcl/toolkit/fixed.hxx
index 90d19afe43bc..57905797a45c 100644
--- a/include/vcl/toolkit/fixed.hxx
+++ b/include/vcl/toolkit/fixed.hxx
@@ -33,6 +33,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 ed655ede8435..968d5e97504d 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -223,7 +223,7 @@ class JSInstanceBuilder : 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);
@@ -457,10 +457,10 @@ public:
                 bool bTakeOwnership);
 };
 
-class JSLabel : public JSWidget<SalInstanceLabel, FixedText>
+class JSLabel : 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;
 };
@@ -702,6 +702,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 8c02b074992e..6d456d469f21 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -55,7 +55,9 @@ bool isBuilderEnabled(const OUString& rUIFile, bool bMobile)
         || rUIFile == "modules/scalc/ui/textimportcsv.ui"
         || rUIFile == "xmlsec/ui/digitalsignaturesdialog.ui"
         || rUIFile == "xmlsec/ui/viewcertdialog.ui" || rUIFile == 
"xmlsec/ui/certgeneral.ui"
-        || rUIFile == "xmlsec/ui/viewcertdialog.ui" || rUIFile == 
"xmlsec/ui/certpage.ui")
+        || rUIFile == "xmlsec/ui/viewcertdialog.ui" || rUIFile == 
"xmlsec/ui/certpage.ui"
+        || rUIFile == "svx/ui/accessibilitycheckdialog.ui"
+        || rUIFile == "svx/ui/accessibilitycheckentry.ui")
     {
         return true;
     }
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index a5bdd87033f6..c449ad5b74ab 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -711,10 +711,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,
@@ -832,7 +853,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)
@@ -1165,9 +1186,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)
 {
 }
 
@@ -1751,6 +1772,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 2a14679a1a78..ee8f5c0ecd45 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -459,6 +459,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