LibreOffice Module desktop (master) 1
migration.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
20#include <sal/config.h>
21
22#include <algorithm>
23#include <iterator>
24#include <map>
25#include <set>
26
27#include <migration.hxx>
28#include "migration_impl.hxx"
29
30#include <sal/log.hxx>
35#include <rtl/uri.hxx>
36#include <i18nlangtag/lang.h>
38#include <tools/urlobj.hxx>
39#include <officecfg/Office/UI.hxx>
40#include <osl/file.hxx>
41#include <osl/security.hxx>
43
44#include <com/sun/star/configuration/Update.hpp>
45#include <com/sun/star/configuration/theDefaultProvider.hpp>
46#include <com/sun/star/container/XNameContainer.hpp>
47#include <com/sun/star/task/XJob.hpp>
48#include <com/sun/star/beans/NamedValue.hpp>
49#include <com/sun/star/beans/XPropertySet.hpp>
50#include <com/sun/star/util/XRefreshable.hpp>
51#include <com/sun/star/util/XChangesBatch.hpp>
52#include <com/sun/star/embed/ElementModes.hpp>
53#include <com/sun/star/embed/FileSystemStorageFactory.hpp>
54#include <com/sun/star/embed/XStorage.hpp>
55#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
56#include <com/sun/star/ui/UIConfigurationManager.hpp>
57#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
59
60using namespace osl;
61using namespace com::sun::star::task;
62using namespace com::sun::star::lang;
63using namespace com::sun::star::beans;
64using namespace com::sun::star::util;
65using namespace com::sun::star::container;
66using com::sun::star::uno::Exception;
67using namespace com::sun::star;
68
69
70namespace desktop
71{
72
73constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
74constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer";
75constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
76
77static OUString mapModuleShortNameToIdentifier(std::u16string_view sShortName)
78{
79 OUString sIdentifier;
80
81 if ( sShortName == u"StartModule" )
82 sIdentifier = "com.sun.star.frame.StartModule";
83
84 else if ( sShortName == u"swriter" )
85 sIdentifier = "com.sun.star.text.TextDocument";
86
87 else if ( sShortName == u"scalc" )
88 sIdentifier = "com.sun.star.sheet.SpreadsheetDocument";
89
90 else if ( sShortName == u"sdraw" )
91 sIdentifier = "com.sun.star.drawing.DrawingDocument";
92
93 else if ( sShortName == u"simpress" )
94 sIdentifier = "com.sun.star.presentation.PresentationDocument";
95
96 else if ( sShortName == u"smath" )
97 sIdentifier = "com.sun.star.formula.FormulaProperties";
98
99 else if ( sShortName == u"schart" )
100 sIdentifier = "com.sun.star.chart2.ChartDocument";
101
102 else if ( sShortName == u"BasicIDE" )
103 sIdentifier = "com.sun.star.script.BasicIDE";
104
105 else if ( sShortName == u"dbapp" )
106 sIdentifier = "com.sun.star.sdb.OfficeDatabaseDocument";
107
108 else if ( sShortName == u"sglobal" )
109 sIdentifier = "com.sun.star.text.GlobalDocument";
110
111 else if ( sShortName == u"sweb" )
112 sIdentifier = "com.sun.star.text.WebDocument";
113
114 else if ( sShortName == u"swxform" )
115 sIdentifier = "com.sun.star.xforms.XMLFormDocument";
116
117 else if ( sShortName == u"sbibliography" )
118 sIdentifier = "com.sun.star.frame.Bibliography";
119
120 return sIdentifier;
121}
122
124{
125 OUString aStr = m_aInfo.userdata + "/MIGRATED4";
126 File aFile(aStr);
127 // create migration stamp, and/or check its existence
128 bool bRet = aFile.open (osl_File_OpenFlag_Write | osl_File_OpenFlag_Create | osl_File_OpenFlag_NoLock) == FileBase::E_EXIST;
129 SAL_INFO( "desktop.migration", "File '" << aStr << "' exists? " << bRet );
130 return bRet;
131}
132
134{
135 bool bRet = false;
136
140 // m_aInfo is now set to the preferred migration source
141 if ( nIndex >= 0 ) {
142 if (alreadyMigrated())
143 return false;
145 }
146
147 bRet = !m_aInfo.userdata.isEmpty();
148 }
149
150 SAL_INFO( "desktop.migration", "Migration " << ( bRet ? "needed" : "not required" ) );
151
152 return bRet;
153}
154
156{
157 MigrationImpl aImpl;
158
159 if (! aImpl.initializeMigration() )
160 return;
161
162 bool bResult = false;
163 try {
164 bResult = aImpl.doMigration();
165 } catch (const Exception&) {
166 TOOLS_WARN_EXCEPTION( "desktop", "doMigration()");
167 }
168 OSL_ENSURE(bResult, "Migration has not been successful");
169}
170
172{
173}
174
176{
177}
178
179// The main entry point for migrating settings
181{
182 // compile file list for migration
184
185 bool result = false;
186 try {
187 NewVersionUIInfo aNewVersionUIInfo;
188 std::vector< MigrationModuleInfo > vModulesInfo = detectUIChangesForAllModules();
189 aNewVersionUIInfo.init(vModulesInfo);
190
191 copyFiles();
192
193 static const OUStringLiteral sMenubarResourceURL(u"private:resource/menubar/menubar");
194 static const OUStringLiteral sToolbarResourcePre(u"private:resource/toolbar/");
195 for (MigrationModuleInfo & i : vModulesInfo) {
196 OUString sModuleIdentifier = mapModuleShortNameToIdentifier(i.sModuleShortName);
197 if (sModuleIdentifier.isEmpty())
198 continue;
199
200
201 OUString aOldCfgDataPath = m_aInfo.userdata + "/user/config/soffice.cfg/modules/" + i.sModuleShortName;
202 uno::Sequence< uno::Any > lArgs {uno::Any(aOldCfgDataPath), uno::Any(embed::ElementModes::READ)};
203
206 uno::Reference< embed::XStorage > xModules(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY);
208
209 if ( xModules.is() ) {
210 xOldCfgManager->setStorage( xModules );
211 xOldCfgManager->reload();
212 }
213
214 uno::Reference< ui::XUIConfigurationManager > xCfgManager = aNewVersionUIInfo.getConfigManager(i.sModuleShortName);
215
216 if (i.bHasMenubar) {
217 uno::Reference< container::XIndexContainer > xOldVersionMenuSettings(xOldCfgManager->getSettings(sMenubarResourceURL, true), uno::UNO_QUERY);
218 uno::Reference< container::XIndexContainer > xNewVersionMenuSettings = aNewVersionUIInfo.getNewMenubarSettings(i.sModuleShortName);
219 compareOldAndNewConfig(OUString(), xOldVersionMenuSettings, xNewVersionMenuSettings, sMenubarResourceURL);
220 mergeOldToNewVersion(xCfgManager, xNewVersionMenuSettings, sModuleIdentifier, sMenubarResourceURL);
221 }
222
223 sal_Int32 nToolbars = i.m_vToolbars.size();
224 if (nToolbars >0) {
225 for (sal_Int32 j=0; j<nToolbars; ++j) {
226 OUString sToolbarName = i.m_vToolbars[j];
227 OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName;
228
229 uno::Reference< container::XIndexContainer > xOldVersionToolbarSettings(xOldCfgManager->getSettings(sToolbarResourceURL, true), uno::UNO_QUERY);
230 uno::Reference< container::XIndexContainer > xNewVersionToolbarSettings = aNewVersionUIInfo.getNewToolbarSettings(i.sModuleShortName, sToolbarName);
231 compareOldAndNewConfig(OUString(), xOldVersionToolbarSettings, xNewVersionToolbarSettings, sToolbarResourceURL);
232 mergeOldToNewVersion(xCfgManager, xNewVersionToolbarSettings, sModuleIdentifier, sToolbarResourceURL);
233 }
234 }
235
237 }
238
239 // execute the migration items from Setup.xcu
240 copyConfig();
241
242 // execute custom migration services from Setup.xcu
243 // and refresh the cache
244 runServices();
246 configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()),
247 uno::UNO_QUERY_THROW)->refresh();
248
249 result = true;
250 } catch (const css::uno::Exception &) {
252 "desktop.migration",
253 "ignored Exception while migrating from version \"" << m_aInfo.productname
254 << "\" data \"" << m_aInfo.userdata << "\"");
255 }
256
257 // prevent running the migration multiple times
259 return result;
260}
261
263{
264 try {
265 uno::Reference< XPropertySet > aPropertySet(getConfigAccess("org.openoffice.Setup/Office", true), uno::UNO_QUERY_THROW);
266 aPropertySet->setPropertyValue("MigrationCompleted", uno::Any(true));
267 uno::Reference< XChangesBatch >(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges();
268 } catch (...) {
269 // fail silently
270 }
271}
272
274{
275 bool bMigrationCompleted = false;
276 try {
278 getConfigAccess("org.openoffice.Setup/Office"), uno::UNO_QUERY_THROW);
279 aPropertySet->getPropertyValue("MigrationCompleted") >>= bMigrationCompleted;
280
281 if( !bMigrationCompleted && getenv("SAL_DISABLE_USERMIGRATION" ) ) {
282 // migration prevented - fake its success
284 bMigrationCompleted = true;
285 }
286 } catch (const Exception&) {
287 // just return false...
288 }
289 SAL_INFO( "desktop.migration", "Migration " << ( bMigrationCompleted ? "already completed" : "not done" ) );
290
291 return bMigrationCompleted;
292}
293
294static void insertSorted(migrations_available& rAvailableMigrations, supported_migration const & aSupportedMigration)
295{
296 migrations_available::iterator pIter = std::find_if(rAvailableMigrations.begin(), rAvailableMigrations.end(),
297 [&aSupportedMigration](const supported_migration& rMigration) { return rMigration.nPriority < aSupportedMigration.nPriority; });
298 if (pIter != rAvailableMigrations.end())
299 rAvailableMigrations.insert(pIter, aSupportedMigration );
300 else
301 rAvailableMigrations.push_back( aSupportedMigration );
302}
303
305{
306 // get supported version names
307 uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_SET_THROW);
308 const uno::Sequence< OUString > seqSupportedVersions = aMigrationAccess->getElementNames();
309
310 static const OUStringLiteral aVersionIdentifiers( u"VersionIdentifiers" );
311 static const OUStringLiteral aPriorityIdentifier( u"Priority" );
312
313 for (OUString const & supportedVersion :seqSupportedVersions) {
314 sal_Int32 nPriority( 0 );
315 uno::Sequence< OUString > seqVersions;
316 uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(supportedVersion), uno::UNO_QUERY_THROW );
317 xMigrationData->getByName( aVersionIdentifiers ) >>= seqVersions;
318 xMigrationData->getByName( aPriorityIdentifier ) >>= nPriority;
319
320 supported_migration aSupportedMigration;
321 aSupportedMigration.name = supportedVersion;
322 aSupportedMigration.nPriority = nPriority;
323 for (OUString const & s : std::as_const(seqVersions))
324 aSupportedMigration.supported_versions.push_back(s.trim());
325 insertSorted( rAvailableMigrations, aSupportedMigration );
326 SAL_INFO( "desktop.migration", " available migration '" << aSupportedMigration.name << "'" );
327 }
328}
329
331{
332 // get migration access
333 uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_SET_THROW);
334 uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(rMigrationName), uno::UNO_QUERY_THROW );
335
336 // get migration description from org.openoffice.Setup/Migration
337 // and build vector of migration steps
338 uno::Reference< XNameAccess > theNameAccess(xMigrationData->getByName("MigrationSteps"), uno::UNO_QUERY_THROW);
341 migrations_vr vrMigrations(new migrations_v);
342 const css::uno::Sequence<OUString> aMigrationSteps = theNameAccess->getElementNames();
343 for (const OUString& rMigrationStep : aMigrationSteps) {
344 // get current migration step
345 theNameAccess->getByName(rMigrationStep) >>= tmpAccess;
346 migration_step tmpStep;
347
348 // read included files from current step description
349 if (tmpAccess->getByName("IncludedFiles") >>= tmpSeq) {
350 for (const OUString& rSeqEntry : std::as_const(tmpSeq))
351 tmpStep.includeFiles.push_back(rSeqEntry);
352 }
353
354 // excluded files...
355 if (tmpAccess->getByName("ExcludedFiles") >>= tmpSeq) {
356 for (const OUString& rSeqEntry : std::as_const(tmpSeq))
357 tmpStep.excludeFiles.push_back(rSeqEntry);
358 }
359
360 // included nodes...
361 if (tmpAccess->getByName("IncludedNodes") >>= tmpSeq) {
362 for (const OUString& rSeqEntry : std::as_const(tmpSeq))
363 tmpStep.includeConfig.push_back(rSeqEntry);
364 }
365
366 // excluded nodes...
367 if (tmpAccess->getByName("ExcludedNodes") >>= tmpSeq) {
368 for (const OUString& rSeqEntry : std::as_const(tmpSeq))
369 tmpStep.excludeConfig.push_back(rSeqEntry);
370 }
371
372 // excluded extensions...
373 if (tmpAccess->getByName("ExcludedExtensions") >>= tmpSeq) {
374 for (const OUString& rSeqEntry : std::as_const(tmpSeq))
375 tmpStep.excludeExtensions.push_back(rSeqEntry);
376 }
377
378 // generic service
379 tmpAccess->getByName("MigrationService") >>= tmpStep.service;
380
381 vrMigrations->push_back(tmpStep);
382 }
383 return vrMigrations;
384}
385
386static FileBase::RC _checkAndCreateDirectory(INetURLObject const & dirURL)
387{
389 if (result == FileBase::E_NOENT) {
390 INetURLObject baseURL(dirURL);
391 baseURL.removeSegment();
394 } else
395 return result;
396}
397
398#if defined UNX && ! defined MACOSX
399
400const char XDG_CONFIG_PART[] = "/.config/";
401
402OUString MigrationImpl::preXDGConfigDir(const OUString& rConfigDir)
403{
404 OUString aPreXDGConfigPath;
405 const char* pXDGCfgHome = getenv("XDG_CONFIG_HOME");
406
407 // cater for XDG_CONFIG_HOME change
408 // If XDG_CONFIG_HOME is set then we;
409 // assume the user knows what they are doing ( room for improvement here, we could
410 // of course search the default config dir etc. also - but this is more complex,
411 // we would need to weigh results from the current config dir against matches in
412 // the 'old' config dir etc. ) - currently we just use the returned config dir.
413 // If XDG_CONFIG_HOME is NOT set;
414 // assume then we should now using the default $HOME/.config config location for
415 // our user profiles, however *all* previous libreoffice and openoffice.org
416 // configurations will be in the 'old' config directory and that's where we need
417 // to search - we convert the returned config dir to the 'old' dir
418 if ( !pXDGCfgHome && rConfigDir.endsWith( XDG_CONFIG_PART ) )
419 // remove trailing '.config/' but leave the terminating '/'
420 aPreXDGConfigPath = rConfigDir.copy( 0, rConfigDir.getLength() - sizeof( XDG_CONFIG_PART ) + 2 );
421 else
422 aPreXDGConfigPath = rConfigDir;
423
424 // the application-specific config dir is no longer prefixed by '.' because it is hidden under ".config"
425 // we have to add the '.' for the pre-XDG directory names
426 aPreXDGConfigPath += ".";
427
428 return aPreXDGConfigPath;
429}
430#endif
431
433 install_info& aInfo,
434 std::u16string_view rConfigDir,
435 const OUString& rVersion)
436{
437 OUString url(INetURLObject(rConfigDir).GetMainURL(INetURLObject::DecodeMechanism::NONE));
438 osl::DirectoryItem item;
439 osl::FileStatus stat(osl_FileStatus_Mask_Type);
440
441 if (osl::DirectoryItem::get(url, item) == osl::FileBase::E_None
442 && item.getFileStatus(stat) == osl::FileBase::E_None
443 && stat.getFileType() == osl::FileStatus::Directory) {
444 aInfo.userdata = url;
445 aInfo.productname = rVersion;
446 }
447}
448
450{
451
452 OUString aTopConfigDir;
453 osl::Security().getConfigDir( aTopConfigDir );
454 if ( !aTopConfigDir.isEmpty() && aTopConfigDir[ aTopConfigDir.getLength()-1 ] != '/' )
455 aTopConfigDir += "/";
456
457#if defined UNX && ! defined MACOSX
458 OUString aPreXDGTopConfigDir = preXDGConfigDir(aTopConfigDir);
459#endif
460
461 install_info aInfo;
462 for (auto const& elem : rVersions)
463 {
464 OUString aVersion, aProfileName;
465 sal_Int32 nSeparatorIndex = elem.indexOf('=');
466 if ( nSeparatorIndex != -1 ) {
467 aVersion = elem.copy( 0, nSeparatorIndex );
468 aProfileName = elem.copy( nSeparatorIndex+1 );
469 }
470
471 if ( !aVersion.isEmpty() && !aProfileName.isEmpty() &&
472 ( aInfo.userdata.isEmpty() ||
473 aProfileName.equalsIgnoreAsciiCase(
475 setInstallInfoIfExist(aInfo, Concat2View(aTopConfigDir + aProfileName), aVersion);
476#if defined UNX && ! defined MACOSX
477 //try preXDG path if the new one does not exist
478 if ( aInfo.userdata.isEmpty())
479 setInstallInfoIfExist(aInfo, Concat2View(aPreXDGTopConfigDir + aProfileName), aVersion);
480#endif
481 }
482 }
483
484 return aInfo;
485}
486
488{
489 sal_Int32 nIndex( -1 );
490 sal_Int32 i( 0 );
491
492 for (auto const& availableMigration : rAvailableMigrations)
493 {
494 install_info aInstallInfo = findInstallation(availableMigration.supported_versions);
495 if (!aInstallInfo.productname.isEmpty() ) {
496 m_aInfo = aInstallInfo;
497 nIndex = i;
498 break;
499 }
500 ++i;
501 }
502
503 SAL_INFO( "desktop.migration", " preferred migration is from product '" << m_aInfo.productname << "'");
504 SAL_INFO( "desktop.migration", " and settings directory '" << m_aInfo.userdata << "'");
505
506 return nIndex;
507}
508
510{
511 using namespace utl;
512 strings_vr vrResult(new strings_v);
513 for (auto const& pattern : vPatterns)
514 {
515 // find matches for this pattern in input set
516 // and copy them to the result
517 SearchParam param(pattern, SearchParam::SearchType::Regexp);
518 TextSearch ts(param, LANGUAGE_DONTKNOW);
519 sal_Int32 start = 0;
520 sal_Int32 end = 0;
521 for (auto const& elem : vSet)
522 {
523 end = elem.getLength();
524 if (ts.SearchForward(elem, &start, &end))
525 vrResult->push_back(elem);
526 }
527 }
528 return vrResult;
529}
530
531strings_vr MigrationImpl::getAllFiles(const OUString& baseURL) const
532{
533 strings_vr vrResult(new strings_v);
534
535 // get sub dirs
536 Directory dir(baseURL);
537 if (dir.open() == FileBase::E_None) {
538 strings_v vSubDirs;
539 strings_vr vrSubResult;
540
541 // work through directory contents...
542 DirectoryItem item;
543 FileStatus fs(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL);
544 while (dir.getNextItem(item) == FileBase::E_None) {
545 if (item.getFileStatus(fs) == FileBase::E_None) {
546 if (fs.getFileType() == FileStatus::Directory)
547 vSubDirs.push_back(fs.getFileURL());
548 else
549 vrResult->push_back(fs.getFileURL());
550 }
551 }
552
553 // recurse subfolders
554 for (auto const& subDir : vSubDirs)
555 {
556 vrSubResult = getAllFiles(subDir);
557 vrResult->insert(vrResult->end(), vrSubResult->begin(), vrSubResult->end());
558 }
559 }
560 return vrResult;
561}
562
563namespace
564{
565
566// removes elements of vector 2 in vector 1
567strings_v subtract(strings_v && a, strings_v && b)
568{
569 std::sort(a.begin(), a.end());
570 strings_v::iterator ae(std::unique(a.begin(), a.end()));
571 std::sort(b.begin(), b.end());
572 strings_v::iterator be(std::unique(b.begin(), b.end()));
573 strings_v c;
574 std::set_difference(a.begin(), ae, b.begin(), be, std::back_inserter(c));
575 return c;
576}
577
578}
579
581{
582
583 strings_vr vrResult(new strings_v);
584
585 // get a list of all files:
587
588 // get a file list result for each migration step
589 for (auto const& rMigration : *m_vrMigrations)
590 {
591 strings_vr vrInclude = applyPatterns(*vrFiles, rMigration.includeFiles);
592 strings_vr vrExclude = applyPatterns(*vrFiles, rMigration.excludeFiles);
593 strings_v sub(subtract(std::move(*vrInclude), std::move(*vrExclude)));
594 vrResult->insert(vrResult->end(), sub.begin(), sub.end());
595 }
596 return vrResult;
597}
598
599namespace
600{
601
602struct componentParts {
603 std::set< OUString > includedPaths;
604 std::set< OUString > excludedPaths;
605};
606
607typedef std::map< OUString, componentParts > Components;
608
609bool getComponent(OUString const & path, OUString * component)
610{
611 OSL_ASSERT(component != nullptr);
612 if (path.isEmpty() || path[0] != '/') {
613 SAL_INFO( "desktop.migration", "configuration migration in/exclude path " << path << " ignored (does not start with slash)" );
614 return false;
615 }
616 sal_Int32 i = path.indexOf('/', 1);
617 *component = i < 0 ? path.copy(1) : path.copy(1, i - 1);
618 return true;
619}
620
621void renameMigratedSetElementTo(
622 css::uno::Reference<css::container::XNameContainer> const & set, OUString const & currentName,
623 OUString const & migratedName)
624{
625 // To avoid unexpected data loss, the code is careful to only rename from currentName to
626 // migratedName in the expected case where the currentName element exists and the migratedName
627 // element doesn't exist:
628 bool const hasCurrent = set->hasByName(currentName);
629 bool const hasMigrated = set->hasByName(migratedName);
630 if (hasCurrent && !hasMigrated) {
631 auto const elem = set->getByName(currentName);
632 set->removeByName(currentName);
633 set->insertByName(migratedName, elem);
634 } else {
635 SAL_INFO_IF(!hasCurrent, "desktop.migration", "unexpectedly missing " << currentName);
636 SAL_INFO_IF(hasMigrated, "desktop.migration", "unexpectedly present " << migratedName);
637 }
638}
639
640void renameMigratedSetElementBack(
641 css::uno::Reference<css::container::XNameContainer> const & set, OUString const & currentName,
642 OUString const & migratedName)
643{
644 // To avoid unexpected data loss, the code is careful to ensure that in the end a currentName
645 // element exists, creating it from a template if the migratedName element had unexpectedly gone
646 // missing:
647 bool const hasMigrated = set->hasByName(migratedName);
648 css::uno::Any elem;
649 if (hasMigrated) {
650 elem = set->getByName(migratedName);
651 set->removeByName(migratedName);
652 } else {
653 SAL_INFO("desktop.migration", "unexpected loss of " << migratedName);
654 elem <<= css::uno::Reference<css::lang::XSingleServiceFactory>(
655 set, css::uno::UNO_QUERY_THROW)->createInstance();
656 }
657 if (set->hasByName(currentName)) {
658 SAL_INFO("desktop.migration", "unexpected reappearance of " << currentName);
659 if (hasMigrated) {
660 SAL_INFO(
661 "desktop.migration",
662 "reappeared " << currentName << " overwritten with " << migratedName);
663 set->replaceByName(currentName, elem);
664 }
665 } else {
666 set->insertByName(currentName, elem);
667 }
668}
669
670}
671
673{
674 Components comps;
675 for (auto const& rMigrationStep : *m_vrMigrations) {
676 for (const OUString& rIncludePath : rMigrationStep.includeConfig) {
677 OUString comp;
678 if (getComponent(rIncludePath, &comp)) {
679 comps[comp].includedPaths.insert(rIncludePath);
680 }
681 }
682 for (const OUString& rExcludePath : rMigrationStep.excludeConfig) {
683 OUString comp;
684 if (getComponent(rExcludePath, &comp)) {
685 comps[comp].excludedPaths.insert(rExcludePath);
686 }
687 }
688 }
689
690 // check if the shared registrymodifications.xcu file exists
691 bool bRegistryModificationsXcuExists = false;
692 OUString regFilePath = m_aInfo.userdata + "/user/registrymodifications.xcu";
693 File regFile(regFilePath);
694 ::osl::FileBase::RC nError = regFile.open(osl_File_OpenFlag_Read);
695 if ( nError == ::osl::FileBase::E_None ) {
696 bRegistryModificationsXcuExists = true;
697 regFile.close();
698 }
699
700 // If the to-be-migrated data contains modifications of
701 // /org.openoffice.Office.UI/ColorScheme/ColorSchemes set elements named after the migrated
702 // product name, those modifications must instead be made to the corresponding set elements
703 // named after the current product name. However, if the current configuration data does not
704 // contain those old-named set elements at all, their modification data would silently be
705 // ignored by css.configuration.XUpdate::insertModificationXcuFile. So temporarily rename any
706 // new-named set elements to their old-named counterparts here, and rename them back again down
707 // below after importing the migrated data:
708 OUString sProductName = utl::ConfigManager::getProductName();
709 OUString sProductNameDark = sProductName + " Dark";
710 OUString sMigratedProductName = m_aInfo.productname;
711 // remove version number from the end of product name if there’s one
712 if (isdigit(sMigratedProductName[sMigratedProductName.getLength() - 1]))
713 sMigratedProductName = (sMigratedProductName.copy(0, m_aInfo.productname.getLength() - 1)).trim();
714 OUString sMigratedProductNameDark = sMigratedProductName + " Dark";
715 auto const tempRename = sMigratedProductName != sProductName;
716 if (tempRename) {
717 auto const batch = comphelper::ConfigurationChanges::create();
718 auto const schemes = officecfg::Office::UI::ColorScheme::ColorSchemes::get(batch);
719 renameMigratedSetElementTo(schemes, sProductName, sMigratedProductName);
720 renameMigratedSetElementTo(schemes, sProductNameDark, sMigratedProductNameDark);
721 batch->commit();
722 }
723
724 for (auto const& comp : comps)
725 {
726 if (!comp.second.includedPaths.empty()) {
727 if (!bRegistryModificationsXcuExists) {
728 // shared registrymodifications.xcu does not exists
729 // the configuration is split in many registry files
730 // determine the file names from the first element in included paths
731 OUStringBuffer buf(m_aInfo.userdata);
732 buf.append("/user/registry/data");
733 sal_Int32 n = 0;
734 do {
735 OUString seg(comp.first.getToken(0, '.', n));
736 OUString enc(
737 rtl::Uri::encode(
738 seg, rtl_UriCharClassPchar, rtl_UriEncodeStrict,
739 RTL_TEXTENCODING_UTF8));
740 if (enc.isEmpty() && !seg.isEmpty()) {
741 SAL_INFO( "desktop.migration", "configuration migration component " << comp.first << " ignored (cannot be encoded as file path)" );
742 goto next;
743 }
744 buf.append('/');
745 buf.append(enc);
746 } while (n >= 0);
747 buf.append(".xcu");
748 regFilePath = buf.makeStringAndClear();
749 }
750 configuration::Update::get(
752 insertModificationXcuFile(
753 regFilePath,
754 comphelper::containerToSequence(comp.second.includedPaths),
755 comphelper::containerToSequence(comp.second.excludedPaths));
756
757 } else {
758 SAL_INFO( "desktop.migration", "configuration migration component " << comp.first << " ignored (only excludes, no includes)" );
759 }
760next:
761 ;
762 }
763 if (tempRename) {
764 auto const batch = comphelper::ConfigurationChanges::create();
765 auto const schemes = officecfg::Office::UI::ColorScheme::ColorSchemes::get(batch);
766 renameMigratedSetElementBack(schemes, sProductName, sMigratedProductName);
767 renameMigratedSetElementBack(schemes, sProductNameDark, sMigratedProductNameDark);
768 batch->commit();
769 }
770 // checking the migrated (product name related) color scheme name, and replace it to the current version scheme name
771 try
772 {
773 OUString sMigratedColorScheme;
774 uno::Reference<XPropertySet> aPropertySet(
775 getConfigAccess("org.openoffice.Office.UI/ColorScheme", true), uno::UNO_QUERY_THROW);
776 if (aPropertySet->getPropertyValue("CurrentColorScheme") >>= sMigratedColorScheme)
777 {
778 if (sMigratedColorScheme.equals(sMigratedProductName))
779 {
780 aPropertySet->setPropertyValue("CurrentColorScheme",
781 uno::Any(sProductName));
782 uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges();
783 }
784 else if (sMigratedColorScheme.equals(sMigratedProductNameDark))
785 {
786 aPropertySet->setPropertyValue("CurrentColorScheme",
787 uno::Any(sProductNameDark));
788 uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges();
789 }
790 }
791 } catch (const Exception&) {
792 // fail silently...
793 }
794}
795
797{
799 try {
800 OUString sAccessSrvc;
801 if (bUpdate)
802 sAccessSrvc = "com.sun.star.configuration.ConfigurationUpdateAccess";
803 else
804 sAccessSrvc = "com.sun.star.configuration.ConfigurationAccess";
805
806 OUString sConfigURL = OUString::createFromAscii(pPath);
807
809 configuration::theDefaultProvider::get(
811
812 // access the provider
813 uno::Sequence< uno::Any > theArgs {uno::Any(sConfigURL)};
814 xNameAccess.set(
815 theConfigProvider->createInstanceWithArguments(
816 sAccessSrvc, theArgs ), uno::UNO_QUERY_THROW );
817 } catch (const css::uno::Exception&) {
818 TOOLS_WARN_EXCEPTION("desktop.migration", "ignoring");
819 }
820 return xNameAccess;
821}
822
824{
825 OUString localName;
826 OUString destName;
827 OUString userInstall;
829 aStatus = utl::Bootstrap::locateUserInstallation(userInstall);
830 if (aStatus == utl::Bootstrap::PATH_EXISTS) {
831 for (auto const& rFile : *m_vrFileList)
832 {
833 // remove installation prefix from file
834 localName = rFile.copy(m_aInfo.userdata.getLength());
835 if (localName.endsWith( "/autocorr/acor_.dat")) {
836 // Previous versions used an empty language tag for
837 // LANGUAGE_DONTKNOW with the "[All]" autocorrection entry.
838 // As of LibreOffice 4.0 it is 'und' for LANGUAGE_UNDETERMINED
839 // so the file name is "acor_und.dat".
840 localName = OUString::Concat(localName.subView( 0, localName.getLength() - 4)) + "und.dat";
841 }
842 destName = userInstall + localName;
843 INetURLObject aURL(destName);
844 // check whether destination directory exists
845 aURL.removeSegment();
847 FileBase::RC copyResult = File::copy(rFile, destName);
848 if (copyResult != FileBase::E_None) {
849 SAL_WARN( "desktop", "Cannot copy " << rFile << " to " << destName);
850 }
851 }
852 } else {
853 OSL_FAIL("copyFiles: UserInstall does not exist");
854 }
855}
856
858{
859 // Build argument array
860 uno::Sequence< uno::Any > seqArguments(3);
861 auto pseqArguments = seqArguments.getArray();
862 pseqArguments[0] <<= NamedValue("Productname",
864 pseqArguments[1] <<= NamedValue("UserData",
866
867
868 // create an instance of every migration service
869 // and execute the migration job
870 uno::Reference< XJob > xMigrationJob;
871
873 for (auto const& rMigration : *m_vrMigrations)
874 {
875 if( !rMigration.service.isEmpty()) {
876
877 try {
878 // set black list for extension migration
879 uno::Sequence< OUString > seqExtDenyList;
880 sal_uInt32 nSize = rMigration.excludeExtensions.size();
881 if ( nSize > 0 )
882 seqExtDenyList = comphelper::arrayToSequence< OUString >(
883 rMigration.excludeExtensions.data(), nSize );
884 pseqArguments[2] <<= NamedValue("ExtensionDenyList",
885 uno::Any( seqExtDenyList ));
886
887 xMigrationJob.set(
888 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(rMigration.service, seqArguments, xContext),
889 uno::UNO_QUERY_THROW);
890
891 xMigrationJob->execute(uno::Sequence< NamedValue >());
892
893
894 } catch (const Exception&) {
895 TOOLS_WARN_EXCEPTION( "desktop", "Execution of migration service failed. Service: "
896 << rMigration.service);
897 } catch (...) {
898 SAL_WARN( "desktop", "Execution of migration service failed (Exception caught).\nService: "
899 << rMigration.service << "\nNo message available");
900 }
901
902 }
903 }
904}
905
906std::vector< MigrationModuleInfo > MigrationImpl::detectUIChangesForAllModules() const
907{
908 std::vector< MigrationModuleInfo > vModulesInfo;
909 static const OUStringLiteral MENUBAR(u"menubar");
910 static const OUStringLiteral TOOLBAR(u"toolbar");
911
912 uno::Sequence< uno::Any > lArgs {uno::Any(m_aInfo.userdata + "/user/config/soffice.cfg/modules"),
913 uno::Any(embed::ElementModes::READ)};
914
918
919 xModules.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY);
920 if (!xModules.is())
921 return vModulesInfo;
922
923 uno::Sequence< OUString > lNames = xModules->getElementNames();
924 sal_Int32 nLength = lNames.getLength();
925 for (sal_Int32 i=0; i<nLength; ++i) {
926 OUString sModuleShortName = lNames[i];
927 uno::Reference< embed::XStorage > xModule = xModules->openStorageElement(sModuleShortName, embed::ElementModes::READ);
928 if (xModule.is()) {
929 MigrationModuleInfo aModuleInfo;
930
931 uno::Reference< embed::XStorage > xMenubar = xModule->openStorageElement(MENUBAR, embed::ElementModes::READ);
932 if (xMenubar.is()) {
933 if (xMenubar->getElementNames().hasElements()) {
934 aModuleInfo.sModuleShortName = sModuleShortName;
935 aModuleInfo.bHasMenubar = true;
936 }
937 }
938
939 uno::Reference< embed::XStorage > xToolbar = xModule->openStorageElement(TOOLBAR, embed::ElementModes::READ);
940 if (xToolbar.is()) {
941 const ::uno::Sequence< OUString > lToolbars = xToolbar->getElementNames();
942 for (OUString const & sToolbarName : lToolbars) {
943 if (sToolbarName.startsWith("custom_"))
944 continue;
945
946 aModuleInfo.sModuleShortName = sModuleShortName;
947 sal_Int32 nIndex = sToolbarName.lastIndexOf('.');
948 if (nIndex > 0) {
949 std::u16string_view sExtension(sToolbarName.subView(nIndex));
950 OUString sToolbarResourceName(sToolbarName.copy(0, nIndex));
951 if (!sToolbarResourceName.isEmpty() && sExtension == u".xml")
952 aModuleInfo.m_vToolbars.push_back(sToolbarResourceName);
953 }
954 }
955 }
956
957 if (!aModuleInfo.sModuleShortName.isEmpty())
958 vModulesInfo.push_back(aModuleInfo);
959 }
960 }
961
962 return vModulesInfo;
963}
964
965void MigrationImpl::compareOldAndNewConfig(const OUString& sParent,
968 const OUString& sResourceURL)
969{
970 static const OUStringLiteral MENU_SEPARATOR(u" | ");
971
972 std::vector< MigrationItem > vOldItems;
973 std::vector< MigrationItem > vNewItems;
975 sal_Int32 nOldCount = xIndexOld->getCount();
976 sal_Int32 nNewCount = xIndexNew->getCount();
977
978 for (int n=0; n<nOldCount; ++n) {
979 MigrationItem aMigrationItem;
980 if (xIndexOld->getByIndex(n) >>= aProps) {
981 for(beans::PropertyValue const & prop : std::as_const(aProps)) {
982 if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL )
983 prop.Value >>= aMigrationItem.m_sCommandURL;
984 else if ( prop.Name == ITEM_DESCRIPTOR_CONTAINER )
985 prop.Value >>= aMigrationItem.m_xPopupMenu;
986 }
987
988 if (!aMigrationItem.m_sCommandURL.isEmpty())
989 vOldItems.push_back(aMigrationItem);
990 }
991 }
992
993 for (int n=0; n<nNewCount; ++n) {
994 MigrationItem aMigrationItem;
995 if (xIndexNew->getByIndex(n) >>= aProps) {
996 for(beans::PropertyValue const & prop : std::as_const(aProps)) {
997 if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL )
998 prop.Value >>= aMigrationItem.m_sCommandURL;
999 else if ( prop.Name == ITEM_DESCRIPTOR_CONTAINER )
1000 prop.Value >>= aMigrationItem.m_xPopupMenu;
1001 }
1002
1003 if (!aMigrationItem.m_sCommandURL.isEmpty())
1004 vNewItems.push_back(aMigrationItem);
1005 }
1006 }
1007
1008 OUString sSibling;
1009 for (auto const& oldItem : vOldItems)
1010 {
1011 std::vector< MigrationItem >::iterator pFound = std::find(vNewItems.begin(), vNewItems.end(), oldItem);
1012 if (pFound != vNewItems.end() && oldItem.m_xPopupMenu.is()) {
1013 OUString sName;
1014 if (!sParent.isEmpty())
1015 sName = sParent + MENU_SEPARATOR + oldItem.m_sCommandURL;
1016 else
1017 sName = oldItem.m_sCommandURL;
1018 compareOldAndNewConfig(sName, oldItem.m_xPopupMenu, pFound->m_xPopupMenu, sResourceURL);
1019 } else if (pFound == vNewItems.end()) {
1020 MigrationItem aMigrationItem(sParent, sSibling, oldItem.m_sCommandURL, oldItem.m_xPopupMenu);
1021 if (m_aOldVersionItemsHashMap.find(sResourceURL)==m_aOldVersionItemsHashMap.end()) {
1022 std::vector< MigrationItem > vMigrationItems;
1023 m_aOldVersionItemsHashMap.emplace(sResourceURL, vMigrationItems);
1024 m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem);
1025 } else {
1026 if (std::find(m_aOldVersionItemsHashMap[sResourceURL].begin(), m_aOldVersionItemsHashMap[sResourceURL].end(), aMigrationItem)==m_aOldVersionItemsHashMap[sResourceURL].end())
1027 m_aOldVersionItemsHashMap[sResourceURL].push_back(aMigrationItem);
1028 }
1029 }
1030
1031 sSibling = oldItem.m_sCommandURL;
1032 }
1033}
1034
1036 const uno::Reference< container::XIndexContainer>& xIndexContainer,
1037 const OUString& sModuleIdentifier,
1038 const OUString& sResourceURL)
1039{
1040 MigrationHashMap::iterator pFound = m_aOldVersionItemsHashMap.find(sResourceURL);
1041 if (pFound==m_aOldVersionItemsHashMap.end())
1042 return;
1043
1044 for (auto const& elem : pFound->second)
1045 {
1046 uno::Reference< container::XIndexContainer > xTemp = xIndexContainer;
1047
1048 OUString sParentNodeName = elem.m_sParentNodeName;
1049 sal_Int32 nIndex = 0;
1050 do {
1051 std::u16string_view sToken( o3tl::trim(o3tl::getToken(sParentNodeName, 0, '|', nIndex)) );
1052 if (sToken.empty())
1053 break;
1054
1055 sal_Int32 nCount = xTemp->getCount();
1056 for (sal_Int32 i=0; i<nCount; ++i) {
1057 OUString sCommandURL;
1058 OUString sLabel;
1060
1062 xTemp->getByIndex(i) >>= aPropSeq;
1063 for (beans::PropertyValue const & prop : std::as_const(aPropSeq)) {
1064 OUString sPropName = prop.Name;
1065 if ( sPropName == ITEM_DESCRIPTOR_COMMANDURL )
1066 prop.Value >>= sCommandURL;
1067 else if ( sPropName == ITEM_DESCRIPTOR_LABEL )
1068 prop.Value >>= sLabel;
1069 else if ( sPropName == ITEM_DESCRIPTOR_CONTAINER )
1070 prop.Value >>= xChild;
1071 }
1072
1073 if (sCommandURL == sToken) {
1074 xTemp = xChild;
1075 break;
1076 }
1077 }
1078
1079 } while (nIndex >= 0);
1080
1081 if (nIndex == -1) {
1082 auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(elem.m_sCommandURL, sModuleIdentifier);
1084 beans::PropertyValue(ITEM_DESCRIPTOR_COMMANDURL, 0, uno::Any(elem.m_sCommandURL), beans::PropertyState_DIRECT_VALUE),
1085 beans::PropertyValue(ITEM_DESCRIPTOR_LABEL, 0, uno::Any(vcl::CommandInfoProvider::GetLabelForCommand(aProperties)), beans::PropertyState_DIRECT_VALUE),
1086 beans::PropertyValue(ITEM_DESCRIPTOR_CONTAINER, 0, uno::Any(elem.m_xPopupMenu), beans::PropertyState_DIRECT_VALUE)
1087 };
1088
1089 if (elem.m_sPrevSibling.isEmpty())
1090 xTemp->insertByIndex(0, uno::Any(aPropSeq));
1091 else {
1092 sal_Int32 nCount = xTemp->getCount();
1093 sal_Int32 i = 0;
1094 for (; i<nCount; ++i) {
1095 OUString sCmd;
1097 xTemp->getByIndex(i) >>= aTempPropSeq;
1098 for (beans::PropertyValue const & prop : std::as_const(aTempPropSeq)) {
1099 if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL ) {
1100 prop.Value >>= sCmd;
1101 break;
1102 }
1103 }
1104
1105 if (sCmd == elem.m_sPrevSibling)
1106 break;
1107 }
1108
1109 xTemp->insertByIndex(i+1, uno::Any(aPropSeq));
1110 }
1111 }
1112 }
1113
1114 if (xIndexContainer.is())
1115 xCfgManager->replaceSettings(sResourceURL, xIndexContainer);
1116
1117 uno::Reference< ui::XUIConfigurationPersistence > xUIConfigurationPersistence(xCfgManager, uno::UNO_QUERY);
1118 if (xUIConfigurationPersistence.is())
1119 xUIConfigurationPersistence->store();
1120}
1121
1123{
1125
1126 for ( const css::beans::PropertyValue& rProp : m_lCfgManagerSeq) {
1127 if (rProp.Name == sModuleShortName) {
1128 rProp.Value >>= xCfgManager;
1129 break;
1130 }
1131 }
1132
1133 return xCfgManager;
1134}
1135
1137{
1139
1140 for (auto const & prop : m_lNewVersionMenubarSettingsSeq) {
1141 if (prop.Name == sModuleShortName) {
1142 prop.Value >>= xNewMenuSettings;
1143 break;
1144 }
1145 }
1146
1147 return xNewMenuSettings;
1148}
1149
1150uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewToolbarSettings(std::u16string_view sModuleShortName, std::u16string_view sToolbarName) const
1151{
1153
1154 for (auto const & newProp : m_lNewVersionToolbarSettingsSeq) {
1155 if (newProp.Name == sModuleShortName) {
1156 uno::Sequence< beans::PropertyValue > lToolbarSettingsSeq;
1157 newProp.Value >>= lToolbarSettingsSeq;
1158 for (auto const & prop : std::as_const(lToolbarSettingsSeq)) {
1159 if (prop.Name == sToolbarName) {
1160 prop.Value >>= xNewToolbarSettings;
1161 break;
1162 }
1163 }
1164
1165 break;
1166 }
1167 }
1168
1169 return xNewToolbarSettings;
1170}
1171
1172void NewVersionUIInfo::init(const std::vector< MigrationModuleInfo >& vModulesInfo)
1173{
1174 m_lCfgManagerSeq.resize(vModulesInfo.size());
1175 m_lNewVersionMenubarSettingsSeq.realloc(vModulesInfo.size());
1176 auto p_lNewVersionMenubarSettingsSeq = m_lNewVersionMenubarSettingsSeq.getArray();
1177 m_lNewVersionToolbarSettingsSeq.realloc(vModulesInfo.size());
1178 auto p_lNewVersionToolbarSettingsSeq = m_lNewVersionToolbarSettingsSeq.getArray();
1179
1180 static const OUStringLiteral sMenubarResourceURL(u"private:resource/menubar/menubar");
1181 static const OUStringLiteral sToolbarResourcePre(u"private:resource/toolbar/");
1182
1183 uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = ui::theModuleUIConfigurationManagerSupplier::get( ::comphelper::getProcessComponentContext() );
1184
1185 for (size_t i=0; i<vModulesInfo.size(); ++i) {
1186 OUString sModuleIdentifier = mapModuleShortNameToIdentifier(vModulesInfo[i].sModuleShortName);
1187 if (!sModuleIdentifier.isEmpty()) {
1188 uno::Reference< ui::XUIConfigurationManager > xCfgManager = xModuleCfgSupplier->getUIConfigurationManager(sModuleIdentifier);
1189 m_lCfgManagerSeq[i].Name = vModulesInfo[i].sModuleShortName;
1190 m_lCfgManagerSeq[i].Value <<= xCfgManager;
1191
1192 if (vModulesInfo[i].bHasMenubar) {
1193 p_lNewVersionMenubarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName;
1194 p_lNewVersionMenubarSettingsSeq[i].Value <<= xCfgManager->getSettings(sMenubarResourceURL, true);
1195 }
1196
1197 sal_Int32 nToolbars = vModulesInfo[i].m_vToolbars.size();
1198 if (nToolbars > 0) {
1199 uno::Sequence< beans::PropertyValue > lPropSeq(nToolbars);
1200 auto plPropSeq = lPropSeq.getArray();
1201 for (sal_Int32 j=0; j<nToolbars; ++j) {
1202 OUString sToolbarName = vModulesInfo[i].m_vToolbars[j];
1203 OUString sToolbarResourceURL = sToolbarResourcePre + sToolbarName;
1204
1205 plPropSeq[j].Name = sToolbarName;
1206 plPropSeq[j].Value <<= xCfgManager->getSettings(sToolbarResourceURL, true);
1207 }
1208
1209 p_lNewVersionToolbarSettingsSeq[i].Name = vModulesInfo[i].sModuleShortName;
1210 p_lNewVersionToolbarSettingsSeq[i].Value <<= lPropSeq;
1211 }
1212 }
1213 }
1214}
1215
1216} // namespace desktop
1217
1218/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
static std::shared_ptr< ConfigurationChanges > create()
static css::uno::Reference< css::container::XNameAccess > getConfigAccess(const char *path, bool rw=false)
Definition: migration.cxx:796
strings_vr getAllFiles(const OUString &baseURL) const
Definition: migration.cxx:531
static void setInstallInfoIfExist(install_info &aInfo, std::u16string_view rConfigDir, const OUString &rVersion)
Definition: migration.cxx:432
migrations_available m_vMigrationsAvailable
static bool checkMigrationCompleted()
Definition: migration.cxx:273
void mergeOldToNewVersion(const css::uno::Reference< css::ui::XUIConfigurationManager > &xCfgManager, const css::uno::Reference< css::container::XIndexContainer > &xIndexContainer, const OUString &sModuleIdentifier, const OUString &sResourceURL)
Definition: migration.cxx:1035
static migrations_vr readMigrationSteps(const OUString &rMigrationName)
Definition: migration.cxx:330
migrations_vr m_vrMigrations
MigrationHashMap m_aOldVersionItemsHashMap
static install_info findInstallation(const strings_v &rVersions)
Definition: migration.cxx:449
void compareOldAndNewConfig(const OUString &sParentNodeName, const css::uno::Reference< css::container::XIndexContainer > &xOldIndexContainer, const css::uno::Reference< css::container::XIndexContainer > &xNewIndexContainer, const OUString &sToolbarName)
Definition: migration.cxx:965
static void readAvailableMigrations(migrations_available &)
Definition: migration.cxx:304
sal_Int32 findPreferredMigrationProcess(const migrations_available &)
Definition: migration.cxx:487
static OUString preXDGConfigDir(const OUString &rConfigDir)
Definition: migration.cxx:402
std::vector< MigrationModuleInfo > detectUIChangesForAllModules() const
Definition: migration.cxx:906
static strings_vr applyPatterns(const strings_v &vSet, const strings_v &vPatterns)
Definition: migration.cxx:509
strings_vr compileFileList()
Definition: migration.cxx:580
static void setMigrationCompleted()
Definition: migration.cxx:262
static void migrateSettingsIfNecessary()
Definition: migration.cxx:155
get the information before copying the ui configuration files of old version to new version
css::uno::Reference< css::container::XIndexContainer > getNewToolbarSettings(std::u16string_view sModuleShortName, std::u16string_view sToolbarName) const
Definition: migration.cxx:1150
void init(const std::vector< MigrationModuleInfo > &vModulesInfo)
Definition: migration.cxx:1172
css::uno::Reference< css::container::XIndexContainer > getNewMenubarSettings(std::u16string_view sModuleShortName) const
Definition: migration.cxx:1136
std::vector< css::beans::PropertyValue > m_lCfgManagerSeq
css::uno::Reference< css::ui::XUIConfigurationManager > getConfigManager(std::u16string_view sModuleShortName) const
Definition: migration.cxx:1122
css::uno::Sequence< css::beans::PropertyValue > m_lNewVersionMenubarSettingsSeq
css::uno::Sequence< css::beans::PropertyValue > m_lNewVersionToolbarSettingsSeq
static PathStatus locateUserInstallation(OUString &_rURL)
static OUString getProductName()
bool SearchForward(const OUString &rStr, sal_Int32 *pStart, sal_Int32 *pEnd, css::util::SearchResult *pRes=nullptr)
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
float u
const char * name
static uno::Reference< css::uno::XComponentContext > xContext
Definition: init.cxx:2516
sal_Int32 nIndex
sal_Int64 n
uno_Any a
#define LANGUAGE_DONTKNOW
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
aStr
std::set< OUString > includedPaths
Definition: migration.cxx:603
std::set< OUString > excludedPaths
Definition: migration.cxx:604
const char * sName
void set(css::uno::UnoInterfaceReference const &value)
@ Exception
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
Definition: app.cxx:165
std::vector< migration_step > migrations_v
std::vector< supported_migration > migrations_available
static void insertSorted(migrations_available &rAvailableMigrations, supported_migration const &aSupportedMigration)
Definition: migration.cxx:294
std::unique_ptr< migrations_v > migrations_vr
const char XDG_CONFIG_PART[]
Definition: migration.cxx:400
std::unique_ptr< strings_v > strings_vr
std::vector< OUString > strings_v
static FileBase::RC _checkAndCreateDirectory(INetURLObject const &dirURL)
Definition: migration.cxx:386
constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL
Definition: migration.cxx:73
constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL
Definition: migration.cxx:75
constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER
Definition: migration.cxx:74
static OUString mapModuleShortNameToIdentifier(std::u16string_view sShortName)
Definition: migration.cxx:77
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
int i
FileStatus
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::u16string_view trim(std::u16string_view str)
enumrange< T >::Iterator begin(enumrange< T >)
end
comp
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
constexpr OUStringLiteral sAccessSrvc
define the item, e.g.
css::uno::Reference< css::container::XIndexContainer > m_xPopupMenu
information for the UI elements to be migrated for one module
std::vector< OUString > m_vToolbars
Any result
std::vector< uno::Reference< sheet::XSpreadsheetDocument > > Components
sal_Int32 nLength