You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by Антон Борисов <an...@gmail.com> on 2014/05/03 17:09:47 UTC

setting PositionX and PositionY of FixedHyperlink have no effect

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?


-- 
Борисов Антон

Re: setting PositionX and PositionY of FixedHyperlink have no effect

Posted by Tsutomu Uchino <ha...@gmail.com>.
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 Антон Борисов <an...@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?
>
>
> --
> Борисов Антон
>

Re: setting PositionX and PositionY of FixedHyperlink have no effect

Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi Антон,

On Sat, May 03, 2014 at 07:09:47PM +0400, Антон Борисов wrote:
> 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?

A few things, please compare with the attached code, it is much simpler:

- create the control model at the dialog model factory
- set the control model properties
- insert the control model in the dialog model container
- get the control from the dialog control
- ...


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina