From 086755c3ab56bd98232253c760d4e81ccd8701fb Mon Sep 17 00:00:00 2001 From: mathog <> Date: Thu, 18 Feb 2016 13:42:37 -0800 Subject: provide end user debugging for EMF and WMF issues (bzr r14660) --- src/extension/internal/emf-inout.cpp | 32 ++++++++++++++++++++++++++------ src/extension/internal/wmf-inout.cpp | 32 ++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 68b38f5ee..13520c40b 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -1617,6 +1617,17 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA uint32_t tbkMode = U_TRANSPARENT; // holds proposed change to bkMode, if text is involved saving these to the DC must wait until the text is written U_COLORREF tbkColor = U_RGB(255, 255, 255); // holds proposed change to bkColor + // code for end user debugging + int eDbgRecord=0; + int eDbgComment=0; + int eDbgFinal=0; + char const* eDbgString = getenv( "INKSCAPE_DBG_EMF" ); + if ( eDbgString != NULL ) { + if(strstr(eDbgString,"RECORD")){ eDbgRecord = 1; } + if(strstr(eDbgString,"COMMENT")){ eDbgComment = 1; } + if(strstr(eDbgString,"FINAL")){ eDbgFinal = 1; } + } + /* initialize the tsp for text reassembly */ tsp.string = NULL; tsp.ori = 0.0; /* degrees */ @@ -1659,8 +1670,11 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA lpEMFR = (PU_ENHMETARECORD)(contents + off); -// Uncomment the following to track down toxic records -// std::cout << "record type: " << iType << " name " << U_emr_names(iType) << " length: " << nSize << " offset: " << off <\n"; 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(); +// At run time define environment variable INKSCAPE_DBG_EMF to include string COMMENT. +// Users may employ this to to place a comment for each processed EMR record in the SVG + if(eDbgComment){ + 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; +// At run time define environment variable INKSCAPE_DBG_EMF to include string FINAL +// Users may employ this to to show the final SVG derived from the EMF + if(eDbgFinal){ + 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(file_status); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index d17180d91..b8b0c73de 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -1528,6 +1528,17 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK uint16_t tbkMode = U_TRANSPARENT; // holds proposed change to bkMode, if text is involved saving these to the DC must wait until the text is written U_COLORREF tbkColor = U_RGB(255, 255, 255); // holds proposed change to bkColor + // code for end user debugging + int wDbgRecord=0; + int wDbgComment=0; + int wDbgFinal=0; + char const* wDbgString = getenv( "INKSCAPE_DBG_WMF" ); + if ( wDbgString != NULL ) { + if(strstr(wDbgString,"RECORD")){ wDbgRecord = 1; } + if(strstr(wDbgString,"COMMENT")){ wDbgComment = 1; } + if(strstr(wDbgString,"FINAL")){ wDbgFinal = 1; } + } + /* initialize the tsp for text reassembly */ tsp.string = NULL; tsp.ori = 0.0; /* degrees */ @@ -1692,8 +1703,11 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK file_status = 0; break; } -// Uncomment the following to track down toxic records -// std::cout << "record type: " << (int) iType << " name " << U_wmr_names(iType) << " length: " << nSize << " offset: " << off <\n"; break; } //end of switch -// When testing, uncomment the following to place a comment for each processed WMR record in the SVG -// d->outsvg += dbg_str.str().c_str(); +// At run time define environment variable INKSCAPE_DBG_WMF to include string COMMENT. +// Users may employ this to to place a comment for each processed WMR record in the SVG + if(wDbgComment){ + d->outsvg += dbg_str.str().c_str(); + } d->path += tmp_path.str().c_str(); if(!nSize){ // There was some problem with the processing of this record, it is not safe to continue file_status = 0; @@ -3043,8 +3060,11 @@ std::cout << "BEFORE DRAW" } } //end of while on OK -// When testing, uncomment the following to show the final SVG derived from the WMF -// std::cout << d->outsvg << std::endl; +// At run time define environment variable INKSCAPE_DBG_WMF to include string FINAL +// Users may employ this to to show the final SVG derived from the WMF + if(wDbgFinal){ + std::cout << d->outsvg << std::endl; + } (void) U_wmr_properties(U_WMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant return(file_status); -- cgit v1.2.3