[Libreoffice] Storage of user's configuration

Stephan Bergmann sbergman at redhat.com
Tue Jan 24 12:38:12 PST 2012

On 01/24/2012 04:22 PM, Martin Richard wrote:
> I'm hacking the cross-platform filepicker (in fpicker/source/office). I
> added a "Places" (bookmarks) list on the left and I would like to save
> the entries that the user bookmarked .
> Cedric Bosdonnat told me to look at xcu and xcs files, but I'm a bit
> lost. I'm looking for a code sample where user's persistent
> configuration is manipulated (read and written) and/or anything that can
> be usefull, like search keywords, links to old threads in the mailing
> list, which would help me to identify some good practices (naming
> conventions, for instance).

The configuration data is stored into a hierarchy of groups (think 
"structs") and typed properties, plus homogeneous sets (where a set is 
somewhat like an array with members of one kind of group, but the order 
is not defined and the members have arbitrary names rather than 
numerical indices).  The static structure of that hierarchy is at 
officecfg/registry/data/ and the actual initial data at 

For file paths, there is already something looking over-engineered at 
org.openoffice.Office.Paths, but if all you need is an (ordered?) list 
of bookmarks (just URIs?) that does not grow unbounded, you might get 
away with a single property of type oor:string-list. 
org.openoffice.Office.Common is a kind of catch-all file for various 
configuration settings that do not fit any of the other, more 
specialized ones.  Maybe you find a fitting group node there, or add a 
new one.

Accessing the configuration at runtime to read/write the data is 
something of a disaster.  The configuration is UNO based, but tries to 
re-use each and every of the existing UNO interfaces, so that getting an 
idea of how it actually works is rather difficult.  Plus, various people 
thought it a good idea to add various wrappers on top of it, adding even 
more confusion.  I'm trying to clean up that mess over time, but it is 
no easy feat.

One thing that's already there, though, is that if you can indeed go 
with a single string-list property (lets assume you add it as 
org.openoffice.Office.Common/Misc/FilePickerBookmarks), you can

   #include "officecfg/Office/Common.hxx"

and read the list (as a com::sun::star::uno::Sequence<rtl::OUString>) with


where context is the UNO component context (use 
comphelper::getProcessComponentContext() for now if you have none 
around).  Writing is always done in batch mode:

   unotools::ConfigurationChanges batch(
     context, batch, value);

svl/source/config/asiancfg.cxx is one of the few examples that are 
already converted to this new, simplified approach.

Don't hesitate to come back with any further questions (I'm sberg on IRC).


More information about the LibreOffice mailing list