예제 #1
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerBreakAfter)
            {
                return new Status(Status.OK);
            }

            if (this.marker == MarkerStart)
            {
                if (!setup)
                {
                    DoSetup(area);
                }
            }
            if (columnWidth > 0)
            {
                this.areaContainer =
                    new AreaContainer(propMgr.GetFontState(area.getFontInfo()),
                                      columnOffset, 0, columnWidth,
                                      area.getContentHeight(), Position.RELATIVE);
                areaContainer.foCreator = this;
                areaContainer.setPage(area.getPage());
                areaContainer.setBorderAndPadding(propMgr.GetBorderAndPadding());
                areaContainer.setBackground(propMgr.GetBackgroundProps());
                areaContainer.SetHeight(area.GetHeight());
                area.addChild(areaContainer);
            }
            return new Status(Status.OK);
        }
예제 #2
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AbsolutePositionProps mAbsProps = propMgr.GetAbsolutePositionProps();
                BorderAndPadding bap = propMgr.GetBorderAndPadding();
                BackgroundProps bProps = propMgr.GetBackgroundProps();
                MarginProps mProps = propMgr.GetMarginProps();

                this.marker = 0;
                this.position = this.properties.GetProperty("position").GetEnum();
                this.top = this.properties.GetProperty("top").GetLength().MValue();
                this.bottom = this.properties.GetProperty("bottom").GetLength().MValue();
                this.left = this.properties.GetProperty("left").GetLength().MValue();
                this.right = this.properties.GetProperty("right").GetLength().MValue();
                this.width = this.properties.GetProperty("width").GetLength().MValue();
                this.height = this.properties.GetProperty("height").GetLength().MValue();
                span = this.properties.GetProperty("span").GetEnum();

                string id = this.properties.GetProperty("id").GetString();
                area.getIDReferences().InitializeID(id, area);
            }

            AreaContainer container = (AreaContainer)area;
            if ((this.width == 0) && (this.height == 0))
            {
                width = right - left;
                height = bottom - top;
            }

            this.areaContainer =
                new AreaContainer(propMgr.GetFontState(container.getFontInfo()),
                                  container.getXPosition() + left,
                                  container.GetYPosition() - top, width, height,
                                  position);

            areaContainer.setPage(area.getPage());
            areaContainer.setBackground(propMgr.GetBackgroundProps());
            areaContainer.setBorderAndPadding(propMgr.GetBorderAndPadding());
            areaContainer.start();

            areaContainer.setAbsoluteHeight(0);
            areaContainer.setIDReferences(area.getIDReferences());

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FObj fo = (FObj)children[i];
                Status status = fo.Layout(areaContainer);
            }

            areaContainer.end();
            if (position == Position.ABSOLUTE)
            {
                areaContainer.SetHeight(height);
            }
            area.addChild(areaContainer);

            return new Status(Status.OK);
        }
예제 #3
0
파일: Title.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
            AuralProps mAurProps = propMgr.GetAuralProps();
            BorderAndPadding bap = propMgr.GetBorderAndPadding();
            BackgroundProps bProps = propMgr.GetBackgroundProps();
            FontState fontState = propMgr.GetFontState(area.getFontInfo());
            MarginInlineProps mProps = propMgr.GetMarginInlineProps();

            Property prop;
            prop = this.properties.GetProperty("baseline-shift");
            if (prop is LengthProperty)
            {
                Length bShift = prop.GetLength();
            }
            else if (prop is EnumProperty)
            {
                int bShift = prop.GetEnum();
            }
            ColorType col = this.properties.GetProperty("color").GetColorType();
            Length lHeight = this.properties.GetProperty("line-height").GetLength();
            int lShiftAdj = this.properties.GetProperty(
                "line-height-shift-adjustment").GetEnum();
            int vis = this.properties.GetProperty("visibility").GetEnum();
            Length zIndex = this.properties.GetProperty("z-index").GetLength();

            return base.Layout(area);
        }
예제 #4
0
파일: XMLObj.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            FonetDriver.ActiveDriver.FireFonetError(
                this.name + " outside foreign xml");

            return new Status(Status.OK);
        }
예제 #5
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
                this.marker = 0;
                string id = this.properties.GetProperty("id").GetString();
                area.getIDReferences().InitializeID(id, area);
            }

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FObj fo = (FObj)children[i];

                Status status;
                if ((status = fo.Layout(area)).isIncomplete())
                {
                    this.marker = i;
                    if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE))
                    {
                        return new Status(Status.AREA_FULL_NONE);
                    }
                    else
                    {
                        return new Status(Status.AREA_FULL_SOME);
                    }
                }
            }
            return new Status(Status.OK);
        }
