summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Mathog <>2012-09-27 06:40:44 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-09-27 06:40:44 +0000
commitdb010468005eb279d242a698ed5b89b05bc0d817 (patch)
treefded1ef29234621af3caa9cca9706b2a3031643e /src
parentrevert .bzrgnore as well (diff)
downloadinkscape-db010468005eb279d242a698ed5b89b05bc0d817.tar.gz
inkscape-db010468005eb279d242a698ed5b89b05bc0d817.zip
fix compiler warnings with old GCC on Mac OS X and Solaris
(bzr r11668.1.16)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/emf-inout.cpp42
-rw-r--r--src/extension/internal/emf-print.cpp30
-rw-r--r--src/extension/internal/uemf.c6
-rw-r--r--src/extension/internal/uemf_endian.c55
4 files changed, 78 insertions, 55 deletions
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index 9fef38333..44f7d0465 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -138,7 +138,7 @@ my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
p->size += length;
}
-void toPNG(PMEMPNG accum, int width, int height, char *px, uint32_t cbPx){
+void toPNG(PMEMPNG accum, int width, int height, char *px){
bitmap_t bmstore;
bitmap_t *bitmap=&bmstore;
accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free().
@@ -650,8 +650,7 @@ uint32_t add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint32_t
toPNG( // Get the image from the RGBA px into mempng
&mempng,
width, height,
- rgba_px,
- 4 * width * height);
+ rgba_px);
free(rgba_px);
}
}
@@ -1462,7 +1461,8 @@ std::cout << "BEFORE DRAW"
tmp_outdef << "<svg\n";
tmp_outdef << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
tmp_outdef << " xmlns=\"http://www.w3.org/2000/svg\"\n";
- tmp_outdef << " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"; //mathog
+ tmp_outdef << " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n";
+ tmp_outdef << " xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n"; // needed for sodipodi:role
tmp_outdef << " version=\"1.0\"\n";
d->xDPI = 2540;
@@ -2557,8 +2557,7 @@ std::cout << "BEFORE DRAW"
toPNG( // Get the image from the RGBA px into mempng
&mempng,
width, height,
- rgba_px,
- 4 * width * height);
+ rgba_px);
free(rgba_px);
}
}
@@ -2710,18 +2709,20 @@ std::cout << "BEFORE DRAW"
// EMF textalignment is a bit strange: 0x6 is center, 0x2 is right, 0x0 is left, the value 0x4 is also drawn left
int lcr = ((d->dc[d->level].textAlign & U_TA_CENTER) == U_TA_CENTER) ? 2 : ((d->dc[d->level].textAlign & U_TA_CENTER) == U_TA_LEFT) ? 0 : 1;
- ts << " <text\n";
-// ts << " id=\"" << (d->id++) << "\"\n";
- ts << " xml:space=\"preserve\"\n";
- ts << " x=\"" << x << "\"\n";
- ts << " y=\"" << y << "\"\n";
+ ts << "<text\n";
+ ts << " xml:space=\"preserve\"\n";
+ ts << " x=\"" << x << "\"\n";
+ ts << " y=\"" << y << "\"\n";
if (d->dc[d->level].style.baseline_shift.value) {
- ts << " transform=\""
+ ts << " transform=\""
<< "rotate(-" << d->dc[d->level].style.baseline_shift.value
<< " " << x << " " << y << ")"
<< "\"\n";
}
- ts << " style=\""
+ ts << "><tspan sodipodi:role=\"line\"";
+ ts << " x=\"" << x << "\"\n";
+ ts << " y=\"" << y << "\"\n";
+ ts << " style=\""
<< "font-size:" << fabs(d->dc[d->level].style.font_size.computed) << "px;"
<< tmp
<< "font-style:" << (i ? "italic" : "normal") << ";"
@@ -2732,6 +2733,7 @@ std::cout << "BEFORE DRAW"
<< "\"\n";
ts << " >";
ts << escaped_text;
+ ts << " </tspan>";
ts << "</text>\n";
*(d->outsvg) += ts.str().c_str();
@@ -2989,7 +2991,7 @@ std::cout << "BEFORE DRAW"
} //end of while
// When testing, uncomment the following to show the final SVG derived from the EMF
-// std::cout << *(d->outsvg) << std::endl;
+std::cout << *(d->outsvg) << std::endl;
return 1;
}
@@ -3019,6 +3021,12 @@ typedef struct
} APMHEADER, *PAPMHEADER;
#pragma pack( pop )
+void free_emf_strings(EMF_STRINGS name){
+ if(name.count){
+ for(int i=0; i< name.count; i++){ free(name.strings[i]); }
+ free(name.strings);
+ }
+}
SPDocument *
Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
@@ -3080,9 +3088,9 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
delete d.path;
delete d.outdef;
delete d.defs;
- if(d.hatches.count){ free(d.hatches.strings); }
- if(d.images.count){ free(d.images.strings); }
-
+ free_emf_strings(d.hatches);
+ free_emf_strings(d.images);
+
if (d.emf_obj) {
int i;
for (i=0; i<d.n_obj; i++)
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index c70e5bd84..093d41fdb 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -207,22 +207,27 @@ static FFNEXUS *last=NULL;
search_long_fflist(fontname, f1, f2, f3);
}
-void smuggle_adx_out(const char *string, uint32_t **adx, int *ndx, float scale){
+void smuggle_adxky_out(const char *string, uint32_t **adx, double *ky, int *ndx, float scale){
float fdx;
int i;
uint32_t *ladx;
- const char *cptr=&string[strlen(string)+1];
+ const char *cptr=&string[strlen(string)+1]; // this works because of the first fake terminator
- *adx=NULL;
+ *adx = NULL;
+ *ky = 0.0; // set a default value
sscanf(cptr,"%7d",ndx);
if(!*ndx)return; // this could happen with an empty string
cptr += 7;
ladx = (uint32_t *) malloc(*ndx * sizeof(uint32_t) );
+ if(!ladx)throw "Out of memory";
*adx=ladx;
for(i=0; i<*ndx; i++,cptr+=7, ladx++){
sscanf(cptr,"%7f",&fdx);
*ladx=(uint32_t) round(fdx * scale);
}
+ cptr++; // skip 2nd fake terminator
+ sscanf(cptr,"%7f",&fdx);
+ *ky=fdx;
}
/* convert an 0RGB color to EMF U_COLORREF.
@@ -1915,23 +1920,12 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
double rotb = -std::atan2(tf[1], tf[0]); // rotation for baseline offset for superscript/subscript, used below
double dx,dy;
double f1,f2,f3;
-
-#ifdef USE_PANGO_WIN32
-/*
- font_instance *tf = (font_factory::Default())->Face(style->text->font_family.value, font_style_to_pos(*style));
- if (tf) {
- LOGFONT *lf = pango_win32_font_logfont(tf->pFont);
- tf->Unref();
- hfont = CreateFontIndirect(lf);
- g_free(lf);
- }
-*/
-#endif
+ double ky;
// the dx array is smuggled in like: text<nul>w1 w2 w3 ...wn<nul><nul>, where the widths are floats 7 characters wide, including the space
int ndx;
uint32_t *adx;
- smuggle_adx_out(text, &adx, &ndx, PX2WORLD * std::min(tf.expansionX(),tf.expansionY())); // side effect: free() adx
+ smuggle_adxky_out(text, &adx, &ky, &ndx, PX2WORLD * std::min(tf.expansionX(),tf.expansionY())); // side effect: free() adx
char *text2 = strdup(text); // because U_Utf8ToUtf16le calls iconv which does not like a const char *
uint16_t *unicode_text = U_Utf8ToUtf16le( text2, 0, NULL );
@@ -2045,8 +2039,12 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te
Geom::Point p2 = p * tf;
//Handle super/subscripts. Negative sign because of geometry of MM_TEXT.
+/*
p2[Geom::X] -= style->baseline_shift.computed * std::sin( rotb );
p2[Geom::Y] -= style->baseline_shift.computed * std::cos( rotb );
+*/
+ p2[Geom::X] += ky * std::sin( rotb );
+ p2[Geom::Y] += ky * std::cos( rotb );
//Conditionally handle compensation for PPT EMF import bug (affects PPT 2003-2010, at least)
if(FixPPTCharPos){
diff --git a/src/extension/internal/uemf.c b/src/extension/internal/uemf.c
index 9cbac159e..517f1f99f 100644
--- a/src/extension/internal/uemf.c
+++ b/src/extension/internal/uemf.c
@@ -14,8 +14,8 @@
/*
File: uemf.c
-Version: 0.0.8
-Date: 14-SEP-2012
+Version: 0.0.89
+Date: 25-SEP-2012
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2012 David Mathog and California Institute of Technology (Caltech)
@@ -59,7 +59,7 @@ definitions are not needed in end user code, so they are here rather than in uem
D = UP4(C); /* pixel array might not be a multiples of 4 bytes*/ \
E = sizeof(U_BITMAPINFOHEADER) + 4 * B->bmiHeader.biClrUsed; /* bmiheader + colortable*/ \
}\
- else { D = 0; E=0; }
+ else { C = 0; D = 0; E=0; }
// variable "off" must be declared in the function
diff --git a/src/extension/internal/uemf_endian.c b/src/extension/internal/uemf_endian.c
index 703714bbb..9c9f7f578 100644
--- a/src/extension/internal/uemf_endian.c
+++ b/src/extension/internal/uemf_endian.c
@@ -10,12 +10,15 @@
on the native byte order.
The only function here which should be called directly is U_emf_endian(), and then,except for testing purposes, only on a BE machine.
+
+ Many variables are initialized to zero even though they will always be set because
+ some versions of gcc give spurious "may be used uninitialized" warnings otherwise.
*/
/*
File: uemf_endian.h
-Version: 0.0.8
-Date: 17-SEP-2012
+Version: 0.0.9
+Date: 26-SEP-2012
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2012 David Mathog and California Institute of Technology (Caltech)
@@ -286,7 +289,7 @@ void extlogpen_swap(
PU_EXTLOGPEN elp,
int torev
){
- int count;
+ int count=0;
U_swap4(elp,3); // elpPenStyle elpWidth elpBrushStyle
// ordered bytes: elpColor
if(torev){
@@ -382,9 +385,9 @@ void emrtext_swap(
int torev
){
int off;
- uint32_t count;
- uint32_t offDx;
- uint32_t fOptions;
+ uint32_t count=0;
+ uint32_t offDx=0;
+ uint32_t fOptions=0;
pointl_swap(&(pemt->ptlReference),1); // ptlReference
if(torev){
count = pemt->nChars;
@@ -438,7 +441,7 @@ void core5_swap(char *record, int torev){
// Functions with the same form starting with U_EMRPOLYBEZIER_swap
void core1_swap(char *record, int torev){
- int count;
+ int count=0;
PU_EMRPOLYLINETO pEmr = (PU_EMRPOLYLINETO) (record);
if(torev){
count = pEmr->cptl;
@@ -454,7 +457,8 @@ void core1_swap(char *record, int torev){
// Functions with the same form starting with U_EMRPOLYPOLYLINE_swap
void core2_swap(char *record, int torev){
- int count, nPolys;
+ int count=0;
+ int nPolys=0;
PU_EMRPOLYPOLYLINE pEmr = (PU_EMRPOLYPOLYLINE) (record);
if(torev){
count = pEmr->cptl;
@@ -488,7 +492,7 @@ void core4_swap(char *record, int torev){
// Functions with the same form starting with U_EMRPOLYBEZIER16_swap
void core6_swap(char *record, int torev){
- int count;
+ int count=0;
PU_EMRPOLYBEZIER16 pEmr = (PU_EMRPOLYBEZIER16) (record);
if(torev){
count = pEmr->cpts;
@@ -530,7 +534,8 @@ void core9_swap(char *record, int torev){
// Functions with the same form starting with U_EMRPOLYPOLYLINE16_swap
void core10_swap(char *record, int torev){
- int count, nPolys;
+ int count=0;
+ int nPolys=0;
PU_EMRPOLYPOLYLINE16 pEmr = (PU_EMRPOLYPOLYLINE16) (record);
if(torev){
count = pEmr->cpts;
@@ -549,7 +554,9 @@ void core10_swap(char *record, int torev){
// Functions with the same form starting with U_EMRINVERTRGN_swap and U_EMRPAINTRGN_swap,
void core11_swap(char *record, int torev){
- int roff,nextroff, limit;
+ int roff=0;
+ int nextroff=0;
+ int limit=0;
PU_EMRINVERTRGN pEmr = (PU_EMRINVERTRGN) (record);
roff = 0;
if(torev){
@@ -718,7 +725,8 @@ void U_EMRSETBRUSHORGEX_swap(char *record, int torev){
// U_EMREOF 14
void U_EMREOF_swap(char *record, int torev){
- int off,cbPalEntries;
+ int off=0;
+ int cbPalEntries=0;
core5_swap(record, torev);
PU_EMREOF pEmr = (PU_EMREOF)(record);
if(torev){
@@ -989,7 +997,7 @@ void U_EMRARCTO_swap(char *record, int torev){
// U_EMRPOLYDRAW 56
void U_EMRPOLYDRAW_swap(char *record, int torev){
- int count;
+ int count=0;
core5_swap(record, torev);
PU_EMRPOLYDRAW pEmr = (PU_EMRPOLYDRAW)(record);
@@ -1079,7 +1087,9 @@ void U_EMRCOMMENT_swap(char *record, int torev){
// U_EMRFILLRGN 71
void U_EMRFILLRGN_swap(char *record, int torev){
- int roff, nextroff, limit;
+ int roff=0;
+ int nextroff=0;
+ int limit=0;
roff=0;
PU_EMRFILLRGN pEmr = (PU_EMRFILLRGN)(record);
if(torev){
@@ -1109,7 +1119,9 @@ void U_EMRFILLRGN_swap(char *record, int torev){
// U_EMRFRAMERGN 72
void U_EMRFRAMERGN_swap(char *record, int torev){
- int roff, nextroff, limit;
+ int roff=0;
+ int nextroff=0;
+ int limit=0;
PU_EMRFRAMERGN pEmr = (PU_EMRFRAMERGN)(record);
roff = 0;
if(torev){
@@ -1150,7 +1162,9 @@ void U_EMRPAINTRGN_swap(char *record, int torev){
// U_EMREXTSELECTCLIPRGN 75
void U_EMREXTSELECTCLIPRGN_swap(char *record, int torev){
- int roff, nextroff, limit;
+ int roff=0;
+ int nextroff=0;
+ int limit=0;
PU_EMREXTSELECTCLIPRGN pEmr = (PU_EMREXTSELECTCLIPRGN) (record);
roff = 0;
if(torev){
@@ -1383,7 +1397,7 @@ void U_EMRPOLYPOLYGON16_swap(char *record, int torev){
// U_EMRPOLYDRAW16 92
void U_EMRPOLYDRAW16_swap(char *record, int torev){
- int count;
+ int count=0;
core5_swap(record, torev);
PU_EMRPOLYDRAW16 pEmr = (PU_EMRPOLYDRAW16)(record);
if(torev){
@@ -1472,7 +1486,8 @@ void U_EMRPIXELFORMAT_swap(char *record, int torev){
// U_EMRSMALLTEXTOUT 108
void U_EMRSMALLTEXTOUT_swap(char *record, int torev){
- int roff,fuOptions;
+ int roff=0;
+ int fuOptions=0;
core5_swap(record, torev);
PU_EMRSMALLTEXTOUT pEmr = (PU_EMRSMALLTEXTOUT)(record);
if(torev){
@@ -1521,7 +1536,9 @@ void U_EMRTRANSPARENTBLT_swap(char *record, int torev){
#define U_EMRUNDEF117_swap U_EMRNOTIMPLEMENTED_swap
// U_EMRGRADIENTFILL 118
void U_EMRGRADIENTFILL_swap(char *record, int torev){
- int nTriVert,nGradObj,ulMode;
+ int nTriVert=0;
+ int nGradObj=0;
+ int ulMode=0;
core5_swap(record, torev);
PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL)(record);
if(torev){