Hi, You instantiated the control and model for hyperlink through the global MCF. Use com.sun.star.lang.XMultiServiceFactory provided by the dialog model to instantiate the control model and insert it into the named container, you do not need to instantiate the control yourself in this case.
> Maybe it's possible to add hyperlink control to xdl file manually without Form Designer? I could add hyperlink control by hand like the following in xdl file: <dlg:linklabel dlg:id="link" dlg:tab-index="3" dlg:left="4" dlg:top="4" dlg:width="123" dlg:height="18" dlg:value="~Link" dlg:url="http://example.org/" /> But if you try to open the xdl file that contains unknown elements for the dialog editor, the office will crash. You can not put your xdl file into any dialog libraries that might be opened in the dialog editor. You can use it only through DialogProvider service. To support hyperlink control on the dialog editor has been requested: https://issues.apache.org/ooo/show_bug.cgi?id=119731 Regards 2014-05-04 0:09 GMT+09:00 Антон Борисов <antonhbbori...@gmail.com>: > Hi all, > I have dialog created by DialogProvider2 and xdl file created in Form > Designer, and i want to add Hyperlink to this dialog by java code, because > there is no ability to add it in Form Designer. > > XDialog dialog = ... > XControl dialogControl = .. > XControlModel dialogControlModel = ... > XNameContainer xNameContainer = > QI.XNameContainer(dialogControlModel); > > Object o = > > getxMCF().createInstanceWithContext("com.sun.star.awt.UnoControlFixedHyperlink", > m_xContext); > XControl hyperlinkControl = QI.XControl(o); > Object model = > > QI.XMultiServiceFactory(QI.XControl(dialog).getModel()).createInstance("com.sun.star.awt.UnoControlFixedHyperlinkModel"); > XControlModel hyperLinkControlModel = > QI.XControlModel(model); > hyperlinkControl.setModel(hyperLinkControlModel); > > XFixedHyperlink xFixedHyperlink = > QI.XFixedHyperlink(hyperlinkControl); > // ... setting url and text > > XPropertySet xPropertySet = > QI.XPropertySet(hyperLinkControlModel); > > xPropertySet.setPropertyValue("PositionX", new > Integer(100)); > xPropertySet.setPropertyValue("PositionY", new > Integer(200)); > > xNameContainer.insertByName("hyperLink", > hyperLinkControlModel); > > QI.XControlContainer(dialog).addControl("hyperLink", > hyperlinkControl); > dialog.execute(); > > This have no effect, hyperlink positioned in left upper corner of dialog > > Maybe it's possible to add hyperlink control to xdl file manually without > Form Designer? > > If it is not possible what am i doing wrong? > > > -- > Борисов Антон >