LibreOffice Module framework (master) 1
presethandler.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <string_view>
25
27
28#include <com/sun/star/embed/XStorage.hpp>
29
30#include <com/sun/star/uno/XComponentContext.hpp>
31
33
34namespace framework
35{
52{
53 public:
54
62 {
66 };
67
68 private:
69
71 css::uno::Reference< css::uno::XComponentContext > m_xContext;
72
78
82
93 css::uno::Reference< css::embed::XStorage > m_xWorkingStorageShare;
94
97 css::uno::Reference< css::embed::XStorage > m_xWorkingStorageNoLang;
98
109 css::uno::Reference< css::embed::XStorage > m_xWorkingStorageUser;
110
114
115 // native interface
116
117 public:
118
125 PresetHandler(css::uno::Reference< css::uno::XComponentContext > xContext);
126
128 PresetHandler(const PresetHandler& rCopy);
129
132
135
150 css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageShare();
151 css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageUser();
152
161 css::uno::Reference< css::embed::XStorage > getWorkingStorageUser() const;
162
172 css::uno::Reference< css::embed::XStorage > getParentStorageShare();
173 css::uno::Reference< css::embed::XStorage > getParentStorageUser ();
174
209 void connectToResource( EConfigType eConfigType ,
210 std::u16string_view sResourceType ,
211 std::u16string_view sModule ,
212 const css::uno::Reference< css::embed::XStorage >& xDocumentRoot ,
213 const LanguageTag& rLanguageTag = LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE));
214
235 void copyPresetToTarget(std::u16string_view sPreset,
236 std::u16string_view sTarget);
237
251 css::uno::Reference< css::io::XStream > openPreset(std::u16string_view sPreset);
252
267 css::uno::Reference< css::io::XStream > openTarget(
268 std::u16string_view sTarget, sal_Int32 nMode);
269
277 void commitUserChanges();
278
282
283 // helper
284
285 private:
286
302 css::uno::Reference< css::embed::XStorage > impl_openPathIgnoringErrors(const OUString& sPath ,
303 sal_Int32 eMode ,
304 bool bShare);
305
328 ::std::vector< OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< OUString >& lLocalizedValues,
329 OUString& rLanguageTag ,
330 bool bAllowFallbacks );
331
359 css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(OUString& sPath ,
360 sal_Int32 eMode ,
361 bool bShare ,
362 OUString& rLanguageTag ,
363 bool bAllowFallback);
364
373 ::std::vector< OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder);
374};
375
376} // namespace framework
377
378/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::vector< OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage > &xFolder)
returns the names of all sub storages of specified storage.
css::uno::Reference< css::io::XStream > openPreset(std::u16string_view sPreset)
open the specified preset as stream object and return it.
PresetHandler(css::uno::Reference< css::uno::XComponentContext > xContext)
does nothing real.
css::uno::Reference< css::embed::XStorage > m_xWorkingStorageUser
holds the folder storage of the user layer alive, where the current configuration set exists.
css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageShare()
return access to the internally used and cached root storage.
css::uno::Reference< css::embed::XStorage > getParentStorageShare()
check if there is a parent storage well known for the specified child storage and return it.
css::uno::Reference< css::embed::XStorage > getWorkingStorageUser() const
provides access to the current working storages.
css::uno::Reference< css::uno::XComponentContext > m_xContext
can be used to create on needed uno resources.
void removeStorageListener(XMLBasedAcceleratorConfiguration *pListener)
css::uno::Reference< css::embed::XStorage > m_xWorkingStorageShare
holds the folder storage of the share layer alive, where the current configuration set exists.
void commitUserChanges()
do anything which is necessary to flush all changes back to disk.
StorageHolder m_lDocumentStorages
if we run in document mode, we can't use the global root storages! We have to use a special document ...
OUString m_sRelPathShare
knows the relative path from the root.
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 speci...
EConfigType
this handler can provide different types of configuration.
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).
~PresetHandler()
closes all open storages ... if user forgot that .
void forgetCachedStorages()
free all currently cache(!) storages.
css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageUser()
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.
css::uno::Reference< css::embed::XStorage > impl_openPathIgnoringErrors(const OUString &sPath, sal_Int32 eMode, bool bShare)
open a config path ignoring errors (catching exceptions).
EConfigType m_eConfigType
knows the type of provided configuration.
css::uno::Reference< css::embed::XStorage > getParentStorageUser()
void addStorageListener(XMLBasedAcceleratorConfiguration *pListener)
TODO.
::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.
css::uno::Reference< css::io::XStream > openTarget(std::u16string_view sTarget, sal_Int32 nMode)
open the specified target as stream object and return it.
css::uno::Reference< css::embed::XStorage > m_xWorkingStorageNoLang
global language-independent storage
implements a read/write access to the accelerator configuration.