예제 #6
0
파일: XMLElement.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            if (!(area is ForeignObjectArea))
            {
                throw new FonetException("XML not in fo:instream-foreign-object");
            }

            return new Status(Status.OK);
        }
예제 #7
0
        public override Status Layout(Area area, Region region)
        {
            int numChildren = this.children.Count;
            string regionClass = "none";
            if (region != null)
            {
                regionClass = region.GetRegionClass();
            }
            else
            {
                if (GetFlowName().Equals("xsl-region-before"))
                {
                    regionClass = RegionBefore.REGION_CLASS;
                }
                else if (GetFlowName().Equals("xsl-region-after"))
                {
                    regionClass = RegionAfter.REGION_CLASS;
                }
                else if (GetFlowName().Equals("xsl-region-start"))
                {
                    regionClass = RegionStart.REGION_CLASS;
                }
                else if (GetFlowName().Equals("xsl-region-end"))
                {
                    regionClass = RegionEnd.REGION_CLASS;
                }
            }

            if (area is AreaContainer)
            {
                ((AreaContainer)area).setAreaName(regionClass);
            }

            area.setAbsoluteHeight(0);

            SetContentWidth(area.getContentWidth());

            for (int i = 0; i < numChildren; i++)
            {
                FObj fo = (FObj)children[i];

                Status status;
                if ((status = fo.Layout(area)).isIncomplete())
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "Some static content could not fit in the area.");
                    this.marker = i;
                    if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE))
                    {
                        status = new Status(Status.AREA_FULL_SOME);
                    }
                    return (status);
                }
            }
            ResetMarker();
            return new Status(Status.OK);
        }
예제 #8
0
 public override Status Layout(Area area)
 {
     AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
     AuralProps mAurProps = propMgr.GetAuralProps();
     BorderAndPadding bap = propMgr.GetBorderAndPadding();
     BackgroundProps bProps = propMgr.GetBackgroundProps();
     MarginProps mProps = propMgr.GetMarginProps();
     RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();
     return base.Layout(area);
 }
예제 #9
0
파일: LinkSet.cs 프로젝트: nholik/Fo.Net
 public void applyAreaContainerOffsets(AreaContainer ac, Area area)
 {
     int height = area.getAbsoluteHeight();
     BlockArea ba = (BlockArea)area;
     foreach (LinkedRectangle r in rects)
     {
         r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset());
         r.setY(ac.GetYPosition() - height + (maxY - r.getY()) - ba.getHalfLeading());
     }
 }
예제 #10
0
 public void ConfigureID(string id, Area area)
 {
     if (id != null && !id.Equals(""))
     {
         setPosition(id,
                     area.getPage().getBody().getXPosition()
                         + area.getTableCellXOffset() - ID_PADDING,
                     area.getPage().getBody().GetYPosition()
                         - area.getAbsoluteHeight() + ID_PADDING);
         setPageNumber(id, area.getPage().getNumber());
         area.getPage().addToIDList(id);
     }
 }
예제 #11
0
파일: Footnote.cs 프로젝트: nholik/Fo.Net
 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;
 }
예제 #12
0
        public override Status Layout(Area area)
        {
            if (marker == MarkerStart)
            {
                marker = 0;
                Page containingPage = area.getPage();
                bestMarker = SearchPage(containingPage);

                if (bestMarker != null)
                {
                    bestMarker.resetMarkerContent();
                    return bestMarker.LayoutMarker(area);
                }

                AreaTree areaTree = containingPage.getAreaTree();
                if (retrieveBoundary == RetrieveBoundary.PAGE_SEQUENCE)
                {
                    PageSequence pageSequence = areaTree.GetCurrentPageSequence();
                    if (pageSequence == containingPage.getPageSequence())
                    {
                        return LayoutBestMarker(areaTree.GetCurrentPageSequenceMarkers(), area);
                    }

                }
                else if (retrieveBoundary == RetrieveBoundary.DOCUMENT)
                {
                    return LayoutBestMarker(areaTree.GetDocumentMarkers(), area);

                }
                else if (retrieveBoundary != RetrieveBoundary.PAGE)
                {
                    throw new FonetException("Illegal 'retrieve-boundary' value");
                }

            }
            else if (bestMarker != null)
            {
                return bestMarker.LayoutMarker(area);
            }

            return new Status(Status.OK);

        }
