From 41a1a91b6ec08d78449a199ec300ff73c85dd148 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 7 Jun 2019 08:48:32 +0200 Subject: tdf#125748 Only execute frame interactions in presentation mode Executing interactions while in edit mode makes editing very hard since you can only hardly select the frame without executing the interaction. Change-Id: I102dac0ff840a914bd6e21ddb047b2df5e278c6f Reviewed-on: https://gerrit.libreoffice.org/73640 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sd/source/ui/func/fudraw.cxx | 222 +------------------------------ sd/source/ui/func/fusel.cxx | 306 +------------------------------------------ sd/source/ui/inc/fudraw.hxx | 1 - sd/source/ui/inc/fusel.hxx | 2 - 4 files changed, 8 insertions(+), 523 deletions(-) diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx index 45a5629609bd..a1aabd63cd2c 100644 --- a/sd/source/ui/func/fudraw.cxx +++ b/sd/source/ui/func/fudraw.cxx @@ -504,8 +504,6 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt) } else if (!mpView->IsAction()) { - SdrObject* pObj = nullptr; - SdrPageView* pPV = nullptr; SdrViewEvent aVEvt; SdrHitKind eHit = SdrHitKind::NONE; SdrDragMode eDragMode = mpView->GetDragMode(); @@ -530,16 +528,7 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt) } } - if (eHit == SdrHitKind::NONE) - { - // found nothing -> look after at the masterpage - pObj = mpView->PickObj(aPnt, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER); - } - else if (eHit == SdrHitKind::UnmarkedObject) - { - pObj = aVEvt.pObj; - } - else if (eHit == SdrHitKind::TextEditObj && dynamic_cast< const FuSelection *>( this ) != nullptr) + if (eHit == SdrHitKind::TextEditObj && dynamic_cast< const FuSelection *>( this ) != nullptr) { sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier(); @@ -548,25 +537,10 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt) nSdrObjKind != OBJ_OUTLINETEXT && aVEvt.pObj->IsEmptyPresObj() ) { - pObj = nullptr; bDefPointer = false; mpWindow->SetPointer(PointerStyle::Arrow); } } - - if (pObj && pMEvt && !pMEvt->IsMod2() && dynamic_cast< const FuSelection *>( this ) != nullptr) - { - // test for animation or ImageMap - bDefPointer = !SetPointer(pObj, aPnt); - - if (bDefPointer && (dynamic_cast< const SdrObjGroup *>( pObj ) != nullptr || dynamic_cast< const E3dScene* >(pObj) != nullptr)) - { - // take a glance into the group - pObj = mpView->PickObj(aPnt, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::DEEP); - if (pObj) - bDefPointer = !SetPointer(pObj, aPnt); - } - } } } @@ -577,94 +551,6 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt) } } -/** - * Set cursor for animation or imagemap - */ -bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos) -{ - bool bSet = false; - - bool bAnimationInfo = dynamic_cast< const GraphicDocShell *>( mpDocSh ) == nullptr && - SdDrawDocument::GetAnimationInfo(pObj); - - bool bImageMapInfo = false; - - if (!bAnimationInfo) - bImageMapInfo = SdDrawDocument::GetIMapInfo(pObj) != nullptr; - - if (bAnimationInfo || bImageMapInfo) - { - const SdrLayerIDSet* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers(); - sal_uInt16 nHitLog(sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width())); - long n2HitLog(nHitLog * 2); - Point aHitPosR(rPos); - Point aHitPosL(rPos); - Point aHitPosT(rPos); - Point aHitPosB(rPos); - - aHitPosR.AdjustX(n2HitLog ); - aHitPosL.AdjustX( -n2HitLog ); - aHitPosT.AdjustY(n2HitLog ); - aHitPosB.AdjustY( -n2HitLog ); - - if ( !pObj->IsClosedObj() || - ( SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false))) - { - /********************************************************** - * hit inside the object (without margin) or open object - ********************************************************/ - - if (bAnimationInfo) - { - /****************************************************** - * Click-Action - ******************************************************/ - SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObj); - - if(( dynamic_cast< const DrawView *>( mpView ) != nullptr && - (pInfo->meClickAction == presentation::ClickAction_BOOKMARK || - pInfo->meClickAction == presentation::ClickAction_DOCUMENT || - pInfo->meClickAction == presentation::ClickAction_PREVPAGE || - pInfo->meClickAction == presentation::ClickAction_NEXTPAGE || - pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE || - pInfo->meClickAction == presentation::ClickAction_LASTPAGE || - pInfo->meClickAction == presentation::ClickAction_VERB || - pInfo->meClickAction == presentation::ClickAction_PROGRAM || - pInfo->meClickAction == presentation::ClickAction_MACRO || - pInfo->meClickAction == presentation::ClickAction_SOUND)) - || - ( dynamic_cast< const DrawView *>( mpView ) != nullptr && - SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) && - (pInfo->meClickAction == presentation::ClickAction_VANISH || - pInfo->meClickAction == presentation::ClickAction_INVISIBLE || - pInfo->meClickAction == presentation::ClickAction_STOPPRESENTATION || - (pInfo->mbActive && - ( pInfo->meEffect != presentation::AnimationEffect_NONE || - pInfo->meTextEffect != presentation::AnimationEffect_NONE ))))) - { - // Animation object - bSet = true; - mpWindow->SetPointer(PointerStyle::RefHand); - } - } - else if (bImageMapInfo && - SdDrawDocument::GetHitIMapObject(pObj, rPos)) - { - /****************************************************** - * ImageMap - ******************************************************/ - bSet = true; - mpWindow->SetPointer(PointerStyle::RefHand); - } - } - } - - return bSet; -} - /** * Response of doubleclick */ @@ -822,112 +708,6 @@ bool FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewE aHelpText = SdResId(STR_CLICKHYPERLINK) + aURL; } } - else if (dynamic_cast< GraphicDocShell *>( mpDocSh ) == nullptr && SdDrawDocument::GetAnimationInfo(pObj)) - { - SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObj); - - switch (pInfo->meClickAction) - { - case presentation::ClickAction_PREVPAGE: - { - // jump to the prior page - aHelpText = SdResId(STR_CLICK_ACTION_PREVPAGE); - } - break; - - case presentation::ClickAction_NEXTPAGE: - { - // jump to the next page - aHelpText = SdResId(STR_CLICK_ACTION_NEXTPAGE); - } - break; - - case presentation::ClickAction_FIRSTPAGE: - { - // jump to the first page - aHelpText = SdResId(STR_CLICK_ACTION_FIRSTPAGE); - } - break; - - case presentation::ClickAction_LASTPAGE: - { - // jump to the last page - aHelpText = SdResId(STR_CLICK_ACTION_LASTPAGE); - } - break; - - case presentation::ClickAction_BOOKMARK: - { - // jump to object/page - aHelpText = SdResId(STR_CLICK_ACTION_BOOKMARK) - + ": " - + INetURLObject::decode( pInfo->GetBookmark(), INetURLObject::DecodeMechanism::WithCharset ); - } - break; - - case presentation::ClickAction_DOCUMENT: - { - // jump to document (object/page) - aHelpText = SdResId(STR_CLICK_ACTION_DOCUMENT) - + ": " - + INetURLObject::decode( pInfo->GetBookmark(), INetURLObject::DecodeMechanism::WithCharset ); - } - break; - - case presentation::ClickAction_PROGRAM: - { - // execute program - aHelpText = SdResId(STR_CLICK_ACTION_PROGRAM) - + ": " - + INetURLObject::decode( pInfo->GetBookmark(), INetURLObject::DecodeMechanism::WithCharset ); - } - break; - - case presentation::ClickAction_MACRO: - { - // execute program - aHelpText = SdResId(STR_CLICK_ACTION_MACRO) + ": "; - - if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) ) - { - aHelpText += pInfo->GetBookmark(); - } - else - { - OUString sBookmark( pInfo->GetBookmark() ); - sal_Int32 nIdx{ 0 }; - const OUString s0{ sBookmark.getToken( 0, '.', nIdx ) }; - const OUString s1{ sBookmark.getToken( 0, '.', nIdx ) }; - const OUString s2{ sBookmark.getToken( 0, '.', nIdx ) }; - aHelpText += s2 + "." + s1 + "." + s0; - } - } - break; - - case presentation::ClickAction_SOUND: - { - // play-back sound - aHelpText = SdResId(STR_CLICK_ACTION_SOUND); - } - break; - - case presentation::ClickAction_VERB: - { - // execute OLE-verb - aHelpText = SdResId(STR_CLICK_ACTION_VERB); - } - break; - - case presentation::ClickAction_STOPPRESENTATION: - { - // quit presentation - aHelpText = SdResId(STR_CLICK_ACTION_STOPPRESENTATION); - } - break; - default: - break; - } - } if (!aHelpText.isEmpty()) { diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx index 7a0a1ed09fcc..0a8bd4452dfe 100644 --- a/sd/source/ui/func/fusel.cxx +++ b/sd/source/ui/func/fusel.cxx @@ -307,30 +307,14 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt) ) { pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER); - if (pObj) + if (pObj && !bReturn && !bReadOnly && rMEvt.GetClicks() == 2 + && (dynamic_cast(pObj) != nullptr + || dynamic_cast(pObj) != nullptr)) { - // Animate object when not just selecting. - if ( ! bSelectionOnly) - bReturn = AnimateObj(pObj, aMDPos); - - if( !bReturn && (dynamic_cast< const SdrObjGroup *>( pObj ) != nullptr || dynamic_cast< const E3dScene* >(pObj) != nullptr)) - { - if(rMEvt.GetClicks() == 1) - { - // Look into the group - pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::DEEP); - if (pObj) - bReturn = AnimateObj(pObj, aMDPos); - } - else if( !bReadOnly && rMEvt.GetClicks() == 2) - { - // New: double click on selected Group object - // enter group - if ( ! bSelectionOnly - && pObj->getSdrPageFromSdrObject() == pPV->GetPage()) - bReturn = pPV->EnterGroup(pObj); - } - } + // New: double click on selected Group object + // enter group + if (!bSelectionOnly && pObj->getSdrPageFromSdrObject() == pPV->GetPage()) + bReturn = pPV->EnterGroup(pObj); } // #i71727# replaced else here with two possibilities, once the original else (!pObj) @@ -1184,282 +1168,6 @@ void FuSelection::SetEditMode(sal_uInt16 nMode) rBindings.Invalidate(SID_BEZIER_INSERT); } -/** - * Execute animation or interaction - */ -bool FuSelection::AnimateObj(SdrObject* pObj, const Point& rPos) -{ - bool bAnimated = false; - bool bClosed = pObj->IsClosedObj(); - bool bFilled = false; - - if (bClosed) - { - SfxItemSet aSet(mpDoc->GetPool()); - - aSet.Put(pObj->GetMergedItemSet()); - - const XFillStyleItem& rFillStyle = aSet.Get(XATTR_FILLSTYLE); - bFilled = rFillStyle.GetValue() != drawing::FillStyle_NONE; - } - - const SdrLayerIDSet* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers(); - sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() ); - const long n2HitLog = nHitLog * 2; - Point aHitPosR(rPos); - Point aHitPosL(rPos); - Point aHitPosT(rPos); - Point aHitPosB(rPos); - - aHitPosR.AdjustX(n2HitLog ); - aHitPosL.AdjustX( -n2HitLog ); - aHitPosT.AdjustY( n2HitLog ); - aHitPosB.AdjustY( -n2HitLog ); - - if ( !bClosed || - !bFilled || - (SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) && - SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) ) ) - { - if ( SdDrawDocument::GetIMapInfo( pObj ) ) - { - const IMapObject* pIMapObj = SdDrawDocument::GetHitIMapObject( pObj, rPos ); - - if ( pIMapObj && !pIMapObj->GetURL().isEmpty() ) - { - // Jump to Document - mpWindow->ReleaseMouse(); - SfxStringItem aStrItem(SID_FILE_NAME, pIMapObj->GetURL()); - SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName()); - SfxViewFrame* pFrame = mpViewShell->GetViewFrame(); - SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame); - SfxBoolItem aBrowseItem( SID_BROWSE, true ); - mpWindow->ReleaseMouse(); - pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, - { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer }); - - bAnimated = true; - } - } - else if( dynamic_cast< const GraphicDocShell *>( mpDocSh ) == nullptr && - dynamic_cast< const DrawView *>( mpView ) != nullptr && - SdDrawDocument::GetAnimationInfo(pObj)) - { - /********************************************************** - * Animation-object hit in the middle -> interaction - **********************************************************/ - SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObj); - DrawViewShell* pDrViewSh = static_cast(mpViewShell); - mpWindow->ReleaseMouse(); - - switch (pInfo->meClickAction) - { - case presentation::ClickAction_BOOKMARK: - { - // Jump to Bookmark (Page or Object) - SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark()); - mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList( - SID_NAVIGATOR_OBJECT, - SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem }); - bAnimated = true; - } - break; - - case presentation::ClickAction_DOCUMENT: - { - OUString sBookmark( pInfo->GetBookmark() ); - // Jump to document - if (!sBookmark.isEmpty()) - { - SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName()); - SfxStringItem aStrItem(SID_FILE_NAME, sBookmark); - SfxViewFrame* pFrame = mpViewShell->GetViewFrame(); - SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame); - SfxBoolItem aBrowseItem( SID_BROWSE, true ); - pFrame->GetDispatcher()-> - ExecuteList(SID_OPENDOC, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, - { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer }); - } - - bAnimated = true; - } - break; - - case presentation::ClickAction_PREVPAGE: - { - // Jump to the previous page - SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS); - mpViewShell->GetViewFrame()->GetDispatcher()-> - ExecuteList(SID_NAVIGATOR_PAGE, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aItem }); - bAnimated = true; - } - break; - - case presentation::ClickAction_NEXTPAGE: - { - // Jump to the next page - SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT); - mpViewShell->GetViewFrame()->GetDispatcher()-> - ExecuteList(SID_NAVIGATOR_PAGE, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aItem }); - bAnimated = true; - } - break; - - case presentation::ClickAction_FIRSTPAGE: - { - // Jump to the first page - SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST); - mpViewShell->GetViewFrame()->GetDispatcher()-> - ExecuteList(SID_NAVIGATOR_PAGE, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aItem }); - bAnimated = true; - } - break; - - case presentation::ClickAction_LASTPAGE: - { - // Jump to the last page - SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST); - mpViewShell->GetViewFrame()->GetDispatcher()-> - ExecuteList(SID_NAVIGATOR_PAGE, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aItem }); - bAnimated = true; - } - break; - - case presentation::ClickAction_SOUND: - { -#if HAVE_FEATURE_AVMEDIA - try - { - mxPlayer.set( avmedia::MediaWindow::createPlayer( pInfo->GetBookmark(), ""/*TODO?*/), uno::UNO_SET_THROW ); - mxPlayer->start(); - } - catch( uno::Exception& ) - { - } -#endif - bAnimated = true; - } - break; - - case presentation::ClickAction_VERB: - { - // Assign verb - mpView->UnmarkAll(); - mpView->MarkObj(pObj, mpView->GetSdrPageView()); - pDrViewSh->DoVerb(static_cast(pInfo->mnVerb)); - bAnimated = true; - } - break; - - case presentation::ClickAction_PROGRAM: - { - OUString aBaseURL = GetDocSh()->GetMedium()->GetBaseURL(); - INetURLObject aURL( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), pInfo->GetBookmark(), - URIHelper::GetMaybeFileHdl(), true, false, - INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism::Unambiguous ) ); - - if( INetProtocol::File == aURL.GetProtocol() ) - { - SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - SfxBoolItem aBrowsing( SID_BROWSE, true ); - - SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if (pViewFrm) - pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, - { &aUrl, &aBrowsing }); - } - - bAnimated = true; - } - break; - - case presentation::ClickAction_MACRO: - { - // Execute macro - OUString aMacro = pInfo->GetBookmark(); - - if ( SfxApplication::IsXScriptURL( aMacro ) ) - { - uno::Any aRet; - uno::Sequence< sal_Int16 > aOutArgsIndex; - uno::Sequence aParams; - uno::Sequence< uno::Any > aOutArgs; - - ErrCode eErr = mpDocSh->CallXScript( aMacro, - aParams, aRet, aOutArgsIndex, aOutArgs); - - // Check the return value from the script - bool bTmp = false; - bAnimated = eErr == ERRCODE_NONE && - aRet.getValueType() == cppu::UnoType::get() && - ( aRet >>= bTmp ) && - bTmp; - } - else - { - // aMacro has got following format: - // "Macroname.Modulname.Libname.Documentname" or - // "Macroname.Modulname.Libname.Applicationname" - sal_Int32 nIdx{ 0 }; - const OUString aMacroName = aMacro.getToken(0, '.', nIdx); - const OUString aModulName = aMacro.getToken(0, '.', nIdx); - - // In this moment the Call-method only - // resolves modulename+macroname - OUString aExecMacro(aModulName + "." + aMacroName); - bAnimated = mpDocSh->GetBasic()->Call(aExecMacro); - } - } - break; - - default: - { - bAnimated = false; - } - break; - } - } - - if (!bAnimated && - dynamic_cast< const DrawView *>( mpView ) != nullptr && - dynamic_cast< const GraphicDocShell *>( mpDocSh ) == nullptr && - SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) && - SdDrawDocument::GetAnimationInfo(pObj)) - { - /********************************************************** - * Effect-Object hit in the middle -> Play effect - **********************************************************/ - SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObj); - - switch (pInfo->meClickAction) - { - case presentation::ClickAction_VANISH: - case presentation::ClickAction_INVISIBLE: - break; - - default: - bAnimated = false; - break; - } - } - } - - return bAnimated; -} - /** is called when the current function should be aborted.

