private void UpdateSectionVisuals(SectionVisual visual, PTS.FSKUPDATE fskupdInherited, ref PTS.FSSECTIONDESCRIPTION sectionDesc) { PTS.FSKUPDATE fskupdate = sectionDesc.fsupdinf.fskupd; if (fskupdate == PTS.FSKUPDATE.fskupdInherited) { fskupdate = fskupdInherited; } ErrorHandler.Assert(fskupdate != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); if (fskupdate == PTS.FSKUPDATE.fskupdNoChange) { return; } PTS.FSSECTIONDETAILS fssectiondetails; PTS.Validate(PTS.FsQuerySectionDetails(this.PtsContext.Context, sectionDesc.pfssection, out fssectiondetails)); bool flag; if (PTS.ToBoolean(fssectiondetails.fFootnotesAsPagenotes)) { ErrorHandler.Assert(fssectiondetails.u.withpagenotes.cEndnoteColumns == 0, ErrorHandler.NotSupportedFootnotes); flag = (fssectiondetails.u.withpagenotes.cBasicColumns == 0); if (!flag) { PTS.FSTRACKDESCRIPTION[] array; PtsHelper.TrackListFromSection(this.PtsContext, sectionDesc.pfssection, ref fssectiondetails, out array); flag = (array.Length == 0); if (!flag) { ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(this._section.Element); visual.DrawColumnRules(ref array, TextDpi.FromTextDpi(sectionDesc.fsrc.v), TextDpi.FromTextDpi(sectionDesc.fsrc.dv), columnProperties); VisualCollection children = visual.Children; if (fskupdate == PTS.FSKUPDATE.fskupdNew) { children.Clear(); for (int i = 0; i < array.Length; i++) { children.Add(new ContainerVisual()); } } ErrorHandler.Assert(children.Count == array.Length, ErrorHandler.ColumnVisualCountMismatch); for (int j = 0; j < array.Length; j++) { ContainerVisual containerVisual = (ContainerVisual)children[j]; PtsHelper.UpdateTrackVisuals(this.PtsContext, containerVisual.Children, fskupdate, ref array[j]); } } } } else { ErrorHandler.Assert(false, ErrorHandler.NotSupportedCompositeColumns); flag = true; } if (flag) { visual.Children.Clear(); } }
private void UpdateSectionVisuals( SectionVisual visual, PTS.FSKUPDATE fskupdInherited, ref PTS.FSSECTIONDESCRIPTION sectionDesc) { PTS.FSKUPDATE fskupd = sectionDesc.fsupdinf.fskupd; if (fskupd == PTS.FSKUPDATE.fskupdInherited) { fskupd = fskupdInherited; } ErrorHandler.Assert(fskupd != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); // If there is no change, visual information is valid if (fskupd == PTS.FSKUPDATE.fskupdNoChange) { return; } bool emptySection; // Get section details PTS.FSSECTIONDETAILS sectionDetails; PTS.Validate(PTS.FsQuerySectionDetails(PtsContext.Context, sectionDesc.pfssection, out sectionDetails)); // There are 2 types of sections: // (1) with page notes - footnotes in section treated as endnotes // (2) with column notes - footnotes in section treated as column notes if (PTS.ToBoolean(sectionDetails.fFootnotesAsPagenotes)) { // (1) with page notes - footnotes in section treated as endnotes ErrorHandler.Assert(sectionDetails.u.withpagenotes.cEndnoteColumns == 0, ErrorHandler.NotSupportedFootnotes); // Debug.Assert(sectionDetails.u.withpagenotes.cSegmentDefinedColumnSpanAreas == 0); Debug.Assert(sectionDetails.u.withpagenotes.cHeightDefinedColumnSpanAreas == 0); // cBasicColumns == 0, means that section content is empty. emptySection = (sectionDetails.u.withpagenotes.cBasicColumns == 0); if (!emptySection) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION [] arrayColumnDesc; PtsHelper.TrackListFromSection(PtsContext, sectionDesc.pfssection, ref sectionDetails, out arrayColumnDesc); emptySection = (arrayColumnDesc.Length == 0); if (!emptySection) { // Draw column rules. ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(_section.Element); visual.DrawColumnRules(ref arrayColumnDesc, TextDpi.FromTextDpi(sectionDesc.fsrc.v), TextDpi.FromTextDpi(sectionDesc.fsrc.dv), columnProperties); VisualCollection visualChildren = visual.Children; if (fskupd == PTS.FSKUPDATE.fskupdNew) { visualChildren.Clear(); for (int index = 0; index < arrayColumnDesc.Length; index++) { visualChildren.Add(new ContainerVisual()); } } ErrorHandler.Assert(visualChildren.Count == arrayColumnDesc.Length, ErrorHandler.ColumnVisualCountMismatch); for (int index = 0; index < arrayColumnDesc.Length; index++) { ContainerVisual trackVisual = (ContainerVisual)visualChildren[index]; PtsHelper.UpdateTrackVisuals(PtsContext, trackVisual.Children, fskupd, ref arrayColumnDesc[index]); } } } } else { // (2) with column notes - footnotes in section treated as column notes ErrorHandler.Assert(false, ErrorHandler.NotSupportedCompositeColumns); emptySection = true; } if (emptySection) { // There is no content, remove all existing visuals. visual.Children.Clear(); } }
internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Floater is always reported as NEW. Override PTS inherited value. fskupdInherited = PTS.FSKUPDATE.fskupdNew; // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); // Obtain all mbd info MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); if (ThisFlowDirection != PageFlowDirection) { mbp.MirrorBP(); } Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty); Visual.DrawBackgroundAndBorder(backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk); ContainerVisual pageContentVisual; ContainerVisual floatingElementsVisual; if (_visual.Children.Count != 2) { _visual.Children.Clear(); _visual.Children.Add(new ContainerVisual()); _visual.Children.Add(new ContainerVisual()); } pageContentVisual = (ContainerVisual)_visual.Children[0]; floatingElementsVisual = (ContainerVisual)_visual.Children[1]; // Subpage content may be simple or complex - // depending of set of features used in the content of the subpage. // (1) simple subpage (contains only one track) // (2) complex subpage (contains columns) if (PTS.ToBoolean(subpageDetails.fSimple)) { // (1) simple subpage (contains only one track) PTS.FSKUPDATE fskupd = subpageDetails.u.simple.trackdescr.fsupdinf.fskupd; if (fskupd == PTS.FSKUPDATE.fskupdInherited) { fskupd = fskupdInherited; } VisualCollection visualChildren = pageContentVisual.Children; if (fskupd == PTS.FSKUPDATE.fskupdNew) { visualChildren.Clear(); visualChildren.Add(new ContainerVisual()); } // For complex subpage SectionVisual is added. So, when morphing // complex subpage to simple one, remove SectionVisual. else if (visualChildren.Count == 1 && !(visualChildren[0] is ContainerVisual)) { visualChildren.Clear(); visualChildren.Add(new ContainerVisual()); } Debug.Assert(visualChildren.Count == 1 && visualChildren[0] is ContainerVisual); ContainerVisual trackVisual = (ContainerVisual)visualChildren[0]; PtsHelper.UpdateTrackVisuals(PtsContext, trackVisual.Children, fskupdInherited, ref subpageDetails.u.simple.trackdescr); } else { // (2) complex page (contains columns) // cBasicColumns == 0, means that subpage content is empty bool emptySubpage = (subpageDetails.u.complex.cBasicColumns == 0); if (!emptySubpage) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); emptySubpage = (arrayColumnDesc.Length == 0); if (!emptySubpage) { PTS.FSKUPDATE fskupd = fskupdInherited; ErrorHandler.Assert(fskupd != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); Debug.Assert(fskupd != PTS.FSKUPDATE.fskupdNoChange); // For complex subpage SectionVisual is added. So, when morphing // simple subpage to complex one, remove ParagraphVisual. VisualCollection visualChildren = pageContentVisual.Children; if (visualChildren.Count == 0) { visualChildren.Add(new SectionVisual()); } else if (!(visualChildren[0] is SectionVisual)) { visualChildren.Clear(); visualChildren.Add(new SectionVisual()); } Debug.Assert(visualChildren.Count == 1 && visualChildren[0] is SectionVisual); SectionVisual sectionVisual = (SectionVisual)visualChildren[0]; // Draw column rules. ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(Paragraph.Element); sectionVisual.DrawColumnRules(ref arrayColumnDesc, TextDpi.FromTextDpi(subpageDetails.u.complex.fsrc.v), TextDpi.FromTextDpi(subpageDetails.u.complex.fsrc.dv), columnProperties); visualChildren = sectionVisual.Children; if (fskupd == PTS.FSKUPDATE.fskupdNew) { visualChildren.Clear(); for (int index = 0; index < arrayColumnDesc.Length; index++) { visualChildren.Add(new ContainerVisual()); } } ErrorHandler.Assert(visualChildren.Count == arrayColumnDesc.Length, ErrorHandler.ColumnVisualCountMismatch); for (int index = 0; index < arrayColumnDesc.Length; index++) { ContainerVisual trackVisual = (ContainerVisual)visualChildren[index]; PtsHelper.UpdateTrackVisuals(PtsContext, trackVisual.Children, fskupdInherited, ref arrayColumnDesc[index]); } } } if (emptySubpage) { // There is no content, remove all existing visuals. _visual.Children.Clear(); } } pageContentVisual.Offset = new PTS.FSVECTOR(ContentRect.u, ContentRect.v).FromTextDpi(); floatingElementsVisual.Offset = new PTS.FSVECTOR(ContentRect.u, ContentRect.v).FromTextDpi(); PTS.FSRECT clipRect = new PTS.FSRECT(_paddingRect.u - _contentRect.u, _paddingRect.v - _contentRect.v, _paddingRect.du, _paddingRect.dv); PtsHelper.ClipChildrenToRect(_visual, clipRect.FromTextDpi()); PtsHelper.UpdateFloatingElementVisuals(floatingElementsVisual, _pageContextOfThisPage.FloatingElementList); }
internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { PTS.FSSUBPAGEDETAILS fssubpagedetails; PTS.Validate(PTS.FsQuerySubpageDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubpagedetails)); MbpInfo mbpInfo = MbpInfo.FromElement(base.Paragraph.Element, base.Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); if (base.ThisFlowDirection != base.PageFlowDirection) { mbpInfo.MirrorBP(); } Brush backgroundBrush = (Brush)base.Paragraph.Element.GetValue(TextElement.BackgroundProperty); this.Visual.DrawBackgroundAndBorder(backgroundBrush, mbpInfo.BorderBrush, mbpInfo.Border, this._rect.FromTextDpi(), this.IsFirstChunk, this.IsLastChunk); if (this._visual.Children.Count != 2) { this._visual.Children.Clear(); this._visual.Children.Add(new ContainerVisual()); this._visual.Children.Add(new ContainerVisual()); } ContainerVisual containerVisual = (ContainerVisual)this._visual.Children[0]; ContainerVisual containerVisual2 = (ContainerVisual)this._visual.Children[1]; if (PTS.ToBoolean(fssubpagedetails.fSimple)) { PTS.FSKUPDATE fskupdate = fssubpagedetails.u.simple.trackdescr.fsupdinf.fskupd; if (fskupdate == PTS.FSKUPDATE.fskupdInherited) { fskupdate = fskupdInherited; } VisualCollection children = containerVisual.Children; if (fskupdate == PTS.FSKUPDATE.fskupdNew) { children.Clear(); children.Add(new ContainerVisual()); } else if (children.Count == 1 && children[0] is SectionVisual) { children.Clear(); children.Add(new ContainerVisual()); } ContainerVisual containerVisual3 = (ContainerVisual)children[0]; PtsHelper.UpdateTrackVisuals(base.PtsContext, containerVisual3.Children, fskupdInherited, ref fssubpagedetails.u.simple.trackdescr); } else { bool flag = fssubpagedetails.u.complex.cBasicColumns == 0; if (!flag) { PTS.FSTRACKDESCRIPTION[] array; PtsHelper.TrackListFromSubpage(base.PtsContext, this._paraHandle.Value, ref fssubpagedetails, out array); flag = (array.Length == 0); if (!flag) { ErrorHandler.Assert(fskupdInherited != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid); VisualCollection children2 = containerVisual.Children; if (children2.Count == 0) { children2.Add(new SectionVisual()); } else if (!(children2[0] is SectionVisual)) { children2.Clear(); children2.Add(new SectionVisual()); } SectionVisual sectionVisual = (SectionVisual)children2[0]; ColumnPropertiesGroup columnProperties = new ColumnPropertiesGroup(base.Paragraph.Element); sectionVisual.DrawColumnRules(ref array, TextDpi.FromTextDpi(fssubpagedetails.u.complex.fsrc.v), TextDpi.FromTextDpi(fssubpagedetails.u.complex.fsrc.dv), columnProperties); children2 = sectionVisual.Children; if (fskupdInherited == PTS.FSKUPDATE.fskupdNew) { children2.Clear(); for (int i = 0; i < array.Length; i++) { children2.Add(new ContainerVisual()); } } ErrorHandler.Assert(children2.Count == array.Length, ErrorHandler.ColumnVisualCountMismatch); for (int j = 0; j < array.Length; j++) { ContainerVisual containerVisual4 = (ContainerVisual)children2[j]; PtsHelper.UpdateTrackVisuals(base.PtsContext, containerVisual4.Children, fskupdInherited, ref array[j]); } } } if (flag) { this._visual.Children.Clear(); } } containerVisual.Offset = new PTS.FSVECTOR(this.ContentRect.u, this.ContentRect.v).FromTextDpi(); containerVisual2.Offset = new PTS.FSVECTOR(this.ContentRect.u, this.ContentRect.v).FromTextDpi(); PTS.FSRECT fsrect = new PTS.FSRECT(this._paddingRect.u - this._contentRect.u, this._paddingRect.v - this._contentRect.v, this._paddingRect.du, this._paddingRect.dv); PtsHelper.ClipChildrenToRect(this._visual, fsrect.FromTextDpi()); PtsHelper.UpdateFloatingElementVisuals(containerVisual2, this._pageContextOfThisPage.FloatingElementList); }