sd/source/ui/view/drviewse.cxx |   37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

New commits:
commit c1c1fb5e1d6055459a8b393114ecfbc31f822d45
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Wed Nov 1 11:27:51 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Nov 1 19:14:14 2023 +0100

    tdf#112131 sd: check if SdrObjKind::UNO accepts hyperlink props
    
    This fixes a form control's hyperlink being set by Insert - Hyperlink.
    
    Calc and Writer do something similar - checking for ButtonType.
    
    Change-Id: Ia36b216c8f749bc2a5dfba448a4771d9d7d50256
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158765
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 5c74a0f50b10..3f0a5792dc5f 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1547,30 +1547,41 @@ void DrawViewShell::InsertURLButton(const OUString& 
rURL, const OUString& rText,
         if( pMarkedObj ) try
         {
             // change first marked object
-            if( SdrInventor::FmForm == pMarkedObj->GetObjInventor() && 
pMarkedObj->GetObjIdentifier() == SdrObjKind::FormButton )
+            if (SdrInventor::FmForm == pMarkedObj->GetObjInventor())
             {
-                bNewObj = false;
-
                 SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pMarkedObj );
 
                 Reference< awt::XControlModel > xControlModel( 
pUnoCtrl->GetUnoControlModel(), UNO_SET_THROW );
                 Reference< beans::XPropertySet > xPropSet( xControlModel, 
UNO_QUERY_THROW );
 
-                xPropSet->setPropertyValue("Label" , Any( rText ) );
-                xPropSet->setPropertyValue("TargetURL" , Any( sTargetURL ) );
+                bool bIsButton = pMarkedObj->GetObjIdentifier() == 
SdrObjKind::FormButton;
+                if (!bIsButton && pMarkedObj->GetObjIdentifier() == 
SdrObjKind::UNO)
+                {
+                    const Reference<beans::XPropertySetInfo> 
xInfo(xPropSet->getPropertySetInfo());
+                    bIsButton = xInfo.is() && 
xInfo->hasPropertyByName("ButtonType")
+                                && xInfo->hasPropertyByName("Label")
+                                && xInfo->hasPropertyByName("TargetURL");
+                }
+                if (bIsButton)
+                {
+                    bNewObj = false;
+
+                    xPropSet->setPropertyValue("Label", Any(rText));
+                    xPropSet->setPropertyValue("TargetURL", Any(sTargetURL));
 
-                if( !rTarget.isEmpty() )
-                    xPropSet->setPropertyValue("TargetFrame" , Any( rTarget ) 
);
+                    if (!rTarget.isEmpty())
+                        xPropSet->setPropertyValue("TargetFrame", 
Any(rTarget));
 
-                xPropSet->setPropertyValue( "ButtonType" , Any( 
form::FormButtonType_URL ) );
+                    xPropSet->setPropertyValue("ButtonType", 
Any(form::FormButtonType_URL));
 #if HAVE_FEATURE_AVMEDIA
-                if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
-                {
-                    xPropSet->setPropertyValue( "DispatchURLInternal" , Any( 
true ) );
-                }
+                    if (::avmedia::MediaWindow::isMediaURL(rURL, ""/*TODO?*/))
+                    {
+                        xPropSet->setPropertyValue("DispatchURLInternal", 
Any(true));
+                    }
 #endif
+                }
             }
-            else
+            if (bNewObj)
             {
                 // add url as interaction for first selected shape
                 bNewObj = false;

Reply via email to