Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/watermark #4481

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -12401,7 +12401,35 @@ CDocument.prototype.SetWatermarkProps = function(oProps)
return;

this.StartAction(AscDFH.historydescription_Document_AddWatermark);
this.SetWatermarkPropsAction(oProps);
for (let pageIndex = 0; pageIndex < this.Pages.length; pageIndex++) {
// Определим четность страницы и является ли она первой в данной секции. Заметим, что четность страницы
// отсчитывается от начала текущей секции и не зависит от настроек нумерации страниц для данной секции.
var SectionPageInfo = this.Get_SectionPageNumInfo( pageIndex );

var bFirst = SectionPageInfo.bFirst;
var bEven = SectionPageInfo.bEven;

// Запросим нужный нам колонтитул
var HdrFtr = this.Get_SectionHdrFtr( pageIndex, bFirst, bEven );

var Header = HdrFtr.Header;
var Footer = HdrFtr.Footer;
var SectPr = HdrFtr.SectPr;

if (!Header && SectPr.IsTitlePage()) {
Header = new CHeaderFooter(this.GetHdrFtr(), this, this.Get_DrawingDocument(), hdrftr_Header);
SectPr.Set_Header_First(Header);
}else if (!Header && SectPr.IsEvenAndOdd()) {
Header = new CHeaderFooter(this.GetHdrFtr(), this, this.Get_DrawingDocument(), hdrftr_Header);
SectPr.Set_Header_First(Header);
} else if(!Header){
Header = new CHeaderFooter(this.GetHdrFtr(), this, this.Get_DrawingDocument(), hdrftr_Header);
SectPr.Set_Header_Default(Header);
}
if(Header){
Header.SetWatermarkPropsAction(oProps);
}
}
this.Recalculate();
this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState();
Expand Down
24 changes: 24 additions & 0 deletions word/Editor/HeaderFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,30 @@ CHeaderFooter.prototype =
return this.Content.CanAddComment();
}
};
CHeaderFooter.prototype.SetWatermarkPropsAction = function (oProps) {
const oLogicDocument = this.LogicDocument;
let oWatermark = this.FindWatermark();
if(oWatermark)
{
if(oWatermark.GraphicObj.selected)
{
this.RemoveSelection(true);
}
oWatermark.Remove_FromDocument(false);
}
oWatermark = oLogicDocument.DrawingObjects.createWatermark(oProps);
if(oWatermark)
{
const oDocState = oLogicDocument.Get_SelectionState2();
const oContent = this.Content;
var paraRun = new ParaRun(null, false);
paraRun.Add(oWatermark);
var oFirstParagraph = oContent.GetFirstParagraph();
oFirstParagraph.AddToContentToEnd(paraRun);
oLogicDocument.Set_SelectionState2(oDocState);
return oWatermark;
}
};
CHeaderFooter.prototype.UpdateContentToDefaults = function()
{
this.Content.ClearContent(true);
Expand Down
Loading