OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "public/fpdf_transformpage.h" | 7 #include "public/fpdf_transformpage.h" |
8 | 8 |
9 #include "fpdfsdk/include/fsdk_define.h" | 9 #include "fpdfsdk/include/fsdk_define.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 pPageDict->SetAt(key, pBoundingBoxArray); | 25 pPageDict->SetAt(key, pBoundingBoxArray); |
26 } | 26 } |
27 | 27 |
28 FPDF_BOOL GetBoundingBox(CPDF_Page* page, | 28 FPDF_BOOL GetBoundingBox(CPDF_Page* page, |
29 const CFX_ByteStringC& key, | 29 const CFX_ByteStringC& key, |
30 float* left, | 30 float* left, |
31 float* bottom, | 31 float* bottom, |
32 float* right, | 32 float* right, |
33 float* top) { | 33 float* top) { |
34 CPDF_Dictionary* pPageDict = page->m_pFormDict; | 34 CPDF_Dictionary* pPageDict = page->m_pFormDict; |
35 CPDF_Array* pArray = pPageDict->GetArray(key); | 35 CPDF_Array* pArray = pPageDict->GetArrayBy(key); |
36 if (!pArray) | 36 if (!pArray) |
37 return FALSE; | 37 return FALSE; |
38 | 38 |
39 *left = pArray->GetFloat(0); | 39 *left = pArray->GetFloatAt(0); |
40 *bottom = pArray->GetFloat(1); | 40 *bottom = pArray->GetFloatAt(1); |
41 *right = pArray->GetFloat(2); | 41 *right = pArray->GetFloatAt(2); |
42 *top = pArray->GetFloat(3); | 42 *top = pArray->GetFloatAt(3); |
43 return TRUE; | 43 return TRUE; |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, | 48 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, |
49 float left, | 49 float left, |
50 float bottom, | 50 float bottom, |
51 float right, | 51 float right, |
52 float top) { | 52 float top) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 CFX_ByteString bsMatix; | 107 CFX_ByteString bsMatix; |
108 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c, | 108 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c, |
109 matrix->d, matrix->e, matrix->f); | 109 matrix->d, matrix->e, matrix->f); |
110 textBuf << bsMatix; | 110 textBuf << bsMatix; |
111 | 111 |
112 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; | 112 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; |
113 CPDF_Object* pContentObj = | 113 CPDF_Object* pContentObj = |
114 pPageDic ? pPageDic->GetElement("Contents") : nullptr; | 114 pPageDic ? pPageDic->GetElement("Contents") : nullptr; |
115 if (!pContentObj) | 115 if (!pContentObj) |
116 pContentObj = pPageDic ? pPageDic->GetArray("Contents") : nullptr; | 116 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; |
117 if (!pContentObj) | 117 if (!pContentObj) |
118 return FALSE; | 118 return FALSE; |
119 | 119 |
120 CPDF_Dictionary* pDic = new CPDF_Dictionary; | 120 CPDF_Dictionary* pDic = new CPDF_Dictionary; |
121 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); | 121 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); |
122 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE); | 122 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE); |
123 CPDF_Document* pDoc = pPage->m_pDocument; | 123 CPDF_Document* pDoc = pPage->m_pDocument; |
124 if (!pDoc) | 124 if (!pDoc) |
125 return FALSE; | 125 return FALSE; |
126 pDoc->AddIndirectObject(pStream); | 126 pDoc->AddIndirectObject(pStream); |
(...skipping 22 matching lines...) Expand all Loading... |
149 pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 149 pContentArray->AddReference(pDoc, pStream->GetObjNum()); |
150 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 150 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); |
151 pContentArray->AddReference(pDoc, pEndStream); | 151 pContentArray->AddReference(pDoc, pEndStream); |
152 pPageDic->SetAtReference("Contents", pDoc, | 152 pPageDic->SetAtReference("Contents", pDoc, |
153 pDoc->AddIndirectObject(pContentArray)); | 153 pDoc->AddIndirectObject(pContentArray)); |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 // Need to transform the patterns as well. | 158 // Need to transform the patterns as well. |
159 CPDF_Dictionary* pRes = pPageDic->GetDict("Resources"); | 159 CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources"); |
160 if (pRes) { | 160 if (pRes) { |
161 CPDF_Dictionary* pPattenDict = pRes->GetDict("Pattern"); | 161 CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern"); |
162 if (pPattenDict) { | 162 if (pPattenDict) { |
163 for (const auto& it : *pPattenDict) { | 163 for (const auto& it : *pPattenDict) { |
164 CPDF_Object* pObj = it.second; | 164 CPDF_Object* pObj = it.second; |
165 if (pObj->IsReference()) | 165 if (pObj->IsReference()) |
166 pObj = pObj->GetDirect(); | 166 pObj = pObj->GetDirect(); |
167 | 167 |
168 CPDF_Dictionary* pDict = nullptr; | 168 CPDF_Dictionary* pDict = nullptr; |
169 if (pObj->IsDictionary()) | 169 if (pObj->IsDictionary()) |
170 pDict = pObj->AsDictionary(); | 170 pDict = pObj->AsDictionary(); |
171 else if (CPDF_Stream* pStream = pObj->AsStream()) | 171 else if (CPDF_Stream* pStream = pObj->AsStream()) |
172 pDict = pStream->GetDict(); | 172 pDict = pStream->GetDict(); |
173 else | 173 else |
174 continue; | 174 continue; |
175 | 175 |
176 CFX_Matrix m = pDict->GetMatrix("Matrix"); | 176 CFX_Matrix m = pDict->GetMatrixBy("Matrix"); |
177 CFX_Matrix t = *(CFX_Matrix*)matrix; | 177 CFX_Matrix t = *(CFX_Matrix*)matrix; |
178 m.Concat(t); | 178 m.Concat(t); |
179 pDict->SetAtMatrix("Matrix", m); | 179 pDict->SetAtMatrix("Matrix", m); |
180 } | 180 } |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 return TRUE; | 184 return TRUE; |
185 } | 185 } |
186 | 186 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, | 263 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, |
264 FPDF_CLIPPATH clipPath) { | 264 FPDF_CLIPPATH clipPath) { |
265 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 265 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
266 if (!pPage) | 266 if (!pPage) |
267 return; | 267 return; |
268 | 268 |
269 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; | 269 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; |
270 CPDF_Object* pContentObj = | 270 CPDF_Object* pContentObj = |
271 pPageDic ? pPageDic->GetElement("Contents") : nullptr; | 271 pPageDic ? pPageDic->GetElement("Contents") : nullptr; |
272 if (!pContentObj) | 272 if (!pContentObj) |
273 pContentObj = pPageDic ? pPageDic->GetArray("Contents") : nullptr; | 273 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; |
274 if (!pContentObj) | 274 if (!pContentObj) |
275 return; | 275 return; |
276 | 276 |
277 CFX_ByteTextBuf strClip; | 277 CFX_ByteTextBuf strClip; |
278 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; | 278 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; |
279 FX_DWORD i; | 279 FX_DWORD i; |
280 for (i = 0; i < pClipPath->GetPathCount(); i++) { | 280 for (i = 0; i < pClipPath->GetPathCount(); i++) { |
281 CPDF_Path path = pClipPath->GetPath(i); | 281 CPDF_Path path = pClipPath->GetPath(i); |
282 int iClipType = pClipPath->GetClipType(i); | 282 int iClipType = pClipPath->GetClipType(i); |
283 if (path.GetPointCount() == 0) { | 283 if (path.GetPointCount() == 0) { |
(...skipping 30 matching lines...) Expand all Loading... |
314 } else if (pDirectObj->IsStream()) { | 314 } else if (pDirectObj->IsStream()) { |
315 pContentArray = new CPDF_Array(); | 315 pContentArray = new CPDF_Array(); |
316 pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 316 pContentArray->AddReference(pDoc, pStream->GetObjNum()); |
317 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 317 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); |
318 pPageDic->SetAtReference("Contents", pDoc, | 318 pPageDic->SetAtReference("Contents", pDoc, |
319 pDoc->AddIndirectObject(pContentArray)); | 319 pDoc->AddIndirectObject(pContentArray)); |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
OLD | NEW |