예제 #13
0
파일: Footnote.cs 프로젝트: nholik/Fo.Net
 public override Status Layout(Area area)
 {
     FONode inline = null;
     FONode fbody = null;
     if (this.marker == MarkerStart)
     {
         this.marker = 0;
     }
     int numChildren = this.children.Count;
     for (int i = this.marker; i < numChildren; i++)
     {
         FONode fo = (FONode)children[i];
         if (fo is Inline)
         {
             inline = fo;
             Status status = fo.Layout(area);
             if (status.isIncomplete())
             {
                 return status;
             }
         }
         else if (inline != null && fo is FootnoteBody)
         {
             fbody = fo;
             if (area is BlockArea)
             {
                 ((BlockArea)area).addFootnote((FootnoteBody)fbody);
             }
             else
             {
                 Page page = area.getPage();
                 LayoutFootnote(page, (FootnoteBody)fbody, area);
             }
         }
     }
     if (fbody == null)
     {
         FonetDriver.ActiveDriver.FireFonetWarning(
             "No footnote-body in footnote");
     }
     if (area is BlockArea) { }
     return new Status(Status.OK);
 }
예제 #14
0
        public override Status Layout(Area area)
        {
            int numChildren = this.children.Count;

            if (numChildren != 1)
            {
                throw new FonetException("list-item-label must have exactly one block in this version of FO.NET");
            }

            AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
            string id = this.properties.GetProperty("id").GetString();
            area.getIDReferences().InitializeID(id, area);

            Block block = (Block)children[0];

            Status status;
            status = block.Layout(area);
            area.addDisplaySpace(-block.GetAreaHeight());
            return status;
        }
예제 #15
0
파일: FObjMixed.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            if (this.properties != null)
            {
                Property prop = this.properties.GetProperty("id");
                if (prop != null)
                {
                    string id = prop.GetString();

                    if (this.marker == MarkerStart)
                    {
                        if (area.getIDReferences() != null)
                        {
                            area.getIDReferences().CreateID(id);
                        }
                        this.marker = 0;
                    }

                    if (this.marker == 0)
                    {
                        if (area.getIDReferences() != null)
                        {
                            area.getIDReferences().ConfigureID(id, area);
                        }
                    }
                }
            }

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];
                Status status;
                if ((status = fo.Layout(area)).isIncomplete())
                {
                    this.marker = i;
                    return status;
                }
            }
            return new Status(Status.OK);
        }
예제 #16
0
        public void DoSetup(Area area)
        {
            BorderAndPadding bap = propMgr.GetBorderAndPadding();
            BackgroundProps bProps = propMgr.GetBackgroundProps();

            this.iColumnNumber =
                this.properties.GetProperty("column-number").GetNumber().IntValue();

            this.numColumnsRepeated =
                this.properties.GetProperty("number-columns-repeated").GetNumber().IntValue();

            this.columnWidthPropVal =
                this.properties.GetProperty("column-width").GetLength();

            this.columnWidth = columnWidthPropVal.MValue();

            string id = this.properties.GetProperty("id").GetString();
            area.getIDReferences().InitializeID(id, area);

            setup = true;
        }
예제 #17
0
파일: PageNumber.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Page-number outside block area");
                return new Status(Status.OK);
            }
            if (this.marker == MarkerStart)
            {
                AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
                AuralProps mAurProps = propMgr.GetAuralProps();
                BorderAndPadding bap = propMgr.GetBorderAndPadding();
                BackgroundProps bProps = propMgr.GetBackgroundProps();
                MarginInlineProps mProps = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                ColorType c = this.properties.GetProperty("color").GetColorType();
                this.red = c.Red;
                this.green = c.Green;
                this.blue = c.Blue;

                this.wrapOption = this.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.properties.GetProperty("white-space-collapse").GetEnum();
                ts = new TextState();
                this.marker = 0;

                string id = this.properties.GetProperty("id").GetString();
                area.getIDReferences().InitializeID(id, area);
            }

            string p = area.getPage().getFormattedNumber();
            this.marker = FOText.addText((BlockArea)area,
                                         propMgr.GetFontState(area.getFontInfo()),
                                         red, green, blue, wrapOption, null,
                                         whiteSpaceCollapse, p.ToCharArray(), 0,
                                         p.Length, ts, VerticalAlign.BASELINE);
            return new Status(Status.OK);
        }
예제 #18
0
파일: Marker.cs 프로젝트: nholik/Fo.Net
        public Status LayoutMarker(Area area)
        {
            if (this.marker == MarkerStart)
            {
                this.marker = 0;
            }

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];

                Status status;
                if ((status = fo.Layout(area)).isIncomplete())
                {
                    this.marker = i;
                    return status;
                }
            }

            return new Status(Status.OK);
        }
예제 #19
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                this.marker = 0;
            }
            BlockArea blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, textIndent, align,
                              alignLast, lineHeight);
            blockArea.setGeneratedBy(this);
            blockArea.isFirst(true);
            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.start();

            blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
            blockArea.setIDReferences(area.getIDReferences());

            blockArea.setTableCellXOffset(area.getTableCellXOffset());

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];
                Status status;
                if ((status = fo.Layout(blockArea)).isIncomplete())
                {
                    this.ResetMarker();
                    return status;
                }
            }
            blockArea.end();
            area.addChild(blockArea);
            area.increaseHeight(blockArea.GetHeight());
            blockArea.isLast(true);
            return new Status(Status.OK);
        }
예제 #20
0
파일: BasicLink.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            string destination;
            int linkType;
            AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
            AuralProps mAurProps = propMgr.GetAuralProps();
            BorderAndPadding bap = propMgr.GetBorderAndPadding();
            BackgroundProps bProps = propMgr.GetBackgroundProps();
            MarginInlineProps mProps = propMgr.GetMarginInlineProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

            if (!(destination =
                this.properties.GetProperty("internal-destination").GetString()).Equals(""))
            {
                linkType = LinkSet.INTERNAL;
            }
            else if (!(destination =
                this.properties.GetProperty("external-destination").GetString()).Equals(""))
            {
                linkType = LinkSet.EXTERNAL;
            }
            else
            {
                throw new FonetException("internal-destination or external-destination must be specified in basic-link");
            }

            if (this.marker == MarkerStart)
            {
                string id = this.properties.GetProperty("id").GetString();
                area.getIDReferences().InitializeID(id, area);
                this.marker = 0;
            }

            LinkSet ls = new LinkSet(destination, area, linkType);

            AreaContainer ac = area.getNearestAncestorAreaContainer();
            while (ac != null && ac.getPosition() != Position.ABSOLUTE)
            {
                ac = ac.getNearestAncestorAreaContainer();
            }
            if (ac == null)
            {
                ac = area.getPage().getBody().getCurrentColumnArea();
            }

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];
                fo.SetLinkSet(ls);

                Status status;
                if ((status = fo.Layout(area)).isIncomplete())
                {
                    this.marker = i;
                    return status;
                }
            }

            ls.applyAreaContainerOffsets(ac, area);
            area.getPage().addLinkSet(ls);

            return new Status(Status.OK);
        }
예제 #21
0
파일: Area.cs 프로젝트: nholik/Fo.Net
 public void setParent(Area parent)
 {
     this.parent = parent;
 }
예제 #22
0
파일: Area.cs 프로젝트: nholik/Fo.Net
 public void removeChild(Area area)
 {
     this.currentHeight -= area.GetHeight();
     this.children.Remove(area);
 }
예제 #23
0
파일: Leader.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            BlockArea blockArea;
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "fo:leader must be a direct child of fo:block ");
                return new Status(Status.OK);
            }
            else
            {
                blockArea = (BlockArea)area;
            }

            AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
            AuralProps mAurProps = propMgr.GetAuralProps();
            BorderAndPadding bap = propMgr.GetBorderAndPadding();
            BackgroundProps bProps = propMgr.GetBackgroundProps();
            MarginInlineProps mProps = propMgr.GetMarginInlineProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();
            ColorType c = this.properties.GetProperty("color").GetColorType();
            float red = c.Red;
            float green = c.Green;
            float blue = c.Blue;

            int leaderPattern = this.properties.GetProperty("leader-pattern").GetEnum();
            int leaderLengthOptimum =
                this.properties.GetProperty("leader-length.optimum").GetLength().MValue();
            int leaderLengthMinimum =
                this.properties.GetProperty("leader-length.minimum").GetLength().MValue();
            Length maxlength = this.properties.GetProperty("leader-length.maximum").GetLength();
            int leaderLengthMaximum;
            if (maxlength is PercentLength)
            {
                leaderLengthMaximum = (int)(((PercentLength)maxlength).value()
                    * area.getAllocationWidth());
            }
            else
            {
                leaderLengthMaximum = maxlength.MValue();
            }
            int ruleThickness =
                this.properties.GetProperty("rule-thickness").GetLength().MValue();
            int ruleStyle = this.properties.GetProperty("rule-style").GetEnum();
            int leaderPatternWidth =
                this.properties.GetProperty("leader-pattern-width").GetLength().MValue();
            int leaderAlignment =
                this.properties.GetProperty("leader-alignment").GetEnum();

            string id = this.properties.GetProperty("id").GetString();
            blockArea.getIDReferences().InitializeID(id, blockArea);

            int succeeded = AddLeader(blockArea,
                                      propMgr.GetFontState(area.getFontInfo()),
                                      red, green, blue, leaderPattern,
                                      leaderLengthMinimum, leaderLengthOptimum,
                                      leaderLengthMaximum, ruleThickness,
                                      ruleStyle, leaderPatternWidth,
                                      leaderAlignment);
            if (succeeded == 1)
            {
                return new Status(Status.OK);
            }
            else
            {
                return new Status(Status.AREA_FULL_SOME);
            }
        }
예제 #24
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
                AuralProps mAurProps = propMgr.GetAuralProps();
                BorderAndPadding bap = propMgr.GetBorderAndPadding();
                BackgroundProps bProps = propMgr.GetBackgroundProps();
                MarginInlineProps mProps = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align = this.properties.GetProperty("text-align").GetEnum();
                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();

                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.width = this.properties.GetProperty("width").GetLength().MValue();
                this.height = this.properties.GetProperty("height").GetLength().MValue();

                this.src = this.properties.GetProperty("src").GetString();
                this.id = this.properties.GetProperty("id").GetString();

                area.getIDReferences().CreateID(id);
                this.marker = 0;
            }

            try
            {
                FonetImage img = FonetImageFactory.Make(src);
                if ((width == 0) || (height == 0))
                {
                    double imgWidth = img.Width;
                    double imgHeight = img.Height;

                    if ((width == 0) && (height == 0))
                    {
                        width = (int)((imgWidth * 1000d));
                        height = (int)((imgHeight * 1000d));
                    }
                    else if (height == 0)
                    {
                        height = (int)((imgHeight * ((double)width)) / imgWidth);
                    }
                    else if (width == 0)
                    {
                        width = (int)((imgWidth * ((double)height)) / imgHeight);
                    }
                }

                double ratio = (double)width / (double)height;

                Length maxWidth = this.properties.GetProperty("max-width").GetLength();
                Length maxHeight = this.properties.GetProperty("max-height").GetLength();

                if (maxWidth != null && width > maxWidth.MValue())
                {
                    width = maxWidth.MValue();
                    height = (int)(((double)width) / ratio);
                }
                if (maxHeight != null && height > maxHeight.MValue())
                {
                    height = maxHeight.MValue();
                    width = (int)(ratio * ((double)height));
                }

                int areaWidth = area.getAllocationWidth() - startIndent - endIndent;
                int pageHeight = area.getPage().getBody().getMaxHeight() - spaceBefore;

                if (height > pageHeight)
                {
                    height = pageHeight;
                    width = (int)(ratio * ((double)height));
                }
                if (width > areaWidth)
                {
                    width = areaWidth;
                    height = (int)(((double)width) / ratio);
                }

                if (area.spaceLeft() < (height + spaceBefore))
                {
                    return new Status(Status.AREA_FULL_NONE);
                }

                this.imageArea =
                    new ImageArea(propMgr.GetFontState(area.getFontInfo()), img,
                                  area.getAllocationWidth(), width, height,
                                  startIndent, endIndent, align);

                if ((spaceBefore != 0) && (this.marker == 0))
                {
                    area.addDisplaySpace(spaceBefore);
                }

                if (marker == 0)
                {
                    area.getIDReferences().ConfigureID(id, area);
                }

                imageArea.start();
                imageArea.end();

                if (spaceAfter != 0)
                {
                    area.addDisplaySpace(spaceAfter);
                }
                if (breakBefore == BreakBefore.PAGE
                    || ((spaceBefore + imageArea.GetHeight())
                        > area.spaceLeft()))
                {
                    return new Status(Status.FORCE_PAGE_BREAK);
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return new Status(Status.FORCE_PAGE_BREAK_ODD);
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return new Status(Status.FORCE_PAGE_BREAK_EVEN);
                }

                if (area is BlockArea)
                {
                    BlockArea ba = (BlockArea)area;
                    LineArea la = ba.getCurrentLineArea();
                    if (la == null)
                    {
                        return new Status(Status.AREA_FULL_NONE);
                    }
                    la.addPending();
                    if (imageArea.getContentWidth() > la.getRemainingWidth())
                    {
                        la = ba.createNextLineArea();
                        if (la == null)
                        {
                            return new Status(Status.AREA_FULL_NONE);
                        }
                    }
                    la.addInlineArea(imageArea, GetLinkSet());
                }
                else
                {
                    area.addChild(imageArea);
                    area.increaseHeight(imageArea.getContentHeight());
                }
                imageArea.setPage(area.getPage());

                if (breakAfter == BreakAfter.PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return new Status(Status.FORCE_PAGE_BREAK);
                }

                if (breakAfter == BreakAfter.ODD_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return new Status(Status.FORCE_PAGE_BREAK_ODD);
                }

                if (breakAfter == BreakAfter.EVEN_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return new Status(Status.FORCE_PAGE_BREAK_EVEN);
                }

            }
            catch (FonetImageException imgex)
            {
                FonetDriver.ActiveDriver.FireFonetError("Error while creating area : " + imgex.Message);
            }

            return new Status(Status.OK);
        }
예제 #25
0
 public override Status Layout(Area area)
 {
     return new Status(Status.OK);
 }
예제 #26
0
파일: Table.cs 프로젝트: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerBreakAfter)
            {
                return new Status(Status.OK);
            }

            if (this.marker == MarkerStart)
            {
                AccessibilityProps mAccProps = propMgr.GetAccessibilityProps();
                AuralProps mAurProps = propMgr.GetAuralProps();
                BorderAndPadding bap = propMgr.GetBorderAndPadding();
                BackgroundProps bProps = propMgr.GetBackgroundProps();
                MarginProps mProps = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.breakBefore = this.properties.GetProperty("break-before").GetEnum();
                this.breakAfter = this.properties.GetProperty("break-after").GetEnum();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();
                this.ipd =
                    this.properties.GetProperty("inline-progression-dimension").
                        GetLengthRange();
                this.height = this.properties.GetProperty("height").GetLength().MValue();
                this.bAutoLayout = (this.properties.GetProperty("table-layout").GetEnum() ==
                    TableLayout.AUTO);

                this.id = this.properties.GetProperty("id").GetString();

                this.omitHeaderAtBreak =
                    this.properties.GetProperty("table-omit-header-at-break").GetEnum()
                        == TableOmitHeaderAtBreak.TRUE;
                this.omitFooterAtBreak =
                    this.properties.GetProperty("table-omit-footer-at-break").GetEnum()
                        == TableOmitFooterAtBreak.TRUE;

                if (area is BlockArea)
                {
                    area.end();
                }
                if (this.areaContainer
                    == null)
                {
                    area.getIDReferences().CreateID(id);
                }

                this.marker = 0;

                if (breakBefore == BreakBefore.PAGE)
                {
                    return new Status(Status.FORCE_PAGE_BREAK);
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return new Status(Status.FORCE_PAGE_BREAK_ODD);
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return new Status(Status.FORCE_PAGE_BREAK_EVEN);
                }

            }

            if ((spaceBefore != 0) && (this.marker == 0))
            {
                area.addDisplaySpace(spaceBefore);
            }

            if (marker == 0 && areaContainer == null)
            {
                area.getIDReferences().ConfigureID(id, area);
            }

            int spaceLeft = area.spaceLeft();
            this.areaContainer =
                new AreaContainer(propMgr.GetFontState(area.getFontInfo()), 0, 0,
                                  area.getAllocationWidth(), area.spaceLeft(),
                                  Position.STATIC);

            areaContainer.foCreator = this;
            areaContainer.setPage(area.getPage());
            areaContainer.setParent(area);
            areaContainer.setBackground(propMgr.GetBackgroundProps());
            areaContainer.setBorderAndPadding(propMgr.GetBorderAndPadding());
            areaContainer.start();

            areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
            areaContainer.setIDReferences(area.getIDReferences());

            bool addedHeader = false;
            bool addedFooter = false;
            int numChildren = this.children.Count;

            if (columns.Count == 0)
            {
                FindColumns(areaContainer);
                if (this.bAutoLayout)
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "table-layout=auto is not supported, using fixed!");
                }
                this.contentWidth =
                    CalcFixedColumnWidths(areaContainer.getAllocationWidth());
            }
            areaContainer.setAllocationWidth(this.contentWidth);
            layoutColumns(areaContainer);

            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];
                if (fo is TableHeader)
                {
                    if (columns.Count == 0)
                    {
                        FonetDriver.ActiveDriver.FireFonetWarning(
                            "Current implementation of tables requires a table-column for each column, indicating column-width");
                        return new Status(Status.OK);
                    }
                    tableHeader = (TableHeader)fo;
                    tableHeader.SetColumns(columns);
                }
                else if (fo is TableFooter)
                {
                    if (columns.Count == 0)
                    {
                        FonetDriver.ActiveDriver.FireFonetWarning(
                            "Current implementation of tables requires a table-column for each column, indicating column-width");
                        return new Status(Status.OK);
                    }
                    tableFooter = (TableFooter)fo;
                    tableFooter.SetColumns(columns);
                }
                else if (fo is TableBody)
                {
                    if (columns.Count == 0)
                    {
                        FonetDriver.ActiveDriver.FireFonetWarning(
                            "Current implementation of tables requires a table-column for each column, indicating column-width");
                        return new Status(Status.OK);
                    }
                    Status status;
                    if (tableHeader != null && !addedHeader)
                    {
                        if ((status =
                            tableHeader.Layout(areaContainer)).isIncomplete())
                        {
                            tableHeader.ResetMarker();
                            return new Status(Status.AREA_FULL_NONE);
                        }
                        addedHeader = true;
                        tableHeader.ResetMarker();
                        area.setMaxHeight(area.getMaxHeight() - spaceLeft
                            + this.areaContainer.getMaxHeight());
                    }
                    if (tableFooter != null && !this.omitFooterAtBreak
                        && !addedFooter)
                    {
                        if ((status =
                            tableFooter.Layout(areaContainer)).isIncomplete())
                        {
                            return new Status(Status.AREA_FULL_NONE);
                        }
                        addedFooter = true;
                        tableFooter.ResetMarker();
                    }
                    fo.SetWidows(widows);
                    fo.SetOrphans(orphans);
                    ((TableBody)fo).SetColumns(columns);

                    if ((status = fo.Layout(areaContainer)).isIncomplete())
                    {
                        this.marker = i;
                        if (bodyCount == 0
                            && status.getCode() == Status.AREA_FULL_NONE)
                        {
                            if (tableHeader != null)
                            {
                                tableHeader.RemoveLayout(areaContainer);
                            }
                            if (tableFooter != null)
                            {
                                tableFooter.RemoveLayout(areaContainer);
                            }
                            ResetMarker();
                        }
                        if (areaContainer.getContentHeight() > 0)
                        {
                            area.addChild(areaContainer);
                            area.increaseHeight(areaContainer.GetHeight());
                            if (this.omitHeaderAtBreak)
                            {
                                tableHeader = null;
                            }
                            if (tableFooter != null && !this.omitFooterAtBreak)
                            {
                                ((TableBody)fo).SetYPosition(tableFooter.GetYPosition());
                                tableFooter.SetYPosition(tableFooter.GetYPosition()
                                    + ((TableBody)fo).GetHeight());
                            }
                            SetupColumnHeights();
                            status = new Status(Status.AREA_FULL_SOME);
                        }
                        return status;
                    }
                    else
                    {
                        bodyCount++;
                    }
                    area.setMaxHeight(area.getMaxHeight() - spaceLeft
                        + this.areaContainer.getMaxHeight());
                    if (tableFooter != null && !this.omitFooterAtBreak)
                    {
                        ((TableBody)fo).SetYPosition(tableFooter.GetYPosition());
                        tableFooter.SetYPosition(tableFooter.GetYPosition()
                            + ((TableBody)fo).GetHeight());
                    }
                }
            }

            if (tableFooter != null && this.omitFooterAtBreak)
            {
                if (tableFooter.Layout(areaContainer).isIncomplete())
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "Footer could not fit on page, moving last body row to next page");
                    area.addChild(areaContainer);
                    area.increaseHeight(areaContainer.GetHeight());
                    if (this.omitHeaderAtBreak)
                    {
                        tableHeader = null;
                    }
                    tableFooter.RemoveLayout(areaContainer);
                    tableFooter.ResetMarker();
                    return new Status(Status.AREA_FULL_SOME);
                }
            }

            if (height != 0)
            {
                areaContainer.SetHeight(height);
            }

            SetupColumnHeights();

            areaContainer.end();
            area.addChild(areaContainer);

            area.increaseHeight(areaContainer.GetHeight());

            if (spaceAfter != 0)
            {
                area.addDisplaySpace(spaceAfter);
            }

            if (area is BlockArea)
            {
                area.start();
            }

            if (breakAfter == BreakAfter.PAGE)
            {
                this.marker = MarkerBreakAfter;
                return new Status(Status.FORCE_PAGE_BREAK);
            }

            if (breakAfter == BreakAfter.ODD_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return new Status(Status.FORCE_PAGE_BREAK_ODD);
            }

            if (breakAfter == BreakAfter.EVEN_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return new Status(Status.FORCE_PAGE_BREAK_EVEN);
            }

            return new Status(Status.OK);
        }
예제 #27
0
파일: Table.cs 프로젝트: nholik/Fo.Net
 private void layoutColumns(Area tableArea)
 {
     foreach (TableColumn c in columns)
     {
         if (c != null)
         {
             c.Layout(tableArea);
         }
     }
 }
예제 #28
0
파일: Table.cs 프로젝트: nholik/Fo.Net
 private void FindColumns(Area areaContainer)
 {
     int nextColumnNumber = 1;
     foreach (FONode fo in children)
     {
         if (fo is TableColumn)
         {
             TableColumn c = (TableColumn)fo;
             c.DoSetup(areaContainer);
             int numColumnsRepeated = c.GetNumColumnsRepeated();
             int currentColumnNumber = c.GetColumnNumber();
             if (currentColumnNumber == 0)
             {
                 currentColumnNumber = nextColumnNumber;
             }
             for (int j = 0; j < numColumnsRepeated; j++)
             {
                 if (currentColumnNumber < columns.Count)
                 {
                     if (columns[currentColumnNumber - 1] != null)
                     {
                         FonetDriver.ActiveDriver.FireFonetWarning(
                             "More than one column object assigned to column " + currentColumnNumber);
                     }
                 }
                 columns.Insert(currentColumnNumber - 1, c);
                 currentColumnNumber++;
             }
             nextColumnNumber = currentColumnNumber;
         }
     }
 }
