Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: fpdfsdk/src/fpdfeditpage.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_edit.h" 7 #include "../../public/fpdf_edit.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 9
10
11 #if _FX_OS_ == _FX_ANDROID_ 10 #if _FX_OS_ == _FX_ANDROID_
12 #include "time.h" 11 #include "time.h"
13 #else 12 #else
14 #include <ctime> 13 #include <ctime>
15 #endif 14 #endif
16 15
17 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() 16 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
18 { 17 CPDF_Document* pDoc = new CPDF_Document;
19 CPDF_Document* pDoc = new CPDF_Document; 18 pDoc->CreateNewDoc();
20 pDoc->CreateNewDoc(); 19 time_t currentTime;
21 time_t currentTime; 20
22 21 CFX_ByteString DateStr;
23 CFX_ByteString DateStr; 22
24 23 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
25 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 24 if (-1 != time(&currentTime)) {
26 { 25 tm* pTM = localtime(&currentTime);
27 if ( -1 != time( &currentTime ) ) 26 if (pTM) {
28 { 27 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
29 tm * pTM = localtime( &currentTime ); 28 pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
30 if ( pTM ) 29 pTM->tm_sec);
31 { 30 }
32 DateStr.Format( "D:%04d%02d%02d%02d%02d%02d", pT M->tm_year+1900, pTM->tm_mon+1, 31 }
33 pTM->tm_mday, pTM->tm_hour, pTM->tm_min, pTM->tm_sec ); 32 }
34 } 33
35 } 34 CPDF_Dictionary* pInfoDict = NULL;
36 } 35 pInfoDict = pDoc->GetInfo();
37 36 if (pInfoDict) {
38 CPDF_Dictionary* pInfoDict = NULL; 37 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
39 pInfoDict = pDoc->GetInfo(); 38 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));
40 if (pInfoDict) 39 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
41 { 40 }
42 if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) 41
43 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr )); 42 return pDoc;
44 pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); 43 }
45 } 44
46 45 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
47 return pDoc; 46 CPDF_Document* pDoc = (CPDF_Document*)document;
48 } 47 if (pDoc == NULL)
49 48 return;
50 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) 49 if (page_index < 0 || page_index >= pDoc->GetPageCount())
51 { 50 return;
52 CPDF_Document* pDoc = (CPDF_Document*)document; 51
53 if (pDoc == NULL) 52 pDoc->DeletePage(page_index);
54 return; 53 }
55 if (page_index < 0 || page_index >= pDoc->GetPageCount()) 54
56 return; 55 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
57 56 int page_index,
58 pDoc->DeletePage(page_index); 57 double width,
59 } 58 double height) {
60 59 if (!document)
61 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height) 60 return NULL;
62 { 61
63 if (!document) 62 // CPDF_Parser* pParser = (CPDF_Parser*)document;
64 return NULL; 63 CPDF_Document* pDoc = (CPDF_Document*)document;
65 64 if (page_index < 0)
66 // CPDF_Parser* pParser = (CPDF_Parser*)document; 65 page_index = 0;
67 CPDF_Document* pDoc = (CPDF_Document*)document; 66 if (pDoc->GetPageCount() < page_index)
68 if(page_index < 0) 67 page_index = pDoc->GetPageCount();
69 page_index = 0; 68 // if (page_index < 0 || page_index >= pDoc->GetPageCount())
70 if(pDoc->GetPageCount()<page_index) 69 // return NULL;
71 page_index = pDoc->GetPageCount(); 70
72 // if (page_index < 0 || page_index >= pDoc->GetPageCount()) 71 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
73 // return NULL; 72 if (!pPageDict)
74 73 return NULL;
75 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); 74 CPDF_Array* pMediaBoxArray = new CPDF_Array;
76 if(!pPageDict) 75 pMediaBoxArray->Add(new CPDF_Number(0));
77 return NULL; 76 pMediaBoxArray->Add(new CPDF_Number(0));
78 CPDF_Array* pMediaBoxArray = new CPDF_Array; 77 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
79 pMediaBoxArray->Add(new CPDF_Number(0)); 78 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
80 pMediaBoxArray->Add(new CPDF_Number(0)); 79
81 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width))); 80 pPageDict->SetAt("MediaBox", pMediaBoxArray);
82 pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height))); 81 pPageDict->SetAt("Rotate", new CPDF_Number(0));
83 82 pPageDict->SetAt("Resources", new CPDF_Dictionary);
84 pPageDict->SetAt("MediaBox", pMediaBoxArray); 83
85 pPageDict->SetAt("Rotate", new CPDF_Number(0)); 84 CPDF_Page* pPage = new CPDF_Page;
86 pPageDict->SetAt("Resources", new CPDF_Dictionary); 85 pPage->Load(pDoc, pPageDict);
87 86 pPage->ParseContent();
88 CPDF_Page* pPage = new CPDF_Page; 87
89 pPage->Load(pDoc,pPageDict); 88 return pPage;
90 pPage->ParseContent(); 89 }
91 90
92 return pPage; 91 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
93 } 92 CPDF_Page* pPage = (CPDF_Page*)page;
94 93 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
95 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) 94 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
96 { 95 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
97 CPDF_Page* pPage = (CPDF_Page*)page; 96 "Page")) {
98 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 97 return -1;
99 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 98 }
100 { 99 CPDF_Dictionary* pDict = pPage->m_pFormDict;
101 return -1; 100
102 } 101 int rotate = 0;
103 CPDF_Dictionary* pDict = pPage->m_pFormDict; 102 if (pDict != NULL) {
104 103 if (pDict->KeyExist("Rotate"))
105 int rotate = 0; 104 rotate = pDict->GetElement("Rotate")->GetDirect()
106 if(pDict != NULL) 105 ? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90
107 { 106 : 0;
108 if (pDict->KeyExist("Rotate")) 107 else {
109 rotate = pDict->GetElement("Rotate")->GetDirect()? pDict ->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0; 108 if (pDict->KeyExist("Parent")) {
110 else 109 CPDF_Dictionary* pPages =
111 { 110 (CPDF_Dictionary*)pDict->GetElement("Parent")->GetDirect();
112 if(pDict->KeyExist("Parent")) 111 while (pPages) {
113 { 112 if (pPages->KeyExist("Rotate")) {
114 CPDF_Dictionary* pPages = (CPDF_Dictionary*)pDic t->GetElement("Parent")->GetDirect(); 113 rotate =
115 while(pPages) 114 pPages->GetElement("Rotate")->GetDirect()
116 { 115 ? pPages->GetElement("Rotate")->GetDirect()->GetInteger() /
117 if(pPages->KeyExist("Rotate")) 116 90
118 { 117 : 0;
119 rotate = pPages->GetElement("Rot ate")->GetDirect()? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0; 118 break;
120 break; 119 } else if (pPages->KeyExist("Parent"))
121 } 120 pPages =
122 else if(pPages->KeyExist("Parent")) 121 (CPDF_Dictionary*)pPages->GetElement("Parent")->GetDirect();
123 pPages = (CPDF_Dictionary*)pPage s->GetElement("Parent")->GetDirect(); 122 else
124 else break; 123 break;
125 } 124 }
126 } 125 }
127 } 126 }
128 } 127 } else {
129 else 128 return -1;
130 { 129 }
131 return -1; 130
132 } 131 return rotate;
133 132 }
134 return rotate; 133
135 } 134 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
136 135 FPDF_PAGEOBJECT page_obj) {
137 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag e_obj) 136 CPDF_Page* pPage = (CPDF_Page*)page;
138 { 137 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
139 CPDF_Page* pPage = (CPDF_Page*)page; 138 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
140 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 139 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
141 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 140 "Page")) {
142 { 141 return;
143 return; 142 }
144 } 143 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj;
145 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; 144 if (pPageObj == NULL)
146 if(pPageObj == NULL) 145 return;
147 return; 146 FX_POSITION LastPersition = pPage->GetLastObjectPosition();
148 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); 147
149 148 pPage->InsertObject(LastPersition, pPageObj);
150 pPage->InsertObject(LastPersition, pPageObj); 149 switch (pPageObj->m_Type) {
151 switch(pPageObj->m_Type) 150 case FPDF_PAGEOBJ_PATH: {
152 { 151 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;
153 case FPDF_PAGEOBJ_PATH: 152 pPathObj->CalcBoundingBox();
154 { 153 break;
155 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; 154 }
156 pPathObj->CalcBoundingBox(); 155 case FPDF_PAGEOBJ_TEXT: {
157 break; 156 // CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;
158 } 157 // pPathObj->CalcBoundingBox();
159 case FPDF_PAGEOBJ_TEXT: 158 break;
160 { 159 }
161 // CPDF_PathObject* pPathObj = (CPDF_PathObject*)pP ageObj; 160 case FPDF_PAGEOBJ_IMAGE: {
162 // pPathObj->CalcBoundingBox(); 161 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj;
163 break; 162 pImageObj->CalcBoundingBox();
164 } 163 break;
165 case FPDF_PAGEOBJ_IMAGE: 164 }
166 { 165 case FPDF_PAGEOBJ_SHADING: {
167 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageOb j; 166 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj;
168 pImageObj->CalcBoundingBox(); 167 pShadingObj->CalcBoundingBox();
169 break; 168 break;
170 } 169 }
171 case FPDF_PAGEOBJ_SHADING: 170 case FPDF_PAGEOBJ_FORM: {
172 { 171 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
173 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)p PageObj; 172 pFormObj->CalcBoundingBox();
174 pShadingObj->CalcBoundingBox(); 173 break;
175 break; 174 }
176 } 175 default:
177 case FPDF_PAGEOBJ_FORM: 176 break;
178 { 177 }
179 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; 178
180 pFormObj->CalcBoundingBox(); 179 // pPage->ParseContent();
181 break; 180 // pPage->GenerateContent();
182 } 181 }
183 default: 182
184 break; 183 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) {
185 } 184 CPDF_Page* pPage = (CPDF_Page*)page;
186 185 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
187 // pPage->ParseContent(); 186 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
188 //pPage->GenerateContent(); 187 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
189 188 "Page")) {
190 } 189 return -1;
191 190 }
192 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) 191 return pPage->CountObjects();
193 { 192 // return 0;
194 CPDF_Page* pPage = (CPDF_Page*)page; 193 }
195 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 194
196 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 195 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page,
197 { 196 int index) {
198 return -1; 197 CPDF_Page* pPage = (CPDF_Page*)page;
199 } 198 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
200 return pPage->CountObjects(); 199 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
201 // return 0; 200 "Page")) {
202 } 201 return NULL;
203 202 }
204 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index) 203 return pPage->GetObjectByIndex(index);
205 { 204 // return NULL;
206 CPDF_Page* pPage = (CPDF_Page*)page; 205 }
207 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") 206
208 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 207 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) {
209 { 208 if (!page)
210 return NULL; 209 return FALSE;
211 } 210 CPDF_Page* pPage = (CPDF_Page*)page;
212 return pPage->GetObjectByIndex(index); 211
213 // return NULL; 212 return pPage->BackgroundAlphaNeeded();
214 } 213 }
215 214
216 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) 215 DLLEXPORT FPDF_BOOL STDCALL
217 { 216 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
218 if(!page) return FALSE; 217 if (!pageObject)
219 CPDF_Page* pPage = (CPDF_Page*)page; 218 return FALSE;
220 219 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject;
221 return pPage->BackgroundAlphaNeeded(); 220
222 } 221 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
223 222 int blend_type =
224 DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObje ct) 223 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
225 { 224 if (blend_type != FXDIB_BLEND_NORMAL)
226 if(!pageObject) return FALSE; 225 return TRUE;
227 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject; 226
228 227 CPDF_Dictionary* pSMaskDict =
229 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; 228 pGeneralState ? (CPDF_Dictionary*)pGeneralState->m_pSoftMask : NULL;
230 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEN D_NORMAL; 229 if (pSMaskDict)
231 if (blend_type != FXDIB_BLEND_NORMAL) return TRUE; 230 return TRUE;
232 231
233 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneral State->m_pSoftMask : NULL; 232 if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f)
234 if(pSMaskDict) return TRUE; 233 return TRUE;
235 234
236 if(pGeneralState && pGeneralState->m_FillAlpha != 1.0f) 235 if (pPageObj->m_Type == PDFPAGE_PATH) {
237 return TRUE; 236 if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f)
238 237 return TRUE;
239 if(pPageObj->m_Type == PDFPAGE_PATH) 238 }
240 { 239
241 if(pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f) 240 if (pPageObj->m_Type == PDFPAGE_FORM) {
242 return TRUE; 241 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
243 } 242 if (pFormObj->m_pForm &&
244 243 (pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED))
245 if(pPageObj->m_Type == PDFPAGE_FORM) 244 return TRUE;
246 { 245 if (pFormObj->m_pForm &&
247 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; 246 (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) &&
248 if(pFormObj->m_pForm && (pFormObj->m_pForm->m_Transparency & PDF TRANS_ISOLATED)) 247 (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP)))
249 return TRUE; 248 return TRUE;
250 if(pFormObj->m_pForm && (!(pFormObj->m_pForm->m_Transparency & P DFTRANS_ISOLATED) && (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP))) 249 }
251 return TRUE; 250 return FALSE;
252 } 251 }
253 return FALSE; 252
254 } 253 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) {
255 254 CPDF_Page* pPage = (CPDF_Page*)page;
256 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) 255 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
257 { 256 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
258 CPDF_Page* pPage = (CPDF_Page*)page; 257 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
259 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 258 "Page")) {
260 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 259 return FALSE;
261 { 260 }
262 return FALSE; 261 CPDF_PageContentGenerate CG(pPage);
263 } 262 CG.GenerateContent();
264 CPDF_PageContentGenerate CG(pPage); 263
265 CG.GenerateContent(); 264 return TRUE;
266
267 return TRUE;
268 } 265 }
269 266
270 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, 267 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
271 » » » double a, double b, double c, double d, double e, doubl e f) 268 double a,
272 { 269 double b,
273 » CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; 270 double c,
274 » if(pPageObj == NULL) 271 double d,
275 » » return; 272 double e,
276 » CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d, (FX_FLOAT)e,(FX_FLOAT)f); 273 double f) {
277 » pPageObj->Transform(matrix); 274 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
275 if (pPageObj == NULL)
276 return;
277 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
278 (FX_FLOAT)e, (FX_FLOAT)f);
279 pPageObj->Transform(matrix);
278 } 280 }
279 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, 281 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
280 » » » » » » » » » » » double a, double b, double c, double d, double e, double f) 282 double a,
281 { 283 double b,
282 » if(page == NULL) 284 double c,
283 » » return; 285 double d,
284 » CPDF_Page* pPage = (CPDF_Page*)page; 286 double e,
285 » CPDF_AnnotList AnnotList(pPage); 287 double f) {
286 » for (int i=0; i<AnnotList.Count();i++) 288 if (page == NULL)
287 » { 289 return;
288 » » CPDF_Annot* pAnnot = AnnotList.GetAt(i); 290 CPDF_Page* pPage = (CPDF_Page*)page;
289 » » // transformAnnots Rectangle 291 CPDF_AnnotList AnnotList(pPage);
290 » » CPDF_Rect rect; 292 for (int i = 0; i < AnnotList.Count(); i++) {
291 » » pAnnot->GetRect(rect); 293 CPDF_Annot* pAnnot = AnnotList.GetAt(i);
292 » » CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_ FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f); 294 // transformAnnots Rectangle
293 » » rect.Transform(&matrix); 295 CPDF_Rect rect;
294 » » CPDF_Array *pRectArray = NULL; 296 pAnnot->GetRect(rect);
295 » » pRectArray = pAnnot->GetAnnotDict()->GetArray("Rect"); 297 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
296 » » if (!pRectArray) pRectArray=CPDF_Array::Create(); 298 (FX_FLOAT)e, (FX_FLOAT)f);
297 » » pRectArray->SetAt(0, new CPDF_Number(rect.left)); 299 rect.Transform(&matrix);
298 » » pRectArray->SetAt(1, new CPDF_Number(rect.bottom)); 300 CPDF_Array* pRectArray = NULL;
299 » » pRectArray->SetAt(2, new CPDF_Number(rect.right)); 301 pRectArray = pAnnot->GetAnnotDict()->GetArray("Rect");
300 » » pRectArray->SetAt(3, new CPDF_Number(rect.top)); 302 if (!pRectArray)
301 » » pAnnot->GetAnnotDict()->SetAt("Rect",pRectArray); 303 pRectArray = CPDF_Array::Create();
302 304 pRectArray->SetAt(0, new CPDF_Number(rect.left));
303 » » //Transform AP's rectangle 305 pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
304 » » //To Do 306 pRectArray->SetAt(2, new CPDF_Number(rect.right));
305 » } 307 pRectArray->SetAt(3, new CPDF_Number(rect.top));
306 308 pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray);
307 } 309
308 310 // Transform AP's rectangle
309 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) 311 // To Do
310 { 312 }
311 » CPDF_Page* pPage = (CPDF_Page*)page; 313 }
312 » if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type ") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() 314
313 » » || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin g().Compare("Page")) 315 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
314 » { 316 CPDF_Page* pPage = (CPDF_Page*)page;
315 » » return; 317 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
316 » } 318 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
317 » CPDF_Dictionary* pDict = pPage->m_pFormDict; 319 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
318 » rotate %=4; 320 "Page")) {
319 321 return;
320 » pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 322 }
321 } 323 CPDF_Dictionary* pDict = pPage->m_pFormDict;
324 rotate %= 4;
325
326 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698