コード例 #1
0
        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());
            }
        }
コード例 #2
0
ファイル: FootnoteBody.cs プロジェクト: nholik/Fo.Net
        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);
        }
コード例 #3
0
ファイル: Leader.cs プロジェクト: nholik/Fo.Net
        public int AddLeader(BlockArea ba, FontState fontState, float red,
                             float green, float blue, int leaderPattern,
                             int leaderLengthMinimum, int leaderLengthOptimum,
                             int leaderLengthMaximum, int ruleThickness,
                             int ruleStyle, int leaderPatternWidth,
                             int leaderAlignment)
        {
            LineArea la = ba.getCurrentLineArea();
            if (la == null)
            {
                return -1;
            }

            la.changeFont(fontState);
            la.changeColor(red, green, blue);

            if (leaderLengthOptimum <= (la.getRemainingWidth()))
            {
                la.AddLeader(leaderPattern, leaderLengthMinimum,
                             leaderLengthOptimum, leaderLengthMaximum, ruleStyle,
                             ruleThickness, leaderPatternWidth, leaderAlignment);
            }
            else
            {
                la = ba.createNextLineArea();
                if (la == null)
                {
                    return -1;
                }
                la.changeFont(fontState);
                la.changeColor(red, green, blue);

                if (leaderLengthMinimum <= la.getContentWidth())
                {
                    la.AddLeader(leaderPattern, leaderLengthMinimum,
                                 leaderLengthOptimum, leaderLengthMaximum,
                                 ruleStyle, ruleThickness, leaderPatternWidth,
                                 leaderAlignment);
                }
                else
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "Leader doesn't fit into line, it will be clipped to fit.");
                    la.AddLeader(leaderPattern, la.getRemainingWidth(),
                                 leaderLengthOptimum, leaderLengthMaximum,
                                 ruleStyle, ruleThickness, leaderPatternWidth,
                                 leaderAlignment);
                }
            }
            return 1;
        }
コード例 #4
0
ファイル: ListBlock.cs プロジェクト: nholik/Fo.Net
        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();
                MarginProps mProps = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align = this.properties.GetProperty("text-align").GetEnum();
                this.alignLast = this.properties.GetProperty("text-align-last").GetEnum();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                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.marker = 0;

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

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

                if (this.isInTableCell)
                {
                    startIndent += forcedStartOffset;
                    endIndent += area.getAllocationWidth() - forcedWidth
                        - forcedStartOffset;
                }

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

            BlockArea blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, 0, align, alignLast,
                              lineHeight);
            blockArea.setTableCellXOffset(area.getTableCellXOffset());
            blockArea.setGeneratedBy(this);
            this.areasGenerated++;
            if (this.areasGenerated == 1)
            {
                blockArea.isFirst(true);
            }
            blockArea.addLineagePair(this, this.areasGenerated);

            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.setBackground(propMgr.GetBackgroundProps());
            blockArea.start();

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

            int numChildren = this.children.Count;
            for (int i = this.marker; i < numChildren; i++)
            {
                if (!(children[i] is ListItem))
                {
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Children of list-blocks must be list-items");
                    return new Status(Status.OK);
                }
                ListItem listItem = (ListItem)children[i];
                Status status;
                if ((status = listItem.Layout(blockArea)).isIncomplete())
                {
                    if (status.getCode() == Status.AREA_FULL_NONE && i > 0)
                    {
                        status = new Status(Status.AREA_FULL_SOME);
                    }
                    this.marker = i;
                    blockArea.end();
                    area.addChild(blockArea);
                    area.increaseHeight(blockArea.GetHeight());
                    return status;
                }
            }

            blockArea.end();
            area.addChild(blockArea);
            area.increaseHeight(blockArea.GetHeight());

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

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

            blockArea.isLast(true);
            return new Status(Status.OK);
        }
コード例 #5
0
ファイル: PdfRenderer.cs プロジェクト: nholik/Fo.Net
 public void RenderBlockArea(BlockArea area) {
     // KLease: Temporary test to fix block positioning
     // Offset ypos by padding and border widths
     this.currentYPosition -= (area.getPaddingTop()
         + area.getBorderTopWidth());
     DoFrame(area);
     foreach (Box b in area.getChildren()) {
         b.render(this);
     }
     this.currentYPosition -= (area.getPaddingBottom()
         + area.getBorderBottomWidth());
 }
コード例 #6
0
ファイル: Block.cs プロジェクト: nholik/Fo.Net
        public override Status Layout(Area area)
        {
            BlockArea blockArea;

            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();
                HyphenationProps mHyphProps = propMgr.GetHyphenationProps();
                MarginProps mProps = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align = this.properties.GetProperty("text-align").GetEnum();
                this.alignLast = this.properties.GetProperty("text-align-last").GetEnum();
                this.breakAfter = this.properties.GetProperty("break-after").GetEnum();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                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.textIndent =
                    this.properties.GetProperty("text-indent").GetLength().MValue();
                this.keepWithNext =
                    this.properties.GetProperty("keep-with-next").GetEnum();

                this.blockWidows =
                    this.properties.GetProperty("widows").GetNumber().IntValue();
                this.blockOrphans = (int)
                    this.properties.GetProperty("orphans").GetNumber().IntValue();
                this.id = this.properties.GetProperty("id").GetString();

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

                if (area.getIDReferences() != null)
                {
                    area.getIDReferences().CreateID(id);
                }

                this.marker = 0;

                int breakBeforeStatus = propMgr.CheckBreakBefore(area);
                if (breakBeforeStatus != Status.OK)
                {
                    return new Status(breakBeforeStatus);
                }

                int numChildren = this.children.Count;
                for (int i = 0; i < numChildren; i++)
                {
                    FONode fo = (FONode)children[i];
                    if (fo is FOText)
                    {
                        if (((FOText)fo).willCreateArea())
                        {
                            fo.SetWidows(blockWidows);
                            break;
                        }
                        else
                        {
                            children.RemoveAt(i);
                            numChildren = this.children.Count;
                            i--;
                        }
                    }
                    else
                    {
                        fo.SetWidows(blockWidows);
                        break;
                    }
                }

                for (int i = numChildren - 1; i >= 0; i--)
                {
                    FONode fo = (FONode)children[i];
                    if (fo is FOText)
                    {
                        if (((FOText)fo).willCreateArea())
                        {
                            fo.SetOrphans(blockOrphans);
                            break;
                        }
                    }
                    else
                    {
                        fo.SetOrphans(blockOrphans);
                        break;
                    }
                }
            }

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

            if (anythingLaidOut)
            {
                this.textIndent = 0;
            }

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

            int spaceLeft = area.spaceLeft();
            blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, textIndent, align,
                              alignLast, lineHeight);
            blockArea.setGeneratedBy(this);
            this.areasGenerated++;
            if (this.areasGenerated == 1)
            {
                blockArea.isFirst(true);
            }
            blockArea.addLineagePair(this, this.areasGenerated);
            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.setBackground(propMgr.GetBackgroundProps());
            blockArea.setBorderAndPadding(propMgr.GetBorderAndPadding());
            blockArea.setHyphenation(propMgr.GetHyphenationProps());
            blockArea.start();

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

            blockArea.setTableCellXOffset(area.getTableCellXOffset());

            for (int i = this.marker; i < children.Count; i++)
            {
                FONode fo = (FONode)children[i];
                Status status;
                if ((status = fo.Layout(blockArea)).isIncomplete())
                {
                    this.marker = i;
                    if (status.getCode() == Status.AREA_FULL_NONE)
                    {
                        if ((i != 0))
                        {
                            status = new Status(Status.AREA_FULL_SOME);
                            area.addChild(blockArea);
                            area.setMaxHeight(area.getMaxHeight() - spaceLeft
                                + blockArea.getMaxHeight());
                            area.increaseHeight(blockArea.GetHeight());
                            anythingLaidOut = true;

                            return status;
                        }
                        else
                        {
                            anythingLaidOut = false;
                            return status;
                        }
                    }
                    area.addChild(blockArea);
                    area.setMaxHeight(area.getMaxHeight() - spaceLeft
                        + blockArea.getMaxHeight());
                    area.increaseHeight(blockArea.GetHeight());
                    anythingLaidOut = true;
                    return status;
                }
                anythingLaidOut = true;
            }

            blockArea.end();

            area.setMaxHeight(area.getMaxHeight() - spaceLeft
                + blockArea.getMaxHeight());

            area.addChild(blockArea);

            area.increaseHeight(blockArea.GetHeight());

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

            if (area is BlockArea)
            {
                area.start();
            }
            areaHeight = blockArea.GetHeight();
            contentWidth = blockArea.getContentWidth();
            int breakAfterStatus = propMgr.CheckBreakAfter(area);
            if (breakAfterStatus != Status.OK)
            {
                this.marker = MarkerBreakAfter;
                blockArea = null;
                return new Status(breakAfterStatus);
            }

            if (keepWithNext != 0)
            {
                blockArea = null;
                return new Status(Status.KEEP_WITH_NEXT);
            }

            blockArea.isLast(true);
            blockArea = null;
            return new Status(Status.OK);
        }
