summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp10
-rw-r--r--fpdfsdk/fpdfeditpage.cpp15
-rw-r--r--fpdfsdk/fpdfview.cpp14
3 files changed, 12 insertions, 27 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index 952564db49..d62f5ca85c 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -694,3 +694,13 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) {
ASSERT_TRUE(widths_array);
CheckCompositeFontWidths(widths_array, typed_font);
}
+
+TEST_F(FPDFEditEmbeddertest, NormalizeNegativeRotation) {
+ // Load document with a -90 degree rotation
+ EXPECT_TRUE(OpenDocument("bug_713197.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+
+ EXPECT_EQ(3, FPDFPage_GetRotation(page));
+ UnloadPage(page);
+}
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 511b7f5b4b..739723f6ee 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -133,20 +133,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!IsPageObject(pPage))
return -1;
-
- CPDF_Dictionary* pDict = pPage->m_pFormDict;
- while (pDict) {
- if (pDict->KeyExist("Rotate")) {
- CPDF_Object* pRotateObj = pDict->GetObjectFor("Rotate")->GetDirect();
- return pRotateObj ? pRotateObj->GetInteger() / 90 : 0;
- }
- if (!pDict->KeyExist("Parent"))
- break;
-
- pDict = ToDictionary(pDict->GetObjectFor("Parent")->GetDirect());
- }
-
- return 0;
+ return pPage->GetPageRotation();
}
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 4fea392228..c928ebe445 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -740,19 +740,7 @@ FX_RECT GetMaskDimensionsAndOffsets(CPDF_Page* pPage,
static_cast<int>(mask_box.bottom * scale_y);
// Get page rotation
- int page_rotation = 0;
- CPDF_Dictionary* pDict = pPage->m_pFormDict;
- while (pDict) {
- if (pDict->KeyExist("Rotate")) {
- CPDF_Object* pRotateObj = pDict->GetObjectFor("Rotate")->GetDirect();
- page_rotation = pRotateObj ? pRotateObj->GetInteger() / 90 : 0;
- break;
- }
- if (!pDict->KeyExist("Parent"))
- break;
-
- pDict = ToDictionary(pDict->GetObjectFor("Parent")->GetDirect());
- }
+ int page_rotation = pPage->GetPageRotation();
// Compute offsets
int offset_x = 0;