Exemple #1
0
        public BackgroundProps GetBackgroundProps()
        {
            if (bgProps == null)
            {
                bgProps = new BackgroundProps();

                bgProps.backColor =
                    properties.GetProperty("background-color").GetColorType();

                string src = properties.GetProperty("background-image").GetString();
                if (src == "none")
                {
                    bgProps.backImage = null;
                }
                else if (src == "inherit")
                {
                    bgProps.backImage = null;
                }
                else
                {
                    try
                    {
                        bgProps.backImage = FonetImageFactory.Make(src);
                    }
                    catch (FonetImageException imgex)
                    {
                        bgProps.backImage = null;
                        FonetDriver.ActiveDriver.FireFonetError(imgex.Message);
                    }
                }

                bgProps.backRepeat = properties.GetProperty("background-repeat").GetEnum();
            }
            return(bgProps);
        }
Exemple #2
0
        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));
        }
Exemple #3
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.GetSpanKind();
                area.GetMyRefs().InitializeID(this.properties.GetId(), 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));
        }
Exemple #4
0
        public override RegionArea MakeRegionArea(int allocationRectangleXPosition,
                                                  int allocationRectangleYPosition,
                                                  int allocationRectangleWidth,
                                                  int allocationRectangleHeight)
        {
            BorderAndPadding bap    = propMgr.GetBorderAndPadding();
            BackgroundProps  bProps = propMgr.GetBackgroundProps();
            MarginProps      mProps = propMgr.GetMarginProps();
            int extent = this.properties.GetProperty("extent").GetLength().MValue();

            if (extent != 0)
            {
                allocationRectangleHeight = extent;
            }
            RegionArea area = new RegionArea(
                allocationRectangleXPosition
                + mProps.marginLeft,
                allocationRectangleYPosition
                - mProps.marginTop,
                allocationRectangleWidth
                - mProps.marginLeft
                - mProps.marginRight,
                allocationRectangleHeight
                - mProps.marginTop
                - mProps.marginBottom);

            area.setBackground(bProps);

            return(area);
        }
Exemple #5
0
 protected InlineContainer(FObj parent, PropertyList propertyList)
     : base(parent, propertyList)
 {
     BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
     BackgroundProps       bProps    = propMgr.GetBackgroundProps();
     MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
     RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();
 }
Exemple #6
0
        public override Status Layout(Area area)
        {
            AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
            AuralProps            mAurProps = propMgr.GetAuralProps();
            BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps    = propMgr.GetBackgroundProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

            return(base.Layout(area));
        }
        public override RegionArea MakeRegionArea(int allocationRectangleXPosition,
                                                  int allocationRectangleYPosition,
                                                  int allocationRectangleWidth,
                                                  int allocationRectangleHeight)
        {
            BorderAndPadding bap    = propMgr.GetBorderAndPadding();
            BackgroundProps  bProps = propMgr.GetBackgroundProps();
            MarginProps      mProps = propMgr.GetMarginProps();
            BodyRegionArea   body   = new BodyRegionArea(allocationRectangleXPosition
                                                         + mProps.marginLeft,
                                                         allocationRectangleYPosition
                                                         - mProps.marginTop,
                                                         allocationRectangleWidth
                                                         - mProps.marginLeft
                                                         - mProps.marginRight,
                                                         allocationRectangleHeight
                                                         - mProps.marginTop
                                                         - mProps.marginBottom);

            body.setBackground(propMgr.GetBackgroundProps());

            int    overflow            = this.properties.GetProperty("overflow").GetEnum();
            string columnCountAsString =
                this.properties.GetProperty("column-count").GetString();
            int columnCount = 1;

            try
            {
                columnCount = Int32.Parse(columnCountAsString);
            }
            catch (FormatException)
            {
                FonetDriver.ActiveDriver.FireFonetError(
                    "Bad value on region body 'column-count'");
                columnCount = 1;
            }
            if ((columnCount > 1) && (overflow == Overflow.SCROLL))
            {
                FonetDriver.ActiveDriver.FireFonetError(
                    "Setting 'column-count' to 1 because 'overflow' is set to 'scroll'");
                columnCount = 1;
            }
            body.setColumnCount(columnCount);

            int columnGap =
                this.properties.GetProperty("column-gap").GetLength().MValue();

            body.setColumnGap(columnGap);

            return(body);
        }
Exemple #8
0
        public override RegionArea MakeRegionArea(int allocationRectangleXPosition,
                                                  int allocationRectangleYPosition,
                                                  int allocationRectangleWidth,
                                                  int allocationRectangleHeight)
        {
            BorderAndPadding bap    = propMgr.GetBorderAndPadding();
            BackgroundProps  bProps = propMgr.GetBackgroundProps();
            int extent = this.properties.GetProperty("extent").GetLength().MValue();

            return(MakeRegionArea(allocationRectangleXPosition,
                                  allocationRectangleYPosition,
                                  allocationRectangleWidth, extent, false, false,
                                  0, 0));
        }
Exemple #9
0
        public void DoSetup()
        {
            AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
            AuralProps            mAurProps = propMgr.GetAuralProps();
            BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps    = propMgr.GetBackgroundProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

            this.iColNumber =
                properties.GetProperty("column-number").GetNumber().IntValue();
            if (iColNumber < 0)
            {
                iColNumber = 0;
            }
            this.numColumnsSpanned =
                this.properties.GetProperty("number-columns-spanned").GetNumber().IntValue();
            if (numColumnsSpanned < 1)
            {
                numColumnsSpanned = 1;
            }
            this.numRowsSpanned =
                this.properties.GetProperty("number-rows-spanned").GetNumber().IntValue();
            if (numRowsSpanned < 1)
            {
                numRowsSpanned = 1;
            }

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

            bSepBorders = (this.properties.GetProperty("border-collapse").GetEnum()
                           == BorderCollapse.SEPARATE);

            CalcBorders(propMgr.GetBorderAndPadding());

            verticalAlign = this.properties.GetProperty("display-align").GetEnum();
            if (verticalAlign == DisplayAlign.AUTO)
            {
                bRelativeAlign = true;
                verticalAlign  = this.properties.GetProperty("relative-align").GetEnum();
            }
            else
            {
                bRelativeAlign = false;
            }

            this.minCellHeight =
                this.properties.GetProperty("height").GetLength().MValue();
        }
Exemple #10
0
        public Inline(FObj parent, PropertyList propertyList)
            : base(parent, propertyList)
        {
            if (parent.ElementName.Equals("fo:flow"))
            {
                throw new FonetException("inline formatting objects cannot"
                                         + " be directly under flow");
            }

            AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
            AuralProps            mAurProps = propMgr.GetAuralProps();
            BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps    = propMgr.GetBackgroundProps();
            MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

            ts = propMgr.getTextDecoration(parent);
        }
Exemple #11
0
        public void DoSetup(Area area)
        {
            AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
            AuralProps            mAurProps = propMgr.GetAuralProps();
            BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps    = propMgr.GetBackgroundProps();
            RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

            this.breakAfter       = this.properties.GetProperty("break-after").GetEnum();
            this.keepTogether     = getKeepValue("keep-together.within-column");
            this.keepWithNext     = getKeepValue("keep-with-next.within-column");
            this.keepWithPrevious =
                getKeepValue("keep-with-previous.within-column");

            this.id        = this.properties.GetProperty("id").GetString();
            this.minHeight = this.properties.GetProperty("height").GetLength().MValue();
            setup          = true;
        }
Exemple #12
0
        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));
        }
        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;
        }
Exemple #14
0
        public override Status Layout(Area area)
        {
            string destination;

            Fonet.Pdf.LinkKind 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 = Pdf.LinkKind.Internal;
            }
            else if (!(destination =
                           this.properties.GetProperty("external-destination").GetString()).Equals(""))
            {
                linkType = Pdf.LinkKind.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();
                MyIDRefs refs = (MyIDRefs)area.getIDReferences();

                refs.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));
        }
Exemple #15
0
 public void setBackground(BackgroundProps bg)
 {
     this.background = bg;
 }
