include/vcl/builder.hxx                 |   24 +++++-------------------
 vcl/source/app/salvtables.cxx           |    2 +-
 vcl/source/control/NotebookbarPopup.cxx |    2 +-
 vcl/source/window/builder.cxx           |    2 +-
 vcl/source/window/dockwin.cxx           |    4 ++--
 5 files changed, 10 insertions(+), 24 deletions(-)

New commits:
commit 92820328943623ef29a76cf7721a52bc7d051c90
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 25 11:20:31 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Sep 25 21:09:53 2024 +0200

    tdf#130857 Use std::u16string_view for VclBuilder::get param
    
    This prepares for reusing the method elsewhere in
    `VclBuilder`.
    
    Only the `SAL_WARN_IF` (a no-op in release builds without
    `--enable-sal-log`) previously needed a `OUString`.
    Call `OUStringToOString` for that one explicitly, which
    is what previously happened implicitly by
    
        template< typename charT, typename traits >
        inline std::basic_ostream<charT, traits> & operator <<(
            std::basic_ostream<charT, traits> & stream, OUString const & 
rString)
    
    defined in include/rtl/ustring.hxx.
    
    Change-Id: I57ebac8c2189afeca33bfa483b8d5d5c7866d904
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173928
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 0e163198465f..e378601656cb 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -72,7 +72,7 @@ public:
     void disposeBuilder();
 
     //sID may not exist, but must be of type T if it does
-    template <typename T = vcl::Window> T* get(const OUString& sID);
+    template <typename T = vcl::Window> T* get(std::u16string_view sID);
 
     vcl::Window*    get_widget_root();
 
@@ -351,11 +351,12 @@ namespace BuilderUtils
 
 //sID may not exist, but must be of type T if it does
 template <typename T>
-inline T* VclBuilder::get(const OUString& sID)
+inline T* VclBuilder::get(std::u16string_view sID)
 {
     vcl::Window *w = get_by_name(sID);
-    SAL_WARN_IF(w && !dynamic_cast<T*>(w),
-        "vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl 
type " << typeid(T).name());
+    SAL_WARN_IF(w && !dynamic_cast<T*>(w), "vcl.layout",
+                ".ui widget \"" << OUStringToOString(sID, 
RTL_TEXTENCODING_UTF8)
+                                << "\" needs to correspond to vcl type " << 
typeid(T).name());
     assert(!w || dynamic_cast<T*>(w));
     return static_cast<T*>(w);
 }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index c875b3847ea1..4dc96a6a1d46 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -7428,7 +7428,7 @@ std::unique_ptr<weld::SizeGroup> 
SalInstanceBuilder::create_size_group()
 
 OUString SalInstanceBuilder::get_current_page_help_id() const
 {
-    vcl::Window* pCtrl = m_xBuilder->get(u"tabcontrol"_ustr);
+    vcl::Window* pCtrl = m_xBuilder->get(u"tabcontrol");
     if (!pCtrl)
         return {};
     VclPtr<vcl::Window> xTabPage;
diff --git a/vcl/source/control/NotebookbarPopup.cxx 
b/vcl/source/control/NotebookbarPopup.cxx
index 17d1d1703e16..d81689ae3071 100644
--- a/vcl/source/control/NotebookbarPopup.cxx
+++ b/vcl/source/control/NotebookbarPopup.cxx
@@ -17,7 +17,7 @@ NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& 
pParent)
     : FloatingWindow(pParent, u"Popup"_ustr, 
u"sfx/ui/notebookbarpopup.ui"_ustr)
     , m_pParent(pParent)
 {
-    m_pBox = m_pUIBuilder->get<VclHBox>(u"box"_ustr);
+    m_pBox = m_pUIBuilder->get<VclHBox>(u"box");
     m_pBox->SetSizePixel(Size(100, 75));
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 54a1fed494d9..4b7d3148be9a 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -818,7 +818,7 @@ VclBuilder::VclBuilder(vcl::Window* pParent, 
std::u16string_view sUIDir, const O
         officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
     if (bHideHelp)
     {
-        if (vcl::Window *pHelpButton = get(u"help"_ustr))
+        if (vcl::Window *pHelpButton = get(u"help"))
             pHelpButton->Hide();
     }
 }
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index c379a37788d1..fd4f07794de4 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -1090,7 +1090,7 @@ DropdownDockingWindow::DropdownDockingWindow(vcl::Window* 
pParent, const css::un
                     !bTearable ? u"vcl/ui/interimdockparent.ui"_ustr : 
u"vcl/ui/interimtearableparent.ui"_ustr,
                     "vcl::DropdownDockingWindow maLayoutIdle",
                     rFrame)
-    , m_xBox(m_pUIBuilder->get(u"box"_ustr))
+    , m_xBox(m_pUIBuilder->get(u"box"))
 {
 }
 
@@ -1107,7 +1107,7 @@ void DropdownDockingWindow::dispose()
 
 ResizableDockingWindow::ResizableDockingWindow(vcl::Window* pParent, const 
css::uno::Reference<css::frame::XFrame>& rFrame)
     : DockingWindow(pParent, u"DockingWindow"_ustr, 
u"vcl/ui/dockingwindow.ui"_ustr, "vcl::ResizableDockingWindow maLayoutIdle", 
rFrame)
-    , m_xBox(m_pUIBuilder->get(u"box"_ustr))
+    , m_xBox(m_pUIBuilder->get(u"box"))
 {
 }
 
commit fa3e77680b4f953a069ec62f75a5370db6d5d751
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 25 11:13:34 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Sep 25 21:09:42 2024 +0200

    tdf#130857 Consolidate to one VclBuilder::get method
    
    Convert the single caller of the other variant to use
    the same as all other places, and drop the now unused
    method.
    
    Change-Id: Icde971b50f39cb8c8f32d1a6ddf4d0cc84f90440
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173927
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 61f7172d0395..0e163198465f 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -70,8 +70,6 @@ public:
     virtual ~VclBuilder();
     ///releases references and disposes all children.
     void disposeBuilder();
-    //sID must exist and be of type T
-    template <typename T> T* get(VclPtr<T>& ret, const OUString& sID);
 
     //sID may not exist, but must be of type T if it does
     template <typename T = vcl::Window> T* get(const OUString& sID);
@@ -351,19 +349,6 @@ namespace BuilderUtils
     sal_Int16 getRoleFromName(const OUString& roleName);
 }
 
-template <typename T>
-inline T* VclBuilder::get(VclPtr<T>& ret, const OUString& sID)
-{
-    vcl::Window *w = get_by_name(sID);
-    SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID << "\" not found in .ui");
-    SAL_WARN_IF(!dynamic_cast<T*>(w),
-       "vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl 
type " << typeid(T).name());
-    assert(w);
-    assert(dynamic_cast<T*>(w));
-    ret = static_cast<T*>(w);
-    return ret.get();
-}
-
 //sID may not exist, but must be of type T if it does
 template <typename T>
 inline T* VclBuilder::get(const OUString& sID)
diff --git a/vcl/source/control/NotebookbarPopup.cxx 
b/vcl/source/control/NotebookbarPopup.cxx
index 2821a048843b..17d1d1703e16 100644
--- a/vcl/source/control/NotebookbarPopup.cxx
+++ b/vcl/source/control/NotebookbarPopup.cxx
@@ -17,7 +17,7 @@ NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& 
pParent)
     : FloatingWindow(pParent, u"Popup"_ustr, 
u"sfx/ui/notebookbarpopup.ui"_ustr)
     , m_pParent(pParent)
 {
-    m_pUIBuilder->get(m_pBox, u"box"_ustr);
+    m_pBox = m_pUIBuilder->get<VclHBox>(u"box"_ustr);
     m_pBox->SetSizePixel(Size(100, 75));
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();

Reply via email to