コード例 #1
0
 private void addBlock(RtfBlock block)
 {
     if (block != null)
     {
         _blocks.Add(block);
     }
 }
コード例 #2
0
        public override string render()
        {
            StringBuilder result = new StringBuilder();
            string        align  = "";

            switch (_halign)
            {
            case Align.Left:
                align = @"\ql";
                break;

            case Align.Right:
                align = @"\qr";
                break;

            case Align.Center:
                align = @"\qc";
                break;

            case Align.FullyJustify:
                align = @"\qj";
                break;

            case Align.Distributed:
                align = @"\qd";
                break;
            }


            if (base._blocks.Count <= 0)
            {
                result.AppendLine(@"\pard\intbl");
            }
            else
            {
                for (int i = 0; i < base._blocks.Count; i++)
                {
                    RtfBlock block = (RtfBlock)base._blocks[i];
                    if (_defaultCharFormat != null && block.DefaultCharFormat != null)
                    {
                        block.DefaultCharFormat.copyFrom(_defaultCharFormat);
                    }
                    if (block.Margins[Direction.Top] < 0)
                    {
                        block.Margins[Direction.Top] = 0;
                    }
                    if (block.Margins[Direction.Right] < 0)
                    {
                        block.Margins[Direction.Right] = 0;
                    }
                    if (block.Margins[Direction.Bottom] < 0)
                    {
                        block.Margins[Direction.Bottom] = 0;
                    }
                    if (block.Margins[Direction.Left] < 0)
                    {
                        block.Margins[Direction.Left] = 0;
                    }
                    if (i == 0)
                    {
                        block.BlockHead = @"\pard\intbl" + align;
                    }
                    else
                    {
                        block.BlockHead = @"\par" + align;
                    }
                    block.BlockTail = "";
                    result.AppendLine(block.render());
                }
            }

            result.AppendLine(@"\cell");
            return(result.ToString());
        }