emf-win32-inout.cpp revision fac8f5940dd8826336d4a34dba6616c8e9688948
/** @file
* @brief Windows-only Enhanced Metafile input and output.
*/
/* Authors:
* Ulf Erikson <ulferikson@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2006-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
* References:
* - How to Create & Play Enhanced Metafiles in Win32
* - INFO: Windows Metafile Functions & Aldus Placeable Metafiles
* - Metafile Functions
* - Metafile Structures
*/
#ifdef WIN32
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
//#include "inkscape.h"
#include "sp-root.h"
#include "sp-path.h"
#include "style.h"
//#include "color.h"
//#include "libnr/nr-point-matrix-ops.h"
#include "print.h"
//#include "extension/extension.h"
//#include "document.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
//#include "libnr/nr-matrix.h"
//#include "libnr/nr-pixblock.h"
//#include <stdio.h>
//#include <string.h>
//#include <vector>
//#include <string>
#include "unit-constants.h"
#include "clear-n_.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "win32.h"
#include "emf-win32-print.h"
#include "emf-win32-inout.h"
#define PRINT_EMF_WIN32 "org.inkscape.print.emf.win32"
#ifndef PS_JOIN_MASK
#endif
namespace Inkscape {
namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
static bool clipset = false;
{
return;
}
{
return;
}
bool
{
return FALSE;
return TRUE;
}
static void
{
unsigned int ret;
doc->ensureUpToDate();
/* Start */
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
/* Print document */
if (ret) {
}
/* Release arena */
/* end */
return;
}
void
{
return;
return;
}
typedef struct {
int type;
int level;
} EMF_OBJECT, *PEMF_OBJECT;
typedef struct emf_device_context {
class SPTextStyle tstyle;
bool stroke_set;
bool fill_set;
float PixelsOutX, PixelsOutY;
bool textColorSet;
#define EMF_MAX_DC 128
typedef struct emf_callback_data {
int level;
bool pathless_stroke;
bool inpath;
float MMX;
float MMY;
float dwInchesX;
float dwInchesY;
unsigned int id;
int n_obj;
static void
{
// SVGOStringStream tmp_id;
char tmp[1024] = {0};
float fill_rgb[3];
float stroke_rgb[3];
// tmp_id << "\n\tid=\"" << (d->id++) << "\"";
// *(d->outsvg) += tmp_id.str().c_str();
*(d->outsvg) += "\n\tstyle=\"";
tmp_style << "fill:none;";
} else {
"fill:#%02x%02x%02x;",
SP_COLOR_F_TO_U(fill_rgb[0]),
"fill-rule:%s;",
tmp_style << "fill-opacity:1;";
if (d->dc[d->level].fill_set && d->dc[d->level].stroke_set && d->dc[d->level].style.stroke_width.value == 1 &&
{
}
}
tmp_style << "stroke:none;";
} else {
"stroke:#%02x%02x%02x;",
tmp_style << "stroke-width:" <<
tmp_style << "stroke-linecap:" <<
"unknown") << ";";
tmp_style << "stroke-linejoin:" <<
"unknown") << ";";
tmp_style << "stroke-miterlimit:" <<
}
{
tmp_style << "stroke-dasharray:";
if (i)
tmp_style << ",";
}
tmp_style << ";";
tmp_style << "stroke-dashoffset:0;";
} else {
tmp_style << "stroke-dasharray:none;";
}
tmp_style << "stroke-opacity:1;";
}
tmp_style << "\" ";
if (clipset)
clipset = false;
}
static double
{
return tmp;
}
static double
{
return tmp;
}
static double
{
double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
return x;
}
static double
{
double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
return y;
}
static double
{
double ppy = 0;
return tmp;
}
static void
{
if (!pEmr)
return;
case PS_DASH:
case PS_DOT:
case PS_DASHDOT:
case PS_DASHDOTDOT:
{
int i = 0;
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
}
}
if (penstyle==PS_DASHDOTDOT) {
}
break;
}
case PS_SOLID:
default:
{
break;
}
}
case PS_ENDCAP_ROUND:
{
break;
}
case PS_ENDCAP_SQUARE:
{
break;
}
case PS_ENDCAP_FLAT:
default:
{
break;
}
}
case PS_JOIN_BEVEL:
{
break;
}
case PS_JOIN_MITER:
{
break;
}
case PS_JOIN_ROUND:
default:
{
break;
}
}
} else { // this stroke should always be rendered as 1 pixel wide, independent of zoom level (can that be done in SVG?)
//d->dc[d->level].style.stroke_width.value = 1.0;
}
double r, g, b;
}
static void
{
if (!pEmr)
return;
case PS_USERSTYLE:
{
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
}
} else {
}
break;
}
case PS_DASH:
case PS_DOT:
case PS_DASHDOT:
case PS_DASHDOTDOT:
{
int i = 0;
if (d->dc[d->level].style.stroke_dash.dash && (d->level==0 || (d->level>0 && d->dc[d->level].style.stroke_dash.dash!=d->dc[d->level-1].style.stroke_dash.dash)))
}
}
if (penstyle==PS_DASHDOTDOT) {
}
break;
}
case PS_SOLID:
default:
{
break;
}
}
case PS_ENDCAP_ROUND:
{
break;
}
case PS_ENDCAP_SQUARE:
{
break;
}
case PS_ENDCAP_FLAT:
default:
{
break;
}
}
case PS_JOIN_BEVEL:
{
break;
}
case PS_JOIN_MITER:
{
break;
}
case PS_JOIN_ROUND:
default:
{
break;
}
}
} else { // this stroke should always be rendered as 1 pixel wide, independent of zoom level (can that be done in SVG?)
//d->dc[d->level].style.stroke_width.value = 1.0;
}
double r, g, b;
}
static void
{
if (!pEmr)
return;
double r, g, b;
}
}
static void
{
if (!pEmr)
return;
d->dc[d->level].style.font_style.value = (pEmr->elfw.elfLogFont.lfItalic ? SP_CSS_FONT_STYLE_ITALIC : SP_CSS_FONT_STYLE_NORMAL);
d->dc[d->level].style.baseline_shift.value = ((pEmr->elfw.elfLogFont.lfEscapement + 3600) % 3600) / 10; // use baseline_shift instead of text_transform to avoid overflow
}
static void
{
}
}
static void
{
delete_object(d, index);
}
}
static void
{
// g_debug("emf-win32-inout: assert_empty_path failed for %s\n", fun);
*(d->outsvg) += "<!--\n";
*(d->outsvg) += " <path \t";
*(d->outsvg) += "d=\"";
*(d->outsvg) += "\n\t";
}
*(d->outsvg) += " \" /> \n";
*(d->outsvg) += "-->\n";
*(d->path) = "";
}
}
static int CALLBACK
myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *lpEMFR, int /*nObj*/, LPARAM lpData)
{
d = (PEMF_CALLBACK_DATA) lpData;
if (d->pathless_stroke) {
{
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
d->pathless_stroke = false;
}
}
{
case EMR_HEADER:
{
dbg_str << "<!-- EMR_HEADER -->\n";
*(d->outdef) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
if (d->pDesc) {
*(d->outdef) += "<!-- ";
*(d->outdef) += " -->\n";
}
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 << " version=\"1.0\"\n";
d->xDPI = 2540;
d->yDPI = 2540;
tmp_outdef <<
// Init the new emf_obj list elements to null, provided the
// dynamic allocation succeeded.
{
for( int i=0; i < d->n_obj; ++i )
} //if
} else {
}
break;
}
case EMR_POLYBEZIER:
{
dbg_str << "<!-- EMR_POLYBEZIER -->\n";
DWORD i,j;
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYBEZIER");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
tmp_str << "\n\tC ";
tmp_str <<
}
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYGON:
{
dbg_str << "<!-- EMR_POLYGON -->\n";
DWORD i;
break;
assert_empty_path(d, "EMR_POLYGON");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
tmp_str <<
"\n\tM " <<
tmp_str <<
"\n\tL " <<
}
*(d->outsvg) += " z \" /> \n";
break;
}
case EMR_POLYLINE:
{
dbg_str << "<!-- EMR_POLYLINE -->\n";
DWORD i;
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYLINE");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
tmp_str <<
"\n\tL " <<
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYBEZIERTO:
{
dbg_str << "<!-- EMR_POLYBEZIERTO -->\n";
DWORD i,j;
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path << "\n\tC ";
tmp_path <<
}
}
break;
}
case EMR_POLYLINETO:
{
dbg_str << "<!-- EMR_POLYLINETO -->\n";
DWORD i;
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path <<
"\n\tL " <<
}
break;
}
case EMR_POLYPOLYLINE:
case EMR_POLYPOLYGON:
{
dbg_str << "<!-- EMR_POLYPOLYLINE -->\n";
dbg_str << "<!-- EMR_POLYPOLYGON -->\n";
unsigned int n, i, j;
if (!d->inpath) {
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
i = 0;
poly_path << "\n\tM " <<
i++;
poly_path << "\n\tL " <<
i++;
}
tmp_str << " z";
tmp_str << " \n";
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_SETWINDOWEXTEX:
{
dbg_str << "<!-- EMR_SETWINDOWEXTEX -->\n";
}
}
}
d->dc[d->level].ScaleInX = (double) d->dc[d->level].sizeView.cx / (double) d->dc[d->level].PixelsInX;
d->dc[d->level].ScaleInY = (double) d->dc[d->level].sizeView.cy / (double) d->dc[d->level].PixelsInY;
}
else {
}
d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx;
d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy;
}
else {
}
break;
}
case EMR_SETWINDOWORGEX:
{
dbg_str << "<!-- EMR_SETWINDOWORGEX -->\n";
break;
}
case EMR_SETVIEWPORTEXTEX:
{
dbg_str << "<!-- EMR_SETVIEWPORTEXTEX -->\n";
}
}
}
d->dc[d->level].ScaleInX = (double) d->dc[d->level].sizeView.cx / (double) d->dc[d->level].PixelsInX;
d->dc[d->level].ScaleInY = (double) d->dc[d->level].sizeView.cy / (double) d->dc[d->level].PixelsInY;
}
else {
}
d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx;
d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy;
}
else {
}
break;
}
case EMR_SETVIEWPORTORGEX:
{
dbg_str << "<!-- EMR_SETVIEWPORTORGEX -->\n";
break;
}
case EMR_SETBRUSHORGEX:
dbg_str << "<!-- EMR_SETBRUSHORGEX -->\n";
break;
case EMR_EOF:
{
dbg_str << "<!-- EMR_EOF -->\n";
assert_empty_path(d, "EMR_EOF");
tmp_outsvg << "</g>\n";
tmp_outsvg << "</svg>\n";
break;
}
case EMR_SETPIXELV:
dbg_str << "<!-- EMR_SETPIXELV -->\n";
break;
case EMR_SETMAPPERFLAGS:
dbg_str << "<!-- EMR_SETMAPPERFLAGS -->\n";
break;
case EMR_SETMAPMODE:
dbg_str << "<!-- EMR_SETMAPMODE -->\n";
break;
case EMR_SETBKMODE:
dbg_str << "<!-- EMR_SETBKMODE -->\n";
break;
case EMR_SETPOLYFILLMODE:
{
dbg_str << "<!-- EMR_SETPOLYFILLMODE -->\n";
break;
}
case EMR_SETROP2:
dbg_str << "<!-- EMR_SETROP2 -->\n";
break;
case EMR_SETSTRETCHBLTMODE:
dbg_str << "<!-- EMR_SETSTRETCHBLTMODE -->\n";
break;
case EMR_SETTEXTALIGN:
{
dbg_str << "<!-- EMR_SETTEXTALIGN -->\n";
break;
}
case EMR_SETCOLORADJUSTMENT:
dbg_str << "<!-- EMR_SETCOLORADJUSTMENT -->\n";
break;
case EMR_SETTEXTCOLOR:
{
dbg_str << "<!-- EMR_SETTEXTCOLOR -->\n";
break;
}
case EMR_SETBKCOLOR:
dbg_str << "<!-- EMR_SETBKCOLOR -->\n";
break;
case EMR_OFFSETCLIPRGN:
dbg_str << "<!-- EMR_OFFSETCLIPRGN -->\n";
break;
case EMR_MOVETOEX:
{
dbg_str << "<!-- EMR_MOVETOEX -->\n";
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path <<
"\n\tM " <<
break;
}
case EMR_SETMETARGN:
dbg_str << "<!-- EMR_SETMETARGN -->\n";
break;
case EMR_EXCLUDECLIPRECT:
dbg_str << "<!-- EMR_EXCLUDECLIPRECT -->\n";
break;
case EMR_INTERSECTCLIPRECT:
{
dbg_str << "<!-- EMR_INTERSECTCLIPRECT -->\n";
clipset = true;
if ((rc.left == rc_old.left) && (rc.top == rc_old.top) && (rc.right == rc_old.right) && (rc.bottom == rc_old.bottom))
break;
tmp_rectangle << "\n<clipPath\n\tclipPathUnits=\"userSpaceOnUse\" ";
tmp_rectangle << "\n<rect ";
tmp_rectangle << "\n</clipPath>";
assert_empty_path(d, "EMR_RECTANGLE");
*(d->path) = "";
break;
}
case EMR_SCALEVIEWPORTEXTEX:
dbg_str << "<!-- EMR_SCALEVIEWPORTEXTEX -->\n";
break;
case EMR_SCALEWINDOWEXTEX:
dbg_str << "<!-- EMR_SCALEWINDOWEXTEX -->\n";
break;
case EMR_SAVEDC:
dbg_str << "<!-- EMR_SAVEDC -->\n";
if (d->level < EMF_MAX_DC) {
}
break;
case EMR_RESTOREDC:
{
dbg_str << "<!-- EMR_RESTOREDC -->\n";
}
else {
}
if (d->dc[old_level].style.stroke_dash.dash && (old_level==0 || (old_level>0 && d->dc[old_level].style.stroke_dash.dash!=d->dc[old_level-1].style.stroke_dash.dash)))
old_level--;
}
break;
}
case EMR_SETWORLDTRANSFORM:
{
dbg_str << "<!-- EMR_SETWORLDTRANSFORM -->\n";
break;
}
case EMR_MODIFYWORLDTRANSFORM:
{
dbg_str << "<!-- EMR_MODIFYWORLDTRANSFORM -->\n";
{
case MWT_IDENTITY:
break;
case MWT_LEFTMULTIPLY:
{
// d->dc[d->level].worldTransform = pEmr->xform * worldTransform;
float a13 = 0.0;
float a23 = 0.0;
float a33 = 1.0;
//float b13 = 0.0;
//float b23 = 0.0;
//float b33 = 1.0;
//float c13 = a11*b13 + a12*b23 + a13*b33;;
//float c23 = a21*b13 + a22*b23 + a23*b33;;
//float c33 = a31*b13 + a32*b23 + a33*b33;;
break;
}
case MWT_RIGHTMULTIPLY:
{
// d->dc[d->level].worldTransform = worldTransform * pEmr->xform;
float a13 = 0.0;
float a23 = 0.0;
float a33 = 1.0;
//float b13 = 0.0;
//float b23 = 0.0;
//float b33 = 1.0;
//float c13 = a11*b13 + a12*b23 + a13*b33;;
//float c23 = a21*b13 + a22*b23 + a23*b33;;
//float c33 = a31*b13 + a32*b23 + a33*b33;;
break;
}
// case MWT_SET:
default:
break;
}
break;
}
case EMR_SELECTOBJECT:
{
dbg_str << "<!-- EMR_SELECTOBJECT -->\n";
if (index >= ENHMETA_STOCK_OBJECT) {
switch (index) {
case NULL_BRUSH:
break;
case BLACK_BRUSH:
case DKGRAY_BRUSH:
case GRAY_BRUSH:
case LTGRAY_BRUSH:
case WHITE_BRUSH:
{
float val = 0;
switch (index) {
case BLACK_BRUSH:
break;
case DKGRAY_BRUSH:
break;
case GRAY_BRUSH:
break;
case LTGRAY_BRUSH:
break;
case WHITE_BRUSH:
break;
}
break;
}
case NULL_PEN:
break;
case BLACK_PEN:
case WHITE_PEN:
{
break;
}
}
} else {
{
case EMR_CREATEPEN:
select_pen(d, index);
break;
case EMR_CREATEBRUSHINDIRECT:
select_brush(d, index);
break;
case EMR_EXTCREATEPEN:
select_extpen(d, index);
break;
select_font(d, index);
break;
}
}
}
break;
}
case EMR_CREATEPEN:
{
dbg_str << "<!-- EMR_CREATEPEN -->\n";
EMRCREATEPEN *pPen =
break;
}
case EMR_CREATEBRUSHINDIRECT:
{
dbg_str << "<!-- EMR_CREATEBRUSHINDIRECT -->\n";
break;
}
case EMR_DELETEOBJECT:
dbg_str << "<!-- EMR_DELETEOBJECT -->\n";
break;
case EMR_ANGLEARC:
dbg_str << "<!-- EMR_ANGLEARC -->\n";
break;
case EMR_ELLIPSE:
{
dbg_str << "<!-- EMR_ELLIPSE -->\n";
double cx = (l + r) / 2.0;
double cy = (t + b) / 2.0;
assert_empty_path(d, "EMR_ELLIPSE");
*(d->outsvg) += " <ellipse ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += "/> \n";
*(d->path) = "";
break;
}
case EMR_RECTANGLE:
{
dbg_str << "<!-- EMR_RECTANGLE -->\n";
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_RECTANGLE");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
break;
}
case EMR_ROUNDRECT:
{
dbg_str << "<!-- EMR_ROUNDRECT -->\n";
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tC " << l << ", " << t + (1-f)*cny << " " << l + (1-f)*cnx << ", " << t << " " << l + cnx << ", " << t << " ";
tmp_rectangle << "\n\tC " << r - (1-f)*cnx << ", " << t << " " << r << ", " << t + (1-f)*cny << " " << r << ", " << t + cny << " ";
tmp_rectangle << "\n\tC " << r << ", " << b - (1-f)*cny << " " << r - (1-f)*cnx << ", " << b << " " << r - cnx << ", " << b << " ";
tmp_rectangle << "\n\tC " << l + (1-f)*cnx << ", " << b << " " << l << ", " << b - (1-f)*cny << " " << l << ", " << b - cny << " ";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_ROUNDRECT");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
break;
}
case EMR_ARC:
dbg_str << "<!-- EMR_ARC -->\n";
break;
case EMR_CHORD:
dbg_str << "<!-- EMR_CHORD -->\n";
break;
case EMR_PIE:
dbg_str << "<!-- EMR_PIE -->\n";
break;
case EMR_SELECTPALETTE:
dbg_str << "<!-- EMR_SELECTPALETTE -->\n";
break;
case EMR_CREATEPALETTE:
dbg_str << "<!-- EMR_CREATEPALETTE -->\n";
break;
case EMR_SETPALETTEENTRIES:
dbg_str << "<!-- EMR_SETPALETTEENTRIES -->\n";
break;
case EMR_RESIZEPALETTE:
dbg_str << "<!-- EMR_RESIZEPALETTE -->\n";
break;
case EMR_REALIZEPALETTE:
dbg_str << "<!-- EMR_REALIZEPALETTE -->\n";
break;
case EMR_EXTFLOODFILL:
dbg_str << "<!-- EMR_EXTFLOODFILL -->\n";
break;
case EMR_LINETO:
{
dbg_str << "<!-- EMR_LINETO -->\n";
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path <<
"\n\tL " <<
break;
}
case EMR_ARCTO:
dbg_str << "<!-- EMR_ARCTO -->\n";
break;
case EMR_POLYDRAW:
dbg_str << "<!-- EMR_POLYDRAW -->\n";
break;
case EMR_SETARCDIRECTION:
dbg_str << "<!-- EMR_SETARCDIRECTION -->\n";
break;
case EMR_SETMITERLIMIT:
{
dbg_str << "<!-- EMR_SETMITERLIMIT -->\n";
break;
}
case EMR_BEGINPATH:
{
dbg_str << "<!-- EMR_BEGINPATH -->\n";
tmp_path << "d=\"";
*(d->path) = "";
d->inpath = true;
break;
}
case EMR_ENDPATH:
{
dbg_str << "<!-- EMR_ENDPATH -->\n";
tmp_path << "\"";
d->inpath = false;
break;
}
case EMR_CLOSEFIGURE:
{
dbg_str << "<!-- EMR_CLOSEFIGURE -->\n";
tmp_path << "\n\tz";
break;
}
case EMR_FILLPATH:
case EMR_STROKEANDFILLPATH:
case EMR_STROKEPATH:
{
dbg_str << "<!-- EMR_FILLPATH -->\n";
dbg_str << "<!-- EMR_STROKEANDFILLPATH -->\n";
dbg_str << "<!-- EMR_STROKEPATH -->\n";
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += " /> \n";
*(d->path) = "";
break;
}
case EMR_FLATTENPATH:
dbg_str << "<!-- EMR_FLATTENPATH -->\n";
break;
case EMR_WIDENPATH:
dbg_str << "<!-- EMR_WIDENPATH -->\n";
break;
case EMR_SELECTCLIPPATH:
dbg_str << "<!-- EMR_SELECTCLIPPATH -->\n";
break;
case EMR_ABORTPATH:
dbg_str << "<!-- EMR_ABORTPATH -->\n";
break;
case EMR_GDICOMMENT:
{
dbg_str << "<!-- EMR_GDICOMMENT -->\n";
if ( *szTxt) {
}
szTxt++;
}
}
tmp_outsvg << " <!-- \"";
tmp_outsvg << "\" -->\n";
}
break;
}
case EMR_FILLRGN:
dbg_str << "<!-- EMR_FILLRGN -->\n";
break;
case EMR_FRAMERGN:
dbg_str << "<!-- EMR_FRAMERGN -->\n";
break;
case EMR_INVERTRGN:
dbg_str << "<!-- EMR_INVERTRGN -->\n";
break;
case EMR_PAINTRGN:
dbg_str << "<!-- EMR_PAINTRGN -->\n";
break;
case EMR_EXTSELECTCLIPRGN:
dbg_str << "<!-- EMR_EXTSELECTCLIPRGN -->\n";
break;
case EMR_BITBLT:
{
dbg_str << "<!-- EMR_BITBLT -->\n";
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
tmp_rectangle << "d=\"";
tmp_rectangle << "\n\tz";
assert_empty_path(d, "EMR_BITBLT");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\t";
*(d->outsvg) += " \" /> \n";
*(d->path) = "";
}
break;
}
case EMR_STRETCHBLT:
dbg_str << "<!-- EMR_STRETCHBLT -->\n";
break;
case EMR_MASKBLT:
dbg_str << "<!-- EMR_MASKBLT -->\n";
break;
case EMR_PLGBLT:
dbg_str << "<!-- EMR_PLGBLT -->\n";
break;
case EMR_SETDIBITSTODEVICE:
dbg_str << "<!-- EMR_SETDIBITSTODEVICE -->\n";
break;
case EMR_STRETCHDIBITS:
dbg_str << "<!-- EMR_STRETCHDIBITS -->\n";
break;
{
dbg_str << "<!-- EMR_EXTCREATEFONTINDIRECTW -->\n";
break;
}
case EMR_EXTTEXTOUTA:
{
dbg_str << "<!-- EMR_EXTTEXTOUTA -->\n";
break;
}
case EMR_EXTTEXTOUTW:
{
dbg_str << "<!-- EMR_EXTTEXTOUTW -->\n";
}
x1 += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
y1 += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
}
else
if (ansi_text) {
// gchar *p = ansi_text;
// while (*p) {
// if (*p < 32 || *p >= 127) {
// g_free(ansi_text);
// ansi_text = g_strdup("");
// break;
// }
// p++;
// }
// float text_rgb[3];
// sp_color_get_rgb_floatv( &(d->dc[d->level].style.fill.value.color), text_rgb );
// if (!d->dc[d->level].textColorSet) {
// d->dc[d->level].textColor = RGB(SP_COLOR_F_TO_U(text_rgb[0]),
// SP_COLOR_F_TO_U(text_rgb[1]),
// SP_COLOR_F_TO_U(text_rgb[2]));
// }
char tmp[128];
"fill:#%02x%02x%02x;",
//bool o = (d->dc[d->level].style.font_style.value == SP_CSS_FONT_STYLE_OBLIQUE);
(d->dc[d->level].style.font_weight.value >= SP_CSS_FONT_WEIGHT_500 && d->dc[d->level].style.font_weight.value <= SP_CSS_FONT_WEIGHT_900);
int lcr = ((d->dc[d->level].textAlign & TA_CENTER) == TA_CENTER) ? 2 : ((d->dc[d->level].textAlign & TA_RIGHT) == TA_RIGHT) ? 1 : 0;
assert_empty_path(d, "EMR_EXTTEXTOUTW");
ts << " <text\n";
// ts << " id=\"" << (d->id++) << "\"\n";
ts << " xml:space=\"preserve\"\n";
ts << " transform=\""
<< " " << x << " " << y << ")"
<< "\"\n";
}
ts << " style=\""
<< tmp
<< "font-style:" << (i ? "italic" : "normal") << ";"
<< "font-weight:" << (b ? "bold" : "normal") << ";"
<< "\"\n";
ts << " >";
ts << escaped_text;
ts << "</text>\n";
}
break;
}
case EMR_POLYBEZIER16:
{
dbg_str << "<!-- EMR_POLYBEZIER16 -->\n";
DWORD i,j;
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYBEZIER16");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
tmp_str << "\n\tC ";
tmp_str <<
}
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYGON16:
{
dbg_str << "<!-- EMR_POLYGON16 -->\n";
unsigned int i;
unsigned int first = 0;
assert_empty_path(d, "EMR_POLYGON16");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
// skip the first point?
tmp_poly << "\n\tM " <<
tmp_poly << "\n\tL " <<
}
*(d->outsvg) += " z \" /> \n";
break;
}
case EMR_POLYLINE16:
{
dbg_str << "<!-- EMR_POLYLINE16 -->\n";
DWORD i;
break;
if (!d->inpath) {
assert_empty_path(d, "EMR_POLYLINE16");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
tmp_str <<
"\n\tM " <<
tmp_str <<
"\n\tL " <<
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYBEZIERTO16:
{
dbg_str << "<!-- EMR_POLYBEZIERTO16 -->\n";
DWORD i,j;
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path << "\n\tC ";
tmp_path <<
}
}
break;
}
case EMR_POLYLINETO16:
{
dbg_str << "<!-- EMR_POLYLINETO16 -->\n";
DWORD i;
d->pathless_stroke = true;
*(d->path) = "d=\"";
}
tmp_path <<
"\n\tL " <<
}
break;
}
case EMR_POLYPOLYLINE16:
case EMR_POLYPOLYGON16:
{
dbg_str << "<!-- EMR_POLYPOLYLINE16 -->\n";
dbg_str << "<!-- EMR_POLYPOLYGON16 -->\n";
unsigned int n, i, j;
if (!d->inpath) {
assert_empty_path(d, lpEMFR->iType == EMR_POLYPOLYGON16 ? "EMR_POLYPOLYGON16" : "EMR_POLYPOLYLINE16");
*(d->outsvg) += " <path ";
*(d->outsvg) += "\n\td=\"";
}
i = 0;
poly_path << "\n\tM " <<
i++;
poly_path << "\n\tL " <<
i++;
}
tmp_str << " z";
tmp_str << " \n";
}
if (d->inpath) {
}
else {
*(d->outsvg) += " \" /> \n";
}
break;
}
case EMR_POLYDRAW16:
dbg_str << "<!-- EMR_POLYDRAW16 -->\n";
break;
case EMR_CREATEMONOBRUSH:
dbg_str << "<!-- EMR_CREATEMONOBRUSH -->\n";
break;
{
dbg_str << "<!-- EMR_CREATEDIBPATTERNBRUSHPT -->\n";
break;
}
case EMR_EXTCREATEPEN:
{
dbg_str << "<!-- EMR_EXTCREATEPEN -->\n";
}
break;
}
case EMR_POLYTEXTOUTA:
dbg_str << "<!-- EMR_POLYTEXTOUTA -->\n";
break;
case EMR_POLYTEXTOUTW:
dbg_str << "<!-- EMR_POLYTEXTOUTW -->\n";
break;
case EMR_SETICMMODE:
dbg_str << "<!-- EMR_SETICMMODE -->\n";
break;
case EMR_CREATECOLORSPACE:
dbg_str << "<!-- EMR_CREATECOLORSPACE -->\n";
break;
case EMR_SETCOLORSPACE:
dbg_str << "<!-- EMR_SETCOLORSPACE -->\n";
break;
case EMR_DELETECOLORSPACE:
dbg_str << "<!-- EMR_DELETECOLORSPACE -->\n";
break;
case EMR_GLSRECORD:
dbg_str << "<!-- EMR_GLSRECORD -->\n";
break;
case EMR_GLSBOUNDEDRECORD:
dbg_str << "<!-- EMR_GLSBOUNDEDRECORD -->\n";
break;
case EMR_PIXELFORMAT:
dbg_str << "<!-- EMR_PIXELFORMAT -->\n";
break;
default:
dbg_str << "<!-- EMR_??? -->\n";
break;
}
// *(d->outsvg) += dbg_str.str().c_str();
return 1;
}
static int CALLBACK
myMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, METARECORD * /*lpMFR*/, int /*nObj*/, LPARAM /*lpData*/)
{
g_warning("Unable to import Windows Meta File.\n");
return 0;
}
// Aldus Placeable Header ===================================================
// Since we are a 32bit app, we have to be sure this structure compiles to
// be identical to a 16 bit app's version. To do this, we use the #pragma
// to adjust packing, we use a WORD for the hmf handle, and a SMALL_RECT
// for the bbox rectangle.
#pragma pack( 2 )
typedef struct
{
} APMHEADER, *PAPMHEADER;
{
memset(&d, 0, sizeof(d));
gsize bytesWritten = 0;
return NULL;
}
if (PrintWin32::is_os_wide()) {
}
else {
}
if ( fp != INVALID_HANDLE_VALUE ) {
}
// Try open as Enhanced Metafile
if (PrintWin32::is_os_wide())
else
if (!hemf) {
// Try open as Windows Metafile
if (PrintWin32::is_os_wide())
else
if (!hmf) {
if (PrintWin32::is_os_wide()) {
if (dw) {
}
} else {
if (dw) {
}
}
}
if (hmf) {
if (!nSize)
if (nSize) {
if (lpvData) {
if (dw) {
// Fill out a METAFILEPICT structure
// Get a reference DC
// Make an enhanced metafile from the windows metafile
// Clean up
DeleteMetaFile( hmf );
}
else {
// EnumMetaFile
}
delete[] lpvData;
}
else {
DeleteMetaFile( hmf );
}
}
else {
DeleteMetaFile( hmf );
}
}
else {
// Try open as Aldus Placeable Metafile
if (PrintWin32::is_os_wide())
hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
else
if (hFile != INVALID_HANDLE_VALUE) {
if (nSize) {
if (lpvData) {
if (dw) {
// Fill out a METAFILEPICT structure
// Get a reference DC
// Create an enhanced metafile from the bits
// Clean up
}
}
delete[] lpvData;
}
}
CloseHandle( hFile );
}
}
}
if (d.outsvg)
delete d.outsvg;
if (d.path)
delete d.path;
if (d.outdef)
delete d.outdef;
if (local_fn)
if (unicode_fn)
if (hemf)
if (hmf)
return NULL;
}
if (hemf) {
if ( dwNeeded > 0 ) {
}
// This ugly reinterpret_cast is to prevent old versions of gcc from whining about a mismatch in the const-ness of the arguments
}
else {
}
if (d.pDesc)
// std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl;
SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg->c_str(), strlen(d.outsvg->c_str()), TRUE);
delete d.outsvg;
delete d.path;
delete d.outdef;
if (d.emf_obj) {
int i;
for (i=0; i<d.n_obj; i++)
delete_object(&d, i);
delete[] d.emf_obj;
}
if (local_fn)
if (unicode_fn)
return doc;
}
void
{
/* EMF in */
"<id>org.inkscape.input.emf.win32</id>\n"
"<input>\n"
"<extension>.emf</extension>\n"
"<output_extension>org.inkscape.output.emf.win32</output_extension>\n"
"</input>\n"
"</inkscape-extension>", new EmfWin32());
/* WMF in */
"<id>org.inkscape.input.wmf.win32</id>\n"
"<input>\n"
"<extension>.wmf</extension>\n"
"<output_extension>org.inkscape.output.emf.win32</output_extension>\n"
"</input>\n"
"</inkscape-extension>", new EmfWin32());
/* EMF out */
"<id>org.inkscape.output.emf.win32</id>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n"
"<output>\n"
"<extension>.emf</extension>\n"
"</output>\n"
"</inkscape-extension>", new EmfWin32());
return;
}
} } } /* namespace Inkscape, Extension, Implementation */
#endif /* WIN32 */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :