Can someone explain it to me?
The following code calls realculate and then GetSectionHdrFtr when calculating the watermark on each page
CDocumentPrintView.prototype.GetSectionHdrFtr = function(nPageAbs, isFirst, isEven)
{
let oLogicDocument = this.LogicDocument;
let nSectionIndex = this.SectionsInfo.Get_Index(oLogicDocument.GetPage(nPageAbs).GetStartPos());
let oSectPr = this.SectionsInfo.Get_SectPr2(nSectionIndex).SectPr;
let startSectPr = oSectPr;
isEven = isEven && oSectPr.IsEvenAndOdd();
isFirst = isFirst && oSectPr.IsTitlePage();
let oHeader = null;
let oFooter = null;
while (nSectionIndex >= 0)
{
oSectPr = this.SectionsInfo.Get_SectPr2(nSectionIndex--).SectPr;
if (!oHeader)
oHeader = oSectPr.GetHdrFtr(true, isFirst, isEven);
if (!oFooter)
oFooter = oSectPr.GetHdrFtr(false, isFirst, isEven);
if (oHeader && oFooter)
break;
}
return {
Header : oHeader,
Footer : oFooter,
SectPr : startSectPr
};
};
Why does a docx document have more than one SectPr?
The resulting phenomenon is: A document set watermark will be divided into several sections, for example, I set watermark on the first page (the first page corresponds to == oSectPr subscript 0), may get GetSectionHdrFtr() on the fifth page, resulting in the oSectPr obtained by the watermark article is “”, As a result, there is no watermark behind the fifth page.
Why does it look in realculate() for FooterDefault based on the oSectPr of the current page, which may find other FooterDefault that is not empty, what is really needed in the element array (oSectPr array) may be the oSectPr with index 0, There is no watermark on subsequent pages
// It is possible to find an oHeader that is not empty, but it is not the watermarked text we need
oSectPr = this.SectionsInfo.Get_SectPr2(nSectionIndex--).SectPr;
if (!oHeader)
oHeader = oSectPr.GetHdrFtr(true, isFirst, isEven);
Looking forward to your reply
function CDocumentSectionsInfoElement(SectPr, Index)
{
this.SectPr = SectPr;
this.Index = Index;
}