Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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 officecfg/registry/schema/.

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

  officecfg::Office::Common::Misc::FilePickerBookmarks::get(context)

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(
    unotools::ConfigurationChanges::create(context));
  officecfg::Office::Common::Misc::FilePickerBookmarks::set(
    context, batch, value);
  batch.commit();

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).

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.