[Libreoffice-commits] core.git: sc/inc sc/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 5 10:51:27 UTC 2021


 sc/inc/userdat.hxx                       |    4 ----
 sc/source/filter/excel/xiescher.cxx      |    5 +++--
 sc/source/filter/oox/drawingfragment.cxx |    5 +----
 sc/source/filter/xcl97/xcl97esc.cxx      |    6 ++++--
 sc/source/ui/drawfunc/drawsh.cxx         |   27 ++++++++++-----------------
 sc/source/ui/drawfunc/drawsh2.cxx        |    3 +--
 sc/source/ui/drawfunc/drawsh5.cxx        |    8 ++++----
 sc/source/ui/drawfunc/fudraw.cxx         |    2 +-
 sc/source/ui/drawfunc/fusel.cxx          |    4 ++--
 sc/source/ui/inc/drawsh.hxx              |    2 ++
 sc/source/ui/unoobj/shapeuno.cxx         |   17 +++++++----------
 sc/source/ui/view/gridwin5.cxx           |    5 ++---
 12 files changed, 37 insertions(+), 51 deletions(-)

New commits:
commit 3d75afe9cc89d4c00d224f08331ceaea21214e95
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Thu Aug 5 11:02:39 2021 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
CommitDate: Thu Aug 5 12:50:51 2021 +0200

    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 at allotropia.de>

diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx
index dc0dfeb844af..e61d7950750f 100644
--- a/sc/inc/userdat.hxx
+++ b/sc/inc/userdat.hxx
@@ -81,12 +81,8 @@ public:
     void            SetMacro( const OUString& rMacro ) { maMacro = rMacro; }
     const OUString& GetMacro() const { return maMacro; }
 
-    void            SetHlink( const OUString& rHlink ) { maHlink = rHlink; }
-    const OUString& GetHlink() const { return maHlink; }
-
 private:
     OUString   maMacro;
-    OUString   maHlink;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 0e8ff487e8b1..ea40954e89f3 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -546,7 +546,7 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
 
     // macro and hyperlink
     // removed oracle/sun check for mbSimpleMacro ( no idea what its for )
-    if (!maMacroName.isEmpty() || !maHyperlink.isEmpty())
+    if (!maMacroName.isEmpty())
     {
         if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, true ) )
         {
@@ -554,9 +554,10 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
             if (!sMacro.isEmpty())
                 NotifyMacroEventRead();
             pInfo->SetMacro(sMacro);
-            pInfo->SetHlink( maHyperlink );
         }
     }
+    if (!maHyperlink.isEmpty())
+        rSdrObj.setHyperlink(maHyperlink);
 
     // call virtual function for object type specific processing
     DoPreProcessSdrObj( rDffConv, rSdrObj );
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index eb9b6627a120..a366b17e0dd4 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -116,10 +116,7 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >&
     {
         SdrObject* pObj = SdrObject::getSdrObjectFromXShape( mxShape );
         if ( pObj )
-        {
-            if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, true ) )
-                pInfo->SetHlink( sURL );
-        }
+            pObj->setHyperlink(sURL);
     }
 }
 
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx
index 33363d6cdb4a..cef0b52a6b48 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -548,9 +548,11 @@ ShapeInteractionHelper::PopulateShapeInteractionInfo( const XclExpObjectManager&
       SvMemoryStream* pMemStrm = nullptr;
       OUString sHyperLink;
       OUString sMacro;
-      if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( ::GetSdrObjectFromXShape( xShape ) ) )
+      SdrObject* pObj = GetSdrObjectFromXShape( xShape );
+      if (pObj)
+        sHyperLink = pObj->getHyperlink();
+      if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ) )
       {
-         sHyperLink = pInfo->GetHlink();
          sMacro = pInfo->GetMacro();
       }
       if (  !sHyperLink.isEmpty() )
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() )
                    {
diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx
index d00752a54c2c..8644bc13f3d5 100644
--- a/sc/source/ui/inc/drawsh.hxx
+++ b/sc/source/ui/inc/drawsh.hxx
@@ -91,6 +91,8 @@ public:
 
     void GetDrawAttrStateForIFBX( SfxItemSet& rSet );
     OUString const & GetSidebarContextName();
+
+    void setModified();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index 590f8acb28d6..0de4d26c075f 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -636,10 +636,10 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const
     else if  ( aPropertyName == SC_UNONAME_HYPERLINK ||
                aPropertyName == SC_UNONAME_URL )
     {
-        OUString sHlink;
-        ScMacroInfo* pInfo = ScShapeObj_getShapeHyperMacroInfo(this, true);
-        if ( ( aValue >>= sHlink ) && pInfo )
-            pInfo->SetHlink( sHlink );
+        OUString sHyperlink;
+        SdrObject* pObj = GetSdrObject();
+        if (pObj && (aValue >>= sHyperlink))
+            pObj->setHyperlink(sHyperlink);
     }
     else if ( aPropertyName == SC_UNONAME_MOVEPROTECT )
     {
@@ -833,8 +833,8 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName )
               aPropertyName == SC_UNONAME_URL )
     {
         OUString sHlink;
-        if ( ScMacroInfo* pInfo = ScShapeObj_getShapeHyperMacroInfo(this) )
-            sHlink = pInfo->GetHlink();
+        if (SdrObject* pObj = GetSdrObject())
+            sHlink = pObj->getHyperlink();
         aAny <<= sHlink;
     }
     else if ( aPropertyName == SC_UNONAME_MOVEPROTECT )
@@ -1354,10 +1354,7 @@ public:
                     OSL_ENSURE( pInfo, "shape macro info could not be created!" );
                     if ( !pInfo )
                         break;
-                    if ( rProperty.Name == SC_EVENTACC_SCRIPT )
-                        pInfo->SetMacro( sValue );
-                    else
-                        pInfo->SetHlink( sValue );
+                    pInfo->SetMacro( sValue );
                 }
             }
         }
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 915cb06e99f0..96bd21856009 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -291,13 +291,12 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
                                     if (pHit)
                                         pObj = pHit;
                             }
-                            ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
                             // Fragments pointing into the current document need no tooltip
                             // describing the ctrl-click functionality.
-                            if ( pInfo && (pInfo->GetHlink().getLength() > 0) && !pInfo->GetHlink().startsWith("#") )
+                            if ( !pObj->getHyperlink().isEmpty() && !pObj->getHyperlink().startsWith("#") )
                             {
                                 aPixRect = LogicToPixel(aVEvt.mpObj->GetLogicRect());
-                                aHelpText = SfxHelp::GetURLHelpText(pInfo->GetHlink());
+                                aHelpText = SfxHelp::GetURLHelpText(pObj->getHyperlink());
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list