Exemple #1
0
        private void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit   leftPos       = innerRect.X;
            XUnit   rightPos      = leftPos + innerRect.Width;
            XUnit   topPos        = innerRect.Y;
            XUnit   bottomPos     = innerRect.Y + innerRect.Height;
            Borders mergedBorders = _mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, _gfx);
            XUnit           bottomWidth     = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit           leftWidth       = bordersRenderer.GetWidth(BorderType.Left);
            XUnit           topWidth        = bordersRenderer.GetWidth(BorderType.Top);
            XUnit           rightWidth      = bordersRenderer.GetWidth(BorderType.Right);

            if (cell.RoundedCorner == RoundedCorner.TopLeft)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y, innerRect.Width + rightWidth, innerRect.Height + bottomWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.TopRight)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y, innerRect.Width + leftWidth, innerRect.Height + bottomWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.BottomLeft)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y - topWidth, innerRect.Width + rightWidth, innerRect.Height + topWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y - topWidth, innerRect.Width + leftWidth, innerRect.Height + topWidth);
            }

            // Render horizontal and vertical borders only if touching no rounded corner.
            if (cell.RoundedCorner != RoundedCorner.TopRight && cell.RoundedCorner != RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            }

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.BottomLeft)
            {
                bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
            }

            if (cell.RoundedCorner != RoundedCorner.BottomLeft && cell.RoundedCorner != RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
            }

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.TopRight)
            {
                bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);
            }

            RenderDiagonalBorders(mergedBorders, innerRect);
        }
Exemple #2
0
        /// <summary>
        ///   Calculates the top border width for the first row that is rendered or formatted.
        /// </summary>
        /// <param name="row"> The row index. </param>
        private XUnit CalcMaxTopBorderWidth(int row)
        {
            XUnit maxWidth = 0;

            if (_table.Rows.Count > row)
            {
                int  cellIdx = _mergedCells.BinarySearch(_table[row, 0], new CellComparer());
                Cell rowCell = _mergedCells[cellIdx];
                while (cellIdx < _mergedCells.Count)
                {
                    rowCell = _mergedCells[cellIdx];
                    if (rowCell.Row.Index > row)
                    {
                        break;
                    }

                    if (rowCell._borders != null && !rowCell._borders.IsNull())
                    {
                        BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, _gfx);
                        XUnit           width           = bordersRenderer.GetWidth(BorderType.Top);
                        if (width > maxWidth)
                        {
                            maxWidth = width;
                        }
                    }
                    ++cellIdx;
                }
            }
            return(maxWidth);
        }
Exemple #3
0
        /// <summary>
        /// Calculates the top border width for the first row that is rendered or formatted.
        /// </summary>
        /// <param name="row">The row index.</param>
        XUnit CalcMaxTopBorderWidth(int row)
        {
            //!!!modTHHO 09.08.2006 begin
            XUnit maxWidth = 0;

            if (this.table.Rows.Count > row)
            {
                int  cellIdx = this.mergedCells.BinarySearch(this.table[row, 0], new CellComparer());
                Cell rowCell = this.mergedCells[cellIdx];
                while (cellIdx < this.mergedCells.Count)
                {
                    rowCell = this.mergedCells[cellIdx];
                    if (rowCell.Row.Index > row)
                    {
                        break;
                    }

                    if (!rowCell.IsNull("Borders"))
                    {
                        BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, this.gfx);
                        XUnit           width           = 0;
                        width = bordersRenderer.GetWidth(BorderType.Top);
                        if (width > maxWidth)
                        {
                            maxWidth = width;
                        }
                    }
                    ++cellIdx;
                }
            }
            return(maxWidth);
            //!!!modTHHO 09.08.2006 end
        }
Exemple #4
0
        private Rectangle GetInnerRect(XUnit startingHeight, Cell cell)
        {
            BordersRenderer bordersRenderer = new BordersRenderer(_mergedCells.GetEffectiveBorders(cell), _gfx);
            FormattedCell   formattedCell   = _formattedCells[cell];
            XUnit           width           = formattedCell.InnerWidth;

            XUnit y = _startY;

            if (cell.Row.Index > _lastHeaderRow)
            {
                y += startingHeight;
            }
            else
            {
                y += CalcMaxTopBorderWidth(0);
            }

#if true
            // !!!new 18-03-09 Attempt to fix an exception. begin
            XUnit upperBorderPos;
            if (!_bottomBorderMap.TryGetValue(cell.Row.Index, out upperBorderPos))
            {
                //GetType();
            }
            // !!!new 18-03-09 Attempt to fix an exception. end
#else
            XUnit upperBorderPos = _bottomBorderMap[cell.Row.Index];
#endif

            y += upperBorderPos;
            if (cell.Row.Index > _lastHeaderRow)
            {
                y -= _bottomBorderMap[_startRow];
            }

#if true
            // !!!new 18-03-09 Attempt to fix an exception. begin
            XUnit lowerBorderPos;
            if (!_bottomBorderMap.TryGetValue(cell.Row.Index + cell.MergeDown + 1, out lowerBorderPos))
            {
                //GetType();
            }
            // !!!new 18-03-09 Attempt to fix an exception. end
#else
            XUnit lowerBorderPos = _bottomBorderMap[cell.Row.Index + cell.MergeDown + 1];
#endif

            XUnit height = lowerBorderPos - upperBorderPos;
            height -= bordersRenderer.GetWidth(BorderType.Bottom);

            XUnit x = _startX;
            for (int clmIdx = 0; clmIdx < cell.Column.Index; ++clmIdx)
            {
                x += _table.Columns[clmIdx].Width;
            }
            x += LeftBorderOffset;

            return(new Rectangle(x, y, width, height));
        }
Exemple #5
0
        /// <summary>
        ///   Calculates bottom border width of a cell.
        /// </summary>
        /// <param name="cell"> The cell the bottom border of the row that is probed. </param>
        /// <returns> The calculated border width. </returns>
        private XUnit CalcBottomBorderWidth(Cell cell)
        {
            Borders borders = _mergedCells.GetEffectiveBorders(cell);

            if (borders != null)
            {
                BordersRenderer bordersRenderer = new BordersRenderer(borders, _gfx);
                return(bordersRenderer.GetWidth(BorderType.Bottom));
            }
            return(0);
        }
Exemple #6
0
        void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit   leftPos       = innerRect.X;
            XUnit   rightPos      = leftPos + innerRect.Width;
            XUnit   topPos        = innerRect.Y;
            XUnit   bottomPos     = innerRect.Y + innerRect.Height;
            Borders mergedBorders = this.mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx);
            XUnit           bottomWidth     = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit           leftWidth       = bordersRenderer.GetWidth(BorderType.Left);
            XUnit           topWidth        = bordersRenderer.GetWidth(BorderType.Top);
            XUnit           rightWidth      = bordersRenderer.GetWidth(BorderType.Right);

            bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
            bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
            bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);

            RenderDiagonalBorders(mergedBorders, innerRect);
        }
        private Rectangle GetInnerRect(XUnit startingHeight, Cell cell)
        {
            BordersRenderer bordersRenderer = new BordersRenderer(_mergedCells.GetEffectiveBorders(cell), _gfx);
            FormattedCell   formattedCell   = _formattedCells[cell];
            XUnit           width           = formattedCell.InnerWidth;

            XUnit y = _startY;

            if (cell.Row.Index > _lastHeaderRow)
            {
                y += startingHeight;
            }
            else
            {
                y += CalcMaxTopBorderWidth(0);
            }

            XUnit upperBorderPos = _bottomBorderMap[cell.Row.Index];

            y += upperBorderPos;
            if (cell.Row.Index > _lastHeaderRow)
            {
                y -= _bottomBorderMap[_startRow];
            }

            XUnit lowerBorderPos = _bottomBorderMap[cell.Row.Index + cell.MergeDown + 1];


            XUnit height = lowerBorderPos - upperBorderPos;

            height -= bordersRenderer.GetWidth(BorderType.Bottom);

            XUnit x = _startX;

            for (int clmIdx = 0; clmIdx < cell.Column.Index; ++clmIdx)
            {
                x += _table.Columns[clmIdx].Width;
            }
            x += LeftBorderOffset;

            return(new Rectangle(x, y, width, height));
        }
Exemple #8
0
        /// <summary>
        /// Calculates the top border width for the first row that is rendered or formatted.
        /// </summary>
        /// <param name="row">The row index.</param>
        XUnit CalcMaxTopBorderWidth(int row)
        {
            XUnit maxWidth = 0;

            if (this.table.Rows.Count > row)
            {
                foreach (Cell rowCell in this.mergedCells.GetRowCells(row))
                {
                    if (rowCell.HasBorders)
                    {
                        BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, this.gfx);
                        XUnit           width           = 0;
                        width = bordersRenderer.GetWidth(BorderType.Top);
                        if (width > maxWidth)
                        {
                            maxWidth = width;
                        }
                    }
                }
            }
            return(maxWidth);
        }
