From 30c0c6cc92df8f86d8b6fdf9143b46f77befc92f Mon Sep 17 00:00:00 2001
From: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri, 11 Apr 2025 17:19:20 +0200
Subject: [PATCH] qt: Consolidate to one toOUString helper

Instead of having one for vcl in vcl/inc/qt5/QtTools.hxx
and one in avmedia/source/qt6/QtFrameGrabber.cxx,
move the existing implementation to
include/vcl/qt/QtUtils.hxx and use it everywhere.

Change-Id: I8576ab0fe2fd12bb25ae262e59acb8412ef8be0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184057
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit d023035acf83ee1b61dfc03333bfc6e612bb58f6)
---

diff --git a/avmedia/source/qt6/QtFrameGrabber.cxx b/avmedia/source/qt6/QtFrameGrabber.cxx
index a9cf99f..b82b020 100644
--- a/avmedia/source/qt6/QtFrameGrabber.cxx
+++ b/avmedia/source/qt6/QtFrameGrabber.cxx
@@ -14,6 +14,7 @@
 #include <vcl/filter/PngImageReader.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/image.hxx>
+#include <vcl/qt/QtUtils.hxx>
 #include <vcl/scheduler.hxx>
 
 #include "QtFrameGrabber.hxx"
@@ -23,11 +24,6 @@
 
 namespace
 {
-inline OUString toOUString(const QString& s)
-{
-    return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length());
-}
-
 uno::Reference<css::graphic::XGraphic> toXGraphic(const QImage& rImage)
 {
     QByteArray aData;
diff --git a/include/vcl/qt/QtUtils.hxx b/include/vcl/qt/QtUtils.hxx
index 87f21d9..3ab5f19 100644
--- a/include/vcl/qt/QtUtils.hxx
+++ b/include/vcl/qt/QtUtils.hxx
@@ -31,6 +31,12 @@
     return QString::fromUtf16(rStr.getStr(), rStr.getLength());
 }
 
+inline OUString toOUString(const QString& s)
+{
+    // QString stores UTF16, just like OUString
+    return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length());
+}
+
 inline QPixmap toQPixmap(const BitmapEx& rBitmapEx)
 {
     SvMemoryStream aMemoryStream;
diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx
index c1b2b75..b090ba3 100644
--- a/vcl/inc/qt5/QtTools.hxx
+++ b/vcl/inc/qt5/QtTools.hxx
@@ -33,6 +33,7 @@
 #include <tools/color.hxx>
 #include <tools/gen.hxx>
 #include <vcl/bitmap/BitmapTypes.hxx>
+#include <vcl/qt/QtUtils.hxx>
 #include <vcl/vclenum.hxx>
 
 #include <com/sun/star/uno/Sequence.hxx>
@@ -43,12 +44,6 @@
 class Image;
 class QImage;
 
-inline OUString toOUString(const QString& s)
-{
-    // QString stores UTF16, just like OUString
-    return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length());
-}
-
 inline QRect toQRect(const tools::Rectangle& rRect)
 {
     return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight());
