Esempio n. 1
0
        //--------------------------------------------------------------------
        //
        // Public methods
        //
        //---------------------------------------------------------------------

        public void AddContainer(FixedSOMPageElement pageElement)
        {
            FixedSOMFixedBlock block = pageElement as FixedSOMFixedBlock;

            if (block == null || (!block.IsFloatingImage && !block.IsWhiteSpace))
            {
                if (pageElement.IsRTL)
                {
                    _RTLCount++;
                }
                else
                {
                    _LTRCount++;
                }
            }

            _semanticBoxes.Add(pageElement);

            if (_boundingRect.IsEmpty)
            {
                _boundingRect = pageElement.BoundingRect;
            }
            else
            {
                _boundingRect.Union(pageElement.BoundingRect);
            }
        }
Esempio n. 2
0
        //Creates a set of groups inside this container based on heuristics.
        //This will ensure that elements consecutive in markup that also seem to be
        //spatially consecutive don't get separated
        private void _CreateGroups(FixedSOMContainer container)
        {
            if (container.SemanticBoxes.Count > 0)
            {
                List <FixedSOMSemanticBox> groups = new List <FixedSOMSemanticBox>();

                FixedSOMGroup       currentGroup       = new FixedSOMGroup(_fixedSOMPage);
                FixedSOMPageElement currentPageElement = container.SemanticBoxes[0] as FixedSOMPageElement;
                Debug.Assert(currentPageElement != null);

                FixedSOMPageElement nextPageElement = null;
                currentGroup.AddContainer(currentPageElement);

                groups.Add(currentGroup);

                for (int i = 1; i < container.SemanticBoxes.Count; i++)
                {
                    nextPageElement = container.SemanticBoxes[i] as FixedSOMPageElement;
                    Debug.Assert(nextPageElement != null);

                    if (!(_IsSpatiallyCombinable(currentPageElement, nextPageElement, 0, 30) &&
                          nextPageElement.BoundingRect.Top >= currentPageElement.BoundingRect.Top))
                    {
                        currentGroup = new FixedSOMGroup(_fixedSOMPage);
                        groups.Add(currentGroup);
                    }
                    currentGroup.AddContainer(nextPageElement);
                    currentPageElement = nextPageElement;
                }
                container.SemanticBoxes = groups;
            }
        }
        // Token: 0x06002DC3 RID: 11715 RVA: 0x000CDE50 File Offset: 0x000CC050
        public void AddContainer(FixedSOMPageElement pageElement)
        {
            FixedSOMFixedBlock fixedSOMFixedBlock = pageElement as FixedSOMFixedBlock;

            if (fixedSOMFixedBlock == null || (!fixedSOMFixedBlock.IsFloatingImage && !fixedSOMFixedBlock.IsWhiteSpace))
            {
                if (pageElement.IsRTL)
                {
                    this._RTLCount++;
                }
                else
                {
                    this._LTRCount++;
                }
            }
            this._semanticBoxes.Add(pageElement);
            if (this._boundingRect.IsEmpty)
            {
                this._boundingRect = pageElement.BoundingRect;
                return;
            }
            this._boundingRect.Union(pageElement.BoundingRect);
        }
Esempio n. 4
0
 // Token: 0x06002E06 RID: 11782 RVA: 0x000CFE64 File Offset: 0x000CE064
 private void _CreateGroups(FixedSOMContainer container)
 {
     if (container.SemanticBoxes.Count > 0)
     {
         List <FixedSOMSemanticBox> list         = new List <FixedSOMSemanticBox>();
         FixedSOMGroup       fixedSOMGroup       = new FixedSOMGroup(this._fixedSOMPage);
         FixedSOMPageElement fixedSOMPageElement = container.SemanticBoxes[0] as FixedSOMPageElement;
         fixedSOMGroup.AddContainer(fixedSOMPageElement);
         list.Add(fixedSOMGroup);
         for (int i = 1; i < container.SemanticBoxes.Count; i++)
         {
             FixedSOMPageElement fixedSOMPageElement2 = container.SemanticBoxes[i] as FixedSOMPageElement;
             if (!this._IsSpatiallyCombinable(fixedSOMPageElement, fixedSOMPageElement2, 0.0, 30.0) || fixedSOMPageElement2.BoundingRect.Top < fixedSOMPageElement.BoundingRect.Top)
             {
                 fixedSOMGroup = new FixedSOMGroup(this._fixedSOMPage);
                 list.Add(fixedSOMGroup);
             }
             fixedSOMGroup.AddContainer(fixedSOMPageElement2);
             fixedSOMPageElement = fixedSOMPageElement2;
         }
         container.SemanticBoxes = list;
     }
 }
