WrapSide

Inheritance: java.lang.Object

public class WrapSide

Specifies what side(s) of the shape or picture the text wraps around.

Examples:

Shows how to replace all textbox shapes with image shapes.


 Document doc = new Document(getMyDir() + "Textboxes in drawing canvas.docx");

 List shapeList = Arrays.stream(doc.getChildNodes(NodeType.SHAPE, true).toArray())
         .filter(Shape.class::isInstance)
         .map(Shape.class::cast)
         .collect(Collectors.toList());

 Assert.assertEquals(3, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.TEXT_BOX));
 Assert.assertEquals(1, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.IMAGE));

 for (Shape shape : shapeList) {
     if (((shape.getShapeType()) == (ShapeType.TEXT_BOX))) {
         Shape replacementShape = new Shape(doc, ShapeType.IMAGE);
         replacementShape.getImageData().setImage(getImageDir() + "Logo.jpg");
         replacementShape.setLeft(shape.getLeft());
         replacementShape.setTop(shape.getTop());
         replacementShape.setWidth(shape.getWidth());
         replacementShape.setHeight(shape.getHeight());
         replacementShape.setRelativeHorizontalPosition(shape.getRelativeHorizontalPosition());
         replacementShape.setRelativeVerticalPosition(shape.getRelativeVerticalPosition());
         replacementShape.setHorizontalAlignment(shape.getHorizontalAlignment());
         replacementShape.setVerticalAlignment(shape.getVerticalAlignment());
         replacementShape.setWrapType(shape.getWrapType());
         replacementShape.setWrapSide(shape.getWrapSide());

         shape.getParentNode().insertAfter(replacementShape, shape);
         shape.remove();
     }
 }

 shapeList = Arrays.stream(doc.getChildNodes(NodeType.SHAPE, true).toArray())
         .filter(Shape.class::isInstance)
         .map(Shape.class::cast)
         .collect(Collectors.toList());

 Assert.assertEquals(0, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.TEXT_BOX));
 Assert.assertEquals(4, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.IMAGE));

 doc.save(getArtifactsDir() + "Shape.ReplaceTextboxesWithImages.docx");
 

Fields

FieldDescription
BOTHThe document text wraps on both sides of the shape.
DEFAULTDefault value is BOTH.
LARGESTThe document text wraps on the side of the shape that is farthest from the page margin, leaving text free area on the other side of the shape.
LEFTThe document text wraps on the left side of the shape only.
RIGHTThe document text wraps on the right side of the shape only.
length

Methods

MethodDescription
fromName(String wrapSideName)
getName(int wrapSide)
getValues()
toString(int wrapSide)

BOTH

public static int BOTH

The document text wraps on both sides of the shape.

DEFAULT

public static int DEFAULT

Default value is BOTH.

LARGEST

public static int LARGEST

The document text wraps on the side of the shape that is farthest from the page margin, leaving text free area on the other side of the shape.

LEFT

public static int LEFT

The document text wraps on the left side of the shape only. There is a text free area on the right of the shape.

public static int RIGHT

The document text wraps on the right side of the shape only. There is a text free area on the left side of the shape.

length

public static int length

fromName(String wrapSideName)

public static int fromName(String wrapSideName)

Parameters:

ParameterTypeDescription
wrapSideNamejava.lang.String

Returns: int

getName(int wrapSide)

public static String getName(int wrapSide)

Parameters:

ParameterTypeDescription
wrapSideint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int wrapSide)

public static String toString(int wrapSide)

Parameters:

ParameterTypeDescription
wrapSideint

Returns: java.lang.String