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 /configmgr | |
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 'configmgr')
-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 |
15 files changed, 64 insertions, 40 deletions
diff --git a/configmgr/Library_configmgr.mk b/configmgr/Library_configmgr.mk index 11bba5f0f4cf..1c4b216a3740 100644 --- a/configmgr/Library_configmgr.mk +++ b/configmgr/Library_configmgr.mk @@ -51,6 +51,10 @@ $(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 3c35a258c12c..8d933d2c1651 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -95,23 +95,23 @@ typedef std::vector< UnresolvedVectorItem > UnresolvedVector; void parseXcsFile( OUString const & url, int layer, Data & data, Partial const * partial, - Modifications * modifications, Additions * additions) + Modifications * modifications, Additions * additions, OUString const & oldProductName) { assert(partial == nullptr && modifications == nullptr && additions == nullptr); (void) partial; (void) modifications; (void) additions; bool ok = rtl::Reference< ParseManager >( - new ParseManager(url, new XcsParser(layer, data)))->parse(nullptr); + new ParseManager(url, oldProductName, 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) + Modifications * modifications, Additions * additions, OUString const & oldProductName) { bool ok = rtl::Reference< ParseManager >( new ParseManager( - url, + url, oldProductName, new XcuParser(layer, data, partial, modifications, additions)))-> parse(nullptr); assert(ok); @@ -214,7 +214,7 @@ rtl::Reference< Node > Components::resolvePathRepresentation( const { return data_.resolvePathRepresentation( - pathRepresentation, canonicRepresentation, path, finalizedLayer); + pathRepresentation, OUString(), canonicRepresentation, path, finalizedLayer); } rtl::Reference< Node > Components::getTemplate(OUString const & fullName) const @@ -311,7 +311,7 @@ void Components::insertExtensionXcsFile( { int layer = getExtensionLayer(shared); try { - parseXcsFile(fileUri, layer, data_, nullptr, nullptr, nullptr); + parseXcsFile(fileUri, layer, data_, nullptr, nullptr, nullptr, OUString()); } catch (css::container::NoSuchElementException & e) { throw css::uno::RuntimeException( "insertExtensionXcsFile does not exist: " + e.Message); @@ -325,7 +325,7 @@ void Components::insertExtensionXcuFile( int layer = getExtensionLayer(shared) + 1; Additions * adds = data_.addExtensionXcuAdditions(fileUri, layer); try { - parseXcuFile(fileUri, layer, data_, nullptr, modifications, adds); + parseXcuFile(fileUri, layer, data_, nullptr, modifications, adds, OUString()); } catch (css::container::NoSuchElementException & e) { data_.removeExtensionXcuAdditions(fileUri); throw css::uno::RuntimeException( @@ -388,7 +388,7 @@ void Components::removeExtensionXcuFile( } void Components::insertModificationXcuFile( - OUString const & fileUri, + OUString const & fileUri, OUString const & oldProductName, std::set< OUString > const & includedPaths, std::set< OUString > const & excludedPaths, Modifications * modifications) @@ -397,7 +397,7 @@ void Components::insertModificationXcuFile( Partial part(includedPaths, excludedPaths); try { parseFileLeniently( - &parseXcuFile, fileUri, Data::NO_LAYER, &part, modifications, nullptr); + &parseXcuFile, fileUri, Data::NO_LAYER, &part, modifications, nullptr, oldProductName); } catch (const css::container::NoSuchElementException &) { TOOLS_WARN_EXCEPTION( "configmgr", @@ -553,7 +553,7 @@ Components::Components( } OUString aTempFileURL; if (dumpWindowsRegistry(&aTempFileURL, eType)) { - parseFileLeniently(&parseXcuFile, aTempFileURL, layer, nullptr, nullptr, nullptr); + parseFileLeniently(&parseXcuFile, aTempFileURL, layer, nullptr, nullptr, nullptr, OUString()); if (!getenv("SAL_CONFIG_WINREG_RETAIN_TMP")) osl::File::remove(aTempFileURL); } @@ -645,11 +645,11 @@ Components::~Components() void Components::parseFileLeniently( FileParser * parseFile, OUString const & url, int layer, Partial const * partial, Modifications * modifications, - Additions * additions) + Additions * additions, OUString const & oldProductName) { assert(parseFile != nullptr); try { - (*parseFile)(url, layer, data_, partial, modifications, additions); + (*parseFile)(url, layer, data_, partial, modifications, additions, oldProductName); } catch (const css::container::NoSuchElementException &) { throw; } catch (const css::uno::Exception &) { //TODO: more specific exception catching @@ -702,7 +702,7 @@ void Components::parseFiles( if (file.endsWith(extension)) { try { parseFileLeniently( - parseFile, stat.getFileURL(), layer, nullptr, nullptr, nullptr); + parseFile, stat.getFileURL(), layer, nullptr, nullptr, nullptr, OUString()); } catch (css::container::NoSuchElementException & e) { if (stat.getFileType() == osl::FileStatus::Link) { SAL_WARN("configmgr", "dangling link <" << stat.getFileURL() << ">"); @@ -728,7 +728,7 @@ void Components::parseFileList( adds = data_.addExtensionXcuAdditions(url, layer); } try { - parseFileLeniently(parseFile, url, layer, nullptr, nullptr, adds); + parseFileLeniently(parseFile, url, layer, nullptr, nullptr, adds, OUString()); } catch (const css::container::NoSuchElementException &) { TOOLS_WARN_EXCEPTION("configmgr", "file does not exist"); if (adds != nullptr) { @@ -781,7 +781,7 @@ void Components::parseXcdFiles(int layer, OUString const & url) { rtl::Reference< ParseManager > manager; try { manager = new ParseManager( - stat.getFileURL(), + stat.getFileURL(), OUString(), new XcdParser(layer, processedDeps, data_)); } catch (css::container::NoSuchElementException & e) { if (stat.getFileType() == osl::FileStatus::Link) { @@ -865,7 +865,7 @@ void Components::parseResLayer(int layer, std::u16string_view url) { void Components::parseModificationLayer(int layer, OUString const & url) { try { - parseFileLeniently(&parseXcuFile, url, layer, nullptr, nullptr, nullptr); + parseFileLeniently(&parseXcuFile, url, layer, nullptr, nullptr, nullptr, OUString()); } 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 5d7b6b5967ee..87c9a1f7c7b4 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -91,6 +91,7 @@ public: void insertModificationXcuFile( OUString const & fileUri, + OUString const & oldProductName, std::set< OUString > const & includedPaths, std::set< OUString > const & excludedPaths, Modifications * modifications); @@ -104,7 +105,7 @@ private: typedef void FileParser( OUString const &, int, Data &, Partial const *, Modifications *, - Additions *); + Additions *, OUString const &); public: explicit Components( css::uno::Reference< css::uno::XComponentContext > const & context); @@ -115,7 +116,7 @@ private: void parseFileLeniently( FileParser * parseFile, OUString const & url, int layer, Partial const * partial, Modifications * modifications, - Additions * additions); + Additions * additions, OUString const & oldProductName); void parseFiles( int layer, OUString const & extension, FileParser * parseFile, diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index f173ee1556fb..fd4ecb0f3b0b 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -24,6 +24,7 @@ #include <cstddef> #include <com/sun/star/uno/RuntimeException.hpp> +#include <officecfg/Setup.hxx> #include <rtl/ref.hxx> #include <rtl/string.h> #include <rtl/ustrbuf.hxx> @@ -179,7 +180,7 @@ bool Data::equalTemplateNames( Data::Data(): root_(new RootNode) {} rtl::Reference< Node > Data::resolvePathRepresentation( - OUString const & pathRepresentation, + OUString const & pathRepresentation, OUString const & oldProductName, OUString * canonicRepresentation, std::vector<OUString> * path, int * finalizedLayer) const { @@ -249,6 +250,21 @@ 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 c3614e6435da..e7af062efff8 100644 --- a/configmgr/source/data.hxx +++ b/configmgr/source/data.hxx @@ -67,7 +67,7 @@ struct Data { Data(); rtl::Reference< Node > resolvePathRepresentation( - OUString const & pathRepresentation, + OUString const & pathRepresentation, OUString const & oldProductName, OUString * canonicRepresentation, std::vector<OUString> * path, int * finalizedLayer) const; diff --git a/configmgr/source/parsemanager.cxx b/configmgr/source/parsemanager.cxx index 36dea373dca1..fbce29f74459 100644 --- a/configmgr/source/parsemanager.cxx +++ b/configmgr/source/parsemanager.cxx @@ -33,8 +33,8 @@ namespace configmgr { ParseManager::ParseManager( - OUString const & url, rtl::Reference< Parser > const & parser) - : reader_(url), parser_(parser), itemNamespaceId_(-1) + OUString const & url, OUString const & oldProductName, rtl::Reference< Parser > const & parser) + : reader_(url), oldProductName_(oldProductName), 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_, itemNamespaceId_, itemData_, existingDependencies)) + reader_, oldProductName_, 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 fba61ec07b94..eb91cf201ee6 100644 --- a/configmgr/source/parsemanager.hxx +++ b/configmgr/source/parsemanager.hxx @@ -36,7 +36,7 @@ class Parser; class ParseManager: public salhelper::SimpleReferenceObject { public: ParseManager( - OUString const & url, rtl::Reference< Parser > const & parser); + OUString const & url, OUString const & oldProductName, rtl::Reference< Parser > const & parser); bool parse(std::set< OUString > const * existingDependencies); @@ -46,6 +46,7 @@ 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 a3984203c583..d6ee654f67bf 100644 --- a/configmgr/source/parser.hxx +++ b/configmgr/source/parser.hxx @@ -35,8 +35,8 @@ public: virtual xmlreader::XmlReader::Text getTextMode() = 0; virtual bool startElement( - xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, - std::set< OUString > const * existingDependencies) = 0; + xmlreader::XmlReader & reader, OUString const & oldProductName, 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 1cc2a06fe2a2..4033e9dc9caf 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -76,6 +76,7 @@ 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; @@ -121,6 +122,7 @@ 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) { @@ -130,7 +132,7 @@ void Service::insertModificationXcuFile( Components & components = Components::getSingleton(context_); Modifications mods; components.insertModificationXcuFile( - fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); + fileUri, oldProductName, 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 a069c6b99c6f..bd4be2de7482 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, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) { if (nestedParser_.is()) { assert(nesting_ != LONG_MAX); ++nesting_; return nestedParser_->startElement( - reader, nsId, name, existingDependencies); + reader, oldProductName, 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, nsId, name, existingDependencies); + reader, oldProductName, 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, nsId, name, existingDependencies); + reader, oldProductName, nsId, name, existingDependencies); } break; default: // STATE_DEPENDENCY diff --git a/configmgr/source/xcdparser.hxx b/configmgr/source/xcdparser.hxx index 1ca32931ea48..883a0aa980bb 100644 --- a/configmgr/source/xcdparser.hxx +++ b/configmgr/source/xcdparser.hxx @@ -47,7 +47,7 @@ private: virtual xmlreader::XmlReader::Text getTextMode() override; virtual bool startElement( - xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & oldProductName, 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 947792c0a62e..c3006d0258f3 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, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & /*oldProductName*/, 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 f2c5c77429d6..385f114dda57 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, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & /*oldProductName*/, 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 af21518abd78..696d124127ea 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, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & oldProductName, 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); + handleItem(reader, oldProductName); } 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) { +void XcuParser::handleItem(xmlreader::XmlReader & reader, OUString const & oldProductName) { xmlreader::Span attrPath; for (;;) { int attrNsId; @@ -332,7 +332,7 @@ void XcuParser::handleItem(xmlreader::XmlReader & reader) { int finalizedLayer; rtl::Reference< Node > node( data_.resolvePathRepresentation( - path, nullptr, &path_, &finalizedLayer)); + path, oldProductName, nullptr, &path_, &finalizedLayer)); if (!node.is()) { SAL_WARN( "configmgr", diff --git a/configmgr/source/xcuparser.hxx b/configmgr/source/xcuparser.hxx index e50b7b5a0fc8..19b50e144164 100644 --- a/configmgr/source/xcuparser.hxx +++ b/configmgr/source/xcuparser.hxx @@ -61,7 +61,7 @@ private: virtual xmlreader::XmlReader::Text getTextMode() override; virtual bool startElement( - xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name, + xmlreader::XmlReader & reader, OUString const & oldProductName, int nsId, xmlreader::Span const & name, std::set< OUString > const * existingDependencies) override; virtual void endElement(xmlreader::XmlReader const & reader) override; @@ -75,7 +75,7 @@ private: void handleComponentData(xmlreader::XmlReader & reader); - void handleItem(xmlreader::XmlReader & reader); + void handleItem(xmlreader::XmlReader & reader, OUString const & oldProductName); void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop); |