summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-03 08:41:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-03 11:12:07 +0200
commite54777276d28e6bbceefa07e260926c81790938c (patch)
tree54aee65d9ab60e0dafbd574c1d0849b516af2367 /configmgr
parent32090b018d9ff81659a4c9ed41c64109ebebe4fc (diff)
loplugin:flatten in configmgr..i18nutil
Change-Id: Idaeed33df4f1dd1b2acbdaf8a895c5d56c3ca14c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99980 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/components.cxx132
-rw-r--r--configmgr/source/rootaccess.cxx23
-rw-r--r--configmgr/source/writemodfile.cxx25
-rw-r--r--configmgr/source/xcsparser.cxx84
4 files changed, 134 insertions, 130 deletions
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 7f629bc8afbe..f7bd5ba34e3a 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -271,23 +271,24 @@ void Components::addModification(std::vector<OUString> const & path) {
void Components::writeModifications() {
- if (!data_.modifications.empty()) {
- switch (modificationTarget_) {
- case ModificationTarget::None:
- break;
- case ModificationTarget::File:
- if (!writeThread_.is()) {
- writeThread_ = new WriteThread(
- &writeThread_, *this, modificationFileUrl_, data_);
- writeThread_->launch();
- }
- break;
- case ModificationTarget::Dconf:
+ if (data_.modifications.empty())
+ return;
+
+ switch (modificationTarget_) {
+ case ModificationTarget::None:
+ break;
+ case ModificationTarget::File:
+ if (!writeThread_.is()) {
+ writeThread_ = new WriteThread(
+ &writeThread_, *this, modificationFileUrl_, data_);
+ writeThread_->launch();
+ }
+ break;
+ case ModificationTarget::Dconf:
#if ENABLE_DCONF
- dconf::writeModifications(*this, data_);
+ dconf::writeModifications(*this, data_);
#endif
- break;
- }
+ break;
}
}
@@ -349,38 +350,39 @@ void Components::removeExtensionXcuFile(
assert(modifications != nullptr);
rtl::Reference< Data::ExtensionXcu > item(
data_.removeExtensionXcuAdditions(fileUri));
- if (item.is()) {
- for (Additions::reverse_iterator i(item->additions.rbegin());
- i != item->additions.rend(); ++i)
+ if (!item.is())
+ return;
+
+ for (Additions::reverse_iterator i(item->additions.rbegin());
+ i != item->additions.rend(); ++i)
+ {
+ rtl::Reference< Node > parent;
+ NodeMap const * map = &data_.getComponents();
+ rtl::Reference< Node > node;
+ for (auto const& j : *i)
{
- rtl::Reference< Node > parent;
- NodeMap const * map = &data_.getComponents();
- rtl::Reference< Node > node;
- for (auto const& j : *i)
- {
- parent = node;
- node = map->findNode(Data::NO_LAYER, j);
- if (!node.is()) {
- break;
- }
- map = &node->getMembers();
+ parent = node;
+ node = map->findNode(Data::NO_LAYER, j);
+ if (!node.is()) {
+ break;
}
- if (node.is()) {
- assert(parent.is());
- if (parent->kind() == Node::KIND_SET) {
- assert(
- node->kind() == Node::KIND_GROUP ||
- node->kind() == Node::KIND_SET);
- if (canRemoveFromLayer(item->layer, node)) {
- parent->getMembers().erase(i->back());
- data_.modifications.remove(*i);
- modifications->add(*i);
- }
+ map = &node->getMembers();
+ }
+ if (node.is()) {
+ assert(parent.is());
+ if (parent->kind() == Node::KIND_SET) {
+ assert(
+ node->kind() == Node::KIND_GROUP ||
+ node->kind() == Node::KIND_SET);
+ if (canRemoveFromLayer(item->layer, node)) {
+ parent->getMembers().erase(i->back());
+ data_.modifications.remove(*i);
+ modifications->add(*i);
}
}
}
- writeModifications();
}
+ writeModifications();
}
void Components::insertModificationXcuFile(
@@ -825,32 +827,32 @@ void Components::parseXcsXcuIniLayer(
// Check if ini file exists (otherwise .override would still read global
// SCHEMA/DATA variables, which could interfere with unrelated environment
// variables):
- if (rtl::Bootstrap(url).getHandle() != nullptr) {
- OUStringBuffer prefix("${.override:");
- for (sal_Int32 i = 0; i != url.getLength(); ++i) {
- sal_Unicode c = url[i];
- switch (c) {
- case '$':
- case ':':
- case '\\':
- prefix.append('\\');
- [[fallthrough]];
- default:
- prefix.append(c);
- }
- }
- prefix.append(':');
- OUString urls(prefix.toString() + "SCHEMA}");
- rtl::Bootstrap::expandMacros(urls);
- if (!urls.isEmpty()) {
- parseFileList(layer, &parseXcsFile, urls, false);
- }
- urls = prefix.makeStringAndClear() + "DATA}";
- rtl::Bootstrap::expandMacros(urls);
- if (!urls.isEmpty()) {
- parseFileList(layer + 1, &parseXcuFile, urls, recordAdditions);
+ if (rtl::Bootstrap(url).getHandle() == nullptr) return;
+
+ OUStringBuffer prefix("${.override:");
+ for (sal_Int32 i = 0; i != url.getLength(); ++i) {
+ sal_Unicode c = url[i];
+ switch (c) {
+ case '$':
+ case ':':
+ case '\\':
+ prefix.append('\\');
+ [[fallthrough]];
+ default:
+ prefix.append(c);
}
}
+ prefix.append(':');
+ OUString urls(prefix.toString() + "SCHEMA}");
+ rtl::Bootstrap::expandMacros(urls);
+ if (!urls.isEmpty()) {
+ parseFileList(layer, &parseXcsFile, urls, false);
+ }
+ urls = prefix.makeStringAndClear() + "DATA}";
+ rtl::Bootstrap::expandMacros(urls);
+ if (!urls.isEmpty()) {
+ parseFileList(layer + 1, &parseXcuFile, urls, recordAdditions);
+ }
}
void Components::parseResLayer(int layer, OUString const & url) {
diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx
index 17c9f111a27a..a3804fa47d4d 100644
--- a/configmgr/source/rootaccess.cxx
+++ b/configmgr/source/rootaccess.cxx
@@ -75,17 +75,18 @@ void RootAccess::initBroadcaster(
std::vector< css::util::ElementChange > changes;
initBroadcasterAndChanges(
modifications, broadcaster, changesListeners_.empty() ? nullptr : &changes);
- if (!changes.empty()) {
- css::util::ChangesSet set(comphelper::containerToSequence(changes));
- for (auto const& changesListener : changesListeners_)
- {
- cppu::OWeakObject* pSource = this;
- css::uno::Reference< css::uno::XInterface > xBase( pSource, css::uno::UNO_QUERY );
- broadcaster->addChangesNotification(
- changesListener,
- css::util::ChangesEvent(
- pSource, css::uno::Any( xBase ), set));
- }
+ if (changes.empty())
+ return;
+
+ css::util::ChangesSet set(comphelper::containerToSequence(changes));
+ for (auto const& changesListener : changesListeners_)
+ {
+ cppu::OWeakObject* pSource = this;
+ css::uno::Reference< css::uno::XInterface > xBase( pSource, css::uno::UNO_QUERY );
+ broadcaster->addChangesNotification(
+ changesListener,
+ css::util::ChangesEvent(
+ pSource, css::uno::Any( xBase ), set));
}
}
diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx
index 3df150c448cd..29d4b18c49bf 100644
--- a/configmgr/source/writemodfile.cxx
+++ b/configmgr/source/writemodfile.cxx
@@ -75,20 +75,21 @@ OString convertToUtf8(std::u16string_view text) {
} // anonymous namespace
TempFile::~TempFile() {
- if (handle != nullptr) {
- if (!closed) {
- oslFileError e = osl_closeFile(handle);
- if (e != osl_File_E_None) {
- SAL_WARN("configmgr", "osl_closeFile failed with " << +e);
- }
- }
- osl::FileBase::RC e = osl::File::remove(url);
- if (e != osl::FileBase::E_None) {
- SAL_WARN(
- "configmgr",
- "osl::File::remove(" << url << ") failed with " << +e);
+ if (handle == nullptr)
+ return;
+
+ if (!closed) {
+ oslFileError e = osl_closeFile(handle);
+ if (e != osl_File_E_None) {
+ SAL_WARN("configmgr", "osl_closeFile failed with " << +e);
}
}
+ osl::FileBase::RC e = osl::File::remove(url);
+ if (e != osl::FileBase::E_None) {
+ SAL_WARN(
+ "configmgr",
+ "osl::File::remove(" << url << ") failed with " << +e);
+ }
}
#ifdef _WIN32
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 7b1750b20972..947792c0a62e 100644
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -55,54 +55,54 @@ void merge(
assert(
original.is() && update.is() && original->kind() == update->kind() &&
update->getFinalized() == Data::NO_LAYER);
- if (update->getLayer() >= original->getLayer() &&
- update->getLayer() <= original->getFinalized())
- {
- switch (original->kind()) {
- case Node::KIND_PROPERTY:
- case Node::KIND_LOCALIZED_PROPERTY:
- case Node::KIND_LOCALIZED_VALUE:
- break; //TODO: merge certain parts?
- case Node::KIND_GROUP:
- for (auto const& updateMember : update->getMembers())
- {
- NodeMap & members = original->getMembers();
- NodeMap::iterator i1(members.find(updateMember.first));
- if (i1 == members.end()) {
- if (updateMember.second->kind() == Node::KIND_PROPERTY &&
- static_cast< GroupNode * >(
- original.get())->isExtensible())
- {
- members.insert(updateMember);
- }
- } else if (updateMember.second->kind() == i1->second->kind()) {
- merge(i1->second, updateMember.second);
+ if (update->getLayer() < original->getLayer() ||
+ update->getLayer() > original->getFinalized())
+ return;
+
+ switch (original->kind()) {
+ case Node::KIND_PROPERTY:
+ case Node::KIND_LOCALIZED_PROPERTY:
+ case Node::KIND_LOCALIZED_VALUE:
+ break; //TODO: merge certain parts?
+ case Node::KIND_GROUP:
+ for (auto const& updateMember : update->getMembers())
+ {
+ NodeMap & members = original->getMembers();
+ NodeMap::iterator i1(members.find(updateMember.first));
+ if (i1 == members.end()) {
+ if (updateMember.second->kind() == Node::KIND_PROPERTY &&
+ static_cast< GroupNode * >(
+ original.get())->isExtensible())
+ {
+ members.insert(updateMember);
}
+ } else if (updateMember.second->kind() == i1->second->kind()) {
+ merge(i1->second, updateMember.second);
}
- break;
- case Node::KIND_SET:
- for (auto const& updateMember : update->getMembers())
- {
- NodeMap & members = original->getMembers();
- NodeMap::iterator i1(members.find(updateMember.first));
- if (i1 == members.end()) {
- if (static_cast< SetNode * >(original.get())->
- isValidTemplate(updateMember.second->getTemplateName()))
- {
- members.insert(updateMember);
- }
- } else if (updateMember.second->kind() == i1->second->kind() &&
- (updateMember.second->getTemplateName() ==
- i1->second->getTemplateName()))
+ }
+ break;
+ case Node::KIND_SET:
+ for (auto const& updateMember : update->getMembers())
+ {
+ NodeMap & members = original->getMembers();
+ NodeMap::iterator i1(members.find(updateMember.first));
+ if (i1 == members.end()) {
+ if (static_cast< SetNode * >(original.get())->
+ isValidTemplate(updateMember.second->getTemplateName()))
{
- merge(i1->second, updateMember.second);
+ members.insert(updateMember);
}
+ } else if (updateMember.second->kind() == i1->second->kind() &&
+ (updateMember.second->getTemplateName() ==
+ i1->second->getTemplateName()))
+ {
+ merge(i1->second, updateMember.second);
}
- break;
- case Node::KIND_ROOT:
- assert(false); // this cannot happen
- break;
}
+ break;
+ case Node::KIND_ROOT:
+ assert(false); // this cannot happen
+ break;
}
}