[Libreoffice-commits] core.git: Branch 'feature/cib_contract935' - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Sep 27 20:05:46 UTC 2018
sw/source/core/doc/docnew.cxx | 44 +++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
New commits:
commit 6d96af4266b4fd1b5adb464c7b877426bf49f520
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Sep 26 14:42:44 2018 +0200
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu Sep 27 22:05:22 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/61060
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index f665c032ccf1..5a42a5c2f796 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -920,19 +920,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