]> www.wagner.pp.ru Git - oss/catdoc.git/commitdiff
Implemented
authorVictor Wagner <vitus@wagner.pp.ru>
Tue, 17 Oct 2006 19:11:29 +0000 (19:11 +0000)
committerVictor Wagner <vitus@wagner.pp.ru>
Tue, 17 Oct 2006 19:11:29 +0000 (19:11 +0000)
option -b in catppt fixses debian bug 383576
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=383576

src/catppt.c
src/pptparse.c

index 31c81207b257cfe7c5b19943bfc25d1f814c5a0e..c90580cb809042293def7f2fffb0a8e6cf6a27e6 100644 (file)
@@ -2,7 +2,7 @@
  * @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;
 
 /** 
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
        
        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);
@@ -81,6 +81,9 @@ int main(int argc, char *argv[]) {
                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:
index e74c93ab782bed25952045f90467a8d303f98301..c5ebe0381bd3c78f6cb5839198343736546a0b7c 100644 (file)
@@ -2,7 +2,7 @@
  * @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);
 
 /** 
  * 
@@ -34,12 +37,21 @@ static void process_item (int rectype, long reclen, FILE* input);
  * @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); */
@@ -73,11 +85,16 @@ void do_ppt(FILE *input,char *filename) {
 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:
@@ -92,7 +109,6 @@ static void process_item (int rectype, long reclen, FILE* input) {
 
        case SLIDE:
 /*             fprintf(stderr,"Slide, reclen=%ld\n", reclen); */
-/*             fputs("---------------------------------------\n",stderr); */
                break;
 
        case SLIDE_ATOM:
@@ -133,6 +149,7 @@ static void process_item (int rectype, long reclen, FILE* input) {
                
        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)
@@ -149,6 +166,7 @@ static void process_item (int rectype, long reclen, FILE* input) {
                        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);
@@ -247,7 +265,9 @@ static void process_item (int rectype, long reclen, FILE* 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;