1/* 2 * Copyright 2013 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#ifdef PDF_REPORT 9 10#include "SkPdfReporter.h" 11 12#include "SkTypes.h" 13 14const char* severityName[] = { 15"Info", 16"CodeWarning", 17"Warning", 18"IgnoreError", 19"Error", 20"FatalError", 21}; 22 23const char* getSeverityName(SkPdfIssueSeverity sev) { 24 if (0 <= sev && sev < _kCount__SkPdfIssueSeverity) { 25 return severityName[sev]; 26 } 27 SkASSERT(false); 28 return "UNKOWN SEVERITY"; 29} 30 31// TODO(edisonn): add a flag to set the minimum warning level 32// TODO(edisonn): get the address in the file, and report it. 33// TODO(edisonn): build a html file based on warnings which would showe the original pdf 34// content, with tooltips where warnings/errors were reported. 35 36 37void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue, 38 const char* context, 39 const SkPdfNativeObject* obj, 40 SkPdfContext* pdfContext) { 41 if (sev >= kIgnoreError_SkPdfIssueSeverity) { 42 printf("%s: %s\n", getSeverityName(sev), context); 43 } 44} 45 46void SkPdfReportIf(bool report, 47 SkPdfIssueSeverity sev, SkPdfIssue issue, 48 const char* context, 49 const SkPdfNativeObject* obj, 50 SkPdfContext* pdfContext) { 51 if (!report) { 52 return; 53 } 54 SkPdfReport(sev, issue, context, obj, pdfContext); 55} 56 57void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, 58 const char* context, 59 const SkPdfNativeObject* obj, 60 int anyOfTypes, SkPdfContext* pdfContext) { 61 if (sev >= kIgnoreError_SkPdfIssueSeverity) { 62 printf("%s: %s\n", getSeverityName(sev), context); 63 } 64} 65 66#endif // PDF_REPORT 67