Esempio n. 5
0
        //--------------------------------------------------------------------
        //
        // Public methods
        //
        //---------------------------------------------------------------------

        public void AddContainer(FixedSOMPageElement pageElement)
        {
            FixedSOMFixedBlock block = pageElement as FixedSOMFixedBlock;
            if (block == null || (!block.IsFloatingImage && !block.IsWhiteSpace))
            {
                if (pageElement.IsRTL)
                {
                    _RTLCount++;
                }
                else
                {
                    _LTRCount++;
                }
            }
           
            _semanticBoxes.Add(pageElement);
            
            if (_boundingRect.IsEmpty)
            {
                _boundingRect = pageElement.BoundingRect;
            }
            else
            {
                _boundingRect.Union(pageElement.BoundingRect);
            }
        }
Esempio n. 6
0
        int IComparable.CompareTo(object comparedObj)
        {
            int result = Int32.MinValue;

            FixedSOMPageElement compared = comparedObj as FixedSOMPageElement;
            FixedSOMPageElement This     = this as FixedSOMPageElement;

            Debug.Assert(compared != null);
            Debug.Assert(This != null);
            if (compared == null)
            {
                throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, comparedObj.GetType(), typeof(FixedSOMContainer)), "comparedObj");
            }
            SpatialComparison compareHor = base._CompareHorizontal(compared, false);
            SpatialComparison compareVer = base._CompareVertical(compared);

            Debug.Assert(compareHor != SpatialComparison.None);
            Debug.Assert(compareVer != SpatialComparison.None);

            switch (compareHor)
            {
            case SpatialComparison.Before:
                if (compareVer != SpatialComparison.After)
                {
                    result = -1;
                }
                break;

            case SpatialComparison.After:
                if (compareVer != SpatialComparison.Before)
                {
                    result = 1;
                }
                break;

            case SpatialComparison.OverlapBefore:
                if (compareVer == SpatialComparison.Before)
                {
                    result = -1;
                }
                else if (compareVer == SpatialComparison.After)
                {
                    result = 1;
                }
                break;

            case SpatialComparison.OverlapAfter:
                if (compareVer == SpatialComparison.After)
                {
                    result = 1;
                }
                else if (compareVer == SpatialComparison.Before)
                {
                    result = -1;
                }
                break;

            case SpatialComparison.Equal:
                switch (compareVer)
                {
                case SpatialComparison.After:
                case SpatialComparison.OverlapAfter:
                    result = 1;
                    break;

                case SpatialComparison.Before:
                case SpatialComparison.OverlapBefore:
                    result = -1;
                    break;

                case SpatialComparison.Equal:
                    result = 0;
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
                break;

            default:
                //Shouldn't happen
                Debug.Assert(false);
                break;
            }

            if (result == Int32.MinValue)
            {
                //Indecisive. Does markup order help?

                if (This.FixedNodes.Count == 0 || compared.FixedNodes.Count == 0)
                {
                    result = 0;
                }
                else
                {
                    FixedNode thisObjFirstNode = This.FixedNodes[0];
                    FixedNode thisObjLastNode  = This.FixedNodes[This.FixedNodes.Count - 1];

                    FixedNode otherObjFirstNode = compared.FixedNodes[0];
                    FixedNode otherObjLastNode  = compared.FixedNodes[compared.FixedNodes.Count - 1];

                    if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjFirstNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjLastNode) == 1)
                    {
                        result = -1;
                    }
                    else if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjLastNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjFirstNode) == 1)
                    {
                        result = 1;
                    }
                    else
                    {
                        //Indecisive. Whichever is below comes after; if same whichever is on the right comes after
                        int absVerComparison = _SpatialToAbsoluteComparison(compareVer);
                        result = absVerComparison != 0 ? absVerComparison : _SpatialToAbsoluteComparison(compareHor);
                    }
                }
            }

            return(result);
        }
