//
        // overflow methods
        //

        #region protected virtual bool StartListInAnotherRegion(PDFUnit itemHeight, PDFLayoutBlock item, int itemindex)

        /// <summary>
        /// Closes down the current list and attempts to open a new region to start laying out any further items.
        /// Returns true if a new region was created, otherwise false.
        /// </summary>
        /// <param name="itemHeight"></param>
        /// <param name="item"></param>
        /// <param name="itemindex"></param>
        /// <returns></returns>
        protected virtual bool StartListInAnotherRegion(PDFUnit itemHeight, PDFLayoutBlock item, int itemindex)
        {
            PDFLayoutRegion itemRegion     = item.CurrentRegion;
            PDFLayoutBlock  origListBlock  = item.Parent as PDFLayoutBlock;
            PDFLayoutRegion origListRegion = origListBlock.CurrentRegion;

            if (origListBlock.IsClosed == false)
            {
                origListBlock.Close();
            }
            //(origListBlock.Parent as PDFLayoutBlock).CurrentRegion.AddToSize(origListBlock);

            bool newPage;
            bool started = this.MoveToNextRegion(itemHeight, ref itemRegion, ref item, out newPage);

            if (started)
            {
                if (this.Context.ShouldLogVerbose)
                {
                    this.Context.TraceLog.Add(TraceLevel.Verbose, ListEngineLogCategory, "Started list '" + this.List.ID + "' in a new " + (newPage ? "Page" : "Region") + " and list item block is now '" + item.ToString() + "'");
                }
            }

            return(started);
        }
        /// <summary>
        /// Moves the entire list block to a new region or page in the layout
        /// </summary>
        /// <param name="requiredHeight"></param>
        /// <returns></returns>
        protected virtual bool MoveFullListToNextRegion(PDFUnit requiredHeight)
        {
            if (_didmovefulllist)
            {
                this.Context.TraceLog.Add(TraceLevel.Error, ListEngineLogCategory, "Already moved list to the next region so cannot move list '" + this.List.ID + "' to the next region");
                return(false);
            }


            PDFLayoutBlock  block  = this._listBlock;
            PDFLayoutRegion region = this._listBlock.CurrentRegion;
            bool            newPage;

            if (this.MoveToNextRegion(requiredHeight, ref region, ref block, out newPage))
            {
                if (this.Context.ShouldLogVerbose)
                {
                    this.Context.TraceLog.Add(TraceLevel.Verbose, ListEngineLogCategory, "Moved entire list '" + this.List.ID + "' to the next " + (newPage ? "Page" : "Region") + " and list block is now '" + block.ToString() + "'");
                }

                //If we have a new block then we set the old one as invisible
                if (block != _listBlock)
                {
                    _listBlock.Position.Visibility = Visibility.None;
                }

                _listBlock       = block;
                _didmovefulllist = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// If there is no open line at the start, or after a hard return, then this created a new one (adding inset as required)
        /// </summary>
        /// <returns></returns>
        private PDFLayoutLine EnsureFirstLineAvailable(out bool startedLine)
        {
            startedLine = false;
            PDFLayoutPage  pg    = this.Context.DocumentLayout.CurrentPage;
            PDFLayoutBlock block = pg.LastOpenBlock();

            if (null == block || block.IsClosed)
            {
                this.Context.TraceLog.Add(TraceLevel.Error, LOG_CATEGORY, "There is no open block on page '" + pg.ToString() + "' to add content to.");
                return(null);

                throw new InvalidOperationException("There is no open block to add the textual content to.");
            }
            PDFLayoutRegion reg = block.CurrentRegion;

            if (null == reg || reg.IsClosed)
            {
                this.Context.TraceLog.Add(TraceLevel.Error, LOG_CATEGORY, "There is no open region in block '" + block.ToString() + "' on page '" + pg.ToString() + "' to add content to.");
                return(null);

                throw new InvalidOperationException("There is no open block to add the textual content to.");
            }
            PDFLayoutLine line;

            if (reg.HasOpenItem)
            {
                line = (PDFLayoutLine)reg.CurrentItem;
            }
            else
            {
                line        = reg.BeginNewLine();
                startedLine = true;
                //No Inset spacer as this will be handled by the begin run
            }

            return(line);
        }