LibreOffice Module framework (master) 1
|
TODO document me. More...
#include <presethandler.hxx>
Public Types | |
enum | EConfigType { E_GLOBAL , E_MODULES , E_DOCUMENT } |
this handler can provide different types of configuration. More... | |
Public Member Functions | |
PresetHandler (css::uno::Reference< css::uno::XComponentContext > xContext) | |
does nothing real. More... | |
PresetHandler (const PresetHandler &rCopy) | |
copy ctor More... | |
~PresetHandler () | |
closes all open storages ... if user forgot that . More... | |
void | forgetCachedStorages () |
free all currently cache(!) storages. More... | |
css::uno::Reference< css::embed::XStorage > | getOrCreateRootStorageShare () |
return access to the internally used and cached root storage. More... | |
css::uno::Reference< css::embed::XStorage > | getOrCreateRootStorageUser () |
css::uno::Reference< css::embed::XStorage > | getWorkingStorageUser () const |
provides access to the current working storages. More... | |
css::uno::Reference< css::embed::XStorage > | getParentStorageShare () |
check if there is a parent storage well known for the specified child storage and return it. More... | |
css::uno::Reference< css::embed::XStorage > | getParentStorageUser () |
void | connectToResource (EConfigType eConfigType, std::u16string_view sResourceType, std::u16string_view sModule, const css::uno::Reference< css::embed::XStorage > &xDocumentRoot, const LanguageTag &rLanguageTag=LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE)) |
free all internal structures and let this handler work on a new type of configuration sets. More... | |
void | copyPresetToTarget (std::u16string_view sPreset, std::u16string_view sTarget) |
try to copy the specified preset from the share layer to the user layer and establish it as the specified target. More... | |
css::uno::Reference< css::io::XStream > | openPreset (std::u16string_view sPreset) |
open the specified preset as stream object and return it. More... | |
css::uno::Reference< css::io::XStream > | openTarget (std::u16string_view sTarget, sal_Int32 nMode) |
open the specified target as stream object and return it. More... | |
void | commitUserChanges () |
do anything which is necessary to flush all changes back to disk. More... | |
void | addStorageListener (XMLBasedAcceleratorConfiguration *pListener) |
TODO. More... | |
void | removeStorageListener (XMLBasedAcceleratorConfiguration *pListener) |
Private Member Functions | |
css::uno::Reference< css::embed::XStorage > | impl_openPathIgnoringErrors (const OUString &sPath, sal_Int32 eMode, bool bShare) |
open a config path ignoring errors (catching exceptions). More... | |
::std::vector< OUString >::const_iterator | impl_findMatchingLocalizedValue (const ::std::vector< OUString > &lLocalizedValues, OUString &rLanguageTag, bool bAllowFallbacks) |
try to find the specified locale inside list of possible ones. More... | |
css::uno::Reference< css::embed::XStorage > | impl_openLocalizedPathIgnoringErrors (OUString &sPath, sal_Int32 eMode, bool bShare, OUString &rLanguageTag, bool bAllowFallback) |
open a config path ignoring errors (catching exceptions). More... | |
::std::vector< OUString > | impl_getSubFolderNames (const css::uno::Reference< css::embed::XStorage > &xFolder) |
returns the names of all sub storages of specified storage. More... | |
Private Attributes | |
css::uno::Reference< css::uno::XComponentContext > | m_xContext |
can be used to create on needed uno resources. More... | |
EConfigType | m_eConfigType |
knows the type of provided configuration. More... | |
StorageHolder | m_lDocumentStorages |
if we run in document mode, we can't use the global root storages! We have to use a special document storage explicitly. More... | |
css::uno::Reference< css::embed::XStorage > | m_xWorkingStorageShare |
holds the folder storage of the share layer alive, where the current configuration set exists. More... | |
css::uno::Reference< css::embed::XStorage > | m_xWorkingStorageNoLang |
global language-independent storage More... | |
css::uno::Reference< css::embed::XStorage > | m_xWorkingStorageUser |
holds the folder storage of the user layer alive, where the current configuration set exists. More... | |
OUString | m_sRelPathShare |
knows the relative path from the root. More... | |
OUString | m_sRelPathUser |
TODO document me.
<layer>/global/<resourcetype>/<preset>.xml <layer>/modules/<moduleid>/<resourcetype>/<preset>.xml RESOURCETYPE PRESET TARGET (share) (user) "accelerator" "default" "current" "word" "excel" "menubar" "default" "menubar"
Definition at line 51 of file presethandler.hxx.
this handler can provide different types of configuration.
@descr Means: a global or a module dependent or ... configuration.
Enumerator | |
---|---|
E_GLOBAL | |
E_MODULES | |
E_DOCUMENT |
Definition at line 61 of file presethandler.hxx.
framework::PresetHandler::PresetHandler | ( | css::uno::Reference< css::uno::XComponentContext > | xContext | ) |
does nothing real.
xContext | points to a uno service manager, which is used internally to create own needed uno resources. |
Definition at line 76 of file presethandler.cxx.
framework::PresetHandler::PresetHandler | ( | const PresetHandler & | rCopy | ) |
copy ctor
Definition at line 82 of file presethandler.cxx.
References m_eConfigType, m_lDocumentStorages, m_sRelPathShare, m_sRelPathUser, m_xContext, m_xWorkingStorageNoLang, m_xWorkingStorageShare, and m_xWorkingStorageUser.
framework::PresetHandler::~PresetHandler | ( | ) |
closes all open storages ... if user forgot that .
-)
Definition at line 94 of file presethandler.cxx.
References framework::StorageHolder::forgetCachedStorages(), m_lDocumentStorages, m_sRelPathShare, m_sRelPathUser, m_xWorkingStorageNoLang, m_xWorkingStorageShare, and m_xWorkingStorageUser.
void framework::PresetHandler::addStorageListener | ( | XMLBasedAcceleratorConfiguration * | pListener | ) |
TODO.
Definition at line 562 of file presethandler.cxx.
References framework::StorageHolder::addStorageListener(), E_DOCUMENT, E_GLOBAL, E_MODULES, m_eConfigType, m_lDocumentStorages, and m_sRelPathUser.
void framework::PresetHandler::commitUserChanges | ( | ) |
do anything which is necessary to flush all changes back to disk.
@descr We have to call commit on all cached sub storages on the path from the root storage upside down to the working storage (which are not really used, but required to be holded alive!).
Definition at line 524 of file presethandler.cxx.
References framework::StorageHolder::commitPath(), E_DOCUMENT, E_GLOBAL, E_MODULES, framework::StorageHolder::getPathOfStorage(), m_eConfigType, m_lDocumentStorages, m_xWorkingStorageUser, and framework::StorageHolder::notifyPath().
Referenced by copyPresetToTarget(), and framework::XMLBasedAcceleratorConfiguration::store().
void framework::PresetHandler::connectToResource | ( | PresetHandler::EConfigType | eConfigType, |
std::u16string_view | sResourceType, | ||
std::u16string_view | sModule, | ||
const css::uno::Reference< css::embed::XStorage > & | xDocumentRoot, | ||
const LanguageTag & | rLanguageTag = LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE) |
||
) |
free all internal structures and let this handler work on a new type of configuration sets.
eConfigType | differ between global or module dependent configuration. |
sResourceType | differ between menubar/toolbar/accelerator/... configuration. |
sModule | if sResourceType is set to a module dependent configuration, it address the current application module. |
xDocumentRoot | if sResourceType is set to E_DOCUMENT, this value points to the root storage inside the document, where we can save our configuration files. Note: that's not the real root of the document... its only a sub storage. But we interpret it as our root storage. |
rLanguageTag | in case this configuration supports localized entries, the current locale must be set. |
Localization will be represented as directory structure of provided presets. Means: you call us with a preset name "default"; and we use e.g. "/en-US/default.xml" internally.
If no localization exists for this preset set, this class will work in default mode - means "no locale" - automatically. e.g. "/default.xml"
css::uno::RuntimeException(!) | if the specified resource couldn't be located. |
Definition at line 308 of file presethandler.cxx.
References E_DOCUMENT, E_GLOBAL, E_MODULES, ex, LanguageTag::getBcp47(), cppu::getCaughtException(), getOrCreateRootStorageShare(), getOrCreateRootStorageUser(), ID_CORRUPT_UICONFIG_GENERAL, impl_openLocalizedPathIgnoringErrors(), impl_openPathIgnoringErrors(), LANGUAGE_USER_PRIV_NOTRANSLATE, m_eConfigType, m_lDocumentStorages, m_sRelPathShare, m_sRelPathUser, m_xWorkingStorageNoLang, m_xWorkingStorageShare, m_xWorkingStorageUser, framework::StorageHolder::openPath(), and framework::StorageHolder::setRootStorage().
void framework::PresetHandler::copyPresetToTarget | ( | std::u16string_view | sPreset, |
std::u16string_view | sTarget | ||
) |
try to copy the specified preset from the share layer to the user layer and establish it as the specified target.
@descr Means: copy share/.../<preset>.xml user/.../<target>.xml Note: The target will be overwritten completely or created as new by this operation!
sPreset | the ALIAS name of an existing preset. |
sTarget | the ALIAS name of the target. |
css::container::NoSuchElementException | if the specified preset does not exists. |
css::io::IOException | if copying failed. |
Definition at line 446 of file presethandler.cxx.
References commitUserChanges(), m_xWorkingStorageNoLang, m_xWorkingStorageShare, and m_xWorkingStorageUser.
Referenced by framework::XMLBasedAcceleratorConfiguration::reset().
void framework::PresetHandler::forgetCachedStorages | ( | ) |
free all currently cache(!) storages.
Definition at line 121 of file presethandler.cxx.
References E_DOCUMENT, framework::StorageHolder::forgetCachedStorages(), m_eConfigType, m_lDocumentStorages, m_xWorkingStorageNoLang, m_xWorkingStorageShare, and m_xWorkingStorageUser.
css::uno::Reference< css::embed::XStorage > framework::PresetHandler::getOrCreateRootStorageShare | ( | ) |
return access to the internally used and cached root storage.
@descr These root storages are the base of all further opened presets and targets. They are provided here only, to support older implementations, which base on them ...
getOrCreate...() - What does it mean? Such root storage will be created one times only and cached then internally till the last instance of such PresetHandler dies.
Definition at line 174 of file presethandler.cxx.
References ex, cppu::getCaughtException(), ID_CORRUPT_UICONFIG_SHARE, m_xContext, and nPos.
Referenced by connectToResource().
css::uno::Reference< css::embed::XStorage > framework::PresetHandler::getOrCreateRootStorageUser | ( | ) |
Definition at line 233 of file presethandler.cxx.
References ex, cppu::getCaughtException(), ID_CORRUPT_UICONFIG_USER, m_xContext, and nPos.
Referenced by connectToResource().
css::uno::Reference< css::embed::XStorage > framework::PresetHandler::getParentStorageShare | ( | ) |
check if there is a parent storage well known for the specified child storage and return it.
xChild | the child storage where a paranet storage should be searched for. |
Definition at line 286 of file presethandler.cxx.
References m_xWorkingStorageShare.
css::uno::Reference< css::embed::XStorage > framework::PresetHandler::getParentStorageUser | ( | ) |
Definition at line 297 of file presethandler.cxx.
References m_xWorkingStorageUser.
css::uno::Reference< css::embed::XStorage > framework::PresetHandler::getWorkingStorageUser | ( | ) | const |
provides access to the current working storages.
@descr Working storages are the "lowest" storages, where the preset and target files exists.
Definition at line 280 of file presethandler.cxx.
References m_xWorkingStorageUser.
|
private |
try to find the specified locale inside list of possible ones.
@descr The list of possible locale values was e.g. retrieved from the system (configuration, directory listing etcpp). The locale normally represent the current office locale. This method search for a suitable item by using different algorithm. a) exact search b) search with using fallbacks
lLocalizedValues | list of BCP47 language tags / locale codes |
rLanguageTag | [IN ] the current office locale, which should be searched inside lLocalizedValues. [OUT] in case fallbacks was allowed, it contains afterwards the fallback locale. |
bAllowFallbacks | enable/disable using of fallbacks |
Definition at line 641 of file presethandler.cxx.
References LanguageTag::getFallback().
Referenced by impl_openLocalizedPathIgnoringErrors().
|
private |
returns the names of all sub storages of specified storage.
xFolder | the base storage for this operation. |
Definition at line 702 of file presethandler.cxx.
References i.
Referenced by impl_openLocalizedPathIgnoringErrors().
|
private |
open a config path ignoring errors (catching exceptions).
@descr We catch only normal exceptions here - no runtime exceptions. Further the path itself is tries in different versions (using locale specific attributes). e.g. "path/e-US" => "path/en" => "path/de"
sPath | the configuration path, which should be opened. It's further used as out parameter too, so we can return the localized path! |
eMode | the open mode (READ/READWRITE) |
bShare | force using of the share layer instead of the user layer. |
rLanguageTag | [IN ] contains the start locale for searching localized sub dirs. [OUT] contains the locale of a found localized sub dir |
bAllowFallback | enable/disable fallback handling for locales |
Definition at line 665 of file presethandler.cxx.
References eMode, impl_findMatchingLocalizedValue(), impl_getSubFolderNames(), and impl_openPathIgnoringErrors().
Referenced by connectToResource().
|
private |
open a config path ignoring errors (catching exceptions).
@descr We catch only normal exceptions here - no runtime exceptions.
sPath | the configuration path, which should be opened. |
eMode | the open mode (READ/READWRITE) |
bShare | force using of the share layer instead of the user layer. |
Definition at line 622 of file presethandler.cxx.
References eMode.
Referenced by connectToResource(), and impl_openLocalizedPathIgnoringErrors().
css::uno::Reference< css::io::XStream > framework::PresetHandler::openPreset | ( | std::u16string_view | sPreset | ) |
open the specified preset as stream object and return it.
@descr Note: Because presets resist inside the share layer, they will be opened readonly every time.
sPreset | the ALIAS name of an existing preset. |
Accesses the global language-independent storage instead of the preset storage
Definition at line 487 of file presethandler.cxx.
References m_xWorkingStorageNoLang, and xStream.
Referenced by framework::XMLBasedAcceleratorConfiguration::reload().
css::uno::Reference< css::io::XStream > framework::PresetHandler::openTarget | ( | std::u16string_view | sTarget, |
sal_Int32 | nMode | ||
) |
open the specified target as stream object and return it.
@descr Note: Targets resist inside the user layer. Normally they are opened in read/write mode. But it will be opened readonly automatically if that isn't possible (may be the file is write protected on the system ...).
sTarget | the ALIAS name of the target. |
Definition at line 506 of file presethandler.cxx.
References m_xWorkingStorageUser.
Referenced by framework::XMLBasedAcceleratorConfiguration::isReadOnly(), framework::XMLBasedAcceleratorConfiguration::reload(), and framework::XMLBasedAcceleratorConfiguration::store().
void framework::PresetHandler::removeStorageListener | ( | XMLBasedAcceleratorConfiguration * | pListener | ) |
Definition at line 592 of file presethandler.cxx.
References E_DOCUMENT, E_GLOBAL, E_MODULES, m_eConfigType, m_lDocumentStorages, m_sRelPathUser, and framework::StorageHolder::removeStorageListener().
|
private |
knows the type of provided configuration.
@descr e.g. global, modules, ...
Definition at line 77 of file presethandler.hxx.
Referenced by addStorageListener(), commitUserChanges(), connectToResource(), forgetCachedStorages(), PresetHandler(), and removeStorageListener().
|
private |
if we run in document mode, we can't use the global root storages! We have to use a special document storage explicitly.
Definition at line 81 of file presethandler.hxx.
Referenced by addStorageListener(), commitUserChanges(), connectToResource(), forgetCachedStorages(), PresetHandler(), removeStorageListener(), and ~PresetHandler().
|
private |
knows the relative path from the root.
Definition at line 112 of file presethandler.hxx.
Referenced by connectToResource(), PresetHandler(), and ~PresetHandler().
|
private |
Definition at line 113 of file presethandler.hxx.
Referenced by addStorageListener(), connectToResource(), PresetHandler(), removeStorageListener(), and ~PresetHandler().
|
private |
can be used to create on needed uno resources.
Definition at line 71 of file presethandler.hxx.
Referenced by getOrCreateRootStorageShare(), getOrCreateRootStorageUser(), and PresetHandler().
|
private |
global language-independent storage
Definition at line 97 of file presethandler.hxx.
Referenced by connectToResource(), copyPresetToTarget(), forgetCachedStorages(), openPreset(), PresetHandler(), and ~PresetHandler().
|
private |
holds the folder storage of the share layer alive, where the current configuration set exists.
@descr Note: If this preset handler works in document mode this member is meant relative to the document root... not to the share layer root!
Further is defined, that m_xWorkingStorageUser is equals to m_xWorkingStorageShare then!
Definition at line 93 of file presethandler.hxx.
Referenced by connectToResource(), copyPresetToTarget(), forgetCachedStorages(), getParentStorageShare(), PresetHandler(), and ~PresetHandler().
|
private |
holds the folder storage of the user layer alive, where the current configuration set exists.
@descr Note: If this preset handler works in document mode this member is meant relative to the document root... not to the user layer root!
Further is defined, that m_xWorkingStorageUser is equals to m_xWorkingStorageShare then!
Definition at line 109 of file presethandler.hxx.
Referenced by commitUserChanges(), connectToResource(), copyPresetToTarget(), forgetCachedStorages(), getParentStorageUser(), getWorkingStorageUser(), openTarget(), PresetHandler(), and ~PresetHandler().