Page 1 of 1

ContentControlsPartsInfo example

PostPosted: Sat Mar 26, 2016 1:42 pm
by jason.r.berk
looking at
https://github.com/plutext/docx4j/blob/ ... lEdit.java

// If we know the itemId ....
String itemId = "{5448916C-134B-45E6-B8FE-88CC1FFC17C3}".toLowerCase();
CustomXmlDataStoragePart customXmlDataStoragePart = (CustomXmlDataStoragePart)wordMLPackage.getCustomXmlDataStorageParts().get(itemId);
// .. if you don't know the itemId (which you can get using ContentControlsPartsInfo),


I'm still confused on how to get the itemId and I can't seem to find any real info on the "ContentControlsPartsInfo"

I've created an example word file (attached) and using the OpenDOPE authoring plugin I've added an XML part with three elements (very simple stuff)

this example works perfectly, but in "production", I'm being handed the .docx file and I need to figure out how to identify the part containing the values I need to update. I only added one part, but there appears to be three parts.

Re: ContentControlsPartsInfo example

PostPosted: Sat Mar 26, 2016 11:02 pm
by jason.r.berk
I did a fresh clone and grep'd the code:
jberk@mac-pro:~/repos/docx4j/src/samples/docx4j$ grep -ri 'partsinfo' .
./org/docx4j/samples/ContentControlsXmlEdit.java: // .. if you don't know the itemId (which you can get using ContentControlsPartsInfo),


I need to know if I should be putting an ID on an element or using a namespace or something like that. If someone from the business produces a word file using the plugin from http://www.opendope.org/downloads/autho ... /setup.exe, how can I programmatically determine which parts is the custom part? I assume Word is creating the UUID used as the item id?

Re: ContentControlsPartsInfo example

PostPosted: Sat Mar 26, 2016 11:08 pm
by jason.r.berk
https://github.com/plutext/docx4j/blob/ ... Parts.java seems to be what I was looking for...notice the name is different. "(which you can get using ContentControlsPartsInfo)"

ContentControlsInfoParts.java vs ContentControlsPartsInfo

Re: ContentControlsPartsInfo example

PostPosted: Sun Mar 27, 2016 1:02 pm
by jason
jason.r.berk wrote: I only added one part, but there appears to be three parts.


Yes, if you look at their contents, you'll aways find:

(1) a part containing your xml
(2) a part containing the xpaths (referenced from content controls via w:tag); this is because w:tag values are restricted in length (to 64 char iirc)
(3) a part containing condition definitions

jason.r.berk wrote:in "production", I'm being handed the .docx file and I need to figure out how to identify the part containing the values I need to update


Ordinarily, you rely on docx4j to figure that out; see https://github.com/plutext/docx4j/blob/ ... sions.java