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>
This commit is contained in:
Noel Grandin
2020-08-03 11:12:07 +02:00
parent 32090b018d
commit e54777276d
8 changed files with 273 additions and 269 deletions
+68 -66
View File
@@ -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 ENABLE_DCONF
dconf::writeModifications(*this, data_);
#endif
break;
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_);
#endif
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) {
+12 -11
View File
@@ -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));
}
}
+13 -12
View File
@@ -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
+44 -44
View File
@@ -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);
}
}
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()))
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())
{
merge(i1->second, updateMember.second);
members.insert(updateMember);
}
} else if (updateMember.second->kind() == i1->second->kind()) {
merge(i1->second, updateMember.second);
}
break;
case Node::KIND_ROOT:
assert(false); // this cannot happen
break;
}
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()))
{
merge(i1->second, updateMember.second);
}
}
break;
case Node::KIND_ROOT:
assert(false); // this cannot happen
break;
}
}
+45 -45
View File
@@ -1366,68 +1366,68 @@ extern "C" void SAL_CALL typelib_typedescription_release(
{
sal_Int32 ref = osl_atomic_decrement( &pTD->nRefCount );
OSL_ASSERT(ref >= 0);
if (0 == ref)
if (0 != ref)
return;
TypeDescriptor_Init_Impl &rInit = Init::get();
if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
{
TypeDescriptor_Init_Impl &rInit = Init::get();
if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) )
if( pTD->pWeakRef )
{
if( pTD->pWeakRef )
{
{
MutexGuard aGuard( rInit.getMutex() );
// remove this description from the weak reference
pTD->pWeakRef->pType = nullptr;
}
typelib_typedescriptionreference_release( pTD->pWeakRef );
}
typelib_typedescriptionreference_release( pTD->pWeakRef );
}
else
}
else
{
// this description is a reference too, so remove it from the hash table
if( rInit.pWeakMap )
{
// this description is a reference too, so remove it from the hash table
if( rInit.pWeakMap )
MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( pTD->pTypeName->buffer );
if( aIt != rInit.pWeakMap->end() && static_cast<void *>((*aIt).second) == static_cast<void *>(pTD) )
{
MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( pTD->pTypeName->buffer );
if( aIt != rInit.pWeakMap->end() && static_cast<void *>((*aIt).second) == static_cast<void *>(pTD) )
{
// remove only if it contains the same object
rInit.pWeakMap->erase( aIt );
}
// remove only if it contains the same object
rInit.pWeakMap->erase( aIt );
}
}
}
typelib_typedescription_destructExtendedMembers( pTD );
rtl_uString_release( pTD->pTypeName );
typelib_typedescription_destructExtendedMembers( pTD );
rtl_uString_release( pTD->pTypeName );
#if OSL_DEBUG_LEVEL > 0
switch( pTD->eTypeClass )
{
case typelib_TypeClass_SEQUENCE:
osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount );
break;
case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION:
osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE:
osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE_METHOD:
osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount );
break;
case typelib_TypeClass_ENUM:
osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount );
break;
default:
osl_atomic_decrement( &rInit.nTypeDescriptionCount );
}
switch( pTD->eTypeClass )
{
case typelib_TypeClass_SEQUENCE:
osl_atomic_decrement( &rInit.nIndirectTypeDescriptionCount );
break;
case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION:
osl_atomic_decrement( &rInit.nCompoundTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE:
osl_atomic_decrement( &rInit.nInterfaceTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE_METHOD:
osl_atomic_decrement( &rInit.nInterfaceMethodTypeDescriptionCount );
break;
case typelib_TypeClass_INTERFACE_ATTRIBUTE:
osl_atomic_decrement( &rInit.nInterfaceAttributeTypeDescriptionCount );
break;
case typelib_TypeClass_ENUM:
osl_atomic_decrement( &rInit.nEnumTypeDescriptionCount );
break;
default:
osl_atomic_decrement( &rInit.nTypeDescriptionCount );
}
#endif
freeTypeDescription(pTD);
}
freeTypeDescription(pTD);
}
+65 -65
View File
@@ -3644,84 +3644,84 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned long
if (!pWindow && nWindowId >= 1000000000 /* why unsigned? */)
pWindow = getSidebarWindow();
if (aMap.find("id") != aMap.end())
if (aMap.find("id") == aMap.end())
return;
static const OUString sClickAction("CLICK");
static const OUString sSelectAction("SELECT");
static const OUString sClearAction("CLEAR");
static const OUString sTypeAction("TYPE");
static const OUString sUpAction("UP");
static const OUString sDownAction("DOWN");
static const OUString sValue("VALUE");
bool bIsWeldedDialog = false;
try
{
static const OUString sClickAction("CLICK");
static const OUString sSelectAction("SELECT");
static const OUString sClearAction("CLEAR");
static const OUString sTypeAction("TYPE");
static const OUString sUpAction("UP");
static const OUString sDownAction("DOWN");
static const OUString sValue("VALUE");
OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US);
bool bIsWeldedDialog = false;
bIsWeldedDialog = jsdialog::ExecuteAction(nWindowId, sControlId, aMap);
if (!bIsWeldedDialog)
bIsWeldedDialog = jsdialog::ExecuteAction(reinterpret_cast<sal_uInt64>(SfxViewShell::Current()),
sControlId, aMap);
try
if (!pWindow)
{
OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US);
SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found.");
return;
}
bIsWeldedDialog = jsdialog::ExecuteAction(nWindowId, sControlId, aMap);
if (!bIsWeldedDialog)
bIsWeldedDialog = jsdialog::ExecuteAction(reinterpret_cast<sal_uInt64>(SfxViewShell::Current()),
sControlId, aMap);
if (!bIsWeldedDialog)
{
WindowUIObject aUIObject(pWindow);
std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"]));
if (pUIWindow) {
bool bIsClickAction = false;
if (!pWindow)
{
SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found.");
return;
}
if (aMap.find("cmd") != aMap.end()) {
if (aMap["cmd"] == "selected")
{
aMap["POS"] = aMap["data"];
aMap["TEXT"] = aMap["data"];
if (!bIsWeldedDialog)
{
WindowUIObject aUIObject(pWindow);
std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"]));
if (pUIWindow) {
bool bIsClickAction = false;
pUIWindow->execute(sSelectAction, aMap);
}
else if (aMap["cmd"] == "plus")
{
pUIWindow->execute(sUpAction, aMap);
}
else if (aMap["cmd"] == "minus")
{
pUIWindow->execute(sDownAction, aMap);
}
else if (aMap["cmd"] == "set")
{
aMap["TEXT"] = aMap["data"];
if (aMap.find("cmd") != aMap.end()) {
if (aMap["cmd"] == "selected")
{
aMap["POS"] = aMap["data"];
aMap["TEXT"] = aMap["data"];
pUIWindow->execute(sSelectAction, aMap);
}
else if (aMap["cmd"] == "plus")
{
pUIWindow->execute(sUpAction, aMap);
}
else if (aMap["cmd"] == "minus")
{
pUIWindow->execute(sDownAction, aMap);
}
else if (aMap["cmd"] == "set")
{
aMap["TEXT"] = aMap["data"];
pUIWindow->execute(sClearAction, aMap);
pUIWindow->execute(sTypeAction, aMap);
}
else if (aMap["cmd"] == "value")
{
aMap["VALUE"] = aMap["data"];
pUIWindow->execute(sValue, aMap);
}
else
bIsClickAction = true;
pUIWindow->execute(sClearAction, aMap);
pUIWindow->execute(sTypeAction, aMap);
}
else if (aMap["cmd"] == "value")
{
aMap["VALUE"] = aMap["data"];
pUIWindow->execute(sValue, aMap);
}
else
bIsClickAction = true;
if (bIsClickAction)
pUIWindow->execute(sClickAction, aMap);
}
}
} catch(...) {}
else
bIsClickAction = true;
// force resend
if (!bIsWeldedDialog)
pWindow->Resize();
}
if (bIsClickAction)
pUIWindow->execute(sClickAction, aMap);
}
}
} catch(...) {}
// force resend
if (!bIsWeldedDialog)
pWindow->Resize();
}
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished)
+10 -10
View File
@@ -4185,18 +4185,18 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
// I find it not so good, but Writer3 feature:
// Check if distance by LineSpacing > Lower: this value is not
// stuck in the height of PrevPortion.
if ( !pPrev->IsInvalid() )
if ( pPrev->IsInvalid() )
return;
nExtraSpace = GetYValue( lcl_CalcExtraSpace( rPrevLSItem ) );
if ( nExtraSpace > nPrevLower )
{
nExtraSpace = GetYValue( lcl_CalcExtraSpace( rPrevLSItem ) );
if ( nExtraSpace > nPrevLower )
sal_uInt16 nMoreLower = nExtraSpace - nPrevLower;
// Paragraph becomes 'bigger', 'grows' downwards:
if ( nMoreLower > pPortion->nFirstLineOffset )
{
sal_uInt16 nMoreLower = nExtraSpace - nPrevLower;
// Paragraph becomes 'bigger', 'grows' downwards:
if ( nMoreLower > pPortion->nFirstLineOffset )
{
pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset );
pPortion->nFirstLineOffset = nMoreLower;
}
pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset );
pPortion->nFirstLineOffset = nMoreLower;
}
}
}
+16 -16
View File
@@ -70,27 +70,27 @@ oneToOneMappingWithFlag::~oneToOneMappingWithFlag()
void oneToOneMappingWithFlag::makeIndex()
{
if( !mbHasIndex && mpTableWF )
if( mbHasIndex || !mpTableWF )
return;
int current = -1;
for( size_t k = 0; k < mnSize; k++ )
{
int current = -1;
for( size_t k = 0; k < mnSize; k++ )
const int high = (mpTableWF[k].first >> 8) & 0xFF;
const int low = (mpTableWF[k].first) & 0xFF;
if( high != current )
{
const int high = (mpTableWF[k].first >> 8) & 0xFF;
const int low = (mpTableWF[k].first) & 0xFF;
if( high != current )
{
current = high;
mpIndex[high].reset(new UnicodePairWithFlag const *[256]);
current = high;
mpIndex[high].reset(new UnicodePairWithFlag const *[256]);
for (int j = 0; j < 256; ++j)
mpIndex[high][j] = nullptr;
}
mpIndex[high][low] = &mpTableWF[k];
for (int j = 0; j < 256; ++j)
mpIndex[high][j] = nullptr;
}
mbHasIndex = true;
mpIndex[high][low] = &mpTableWF[k];
}
mbHasIndex = true;
}
sal_Unicode oneToOneMappingWithFlag::find( const sal_Unicode nKey ) const