Exemple #9
0
    void RenderBorders()
    {
      if (this.paragraph.Format.IsNull("Borders"))
        return;

      Area shadingArea = GetShadingArea();
      XUnit left = shadingArea.X;
      XUnit top = shadingArea.Y;
      XUnit bottom = shadingArea.Y + shadingArea.Height;
      XUnit right = shadingArea.X + shadingArea.Width;

      Borders borders = this.paragraph.Format.Borders;
      BordersRenderer bordersRenderer = new BordersRenderer(borders, this.gfx);
      XUnit borderWidth = bordersRenderer.GetWidth(BorderType.Left);
      if (borderWidth > 0)
      {
        left -= borderWidth;
        bordersRenderer.RenderVertically(BorderType.Left, left, top, bottom - top);
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Right);
      if (borderWidth > 0)
      {
        bordersRenderer.RenderVertically(BorderType.Right, right, top, bottom - top);
        right += borderWidth;
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Top);
      if (this.renderInfo.FormatInfo.IsStarting && borderWidth > 0)
      {
        top -= borderWidth;
        bordersRenderer.RenderHorizontally(BorderType.Top, left, top, right - left);
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Bottom);
      if (this.renderInfo.FormatInfo.IsEnding && borderWidth > 0)
      {
        bordersRenderer.RenderHorizontally(BorderType.Bottom, left, bottom, right - left);
      }
    }
Exemple #10
0
    Area GetShadingArea()
    {
      Area contentArea = this.renderInfo.LayoutInfo.ContentArea;
      ParagraphFormat format = this.paragraph.Format;
      XUnit left = contentArea.X;
      left += format.LeftIndent;
      if (format.FirstLineIndent < 0)
        left += format.FirstLineIndent;

      XUnit top = contentArea.Y;
      XUnit bottom = contentArea.Y + contentArea.Height;
      XUnit right = contentArea.X + contentArea.Width;
      right -= format.RightIndent;

      if (!this.paragraph.Format.IsNull("Borders"))
      {
        Borders borders = format.Borders;
        BordersRenderer bordersRenderer = new BordersRenderer(borders, this.gfx);

        if (this.renderInfo.FormatInfo.IsStarting)
          top += bordersRenderer.GetWidth(BorderType.Top);
        if (this.renderInfo.FormatInfo.IsEnding)
          bottom -= bordersRenderer.GetWidth(BorderType.Bottom);

        left -= borders.DistanceFromLeft;
        right += borders.DistanceFromRight;
      }
      return new Rectangle(left, top, right - left, bottom - top);
    }
 /// <summary>
 /// Calculates bottom border width of a cell.
 /// </summary>
 /// <param name="cell">The cell the bottom border of the row that is probed.</param>
 /// <returns>The calculated border width.</returns>
 XUnit CalcBottomBorderWidth(Cell cell)
 {
   Borders borders = this.mergedCells.GetEffectiveBorders(cell);
   if (borders != null)
   {
     BordersRenderer bordersRenderer = new BordersRenderer(borders, this.gfx);
     return bordersRenderer.GetWidth(BorderType.Bottom);
   }
   return 0;
 }
    /// <summary>
    /// Calculates the top border width for the first row that is rendered or formatted.
    /// </summary>
    /// <param name="row">The row index.</param>
    XUnit CalcMaxTopBorderWidth(int row)
    {
      XUnit maxWidth = 0;
      if (this.table.Rows.Count > row)
      {
        int cellIdx = this.mergedCells.BinarySearch(this.table[row, 0], new CellComparer());
        Cell rowCell = this.mergedCells[cellIdx];
        while (cellIdx < this.mergedCells.Count)
        {
          rowCell = this.mergedCells[cellIdx];
          if (rowCell.Row.Index > row)
            break;

          if (!rowCell.IsNull("Borders"))
          {
            BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, this.gfx);
            XUnit width = 0;
            width = bordersRenderer.GetWidth(BorderType.Top);
            if (width > maxWidth)
              maxWidth = width;
          }
          ++cellIdx;
        }
      }
      return maxWidth;
    }
    Rectangle GetInnerRect(XUnit startingHeight, Cell cell)
    {
      BordersRenderer bordersRenderer = new BordersRenderer(this.mergedCells.GetEffectiveBorders(cell), this.gfx);
      FormattedCell formattedCell = (FormattedCell)this.formattedCells[cell];
      XUnit width = formattedCell.InnerWidth;

      XUnit y = this.startY;
      if (cell.Row.Index > this.lastHeaderRow)
        y += startingHeight;
      else
        y += CalcMaxTopBorderWidth(0);

      XUnit upperBorderPos = (XUnit)this.bottomBorderMap[cell.Row.Index];

      y += upperBorderPos;
      if (cell.Row.Index > this.lastHeaderRow)
        y -= (XUnit)this.bottomBorderMap[this.startRow];

      XUnit lowerBorderPos = (XUnit)this.bottomBorderMap[cell.Row.Index + cell.MergeDown + 1];


      XUnit height = lowerBorderPos - upperBorderPos;
      height -= bordersRenderer.GetWidth(BorderType.Bottom);

      XUnit x = this.startX;
      for (int clmIdx = 0; clmIdx < cell.Column.Index; ++clmIdx)
      {
        x += this.table.Columns[clmIdx].Width;
      }
      x += LeftBorderOffset;

      return new Rectangle(x, y, width, height);
    }
    void RenderBorders(Cell cell, Rectangle innerRect)
    {
      XUnit leftPos = innerRect.X;
      XUnit rightPos = leftPos + innerRect.Width;
      XUnit topPos = innerRect.Y;
      XUnit bottomPos = innerRect.Y + innerRect.Height;
      Borders mergedBorders = this.mergedCells.GetEffectiveBorders(cell);

      BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx);
      XUnit bottomWidth = bordersRenderer.GetWidth(BorderType.Bottom);
      XUnit leftWidth = bordersRenderer.GetWidth(BorderType.Left);
      XUnit topWidth = bordersRenderer.GetWidth(BorderType.Top);
      XUnit rightWidth = bordersRenderer.GetWidth(BorderType.Right);

      bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
      bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
      bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
      bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);

      RenderDiagonalBorders(mergedBorders, innerRect);
    }
