Hallo Kushal,
> nope, i dont have any dialog model yet.
> how can i get that from the XWindow(see code attached for reference)???
Ah, I see ... your code indeed works directly with window peers. This
will also yield results (obviously, as you already have a working dialog
:) ), however, it has disadvantages: One is the mentioned
desktop/theme-dependency: Try switching your desktop theme to another
(larger or smaller) font, and see how your pixel coordinates won't work
anymore. Another is that parts of the API you're using is pretty
unofficial, for instance, the window names to use at the toolkit are not
officially documented, to my best knowledge.
Okay, first let me suggest how you *should* do that, IMO :)
- create the dialog you want in the Basic dialog editor.
- search for the resulting .xdl file
- include this file in your extension
- at runtime, do the following (pseudo-code, more Java than C++, sorry):
XDialogProvider dlgProv = ServiceFactory.createInstance(
"com.sun.star.awt.DialogProvider2" )
dlgProv.
XDialog dialog = dlgProvider.createDialog(
"vnd.sun.star.extension://your-extension-identifier/path" +
"/within/oxt/file/dialog.xdl";
dialog.execute();
This has several advantages:
- You can edit the dialog within Basic's dialog editor. While it is not
the most convenient tool on earth, it still is better than creating
the dialog programmatically.
- Your dialog definition in the XDL file now has APPFONT coordinates,
i.e. will not suffer from the desktop/theme size mentioned above.
- You have access to the dialog model (see below), which will easily
allow you to manipulate the dialog at runtime, using a reliable API.
For accessing the model, just do
XControl dialogControl = (XControl)dialog;
XNameAccess dialogModel = (XNameAccess)dialogControl.getModel();
Now dialogModel contains an object which supports the
css.awt.UnoControlDialogModel service. This includes support for
accessing its children, removing and adding children, and property
support as described in the service.
The children then are UnoControl*Model instances, including full support
for all properties described in the respective services.
So, to answer your original question (how to add an image control) in
this context:
- add an image control to your dialog in Basic's dialog editor
- set its "Scale" property (in the property editor) to the desired value
- at runtime, retrieve the image control model:
XPropertySet imageProps = (XPropertySet)dialogModel.getByName(
"imageControlName" );
- set the ImageURL property:
imageProps.setPropertyValue( "ImageURL", "vnd.sun.star.extension://" +
"your-extension-identifier/path/within/oxt/file/image.jpg" );
=> you're done :)
Your second question about the font attributes would then be answered with:
XPropertySet controlProperties = (XPropertySet)dialogModel.getByName(
"controlName" );
FontDescriptor font = (FontDescriptor)controlProperties.
getPropertyValue( "FontDescriptor" );
font.Weight = FontWeight.BOLD;
controlProperties.setPropertyValue( "FontDescriptor", font );
So, as you see, this approach would make some things easier ...
If you'd insist on using your old approach for whatever reasons, then
you'd need to lookup the window names (as to be passed in the
WindowDescriptor) in toolkit/source/awt/vclxtoolkit.cxx - as said,
they're not officially documented, so you'd need to look into the
implementation. For an image control, "fixedimage" would be the name to use.
For setting properties, you could still look up all the properties in
the respective UnoControl*Model services in css.awt. Then, use the
XVclWindowPeer::setProperty method of your XWindow: just pass the
property name as obtained from the UnoControl*Model service description,
and the desired value. This should work for all properties, including
FontDescriptor.
Hope this helps
Ciao
Frank
--
ORACLE
Frank Schönheit | Software Engineer | [email protected]
Oracle Office Productivity: http://www.oracle.com/office
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]