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