sd/source/ui/inc/DrawViewShell.hxx | 3 + sd/source/ui/view/drviews7.cxx | 70 +++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 30 deletions(-)
New commits: commit eb3999a8cc75a42edbb8a81ecbff14a4bd9965ed Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Oct 13 19:25:57 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Oct 13 21:57:19 2020 +0200 split out detection of should disable EditHyperlink as standalone function Change-Id: I69c4d93b402a33d5ef3b55a7fc0a053332eb0196 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104253 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 5213c25f4c91..8d1820ae3409 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -494,6 +494,9 @@ private: void ConfigureAppBackgroundColor( svtools::ColorConfig* pColorConfig = nullptr ); + /// return true if "Edit Hyperlink" in context menu should be disabled + bool ShouldDisableEditHyperlink(); + // The colour of the area behind the slide (used to be called "Wiese") Color mnAppBackgroundColor; }; diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 9f7dd8d417d3..572d221c7f19 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -284,6 +284,45 @@ void DrawViewShell::GetMarginProperties( SfxItemSet &rSet ) } } +bool DrawViewShell::ShouldDisableEditHyperlink() +{ + if (!mpDrawView) + return true; + if (!mpDrawView->AreObjectsMarked()) + return true; + if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 1) + return true; + + bool bDisableEditHyperlink = true; + if( mpDrawView->IsTextEdit() ) + { + if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView())) + bDisableEditHyperlink = false; + } + else + { + SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() ); + + if ( pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor() ) + { + const uno::Reference< awt::XControlModel >& xControlModel( pUnoCtrl->GetUnoControlModel() ); + if( xControlModel.is() ) + { + uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); + if( xPropSet.is() ) + { + uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo() ); + if( xPropInfo.is() && xPropInfo->hasPropertyByName( "TargetURL") ) + { + bDisableEditHyperlink = false; + } + } + } + } + } + return bDisableEditHyperlink; +} + void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { if (mpDrawView == nullptr) @@ -1443,36 +1482,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) // Menuoption: Edit->Hyperlink // Disable, if there is no hyperlink - bool bDisableEditHyperlink = true; - if( mpDrawView->AreObjectsMarked() && ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 ) ) - { - if( mpDrawView->IsTextEdit() ) - { - if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView())) - bDisableEditHyperlink = false; - } - else - { - SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() ); - - if ( pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor() ) - { - const uno::Reference< awt::XControlModel >& xControlModel( pUnoCtrl->GetUnoControlModel() ); - if( xControlModel.is() ) - { - uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); - if( xPropSet.is() ) - { - uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo() ); - if( xPropInfo.is() && xPropInfo->hasPropertyByName( "TargetURL") ) - { - bDisableEditHyperlink = false; - } - } - } - } - } - } + bool bDisableEditHyperlink = ShouldDisableEditHyperlink(); //highlight selected custom shape { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits