tdf#121119 master docs at-page anchor: fix runtime duplicated images
Asking for "All" update of the master document resulted duplicated objects anchored at page, loading the subdocuments again, which contained the images originally. Follow-up to commit2f135fa82c"tdf#121119 master docs at-page anchor: fix missing images" and commitfb4197ed81"tdf#121119 master docs at-page anchor: fix duplicated images". Change-Id: I4c76c325963cd740906045653fc90055ce1840c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180628 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: Jenkins
This commit is contained in:
@@ -1788,6 +1788,27 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121119)
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xIndexAccess2->getCount());
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testTdf121119_runtime_update)
|
||||
{
|
||||
createSwGlobalDoc("tdf121119.odm");
|
||||
SwDoc* pDoc = getSwDoc();
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
size_t(2), pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks().size());
|
||||
pDoc->getIDocumentLinksAdministration().GetLinkManager().UpdateAllLinks(false, false, nullptr,
|
||||
u""_ustr);
|
||||
// double update of the links
|
||||
pDoc->getIDocumentLinksAdministration().GetLinkManager().UpdateAllLinks(false, false, nullptr,
|
||||
u""_ustr);
|
||||
|
||||
uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent,
|
||||
uno::UNO_QUERY);
|
||||
uno::Reference<container::XIndexAccess> xIndexAccess(
|
||||
xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
|
||||
|
||||
// This was 8 (duplicated images anchored at page)
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xIndexAccess->getCount());
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testTdf163703)
|
||||
{
|
||||
// Given a document with italics autostyle in a comment
|
||||
|
||||
@@ -1264,6 +1264,19 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& rUpdLnk, SwSectionNode& rSe
|
||||
}
|
||||
else if( pSrcDoc != pDoc )
|
||||
{
|
||||
// before update, remove obsolete page-anchored flys from the target master document
|
||||
auto pFormats = pDoc->GetSpzFrameFormats();
|
||||
for( sal_uInt16 nCnt = pFormats->size(); nCnt; )
|
||||
{
|
||||
SwFrameFormat* pFormat = (*pFormats)[ --nCnt ];
|
||||
SwFormatAnchor aAnchor( pFormat->GetAnchor() );
|
||||
if ( RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId() &&
|
||||
pFormat->GetName().indexOf(sFileName) > -1 )
|
||||
{
|
||||
pDoc->getIDocumentLayoutAccess().DelLayoutFormat( pFormat );
|
||||
}
|
||||
}
|
||||
|
||||
// store page count of the source document to calculate
|
||||
// the physical page number of the objects anchored at page
|
||||
const SwDocStat& rDStat = pSrcDoc->getIDocumentStatistics().GetDocStat();
|
||||
|
||||
Reference in New Issue
Block a user