Esempio n. 7
0
        // Token: 0x06002E16 RID: 11798 RVA: 0x000D0230 File Offset: 0x000CE430
        int IComparable.CompareTo(object comparedObj)
        {
            int num = int.MinValue;
            FixedSOMPageElement fixedSOMPageElement  = comparedObj as FixedSOMPageElement;
            FixedSOMPageElement fixedSOMPageElement2 = this as FixedSOMPageElement;

            if (fixedSOMPageElement == null)
            {
                throw new ArgumentException(SR.Get("UnexpectedParameterType", new object[]
                {
                    comparedObj.GetType(),
                    typeof(FixedSOMContainer)
                }), "comparedObj");
            }
            FixedSOMSemanticBox.SpatialComparison comparison        = base._CompareHorizontal(fixedSOMPageElement, false);
            FixedSOMSemanticBox.SpatialComparison spatialComparison = base._CompareVertical(fixedSOMPageElement);
            switch (comparison)
            {
            case FixedSOMSemanticBox.SpatialComparison.Before:
                if (spatialComparison != FixedSOMSemanticBox.SpatialComparison.After)
                {
                    num = -1;
                }
                break;

            case FixedSOMSemanticBox.SpatialComparison.OverlapBefore:
                if (spatialComparison == FixedSOMSemanticBox.SpatialComparison.Before)
                {
                    num = -1;
                }
                else if (spatialComparison == FixedSOMSemanticBox.SpatialComparison.After)
                {
                    num = 1;
                }
                break;

            case FixedSOMSemanticBox.SpatialComparison.Equal:
                switch (spatialComparison)
                {
                case FixedSOMSemanticBox.SpatialComparison.Before:
                case FixedSOMSemanticBox.SpatialComparison.OverlapBefore:
                    num = -1;
                    break;

                case FixedSOMSemanticBox.SpatialComparison.Equal:
                    num = 0;
                    break;

                case FixedSOMSemanticBox.SpatialComparison.OverlapAfter:
                case FixedSOMSemanticBox.SpatialComparison.After:
                    num = 1;
                    break;
                }
                break;

            case FixedSOMSemanticBox.SpatialComparison.OverlapAfter:
                if (spatialComparison == FixedSOMSemanticBox.SpatialComparison.After)
                {
                    num = 1;
                }
                else if (spatialComparison == FixedSOMSemanticBox.SpatialComparison.Before)
                {
                    num = -1;
                }
                break;

            case FixedSOMSemanticBox.SpatialComparison.After:
                if (spatialComparison != FixedSOMSemanticBox.SpatialComparison.Before)
                {
                    num = 1;
                }
                break;
            }
            if (num == -2147483648)
            {
                if (fixedSOMPageElement2.FixedNodes.Count == 0 || fixedSOMPageElement.FixedNodes.Count == 0)
                {
                    num = 0;
                }
                else
                {
                    FixedNode item  = fixedSOMPageElement2.FixedNodes[0];
                    FixedNode item2 = fixedSOMPageElement2.FixedNodes[fixedSOMPageElement2.FixedNodes.Count - 1];
                    FixedNode item3 = fixedSOMPageElement.FixedNodes[0];
                    FixedNode item4 = fixedSOMPageElement.FixedNodes[fixedSOMPageElement.FixedNodes.Count - 1];
                    if (fixedSOMPageElement2.FixedSOMPage.MarkupOrder.IndexOf(item3) - fixedSOMPageElement2.FixedSOMPage.MarkupOrder.IndexOf(item2) == 1)
                    {
                        num = -1;
                    }
                    else if (fixedSOMPageElement2.FixedSOMPage.MarkupOrder.IndexOf(item4) - fixedSOMPageElement2.FixedSOMPage.MarkupOrder.IndexOf(item) == 1)
                    {
                        num = 1;
                    }
                    else
                    {
                        int num2 = base._SpatialToAbsoluteComparison(spatialComparison);
                        num = ((num2 != 0) ? num2 : base._SpatialToAbsoluteComparison(comparison));
                    }
                }
            }
            return(num);
        }