From cf2e4c3ecc2a66f0a01e6a1d8c20dcb73e4b8024 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 11 Jun 2015 14:00:52 -0700 Subject: Remove trailing whitespaces in fpdfsdk. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1173343004. --- fpdfsdk/src/fsdk_baseform.cpp | 358 +++++++++++++++++++++--------------------- 1 file changed, 179 insertions(+), 179 deletions(-) (limited to 'fpdfsdk/src/fsdk_baseform.cpp') diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index f18180bf71..59431ec13d 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -1,7 +1,7 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../third_party/base/nonstd_unique_ptr.h" @@ -15,7 +15,7 @@ #include "../include/javascript/IJavaScript.h" //------------------------------------------------------------------------------------ -//* CPDFSDK_Widget +//* CPDFSDK_Widget //------------------------------------------------------------------------------------ #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) @@ -41,7 +41,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode { CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); if (pAP == NULL) return FALSE; - + // Choose the right sub-ap const FX_CHAR* ap_entry = "N"; if (mode == CPDF_Annot::Down) @@ -50,11 +50,11 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode ap_entry = "R"; if (!pAP->KeyExist(ap_entry)) ap_entry = "N"; - + // Get the AP stream or subdirectory CPDF_Object* psub = pAP->GetElementValue(ap_entry); if (psub == NULL) return FALSE; - + int nFieldType = GetFieldType(); switch (nFieldType) { @@ -66,17 +66,17 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode return psub->GetType() == PDFOBJ_STREAM; case FIELDTYPE_CHECKBOX: case FIELDTYPE_RADIOBUTTON: - if (psub->GetType() == PDFOBJ_DICTIONARY) + if (psub->GetType() == PDFOBJ_DICTIONARY) { CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub; - + return pSubDict->GetStream(GetAppState()) != NULL; } else return FALSE; break; } - + return TRUE; } @@ -84,7 +84,7 @@ int CPDFSDK_Widget::GetFieldType() const { CPDF_FormField* pField = GetFormField(); ASSERT(pField != NULL); - + return pField->GetFieldType(); } @@ -101,7 +101,7 @@ int CPDFSDK_Widget::GetFieldFlags() const CFX_ByteString CPDFSDK_Widget::GetSubType() const { int nType = GetFieldType(); - + if (nType == FIELDTYPE_SIGNATURE) return BFFT_SIGNATURE; return CPDFSDK_Annot::GetSubType(); @@ -110,20 +110,20 @@ CFX_ByteString CPDFSDK_Widget::GetSubType() const CPDF_FormField* CPDFSDK_Widget::GetFormField() const { ASSERT(m_pInterForm != NULL); - - CPDF_FormControl* pCtrl = GetFormControl(); + + CPDF_FormControl* pCtrl = GetFormControl(); ASSERT(pCtrl != NULL); - + return pCtrl->GetField(); } CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { ASSERT(m_pInterForm != NULL); - + CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); ASSERT(pPDFInterForm != NULL); - + return pPDFInterForm->GetControlByDict(GetAnnotDict()); } static CPDF_Dictionary* BF_GetField(CPDF_Dictionary* pFieldDict, const FX_CHAR* name) @@ -132,11 +132,11 @@ static CPDF_Dictionary* BF_GetField(CPDF_Dictionary* pFieldDict, const FX_CHAR* // First check the dictionary itself CPDF_Object* pAttr = pFieldDict->GetElementValue(name); if (pAttr) return pFieldDict; - + // Now we need to search from parents CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); if (pParent == NULL) return NULL; - + return BF_GetField(pParent, name); } @@ -144,9 +144,9 @@ CPDF_FormControl* CPDFSDK_Widget::GetFormControl(CPDF_InterForm* pInterForm, CPD { ASSERT(pInterForm != NULL); ASSERT(pAnnotDict != NULL); - + CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict); - + return pControl; } @@ -154,7 +154,7 @@ int CPDFSDK_Widget::GetRotate() const { CPDF_FormControl* pCtrl = GetFormControl(); ASSERT(pCtrl != NULL); - + return pCtrl->GetRotation() % 360; } @@ -162,10 +162,10 @@ FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - - int iColorType = 0; + + int iColorType = 0; color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); - + return iColorType != COLORTYPE_TRANSPARENT; } @@ -173,10 +173,10 @@ FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - - int iColorType = 0; + + int iColorType = 0; color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); - + return iColorType != COLORTYPE_TRANSPARENT; } @@ -184,18 +184,18 @@ FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - + CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); if (da.HasColor()) { FX_ARGB argb; - int iColorType = COLORTYPE_TRANSPARENT; + int iColorType = COLORTYPE_TRANSPARENT; da.GetColor(argb, iColorType); color = FX_ARGBTOCOLORREF(argb); - + return iColorType != COLORTYPE_TRANSPARENT; } - + return FALSE; } @@ -203,12 +203,12 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - + CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); CFX_ByteString csFont = ""; FX_FLOAT fFontSize = 0.0f; pDa.GetFont(csFont, fFontSize); - + return fFontSize; } @@ -216,7 +216,7 @@ int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetSelectedIndex(nIndex); } @@ -224,7 +224,7 @@ CFX_WideString CPDFSDK_Widget::GetValue() const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetValue(); } @@ -232,7 +232,7 @@ CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetDefaultValue(); } @@ -240,7 +240,7 @@ CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetOptionLabel(nIndex); } @@ -248,7 +248,7 @@ int CPDFSDK_Widget::CountOptions() const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->CountOptions(); } @@ -256,7 +256,7 @@ FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->IsItemSelected(nIndex); } @@ -264,7 +264,7 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetTopVisibleIndex(); } @@ -272,7 +272,7 @@ FX_BOOL CPDFSDK_Widget::IsChecked() const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - + return pFormCtrl->IsChecked(); } @@ -280,7 +280,7 @@ int CPDFSDK_Widget::GetAlignment() const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - + return pFormCtrl->GetControlAlignment(); } @@ -288,7 +288,7 @@ int CPDFSDK_Widget::GetMaxLen() const { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + return pFormField->GetMaxLen(); } @@ -296,10 +296,10 @@ void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); - + CPDF_FormField* pFormField = pFormCtrl->GetField(); ASSERT(pFormField != NULL); - + pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify); } @@ -307,7 +307,7 @@ void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + pFormField->SetValue(sValue, bNotify); } @@ -318,7 +318,7 @@ void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bN { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + pFormField->SetItemSelection(index, bSelected, bNotify); } @@ -326,7 +326,7 @@ void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + pFormField->ClearSelection(bNotify); } @@ -360,7 +360,7 @@ void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChang m_nValueAge++; int nFieldType = GetFieldType(); - + switch (nFieldType) { case FIELDTYPE_PUSHBUTTON: @@ -382,7 +382,7 @@ void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChang ResetAppearance_TextField(sValue); break; } - + ASSERT(m_pAnnot != NULL); m_pAnnot->ClearCachedAP(); } @@ -398,7 +398,7 @@ void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + ASSERT(m_pInterForm != NULL); m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); @@ -408,21 +408,21 @@ void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions) { int nFieldType = GetFieldType(); - + if ((nFieldType == FIELDTYPE_CHECKBOX || nFieldType == FIELDTYPE_RADIOBUTTON) && - mode == CPDF_Annot::Normal && + mode == CPDF_Annot::Normal && !IsWidgetAppearanceValid(CPDF_Annot::Normal)) { CFX_PathData pathData; - + CPDF_Rect rcAnnot = GetRect(); - + pathData.AppendRect(rcAnnot.left, rcAnnot.bottom, rcAnnot.right, rcAnnot.top); - + CFX_GraphStateData gsd; gsd.m_LineWidth = 0.0f; - + pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, FXFILL_ALTERNATE); } else @@ -435,7 +435,7 @@ void CPDFSDK_Widget::UpdateField() { CPDF_FormField* pFormField = GetFormField(); ASSERT(pFormField != NULL); - + ASSERT(m_pInterForm != NULL); m_pInterForm->UpdateField(pFormField); } @@ -443,11 +443,11 @@ void CPDFSDK_Widget::UpdateField() void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView) { ASSERT(m_pInterForm != NULL); - + int nFieldType = GetFieldType(); if (m_pInterForm->IsNeedHighLight(nFieldType)) { - + // if (nFieldType != FIELDTYPE_PUSHBUTTON) // { CPDF_Rect rc = GetRect(); @@ -470,7 +470,7 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPa FX_ARGB argb = ArgbEncode((int)alpha, color); FX_RECT rcDev((int)rcDevice.left,(int)rcDevice.top,(int)rcDevice.right,(int)rcDevice.bottom); - pDevice->FillRect(&rcDev, argb); + pDevice->FillRect(&rcDev, argb); /* }*/ } } @@ -481,8 +481,8 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() ASSERT(pControl != NULL); - - CPDF_Rect rcWindow = GetRotatedRect(); + + CPDF_Rect rcWindow = GetRotatedRect(); int32_t nLayout = 0; @@ -550,12 +550,12 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() case BBS_UNDERLINE: nBorderStyle = PBS_UNDERLINED; break; - default: + default: nBorderStyle = PBS_SOLID; break; } - CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth); + CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth); CPWL_Color crText(COLORTYPE_GRAY,0); @@ -569,7 +569,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); } - if (da.HasFont()) + if (da.HasFont()) da.GetFont(csNameTag, fFontSize); CFX_WideString csWCaption; @@ -643,7 +643,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() FontMap.SetAPType("N"); - CFX_ByteString csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + + CFX_ByteString csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pNormalIcon, iconFit, csNormalCaption, crText, fFontSize, nLayout); @@ -654,7 +654,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode(); if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle) { - if (csRolloverCaption.IsEmpty() && !pRolloverIcon) + if (csRolloverCaption.IsEmpty() && !pRolloverIcon) { csRolloverCaption = csNormalCaption; pRolloverIcon = pNormalIcon; @@ -662,7 +662,7 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() FontMap.SetAPType("R"); - csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + + csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pRolloverIcon, iconFit, csRolloverCaption, crText, fFontSize, nLayout); @@ -690,11 +690,11 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() crRightBottom = CPWL_Color(COLORTYPE_GRAY,1); break; } - + FontMap.SetAPType("D"); - csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, CPWL_Utils::SubstractColor(crBackground,0.25f)) + - CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + + csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, CPWL_Utils::SubstractColor(crBackground,0.25f)) + + CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ? rcWindow : rcClient, &FontMap, pDownIcon, iconFit, csDownCaption, crText, fFontSize, nLayout); WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP); @@ -716,7 +716,7 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() CPWL_Color crBackground, crBorder, crText; - + int iColorType; FX_FLOAT fc[4]; @@ -754,7 +754,7 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() case BBS_UNDERLINE: nBorderStyle = PBS_UNDERLINED; break; - default: + default: nBorderStyle = PBS_SOLID; break; } @@ -777,7 +777,7 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() switch (csWCaption[0]) { case L'l': - nStyle = PCS_CIRCLE; + nStyle = PCS_CIRCLE; break; case L'8': nStyle = PCS_CROSS; @@ -821,7 +821,7 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() break; } - CFX_ByteString csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) + + CFX_ByteString csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) + CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); CFX_ByteString csAP_D_OFF = csAP_D_ON; @@ -844,11 +844,11 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() { CPDF_FormControl* pControl = GetFormControl(); ASSERT(pControl != NULL); - + CPWL_Color crBackground, crBorder, crText; - + int iColorType; FX_FLOAT fc[4]; @@ -886,7 +886,7 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() case BBS_UNDERLINE: nBorderStyle = PBS_UNDERLINED; break; - default: + default: nBorderStyle = PBS_SOLID; break; } @@ -909,7 +909,7 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() switch (csWCaption[0]) { default: //L'l': - nStyle = PCS_CIRCLE; + nStyle = PCS_CIRCLE; break; case L'8': nStyle = PCS_CROSS; @@ -936,7 +936,7 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() CFX_ByteString csAP_N_ON; CPDF_Rect rcCenter = CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f); - + if (nStyle == PCS_CIRCLE) { if (nBorderStyle == PBS_BEVELED) @@ -950,12 +950,12 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75f); } - csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBackground) + + csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBackground) + CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); } else { - csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) + + csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackground) + CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); } @@ -998,8 +998,8 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() } else { - csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) + - CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); + csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils::SubstractColor(crBackground,0.25f)) + + CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); } CFX_ByteString csAP_D_OFF = csAP_D_ON; @@ -1046,7 +1046,7 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) CPDF_Rect rcEdit = rcClient; rcEdit.right = rcButton.left; rcEdit.Normalize(); - + pEdit->SetPlateRect(rcEdit); pEdit->SetAlignmentV(1); @@ -1055,9 +1055,9 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) pEdit->SetAutoFontSize(TRUE); else pEdit->SetFontSize(fFontSize); - + pEdit->Initialize(); - + if (sValue) pEdit->SetText(sValue); else @@ -1079,11 +1079,11 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) if (rcContent.Width() > rcEdit.Width() || rcContent.Height() > rcEdit.Height()) { - sBody << rcEdit.left << " " << rcEdit.bottom << " " + sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; } - CPWL_Color crText = GetTextPWLColor(); + CPWL_Color crText = GetTextPWLColor(); sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n"; } @@ -1120,15 +1120,15 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() FontMap.Initial(); pEdit->SetFontMap(&FontMap); - pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f)); - + pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,0.0f)); + FX_FLOAT fFontSize = GetFontSize(); if (IsFloatZero(fFontSize)) pEdit->SetFontSize(12.0f); else pEdit->SetFontSize(fFontSize); - + pEdit->Initialize(); CFX_ByteTextBuf sList; @@ -1140,7 +1140,7 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() for (int32_t i=nTop; iGetSelectedIndex(j) == i) @@ -1161,22 +1161,22 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() sList << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),TRUE) << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n"; - sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1),TRUE) << + sList << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1),TRUE) << CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n"; } else { CPWL_Color crText = GetTextPWLColor(); - sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << + sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,fy)) << "ET\n"; } fy -= fItemHeight; } - + if (sList.GetSize() > 0) { - sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bottom << " " + sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " << rcClient.bottom << " " << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; sBody << sList << "Q\nEMC\n"; } @@ -1197,7 +1197,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) ASSERT(pField != NULL); CFX_ByteTextBuf sBody, sLines; - + if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) { pEdit->EnableRefresh(FALSE); @@ -1213,7 +1213,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) CPDF_Rect rcClient = GetClientRect(); pEdit->SetPlateRect(rcClient); pEdit->SetAlignmentH(pControl->GetControlAlignment()); - + FX_DWORD dwFieldFlags = pField->GetFieldFlags(); FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; @@ -1236,7 +1236,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) int nMaxLen = pField->GetMaxLen(); FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; - FX_FLOAT fFontSize = GetFontSize(); + FX_FLOAT fFontSize = GetFontSize(); if (nMaxLen > 0) { @@ -1252,7 +1252,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) else { if (sValue) - nMaxLen = wcslen((const wchar_t*)sValue); + nMaxLen = wcslen((const wchar_t*)sValue); pEdit->SetLimitChar(nMaxLen); } } @@ -1263,7 +1263,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) pEdit->SetFontSize(fFontSize); pEdit->Initialize(); - + if (sValue) pEdit->SetText(sValue); else @@ -1280,10 +1280,10 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) if (rcContent.Width() > rcClient.Width() || rcContent.Height() > rcClient.Height()) { - sBody << rcClient.left << " " << rcClient.bottom << " " + sBody << rcClient.left << " " << rcClient.bottom << " " << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; } - CPWL_Color crText = GetTextPWLColor(); + CPWL_Color crText = GetTextPWLColor(); sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n" << "Q\nEMC\n"; } @@ -1296,18 +1296,18 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE); if (sColor.GetLength() > 0) { - sLines << "q\n" << GetBorderWidth() << " w\n" - << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE) << " 2 J 0 j\n"; + sLines << "q\n" << GetBorderWidth() << " w\n" + << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(),FALSE) << " 2 J 0 j\n"; for (int32_t i=1;iGetRotation() % 360)) @@ -1543,7 +1543,7 @@ void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_St sImageAlias = pImageDict->GetString("Name"); if (sImageAlias.IsEmpty()) sImageAlias = "IMG"; - } + } CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); if (!pStreamResList) @@ -1576,13 +1576,13 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAc { CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); ASSERT(pDocument != NULL); - + CPDFDoc_Environment* pEnv = pDocument->GetEnv(); ASSERT(pEnv != NULL); CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();/*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/ ASSERT(pActionHandler != NULL); - + return pActionHandler->DoAction_Field(action, type, pDocument, GetFormField(), data); } @@ -1651,11 +1651,11 @@ FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) if(annotRect.Contains(pageX, pageY)) { if (!IsVisible()) return FALSE; - + int nFieldFlags = GetFieldFlags(); - if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) + if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FALSE; - + return TRUE; } return FALSE; @@ -1720,7 +1720,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL b CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { if(!pControl || !m_pInterForm) return NULL; - + CPDFSDK_Widget* pWidget = NULL; m_Map.Lookup(pControl, pWidget); @@ -1743,7 +1743,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const } } - if (!pPage) + if (!pPage) { int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); if (nPageIndex >= 0) @@ -1767,7 +1767,7 @@ void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArra CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName); ASSERT(pFormField != NULL); - GetWidgets(pFormField, widgets); + GetWidgets(pFormField, widgets); } } @@ -1795,7 +1795,7 @@ int CPDFSDK_InterForm::GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Di for (int i=0,sz=pDocument->GetPageCount(); iGetPage(i)) - { + { if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { for (int j=0,jsz=pAnnots->GetCount(); jNewContext(); ASSERT(pContext != NULL); - + CFX_WideString sOldValue = pField->GetValue(); CFX_WideString sValue = sOldValue; FX_BOOL bRC = TRUE; pContext->OnField_Calculate(pFormField, pField, sValue, bRC); - + CFX_WideString sInfo; FX_BOOL bRet = pContext->RunScript(csJS, sInfo); pRuntime->ReleaseContext(pContext); - + if (bRet) { if (bRC) @@ -1962,7 +1962,7 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) } } - + } m_bBusy = FALSE; @@ -1980,11 +1980,11 @@ CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, FX_BOOL& { bFormated = FALSE; return sValue; - } + } IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); ASSERT(pRuntime != NULL); - + pRuntime->SetReaderDocument(m_pDocument); if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) @@ -2000,11 +2000,11 @@ CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated = FALSE; CPDF_AAction aAction = pFormField->GetAdditionalAction(); - if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) + if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) { CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); if (action) - { + { CFX_WideString script = action.GetJavaScript(); if (!script.IsEmpty()) { @@ -2014,7 +2014,7 @@ CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, FX_BOOL& ASSERT(pContext != NULL); pContext->OnField_Format(pFormField, Value, TRUE); - + CFX_WideString sInfo; FX_BOOL bRet = pContext->RunScript(script, sInfo); pRuntime->ReleaseContext(pContext); @@ -2059,7 +2059,7 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { CPDFDoc_Environment * pEnv = m_pDocument->GetEnv(); CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); - + CPDF_Page * pPage = pWidget->GetPDFPage(); CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(pPage,FALSE); @@ -2075,24 +2075,24 @@ void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideSt ASSERT(pFormField != NULL); CPDF_AAction aAction = pFormField->GetAdditionalAction(); - if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) + if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) { CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); if (action) - { + { ASSERT(m_pDocument != NULL); CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); ASSERT(pEnv != NULL); CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); ASSERT(pActionHandler != NULL); - + PDFSDK_FieldAction fa; fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); fa.sValue = csValue; - pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, + pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, m_pDocument, pFormField, fa); bRC = fa.bRC; } @@ -2104,15 +2104,15 @@ void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c ASSERT(pFormField != NULL); CPDF_AAction aAction = pFormField->GetAdditionalAction(); - if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) + if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) { CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); if (action) - { + { ASSERT(m_pDocument != NULL); CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); ASSERT(pEnv != NULL); - + CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); ASSERT(pActionHandler != NULL); @@ -2123,7 +2123,7 @@ void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, m_pDocument, pFormField, fa); bRC = fa.bRC; - + } } } @@ -2144,13 +2144,13 @@ FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) FX_BOOL bHide = action.GetHideStatus(); FX_BOOL bChanged = FALSE; - + for (int i=0, sz=fields.GetSize(); iCountControls(); jGetControl(j); @@ -2175,7 +2175,7 @@ FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) CPDFSDK_PageView* pPageView = pWidget->GetPageView(); ASSERT(pPageView != NULL); - + pPageView->UpdateView(pWidget); bChanged = TRUE; @@ -2199,12 +2199,12 @@ FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { CPDF_ActionFields af = action.GetWidgets(); FX_DWORD dwFlags = action.GetFlags(); - + CFX_PtrArray fieldObjects; af.GetAllFields(fieldObjects); CFX_PtrArray fields; GetFieldFromObjects(fieldObjects, fields); - + if (fields.GetSize() != 0) { FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01); @@ -2246,7 +2246,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con uint8_t* pBuffer = textBuf.GetBuffer(); FX_STRSIZE nBufSize = textBuf.GetLength(); - + if (bUrlEncoded) { if(!FDFToURLEncodedData(pBuffer, nBufSize)) @@ -2254,7 +2254,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con } pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); - + return TRUE; } @@ -2263,18 +2263,18 @@ void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) ASSERT(m_pDocument != NULL); if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsigned char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength())) - { + { CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot(); if(pRootDic) { CPDF_Dictionary * pFDFDict=pRootDic->GetDict("FDF"); if(pFDFDict) - { + { CPDF_Dictionary * pJSDict = pFDFDict->GetDict("JavaScript"); if(pJSDict) { CFX_WideString csJS; - + CPDF_Object* pJS = pJSDict->GetElementValue("Before"); if (pJS != NULL) { @@ -2284,7 +2284,7 @@ void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) else if (iType == PDFOBJ_STREAM) csJS = pJS->GetUnicodeText(); } - + } } } @@ -2306,14 +2306,14 @@ FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufS { CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); if (pMainDict == NULL) return FALSE; - + // Get fields CPDF_Array* pFields = pMainDict->GetArray("Fields"); if (pFields == NULL) return FALSE; - + CFX_ByteTextBuf fdfEncodedData; - for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) + for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) { CPDF_Dictionary* pField = pFields->GetDict(i); if (pField == NULL) continue; @@ -2344,12 +2344,12 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F { ASSERT(m_pDocument != NULL); ASSERT(m_pInterForm != NULL); - + CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(CFX_PtrArray&)fields, bIncludeOrExclude); if (!pFDF) return FALSE; FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// delete pFDF; - + return bRet; } @@ -2368,7 +2368,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOO if(NULL == m_pDocument) return FALSE; CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); - + if(NULL == m_pInterForm) return FALSE; CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); if (NULL == pFDFDoc) return FALSE; @@ -2380,7 +2380,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOO uint8_t* pBuffer = FdfBuffer.GetBuffer(); FX_STRSIZE nBufSize = FdfBuffer.GetLength(); - + if (bUrlEncoded) { if(!FDFToURLEncodedData(pBuffer, nBufSize)) @@ -2388,11 +2388,11 @@ FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOO } pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); - + if (bUrlEncoded && pBuffer) { FX_Free(pBuffer); - pBuffer = NULL; + pBuffer = NULL; } return TRUE; @@ -2403,13 +2403,13 @@ FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) ASSERT(m_pInterForm != NULL); ASSERT(m_pDocument != NULL); - + CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); if (!pFDF) return FALSE; - + FX_BOOL bRet = pFDF->WriteBuf(textBuf); delete pFDF; - + return bRet; } @@ -2448,7 +2448,7 @@ void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr { CPDF_Object* pObject = (CPDF_Object*)objects[i]; if (pObject == NULL) continue; - + int iType = pObject->GetType(); if (iType == PDFOBJ_STRING) { @@ -2478,7 +2478,7 @@ int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_WideS { FX_BOOL bRC = TRUE; OnKeyStrokeCommit(pFormField, csValue, bRC); - if (bRC) + if (bRC) { OnValidate(pFormField, csValue, bRC); if (bRC) @@ -2526,7 +2526,7 @@ int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, CFX_W { FX_BOOL bRC = TRUE; OnKeyStrokeCommit(pFormField, csValue, bRC); - if (bRC) + if (bRC) { OnValidate(pFormField, csValue, bRC); if (bRC) @@ -2628,7 +2628,7 @@ void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) break; } } - + } FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) @@ -2681,7 +2681,7 @@ CPDFSDK_Annot* CBA_AnnotIterator::GetFirstAnnot() { if (m_Annots.GetSize() > 0) return m_Annots[0]; - + return NULL; } @@ -2769,7 +2769,7 @@ void CBA_AnnotIterator::GenerateResults() CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); ASSERT(pAnnot != NULL); - if (pAnnot->GetType() == m_sType + if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) m_Annots.Add(pAnnot); } @@ -2780,13 +2780,13 @@ void CBA_AnnotIterator::GenerateResults() CPDFSDK_SortAnnots sa; { - + for (int i=0,sz=m_pPageView->CountAnnots(); iGetAnnot(i); ASSERT(pAnnot != NULL); - if (pAnnot->GetType() == m_sType + if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) sa.Add(pAnnot); } @@ -2825,7 +2825,7 @@ void CBA_AnnotIterator::GenerateResults() ASSERT(pLeftTopAnnot != NULL); CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); - + m_Annots.Add(pLeftTopAnnot); sa.RemoveAt(nLeftTopIndex); @@ -2876,7 +2876,7 @@ void CBA_AnnotIterator::GenerateResults() CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); ASSERT(pAnnot != NULL); - if (pAnnot->GetType() == m_sType + if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) sa.Add(pAnnot); } @@ -2920,7 +2920,7 @@ void CBA_AnnotIterator::GenerateResults() ASSERT(pLeftTopAnnot != NULL); CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); - + m_Annots.Add(pLeftTopAnnot); sa.RemoveAt(nLeftTopIndex); -- cgit v1.2.3