コード例 #7
0
ファイル: FOText.cs プロジェクト: nholik/Fo.Net
        protected static int addRealText(BlockArea ba, FontState fontState,
                                         float red, float green, float blue,
                                         int wrapOption, LinkSet ls,
                                         int whiteSpaceCollapse, char[] data,
                                         int start, int end, TextState textState,
                                         int vAlign)
        {
            int ts, te;
            char[] ca;

            ts = start;
            te = end;
            ca = data;

            LineArea la = ba.getCurrentLineArea();
            if (la == null)
            {
                return start;
            }

            la.changeFont(fontState);
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            la.changeVerticalAlign(vAlign);
            ba.setupLinkSet(ls);

            ts = la.addText(ca, ts, te, ls, textState);

            while (ts != -1)
            {
                la = ba.createNextLineArea();
                if (la == null)
                {
                    return ts;
                }
                la.changeFont(fontState);
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                ba.setupLinkSet(ls);

                ts = la.addText(ca, ts, te, ls, textState);
            }
            return -1;
        }
コード例 #8
0
ファイル: FOText.cs プロジェクト: nholik/Fo.Net
        public static int addText(BlockArea ba, FontState fontState, float red,
                                  float green, float blue, int wrapOption,
                                  LinkSet ls, int whiteSpaceCollapse,
                                  char[] data, int start, int end,
                                  TextState textState, int vAlign)
        {
            if (fontState.FontVariant == FontVariant.SMALL_CAPS)
            {
                FontState smallCapsFontState;
                try
                {
                    int smallCapsFontHeight =
                        (int)(((double)fontState.FontSize) * 0.8d);
                    smallCapsFontState = new FontState(fontState.FontInfo,
                                                       fontState.FontFamily,
                                                       fontState.FontStyle,
                                                       fontState.FontWeight,
                                                       smallCapsFontHeight,
                                                       FontVariant.NORMAL);
                }
                catch (FonetException ex)
                {
                    smallCapsFontState = fontState;
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Error creating small-caps FontState: " + ex.Message);
                }

                char c;
                bool isLowerCase;
                int caseStart;
                FontState fontStateToUse;
                for (int i = start; i < end; )
                {
                    caseStart = i;
                    c = data[i];
                    isLowerCase = (Char.IsLetter(c) && Char.IsLower(c));
                    while (isLowerCase == (Char.IsLetter(c) && Char.IsLower(c)))
                    {
                        if (isLowerCase)
                        {
                            data[i] = Char.ToUpper(c);
                        }
                        i++;
                        if (i == end)
                        {
                            break;
                        }
                        c = data[i];
                    }
                    if (isLowerCase)
                    {
                        fontStateToUse = smallCapsFontState;
                    }
                    else
                    {
                        fontStateToUse = fontState;
                    }
                    int index = addRealText(ba, fontStateToUse, red, green, blue,
                                            wrapOption, ls, whiteSpaceCollapse,
                                            data, caseStart, i, textState,
                                            vAlign);
                    if (index != -1)
                    {
                        return index;
                    }
                }

                return -1;
            }

            return addRealText(ba, fontState, red, green, blue, wrapOption, ls,
                               whiteSpaceCollapse, data, start, end, textState,
                               vAlign);
        }