Hello Andrzej !
Hi Andreas !
I think I'm in a dead point right now, I can't figure this out :-(
I've been trying to get the menubar retrieving done for the
whole afternoon, yet without effect.
First, I implemented your basic example in my component,
more less like this :
Reference< css::beans::XPropertySet > xFrameProp(xFrame, UNO_QUERY_THROW);
Reference< XLayoutManager > xLayout;
Any aProp =
xFrameProp->getPropertyValue(::rtl::OUString::createFromAscii("LayoutManager"));
aProp >>= xLayout;
Reference< css::ui::XUIElement > xMenu
(xLayout->getElement(::rtl::OUString::createFromAscii("private:resource/menubar/menubar")));
if( xMenu.is()) printf("*** properly retrieved xMenu ***\n");
else {
xLayout->createElement(::rtl::OUString::createFromAscii("private:resource/menubar/menubar"));
xMenu = Reference<css::ui::XUIElement
>(xLayout->getElement(::rtl::OUString::createFromAscii("private:resource/menubar/menubar")
This looks good ... but .-)
The UIElement returned by xLayout->getElement() isnt the menu bar
object. It's a wrapper around it. You have to query this xMenu object
for it's XPropertySet interface and ask for it's property "XMenuBar".
This property can then be used as XMenuBar reference to be set on a
XTopWindow->setMenubar() call.
On the other side you may be dont checked the "else" switch.
If the document was loaded, there is may be nor menu bar available.
But it's possible to create one. That's why you have to make the following:
// try to retrieve the menu bar wrapper
xMenuWrapper = xLayout->getElement("")
// if it does not exists ...
if ! xMenuWrapper.is()
// ... create it ...
xLayout->createElement("")
// ... and try to retrieve it again.
xMenuWrapper = xLayout->getElement("")
// if no menu bar wrapper exists and could not be created successfully
// throw a RuntimeException to show this unexpected situation !
if ! xMenuWrapper.is()
throw RuntimeException();
// Otherwise get the real XMenuBar interface from this wrapper.
xMenuBar = xMenuWrapper->getPropertyValue("XMenuBar");
but I couldn't retrieve the menubar.
I also tried to retrieve the "_blank" frame from the desktop and get the
layout manager for that frame, that didn't work either. I made a couple
of other tryes, I even tried retrieving an XTopWindow using the
XExtendedToolkit, but nothing worked.
Then I tried doing a similar thing from basic (using the child frame
returned by
my component's createInstance) - still no joy.
Then I figured I'll check the interfaces supported by the tabcontrol's
parent :
oTabWinFactory = createUnoService( "com.sun.star.frame.TabWindowFactory" )
oTabWindow = oTabWinFactory.createInstanceWithContext(
GetDefaultContext() )
oParentWindow = oTabWindow.getPropertyValue("ParentWindow")
msgbox oParentWindow.dbg_supportedInterfaces
the XTopWindow isn't on that list :/
is that why I can't get the menu? You said that only the windows that
implement this interface have a menubar. But why can't I create one?
The menu bar must be retrieved from the layout manager ... not from the
parent window ! The parent window must be asked for it's XTopWindow
interface to SET(!) the menu bar there.
xMenuBar = impl_getMenuBarFromLayoutManager(xLayout);
xTopWindow->setMenuBar(xMenuBar)
On the other side you are right ... the returned parent window of the
TabControl does not provide the right interface .-(
The returned window isnt the most upper window ... it's another child
window of it.
Hierarchy:
TabControl
[
TopWindow (1)
-> ChildWindow (2) with TabButtons
-> ChildWindow (3) to layout Frames there
]
You will get the ChildWindow (3); which isnt the window you need.
I thing we have to adopt the TabControl a little bit.
May be there will be another property: "TopWindow", which returns the
real top window of this control and can be used.
Sorry for that .-)
I'll sit on this a bit more, maybe I'll come up with something...
Regards,
Andrzej
Regards
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]