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

Side by Side Diff: core/src/fpdfdoc/doc_ap.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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
« no previous file with comments | « core/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_basic.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fpdfdoc/fpdf_vt.h" 8 #include "../../include/fpdfdoc/fpdf_vt.h"
9 #include "pdf_vt.h" 9 #include "pdf_vt.h"
10 #include "../../include/fpdfdoc/fpdf_ap.h" 10 #include "../../include/fpdfdoc/fpdf_ap.h"
11 FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) 11 bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
12 { 12 {
13 if (!pAnnotDict || pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget ")) { 13 if (!pAnnotDict || pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget ")) {
14 return FALSE; 14 return false;
15 } 15 }
16 CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString() ; 16 CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString() ;
17 FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnn otDict, "Ff")->GetInteger() : 0; 17 FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnn otDict, "Ff")->GetInteger() : 0;
18 if (field_type == "Tx") { 18 if (field_type == "Tx") {
19 return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); 19 return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict);
20 } else if (field_type == "Ch") { 20 } else if (field_type == "Ch") {
21 if (flags & (1 << 17)) { 21 if (flags & (1 << 17)) {
22 return CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict); 22 return CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict);
23 } else { 23 } else {
24 return CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); 24 return CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict);
25 } 25 }
26 } else if (field_type == "Btn") { 26 } else if (field_type == "Btn") {
27 if (!(flags & (1 << 16))) { 27 if (!(flags & (1 << 16))) {
28 if (!pAnnotDict->KeyExist("AS")) { 28 if (!pAnnotDict->KeyExist("AS")) {
29 if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDict("Parent") ) { 29 if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDict("Parent") ) {
30 if (pParentDict->KeyExist("AS")) { 30 if (pParentDict->KeyExist("AS")) {
31 pAnnotDict->SetAtString("AS", pParentDict->GetString("AS ")); 31 pAnnotDict->SetAtString("AS", pParentDict->GetString("AS "));
32 } 32 }
33 } 33 }
34 } 34 }
35 } 35 }
36 } 36 }
37 return FALSE; 37 return false;
38 } 38 }
39 class CPVT_FontMap : public IPVT_FontMap 39 class CPVT_FontMap : public IPVT_FontMap
40 { 40 {
41 public: 41 public:
42 CPVT_FontMap(CPDF_Document * pDoc, CPDF_Dictionary * pResDict, CPDF_Font * p DefFont, 42 CPVT_FontMap(CPDF_Document * pDoc, CPDF_Dictionary * pResDict, CPDF_Font * p DefFont,
43 const CFX_ByteString & sDefFontAlias); 43 const CFX_ByteString & sDefFontAlias);
44 virtual ~CPVT_FontMap(); 44 virtual ~CPVT_FontMap();
45 CPDF_Font* GetPDFFont(int32_t nFont Index); 45 CPDF_Font* GetPDFFont(int32_t nFont Index);
46 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex); 46 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex);
47 static void GetAnnotSysPDFFont(CPDF_ Document * pDoc, CPDF_Dictionary * pResDict, 47 static void GetAnnotSysPDFFont(CPDF_ Document * pDoc, CPDF_Dictionary * pResDict,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (pDefFont->CharCodeFromUnicode(word) != -1) { 147 if (pDefFont->CharCodeFromUnicode(word) != -1) {
148 return 0; 148 return 0;
149 } 149 }
150 } 150 }
151 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) 151 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1))
152 if (pSysFont->CharCodeFromUnicode(word) != -1) { 152 if (pSysFont->CharCodeFromUnicode(word) != -1) {
153 return 1; 153 return 1;
154 } 154 }
155 return -1; 155 return -1;
156 } 156 }
157 FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) 157 bool CPVT_Provider::IsLatinWord(FX_WORD word)
158 { 158 {
159 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || word == 0x2D || word == 0x27) { 159 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || word == 0x2D || word == 0x27) {
160 return TRUE; 160 return true;
161 } 161 }
162 return FALSE; 162 return false;
163 } 163 }
164 int32_t CPVT_Provider::GetDefaultFontIndex() 164 int32_t CPVT_Provider::GetDefaultFontIndex()
165 { 165 {
166 return 0; 166 return 0;
167 } 167 }
168 static CFX_ByteString GetPDFWordString(IPVT_FontMap * pFontMap, int32_t nFontInd ex, FX_WORD Word, FX_WORD SubWord) 168 static CFX_ByteString GetPDFWordString(IPVT_FontMap * pFontMap, int32_t nFontInd ex, FX_WORD Word, FX_WORD SubWord)
169 { 169 {
170 CFX_ByteString sWord; 170 CFX_ByteString sWord;
171 if (SubWord > 0) { 171 if (SubWord > 0) {
172 sWord.Format("%c", SubWord); 172 sWord.Format("%c", SubWord);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 break; 237 break;
238 case 3: 238 case 3:
239 rt = CPVT_Color(CT_RGB, array.GetFloat(0), array.GetFloat(1), array. GetFloat(2)); 239 rt = CPVT_Color(CT_RGB, array.GetFloat(0), array.GetFloat(1), array. GetFloat(2));
240 break; 240 break;
241 case 4: 241 case 4:
242 rt = CPVT_Color(CT_CMYK, array.GetFloat(0), array.GetFloat(1), array .GetFloat(2), array.GetFloat(3)); 242 rt = CPVT_Color(CT_CMYK, array.GetFloat(0), array.GetFloat(1), array .GetFloat(2), array.GetFloat(3));
243 break; 243 break;
244 } 244 }
245 return rt; 245 return rt;
246 } 246 }
247 static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict , const int32_t & nWidgetType) 247 static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c onst int32_t & nWidgetType)
248 { 248 {
249 CPDF_Dictionary* pFormDict = NULL; 249 CPDF_Dictionary* pFormDict = NULL;
250 if (CPDF_Dictionary * pRootDict = pDoc->GetRoot()) { 250 if (CPDF_Dictionary * pRootDict = pDoc->GetRoot()) {
251 pFormDict = pRootDict->GetDict("AcroForm"); 251 pFormDict = pRootDict->GetDict("AcroForm");
252 } 252 }
253 if (!pFormDict) { 253 if (!pFormDict) {
254 return FALSE; 254 return false;
255 } 255 }
256 CFX_ByteString DA; 256 CFX_ByteString DA;
257 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) { 257 if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) {
258 DA = pDAObj->GetString(); 258 DA = pDAObj->GetString();
259 } 259 }
260 if (DA.IsEmpty()) { 260 if (DA.IsEmpty()) {
261 DA = pFormDict->GetString("DA"); 261 DA = pFormDict->GetString("DA");
262 } 262 }
263 if (DA.IsEmpty()) { 263 if (DA.IsEmpty()) {
264 return FALSE; 264 return false;
265 } 265 }
266 CPDF_SimpleParser syntax(DA); 266 CPDF_SimpleParser syntax(DA);
267 syntax.FindTagParam("Tf", 2); 267 syntax.FindTagParam("Tf", 2);
268 CFX_ByteString sFontName = syntax.GetWord(); 268 CFX_ByteString sFontName = syntax.GetWord();
269 sFontName = PDF_NameDecode(sFontName); 269 sFontName = PDF_NameDecode(sFontName);
270 if (sFontName.IsEmpty()) { 270 if (sFontName.IsEmpty()) {
271 return FALSE; 271 return false;
272 } 272 }
273 FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); 273 FX_FLOAT fFontSize = FX_atof(syntax.GetWord());
274 CPVT_Color crText = ParseColor(DA); 274 CPVT_Color crText = ParseColor(DA);
275 FX_BOOL bUseFormRes = FALSE; 275 bool bUseFormRes = false;
276 CPDF_Dictionary * pFontDict = NULL; 276 CPDF_Dictionary * pFontDict = NULL;
277 CPDF_Dictionary* pDRDict = pAnnotDict->GetDict(FX_BSTRC("DR")); 277 CPDF_Dictionary* pDRDict = pAnnotDict->GetDict(FX_BSTRC("DR"));
278 if (pDRDict == NULL) { 278 if (pDRDict == NULL) {
279 pDRDict = pFormDict->GetDict(FX_BSTRC("DR")); 279 pDRDict = pFormDict->GetDict(FX_BSTRC("DR"));
280 bUseFormRes = TRUE; 280 bUseFormRes = true;
281 } 281 }
282 CPDF_Dictionary * pDRFontDict = NULL; 282 CPDF_Dictionary * pDRFontDict = NULL;
283 if (pDRDict && (pDRFontDict = pDRDict->GetDict("Font"))) { 283 if (pDRDict && (pDRFontDict = pDRDict->GetDict("Font"))) {
284 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1)); 284 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1));
285 if (!pFontDict && !bUseFormRes) { 285 if (!pFontDict && !bUseFormRes) {
286 pDRDict = pFormDict->GetDict(FX_BSTRC("DR")); 286 pDRDict = pFormDict->GetDict(FX_BSTRC("DR"));
287 pDRFontDict = pDRDict->GetDict("Font"); 287 pDRFontDict = pDRDict->GetDict("Font");
288 if (pDRFontDict) { 288 if (pDRFontDict) {
289 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1)); 289 pFontDict = pDRFontDict->GetDict(sFontName.Mid(1));
290 } 290 }
291 } 291 }
292 } 292 }
293 if (!pDRFontDict) { 293 if (!pDRFontDict) {
294 return FALSE; 294 return false;
295 } 295 }
296 if (!pFontDict) { 296 if (!pFontDict) {
297 pFontDict = CPDF_Dictionary::Create(); 297 pFontDict = CPDF_Dictionary::Create();
298 if (pFontDict == NULL) { 298 if (pFontDict == NULL) {
299 return FALSE; 299 return false;
300 } 300 }
301 pFontDict->SetAtName(FX_BSTRC("Type"), "Font"); 301 pFontDict->SetAtName(FX_BSTRC("Type"), "Font");
302 pFontDict->SetAtName(FX_BSTRC("Subtype"), "Type1"); 302 pFontDict->SetAtName(FX_BSTRC("Subtype"), "Type1");
303 pFontDict->SetAtName(FX_BSTRC("BaseFont"), "Helvetica"); 303 pFontDict->SetAtName(FX_BSTRC("BaseFont"), "Helvetica");
304 pFontDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding"); 304 pFontDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
305 pDoc->AddIndirectObject(pFontDict); 305 pDoc->AddIndirectObject(pFontDict);
306 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); 306 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
307 } 307 }
308 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); 308 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
309 if (!pDefFont) { 309 if (!pDefFont) {
310 return FALSE; 310 return false;
311 } 311 }
312 CPDF_Rect rcAnnot = pAnnotDict->GetRect("Rect"); 312 CPDF_Rect rcAnnot = pAnnotDict->GetRect("Rect");
313 int32_t nRotate = 0; 313 int32_t nRotate = 0;
314 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) { 314 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) {
315 nRotate = pMKDict->GetInteger("R"); 315 nRotate = pMKDict->GetInteger("R");
316 } 316 }
317 CPDF_Rect rcBBox; 317 CPDF_Rect rcBBox;
318 CPDF_Matrix matrix; 318 CPDF_Matrix matrix;
319 switch (nRotate % 360) { 319 switch (nRotate % 360) {
320 case 0: 320 case 0:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 CPVT_Color crBorder, crBG; 371 CPVT_Color crBorder, crBG;
372 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) { 372 if (CPDF_Dictionary * pMKDict = pAnnotDict->GetDict("MK")) {
373 if (CPDF_Array * pArray = pMKDict->GetArray("BC")) { 373 if (CPDF_Array * pArray = pMKDict->GetArray("BC")) {
374 crBorder = ParseColor(*pArray); 374 crBorder = ParseColor(*pArray);
375 } 375 }
376 if (CPDF_Array * pArray = pMKDict->GetArray("BG")) { 376 if (CPDF_Array * pArray = pMKDict->GetArray("BG")) {
377 crBG = ParseColor(*pArray); 377 crBG = ParseColor(*pArray);
378 } 378 }
379 } 379 }
380 CFX_ByteTextBuf sAppStream; 380 CFX_ByteTextBuf sAppStream;
381 CFX_ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, TRUE); 381 CFX_ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, true);
382 if (sBG.GetLength() > 0) { 382 if (sBG.GetLength() > 0) {
383 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " 383 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " "
384 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" << " Q\n"; 384 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" << " Q\n";
385 } 385 }
386 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP(rcBBox, fBo rderWidth, 386 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP(rcBBox, fBo rderWidth,
387 crBorder, crLeftTop, crRightBottom, nBorderSt yle, dsBorder); 387 crBorder, crLeftTop, crRightBottom, nBorderSt yle, dsBorder);
388 if (sBorderStream.GetLength() > 0) { 388 if (sBorderStream.GetLength() > 0) {
389 sAppStream << "q\n" << sBorderStream << "Q\n"; 389 sAppStream << "q\n" << sBorderStream << "Q\n";
390 } 390 }
391 CPDF_Rect rcBody = CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBo rderWidth, 391 CPDF_Rect rcBody = CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBo rderWidth,
392 rcBBox.right - fBorderWidth, rcBBox.top - fBord erWidth); 392 rcBBox.right - fBorderWidth, rcBBox.top - fBord erWidth);
393 rcBody.Normalize(); 393 rcBody.Normalize();
394 CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP"); 394 CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP");
395 if (pAPDict == NULL) { 395 if (pAPDict == NULL) {
396 pAPDict = CPDF_Dictionary::Create(); 396 pAPDict = CPDF_Dictionary::Create();
397 if (pAPDict == NULL) { 397 if (pAPDict == NULL) {
398 return FALSE; 398 return false;
399 } 399 }
400 pAnnotDict->SetAt("AP", pAPDict); 400 pAnnotDict->SetAt("AP", pAPDict);
401 } 401 }
402 CPDF_Stream* pNormalStream = pAPDict->GetStream("N"); 402 CPDF_Stream* pNormalStream = pAPDict->GetStream("N");
403 if (pNormalStream == NULL) { 403 if (pNormalStream == NULL) {
404 pNormalStream = CPDF_Stream::Create(NULL, 0, NULL); 404 pNormalStream = CPDF_Stream::Create(NULL, 0, NULL);
405 if (pNormalStream == NULL) { 405 if (pNormalStream == NULL) {
406 return FALSE; 406 return false;
407 } 407 }
408 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); 408 int32_t objnum = pDoc->AddIndirectObject(pNormalStream);
409 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum); 409 pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum);
410 } 410 }
411 CPDF_Dictionary * pStreamDict = pNormalStream->GetDict(); 411 CPDF_Dictionary * pStreamDict = pNormalStream->GetDict();
412 if (pStreamDict) { 412 if (pStreamDict) {
413 pStreamDict->SetAtMatrix("Matrix", matrix); 413 pStreamDict->SetAtMatrix("Matrix", matrix);
414 pStreamDict->SetAtRect("BBox", rcBBox); 414 pStreamDict->SetAtRect("BBox", rcBBox);
415 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); 415 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
416 if (pStreamResList) { 416 if (pStreamResList) {
417 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font" ); 417 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font" );
418 if (!pStreamResFontList) { 418 if (!pStreamResFontList) {
419 pStreamResFontList = CPDF_Dictionary::Create(); 419 pStreamResFontList = CPDF_Dictionary::Create();
420 if (pStreamResFontList == NULL) { 420 if (pStreamResFontList == NULL) {
421 return FALSE; 421 return false;
422 } 422 }
423 pStreamResList->SetAt("Font", pStreamResFontList); 423 pStreamResList->SetAt("Font", pStreamResFontList);
424 } 424 }
425 if (!pStreamResFontList->KeyExist(sFontName)) { 425 if (!pStreamResFontList->KeyExist(sFontName)) {
426 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict); 426 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
427 } 427 }
428 } else { 428 } else {
429 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone()); 429 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone());
430 pStreamResList = pStreamDict->GetDict("Resources"); 430 pStreamResList = pStreamDict->GetDict("Resources");
431 } 431 }
432 } 432 }
433 switch (nWidgetType) { 433 switch (nWidgetType) {
434 case 0: { 434 case 0: {
435 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPD F_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString(); 435 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPD F_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
436 int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFie ldAttr(pAnnotDict, "Q")->GetInteger() : 0; 436 int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFie ldAttr(pAnnotDict, "Q")->GetInteger() : 0;
437 FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_Get FieldAttr(pAnnotDict, "Ff")->GetInteger() : 0; 437 FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_Get FieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
438 FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FP DF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0; 438 FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FP DF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0;
439 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou rces") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1)); 439 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou rces") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1));
440 CPVT_Provider prd(&map); 440 CPVT_Provider prd(&map);
441 CPDF_VariableText vt; 441 CPDF_VariableText vt;
442 vt.SetProvider(&prd); 442 vt.SetProvider(&prd);
443 vt.SetPlateRect(rcBody); 443 vt.SetPlateRect(rcBody);
444 vt.SetAlignment(nAlign); 444 vt.SetAlignment(nAlign);
445 if (IsFloatZero(fFontSize)) { 445 if (IsFloatZero(fFontSize)) {
446 vt.SetAutoFontSize(TRUE); 446 vt.SetAutoFontSize(true);
447 } else { 447 } else {
448 vt.SetFontSize(fFontSize); 448 vt.SetFontSize(fFontSize);
449 } 449 }
450 FX_BOOL bMultiLine = (dwFlags >> 12) & 1; 450 bool bMultiLine = (dwFlags >> 12) & 1;
451 if (bMultiLine) { 451 if (bMultiLine) {
452 vt.SetMultiLine(TRUE); 452 vt.SetMultiLine(true);
453 vt.SetAutoReturn(TRUE); 453 vt.SetAutoReturn(true);
454 } 454 }
455 FX_WORD subWord = 0; 455 FX_WORD subWord = 0;
456 if ((dwFlags >> 13) & 1) { 456 if ((dwFlags >> 13) & 1) {
457 subWord = '*'; 457 subWord = '*';
458 vt.SetPasswordChar(subWord); 458 vt.SetPasswordChar(subWord);
459 } 459 }
460 FX_BOOL bCharArray = (dwFlags >> 24) & 1; 460 bool bCharArray = (dwFlags >> 24) & 1;
461 if (bCharArray) { 461 if (bCharArray) {
462 vt.SetCharArray(dwMaxLen); 462 vt.SetCharArray(dwMaxLen);
463 } else { 463 } else {
464 vt.SetLimitChar(dwMaxLen); 464 vt.SetLimitChar(dwMaxLen);
465 } 465 }
466 vt.Initialize(); 466 vt.Initialize();
467 vt.SetText(swValue.c_str()); 467 vt.SetText(swValue.c_str());
468 vt.RearrangeAll(); 468 vt.RearrangeAll();
469 CPDF_Rect rcContent = vt.GetContentRect(); 469 CPDF_Rect rcContent = vt.GetContentRect();
470 CPDF_Point ptOffset(0.0f, 0.0f); 470 CPDF_Point ptOffset(0.0f, 0.0f);
471 if (!bMultiLine) { 471 if (!bMultiLine) {
472 ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcBody.Hei ght()) / 2.0f); 472 ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcBody.Hei ght()) / 2.0f);
473 } 473 }
474 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP(&map, vt. GetIterator(), ptOffset, !bCharArray, subWord); 474 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP(&map, vt. GetIterator(), ptOffset, !bCharArray, subWord);
475 if (sBody.GetLength() > 0) { 475 if (sBody.GetLength() > 0) {
476 sAppStream << "/Tx BMC\n" << "q\n"; 476 sAppStream << "/Tx BMC\n" << "q\n";
477 if (rcContent.Width() > rcBody.Width() || 477 if (rcContent.Width() > rcBody.Width() ||
478 rcContent.Height() > rcBody.Height()) { 478 rcContent.Height() > rcBody.Height()) {
479 sAppStream << rcBody.left << " " << rcBody.bottom << " " 479 sAppStream << rcBody.left << " " << rcBody.bottom << " "
480 << rcBody.Width() << " " << rcBody.Height() < < " re\nW\nn\n"; 480 << rcBody.Width() << " " << rcBody.Height() < < " re\nW\nn\n";
481 } 481 }
482 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crT ext, TRUE) << sBody << "ET\n" << "Q\nEMC\n"; 482 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crT ext, true) << sBody << "ET\n" << "Q\nEMC\n";
483 } 483 }
484 } 484 }
485 break; 485 break;
486 case 1: { 486 case 1: {
487 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FP DF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString(); 487 CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FP DF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
488 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou rces"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1)); 488 CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resou rces"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1));
489 CPVT_Provider prd(&map); 489 CPVT_Provider prd(&map);
490 CPDF_VariableText vt; 490 CPDF_VariableText vt;
491 vt.SetProvider(&prd); 491 vt.SetProvider(&prd);
492 CPDF_Rect rcButton = rcBody; 492 CPDF_Rect rcButton = rcBody;
493 rcButton.left = rcButton.right - 13; 493 rcButton.left = rcButton.right - 13;
494 rcButton.Normalize(); 494 rcButton.Normalize();
495 CPDF_Rect rcEdit = rcBody; 495 CPDF_Rect rcEdit = rcBody;
496 rcEdit.right = rcButton.left; 496 rcEdit.right = rcButton.left;
497 rcEdit.Normalize(); 497 rcEdit.Normalize();
498 vt.SetPlateRect(rcEdit); 498 vt.SetPlateRect(rcEdit);
499 if (IsFloatZero(fFontSize)) { 499 if (IsFloatZero(fFontSize)) {
500 vt.SetAutoFontSize(TRUE); 500 vt.SetAutoFontSize(true);
501 } else { 501 } else {
502 vt.SetFontSize(fFontSize); 502 vt.SetFontSize(fFontSize);
503 } 503 }
504 vt.Initialize(); 504 vt.Initialize();
505 vt.SetText(swValue.c_str()); 505 vt.SetText(swValue.c_str());
506 vt.RearrangeAll(); 506 vt.RearrangeAll();
507 CPDF_Rect rcContent = vt.GetContentRect(); 507 CPDF_Rect rcContent = vt.GetContentRect();
508 CPDF_Point ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcE dit.Height()) / 2.0f); 508 CPDF_Point ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcE dit.Height()) / 2.0f);
509 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt. GetIterator(), ptOffset, TRUE, 0); 509 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt. GetIterator(), ptOffset, true, 0);
510 if (sEdit.GetLength() > 0) { 510 if (sEdit.GetLength() > 0) {
511 sAppStream << "/Tx BMC\n" << "q\n"; 511 sAppStream << "/Tx BMC\n" << "q\n";
512 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " 512 sAppStream << rcEdit.left << " " << rcEdit.bottom << " "
513 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; 513 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n";
514 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crT ext, TRUE) << sEdit << "ET\n" << "Q\nEMC\n"; 514 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crT ext, true) << sEdit << "ET\n" << "Q\nEMC\n";
515 } 515 }
516 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(CPVT_C olor(CT_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), TRUE); 516 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(CPVT_C olor(CT_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), true);
517 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { 517 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) {
518 sAppStream << "q\n" << sButton; 518 sAppStream << "q\n" << sButton;
519 sAppStream << rcButton.left << " " << rcButton.bottom << " " 519 sAppStream << rcButton.left << " " << rcButton.bottom << " "
520 << rcButton.Width() << " " << rcButton.Height() < < " re f\n"; 520 << rcButton.Width() << " " << rcButton.Height() < < " re f\n";
521 sAppStream << "Q\n"; 521 sAppStream << "Q\n";
522 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBord erAP(rcButton, 2, CPVT_Color(CT_GRAY, 0), CPVT_Color(CT_GRAY, 1), CPVT_Color(CT_ GRAY, 0.5), PBS_BEVELED, CPVT_Dash(3, 0, 0)); 522 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBord erAP(rcButton, 2, CPVT_Color(CT_GRAY, 0), CPVT_Color(CT_GRAY, 1), CPVT_Color(CT_ GRAY, 0.5), PBS_BEVELED, CPVT_Dash(3, 0, 0));
523 if (sButtonBorder.GetLength() > 0) { 523 if (sButtonBorder.GetLength() > 0) {
524 sAppStream << "q\n" << sButtonBorder << "Q\n"; 524 sAppStream << "q\n" << sButtonBorder << "Q\n";
525 } 525 }
526 CPDF_Point ptCenter = CPDF_Point((rcButton.left + rcButton.r ight) / 2, (rcButton.top + rcButton.bottom) / 2); 526 CPDF_Point ptCenter = CPDF_Point((rcButton.left + rcButton.r ight) / 2, (rcButton.top + rcButton.bottom) / 2);
(...skipping 21 matching lines...) Expand all
548 if (IsFloatSmaller(fy, rcBody.bottom)) { 548 if (IsFloatSmaller(fy, rcBody.bottom)) {
549 break; 549 break;
550 } 550 }
551 if (CPDF_Object* pOpt = pOpts->GetElementValue(i)) { 551 if (CPDF_Object* pOpt = pOpts->GetElementValue(i)) {
552 CFX_WideString swItem; 552 CFX_WideString swItem;
553 if (pOpt->GetType() == PDFOBJ_STRING) { 553 if (pOpt->GetType() == PDFOBJ_STRING) {
554 swItem = pOpt->GetUnicodeText(); 554 swItem = pOpt->GetUnicodeText();
555 } else if (pOpt->GetType() == PDFOBJ_ARRAY) { 555 } else if (pOpt->GetType() == PDFOBJ_ARRAY) {
556 swItem = ((CPDF_Array*)pOpt)->GetElementValue(1) ->GetUnicodeText(); 556 swItem = ((CPDF_Array*)pOpt)->GetElementValue(1) ->GetUnicodeText();
557 } 557 }
558 FX_BOOL bSelected = FALSE; 558 bool bSelected = false;
559 if (pSels) { 559 if (pSels) {
560 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) { 560 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) {
561 if (i == pSels->GetInteger(s)) { 561 if (i == pSels->GetInteger(s)) {
562 bSelected = TRUE; 562 bSelected = true;
563 break; 563 break;
564 } 564 }
565 } 565 }
566 } 566 }
567 CPDF_VariableText vt; 567 CPDF_VariableText vt;
568 vt.SetProvider(&prd); 568 vt.SetProvider(&prd);
569 vt.SetPlateRect(CPDF_Rect(rcBody.left, 0.0f, rcBody. right, 0.0f)); 569 vt.SetPlateRect(CPDF_Rect(rcBody.left, 0.0f, rcBody. right, 0.0f));
570 if (IsFloatZero(fFontSize)) { 570 if (IsFloatZero(fFontSize)) {
571 vt.SetFontSize(12.0f); 571 vt.SetFontSize(12.0f);
572 } else { 572 } else {
573 vt.SetFontSize(fFontSize); 573 vt.SetFontSize(fFontSize);
574 } 574 }
575 vt.Initialize(); 575 vt.Initialize();
576 vt.SetText(swItem.c_str()); 576 vt.SetText(swItem.c_str());
577 vt.RearrangeAll(); 577 vt.RearrangeAll();
578 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); 578 FX_FLOAT fItemHeight = vt.GetContentRect().Height();
579 if (bSelected) { 579 if (bSelected) {
580 CPDF_Rect rcItem = CPDF_Rect(rcBody.left, fy - f ItemHeight, rcBody.right, fy); 580 CPDF_Rect rcItem = CPDF_Rect(rcBody.left, fy - f ItemHeight, rcBody.right, fy);
581 sBody << "q\n" << CPVT_GenerateAP::GenerateColor AP(CPVT_Color(CT_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), TRUE) 581 sBody << "q\n" << CPVT_GenerateAP::GenerateColor AP(CPVT_Color(CT_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), true)
582 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n"; 582 << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n";
583 sBody << "BT\n" << CPVT_GenerateAP::GenerateColo rAP(CPVT_Color(CT_GRAY, 1), TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.Ge tIterator(), CPDF_Point(0.0f, fy), TRUE, 0) << "ET\n"; 583 sBody << "BT\n" << CPVT_GenerateAP::GenerateColo rAP(CPVT_Color(CT_GRAY, 1), true) << CPVT_GenerateAP::GenerateEditAP(&map, vt.Ge tIterator(), CPDF_Point(0.0f, fy), true, 0) << "ET\n";
584 } else { 584 } else {
585 sBody << "BT\n" << CPVT_GenerateAP::GenerateColo rAP(crText, TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPD F_Point(0.0f, fy), TRUE, 0) << "ET\n"; 585 sBody << "BT\n" << CPVT_GenerateAP::GenerateColo rAP(crText, true) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPD F_Point(0.0f, fy), true, 0) << "ET\n";
586 } 586 }
587 fy -= fItemHeight; 587 fy -= fItemHeight;
588 } 588 }
589 } 589 }
590 } 590 }
591 if (sBody.GetSize() > 0) { 591 if (sBody.GetSize() > 0) {
592 sAppStream << "/Tx BMC\n" << "q\n"; 592 sAppStream << "/Tx BMC\n" << "q\n";
593 sAppStream << rcBody.left << " " << rcBody.bottom << " " 593 sAppStream << rcBody.left << " " << rcBody.bottom << " "
594 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n"; 594 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n";
595 sAppStream << sBody.GetByteString() << "Q\nEMC\n"; 595 sAppStream << sBody.GetByteString() << "Q\nEMC\n";
596 } 596 }
597 } 597 }
598 break; 598 break;
599 } 599 }
600 if (pNormalStream) { 600 if (pNormalStream) {
601 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetS ize(), FALSE, FALSE); 601 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetS ize(), false, false);
602 pStreamDict = pNormalStream->GetDict(); 602 pStreamDict = pNormalStream->GetDict();
603 if (pStreamDict) { 603 if (pStreamDict) {
604 pStreamDict->SetAtMatrix("Matrix", matrix); 604 pStreamDict->SetAtMatrix("Matrix", matrix);
605 pStreamDict->SetAtRect("BBox", rcBBox); 605 pStreamDict->SetAtRect("BBox", rcBBox);
606 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); 606 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
607 if (pStreamResList) { 607 if (pStreamResList) {
608 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("F ont"); 608 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("F ont");
609 if (!pStreamResFontList) { 609 if (!pStreamResFontList) {
610 pStreamResFontList = CPDF_Dictionary::Create(); 610 pStreamResFontList = CPDF_Dictionary::Create();
611 if (pStreamResFontList == NULL) { 611 if (pStreamResFontList == NULL) {
612 return FALSE; 612 return false;
613 } 613 }
614 pStreamResList->SetAt("Font", pStreamResFontList); 614 pStreamResList->SetAt("Font", pStreamResFontList);
615 } 615 }
616 if (!pStreamResFontList->KeyExist(sFontName)) { 616 if (!pStreamResFontList->KeyExist(sFontName)) {
617 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDic t); 617 pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDic t);
618 } 618 }
619 } else { 619 } else {
620 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone( )); 620 pStreamDict->SetAt("Resources", pFormDict->GetDict("DR")->Clone( ));
621 pStreamResList = pStreamDict->GetDict("Resources"); 621 pStreamResList = pStreamDict->GetDict("Resources");
622 } 622 }
623 } 623 }
624 } 624 }
625 return TRUE; 625 return true;
626 } 626 }
627 FX_BOOL CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionar y* pAnnotDict) 627 bool CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
628 { 628 {
629 return GenerateWidgetAP(pDoc, pAnnotDict, 0); 629 return GenerateWidgetAP(pDoc, pAnnotDict, 0);
630 } 630 }
631 FX_BOOL CPVT_GenerateAP::GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary * pAnnotDict) 631 bool CPVT_GenerateAP::GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* p AnnotDict)
632 { 632 {
633 return GenerateWidgetAP(pDoc, pAnnotDict, 1); 633 return GenerateWidgetAP(pDoc, pAnnotDict, 1);
634 } 634 }
635 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) 635 bool CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pA nnotDict)
636 { 636 {
637 return GenerateWidgetAP(pDoc, pAnnotDict, 2); 637 return GenerateWidgetAP(pDoc, pAnnotDict, 2);
638 } 638 }
639 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_Var iableText_Iterator* pIterator, const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord, const CPVT_WordRange * pVisible) 639 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_Var iableText_Iterator* pIterator, const CPDF_Point & ptOffset, bool bContinuous, FX _WORD SubWord, const CPVT_WordRange * pVisible)
640 { 640 {
641 CFX_ByteTextBuf sEditStream, sLineStream, sWords; 641 CFX_ByteTextBuf sEditStream, sLineStream, sWords;
642 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); 642 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
643 int32_t nCurFontIndex = -1; 643 int32_t nCurFontIndex = -1;
644 if (pIterator) { 644 if (pIterator) {
645 if (pVisible) { 645 if (pVisible) {
646 pIterator->SetAt(pVisible->BeginPos); 646 pIterator->SetAt(pVisible->BeginPos);
647 } else { 647 } else {
648 pIterator->SetAt(0); 648 pIterator->SetAt(0);
649 } 649 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 CFX_ByteString sColor; 719 CFX_ByteString sColor;
720 FX_FLOAT fLeft = rect.left; 720 FX_FLOAT fLeft = rect.left;
721 FX_FLOAT fRight = rect.right; 721 FX_FLOAT fRight = rect.right;
722 FX_FLOAT fTop = rect.top; 722 FX_FLOAT fTop = rect.top;
723 FX_FLOAT fBottom = rect.bottom; 723 FX_FLOAT fBottom = rect.bottom;
724 if (fWidth > 0.0f) { 724 if (fWidth > 0.0f) {
725 FX_FLOAT fHalfWidth = fWidth / 2.0f; 725 FX_FLOAT fHalfWidth = fWidth / 2.0f;
726 switch (nStyle) { 726 switch (nStyle) {
727 default: 727 default:
728 case PBS_SOLID: 728 case PBS_SOLID:
729 sColor = GenerateColorAP(color, TRUE); 729 sColor = GenerateColorAP(color, true);
730 if (sColor.GetLength() > 0) { 730 if (sColor.GetLength() > 0) {
731 sAppStream << sColor; 731 sAppStream << sColor;
732 sAppStream << fLeft << " " << fBottom << " " << fRight - fLe ft << " " << fTop - fBottom << " re\n"; 732 sAppStream << fLeft << " " << fBottom << " " << fRight - fLe ft << " " << fTop - fBottom << " re\n";
733 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " 733 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
734 << fRight - fLeft - fWidth * 2 << " " << fTop - f Bottom - fWidth * 2 << " re\n"; 734 << fRight - fLeft - fWidth * 2 << " " << fTop - f Bottom - fWidth * 2 << " re\n";
735 sAppStream << "f*\n"; 735 sAppStream << "f*\n";
736 } 736 }
737 break; 737 break;
738 case PBS_DASH: 738 case PBS_DASH:
739 sColor = GenerateColorAP(color, FALSE); 739 sColor = GenerateColorAP(color, false);
740 if (sColor.GetLength() > 0) { 740 if (sColor.GetLength() > 0) {
741 sAppStream << sColor; 741 sAppStream << sColor;
742 sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n"; 742 sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n";
743 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " m\n"; 743 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " m\n";
744 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 << " l\n"; 744 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
745 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 << " l\n"; 745 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
746 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 << " l\n"; 746 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 << " l\n";
747 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " l S\n"; 747 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " l S\n";
748 } 748 }
749 break; 749 break;
750 case PBS_BEVELED: 750 case PBS_BEVELED:
751 case PBS_INSET: 751 case PBS_INSET:
752 sColor = GenerateColorAP(crLeftTop, TRUE); 752 sColor = GenerateColorAP(crLeftTop, true);
753 if (sColor.GetLength() > 0) { 753 if (sColor.GetLength() > 0) {
754 sAppStream << sColor; 754 sAppStream << sColor;
755 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWi dth << " m\n"; 755 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWi dth << " m\n";
756 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth << " l\n"; 756 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth << " l\n";
757 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidt h << " l\n"; 757 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidt h << " l\n";
758 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalf Width * 2 << " l\n"; 758 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalf Width * 2 << " l\n";
759 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfW idth * 2 << " l\n"; 759 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfW idth * 2 << " l\n";
760 sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHa lfWidth * 2 << " l f\n"; 760 sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHa lfWidth * 2 << " l f\n";
761 } 761 }
762 sColor = GenerateColorAP(crRightBottom, TRUE); 762 sColor = GenerateColorAP(crRightBottom, true);
763 if (sColor.GetLength() > 0) { 763 if (sColor.GetLength() > 0) {
764 sAppStream << sColor; 764 sAppStream << sColor;
765 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidt h << " m\n"; 765 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidt h << " m\n";
766 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfW idth << " l\n"; 766 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfW idth << " l\n";
767 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfW idth << " l\n"; 767 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfW idth << " l\n";
768 sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHa lfWidth * 2 << " l\n"; 768 sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHa lfWidth * 2 << " l\n";
769 sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fH alfWidth * 2 << " l\n"; 769 sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fH alfWidth * 2 << " l\n";
770 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalf Width * 2 << " l f\n"; 770 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalf Width * 2 << " l f\n";
771 } 771 }
772 sColor = GenerateColorAP(color, TRUE); 772 sColor = GenerateColorAP(color, true);
773 if (sColor.GetLength() > 0) { 773 if (sColor.GetLength() > 0) {
774 sAppStream << sColor; 774 sAppStream << sColor;
775 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n"; 775 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
776 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWi dth << " " 776 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWi dth << " "
777 << fRight - fLeft - fHalfWidth * 2 << " " << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; 777 << fRight - fLeft - fHalfWidth * 2 << " " << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
778 } 778 }
779 break; 779 break;
780 case PBS_UNDERLINED: 780 case PBS_UNDERLINED:
781 sColor = GenerateColorAP(color, FALSE); 781 sColor = GenerateColorAP(color, false);
782 if (sColor.GetLength() > 0) { 782 if (sColor.GetLength() > 0) {
783 sAppStream << sColor; 783 sAppStream << sColor;
784 sAppStream << fWidth << " w\n"; 784 sAppStream << fWidth << " w\n";
785 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n" ; 785 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n" ;
786 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S \n"; 786 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S \n";
787 } 787 }
788 break; 788 break;
789 } 789 }
790 } 790 }
791 return sAppStream.GetByteString(); 791 return sAppStream.GetByteString();
792 } 792 }
793 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke) 793 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color & color, const bool & bFillOrStroke)
794 { 794 {
795 CFX_ByteTextBuf sColorStream; 795 CFX_ByteTextBuf sColorStream;
796 switch (color.nColorType) { 796 switch (color.nColorType) {
797 case CT_RGB: 797 case CT_RGB:
798 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo r.fColor3 << " " 798 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo r.fColor3 << " "
799 << (bFillOrStroke ? "rg" : "RG") << "\n"; 799 << (bFillOrStroke ? "rg" : "RG") << "\n";
800 break; 800 break;
801 case CT_GRAY: 801 case CT_GRAY:
802 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") << "\n"; 802 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") << "\n";
803 break; 803 break;
804 case CT_CMYK: 804 case CT_CMYK:
805 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo r.fColor3 << " " << color.fColor4 << " " 805 sColorStream << color.fColor1 << " " << color.fColor2 << " " << colo r.fColor3 << " " << color.fColor4 << " "
806 << (bFillOrStroke ? "k" : "K") << "\n"; 806 << (bFillOrStroke ? "k" : "K") << "\n";
807 break; 807 break;
808 } 808 }
809 return sColorStream.GetByteString(); 809 return sColorStream.GetByteString();
810 } 810 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_basic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698