diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-08-05 11:02:39 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-08-05 12:50:51 +0200 |
commit | 3d75afe9cc89d4c00d224f08331ceaea21214e95 (patch) | |
tree | 92e5b462f2722e0126960523ab5013278a71d7d6 /sc/source/ui/drawfunc | |
parent | e3169a559505f911fb30580ed34ddfe0a36f2a17 (diff) |
Use SdrObject::set/getHyperlink
Change-Id: I00e6962450689b2c0d215e52beb4e9d1524179d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120062
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sc/source/ui/drawfunc')
-rw-r--r-- | sc/source/ui/drawfunc/drawsh.cxx | 27 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh2.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh5.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fudraw.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fusel.cxx | 4 |
5 files changed, 18 insertions, 26 deletions
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index 1249cf839ef6..3de430eecb7e 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -153,8 +153,9 @@ void ScDrawShell::StateDisableItems( SfxItemSet &rSet ) } } -static void lcl_setModified( const SfxObjectShell* pShell ) +void ScDrawShell::setModified() { + const SfxObjectShell* pShell = GetObjectShell(); if ( pShell ) { css::uno::Reference< css::util::XModifiable > xModif( pShell->GetModel(), css::uno::UNO_QUERY ); @@ -323,7 +324,10 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) case SID_REMOVE_HYPERLINK: if ( pSingleSelectedObj ) - SetHlinkForObject( pSingleSelectedObj, OUString() ); + { + pSingleSelectedObj->setHyperlink(OUString()); + setModified(); + } break; case SID_OPEN_HYPERLINK: @@ -339,18 +343,17 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) pObj = pHit; } - ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); - if (pInfo && !pInfo->GetHlink().isEmpty()) + if (!pObj->getHyperlink().isEmpty()) { if (nSlot == SID_OPEN_HYPERLINK) { - ScGlobal::OpenURL(pInfo->GetHlink(), OUString(), true); + ScGlobal::OpenURL(pObj->getHyperlink(), OUString(), true); } else if (nSlot == SID_COPY_HYPERLINK_LOCATION) { uno::Reference<datatransfer::clipboard::XClipboard> xClipboard = GetViewShell()->GetWindow()->GetClipboard(); - vcl::unohelper::TextDataObject::CopyStringTo(pInfo->GetHlink(), xClipboard); + vcl::unohelper::TextDataObject::CopyStringTo(pObj->getHyperlink(), xClipboard); } } } @@ -495,7 +498,7 @@ void ScDrawShell::ExecuteMacroAssign(SdrObject* pObj, weld::Window* pWin) } else pInfo->SetMacro( sMacro ); - lcl_setModified( GetObjectShell() ); + setModified(); } void ScDrawShell::ExecuteLineDlg( const SfxRequest& rReq ) @@ -622,14 +625,4 @@ void ScDrawShell::ExecuteMeasureDlg( SfxRequest& rReq ) } } -void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const OUString& rHlnk ) -{ - if ( pObj ) - { - ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, true ); - pInfo->SetHlink( rHlnk ); - lcl_setModified( GetObjectShell() ); - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 9ff7c536617c..6c0314493eea 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -229,8 +229,7 @@ void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // disable functions else if ( nMarkCount == 1 ) { SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); - if ( !pInfo || pInfo->GetHlink().isEmpty() ) + if ( !pObj || pObj->getHyperlink().isEmpty() ) { rSet.DisableItem( SID_EDIT_HYPERLINK ); rSet.DisableItem( SID_OPEN_HYPERLINK ); diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index baaf81d28e5b..7b3d47a83ced 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -64,10 +64,9 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink if ( rMarkList.GetMarkCount() == 1 ) // URL-Button marked ? { SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); - if ( pInfo && !pInfo->GetHlink().isEmpty() ) + if ( pObj && !pObj->getHyperlink().isEmpty() ) { - aHLinkItem.SetURL( pInfo->GetHlink() ); + aHLinkItem.SetURL( pObj->getHyperlink() ); aHLinkItem.SetInsertMode(HLINK_FIELD); } SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj ); @@ -203,7 +202,8 @@ void ScDrawShell::ExecuteHLink( const SfxRequest& rReq ) } else { - SetHlinkForObject( pObj, rURL ); + pObj->setHyperlink(rURL); + setModified(); bDone = true; } } diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx index b55ccdfecd17..f32b0ad3c68c 100644 --- a/sc/source/ui/drawfunc/fudraw.cxx +++ b/sc/source/ui/drawfunc/fudraw.cxx @@ -714,7 +714,7 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt) SdrObjMacroHitRec aHitRec; //! something missing ???? rViewShell.SetActivePointer( pObj->GetMacroPointer(aHitRec) ); } - else if ( !bAlt && pInfo && (!pInfo->GetMacro().isEmpty() || !pInfo->GetHlink().isEmpty()) ) + else if ( !bAlt && pInfo && (!pInfo->GetMacro().isEmpty() || !pObj->getHyperlink().isEmpty()) ) pWindow->SetPointer( PointerStyle::RefHand ); else if ( IsDetectiveHit( aPnt ) ) rViewShell.SetActivePointer( PointerStyle::Detective ); diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx index 0e103948835f..f32249d4ff3e 100644 --- a/sc/source/ui/drawfunc/fusel.cxx +++ b/sc/source/ui/drawfunc/fusel.cxx @@ -167,9 +167,9 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt) ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, true ); // For interoperability favour links over macros if both are defined - if ( !pInfo->GetHlink().isEmpty() ) + if ( !pObj->getHyperlink().isEmpty() ) { - sURL = pInfo->GetHlink(); + sURL = pObj->getHyperlink(); } else if ( !pInfo->GetMacro().isEmpty() ) { |