BuildingBlockGallery

Inheritance: java.lang.Object

public class BuildingBlockGallery

Specifies the predefined gallery into which a building block is classified.

Remarks:

Corresponds to the ST_DocPartGallery type in OOXML.

Examples:

Shows ways of accessing building blocks in a glossary document.


 public void glossaryDocument() throws Exception {
     Document doc = new Document();
     GlossaryDocument glossaryDoc = new GlossaryDocument();

     glossaryDoc.appendChild(createNewBuildingBlock(glossaryDoc, "Block 1"));
     glossaryDoc.appendChild(createNewBuildingBlock(glossaryDoc, "Block 2"));
     glossaryDoc.appendChild(createNewBuildingBlock(glossaryDoc, "Block 3"));
     glossaryDoc.appendChild(createNewBuildingBlock(glossaryDoc, "Block 4"));
     glossaryDoc.appendChild(createNewBuildingBlock(glossaryDoc, "Block 5"));

     Assert.assertEquals(glossaryDoc.getBuildingBlocks().getCount(), 5);

     doc.setGlossaryDocument(glossaryDoc);

     // There are various ways of accessing building blocks.
     // 1 -  Get the first/last building blocks in the collection:
     Assert.assertEquals("Block 1", glossaryDoc.getFirstBuildingBlock().getName());
     Assert.assertEquals("Block 5", glossaryDoc.getLastBuildingBlock().getName());

     // 2 -  Get a building block by index:
     Assert.assertEquals("Block 2", glossaryDoc.getBuildingBlocks().get(1).getName());
     Assert.assertEquals("Block 3", glossaryDoc.getBuildingBlocks().toArray()[2].getName());

     // 3 -  Get the first building block that matches a gallery, name and category:
     Assert.assertEquals("Block 4",
             glossaryDoc.getBuildingBlock(BuildingBlockGallery.ALL, "(Empty Category)", "Block 4").getName());

     // We will do that using a custom visitor,
     // which will give every BuildingBlock in the GlossaryDocument a unique GUID
     GlossaryDocVisitor visitor = new GlossaryDocVisitor();
     glossaryDoc.accept(visitor);
     System.out.println(visitor.getText());

     // In Microsoft Word, we can access the building blocks via "Insert" -> "Quick Parts" -> "Building Blocks Organizer".
     doc.save(getArtifactsDir() + "BuildingBlocks.GlossaryDocument.dotx");
 }

 public static BuildingBlock createNewBuildingBlock(final GlossaryDocument glossaryDoc, final String buildingBlockName) {
     BuildingBlock buildingBlock = new BuildingBlock(glossaryDoc);
     buildingBlock.setName(buildingBlockName);

     return buildingBlock;
 }

 /// 
 /// Gives each building block in a visited glossary document a unique GUID.
 /// Stores the GUID-building block pairs in a dictionary.
 /// 
 public static class GlossaryDocVisitor extends DocumentVisitor {
     public GlossaryDocVisitor() {
         mBlocksByGuid = new HashMap<>();
         mBuilder = new StringBuilder();
     }

     public String getText() {
         return mBuilder.toString();
     }

     public HashMap getDictionary() {
         return mBlocksByGuid;
     }

     public int visitGlossaryDocumentStart(final GlossaryDocument glossary) {
         mBuilder.append("Glossary document found!\n");
         return VisitorAction.CONTINUE;
     }

     public int visitGlossaryDocumentEnd(final GlossaryDocument glossary) {
         mBuilder.append("Reached end of glossary!\n");
         mBuilder.append("BuildingBlocks found: " + mBlocksByGuid.size() + "\r\n");
         return VisitorAction.CONTINUE;
     }

     public int visitBuildingBlockStart(final BuildingBlock block) {
         block.setGuid(UUID.randomUUID());
         mBlocksByGuid.put(block.getGuid(), block);
         return VisitorAction.CONTINUE;
     }

     public int visitBuildingBlockEnd(final BuildingBlock block) {
         mBuilder.append("\tVisited block \"" + block.getName() + "\"" + "\r\n");
         mBuilder.append("\t Type: " + block.getType() + "\r\n");
         mBuilder.append("\t Gallery: " + block.getGallery() + "\r\n");
         mBuilder.append("\t Behavior: " + block.getBehavior() + "\r\n");
         mBuilder.append("\t Description: " + block.getDescription() + "\r\n");

         return VisitorAction.CONTINUE;
     }

     private final HashMap mBlocksByGuid;
     private final StringBuilder mBuilder;
 }
 

Fields

