include/vcl/imap.hxx                 |    2 +-
 svx/source/sdr/misc/ImageMapInfo.cxx |   16 ++++++++--------
 sw/source/core/layout/atrfrm.cxx     |    3 +--
 vcl/source/treelist/imap.cxx         |    2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit ef609a580b3e1de7c39ef391bb5df92680a22f36
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jul 13 11:54:41 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jul 13 17:58:34 2023 +0200

    ImageMap::GetHitIMapObject can be const
    
    which removes an unnecessary const_cast
    
    Change-Id: I9ef2e7c8b87e15ebd04e8864bfdd322991d9af00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154383
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/vcl/imap.hxx b/include/vcl/imap.hxx
index 6245d2928802..8a34ad1bf7d1 100644
--- a/include/vcl/imap.hxx
+++ b/include/vcl/imap.hxx
@@ -95,7 +95,7 @@ public:
     IMapObject*         GetHitIMapObject( const Size& rOriginalSize,
                                           const Size& rDisplaySize,
                                           const Point& rRelHitPoint,
-                                          sal_uLong nFlags = 0 );
+                                          sal_uLong nFlags = 0 ) const;
 
     // returns the total amount of IMap objects
     size_t              GetIMapObjectCount() const { return maList.size(); }
diff --git a/svx/source/sdr/misc/ImageMapInfo.cxx 
b/svx/source/sdr/misc/ImageMapInfo.cxx
index 1d5600810f09..ac141d253d8b 100644
--- a/svx/source/sdr/misc/ImageMapInfo.cxx
+++ b/svx/source/sdr/misc/ImageMapInfo.cxx
@@ -57,7 +57,7 @@ IMapObject* SvxIMapInfo::GetHitIMapObject(const SdrObject* 
pObj, const Point& rW
         const MapMode aMap100(MapUnit::Map100thMM);
         Size aGraphSize;
         Point aRelPoint(rWinPoint);
-        ImageMap& rImageMap = const_cast<ImageMap&>(pIMapInfo->GetImageMap());
+        const ImageMap& rImageMap = pIMapInfo->GetImageMap();
         tools::Rectangle aRect = pObj->GetLogicRect();
 
         if (pCmpWnd)
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 596ae8d93fe4..c6b975827737 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3591,8 +3591,7 @@ IMapObject* SwFrameFormat::GetIMapObject( const Point& 
rPoint,
                 nFlags = IMAP_MIRROR_HORZ;
 
         }
-        return const_cast<ImageMap*>(rURL.GetMap())->GetHitIMapObject( aOrigSz,
-                                                aActSz, aPos, nFlags );
+        return rURL.GetMap()->GetHitIMapObject( aOrigSz, aActSz, aPos, nFlags 
);
     }
 
     return nullptr;
diff --git a/vcl/source/treelist/imap.cxx b/vcl/source/treelist/imap.cxx
index 5c3b5b0b252a..ba29af020261 100644
--- a/vcl/source/treelist/imap.cxx
+++ b/vcl/source/treelist/imap.cxx
@@ -771,7 +771,7 @@ void ImageMap::InsertIMapObject( 
std::unique_ptr<IMapObject> pNewObject )
 IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize,
                                         const Size& rDisplaySize,
                                         const Point& rRelHitPoint,
-                                        sal_uLong nFlags )
+                                        sal_uLong nFlags ) const
 {
     Point aRelPoint( rTotalSize.Width() * rRelHitPoint.X() / 
rDisplaySize.Width(),
                      rTotalSize.Height() * rRelHitPoint.Y() / 
rDisplaySize.Height() );
commit deb9236d71dddbda6517bdc3a6f0911d38a77113
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Jul 13 11:52:28 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jul 13 17:58:23 2023 +0200

    remove very dodgy const_cast in SvxIMapInfo::GetHitIMapObject
    
    This code has been here since
        commit 8a6861a404c082226b52df335e3b0046164e6432
        Author: Jens-Heiner Rechtien <h...@openoffice.org>
        Date:   Mon Sep 18 23:16:46 2000 +0000
        initial import
    
    but it really does not seem likely that it actually wants to update the
    internal LogicRect of the svx object.
    
    Change-Id: If0523c1e353faf96ca70c6afb3c0125472ca256d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154382
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svx/source/sdr/misc/ImageMapInfo.cxx 
b/svx/source/sdr/misc/ImageMapInfo.cxx
index a37e65247815..1d5600810f09 100644
--- a/svx/source/sdr/misc/ImageMapInfo.cxx
+++ b/svx/source/sdr/misc/ImageMapInfo.cxx
@@ -58,13 +58,13 @@ IMapObject* SvxIMapInfo::GetHitIMapObject(const SdrObject* 
pObj, const Point& rW
         Size aGraphSize;
         Point aRelPoint(rWinPoint);
         ImageMap& rImageMap = const_cast<ImageMap&>(pIMapInfo->GetImageMap());
-        tools::Rectangle& rRect = 
const_cast<tools::Rectangle&>(pObj->GetLogicRect());
+        tools::Rectangle aRect = pObj->GetLogicRect();
 
         if (pCmpWnd)
         {
             MapMode aWndMode = pCmpWnd->GetMapMode();
             aRelPoint = pCmpWnd->LogicToLogic(rWinPoint, &aWndMode, &aMap100);
-            rRect = pCmpWnd->LogicToLogic(pObj->GetLogicRect(), &aWndMode, 
&aMap100);
+            aRect = pCmpWnd->LogicToLogic(pObj->GetLogicRect(), &aWndMode, 
&aMap100);
         }
 
         bool bObjSupported = false;
@@ -78,16 +78,16 @@ IMapObject* SvxIMapInfo::GetHitIMapObject(const SdrObject* 
pObj, const Point& rW
 
             // Undo rotation
             if (rGeo.m_nRotationAngle)
-                RotatePoint(aRelPoint, rRect.TopLeft(), 
-rGeo.mfSinRotationAngle,
+                RotatePoint(aRelPoint, aRect.TopLeft(), 
-rGeo.mfSinRotationAngle,
                             rGeo.mfCosRotationAngle);
 
             // Undo mirroring
             if (pGeoData->bMirrored)
-                aRelPoint.setX(rRect.Right() + rRect.Left() - aRelPoint.X());
+                aRelPoint.setX(aRect.Right() + aRect.Left() - aRelPoint.X());
 
             // Undo shearing
             if (rGeo.m_nShearAngle)
-                ShearPoint(aRelPoint, rRect.TopLeft(), -rGeo.mfTanShearAngle);
+                ShearPoint(aRelPoint, aRect.TopLeft(), -rGeo.mfTanShearAngle);
 
             if (pGrafObj->GetGrafPrefMapMode().GetMapUnit() == 
MapUnit::MapPixel)
                 aGraphSize = Application::GetDefaultDevice()->PixelToLogic(
@@ -108,8 +108,8 @@ IMapObject* SvxIMapInfo::GetHitIMapObject(const SdrObject* 
pObj, const Point& rW
         if (bObjSupported)
         {
             // Calculate relative position of mouse cursor
-            aRelPoint -= rRect.TopLeft();
-            pIMapObj = rImageMap.GetHitIMapObject(aGraphSize, rRect.GetSize(), 
aRelPoint);
+            aRelPoint -= aRect.TopLeft();
+            pIMapObj = rImageMap.GetHitIMapObject(aGraphSize, aRect.GetSize(), 
aRelPoint);
 
             // We don't care about deactivated objects
             if (pIMapObj && !pIMapObj->IsActive())

Reply via email to