Exemple #16
0
        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();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

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

                try
                {
                    area.getIDReferences().CreateID(id);
                }
                catch (FonetException e)
                {
                    throw e;
                }

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

                if (rowSpanMgr == null)
                {
                    rowSpanMgr = new RowSpanMgr(columns.Count);
                }

                this.marker = 0;
            }

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

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

            int spaceLeft = area.spaceLeft();

            this.areaContainer =
                new AreaContainer(propMgr.GetFontState(area.getFontInfo()), 0,
                                  area.getContentHeight(),
                                  area.getContentWidth(),
                                  area.spaceLeft(), Position.RELATIVE);
            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());

            Hashtable keepWith     = new Hashtable();
            int       numChildren  = this.children.Count;
            TableRow  lastRow      = null;
            bool      endKeepGroup = true;

            for (int i = this.marker; i < numChildren; i++)
            {
                Object child = children[i];
                if (child is Marker)
                {
                    ((Marker)child).Layout(area);
                    continue;
                }
                if (!(child is TableRow))
                {
                    throw new FonetException("Currently only Table Rows are supported in table body, header and footer");
                }
                TableRow row = (TableRow)child;

                row.SetRowSpanMgr(rowSpanMgr);
                row.SetColumns(columns);
                row.DoSetup(areaContainer);
                if ((row.GetKeepWithPrevious().GetKeepType() != KeepValue.KEEP_WITH_AUTO ||
                     row.GetKeepWithNext().GetKeepType() != KeepValue.KEEP_WITH_AUTO ||
                     row.GetKeepTogether().GetKeepType() != KeepValue.KEEP_WITH_AUTO) &&
                    lastRow != null && !keepWith.Contains(lastRow))
                {
                    keepWith.Add(lastRow, null);
                }
                else
                {
                    if (endKeepGroup && keepWith.Count > 0)
                    {
                        keepWith = new Hashtable();
                    }
                    if (endKeepGroup && i > this.marker)
                    {
                        rowSpanMgr.SetIgnoreKeeps(false);
                    }
                }

                bool bRowStartsArea = (i == this.marker);
                if (bRowStartsArea == false && keepWith.Count > 0)
                {
                    if (children.IndexOf(keepWith[0]) == this.marker)
                    {
                        bRowStartsArea = true;
                    }
                }
                row.setIgnoreKeepTogether(bRowStartsArea && startsAC(area));
                Status status = row.Layout(areaContainer);
                if (status.isIncomplete())
                {
                    if (status.isPageBreak())
                    {
                        this.marker = i;
                        area.addChild(areaContainer);

                        area.increaseHeight(areaContainer.GetHeight());
                        if (i == numChildren - 1)
                        {
                            this.marker = MarkerBreakAfter;
                            if (spaceAfter != 0)
                            {
                                area.increaseHeight(spaceAfter);
                            }
                        }
                        return(status);
                    }
                    if ((keepWith.Count > 0) &&
                        (!rowSpanMgr.IgnoreKeeps()))
                    {
                        row.RemoveLayout(areaContainer);
                        foreach (TableRow tr in keepWith.Keys)
                        {
                            tr.RemoveLayout(areaContainer);
                            i--;
                        }
                        if (i == 0)
                        {
                            ResetMarker();

                            rowSpanMgr.SetIgnoreKeeps(true);

                            return(new Status(Status.AREA_FULL_NONE));
                        }
                    }
                    this.marker = i;
                    if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE))
                    {
                        status = new Status(Status.AREA_FULL_SOME);
                    }
                    if (!((i == 0) && (areaContainer.getContentHeight() <= 0)))
                    {
                        area.addChild(areaContainer);

                        area.increaseHeight(areaContainer.GetHeight());
                    }

                    rowSpanMgr.SetIgnoreKeeps(true);

                    return(status);
                }
                else if (status.getCode() == Status.KEEP_WITH_NEXT ||
                         rowSpanMgr.HasUnfinishedSpans())
                {
                    keepWith.Add(row, null);
                    endKeepGroup = false;
                }
                else
                {
                    endKeepGroup = true;
                }
                lastRow = row;
                area.setMaxHeight(area.getMaxHeight() - spaceLeft
                                  + this.areaContainer.getMaxHeight());
                spaceLeft = area.spaceLeft();
            }
            area.addChild(areaContainer);
            areaContainer.end();

            area.increaseHeight(areaContainer.GetHeight());

            if (spaceAfter != 0)
            {
                area.increaseHeight(spaceAfter);
                area.setMaxHeight(area.getMaxHeight() - spaceAfter);
            }

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

            return(new Status(Status.OK));
        }
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Page-number-citation outside block area");
                return(new Status(Status.OK));
            }

            IDReferences idReferences = area.getIDReferences();

            this.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();

                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();

                this.refId = this.properties.GetProperty("ref-id").GetString();

                if (this.refId.Equals(""))
                {
                    throw new FonetException("page-number-citation must contain \"ref-id\"");
                }

                this.id = this.properties.GetProperty("id").GetString();
                idReferences.CreateID(id);
                ts = new TextState();

                this.marker = 0;
            }

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


            pageNumber = idReferences.getPageNumber(refId);

            if (pageNumber != null)
            {
                this.marker =
                    FOText.addText((BlockArea)area,
                                   propMgr.GetFontState(area.getFontInfo()), red,
                                   green, blue, wrapOption, null,
                                   whiteSpaceCollapse, pageNumber.ToCharArray(),
                                   0, pageNumber.Length, ts,
                                   VerticalAlign.BASELINE);
            }
            else
            {
                BlockArea blockArea = (BlockArea)area;
                LineArea  la        = blockArea.getCurrentLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.changeFont(propMgr.GetFontState(area.getFontInfo()));
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                la.addPageNumberCitation(refId, null);
                this.marker = -1;
            }

            if (this.marker == -1)
            {
                return(new Status(Status.OK));
            }
            else
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
        }
