diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-14 06:23:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-14 06:23:48 -0700 |
commit | f2662c4a0bdfbe52d961ab4d2ff9a448323c3af9 (patch) | |
tree | 18cf6a6fdf1fd2dfcf39eef4fb99f5687cd0f720 | |
parent | 89f8fa8694bbf209412845c250af48bbc539962b (diff) | |
download | pdfium-f2662c4a0bdfbe52d961ab4d2ff9a448323c3af9.tar.xz |
Cleanup CPDFXFA_Document.
Remove unused params and methods. Cleanup formatting.
Review-Url: https://codereview.chromium.org/2322003002
-rw-r--r-- | core/fxcrt/include/fx_coordinates.h | 226 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp | 365 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h | 22 | ||||
-rw-r--r-- | fpdfsdk/include/cpdfdoc_environment.h | 4 | ||||
-rw-r--r-- | public/fpdf_formfill.h | 14 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffchoicelist.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffnotify.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftextedit.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/include/fxfa.h | 14 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 2 |
11 files changed, 298 insertions, 357 deletions
diff --git a/core/fxcrt/include/fx_coordinates.h b/core/fxcrt/include/fx_coordinates.h index bfdc46cbf2..a7c01cadb7 100644 --- a/core/fxcrt/include/fx_coordinates.h +++ b/core/fxcrt/include/fx_coordinates.h @@ -191,117 +191,6 @@ class CFX_FloatPoint { FX_FLOAT y; }; -class CFX_FloatRect { - public: - CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {} - CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t) - : left(l), bottom(b), right(r), top(t) {} - - explicit CFX_FloatRect(const FX_FLOAT* pArray) - : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {} - - explicit CFX_FloatRect(const FX_RECT& rect); - - void Normalize(); - - void Reset() { - left = 0.0f; - right = 0.0f; - bottom = 0.0f; - top = 0.0f; - } - - bool IsEmpty() const { return left >= right || bottom >= top; } - bool Contains(const CFX_FloatRect& other_rect) const; - bool Contains(FX_FLOAT x, FX_FLOAT y) const; - - void Transform(const CFX_Matrix* pMatrix); - void Intersect(const CFX_FloatRect& other_rect); - void Union(const CFX_FloatRect& other_rect); - - FX_RECT GetInnerRect() const; - FX_RECT GetOuterRect() const; - FX_RECT GetClosestRect() const; - - int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects); - - void InitRect(FX_FLOAT x, FX_FLOAT y) { - left = x; - right = x; - bottom = y; - top = y; - } - void UpdateRect(FX_FLOAT x, FX_FLOAT y); - - FX_FLOAT Width() const { return right - left; } - FX_FLOAT Height() const { return top - bottom; } - - void Inflate(FX_FLOAT x, FX_FLOAT y) { - Normalize(); - left -= x; - right += x; - bottom -= y; - top += y; - } - - void Inflate(FX_FLOAT other_left, - FX_FLOAT other_bottom, - FX_FLOAT other_right, - FX_FLOAT other_top) { - Normalize(); - left -= other_left; - bottom -= other_bottom; - right += other_right; - top += other_top; - } - - void Inflate(const CFX_FloatRect& rt) { - Inflate(rt.left, rt.bottom, rt.right, rt.top); - } - - void Deflate(FX_FLOAT x, FX_FLOAT y) { - Normalize(); - left += x; - right -= x; - bottom += y; - top -= y; - } - - void Deflate(FX_FLOAT other_left, - FX_FLOAT other_bottom, - FX_FLOAT other_right, - FX_FLOAT other_top) { - Normalize(); - left += other_left; - bottom += other_bottom; - right -= other_right; - top -= other_top; - } - - void Deflate(const CFX_FloatRect& rt) { - Deflate(rt.left, rt.bottom, rt.right, rt.top); - } - - void Translate(FX_FLOAT e, FX_FLOAT f) { - left += e; - right += e; - top += f; - bottom += f; - } - - static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints); - - FX_RECT ToFxRect() const { - return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top), - static_cast<int32_t>(right), static_cast<int32_t>(bottom)); - } - - FX_FLOAT left; - FX_FLOAT bottom; - FX_FLOAT right; - FX_FLOAT top; -}; - // LTWH rectangles (y-axis runs downwards). template <class baseType> class CFX_RTemplate { @@ -545,6 +434,121 @@ typedef CFX_RTemplate<int32_t> CFX_Rect; typedef CFX_RTemplate<FX_FLOAT> CFX_RectF; typedef CFX_ArrayTemplate<CFX_RectF> CFX_RectFArray; +class CFX_FloatRect { + public: + CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {} + CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t) + : left(l), bottom(b), right(r), top(t) {} + + explicit CFX_FloatRect(const FX_FLOAT* pArray) + : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {} + + explicit CFX_FloatRect(const FX_RECT& rect); + + void Normalize(); + + void Reset() { + left = 0.0f; + right = 0.0f; + bottom = 0.0f; + top = 0.0f; + } + + bool IsEmpty() const { return left >= right || bottom >= top; } + bool Contains(const CFX_FloatRect& other_rect) const; + bool Contains(FX_FLOAT x, FX_FLOAT y) const; + + void Transform(const CFX_Matrix* pMatrix); + void Intersect(const CFX_FloatRect& other_rect); + void Union(const CFX_FloatRect& other_rect); + + FX_RECT GetInnerRect() const; + FX_RECT GetOuterRect() const; + FX_RECT GetClosestRect() const; + + int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects); + + void InitRect(FX_FLOAT x, FX_FLOAT y) { + left = x; + right = x; + bottom = y; + top = y; + } + void UpdateRect(FX_FLOAT x, FX_FLOAT y); + + FX_FLOAT Width() const { return right - left; } + FX_FLOAT Height() const { return top - bottom; } + + void Inflate(FX_FLOAT x, FX_FLOAT y) { + Normalize(); + left -= x; + right += x; + bottom -= y; + top += y; + } + + void Inflate(FX_FLOAT other_left, + FX_FLOAT other_bottom, + FX_FLOAT other_right, + FX_FLOAT other_top) { + Normalize(); + left -= other_left; + bottom -= other_bottom; + right += other_right; + top += other_top; + } + + void Inflate(const CFX_FloatRect& rt) { + Inflate(rt.left, rt.bottom, rt.right, rt.top); + } + + void Deflate(FX_FLOAT x, FX_FLOAT y) { + Normalize(); + left += x; + right -= x; + bottom += y; + top -= y; + } + + void Deflate(FX_FLOAT other_left, + FX_FLOAT other_bottom, + FX_FLOAT other_right, + FX_FLOAT other_top) { + Normalize(); + left += other_left; + bottom += other_bottom; + right -= other_right; + top -= other_top; + } + + void Deflate(const CFX_FloatRect& rt) { + Deflate(rt.left, rt.bottom, rt.right, rt.top); + } + + void Translate(FX_FLOAT e, FX_FLOAT f) { + left += e; + right += e; + top += f; + bottom += f; + } + + static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints); + + FX_RECT ToFxRect() const { + return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top), + static_cast<int32_t>(right), static_cast<int32_t>(bottom)); + } + + static CFX_FloatRect FromCFXRectF(const CFX_RectF& rect) { + return CFX_FloatRect(rect.left, rect.top, rect.right(), rect.bottom()); + } + + FX_FLOAT left; + FX_FLOAT bottom; + FX_FLOAT right; + FX_FLOAT top; +}; + class CFX_Matrix { public: CFX_Matrix() { SetIdentity(); } diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index be83d3416e..57de222e1c 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -65,9 +65,8 @@ CPDFXFA_Document::~CPDFXFA_Document() { CXFA_FFApp* pApp = m_pApp->GetXFAApp(); if (pApp) { CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); - if (pDocHandler) { + if (pDocHandler) CloseXFADoc(pDocHandler); - } } m_pXFADoc.reset(); } @@ -220,18 +219,9 @@ CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( return m_pSDKDoc.get(); } -void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, - CFX_FloatRect& pdfRect) { - pdfRect.left = fxRectF.left; - pdfRect.top = fxRectF.bottom(); - pdfRect.right = fxRectF.right(); - pdfRect.bottom = fxRectF.top; -} - void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { - if (hDoc == m_pXFADoc.get() && m_pSDKDoc) { + if (hDoc == m_pXFADoc.get() && m_pSDKDoc) m_pSDKDoc->SetChangeMark(); - } } void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, @@ -243,9 +233,6 @@ void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, if (m_iDocType != DOCTYPE_DYNAMIC_XFA) return; - CFX_FloatRect rcPage; - FXRect2PDFRect(rt, rcPage); - CPDFXFA_Page* pPage = GetPage(pPageView); if (!pPage) return; @@ -254,6 +241,7 @@ void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, if (!pEnv) return; + CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, rcPage.right, rcPage.top); } @@ -279,13 +267,11 @@ void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, if (!pPage) return; - CFX_FloatRect rcCaret; - FXRect2PDFRect(*pRtAnchor, rcCaret); - CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return; + CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, rcCaret.right, rcCaret.bottom); } @@ -311,60 +297,49 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return FALSE; + FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; pEnv->FFI_GetPageViewRect(pPage, pageViewRect); - CFX_FloatRect rcAnchor; - rcAnchor.left = rtAnchor.left; - rcAnchor.top = rtAnchor.bottom(); - rcAnchor.right = rtAnchor.right(); - rcAnchor.bottom = rtAnchor.top; - - int t1, t2, t; - uint32_t dwPos; - FX_FLOAT fPoupHeight; + int t1; + int t2; + CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); switch (nRotate) { case 90: { t1 = (int)(pageViewRect.right - rcAnchor.right); t2 = (int)(rcAnchor.left - pageViewRect.left); - if (rcAnchor.bottom < pageViewRect.bottom) { + if (rcAnchor.bottom < pageViewRect.bottom) rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; - } - break; } - case 180: { t2 = (int)(pageViewRect.top - rcAnchor.top); t1 = (int)(rcAnchor.bottom - pageViewRect.bottom); - if (rcAnchor.left < pageViewRect.left) { + if (rcAnchor.left < pageViewRect.left) rtPopup.left += rcAnchor.left - pageViewRect.left; - } break; } case 270: { t1 = (int)(rcAnchor.left - pageViewRect.left); t2 = (int)(pageViewRect.right - rcAnchor.right); - - if (rcAnchor.top > pageViewRect.top) { + if (rcAnchor.top > pageViewRect.top) rtPopup.left -= rcAnchor.top - pageViewRect.top; - } break; } case 0: default: { t1 = (int)(pageViewRect.top - rcAnchor.top); t2 = (int)(rcAnchor.bottom - pageViewRect.bottom); - if (rcAnchor.right > pageViewRect.right) { + if (rcAnchor.right > pageViewRect.right) rtPopup.left -= rcAnchor.right - pageViewRect.right; - } break; } } - if (t1 <= 0 && t2 <= 0) { + int t; + uint32_t dwPos; + if (t1 <= 0 && t2 <= 0) return FALSE; - } if (t1 <= 0) { t = t2; dwPos = 1; @@ -378,23 +353,24 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, t = t2; dwPos = 1; } - if (t < fMinPopup) { - fPoupHeight = fMinPopup; - } else if (t > fMaxPopup) { - fPoupHeight = fMaxPopup; - } else { - fPoupHeight = (FX_FLOAT)t; - } + + FX_FLOAT fPopupHeight; + if (t < fMinPopup) + fPopupHeight = fMinPopup; + else if (t > fMaxPopup) + fPopupHeight = fMaxPopup; + else + fPopupHeight = static_cast<FX_FLOAT>(t); switch (nRotate) { case 0: case 180: { if (dwPos == 0) { rtPopup.top = rtAnchor.height; - rtPopup.height = fPoupHeight; + rtPopup.height = fPopupHeight; } else { - rtPopup.top = -fPoupHeight; - rtPopup.height = fPoupHeight; + rtPopup.top = -fPopupHeight; + rtPopup.height = fPopupHeight; } break; } @@ -402,10 +378,10 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, case 270: { if (dwPos == 0) { rtPopup.top = rtAnchor.width; - rtPopup.height = fPoupHeight; + rtPopup.height = fPopupHeight; } else { - rtPopup.top = -fPoupHeight; - rtPopup.height = fPoupHeight; + rtPopup.top = -fPopupHeight; + rtPopup.height = fPopupHeight; } break; } @@ -417,8 +393,7 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, } FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, - CFX_PointF ptPopup, - const CFX_RectF* pRectExclude) { + CFX_PointF ptPopup) { if (!hWidget) return FALSE; @@ -430,24 +405,25 @@ FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, if (!pPage) return FALSE; - int menuFlag = 0; + CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); + if (!pEnv) + return FALSE; + int menuFlag = 0; if (hWidget->CanUndo()) - menuFlag |= FXFA_MEMU_UNDO; + menuFlag |= FXFA_MENU_UNDO; if (hWidget->CanRedo()) - menuFlag |= FXFA_MEMU_REDO; + menuFlag |= FXFA_MENU_REDO; if (hWidget->CanPaste()) - menuFlag |= FXFA_MEMU_PASTE; + menuFlag |= FXFA_MENU_PASTE; if (hWidget->CanCopy()) - menuFlag |= FXFA_MEMU_COPY; + menuFlag |= FXFA_MENU_COPY; if (hWidget->CanCut()) - menuFlag |= FXFA_MEMU_CUT; + menuFlag |= FXFA_MENU_CUT; if (hWidget->CanSelectAll()) - menuFlag |= FXFA_MEMU_SELECTALL; + menuFlag |= FXFA_MENU_SELECTALL; - CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - return pEnv && - pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); + return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); } void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, @@ -456,32 +432,34 @@ void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, if (!pEnv) return; - if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING && - m_nLoadStatus != FXFA_LOADSTATUS_CLOSING && - XFA_PAGEVIEWEVENT_StopLayout == dwFlags) { - int nNewCount = GetPageCount(); - if (nNewCount == m_nPageCount) - return; + if (m_nLoadStatus == FXFA_LOADSTATUS_LOADING || + m_nLoadStatus == FXFA_LOADSTATUS_CLOSING || + XFA_PAGEVIEWEVENT_StopLayout != dwFlags) + return; - CXFA_FFDocView* pXFADocView = GetXFADocView(); - if (!pXFADocView) - return; - for (int iPageIter = 0; iPageIter < m_nPageCount; iPageIter++) { - CPDFXFA_Page* pPage = m_XFAPageList.GetAt(iPageIter); - if (!pPage) - continue; - m_pSDKDoc->RemovePageView(pPage); - CXFA_FFPageView* pXFAPageView = pXFADocView->GetPageView(iPageIter); - pPage->SetXFAPageView(pXFAPageView); - } + int nNewCount = GetPageCount(); + if (nNewCount == m_nPageCount) + return; + + CXFA_FFDocView* pXFADocView = GetXFADocView(); + if (!pXFADocView) + return; - int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED - : FXFA_PAGEVIEWEVENT_POSTADDED; - int count = FXSYS_abs(nNewCount - m_nPageCount); - m_nPageCount = nNewCount; - m_XFAPageList.SetSize(nNewCount); - pEnv->FFI_PageEvent(count, flag); + for (int iPageIter = 0; iPageIter < m_nPageCount; iPageIter++) { + CPDFXFA_Page* pPage = m_XFAPageList.GetAt(iPageIter); + if (!pPage) + continue; + + m_pSDKDoc->RemovePageView(pPage); + pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); } + + int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED + : FXFA_PAGEVIEWEVENT_POSTADDED; + int count = FXSYS_abs(nNewCount - m_nPageCount); + m_nPageCount = nNewCount; + m_XFAPageList.SetSize(nNewCount); + pEnv->FFI_PageEvent(count, flag); } void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget, @@ -543,6 +521,7 @@ void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { iCurPage >= m_pSDKDoc->GetPageCount()) { return; } + CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return; @@ -554,7 +533,6 @@ FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { return FALSE; if (m_pSDKDoc->GetInterForm()) return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); - return FALSE; } @@ -606,14 +584,15 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, if (wsFilePath.IsEmpty()) { if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) return; + CFX_WideString filepath = pEnv->JS_fieldBrowse(); bs = filepath.UTF16LE_Encode(); } - int len = bs.GetLength() / sizeof(unsigned short); - FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( - bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, - (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); - bs.ReleaseBuffer(len * sizeof(unsigned short)); + int len = bs.GetLength(); + FPDF_FILEHANDLER* pFileHandler = + pEnv->FFI_OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, + (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); + bs.ReleaseBuffer(len); if (!pFileHandler) return; @@ -628,12 +607,15 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, } else if (fileType == FXFA_SAVEAS_XDP) { if (!m_pPDFDoc) return; + CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); if (!pRoot) return; + CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); if (!pAcroForm) return; + CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); if (!pArray) return; @@ -646,32 +628,35 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, continue; if (!pPDFObj->IsReference()) continue; + CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); if (!pStream) continue; if (pPrePDFObj->GetString() == "form") { m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite, nullptr); - } else if (pPrePDFObj->GetString() == "datasets") { + continue; + } + if (pPrePDFObj->GetString() == "datasets") { m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite, nullptr); - } else { - if (i == size - 1) { - CFX_WideString wPath = CFX_WideString::FromUTF16LE( - reinterpret_cast<const unsigned short*>(bs.c_str()), - bs.GetLength() / sizeof(unsigned short)); - CFX_ByteString bPath = wPath.UTF8Encode(); - const char* szFormat = - "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; - content.Format(szFormat, bPath.c_str()); - fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), - content.GetLength()); - } - std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); - pAcc->LoadAllData(pStream); - fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), - pAcc->GetSize()); + continue; } + if (i == size - 1) { + CFX_WideString wPath = CFX_WideString::FromUTF16LE( + reinterpret_cast<const unsigned short*>(bs.c_str()), + bs.GetLength() / sizeof(unsigned short)); + CFX_ByteString bPath = wPath.UTF8Encode(); + const char* szFormat = + "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; + content.Format(szFormat, bPath.c_str()); + fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), + content.GetLength()); + } + std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); + pAcc->LoadAllData(pStream); + fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), + pAcc->GetSize()); } } if (!fileWrite.Flush()) { @@ -702,7 +687,6 @@ FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { return FALSE; if (m_pSDKDoc->GetInterForm()) return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); - return TRUE; } @@ -729,6 +713,7 @@ void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); if (!pPageView) continue; + CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); if (pAnnot) { m_pSDKDoc->SetFocusAnnot(pAnnot); @@ -759,29 +744,16 @@ void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, dwOptions & XFA_PRINTOPT_PrintAnnot); } -void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { - if (hDoc != m_pXFADoc.get()) - return; - - CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (!pEnv) - return; - - pEnv->FFI_GetURL(this, wsDocURL); -} - FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { - if (hDoc != m_pXFADoc.get()) + if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) return 0; - if (m_pSDKDoc) { - if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { - FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); - uint8_t alpha = pInterForm->GetHighlightAlpha(); - FX_ARGB argb = ArgbEncode((int)alpha, color); - return argb; - } - } - return 0; + + CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm(); + if (!pInterForm) + return 0; + + return ArgbEncode(pInterForm->GetHighlightAlpha(), + pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); } FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { @@ -813,29 +785,31 @@ FX_BOOL CPDFXFA_Document::OnBeforeNotifySubmit() { } pWidgetAccIterator.reset(m_pXFADocView->CreateWidgetAccIterator()); - if (pWidgetAccIterator) { - CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); - pWidgetAcc = pWidgetAccIterator->MoveToNext(); - while (pWidgetAcc) { - int fRet = pWidgetAcc->ProcessValidate(-1); - if (fRet == XFA_EVENTERROR_Error) { - CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (!pEnv) - return FALSE; - CFX_WideString ws; - ws.FromLocal(IDS_XFA_Validate_Input); - CFX_ByteString bs = ws.UTF16LE_Encode(); - int len = bs.GetLength() / sizeof(unsigned short); - pEnv->FFI_Alert( - (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), - (FPDF_WIDESTRING)L"", 0, 1); - bs.ReleaseBuffer(len * sizeof(unsigned short)); + if (!pWidgetAccIterator) + return TRUE; + + CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); + pWidgetAcc = pWidgetAccIterator->MoveToNext(); + while (pWidgetAcc) { + int fRet = pWidgetAcc->ProcessValidate(-1); + if (fRet == XFA_EVENTERROR_Error) { + CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); + if (!pEnv) return FALSE; - } - pWidgetAcc = pWidgetAccIterator->MoveToNext(); + + CFX_WideString ws; + ws.FromLocal(IDS_XFA_Validate_Input); + CFX_ByteString bs = ws.UTF16LE_Encode(); + int len = bs.GetLength(); + pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", + 0, 1); + bs.ReleaseBuffer(len); + return FALSE; } - m_pXFADocView->UpdateDocView(); + pWidgetAcc = pWidgetAccIterator->MoveToNext(); } + m_pXFADocView->UpdateDocView(); + return TRUE; } @@ -868,8 +842,8 @@ void CPDFXFA_Document::OnAfterNotifySubmit() { FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { if (!NotifySubmit(TRUE) || !m_pXFADocView) return FALSE; - m_pXFADocView->UpdateDocView(); + m_pXFADocView->UpdateDocView(); FX_BOOL ret = SubmitDataInternal(hDoc, submit); NotifySubmit(FALSE); return ret; @@ -880,11 +854,12 @@ IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return FALSE; + CFX_ByteString bs = wsLink.UTF16LE_Encode(); - int len = bs.GetLength() / sizeof(unsigned short); - FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( - 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); - bs.ReleaseBuffer(len * sizeof(unsigned short)); + int len = bs.GetLength(); + FPDF_FILEHANDLER* pFileHandler = + pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); + bs.ReleaseBuffer(len); if (!pFileHandler) return nullptr; @@ -904,7 +879,6 @@ FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, return FALSE; CFPDF_FileStream fileStream(pFileHandler); - if (fileType == FXFA_SAVEAS_XML) { const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; fileStream.WriteBlock(kContent, 0, strlen(kContent)); @@ -923,16 +897,19 @@ FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, fileStream.Flush(); return FALSE; } + CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); if (!pRoot) { fileStream.Flush(); return FALSE; } + CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); if (!pAcroForm) { fileStream.Flush(); return FALSE; } + CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); if (!pArray) { fileStream.Flush(); @@ -947,6 +924,7 @@ FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, continue; if (!pPDFObj->IsReference()) continue; + CPDF_Object* pDirectObj = pPDFObj->GetDirect(); if (!pDirectObj->IsStream()) continue; @@ -996,9 +974,10 @@ void CPDFXFA_Document::ToXFAContentFlags(CFX_WideString csSrcContent, flag |= FXFA_XFDF; if (csSrcContent.Find(L" form ", 0) != -1) flag |= FXFA_FORM; - if (flag == 0) + if (flag == 0) { flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; + } } FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, @@ -1009,8 +988,9 @@ FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, CFX_WideString& csMsg) { CFX_WideString srcURL = csURL; srcURL.TrimLeft(); - if (0 != srcURL.Left(7).CompareNoCase(L"mailto:")) + if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0) return FALSE; + int pos = srcURL.Find(L'?', 0); CFX_WideString tmp; if (pos == -1) { @@ -1019,14 +999,12 @@ FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, return FALSE; tmp = srcURL.Right(csURL.GetLength() - 7); - tmp.TrimLeft(); - tmp.TrimRight(); } else { tmp = srcURL.Left(pos); tmp = tmp.Right(tmp.GetLength() - 7); - tmp.TrimLeft(); - tmp.TrimRight(); } + tmp.TrimLeft(); + tmp.TrimRight(); csToAddress = tmp; @@ -1035,38 +1013,31 @@ FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, srcURL.TrimLeft(); srcURL.TrimRight(); pos = srcURL.Find(L'&', 0); - if (pos == -1) - tmp = srcURL; - else - tmp = srcURL.Left(pos); + tmp = (pos == -1) ? srcURL : srcURL.Left(pos); tmp.TrimLeft(); tmp.TrimRight(); - if (tmp.GetLength() >= 3 && 0 == tmp.Left(3).CompareNoCase(L"cc=")) { + if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) { tmp = tmp.Right(tmp.GetLength() - 3); if (!csCCAddress.IsEmpty()) csCCAddress += L';'; csCCAddress += tmp; - } else if (tmp.GetLength() >= 4 && - 0 == tmp.Left(4).CompareNoCase(L"bcc=")) { + tmp.Left(4).CompareNoCase(L"bcc=") == 0) { tmp = tmp.Right(tmp.GetLength() - 4); if (!csBCCAddress.IsEmpty()) csBCCAddress += L';'; csBCCAddress += tmp; } else if (tmp.GetLength() >= 8 && - 0 == tmp.Left(8).CompareNoCase(L"subject=")) { + tmp.Left(8).CompareNoCase(L"subject=") == 0) { tmp = tmp.Right(tmp.GetLength() - 8); csSubject += tmp; } else if (tmp.GetLength() >= 5 && - 0 == tmp.Left(5).CompareNoCase(L"body=")) { + tmp.Left(5).CompareNoCase(L"body=") == 0) { tmp = tmp.Right(tmp.GetLength() - 5); csMsg += tmp; } - if (pos == -1) - srcURL = L""; - else - srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); + srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); } csToAddress.Replace(L",", L";"); csCCAddress.Replace(L",", L";"); @@ -1079,6 +1050,7 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); if (!pEnv) return FALSE; + CFX_WideStringC csURLC; submit.GetSubmitTarget(csURLC); CFX_WideString csURL(csURLC); @@ -1086,12 +1058,13 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, CFX_WideString ws; ws.FromLocal("Submit cancelled."); CFX_ByteString bs = ws.UTF16LE_Encode(); - int len = bs.GetLength() / sizeof(unsigned short); - pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), - (FPDF_WIDESTRING)L"", 0, 4); - bs.ReleaseBuffer(len * sizeof(unsigned short)); + int len = bs.GetLength(); + pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, + 4); + bs.ReleaseBuffer(len); return FALSE; } + FPDF_BOOL bRet = TRUE; FPDF_FILEHANDLER* pFileHandler = nullptr; int fileFlag = -1; @@ -1109,6 +1082,7 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, FPDF_DWORD flag = 0; if (submit.IsSubmitEmbedPDF()) flag |= FXFA_PDF; + ToXFAContentFlags(csContent, flag); pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); fileFlag = FXFA_SAVEAS_XDP; @@ -1132,7 +1106,7 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, } if (!pFileHandler) return FALSE; - if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { + if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { CFX_WideString csToAddress; CFX_WideString csCCAddress; CFX_WideString csBCCAddress; @@ -1142,6 +1116,7 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, csMsg); if (!bRet) return FALSE; + CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); @@ -1163,11 +1138,10 @@ FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, // HTTP or FTP CFX_WideString ws; CFX_ByteString bs = csURL.UTF16LE_Encode(); - int len = bs.GetLength() / sizeof(unsigned short); - pEnv->FFI_UploadTo( - pFileHandler, fileFlag, - (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); - bs.ReleaseBuffer(len * sizeof(unsigned short)); + int len = bs.GetLength(); + pEnv->FFI_UploadTo(pFileHandler, fileFlag, + (FPDF_WIDESTRING)bs.GetBuffer(len)); + bs.ReleaseBuffer(len); } return bRet; } @@ -1183,22 +1157,7 @@ FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, pValue); return FALSE; } -FX_BOOL CPDFXFA_Document::GetPDFScriptObject(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& utf8Name, - CFXJSE_Value* pValue) { - if (hDoc != m_pXFADoc.get()) - return FALSE; - - if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) - return FALSE; - if (!m_pJSContext) { - m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); - m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); - } - - return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(utf8Name, pValue); -} FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) { diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h index c3abeb2247..31f3706b72 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h @@ -32,14 +32,12 @@ class CPDFXFA_Document : public IXFA_DocProvider { ~CPDFXFA_Document() override; FX_BOOL LoadXFADoc(); - CPDFXFA_App* GetApp() { return m_pApp; } CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } int GetPageCount(); CPDFXFA_Page* GetPage(int page_index); - CPDFXFA_Page* GetPage(CXFA_FFPageView* pPage); void DeletePage(int page_index); void RemovePage(CPDFXFA_Page* page); @@ -47,14 +45,12 @@ class CPDFXFA_Document : public IXFA_DocProvider { CPDFSDK_Document* GetSDKDocument(CPDFDoc_Environment* pFormFillEnv); - void FXRect2PDFRect(const CFX_RectF& fxRectF, CFX_FloatRect& pdfRect); - // IXFA_DocProvider void SetChangeMark(CXFA_FFDoc* hDoc) override; // used in dynamic xfa, dwFlags refer to XFA_INVALIDATE_XXX macros. void InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt, - uint32_t dwFlags = 0) override; + uint32_t dwFlags) override; // show or hide caret void DisplayCaret(CXFA_FFWidget* hWidget, FX_BOOL bVisible, @@ -65,9 +61,7 @@ class CPDFXFA_Document : public IXFA_DocProvider { FX_FLOAT fMaxPopup, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) override; - FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, - CFX_PointF ptPopup, - const CFX_RectF* pRectExclude = nullptr) override; + FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) override; // dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) override; @@ -86,10 +80,10 @@ class CPDFXFA_Document : public IXFA_DocProvider { void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) override; void ExportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath, - FX_BOOL bXDP = TRUE) override; + FX_BOOL bXDP) override; void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL, - FX_BOOL bAppend = TRUE) override; + FX_BOOL bAppend) override; FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) override; void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) override; void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) override; @@ -97,8 +91,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { int32_t nStartPage, int32_t nEndPage, uint32_t dwOptions) override; - // Get document path - void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) override; FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) override; /** @@ -115,11 +107,6 @@ class CPDFXFA_Document : public IXFA_DocProvider { */ FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) override; - // Get PDF javascript object, set the object to pValue. - FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& utf8Name, - CFXJSE_Value* pValue) override; - FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) override; @@ -149,6 +136,7 @@ class CPDFXFA_Document : public IXFA_DocProvider { } } + CPDFXFA_Page* GetPage(CXFA_FFPageView* pPage); FX_BOOL OnBeforeNotifySubmit(); void OnAfterNotifySubmit(); FX_BOOL NotifySubmit(FX_BOOL bPrevOrPost); diff --git a/fpdfsdk/include/cpdfdoc_environment.h b/fpdfsdk/include/cpdfdoc_environment.h index f6211d264c..2d29e11a92 100644 --- a/fpdfsdk/include/cpdfdoc_environment.h +++ b/fpdfsdk/include/cpdfdoc_environment.h @@ -202,10 +202,6 @@ class CPDFDoc_Environment final { } } - void FFI_GetURL(FPDF_DOCUMENT document, CFX_WideString& wsURL) { - wsURL = CFX_WideString(); - } - void FFI_GetPageViewRect(FPDF_PAGE page, FS_RECTF& dstRect) { if (m_pInfo && m_pInfo->FFI_GetPageViewRect) { double left; diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h index 09674b007c..d6fddf19bd 100644 --- a/public/fpdf_formfill.h +++ b/public/fpdf_formfill.h @@ -356,12 +356,12 @@ typedef struct _FPDF_SYSTEMTIME { * @name Macro Definitions for Right Context Menu Features Of XFA Fields */ /*@{*/ -#define FXFA_MEMU_COPY 1 -#define FXFA_MEMU_CUT 2 -#define FXFA_MEMU_SELECTALL 4 -#define FXFA_MEMU_UNDO 8 -#define FXFA_MEMU_REDO 16 -#define FXFA_MEMU_PASTE 32 +#define FXFA_MENU_COPY 1 +#define FXFA_MENU_CUT 2 +#define FXFA_MENU_SELECTALL 4 +#define FXFA_MENU_UNDO 8 +#define FXFA_MENU_REDO 16 +#define FXFA_MENU_PASTE 32 /*@}*/ // file type @@ -870,7 +870,7 @@ typedef struct _FPDF_FORMFILLINFO { *function. * hWidget - Handle to XFA fields. * menuFlag - The menu flags. Please refer to macro definition - *of FXFA_MEMU_XXX and this can be one or a combination of these macros. + *of FXFA_MENU_XXX and this can be one or a combination of these macros. * x - X position of the client area in PDF page *coordinate. * y - Y position of the client area in PDF page diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index da778ff0ad..e6cb1090ad 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -287,7 +287,7 @@ FX_BOOL CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) return FALSE; - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); + GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy)); return TRUE; } FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 3609e55cba..0efdef6db1 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -560,7 +560,7 @@ void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, void CXFA_FFDocView::RunInvalidate() { for (const auto& pair : m_mapPageInvalidate) - m_pDoc->GetDocProvider()->InvalidateRect(pair.first, *pair.second); + m_pDoc->GetDocProvider()->InvalidateRect(pair.first, *pair.second, 0); m_mapPageInvalidate.clear(); } diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h index 07e5419842..ef34afb7b8 100644 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ b/xfa/fxfa/app/xfa_ffnotify.h @@ -70,7 +70,7 @@ class CXFA_FFNotify { CXFA_Node* GetFocusWidgetNode(); void SetFocusWidgetNode(CXFA_Node* pNode); - protected: + private: CXFA_FFDoc* const m_pDoc; }; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index bd92a45e4c..8418da4a81 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -146,7 +146,7 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) return FALSE; - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); + GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy)); return TRUE; } FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 2ee19eee8a..e7579e23fd 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -298,7 +298,7 @@ class IXFA_DocProvider { virtual void SetChangeMark(CXFA_FFDoc* hDoc) = 0; virtual void InvalidateRect(CXFA_FFPageView* pPageView, const CFX_RectF& rt, - uint32_t dwFlags = 0) = 0; + uint32_t dwFlags) = 0; virtual void DisplayCaret(CXFA_FFWidget* hWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor) = 0; @@ -307,9 +307,7 @@ class IXFA_DocProvider { FX_FLOAT fMaxPopup, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) = 0; - virtual FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, - CFX_PointF ptPopup, - const CFX_RectF* pRectExclude = nullptr) = 0; + virtual FX_BOOL PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) = 0; virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) = 0; virtual void WidgetPostAdd(CXFA_FFWidget* hWidget, CXFA_WidgetAcc* pWidgetData) = 0; @@ -325,10 +323,10 @@ class IXFA_DocProvider { virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) = 0; virtual void ExportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath, - FX_BOOL bXDP = TRUE) = 0; + FX_BOOL bXDP) = 0; virtual void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL, - FX_BOOL bAppend = TRUE) = 0; + FX_BOOL bAppend) = 0; virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) = 0; virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) = 0; virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) = 0; @@ -336,13 +334,9 @@ class IXFA_DocProvider { int32_t nStartPage, int32_t nEndPage, uint32_t dwOptions) = 0; - virtual void GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) = 0; virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0; virtual FX_BOOL SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) = 0; - virtual FX_BOOL GetPDFScriptObject(CXFA_FFDoc* hDoc, - const CFX_ByteStringC& utf8Name, - CFXJSE_Value* pValue) = 0; virtual FX_BOOL GetGlobalProperty(CXFA_FFDoc* hDoc, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) = 0; diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index cee99e8a3b..15f175cd49 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -238,7 +238,7 @@ void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { CFX_ByteString bsURL = pArguments->GetUTF8String(0); wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC()); } - pNotify->GetDocProvider()->GotoURL(hDoc, wsURL); + pNotify->GetDocProvider()->GotoURL(hDoc, wsURL, TRUE); } void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { |