Правки в работе пакета word

This commit is contained in:
kotcheshir73 2022-12-19 11:10:05 +04:00
parent 0afe8a7682
commit 6c2bb49d4d
40 changed files with 1080 additions and 811 deletions

View File

@ -2,7 +2,7 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System.IO;
using ToolsOffice.Implements.WordOpenXML.Extenstions;
using ToolsOffice.Implements.WordOpenXML.Extensions;
using ToolsOffice.Implements.WordOpenXML.Models;
using ToolsOffice.Interfaces.Word;
using ToolsOffice.Interfaces.Word.Models;
@ -17,57 +17,37 @@ namespace ToolsOffice.Implements.WordOpenXML
private MemoryStream _memoryStream;
public override void CreateDocument(ICreateWordModel model)
public override void CreateDocument(ModelWordDocument model)
{
var doc = WordCreateDocument.Create(model);
if (doc == null)
{
return;
}
_memoryStream = new MemoryStream();
_wordDocument = WordprocessingDocument.Create(_memoryStream, WordprocessingDocumentType.Document);
var mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
if (model is WordCreateDocument document)
if (doc != null)
{
mainPart.AddParts(document.WordDocumentParts);
mainPart.AddParts(doc.WordDocumentParts);
}
}
public override void CreateParagraph(IParagraphWordModel model)
public override void CreateParagraph(ModelWordParagraph model)
{
if (model is WordParagraph paragraph)
{
var docParagraph = new Paragraph();
docParagraph.AddParagraphProperties(paragraph.ParagraphProperties);
foreach (var run in paragraph.Texts)
{
docParagraph.AddRun(run);
}
_docBody.AppendChild(docParagraph);
}
_docBody.AddParagraph(model);
}
public override void CreateTable(ITableWordModel model)
public override void CreateTable(ModelWordTable model)
{
if (model is WordTable table)
{
var docTable = new Table();
docTable.AddTableProperties(table.TableProperties);
docTable.AddGridColumn(table.TableGrid);
foreach (var row in table.Rows)
{
docTable.AddTableRow(row);
}
_docBody.AppendChild(docTable);
}
_docBody.AddTable(model);
}
public override Stream SaveDocument(ISaveWordModel info)
public override Stream SaveDocument(ModelWordDocument info)
{
if (info is WordSaveDocument document)
{
_docBody.AddSectionProperties(document);
}
_docBody.AddSectionProperties(info);
_wordDocument.MainDocumentPart.Document.Save();
_wordDocument.Close();
return _memoryStream;

View File

@ -0,0 +1,54 @@
using DocumentFormat.OpenXml.Wordprocessing;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordCellExtension
{
/// <summary>
/// Добавление ячейки в строку
/// </summary>
/// <param name="row"></param>
/// <param name="model"></param>
public static void AddTableCell(this TableRow row, ModelWordTableCell model)
{
if (model == null)
{
return;
}
var cell = new TableCell();
cell.AddTableCellProperties(model);
foreach (var paragraph in model.Texts)
{
cell.AddParagraph(paragraph);
}
row.AppendChild(cell);
}
/// <summary>
/// Добавление свойств ячейки
/// </summary>
/// <param name="run"></param>
/// <param name="model"></param>
private static void AddTableCellProperties(this TableCell cell, ModelWordTableCell model)
{
if (model == null)
{
return;
}
var properties = new TableCellProperties();
if (model.IsNewMerge)
{
properties.AppendChild(new VerticalMerge()
{
Val = MergedCellValues.Restart
});
}
if (model.IsContinueMerge)
{
properties.AppendChild(new VerticalMerge());
}
cell.AppendChild(properties);
}
}
}

View File

@ -0,0 +1,169 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using ToolsModule.ManagmentExtension;
using ToolsOffice.Implements.WordOpenXML.Models;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordDocumentExtension
{
/// <summary>
/// Добавление общих элементов документа
/// </summary>
/// <param name="mainPart"></param>
/// <param name="parts"></param>
public static void AddParts(this MainDocumentPart mainPart, WordDocumentParts parts)
{
if (parts == null)
{
return;
}
CreateDocumentSettingsPart(parts, mainPart);
CreateFontTablesPart(parts, mainPart);
CreateNumberingsPart(parts, mainPart);
CreateStyleDefinitionsPart(parts, mainPart);
CreateThemePart(parts, mainPart);
CreateWebSetting(parts, mainPart);
}
/// <summary>
/// Добавление общих настроек документа
/// </summary>
/// <param name="body"></param>
/// <param name="document"></param>
public static void AddSectionProperties(this Body body, ModelWordDocument model)
{
if (model == null)
{
return;
}
var properties = new SectionProperties();
var pageSize = new PageSize();
if (model.PageSizeHeight != null)
{
pageSize.Height = new UInt32Value(Convert.ToUInt32(model.PageSizeHeight.Value));
}
if (model.PageSizeWidth != null)
{
pageSize.Width = new UInt32Value(Convert.ToUInt32(model.PageSizeWidth.Value));
}
if (model.WordPageOrientation.HasValue)
{
pageSize.Orient = (PageOrientationValues)Enum.Parse(typeof(PageOrientationValues), model.WordPageOrientation.Value.ToString());
}
properties.AppendChild(pageSize);
var pageMargin = new PageMargin();
if (model.PageMarginBottom.HasValue)
{
pageMargin.Bottom = model.PageMarginBottom.Value;
}
if (model.PageMarginFooter != null)
{
pageMargin.Footer = new UInt32Value(Convert.ToUInt32(model.PageMarginFooter.Value));
}
if (model.PageMarginGutter != null)
{
pageMargin.Gutter = new UInt32Value(Convert.ToUInt32(model.PageMarginGutter.Value));
}
if (model.PageMarginLeft != null)
{
pageMargin.Left = new UInt32Value(Convert.ToUInt32(model.PageMarginLeft.Value));
}
if (model.PageMarginRight != null)
{
pageMargin.Right = new UInt32Value(Convert.ToUInt32(model.PageMarginRight.Value));
}
if (model.PageMarginTop.HasValue)
{
pageMargin.Top = model.PageMarginTop.Value;
}
properties.AppendChild(pageMargin);
body.AppendChild(properties);
}
private static void CreateDocumentSettingsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.DocumentSettings.IsNotEmpty())
{
var settings = mainPart.AddNewPart<DocumentSettingsPart>();
settings.Settings = new Settings
{
InnerXml = parts.DocumentSettings
};
settings.Settings.Save();
}
}
private static void CreateFontTablesPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.FontTable.IsNotEmpty())
{
var fonts = mainPart.AddNewPart<FontTablePart>();
fonts.Fonts = new Fonts
{
InnerXml = parts.FontTable
};
fonts.Fonts.Save();
}
}
private static void CreateNumberingsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.NumberingDefinitions.IsNotEmpty())
{
var numbering = mainPart.AddNewPart<NumberingDefinitionsPart>();
numbering.Numbering = new Numbering
{
InnerXml = parts.NumberingDefinitions
};
numbering.Numbering.Save();
}
}
private static void CreateStyleDefinitionsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.StyleDefinitions.IsNotEmpty())
{
var styles = mainPart.AddNewPart<StyleDefinitionsPart>();
styles.Styles = new Styles
{
InnerXml = parts.StyleDefinitions
};
styles.Styles.Save();
}
}
private static void CreateThemePart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.Theme.IsNotEmpty())
{
var thems = mainPart.AddNewPart<ThemePart>();
thems.Theme = new DocumentFormat.OpenXml.Drawing.Theme
{
InnerXml = parts.Theme
};
thems.Theme.Save();
}
}
private static void CreateWebSetting(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.WebSettings.IsNotEmpty())
{
var settings = mainPart.AddNewPart<WebSettingsPart>();
settings.WebSettings = new WebSettings
{
InnerXml = parts.WebSettings
};
settings.WebSettings.Save();
}
}
}
}

View File

@ -0,0 +1,134 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordParagraphExtension
{
/// <summary>
/// Добавление абзаца в тело документа
/// </summary>
/// <param name="body"></param>
/// <param name="model"></param>
public static void AddParagraph(this Body body, ModelWordParagraph model)
{
if (model == null)
{
return;
}
var paragraph = new Paragraph();
paragraph.AddParagraphProperties(model);
if (model.WordTexts != null)
{
foreach (var text in model.WordTexts)
{
paragraph.AddRun(text);
}
}
body.AppendChild(paragraph);
}
/// <summary>
/// Добавление абзаца в ячейку таблицы
/// </summary>
/// <param name="body"></param>
/// <param name="model"></param>
public static void AddParagraph(this TableCell cell, ModelWordParagraph model)
{
if (model == null)
{
return;
}
var paragraph = new Paragraph();
paragraph.AddParagraphProperties(model);
if (model.WordTexts != null)
{
foreach (var text in model.WordTexts)
{
paragraph.AddRun(text);
}
}
cell.AppendChild(paragraph);
}
/// <summary>
/// Добавление свойств абзаца
/// </summary>
/// <param name="paragraph"></param>
/// <param name="model"></param>
private static void AddParagraphProperties(this Paragraph paragraph, ModelWordParagraph model)
{
if (model == null)
{
return;
}
var properties = new ParagraphProperties();
if (model.JustificationType.HasValue)
{
var justification = new Justification()
{
Val = (JustificationValues)Enum.Parse(typeof(JustificationValues), model.JustificationType.Value.ToString())
};
properties.AppendChild(justification);
}
var spacingBetweenLines = new SpacingBetweenLines();
if (model.SpacingBetweenLinesLine != null)
{
spacingBetweenLines.Line = new StringValue(model.SpacingBetweenLinesLine.Value.ToString());
}
if (model.SpacingBetweenLinesBefore != null)
{
spacingBetweenLines.Before = new StringValue(model.SpacingBetweenLinesBefore.Value.ToString());
}
if (model.SpacingBetweenLinesAfter != null)
{
spacingBetweenLines.After = new StringValue(model.SpacingBetweenLinesAfter.Value.ToString());
}
properties.AppendChild(spacingBetweenLines);
var indentation = new Indentation();
if (model.IndentationFirstLine != null)
{
indentation.FirstLine = new StringValue(model.IndentationFirstLine.Value.ToString());
}
if (model.IndentationHanging != null)
{
indentation.Hanging = new StringValue(model.IndentationHanging.Value.ToString());
}
if (model.IndentationLeft != null)
{
indentation.Left = new StringValue(model.IndentationLeft.Value.ToString());
}
if (model.IndentationRight != null)
{
indentation.Right = new StringValue(model.IndentationRight.Value.ToString());
}
properties.AppendChild(indentation);
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (model.FontSize.HasValue)
{
paragraphMarkRunProperties.AppendChild(new FontSize { Val = new StringValue(model.FontSize.Value.ToString()) });
}
if (model.IsBold)
{
paragraphMarkRunProperties.AppendChild(new Bold());
}
if (model.IsItalic)
{
paragraphMarkRunProperties.AppendChild(new Italic());
}
if (model.IsUnderline)
{
paragraphMarkRunProperties.AppendChild(new Underline());
}
properties.AppendChild(paragraphMarkRunProperties);
paragraph.AppendChild(properties);
}
}
}

View File

@ -0,0 +1,49 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordRowExtension
{
/// <summary>
/// Добавление строки в таблицу
/// </summary>
/// <param name="table"></param>
/// <param name="model"></param>
public static void AddTableRow(this Table table, ModelWordTableRow model)
{
if (model == null)
{
return;
}
var row = new TableRow();
row.AddTableRowProperties(model);
foreach (var cell in model.Cells)
{
row.AddTableCell(cell);
}
table.AppendChild(row);
}
/// <summary>
/// Добавление свойств строки
/// </summary>
/// <param name="row"></param>
/// <param name="model"></param>
private static void AddTableRowProperties(this TableRow row, ModelWordTableRow model)
{
if (model == null)
{
return;
}
if (model.Height.HasValue)
{
var properties = new TableRowProperties();
properties.AppendChild(new TableRowHeight() { Val = new UInt32Value(Convert.ToUInt32(model.Height.Value)) });
row.AppendChild(properties);
}
}
}
}

View File

@ -0,0 +1,72 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordRunExtension
{
/// <summary>
/// Добавление текста в абзац
/// </summary>
/// <param name="paragraph"></param>
/// <param name="model"></param>
public static void AddRun(this Paragraph paragraph, ModelWordText model)
{
if (model == null)
{
return;
}
var docRun = new Run();
docRun.AddRunProperties(model);
if (model.IsBreak)
{
docRun.AppendChild(new Break());
}
else if (model.IsTabChar)
{
docRun.AppendChild(new TabChar());
}
else
{
docRun.AppendChild(new Text { Text = model.Text, Space = SpaceProcessingModeValues.Preserve });
}
paragraph.AppendChild(docRun);
}
/// <summary>
/// Добавление свойств текста
/// </summary>
/// <param name="run"></param>
/// <param name="model"></param>
private static void AddRunProperties(this Run run, ModelWordText model)
{
if (model == null)
{
return;
}
if (model.FontSize.HasValue || model.IsBold || model.IsItalic || model.IsUnderline)
{
var properties = new RunProperties();
if (model.FontSize.HasValue)
{
properties.AppendChild(new FontSize { Val = new StringValue(model.FontSize.Value.ToString()) });
}
if (model.IsBold)
{
properties.AppendChild(new Bold());
}
if (model.IsItalic)
{
properties.AppendChild(new Italic());
}
if (model.IsUnderline)
{
properties.AppendChild(new Underline());
}
run.AppendChild(properties);
}
}
}
}

View File

@ -0,0 +1,251 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Linq;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extensions
{
public static class WordTableExtension
{
/// <summary>
/// Добавление таблицы в тело документа
/// </summary>
/// <param name="body"></param>
/// <param name="model"></param>
public static void AddTable(this Body body, ModelWordTable model)
{
if (model == null)
{
return;
}
model.CreateRows();
var table = new Table();
table.AddTableProperties(model);
table.AddGridColumn(model);
foreach (var row in model.Rows)
{
table.AddTableRow(row);
}
body.AppendChild(table);
}
/// <summary>
/// Создание строк таблицы на основе входных данных
/// </summary>
/// <param name="model"></param>
private static void CreateRows(this ModelWordTable model)
{
model.Rows = new Queue<ModelWordTableRow>();
var headerRowsCount = model.Headers.Select(x => x.RowIndex).Distinct().Count();
for(int rowIndex = 0; rowIndex < headerRowsCount; ++rowIndex)
{
var header = new ModelWordTableRow();
if (model.RowsHeight.ContainsKey(rowIndex))
{
header.Height = model.RowsHeight[rowIndex];
}
for (int i = 0; i < model.Data.GetLength(1); ++i)
{
header.Cells.Enqueue(CreateHeaderCell(model, rowIndex, i));
}
model.Rows.Enqueue(header);
}
for (int i = 0; i < model.Data.Length; ++i)
{
var row = new ModelWordTableRow();
if (model.RowsHeight.ContainsKey(i + headerRowsCount))
{
row.Height = model.RowsHeight[i + headerRowsCount];
}
for (int j = 0; j < model.Data.GetLength(1); ++j)
{
row.Cells.Enqueue(CreateCell(model, i, j));
}
model.Rows.Enqueue(row);
}
}
/// <summary>
/// Добавление свойсвт таблицы
/// </summary>
/// <param name="table"></param>
/// <param name="model"></param>
private static void AddTableProperties(this Table table, ModelWordTable model)
{
if (model == null)
{
return;
}
var properties = new TableProperties();
var tableLook = new TableLook();
if (model.LookFirstRow)
{
tableLook.FirstRow = new OnOffValue(model.LookFirstRow);
}
if (model.LookFirstColumn)
{
tableLook.FirstColumn = new OnOffValue(model.LookFirstColumn);
}
if (model.LookLastRow)
{
tableLook.LastRow = new OnOffValue(model.LookLastRow);
}
if (model.LookLastColumn)
{
tableLook.LastColumn = new OnOffValue(model.LookLastColumn);
}
if (model.LookNoHorizontalBand)
{
tableLook.NoHorizontalBand = new OnOffValue(model.LookNoHorizontalBand);
}
if (model.LookNoVerticalBand)
{
tableLook.NoVerticalBand = new OnOffValue(model.LookNoVerticalBand);
}
properties.AppendChild(tableLook);
var tableBorders = new TableBorders();
tableBorders.AddBorder(model, new TopBorder());
tableBorders.AddBorder(model, new BottomBorder());
tableBorders.AddBorder(model, new LeftBorder());
tableBorders.AddBorder(model, new RightBorder());
properties.AppendChild(tableBorders);
table.AppendChild(properties);
}
/// <summary>
/// Добавление колонок таблицы
/// </summary>
/// <param name="table"></param>
/// <param name="model"></param>
private static void AddGridColumn(this Table table, ModelWordTable model)
{
if (model == null || model.ColumnWidths == null || model.ColumnWidths.Count == 0)
{
return;
}
var tableGrid = new TableGrid();
foreach (var grid in model.ColumnWidths)
{
tableGrid.AppendChild(new GridColumn() { Width = new StringValue(grid.ToString()) });
}
table.AppendChild(tableGrid);
}
/// <summary>
/// Добавление границ таблицы
/// </summary>
/// <param name="tableBorders"></param>
/// <param name="model"></param>
/// <param name="borderType"></param>
private static void AddBorder(this TableBorders tableBorders, ModelWordTable model, BorderType borderType)
{
if (model == null)
{
return;
}
if (model.BorderType.HasValue)
{
borderType.Val = (BorderValues)Enum.Parse(typeof(BorderValues), model.BorderType.Value.ToString());
}
tableBorders.AppendChild(borderType);
}
/// <summary>
/// Создание ячейки строки-заголовка
/// </summary>
/// <param name="model"></param>
/// <param name="rowIndex"></param>
/// <param name="columnIndex"></param>
/// <returns></returns>
private static ModelWordTableCell CreateHeaderCell(ModelWordTable model, int rowIndex, int columnIndex)
{
var cell = new ModelWordTableCell();
var elem = model.Headers.FirstOrDefault(x => x.ColumnIndex == columnIndex && x.RowIndex == rowIndex);
if (elem != default)
{
cell.Texts = new Queue<ModelWordParagraph>();
var paragraph = new ModelWordParagraph
{
FontSize = 14,
FontName = Interfaces.FontNames.TimesNewRoman,
IsBold = true,
JustificationType = TypeWordJustification.Center,
WordTexts = new Queue<ModelWordText>()
};
paragraph.WordTexts.Enqueue(new ModelWordText
{
Text = elem.Header
});
cell.Texts.Enqueue(paragraph);
}
else
{
var union = model.CellUnion.FirstOrDefault(x => x.StartColumnIndex >= columnIndex && x.StartRowIndex >= rowIndex &&
x.FinishColumnIndex <= columnIndex && x.FinishRowIndex <= rowIndex);
if (union != default)
{
if (union.StartColumnIndex == columnIndex)
{
cell.IsNewMerge = true;
}
else
{
cell.IsContinueMerge = true;
}
}
}
return cell;
}
/// <summary>
/// Создание ячейки строки данных
/// </summary>
/// <param name="model"></param>
/// <param name="rowIndex"></param>
/// <param name="columnIndex"></param>
/// <returns></returns>
private static ModelWordTableCell CreateCell(ModelWordTable model, int rowIndex, int columnIndex)
{
var cell = new ModelWordTableCell();
var union = model.CellUnion.FirstOrDefault(x => x.StartColumnIndex >= columnIndex && x.StartRowIndex >= rowIndex &&
x.FinishColumnIndex <= columnIndex && x.FinishRowIndex <= rowIndex);
if (union != default)
{
if (union.StartColumnIndex == columnIndex)
{
cell.IsNewMerge = true;
}
else
{
cell.IsContinueMerge = true;
}
}
else
{
cell.Texts = new Queue<ModelWordParagraph>();
var paragraph = new ModelWordParagraph
{
FontSize = 14,
FontName = Interfaces.FontNames.TimesNewRoman,
JustificationType = TypeWordJustification.Left,
WordTexts = new Queue<ModelWordText>()
};
paragraph.WordTexts.Enqueue(new ModelWordText
{
Text = model.Data[rowIndex, columnIndex]
});
cell.Texts.Enqueue(paragraph);
}
return cell;
}
}
}

View File

@ -1,516 +0,0 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using ToolsModule.ManagmentExtension;
using ToolsOffice.Implements.WordOpenXML.Models;
namespace ToolsOffice.Implements.WordOpenXML.Extenstions
{
public static class WordDocumentExtenstion
{
/// <summary>
/// Добавление общих элементов документа
/// </summary>
/// <param name="mainPart"></param>
/// <param name="parts"></param>
public static void AddParts(this MainDocumentPart mainPart, WordDocumentParts parts)
{
if (parts == null)
{
return;
}
CreateDocumentSettingsPart(parts, mainPart);
CreateFontTablesPart(parts, mainPart);
CreateNumberingsPart(parts, mainPart);
CreateStyleDefinitionsPart(parts, mainPart);
CreateThemePart(parts, mainPart);
CreateWebSetting(parts, mainPart);
}
/// <summary>
/// Добавление общих настроек документа
/// </summary>
/// <param name="body"></param>
/// <param name="document"></param>
public static void AddSectionProperties(this Body body, WordSaveDocument document)
{
if (document == null || document.DocumentSettings == null)
{
return;
}
var properties = new SectionProperties();
var pageSize = new PageSize();
if (document.DocumentSettings.PageSizeHeight != null)
{
pageSize.Height = document.DocumentSettings.PageSizeHeight;
}
if (document.DocumentSettings.PageSizeWidth != null)
{
pageSize.Width = document.DocumentSettings.PageSizeWidth;
}
if (document.DocumentSettings.WordPageOrientation.HasValue)
{
pageSize.Orient = (PageOrientationValues)Enum.Parse(typeof(PageOrientationValues), document.DocumentSettings.WordPageOrientation.Value.ToString());
}
properties.AppendChild(pageSize);
var pageMargin = new PageMargin();
if (document.DocumentSettings.PageMarginBottom.HasValue)
{
pageMargin.Bottom = document.DocumentSettings.PageMarginBottom.Value;
}
if (document.DocumentSettings.PageMarginFooter != null)
{
pageMargin.Footer = document.DocumentSettings.PageMarginFooter;
}
if (document.DocumentSettings.PageMarginGutter != null)
{
pageMargin.Gutter = document.DocumentSettings.PageMarginGutter;
}
if (document.DocumentSettings.PageMarginLeft != null)
{
pageMargin.Left = document.DocumentSettings.PageMarginLeft;
}
if (document.DocumentSettings.PageMarginRight != null)
{
pageMargin.Right = document.DocumentSettings.PageMarginRight;
}
if (document.DocumentSettings.PageMarginTop.HasValue)
{
pageMargin.Top = document.DocumentSettings.PageMarginTop.Value;
}
properties.AppendChild(pageMargin);
body.AppendChild(properties);
}
/// <summary>
/// Добавление свойств абзаца
/// </summary>
/// <param name="paragraph"></param>
/// <param name="wordProperties"></param>
public static void AddParagraphProperties(this Paragraph paragraph, WordParagraphProperties wordProperties)
{
if (wordProperties == null)
{
return;
}
var properties = new ParagraphProperties();
if (wordProperties.JustificationType.HasValue)
{
var justification = new Justification()
{
Val = (JustificationValues)Enum.Parse(typeof(JustificationValues), wordProperties.JustificationType.Value.ToString())
};
properties.AppendChild(justification);
}
var spacingBetweenLines = new SpacingBetweenLines();
if (wordProperties.SpacingBetweenLinesLine != null)
{
spacingBetweenLines.Line = wordProperties.SpacingBetweenLinesLine;
}
if (wordProperties.SpacingBetweenLinesBefore != null)
{
spacingBetweenLines.Before = wordProperties.SpacingBetweenLinesBefore;
}
if (wordProperties.SpacingBetweenLinesAfter != null)
{
spacingBetweenLines.After = wordProperties.SpacingBetweenLinesAfter;
}
properties.AppendChild(spacingBetweenLines);
var indentation = new Indentation();
if (wordProperties.IndentationFirstLine != null)
{
indentation.FirstLine = wordProperties.IndentationFirstLine;
}
if (wordProperties.IndentationHanging != null)
{
indentation.Hanging = wordProperties.IndentationHanging;
}
if (wordProperties.IndentationLeft != null)
{
indentation.Left = wordProperties.IndentationLeft;
}
if (wordProperties.IndentationRight != null)
{
indentation.Right = wordProperties.IndentationRight;
}
properties.AppendChild(indentation);
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (wordProperties.Size != null)
{
paragraphMarkRunProperties.AppendChild(new FontSize { Val = wordProperties.Size });
}
if (wordProperties.IsBold)
{
paragraphMarkRunProperties.AppendChild(new Bold());
}
if (wordProperties.IsItalic)
{
paragraphMarkRunProperties.AppendChild(new Italic());
}
if (wordProperties.IsUnderline)
{
paragraphMarkRunProperties.AppendChild(new Underline());
}
properties.AppendChild(paragraphMarkRunProperties);
paragraph.AppendChild(properties);
}
/// <summary>
/// Добавление текста в абзац
/// </summary>
/// <param name="paragraph"></param>
/// <param name="run"></param>
/// <returns></returns>
public static void AddRun(this Paragraph paragraph, WordRun run)
{
if (run == null)
{
return;
}
var docRun = new Run();
docRun.AddRunProperties(run.RunProperties);
if (run.IsBreak)
{
docRun.AppendChild(new Break());
}
else if (run.IsTabChar)
{
docRun.AppendChild(new TabChar());
}
else
{
docRun.AppendChild(new Text { Text = run.Text, Space = SpaceProcessingModeValues.Preserve });
}
paragraph.AppendChild(docRun);
}
public static void AddTableProperties(this Table table, WordTableProperties wordTableProperties)
{
if (wordTableProperties == null)
{
return;
}
var properties = new TableProperties();
if (wordTableProperties.Width != null)
{
properties.AppendChild(new TableWidth() { Width = wordTableProperties.Width });
}
var tableLook = new TableLook();
if (wordTableProperties.LookValue != null)
{
tableLook.Val = wordTableProperties.LookValue;
}
if (wordTableProperties.LookFirstRow)
{
tableLook.FirstRow = new OnOffValue(wordTableProperties.LookFirstRow);
}
if (wordTableProperties.LookFirstColumn)
{
tableLook.FirstColumn = new OnOffValue(wordTableProperties.LookFirstColumn);
}
if (wordTableProperties.LookLastRow)
{
tableLook.LastRow = new OnOffValue(wordTableProperties.LookLastRow);
}
if (wordTableProperties.LookLastColumn)
{
tableLook.LastColumn = new OnOffValue(wordTableProperties.LookLastColumn);
}
if (wordTableProperties.LookNoHorizontalBand)
{
tableLook.NoHorizontalBand = new OnOffValue(wordTableProperties.LookNoHorizontalBand);
}
if (wordTableProperties.LookNoVerticalBand)
{
tableLook.NoVerticalBand = new OnOffValue(wordTableProperties.LookNoVerticalBand);
}
properties.AppendChild(tableLook);
var tableBorders = new TableBorders();
tableBorders.AddBorder(wordTableProperties.TopBorder, new TopBorder());
tableBorders.AddBorder(wordTableProperties.BottomBorder, new BottomBorder());
tableBorders.AddBorder(wordTableProperties.LeftBorder, new LeftBorder());
tableBorders.AddBorder(wordTableProperties.RightBorder, new RightBorder());
properties.AppendChild(tableBorders);
table.AppendChild(properties);
}
public static void AddGridColumn(this Table table, WordTableGrid wordTableGrid)
{
if (wordTableGrid == null || wordTableGrid.Widths == null || wordTableGrid.Widths.Count == 0)
{
return;
}
var tableGrid = new TableGrid();
foreach (var grid in wordTableGrid.Widths)
{
tableGrid.AppendChild(new GridColumn() { Width = grid });
}
table.AppendChild(tableGrid);
}
public static void AddTableRow(this Table table, WordTableRow row)
{
if (row == null)
{
return;
}
var docRow = new TableRow();
docRow.AddTableRowProperties(row.RowProperties);
foreach (var cell in row.Cells)
{
docRow.AddTableCell(cell);
}
table.AppendChild(docRow);
}
/// <summary>
/// Добавление свойств текста
/// </summary>
/// <param name="run"></param>
/// <param name="wordProperties"></param>
private static void AddRunProperties(this Run run, WordRunProperties wordProperties)
{
if (wordProperties == null)
{
return;
}
if (wordProperties.Size != null || wordProperties.IsBold || wordProperties.IsItalic || wordProperties.IsUnderline)
{
var properties = new RunProperties();
if (wordProperties.Size != null)
{
properties.AppendChild(new FontSize { Val = wordProperties.Size });
}
if (wordProperties.IsBold)
{
properties.AppendChild(new Bold());
}
if (wordProperties.IsItalic)
{
properties.AppendChild(new Italic());
}
if (wordProperties.IsUnderline)
{
properties.AppendChild(new Underline());
}
run.AppendChild(properties);
}
}
private static void AddBorder(this TableBorders tableBorders, WordTableBorder wordTableBorder, BorderType borderType)
{
if (wordTableBorder == null)
{
return;
}
if (wordTableBorder.BorderType.HasValue)
{
borderType.Val = (BorderValues)Enum.Parse(typeof(BorderValues), wordTableBorder.BorderType.Value.ToString());
}
if (wordTableBorder.Color != null)
{
borderType.Color = wordTableBorder.Color;
}
if (wordTableBorder.Size != null)
{
borderType.Size = wordTableBorder.Size;
}
if (wordTableBorder.Space != null)
{
borderType.Space = wordTableBorder.Space;
}
tableBorders.AppendChild(borderType);
}
private static void AddTableRowProperties(this TableRow row, WordTableRowProperties wordTableRowProperties)
{
if (wordTableRowProperties == null)
{
return;
}
if (wordTableRowProperties.CantSplit.HasValue || wordTableRowProperties.TableRowHeight != null)
{
var properties = new TableRowProperties();
if (wordTableRowProperties.CantSplit.HasValue)
{
properties.AppendChild(new CantSplit() { Val = wordTableRowProperties.CantSplit.Value ? OnOffOnlyValues.On : OnOffOnlyValues.Off });
}
if (wordTableRowProperties.TableRowHeight != null)
{
properties.AppendChild(new TableRowHeight() { Val = wordTableRowProperties.TableRowHeight });
}
row.AppendChild(properties);
}
}
private static void AddTableCell(this TableRow row, WordTableCell cell)
{
if (cell == null)
{
return;
}
var docCell = new TableCell();
docCell.AddTableCellProperties(cell.CellProperties);
foreach (var paragraph in cell.Paragraphs)
{
docCell.AddParagraph(paragraph);
}
row.AppendChild(docCell);
}
private static void AddTableCellProperties(this TableCell cell, WordTableCellProperties wordTableCellProperties)
{
if (wordTableCellProperties == null)
{
return;
}
var properties = new TableCellProperties();
if (wordTableCellProperties.TableCellWidth != null)
{
properties.AppendChild(new TableCellWidth() { Width = wordTableCellProperties.TableCellWidth });
}
if (wordTableCellProperties.GridSpan != null)
{
properties.AppendChild(new GridSpan() { Val = wordTableCellProperties.GridSpan });
}
if (wordTableCellProperties.MergeType.HasValue)
{
if (wordTableCellProperties.MergeType.Value)
{
properties.AppendChild(new VerticalMerge()
{
Val = MergedCellValues.Restart
});
}
else
{
properties.AppendChild(new VerticalMerge());
}
}
cell.AppendChild(properties);
}
private static void AddParagraph(this TableCell cell, WordParagraph paragraph)
{
if (paragraph == null)
{
return;
}
var docParagraph = new Paragraph();
docParagraph.AddParagraphProperties(paragraph.ParagraphProperties);
foreach (var run in paragraph.Texts)
{
docParagraph.AddRun(run);
}
cell.AppendChild(docParagraph);
}
private static void CreateDocumentSettingsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.DocumentSettings.IsNotEmpty())
{
var settings = mainPart.AddNewPart<DocumentSettingsPart>();
settings.Settings = new Settings
{
InnerXml = parts.DocumentSettings
};
settings.Settings.Save();
}
}
private static void CreateFontTablesPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.FontTable.IsNotEmpty())
{
var fonts = mainPart.AddNewPart<FontTablePart>();
fonts.Fonts = new Fonts
{
InnerXml = parts.FontTable
};
fonts.Fonts.Save();
}
}
private static void CreateNumberingsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.NumberingDefinitions.IsNotEmpty())
{
var numbering = mainPart.AddNewPart<NumberingDefinitionsPart>();
numbering.Numbering = new Numbering
{
InnerXml = parts.NumberingDefinitions
};
numbering.Numbering.Save();
}
}
private static void CreateStyleDefinitionsPart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.StyleDefinitions.IsNotEmpty())
{
var styles = mainPart.AddNewPart<StyleDefinitionsPart>();
styles.Styles = new Styles
{
InnerXml = parts.StyleDefinitions
};
styles.Styles.Save();
}
}
private static void CreateThemePart(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.Theme.IsNotEmpty())
{
var thems = mainPart.AddNewPart<ThemePart>();
thems.Theme = new DocumentFormat.OpenXml.Drawing.Theme
{
InnerXml = parts.Theme
};
thems.Theme.Save();
}
}
private static void CreateWebSetting(WordDocumentParts parts, MainDocumentPart mainPart)
{
if (parts.WebSettings.IsNotEmpty())
{
var settings = mainPart.AddNewPart<WebSettingsPart>();
settings.WebSettings = new WebSettings
{
InnerXml = parts.WebSettings
};
settings.WebSettings.Save();
}
}
}
}

