File: qt-Consolidate-to-one-toOUString-helper.diff

package info (click to toggle)
libreoffice 4%3A25.2.3-2%2Bdeb13u2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,785,556 kB
  • sloc: cpp: 4,354,935; xml: 450,154; java: 260,044; python: 80,206; ansic: 33,790; perl: 30,351; javascript: 18,236; sh: 12,043; makefile: 10,672; cs: 8,865; yacc: 8,549; objc: 2,131; lex: 1,379; asm: 1,231; awk: 996; pascal: 940; csh: 20; sed: 5
file content (90 lines) | stat: -rw-r--r-- 2,944 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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)
---
 avmedia/source/qt6/QtFrameGrabber.cxx | 6 +-----
 include/vcl/qt/QtUtils.hxx            | 6 ++++++
 vcl/inc/qt5/QtTools.hxx               | 7 +------
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/avmedia/source/qt6/QtFrameGrabber.cxx b/avmedia/source/qt6/QtFrameGrabber.cxx
index a9cf99fadc7f..b82b02005d9a 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 @@ using namespace ::com::sun::star;
 
 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 87f21d96315c..3ab5f19f02cb 100644
--- a/include/vcl/qt/QtUtils.hxx
+++ b/include/vcl/qt/QtUtils.hxx
@@ -31,6 +31,12 @@ inline QString toQString(const OUString& rStr)
     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 c1b2b75fff5f..b090ba3718c8 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());
-- 
2.47.2