12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include <opc/opc.h>
- #ifdef WIN32
- #include <crtdbg.h>
- #endif
- int main( int argc, const char* argv[] )
- {
- #ifdef WIN32
- _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
- #endif
- opcInitLibrary();
- for(int i=1;i<argc;i++) {
- opcContainer *c=opcContainerOpen(_X(argv[1]), OPC_OPEN_READ_ONLY, NULL, NULL);
- opcRelation rel=opcRelationFind(c, OPC_PART_INVALID, NULL, _X("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"));
- if (OPC_RELATION_INVALID!=rel) {
- opcPart mainPart=opcRelationGetInternalTarget(c, OPC_PART_INVALID, rel);
- if (OPC_PART_INVALID!=mainPart) {
- const xmlChar *type=opcPartGetType(c, mainPart);
- printf("Office Document Type: %s\n", type);
- if (0==xmlStrcmp(type, _X("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"))) {
- printf("WORD Document\n");
- } else if (0==xmlStrcmp(type, _X("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"))) {
- printf("POWERPOINT Document\n");
- } else if (0==xmlStrcmp(type, _X("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"))) {
- printf("EXCEL Document\n");
- }
- }
- }
- opcContainerClose(c, OPC_CLOSE_NOW);
- }
- opcFreeLibrary();
- #ifdef WIN32
- OPC_ASSERT(!_CrtDumpMemoryLeaks());
- #endif
- return 0;
- }
|