This is used when a function gets a KEY_ESCAPE but can also be called directly. diff --git a/sd/source/ui/inc/fudraw.hxx b/sd/source/ui/inc/fudraw.hxx index 11158738ff82..9e64300928a6 100644 --- a/sd/source/ui/inc/fudraw.hxx +++ b/sd/source/ui/inc/fudraw.hxx @@ -47,7 +47,6 @@ public: virtual void DoubleClick(const MouseEvent& rMEvt); - bool SetPointer(SdrObject* pObj, const Point& rPos); bool SetHelpText(SdrObject* pObj, const Point& rPos, const SdrViewEvent& rVEvt); void SetPermanent(bool bSet) { bPermanent = bSet; } diff --git a/sd/source/ui/inc/fusel.hxx b/sd/source/ui/inc/fusel.hxx index 9491e97eff79..5806cb2e8d66 100644 --- a/sd/source/ui/inc/fusel.hxx +++ b/sd/source/ui/inc/fusel.hxx @@ -50,8 +50,6 @@ public: void SetEditMode(sal_uInt16 nMode); sal_uInt16 GetEditMode() { return nEditMode; } - bool AnimateObj(SdrObject* pObj, const Point& rPos); - /** is called when the current function should be aborted.

This is used when a function gets a KEY_ESCAPE but can also be called directly. -- cgit v1.2.3