Page 1 of 1

problem with generate textId

PostPosted: Thu Jul 24, 2014 7:04 am
by RFleischman
I have an application that is generating docx documents, however when they are being merged into other documents by Sharepoint we are experiencing problems.

When the documents are run through Microsoft's OpenXML tool it fails to validate with the following error:
Capture.PNG
shows the error
Capture.PNG (10.91 KiB) Viewed 1418 times


When I look at the source code for the P class it clearly states the same restriction. I am not sure where in the process this textId (and paraId) are being set, or how, but occasionally they violate this rule.

Can anyone either point me in the right direction or tell me if this has been logged as a bug?

Thanks

Bob Fleischman

Re: problem with generate textId

PostPosted: Thu Jul 24, 2014 8:29 am
by RFleischman
I found the code that sets the value in MainDocumentPartMceIgnorableHelper

Code: Select all
         
         // For W14, we'll check/set paraId, textId
         if (p.getParaId()==null) {
            // Values MUST be greater than 0 and less than 0x80000000
            // So let's
            
            String uuid = java.util.UUID.randomUUID().toString();
            // That's 32 digits, but 8'll do nicely
            uuid = uuid.replace("-", "").substring(0, 8);
            
            p.setParaId(uuid);
            p.setTextId(uuid);
         }

The problem is an 8 character hex code could exceed, by a lot, the max allowed value.

Either just use 7 or test if the value exceeds the allowed amount and regenerate.

Do you have a preferred method?

Re: problem with generate textId

PostPosted: Thu Jul 24, 2014 9:21 am
by jason
Hi Bob, thanks for chasing this one down.

Either just use 7 or test if the value exceeds the allowed amount and regenerate.

Do you have a preferred method?


Just using 7 would be the simplest. If it is easy for you to make this change, test, then send a pull request, please do so. Otherwise, I'll make the change myself, and you can try it in a nightly build. Let me know which you prefer.

Re: problem with generate textId

PostPosted: Fri Jul 25, 2014 1:17 am
by RFleischman
I forked the code and made the change to 7, however when I tried to run the tests i received the following error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project docx4j: Compilation failure: Compilation failure:
[ERROR] \gitrepo\docx4j\src\main\java\org\docx4j\fonts\GlyphCheck.java:[12,30] package com.google.common.cache does not exist

Re: problem with generate textId

PostPosted: Fri Jul 25, 2014 7:59 am
by jason
Since last week, docx4j tip has required com.google.guava

Committed just now is https://github.com/plutext/docx4j/commi ... 161043b086 which updates the Maven pom and ant build files. Sorry about that.