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>
This commit is contained in:
committed by
Michael Stahl
parent
3a9d504b01
commit
9f7ee38ace
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user