emf-win32-print.cpp revision ee19b9f92bd6039afa73c81389ae19881036feb8
/** @file
* @brief Enhanced Metafile printing
*/
/* Authors:
* Ulf Erikson <ulferikson@users.sf.net>
*
* 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 <string.h>
//#include <signal.h>
//#include <errno.h>
//#include "libnr/nr-point-matrix-ops.h"
//#include "libnr/nr-matrix.h"
#include "libnr/nr-matrix-ops.h"
//#include "libnr/nr-matrix-scale-ops.h"
//#include "libnr/nr-matrix-translate-ops.h"
#include "libnr/nr-scale-translate-ops.h"
//#include "libnr/nr-translate-scale-ops.h"
//#include "libnr/nr-matrix-fns.h"
//#include "libnr/nr-pixblock.h"
#include "helper/geom-curves.h"
//#include "display/canvas-bpath.h"
#include "sp-item.h"
//#include "glib.h"
//#include "gtk/gtkdialog.h"
//#include "gtk/gtkstock.h"
//#include "enums.h"
//#include "document.h"
#include "style.h"
//#include "sp-paint-server.h"
#include "inkscape_version.h"
//#include "libnrtype/FontFactory.h"
//#include "libnrtype/font-instance.h"
//#include "libnrtype/font-style-to-pos.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "win32.h"
#include "emf-win32-print.h"
#include "unit-constants.h"
//#include "extension/extension.h"
//#include "macros.h"
namespace Inkscape {
namespace Extension {
namespace Internal {
static float dwDPI = 2540;
PrintEmfWin32::PrintEmfWin32 (void):
stroke_and_fill(false),
fill_only(false),
simple_shape(false)
{
}
PrintEmfWin32::~PrintEmfWin32 (void)
{
if (hdc) {
if ( metafile ) {
}
}
/* restore default signal handling for SIGPIPE */
#endif
return;
}
unsigned int
{
return TRUE;
}
unsigned int
{
gsize bytesWritten = 0;
return 1;
}
// width and height in px
NRRect d;
bool pageBoundingBox;
if (pageBoundingBox) {
} else {
}
// dwInchesX x dwInchesY in .01mm units
// Get a Reference DC
// Get the physical characteristics of the reference DC
if (p)
p++;
else
p = ansi_uri;
// Create the Metafile
if (PrintWin32::is_os_wide()) {
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buff, sizeof(buff)/sizeof(buff[0]), wbuff, sizeof(wbuff)/sizeof(wbuff[0]));
}
else {
}
// Release the reference DC
// Did we get a good metafile?
{
return 1;
}
// Anisotropic mapping mode
// Set the Windows extent
// Set the viewport extent to reflect
// dwInchesX" x dwInchesY" in device units
if (1) {
snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * MM_PER_IN, dwInchesY * MM_PER_IN);
}
return 0;
}
unsigned int
{
if (!hdc) return 0;
flush_fill(); // flush any pending fills
if ( metafile ) {
}
return 0;
}
unsigned int
const char * /*comment*/)
{
if (!hdc) return 0;
flush_fill(); // flush any pending fills
return 0;
}
int
{
float rgb[3];
if (style) {
if (opacity <= 0.0)
return 1;
} else { // if (!style)
}
return 0;
}
void
{
if (hbrush)
DeleteObject( hbrush );
}
void
{
if (style) {
float rgb[3];
int linecap = 0;
int linejoin = 0;
using Geom::X;
using Geom::Y;
}
}
}
}
}
}
{
int i = 0;
while (linestyle != PS_USERSTYLE &&
i++;
}
if (linestyle == PS_USERSTYLE) {
}
}
}
hpen = ExtCreatePen(
&lb,
dash );
hpen = ExtCreatePen(
&lb,
0,
NULL );
}
if ( !hpen ) {
}
if (linejoin == PS_JOIN_MITER) {
float oldmiterlimit;
if (miterlimit < 1)
miterlimit = 10.0;
hdc,
&oldmiterlimit );
}
if (n_dash) {
delete[] dash;
}
}
else { // if (!style)
}
}
void
{
if (hpen)
DeleteObject( hpen );
}
void
{
if (!fill_pathv.empty()) {
stroke_and_fill = false;
fill_only = true;
fill_only = false;
if (!simple_shape)
fill_pathv.clear();
}
}
unsigned int
PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Matrix const *transform, float /*opacity*/)
{
if (m_tr_stack.size()) {
} else {
}
return 1;
}
unsigned int
{
m_tr_stack.pop();
return 1;
}
unsigned int
{
if (!hdc) return 0;
flush_fill(); // flush any pending fills
if (create_brush(style))
return 0;
} else {
// create_brush(NULL);
return 0;
}
fill_pathv.clear();
fill_transform = tf;
// postpone fill in case of stroke-and-fill
return 0;
}
unsigned int
{
if (!hdc) return 0;
if (!stroke_and_fill) {
flush_fill(); // flush any pending fills
}
} else {
// create_pen(NULL, tf);
return 0;
}
if (stroke_and_fill) {
if (!simple_shape)
StrokeAndFillPath( hdc );
fill_pathv.clear();
} else {
if (!simple_shape)
StrokePath( hdc );
}
destroy_pen();
return 0;
}
bool
{
int nodes = 0;
int moves = 0;
int lines = 0;
int curves = 0;
{
moves++;
nodes++;
{
nodes++;
if ( is_straight_curve(*cit) ) {
lines++;
}
curves++;
}
}
}
if (!nodes)
return false;
int i = 0;
/**
* For all Subpaths in the <path>
*/
{
using Geom::X;
using Geom::Y;
i = i + 1;
/**
* For all segments in the subpath
*/
{
if ( is_straight_curve(*cit) )
{
//Geom::Point p0 = cit->initialPoint();
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
i = i + 1;
}
{
//Geom::Point p0 = points[0];
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
i = i + 3;
}
}
}
bool done = false;
bool polygon = false;
bool polyline = false;
bool rectangle = false;
bool ellipse = false;
polygon = true;
if (nodes==5) {
{
rectangle = true;
}
}
}
polyline = true;
}
lpPoints[2].x == lpPoints[10].x && lpPoints[3].x == lpPoints[9].x && lpPoints[4].x == lpPoints[8].x &&
lpPoints[5].y == lpPoints[1].y && lpPoints[6].y == lpPoints[0].y && lpPoints[7].y == lpPoints[11].y)
{
ellipse = true;
}
}
if (!stroke_and_fill) {
if (fill_only) {
}
else { // if (stroke_only)
}
}
if (polygon) {
if (rectangle)
else
}
else if (polyline) {
}
else if (ellipse) {
}
done = true;
if (hpenOld)
if (hpenTmp)
DeleteObject( hpenTmp );
if (hbrushOld)
if (hbrushTmp)
}
delete[] lpPoints;
return done;
}
unsigned int
{
if (simple_shape)
return TRUE;
/**
* For all Subpaths in the <path>
*/
{
using Geom::X;
using Geom::Y;
/**
* For all segments in the subpath
*/
{
if ( is_straight_curve(*cit) )
{
//Geom::Point p0 = cit->initialPoint();
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
}
{
//Geom::Point p0 = points[0];
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
}
else
{
g_warning("logical error, because pathv_to_linear_and_cubic_beziers was used");
}
}
CloseFigure( hdc );
}
}
return TRUE;
}
bool
{
}
unsigned int
{
if (!hdc) return 0;
#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
if (!hfont) {
if (PrintWin32::is_os_wide()) {
lf->lfEscapement = 0;
lf->lfOrientation = 0;
}
else {
lf->lfEscapement = 0;
lf->lfOrientation = 0;
}
}
float rgb[3];
// Text alignment:
// - (x,y) coordinates received by this filter are those of the point where the text
// actually starts, and already takes into account the text object's alignment;
// - for this reason, the EMF text alignment must always be TA_BASELINE|TA_LEFT.
// Transparent text background
p = p * tf;
if (PrintWin32::is_os_wide()) {
}
else {
}
return 0;
}
void
PrintEmfWin32::init (void)
{
/* EMF print */
"<name>Enhanced Metafile Print</name>\n"
"<id>org.inkscape.print.emf.win32</id>\n"
"<param name=\"destination\" type=\"string\"></param>\n"
"<param name=\"textToPath\" type=\"boolean\">true</param>\n"
"<param name=\"pageBoundingBox\" type=\"boolean\">true</param>\n"
"<print/>\n"
"</inkscape-extension>", new PrintEmfWin32());
return;
}
} /* namespace Internal */
} /* namespace Extension */
} /* namespace Inkscape */
#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:encoding=utf-8:textwidth=99 :