예제 #1
0
 internal FormattedCell(Cell cell, DocumentRenderer documentRenderer, Borders cellBorders, FieldInfos fieldInfos, XUnit xOffset, XUnit yOffset)
 {
   this.cell = cell;
   this.fieldInfos = fieldInfos;
   this.yOffset = yOffset;
   this.xOffset = xOffset;
   this.bordersRenderer = new BordersRenderer(cellBorders, null);
   this.documentRenderer = documentRenderer;
 }
예제 #2
0
 internal FormattedCell(Cell cell, DocumentRenderer documentRenderer, Borders cellBorders, FieldInfos fieldInfos, XUnit xOffset, XUnit yOffset)
 {
     _cell = cell;
     _fieldInfos = fieldInfos;
     _yOffset = yOffset;
     _xOffset = xOffset;
     _bordersRenderer = new BordersRenderer(cellBorders, null);
     _documentRenderer = documentRenderer;
 }
예제 #3
0
        public void GetLabelCell(Cell cell)
        {
            var cellContent =  cell.AddParagraph();

            foreach (var img in _images)
            {
                //TODO: Images
            }

            foreach (var txt in _textChunks)
            {
                cellContent.AddText(txt.Text);
                cellContent.Format.Font.Size = Unit.FromPoint(txt.FontSize);
                cellContent.Format.Font.Name = txt.FontName;
                //TODO: Styles
                
            }

            
            cellContent.Format.Alignment = (ParagraphAlignment)_hAlign;
            cell.VerticalAlignment = VerticalAlignment.Top;
        }
예제 #4
0
파일: DdlParser.cs 프로젝트: Sl0vi/MigraDoc
        /// <summary>
        /// Parses the keyword «\cell».
        /// </summary>
        private void ParseCell(Cell cell)
        {
            Debug.Assert(cell != null);
            Debug.Assert(Symbol == Symbol.Cell);

            ReadCode();
            if (Symbol == Symbol.BracketLeft)
                ParseAttributes(cell);

            // Empty cells without braces are valid.
            if (Symbol == Symbol.BraceLeft)
            {
                if (IsParagraphContent())
                {
                    ParseParagraphContent(cell.Elements, null);
                }
                else
                {
                    ReadCode();
                    if (Symbol != Symbol.BraceRight)
                        ParseDocumentElements(cell.Elements, Symbol.Cell);
                }
                AssertSymbol(Symbol.BraceRight);
                ReadCode(); // read '}'
            }
        }
예제 #5
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);
        }
예제 #6
0
 internal override void VisitCell(Cell cell)
 {
     // format, shading and borders are already processed.
 }
예제 #7
0
        private void EqualizeRoundedCornerBorders(Cell cell)
        {
            // If any of a corner relevant border is set, we want to copy its values to the second corner relevant border, 
            // to ensure the innerWidth of the cell is the same, regardless of which border is used.
            // If set, we use the vertical borders as source for the values, otherwise we use the horizontal borders.
            RoundedCorner roundedCorner = cell.RoundedCorner;

            if (roundedCorner == RoundedCorner.None)
                return;

            BorderType primaryBorderType = BorderType.Top, secondaryBorderType = BorderType.Top;

            if (roundedCorner == RoundedCorner.TopLeft || roundedCorner == RoundedCorner.BottomLeft)
                primaryBorderType = BorderType.Left;
            if (roundedCorner == RoundedCorner.TopRight || roundedCorner == RoundedCorner.BottomRight)
                primaryBorderType = BorderType.Right;

            if (roundedCorner == RoundedCorner.TopLeft || roundedCorner == RoundedCorner.TopRight)
                secondaryBorderType = BorderType.Top;
            if (roundedCorner == RoundedCorner.BottomLeft || roundedCorner == RoundedCorner.BottomRight)
                secondaryBorderType = BorderType.Bottom;

            // If both borders don't exist, there's nothing to do and we should not create one by accessing it.
            if (!cell.Borders.HasBorder(primaryBorderType) && !cell.Borders.HasBorder(secondaryBorderType))
                return;

            // Get the borders. By using GV.ReadWrite we create the border, if not existing.
            Border primaryBorder = (Border) cell.Borders.GetValue(primaryBorderType.ToString(), GV.ReadWrite);
            Border secondaryBorder = (Border) cell.Borders.GetValue(secondaryBorderType.ToString(), GV.ReadWrite);

            Border source = primaryBorder.Visible ? primaryBorder
                : secondaryBorder.Visible ? secondaryBorder : null;
            Border target = primaryBorder.Visible ? secondaryBorder
                : secondaryBorder.Visible ? primaryBorder : null;

            if (source == null || target == null)
                return;

            target.Visible = source.Visible;
            target.Width = source.Width;
            target.Style = source.Style;
            target.Color = source.Color;
        }
예제 #8
0
 private void RenderShading(Cell cell, Rectangle innerRect)
 {
     ShadingRenderer shadeRenderer = new ShadingRenderer(_gfx, cell.Shading);
     shadeRenderer.Render(innerRect.X, innerRect.Y, innerRect.Width, innerRect.Height, cell.RoundedCorner);
 }
예제 #9
0
 void RenderCell(Cell cell)
 {
   Rectangle innerRect = GetInnerRect(CalcStartingHeight(), cell);
   RenderShading(cell, innerRect);
   RenderContent(cell, innerRect);
   RenderBorders(cell, innerRect);
 }
예제 #10
0
        /// <summary>
        /// Returns whether cell2 is a neighbor of cell1 at the specified position.
        /// </summary>
        private bool IsNeighbor(Cell cell1, Cell cell2, NeighborPosition position)
        {
            bool isNeighbor = false;
              switch (position)
              {
            case NeighborPosition.Bottom:
              int bottomRowIdx = cell1.Row.Index + cell1.MergeDown + 1;
              isNeighbor = cell2.Row.Index == bottomRowIdx &&
            cell2.Column.Index <= cell1.Column.Index &&
            cell2.Column.Index + cell2.MergeRight >= cell1.Column.Index;
              break;

            case NeighborPosition.Left:
              int leftClmIdx = cell1.Column.Index - 1;
              isNeighbor = cell2.Row.Index <= cell1.Row.Index &&
            cell2.Row.Index + cell2.MergeDown >= cell1.Row.Index &&
            cell2.Column.Index + cell2.MergeRight == leftClmIdx;
              break;

            case NeighborPosition.Right:
              int rightClmIdx = cell1.Column.Index + cell1.MergeRight + 1;
              isNeighbor = cell2.Row.Index <= cell1.Row.Index &&
            cell2.Row.Index + cell2.MergeDown >= cell1.Row.Index &&
            cell2.Column.Index == rightClmIdx;
              break;

            case NeighborPosition.Top:
              int topRowIdx = cell1.Row.Index - 1;
              isNeighbor = cell2.Row.Index + cell2.MergeDown == topRowIdx &&
            cell2.Column.Index + cell2.MergeRight >= cell1.Column.Index &&
            cell2.Column.Index <= cell1.Column.Index;
              break;
              }
              return isNeighbor;
        }
예제 #11
0
 private void FormatCell(ref Cell cellName, string className)
 {
     if (className == "RaisedOrBetter")
     {
         // If the cell's value gets better
         cellName.Format.Font.Color = Colors.LightGreen;
     }
     else if (className == "LowerOrWorse")
     {
         // If the cell's value gets worse
         cellName.Format.Font.Color = Colors.Red;
     }
     else if (className == "sev1")
     {
         // If the cell's become a Sev1
         cellName.Shading.Color = Colors.Red;
     }
 }
예제 #12
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);
    }
예제 #13
0
        /// <summary>
        /// Renders the cell's shading, borders and so on (used by the RowRenderer).
        /// </summary>
        internal override void Render()
        {
            useEffectiveValue = true;
              this.coveringCell = this.cellList.GetCoveringCell(this.cell);
              Borders borders = this.cellList.GetEffectiveBorders(this.coveringCell);
              if (this.cell.Column.Index != this.coveringCell.Column.Index)
            return;

              if (borders != null)
              {
            BordersRenderer brdrsRenderer = new BordersRenderer(borders, this.docRenderer);
            brdrsRenderer.leaveAwayLeft = this.cell.Column.Index != this.coveringCell.Column.Index;
            brdrsRenderer.leaveAwayTop = this.cell.Row.Index != this.coveringCell.Row.Index;
            brdrsRenderer.leaveAwayBottom = this.cell.Row.Index != this.coveringCell.Row.Index + this.coveringCell.MergeDown;
            brdrsRenderer.leaveAwayRight = false;
            brdrsRenderer.ParentCell = this.cell;
            brdrsRenderer.Render();
              }
              if (cell == this.coveringCell)
              {
            RenderLeftRightPadding();
            Translate("VerticalAlignment", "clvertal");
              }
              object obj = this.coveringCell.GetValue("Shading", GV.GetNull);
              if (obj != null)
            new ShadingRenderer((DocumentObject)obj, this.docRenderer).Render();

              //Note that vertical and horizontal merging are not symmetrical.
              //Horizontally merged cells are simply rendered as bigger cells.
              if (this.cell.Row.Index == this.coveringCell.Row.Index && this.coveringCell.MergeDown > 0)
            this.rtfWriter.WriteControl("clvmgf");

              if (this.cell.Row.Index > this.coveringCell.Row.Index)
            this.rtfWriter.WriteControl("clvmrg");

              this.rtfWriter.WriteControl("cellx", GetRightCellBoundary());
        }
예제 #14
0
        /// <summary>
        /// Gets a borders object that should be used for rendering.
        /// </summary>
        /// <exception cref="System.ArgumentException">
        ///   Thrown when the cell is not in this list.
        ///   This situation occurs if the given cell is merged "away" by a previous one.
        /// </exception>
        public Borders GetEffectiveBorders(Cell cell)
        {
            Borders borders = cell.GetValue("Borders", GV.ReadOnly) as Borders;
              if (borders != null)
              {
            Document doc = borders.Document;
            borders = borders.Clone();
            borders.parent = cell;
            doc = borders.Document;
              }
              else
            borders = new Borders(cell.parent);

              int cellIdx = this.BinarySearch(cell, new CellComparer());
              if (!(cellIdx >= 0 && cellIdx < this.Count))
            throw new ArgumentException("cell is not a relevant cell", "cell");

              if (cell.mergeRight > 0)
              {
            Cell rightBorderCell = cell.Table[cell.Row.Index, cell.Column.Index + cell.mergeRight];
            if (rightBorderCell.borders != null && rightBorderCell.borders.right != null)
              borders.Right = rightBorderCell.borders.right.Clone();
            else
              borders.right = null;
              }

              if (cell.mergeDown > 0)
              {
            Cell bottomBorderCell = cell.Table[cell.Row.Index + cell.mergeDown, cell.Column.Index];
            if (bottomBorderCell.borders != null && bottomBorderCell.borders.bottom != null)
              borders.Bottom = bottomBorderCell.borders.bottom.Clone();
            else
              borders.bottom = null;
              }

              Cell leftNeighbor = GetNeighbor(cellIdx, NeighborPosition.Left);
              Cell rightNeighbor = GetNeighbor(cellIdx, NeighborPosition.Right);
              Cell topNeighbor = GetNeighbor(cellIdx, NeighborPosition.Top);
              Cell bottomNeighbor = GetNeighbor(cellIdx, NeighborPosition.Bottom);
              if (leftNeighbor != null)
              {
            Borders nbrBrdrs = leftNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
            if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Right) >= GetEffectiveBorderWidth(borders, BorderType.Left))
              borders.SetValue("Left", GetBorderFromBorders(nbrBrdrs, BorderType.Right));
              }
              if (rightNeighbor != null)
              {
            Borders nbrBrdrs = rightNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
            if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Left) > GetEffectiveBorderWidth(borders, BorderType.Right))
              borders.SetValue("Right", GetBorderFromBorders(nbrBrdrs, BorderType.Left));
              }
              if (topNeighbor != null)
              {
            Borders nbrBrdrs = topNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
            if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Bottom) >= GetEffectiveBorderWidth(borders, BorderType.Top))
              borders.SetValue("Top", GetBorderFromBorders(nbrBrdrs, BorderType.Bottom));
              }
              if (bottomNeighbor != null)
              {
            Borders nbrBrdrs = bottomNeighbor.GetValue("Borders", GV.ReadWrite) as Borders;
            if (nbrBrdrs != null && GetEffectiveBorderWidth(nbrBrdrs, BorderType.Top) > GetEffectiveBorderWidth(borders, BorderType.Bottom))
              borders.SetValue("Bottom", GetBorderFromBorders(nbrBrdrs, BorderType.Top));
              }
              return borders;
        }
