diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-25 23:37:50 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 23:37:50 +0000 |
commit | ca02733961f84abd562d59e4b6a83018ef41b143 (patch) | |
tree | a5f2cb28353fc82aab57f99d6605f5b817a04cce /fpdfsdk | |
parent | df93cd35530e7b8dd67abde8d199c36c3fae76be (diff) | |
download | pdfium-ca02733961f84abd562d59e4b6a83018ef41b143.tar.xz |
Replace some #ifdefs PDF_ENABLE_XFA, part 2.
Tidy some code encountered along the way in cpdfsdk_helpers.cpp
Remove one ifdef from xfa-only file.
Restore some option flag processing (probably wrong to remove).
Flip some #ifndef to #ifdef (#ifndef PDF_ENABLE_XFA is an
anti-pattern and should be treated with suspicion since XFA should
always be "additive").
Change-Id: I564a28401e20e6269c85ea610da8c96f8c8dd737
Reviewed-on: https://pdfium-review.googlesource.com/32834
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.h | 6 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.h | 6 | ||||
-rw-r--r-- | fpdfsdk/fpdf_formfill.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdf_text.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view_embeddertest.cpp | 6 |
7 files changed, 17 insertions, 30 deletions
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index eb91bcf9ba..5773a8b512 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -215,10 +215,9 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { if (!pDoc) return; - // Portfolios and Packages const CPDF_Dictionary* pRootDict = pDoc->GetRoot(); if (pRootDict) { - ByteString cbString; + // Portfolios and Packages if (pRootDict->KeyExist("Collection")) { RaiseUnSupportError(FPDF_UNSP_DOC_PORTABLECOLLECTION); return; @@ -244,12 +243,8 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { } } } - } - - // SharedForm - const CPDF_Dictionary* pRoot = pDoc->GetRoot(); - if (pRoot) { - const CPDF_Stream* pStream = pRoot->GetStreamFor("Metadata"); + // SharedForm + const CPDF_Stream* pStream = pRootDict->GetStreamFor("Metadata"); if (pStream) { CPDF_Metadata metaData(pStream); for (const auto& err : metaData.CheckForSharedForm()) diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h index 10f44e409a..ba54645de8 100644 --- a/fpdfsdk/cpdfsdk_helpers.h +++ b/fpdfsdk/cpdfsdk_helpers.h @@ -50,10 +50,10 @@ class CXFA_FFWidget; // Object types for public FPDF_ types; these correspond to next layer down // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are // CPDFXFA_ types. -#ifndef PDF_ENABLE_XFA -using UnderlyingPageType = CPDF_Page; -#else // PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA using UnderlyingPageType = CPDFXFA_Page; +#else // PDF_ENABLE_XFA +using UnderlyingPageType = CPDF_Page; #endif // PDF_ENABLE_XFA // Conversions to/from underlying types. diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index db03262aa9..43482ea7d5 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -70,10 +70,10 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { float GetFontSize() const; int GetSelectedIndex(int nIndex) const; -#ifndef PDF_ENABLE_XFA - WideString GetValue() const; -#else +#ifdef PDF_ENABLE_XFA WideString GetValue(bool bDisplay = true) const; +#else + WideString GetValue() const; #endif // PDF_ENABLE_XFA WideString GetDefaultValue() const; WideString GetOptionLabel(int nIndex) const; diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp index 8a43fa6e77..0124124ff6 100644 --- a/fpdfsdk/fpdf_formfill.cpp +++ b/fpdfsdk/fpdf_formfill.cpp @@ -148,6 +148,8 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, HandleToCPDFSDKEnvironment(hHandle); if (!pFormFillEnv) return; +#else // PDF_ENABLE_XFA + CPDF_Document* pPDFDoc = pPage->GetDocument(); #endif // PDF_ENABLE_XFA const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y); @@ -176,15 +178,13 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, options.SetColorMode(CPDF_RenderOptions::kGray); options.SetDrawAnnots(flags & FPDF_ANNOT); - -#ifdef PDF_ENABLE_XFA options.SetOCContext( pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View)); + +#ifdef PDF_ENABLE_XFA if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, rect); #else // PDF_ENABLE_XFA - options.SetOCContext(pdfium::MakeRetain<CPDF_OCContext>( - pPage->GetDocument(), CPDF_OCContext::View)); if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, FPDFPageFromUnderlying(pPage))) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); diff --git a/fpdfsdk/fpdf_text.cpp b/fpdfsdk/fpdf_text.cpp index a1bbbb4a7a..d8d3b2675b 100644 --- a/fpdfsdk/fpdf_text.cpp +++ b/fpdfsdk/fpdf_text.cpp @@ -40,14 +40,7 @@ FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page) { if (!pPDFPage) return nullptr; -#ifdef PDF_ENABLE_XFA - CPDFXFA_Page* pPage = UnderlyingFromFPDFPage(page); - auto* pContext = static_cast<CPDFXFA_Context*>(pPage->GetDocumentExtension()); - CPDF_ViewerPreferences viewRef(pContext->GetPDFDoc()); -#else // PDF_ENABLE_XFA CPDF_ViewerPreferences viewRef(pPDFPage->GetDocument()); -#endif // PDF_ENABLE_XFA - CPDF_TextPage* textpage = new CPDF_TextPage( pPDFPage, viewRef.IsDirectionR2L() ? FPDFText_Direction::Right : FPDFText_Direction::Left); diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp index 593a092fd3..af9117579d 100644 --- a/fpdfsdk/fpdf_view.cpp +++ b/fpdfsdk/fpdf_view.cpp @@ -94,14 +94,13 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext, option_flags |= RENDER_LIMITEDIMAGECACHE; if (flags & FPDF_RENDER_FORCEHALFTONE) option_flags |= RENDER_FORCE_HALFTONE; -#ifndef PDF_ENABLE_XFA if (flags & FPDF_RENDER_NO_SMOOTHTEXT) option_flags |= RENDER_NOTEXTSMOOTH; if (flags & FPDF_RENDER_NO_SMOOTHIMAGE) option_flags |= RENDER_NOIMAGESMOOTH; if (flags & FPDF_RENDER_NO_SMOOTHPATH) option_flags |= RENDER_NOPATHSMOOTH; -#endif // PDF_ENABLE_XFA + pContext->m_pOptions->SetFlags(option_flags); // Grayscale output diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp index 580ba76e31..7cc5478808 100644 --- a/fpdfsdk/fpdf_view_embeddertest.cpp +++ b/fpdfsdk/fpdf_view_embeddertest.cpp @@ -75,10 +75,10 @@ TEST_F(FPDFViewEmbeddertest, EmptyDocument) { } { -#ifndef PDF_ENABLE_XFA - const unsigned long kExpected = 0; -#else +#ifdef PDF_ENABLE_XFA const unsigned long kExpected = static_cast<uint32_t>(-1); +#else + const unsigned long kExpected = 0; #endif EXPECT_EQ(kExpected, FPDF_GetDocPermissions(document())); } |