diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-07-10 14:49:03 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-07-11 06:44:28 +0200 |
commit | f111fbf5d508c8215615f037d7e1c1f563812a13 (patch) | |
tree | c1c57cb5b6460ed1c466cae833cc37ec29828008 /include | |
parent | 37217909f2e7c042eab9a8b5eb1ab0a88cdda513 (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
Diffstat (limited to 'include')
-rw-r--r-- | include/toolkit/helper/vclunohelper.hxx | 42 |
1 files changed, 34 insertions, 8 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( |