diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2022-09-08 16:04:10 +0200 |
---|---|---|
committer | Balazs Varga <balazs.varga.extern@allotropia.de> | 2022-09-13 19:50:00 +0200 |
commit | 583ea856f2aa227bb04581c5bcdc3a402f5a184f (patch) | |
tree | 8518366a3a9bfd8435cd2748fc771d04f12b33aa /desktop | |
parent | 5e192fab19e1f51a704a0c690af5343d43b8e724 (diff) |
Migrating product name related color schemes between different versions
Making work to migrate product name related color schemes
with different kind of product names. For example from a product
named by LibreOffice to a product named by LibreOfficeDev.
Change-Id: Iabef982216f126b781df122ed258816af2ae337c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139690
Tested-by: Jenkins
Tested-by: Gabor Kelemen <kelemeng@ubuntu.com>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/migration/migration.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 5d0db5a52bfd..0f8099278c0c 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -639,6 +639,10 @@ void MigrationImpl::copyConfig() // check if the shared registrymodifications.xcu file exists bool bRegistryModificationsXcuExists = false; OUString regFilePath = m_aInfo.userdata + "/user/registrymodifications.xcu"; + OUString sMigratedProductName = m_aInfo.productname; + // remove version number from the end of pruduct name if exist + if (isdigit(sMigratedProductName[sMigratedProductName.getLength() - 1])) + sMigratedProductName = (sMigratedProductName.copy(0, m_aInfo.productname.getLength() - 1)).trim(); File regFile(regFilePath); ::osl::FileBase::RC nError = regFile.open(osl_File_OpenFlag_Read); if ( nError == ::osl::FileBase::E_None ) { @@ -676,14 +680,41 @@ void MigrationImpl::copyConfig() comphelper::getProcessComponentContext())-> insertModificationXcuFile( regFilePath, + sMigratedProductName, comphelper::containerToSequence(comp.second.includedPaths), comphelper::containerToSequence(comp.second.excludedPaths)); + } else { SAL_INFO( "desktop.migration", "configuration migration component " << comp.first << " ignored (only excludes, no includes)" ); } next: ; } + // checking the migrated (product name related) color scheme name, and replace it to the current version scheme name + try + { + OUString sMigratedColorScheme; + uno::Reference<XPropertySet> aPropertySet( + getConfigAccess("org.openoffice.Office.UI/ColorScheme", true), uno::UNO_QUERY_THROW); + if (aPropertySet->getPropertyValue("CurrentColorScheme") >>= sMigratedColorScheme) + { + OUString aDarkTheme = " Dark"; + if (sMigratedColorScheme.equals(sMigratedProductName)) + { + aPropertySet->setPropertyValue("CurrentColorScheme", + uno::Any(utl::ConfigManager::getProductName())); + uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges(); + } + else if (sMigratedColorScheme.equals(sMigratedProductName + aDarkTheme)) + { + aPropertySet->setPropertyValue("CurrentColorScheme", + uno::Any(utl::ConfigManager::getProductName() + aDarkTheme)); + uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges(); + } + } + } catch (const Exception&) { + // fail silently... + } } uno::Reference< XNameAccess > MigrationImpl::getConfigAccess(const char* pPath, bool bUpdate) |