* @file ppt2text.c
* @author Alex Ott <alexott@gmail.com>
* @date 23 äÅË 2004
- * Version: $Id: catppt.c,v 1.1 2006-02-24 17:44:06 vitus Exp $
+ * Version: $Id: catppt.c,v 1.2 2006-10-17 19:11:29 vitus Exp $
* Copyright: Alex Ott
*
* @brief main module for text extracting from .ppt
*
*/
void help (void) {
- printf("Usage:\n ppt2text [-lV] [-b string] [-s charset] [-d charset] files\n");
+ printf("Usage:\n catppt [-lV] [-b string] [-s charset] [-d charset] files\n");
}
-
+extern char *slide_separator;
char *input_buffer, *output_buffer;
/**
check_charset(&dest_csname,dest_csname);
- while ((c=getopt(argc,argv,"Vls:d:p:"))!=-1) {
+ while ((c=getopt(argc,argv,"Vls:d:b:"))!=-1) {
switch(c) {
case 'l':
list_charsets(); exit(0);
case 'd':
check_charset(&dest_csname,optarg);
break;
+ case 'b':
+ slide_separator = strdup(optarg);
+ break;
case 'V': printf("Catdoc Version %s\n",CATDOC_VERSION);
exit(0);
default:
* @file pptparse.c
* @author Alex Ott <alexott@gmail.com>
* @date 23 äÅË 2004
- * Version: $Id: pptparse.c,v 1.1 2006-02-24 17:44:06 vitus Exp $
+ * Version: $Id: pptparse.c,v 1.2 2006-10-17 19:11:29 vitus Exp $
* Copyright: Alex Ott
*
* @brief .ppt parsing routines
#include "catdoc.h"
#include "ppttypes.h"
+char *slide_separator = "\f";
+
static void process_item (int rectype, long reclen, FILE* input);
#if !defined(min)
#define min(x,y) ((x) < (y) ? (x) : (y))
#endif
+static void start_text_out(void);
/**
*
* @param input
* @param filename
*/
+
+enum {START_FILE,START_SLIDE,TEXTOUT,END_FILE} slide_state ;
+
+static void start_text_out(void) {
+ if (slide_state == START_SLIDE) {
+ fputs(slide_separator,stdout);
+ }
+ slide_state = TEXTOUT;
+}
void do_ppt(FILE *input,char *filename) {
int itemsread=1;
int rectype;
long reclen;
unsigned char recbuf[8];
-
+ slide_state = START_FILE;
while(itemsread) {
itemsread = catdoc_read(recbuf, 1, 8, input);
/* fprintf(stderr,"itemsread=%d: ",itemsread); */
static void process_item (int rectype, long reclen, FILE* input) {
int i=0, u;
static char buf[2];
-
+/* fprintf(stderr,"Processing record %d length %d\n",rectype,reclen);
+ * */
switch(rectype) {
case DOCUMENT_END:
/* fprintf(stderr,"End of document, ended at %ld\n",catdoc_tell(input)); */
catdoc_seek(input, reclen, SEEK_CUR);
+ if (slide_state == TEXTOUT) {
+ fputs(slide_separator,stdout);
+ slide_state = END_FILE;
+ }
break;
case DOCUMENT:
case SLIDE:
/* fprintf(stderr,"Slide, reclen=%ld\n", reclen); */
-/* fputs("---------------------------------------\n",stderr); */
break;
case SLIDE_ATOM:
case TEXT_BYTES_ATOM: {
/* fprintf(stderr,"TextBytes, reclen=%ld\n", reclen); */
+ start_text_out();
for(i=0; i < reclen; i++) {
catdoc_read(buf,1,1,input);
if((unsigned char)*buf!=0x0d)
long text_len;
/* fprintf(stderr,"CString, reclen=%ld\n", reclen); */
+ start_text_out();
text_len=reclen/2;
for(i=0; i < text_len; i++) {
catdoc_read(buf,2,1,input);
break;
case SLIDE_PERSIST_ATOM:
-/* fprintf(stderr,"SlidePersistAtom, reclen=%ld\n", reclen); */
+ if (slide_state != START_FILE) {
+ slide_state = START_SLIDE;
+ }
catdoc_seek(input, reclen, SEEK_CUR);
break;