sw/source/core/undo/unattr.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
New commits: commit 24122c202149761121ffde6788d1b28b6f3ca8f1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Nov 7 13:18:35 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Nov 7 13:52:48 2022 +0100 tdf#148719 Moving caption frame & undoing is shrinking caption frame So the problem here is that when we call SwDoc::FindFormatByName we can have the situation that there are two formats with the same name. Those formats appear to have which ids 159 RES_DRAWFRMFMT 156 RES_FLYFRMFMT Previously, the index was sorted by ... which ... name which meant that the lower-valued which was always been returned. After my path, the index is sorted by ...name....which The problem is call path is sw/source/core/undo/unattr.cxx:252 in SwUndoFormatAttr::GetFormat where it calls rDoc.GetSpzFrameFormats()->FindFormatByName() To fix it, use the findByTypeAndName method to explicitly specify which which-id we are interested in. Change-Id: I8941f7c277785afb1940bcf5d2b5153c291b6f97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142371 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 50e4670bfbfc..4813b4e269d0 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -248,10 +248,10 @@ SwFormat* SwUndoFormatAttr::GetFormat( const SwDoc& rDoc ) case RES_DRAWFRMFMT: case RES_FLYFRMFMT: { - SwFormat * pFormat = rDoc.GetSpzFrameFormats()->FindFormatByName(m_sFormatName); - if (pFormat) - return pFormat; - pFormat = rDoc.GetFrameFormats()->FindFormatByName(m_sFormatName); + auto it = rDoc.GetSpzFrameFormats()->findByTypeAndName( m_nFormatWhich, m_sFormatName ); + if( it != rDoc.GetSpzFrameFormats()->typeAndNameEnd() ) + return *it; + SwFormat* pFormat = rDoc.GetFrameFormats()->FindFormatByName(m_sFormatName); if (pFormat) return pFormat; }