summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-07-10 14:49:03 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-07-11 06:44:28 +0200
commitf111fbf5d508c8215615f037d7e1c1f563812a13 (patch)
treec1c57cb5b6460ed1c466cae833cc37ec29828008
parent37217909f2e7c042eab9a8b5eb1ab0a88cdda513 (diff)
VCLUnoHelper: Align AWT <-> VCL helpers with convert.hxx impl
There are currently (at least) 2 sets of helpers for converting from AWT to VCL point, rectangle and size classes - and the other way around: * the ones in `include/toolkit/helper/convert.hxx` * the ones provided by `VCLUnoHelper` Align the `VCLUnoHelper` implementations with the ones in `include/toolkit/helper/convert.hxx` and make them inline as well. Switch params from the specific subclasses to the more generic base classes as well (e.g. `css::awt::Point` -> `PointTemplateBase`). Otherwise, `VCLUnoHelper::ConvertToVCLRect` is the only one that didn't implement the functionality in the exact same way as the counterpart, `VCLRectangle`, as it was manually calculating the right and bottom edges. The `VCLRectangle` implementation gives the same result for valid rects, so take over that one. (It shouldn't make a difference for the only 2 current callers, `ControlHolder::getPosSize` and `VCLXGraphics::clear`.) This commit is in preparation of consolidating all uses to use the `VCLUnoHelper` variants and getting rid of the other one in following commits. Change-Id: Id48f81deb05aee2026509037f7d14575735e5be0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170316 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--include/toolkit/helper/vclunohelper.hxx42
-rw-r--r--toolkit/source/helper/vclunohelper.cxx37
2 files changed, 34 insertions, 45 deletions
diff --git a/include/toolkit/helper/vclunohelper.hxx b/include/toolkit/helper/vclunohelper.hxx
index 07d4aeff1047..16616119e1aa 100644
--- a/include/toolkit/helper/vclunohelper.hxx
+++ b/include/toolkit/helper/vclunohelper.hxx
@@ -24,6 +24,9 @@
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/awt/MouseEvent.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/Size.hpp>
#include <vcl/bitmapex.hxx>
#include <vcl/font.hxx>
@@ -122,14 +125,37 @@ public:
/// @throws css::lang::IllegalArgumentException
static MapUnit /* MapModeUnit */ ConvertToMapModeUnit(sal_Int16 /* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit);
- static ::Size /* VCLSize */ ConvertToVCLSize(css::awt::Size const& _aSize);
- static css::awt::Size ConvertToAWTSize(::Size /* VCLSize */ const& _aSize);
-
- static ::Point /* VCLPoint */ ConvertToVCLPoint(css::awt::Point const& _aPoint);
- static css::awt::Point ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint);
-
- static ::tools::Rectangle ConvertToVCLRect( css::awt::Rectangle const & _rRect );
- static css::awt::Rectangle ConvertToAWTRect( ::tools::Rectangle const & _rRect );
+ static inline ::Size ConvertToVCLSize(const css::awt::Size& rAWTSize)
+ {
+ return ::Size(rAWTSize.Width, rAWTSize.Height);
+ }
+
+ static inline css::awt::Size ConvertToAWTSize(const Size& rVCLSize)
+ {
+ return css::awt::Size(rVCLSize.Width(), rVCLSize.Height());
+ }
+
+ static inline ::Point ConvertToVCLPoint(const css::awt::Point& rAWTPoint)
+ {
+ return ::Point(rAWTPoint.X, rAWTPoint.Y);
+ }
+
+ static inline css::awt::Point ConvertToAWTPoint(const PointTemplateBase& rVCLPoint)
+ {
+ return css::awt::Point(rVCLPoint.X(), rVCLPoint.Y());
+ }
+
+ static inline ::tools::Rectangle ConvertToVCLRect(const css::awt::Rectangle& rAWTRect)
+ {
+ return ::tools::Rectangle(::Point(rAWTRect.X, rAWTRect.Y),
+ ::Size(rAWTRect.Width, rAWTRect.Height));
+ }
+
+ static inline css::awt::Rectangle ConvertToAWTRect(const RectangleTemplateBase& rVCLRect)
+ {
+ return css::awt::Rectangle(rVCLRect.Left(), rVCLRect.Top(), rVCLRect.GetWidth(),
+ rVCLRect.GetHeight());
+ }
static css::awt::MouseEvent
createMouseEvent(
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index fc6925561984..354675e5c96b 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -48,8 +48,6 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/awt/Toolkit.hpp>
-#include <com/sun/star/awt/Size.hpp>
-#include <com/sun/star/awt/Point.hpp>
using namespace ::com::sun::star;
@@ -478,41 +476,6 @@ MapUnit /* MapModeUnit */ VCLUnoHelper::ConvertToMapModeUnit(sal_Int16 /* com.su
return eMode;
}
-::Size VCLUnoHelper::ConvertToVCLSize(css::awt::Size const& _aSize)
-{
- ::Size aVCLSize(_aSize.Width, _aSize.Height);
- return aVCLSize;
-}
-
-css::awt::Size VCLUnoHelper::ConvertToAWTSize(::Size /* VCLSize */ const& _aSize)
-{
- css::awt::Size aAWTSize(_aSize.Width(), _aSize.Height());
- return aAWTSize;
-}
-
-
-::Point VCLUnoHelper::ConvertToVCLPoint(css::awt::Point const& _aPoint)
-{
- ::Point aVCLPoint(_aPoint.X, _aPoint.Y);
- return aVCLPoint;
-}
-
-css::awt::Point VCLUnoHelper::ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint)
-{
- css::awt::Point aAWTPoint(_aPoint.X(), _aPoint.Y());
- return aAWTPoint;
-}
-
-::tools::Rectangle VCLUnoHelper::ConvertToVCLRect( css::awt::Rectangle const & _rRect )
-{
- return ::tools::Rectangle( _rRect.X, _rRect.Y, _rRect.X + _rRect.Width - 1, _rRect.Y + _rRect.Height - 1 );
-}
-
-css::awt::Rectangle VCLUnoHelper::ConvertToAWTRect( ::tools::Rectangle const & _rRect )
-{
- return css::awt::Rectangle( _rRect.Left(), _rRect.Top(), _rRect.GetWidth(), _rRect.GetHeight() );
-}
-
awt::MouseEvent VCLUnoHelper::createMouseEvent( const ::MouseEvent& _rVclEvent, const uno::Reference< uno::XInterface >& _rxContext )
{
awt::MouseEvent aMouseEvent;