summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam P. White <inkscapebronyat-signgmaildotcom>2014-03-20 21:12:35 +0000
committerLiam P. White <inkscapebronyat-signgmaildotcom>2014-03-20 21:12:35 +0000
commite28fc6a2c6c372f231f4cef15533082a83d6cbb2 (patch)
treef095ec8539529b2ec8fd008e9c4fc52e0cd9f866
parentFix a linker error ("static") (diff)
parentchange more warnings into errors. (diff)
downloadinkscape-e28fc6a2c6c372f231f4cef15533082a83d6cbb2.tar.gz
inkscape-e28fc6a2c6c372f231f4cef15533082a83d6cbb2.zip
Update to trunk
(bzr r13090.1.29)
-rw-r--r--build.xml2
-rw-r--r--configure.ac9
-rw-r--r--share/extensions/hpgl_encoder.py9
-rwxr-xr-xshare/extensions/hpgl_output.py7
-rw-r--r--share/extensions/plotter.py27
-rw-r--r--src/extension/internal/emf-inout.cpp4
-rw-r--r--src/extension/internal/wmf-inout.cpp113
7 files changed, 87 insertions, 84 deletions
diff --git a/build.xml b/build.xml
index 1e8341777..11c03b17f 100644
--- a/build.xml
+++ b/build.xml
@@ -351,7 +351,7 @@
</excludeinc>
<flags>
<!-- -std=gnu++0x -DCPP11 -->
- -Wall -Wformat -Werror=format-security -W -Wpointer-arith -Wcast-align -Wsign-compare -Woverloaded-virtual -Wswitch
+ -Wall -Wformat -Werror=format-security -W -Wpointer-arith -Wcast-align -Wsign-compare -Woverloaded-virtual -Werror=switch
-Werror=return-type
-O2
-mms-bitfields
diff --git a/configure.ac b/configure.ac
index 56bd68e15..d2454da06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,11 +89,14 @@ if test "$GCC" = "yes"; then
# enforced in Gtk+ 3, so it is important to check this in Gtk+ 2 builds
CPPFLAGS="-DGSEAL_ENABLE $CPPFLAGS"
+ # Unfortunately, we cannot (yet) build with -Werror, so we have to manually
+ # change a ton of warnings into errors.
+ # After some more work on fixing warning-inducing code, we can change this set into
+ # it's complement and use -Wno-error=...
# Test for -Werror=... (introduced some time post-4.0)
- # If we hit a format error -- it should be fatal.
- AC_MSG_CHECKING([compiler support for -Werror=format-security])
+ AC_MSG_CHECKING([compiler support for -Werror=...])
ink_svd_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="-Werror=format-security $CPPFLAGS"
+ CPPFLAGS="-Werror=format-security -Werror=switch -Werror=return-type $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [ink_opt_ok=yes], [ink_opt_ok=no])
AC_MSG_RESULT([$ink_opt_ok])
if test "x$ink_opt_ok" != "xyes"; then
diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py
index c7f0cd282..a16561e97 100644
--- a/share/extensions/hpgl_encoder.py
+++ b/share/extensions/hpgl_encoder.py
@@ -59,6 +59,7 @@ class hpglEncoder:
self.doc = effect.document.getroot()
self.docWidth = effect.unittouu(self.doc.get('width'))
self.docHeight = effect.unittouu(self.doc.get('height'))
+ self.hpgl = ''
self.divergenceX = 'False'
self.divergenceY = 'False'
self.sizeX = 'False'
@@ -156,12 +157,6 @@ class hpglEncoder:
[0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, -self.divergenceY + self.offsetY]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
- # store initial hpgl commands
- self.hpgl = 'IN;SP%d' % self.options.pen
- if self.options.force > 0:
- self.hpgl += ';FS%d' % self.options.force
- if self.options.speed > 0:
- self.hpgl += ';VS%d' % self.options.speed
# add move to zero point and precut
if self.toolOffset > 0.0 and self.options.precut:
if self.options.center:
@@ -185,8 +180,6 @@ class hpglEncoder:
self.processGroups(self.doc, groupmat)
# shift an empty node in in order to process last node in cache
self.processOffset('PU', 0, 0)
- # add return to zero point
- self.hpgl += ';PU0,0;'
if self.options.debug:
return self.hpgl, self
else:
diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py
index 5b5521926..c6713cb65 100755
--- a/share/extensions/hpgl_output.py
+++ b/share/extensions/hpgl_output.py
@@ -61,6 +61,13 @@ class HpglOutput(inkex.Effect):
else:
type, value, traceback = sys.exc_info()
raise ValueError, ("", type, value), traceback
+ # convert raw HPGL to HPGL
+ hpglInit = 'IN;SP%d' % self.options.pen
+ if self.options.force > 0:
+ hpglInit += ';FS%d' % self.options.force
+ if self.options.speed > 0:
+ hpglInit += ';VS%d' % self.options.speed
+ self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN;'
def output(self):
# print to file
diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py
index be59f604b..398ab683e 100644
--- a/share/extensions/plotter.py
+++ b/share/extensions/plotter.py
@@ -83,6 +83,8 @@ class Plot(inkex.Effect):
else:
'''
# convert to other formats
+ if self.options.commandLanguage == 'HPGL':
+ self.convertToHpgl()
if self.options.commandLanguage == 'DMPL':
self.convertToDmpl()
if self.options.commandLanguage == 'ZING':
@@ -93,6 +95,15 @@ class Plot(inkex.Effect):
else:
self.sendHpglToSerial()
+ def convertToHpgl(self):
+ # convert raw HPGL to HPGL
+ hpglInit = 'IN;SP%d' % self.options.pen
+ if self.options.force > 0:
+ hpglInit += ';FS%d' % self.options.force
+ if self.options.speed > 0:
+ hpglInit += ';VS%d' % self.options.speed
+ self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN;'
+
def convertToDmpl(self):
# convert HPGL to DMPL
# ;: = Initialise plotter
@@ -109,16 +120,20 @@ class Plot(inkex.Effect):
self.hpgl = self.hpgl.replace(';', ',')
self.hpgl = self.hpgl.replace('PU', 'U')
self.hpgl = self.hpgl.replace('PD', 'D')
- velocity = ''
+ dmplInit = ';:HAL0P%d' % self.options.pen
if self.options.speed > 0:
- velocity = 'V' + str(self.options.speed)
- self.hpgl = re.sub(r'IN,SP[0-9]+(,FS[0-9]+)?(,VS[0-9]+)?,', r';:HAL0P' + str(self.options.pen) + velocity + 'EC1', self.hpgl)
- self.hpgl += 'Z'
+ dmplInit += 'V%d' % self.options.speed
+ dmplInit += 'EC1'
+ self.hpgl = dmplInit + self.hpgl[1:] + ',U0,0,P0Z'
def convertToZing(self):
# convert HPGL to Zing
- self.hpgl = self.hpgl.replace('IN;', 'ZG;')
- self.hpgl += '@'
+ hpglInit = 'ZG;SP%d' % self.options.pen
+ if self.options.force > 0:
+ hpglInit += ';FS%d' % self.options.force
+ if self.options.speed > 0:
+ hpglInit += ';VS%d' % self.options.speed
+ self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;@'
def sendHpglToSerial(self):
# gracefully exit script when pySerial is missing
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index bbbce46e7..a4d204472 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -2163,9 +2163,9 @@ std::cout << "BEFORE DRAW"
tmp_rectangle << "\n x=\"" << dx << "\" ";
tmp_rectangle << "\n y=\"" << dy << "\" ";
tmp_rectangle << "\n width=\"" << dw << "\" ";
- tmp_rectangle << "\n height=\"" << dh << "\" />";
+ tmp_rectangle << "\n height=\"" << dh << "\" ";
tmp_rectangle << "\n transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset
- tmp_rectangle << "\n</clipPath>";
+ tmp_rectangle << "/>\n</clipPath>";
*(d->outdef) += tmp_rectangle.str().c_str();
*(d->path) = "";
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index 906c40301..9980d9d6d 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -445,9 +445,9 @@ int Wmf::in_images(PWMF_CALLBACK_DATA d, char *test){
uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsage){
uint32_t idx;
- char imagename[64]; // big enough
- char xywh[64]; // big enough
- int dibparams;
+ char imagename[64]; // big enough
+ char xywh[64]; // big enough
+ int dibparams = U_BI_UNKNOWN; // type of image not yet determined
MEMPNG mempng; // PNG in memory comes back in this
mempng.buffer = NULL;
@@ -480,6 +480,7 @@ uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsa
}
}
}
+
gchar *base64String=NULL;
if(dibparams == U_BI_JPEG || dibparams==U_BI_PNG){ // image was binary png or jpg in source file
base64String = g_base64_encode((guchar*) px, numCt );
@@ -1248,13 +1249,11 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
double dx, double dy, double dw, double dh, int sx, int sy, int sw, int sh, uint32_t iUsage){
SVGOStringStream tmp_image;
- int dibparams;
+ int dibparams = U_BI_UNKNOWN; // type of image not yet determined
tmp_image << "\n\t <image\n";
tmp_image << " y=\"" << dy << "\"\n x=\"" << dx <<"\"\n ";
- // The image ID is filled in much later when tmp_image is converted
-
MEMPNG mempng; // PNG in memory comes back in this
mempng.buffer = NULL;
@@ -1262,79 +1261,65 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
char *sub_px = NULL; // RGBA pixels, subarray
const char *px = NULL; // DIB pixels
const U_RGBQUAD *ct = NULL; // color table
- int32_t width, height, colortype, numCt, invert;
- if( (iUsage != U_DIB_RGB_COLORS) ||
- !(dibparams = wget_DIB_params( // this returns pointers and values, but allocates no memory
- dib,
- &px,
- &ct,
- &numCt,
- &width,
- &height,
- &colortype,
- &invert
- ))
- ){
- if(sw == 0 || sh == 0){
- sw = width;
- sh = height;
- }
-
- if(!DIB_to_RGBA(
- px, // DIB pixel array
- ct, // DIB color table
- numCt, // DIB color table number of entries
- &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free.
- width, // Width of pixel array
- height, // Height of pixel array
- colortype, // DIB BitCount Enumeration
- numCt, // Color table used if not 0
- invert // If DIB rows are in opposite order from RGBA rows
- ) &&
- rgba_px
- ){
- sub_px = RGBA_to_RGBA(
- rgba_px, // full pixel array from DIB
+ int32_t width, height, colortype, numCt, invert; // if needed these values will be set in wget_DIB_params
+ if(iUsage == U_DIB_RGB_COLORS){
+ // next call returns pointers and values, but allocates no memory
+ dibparams = wget_DIB_params(dib, &px, &ct, &numCt, &width, &height, &colortype, &invert);
+ if(dibparams == U_BI_RGB){
+ if(sw == 0 || sh == 0){
+ sw = width;
+ sh = height;
+ }
+ if(!DIB_to_RGBA(
+ px, // DIB pixel array
+ ct, // DIB color table
+ numCt, // DIB color table number of entries
+ &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free.
width, // Width of pixel array
height, // Height of pixel array
- sx,sy, // starting point in pixel array
- &sw,&sh // columns/rows to extract from the pixel array (output array size)
- );
-
- if(!sub_px)sub_px=rgba_px;
- toPNG( // Get the image from the RGBA px into mempng
- &mempng,
- sw, sh, // size of the extracted pixel array
- sub_px
- );
- free(sub_px);
+ colortype, // DIB BitCount Enumeration
+ numCt, // Color table used if not 0
+ invert // If DIB rows are in opposite order from RGBA rows
+ )){
+ sub_px = RGBA_to_RGBA( // returns either a subset (side effect: frees rgba_px) or NULL (for subset == entire image)
+ rgba_px, // full pixel array from DIB
+ width, // Width of pixel array
+ height, // Height of pixel array
+ sx,sy, // starting point in pixel array
+ &sw,&sh // columns/rows to extract from the pixel array (output array size)
+ );
+
+ if(!sub_px)sub_px=rgba_px;
+ toPNG( // Get the image from the RGBA px into mempng
+ &mempng,
+ sw, sh, // size of the extracted pixel array
+ sub_px
+ );
+ free(sub_px);
+ }
}
}
- gchar *base64String;
- if(dibparams == U_BI_JPEG){
+
+ gchar *base64String=NULL;
+ if(dibparams == U_BI_JPEG){ // image was binary jpg in source file
tmp_image << " xlink:href=\"data:image/jpeg;base64,";
base64String = g_base64_encode((guchar*) px, numCt );
- tmp_image << base64String ;
- g_free(base64String);
}
- else if(dibparams==U_BI_PNG){
+ else if(dibparams==U_BI_PNG){ // image was binary png in source file
tmp_image << " xlink:href=\"data:image/png;base64,";
base64String = g_base64_encode((guchar*) px, numCt );
- tmp_image << base64String ;
- g_free(base64String);
}
- else if(mempng.buffer){
+ else if(mempng.buffer){ // image was DIB in source file, converted to png in this routine
tmp_image << " xlink:href=\"data:image/png;base64,";
- gchar *base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size );
+ base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size );
free(mempng.buffer);
- tmp_image << base64String ;
- g_free(base64String);
}
- else {
+ else { // unknown or unsupported image type or failed conversion, insert the common bad image picture
tmp_image << " xlink:href=\"data:image/png;base64,";
- // insert a random 3x4 blotch otherwise
- tmp_image << "iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII=";
+ base64String = bad_image_png();
}
+ tmp_image << base64String;
+ g_free(base64String);
tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n";
tmp_image << " transform=" << current_matrix(d, 0.0, 0.0, 0); // returns an identity matrix, no offsets.