Beispiel #1
0
        public ITableCell CreateTableCell(IList <IParagraph> cellContents, TableCellPropertiesModel cellModel)
        {
            if (cellContents == null)
            {
                throw new ArgumentNullException("cellContents must not be null");
            }
            if (cellContents.Count == 0)
            {
                throw new ArgumentNullException("cellContents must not be an empty list");
            }
            if (cellContents.Any(e => e == null))
            {
                throw new ArgumentNullException("All elements of cellContents must be not null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            var platformCellTable = PlatformTableCell.New();

            if (cellModel != null)
            {
                AutoMapper.Mapper.Map(cellModel, platformCellTable.Properties);
            }

            TableCell tc = platformCellTable.ContentItem as TableCell;

            var tableCellProperties = platformCellTable.Properties.ContentItem as TableCellProperties;

            //tableCellProperties.Append(new TableCellVerticalAlignment { Val = cellModel.TableVerticalAlignementValues.ToOOxml() });

            // Modification de la rotation du texte dans la cellule
            if (cellModel.TextDirectionValues.HasValue)
            {
                tableCellProperties.Append(new TextDirection {
                    Val = cellModel.TextDirectionValues.ToOOxml()
                });
            }

            for (int i = 0; i < cellContents.Count; i++)
            {
                platformCellTable.Append(cellContents[i]);
            }

            return(platformCellTable);
        }
Beispiel #2
0
        public ITableCell CreateTableMergeCell(IList <IRun> cellContents, TableCellPropertiesModel cellModel)
        {
            if (cellContents == null)
            {
                throw new ArgumentNullException("cellContents must not be null");
            }
            if (cellContents.Any(e => e == null))
            {
                throw new ArgumentNullException("All elements of cellContents must be not null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            var platformCellTable = PlatformTableCell.New();

            if (cellModel != null)
            {
                AutoMapper.Mapper.Map(cellModel, platformCellTable.Properties);
            }

            TableCell tc = platformCellTable.ContentItem as TableCell;

            var tableCellProperties = platformCellTable.Properties.ContentItem as TableCellProperties;

            //tableCellProperties.Append(new TableCellVerticalAlignment { Val = cellModel.TableVerticalAlignementValues.ToOOxml() });

            // Gestion de la fusion des cellules
            if (cellModel.Fusion)
            {
                if (cellModel.FusionChild)
                {
                    // Obligation de rajouter la balise vMerge, elle permet d'indiquer que la cellule doit fusionner avec la cellule précédente qui contient un vMerge w: val = Restart
                    tableCellProperties.Append(new VerticalMerge() /*Val = MergedCellValues.Continue*/ }
                    {
Beispiel #3
0
        public ITableCell CreateTableCell(IList <IRun> cellContents, TableCellPropertiesModel cellModel)
        {
            if (cellContents == null)
            {
                throw new ArgumentNullException("cellContents must not be null");
            }
            if (cellContents.Count == 0)
            {
                throw new ArgumentNullException("cellContents must not be an empty list");
            }
            if (cellContents.Any(e => e == null))
            {
                throw new ArgumentNullException("All elements of cellContents must be not null");
            }
            if (cellModel == null)
            {
                throw new ArgumentNullException("cellModel must not be null");
            }

            var platformCellTable = PlatformTableCell.New();

            if (cellModel != null)
            {
                AutoMapper.Mapper.Map(cellModel, platformCellTable.Properties);
            }

            TableCell tc = platformCellTable.ContentItem as TableCell;

            var tableCellProperties = platformCellTable.Properties.ContentItem as TableCellProperties;

            //tableCellProperties.Append(new TableCellVerticalAlignment { Val = cellModel.TableVerticalAlignementValues.ToOOxml() });

            // Modification de la rotation du texte dans la cellule
            if (cellModel.TextDirectionValues.HasValue)
            {
                tableCellProperties.Append(new TextDirection {
                    Val = cellModel.TextDirectionValues.ToOOxml()
                });
            }

            Paragraph           par = new Paragraph();
            ParagraphProperties pr  = new ParagraphProperties(); // new TableCellVerticalAlignment { Val = cellModel.TableVerticalAlignementValues.ToOOxml() });

            //new SpacingBetweenLines() { After = cellModel.SpacingAfter, Before = cellModel.SpacingBefore, Line = "240" });

            if (cellModel.Justification.HasValue)
            {
                pr.Append(new Justification()
                {
                    Val = cellModel.Justification.Value.ToOOxml()
                });
            }

            if (cellModel.ParagraphSolidarity)
            {
                pr.Append(new KeepNext());
            }
            par.Append(pr);

            for (int i = 0; i < cellContents.Count; i++)
            {
                par.Append(cellContents[i].ContentItem as Run);
            }

            tc.Append(par);

            return(new PlatformTableCell(tc));
        }