Word documents with more than about 1024 graphics let Abiword crash on linux because in default settings we can only have 1024 file descriptors open per process.
E.g. in bug #2633 http://www.stud.uni-karlsruhe.de/~uhwe/abi2/HoehereMathematik121098-231098.doc show this behavior. Following patch works around this problem by holding the data in memory instead of in files. Note that I did not convert all uses of tmpfile() in wv to this new behavior and probably other users of wv subroutines will have to be updated, too. Please let me know what you think about this way. Robert Index: src/wp/impexp/xp/ie_imp_MsWord_97.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_MsWord_97.cpp,v retrieving revision 1.145 diff -u -r1.145 ie_imp_MsWord_97.cpp --- src/wp/impexp/xp/ie_imp_MsWord_97.cpp 2002/01/24 10:20:14 1.145 +++ src/wp/impexp/xp/ie_imp_MsWord_97.cpp 2002/01/30 18:40:51 @@ -2429,16 +2429,23 @@ MSWord_ImageType imgType = s_determineImageType ( b ); - if ( imgType == MSWord_RasterImage ) + if ( (imgType == MSWord_RasterImage) || (imgType == MSWord_VectorImage) ) { - while (EOF != (data = getc(b->blip.bitmap.m_pvBits->stream.file_stream))) + if (b->blip.bitmap.m_pvBits->kind == FILE_STREAM) + { + + while (EOF != (data = getc(b->blip.bitmap.m_pvBits->stream.file_stream))) pictData->append((UT_Byte*)&data, 1); + } + else + if (b->blip.bitmap.m_pvBits->kind == MEMORY_STREAM) + { + +pictData->append((UT_Byte*)b->blip.bitmap.m_pvBits->stream.memory_stream->mem, +(unsigned int) b->blip.bitmap.m_pvBits->stream.memory_stream->size ); + } + else + abort(); + } - else if ( imgType == MSWord_VectorImage ) - { - while (EOF != (data = getc(b->blip.metafile.m_pvBits->stream.file_stream))) - pictData->append((UT_Byte*)&data, 1); - } else { UT_DEBUGMSG(("UNKNOWN IMAGE TYPE!!")); Index: fbse.c =================================================================== RCS file: /cvsroot/wv/fbse.c,v retrieving revision 1.12 diff -u -r1.12 fbse.c --- fbse.c 2001/12/26 16:52:19 1.12 +++ fbse.c 2002/01/30 18:43:05 @@ -292,8 +293,26 @@ } rewind (tmp); + + { + MemoryStream ms; + char *p; + + + fseek(tmp,0,SEEK_END); + ms.size = ftell(tmp); + + ms.mem = p = malloc(ms.size); + + + for(i=0;i<ms.size;i++) + *p++ = getc(tmp); + + fclose(tmp); - wvStream_FILE_create (&stm, tmp); + + wvStream_memory_create (&stm, &ms); + } amf->m_pvBits = stm; Index: support.c =================================================================== RCS file: /cvsroot/wv/support.c,v retrieving revision 1.23 diff -u -r1.23 support.c --- support.c 2001/10/23 16:42:25 1.23 +++ support.c 2002/01/30 18:43:05 @@ -84,6 +84,15 @@ } void +wvStream_memory_create (wvStream ** in, MemoryStream * inner) +{ + wvInternalStream str; + str.libole_stream = inner; + wvStream_create (in, MEMORY_STREAM, str); +} + + +void wvStream_create (wvStream ** in, wvStreamKind kind, wvInternalStream inner) { wvStream_list *listEntry; @@ -260,12 +276,21 @@ return (ret); } else + if (in->kind == FILE_STREAM) { U32 ret; ret = (U32) fclose (in->stream.file_stream); wvFree (in); return (ret); } + else + if (in->kind == MEMORY_STREAM) + { + free (in->stream.memory_stream->mem); + wvFree (in); + return 0; + } + else abort(); } Index: wv.h =================================================================== RCS file: /cvsroot/wv/wv.h,v retrieving revision 1.98 diff -u -r1.98 wv.h --- wv.h 2002/01/21 15:00:42 1.98 +++ wv.h 2002/01/30 18:43:11 @@ -19,12 +19,19 @@ */ typedef enum { LIBOLE_STREAM, - FILE_STREAM + FILE_STREAM, + MEMORY_STREAM } wvStreamKind; + typedef struct { + char *mem; + unsigned long size; + } MemoryStream; + typedef union { FILE *file_stream; MsOleStream *libole_stream; + MemoryStream *memory_stream; } wvInternalStream; typedef struct {
