[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Oct 4 09:05:52 UTC 2018
sw/source/core/doc/docnew.cxx | 44 +++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
New commits:
commit 12db0c2a7b240b73a9445fffa026c4d1c349814c
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Sep 26 14:42:44 2018 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 4 11:05:28 2018 +0200
sw: fix copying of PageDesc follows in SwDoc::AppendDoc
The problem in the bugdoc is that there are 2 styles; "First Page"
has "Default Style" as the follow, and vice versa.
When the "First Page" style is copied, its follow is copied as well, but
the follow of the follow doesn't point to the *new* "First PageN" style
that was just created, but the original "First Page" one.
Change-Id: Ie5b0064581a585a3a545360ea5c05f60652f0d4e
Reviewed-on: https://gerrit.libreoffice.org/60993
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
(cherry picked from commit a6a4fa526b8ad19ff6d44a89ee56d4268c8e90be)
Reviewed-on: https://gerrit.libreoffice.org/61062
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 07fca37917bb..6940e86acc94 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -943,19 +943,45 @@ static void lcl_CopyFollowPageDesc(
const sal_uLong nDocNo )
{
//now copy the follow page desc, too
- const SwPageDesc* pFollowPageDesc = rSourcePageDesc.GetFollow();
- OUString sFollowPageDesc = pFollowPageDesc->GetName();
- if( sFollowPageDesc != rSourcePageDesc.GetName() )
+ // note: these may at any point form a cycle, so a loop is needed and it
+ // must be detected that the last iteration closes the cycle and doesn't
+ // copy the first page desc of the cycle again.
+ std::map<OUString, OUString> followMap{ { rSourcePageDesc.GetName(), rTargetPageDesc.GetName() } };
+ SwPageDesc const* pCurSourcePageDesc(&rSourcePageDesc);
+ SwPageDesc const* pCurTargetPageDesc(&rTargetPageDesc);
+ do
{
+ const SwPageDesc* pFollowPageDesc = pCurSourcePageDesc->GetFollow();
+ OUString sFollowPageDesc = pFollowPageDesc->GetName();
+ if (sFollowPageDesc == pCurSourcePageDesc->GetName())
+ {
+ break;
+ }
SwDoc* pTargetDoc = rTargetShell.GetDoc();
- OUString sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
- SwPageDesc* pTargetFollowPageDesc = pTargetDoc->MakePageDesc(sNewFollowPageDesc);
-
- pTargetDoc->CopyPageDesc(*pFollowPageDesc, *pTargetFollowPageDesc, false);
- SwPageDesc aDesc(rTargetPageDesc);
+ SwPageDesc* pTargetFollowPageDesc(nullptr);
+ auto const itMapped(followMap.find(sFollowPageDesc));
+ if (itMapped == followMap.end())
+ {
+ OUString sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo);
+ pTargetFollowPageDesc = pTargetDoc->MakePageDesc(sNewFollowPageDesc);
+ pTargetDoc->CopyPageDesc(*pFollowPageDesc, *pTargetFollowPageDesc, false);
+ }
+ else
+ {
+ pTargetFollowPageDesc = pTargetDoc->FindPageDesc(itMapped->second);
+ }
+ SwPageDesc aDesc(*pCurTargetPageDesc);
aDesc.SetFollow(pTargetFollowPageDesc);
- pTargetDoc->ChgPageDesc(rTargetPageDesc.GetName(), aDesc);
+ pTargetDoc->ChgPageDesc(pCurTargetPageDesc->GetName(), aDesc);
+ if (itMapped != followMap.end())
+ {
+ break; // was already copied
+ }
+ pCurSourcePageDesc = pCurSourcePageDesc->GetFollow();
+ pCurTargetPageDesc = pTargetFollowPageDesc;
+ followMap[pCurSourcePageDesc->GetName()] = pCurTargetPageDesc->GetName();
}
+ while (true);
}
// appends all pages of source SwDoc - based on SwFEShell::Paste( SwDoc* )
More information about the Libreoffice-commits
mailing list