예제 #15
0
 internal CellFormatRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.cell = domObj as Cell;
 }
예제 #16
0
 private static void SetCellResultStyle(Cell pdfCell, Color color)
 {
     pdfCell.Style = "RightAligned";
     pdfCell.Shading.Visible = true;
     pdfCell.Shading.Color = color;
 }
예제 #17
0
 /// <summary>
 /// Gets the cell that covers the given cell by merging. Usually the cell itself if not merged.
 /// </summary>
 public Cell GetCoveringCell(Cell cell)
 {
     int cellIdx = this.BinarySearch(cell, new CellComparer());
       if (cellIdx >= 0 && cellIdx < this.Count)
     return this[cellIdx];
       else //Binary Search returns the complement of the next value, therefore, "~cellIdx - 1" is the previous cell.
     cellIdx = ~cellIdx - 1;
       for (int index = cellIdx; index >= 0; --index)
       {
     Cell currCell = this[index];
     if (currCell.Column.Index <= cell.Column.Index &&
       currCell.Column.Index + currCell.MergeRight >= cell.Column.Index &&
       currCell.Row.Index <= cell.Row.Index &&
       currCell.Row.Index + currCell.MergeDown >= cell.Row.Index)
       return currCell;
       }
       return null;
 }
예제 #18
0
        private static void CreateMicTable(Document doc, SetItem itemSet, Section section, out Table table, out Row row, out Cell cell)
        {
            table = new Table();
            table.Borders.Width = "0.015cm";

            int i = 0;
            int cntr = 0;

            //Add CEll, Number, MusNumber, Organism to table
            //CEll
            var column = table.AddColumn("0.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            // MusNumber
            column = table.AddColumn("2cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            // Organism
            column = table.AddColumn("1.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Mic
            var micCount = itemSet.MICList.Count;
            double micWidth = ((doc.DefaultPageSetup.PageWidth.Centimeter - 5.5*(section.PageSetup.LeftMargin.Centimeter + section.PageSetup.RightMargin.Centimeter) )
                / micCount);

            for (int j = 0; j < micCount ; j++)
            {
                column = table.AddColumn(micWidth.ToString() + "cm");
                column.Format.Alignment = ParagraphAlignment.Center;
            }

            // Total Mic
            column = table.AddColumn("1.8cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            //Add header row
            row = table.AddRow();

            row.Height = "0.4cm";
            row.HeadingFormat = true;
            row.Borders.Bottom.Width = "0.05cm";

            cell = row.Cells[0];
            cell.AddParagraph("Ячейка");
            cell.VerticalAlignment = VerticalAlignment.Center;

            cell = row.Cells[1];
            cell.AddParagraph("Муз.№");
            cell.VerticalAlignment = VerticalAlignment.Center;

            cell = row.Cells[2];
            cell.AddParagraph("МО");
            cell.VerticalAlignment = VerticalAlignment.Center;

            for (int j = 0; j < micCount ; j++)
            {
                cell = row.Cells[3 + j];
                cell.VerticalAlignment = VerticalAlignment.Center;
                cell.AddParagraph(itemSet.MICList[j].ToString());
            }

            cell = row.Cells[3 + micCount];
            cell.VerticalAlignment = VerticalAlignment.Center;
            cell.AddParagraph("МПК");
        }
예제 #19
0
    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);
    }
예제 #20
0
 private Cell FormatCell(Cell cell)
 {
     cell.Row.Borders.Visible = IncludeLabelBorders;
     if(IncludeLabelBorders)
     { 
     cell.Row.Borders.Top.Style = MigraDoc.DocumentObjectModel.BorderStyle.Single;
     cell.Row.Borders.Top.Color = Color.Parse("Black");
     cell.Row.Borders.Bottom.Style = MigraDoc.DocumentObjectModel.BorderStyle.Single;
     cell.Row.Borders.Bottom.Color = Color.Parse("Black");
     cell.Row.Borders.Left.Style = MigraDoc.DocumentObjectModel.BorderStyle.Single;
     cell.Row.Borders.Left.Color = Color.Parse("Black");
     cell.Row.Borders.Right.Style = MigraDoc.DocumentObjectModel.BorderStyle.Single;
     cell.Row.Borders.Right.Color = Color.Parse("Black");
     }
     return cell;
 }
예제 #21
0
        //---------------------------
        private static void AddIamge(Cell cell, MyImage ImageFile, string ImageWidth)
        {
            //row.Shading.Color = TableBlue;
            Image img = cell.AddImage(ImageFile.ImageFile);

            if (ImageFile.ImageOrientation == Orientation.Landscape)
            { img.Width = ImageWidth; }
            else
            { img.Height = "9.8cm"; }

            //img.Height = "9cm";
            img.LockAspectRatio = true;

            cell.Format.Font.Bold = false;
            cell.Format.Alignment =  ParagraphAlignment.Center;
            cell.VerticalAlignment = VerticalAlignment.Center;
        }
예제 #22
0
 void RenderShading(Cell cell, Rectangle innerRect)
 {
   ShadingRenderer shadeRenderer = new ShadingRenderer(this.gfx, cell.Shading);
   shadeRenderer.Render(innerRect.X, innerRect.Y, innerRect.Width, innerRect.Height);
 }
예제 #23
0
        /// <summary>
        /// Returns whether the given cell is already covered by a preceding cell in this instance.
        /// </summary>
        /// <remarks>
        /// Help function for Init().
        /// </remarks>
        private bool IsAlreadyCovered(Cell cell)
        {
            for (int index = this.Count - 1; index >= 0; --index)
              {

            Cell currentCell = this[index];
            if (currentCell.Column.Index <= cell.Column.Index && currentCell.Column.Index + currentCell.MergeRight >= cell.Column.Index)
            {
              if (currentCell.Row.Index <= cell.Row.Index && currentCell.Row.Index + currentCell.MergeDown >= cell.Row.Index)
            return true;
              else if (currentCell.Row.Index + currentCell.MergeDown == cell.Row.Index - 1)
            return false;

            }
              }
              return false;
        }
예제 #24
0
    void RenderContent(Cell cell, Rectangle innerRect)
    {
      FormattedCell formattedCell = (FormattedCell)this.formattedCells[cell];
      RenderInfo[] renderInfos = formattedCell.GetRenderInfos();

      if (renderInfos == null)
        return;

      VerticalAlignment verticalAlignment = cell.VerticalAlignment;
      XUnit contentHeight = formattedCell.ContentHeight;
      XUnit innerHeight = innerRect.Height;
      XUnit targetX = innerRect.X + cell.Column.LeftPadding;

      XUnit targetY;
      if (verticalAlignment == VerticalAlignment.Bottom)
      {
        targetY = innerRect.Y + innerRect.Height;
        targetY -= cell.Row.BottomPadding;
        targetY -= contentHeight;
      }
      else if (verticalAlignment == VerticalAlignment.Center)
      {
        targetY = innerRect.Y + cell.Row.TopPadding;
        targetY += innerRect.Y + innerRect.Height - cell.Row.BottomPadding;
        targetY -= contentHeight;
        targetY /= 2;
      }
      else
        targetY = innerRect.Y + cell.Row.TopPadding;

      RenderByInfos(targetX, targetY, renderInfos);
    }
예제 #25
0
        private static string AdjustIfTooWideToFitIn(Cell cell, string text, TextMeasurement tm)
        {
            Column column = cell.Column;
            Unit availableWidth = column.Width - column.Table.Borders.Width - cell.Borders.Width - Unit.FromMillimeter(2);

            var tooWideWords = text.Split(" ".ToCharArray()).Distinct().Where(s => TooWide(s, availableWidth, tm));

            var adjusted = new StringBuilder(text);
            foreach (string word in tooWideWords)
            {
                var replacementWord = MakeFit(word, availableWidth, tm);
                adjusted.Replace(word, replacementWord);
            }

            return adjusted.ToString();
        }
예제 #26
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>
 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;
 }
예제 #27
0
 // Table
 internal virtual void VisitCell(Cell cell) { }