summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-11-01 11:27:51 -0400
committerJustin Luth <jluth@mail.com>2023-11-01 19:14:14 +0100
commitc1c1fb5e1d6055459a8b393114ecfbc31f822d45 (patch)
tree7c87dac34a1bd640549fd7bd1e031b5b6fc02939
parent43464d9f31c4aaea07cc84c03d5ce67ce2cdc142 (diff)
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 <jluth@mail.com>
-rw-r--r--sd/source/ui/view/drviewse.cxx37
1 files changed, 24 insertions, 13 deletions
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;