예제 #29
0
 public LinkSet(string destination, Area area, int linkType)
 {
     this.destination = destination;
     this.area        = area;
     this.linkType    = linkType;
 }
예제 #30
0
 public int CheckBreakAfter(Area area)
 {
     switch (properties.GetProperty("break-after").GetEnum())
     {
         case BreakAfter.PAGE:
             return Status.FORCE_PAGE_BREAK;
         case BreakAfter.ODD_PAGE:
             return Status.FORCE_PAGE_BREAK_ODD;
         case BreakAfter.EVEN_PAGE:
             return Status.FORCE_PAGE_BREAK_EVEN;
         case BreakAfter.COLUMN:
             return Status.FORCE_COLUMN_BREAK;
         default:
             return Status.OK;
     }
 }
예제 #31
0
 public int CheckBreakBefore(Area area)
 {
     if (!(area is ColumnArea))
     {
         switch (properties.GetProperty("break-before").GetEnum())
         {
             case BreakBefore.PAGE:
                 return Status.FORCE_PAGE_BREAK;
             case BreakBefore.ODD_PAGE:
                 return Status.FORCE_PAGE_BREAK_ODD;
             case BreakBefore.EVEN_PAGE:
                 return Status.FORCE_PAGE_BREAK_EVEN;
             case BreakBefore.COLUMN:
                 return Status.FORCE_COLUMN_BREAK;
             default:
                 return Status.OK;
         }
     }
     else
     {
         ColumnArea colArea = (ColumnArea)area;
         switch (properties.GetProperty("break-before").GetEnum())
         {
             case BreakBefore.PAGE:
                 if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1))
                 {
                     return Status.OK;
                 }
                 else
                 {
                     return Status.FORCE_PAGE_BREAK;
                 }
             case BreakBefore.ODD_PAGE:
                 if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1)
                     && (colArea.getPage().getNumber() % 2 != 0))
                 {
                     return Status.OK;
                 }
                 else
                 {
                     return Status.FORCE_PAGE_BREAK_ODD;
                 }
             case BreakBefore.EVEN_PAGE:
                 if (!colArea.hasChildren() && (colArea.getColumnIndex() == 1)
                     && (colArea.getPage().getNumber() % 2 == 0))
                 {
                     return Status.OK;
                 }
                 else
                 {
                     return Status.FORCE_PAGE_BREAK_EVEN;
                 }
             case BreakBefore.COLUMN:
                 if (!area.hasChildren())
                 {
                     return Status.OK;
                 }
                 else
                 {
                     return Status.FORCE_COLUMN_BREAK;
                 }
             default:
                 return Status.OK;
         }
     }
 }