diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-04-27 10:54:19 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-04-27 10:54:19 +0000 |
| commit | 77fd4884ad0ad8c374ba2450d5faa2c5c87e4bb3 (patch) | |
| tree | db1fd0a1f5c132553ba82d8341e94948576e8d08 /src | |
| parent | update to trunk (diff) | |
| parent | Replace 'memset' by constructors. Fixes segfault from turning SPStyle into a ... (diff) | |
| download | inkscape-77fd4884ad0ad8c374ba2450d5faa2c5c87e4bb3.tar.gz inkscape-77fd4884ad0ad8c374ba2450d5faa2c5c87e4bb3.zip | |
update to trunk
(bzr r11950.1.337)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/emf-inout.cpp | 343 | ||||
| -rw-r--r-- | src/extension/internal/emf-inout.h | 76 |
2 files changed, 217 insertions, 202 deletions
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index eae3bfb5a..711d7e3a4 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -273,54 +273,54 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } d->hatches.strings[d->hatches.count++]=strdup(hpathname); - *(d->defs) += "\n"; + d->defs += "\n"; switch(hatchType){ case U_HS_HORIZONTAL: - *(d->defs) += " <path id=\""; - *(d->defs) += hpathname; - *(d->defs) += "\" d=\"M 0 0 6 0\" style=\"fill:none;stroke:#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\" />\n"; + d->defs += " <path id=\""; + d->defs += hpathname; + d->defs += "\" d=\"M 0 0 6 0\" style=\"fill:none;stroke:#"; + d->defs += tmpcolor; + d->defs += "\" />\n"; break; case U_HS_VERTICAL: - *(d->defs) += " <path id=\""; - *(d->defs) += hpathname; - *(d->defs) += "\" d=\"M 0 0 0 6\" style=\"fill:none;stroke:#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\" />\n"; + d->defs += " <path id=\""; + d->defs += hpathname; + d->defs += "\" d=\"M 0 0 0 6\" style=\"fill:none;stroke:#"; + d->defs += tmpcolor; + d->defs += "\" />\n"; break; case U_HS_FDIAGONAL: - *(d->defs) += " <line id=\"sub"; - *(d->defs) += hpathname; - *(d->defs) += "\" x1=\"-1\" y1=\"-1\" x2=\"7\" y2=\"7\" stroke=\"#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\"/>\n"; + d->defs += " <line id=\"sub"; + d->defs += hpathname; + d->defs += "\" x1=\"-1\" y1=\"-1\" x2=\"7\" y2=\"7\" stroke=\"#"; + d->defs += tmpcolor; + d->defs += "\"/>\n"; break; case U_HS_BDIAGONAL: - *(d->defs) += " <line id=\"sub"; - *(d->defs) += hpathname; - *(d->defs) += "\" x1=\"-1\" y1=\"7\" x2=\"7\" y2=\"-1\" stroke=\"#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\"/>\n"; + d->defs += " <line id=\"sub"; + d->defs += hpathname; + d->defs += "\" x1=\"-1\" y1=\"7\" x2=\"7\" y2=\"-1\" stroke=\"#"; + d->defs += tmpcolor; + d->defs += "\"/>\n"; break; case U_HS_CROSS: - *(d->defs) += " <path id=\""; - *(d->defs) += hpathname; - *(d->defs) += "\" d=\"M 0 0 6 0 M 0 0 0 6\" style=\"fill:none;stroke:#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\" />\n"; + d->defs += " <path id=\""; + d->defs += hpathname; + d->defs += "\" d=\"M 0 0 6 0 M 0 0 0 6\" style=\"fill:none;stroke:#"; + d->defs += tmpcolor; + d->defs += "\" />\n"; break; case U_HS_DIAGCROSS: - *(d->defs) += " <line id=\"subfd"; - *(d->defs) += hpathname; - *(d->defs) += "\" x1=\"-1\" y1=\"-1\" x2=\"7\" y2=\"7\" stroke=\"#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\"/>\n"; - *(d->defs) += " <line id=\"subbd"; - *(d->defs) += hpathname; - *(d->defs) += "\" x1=\"-1\" y1=\"7\" x2=\"7\" y2=\"-1\" stroke=\"#"; - *(d->defs) += tmpcolor; - *(d->defs) += "\"/>\n"; + d->defs += " <line id=\"subfd"; + d->defs += hpathname; + d->defs += "\" x1=\"-1\" y1=\"-1\" x2=\"7\" y2=\"7\" stroke=\"#"; + d->defs += tmpcolor; + d->defs += "\"/>\n"; + d->defs += " <line id=\"subbd"; + d->defs += hpathname; + d->defs += "\" x1=\"-1\" y1=\"7\" x2=\"7\" y2=\"-1\" stroke=\"#"; + d->defs += tmpcolor; + d->defs += "\"/>\n"; break; case U_HS_SOLIDCLR: case U_HS_DITHEREDCLR: @@ -329,12 +329,12 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat case U_HS_SOLIDBKCLR: case U_HS_DITHEREDBKCLR: default: - *(d->defs) += " <path id=\""; - *(d->defs) += hpathname; - *(d->defs) += "\" d=\"M 0 0 6 0 6 6 0 6 z\" style=\"fill:#"; - *(d->defs) += tmpcolor; - *(d->defs) += ";stroke:none"; - *(d->defs) += "\" />\n"; + d->defs += " <path id=\""; + d->defs += hpathname; + d->defs += "\" d=\"M 0 0 6 0 6 6 0 6 z\" style=\"fill:#"; + d->defs += tmpcolor; + d->defs += ";stroke:none"; + d->defs += "\" />\n"; break; } } @@ -396,12 +396,12 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat if(!idx){ // add it if not already present if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } d->hatches.strings[d->hatches.count++]=strdup(hatchname); - *(d->defs) += "\n"; - *(d->defs) += " <pattern id=\""; - *(d->defs) += hatchname; - *(d->defs) += "\" xlink:href=\"#EMFhbasepattern\">\n"; - *(d->defs) += refpath; - *(d->defs) += " </pattern>\n"; + d->defs += "\n"; + d->defs += " <pattern id=\""; + d->defs += hatchname; + d->defs += "\" xlink:href=\"#EMFhbasepattern\">\n"; + d->defs += refpath; + d->defs += " </pattern>\n"; idx = d->hatches.count; } } @@ -414,12 +414,12 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } d->hatches.strings[d->hatches.count++]=strdup(hbkname); - *(d->defs) += "\n"; - *(d->defs) += " <rect id=\""; - *(d->defs) += hbkname; - *(d->defs) += "\" x=\"0\" y=\"0\" width=\"6\" height=\"6\" fill=\"#"; - *(d->defs) += bkcolor; - *(d->defs) += "\" />\n"; + d->defs += "\n"; + d->defs += " <rect id=\""; + d->defs += hbkname; + d->defs += "\" x=\"0\" y=\"0\" width=\"6\" height=\"6\" fill=\"#"; + d->defs += bkcolor; + d->defs += "\" />\n"; } // this is the pattern, its name will show up in Inkscape's pattern selector @@ -428,15 +428,15 @@ uint32_t Emf::add_hatch(PEMF_CALLBACK_DATA d, uint32_t hatchType, U_COLORREF hat if(!idx){ // add it if not already present if(d->hatches.count == d->hatches.size){ enlarge_hatches(d); } d->hatches.strings[d->hatches.count++]=strdup(hatchname); - *(d->defs) += "\n"; - *(d->defs) += " <pattern id=\""; - *(d->defs) += hatchname; - *(d->defs) += "\" xlink:href=\"#EMFhbasepattern\">\n"; - *(d->defs) += " <use xlink:href=\"#"; - *(d->defs) += hbkname; - *(d->defs) += "\" />\n"; - *(d->defs) += refpath; - *(d->defs) += " </pattern>\n"; + d->defs += "\n"; + d->defs += " <pattern id=\""; + d->defs += hatchname; + d->defs += "\" xlink:href=\"#EMFhbasepattern\">\n"; + d->defs += " <use xlink:href=\"#"; + d->defs += hbkname; + d->defs += "\" />\n"; + d->defs += refpath; + d->defs += " </pattern>\n"; idx = d->hatches.count; } } @@ -544,35 +544,35 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint sprintf(imagename,"EMFimage%d",idx++); sprintf(xywh," x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" ",width,height); // reuse this buffer - *(d->defs) += "\n"; - *(d->defs) += " <image id=\""; - *(d->defs) += imagename; - *(d->defs) += "\"\n "; - *(d->defs) += xywh; - *(d->defs) += "\n"; - if(dibparams == U_BI_JPEG){ *(d->defs) += " xlink:href=\"data:image/jpeg;base64,"; } - else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; } - *(d->defs) += base64String; - *(d->defs) += "\"\n"; - *(d->defs) += " preserveAspectRatio=\"none\"\n"; - *(d->defs) += " />\n"; - - - *(d->defs) += "\n"; - *(d->defs) += " <pattern id=\""; - *(d->defs) += imagename; - *(d->defs) += "_ref\"\n "; - *(d->defs) += xywh; - *(d->defs) += "\n patternUnits=\"userSpaceOnUse\""; - *(d->defs) += " >\n"; - *(d->defs) += " <use id=\""; - *(d->defs) += imagename; - *(d->defs) += "_ign\" "; - *(d->defs) += " xlink:href=\"#"; - *(d->defs) += imagename; - *(d->defs) += "\" />\n"; - *(d->defs) += " "; - *(d->defs) += " </pattern>\n"; + d->defs += "\n"; + d->defs += " <image id=\""; + d->defs += imagename; + d->defs += "\"\n "; + d->defs += xywh; + d->defs += "\n"; + if(dibparams == U_BI_JPEG){ d->defs += " xlink:href=\"data:image/jpeg;base64,"; } + else { d->defs += " xlink:href=\"data:image/png;base64,"; } + d->defs += base64String; + d->defs += "\"\n"; + d->defs += " preserveAspectRatio=\"none\"\n"; + d->defs += " />\n"; + + + d->defs += "\n"; + d->defs += " <pattern id=\""; + d->defs += imagename; + d->defs += "_ref\"\n "; + d->defs += xywh; + d->defs += "\n patternUnits=\"userSpaceOnUse\""; + d->defs += " >\n"; + d->defs += " <use id=\""; + d->defs += imagename; + d->defs += "_ign\" "; + d->defs += " xlink:href=\"#"; + d->defs += imagename; + d->defs += "\" />\n"; + d->defs += " "; + d->defs += " </pattern>\n"; } g_free(base64String);//wait until this point to free because it might be a duplicate image @@ -596,17 +596,17 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint d->images.strings[d->images.count++]=strdup(base64String); sprintf(imrotname,"EMFimage%d",idx++); - *(d->defs) += "\n"; - *(d->defs) += " <pattern\n"; - *(d->defs) += " id=\""; - *(d->defs) += imrotname; - *(d->defs) += "_ref\"\n"; - *(d->defs) += " xlink:href=\"#"; - *(d->defs) += imagename; - *(d->defs) += "_ref\"\n"; - *(d->defs) += " patternTransform="; - *(d->defs) += current_matrix(d, 0.0, 0.0, 0); //j use offset 0,0 - *(d->defs) += " />\n"; + d->defs += "\n"; + d->defs += " <pattern\n"; + d->defs += " id=\""; + d->defs += imrotname; + d->defs += "_ref\"\n"; + d->defs += " xlink:href=\"#"; + d->defs += imagename; + d->defs += "_ref\"\n"; + d->defs += " patternTransform="; + d->defs += current_matrix(d, 0.0, 0.0, 0); //j use offset 0,0 + d->defs += " />\n"; } g_free(base64String); } @@ -716,7 +716,7 @@ uint32_t Emf::add_gradient(PEMF_CALLBACK_DATA d, uint32_t gradientType, U_TRIVER stmp << tmpcolor2; stmp << ";stop-opacity:1\" />\n"; stmp << " </linearGradient>\n"; - *(d->defs) += stmp.str().c_str(); + d->defs += stmp.str().c_str(); } return(idx-1); @@ -811,8 +811,8 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) // tmp_id << "\n\tid=\"" << (d->id++) << "\""; -// *(d->outsvg) += tmp_id.str().c_str(); - *(d->outsvg) += "\n\tstyle=\""; +// d->outsvg += tmp_id.str().c_str(); + d->outsvg += "\n\tstyle=\""; if (iType == U_EMR_STROKEPATH || !d->dc[d->level].fill_set) { tmp_style << "fill:none;"; } else { @@ -936,7 +936,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) tmp_style << "\n\tclip-path=\"url(#clipEmfPath" << d->id << ")\" "; clipset = false; - *(d->outsvg) += tmp_style.str().c_str(); + d->outsvg += tmp_style.str().c_str(); } @@ -1525,8 +1525,8 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr, tmp_image << " preserveAspectRatio=\"none\"\n"; tmp_image << "/> \n"; - *(d->outsvg) += tmp_image.str().c_str(); - *(d->path) = ""; + d->outsvg += tmp_image.str().c_str(); + d->path = ""; } /** @@ -1595,7 +1595,7 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA TR_layout_2_svg(d->tri); SVGOStringStream ts; ts << d->tri->out; - *(d->outsvg) += ts.str().c_str(); + d->outsvg += ts.str().c_str(); d->tri = trinfo_clear(d->tri); } if(d->dc[d->level].dirty){ //Apply the delayed background changes, clear the flag @@ -1652,7 +1652,7 @@ std::cout << "BEFORE DRAW" ) ){ // std::cout << "PATH DRAW at TOP" << std::endl; - *(d->outsvg) += " <path "; // this is the ONLY place <path should be used!!! One exception, gradientfill. + d->outsvg += " <path "; // this is the ONLY place <path should be used!!! One exception, gradientfill. if(d->drawtype){ // explicit draw type EMR record output_style(d, d->drawtype); } @@ -1662,11 +1662,11 @@ std::cout << "BEFORE DRAW" else { output_style(d, U_EMR_STROKEPATH); } - *(d->outsvg) += "\n\t"; - *(d->outsvg) += "\n\td=\""; // this is the ONLY place d=" should be used!!!! One exception, gradientfill. - *(d->outsvg) += *(d->path); - *(d->outsvg) += " \" /> \n"; - *(d->path) = ""; + d->outsvg += "\n\t"; + d->outsvg += "\n\td=\""; // this is the ONLY place d=" should be used!!!! One exception, gradientfill. + d->outsvg += d->path; + d->outsvg += " \" /> \n"; + d->path = ""; // reset the flags d->mask = 0; d->drawtype = 0; @@ -1679,12 +1679,12 @@ std::cout << "BEFORE DRAW" { dbg_str << "<!-- U_EMR_HEADER -->\n"; - *(d->outdef) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; + d->outdef += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; if (d->pDesc) { - *(d->outdef) += "<!-- "; - *(d->outdef) += d->pDesc; - *(d->outdef) += " -->\n"; + d->outdef += "<!-- "; + d->outdef += d->pDesc; + d->outdef += " -->\n"; } PU_EMRHEADER pEmr = (PU_EMRHEADER) lpEMFR; @@ -1745,8 +1745,8 @@ std::cout << "BEFORE DRAW" tmp_outdef << " width=\"" << d->MMX << "mm\"\n" << " height=\"" << d->MMY << "mm\">\n"; - *(d->outdef) += tmp_outdef.str().c_str(); - *(d->outdef) += "<defs>"; // temporary end of header + d->outdef += tmp_outdef.str().c_str(); + d->outdef += "<defs>"; // temporary end of header // d->defs holds any defines which are read in. @@ -2015,7 +2015,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_EMR_EOF -->\n"; tmp_outsvg << "</svg>\n"; - *(d->outsvg) = *(d->outdef) + *(d->defs) + *(d->outsvg); + d->outsvg = d->outdef + d->defs + d->outsvg; OK=0; break; } @@ -2167,8 +2167,8 @@ std::cout << "BEFORE DRAW" tmp_rectangle << "\n transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset tmp_rectangle << "/>\n</clipPath>"; - *(d->outdef) += tmp_rectangle.str().c_str(); - *(d->path) = ""; + d->outdef += tmp_rectangle.str().c_str(); + d->path = ""; break; } case U_EMR_SCALEVIEWPORTEXTEX: dbg_str << "<!-- U_EMR_SCALEVIEWPORTEXTEX -->\n"; break; @@ -2453,12 +2453,12 @@ std::cout << "BEFORE DRAW" d->mask |= emr_mask; - *(d->outsvg) += " <ellipse "; + d->outsvg += " <ellipse "; output_style(d, lpEMFR->iType); // - *(d->outsvg) += "\n\t"; - *(d->outsvg) += tmp_ellipse.str().c_str(); - *(d->outsvg) += "/> \n"; - *(d->path) = ""; + d->outsvg += "\n\t"; + d->outsvg += tmp_ellipse.str().c_str(); + d->outsvg += "/> \n"; + d->path = ""; break; } case U_EMR_RECTANGLE: @@ -2679,7 +2679,7 @@ std::cout << "BEFORE DRAW" // The next line should never be needed, should have been handled before main switch // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto if(d->mask & U_DRAW_VISIBLE){ - *(d->path) = ""; + d->path = ""; } d->mask |= emr_mask; break; @@ -2739,7 +2739,7 @@ std::cout << "BEFORE DRAW" case U_EMR_ABORTPATH: { dbg_str << "<!-- U_EMR_ABORTPATH -->\n"; - *(d->path) = ""; + d->path = ""; d->drawtype = 0; break; } @@ -3048,7 +3048,7 @@ std::cout << "BEFORE DRAW" TR_layout_analyze(d->tri); TR_layout_2_svg(d->tri); ts << d->tri->out; - *(d->outsvg) += ts.str().c_str(); + d->outsvg += ts.str().c_str(); d->tri = trinfo_clear(d->tri); (void) trinfo_load_textrec(d->tri, &tsp, tsp.ori,TR_EMFBOT); // ignore return status, it must work } @@ -3292,7 +3292,7 @@ std::cout << "BEFORE DRAW" tmp_rectangle << d->gradients.strings[fill_idx]; tmp_rectangle << ");\"\n/>\n"; } - *(d->outsvg) += tmp_rectangle.str().c_str(); + d->outsvg += tmp_rectangle.str().c_str(); } else if(pEmr->ulMode == U_GRADIENT_FILL_TRIANGLE){ SVGOStringStream tmp_triangle; @@ -3310,9 +3310,9 @@ std::cout << "BEFORE DRAW" tmp_triangle << tmpcolor; tmp_triangle << ";\"\n/>\n"; } - *(d->outsvg) += tmp_triangle.str().c_str(); + d->outsvg += tmp_triangle.str().c_str(); } - *(d->path) = ""; + d->path = ""; // if it is anything else the record is bogus, so ignore it break; } @@ -3325,13 +3325,13 @@ std::cout << "BEFORE DRAW" break; } //end of switch // When testing, uncomment the following to place a comment for each processed EMR record in the SVG -// *(d->outsvg) += dbg_str.str().c_str(); - *(d->outsvg) += tmp_outsvg.str().c_str(); - *(d->path) += tmp_path.str().c_str(); +// d->outsvg += dbg_str.str().c_str(); + d->outsvg += tmp_outsvg.str().c_str(); + d->path += tmp_path.str().c_str(); } //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; (void) emr_properties(U_EMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant return 1; @@ -3349,61 +3349,20 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) { EMF_CALLBACK_DATA d; -// memset(&d, 0, sizeof(d)); - memset(&d, 0, sizeof(EMF_CALLBACK_DATA)); - - for(int i = 0; i < EMF_MAX_DC+1; i++){ // be sure all values and pointers are empty to start with - memset(&(d.dc[i]),0,sizeof(EMF_DEVICE_CONTEXT)); - } - - d.dc[0].worldTransform.eM11 = 1.0; - d.dc[0].worldTransform.eM12 = 0.0; - d.dc[0].worldTransform.eM21 = 0.0; - d.dc[0].worldTransform.eM22 = 1.0; - d.dc[0].worldTransform.eDx = 0.0; - d.dc[0].worldTransform.eDy = 0.0; - d.dc[0].font_name = strdup("Arial"); // Default font, EMF spec says device can pick whatever it wants - d.dc[0].textColor = U_RGB(0, 0, 0); // default foreground color (black) - d.dc[0].bkColor = U_RGB(255, 255, 255); // default background color (white) - d.dc[0].bkMode = U_TRANSPARENT; - d.dc[0].dirty = 0; - if (uri == NULL) { return NULL; } - d.outsvg = new Glib::ustring(""); - d.path = new Glib::ustring(""); - d.outdef = new Glib::ustring(""); - d.defs = new Glib::ustring(""); - d.mask = 0; - d.drawtype = 0; - d.arcdir = U_AD_COUNTERCLOCKWISE; - d.dwRop2 = U_R2_COPYPEN; - d.dwRop3 = 0; - d.E2IdirY = 1.0; - d.D2PscaleX = 1.0; - d.D2PscaleY = 1.0; - d.hatches.size = 0; - d.hatches.count = 0; - d.hatches.strings = NULL; - d.images.size = 0; - d.images.count = 0; - d.images.strings = NULL; - d.gradients.size = 0; - d.gradients.count = 0; - d.gradients.strings = NULL; - // set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing. - *(d.defs) += "\n"; - *(d.defs) += " <pattern id=\"EMFhbasepattern\" \n"; - *(d.defs) += " patternUnits=\"userSpaceOnUse\"\n"; - *(d.defs) += " width=\"6\" \n"; - *(d.defs) += " height=\"6\" \n"; - *(d.defs) += " x=\"0\" \n"; - *(d.defs) += " y=\"0\"> \n"; - *(d.defs) += " </pattern> \n"; + d.defs += "\n"; + d.defs += " <pattern id=\"EMFhbasepattern\" \n"; + d.defs += " patternUnits=\"userSpaceOnUse\"\n"; + d.defs += " width=\"6\" \n"; + d.defs += " height=\"6\" \n"; + d.defs += " x=\"0\" \n"; + d.defs += " y=\"0\"> \n"; + d.defs += " </pattern> \n"; size_t length; @@ -3425,12 +3384,8 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl; - SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg->c_str(), strlen(d.outsvg->c_str()), TRUE); + SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg.c_str(), strlen(d.outsvg.c_str()), TRUE); - delete d.outsvg; - delete d.path; - delete d.outdef; - delete d.defs; free_emf_strings(d.hatches); free_emf_strings(d.images); free_emf_strings(d.gradients); diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h index fc98958bb..280269d0d 100644 --- a/src/extension/internal/emf-inout.h +++ b/src/extension/internal/emf-inout.h @@ -27,20 +27,59 @@ namespace Internal { #define DIRTY_FILL 0x02 #define DIRTY_STROKE 0x04 -typedef struct { +typedef struct emf_object { + emf_object() : + type(0), + level(0), + lpEMFR(NULL) + {}; int type; int level; char *lpEMFR; } EMF_OBJECT, *PEMF_OBJECT; -typedef struct { +typedef struct emf_strings { + emf_strings() : + size(0), + count(0), + strings(NULL) + {}; int size; // number of slots allocated in strings int count; // number of slots used in strings char **strings; // place to store strings } EMF_STRINGS, *PEMF_STRINGS; typedef struct emf_device_context { - class SPStyle style; + emf_device_context() : + // SPStyle: class with constructor + font_name(NULL), + stroke_set(false), stroke_mode(0), stroke_idx(0), stroke_recidx(0), + fill_set(false), fill_mode(0), fill_idx(0), fill_recidx(0), + dirty(0), + // sizeWnd, sizeView, winorg, vieworg, + ScaleInX(0), ScaleInY(0), + ScaleOutX(0), ScaleOutY(0), + bkMode(U_TRANSPARENT), + // bkColor, textColor + textAlign(0) + // worldTransform, cur + { + font_name = strdup("Arial"); // Default font, EMF spec says device can pick whatever it wants + sizeWnd = sizel_set( 0.0, 0.0 ); + sizeView = sizel_set( 0.0, 0.0 ); + winorg = point32_set( 0.0, 0.0 ); + vieworg = point32_set( 0.0, 0.0 ); + bkColor = U_RGB(255, 255, 255); // default foreground color (white) + textColor = U_RGB(0, 0, 0); // default foreground color (black) + worldTransform.eM11 = 1.0; + worldTransform.eM12 = 0.0; + worldTransform.eM21 = 0.0; + worldTransform.eM22 = 1.0; + worldTransform.eDx = 0.0; + worldTransform.eDy = 0.0; + cur = point32_set( 0, 0 ); + }; + SPStyle style; char *font_name; bool stroke_set; int stroke_mode; // enumeration from drawmode, not used if fill_set is not True @@ -67,11 +106,32 @@ typedef struct emf_device_context { #define EMF_MAX_DC 128 -typedef struct { - Glib::ustring *outsvg; - Glib::ustring *path; - Glib::ustring *outdef; - Glib::ustring *defs; +typedef struct emf_callback_data { + + emf_callback_data() : + // dc: array, structure w/ constructor + level(0), + E2IdirY(1.0), + D2PscaleX(1.0), D2PscaleY(1.0), + MM100InX(0), MM100InY(0), + PixelsInX(0), PixelsInY(0), + PixelsOutX(0), PixelsOutY(0), + ulCornerInX(0), ulCornerInY(0), + ulCornerOutX(0), ulCornerOutY(0), + mask(0), + arcdir(U_AD_COUNTERCLOCKWISE), + dwRop2(U_R2_COPYPEN), dwRop3(0), + MMX(0),MMY(0), + id(0), drawtype(0), + pDesc(NULL), + // hatches, images, gradients, struct w/ constructor + tri(NULL) + {}; + + Glib::ustring outsvg; + Glib::ustring path; + Glib::ustring outdef; + Glib::ustring defs; EMF_DEVICE_CONTEXT dc[EMF_MAX_DC+1]; // FIXME: This should be dynamic.. int level; |