Exemple #18
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.GetMyRefs().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));
        }
Exemple #19
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();
                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));
        }
        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();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                string id       = this.properties.GetProperty("id").GetString();
                int    align    = this.properties.GetProperty("text-align").GetEnum();
                int    valign   = this.properties.GetProperty("vertical-align").GetEnum();
                int    overflow = this.properties.GetProperty("overflow").GetEnum();

                this.breakBefore = this.properties.GetProperty("break-before").GetEnum();
                this.breakAfter  = this.properties.GetProperty("break-after").GetEnum();
                this.width       = this.properties.GetProperty("width").GetLength().MValue();
                this.height      = this.properties.GetProperty("height").GetLength().MValue();
                this.contwidth   =
                    this.properties.GetProperty("content-width").GetLength().MValue();
                this.contheight =
                    this.properties.GetProperty("content-height").GetLength().MValue();
                this.wauto  = this.properties.GetProperty("width").GetLength().IsAuto();
                this.hauto  = this.properties.GetProperty("height").GetLength().IsAuto();
                this.cwauto =
                    this.properties.GetProperty("content-width").GetLength().IsAuto();
                this.chauto =
                    this.properties.GetProperty("content-height").GetLength().IsAuto();

                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.scaling = this.properties.GetProperty("scaling").GetEnum();

                area.getIDReferences().CreateID(id);
                if (this.areaCurrent == null)
                {
                    this.areaCurrent =
                        new ForeignObjectArea(propMgr.GetFontState(area.getFontInfo()),
                                              area.getAllocationWidth());

                    this.areaCurrent.start();
                    areaCurrent.SetWidth(this.width);
                    areaCurrent.SetHeight(this.height);
                    areaCurrent.SetContentWidth(this.contwidth);
                    areaCurrent.setContentHeight(this.contheight);
                    areaCurrent.setScaling(this.scaling);
                    areaCurrent.setAlign(align);
                    areaCurrent.setVerticalAlign(valign);
                    areaCurrent.setOverflow(overflow);
                    areaCurrent.setSizeAuto(wauto, hauto);
                    areaCurrent.setContentSizeAuto(cwauto, chauto);

                    areaCurrent.setPage(area.getPage());

                    int numChildren = this.children.Count;
                    if (numChildren > 1)
                    {
                        throw new FonetException("Only one child element is allowed in an instream-foreign-object");
                    }
                    if (this.children.Count > 0)
                    {
                        FONode fo = (FONode)children[0];
                        Status status;
                        if ((status =
                                 fo.Layout(this.areaCurrent)).isIncomplete())
                        {
                            return(status);
                        }
                        this.areaCurrent.end();
                    }
                }

                this.marker = 0;

                if (breakBefore == BreakBefore.PAGE ||
                    ((spaceBefore + areaCurrent.getEffectiveHeight())
                     > 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 (this.areaCurrent == null)
            {
                return(new Status(Status.OK));
            }

            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 (areaCurrent.getEffectiveWidth() > la.getRemainingWidth())
                {
                    la = ba.createNextLineArea();
                    if (la == null)
                    {
                        return(new Status(Status.AREA_FULL_NONE));
                    }
                }
                la.addInlineArea(areaCurrent, GetLinkSet());
            }
            else
            {
                area.addChild(areaCurrent);
                area.increaseHeight(areaCurrent.getEffectiveHeight());
            }

            if (this.isInTableCell)
            {
                startIndent += forcedStartOffset;
            }

            areaCurrent.setStartIndent(startIndent);
            areaCurrent.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));
            }

            areaCurrent = null;
            return(new Status(Status.OK));
        }
