// Token: 0x06006609 RID: 26121 RVA: 0x001CB1DC File Offset: 0x001C93DC
        private TextRun HandleInlineObject(StaticTextPointer position, int dcp)
        {
            DependencyObject dependencyObject = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
            TextRun          result;

            if (dependencyObject is UIElement)
            {
                TextRunProperties textProps = new TextProperties(dependencyObject, position, true, true, base.PixelsPerDip);
                result = new InlineObject(dcp, TextContainerHelper.EmbeddedObjectLength, (UIElement)dependencyObject, textProps, this._owner);
            }
            else
            {
                result = this.HandleElementEndEdge(position);
            }
            return(result);
        }
Esempio n. 2
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        // ------------------------------------------------------------------
        // Fetch the next run at text position.
        //
        //      position - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleText(StaticTextPointer position)
        {
            DependencyObject  element;
            StaticTextPointer endOfRunPosition;

            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text, "TextPointer does not point to characters.");
            if (position.Parent != null)
            {
                element = position.Parent;
            }
            else
            {
                element = _owner;
            }

            // Extract the aggregated properties into something that the textrun can use.
            //



            TextRunProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */);

            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            endOfRunPosition = _owner.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Note the actual number of characters copied,
            // which may be different than the buffer's length. Buffer length only specifies the maximum
            // number of characters
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);

            // Create text run, using characters copied as length
            return(new TextCharacters(textBuffer, 0, charactersCopied, textProps));
        }
Esempio n. 3
0
        // ------------------------------------------------------------------
        // Fetch the next run at UIElment position.
        //
        //      position - current position in the text array
        //      dcp - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleInlineObject(StaticTextPointer position, int dcp)
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");

            TextRun          run     = null;
            DependencyObject element = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;

            if (element is UIElement)
            {
                //  Need to Handle visibility collapsed.

                TextRunProperties textProps = new TextProperties(element, position, true /* inline objects */, true /* get background */, PixelsPerDip);

                // Create object run.
                run = new InlineObject(dcp, TextContainerHelper.EmbeddedObjectLength, (UIElement)element, textProps, _owner);
            }
            else
            {
                // If the embedded object is of an unknown type (not UIElement),
                // treat it as element edge.
                run = HandleElementEndEdge(position);
            }
            return(run);
        }
        // Token: 0x06006606 RID: 26118 RVA: 0x001CAF70 File Offset: 0x001C9170
        private TextRun HandleText(StaticTextPointer position)
        {
            DependencyObject target;

            if (position.Parent != null)
            {
                target = position.Parent;
            }
            else
            {
                target = this._owner;
            }
            TextRunProperties textRunProperties = new TextProperties(target, position, false, true, base.PixelsPerDip);
            StaticTextPointer position2         = this._owner.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            if (position.GetOffsetToPosition(position2) > 4096)
            {
                position2 = position.CreatePointer(4096);
            }
            char[] array     = new char[position.GetOffsetToPosition(position2)];
            int    textInRun = position.GetTextInRun(LogicalDirection.Forward, array, 0, array.Length);

            return(new TextCharacters(array, 0, textInRun, textRunProperties));
        }
        // Copy constructor, with override for default TextDecorationCollection value.
        internal TextProperties(TextProperties source, TextDecorationCollection textDecorations)
        {
            _backgroundBrush = source._backgroundBrush;
            _typeface = source._typeface;
            _fontSize = source._fontSize;
            _foreground = source._foreground;
            _textEffects = source._textEffects;
            _cultureInfo = source._cultureInfo;
            _numberSubstitution = source._numberSubstitution;
            _typographyProperties = source._typographyProperties;
            _baselineAlignment = source._baselineAlignment;

            _textDecorations = textDecorations;
        }
Esempio n. 6
0
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Fetch the next run at text position.
        /// </summary>
        private TextRun HandleText(StaticTextPointer position)
        {
            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            StaticTextPointer endOfRunPosition = _owner.Host.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            // Factor in any speller error squiggles on the run.
            TextDecorationCollection highlightDecorations = position.TextContainer.Highlights.GetHighlightValue(position, LogicalDirection.Forward, typeof(SpellerHighlightLayer)) as TextDecorationCollection;
            TextRunProperties properties;

            if (highlightDecorations == null)
            {
                properties = _lineProperties.DefaultTextRunProperties;
            }
            else
            {
                if (_spellerErrorProperties == null)
                {
                    _spellerErrorProperties = new TextProperties((TextProperties)_lineProperties.DefaultTextRunProperties, highlightDecorations);
                }
                properties = _spellerErrorProperties;
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Since we are dealing with plain text content, 
            // we expect to get all the characters from position to endOfRunPosition.
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);
            Invariant.Assert(charactersCopied == textBuffer.Length);

            // Create text run, using characters copied as length
            return new TextCharacters(textBuffer, 0, charactersCopied, properties);
        }
Esempio n. 7
0
        // -----------------------------------------------------------------
        // Fetch the next run at UIElment position. 
        // 
        //      position - current position in the text array
        //      dcp - current position in the text array 
        // -----------------------------------------------------------------
        private TextRun HandleInlineObject(StaticTextPointer position, int dcp)
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object."); 

            TextRun run = null; 
            DependencyObject element = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject; 
            if (element is UIElement)
            { 
                //


                TextRunProperties textProps = new TextProperties(element, position, true /* inline objects */, true /* get background */); 

                // Create object run. 
                run = new InlineObject(dcp, TextContainerHelper.EmbeddedObjectLength, (UIElement)element, textProps, _owner); 
            }
            else 
            {
                // If the embedded object is of an unknown type (not UIElement),
                // treat it as element edge.
                run = HandleElementEndEdge(position); 
            }
            return run; 
        } 
Esempio n. 8
0
        // ------------------------------------------------------------------
        // Fetch the next run at element open edge position. 
        //
        //      position - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleElementStartEdge(StaticTextPointer position) 
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge."); 
 
            //
 
            TextRun run = null;
            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
            Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");
 
            if (element is LineBreak)
            { 
                run = new TextEndOfLine(_elementEdgeCharacterLength * 2); 
            }
            else if (element.IsEmpty) 
            {
                // Empty TextElement should affect line metrics.
                // TextFormatter does not support this feature right now, so as workaround
                // TextRun with ZERO WIDTH SPACE is used. 
                TextRunProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */);
                char[] textBuffer = new char[_elementEdgeCharacterLength * 2]; 
                textBuffer[0] = (char)0x200B; 
                textBuffer[1] = (char)0x200B;
                run = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps); 
            }
            else
            {
                Inline inline = element as Inline; 
                if (inline == null)
                { 
                    run = new TextHidden(_elementEdgeCharacterLength); 
                }
                else 
                {
                    DependencyObject parent = inline.Parent;
                    FlowDirection inlineFlowDirection = inline.FlowDirection;
                    FlowDirection parentFlowDirection = inlineFlowDirection; 

                    if(parent != null) 
                    { 
                        parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                    } 

                    TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);

                    if (inlineFlowDirection != parentFlowDirection) 
                    {
                        // Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction 
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0) 
                        {
                            run = new TextSpanModifier( 
                                _elementEdgeCharacterLength,
                                null,
                                null,
                                inlineFlowDirection 
                                );
                        } 
                        else 
                        {
                            run = new TextSpanModifier( 
                                _elementEdgeCharacterLength,
                                inlineTextDecorations,
                                inline.Foreground,
                                inlineFlowDirection 
                                );
                        } 
                    } 
                    else
                    { 
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                        {
                            run = new TextHidden(_elementEdgeCharacterLength);
                        } 
                        else
                        { 
                            run = new TextSpanModifier( 
                                _elementEdgeCharacterLength,
                                inlineTextDecorations, 
                                inline.Foreground
                                );
                        }
                    } 
                }
            } 
            return run; 
        }
Esempio n. 9
0
        // Reads the current (interesting) property values on the owning TextBox.
        private LineProperties GetLineProperties()
        {
            TextProperties defaultTextProperties = new TextProperties((Control)_host, _host.IsTypographyDefaultValue);

            // Pass page width and height as double.MaxValue when creating LineProperties, since TextBox does not restrict
            // TextIndent or LineHeight.
            return new LineProperties((Control)_host, (Control)_host, defaultTextProperties, null, this.CalculatedTextAlignment);
        }
 // Token: 0x06006660 RID: 26208 RVA: 0x001CC120 File Offset: 0x001CA320
 internal LineProperties(DependencyObject element, DependencyObject contentHost, TextProperties defaultTextProperties, MarkerProperties markerProperties, TextAlignment textAlignment)
 {
     this._defaultTextProperties = defaultTextProperties;
     this._markerProperties      = ((markerProperties != null) ? markerProperties.GetTextMarkerProperties(this) : null);
     this._flowDirection         = (FlowDirection)element.GetValue(Block.FlowDirectionProperty);
     this._textAlignment         = textAlignment;
     this._lineHeight            = (double)element.GetValue(Block.LineHeightProperty);
     this._textIndent            = (double)element.GetValue(Paragraph.TextIndentProperty);
     this._lineStackingStrategy  = (LineStackingStrategy)element.GetValue(Block.LineStackingStrategyProperty);
     this._textWrapping          = TextWrapping.Wrap;
     this._textTrimming          = TextTrimming.None;
     if (contentHost is TextBlock || contentHost is ITextBoxViewHost)
     {
         this._textWrapping = (TextWrapping)contentHost.GetValue(TextBlock.TextWrappingProperty);
         this._textTrimming = (TextTrimming)contentHost.GetValue(TextBlock.TextTrimmingProperty);
         return;
     }
     if (contentHost is FlowDocument)
     {
         this._textWrapping = ((FlowDocument)contentHost).TextWrapping;
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Fetch the next run at embedded object position. 
        /// </summary>
        /// <param name="dcp">
        /// Character offset of this run.
        /// </param>
        /// <param name="position">
        /// Current position in the text array.
        /// </param>
        protected TextRun HandleEmbeddedObject(int dcp, StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement, "TextPointer does not point to embedded object.");

            TextRun run = null;
            DependencyObject embeddedObject = position.GetAdjacentElement(LogicalDirection.Forward) as DependencyObject;
            if (embeddedObject is UIElement)
            {
                // Extract the aggregated properties into something that the textrun can use.
                TextRunProperties textProps = new TextProperties(embeddedObject, position, true /* inline objects */, true /* get background */);

                // Create inline object run.
                run = new InlineObjectRun(TextContainerHelper.EmbeddedObjectLength, (UIElement)embeddedObject, textProps, _paraClient.Paragraph as TextParagraph);
            }
            else
            {
                // If the embedded object is of an unknown type, treat it as hidden content.
                run = new TextHidden(TextContainerHelper.EmbeddedObjectLength);
            }
            return run;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        internal LineProperties(
            DependencyObject element,
            DependencyObject contentHost,
            TextProperties defaultTextProperties,
            MarkerProperties markerProperties,
            TextAlignment textAlignment)
        {
            _defaultTextProperties = defaultTextProperties;
            _markerProperties = (markerProperties != null) ? markerProperties.GetTextMarkerProperties(this) : null;

            _flowDirection = (FlowDirection)element.GetValue(Block.FlowDirectionProperty);
            _textAlignment = textAlignment;
            _lineHeight = (double)element.GetValue(Block.LineHeightProperty);
            _textIndent = (double)element.GetValue(Paragraph.TextIndentProperty);
            _lineStackingStrategy = (LineStackingStrategy)element.GetValue(Block.LineStackingStrategyProperty);

            _textWrapping = TextWrapping.Wrap;
            _textTrimming = TextTrimming.None;

            if (contentHost is TextBlock || contentHost is ITextBoxViewHost)
            {
                // NB: we intentially don't try to find the "PropertyOwner" of
                // a FlowDocument here.  TextWrapping has a hard-coded
                // value SetValue'd when a FlowDocument is hosted by a TextBoxBase.
                _textWrapping = (TextWrapping)contentHost.GetValue(TextBlock.TextWrappingProperty);
                _textTrimming = (TextTrimming)contentHost.GetValue(TextBlock.TextTrimmingProperty);
            }
            else if (contentHost is FlowDocument)
            {
                _textWrapping = ((FlowDocument)contentHost).TextWrapping;
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 internal LineProperties(
     DependencyObject element,
     DependencyObject contentHost,
     TextProperties defaultTextProperties,
     MarkerProperties markerProperties)
     : this(element, contentHost, defaultTextProperties, markerProperties, (TextAlignment)element.GetValue(Block.TextAlignmentProperty))
 {
 }
Esempio n. 14
0
        // ------------------------------------------------------------------
        // Refetch and cache line properties, if needed.
        // ------------------------------------------------------------------
        private LineProperties GetLineProperties()
        {
            // For default text properties always set background to null.
            // REASON: If element associated with the text run is TextBlock element, ignore background
            //         brush, because it is handled outside as FrameworkElement's background.

            TextProperties defaultTextProperties = new TextProperties(this, this.IsTypographyDefaultValue);

            // Do not allow hyphenation for plain Text so always pass null for IHyphenate.
            // Pass page width and height as double.MaxValue when creating LineProperties, since TextBlock does not restrict
            // TextIndent or LineHeight
            LineProperties lineProperties = new LineProperties(this, this, defaultTextProperties, null);

            bool isHyphenationEnabled = (bool) this.GetValue(IsHyphenationEnabledProperty);
            if(isHyphenationEnabled)
            {
                lineProperties.Hyphenator = EnsureHyphenator();
            }


            return lineProperties;

        }
Esempio n. 15
0
        // ------------------------------------------------------------------
        // Fetch the next run at element open edge position.
        //
        //      position - current position in the text array
        // ------------------------------------------------------------------
        private TextRun HandleElementStartEdge(StaticTextPointer position)
        {
            Debug.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");

            //

            TextRun     run     = null;
            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);

            Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");

            if (element is LineBreak)
            {
                run = new TextEndOfLine(_elementEdgeCharacterLength * 2);
            }
            else if (element.IsEmpty)
            {
                // Empty TextElement should affect line metrics.
                // TextFormatter does not support this feature right now, so as workaround
                // TextRun with ZERO WIDTH SPACE is used.
                TextRunProperties textProps  = new TextProperties(element, position, false /* inline objects */, true /* get background */);
                char[]            textBuffer = new char[_elementEdgeCharacterLength * 2];
                textBuffer[0] = (char)0x200B;
                textBuffer[1] = (char)0x200B;
                run           = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps);
            }
            else
            {
                Inline inline = element as Inline;
                if (inline == null)
                {
                    run = new TextHidden(_elementEdgeCharacterLength);
                }
                else
                {
                    DependencyObject parent = inline.Parent;
                    FlowDirection    inlineFlowDirection = inline.FlowDirection;
                    FlowDirection    parentFlowDirection = inlineFlowDirection;

                    if (parent != null)
                    {
                        parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                    }

                    TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);

                    if (inlineFlowDirection != parentFlowDirection)
                    {
                        // Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                null,
                                null,
                                inlineFlowDirection
                                );
                        }
                        else
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                inlineTextDecorations,
                                inline.Foreground,
                                inlineFlowDirection
                                );
                        }
                    }
                    else
                    {
                        if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                        {
                            run = new TextHidden(_elementEdgeCharacterLength);
                        }
                        else
                        {
                            run = new TextSpanModifier(
                                _elementEdgeCharacterLength,
                                inlineTextDecorations,
                                inline.Foreground
                                );
                        }
                    }
                }
            }
            return(run);
        }
Esempio n. 16
0
        /// <summary>
        /// Return next TextRun at element edge start position
        /// </summary>
        /// <param name="position">
        /// Current position in text array
        /// </param>
        protected TextRun HandleElementStartEdge(StaticTextPointer position)
        {
            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart, "TextPointer does not point to element start edge.");

            // 

            TextRun run = null;
            TextElement element = (TextElement)position.GetAdjacentElement(LogicalDirection.Forward);
            Debug.Assert(element != null, "Cannot use ITextContainer that does not provide TextElement instances.");

            Invariant.Assert(!(element is Block), "We do not expect any Blocks inside Paragraphs");

            // Treat figure and floaters as special hidden runs.
            if (element is Figure || element is Floater)
            {
                // Get the length of the element
                int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
                // Create special hidden run.
                run = new FloatingRun(cch, element is Figure);
                if (element is Figure)
                {
                    _hasFigures = true;
                }
                else
                {
                    _hasFloaters = true;
                }
            }
            else if (element is LineBreak)
            {
                int cch = TextContainerHelper.GetElementLength(_paraClient.Paragraph.StructuralCache.TextContainer, element);
                run = new LineBreakRun(cch, PTS.FSFLRES.fsflrSoftBreak);
            }
            else if (element.IsEmpty)
            {
                // Empty TextElement should affect line metrics.
                // TextFormatter does not support this feature right now, so as workaround
                // TextRun with ZERO WIDTH SPACE is used.
                TextProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */);

                char[] textBuffer = new char[_elementEdgeCharacterLength * 2];
                
                // Assert that _elementEdgeCharacterLength is 1 before we use hard-coded indices
                Invariant.Assert(_elementEdgeCharacterLength == 1, "Expected value of _elementEdgeCharacterLength is 1");

                textBuffer[0] = (char)0x200B;
                textBuffer[1] = (char)0x200B;

                run = new TextCharacters(textBuffer, 0, textBuffer.Length, textProps);
            }
            else
            {
                Inline inline = (Inline) element;
                DependencyObject parent = inline.Parent;

                FlowDirection inlineFlowDirection = inline.FlowDirection;
                FlowDirection parentFlowDirection = inlineFlowDirection;

                TextDecorationCollection inlineTextDecorations = DynamicPropertyReader.GetTextDecorations(inline);

                if(parent != null)
                {
                    parentFlowDirection = (FlowDirection)parent.GetValue(FrameworkElement.FlowDirectionProperty);
                }

                if (inlineFlowDirection != parentFlowDirection)
                {
                    // Inline's flow direction is different from its parent. Need to create new TextSpanModifier with flow direction
                    if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            null,
                            null,
                            inlineFlowDirection
                            );
                    }
                    else
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            inlineTextDecorations,
                            inline.Foreground,
                            inlineFlowDirection
                            );
                    }
                }
                else
                {
                    if (inlineTextDecorations == null || inlineTextDecorations.Count == 0)
                    {
                        run = new TextHidden(_elementEdgeCharacterLength);
                    }
                    else
                    {
                        run = new TextSpanModifier(
                            _elementEdgeCharacterLength,
                            inlineTextDecorations,
                            inline.Foreground
                            );
                    }
                }
            }
            return run;
        }
Esempio n. 17
0
        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); 
            if (ThisFlowDirection != PageFlowDirection)
            {
                mbp.MirrorBP();
            } 

            uint fswdir = PTS.FlowDirectionToFswdir((FlowDirection)Paragraph.Element.GetValue(FrameworkElement.FlowDirectionProperty)); 
 
            Brush backgroundBrush = (Brush)Paragraph.Element.GetValue(TextElement.BackgroundProperty);
 
            TextProperties textProperties = new TextProperties(Paragraph.Element, StaticTextPointer.Null, false /* inline objects */, false /* get background */);

            // 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();
            } 

        } 
Esempio n. 18
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// Fetch the next run at text position. 
        /// </summary>
        /// <param name="position">
        /// Current position in text array
        /// </param>
        /// <returns></returns>
        protected TextRun HandleText(StaticTextPointer position)
        {
            DependencyObject element;
            StaticTextPointer endOfRunPosition;

            Invariant.Assert(position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text, "TextPointer does not point to characters.");

            if (position.Parent != null)
            {
                element = position.Parent;
            }
            else
            {
                element = _paraClient.Paragraph.Element;
            }

            // Extract the aggregated properties into something that the textrun can use.
            // 


            TextProperties textProps = new TextProperties(element, position, false /* inline objects */, true /* get background */);

            // Calculate the end of the run by finding either:
            //      a) the next intersection of highlight ranges, or
            //      b) the natural end of this textrun
            endOfRunPosition = position.TextContainer.Highlights.GetNextPropertyChangePosition(position, LogicalDirection.Forward);

            // Clamp the text run at an arbitrary limit, so we don't make
            // an unbounded allocation.
            if (position.GetOffsetToPosition(endOfRunPosition) > 4096)
            {
                endOfRunPosition = position.CreatePointer(4096);
            }

            // Get character buffer for the text run.
            char[] textBuffer = new char[position.GetOffsetToPosition(endOfRunPosition)];

            // Copy characters from text run into buffer. Note the actual number of characters copied,
            // which may be different than the buffer's length. Buffer length only specifies the maximum
            // number of characters
            int charactersCopied = position.GetTextInRun(LogicalDirection.Forward, textBuffer, 0, textBuffer.Length);

            // Create text run using the actual number of characters copied
            return new TextCharacters(textBuffer, 0, charactersCopied, textProps);
        }
 // Token: 0x0600665F RID: 26207 RVA: 0x001CC103 File Offset: 0x001CA303
 internal LineProperties(DependencyObject element, DependencyObject contentHost, TextProperties defaultTextProperties, MarkerProperties markerProperties) : this(element, contentHost, defaultTextProperties, markerProperties, (TextAlignment)element.GetValue(Block.TextAlignmentProperty))
 {
 }