[api-dev] How to make MenuBar chnages Persistent par Document.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[api-dev] How to make MenuBar chnages Persistent par Document.

Fernand Vanrie
Hallo,
I can make disappear  some Buttons from a Menubar in a document). But
After saving an reopening the doc, the buttons are "again" in place.

my code uses

oMenuBar.Persistent = true

In the ODK help i can find: If the property Persistent is *true* changes
on the structure of the user interface element are written back to
configuration source. When this property is changed, afterwards
XUIElementSettings::updateSettings must be called so the user interface
element tries to retrieve its settings from the new user interface
configuration manager.  BUT wath mean this lines ?

There was a issue (46194) whois fixed ("false" wasn't working) , but now
i think "true" is not working any more

Thank for any hint.

Fernand


Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] How to make MenuBar chnages Persistent par Document.

Carsten Driesner-3
On 05.01.2011 11:45, Fernand Vanrie wrote:

> Hallo,
> I can make disappear some Buttons from a Menubar in a document). But
> After saving an reopening the doc, the buttons are "again" in place.
>
> my code uses
>
> oMenuBar.Persistent = true
>
> In the ODK help i can find: If the property Persistent is *true* changes
> on the structure of the user interface element are written back to
> configuration source. When this property is changed, afterwards
> XUIElementSettings::updateSettings must be called so the user interface
> element tries to retrieve its settings from the new user interface
> configuration manager. BUT wath mean this lines ?
>
> There was a issue (46194) whois fixed ("false" wasn't working) , but now
> i think "true" is not working any more
Hi Fernand,

You have to use the UI Configuration Manager from the document. Changing
the "Persistent" property to true (which is the default value) is only a
prerequisite. If you retrieve the UI element from the Layout Manager the
configuration source is normally the module and NOT the document.

Just look at the following example which copies the menu bar settings
from the module to a loaded document.

REM  *****  BASIC  *****

Sub Main
    sMenuBarResUrl = "private:resource/menubar/menubar"
    oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
       
    REM *** Propterties for loadComponentFromUrl ***
    Dim OpenProperties(3) as new com.sun.star.beans.PropertyValue
    OpenProperties(0).Name = "Hidden"
    OpenProperties(0).Value = True
    OpenProperties(1).Name = "AsTemplate"
    OpenProperties(1).Value = False
    OpenProperties(2).Name = "MacroExecutionMode"
    OpenProperties(2).Value =
com.sun.star.document.MacroExecMode.NEVER_EXECUTE

    REM *** Load a document ***
    sDocUrl = "file:///d:/document.odt"
    oDoc = oDesktop.loadComponentFromUrl(sDocUrl, "_default", 0,
OpenProperties())
       
    oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")

    REM *** Retrieve the text module UI configuration manager with
module identifier
    REM *** See com.sun.star.frame.ModuleManager for more information
    oModuleCfgMgr    = oModuleCfgMgrSupplier.getUIConfigurationManager(
"com.sun.star.text.TextDocument" )
    oMenuBarSettings = oModuleCfgMgr.getSettings( sMenuBarResUrl, true )

    REM *** Retrieve the document UI configuration manager
    oDocUICfgMgr = oDoc.getUIConfigurationManager()

    REM *** Insert/replace the menubar settings to the target document
    REM *** with the module ui configuration manager settings.
    if oDocUICfgMgr.hasSettings( sMenuBarResUrl ) then
        oDocUICfgMgr.replaceSettings( sMenuBarResUrl, oMenuBarSettings )
    else
        oDocUICfgMgr.insertSettings( sMenuBarResUrl, oMenuBarSettings )
    endif

    REM *** Store the changes to the document
    oDocUICfgMgr.store()
    oDoc.store()

End Sub

Regards,
Carsten

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

Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] How to make MenuBar chnages Persistent par Document.

Fernand Vanrie
OCarsten,

Thanks, works like a charm now :-)

Fernand

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