///////////////////////////////////////////////
// First, contents of existing content controls
// .. find the content controls
SdtFinder sdtFinder = new SdtFinder();
new TraversalUtil(mainDocument.getContent(), sdtFinder);
// .. loop through them
for (SdtElement sdtEl : sdtFinder.getSdtList()) {
content = sdtEl.getSdtContent().getContent();
groupedContent = groupContent(content);
if (groupedContent != null) {
content.clear();
content.addAll(groupedContent);
}
}
///////////////////////////////////////////////
// Second, contents of table cells
TcFinder tcFinder = new TcFinder();
tcFinder.setTraverseTables(true);
new TraversalUtil(mainDocument.getContent(), tcFinder);
for (Tc tc : tcFinder.tcList) {
content = tc.getContent();
groupedContent = groupContent(content);