View File

@ -2,8 +2,17 @@
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordCreateDocument : ICreateWordModel
public class WordCreateDocument
{
public WordDocumentParts WordDocumentParts { get; set; }
public static WordCreateDocument Create(ModelWordDocument model)
{
if (model == null)
{
return null;
}
return new WordCreateDocument();
}
}
}

View File

@ -1,26 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordDocumentSettings
{
public UInt32Value PageSizeHeight { get; set; }
public UInt32Value PageSizeWidth { get; set; }
public WordPageOrientationType? WordPageOrientation { get; set; }
public UInt32Value PageMarginFooter { get; set; }
public UInt32Value PageMarginGutter { get; set; }
public int? PageMarginBottom { get; set; }
public int? PageMarginTop { get; set; }
public UInt32Value PageMarginLeft { get; set; }
public UInt32Value PageMarginRight { get; set; }
}
}

View File

@ -1,13 +0,0 @@
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public enum WordJustificationType
{
Left = 0,
Center = 2,
Right = 3,
Both = 5
}
}

View File

@ -1,12 +0,0 @@
using System.Collections.Generic;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordParagraph : IParagraphWordModel
{
public List<WordRun> Texts { get; set; }
public WordParagraphProperties ParagraphProperties { get; set; }
}
}

View File

