OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/cpvt_generateap.h" | 7 #include "core/fpdfdoc/cpvt_generateap.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; | 337 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; |
338 sAppStream << sButton << "Q\n"; | 338 sAppStream << sButton << "Q\n"; |
339 } | 339 } |
340 } | 340 } |
341 } break; | 341 } break; |
342 case 2: { | 342 case 2: { |
343 CPVT_FontMap map( | 343 CPVT_FontMap map( |
344 pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, | 344 pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, |
345 pDefFont, sFontName.Right(sFontName.GetLength() - 1)); | 345 pDefFont, sFontName.Right(sFontName.GetLength() - 1)); |
346 CPDF_VariableText::Provider prd(&map); | 346 CPDF_VariableText::Provider prd(&map); |
347 CPDF_Array* pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt") | 347 CPDF_Array* pOpts = ToArray(FPDF_GetFieldAttr(pAnnotDict, "Opt")); |
348 ? FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray() | 348 CPDF_Array* pSels = ToArray(FPDF_GetFieldAttr(pAnnotDict, "I")); |
349 : nullptr; | 349 CPDF_Object* pTi = FPDF_GetFieldAttr(pAnnotDict, "TI"); |
350 CPDF_Array* pSels = FPDF_GetFieldAttr(pAnnotDict, "I") | 350 int32_t nTop = pTi ? pTi->GetInteger() : 0; |
351 ? FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray() | |
352 : nullptr; | |
353 int32_t nTop = FPDF_GetFieldAttr(pAnnotDict, "TI") | |
354 ? FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger() | |
355 : 0; | |
356 CFX_ByteTextBuf sBody; | 351 CFX_ByteTextBuf sBody; |
357 if (pOpts) { | 352 if (pOpts) { |
358 FX_FLOAT fy = rcBody.top; | 353 FX_FLOAT fy = rcBody.top; |
359 for (size_t i = nTop, sz = pOpts->GetCount(); i < sz; i++) { | 354 for (size_t i = nTop, sz = pOpts->GetCount(); i < sz; i++) { |
360 if (IsFloatSmaller(fy, rcBody.bottom)) | 355 if (IsFloatSmaller(fy, rcBody.bottom)) |
361 break; | 356 break; |
362 | 357 |
363 if (CPDF_Object* pOpt = pOpts->GetDirectObjectAt(i)) { | 358 if (CPDF_Object* pOpt = pOpts->GetDirectObjectAt(i)) { |
364 CFX_WideString swItem; | 359 CFX_WideString swItem; |
365 if (pOpt->IsString()) | 360 if (pOpt->IsString()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 403 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
409 CFX_FloatPoint(0.0f, fy), | 404 CFX_FloatPoint(0.0f, fy), |
410 TRUE, 0) | 405 TRUE, 0) |
411 << "ET\n"; | 406 << "ET\n"; |
412 } | 407 } |
413 fy -= fItemHeight; | 408 fy -= fItemHeight; |
414 } | 409 } |
415 } | 410 } |
416 } | 411 } |
417 if (sBody.GetSize() > 0) { | 412 if (sBody.GetSize() > 0) { |
418 sAppStream << "/Tx BMC\n" | 413 sAppStream << "/Tx BMC\nq\n" |
419 << "q\n"; | 414 << rcBody.left << " " << rcBody.bottom << " " |
420 sAppStream << rcBody.left << " " << rcBody.bottom << " " | 415 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n" |
421 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n"; | 416 << sBody.AsStringC() << "Q\nEMC\n"; |
422 sAppStream << sBody.AsStringC() << "Q\nEMC\n"; | |
423 } | 417 } |
424 } break; | 418 } break; |
425 } | 419 } |
426 if (pNormalStream) { | 420 if (pNormalStream) { |
427 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), | 421 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), |
428 sAppStream.GetSize(), FALSE, FALSE); | 422 sAppStream.GetSize(), FALSE, FALSE); |
429 pStreamDict = pNormalStream->GetDict(); | 423 pStreamDict = pNormalStream->GetDict(); |
430 if (pStreamDict) { | 424 if (pStreamDict) { |
431 pStreamDict->SetAtMatrix("Matrix", matrix); | 425 pStreamDict->SetAtMatrix("Matrix", matrix); |
432 pStreamDict->SetAtRect("BBox", rcBBox); | 426 pStreamDict->SetAtRect("BBox", rcBBox); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 int32_t nFontIndex, | 750 int32_t nFontIndex, |
757 FX_FLOAT fFontSize) { | 751 FX_FLOAT fFontSize) { |
758 CFX_ByteTextBuf sRet; | 752 CFX_ByteTextBuf sRet; |
759 if (pFontMap) { | 753 if (pFontMap) { |
760 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 754 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
761 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 755 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
762 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 756 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
763 } | 757 } |
764 return sRet.MakeString(); | 758 return sRet.MakeString(); |
765 } | 759 } |
OLD | NEW |