eric b wrote:
Hello,
As proof of concept, I'd like to add new toolbars (first in Writer,
later in other applications). The problem is, I'm not sure to do that
the right way. Of course, this can seriously be improved, but what I
need is a proof of concept, not a final product for the moment
Hi Eric,
First, I created e.g. writercycle2.xml, writercycle3.xml, two custom
toolbars. Putting those .xml file in sw/uiconfig/swriter/toolbar, they
are correctly packaged, and bundled. No problem with that.
That's correct.
*Question 1* : shall I register those new toolbar. e.g. in
framework/collector/cmduicollector.cxx or somewhere else ? (currently :
I didn't register them, since they are automagically packaged in
postprocess, but maybe this is not sufficient)
No. cmduicollector.cxx was used to migrate toolbar, statusbar and menu
resources to xml files. Currently it's not used for anything.
For Writer, the choice was to modify WriterWindowState.xcu , located in
org/openoffice/Office/UI path
The idea is to display only one between 3 toolbars :
- writercycle2.xml for the Beginner level
- writercycle3.xml for the Average level
- standardbar.xml (already existing), for the Expert level
.. means have only the "Visible" property == true, in same time for one
toolbar only, while the other have false (e.g. writercycle2 and
writercycle3 have Visible=false, standardbar has visible == true, when
the "Expert" level is checked).
Please don't use the WindowState.xcu files to control the visibility for
context dependent toolbars. You have to use the layout manager to
control the creation by your implementation. The "Visible" property must
by default set to true for all your toolbars. Your implementation calls
LayoutManager->requestElement("private:resource/toolbar/writercycle")
to make it visible.
LayoutManager->destroyElement("private:resource/toolbar/writercycle")
to hide it.
These calls are used by the sfx2 based shell manager to make context
dependent toolbars visible/invisible. The layout manager is responsible
to update the state of the WindowState.xcu files.
In the code (in svx/source/cui/optgdlg.cxx), I proceeed as follow, e.g.
for the getToolbarState (the setter is similar)
static const OUString sULConfigSrvc( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationProvider" ) );
static const OUString sULAccessSrvc( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationUpdateAccess" ) );
/* adapt the toolbars to the level */
// The standard toolbar
static const OUString sStandardbarToolbarNode(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.Office.UI.WriterWindowState/UIElements/States/private:resource/toolbar/standardbar"
) );
// Writer toolbars
static const OUString sWriterCycle2ToolbarNode(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.Office.UI.WriterWindowState/UIElements/States/private:resource/toolbar/writercycle2"
) );
static const OUString sWriterCycle3ToolbarNode(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.Office.UI.WriterWindowState/UIElements/States/private:resource/toolbar/writercycle3"
) );
//*Question 2* : is the path above correct ? WriterWindowState does
contain the nodes, themselves containing the property "Visible" (see
below), I'd like to set as true/false, as an OUString (is the type
correct btw, because the .xcs is not clear about that ?)
Please don't write to the WindowState.xcu file by yourself. This breaks
the whole framework implementation and is the wrong way to solve your
problems.
// Visible property
static const OUString sToolbarPropertyNameVisible( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ) );
I pasted the getter below. The problem is, there is no crash, but it
does not work,, I don't see why an exception is caught. The line causing
that is :
Reference< XNameAccess > xConfigAccess( Reference< XNameAccess
>(xConfigProvider->createInstanceWithArguments( sULAccessSrvc, aArgs ),
UNO_QUERY ));
*Question 3*: is something obviously wrong ? Is the WriterWindowState in
read only mode ? ( or lazy_write ? )
*Question 4* : I was searching with OpenGrok since yesterday, and the
most usefull example I found, is windowstateconfiguration.cxx (located
in framework/source/uiconfiguration), but the interface is not public,
so, looks like a bad track :-/ Is there something usefull on tools ?
*Question 5* : I'd like to see the toolbar change *immediately* visible,
i.e. without the need to relaunch the office. How proceed ? Which event,
signal has to be sent ? and is there an example in the code I could
reuse ? Any idea or suggestion ?
Must be obvious, but any hint would help me a lot. Thanks a lot in
advance !!
Eric Bachard
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@framework.openoffice.org
For additional commands, e-mail: dev-h...@framework.openoffice.org