include/vcl/weld.hxx             |    2 +-
 vcl/inc/qt5/QtInstanceWidget.hxx |    2 +-
 vcl/qt5/QtInstanceWidget.cxx     |    6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

New commits:
commit ce871166dad9d1cc618fae1684c8f8031cb4e635
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Aug 7 11:48:48 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Aug 7 14:57:32 2024 +0200

    tdf#130857 qt weld: Implement newly added 'escape_ui_str'
    
    Implement actual Qt-specific handling in
    `weld::QtInstanceWidget::escape_ui_str`, newly added
    in
    
        commit ee749f4b43fea3b666c9c3613b232bc8fecf73fa
        Date:   Tue Aug 6 16:47:30 2024 +0200
    
            add polymorph function for VCL/ui specific string escaping
    
    For a sample use, see also
    
        commit fb56e1e284925937eff4386a7e3655c0f3182640
        Date:   Wed Jul 31 22:25:01 2024 +0200
    
            tdf#161909: Escape filepaths for password dialog.
    
    (See also `vclToQtStringWithAccelerator`, but which
    would result in the accelerator character '~' to be
    preserved/converted as an accelerator, which is
    unintended here.)
    
    While at it, also fix a typo in the doc.
    
    Change-Id: Ic557a1aa8c6b46257a231627d817f1f7e1d101cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171586
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index ed4aedb3d59a..49c92ebb290a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -336,7 +336,7 @@ public:
     /* Escapes string contents which are interpreted by the UI.
 
        Should be overwritten by each VCL implementation to account for the
-       string contents which are interpreted by it's ui.
+       string contents which are interpreted by its ui.
     */
     virtual OUString escape_ui_str(const OUString& rLabel) const = 0;
 
diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index e7f51c97a969..e1dda3f11772 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -150,7 +150,7 @@ public:
 
     virtual OUString strip_mnemonic(const OUString&) const override;
 
-    virtual OUString escape_ui_str(const OUString&) const override;
+    virtual OUString escape_ui_str(const OUString& rLabel) const override;
 
     virtual VclPtr<VirtualDevice> create_virtual_device() const override;
 
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 35bfb4c2cca1..3d377df18202 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -229,7 +229,11 @@ void QtInstanceWidget::help_hierarchy_foreach(const 
std::function<bool(const OUS
 
 OUString QtInstanceWidget::strip_mnemonic(const OUString&) const { return 
OUString(); }
 
-OUString QtInstanceWidget::escape_ui_str(const OUString&) const { return 
OUString(); }
+OUString QtInstanceWidget::escape_ui_str(const OUString& rLabel) const
+{
+    // preserve literal '&'
+    return rLabel.replaceAll("&", "&&");
+}
 
 VclPtr<VirtualDevice> QtInstanceWidget::create_virtual_device() const { return 
nullptr; }
 

Reply via email to