Table of Contents

Method MoveBlocks

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

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.

public static DocumentEdit MoveBlocks(this WordDocument document, Block first, int count, Block? before)

Parameters

document WordDocument

The document that holds the blocks.

first Block

The first block of the run.

count int

How many blocks the run holds, from first on.

before Block

The block of the same container the run goes before, or null for the container's end.

Returns

DocumentEdit

The edit; After is the start of the run's first paragraph, where it now is.

Remarks

Word keeps a paragraph after a table and joins two tables that nothing stands between (WQ-0129). So a move that would leave the container ending in a table adds an empty paragraph after it, as part of the edit; a move that would put two tables next to each other is refused.

Exceptions

ArgumentNullException

document or first is null.

ArgumentOutOfRangeException

count is less than one, or runs past the container's last block.

ArgumentException

A block is not in document, or before is not a block of the run's container or is one of the run's.

InvalidOperationException

The run is not in a block container, holds no paragraph, or the move would put two tables next to each other.