@ -1,31 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordParagraphProperties
{
public StringValue Size { get; set; }
public bool IsBold { get; set; }
public bool IsItalic { get; set; }
public bool IsUnderline { get; set; }
public WordJustificationType? JustificationType { get; set; }
public StringValue SpacingBetweenLinesLine { get; set; }
public StringValue SpacingBetweenLinesBefore { get; set; }
public StringValue SpacingBetweenLinesAfter { get; set; }
public StringValue IndentationFirstLine { get; set; }
public StringValue IndentationHanging { get; set; }
public StringValue IndentationLeft { get; set; }
public StringValue IndentationRight { get; set; }
}
}

View File

@ -1,13 +0,0 @@
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordRun
{
public string Text { get; set; }
public bool IsBreak { get; set; }
public bool IsTabChar { get; set; }
public WordRunProperties RunProperties { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordRunProperties
{
public StringValue Size { get; set; }
public bool IsBold { get; set; }
public bool IsItalic { get; set; }
public bool IsUnderline { get; set; }
}
}

View File

@ -1,9 +0,0 @@
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordSaveDocument : ISaveWordModel
{
public WordDocumentSettings DocumentSettings { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System.Collections.Generic;
using ToolsOffice.Interfaces.Word.Models;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTable : ITableWordModel
{
public WordTableProperties TableProperties { get; set; }
public WordTableGrid TableGrid { get; set; }
public List<WordTableRow> Rows { get; set; }
}
}

View File

@ -1,15 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableBorder
{
public UInt32Value Size { get; set; }
public UInt32Value Space { get; set; }
public StringValue Color { get; set; }
public WordTableBorderType? BorderType { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableCell
{
public WordTableCellProperties CellProperties { get; set; }
public List<WordParagraph> Paragraphs { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableCellProperties
{
public StringValue TableCellWidth { get; set; }
public Int32Value GridSpan { get; set; }
public bool? MergeType { get; set; }
}
}

View File

@ -1,10 +0,0 @@
using DocumentFormat.OpenXml;
using System.Collections.Generic;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableGrid
{
public List<StringValue> Widths { get; set; }
}
}

View File

@ -1,31 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableProperties
{
public StringValue Width { get; set; }
public HexBinaryValue LookValue { get; set; }
public bool LookFirstRow { get; set; }
public bool LookFirstColumn { get; set; }
public bool LookLastRow { get; set; }
public bool LookLastColumn { get; set; }
public bool LookNoHorizontalBand { get; set; }
public bool LookNoVerticalBand { get; set; }
public WordTableBorder TopBorder { get; set; }
public WordTableBorder BottomBorder { get; set; }
public WordTableBorder LeftBorder { get; set; }
public WordTableBorder RightBorder { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableRow
{
public WordTableRowProperties RowProperties { get; set; }
public List<WordTableCell> Cells { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using DocumentFormat.OpenXml;
namespace ToolsOffice.Implements.WordOpenXML.Models
{
public class WordTableRowProperties
{
public bool? CantSplit { get; set; }
public UInt32Value TableRowHeight { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ToolsOffice.Interfaces
{
public enum FontNames
{
TimesNewRoman = 0
}
}

View File

@ -9,24 +9,24 @@ namespace ToolsOffice.Interfaces.Word
/// Создание документа
/// </summary>
/// <param name="model"></param>
public abstract void CreateDocument(ICreateWordModel model);
public abstract void CreateDocument(ModelWordDocument model);
/// <summary>
/// Создание абзаца с текстом
/// </summary>
/// <param name="model"></param>
public abstract void CreateParagraph(IParagraphWordModel model);
public abstract void CreateParagraph(ModelWordParagraph model);
/// <summary>
/// Создание абзаца с текстом
/// </summary>
/// <param name="model"></param>
public abstract void CreateTable(ITableWordModel model);
public abstract void CreateTable(ModelWordTable model);
/// <summary>
/// Сохранение файла
/// </summary>
/// <param name="info"></param>
public abstract Stream SaveDocument(ISaveWordModel info);
public abstract Stream SaveDocument(ModelWordDocument info);
}
}

View File

@ -1,4 +0,0 @@
namespace ToolsOffice.Interfaces.Word.Models
{
public interface ICreateWordModel { }
}

View File

@ -1,4 +0,0 @@
namespace ToolsOffice.Interfaces.Word.Models
{
public interface IParagraphWordModel { }
}

View File

@ -1,4 +0,0 @@
namespace ToolsOffice.Interfaces.Word.Models
{
public interface ISaveWordModel { }
}

View File

@ -1,4 +0,0 @@
namespace ToolsOffice.Interfaces.Word.Models
{
public interface ITableWordModel { }
}

View File

@ -0,0 +1,7 @@
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель данных при создании элемента документа (абзац, таблица)
/// </summary>
public interface IWordDocumentPartModel { }
}

View File

@ -0,0 +1,36 @@
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания документа
/// </summary>
public class ModelWordDocument
{
/// <summary>
/// Высота страницы
/// </summary>
public int? PageSizeHeight { get; set; }
/// <summary>
/// Ширина страницы
/// </summary>
public int? PageSizeWidth { get; set; }
/// <summary>
/// Ориентация страницы
/// </summary>
public TypeWordPageOrientation? WordPageOrientation { get; set; }
public int? PageMarginFooter { get; set; }
public int? PageMarginGutter { get; set; }
public int? PageMarginBottom { get; set; }
public int? PageMarginTop { get; set; }
public int? PageMarginLeft { get; set; }
public int? PageMarginRight { get; set; }
}
}

View File

@ -0,0 +1,80 @@
using System.Collections.Generic;
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания абзаца документа
/// </summary>
public class ModelWordParagraph : IWordDocumentPartModel
{
/// <summary>
/// Набор текстов
/// </summary>
public Queue<ModelWordText> WordTexts { get; set; }
/// <summary>
/// Размер шрифта
/// </summary>
public int? FontSize { get; set; }
/// <summary>
/// Название шрифта
/// </summary>
public FontNames FontName { get; set; }
/// <summary>
/// Жирный
/// </summary>
public bool IsBold { get; set; } = false;
/// <summary>
/// Курсив
/// </summary>
public bool IsItalic { get; set; } = false;
/// <summary>
/// Подчеркивание
/// </summary>
public bool IsUnderline { get; set; } = false;
/// <summary>
/// Выравнивание абзаца
/// </summary>
public TypeWordJustification? JustificationType { get; set; }
/// <summary>
/// Расстояние между строками абзаца
/// </summary>
public int? SpacingBetweenLinesLine { get; set; }
/// <summary>
/// Отступ до абзаца
/// </summary>
public int? SpacingBetweenLinesBefore { get; set; }
/// <summary>
/// Отступ после абзаца
/// </summary>
public int? SpacingBetweenLinesAfter { get; set; }
/// <summary>
/// Отступ первой строки
/// </summary>
public int? IndentationFirstLine { get; set; }
/// <summary>
/// Выступ
/// </summary>
public int? IndentationHanging { get; set; }
/// <summary>
/// Отступ слева
/// </summary>
public int? IndentationLeft { get; set; }
/// <summary>
/// Отступ справа
/// </summary>
public int? IndentationRight { get; set; }
}
}

View File

@ -0,0 +1,75 @@
using System.Collections.Generic;
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания таблицы документа
/// </summary>
public class ModelWordTable : IWordDocumentPartModel
{
/// <summary>
/// Информация по ширине колонок (номер колонки, ширина колонки), отсчет с 0
/// </summary>
public Dictionary<int, int> ColumnWidths { get; set; }
/// <summary>
/// Информация по высоте строк (номер строки, высота строки), отсчет с 0
/// </summary>
public Dictionary<int, int > RowsHeight { get; set; }
/// <summary>
/// Информация по объединению ячеек
/// </summary>
public List<(int StartRowIndex, int StartColumnIndex, int FinishRowIndex, int FinishColumnIndex)> CellUnion { get; set; }
/// <summary>
/// Заголовки для таблицы
/// </summary>
public List<(int ColumnIndex, int RowIndex, string Header)> Headers { get; set; }
/// <summary>
/// Данные
/// </summary>
public string[,] Data { get; set; }
/// <summary>
/// Иной вывод первой строки
/// </summary>
public bool LookFirstRow { get; set; }
/// <summary>
/// Иной вывод первого столбца
/// </summary>
public bool LookFirstColumn { get; set; }
/// <summary>
/// Иной вывод последней строки
/// </summary>
public bool LookLastRow { get; set; }
/// <summary>
/// Иной вывод последнего столбца
/// </summary>
public bool LookLastColumn { get; set; }
/// <summary>
///
/// </summary>
public bool LookNoHorizontalBand { get; set; }
/// <summary>
///
/// </summary>
public bool LookNoVerticalBand { get; set; }
/// <summary>
/// Тип рамки таблицы
/// </summary>
public TypeWordTableBorder? BorderType { get; set; }
/// <summary>
/// Список строк для таблицы
/// </summary>
public Queue<ModelWordTableRow> Rows { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System.Collections.Generic;
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания ячейки таблицы
/// </summary>
public class ModelWordTableCell
{
/// <summary>
/// Новое объединение ячеек
/// </summary>
public bool IsNewMerge {get;set; }
/// <summary>
/// Признак, продолжения объединения ячеек
/// </summary>
public bool IsContinueMerge { get; set; }
/// <summary>
/// Абзацы текста в ячейке
/// </summary>
public Queue<ModelWordParagraph> Texts { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System.Collections.Generic;
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания строки таблицы
/// </summary>
public class ModelWordTableRow
{
/// <summary>
/// Высота строки
/// </summary>
public int? Height { get; set; }
/// <summary>
/// Список ячеек строки
/// </summary>
public Queue<ModelWordTableCell> Cells { get; set; }
}
}

View File

@ -0,0 +1,43 @@
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Модель описания текста из абзаца документа
/// </summary>
public class ModelWordText
{
/// <summary>
/// Сам текст
/// </summary>
public string Text { get; set; }
/// <summary>
/// Признак разрыва страниц
/// </summary>
public bool IsBreak { get; set; } = false;
/// <summary>
/// Признак табулятора
/// </summary>
public bool IsTabChar { get; set; } = false;
/// <summary>
/// Размер шрифта
/// </summary>
public int? FontSize { get; set; }
/// <summary>
/// Жирный
/// </summary>
public bool IsBold { get; set; } = false;
/// <summary>
/// Курсив
/// </summary>
public bool IsItalic { get; set; } = false;
/// <summary>
/// Подчеркивание
/// </summary>
public bool IsUnderline { get; set; } = false;
}
}

View File

@ -0,0 +1,16 @@
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Выравнивание абзаца
/// </summary>
public enum TypeWordJustification
{
Left = 0,
Center = 2,
Right = 3,
Both = 5
}
}

View File

@ -1,9 +1,9 @@
namespace ToolsOffice.Implements.WordOpenXML.Models
namespace ToolsOffice.Interfaces.Word.Models
{
/// <summary>
/// Ориентация страниц документа
/// </summary>
public enum WordPageOrientationType
public enum TypeWordPageOrientation
{
Portrait = 0,

View File

@ -1,6 +1,9 @@
namespace ToolsOffice.Implements.WordOpenXML.Models
namespace ToolsOffice.Interfaces.Word.Models
{
public enum WordTableBorderType
/// <summary>
/// Тип границ таблицы
/// </summary>
public enum TypeWordTableBorder
{
None = 1,