Help with Error

Aug 19, 2011 at 8:03 AM

Hello,

I'm attempting to create my own document.xml and place it into an existing docx, and i'm getting an assertion. Using the following code:

 

               QString outputString;
               QTextStream textStream(&outputString);
               DocXVisitor docxVisitor(textStream);
               currentDocument_->Accept(docxVisitor);

               opcContainer *c=opcContainerOpen(_X(qPrintable(fileName)), 
                  OPC_OPEN_READ_WRITE, 
                  NULL, NULL);
               opcPart part=opcPartCreate(c, _X("word/document.xml"), _X("text/xml"), 0);
            
               opcContainerOutputStream *stream=opcContainerCreateOutputStream(c, part, OPC_COMPRESSIONOPTION_NONE);
               opcContainerWriteOutputStream(stream, (const opc_uint8_t *)qPrintable(outputString), outputString.length());
               opcContainerCloseOutputStream(stream);
               opcContainerClose(c, OPC_CLOSE_NOW);

 

I'm getting the following assertion:

Assertion failed: 8!=compression_method || bit_flag==6, file c:\users\flo\documents\libopc\libopc-8525\opc\zip.c, line 980

Stack trace is:

 	msvcr100d.dll!abort()  Line 61 + 0x7 bytes	C
 	msvcr100d.dll!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno)  Line 153	C
 	ICDE.exe!opcZipCreateSegment()  Line 980 + 0x2e bytes	C++
 	ICDE.exe!opcZipOutputStreamFlushAndGrow()  Line 1299 + 0x36 bytes	C++
 	ICDE.exe!opcZipOutputStreamFinishSegment()  Line 1345 + 0xd bytes	C++
 	ICDE.exe!opcZipCloseOutputStream()  Line 1352 + 0xd bytes	C++
 	ICDE.exe!opcContainerCloseOutputStream()  Line 907 + 0x19 bytes	C++
>	ICDE.exe!EditTab::SaveCurrentDocumentToDocx()  Line 342 + 0x9 bytes	C++

The line it's erroring on is this:

 OPC_ASSERT(8!=compression_method || bit_flag==6); // WHEN DELFATE set bit_flag to BEST compression

I had a guess at the cause and changed the compression settings around, but couldn't get it to work. It's actually hitting this problem when I close the output stream. 

Any guidance would be a boon.

Thanks,

Simon

Coordinator
Aug 22, 2011 at 8:36 AM

Hi Simon,

 

I couldn't reproduce the problem with a simple "Hello World.docx". Is it possible for you to share the document you are using for testing with me?

The code to replace a stream inline is quite tricky and its possible that there is an error in libopc, but I would need a sample doc to find the problem.

Best would be to create an issue and attach the sample doc,

 

Thanks a lot,

 

Florian

Coordinator
Aug 22, 2011 at 9:00 AM

Hi Simon,

 

I was playing a bit more with some sample docs. I found an error: #603 which has to to with OPC_CLOSE_NOW. Its fixed upstream. 

If you use OPC_CLOSE_TRIM instead of OPC_CLOSE_NOW does the problem resp. assertion still occur?

 

Thanks,

 

Florian

Aug 22, 2011 at 10:00 AM

Hi Florian, 

Using OPC_CLOSE_TRIM I get a different error:

R6010 - abort() has been called.

Callstack:

	msvcr100d.dll!_NMSG_WRITE(int rterrnum)  Line 217	C
 	msvcr100d.dll!abort()  Line 61 + 0x7 bytes	C
 	msvcr100d.dll!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno)  Line 153	C
 	ICDE.exe!opcZipCreateSegment()  Line 980 + 0x2e bytes	C++
 	ICDE.exe!opcZipOutputStreamFlushAndGrow()  Line 1299 + 0x36 bytes	C++
 	ICDE.exe!opcZipOutputStreamFinishSegment()  Line 1345 + 0xd bytes	C++
 	ICDE.exe!opcZipCloseOutputStream()  Line 1352 + 0xd bytes	C++
 	ICDE.exe!opcContainerCloseOutputStream()  Line 907 + 0x19 bytes	C++
 	ICDE.exe!EditTab::SaveCurrentDocumentToDocx()  Line 342 + 0x9 bytes	C++

I can email you the content that's causing this crash no problems (would rather not post it on the forums - legalities!). I don't get the problem with simple examples, so there's something which this particular document is doing which is causing all sorts of problem.

Coordinator
Aug 22, 2011 at 10:11 AM

Hi Simon,

 

thanks for the feedback. Can you send the document to "flr (at) nooxml.com"?

 

Florian

Coordinator
Aug 22, 2011 at 11:10 AM

Hi Simon,

 

thanks for the sample data. I create an issue http://libopc.codeplex.com/workitem/605 and fixed it upstream.

 

Can you check whether it works for you?

 

Thanks a lot,

 

Florian

Aug 24, 2011 at 11:26 AM

Not going to get a chance to test it until Friday - I've been using release 0.2 so I'll have to download the source and roll my own. 

How would I go about just using the compression settings that are already present? Ideally I'd just use whatever the "template" document is using... that would also subvert the issue raised in 605 too.

Aug 26, 2011 at 3:45 AM

Can confirm that works. 

Coordinator
Aug 26, 2011 at 2:55 PM

Hi,

 

Thanks a lot for the feedback and the testing! I'll close the issue.

 

Florian