Hello Alexander,

On Monday 12 October 2009, 01:50, Alexander Anisimov wrote:
> Hello Ariel,
> 
> I have one more question. I think it last question.
> 
> Now I know how to operate with toolbar items. But I need to know how to
>  hide or show some toolbar and then save it in document storage.

do you want to save the visibility state inside the document?
AFAIK this isn't possible.

I'm just an API client, so the following is just "guessing" (Carsten Diesner 
usually reads this mailing list, sure the mail subject catches his attention; 
he could give you a better advice, as he developed the code).

* as far as I could see, the window state configuration is stored globally; 
even if the doc has its own UI elements, as long as they are persistent, their 
window state is stored globally, per module

> Sub Hide_Standard_Toolbar()
> 
> >   Dim oDoc As Object
> >   Dim oFrame
> >   Dim element
> >   Dim layoutmanager
> >
> >   oDoc = ThisComponent
> >
> >   Dim oUIConfigurationManager as Object
> >   oUIConfigurationManager = oDoc.getUIConfigurationManager()
> >
> >   oFrame = oDoc.getCurrentController().getFrame()
> >   layoutmanager = oFrame.LayoutManager
> >
> >   element =
> > layoutmanager.getElement("private:resource/toolbar/standardbar")
> >   element.ConfigurationSource = oUIConfigurationManager

* does this switch the storage? I mean, if the toolbar wasn't stored in the 
document, changing the configuration source copies the module toolbar into the 
document storage? I didn't try if this works.

>   element.Persistent = true

* you should do the opposite: setting this to true stores the window state at 
the module level cf. 
http://svn.services.openoffice.org/opengrok/xref/DEV300_m61/framework/source/layoutmanager/layoutmanager.cxx#1545
spec. 1573

I'd try the following:

* do not access the toolbar by the LayoutManager and then change the 
ConfigurationSource. Use the way you already learn by getting it from the 
configuration manager (first try to see if the document already has a 
customized 
version in its storage; if not, get it from the module ui config. manager, and 
copy it in the document ui config. manager). You can make a helper method 
getToolbar(sResourceURL) for this.
This way you make sure that you're always working with the toolbar at document 
level, not module.

* now fool the LayoutManager to set it not visible without storing the window 
state information:

        Dim oLayoutManager as Object
        oLayoutManager = 
oDoc.getCurrentController().getFrame().getPropertyValue("LayoutManager")
        Dim oUIElement as Object
        oUIElement = oLayoutManager.getElement(OOO_WRITER_STANDARD_TOOLBAR)
        'Fool the LayoutManager
        oUIElement.Persistent = False
        oLayoutManager.hideElement(OOO_WRITER_STANDARD_TOOLBAR)
        'Set it Persistent again
        oUIElement.Persistent = True

I've updated the doc with a new sub 
http://arielch.fedorapeople.org/docs/com.sun.star.ui.XUIConfigirationManager.odt

I didn't test much, but that trick seems to work.

Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to