diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-13 19:25:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-13 21:57:19 +0200 |
commit | eb3999a8cc75a42edbb8a81ecbff14a4bd9965ed (patch) | |
tree | fa30b451edd78c8f6e7a2cf4ba44afeb08721f6c /sd/source/ui | |
parent | 3a33828b8de7554e497051738c722b1764960a86 (diff) |
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 <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/inc/DrawViewShell.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 70 |
2 files changed, 43 insertions, 30 deletions
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 { |