LibreOffice Module framework (master) 1
presethandler.cxx
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
21
22#include <classes/fwkresid.hxx>
23
24#include <strings.hrc>
25
26#include <com/sun/star/configuration/CorruptedUIConfigurationException.hpp>
27#include <com/sun/star/container/XNameAccess.hpp>
28#include <com/sun/star/embed/ElementModes.hpp>
29#include <com/sun/star/embed/FileSystemStorageFactory.hpp>
30#include <com/sun/star/lang/XSingleServiceFactory.hpp>
31#include <com/sun/star/util/thePathSettings.hpp>
32
33#include <utility>
34#include <vcl/svapp.hxx>
36#include <rtl/ustrbuf.hxx>
37#include <osl/diagnose.h>
39
40const ::sal_Int32 ID_CORRUPT_UICONFIG_SHARE = 1;
41const ::sal_Int32 ID_CORRUPT_UICONFIG_USER = 2;
42const ::sal_Int32 ID_CORRUPT_UICONFIG_GENERAL = 3;
43
44namespace framework
45{
46
47namespace {
48
55struct TSharedStorages final
56{
57 StorageHolder m_lStoragesShare;
58 StorageHolder m_lStoragesUser;
59
60 TSharedStorages()
61 {};
62};
63
68TSharedStorages& SharedStorages()
69{
70 static TSharedStorages theStorages;
71 return theStorages;
72}
73
74}
75
76PresetHandler::PresetHandler(css::uno::Reference< css::uno::XComponentContext > xContext)
77 : m_xContext(std::move(xContext))
78 , m_eConfigType(E_GLOBAL)
79{
80}
81
83{
84 m_xContext = rCopy.m_xContext;
92}
93
95{
99
100 /* #i46497#
101 Don't call forgetCachedStorages() here for shared storages.
102 Because we opened different sub storages by using openPath().
103 And every already open path was reused and referenced (means it's
104 ref count was increased!)
105 So now we have to release our ref counts to these shared storages
106 only ... and not to free all used storages.
107 Otherwise we will disconnect all other open configuration access
108 objects which base on these storages.
109 */
110 auto & sharedStorages = SharedStorages();
111 sharedStorages.m_lStoragesShare.closePath(m_sRelPathShare);
112 sharedStorages.m_lStoragesUser.closePath (m_sRelPathUser );
113
114 /* On the other side closePath() is not needed for our special handled
115 document storage. Because it's not shared with others ... so we can
116 free it.
117 */
119}
120
122{
124
126 {
129 m_xWorkingStorageUser.clear();
130 }
131
133}
134
135namespace {
136
137OUString lcl_getLocalizedMessage(::sal_Int32 nID)
138{
139 OUString sMessage("Unknown error.");
140
141 switch(nID)
142 {
144 sMessage = FwkResId(STR_CORRUPT_UICFG_SHARE);
145
146 break;
147
149 sMessage = FwkResId(STR_CORRUPT_UICFG_USER);
150 break;
151
153 sMessage = FwkResId(STR_CORRUPT_UICFG_GENERAL);
154 break;
155 }
156
157 return sMessage;
158}
159
160void lcl_throwCorruptedUIConfigurationException(
161 css::uno::Any const & exception, sal_Int32 id)
162{
163 css::uno::Exception e;
164 bool ok = (exception >>= e);
165 OSL_ASSERT(ok);
166 throw css::configuration::CorruptedUIConfigurationException(
167 lcl_getLocalizedMessage(id),
168 css::uno::Reference< css::uno::XInterface >(),
169 exception.getValueTypeName() + ": \"" + e.Message + "\"");
170}
171
172}
173
174css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageShare()
175{
176 auto & sharedStorages = SharedStorages();
177 css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesShare.getRootStorage();
178 if (xRoot.is())
179 return xRoot;
180
181 css::uno::Reference< css::uno::XComponentContext > xContext;
182 {
184 xContext = m_xContext;
185 }
186
187 css::uno::Reference< css::util::XPathSettings > xPathSettings =
188 css::util::thePathSettings::get( xContext );
189
190 OUString sShareLayer = xPathSettings->getBasePathShareLayer();
191
192 // "UIConfig" is a "multi path" ... use first part only here!
193 sal_Int32 nPos = sShareLayer.indexOf(';');
194 if (nPos > 0)
195 sShareLayer = sShareLayer.copy(0, nPos);
196
197 // Note: May be an user uses URLs without a final slash! Check it ...
198 nPos = sShareLayer.lastIndexOf('/');
199 if (nPos != sShareLayer.getLength()-1)
200 sShareLayer += "/";
201
202 sShareLayer += "soffice.cfg";
203 /*
204 // TODO remove me!
205 // Attention: This is temp. workaround ... We create a temp. storage file
206 // based of a system directory. This must be used so, till the storage implementation
207 // can work on directories too.
208 */
209 css::uno::Sequence< css::uno::Any > lArgs{
210 css::uno::Any(sShareLayer),
211 css::uno::Any(css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE)
212 };
213
214 css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( xContext );
215 css::uno::Reference< css::embed::XStorage > xStorage;
216
217 try
218 {
219 xStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
220 }
221 catch(const css::uno::Exception&)
222 {
223 css::uno::Any ex(cppu::getCaughtException());
224 lcl_throwCorruptedUIConfigurationException(
226 }
227
228 sharedStorages.m_lStoragesShare.setRootStorage(xStorage);
229
230 return xStorage;
231}
232
233css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorageUser()
234{
235 auto & sharedStorages = SharedStorages();
236 css::uno::Reference< css::embed::XStorage > xRoot = sharedStorages.m_lStoragesUser.getRootStorage();
237 if (xRoot.is())
238 return xRoot;
239
240 css::uno::Reference< css::uno::XComponentContext > xContext;
241 {
243 xContext = m_xContext;
244 }
245
246 css::uno::Reference< css::util::XPathSettings > xPathSettings =
247 css::util::thePathSettings::get( xContext );
248
249 OUString sUserLayer = xPathSettings->getBasePathUserLayer();
250
251 // Note: May be an user uses URLs without a final slash! Check it ...
252 sal_Int32 nPos = sUserLayer.lastIndexOf('/');
253 if (nPos != sUserLayer.getLength()-1)
254 sUserLayer += "/";
255
256 sUserLayer += "soffice.cfg"; // storage file
257
258 css::uno::Sequence< css::uno::Any > lArgs{ css::uno::Any(sUserLayer),
259 css::uno::Any(css::embed::ElementModes::READWRITE) };
260
261 css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( xContext );
262 css::uno::Reference< css::embed::XStorage > xStorage;
263
264 try
265 {
266 xStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
267 }
268 catch(const css::uno::Exception&)
269 {
270 css::uno::Any ex(cppu::getCaughtException());
271 lcl_throwCorruptedUIConfigurationException(
273 }
274
275 sharedStorages.m_lStoragesUser.setRootStorage(xStorage);
276
277 return xStorage;
278}
279
280css::uno::Reference< css::embed::XStorage > PresetHandler::getWorkingStorageUser() const
281{
284}
285
286css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageShare()
287{
288 css::uno::Reference< css::embed::XStorage > xWorking;
289 {
291 xWorking = m_xWorkingStorageShare;
292 }
293
294 return SharedStorages().m_lStoragesShare.getParentStorage(xWorking);
295}
296
297css::uno::Reference< css::embed::XStorage > PresetHandler::getParentStorageUser()
298{
299 css::uno::Reference< css::embed::XStorage > xWorking;
300 {
302 xWorking = m_xWorkingStorageUser;
303 }
304
305 return SharedStorages().m_lStoragesUser.getParentStorage(xWorking);
306}
307
309 std::u16string_view sResource ,
310 std::u16string_view sModule ,
311 const css::uno::Reference< css::embed::XStorage >& xDocumentRoot,
312 const LanguageTag& rLanguageTag )
313{
314 // TODO free all current open storages!
315
316 {
318 m_eConfigType = eConfigType;
319 }
320
321 css::uno::Reference< css::embed::XStorage > xShare;
322 css::uno::Reference< css::embed::XStorage > xNoLang;
323 css::uno::Reference< css::embed::XStorage > xUser;
324
325 // special case for documents
326 // use outside root storage, if we run in E_DOCUMENT mode!
327 if (eConfigType == E_DOCUMENT)
328 {
329 if (!xDocumentRoot.is())
330 throw css::uno::RuntimeException(
331 "There is valid root storage, where the UI configuration can work on.");
332 m_lDocumentStorages.setRootStorage(xDocumentRoot);
333 xShare = xDocumentRoot;
334 xUser = xDocumentRoot;
335 }
336 else
337 {
340 }
341
342 // #...#
343 try
344 {
345
346 // a) inside share layer we should not create any new structures... We have to use
347 // existing ones only!
348 // b) inside user layer we can (SOFT mode!) but sometimes we should not (HARD mode!)
349 // create new empty structures. We should prefer using of any existing structure.
350 sal_Int32 eShareMode = (css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE);
351 sal_Int32 eUserMode = css::embed::ElementModes::READWRITE;
352
353 OUStringBuffer sRelPathBuf(1024);
354 OUString sRelPathShare;
355 OUString sRelPathUser;
356 switch(eConfigType)
357 {
358 case E_GLOBAL :
359 {
360 sRelPathShare = OUString::Concat("global/") + sResource;
361 sRelPathUser = sRelPathShare;
362
363 xShare = impl_openPathIgnoringErrors(sRelPathShare, eShareMode, true );
364 xUser = impl_openPathIgnoringErrors(sRelPathUser , eUserMode , false);
365 }
366 break;
367
368 case E_MODULES :
369 {
370 sRelPathShare = OUString::Concat("modules/") + sModule + "/" + sResource;
371 sRelPathUser = sRelPathShare;
372
373 xShare = impl_openPathIgnoringErrors(sRelPathShare, eShareMode, true );
374 xUser = impl_openPathIgnoringErrors(sRelPathUser , eUserMode , false);
375 }
376 break;
377
378 case E_DOCUMENT :
379 {
380 // A document does not have a share layer in real.
381 // It has one layer only, and this one should be opened READ_WRITE.
382 // So we open the user layer here only and set the share layer equals to it .-)
383
384 sRelPathBuf.append(sResource);
385 sRelPathUser = sRelPathBuf.makeStringAndClear();
386 sRelPathShare = sRelPathUser;
387
388 try
389 {
390 xUser = m_lDocumentStorages.openPath(sRelPathUser , eUserMode );
391 xShare = xUser;
392 }
393 catch(const css::uno::RuntimeException&)
394 { throw; }
395 catch(const css::uno::Exception&)
396 { xShare.clear(); xUser.clear(); }
397 }
398 break;
399 }
400
401 // Non-localized global share
402 xNoLang = xShare;
403
404 if (
405 (rLanguageTag != LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE)) && // localized level?
406 (eConfigType != E_DOCUMENT ) // no localization in document mode!
407 )
408 {
409 // First try to find the right localized set inside share layer.
410 // Fallbacks are allowed there.
411 OUString aShareLocale( rLanguageTag.getBcp47());
412 OUString sLocalizedSharePath(sRelPathShare);
413 bool bAllowFallbacks = true;
414 xShare = impl_openLocalizedPathIgnoringErrors(sLocalizedSharePath, eShareMode, true , aShareLocale, bAllowFallbacks);
415
416 // The try to locate the right sub dir inside user layer ... without using fallbacks!
417 // Normally the corresponding sub dir should be created matching the specified locale.
418 // Because we allow creation of storages inside user layer by default.
419 OUString aUserLocale( rLanguageTag.getBcp47());
420 OUString sLocalizedUserPath(sRelPathUser);
421 bAllowFallbacks = false;
422 xUser = impl_openLocalizedPathIgnoringErrors(sLocalizedUserPath, eUserMode, false, aUserLocale, bAllowFallbacks);
423
424 sRelPathShare = sLocalizedSharePath;
425 sRelPathUser = sLocalizedUserPath;
426 }
427
428 {
430 m_xWorkingStorageShare = xShare;
432 m_xWorkingStorageUser = xUser;
433 m_sRelPathShare = sRelPathShare;
434 m_sRelPathUser = sRelPathUser;
435 }
436
437 }
438 catch(const css::uno::Exception&)
439 {
440 css::uno::Any ex(cppu::getCaughtException());
441 lcl_throwCorruptedUIConfigurationException(
443 }
444}
445
446void PresetHandler::copyPresetToTarget(std::u16string_view sPreset,
447 std::u16string_view sTarget)
448{
449 // don't check our preset list, if element exists
450 // We try to open it and forward all errors to the user!
451
452 css::uno::Reference< css::embed::XStorage > xWorkingShare;
453 css::uno::Reference< css::embed::XStorage > xWorkingNoLang;
454 css::uno::Reference< css::embed::XStorage > xWorkingUser;
455 {
457 xWorkingShare = m_xWorkingStorageShare;
458 xWorkingNoLang= m_xWorkingStorageNoLang;
459 xWorkingUser = m_xWorkingStorageUser;
460 }
461
462 // e.g. module without any config data ?!
463 if (
464 (!xWorkingShare.is()) ||
465 (!xWorkingUser.is() )
466 )
467 {
468 return;
469 }
470
471 OUString sPresetFile = OUString::Concat(sPreset) + ".xml";
472 OUString sTargetFile = OUString::Concat(sTarget) + ".xml";
473
474 // remove existing elements before you try to copy the preset to that location ...
475 // Otherwise w will get an ElementExistException inside copyElementTo()!
476 css::uno::Reference< css::container::XNameAccess > xCheckingUser(xWorkingUser, css::uno::UNO_QUERY_THROW);
477 if (xCheckingUser->hasByName(sTargetFile))
478 xWorkingUser->removeElement(sTargetFile);
479
480 xWorkingShare->copyElementTo(sPresetFile, xWorkingUser, sTargetFile);
481
482 // If our storages work in transacted mode, we have
483 // to commit all changes from bottom to top!
485}
486
487css::uno::Reference< css::io::XStream > PresetHandler::openPreset(std::u16string_view sPreset)
488{
489 css::uno::Reference< css::embed::XStorage > xFolder;
490 {
492 xFolder = m_xWorkingStorageNoLang;
493 }
494
495 // e.g. module without any config data ?!
496 if (!xFolder.is())
497 return css::uno::Reference< css::io::XStream >();
498
499 OUString sFile = OUString::Concat(sPreset) + ".xml";
500
501 // inform user about errors (use original exceptions!)
502 css::uno::Reference< css::io::XStream > xStream = xFolder->openStreamElement(sFile, css::embed::ElementModes::READ);
503 return xStream;
504}
505
506css::uno::Reference< css::io::XStream > PresetHandler::openTarget(
507 std::u16string_view sTarget, sal_Int32 const nMode)
508{
509 css::uno::Reference< css::embed::XStorage > xFolder;
510 {
512 xFolder = m_xWorkingStorageUser;
513 }
514
515 // e.g. module without any config data ?!
516 if (!xFolder.is())
517 return css::uno::Reference< css::io::XStream >();
518
519 OUString const sFile(OUString::Concat(sTarget) + ".xml");
520
521 return xFolder->openStreamElement(sFile, nMode);
522}
523
525{
526 css::uno::Reference< css::embed::XStorage > xWorking;
527 EConfigType eCfgType;
528 {
530 xWorking = m_xWorkingStorageUser;
531 eCfgType = m_eConfigType;
532 }
533
534 // e.g. module without any config data ?!
535 if (!xWorking.is())
536 return;
537
538 OUString sPath;
539
540 switch(eCfgType)
541 {
542 case E_GLOBAL :
543 case E_MODULES :
544 {
545 auto & sharedStorages = SharedStorages();
546 sPath = sharedStorages.m_lStoragesUser.getPathOfStorage(xWorking);
547 sharedStorages.m_lStoragesUser.commitPath(sPath);
548 sharedStorages.m_lStoragesUser.notifyPath(sPath);
549 }
550 break;
551
552 case E_DOCUMENT :
553 {
554 sPath = m_lDocumentStorages.getPathOfStorage(xWorking);
557 }
558 break;
559 }
560}
561
563{
564 OUString sRelPath;
565 EConfigType eCfgType;
566 {
568 sRelPath = m_sRelPathUser; // use user path ... because we don't work directly on the share layer!
569 eCfgType = m_eConfigType;
570 }
571
572 if (sRelPath.isEmpty())
573 return;
574
575 switch(eCfgType)
576 {
577 case E_GLOBAL :
578 case E_MODULES :
579 {
580 SharedStorages().m_lStoragesUser.addStorageListener(pListener, sRelPath);
581 }
582 break;
583
584 case E_DOCUMENT :
585 {
586 m_lDocumentStorages.addStorageListener(pListener, sRelPath);
587 }
588 break;
589 }
590}
591
593{
594 OUString sRelPath;
595 EConfigType eCfgType;
596 {
598 sRelPath = m_sRelPathUser; // use user path ... because we don't work directly on the share layer!
599 eCfgType = m_eConfigType;
600 }
601
602 if (sRelPath.isEmpty())
603 return;
604
605 switch(eCfgType)
606 {
607 case E_GLOBAL :
608 case E_MODULES :
609 {
610 SharedStorages().m_lStoragesUser.removeStorageListener(pListener, sRelPath);
611 }
612 break;
613
614 case E_DOCUMENT :
615 {
616 m_lDocumentStorages.removeStorageListener(pListener, sRelPath);
617 }
618 break;
619 }
620}
621
622css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoringErrors(const OUString& sPath ,
623 sal_Int32 eMode ,
624 bool bShare)
625{
626 css::uno::Reference< css::embed::XStorage > xPath;
627 try
628 {
629 if (bShare)
630 xPath = SharedStorages().m_lStoragesShare.openPath(sPath, eMode);
631 else
632 xPath = SharedStorages().m_lStoragesUser.openPath(sPath, eMode);
633 }
634 catch(const css::uno::RuntimeException&)
635 { throw; }
636 catch(const css::uno::Exception&)
637 { xPath.clear(); }
638 return xPath;
639}
640
641::std::vector< OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(
642 const ::std::vector< OUString >& lLocalizedValues,
643 OUString& rLanguageTag,
644 bool bAllowFallbacks )
645{
646 ::std::vector< OUString >::const_iterator pFound = lLocalizedValues.end();
647 if (bAllowFallbacks)
648 {
649 pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag);
650 // if we found a valid locale ... take it over to our in/out parameter
651 // rLanguageTag
652 if (pFound != lLocalizedValues.end())
653 {
654 rLanguageTag = *pFound;
655 }
656 }
657 else
658 {
659 pFound = std::find(lLocalizedValues.begin(), lLocalizedValues.end(), rLanguageTag);
660 }
661
662 return pFound;
663}
664
665css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPathIgnoringErrors(
666 OUString& sPath ,
667 sal_Int32 eMode ,
668 bool bShare ,
669 OUString& rLanguageTag ,
670 bool bAllowFallback)
671{
672 css::uno::Reference< css::embed::XStorage > xPath = impl_openPathIgnoringErrors(sPath, eMode, bShare);
673 ::std::vector< OUString > lSubFolders = impl_getSubFolderNames(xPath);
674 ::std::vector< OUString >::const_iterator pLocaleFolder = impl_findMatchingLocalizedValue(lSubFolders, rLanguageTag, bAllowFallback);
675
676 // no fallback ... creation not allowed => no storage
677 if (
678 (pLocaleFolder == lSubFolders.end() ) &&
679 ((eMode & css::embed::ElementModes::NOCREATE) == css::embed::ElementModes::NOCREATE)
680 )
681 return css::uno::Reference< css::embed::XStorage >();
682
683 // it doesn't matter, if there is a locale fallback or not
684 // If creation of storages is allowed, we do it anyway.
685 // Otherwise we have no acc config at all, which can make other trouble.
686 OUString sLocalizedPath = sPath + "/";
687 if (pLocaleFolder != lSubFolders.end())
688 sLocalizedPath += *pLocaleFolder;
689 else
690 sLocalizedPath += rLanguageTag;
691
692 css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
693
694 if (xLocalePath.is())
695 sPath = sLocalizedPath;
696 else
697 sPath.clear();
698
699 return xLocalePath;
700}
701
702::std::vector< OUString > PresetHandler::impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder)
703{
704 if (!xFolder.is())
705 return ::std::vector< OUString >();
706
707 ::std::vector< OUString > lSubFolders;
708 const css::uno::Sequence< OUString > lNames = xFolder->getElementNames();
709 const OUString* pNames = lNames.getConstArray();
710 sal_Int32 c = lNames.getLength();
711 sal_Int32 i = 0;
712
713 for (i=0; i<c; ++i)
714 {
715 try
716 {
717 if (xFolder->isStorageElement(pNames[i]))
718 lSubFolders.push_back(pNames[i]);
719 }
720 catch(const css::uno::RuntimeException&)
721 { throw; }
722 catch(const css::uno::Exception&)
723 {}
724 }
725
726 return lSubFolders;
727}
728
729} // namespace framework
730
731/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XInputStream > xStream
const OUString & getBcp47(bool bResolveSystem=true) const
::std::vector< OUString >::const_iterator getFallback(const ::std::vector< OUString > &rList, const OUString &rReference)
::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
void removeStorageListener(XMLBasedAcceleratorConfiguration *pListener, const OUString &sPath)
TODO.
void commitPath(const OUString &sPath)
TODO.
OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage > &xStorage)
TODO.
void forgetCachedStorages()
TODO.
void setRootStorage(const css::uno::Reference< css::embed::XStorage > &xRoot)
TODO.
void notifyPath(const OUString &sPath)
TODO.
void addStorageListener(XMLBasedAcceleratorConfiguration *pListener, const OUString &sPath)
TODO.
css::uno::Reference< css::embed::XStorage > openPath(const OUString &sPath, sal_Int32 nOpenMode)
TODO open or get!
implements a read/write access to the accelerator configuration.
OUString FwkResId(TranslateId aId)
Definition: fwkresid.cxx:22
css::uno::Reference< css::uno::XComponentContext > m_xContext
Mode eMode
#define LANGUAGE_USER_PRIV_NOTRANSLATE
sal_uInt16 nPos
Any SAL_CALL getCaughtException()
int i
const ::sal_Int32 ID_CORRUPT_UICONFIG_GENERAL
const ::sal_Int32 ID_CORRUPT_UICONFIG_USER
StorageHolder m_lStoragesShare
const ::sal_Int32 ID_CORRUPT_UICONFIG_SHARE
StorageHolder m_lStoragesUser
OUString sMessage