From f917d5d3c3e6ae3cebdaed3e13ad216de4158e26 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 11 Apr 2025 17:19:20 +0200 Subject: [PATCH] [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 (cherry picked from commit d023035acf83ee1b61dfc03333bfc6e612bb58f6) Gbp-Pq: Name qt-Consolidate-to-one-toOUString-helper.diff --- 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 a9cf99fadc7..b82b02005d9 100644 --- a/avmedia/source/qt6/QtFrameGrabber.cxx +++ b/avmedia/source/qt6/QtFrameGrabber.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "QtFrameGrabber.hxx" @@ -23,11 +24,6 @@ using namespace ::com::sun::star; namespace { -inline OUString toOUString(const QString& s) -{ - return OUString(reinterpret_cast(s.data()), s.length()); -} - uno::Reference toXGraphic(const QImage& rImage) { QByteArray aData; diff --git a/include/vcl/qt/QtUtils.hxx b/include/vcl/qt/QtUtils.hxx index 87f21d96315..3ab5f19f02c 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(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 c1b2b75fff5..b090ba3718c 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -43,12 +44,6 @@ class Image; class QImage; -inline OUString toOUString(const QString& s) -{ - // QString stores UTF16, just like OUString - return OUString(reinterpret_cast(s.data()), s.length()); -} - inline QRect toQRect(const tools::Rectangle& rRect) { return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight()); -- 2.30.2