diff options
-rw-r--r-- | configmgr/Library_configmgr.mk | 4 | ||||
-rw-r--r-- | configmgr/source/components.cxx | 32 | ||||
-rw-r--r-- | configmgr/source/components.hxx | 5 | ||||
-rw-r--r-- | configmgr/source/data.cxx | 18 | ||||
-rw-r--r-- | configmgr/source/data.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/parsemanager.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/parsemanager.hxx | 3 | ||||
-rw-r--r-- | configmgr/source/parser.hxx | 4 | ||||
-rw-r--r-- | configmgr/source/update.cxx | 4 | ||||
-rw-r--r-- | configmgr/source/xcdparser.cxx | 8 | ||||
-rw-r--r-- | configmgr/source/xcdparser.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/xcsparser.cxx | 2 | ||||
-rw-r--r-- | configmgr/source/xcsparser.hxx | 2 | ||||
-rw-r--r-- | configmgr/source/xcuparser.cxx | 8 | ||||
-rw-r--r-- | configmgr/source/xcuparser.hxx | 4 | ||||
-rw-r--r-- | desktop/source/migration/migration.cxx | 94 | ||||
-rw-r--r-- | offapi/com/sun/star/configuration/XUpdate.idl | 4 |
17 files changed, 127 insertions, 75 deletions
diff --git a/configmgr/Library_configmgr.mk b/configmgr/Library_configmgr.mk index d7873a09ba0e..19477b172308 100644 --- a/configmgr/Library_configmgr.mk +++ b/configmgr/Library_configmgr.mk @@ -52,10 +52,6 @@ $(eval $(call gb_Library_use_externals,configmgr, \ dconf \ )) -$(eval $(call gb_Library_use_custom_headers,configmgr, \ - officecfg/registry \ -)) - $(eval $(call gb_Library_use_sdk_api,configmgr)) $(eval $(call gb_Library_use_libraries,configmgr, \ diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 425d7925d366..939d226e964d 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -93,23 +93,23 @@ typedef std::vector< UnresolvedVectorItem > UnresolvedVector; void parseXcsFile( OUString const & url, int layer, Data & data, Partial const * partial, - Modifications * modifications, Additions * additions, OUString const & oldProductName) + Modifications * modifications, Additions * additions) { assert(partial == nullptr && modifications == nullptr && additions == nullptr); (void) partial; (void) modifications; (void) additions; bool ok = rtl::Reference< ParseManager >( - new ParseManager(url, oldProductName, new XcsParser(layer, data)))->parse(nullptr); + new ParseManager(url, new XcsParser(layer, data)))->parse(nullptr); assert(ok); (void) ok; // avoid warnings } void parseXcuFile( OUString const & url, int layer, Data & data, Partial const * partial, - Modifications * modifications, Additions * additions, OUString const & oldProductName) + Modifications * modifications, Additions * additions) { bool ok = rtl::Reference< ParseManager >( new ParseManager( - url, oldProductName, + url, new XcuParser(layer, data, partial, modifications, additions)))-> parse(nullptr); assert(ok); @@ -212,7 +212,7 @@ rtl::Reference< Node > Components::resolvePathRepresentation( const { return data_.resolvePathRepresentation( - pathRepresentation, OUString(), canonicRepresentation, path, finalizedLayer); + pathRepresentation, canonicRepresentation, path, finalizedLayer); } rtl::Reference< Node > Components::getTemplate(OUString const & fullName) const @@ -308,7 +308,7 @@ void Components::insertExtensionXcsFile( { int layer = getExtensionLayer(shared); try { - parseXcsFile(fileUri, layer, data_, nullptr, nullptr, nullptr, OUString()); + parseXcsFile(fileUri, layer, data_, nullptr, nullptr, nullptr); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( "insertExtensionXcsFile does not exist: " + e.Message); @@ -322,7 +322,7 @@ void Components::insertExtensionXcuFile( int layer = getExtensionLayer(shared) + 1; Additions * adds = data_.addExtensionXcuAdditions(fileUri, layer); try { - parseXcuFile(fileUri, layer, data_, nullptr, modifications, adds, OUString()); + parseXcuFile(fileUri, layer, data_, nullptr, modifications, adds); } catch (css::container::NoSuchElementException & e) { data_.removeExtensionXcuAdditions(fileUri); throw css::uno::RuntimeException( @@ -384,7 +384,7 @@ void Components::removeExtensionXcuFile( } void Components::insertModificationXcuFile( - OUString const & fileUri, OUString const & oldProductName, + OUString const & fileUri, std::set< OUString > const & includedPaths, std::set< OUString > const & excludedPaths, Modifications * modifications) @@ -393,7 +393,7 @@ void Components::insertModificationXcuFile( Partial part(includedPaths, excludedPaths); try { parseFileLeniently( - &parseXcuFile, fileUri, Data::NO_LAYER, &part, modifications, nullptr, oldProductName); + &parseXcuFile, fileUri, Data::NO_LAYER, &part, modifications, nullptr); } catch (const css::container::NoSuchElementException &) { TOOLS_WARN_EXCEPTION( "configmgr", @@ -552,7 +552,7 @@ Components::Components( } OUString aTempFileURL; if (dumpWindowsRegistry(&aTempFileURL, eType)) { - parseFileLeniently(&parseXcuFile, aTempFileURL, layer, nullptr, nullptr, nullptr, OUString()); + parseFileLeniently(&parseXcuFile, aTempFileURL, layer, nullptr, nullptr, nullptr); if (!getenv("SAL_CONFIG_WINREG_RETAIN_TMP")) osl::File::remove(aTempFileURL); } @@ -644,11 +644,11 @@ Components::~Components() void Components::parseFileLeniently( FileParser * parseFile, OUString const & url, int layer, Partial const * partial, Modifications * modifications, - Additions * additions, OUString const & oldProductName) + Additions * additions) { assert(parseFile != nullptr); try { - (*parseFile)(url, layer, data_, partial, modifications, additions, oldProductName); + (*parseFile)(url, layer, data_, partial, modifications, additions); } catch (const css::container::NoSuchElementException &) { throw; } catch (const css::uno::Exception &) { //TODO: more specific exception catching @@ -701,7 +701,7 @@ void Components::parseFiles( if (file.endsWith(extension)) { try { parseFileLeniently( - parseFile, stat.getFileURL(), layer, nullptr, nullptr, nullptr, OUString()); + parseFile, stat.getFileURL(), layer, nullptr, nullptr, nullptr); } catch (css::container::NoSuchElementException & e) { if (stat.getFileType() == osl::FileStatus::Link) { SAL_WARN("configmgr", "dangling link <" << stat.getFileURL() << ">"); @@ -727,7 +727,7 @@ void Components::parseFileList( adds = data_.addExtensionXcuAdditions(url, layer); } try { - parseFileLeniently(parseFile, url, layer, nullptr, nullptr, adds, OUString()); + parseFileLeniently(parseFile, url, layer, nullptr, nullptr, adds); } catch (const css::container::NoSuchElementException &) { TOOLS_WARN_EXCEPTION("configmgr", "file does not exist"); if (adds != nullptr) { @@ -780,7 +780,7 @@ void Components::parseXcdFiles(int layer, OUString const & url) { rtl::Reference< ParseManager > manager; try { manager = new ParseManager( - stat.getFileURL(), OUString(), + stat.getFileURL(), new XcdParser(layer, processedDeps, data_)); } catch (css::container::NoSuchElementException & e) { if (stat.getFileType() == osl::FileStatus::Link) { @@ -868,7 +868,7 @@ void Components::parseResLayer(int layer, OUString const & url) { void Components::parseModificationLayer(int layer, OUString const & url) { try { - parseFileLeniently(&parseXcuFile, url, layer, nullptr, nullptr, nullptr, OUString()); + parseFileLeniently(&parseXcuFile, url, layer, nullptr, nullptr, nullptr); } catch (css::container::NoSuchElementException &) { SAL_INFO( "configmgr", "user registrymodifications.xcu does not (yet) exist"); diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index 0dfb4bca8c5d..dc64d3c995a3 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -91,7 +91,6 @@ public: void insertModificationXcuFile( OUString const & fileUri, - OUString const & oldProductName, std::set< OUString > const & includedPaths, std::set< OUString > const & excludedPaths, Modifications * modifications); @@ -105,7 +104,7 @@ private: typedef void FileParser( OUString const &, int, Data &, Partial const *, Modifications *, - Additions *, OUString const &); + Additions *); public: explicit Components( css::uno::Reference< css::uno::XComponentContext > const & context); @@ -116,7 +115,7 @@ private: void parseFileLeniently( FileParser * parseFile, OUString const & url, int layer, Partial const * partial, Modifications * modifications, - Additions * additions, OUString const & oldProductName); + Additions * additions); void parseFiles( int layer, OUString const & extension, FileParser * parseFile, diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index 5eac69345f03..4f91d3b25612 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -23,7 +23,6 @@ #include <cassert> #include <com/sun/star/uno/RuntimeException.hpp> -#include <officecfg/Setup.hxx> #include <rtl/ref.hxx> #include <rtl/string.h> #include <rtl/ustrbuf.hxx> @@ -178,7 +177,7 @@ bool Data::equalTemplateNames( Data::Data(): root_(new RootNode) {} rtl::Reference< Node > Data::resolvePathRepresentation( - OUString const & pathRepresentation, OUString const & oldProductName, + OUString const & pathRepresentation, OUString * canonicRepresentation, std::vector<OUString> * path, int * finalizedLayer) const { @@ -248,21 +247,6 @@ rtl::Reference< Node > Data::resolvePathRepresentation( throw css::uno::RuntimeException( "bad path " + pathRepresentation); } - // The name of the product name related color schemes need to be replaced - // with the new product name during migration. - if (path != nullptr && path->back() == "ColorSchemes") - { - OUString aDarkTheme = " Dark"; - if (seg.equals(oldProductName)) - { - seg = officecfg::Setup::Product::ooName::get(); - } - else if (seg.equals(oldProductName + aDarkTheme)) - { - seg = officecfg::Setup::Product::ooName::get() + aDarkTheme; - } - } - // For backwards compatibility, allow set members to be accessed with // simple path segments, like group members: p = p->getMember(seg); diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx index ddfc4daeb95c..3e4bbd73ff36 100644 --- a/configmgr/source/data.hxx +++ b/configmgr/source/data.hxx @@ -68,7 +68,7 @@ struct Data { Data(); rtl::Reference< Node > resolvePathRepresentation( - OUString const & pathRepresentation, OUString const & oldProductName, + OUString const & pathRepresentation, OUString * canonicRepresentation, std::vector<OUString> * path, int * finalizedLayer) const; diff --git a/configmgr/source/parsemanager.cxx b/configmgr/source/parsemanager.cxx index fbce29f74459..36dea373dca1 100644 --- a/configmgr/source/parsemanager.cxx +++ b/configmgr/source/parsemanager.cxx @@ -33,8 +33,8 @@ namespace configmgr { ParseManager::ParseManager( - OUString const & url, OUString const & oldProductName, rtl::Reference< Parser > const & parser) - : reader_(url), oldProductName_(oldProductName), parser_(parser), itemNamespaceId_(-1) + OUString const & url, rtl::Reference< Parser > const & parser) + : reader_(url), parser_(parser), itemNamespaceId_(-1) { assert(parser.is()); int id; @@ -64,7 +64,7 @@ bool ParseManager::parse(std::set< OUString > const * existingDependencies) { { case xmlreader::XmlReader::Result::Begin: if (!parser_->startElement( - reader_, oldProductName_, itemNamespaceId_, itemData_, existingDependencies)) + reader_, itemNamespaceId_, itemData_, existingDependencies)) { SAL_INFO("configmgr", "parsing " << reader_.getUrl() << " took " << (osl_getGlobalTimer() - startTime) << " ms, fail"); return false; diff --git a/configmgr/source/parsemanager.hxx b/configmgr/source/parsemanager.hxx index b6c8fca4151a..86eb2db5ac9f 100644 --- a/configmgr/source/parsemanager.hxx +++ b/configmgr/source/parsemanager.hxx @@ -37,7 +37,7 @@ class Parser; class ParseManager: public salhelper::SimpleReferenceObject { public: ParseManager( - OUString const & url, OUString const & oldProductName, rtl::Reference< Parser > const & parser); + OUString const & url, rtl::Reference< Parser > const & parser); bool parse(std::set< OUString > const * existingDependencies); @@ -47,7 +47,6 @@ private: virtual ~ParseManager() override; xmlreader::XmlReader reader_; - OUString oldProductName_; rtl::Reference< Parser > parser_; xmlreader::Span itemData_; int itemNamespaceId_; diff --git a/configmgr/source/parser.hxx b/configmgr/source/parser.hxx index 1b8693e2e070..de57d4783381 100644 --- a/configmgr/source/parser.hxx +++ b/configmgr/source/parser.hxx @@ -36,8 +36,8 @@ public: virtual xmlreader::XmlReader::Text getTextMode() = 0; virtual bool startElement( - xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, - xmlreader::Span const & name, std::set< OUString > const * existingDependencies) = 0; + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, + std::set< OUString > const * existingDependencies) = 0; virtual void endElement(xmlreader::XmlReader const & reader) = 0; diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 683ef9c22a6f..046fea4b0285 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -78,7 +78,6 @@ private: virtual void SAL_CALL insertModificationXcuFile( OUString const & fileUri, - OUString const & oldProductName, css::uno::Sequence< OUString > const & includedPaths, css::uno::Sequence< OUString > const & excludedPaths) override; @@ -124,7 +123,6 @@ void Service::removeExtensionXcuFile(OUString const & fileUri) void Service::insertModificationXcuFile( OUString const & fileUri, - OUString const & oldProductName, css::uno::Sequence< OUString > const & includedPaths, css::uno::Sequence< OUString > const & excludedPaths) { @@ -134,7 +132,7 @@ void Service::insertModificationXcuFile( Components & components = Components::getSingleton(context_); Modifications mods; components.insertModificationXcuFile( - fileUri, oldProductName, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); + fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } diff --git a/configmgr/source/xcdparser.cxx b/configmgr/source/xcdparser.cxx index bd4be2de7482..a069c6b99c6f 100644 --- a/configmgr/source/xcdparser.cxx +++ b/configmgr/source/xcdparser.cxx @@ -50,14 +50,14 @@ xmlreader::XmlReader::Text XcdParser::getTextMode() { } bool XcdParser::startElement( - xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) { if (nestedParser_.is()) { assert(nesting_ != LONG_MAX); ++nesting_; return nestedParser_->startElement( - reader, oldProductName, nsId, name, existingDependencies); + reader, nsId, name, existingDependencies); } switch (state_) { case STATE_START: @@ -123,7 +123,7 @@ bool XcdParser::startElement( nestedParser_ = new XcsParser(layer_, data_); nesting_ = 1; return nestedParser_->startElement( - reader, oldProductName, nsId, name, existingDependencies); + reader, nsId, name, existingDependencies); } if (nsId == ParseManager::NAMESPACE_OOR && (name == "component-data" || name == "items")) @@ -131,7 +131,7 @@ bool XcdParser::startElement( nestedParser_ = new XcuParser(layer_ + 1, data_, nullptr, nullptr, nullptr); nesting_ = 1; return nestedParser_->startElement( - reader, oldProductName, nsId, name, existingDependencies); + reader, nsId, name, existingDependencies); } break; default: // STATE_DEPENDENCY diff --git a/configmgr/source/xcdparser.hxx b/configmgr/source/xcdparser.hxx index 5141b0ba734c..c51bd6368136 100644 --- a/configmgr/source/xcdparser.hxx +++ b/configmgr/source/xcdparser.hxx @@ -48,7 +48,7 @@ private: virtual xmlreader::XmlReader::Text getTextMode() override; virtual bool startElement( - xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) override; virtual void endElement(xmlreader::XmlReader const & reader) override; diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index 5acd87393567..7b1750b20972 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -119,7 +119,7 @@ xmlreader::XmlReader::Text XcsParser::getTextMode() { } bool XcsParser::startElement( - xmlreader::XmlReader & reader, OUString const & /*oldProductName*/, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * /*existingDependencies*/) { if (valueParser_.startElement(reader, nsId, name)) { diff --git a/configmgr/source/xcsparser.hxx b/configmgr/source/xcsparser.hxx index 9b90555e45a8..d662ff47bbed 100644 --- a/configmgr/source/xcsparser.hxx +++ b/configmgr/source/xcsparser.hxx @@ -50,7 +50,7 @@ private: virtual xmlreader::XmlReader::Text getTextMode() override; virtual bool startElement( - xmlreader::XmlReader & reader, OUString const & /*oldProductName*/, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) override; virtual void endElement(xmlreader::XmlReader const & reader) override; diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index b6bdd4200d61..03e3c60ab067 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -67,7 +67,7 @@ xmlreader::XmlReader::Text XcuParser::getTextMode() { } bool XcuParser::startElement( - xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * /*existingDependencies*/) { if (valueParser_.startElement(reader, nsId, name)) { @@ -95,7 +95,7 @@ bool XcuParser::startElement( "bad items node member <" + name.convertFromUtf8() + "> in " + reader.getUrl()); } - handleItem(reader, oldProductName); + handleItem(reader); } else { switch (state_.top().node->kind()) { case Node::KIND_PROPERTY: @@ -312,7 +312,7 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { state_.push(State::Modify(node)); } -void XcuParser::handleItem(xmlreader::XmlReader & reader, OUString const & oldProductName) { +void XcuParser::handleItem(xmlreader::XmlReader & reader) { xmlreader::Span attrPath; for (;;) { int attrNsId; @@ -332,7 +332,7 @@ void XcuParser::handleItem(xmlreader::XmlReader & reader, OUString const & oldPr int finalizedLayer; rtl::Reference< Node > node( data_.resolvePathRepresentation( - path, oldProductName, nullptr, &path_, &finalizedLayer)); + path, nullptr, &path_, &finalizedLayer)); if (!node.is()) { SAL_WARN( "configmgr", diff --git a/configmgr/source/xcuparser.hxx b/configmgr/source/xcuparser.hxx index 15a566f8336d..3e3544385634 100644 --- a/configmgr/source/xcuparser.hxx +++ b/configmgr/source/xcuparser.hxx @@ -60,7 +60,7 @@ private: virtual xmlreader::XmlReader::Text getTextMode() override; virtual bool startElement( - xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) override; virtual void endElement(xmlreader::XmlReader const & reader) override; @@ -74,7 +74,7 @@ private: void handleComponentData(xmlreader::XmlReader & reader); - void handleItem(xmlreader::XmlReader & reader, OUString const & oldProductName); + void handleItem(xmlreader::XmlReader & reader); void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop); diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index c36780a1c229..05baeddbb4c3 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -38,6 +38,7 @@ #include <i18nlangtag/lang.h> #include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> +#include <officecfg/Office/UI.hxx> #include <osl/file.hxx> #include <osl/security.hxx> #include <unotools/configmgr.hxx> @@ -45,6 +46,7 @@ #include <com/sun/star/configuration/Update.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/task/XJob.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -666,6 +668,55 @@ bool getComponent(OUString const & path, OUString * component) return true; } +void renameMigratedSetElementTo( + css::uno::Reference<css::container::XNameContainer> const & set, OUString const & currentName, + OUString const & migratedName) +{ + // To avoid unexpected data loss, the code is careful to only rename from currentName to + // migratedName in the expected case where the currentName element exists and the migratedName + // element doesn't exist: + auto const hasCurrent = set->hasByName(currentName); + auto const hasMigrated = set->hasByName(migratedName); + if (hasCurrent && !hasMigrated) { + auto const elem = set->getByName(currentName); + set->removeByName(currentName); + set->insertByName(migratedName, elem); + } else { + SAL_INFO_IF(!hasCurrent, "desktop.migration", "unexpectedly missing " << currentName); + SAL_INFO_IF(hasMigrated, "desktop.migration", "unexpectedly present " << migratedName); + } +} + +void renameMigratedSetElementBack( + css::uno::Reference<css::container::XNameContainer> const & set, OUString const & currentName, + OUString const & migratedName) +{ + // To avoid unexpected data loss, the code is careful to ensure that in the end a currentName + // element exists, creating it from a template if the migratedName element had unexpectedly gone + // missing: + auto const hasMigrated = set->hasByName(migratedName); + css::uno::Any elem; + if (hasMigrated) { + elem = set->getByName(migratedName); + set->removeByName(migratedName); + } else { + SAL_INFO("desktop.migration", "unexpected loss of " << migratedName); + elem <<= css::uno::Reference<css::lang::XSingleServiceFactory>( + set, css::uno::UNO_QUERY_THROW)->createInstance(); + } + if (set->hasByName(currentName)) { + SAL_INFO("desktop.migration", "unexpected reappearance of " << currentName); + if (hasMigrated) { + SAL_INFO( + "desktop.migration", + "reappeared " << currentName << " overwritten with " << migratedName); + set->replaceByName(currentName, elem); + } + } else { + set->insertByName(currentName, elem); + } +} + } void MigrationImpl::copyConfig() @@ -689,10 +740,6 @@ 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 ) { @@ -700,6 +747,30 @@ void MigrationImpl::copyConfig() regFile.close(); } + // If the to-be-migrated data contains modifications of + // /org.openoffice.Office.UI/ColorScheme/ColorSchemes set elements named after the migrated + // product name, those modifications must instead be made to the corresponding set elements + // named after the current product name. However, if the current configuration data does not + // contain those old-named set elements at all, their modification data would silently be + // ignored by css.configuration.XUpdate::insertModificationXcuFile. So temporarily rename any + // new-named set elements to their old-named counterparts here, and rename them back again down + // below after importing the migrated data: + OUString sProductName = utl::ConfigManager::getProductName(); + OUString sProductNameDark = sProductName + " Dark"; + OUString sMigratedProductName = m_aInfo.productname; + // remove version number from the end of product name if there’s one + if (isdigit(sMigratedProductName[sMigratedProductName.getLength() - 1])) + sMigratedProductName = (sMigratedProductName.copy(0, m_aInfo.productname.getLength() - 1)).trim(); + OUString sMigratedProductNameDark = sMigratedProductName + " Dark"; + auto const tempRename = sMigratedProductName != sProductName; + if (tempRename) { + auto const batch = comphelper::ConfigurationChanges::create(); + auto const schemes = officecfg::Office::UI::ColorScheme::ColorSchemes::get(batch); + renameMigratedSetElementTo(schemes, sProductName, sMigratedProductName); + renameMigratedSetElementTo(schemes, sProductNameDark, sMigratedProductNameDark); + batch->commit(); + } + for (auto const& comp : comps) { if (!comp.second.includedPaths.empty()) { @@ -730,7 +801,6 @@ void MigrationImpl::copyConfig() comphelper::getProcessComponentContext())-> insertModificationXcuFile( regFilePath, - sMigratedProductName, comphelper::containerToSequence(comp.second.includedPaths), comphelper::containerToSequence(comp.second.excludedPaths)); @@ -740,6 +810,13 @@ void MigrationImpl::copyConfig() next: ; } + if (tempRename) { + auto const batch = comphelper::ConfigurationChanges::create(); + auto const schemes = officecfg::Office::UI::ColorScheme::ColorSchemes::get(batch); + renameMigratedSetElementBack(schemes, sProductName, sMigratedProductName); + renameMigratedSetElementBack(schemes, sProductNameDark, sMigratedProductNameDark); + batch->commit(); + } // checking the migrated (product name related) color scheme name, and replace it to the current version scheme name try { @@ -748,17 +825,16 @@ next: 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::Any(sProductName)); uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges(); } - else if (sMigratedColorScheme.equals(sMigratedProductName + aDarkTheme)) + else if (sMigratedColorScheme.equals(sMigratedProductNameDark)) { aPropertySet->setPropertyValue("CurrentColorScheme", - uno::Any(utl::ConfigManager::getProductName() + aDarkTheme)); + uno::Any(sProductNameDark)); uno::Reference<XChangesBatch>(aPropertySet, uno::UNO_QUERY_THROW)->commitChanges(); } } diff --git a/offapi/com/sun/star/configuration/XUpdate.idl b/offapi/com/sun/star/configuration/XUpdate.idl index c58cabced7b1..90862b112944 100644 --- a/offapi/com/sun/star/configuration/XUpdate.idl +++ b/offapi/com/sun/star/configuration/XUpdate.idl @@ -40,8 +40,8 @@ interface XUpdate { // argument void insertModificationXcuFile( - [in] string fileUri, [in] string oldProductName, - [in] sequence< string > includedPaths, [in] sequence< string > excludedPaths); + [in] string fileUri, [in] sequence< string > includedPaths, + [in] sequence< string > excludedPaths); }; }; }; }; }; |