[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Sep 27 19:54:13 UTC 2018
sw/source/core/doc/docnew.cxx | 44 +++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
New commits:
commit a6a4fa526b8ad19ff6d44a89ee56d4268c8e90be
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Sep 26 14:42:44 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 27 21:49:48 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>
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 855c9aadc9cf..4e0cfb24c2f2 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -936,19 +936,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