summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-08-26 22:03:54 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-08-27 12:29:57 +0200
commit09be7ac7dce1e8141f25bc84273968ea273a018c (patch)
tree736ef1b9d555abb966f19e7c95dcd23dc647956f
parentc7ea7664002b54786795fab7f6233024a6362f71 (diff)
Move ImageMap related functions to svx
So that in can be used from slideshow module Change-Id: I105582cf523a454701963a253ba39054f09730e8 Reviewed-on: https://gerrit.libreoffice.org/78156 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--include/svx/ImageMapInfo.hxx (renamed from sd/inc/imapinfo.hxx)39
-rw-r--r--sd/inc/drawdoc.hxx7
-rw-r--r--sd/inc/glob.hxx2
-rw-r--r--sd/inc/pch/precompiled_sd.hxx1
-rw-r--r--sd/source/core/drawdoc2.cxx94
-rw-r--r--sd/source/filter/html/htmlex.cxx6
-rw-r--r--sd/source/ui/app/sdxfer.cxx4
-rw-r--r--sd/source/ui/func/fudraw.cxx6
-rw-r--r--sd/source/ui/func/fusel.cxx4
-rw-r--r--sd/source/ui/unoidl/unoobj.cxx8
-rw-r--r--sd/source/ui/view/drviewsc.cxx4
-rw-r--r--sd/source/ui/view/drviewsg.cxx6
-rw-r--r--sd/source/ui/view/sdview3.cxx6
-rw-r--r--sd/source/ui/view/sdview4.cxx8
-rw-r--r--solenv/clang-format/blacklist1
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/sdr/misc/ImageMapInfo.cxx122
17 files changed, 174 insertions, 145 deletions
diff --git a/sd/inc/imapinfo.hxx b/include/svx/ImageMapInfo.hxx
index b5eb928ffeaa..424e69679ec3 100644
--- a/sd/inc/imapinfo.hxx
+++ b/include/svx/ImageMapInfo.hxx
@@ -17,34 +17,39 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_SD_INC_IMAPINFO_HXX
-#define INCLUDED_SD_INC_IMAPINFO_HXX
+#pragma once
-#include "glob.hxx"
+#include <svx/svxdllapi.h>
#include <svx/svdobj.hxx>
#include <vcl/imap.hxx>
-class SdIMapInfo : public SdrObjUserData, public SfxListener
-{
+#define SVX_IMAPINFO_ID 2
- ImageMap aImageMap;
+class SVX_DLLPUBLIC SvxIMapInfo : public SdrObjUserData, public SfxListener
+{
+ ImageMap aImageMap;
public:
- SdIMapInfo( const ImageMap& rImageMap ) :
- SdrObjUserData( SdrInventor::StarDrawUserData, SD_IMAPINFO_ID ),
- aImageMap( rImageMap ) {};
+ SvxIMapInfo(const ImageMap& rImageMap)
+ : SdrObjUserData(SdrInventor::StarDrawUserData, SVX_IMAPINFO_ID)
+ , aImageMap(rImageMap){};
- SdIMapInfo( const SdIMapInfo& rIMapInfo ) :
- SdrObjUserData( SdrInventor::StarDrawUserData, SD_IMAPINFO_ID ),
- SfxListener(),
- aImageMap( rIMapInfo.aImageMap ) {};
+ SvxIMapInfo(const SvxIMapInfo& rIMapInfo)
+ : SdrObjUserData(SdrInventor::StarDrawUserData, SVX_IMAPINFO_ID)
+ , SfxListener()
+ , aImageMap(rIMapInfo.aImageMap){};
- virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override { return std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *this )); }
+ virtual std::unique_ptr<SdrObjUserData> Clone(SdrObject*) const override
+ {
+ return std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*this));
+ }
- void SetImageMap( const ImageMap& rIMap ) { aImageMap = rIMap; }
+ void SetImageMap(const ImageMap& rIMap) { aImageMap = rIMap; }
const ImageMap& GetImageMap() const { return aImageMap; }
-};
-#endif // INCLUDED_SD_INC_IMAPINFO_HXX
+ static SvxIMapInfo* GetIMapInfo(SdrObject const* pObject);
+ static IMapObject* GetHitIMapObject(SdrObject const* pObj, const Point& rWinPoint);
+ static ImageMap* GetImageMapForObject(SdrObject* pObj);
+};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 52e31ce2b91b..64397dd9a960 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/text/WritingMode.hpp>
#include <svl/style.hxx>
#include <svx/fmmodel.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <vcl/prntypes.hxx>
#include <xmloff/autolayout.hxx>
@@ -55,8 +56,6 @@ class Timer;
class SfxObjectShell;
class SdPage;
class SdAnimationInfo;
-class SdIMapInfo;
-class IMapObject;
class SdStyleSheetPool;
class SfxMedium;
class SvxSearchItem;
@@ -478,9 +477,6 @@ public:
static SdAnimationInfo* GetShapeUserData(SdrObject& rObject, bool bCreate = false );
- SAL_DLLPRIVATE static SdIMapInfo* GetIMapInfo( SdrObject const * pObject );
- SAL_DLLPRIVATE static IMapObject* GetHitIMapObject( SdrObject const * pObject, const Point& rWinPoint );
-
SAL_DLLPRIVATE CharClass* GetCharClass() const { return mpCharClass.get(); }
SAL_DLLPRIVATE void UpdateAllLinks();
@@ -706,7 +702,6 @@ private:
SAL_DLLPRIVATE virtual void PageListChanged() override;
SAL_DLLPRIVATE virtual void MasterPageListChanged() override;
- SAL_DLLPRIVATE virtual ImageMap* GetImageMapForObject(SdrObject* pObj) override;
};
namespace sd
diff --git a/sd/inc/glob.hxx b/sd/inc/glob.hxx
index 4708196316d0..884d16032719 100644
--- a/sd/inc/glob.hxx
+++ b/sd/inc/glob.hxx
@@ -42,7 +42,7 @@
// Object-Ids for StarDraw UserData
#define SD_ANIMATIONINFO_ID 1
-#define SD_IMAPINFO_ID 2
+// SVX_IMAPINFO_ID = 2
// Separator between layout name and template name of presentation templates
#define SD_LT_SEPARATOR "~LT~"
diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx
index 0d640c20e0d6..4e6053bc295a 100644
--- a/sd/inc/pch/precompiled_sd.hxx
+++ b/sd/inc/pch/precompiled_sd.hxx
@@ -492,7 +492,6 @@
#include <drawdoc.hxx>
#include <glob.hxx>
#include <helpids.h>
-#include <imapinfo.hxx>
#include <notifydocumentevent.hxx>
#include <sdabstdlg.hxx>
#include <sdattr.hxx>
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 8638ec8a00b6..b7c1ae455d42 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -39,6 +39,7 @@
#include <svx/svdlayer.hxx>
#include <svx/svditer.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <vcl/imapobj.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
@@ -51,7 +52,6 @@
#include <glob.hxx>
#include <stlpool.hxx>
#include <anminfo.hxx>
-#include <imapinfo.hxx>
#include <undo/undomanager.hxx>
#include <DrawDocShell.hxx>
@@ -993,98 +993,6 @@ SdAnimationInfo* SdDrawDocument::GetShapeUserData(SdrObject& rObject, bool bCrea
return pRet;
}
-SdIMapInfo* SdDrawDocument::GetIMapInfo( SdrObject const * pObject )
-{
- DBG_ASSERT(pObject, "Without an object there is no IMapInfo");
-
- SdIMapInfo* pIMapInfo = nullptr;
- sal_uInt16 nCount = pObject->GetUserDataCount();
-
- // Can we find IMap information within the user data?
- for ( sal_uInt16 i = 0; i < nCount; i++ )
- {
- SdrObjUserData* pUserData = pObject->GetUserData( i );
-
- if ( ( pUserData->GetInventor() == SdrInventor::StarDrawUserData ) && ( pUserData->GetId() == SD_IMAPINFO_ID ) )
- pIMapInfo = static_cast<SdIMapInfo*>(pUserData);
- }
-
- return pIMapInfo;
-}
-
-IMapObject* SdDrawDocument::GetHitIMapObject( SdrObject const * pObj,
- const Point& rWinPoint )
-{
- SdIMapInfo* pIMapInfo = GetIMapInfo( pObj );
- IMapObject* pIMapObj = nullptr;
-
- if ( pIMapInfo )
- {
- const MapMode aMap100( MapUnit::Map100thMM );
- Size aGraphSize;
- Point aRelPoint( rWinPoint );
- ImageMap& rImageMap = const_cast<ImageMap&>(pIMapInfo->GetImageMap());
- const ::tools::Rectangle& rRect = pObj->GetLogicRect();
- bool bObjSupported = false;
-
- // execute HitTest
- if ( auto pGrafObj = dynamic_cast< const SdrGrafObj *>( pObj ) ) // simple graphics object
- {
- const GeoStat& rGeo = pGrafObj->GetGeoStat();
- std::unique_ptr<SdrGrafObjGeoData> pGeoData(static_cast<SdrGrafObjGeoData*>( pGrafObj->GetGeoData() ));
-
- // Undo rotation
- if ( rGeo.nRotationAngle )
- RotatePoint( aRelPoint, rRect.TopLeft(), -rGeo.nSin, rGeo.nCos );
-
- // Undo mirroring
- if ( pGeoData->bMirrored )
- aRelPoint.setX( rRect.Right() + rRect.Left() - aRelPoint.X() );
-
- // Undo shearing
- if ( rGeo.nShearAngle )
- ShearPoint( aRelPoint, rRect.TopLeft(), -rGeo.nTan );
-
- if ( pGrafObj->GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
- aGraphSize = Application::GetDefaultDevice()->PixelToLogic( pGrafObj->GetGrafPrefSize(), aMap100 );
- else
- aGraphSize = OutputDevice::LogicToLogic( pGrafObj->GetGrafPrefSize(),
- pGrafObj->GetGrafPrefMapMode(), aMap100 );
-
- bObjSupported = true;
- }
- else if ( auto pOleObj = dynamic_cast<const SdrOle2Obj* >(pObj) ) // OLE object
- {
- aGraphSize = pOleObj->GetOrigObjSize();
- bObjSupported = true;
- }
-
- // Everything worked out well, thus execute HitTest
- if ( bObjSupported )
- {
- // Calculate relative position of mouse cursor
- aRelPoint -= rRect.TopLeft();
- pIMapObj = rImageMap.GetHitIMapObject( aGraphSize, rRect.GetSize(), aRelPoint );
-
- // We don't care about deactivated objects
- if ( pIMapObj && !pIMapObj->IsActive() )
- pIMapObj = nullptr;
- }
- }
-
- return pIMapObj;
-}
-
-ImageMap* SdDrawDocument::GetImageMapForObject(SdrObject* pObj)
-{
- SdIMapInfo* pIMapInfo = GetIMapInfo( pObj );
- if ( pIMapInfo )
- {
- return const_cast<ImageMap*>( &(pIMapInfo->GetImageMap()) );
- }
- return nullptr;
-}
-
/** this method enforces that the masterpages are in the correct order,
that is at position 1 is a PageKind::Standard masterpage followed by a
PageKind::Notes masterpage and so on. #
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index c00b7970637c..cb06804eb6aa 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -55,6 +55,7 @@
#include <svx/svdoutl.hxx>
#include <svx/svdogrp.hxx>
#include <svx/svdotable.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <tools/urlobj.hxx>
#include <svtools/sfxecode.hxx>
#include <comphelper/anytostring.hxx>
@@ -71,7 +72,6 @@
#include <strings.hrc>
#include <strings.hxx>
#include <anminfo.hxx>
-#include <imapinfo.hxx>
#include <sdresid.hxx>
#include "buttonset.hxx"
@@ -1549,7 +1549,7 @@ bool HtmlExport::CreateHtmlForPresPages()
while (pObject)
{
SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObject);
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo(pObject);
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(pObject);
if ((pInfo &&
(pInfo->meClickAction == presentation::ClickAction_BOOKMARK ||
@@ -1665,7 +1665,7 @@ bool HtmlExport::CreateHtmlForPresPages()
for (SdrObject* pObject : aClickableObjects)
{
SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObject);
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo(pObject);
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(pObject);
::tools::Rectangle aRect(pObject->GetCurrentBoundRect());
Point aLogPos(aRect.TopLeft());
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 5d042ff64c5a..a48721c3f888 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -34,6 +34,7 @@
#include <editeng/editobj.hxx>
#include <svx/fmglob.hxx>
#include <svx/svdouno.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <sot/formats.hxx>
#include <svl/urlbmk.hxx>
@@ -54,7 +55,6 @@
#include <sdpage.hxx>
#include <drawdoc.hxx>
#include <stlpool.hxx>
-#include <imapinfo.hxx>
#include <sdxfer.hxx>
#include <unomodel.hxx>
#include <vcl/virdev.hxx>
@@ -228,7 +228,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
}
}
- SdIMapInfo* pInfo = SdDrawDocument::GetIMapInfo( pObj );
+ SvxIMapInfo* pInfo = SvxIMapInfo::GetIMapInfo( pObj );
if( pInfo )
mpImageMap.reset( new ImageMap( pInfo->GetImageMap() ) );
diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx
index 5e319eafd260..295f73a0f4c8 100644
--- a/sd/source/ui/func/fudraw.cxx
+++ b/sd/source/ui/func/fudraw.cxx
@@ -589,7 +589,7 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt)
*/
bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
{
- bool bImageMapInfo = SdDrawDocument::GetIMapInfo(pObj) != nullptr;
+ bool bImageMapInfo = SvxIMapInfo::GetIMapInfo(pObj) != nullptr;
if (!bImageMapInfo)
return false;
@@ -618,7 +618,7 @@ bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
pVisiLayer, false)))
{
// hit inside the object (without margin) or open object
- if (SdDrawDocument::GetHitIMapObject(pObj, rPos))
+ if (SvxIMapInfo::GetHitIMapObject(pObj, rPos))
{
mpWindow->SetPointer(PointerStyle::RefHand);
return true;
@@ -737,7 +737,7 @@ bool FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewE
{
OUString aHelpText;
Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(rPosPixel)));
- IMapObject* pIMapObj = SdDrawDocument::GetHitIMapObject(pObj, aPos);
+ IMapObject* pIMapObj = SvxIMapInfo::GetHitIMapObject(pObj, aPos);
if (!rVEvt.pURLField && !pIMapObj)
return false;
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 19fa3326e64c..2c59e1826b19 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -1244,9 +1244,9 @@ bool FuSelection::HandleImageMapClick(SdrObject* pObj, const Point& rPos)
&& SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(),
pVisiLayer, false)))
{
- if (SdDrawDocument::GetIMapInfo(pObj))
+ if (SvxIMapInfo::GetIMapInfo(pObj))
{
- const IMapObject* pIMapObj = SdDrawDocument::GetHitIMapObject(pObj, rPos);
+ const IMapObject* pIMapObj = SvxIMapInfo::GetHitIMapObject(pObj, rPos);
if (pIMapObj && !pIMapObj->GetURL().isEmpty())
{
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index 1c6751feab76..f17c43694bdb 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -50,6 +50,7 @@
#include <svx/svdopath.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdograf.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <filter/msfilter/msdffimp.hxx>
#include <svl/instrm.hxx>
#include <editeng/outlobj.hxx>
@@ -74,7 +75,6 @@
#include <DrawDocShell.hxx>
#include <glob.hxx>
#include "unolayer.hxx"
-#include <imapinfo.hxx>
#include <EffectMigration.hxx>
using namespace ::sd;
@@ -632,7 +632,7 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c
if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
throw lang::IllegalArgumentException();
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo(pObj);
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(pObj);
if( pIMapInfo )
{
// replace existing image map
@@ -641,7 +641,7 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c
else
{
// insert new user data with image map
- pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(aImageMap) ));
+ pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(aImageMap) ));
}
}
}
@@ -775,7 +775,7 @@ css::uno::Any SAL_CALL SdXShape::getPropertyValue( const OUString& PropertyName
if( pDoc )
{
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo(mpShape->GetSdrObject());
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(mpShape->GetSdrObject());
if( pIMapInfo )
{
const ImageMap& rIMap = pIMapInfo->GetImageMap();
diff --git a/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx
index e819d24d3c90..b4e4a04c4063 100644
--- a/sd/source/ui/view/drviewsc.cxx
+++ b/sd/source/ui/view/drviewsc.cxx
@@ -29,6 +29,7 @@
#include <svx/svdoole2.hxx>
#include <svx/svdograf.hxx>
#include <svx/svxdlg.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <svl/style.hxx>
@@ -40,7 +41,6 @@
#include <app.hrc>
#include <Window.hxx>
-#include <imapinfo.hxx>
#include <drawdoc.hxx>
#include <DrawDocShell.hxx>
#include <drawview.hxx>
@@ -59,7 +59,7 @@ void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
Graphic aGraphic;
ImageMap* pIMap = nullptr;
std::unique_ptr<TargetList> pTargetList;
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo( pObj );
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pObj );
// get graphic from shape
SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx
index aaf3d3d7fa09..2b699d322e4e 100644
--- a/sd/source/ui/view/drviewsg.cxx
+++ b/sd/source/ui/view/drviewsg.cxx
@@ -27,12 +27,12 @@
#include <sfx2/viewfrm.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdoole2.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <app.hrc>
#include <drawdoc.hxx>
#include <slideshow.hxx>
-#include <imapinfo.hxx>
#include <sdmod.hxx>
#include <optsitem.hxx>
#include <FrameView.hxx>
@@ -61,10 +61,10 @@ void DrawViewShell::ExecIMap( SfxRequest const & rReq )
if ( pDlg->GetEditingObject() == static_cast<void*>(pSdrObj) )
{
const ImageMap& rImageMap = pDlg->GetImageMap();
- SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo( pSdrObj );
+ SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
if ( !pIMapInfo )
- pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( rImageMap )) );
+ pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
else
pIMapInfo->SetImageMap( rImageMap );
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 14eaef7bdd91..c06e91eeead4 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -49,6 +49,7 @@
#include <svx/obj3d.hxx>
#include <svx/e3dundo.hxx>
#include <svx/unomodel.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <unotools/streamwrap.hxx>
#include <vcl/metaact.hxx>
#include <svx/svxids.hrc>
@@ -65,7 +66,6 @@
#include <sdmod.hxx>
#include <sdresid.hxx>
#include <strings.hrc>
-#include <imapinfo.hxx>
#include <SlideSorterViewShell.hxx>
#include <strmname.h>
#include <unomodel.hxx>
@@ -1004,7 +1004,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
InsertObjectAtView( pObj, *pPV, nOptions );
if( pImageMap )
- pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *pImageMap )) );
+ pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( *pImageMap )) );
if (pObj->IsChart())
{
@@ -1180,7 +1180,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if (bReturn)
{
if( pImageMap )
- pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *pImageMap )) );
+ pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( *pImageMap )) );
// let the object stay in loaded state after insertion
pObj->Unload();
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 3c5f8cd6760b..27fe058851fc 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -39,6 +39,7 @@
#include <svx/svdograf.hxx>
#include <svx/svdomedia.hxx>
#include <svx/svdoole2.hxx>
+#include <svx/ImageMapInfo.hxx>
#include <sot/storage.hxx>
#include <sfx2/app.hxx>
#include <avmedia/mediawindow.hxx>
@@ -54,7 +55,6 @@
#include <drawdoc.hxx>
#include <sdresid.hxx>
#include <strings.hrc>
-#include <imapinfo.hxx>
#include <sdpage.hxx>
#include <view/SlideSorterView.hxx>
#include <undo/undoobjects.hxx>
@@ -145,7 +145,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
}
if (pImageMap)
- pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap)));
+ pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
@@ -230,7 +230,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
{
// replace object
if (pImageMap)
- pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap)));
+ pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
::tools::Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect());
Size aPickObjSize(aPickObjRect.GetSize());
@@ -274,7 +274,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
if (!bSuccess)
pNewGrafObj = nullptr;
else if (pImageMap)
- pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap)));
+ pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
}
}
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 381ed56ec78e..4b3e8a60c84f 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -11593,7 +11593,6 @@ sd/inc/fadedef.h
sd/inc/glob.hxx
sd/inc/helper/simplereferencecomponent.hxx
sd/inc/helpids.h
-sd/inc/imapinfo.hxx
sd/inc/misc/scopelock.hxx
sd/inc/notifydocumentevent.hxx
sd/inc/pch/precompiled_sd.cxx
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 4aca86ba0fb5..aa5c744d7409 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -235,6 +235,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/sdr/overlay/overlaymanager \
svx/source/sdr/overlay/overlayobjectlist \
svx/source/sdr/overlay/overlayhandle \
+ svx/source/sdr/misc/ImageMapInfo \
svx/source/sdr/primitive2d/sdrellipseprimitive2d \
svx/source/sdr/primitive2d/sdrprimitivetools \
svx/source/sdr/primitive2d/sdrtextprimitive2d \
diff --git a/svx/source/sdr/misc/ImageMapInfo.cxx b/svx/source/sdr/misc/ImageMapInfo.cxx
new file mode 100644
index 000000000000..ca820a240b82
--- /dev/null
+++ b/svx/source/sdr/misc/ImageMapInfo.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/ImageMapInfo.hxx>
+
+#include <svx/svdobj.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/unoshape.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <vcl/imapobj.hxx>
+
+SvxIMapInfo* SvxIMapInfo::GetIMapInfo(SdrObject const* pObject)
+{
+ assert(pObject);
+
+ SvxIMapInfo* pIMapInfo = nullptr;
+ sal_uInt16 nCount = pObject->GetUserDataCount();
+
+ // Can we find IMap information within the user data?
+ for (sal_uInt16 i = 0; i < nCount; i++)
+ {
+ SdrObjUserData* pUserData = pObject->GetUserData(i);
+
+ if ((pUserData->GetInventor() == SdrInventor::StarDrawUserData)
+ && (pUserData->GetId() == SVX_IMAPINFO_ID))
+ pIMapInfo = static_cast<SvxIMapInfo*>(pUserData);
+ }
+
+ return pIMapInfo;
+}
+
+IMapObject* SvxIMapInfo::GetHitIMapObject(SdrObject const* pObj, const Point& rWinPoint)
+{
+ SvxIMapInfo* pIMapInfo = GetIMapInfo(pObj);
+ IMapObject* pIMapObj = nullptr;
+
+ if (pIMapInfo)
+ {
+ const MapMode aMap100(MapUnit::Map100thMM);
+ Size aGraphSize;
+ Point aRelPoint(rWinPoint);
+ ImageMap& rImageMap = const_cast<ImageMap&>(pIMapInfo->GetImageMap());
+ const ::tools::Rectangle& rRect = pObj->GetLogicRect();
+ bool bObjSupported = false;
+
+ // execute HitTest
+ if (auto pGrafObj = dynamic_cast<const SdrGrafObj*>(pObj)) // simple graphics object
+ {
+ const GeoStat& rGeo = pGrafObj->GetGeoStat();
+ std::unique_ptr<SdrGrafObjGeoData> pGeoData(
+ static_cast<SdrGrafObjGeoData*>(pGrafObj->GetGeoData()));
+
+ // Undo rotation
+ if (rGeo.nRotationAngle)
+ RotatePoint(aRelPoint, rRect.TopLeft(), -rGeo.nSin, rGeo.nCos);
+
+ // Undo mirroring
+ if (pGeoData->bMirrored)
+ aRelPoint.setX(rRect.Right() + rRect.Left() - aRelPoint.X());
+
+ // Undo shearing
+ if (rGeo.nShearAngle)
+ ShearPoint(aRelPoint, rRect.TopLeft(), -rGeo.nTan);
+
+ if (pGrafObj->GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
+ aGraphSize = Application::GetDefaultDevice()->PixelToLogic(
+ pGrafObj->GetGrafPrefSize(), aMap100);
+ else
+ aGraphSize = OutputDevice::LogicToLogic(pGrafObj->GetGrafPrefSize(),
+ pGrafObj->GetGrafPrefMapMode(), aMap100);
+
+ bObjSupported = true;
+ }
+ else if (auto pOleObj = dynamic_cast<const SdrOle2Obj*>(pObj)) // OLE object
+ {
+ aGraphSize = pOleObj->GetOrigObjSize();
+ bObjSupported = true;
+ }
+
+ // Everything worked out well, thus execute HitTest
+ if (bObjSupported)
+ {
+ // Calculate relative position of mouse cursor
+ aRelPoint -= rRect.TopLeft();
+ pIMapObj = rImageMap.GetHitIMapObject(aGraphSize, rRect.GetSize(), aRelPoint);
+
+ // We don't care about deactivated objects
+ if (pIMapObj && !pIMapObj->IsActive())
+ pIMapObj = nullptr;
+ }
+ }
+
+ return pIMapObj;
+}
+
+ImageMap* SvxIMapInfo::GetImageMapForObject(SdrObject* pObj)
+{
+ SvxIMapInfo* pIMapInfo = GetIMapInfo(pObj);
+ if (pIMapInfo)
+ {
+ return const_cast<ImageMap*>(&(pIMapInfo->GetImageMap()));
+ }
+ return nullptr;
+} \ No newline at end of file