LibreOffice Module comphelper (master) 1
Static Public Member Functions | List of all members
comphelper::ConfigurationHelper Class Reference

#include <configurationhelper.hxx>

Static Public Member Functions

static css::uno::Reference< css::uno::XInterface > openConfig (const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, EConfigurationModes eMode)
 returns access to the specified configuration package. More...
 
static css::uno::Any readRelativeKey (const css::uno::Reference< css::uno::XInterface > &xCFG, const OUString &sRelPath, const OUString &sKey)
 reads the value of an existing(!) configuration key, which is searched relative to the specified configuration access. More...
 
static void writeRelativeKey (const css::uno::Reference< css::uno::XInterface > &xCFG, const OUString &sRelPath, const OUString &sKey, const css::uno::Any &aValue)
 writes a new value for an existing(!) configuration key, which is searched relative to the specified configuration access. More...
 
static css::uno::Reference< css::uno::XInterface > makeSureSetNodeExists (const css::uno::Reference< css::uno::XInterface > &xCFG, const OUString &sRelPathToSet, const OUString &sSetNode)
 it checks if the specified set node exists ... or create an empty one otherwise. More...
 
static void flush (const css::uno::Reference< css::uno::XInterface > &xCFG)
 commit all changes made on the specified configuration access. More...
 
static css::uno::Any readDirectKey (const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, const OUString &sRelPath, const OUString &sKey, EConfigurationModes eMode)
 does the same then openConfig() & readRelativeKey() together. More...
 
static void writeDirectKey (const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sPackage, const OUString &sRelPath, const OUString &sKey, const css::uno::Any &aValue, EConfigurationModes eMode)
 does the same then openConfig() / writeRelativeKey() & flush() together. More...
 

Detailed Description

Definition at line 61 of file configurationhelper.hxx.

Member Function Documentation

◆ flush()

void comphelper::ConfigurationHelper::flush ( const css::uno::Reference< css::uno::XInterface > &  xCFG)
static

commit all changes made on the specified configuration access.

This method must be used in combination with openConfig(). The cached configuration access must be provided here.

Parameters
xCFGthe configuration root, where changes should be committed.
Exceptions
Anyexceptions the underlying configuration can throw. E.g. css::uno::Exception if the provided configuration access does not allow writing for this set.

Definition at line 162 of file configurationhelper.cxx.

Referenced by writeDirectKey().

◆ makeSureSetNodeExists()

css::uno::Reference< css::uno::XInterface > comphelper::ConfigurationHelper::makeSureSetNodeExists ( const css::uno::Reference< css::uno::XInterface > &  xCFG,
const OUString &  sRelPathToSet,
const OUString &  sSetNode 
)
static

it checks if the specified set node exists ... or create an empty one otherwise.

This method must be used in combination with openConfig(). The cached configuration access must be provided here ... and all operations are made relative to this access point.

Further this method must be used only with configuration set's. Atomic keys can't be "created"... they "exist every time".

Parameters
xCFGthe configuration root, where sRelPathToSet should be interpreted as relative path.
sRelPathToSetpath relative to xCFG parameter.
sSetNodethe set node, which should be checked if it exists... or which should be created with default values.
Returns
A reference to the found (or new created) set node. Can't be NULL .. in such case an exception occurs!
Exceptions
Anyexceptions the underlying configuration can throw. E.g. css::uno::Exception if the provided configuration access does not allow writing for this set.

Definition at line 110 of file configurationhelper.cxx.

◆ openConfig()

css::uno::Reference< css::uno::XInterface > comphelper::ConfigurationHelper::openConfig ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
const OUString &  sPackage,
EConfigurationModes  eMode 
)
static

returns access to the specified configuration package.

This method should be used, if e.g. more than one request to the same configuration package is needed. The configuration access can be cached outside and used inbetween.

Parameters
rxContextthe uno service manager, which should be used to create the configuration access.
sPackagethe name of the configuration package. e.g.
  • org.openoffice.Office.Common
  • org.openoffice.Office.Common/Menu
eModespecify the open mode for the returned configuration access. It's interpreted as a flag field and can be any useful combination of values of EConfigurationModes.
Exceptions
Anyexceptions the underlying configuration can throw. E.g. css::uno::Exception if the configuration could not be opened.

Definition at line 35 of file configurationhelper.cxx.

References comphelper::AllLocales, bReadOnly, comphelper::containerToSequence(), eMode, and comphelper::ReadOnly.

Referenced by readDirectKey(), and writeDirectKey().

◆ readDirectKey()

css::uno::Any comphelper::ConfigurationHelper::readDirectKey ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
const OUString &  sPackage,
const OUString &  sRelPath,
const OUString &  sKey,
EConfigurationModes  eMode 
)
static

does the same then openConfig() & readRelativeKey() together.

This method should be used for reading one key at one code place only. Because it opens the specified configuration package, reads the key and closes the configuration again.

So it's not very useful to use this method for reading multiple keys at the same time. (Excepting these keys exists inside different configuration packages ...))

Definition at line 138 of file configurationhelper.cxx.

References eMode, openConfig(), and readRelativeKey().

◆ readRelativeKey()

css::uno::Any comphelper::ConfigurationHelper::readRelativeKey ( const css::uno::Reference< css::uno::XInterface > &  xCFG,
const OUString &  sRelPath,
const OUString &  sKey 
)
static

reads the value of an existing(!) configuration key, which is searched relative to the specified configuration access.

This method must be used in combination with openConfig(). The cached configuration access must be provided here ... and all operations are made relative to this access point.

Parameters
xCFGthe configuration root, where sRelPath should be interpreted. as relative path
sRelPathpath relative to xCFG parameter.
sKeythe configuration node, where we should read the value.
Returns
[css.uno.Any] the value of sKey.
Exceptions
Anyexceptions the underlying configuration can throw. E.g. css::container::NoSuchElementException if the specified key does not exists.

Definition at line 75 of file configurationhelper.cxx.

Referenced by readDirectKey().

◆ writeDirectKey()

void comphelper::ConfigurationHelper::writeDirectKey ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
const OUString &  sPackage,
const OUString &  sRelPath,
const OUString &  sKey,
const css::uno::Any &  aValue,
EConfigurationModes  eMode 
)
static

does the same then openConfig() / writeRelativeKey() & flush() together.

This method should be used for writing one key at one code place only. Because it opens the specified configuration package, writes the key, flush all changes and closes the configuration again.

So it's not very useful to use this method for writing multiple keys at the same time. (Excepting these keys exists inside different configuration packages ...))

Definition at line 149 of file configurationhelper.cxx.

References eMode, flush(), openConfig(), and writeRelativeKey().

◆ writeRelativeKey()

void comphelper::ConfigurationHelper::writeRelativeKey ( const css::uno::Reference< css::uno::XInterface > &  xCFG,
const OUString &  sRelPath,
const OUString &  sKey,
const css::uno::Any &  aValue 
)
static

writes a new value for an existing(!) configuration key, which is searched relative to the specified configuration access.

This method must be used in combination with openConfig(). The cached configuration access must be provided here ... and all operations are made relative to this access point.

Parameters
xCFGthe configuration root, where sRelPath should be interpreted. as relative path
sRelPathpath relative to xCFG parameter.
sKeythe configuration node, where we should write the new value.
aValuethe new value for sKey.
Exceptions
Anyexceptions the underlying configuration can throw. E.g. css::container::NoSuchElementException if the specified key does not exists or css::uno::Exception if the provided configuration access does not allow writing for this key.

Definition at line 92 of file configurationhelper.cxx.

Referenced by writeDirectKey().


The documentation for this class was generated from the following files: