コード例 #1
0
        int IComparable.CompareTo(object comparedObj)
        {
            FixedSOMTextRun otherRun = comparedObj as FixedSOMTextRun;

            Debug.Assert(otherRun != null);
            int result = 0;

            if (_fixedBlock.IsRTL)
            {
                Rect thisRect  = this.BoundingRect;
                Rect otherRect = otherRun.BoundingRect;

                if (!this.Matrix.IsIdentity)
                {
                    Matrix inversionMat = _mat;
                    inversionMat.Invert();
                    thisRect.Transform(inversionMat);
                    thisRect.Offset(_mat.OffsetX, _mat.OffsetY);

                    otherRect.Transform(inversionMat);
                    otherRect.Offset(_mat.OffsetX, _mat.OffsetY);
                }

                thisRect.Offset(_mat.OffsetX, _mat.OffsetY);
                otherRect.Offset(otherRun.Matrix.OffsetX, otherRun.Matrix.OffsetY);

                if (FixedTextBuilder.IsSameLine(otherRect.Top - thisRect.Top, thisRect.Height, otherRect.Height))
                {
                    result = (thisRect.Left < otherRect.Left) ? 1 : -1;
                }
                else
                {
                    result = (thisRect.Top < otherRect.Top) ? -1 : +1;
                }
            }

            else
            {
                //Markup order for LTR languages

                List <FixedNode> markupOrder = this.FixedBlock.FixedSOMPage.MarkupOrder;
                result = markupOrder.IndexOf(this.FixedNode) - markupOrder.IndexOf(otherRun.FixedNode);
            }

            return(result);
        }
コード例 #2
0
        // Token: 0x06002E36 RID: 11830 RVA: 0x000D0CC4 File Offset: 0x000CEEC4
        int IComparable.CompareTo(object comparedObj)
        {
            FixedSOMTextRun fixedSOMTextRun = comparedObj as FixedSOMTextRun;
            int             result;

            if (this._fixedBlock.IsRTL)
            {
                Rect boundingRect  = base.BoundingRect;
                Rect boundingRect2 = fixedSOMTextRun.BoundingRect;
                if (!base.Matrix.IsIdentity)
                {
                    Matrix mat = this._mat;
                    mat.Invert();
                    boundingRect.Transform(mat);
                    boundingRect.Offset(this._mat.OffsetX, this._mat.OffsetY);
                    boundingRect2.Transform(mat);
                    boundingRect2.Offset(this._mat.OffsetX, this._mat.OffsetY);
                }
                boundingRect.Offset(this._mat.OffsetX, this._mat.OffsetY);
                boundingRect2.Offset(fixedSOMTextRun.Matrix.OffsetX, fixedSOMTextRun.Matrix.OffsetY);
                if (FixedTextBuilder.IsSameLine(boundingRect2.Top - boundingRect.Top, boundingRect.Height, boundingRect2.Height))
                {
                    result = ((boundingRect.Left < boundingRect2.Left) ? 1 : -1);
                }
                else
                {
                    result = ((boundingRect.Top < boundingRect2.Top) ? -1 : 1);
                }
            }
            else
            {
                List <FixedNode> markupOrder = this.FixedBlock.FixedSOMPage.MarkupOrder;
                result = markupOrder.IndexOf(base.FixedNode) - markupOrder.IndexOf(fixedSOMTextRun.FixedNode);
            }
            return(result);
        }
コード例 #3
0
        private bool _IsCombinable(FixedSOMFixedBlock fixedBlock, FixedSOMTextRun textRun)
        {
            Debug.Assert(fixedBlock.SemanticBoxes.Count > 0);
            if (fixedBlock.SemanticBoxes.Count == 0)
            {
                return(false);
            }

            //Currently we do not support inline images
            if (fixedBlock.IsFloatingImage)
            {
                return(false);
            }

            Rect textRunRect    = textRun.BoundingRect;
            Rect fixedBlockRect = fixedBlock.BoundingRect;

            FixedSOMTextRun compareLine = null;
            FixedSOMTextRun lastLine    = fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMTextRun;

            if (lastLine != null && textRunRect.Bottom <= lastLine.BoundingRect.Top)
            {
                //This run is above the last run of the fixed block. Can't be the same paragraph
                return(false);
            }

            bool fixedBlockBelow = false;
            bool textRunBelow    = false;
            //Allow 20% overlap
            double verticalOverlap = textRunRect.Height * 0.2;

            if (textRunRect.Bottom - verticalOverlap < fixedBlockRect.Top)
            {
                fixedBlockBelow = true;
                compareLine     = fixedBlock.SemanticBoxes[0] as FixedSOMTextRun;
            }
            else if (textRunRect.Top + verticalOverlap > fixedBlockRect.Bottom)
            {
                textRunBelow = true;
                compareLine  = fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMTextRun;
            }

            if ((fixedBlock.IsWhiteSpace || textRun.IsWhiteSpace) &&
                (fixedBlock != _currentFixedBlock || compareLine != null || !_IsSpatiallyCombinable(fixedBlockRect, textRunRect, textRun.DefaultCharWidth * 3, 0))
                )
            {
                //When combining with white spaces, they need to be consecutive in markup and need to be on the same line.
                return(false);
            }
            if (fixedBlock.Matrix.M11 != textRun.Matrix.M11 ||
                fixedBlock.Matrix.M12 != textRun.Matrix.M12 ||
                fixedBlock.Matrix.M21 != textRun.Matrix.M21 ||
                fixedBlock.Matrix.M22 != textRun.Matrix.M22)
            {
                //We don't allow combining TextRuns with different scale/rotation properties
                return(false);
            }

            Debug.Assert(textRunRect.Height != 0 && fixedBlock.LineHeight != 0);

            //Rect textRunRect = textRun.BoundingRect;

            if (compareLine != null) //Most probably different lines
            {
                double ratio = fixedBlock.LineHeight / textRunRect.Height;
                if (ratio < 1.0)
                {
                    ratio = 1.0 / ratio;
                }
                //Allow 10% height difference
                if ((ratio > 1.1) &&
                    !(FixedTextBuilder.IsSameLine(compareLine.BoundingRect.Top - textRunRect.Top, textRunRect.Height, compareLine.BoundingRect.Height)))
                {
                    return(false);
                }
            }

            double width = textRun.DefaultCharWidth;

            if (width < 1.0)
            {
                width = 1.0;
            }

            double dHorInflate = 0;
            double heightRatio = fixedBlock.LineHeight / textRunRect.Height;

            if (heightRatio < 1.0)
            {
                heightRatio = 1.0 / heightRatio;
            }

            //If consecutive in markup and seem to be on the same line, almost discard horizontal distance
            if (fixedBlock == _currentFixedBlock &&
                compareLine == null &&
                heightRatio < 1.5
                )
            {
                dHorInflate = 200;
            }
            else
            {
                dHorInflate = width * 1.5;
            }

            if (!_IsSpatiallyCombinable(fixedBlockRect, textRunRect, dHorInflate, textRunRect.Height * 0.7))
            {
                return(false);
            }

            //If these two have originated from the same Glyphs element, this means we intentionally separated them (separated by vertical lines).
            //Don't combine in this case.
            FixedSOMElement element = fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMElement;

            if (element != null && element.FixedNode.CompareTo(textRun.FixedNode) == 0)
            {
                return(false);
            }

            //Are these seperated by a line? Check only if they are not considered overlapping
            if (fixedBlockBelow || textRunBelow)
            {
                double bottom = 0.0;
                double top    = 0.0;
                double margin = textRunRect.Height * 0.2;

                if (textRunBelow)
                {
                    top    = fixedBlockRect.Bottom - margin;
                    bottom = textRunRect.Top + margin;
                }
                else
                {
                    top    = textRunRect.Bottom - margin;
                    bottom = fixedBlockRect.Top + margin;
                }
                double left  = (fixedBlockRect.Left > textRunRect.Left) ? fixedBlockRect.Left : textRunRect.Left;
                double right = (fixedBlockRect.Right < textRunRect.Right) ? fixedBlockRect.Right: textRunRect.Right;
                return(!_lines.IsHorizontallySeparated(left, top, right, bottom));
            }
            else
            {
                //These two overlap vertically. Let's check whether there is a vertical separator in between
                double left  = (fixedBlockRect.Right < textRunRect.Right) ? fixedBlockRect.Right: textRunRect.Right;
                double right = (fixedBlockRect.Left > textRunRect.Left) ? fixedBlockRect.Left: textRunRect.Left;
                if (left > right)
                {
                    double temp = left;
                    left  = right;
                    right = temp;
                }
                return(!_lines.IsVerticallySeparated(left, textRunRect.Top, right, textRunRect.Bottom));
            }
        }
