diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-01-27 15:41:40 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-01-29 21:48:52 +0100 |
commit | 74a273836169ad5b78b22c4bdc6724c66ca9007f (patch) | |
tree | 3ab56b011296be7fff42cc2fe315df1af114c3ea | |
parent | drop RadioButton arg defaults (diff) | |
download | core-74a273836169ad5b78b22c4bdc6724c66ca9007f.tar.gz core-74a273836169ad5b78b22c4bdc6724c66ca9007f.zip |
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@allotropia.de>
(cherry picked from commit 960e88835e0b2f7ff5fc57393b74017198c314e3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110064
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | sw/source/uibase/index/toxmgr.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
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(); |