opc_generate output display issue

Mar 25, 2016 at 3:59 PM
Edited Mar 25, 2016 at 4:07 PM
Hi and thank you for the wonderful work you've done here. I am attempting to use opc_generate on a form.docx template created in LibreOffice 4.2.8.2. I first created a template .docx file, then ran the following to generate the new document:
opc_generate form.docx form.cpp
Part /_rels/.rels does not exist.!
time 0.00sec

g++ -I. -I/usr/include/libxml2 -I/usr/include/libxslt -I../../../libopc-0.0.3/usr/include -fPIC -Wall -DPIC form.cpp -o form.out -lxml2 -lxslt -lz -lopc -lmce
which compiled without warnings or errors. Then I generate the new document by running the boilerplate code produced with opc_generate:
./form.out final_form.docx
That ran without error and produced final_form.docx, which I cannot open in the same LibreOffice 4.2.8.2 I used to create the initial form.docx template. Inspecting the final_form.docx container, I noticed a few differences such as the "_rels" directory now being 533 bytes instead of 573 bytes, which is the initial form.docx's "_rels" directory size. There are also changes/differences between the "word" directory and the [Content Types].xml in the root. In each of the differences, the size of the counterpart in the final_form.docx container is smaller*...


So my question is shouldn't the form.out program produced by opc_generate produce the identical copy of the source form.docx?

I'm using libopc-0.0.3 by the way... One other thing, and this may be unrelated, by I will put it here anyway. The same issue seems to be happening when I do the following in code:
std::ifstream src(docxTemplateFile.c_str(), std::ios::binary);
std::ofstream dst(docxFinalFile.c_str(), std::ios::binary);

if (src.is_open() && dst.is_open()) {
dst << src.rdbuf();
dst.close();
src.close();
}
else {
return false;
}

opcContainer* c = opcContainerOpen(_X(docxFinalFile.c_str()), OPC_OPEN_READ_WRITE, NULL, NULL);
opcContainer* cSource = opcContainerOpen(_X(docxTemplateFile.c_str()), OPC_OPEN_READ_ONLY, NULL, NULL);
opcContainerClose(c, OPC_CLOSE_NOW);
opcContainerClose(cSource, OPC_CLOSE_NOW);
The only difference I could identify was the docxFinalFile container c was opened in OPC_OPEN_READ_WRITE mode, while the docxTemplateFile container cSource was opened in OPC_OPEN_READ_ONLY mode . Although I'm opening the container in OPC_OPEN_READ_WRITE mode, I did not make any changes to the container (in code), but there seems to be changes occuring to the container when opcContainerClose(cSource, OPC_CLOSE_NOW) runs. I was expecting the above code to produce a copy of the source docxTemplateFile, but the same issue seems to be happening as with opc_generate? Any ideas?