コード例 #4
0
        // Token: 0x06002DFC RID: 11772 RVA: 0x000CEDF0 File Offset: 0x000CCFF0
        private bool _IsCombinable(FixedSOMFixedBlock fixedBlock, FixedSOMTextRun textRun)
        {
            if (fixedBlock.SemanticBoxes.Count == 0)
            {
                return(false);
            }
            if (fixedBlock.IsFloatingImage)
            {
                return(false);
            }
            Rect            boundingRect     = textRun.BoundingRect;
            Rect            boundingRect2    = fixedBlock.BoundingRect;
            FixedSOMTextRun fixedSOMTextRun  = null;
            FixedSOMTextRun fixedSOMTextRun2 = fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMTextRun;

            if (fixedSOMTextRun2 != null && boundingRect.Bottom <= fixedSOMTextRun2.BoundingRect.Top)
            {
                return(false);
            }
            bool   flag  = false;
            bool   flag2 = false;
            double num   = boundingRect.Height * 0.2;

            if (boundingRect.Bottom - num < boundingRect2.Top)
            {
                flag            = true;
                fixedSOMTextRun = (fixedBlock.SemanticBoxes[0] as FixedSOMTextRun);
            }
            else if (boundingRect.Top + num > boundingRect2.Bottom)
            {
                flag2           = true;
                fixedSOMTextRun = (fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMTextRun);
            }
            if ((fixedBlock.IsWhiteSpace || textRun.IsWhiteSpace) && (fixedBlock != this._currentFixedBlock || fixedSOMTextRun != null || !this._IsSpatiallyCombinable(boundingRect2, boundingRect, textRun.DefaultCharWidth * 3.0, 0.0)))
            {
                return(false);
            }
            if (fixedBlock.Matrix.M11 != textRun.Matrix.M11 || fixedBlock.Matrix.M12 != textRun.Matrix.M12 || fixedBlock.Matrix.M21 != textRun.Matrix.M21 || fixedBlock.Matrix.M22 != textRun.Matrix.M22)
            {
                return(false);
            }
            if (fixedSOMTextRun != null)
            {
                double num2 = fixedBlock.LineHeight / boundingRect.Height;
                if (num2 < 1.0)
                {
                    num2 = 1.0 / num2;
                }
                if (num2 > 1.1 && !FixedTextBuilder.IsSameLine(fixedSOMTextRun.BoundingRect.Top - boundingRect.Top, boundingRect.Height, fixedSOMTextRun.BoundingRect.Height))
                {
                    return(false);
                }
            }
            double num3 = textRun.DefaultCharWidth;

            if (num3 < 1.0)
            {
                num3 = 1.0;
            }
            double num4 = fixedBlock.LineHeight / boundingRect.Height;

            if (num4 < 1.0)
            {
                num4 = 1.0 / num4;
            }
            double inflateH;

            if (fixedBlock == this._currentFixedBlock && fixedSOMTextRun == null && num4 < 1.5)
            {
                inflateH = 200.0;
            }
            else
            {
                inflateH = num3 * 1.5;
            }
            if (!this._IsSpatiallyCombinable(boundingRect2, boundingRect, inflateH, boundingRect.Height * 0.7))
            {
                return(false);
            }
            FixedSOMElement fixedSOMElement = fixedBlock.SemanticBoxes[fixedBlock.SemanticBoxes.Count - 1] as FixedSOMElement;

            if (fixedSOMElement != null && fixedSOMElement.FixedNode.CompareTo(textRun.FixedNode) == 0)
            {
                return(false);
            }
            if (flag || flag2)
            {
                double num5 = boundingRect.Height * 0.2;
                double top;
                double bottom;
                if (flag2)
                {
                    top    = boundingRect2.Bottom - num5;
                    bottom = boundingRect.Top + num5;
                }
                else
                {
                    top    = boundingRect.Bottom - num5;
                    bottom = boundingRect2.Top + num5;
                }
                double left  = (boundingRect2.Left > boundingRect.Left) ? boundingRect2.Left : boundingRect.Left;
                double right = (boundingRect2.Right < boundingRect.Right) ? boundingRect2.Right : boundingRect.Right;
                return(!this._lines.IsHorizontallySeparated(left, top, right, bottom));
            }
            double num6 = (boundingRect2.Right < boundingRect.Right) ? boundingRect2.Right : boundingRect.Right;
            double num7 = (boundingRect2.Left > boundingRect.Left) ? boundingRect2.Left : boundingRect.Left;

            if (FrameworkAppContextSwitches.OptOutOfFixedDocumentModelConstructionFix)
            {
                if (num6 > num7)
                {
                    double num8 = num6;
                    num6 = num7;
                    num7 = num8;
                }
                return(!this._lines.IsVerticallySeparated(num6, boundingRect.Top, num7, boundingRect.Bottom));
            }
            return(num6 >= num7 || !this._lines.IsVerticallySeparated(num6, boundingRect.Top, num7, boundingRect.Bottom));
        }