Exemple #15
0
        /// <summary>
        ///   Calculates the top border width for the first row that is rendered or formatted.
        /// </summary>
        /// <param name="row"> The row index. </param>
        private XUnit CalcMaxTopBorderWidth(int row)
        {
            XUnit maxWidth = 0;
            if (_table.Rows.Count > row)
            {
                int cellIdx = _mergedCells.BinarySearch(_table[row, 0], new CellComparer());
                Cell rowCell = _mergedCells[cellIdx];
                while (cellIdx < _mergedCells.Count)
                {
                    rowCell = _mergedCells[cellIdx];
                    if (rowCell.Row.Index > row)
                        break;

                    if (rowCell._borders != null && !rowCell._borders.IsNull())
                    {
                        BordersRenderer bordersRenderer = new BordersRenderer(rowCell.Borders, _gfx);
                        XUnit width = bordersRenderer.GetWidth(BorderType.Top);
                        if (width > maxWidth)
                            maxWidth = width;
                    }
                    ++cellIdx;
                }
            }
            return maxWidth;
        }
Exemple #16
0
        private void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit leftPos = innerRect.X;
            XUnit rightPos = leftPos + innerRect.Width;
            XUnit topPos = innerRect.Y;
            XUnit bottomPos = innerRect.Y + innerRect.Height;
            Borders mergedBorders = _mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, _gfx);
            XUnit bottomWidth = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit leftWidth = bordersRenderer.GetWidth(BorderType.Left);
            XUnit topWidth = bordersRenderer.GetWidth(BorderType.Top);
            XUnit rightWidth = bordersRenderer.GetWidth(BorderType.Right);

            if (cell.RoundedCorner == RoundedCorner.TopLeft)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y, innerRect.Width + rightWidth, innerRect.Height + bottomWidth);
            else if (cell.RoundedCorner == RoundedCorner.TopRight)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y, innerRect.Width + leftWidth, innerRect.Height + bottomWidth);
            else if (cell.RoundedCorner == RoundedCorner.BottomLeft)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y - topWidth, innerRect.Width + rightWidth, innerRect.Height + topWidth);
            else if (cell.RoundedCorner == RoundedCorner.BottomRight)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y - topWidth, innerRect.Width + leftWidth, innerRect.Height + topWidth);

            // Render horizontal and vertical borders only if touching no rounded corner.
            if (cell.RoundedCorner != RoundedCorner.TopRight && cell.RoundedCorner != RoundedCorner.BottomRight)
                bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            
            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.BottomLeft)
                bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);

            if (cell.RoundedCorner != RoundedCorner.BottomLeft && cell.RoundedCorner != RoundedCorner.BottomRight)
                bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.TopRight)
                bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);
            
            RenderDiagonalBorders(mergedBorders, innerRect);
        }