FieldDescription
ALLSpecifies that this glossary document entry shall be associated with all possible gallery classification values.
AUTO_TEXT
BIBLIOGRAPHY
COVER_PAGE
CUSTOM_1
CUSTOM_2
CUSTOM_3
CUSTOM_4
CUSTOM_5
CUSTOM_AUTO_TEXT
CUSTOM_BIBLIOGRAPHY
CUSTOM_COVER_PAGE
CUSTOM_EQUATIONS
CUSTOM_FOOTERS
CUSTOM_HEADERS
CUSTOM_PAGE_NUMBER
CUSTOM_PAGE_NUMBER_AT_BOTTOM
CUSTOM_PAGE_NUMBER_AT_MARGIN
CUSTOM_PAGE_NUMBER_AT_TOP
CUSTOM_QUICK_PARTS
CUSTOM_TABLES
CUSTOM_TABLE_OF_CONTENTS
CUSTOM_TEXT_BOX
CUSTOM_WATERMARKS
DEFAULTSame as ALL.
EQUATIONS
FOOTERS
HEADERS
NO_GALLERY
PAGE_NUMBER
PAGE_NUMBER_AT_BOTTOM
PAGE_NUMBER_AT_MARGIN
PAGE_NUMBER_AT_TOP
QUICK_PARTS
STRUCTURED_DOCUMENT_TAG_PLACEHOLDER_TEXT
TABLES
TABLE_OF_CONTENTS
TEXT_BOX
WATERMARKS
length

Methods

MethodDescription
fromName(String buildingBlockGalleryName)
getName(int buildingBlockGallery)
getValues()
toString(int buildingBlockGallery)

ALL

public static int ALL

Specifies that this glossary document entry shall be associated with all possible gallery classification values.

AUTO_TEXT

public static int AUTO_TEXT

BIBLIOGRAPHY

public static int BIBLIOGRAPHY

COVER_PAGE

public static int COVER_PAGE

CUSTOM_1

public static int CUSTOM_1

CUSTOM_2

public static int CUSTOM_2

CUSTOM_3

public static int CUSTOM_3

CUSTOM_4

public static int CUSTOM_4

CUSTOM_5

public static int CUSTOM_5

CUSTOM_AUTO_TEXT

public static int CUSTOM_AUTO_TEXT

CUSTOM_BIBLIOGRAPHY

public static int CUSTOM_BIBLIOGRAPHY

CUSTOM_COVER_PAGE

public static int CUSTOM_COVER_PAGE

CUSTOM_EQUATIONS

public static int CUSTOM_EQUATIONS

CUSTOM_FOOTERS

public static int CUSTOM_FOOTERS

CUSTOM_HEADERS

public static int CUSTOM_HEADERS

CUSTOM_PAGE_NUMBER

public static int CUSTOM_PAGE_NUMBER

CUSTOM_PAGE_NUMBER_AT_BOTTOM

public static int CUSTOM_PAGE_NUMBER_AT_BOTTOM

CUSTOM_PAGE_NUMBER_AT_MARGIN

public static int CUSTOM_PAGE_NUMBER_AT_MARGIN

CUSTOM_PAGE_NUMBER_AT_TOP

public static int CUSTOM_PAGE_NUMBER_AT_TOP

CUSTOM_QUICK_PARTS

public static int CUSTOM_QUICK_PARTS

CUSTOM_TABLES

public static int CUSTOM_TABLES

CUSTOM_TABLE_OF_CONTENTS

public static int CUSTOM_TABLE_OF_CONTENTS

CUSTOM_TEXT_BOX

public static int CUSTOM_TEXT_BOX

CUSTOM_WATERMARKS

public static int CUSTOM_WATERMARKS

DEFAULT

public static int DEFAULT

Same as ALL.

EQUATIONS

public static int EQUATIONS

FOOTERS

public static int FOOTERS

HEADERS

public static int HEADERS
public static int NO_GALLERY

PAGE_NUMBER

public static int PAGE_NUMBER

PAGE_NUMBER_AT_BOTTOM

public static int PAGE_NUMBER_AT_BOTTOM

PAGE_NUMBER_AT_MARGIN

public static int PAGE_NUMBER_AT_MARGIN

PAGE_NUMBER_AT_TOP

public static int PAGE_NUMBER_AT_TOP

QUICK_PARTS

public static int QUICK_PARTS

STRUCTURED_DOCUMENT_TAG_PLACEHOLDER_TEXT

public static int STRUCTURED_DOCUMENT_TAG_PLACEHOLDER_TEXT

TABLES

public static int TABLES

TABLE_OF_CONTENTS

public static int TABLE_OF_CONTENTS

TEXT_BOX

public static int TEXT_BOX

WATERMARKS

public static int WATERMARKS

length

public static int length

fromName(String buildingBlockGalleryName)

public static int fromName(String buildingBlockGalleryName)

Parameters:

ParameterTypeDescription
buildingBlockGalleryNamejava.lang.String

Returns: int

getName(int buildingBlockGallery)

public static String getName(int buildingBlockGallery)

Parameters:

ParameterTypeDescription
buildingBlockGalleryint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int buildingBlockGallery)

public static String toString(int buildingBlockGallery)

Parameters:

ParameterTypeDescription
buildingBlockGalleryint

Returns: java.lang.String