[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 29 17:30:24 UTC 2021
sw/source/uibase/index/toxmgr.cxx | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
New commits:
commit 9d980309f19aacb0d6a658e6ac6ca5f14d8994fe
Author: Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Wed Jan 27 15:41:40 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jan 29 18:29:49 2021 +0100
sw: fix SwTOXMgr::UpdateOrInsertTOX() for user-defined
The main problem is that when editing an existing user-defined index,
the "Create From" changes aren't applied, because it does
pCurTOX->SetCreate() and not pNewTOX->SetCreate().
But that wasn't obvious as the function is obviosly very confused about
its 3 different TOX variables.
pTOX is just used at the end, so just move it there.
pCurTOX can be const.
Then there is an odd condition on pSh->HasSelection() which ends up
doing DelRight() but fortunately it's dead code since commit
e9da29679bce3b544add9233a4aca2b19b78da1a #i97572# cleared the selection
already.
The pNewTOX = pCurTOX there seems pointless because pNewTOX is already a
copy of *pCurTOX.
Change-Id: I1e9c8178e314a188a50272410fbe566e4a566742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110021
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
(cherry picked from commit 960e88835e0b2f7ff5fc57393b74017198c314e3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110063
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/index/toxmgr.cxx b/sw/source/uibase/index/toxmgr.cxx
index 4e7e65f9c4d0..fe4885830ffa 100644
--- a/sw/source/uibase/index/toxmgr.cxx
+++ b/sw/source/uibase/index/toxmgr.cxx
@@ -269,13 +269,9 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
{
SwWait aWait( *pSh->GetView().GetDocShell(), true );
bool bRet = true;
- const SwTOXBase* pCurTOX = ppBase && *ppBase ? *ppBase : pSh->GetCurTOX();
- SwTOXBase* pTOX = const_cast<SwTOXBase*>(pCurTOX);
+ const SwTOXBase *const pCurTOX = ppBase && *ppBase ? *ppBase : pSh->GetCurTOX();
- SwTOXBase * pNewTOX = nullptr;
-
- if (pTOX)
- pNewTOX = new SwTOXBase(*pTOX);
+ SwTOXBase * pNewTOX = pCurTOX ? new SwTOXBase(*pCurTOX) : nullptr;
TOXTypes eCurTOXType = rDesc.GetTOXType();
if(pCurTOX && !ppBase && pSh->HasSelection())
@@ -330,7 +326,7 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
}
else
{
- const_cast<SwTOXBase*>( pCurTOX )->SetCreate(rDesc.GetContentOptions());
+ pNewTOX->SetCreate(rDesc.GetContentOptions());
}
pNewTOX->SetLevelFromChapter(rDesc.IsLevelFromChapter());
}
@@ -385,12 +381,6 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
TOX_AUTHORITIES == eCurTOXType ? SwTOXElement::Mark : SwTOXElement::NONE,
pType->GetTypeName());
}
- else
- {
- if((!ppBase || !(*ppBase)) && pSh->HasSelection())
- pSh->DelRight();
- pNewTOX = const_cast<SwTOXBase*>(pCurTOX);
- }
pNewTOX->SetFromObjectNames(rDesc.IsCreateFromObjectNames());
pNewTOX->SetOLEOptions(rDesc.GetOLEOptions());
}
@@ -437,6 +427,7 @@ bool SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc,
pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::TOXCHANGE, nullptr);
}
+ SwTOXBase *const pTOX = const_cast<SwTOXBase*>(pCurTOX);
pDoc->ChangeTOX(*pTOX, *pNewTOX);
pTOX->DisableKeepExpression();
More information about the Libreoffice-commits
mailing list