XFA: merge patch from CL 792953005, fix most warnings
authorBruce Dawson <brucedawson@google.com>
Thu, 8 Jan 2015 19:47:49 +0000 (11:47 -0800)
committerBruce Dawson <brucedawson@google.com>
Thu, 8 Jan 2015 19:47:49 +0000 (11:47 -0800)
Includes fixes to XFA specific warnings -- benign truncations.
Bug https://code.google.com/p/pdfium/issues/detail?id=104
was filed to track changing types to avoid some truncations.

Resolve all but two VC++ build warnings in pdfium.

pdfium builds on Win32 have about 85 warnings (250 in the XFA
branch, totaling over 480 lines!), mostly from four lines in
a header file and a warning that should be disabled. This
change resolves all but two of them and turns on
warning-as-errors. Bugs have been filed for the two
remaining warnings:
https://code.google.com/p/pdfium/issues/detail?id=100
the 64-bit warnings:
https://code.google.com/p/pdfium/issues/detail?id=101
and the Linux warnings:
https://code.google.com/p/pdfium/issues/detail?id=102

The fix to the double->float truncation bugs will also
improve code-generation.

R=bo_xu@foxitsoftware.com, tsepez@chromium.org

Review URL: https://codereview.chromium.org/792953005

BUG= https://code.google.com/p/pdfium/issues/detail?id=100

Review URL: https://codereview.chromium.org/834413002

build/standalone.gypi
core/src/fpdftext/fpdf_text_int.cpp
fpdfsdk/include/fsdk_mgr.h
fpdfsdk/src/fpdfformfill.cpp
fpdfsdk/src/fsdk_mgr.cpp
pdfium.gyp
xfa/src/fxfa/src/parser/xfa_localevalue.cpp

index d335f05..0d650a3 100644 (file)
       'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
       'CharacterSet': '1',
     },
+    'msvs_disabled_warnings': [4800, 4996],
     'msvs_settings': {
       'VCCLCompilerTool': {
         'MinimalRebuild': 'false',
         'EnableFunctionLevelLinking': 'true',
         'RuntimeTypeInfo': 'false',
         'WarningLevel': '3',
-        'WarnAsError': 'false',
         'DebugInformationFormat': '3',
         'Detect64BitPortabilityProblems': 'false',
         'conditions': [
           }, {
             'ExceptionHandling': '0',
           }],
+          ['target_arch=="x64"', {
+            # 64-bit warnings need to be resolved.
+            # https://code.google.com/p/pdfium/issues/detail?id=101
+            'WarnAsError': 'false',
+          }, {
+            'WarnAsError': 'true',
+          }],
         ],
       },
       'VCLibrarianTool': {
index c28647d..5ed0e01 100644 (file)
@@ -37,13 +37,13 @@ FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar)
 FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold)
 {
     if (threshold < 300) {
-        return threshold / 2.0;
+        return threshold / 2.0f;
     } else if (threshold < 500) {
-        return threshold / 4.0;
+        return threshold / 4.0f;
     } else if (threshold < 700) {
-        return threshold / 5.0;
+        return threshold / 5.0f;
     }
-    return threshold / 6.0;
+    return threshold / 6.0f;
 }
 
 FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj,
index cbe4741..357be3c 100644 (file)
@@ -476,10 +476,10 @@ public:
                        double bottom;
                        m_pInfo->FFI_GetPageViewRect(m_pInfo, page, &left, &top, &right, &bottom);
 
-                       dstRect.left = left;
-                       dstRect.top = top < bottom? bottom:top;
-                       dstRect.bottom = top < bottom? top:bottom;
-                       dstRect.right = right;
+                       dstRect.left = static_cast<float>(left);
+                       dstRect.top = static_cast<float>(top < bottom ? bottom : top);
+                       dstRect.bottom = static_cast<float>(top < bottom ? top : bottom);
+                       dstRect.right = static_cast<float>(right);
                }
        }
 
index 0fb3291..ea94925 100644 (file)
@@ -71,7 +71,8 @@ DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_
                        rcWidget.bottom -= 1.0f;
                        rcWidget.top += 1.0f;
 
-                       if (rcWidget.Contains(page_x, page_y)) {
+                       if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x),
+                               static_cast<FX_FLOAT>(page_y))) {
                                pWidgetIterator->Release();
                                return FPDF_FORMFIELD_XFA;
                        }
index c4cee6f..f134b79 100644 (file)
@@ -678,7 +678,10 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
                gs.Create(pDevice);
                if (pClip) {
                        CFX_RectF rectClip;
-                       rectClip.Set(pClip->left, pClip->top, pClip->Width(), pClip->Height());
+                       rectClip.Set(static_cast<FX_FLOAT>(pClip->left),
+                               static_cast<FX_FLOAT>(pClip->top),
+                               static_cast<FX_FLOAT>(pClip->Width()),
+                               static_cast<FX_FLOAT>(pClip->Height()));
                        gs.SetClipRect(rectClip);
                }       
                IXFA_RenderContext* pRenderContext = XFA_RenderContext_Create();
index 1f852d6..9476241 100644 (file)
       'include_dirs': [
       ],
       'ldflags': [ '-L<(PRODUCT_DIR)',],
+      'msvs_settings': {
+        'VCCLCompilerTool': {
+          # Unresolved warnings in fx_codec_jpx_opj.cpp
+          # https://code.google.com/p/pdfium/issues/detail?id=100
+          'WarnAsError': 'false',
+        },
+      },
       'sources': [
         'core/include/fxcodec/fx_codec.h',
         'core/include/fxcodec/fx_codec_def.h',
index 6d55def..46ea47d 100644 (file)
@@ -650,7 +650,7 @@ FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, CF
         return FALSE;\r
     }\r
     CFX_Unitime ut;\r
-    ut.Set(wYear, wMonth, wDay);\r
+    ut.Set(wYear, static_cast<FX_BYTE>(wMonth), static_cast<FX_BYTE>(wDay));\r
     unDate = unDate + ut;\r
     return TRUE;\r
 }\r