Esempio n. 1
0
 public static bool LayoutFootnote(Page p, FootnoteBody fb, Area area)
 {
     try
     {
         BodyAreaContainer bac      = p.getBody();
         AreaContainer     footArea = bac.getFootnoteReferenceArea();
         footArea.setIDReferences(bac.getIDReferences());
         int basePos = footArea.GetCurrentYPosition()
                       - footArea.GetHeight();
         int oldHeight = footArea.GetHeight();
         if (area != null)
         {
             footArea.setMaxHeight(area.getMaxHeight() - area.GetHeight()
                                   + footArea.GetHeight());
         }
         else
         {
             footArea.setMaxHeight(bac.getMaxHeight()
                                   + footArea.GetHeight());
         }
         Status status = fb.Layout(footArea);
         if (status.isIncomplete())
         {
             return(false);
         }
         else
         {
             if (area != null)
             {
                 area.setMaxHeight(area.getMaxHeight()
                                   - footArea.GetHeight() + oldHeight);
             }
             if (bac.getFootnoteState() == 0)
             {
                 Area ar = bac.getMainReferenceArea();
                 DecreaseMaxHeight(ar, footArea.GetHeight() - oldHeight);
                 footArea.setYPosition(basePos + footArea.GetHeight());
             }
         }
     }
     catch (FonetException)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        public virtual Status Layout(Area area, Region region)
        {
            if (this.marker == MarkerStart)
            {
                this.marker = 0;
            }

            BodyAreaContainer bac = (BodyAreaContainer)area;

            bool      prevChildMustKeepWithNext = false;
            ArrayList pageMarker = this.getMarkerSnapshot(new ArrayList());

            int numChildren = this.children.Count;

            if (numChildren == 0)
            {
                throw new FonetException("fo:flow must contain block-level children");
            }
            for (int i = this.marker; i < numChildren; i++)
            {
                FObj fo = (FObj)children[i];

                if (bac.isBalancingRequired(fo))
                {
                    bac.resetSpanArea();

                    this.Rollback(markerSnapshot);
                    i = this.marker - 1;
                    continue;
                }
                Area currentArea = bac.getNextArea(fo);
                currentArea.setIDReferences(bac.getIDReferences());
                if (bac.isNewSpanArea())
                {
                    this.marker    = i;
                    markerSnapshot = this.getMarkerSnapshot(new ArrayList());
                }
                SetContentWidth(currentArea.getContentWidth());

                _status = fo.Layout(currentArea);

                if (_status.isIncomplete())
                {
                    if ((prevChildMustKeepWithNext) && (_status.laidOutNone()))
                    {
                        this.marker = i - 1;
                        FObj prevChild = (FObj)children[this.marker];
                        prevChild.RemoveAreas();
                        prevChild.ResetMarker();
                        prevChild.RemoveID(area.getIDReferences());
                        _status = new Status(Status.AREA_FULL_SOME);
                        return(_status);
                    }
                    if (bac.isLastColumn())
                    {
                        if (_status.getCode() == Status.FORCE_COLUMN_BREAK)
                        {
                            this.marker = i;
                            _status     =
                                new Status(Status.FORCE_PAGE_BREAK);
                            return(_status);
                        }
                        else
                        {
                            this.marker = i;
                            return(_status);
                        }
                    }
                    else
                    {
                        if (_status.isPageBreak())
                        {
                            this.marker = i;
                            return(_status);
                        }
                        ((ColumnArea)currentArea).incrementSpanIndex();
                        i--;
                    }
                }
                if (_status.getCode() == Status.KEEP_WITH_NEXT)
                {
                    prevChildMustKeepWithNext = true;
                }
                else
                {
                    prevChildMustKeepWithNext = false;
                }
            }
            return(_status);
        }