Table of Contents

Class StructureEditingExtensions

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

Tables and inline pictures inserted and edited at a position, as DocumentEdits: each can be undone exactly and names the paragraphs it changed, as the text edits of TextEditingExtensions do.

public static class StructureEditingExtensions
Inheritance
StructureEditingExtensions
Inherited Members

Remarks

  • A table is inserted before the paragraph when the position is at its start, and otherwise between the two halves of the paragraph split there, so a paragraph always follows it. It takes the document's TableGrid style when there is one (single borders otherwise), equal columns over the text width, and an empty paragraph in every cell.
  • Rows and columns are inserted beside a cell, copying its formatting; a vertical merge the new row falls inside is extended. A column inserted inside a horizontally merged cell widens that cell.
  • Merging takes a rectangle of whole cells (its corners are the two cells given), moves the content of the others into the first, and records the merge as Word does (w:gridSpan, w:vMerge). Splitting a merged cell gives each grid column and row its own cell again, the content staying in the first.
  • A picture is inserted as an inline drawing at the position, splitting a run there; its package part and relationship are added with it and taken out again by undo.

Methods

DeleteCells(WordDocument, TableCell, TableCell, CellShift)

Deletes the rectangle of cells two cells bound, as Word's Delete Cells does (WQ-0118, tools/Probe-WordDeleteCells.ps1). Shift left: each row loses its cells of the rectangle, the cells after them move left and the row ends with w:gridAfter (and w:wAfter, the width of the grid columns it leaves). Shift up: the rows stay; in each column of the rectangle the text of the cells below moves up by the rectangle's height and the bottom cells are left empty.

DeleteColumns(WordDocument, TableCell, TableCell)

Deletes the grid columns two cells span between them, and the table when that is all of them.

DeleteRows(WordDocument, TableCell, TableCell)

Deletes the rows from first's to last's, and the table when that is all of them.

DeleteTable(WordDocument, Table)

Deletes a table; a container left with no block gets an empty paragraph.

InsertColumns(WordDocument, TableCell, int, bool)

Inserts grid columns before or after a cell's columns, formatted like the cells beside them.

InsertImage(WordDocument, DocumentPosition, byte[], string, Emu, Emu, string?, string?)

Inserts an inline picture at a position, splitting a text run there.

InsertRows(WordDocument, TableCell, int, bool)

Inserts rows above or below a cell's row, formatted like it.

InsertTable(WordDocument, DocumentPosition, int, int)

Inserts a table at a position.

MergeCells(WordDocument, TableCell, TableCell)

Merges the rectangle of whole cells whose corners are two cells into one cell.

MoveBlocks(WordDocument, Block, int, Block?)

Moves a run of whole blocks to another place among the blocks of their container (Phase 156): count blocks starting at first go to before before, or to the container's end when it is null. The blocks are the same nodes afterwards: their node ids, formatting, tables, pictures, notes and fields go with them, so a position held in one of them is still a position in it. A move to where the run already stands is an empty edit.

SplitCell(WordDocument, TableCell)

Splits a merged cell back into one cell per grid column and row; the content stays in the first.