diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/extension.h | 9 | ||||
| -rw-r--r-- | src/extension/init.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-inout.cpp | 40 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-print.cpp | 118 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-print.h | 3 | ||||
| -rw-r--r-- | src/extension/internal/win32.cpp | 510 | ||||
| -rw-r--r-- | src/extension/internal/win32.h | 96 | ||||
| -rw-r--r-- | src/file.cpp | 14 | ||||
| -rw-r--r-- | src/file.h | 5 | ||||
| -rw-r--r-- | src/inkscape.cpp | 14 | ||||
| -rw-r--r-- | src/io/sys.cpp | 6 | ||||
| -rw-r--r-- | src/io/uristream.cpp | 17 | ||||
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/print.cpp | 37 | ||||
| -rw-r--r-- | src/print.h | 1 | ||||
| -rw-r--r-- | src/verbs.cpp | 5 | ||||
| -rw-r--r-- | src/verbs.h | 1 |
17 files changed, 51 insertions, 833 deletions
diff --git a/src/extension/extension.h b/src/extension/extension.h index 936d2a907..63981522e 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -51,15 +51,6 @@ #define SP_MODULE_KEY_PRINT_LATEX "org.inkscape.print.latex" /** Defines the key for printing with GNOME Print */ #define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome" -/** Defines the key for printing under Win32 */ -#define SP_MODULE_KEY_PRINT_WIN32 "org.inkscape.print.win32" -#ifdef WIN32 -/** Defines the default printing to use */ -#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_WIN32 -#else -/** Defines the default printing to use */ -#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_PS -#endif /** Mime type for SVG */ #define MIME_SVG "image/svg+xml" diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 230d4b50f..355922bc5 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -26,7 +26,6 @@ #include "db.h" #include "internal/svgz.h" #ifdef WIN32 -# include "internal/win32.h" # include "internal/emf-win32-inout.h" # include "internal/emf-win32-print.h" #endif @@ -171,7 +170,6 @@ init() } #endif #ifdef WIN32 - Internal::PrintWin32::init(); Internal::PrintEmfWin32::init(); Internal::EmfWin32::init(); #endif diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 979be1b63..2716faee2 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -42,7 +42,6 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> -#include "win32.h" #include "emf-win32-print.h" #include "emf-win32-inout.h" @@ -2262,12 +2261,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) HMETAFILE hmf; HENHMETAFILE hemf; - if (PrintWin32::is_os_wide()) { - fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } - else { - fp = CreateFileA(ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } + fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if ( fp != INVALID_HANDLE_VALUE ) { filesize = GetFileSize(fp, NULL); @@ -2275,36 +2269,21 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) } // Try open as Enhanced Metafile - if (PrintWin32::is_os_wide()) - hemf = GetEnhMetaFileW(unicode_uri); - else - hemf = GetEnhMetaFileA(ansi_uri); + hemf = GetEnhMetaFileW(unicode_uri); if (!hemf) { // Try open as Windows Metafile - if (PrintWin32::is_os_wide()) - hmf = GetMetaFileW(unicode_uri); - else - hmf = GetMetaFileA(ansi_uri); + hmf = GetMetaFileW(unicode_uri); METAFILEPICT mp; HDC hDC; if (!hmf) { - if (PrintWin32::is_os_wide()) { - WCHAR szTemp[MAX_PATH]; + WCHAR szTemp[MAX_PATH]; - DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH ); - if (dw) { - hmf = GetMetaFileW( szTemp ); - } - } else { - CHAR szTemp[MAX_PATH]; - - DWORD dw = GetShortPathNameA( ansi_uri, szTemp, MAX_PATH ); - if (dw) { - hmf = GetMetaFileA( szTemp ); - } + DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH ); + if (dw) { + hmf = GetMetaFileW( szTemp ); } } @@ -2351,10 +2330,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) else { // Try open as Aldus Placeable Metafile HANDLE hFile; - if (PrintWin32::is_os_wide()) - hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - else - hFile = CreateFileA( ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if (hFile != INVALID_HANDLE_VALUE) { DWORD nSize = GetFileSize( hFile, NULL ); diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 503a13d09..eb6abeaca 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -57,10 +57,6 @@ //#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" @@ -186,15 +182,12 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) snprintf(buff+len+1, sizeof(buff)-len-2, "%s", p); // Create the Metafile - if (PrintWin32::is_os_wide()) { + { WCHAR wbuff[1024]; ZeroMemory(wbuff, sizeof(wbuff)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buff, sizeof(buff)/sizeof(buff[0]), wbuff, sizeof(wbuff)/sizeof(wbuff[0])); hdc = CreateEnhMetaFileW( hScreenDC, unicode_uri, &rc, wbuff ); } - else { - hdc = CreateEnhMetaFileA( hScreenDC, ansi_uri, &rc, buff ); - } // Release the reference DC ReleaseDC( NULL, hScreenDC ); @@ -879,76 +872,40 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom #endif if (!hfont) { - if (PrintWin32::is_os_wide()) { - LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); - g_assert(lf != NULL); - - lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; - lf->lfWidth = 0; - lf->lfEscapement = rot; - lf->lfOrientation = rot; - lf->lfWeight = - style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : - FW_NORMAL; - lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); - lf->lfUnderline = style->text_decoration.underline; - lf->lfStrikeOut = style->text_decoration.line_through; - lf->lfCharSet = DEFAULT_CHARSET; - lf->lfOutPrecision = OUT_DEFAULT_PRECIS; - lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf->lfQuality = DEFAULT_QUALITY; - lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - - gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL ); - wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1); - g_free(unicode_name); - - hfont = CreateFontIndirectW(lf); - - g_free(lf); - } - else { - LOGFONTA *lf = (LOGFONTA*)g_malloc(sizeof(LOGFONTA)); - g_assert(lf != NULL); - - lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; - lf->lfWidth = 0; - lf->lfEscapement = rot; - lf->lfOrientation = rot; - lf->lfWeight = - style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : - FW_NORMAL; - lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); - lf->lfUnderline = style->text_decoration.underline; - lf->lfStrikeOut = style->text_decoration.line_through; - lf->lfCharSet = DEFAULT_CHARSET; - lf->lfOutPrecision = OUT_DEFAULT_PRECIS; - lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf->lfQuality = DEFAULT_QUALITY; - lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - - strncpy(lf->lfFaceName, (char*) style->text->font_family.value, LF_FACESIZE-1); - - hfont = CreateFontIndirectA(lf); - - g_free(lf); - } + LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); + g_assert(lf != NULL); + + lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; + lf->lfWidth = 0; + lf->lfEscapement = rot; + lf->lfOrientation = rot; + lf->lfWeight = + style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : + FW_NORMAL; + lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); + lf->lfUnderline = style->text_decoration.underline; + lf->lfStrikeOut = style->text_decoration.line_through; + lf->lfCharSet = DEFAULT_CHARSET; + lf->lfOutPrecision = OUT_DEFAULT_PRECIS; + lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf->lfQuality = DEFAULT_QUALITY; + lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + + gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL ); + wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1); + g_free(unicode_name); + + hfont = CreateFontIndirectW(lf); + + g_free(lf); } HFONT hfontOld = (HFONT) SelectObject(hdc, hfont); @@ -973,13 +930,10 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom LONG const xpos = (LONG) round(p[Geom::X]); LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]); - if (PrintWin32::is_os_wide()) { + { gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL ); TextOutW(hdc, xpos, ypos, (WCHAR*)unicode_text, wcslen((wchar_t*)unicode_text)); } - else { - TextOutA(hdc, xpos, ypos, (CHAR*)text, strlen((char*)text)); - } SelectObject(hdc, hfontOld); DeleteObject(hfont); diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index a9f639bcd..44327d35e 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -17,6 +17,9 @@ # include "config.h" #endif +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + #include "extension/implementation/implementation.h" //#include "extension/extension.h" diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp deleted file mode 100644 index 537c91a2c..000000000 --- a/src/extension/internal/win32.cpp +++ /dev/null @@ -1,510 +0,0 @@ -/** @file - * @brief Windows-specific stuff - */ -/* Author: - * Lauris Kaplinski <lauris@kaplinski.com> - * Abhishek Sharma - * - * This code is in public domain - */ - -#ifdef WIN32 - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <glib/gmem.h> -#include <libnr/nr-macros.h> -#include <2geom/transforms.h> - -#include "display/nr-arena-item.h" -#include "display/nr-arena.h" -#include "document.h" - -#include "win32.h" -#include "extension/system.h" -#include "extension/print.h" -#include <gtk/gtk.h> - -/* Initialization */ - -namespace Inkscape { -namespace Extension { -namespace Internal { - -static unsigned int SPWin32Modal = FALSE; - -/** - * Callback function.. not a method - */ -static void -my_gdk_event_handler (GdkEvent *event) -{ - if (SPWin32Modal) { - /* Win32 widget is modal, filter events */ - switch (event->type) { - case GDK_NOTHING: - case GDK_DELETE: - case GDK_SCROLL: - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - case GDK_DRAG_STATUS: - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - return; - break; - default: - break; - } - } - gtk_main_do_event (event); -} - -void -PrintWin32::main_init (int argc, char **argv, const char *name) -{ - gdk_event_handler_set ((GdkEventFunc) my_gdk_event_handler, NULL, NULL); -} - -void -PrintWin32::finish (void) -{ -} - -#define SP_FOREIGN_MAX_ITER 10 - - -/** - * Callback function.. not a method - */ -static VOID CALLBACK -my_timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); -} - - -/* Platform detection */ - -gboolean -PrintWin32::is_os_wide() -{ - static gboolean initialized = FALSE; - static gboolean is_wide = FALSE; - static OSVERSIONINFOA osver; - - if ( !initialized ) - { - BOOL result; - - initialized = TRUE; - - memset (&osver, 0, sizeof(OSVERSIONINFOA)); - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - result = GetVersionExA (&osver); - if (result) - { - if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) - is_wide = TRUE; - } - // If we can't even call to get the version, fall back to ANSI API - } - - return is_wide; -} - - -/* Printing */ - -PrintWin32::PrintWin32 (void) -{ - /* Nothing here */ -} - - -PrintWin32::~PrintWin32 (void) -{ - DeleteDC (_hDC); -} - - -/** - * Callback function.. not a method - */ -static UINT_PTR CALLBACK -print_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ -#if 0 - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); -#endif - return 0; -} - -unsigned int -PrintWin32::setup (Inkscape::Extension::Print *mod) -{ - HRESULT res; - PRINTDLG pd = { - sizeof (PRINTDLG), - NULL, /* hwndOwner */ - NULL, /* hDevMode */ - NULL, /* hDevNames */ - NULL, /* hDC */ - PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */ - 1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */ - 1, /* nCoies */ - NULL, /* hInstance */ - 0, /* lCustData */ - NULL, NULL, NULL, NULL, NULL, NULL - }; - UINT_PTR timer; - - SPWin32Modal = TRUE; - pd.Flags |= PD_ENABLEPRINTHOOK; - pd.lpfnPrintHook = print_hook; - timer = SetTimer (NULL, 0, 40, my_timer); - - res = PrintDlg (&pd); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!res) return FALSE; - - _hDC = pd.hDC; - -#if 0 - caps = GetDeviceCaps (_hDC, RASTERCAPS); - if (caps & RC_BANDING) { - printf ("needs banding\n"); - } - if (caps & RC_BITBLT) { - printf ("does bitblt\n"); - } - if (caps & RC_DIBTODEV) { - printf ("does dibtodev\n"); - } - if (caps & RC_STRETCHDIB) { - printf ("does stretchdib\n"); - } -#endif - if (pd.hDevMode) { - DEVMODE *devmodep; - devmodep = (DEVMODE *)pd.hDevMode; - if (devmodep->dmFields & DM_ORIENTATION) { - _landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE); - } - } - - return TRUE; -} - -unsigned int -PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) -{ - DOCINFO di = { - sizeof (DOCINFO), - NULL, /* lpszDocName */ - NULL, /* lpszOutput */ - NULL, /* lpszDatatype */ - 0 /* DI_APPBANDING */ /* fwType */ - }; - int res; - - _PageWidth = doc->getWidth (); - _PageHeight = doc->getHeight (); - - di.lpszDocName = doc->getName(); - - SPWin32Modal = TRUE; - - res = StartDoc (_hDC, &di); - res = StartPage (_hDC); - - SPWin32Modal = FALSE; - - return 0; -} - -unsigned int -PrintWin32::finish (Inkscape::Extension::Print *mod) -{ - int dpiX, dpiY; - int pPhysicalWidth, pPhysicalHeight; - int pPhysicalOffsetX, pPhysicalOffsetY; - int pPrintableWidth, pPrintableHeight; - float scalex, scaley; - int x0, y0, x1, y1; - int width, height; - unsigned char *px; - int sheight, row; - BITMAPINFO bmInfo = { - { - sizeof (BITMAPINFOHEADER), // bV4Size - 64, // biWidth - 64, // biHeight - 1, // biPlanes - 32, // biBitCount - BI_RGB, // biCompression - 0, // biSizeImage - 2835, // biXPelsPerMeter - 2835, // biYPelsPerMeter - 0, // biClrUsed - 0 // biClrImportant - }, - { { 0, 0, 0, 0 } } // bmiColors - }; - //RECT wrect; - int res; - - SPWin32Modal = TRUE; - - // Number of pixels per logical inch - dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX); - dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY); - // Size in pixels of the printable area - pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH); - pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT); - // Top left corner of prontable area - pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX); - pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY); - // Size in pixels of the printable area - pPrintableWidth = GetDeviceCaps (_hDC, HORZRES); - pPrintableHeight = GetDeviceCaps (_hDC, VERTRES); - - // Scaling from document to device - scalex = dpiX / 72.0; - scaley = dpiY / 72.0; - - // We simply map document 0,0 to physical page 0,0 - Geom::Affine affine = Geom::Scale(scalex / 1.25, scaley / 1.25); - - nr_arena_item_set_transform (mod->root, affine); - - // Calculate printable area in device coordinates - x0 = pPhysicalOffsetX; - y0 = pPhysicalOffsetY; - x1 = x0 + pPrintableWidth; - y1 = y0 + pPrintableHeight; - x1 = MIN (x1, (int) (_PageWidth * scalex)); - y1 = MIN (y1, (int) (_PageHeight * scaley)); - - width = x1 - x0; - height = y1 - y0; - - px = g_new (unsigned char, 4 * 64 * width); - sheight = 64; - - /* Printing goes here */ - for (row = 0; row < height; row += 64) { - NRPixBlock pb; - NRRectL bbox; - NRGC gc(NULL); - int num_rows; - int i; - - num_rows = sheight; - if ((row + num_rows) > height) num_rows = height - row; - - /* Set area of interest */ - bbox.x0 = x0; - bbox.y0 = y0 + row; - bbox.x1 = bbox.x0 + width; - bbox.y1 = bbox.y0 + num_rows; - /* Update to renderable state */ - gc.transform.setIdentity(); - nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - - nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE); - - /* Blitter goes here */ - bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0; - bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0); - - memset (px, 0xff, 4 * num_rows * width); - /* Render */ - nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0); - - /* Swap red and blue channels; we use RGBA, whereas - * the Win32 GDI uses BGRx. - */ - for ( i = 0 ; i < num_rows * width ; i++ ) { - unsigned char temp=px[i*4]; - px[i*4] = px[i*4+2]; - px[i*4+2] = temp; - } - - SetStretchBltMode(_hDC, COLORONCOLOR); - res = StretchDIBits (_hDC, - bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - 0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - px, - &bmInfo, - DIB_RGB_COLORS, - SRCCOPY); - - /* Blitter ends here */ - - nr_pixblock_release (&pb); - } - - g_free (px); - - res = EndPage (_hDC); - res = EndDoc (_hDC); - - SPWin32Modal = FALSE; - - return 0; -} - -/* File dialogs */ - -char * -PrintWin32::get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) -{ - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - (const CHAR *)filter, /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - (const CHAR *)title, /* lpstrTitle */ - OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetOpenFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; - } - return g_strdup (fnbuf); -} - -char * -PrintWin32::get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) -{ - return NULL; -} - -char * -PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns) -{ - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - "Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - "Save document to file", /* lpstrTitle */ - OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetSaveFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; - } - *spns = (ofn.nFilterIndex != 2); - return g_strdup (fnbuf); -} - -#include "clear-n_.h" - -void -PrintWin32::init (void) -{ - Inkscape::Extension::Extension * ext; - - /* SVG in */ - ext = Inkscape::Extension::build_from_mem( - "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Windows 32-bit Print") "</name>\n" - "<id>" SP_MODULE_KEY_PRINT_WIN32 "</id>\n" - "<param name=\"textToPath\" type=\"boolean\">true</param>\n" - "<print/>\n" - "</inkscape-extension>", new PrintWin32()); - - return; -} - -} /* namespace Internal */ -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif // ifdef 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 : diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h deleted file mode 100644 index 4a913bb05..000000000 --- a/src/extension/internal/win32.h +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - * @brief Windows-specific stuff - */ -/* Author: - * Lauris Kaplinski <lauris@kaplinski.com> - * Ted Gould <ted@gould.cx> - * - * Lauris: This code is in public domain - * Ted: This code is released under the GNU GPL - */ - -#ifndef __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ -#ifdef WIN32 - -#ifdef HAVE_CONFIG_H - #include <config.h> -#endif - -#ifdef DATADIR -#undef DATADIR -#endif -#include <windows.h> - -#include "extension/extension.h" -#include "extension/implementation/implementation.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { - -/* Initialization */ - -class PrintWin32 : public Inkscape::Extension::Implementation::Implementation { - /* Document dimensions */ - float _PageWidth; - float _PageHeight; - - HDC _hDC; - - unsigned int _landscape; - - void main_init (int argc, char **argv, const char *name); - void finish (void); - - /* File dialogs */ - char *get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title); - char *get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title); - char *get_save_filename (unsigned char *dir, unsigned int *spns); - - VOID CALLBACK timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); - - -public: - PrintWin32 (void); - virtual ~PrintWin32 (void); - - /* Tell modules about me */ - static void init (void); - - /* Platform detection */ - static gboolean is_os_wide(); - - /* Print functions */ - virtual unsigned int setup (Inkscape::Extension::Print * module); - //virtual unsigned int set_preview (Inkscape::Extension::Print * module); - - virtual unsigned int begin (Inkscape::Extension::Print * module, SPDocument *doc); - virtual unsigned int finish (Inkscape::Extension::Print * module); - - /* Rendering methods */ - /* - virtual unsigned int bind (Inkscape::Extension::Print * module, const Geom::Affine *transform, float opacity); - virtual unsigned int release (Inkscape::Extension::Print * module); - virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment); - virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const Geom::Affine *transform, const SPStyle *style); - */ -}; - -} /* namespace Internal */ -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif // ifdef WIN32 -#endif /* __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ */ -/* - 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 : diff --git a/src/file.cpp b/src/file.cpp index ae774bb52..86df2ed44 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1510,20 +1510,6 @@ sp_file_print(Gtk::Window& parentWindow) sp_print_document(parentWindow, doc); } -/** - * Display what the drawing would look like, if - * printed. - */ -void -sp_file_print_preview(gpointer /*object*/, gpointer /*data*/) -{ - - SPDocument *doc = SP_ACTIVE_DOCUMENT; - if (doc) - sp_print_preview_document(doc); - -} - /* Local Variables: diff --git a/src/file.h b/src/file.h index 97d1bd5f8..65d561adc 100644 --- a/src/file.h +++ b/src/file.h @@ -183,11 +183,6 @@ would be useful as instance methods */ void sp_file_print (Gtk::Window& parentWindow); -/** - * - */ -void sp_file_print_preview (gpointer object, gpointer data); - /*##################### ## U T I L I T Y #####################*/ diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1007c315a..b063b909d 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -25,10 +25,6 @@ # define HAS_PROC_SELF_EXE //to get path of executable #else -// For now to get at is_os_wide(). -# include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; - #define _WIN32_IE 0x0400 //#define HAS_SHGetSpecialFolderPath #define HAS_SHGetSpecialFolderLocation @@ -1354,24 +1350,18 @@ profile_path(const char *filename) if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) { gchar * utf8Path = NULL; - if ( PrintWin32::is_os_wide() ) { + { wchar_t pathBuf[MAX_PATH+1]; g_assert(sizeof(wchar_t) == sizeof(gunichar2)); if ( SHGetPathFromIDListW( pidl, pathBuf ) ) { utf8Path = g_utf16_to_utf8( (gunichar2*)(&pathBuf[0]), -1, NULL, NULL, NULL ); } - } else { - char pathBuf[MAX_PATH+1]; - - if ( SHGetPathFromIDListA( pidl, pathBuf ) ) { - utf8Path = g_filename_to_utf8( pathBuf, -1, NULL, NULL, NULL ); - } } if ( utf8Path ) { if (!g_utf8_validate(utf8Path, -1, NULL)) { - g_warning( "SHGetPathFromIDList%c() resulted in invalid UTF-8", (PrintWin32::is_os_wide() ? 'W' : 'A') ); + g_warning( "SHGetPathFromIDListW() resulted in invalid UTF-8"); g_free( utf8Path ); utf8Path = 0; } else { diff --git a/src/io/sys.cpp b/src/io/sys.cpp index a68d02707..198be94e6 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -28,12 +28,6 @@ #include "preferences.h" #include "sys.h" -#ifdef WIN32 -// For now to get at is_os_wide(). -#include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; -#endif // WIN32 - //#define INK_DUMP_FILENAME_CONV 1 #undef INK_DUMP_FILENAME_CONV diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp index 05d7f020a..b5f884b29 100644 --- a/src/io/uristream.cpp +++ b/src/io/uristream.cpp @@ -16,12 +16,6 @@ #include <string> #include <cstring> -#ifdef WIN32 -// For now to get at is_os_wide(). -# include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; -#endif - namespace Inkscape { @@ -65,7 +59,7 @@ static FILE *fopen_utf8name( char const *utf8name, int mode ) g_free(filename); } #else - if ( PrintWin32::is_os_wide() ) { + { gunichar2 *wideName = g_utf8_to_utf16( utf8name, -1, NULL, NULL, NULL ); if ( wideName ) { if (mode == FILE_READ) @@ -78,15 +72,6 @@ static FILE *fopen_utf8name( char const *utf8name, int mode ) g_message("Unable to convert filename from UTF-8 to UTF-16 [%s]", safe); g_free(safe); } - } else { - gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL ); - if ( filename ) { - if (mode == FILE_READ) - fp = std::fopen(filename, "rb"); - else - fp = std::fopen(filename, "wb"); - g_free(filename); - } } #endif diff --git a/src/main.cpp b/src/main.cpp index ac0994be6..b510f6902 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,9 +100,8 @@ #include <extension/input.h> #ifdef WIN32 +#include <windows.h> #include "registrytool.h" -#include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; #endif // WIN32 #include "extension/init.h" @@ -702,9 +701,6 @@ main(int argc, char **argv) } #ifdef WIN32 -#ifndef REPLACEARGS_ANSI - if ( PrintWin32::is_os_wide() ) -#endif // REPLACEARGS_ANSI { // If the call fails, we'll need to convert charsets needToRecodeParams = !replaceArgs( argc, argv ); diff --git a/src/print.cpp b/src/print.cpp index fe52ea6dd..0774f5751 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -85,43 +85,6 @@ unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, /* UI */ void -sp_print_preview_document(SPDocument *doc) -{ - Inkscape::Extension::Print *mod; - unsigned int ret; - - doc->ensureUpToDate(); - - mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT); - - ret = mod->set_preview(); - - if (ret) { - SPPrintContext context; - context.module = mod; - - /* fixme: This has to go into module constructor somehow */ - /* Create new arena */ - mod->base = SP_ITEM(doc->getRoot()); - mod->arena = NRArena::create(); - mod->dkey = SPItem::display_key_new(1); - mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); - /* Print document */ - ret = mod->begin(doc); - (mod->base)->invoke_print(&context); - ret = mod->finish(); - /* Release arena */ - (mod->base)->invoke_hide(mod->dkey); - mod->base = NULL; - mod->root = NULL; - nr_object_unref((NRObject *) mod->arena); - mod->arena = NULL; - } - - return; -} - -void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) { doc->ensureUpToDate(); diff --git a/src/print.h b/src/print.h index 70361fb14..caea6ae3a 100644 --- a/src/print.h +++ b/src/print.h @@ -41,7 +41,6 @@ void sp_print_get_param(SPPrintContext *ctx, gchar *name, bool *value); /* UI */ -void sp_print_preview_document(SPDocument *doc); void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc); void sp_print_document_to_file(SPDocument *doc, gchar const *filename); diff --git a/src/verbs.cpp b/src/verbs.cpp index 1ad68b792..3e0dbf98c 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -824,9 +824,6 @@ FileVerb::perform(SPAction *action, void *data, void */*pdata*/) case SP_VERB_FILE_VACUUM: sp_file_vacuum(); break; - case SP_VERB_FILE_PRINT_PREVIEW: - sp_file_print_preview(NULL, NULL); - break; case SP_VERB_FILE_IMPORT: sp_file_import(*parent); break; @@ -2251,8 +2248,6 @@ Verb *Verb::_base_verbs[] = { // TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions) new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Vac_uum Defs"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"), INKSCAPE_ICON_DOCUMENT_CLEANUP ), - new FileVerb(SP_VERB_FILE_PRINT_PREVIEW, "FilePrintPreview", N_("Print Previe_w"), - N_("Preview document printout"), GTK_STOCK_PRINT_PREVIEW ), new FileVerb(SP_VERB_FILE_IMPORT, "FileImport", N_("_Import..."), N_("Import a bitmap or SVG image into this document"), INKSCAPE_ICON_DOCUMENT_IMPORT), new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."), diff --git a/src/verbs.h b/src/verbs.h index 0c781f0b6..91e00c307 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -41,7 +41,6 @@ enum { SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */ SP_VERB_FILE_PRINT, SP_VERB_FILE_VACUUM, - SP_VERB_FILE_PRINT_PREVIEW, SP_VERB_FILE_IMPORT, SP_VERB_FILE_EXPORT, SP_VERB_FILE_IMPORT_FROM_OCAL, /**< Import the file from Open Clip Art Library */ |
