Re: dom - r22981 - in abiword/trunk/src: af/gr/gtk af/xap/win wp/ap/win wp/ap/xp

From: Dominic Lachowicz <domlachowicz_at_gmail.com>
Date: Sat Mar 01 2008 - 20:36:27 CET

I just tested this on Win32. It doesn't seem like the text is being printed.

Just FYI.

On Sat, Mar 1, 2008 at 2:08 PM, <cvs@abisource.com> wrote:
>
> Author: dom
> Date: 2008-03-01 20:08:27 +0100 (Sat, 01 Mar 2008)
> New Revision: 22981
>
> Modified:
> abiword/trunk/src/af/gr/gtk/Makefile.am
> abiword/trunk/src/af/xap/win/xap_Win32App.cpp
> abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.cpp
> abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.h
> abiword/trunk/src/wp/ap/win/ap_Win32App.cpp
> abiword/trunk/src/wp/ap/win/ap_Win32Dialog_All.h
> abiword/trunk/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h
> abiword/trunk/src/wp/ap/xp/ap_TB_Layouts_FileEditOps.h
> Log:
> Print preview on Win32. Follow's GTK+'s hackery, where we create an EMF
> and ask Explorer to "open" it for us.
>
> Only tested on Linux via cross-compiling + Wine. Needs testing on Win32
> proper.
>
>
>
> Modified: abiword/trunk/src/af/gr/gtk/Makefile.am
> ===================================================================
> --- abiword/trunk/src/af/gr/gtk/Makefile.am 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/af/gr/gtk/Makefile.am 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -7,6 +7,10 @@
> libgtk_la_SOURCES = \
> gr_UnixImage.cpp \
> gr_UnixImage.h \
> + gr_CairoImage.cpp \
> + gr_CairoImage.h \
> + gr_UnixCairoImage.cpp \
> + gr_UnixCairoImage.h \
> gr_UnixNullGraphics.cpp \
> gr_UnixNullGraphics.h \
> gr_UnixPangoGraphics.cpp \
>
> Modified: abiword/trunk/src/af/xap/win/xap_Win32App.cpp
> ===================================================================
> --- abiword/trunk/src/af/xap/win/xap_Win32App.cpp 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/af/xap/win/xap_Win32App.cpp 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -116,7 +116,7 @@
> HINSTANCE hUniscribe = LoadLibrary("usp10.dll");
> #endif
>
> - if(hUniscribe)
> + if(hUniscribe && (NULL == g_getenv("ABIWORD_DISABLE_UNISCRIBE")))
> {
> // register Uniscribe graphics and make it the default
> bSuccess = pGF->registerClass(GR_Win32USPGraphics::graphicsAllocator,
>
> Modified: abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.cpp
> ===================================================================
> --- abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.cpp 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.cpp 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -20,19 +20,119 @@
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> +#include <glib/gstdio.h>
> +#include <io.h>
> +
> #include "ut_assert.h"
> #include "ut_string.h"
> #include "ut_debugmsg.h"
> #include "xap_Dialog_Id.h"
> #include "xap_Win32Dlg_PrintPreview.h"
> #include "xap_Frame.h"
> +#include "xap_App.h"
> #include "xap_DialogFactory.h"
> +#include "gr_Win32Graphics.h"
> +#include "ut_Win32OS.h"
>
> +#include "fv_View.h"
> +
> XAP_Win32Dialog_PrintPreview::XAP_Win32Dialog_PrintPreview(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id)
> - : XAP_Dialog_PrintPreview(pDlgFactory,id)
> + : XAP_Dialog_PrintPreview(pDlgFactory,id), m_pPrintGraphics(0), m_emfFilename(0)
> {
> }
>
> XAP_Win32Dialog_PrintPreview::~XAP_Win32Dialog_PrintPreview(void)
> {
> + DELETEP(m_pPrintGraphics);
> + g_free(m_emfFilename);
> }
> +
> +XAP_Dialog * XAP_Win32Dialog_PrintPreview::static_constructor(XAP_DialogFactory * pFactory,
> + XAP_Dialog_Id id)
> +{
> + return new XAP_Win32Dialog_PrintPreview (pFactory,id);
> +}
> +
> +GR_Graphics * XAP_Win32Dialog_PrintPreview::getPrinterGraphicsContext(void)
> +{
> + return m_pPrintGraphics;
> +}
> +
> +void XAP_Win32Dialog_PrintPreview::releasePrinterGraphicsContext(GR_Graphics * pGraphics)
> +{
> + HDC dc;
> +
> + if (!m_pPrintGraphics) return;
> +
> + dc = ((GR_Win32Graphics *)m_pPrintGraphics)->getPrimaryDC();
> +
> + if (dc != NULL)
> + {
> + HENHMETAFILE metafile;
> +
> + metafile = CloseEnhMetaFile (dc);
> + DeleteEnhMetaFile (metafile);
> +
> + ShellExecuteW (NULL, L"open", (WCHAR *)m_emfFilename, NULL, NULL, SW_SHOW);
> + }
> +
> + DELETEP(m_pPrintGraphics);
> +
> + if (m_emfFilename)
> + {
> + // don't remove m_emfFilename, because the preview application is probably still using the file
> + g_free(m_emfFilename);
> + m_emfFilename = 0;
> + }
> +}
> +
> +void XAP_Win32Dialog_PrintPreview::runModal(XAP_Frame * pFrame)
> +{
> + HDC metafile_dc;
> + RECT rect;
> + char *filename;
> + int fd;
> +
> + FV_View * pView = static_cast<FV_View*>(pFrame->getCurrentView());
> +
> + filename = g_build_filename (g_get_tmp_dir (), "prXXXXXX.emf", NULL);
> + fd = g_mkstemp (filename);
> + close(fd);
> +
> + m_emfFilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
> +
> + rect.left = 0;
> + rect.right = (LONG)(pView->getPageSize().Width (DIM_MM) * 100);
> + rect.top = 0;
> + rect.bottom = (LONG)(pView->getPageSize().Height (DIM_MM) * 100);
> +
> + metafile_dc = CreateEnhMetaFileW (NULL, (WCHAR*)m_emfFilename,
> + &rect, L"AbiWord\0Print Preview\0\0");
> +
> + if (metafile_dc == NULL)
> + {
> + g_remove (filename);
> + g_free (m_emfFilename);
> + m_emfFilename = 0;
> + UT_DEBUGMSG(("Can't create metafile"));
> + UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
> + }
> + else
> + {
> + DOCINFO *di;
> +
> + di = (DOCINFO*) UT_calloc(1, sizeof(DOCINFO));
> + memset( di, 0, sizeof(DOCINFO) );
> + di->cbSize = sizeof(DOCINFO);
> + di->lpszDocName = (LPCTSTR)TEXT("AbiWord Print Preview");
> + di->lpszOutput = (LPTSTR) NULL;
> + di->lpszDatatype = (LPTSTR) NULL;
> + di->fwType = 0;
> +
> + GR_Win32AllocInfo ai(metafile_dc, di, NULL);
> + m_pPrintGraphics = XAP_App::getApp()->newGraphics(ai);
> + UT_ASSERT(m_pPrintGraphics);
> + }
> +
> + g_free(filename);
> +}
>
> Modified: abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.h
> ===================================================================
> --- abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.h 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/af/xap/win/xap_Win32Dlg_PrintPreview.h 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -31,11 +31,17 @@
> XAP_Win32Dialog_PrintPreview(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
> virtual ~XAP_Win32Dialog_PrintPreview(void);
>
> - virtual GR_Graphics * getPrinterGraphicsContext(void) = 0;
> - virtual void releasePrinterGraphicsContext(GR_Graphics * pGraphics) = 0;
> - virtual void runModal(XAP_Frame * pFrame) = 0;
> + virtual GR_Graphics * getPrinterGraphicsContext(void);
> + virtual void releasePrinterGraphicsContext(GR_Graphics * pGraphics);
> + virtual void runModal(XAP_Frame * pFrame);
>
> + static XAP_Dialog *static_constructor(XAP_DialogFactory * pFactory,
> + XAP_Dialog_Id id);
> +
> protected:
> +
> + GR_Graphics * m_pPrintGraphics;
> + gunichar2 * m_emfFilename;
> };
>
> #endif /* XAP_Win32DIALOG_PRINTPREVIEW_H */
>
> Modified: abiword/trunk/src/wp/ap/win/ap_Win32App.cpp
> ===================================================================
> --- abiword/trunk/src/wp/ap/win/ap_Win32App.cpp 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/wp/ap/win/ap_Win32App.cpp 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -149,6 +149,7 @@
> bool bSuccess = true;
> const char * szUserPrivateDirectory = getUserPrivateDirectory();
> bool bVerified = s_createDirectoryIfNecessary(szUserPrivateDirectory);
> +
> UT_return_val_if_fail (bVerified, false);
>
> // load the preferences.
>
> Modified: abiword/trunk/src/wp/ap/win/ap_Win32Dialog_All.h
> ===================================================================
> --- abiword/trunk/src/wp/ap/win/ap_Win32Dialog_All.h 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/wp/ap/win/ap_Win32Dialog_All.h 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -33,6 +33,7 @@
> # include "xap_Win32Dlg_MessageBox.h"
> # include "xap_Win32Dlg_FileOpenSaveAs.h"
> # include "xap_Win32Dlg_Print.h"
> +# include "xap_Win32Dlg_PrintPreview.h"
> # include "xap_Win32Dlg_FontChooser.h"
> # include "xap_Win32Dlg_WindowMore.h"
> # include "xap_Win32Dlg_About.h"
> @@ -97,6 +98,7 @@
> DeclareDialog(XAP_DIALOG_ID_FILE_EXPORT, XAP_Win32Dialog_FileOpenSaveAs)
> DeclareDialog(XAP_DIALOG_ID_INSERT_FILE, XAP_Win32Dialog_FileOpenSaveAs)
> DeclareDialog(XAP_DIALOG_ID_PRINT, XAP_Win32Dialog_Print)
> + DeclareDialog(XAP_DIALOG_ID_PRINTPREVIEW, XAP_Win32Dialog_PrintPreview)
> DeclareDialog(XAP_DIALOG_ID_PRINTTOFILE, XAP_Win32Dialog_FileOpenSaveAs)
> DeclareDialog(XAP_DIALOG_ID_RECORDTOFILE, XAP_Win32Dialog_FileOpenSaveAs)
> DeclareDialog(XAP_DIALOG_ID_REPLAYFROMFILE, XAP_Win32Dialog_FileOpenSaveAs)
>
> Modified: abiword/trunk/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h
> ===================================================================
> --- abiword/trunk/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -51,7 +51,7 @@
> #if !XP_SIMPLE_MENU
> Separator()
> MenuItem(AP_MENU_ID_FILE_PAGESETUP)
> -#ifdef XP_UNIX_TARGET_GTK
> +#if defined(XP_UNIX_TARGET_GTK) || defined (WIN32)
> MenuItem(AP_MENU_ID_FILE_PRINT_PREVIEW)
> #endif
> MenuItem(AP_MENU_ID_FILE_PRINT)
>
> Modified: abiword/trunk/src/wp/ap/xp/ap_TB_Layouts_FileEditOps.h
> ===================================================================
> --- abiword/trunk/src/wp/ap/xp/ap_TB_Layouts_FileEditOps.h 2008-03-01 15:10:28 UTC (rev 22980)
> +++ abiword/trunk/src/wp/ap/xp/ap_TB_Layouts_FileEditOps.h 2008-03-01 19:08:27 UTC (rev 22981)
> @@ -33,7 +33,7 @@
> ToolbarItem(AP_TOOLBAR_ID_FILE_OPEN)
> ToolbarItem(AP_TOOLBAR_ID_FILE_SAVE)
> Spacer()
> -#ifdef XP_UNIX_TARGET_GTK
> +#if defined(XP_UNIX_TARGET_GTK) || defined (WIN32)
> ToolbarItem(AP_TOOLBAR_ID_FILE_PRINT_PREVIEW)
> #endif
> ToolbarItem(AP_TOOLBAR_ID_FILE_PRINT)
>
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the word
> unsubscribe in the message body.
>

-- 
Counting bodies like sheep to the rhythm of the war drums.
Received on Sat Mar 1 20:36:39 2008

This archive was generated by hypermail 2.1.8 : Sat Mar 01 2008 - 20:36:39 CET