예제 #1
0
파일: Flow.cs 프로젝트: nholik/Fo.Net
        protected Flow(FObj parent, PropertyList propertyList)
            : base(parent, propertyList)
        {
            this.name = GetElementName();

            if (parent.GetName().Equals("fo:page-sequence"))
            {
                this.pageSequence = (PageSequence)parent;
            }
            else
            {
                throw new FonetException("flow must be child of "
                    + "page-sequence, not "
                    + parent.GetName());
            }
            SetFlowName(GetProperty("flow-name").GetString());

            if (pageSequence.IsFlowSet)
            {
                if (this.name.Equals("fo:flow"))
                {
                    throw new FonetException("Only a single fo:flow permitted"
                        + " per fo:page-sequence");
                }
                else
                {
                    throw new FonetException(this.name
                        + " not allowed after fo:flow");
                }
            }
            pageSequence.AddFlow(this);
        }
예제 #2
0
        internal void HaveFormattedPageSequence(PageSequence pageSequence)
        {
            this.pageCount += pageSequence.PageCount;
            if (this.pageSequences == null)
            {
                this.pageSequences = new ArrayList();
            }

            this.pageSequences.Add(
                new PageSequenceResults(
                    pageSequence.GetProperty("id").GetString(),
                    pageSequence.PageCount));
        }
예제 #3
0
파일: Root.cs 프로젝트: nholik/Fo.Net
 public PageSequence getSucceedingPageSequence(PageSequence current)
 {
     int currentIndex = pageSequences.IndexOf(current);
     if (currentIndex == -1)
     {
         return null;
     }
     if (currentIndex < (pageSequences.Count - 1))
     {
         return (PageSequence)pageSequences[currentIndex + 1];
     }
     else
     {
         return null;
     }
 }
예제 #4
0
        public PageSequence getSucceedingPageSequence(PageSequence current)
        {
            int currentIndex = pageSequences.IndexOf(current);

            if (currentIndex == -1)
            {
                return(null);
            }
            if (currentIndex < (pageSequences.Count - 1))
            {
                return((PageSequence)pageSequences[currentIndex + 1]);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
파일: Page.cs 프로젝트: nholik/Fo.Net
 public void setPageSequence(PageSequence pageSequence)
 {
     this.pageSequence = pageSequence;
 }
예제 #6
0
        private void ForcePage(AreaTree areaTree, int firstAvailPageNumber)
        {
            bool bmakePage = false;

            if (this.forcePageCount == ForcePageCount.AUTO)
            {
                PageSequence nextSequence =
                    this.root.getSucceedingPageSequence(this);
                if (nextSequence != null)
                {
                    if (nextSequence.IpnValue.Equals("auto"))
                    {
                        // do nothing
                    }
                    else if (nextSequence.IpnValue.Equals("auto-odd"))
                    {
                        if (firstAvailPageNumber % 2 == 0)
                        {
                            bmakePage = true;
                        }
                    }
                    else if (nextSequence.IpnValue.Equals("auto-even"))
                    {
                        if (firstAvailPageNumber % 2 != 0)
                        {
                            bmakePage = true;
                        }
                    }
                    else
                    {
                        int nextSequenceStartPageNumber =
                            nextSequence.CurrentPageNumber;
                        if ((nextSequenceStartPageNumber % 2 == 0) &&
                            (firstAvailPageNumber % 2 == 0))
                        {
                            bmakePage = true;
                        }
                        else if ((nextSequenceStartPageNumber % 2 != 0) &&
                                 (firstAvailPageNumber % 2 != 0))
                        {
                            bmakePage = true;
                        }
                    }
                }
            }
            else if ((this.forcePageCount == ForcePageCount.EVEN) &&
                     (this.pageCount % 2 != 0))
            {
                bmakePage = true;
            }
            else if ((this.forcePageCount == ForcePageCount.ODD) &&
                     (this.pageCount % 2 == 0))
            {
                bmakePage = true;
            }
            else if ((this.forcePageCount == ForcePageCount.END_ON_EVEN) &&
                     (firstAvailPageNumber % 2 == 0))
            {
                bmakePage = true;
            }
            else if ((this.forcePageCount == ForcePageCount.END_ON_ODD) &&
                     (firstAvailPageNumber % 2 != 0))
            {
                bmakePage = true;
            }
            else if (this.forcePageCount == ForcePageCount.NO_FORCE)
            {
                // do nothing
            }

            if (bmakePage)
            {
                try
                {
                    this.isForcing = true;
                    this.currentPageNumber++;
                    firstAvailPageNumber = this.currentPageNumber;
                    currentPage          = MakePage(areaTree, firstAvailPageNumber, false, true);
                    string formattedPageNumber =
                        pageNumberGenerator.makeFormattedPageNumber(this.currentPageNumber);
                    currentPage.setFormattedNumber(formattedPageNumber);
                    currentPage.setPageSequence(this);
                    FormatStaticContent(areaTree);

                    FonetDriver.ActiveDriver.FireFonetInfo(
                        "[forced-" + firstAvailPageNumber + "]");

                    areaTree.addPage(currentPage);
                    this.root.setRunningPageNumberCounter(this.currentPageNumber);
                    this.isForcing = false;
                }
                catch (FonetException)
                {
                    FonetDriver.ActiveDriver.FireFonetInfo(
                        "'force-page-count' failure");
                }
            }
        }
예제 #7
0
        public void QueuePage(Page page)
        {
            // Process markers
            PageSequence pageSequence = page.getPageSequence();
            if (pageSequence != currentPageSequence)
            {
                currentPageSequence = pageSequence;
                currentPageSequenceMarkers = null;
            }
            ArrayList markers = page.getMarkers();
            if (markers != null)
            {
                if (documentMarkers == null)
                {
                    documentMarkers = new ArrayList();
                }
                if (currentPageSequenceMarkers == null)
                {
                    currentPageSequenceMarkers = new ArrayList();
                }
                for (int i = 0; i < markers.Count; i++)
                {
                    Marker marker = (Marker)markers[i];
                    marker.releaseRegistryArea();
                    currentPageSequenceMarkers.Add(marker);
                    documentMarkers.Add(marker);
                }
            }


            // Try to optimise on the common case that there are no pages pending 
            // and that all ID references are valid on the current pages. This 
            // short-cuts the pipeline and renders the area immediately.
            if ((renderQueue.Count == 0) && idReferences.IsEveryIdValid())
            {
                renderer.Render(page);
            }
            else
            {
                AddToRenderQueue(page);
            }

            pageCount++;
        }
예제 #8
0
        /// <summary>
        ///     Format the PageSequence. The PageSequence formats Pages and adds 
        ///     them to the AreaTree, which subsequently calls the StreamRenderer
        ///     instance (this) again to render the page.  At this time the page 
        ///     might be printed or it might be queued. A page might not be 
        ///     renderable immediately if the IDReferences are not all valid. In 
        ///     this case we defer the rendering until they are all valid.
        /// </summary>
        /// <param name="pageSequence"></param>
        public void Render(PageSequence pageSequence)
        {
            AreaTree a = new AreaTree(this);
            a.setFontInfo(fontInfo);

            pageSequence.Format(a);

            this.results.HaveFormattedPageSequence(pageSequence);

            FonetDriver.ActiveDriver.FireFonetInfo(
                "Last page-sequence produced " + pageSequence.PageCount + " page(s).");
        }