Exemple #21
0
        public override Status Layout(Area area)
        {
            BlockArea blockArea;

            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Currently Character can only be in a BlockArea");
                return(new Status(Status.OK));
            }
            blockArea = (BlockArea)area;
            bool textDecoration;

            AuralProps            mAurProps  = propMgr.GetAuralProps();
            BorderAndPadding      bap        = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps     = propMgr.GetBackgroundProps();
            HyphenationProps      mHyphProps = propMgr.GetHyphenationProps();
            MarginInlineProps     mProps     = propMgr.GetMarginInlineProps();
            RelativePositionProps mRelProps  = propMgr.GetRelativePositionProps();
            ColorType             c          = properties.GetColorType();
            float red   = c.Red;
            float green = c.Green;
            float blue  = c.Blue;

            int        whiteSpaceCollapse = properties.GetWhiteSpaceCollapse();
            WrapOption wrapOption         = this.parent.properties.GetWrapOption();

            TextDecoration tmp = properties.GetTextDecoration();

            if (tmp == TextDecoration.UNDERLINE)
            {
                textDecoration = true;
            }
            else
            {
                textDecoration = false;
            }

            char   characterValue = this.properties.GetChar();
            string id             = this.properties.GetId();

            blockArea.GetMyRefs().InitializeID(id, blockArea);

            LineArea la = blockArea.getCurrentLineArea();

            if (la == null)
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
            la.changeFont(propMgr.GetFontState(area.getFontInfo()));
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            blockArea.setupLinkSet(this.GetLinkSet());
            int result = la.addCharacter(characterValue, this.GetLinkSet(),
                                         textDecoration);

            if (result == Character.DOESNOT_FIT)
            {
                la = blockArea.createNextLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.changeFont(propMgr.GetFontState(area.getFontInfo()));
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                blockArea.setupLinkSet(this.GetLinkSet());
                la.addCharacter(characterValue, this.GetLinkSet(),
                                textDecoration);
            }
            return(new Status(Status.OK));
        }
Exemple #22
0
        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));
            }
        }
Exemple #23
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();
                MarginProps           mProps    = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align      = this.properties.GetTextAlign();
                this.alignLast  = this.properties.GetTextAlignLast();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();
                this.id = this.properties.GetProperty("id").GetString();

                area.getIDReferences().CreateID(id);

                this.marker = 0;
            }

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

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

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

            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.start();

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

            int numChildren = this.children.Count;

            if (numChildren != 2)
            {
                throw new FonetException("list-item must have exactly two children");
            }
            ListItemLabel label = (ListItemLabel)children[0];
            ListItemBody  body  = (ListItemBody)children[1];

            Status status;

            if (this.marker == 0)
            {
                area.GetMyRefs().ConfigureID(id, area);

                status = label.Layout(blockArea);
                if (status.isIncomplete())
                {
                    return(status);
                }
            }

            status = body.Layout(blockArea);
            if (status.isIncomplete())
            {
                blockArea.end();
                area.addChild(blockArea);
                area.increaseHeight(blockArea.GetHeight());
                this.marker = 1;
                return(status);
            }

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

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

            if (area is BlockArea)
            {
                area.start();
            }
            this.blockArea.isLast(true);
            return(new Status(Status.OK));
        }
Exemple #24
0
        public BackgroundProps GetBackgroundProps()
        {
            if (bgProps == null)
            {
                bgProps = new BackgroundProps();

                bgProps.backColor =
                    properties.GetProperty("background-color").GetColorType();

                string src = properties.GetProperty("background-image").GetString();
                if (src == "none")
                {
                    bgProps.backImage = null;
                }
                else if (src == "inherit")
                {
                    bgProps.backImage = null;
                }
                else
                {
                    try
                    {
                        bgProps.backImage = FonetImageFactory.Make(src);
                    }
                    catch (FonetImageException imgex)
                    {
                        bgProps.backImage = null;
                        FonetDriver.ActiveDriver.FireFonetError(imgex.Message);
                    }
                }

                bgProps.backRepeat = properties.GetProperty("background-repeat").GetEnum();
            }
            return bgProps;
        }
Exemple #25
0
        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));
        }
Exemple #26
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;

            // Apply fix proposed by claytonrumley
            // on http://fonet.codeplex.com/workitem/4647
            if (area is BlockArea)
            {
                container = ((BlockArea)area).getNearestAncestorAreaContainer();
            }
            else
            {
                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));
        }
Exemple #27
0
        /// <summary>
        ///     Renders an area's background.
        /// </summary>
        /// <param name="area">The area whose background is to be rendered.</param>
        /// <param name="x">The x position of the left edge in millipoints.</param>
        /// <param name="y">The y position of top edge in millipoints.</param>
        /// <param name="w">The width in millipoints.</param>
        /// <param name="h">The height in millipoints.</param>
        private void DoBackground(Area area, int x, int y, int w, int h)
        {
            if (h == 0 || w == 0)
            {
                return;
            }

            BackgroundProps props = area.getBackground();

            if (props == null)
            {
                return;
            }

            if (props.backColor.Alpha == 0)
            {
                AddFilledRect(x, y, w, -h, props.backColor.ToPdfColor());
            }

            if (props.backImage != null)
            {
                int imgW = props.backImage.Width * 1000;
                int imgH = props.backImage.Height * 1000;

                int dx    = x;
                int dy    = y;
                int endX  = x + w;
                int endY  = y - h;
                int clipW = w % imgW;
                int clipH = h % imgH;

                bool repeatX = true;
                bool repeatY = true;
                switch (props.backRepeat)
                {
                case BackgroundRepeat.REPEAT:
                    break;

                case BackgroundRepeat.REPEAT_X:
                    repeatY = false;
                    break;

                case BackgroundRepeat.REPEAT_Y:
                    repeatX = false;
                    break;

                case BackgroundRepeat.NO_REPEAT:
                    repeatX = false;
                    repeatY = false;
                    break;

                case BackgroundRepeat.INHERIT:
                    break;

                default:
                    FonetDriver.ActiveDriver.FireFonetWarning("Ignoring invalid background-repeat property");
                    break;
                }

                while (dy > endY)
                {     // looping through rows
                    while (dx < endX)
                    { // looping through cols
                        if (dx + imgW <= endX)
                        {
                            // no x clipping
                            if (dy - imgH >= endY)
                            {
                                // no x clipping, no y clipping
                                DrawImageScaled(dx, dy, imgW, imgH, props.backImage);
                            }
                            else
                            {
                                // no x clipping, y clipping
                                DrawImageClipped(dx, dy, 0, 0, imgW, clipH, props.backImage);
                            }
                        }
                        else
                        {
                            // x clipping
                            if (dy - imgH >= endY)
                            {
                                // x clipping, no y clipping
                                DrawImageClipped(dx, dy, 0, 0, clipW, imgH, props.backImage);
                            }
                            else
                            {
                                // x clipping, y clipping
                                DrawImageClipped(dx, dy, 0, 0, clipW, clipH, props.backImage);
                            }
                        }

                        if (repeatX)
                        {
                            dx += imgW;
                        }
                        else
                        {
                            break;
                        }
                    } // end looping through cols

                    dx = x;

                    if (repeatY)
                    {
                        dy -= imgH;
                    }
                    else
                    {
                        break;
                    }
                } // end looping through rows
            }
        }
Exemple #28
0
        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.GetTextAlign();
                this.alignLast  = this.properties.GetTextAlignLast();
                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)
            {
                MyIDRefs refs = (MyIDRefs)area.getIDReferences();
                refs.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));
        }