tdf#145671 Don't open URL twice in cell edit mode

Change-Id: I8a324d6a037c8a5c0efc0b2825657513c2f9841c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126159
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
This commit is contained in:
Samuel Mehrbrodt
2021-11-30 23:34:11 +01:00
parent 8368f48df8
commit b9362e87a3
5 changed files with 14 additions and 7 deletions

View File

@@ -2588,8 +2588,9 @@ OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32,
return OUString(' '); return OUString(' ');
} }
void EditEngine::FieldClicked( const SvxFieldItem& ) bool EditEngine::FieldClicked( const SvxFieldItem& )
{ {
return false;
} }

View File

@@ -611,8 +611,11 @@ bool ImpEditEngine::MouseButtonUp( const MouseEvent& rMEvt, EditView* pView )
Point aLogicClick = rOutDev.PixelToLogic(rMEvt.GetPosPixel()); Point aLogicClick = rOutDev.PixelToLogic(rMEvt.GetPosPixel());
if (const SvxFieldItem* pFld = pView->GetField(aLogicClick)) if (const SvxFieldItem* pFld = pView->GetField(aLogicClick))
{ {
bool bUrlOpened = GetEditEnginePtr()->FieldClicked( *pFld );
auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField());
// tdf#121039 When in edit mode, editeng is responsible for opening the URL on mouse click // tdf#121039 When in edit mode, editeng is responsible for opening the URL on mouse click
if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField())) if (!bUrlOpened && pUrlField)
{ {
bool bCtrlClickHappened = rMEvt.IsMod1(); bool bCtrlClickHappened = rMEvt.IsMod1();
bool bCtrlClickSecOption bool bCtrlClickSecOption
@@ -627,7 +630,6 @@ bool ImpEditEngine::MouseButtonUp( const MouseEvent& rMEvt, EditView* pView )
css::system::SystemShellExecuteFlags::DEFAULTS); css::system::SystemShellExecuteFlags::DEFAULTS);
} }
} }
GetEditEnginePtr()->FieldClicked( *pFld );
} }
} }
} }

View File

@@ -516,7 +516,8 @@ public:
const Color& rTextLineColor); const Color& rTextLineColor);
virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const; virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const;
virtual bool SpellNextDocument(); virtual bool SpellNextDocument();
virtual void FieldClicked( const SvxFieldItem& rField ); /** @return true, when click was consumed. false otherwise. */
virtual bool FieldClicked( const SvxFieldItem& rField );
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ); virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor );
// override this if access to bullet information needs to be provided // override this if access to bullet information needs to be provided

View File

@@ -180,7 +180,7 @@ public:
void SetExecuteURL(bool bSet) { bExecuteURL = bSet; } void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
virtual void FieldClicked( const SvxFieldItem& rField ) override; virtual bool FieldClicked( const SvxFieldItem& rField ) override;
virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override; virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
}; };

View File

@@ -895,14 +895,17 @@ OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
return ScEditUtil::GetCellFieldValue(*pFieldData, mpDoc, &rTxtColor); return ScEditUtil::GetCellFieldValue(*pFieldData, mpDoc, &rTxtColor);
} }
void ScFieldEditEngine::FieldClicked( const SvxFieldItem& rField ) bool ScFieldEditEngine::FieldClicked( const SvxFieldItem& rField )
{ {
if (!bExecuteURL) if (!bExecuteURL)
return; return false;
if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(rField.GetField())) if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(rField.GetField()))
{ {
ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame()); ScGlobal::OpenURL(pURLField->GetURL(), pURLField->GetTargetFrame());
return true;
} }
return false;
} }
ScNoteEditEngine::ScNoteEditEngine( SfxItemPool* pEnginePoolP, ScNoteEditEngine::ScNoteEditEngine( SfxItemPool* pEnginePoolP,