internal ColumnResult(BaseParaClient subpage, ref PTS.FSTRACKDESCRIPTION trackDesc, Vector contentOffset) { // Subpage must be figure, floater or subpage paraclient Invariant.Assert(subpage is SubpageParaClient || subpage is FigureParaClient || subpage is FloaterParaClient); _subpage = subpage; _columnHandle = trackDesc.pfstrack; _layoutBox = new Rect( TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v), TextDpi.FromTextDpi(trackDesc.fsrc.du), TextDpi.FromTextDpi(trackDesc.fsrc.dv)); _layoutBox.X += contentOffset.X; _layoutBox.Y += contentOffset.Y; _columnOffset = new Vector(TextDpi.FromTextDpi(trackDesc.fsrc.u), TextDpi.FromTextDpi(trackDesc.fsrc.v)); }
internal override void CollapseMargin( BaseParaClient paraClient, // IN: MarginCollapsingState mcs, // IN: input margin collapsing state uint fswdir, // IN: current direction (of the track, in which margin collapsing is happening) bool suppressTopSpace, // IN: suppress empty space at the top of page out int dvr) // OUT: dvr, calculated based on margin collapsing state { // Floaters are not participating in margin collapsing. // Top space is always suppressed dvr = 0; }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal FigureParagraphResult(BaseParaClient paraClient) : base(paraClient) { }
internal override IInputElement InputHitTest(PTS.FSPOINT pt) { IInputElement ie = null; if (_pageContextOfThisPage.FloatingElementList != null) { for (int index = 0; index < _pageContextOfThisPage.FloatingElementList.Count && ie == null; index++) { BaseParaClient floatingElement = _pageContextOfThisPage.FloatingElementList[index]; ie = floatingElement.InputHitTest(pt); } } if (ie == null) { // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); if (Rect.Contains(pt)) { if (ContentRect.Contains(pt)) { pt = new PTS.FSPOINT(pt.u - ContentRect.u, pt.v - ContentRect.v); // Hittest subpage content. Subpage content may be simple or complex - // depending of set of features used in the content of the page. // (1) simple subpage (contains only one track) // (2) complex subpage (contains columns) if (PTS.ToBoolean(subpageDetails.fSimple)) { ie = PtsHelper.InputHitTestTrack(PtsContext, pt, ref subpageDetails.u.simple.trackdescr); } else { // (2) complex page (contains columns) // cBasicColumns == 0, means that subpage content is empty if (subpageDetails.u.complex.cBasicColumns != 0) { // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); // Arrange each track for (int index = 0; index < arrayColumnDesc.Length && ie == null; index++) { ie = PtsHelper.InputHitTestTrack(PtsContext, pt, ref arrayColumnDesc[index]); } } } } if (ie == null) { ie = Paragraph.Element as IInputElement; } } } return(ie); }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal SubpageParagraphResult(BaseParaClient paraClient) : base(paraClient) { }
//------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods #endregion Protected Methods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Collapse Margins /// </summary> /// <param name="paraClient">Para client</param> /// <param name="mcs">input margin collapsing state</param> /// <param name="fswdir">current direction (of the track, in which margin collapsing is happening)</param> /// <param name="suppressTopSpace">suppress empty space at the top of page</param> /// <param name="dvr">dvr, calculated based on margin collapsing state</param> internal override void CollapseMargin( BaseParaClient paraClient, // IN: MarginCollapsingState mcs, // IN: input margin collapsing state uint fswdir, // IN: current direction (of the track, in which margin collapsing is happening) bool suppressTopSpace, // IN: suppress empty space at the top of page out int dvr) // OUT: dvr, calculated based on margin collapsing state { if (suppressTopSpace && (StructuralCache.CurrentFormatContext.FinitePage || mcs == null)) dvr = 0; else { MbpInfo mbp = MbpInfo.FromElement(Table); MarginCollapsingState mcsOut = null; MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsOut, out dvr); if (mcsOut != null) { dvr = mcsOut.Margin; mcsOut.Dispose(); mcsOut = null; } } }
internal void RemoveFloatingParaClient(BaseParaClient floatingElement) { if(_floatingElementList.Contains(floatingElement)) { _floatingElementList.Remove(floatingElement); } if(_floatingElementList.Count == 0) { _floatingElementList = null; } }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal UIElementParagraphResult(BaseParaClient paraClient) : base(paraClient) { }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal ParagraphResult(BaseParaClient paraClient) { _paraClient = paraClient; _layoutBox = _paraClient.Rect.FromTextDpi(); _element = paraClient.Paragraph.Element; }
//------------------------------------------------------------------- // CollapseMargin //------------------------------------------------------------------- internal override void CollapseMargin( BaseParaClient paraClient, // IN: MarginCollapsingState mcs, // IN: input margin collapsing state uint fswdir, // IN: current direction (of the track, in which margin collapsing is happening) bool suppressTopSpace, // IN: suppress empty space at the top of page out int dvr) // OUT: dvr, calculated based on margin collapsing state { MbpInfo mbp = MbpInfo.FromElement(Element); MarginCollapsingState mcsNew; int margin; MarginCollapsingState.CollapseTopMargin(PtsContext, mbp, mcs, out mcsNew, out margin); if (suppressTopSpace) { dvr = 0; } else { dvr = margin; if (mcsNew != null) { dvr += mcsNew.Margin; } } if (mcsNew != null) { mcsNew.Dispose(); } }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal FloaterParagraphResult(BaseParaClient paraClient) : base(paraClient) { }
out IntPtr paraClientHandle); // OUT: opaque to PTS paragraph client //-------------------------------------------------------------------- // CollapseMargin //------------------------------------------------------------------- internal override abstract void CollapseMargin( BaseParaClient paraClient, // IN: MarginCollapsingState mcs, // IN: input margin collapsing state uint fswdir, // IN: current direction (of the track, in which margin collapsing is happening) bool suppressTopSpace, // IN: suppress empty space at the top of page out int dvr); // OUT: dvr, calculated based on margin collapsing state
/// <summary> /// Validate visual node associated with paragraph. /// </summary> /// <param name="fskupdInherited"> /// Inherited update info /// </param> internal override void ValidateVisual(PTS.FSKUPDATE fskupdInherited) { // Query paragraph details PTS.FSSUBTRACKDETAILS subtrackDetails; PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails)); // Draw border and background info. MbpInfo mbp = MbpInfo.FromElement(Paragraph.Element, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); if (ThisFlowDirection != PageFlowDirection) { mbp.MirrorBP(); } uint fswdir = PTS.FlowDirectionToFswdir((FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty)); Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty); // This textProperties object is eventually used in creation of LineProperties, which leads to creation of a TextMarkerSource. TextMarkerSource relies on PixelsPerDip // from TextProperties, therefore it must be set here properly. TextProperties textProperties = new TextProperties(Paragraph.Element, StaticTextPointer.Null, false /* inline objects */, false /* get background */, Paragraph.StructuralCache.TextFormatterHost.PixelsPerDip); // There might be possibility to get empty sub-track, skip the sub-track in such case. if (subtrackDetails.cParas != 0) { PTS.FSPARADESCRIPTION [] arrayParaDesc; PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc); using (DrawingContext ctx = _visual.RenderOpen()) { _visual.DrawBackgroundAndBorderIntoContext(ctx, backgroundBrush, mbp.BorderBrush, mbp.Border, _rect.FromTextDpi(), IsFirstChunk, IsLastChunk); // Get list of paragraphs ListMarkerLine listMarkerLine = new ListMarkerLine(Paragraph.StructuralCache.TextFormatterHost, this); int indexFirstParaInSubtrack = 0; for (int index = 0; index < subtrackDetails.cParas; index++) { List list = Paragraph.Element as List; BaseParaClient listItemParaClient = PtsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(listItemParaClient); if (index == 0) { indexFirstParaInSubtrack = list.GetListItemIndex(listItemParaClient.Paragraph.Element as ListItem); } if (listItemParaClient.IsFirstChunk) { int dvBaseline = listItemParaClient.GetFirstTextLineBaseline(); if (PageFlowDirection != ThisFlowDirection) { ctx.PushTransform(new MatrixTransform(-1.0, 0.0, 0.0, 1.0, TextDpi.FromTextDpi(2 * listItemParaClient.Rect.u + listItemParaClient.Rect.du), 0.0)); } int adjustedIndex; if (int.MaxValue - index < indexFirstParaInSubtrack) { adjustedIndex = int.MaxValue; } else { adjustedIndex = indexFirstParaInSubtrack + index; } LineProperties lineProps = new LineProperties(Paragraph.Element, Paragraph.StructuralCache.FormattingOwner, textProperties, new MarkerProperties(list, adjustedIndex)); listMarkerLine.FormatAndDrawVisual(ctx, lineProps, listItemParaClient.Rect.u, dvBaseline); if (PageFlowDirection != ThisFlowDirection) { ctx.Pop(); } } } listMarkerLine.Dispose(); } // Render list of paragraphs PtsHelper.UpdateParaListVisuals(PtsContext, _visual.Children, fskupdInherited, arrayParaDesc); } else { _visual.Children.Clear(); } }
private ReadOnlyCollection <ParagraphResult> GetChildrenParagraphResults(out bool hasTextContent) { List <ParagraphResult> paragraphResults; // Query subpage details PTS.FSSUBPAGEDETAILS subpageDetails; PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails)); // hasTextContent is set to true if any of the children paragraphs has text content, not just attached objects hasTextContent = false; // Subpage content may be simple or complex - // depending of set of features used in the content of the page. // (1) simple subpage (contains only one track) // (2) complex subpage (contains columns) if (PTS.ToBoolean(subpageDetails.fSimple)) { // (1) simple subpage (contains only one track) // Get track details PTS.FSTRACKDETAILS trackDetails; PTS.Validate(PTS.FsQueryTrackDetails(PtsContext.Context, subpageDetails.u.simple.trackdescr.pfstrack, out trackDetails)); hasTextContent = true; if (trackDetails.cParas == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } // Get list of paragraphs PTS.FSPARADESCRIPTION[] arrayParaDesc; PtsHelper.ParaListFromTrack(PtsContext, subpageDetails.u.simple.trackdescr.pfstrack, ref trackDetails, out arrayParaDesc); paragraphResults = new List <ParagraphResult>(arrayParaDesc.Length); for (int i = 0; i < arrayParaDesc.Length; i++) { BaseParaClient paraClient = PtsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(paraClient); ParagraphResult paragraphResult = paraClient.CreateParagraphResult(); if (paragraphResult.HasTextContent) { hasTextContent = true; } paragraphResults.Add(paragraphResult); } } else { // (2) complex page (contains columns) // cBasicColumns == 0, means that subpage content is empty if (subpageDetails.u.complex.cBasicColumns == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } // Retrieve description for each column. PTS.FSTRACKDESCRIPTION[] arrayColumnDesc; PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); Debug.Assert(arrayColumnDesc.Length == 1); // Get track details PTS.FSTRACKDETAILS trackDetails; PTS.Validate(PTS.FsQueryTrackDetails(PtsContext.Context, arrayColumnDesc[0].pfstrack, out trackDetails)); if (trackDetails.cParas == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } // Get list of paragraphs PTS.FSPARADESCRIPTION[] arrayParaDesc; PtsHelper.ParaListFromTrack(PtsContext, arrayColumnDesc[0].pfstrack, ref trackDetails, out arrayParaDesc); paragraphResults = new List <ParagraphResult>(arrayParaDesc.Length); for (int i = 0; i < arrayParaDesc.Length; i++) { BaseParaClient paraClient = PtsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(paraClient); ParagraphResult paragraphResult = paraClient.CreateParagraphResult(); if (paragraphResult.HasTextContent) { hasTextContent = true; } paragraphResults.Add(paragraphResult); } } return(new ReadOnlyCollection <ParagraphResult>(paragraphResults)); }
/// <summary> /// Collapse margins /// </summary> /// <param name="paraClient"> /// IN: Paragraph's para client /// </param> /// <param name="mcs"> /// IN: input margin collapsing state /// </param> /// <param name="fswdir"> /// IN: current direction (of the track, in which margin collapsing is happening) /// </param> /// <param name="suppressTopSpace"> /// IN: suppress empty space at the top of page /// </param> /// <param name="dvr"> /// OUT: dvr, calculated based on margin collapsing state /// </param> internal virtual void CollapseMargin( BaseParaClient paraClient, MarginCollapsingState mcs, uint fswdir, bool suppressTopSpace, out int dvr) { // Suppress top space only in paginated scenarios. dvr = (mcs == null || (suppressTopSpace)) ? 0 : mcs.Margin; }
/// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> /// <param name="layoutBox">Layout box for paragraph.</param> /// <param name="element">Element associated with this paragraph result.</param> internal ParagraphResult(BaseParaClient paraClient, Rect layoutBox, DependencyObject element) : this(paraClient) { _layoutBox = layoutBox; _element = element; }
// ------------------------------------------------------------------ // Transfer display related information from another ParaClient. // // oldParaClient - another ParaClient // ------------------------------------------------------------------ internal void TransferDisplayInfo(BaseParaClient oldParaClient) { Debug.Assert(oldParaClient._visual != null); // Transfer visual node ownership _visual = oldParaClient._visual; oldParaClient._visual = null; }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> internal TableParagraphResult(BaseParaClient paraClient) : base(paraClient) { }
internal void AddFloatingParaClient(BaseParaClient floatingElement) { if(_floatingElementList == null) { _floatingElementList = new List<BaseParaClient>(); } if(!_floatingElementList.Contains(floatingElement)) { _floatingElementList.Add(floatingElement); } }
//------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors /// <summary> /// Constructor. /// </summary> /// <param name="paraClient">Object representing a paragraph.</param> /// <param name="index">Index of row in paragraph.</param> /// <param name="rowRect">Rectangle of row - as rendered.</param> /// <param name="rowParagraph">Actual paragraph result is bound to.</param> internal RowParagraphResult(BaseParaClient paraClient, int index, Rect rowRect, RowParagraph rowParagraph) : base(paraClient, rowRect, rowParagraph.Element) { _index = index; }
internal LineBase(BaseParaClient paraClient) : base(paraClient.PtsContext) { _paraClient = paraClient; }
private ReadOnlyCollection <ParagraphResult> GetChildrenParagraphResults(out bool hasTextContent) { PTS.FSSUBPAGEDETAILS fssubpagedetails; PTS.Validate(PTS.FsQuerySubpageDetails(base.PtsContext.Context, this._paraHandle.Value, out fssubpagedetails)); hasTextContent = false; List <ParagraphResult> list; if (PTS.ToBoolean(fssubpagedetails.fSimple)) { PTS.FSTRACKDETAILS fstrackdetails; PTS.Validate(PTS.FsQueryTrackDetails(base.PtsContext.Context, fssubpagedetails.u.simple.trackdescr.pfstrack, out fstrackdetails)); if (fstrackdetails.cParas == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } PTS.FSPARADESCRIPTION[] array; PtsHelper.ParaListFromTrack(base.PtsContext, fssubpagedetails.u.simple.trackdescr.pfstrack, ref fstrackdetails, out array); list = new List <ParagraphResult>(array.Length); for (int i = 0; i < array.Length; i++) { BaseParaClient baseParaClient = base.PtsContext.HandleToObject(array[i].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(baseParaClient); ParagraphResult paragraphResult = baseParaClient.CreateParagraphResult(); if (paragraphResult.HasTextContent) { hasTextContent = true; } list.Add(paragraphResult); } } else { if (fssubpagedetails.u.complex.cBasicColumns == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } PTS.FSTRACKDESCRIPTION[] array2; PtsHelper.TrackListFromSubpage(base.PtsContext, this._paraHandle.Value, ref fssubpagedetails, out array2); PTS.FSTRACKDETAILS fstrackdetails2; PTS.Validate(PTS.FsQueryTrackDetails(base.PtsContext.Context, array2[0].pfstrack, out fstrackdetails2)); if (fstrackdetails2.cParas == 0) { return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0))); } PTS.FSPARADESCRIPTION[] array3; PtsHelper.ParaListFromTrack(base.PtsContext, array2[0].pfstrack, ref fstrackdetails2, out array3); list = new List <ParagraphResult>(array3.Length); for (int j = 0; j < array3.Length; j++) { BaseParaClient baseParaClient2 = base.PtsContext.HandleToObject(array3[j].pfsparaclient) as BaseParaClient; PTS.ValidateHandle(baseParaClient2); ParagraphResult paragraphResult2 = baseParaClient2.CreateParagraphResult(); if (paragraphResult2.HasTextContent) { hasTextContent = true; } list.Add(paragraphResult2); } } return(new ReadOnlyCollection <ParagraphResult>(list)); }