diff options
| author | David Mathog <mathog@caltech.edu> | 2014-02-08 07:17:30 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2014-02-08 07:17:30 +0000 |
| commit | 042cc81dd7c3ca2f0d42b68356f4b450074c8473 (patch) | |
| tree | f9acbfb046848f7cd420a1fbdf718bdcd604ed11 /src/libuemf | |
| parent | Extensions->Render submenu. Scaling of input parameters into document units, ... (diff) | |
| download | inkscape-042cc81dd7c3ca2f0d42b68356f4b450074c8473.tar.gz inkscape-042cc81dd7c3ca2f0d42b68356f4b450074c8473.zip | |
EMF/WMF support: Various changes (see bug #1263242 c35 for details)
EMF support:
- linear gradients: improve numeric stability on round-trip editing
- linear gradients: fix scaling issue
libTERE/text_reassemble update:
- improve handling of whitespace created with large x kerns
- fix handling of absolute RTL-positioning of LTR text in EMF files
WMF support:
- fix support for 'textout' records and Placeable headers
- add support for CREATEPATTERNBRUSH
- fix offset on load if opened via GUI (bug #1250250)
Fixed bugs:
- https://launchpad.net/bugs/1263242
- https://launchpad.net/bugs/1250250
(bzr r13008)
Diffstat (limited to 'src/libuemf')
| -rw-r--r-- | src/libuemf/README | 6 | ||||
| -rw-r--r-- | src/libuemf/uemf_utf.c | 95 | ||||
| -rw-r--r-- | src/libuemf/uwmf.c | 22 |
3 files changed, 87 insertions, 36 deletions
diff --git a/src/libuemf/README b/src/libuemf/README index 4c23cdd52..cfa322178 100644 --- a/src/libuemf/README +++ b/src/libuemf/README @@ -366,6 +366,12 @@ History (Note, version numbers in files represent the libUEMF release where it was last modified, so not all files will show the same version numbers in each release.) +0.1.11 2014-01-29 + Fixed bug in uwmf.c (wrong minimum record size on U_WMRTEXTOUT) + Fixed bug in uwmf.c (U_WMRCREATEPATTERNBRUSH not right) + Added error handling to uemf_utf.c for cases where src is a null pointer. + Added a test of createpatternbrush to testlib_wmf + 0.1.10 2014-01-14 Slight changes in documentation for uemf.h. Fixed typo in uemf_endian.c. diff --git a/src/libuemf/uemf_utf.c b/src/libuemf/uemf_utf.c index f329e74d9..bce60af4d 100644 --- a/src/libuemf/uemf_utf.c +++ b/src/libuemf/uemf_utf.c @@ -12,11 +12,11 @@ /* File: uemf_utf.c -Version: 0.0.4 -Date: 19-MAR-2013 +Version: 0.0.5 +Date: 29-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -68,9 +68,14 @@ These functions are used for development and debugging and should be be includie void wchar8show( const char *src ){ - printf("char show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("char show <NULL>\n"); + } + else { + printf("char show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -80,9 +85,14 @@ void wchar8show( void wchar16show( const uint16_t *src ){ - printf("uint16_t show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("uint16_t show <NULL>\n"); + } + else { + printf("uint16_t show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -91,9 +101,14 @@ void wchar16show( void wchar32show( const uint32_t *src ){ - printf("uint32_t show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("uint32_t show <NULL>\n"); + } + else { + printf("uint32_t show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -104,13 +119,19 @@ void wchartshow( const wchar_t *src ){ uint32_t val; - printf("wchar_t show\n"); - size_t srclen = 0; - while(*src){ - val = *src; // because *src is wchar_t is not strictly an integer type, can cause warnings on next line - printf("%d %d %x\n",(int) srclen,val,val); - srclen++; - src++; + if(!src){ + printf("wchar_t show <NULL>\n"); + } + else { + printf("wchar_t show\n"); + size_t srclen = 0; + if(!src)return; + while(*src){ + val = *src; // because *src is wchar_t is not strictly an integer type, can cause warnings on next line + printf("%d %d %x\n",(int) srclen,val,val); + srclen++; + src++; + } } } @@ -127,7 +148,9 @@ size_t wchar16len( const uint16_t *src ){ size_t srclen = 0; - while(*src){ srclen++; src++; } + if(src){ + while(*src){ srclen++; src++; } + } return(srclen); } @@ -139,7 +162,9 @@ size_t wchar32len( const uint32_t *src ){ size_t srclen = 0; - while(*src){ srclen++; src++; } + if(src){ + while(*src){ srclen++; src++; } + } return(srclen); } @@ -154,9 +179,11 @@ void wchar16strncpy( const uint16_t *src, size_t nchars ){ - for(;nchars;nchars--,dst++,src++){ - *dst = *src; - if(!*src)break; + if(src){ + for(;nchars;nchars--,dst++,src++){ + *dst = *src; + if(!*src)break; + } } } @@ -172,8 +199,10 @@ void wchar16strncpypad( const uint16_t *src, size_t nchars ){ - for(;*src && nchars;nchars--,dst++,src++){ *dst = *src; } - for(;nchars;nchars--,dst++){ *dst = 0; } // Pad the remainder + if(src){ + for(;*src && nchars;nchars--,dst++,src++){ *dst = *src; } + for(;nchars;nchars--,dst++){ *dst = 0; } // Pad the remainder + } } /* For the following converstion functions, remember that iconv() modifies ALL of its parameters, @@ -197,6 +226,7 @@ uint16_t *U_Utf32leToUtf16le( char *dst,*dst2; size_t srclen,dstlen,status; + if(!src)return(NULL); if(max){ srclen = 4*max; } else { srclen = 4 + 4*wchar32len(src); } //include terminator, length in BYTES @@ -226,6 +256,8 @@ uint32_t *U_Utf16leToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*wchar16len(src)+2; } // include terminator, length in BYTES dstlen = 2*(2 + srclen); // This should always work @@ -261,6 +293,8 @@ uint32_t *U_Latin1ToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = sizeof(uint32_t)*(1 + srclen); // This should always work but might waste some space @@ -290,6 +324,8 @@ uint32_t *U_Utf8ToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = sizeof(uint32_t)*(1 + srclen); // This should always work but might waste some space @@ -319,6 +355,8 @@ char *U_Utf32leToUtf8( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 4*max; } else { srclen = 4*(1 + wchar32len(src)); } //include terminator, length in BYTES dstlen = 1 + srclen; // This should always work but might waste some space @@ -349,6 +387,7 @@ uint16_t *U_Utf8ToUtf16le( size_t srclen,dstlen,status; iconv_t conv; + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = 2 * (1 + srclen); // this will always work, but may waste space @@ -378,6 +417,8 @@ char *U_Utf16leToUtf8( char *dst, *dst2; char *ret=NULL; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*(1 +wchar16len(src)); } //include terminator, length in BYTES dstlen = 1 + 2*srclen; // this will always work, but may waste space @@ -410,6 +451,8 @@ char *U_Utf16leToLatin1( char *dst, *dst2; char *ret=NULL; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*(1 +wchar16len(src)); } //include terminator, length in BYTES dstlen = 1 + srclen; // this will always work as latin1 is always 1 byte/character diff --git a/src/libuemf/uwmf.c b/src/libuemf/uwmf.c index a6ac963cb..be1feadea 100644 --- a/src/libuemf/uwmf.c +++ b/src/libuemf/uwmf.c @@ -19,11 +19,11 @@ /* File: uwmf.c -Version: 0.0.12 -Date: 25-NOV-2013 +Version: 0.0.13 +Date: 30-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -4271,13 +4271,12 @@ char *U_WMRCREATEPATTERNBRUSH_set( if(!Bm16 || !Pattern)return(NULL); cbPat = (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; - irecsize = U_SIZE_METARECORD + 14 + 4 + 18 + cbPat; /* core WMR + truncated Bm16 + pattern */ + irecsize = U_SIZE_METARECORD + 14 + 18 + cbPat; /* core WMR + truncated Bm16 + 18 spaces bytes + pattern */ record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_CREATEPATTERNBRUSH); off = U_SIZE_METARECORD; - memcpy(record + off, Bm16, 14); off+=14; /* Truncated bitmap16 object*/ - memset(record + off, 0, 4); off+=4; /* 4 bytes of its "bits", which are ignored */ + memcpy(record + off, Bm16, 14); off+=14; /* Truncated bitmap16 object, last 4 bytes are to be ignored*/ memset(record + off, 0, 18); off+=18; /* 18 bytes of zero, which are ignored */ memcpy(record + off, Pattern, cbPat); /* The pattern array */ } @@ -5359,7 +5358,7 @@ int U_WMRTEXTOUT_get( ){ int16_t L2; int off; - int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRPATBLT)); + int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRTEXTOUT)); if(!size)return(0); *Length = *(int16_t *)(contents + offsetof(U_WMRTEXTOUT, Length)); *string = contents + offsetof(U_WMRTEXTOUT, String); /* May not be null terminated!!! */ @@ -6851,12 +6850,15 @@ int U_WMRCREATEPATTERNBRUSH_get( const char **Pattern ){ int off = U_SIZE_METARECORD; - int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETDIBTODEV)); + /* size in next one is + 6 (core header) + 14 (truncated bitmap16) + 18 bytes reserved + 2 bytes (at least) for data */ + int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_METARECORD + 14 + 18 + 2)); if(!size)return(0); memset(Bm16, 0, U_SIZE_BITMAP16); - memcpy(Bm16, contents + off, 14); /* BM16 is truncated in this record type */ + /* BM16 is truncated in this record type to 14 bytes, last 4 bytes must be ignored, so they are not even copied */ + memcpy(Bm16, contents + off, 10); *pasize = (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; - off += 36; /* skip [truncated bitmap16 object and 18 bytes of reserved */ + off += 32; /* skip [14 bytes of truncated bitmap16 object and 18 bytes of reserved */ *Pattern = (contents + off); return(size); } |
