summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-10-30 17:43:46 +0100
committerMichael Stahl <michael.stahl@cib.de>2019-10-31 11:47:47 +0100
commit9f7ee38acec0cb614e37aecc5ea9c5f1c63b61b6 (patch)
treef9a71a32120c766957a3d113fd51ba13c514c85a /sw
parent3a9d504b01c061f60a915b5681c8313859294118 (diff)
sw: copy bookmarks in SwDoc::CopyPageDescHeaderFooterImpl()
When importing tdf113521-1.doc, a footer is copied, but the fieldmark in it is not copied, so there are CH_TXT_ATR_FIELD* in the copy without matching fieldmark, and the result is sw/source/filter/ww8/wrtw8nds.cxx:2342: virtual void MSWordExportBase::OutputTextNode(SwTextNode&): Assertion `pFieldmark' failed. Change-Id: I42b005e22b57f181e4e8bc52afb053546db5f741 Reviewed-on: https://gerrit.libreoffice.org/81792 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx21
-rw-r--r--sw/source/core/doc/docfmt.cxx4
-rw-r--r--sw/source/core/inc/DocumentContentOperationsManager.hxx3
3 files changed, 21 insertions, 7 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 2e53c74032e9..704603372c65 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -148,7 +148,7 @@ namespace
}
/*
- The lcl_CopyBookmarks function has to copy bookmarks from the source to the destination nodes
+ The CopyBookmarks function has to copy bookmarks from the source to the destination nodes
array. It is called after a call of the CopyNodes(..) function. But this function does not copy
every node (at least at the moment: 2/08/2006 ), section start and end nodes will not be copied
if the corresponding end/start node is outside the copied pam.
@@ -218,10 +218,12 @@ namespace
rChgPos.nContent.Assign( rChgPos.nNode.GetNode().GetContentNode(), nContentPos );
}
+}
+
+namespace sw
+{
// TODO: use SaveBookmark (from DelBookmarks)
- void lcl_CopyBookmarks(
- const SwPaM& rPam,
- SwPaM& rCpyPam )
+ void CopyBookmarks(const SwPaM& rPam, SwPosition& rCpyPam)
{
const SwDoc* pSrcDoc = rPam.GetDoc();
SwDoc* pDestDoc = rCpyPam.GetDoc();
@@ -229,7 +231,7 @@ namespace
::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
- SwPosition* pCpyStt = rCpyPam.Start();
+ SwPosition const*const pCpyStt = &rCpyPam;
typedef std::vector< const ::sw::mark::IMark* > mark_vector_t;
mark_vector_t vMarksToCopy;
@@ -319,7 +321,10 @@ namespace
}
}
}
+} // namespace sw
+namespace
+{
void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam )
{
const SwDoc* pSrcDoc = rPam.GetDoc();
@@ -3398,7 +3403,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
*aCpyPaM.GetPoint() = pCopiedPaM->second;
}
- lcl_CopyBookmarks(pCopiedPaM ? pCopiedPaM->first : aRgTmp, aCpyPaM);
+ sw::CopyBookmarks(pCopiedPaM ? pCopiedPaM->first : aRgTmp, *aCpyPaM.Start());
}
if( bDelRedlines && ( RedlineFlags::DeleteRedlines & pDest->getIDocumentRedlineAccess().GetRedlineFlags() ))
@@ -4919,7 +4924,9 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
// Also copy all bookmarks
if( bCopyBookmarks && m_rDoc.getIDocumentMarkAccess()->getAllMarksCount() )
- lcl_CopyBookmarks( rPam, *pCopyPam );
+ {
+ sw::CopyBookmarks(rPam, *pCopyPam->Start());
+ }
if( RedlineFlags::DeleteRedlines & eOld )
{
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 7ad9ee7b6f77..d3fd405f6dd2 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1392,6 +1392,10 @@ void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader,
rSrcNds.Copy_( aRg, aTmpIdx );
aTmpIdx = *pSttNd;
rSrcFormat.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRg, nullptr, aTmpIdx);
+ // TODO: investigate calling CopyWithFlyInFly?
+ SwPaM const source(aRg.aStart, aRg.aEnd);
+ SwPosition dest(aTmpIdx);
+ sw::CopyBookmarks(source, dest);
pNewFormat->SetFormatAttr( SwFormatContent( pSttNd ));
}
else
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index 3de0b68282bc..bf765d291d46 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -177,6 +177,9 @@ private:
DocumentContentOperationsManager& operator=(DocumentContentOperationsManager const&) = delete;
};
+
+void CopyBookmarks(const SwPaM& rPam, SwPosition& rTarget);
+
}
#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCONTENTOPERATIONSMANAGER_HXX