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 <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "core/fpdfapi/font/cpdf_font.h" | 13 #include "core/fpdfapi/font/cpdf_font.h" |
| 14 #include "core/fpdfapi/parser/cpdf_boolean.h" |
14 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 15 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
15 #include "core/fpdfapi/parser/cpdf_document.h" | 16 #include "core/fpdfapi/parser/cpdf_document.h" |
| 17 #include "core/fpdfapi/parser/cpdf_name.h" |
| 18 #include "core/fpdfapi/parser/cpdf_number.h" |
| 19 #include "core/fpdfapi/parser/cpdf_reference.h" |
16 #include "core/fpdfapi/parser/cpdf_simple_parser.h" | 20 #include "core/fpdfapi/parser/cpdf_simple_parser.h" |
17 #include "core/fpdfapi/parser/cpdf_stream.h" | 21 #include "core/fpdfapi/parser/cpdf_stream.h" |
| 22 #include "core/fpdfapi/parser/cpdf_string.h" |
18 #include "core/fpdfapi/parser/fpdf_parser_decode.h" | 23 #include "core/fpdfapi/parser/fpdf_parser_decode.h" |
19 #include "core/fpdfdoc/cpdf_annot.h" | 24 #include "core/fpdfdoc/cpdf_annot.h" |
20 #include "core/fpdfdoc/cpdf_formfield.h" | 25 #include "core/fpdfdoc/cpdf_formfield.h" |
21 #include "core/fpdfdoc/cpvt_color.h" | 26 #include "core/fpdfdoc/cpvt_color.h" |
22 #include "core/fpdfdoc/cpvt_fontmap.h" | 27 #include "core/fpdfdoc/cpvt_fontmap.h" |
23 #include "core/fpdfdoc/cpvt_word.h" | 28 #include "core/fpdfdoc/cpvt_word.h" |
24 #include "third_party/base/ptr_util.h" | 29 #include "third_party/base/ptr_util.h" |
25 | 30 |
26 namespace { | 31 namespace { |
27 | 32 |
(...skipping 27 matching lines...) Expand all Loading... |
55 if (!pDRDict) | 60 if (!pDRDict) |
56 return false; | 61 return false; |
57 | 62 |
58 CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font"); | 63 CPDF_Dictionary* pDRFontDict = pDRDict->GetDictFor("Font"); |
59 if (!pDRFontDict) | 64 if (!pDRFontDict) |
60 return false; | 65 return false; |
61 | 66 |
62 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1)); | 67 CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1)); |
63 if (!pFontDict) { | 68 if (!pFontDict) { |
64 pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); | 69 pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); |
65 pFontDict->SetNameFor("Type", "Font"); | 70 pFontDict->SetNewFor<CPDF_Name>("Type", "Font"); |
66 pFontDict->SetNameFor("Subtype", "Type1"); | 71 pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); |
67 pFontDict->SetNameFor("BaseFont", "Helvetica"); | 72 pFontDict->SetNewFor<CPDF_Name>("BaseFont", "Helvetica"); |
68 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 73 pFontDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); |
69 pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc, pFontDict); | 74 pDRFontDict->SetNewFor<CPDF_Reference>(sFontName.Mid(1), pDoc, |
| 75 pFontDict->GetObjNum()); |
70 } | 76 } |
71 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); | 77 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); |
72 if (!pDefFont) | 78 if (!pDefFont) |
73 return false; | 79 return false; |
74 | 80 |
75 CFX_FloatRect rcAnnot = pAnnotDict->GetRectFor("Rect"); | 81 CFX_FloatRect rcAnnot = pAnnotDict->GetRectFor("Rect"); |
76 int32_t nRotate = 0; | 82 int32_t nRotate = 0; |
77 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictFor("MK")) | 83 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictFor("MK")) |
78 nRotate = pMKDict->GetIntegerFor("R"); | 84 nRotate = pMKDict->GetIntegerFor("R"); |
79 | 85 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( | 162 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( |
157 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, | 163 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, |
158 dsBorder); | 164 dsBorder); |
159 if (sBorderStream.GetLength() > 0) | 165 if (sBorderStream.GetLength() > 0) |
160 sAppStream << "q\n" << sBorderStream << "Q\n"; | 166 sAppStream << "q\n" << sBorderStream << "Q\n"; |
161 | 167 |
162 CFX_FloatRect rcBody = | 168 CFX_FloatRect rcBody = |
163 CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, | 169 CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, |
164 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); | 170 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); |
165 rcBody.Normalize(); | 171 rcBody.Normalize(); |
| 172 |
166 CPDF_Dictionary* pAPDict = pAnnotDict->GetDictFor("AP"); | 173 CPDF_Dictionary* pAPDict = pAnnotDict->GetDictFor("AP"); |
167 if (!pAPDict) { | 174 if (!pAPDict) |
168 auto pNewAPDict = | 175 pAPDict = pAnnotDict->SetNewFor<CPDF_Dictionary>("AP"); |
169 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 176 |
170 // Ownership passes to |pAnnotDict|. | |
171 pAPDict = pNewAPDict.release(); | |
172 pAnnotDict->SetFor("AP", pAPDict); | |
173 } | |
174 CPDF_Stream* pNormalStream = pAPDict->GetStreamFor("N"); | 177 CPDF_Stream* pNormalStream = pAPDict->GetStreamFor("N"); |
175 if (!pNormalStream) { | 178 if (!pNormalStream) { |
176 pNormalStream = pDoc->NewIndirect<CPDF_Stream>(); | 179 pNormalStream = pDoc->NewIndirect<CPDF_Stream>(); |
177 pAPDict->SetReferenceFor("N", pDoc, pNormalStream); | 180 pAPDict->SetNewFor<CPDF_Reference>("N", pDoc, pNormalStream->GetObjNum()); |
178 } | 181 } |
179 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); | 182 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); |
180 if (pStreamDict) { | 183 if (pStreamDict) { |
181 pStreamDict->SetMatrixFor("Matrix", matrix); | 184 pStreamDict->SetMatrixFor("Matrix", matrix); |
182 pStreamDict->SetRectFor("BBox", rcBBox); | 185 pStreamDict->SetRectFor("BBox", rcBBox); |
183 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); | 186 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); |
184 if (pStreamResList) { | 187 if (pStreamResList) { |
185 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); | 188 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); |
186 if (!pStreamResFontList) { | 189 if (!pStreamResFontList) |
187 auto pNewStreamResFontList = | 190 pStreamResFontList = pStreamResList->SetNewFor<CPDF_Dictionary>("Font"); |
188 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 191 if (!pStreamResFontList->KeyExist(sFontName)) { |
189 // Ownership passes to |pStreamResList|. | 192 pStreamResFontList->SetNewFor<CPDF_Reference>(sFontName, pDoc, |
190 pStreamResFontList = pNewStreamResFontList.release(); | 193 pFontDict->GetObjNum()); |
191 pStreamResList->SetFor("Font", pStreamResFontList); | |
192 } | 194 } |
193 if (!pStreamResFontList->KeyExist(sFontName)) | |
194 pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict); | |
195 } else { | 195 } else { |
196 pStreamDict->SetFor("Resources", | 196 pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); |
197 pFormDict->GetDictFor("DR")->Clone().release()); | |
198 pStreamResList = pStreamDict->GetDictFor("Resources"); | 197 pStreamResList = pStreamDict->GetDictFor("Resources"); |
199 } | 198 } |
200 } | 199 } |
201 switch (nWidgetType) { | 200 switch (nWidgetType) { |
202 case 0: { | 201 case 0: { |
203 CFX_WideString swValue = | 202 CFX_WideString swValue = |
204 FPDF_GetFieldAttr(pAnnotDict, "V") | 203 FPDF_GetFieldAttr(pAnnotDict, "V") |
205 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() | 204 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() |
206 : CFX_WideString(); | 205 : CFX_WideString(); |
207 int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q") | 206 int32_t nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q") |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize()); | 430 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize()); |
432 pStreamDict = pNormalStream->GetDict(); | 431 pStreamDict = pNormalStream->GetDict(); |
433 if (pStreamDict) { | 432 if (pStreamDict) { |
434 pStreamDict->SetMatrixFor("Matrix", matrix); | 433 pStreamDict->SetMatrixFor("Matrix", matrix); |
435 pStreamDict->SetRectFor("BBox", rcBBox); | 434 pStreamDict->SetRectFor("BBox", rcBBox); |
436 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); | 435 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); |
437 if (pStreamResList) { | 436 if (pStreamResList) { |
438 CPDF_Dictionary* pStreamResFontList = | 437 CPDF_Dictionary* pStreamResFontList = |
439 pStreamResList->GetDictFor("Font"); | 438 pStreamResList->GetDictFor("Font"); |
440 if (!pStreamResFontList) { | 439 if (!pStreamResFontList) { |
441 auto pNewStreamResFontList = | 440 pStreamResFontList = |
442 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 441 pStreamResList->SetNewFor<CPDF_Dictionary>("Font"); |
443 // Ownership passes to |pStreamResList|. | |
444 pStreamResFontList = pNewStreamResFontList.release(); | |
445 pStreamResList->SetFor("Font", pStreamResFontList); | |
446 } | 442 } |
447 if (!pStreamResFontList->KeyExist(sFontName)) | 443 if (!pStreamResFontList->KeyExist(sFontName)) { |
448 pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict); | 444 pStreamResFontList->SetNewFor<CPDF_Reference>(sFontName, pDoc, |
| 445 pFontDict->GetObjNum()); |
| 446 } |
449 } else { | 447 } else { |
450 pStreamDict->SetFor("Resources", | 448 pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); |
451 pFormDict->GetDictFor("DR")->Clone().release()); | |
452 pStreamResList = pStreamDict->GetDictFor("Resources"); | 449 pStreamResList = pStreamDict->GetDictFor("Resources"); |
453 } | 450 } |
454 } | 451 } |
455 } | 452 } |
456 return true; | 453 return true; |
457 } | 454 } |
458 | 455 |
459 CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor, | 456 CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor, |
460 const CPVT_Color& crDefaultColor, | 457 const CPVT_Color& crDefaultColor, |
461 PaintOperation nOperation) { | 458 PaintOperation nOperation) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 << "Q\n"; | 544 << "Q\n"; |
548 return sAppStream.MakeString(); | 545 return sAppStream.MakeString(); |
549 } | 546 } |
550 | 547 |
551 std::unique_ptr<CPDF_Dictionary> GenerateExtGStateDict( | 548 std::unique_ptr<CPDF_Dictionary> GenerateExtGStateDict( |
552 const CPDF_Dictionary& pAnnotDict, | 549 const CPDF_Dictionary& pAnnotDict, |
553 const CFX_ByteString& sExtGSDictName, | 550 const CFX_ByteString& sExtGSDictName, |
554 const CFX_ByteString& sBlendMode) { | 551 const CFX_ByteString& sBlendMode) { |
555 auto pGSDict = | 552 auto pGSDict = |
556 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); | 553 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); |
557 pGSDict->SetStringFor("Type", "ExtGState"); | 554 pGSDict->SetNewFor<CPDF_String>("Type", "ExtGState", false); |
558 | 555 |
559 FX_FLOAT fOpacity = | 556 FX_FLOAT fOpacity = |
560 pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1; | 557 pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1; |
561 pGSDict->SetNumberFor("CA", fOpacity); | 558 pGSDict->SetNewFor<CPDF_Number>("CA", fOpacity); |
562 pGSDict->SetNumberFor("ca", fOpacity); | 559 pGSDict->SetNewFor<CPDF_Number>("ca", fOpacity); |
563 pGSDict->SetBooleanFor("AIS", false); | 560 pGSDict->SetNewFor<CPDF_Boolean>("AIS", false); |
564 pGSDict->SetStringFor("BM", sBlendMode); | 561 pGSDict->SetNewFor<CPDF_String>("BM", sBlendMode, false); |
565 | 562 |
566 auto pExtGStateDict = | 563 auto pExtGStateDict = |
567 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); | 564 pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); |
568 pExtGStateDict->SetFor(sExtGSDictName, pGSDict.release()); | 565 pExtGStateDict->SetFor(sExtGSDictName, std::move(pGSDict)); |
569 return pExtGStateDict; | 566 return pExtGStateDict; |
570 } | 567 } |
571 | 568 |
572 std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( | 569 std::unique_ptr<CPDF_Dictionary> GenerateResourceFontDict( |
573 CPDF_Document* pDoc, | 570 CPDF_Document* pDoc, |
574 const CFX_ByteString& sFontDictName) { | 571 const CFX_ByteString& sFontDictName) { |
575 CPDF_Dictionary* pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); | 572 CPDF_Dictionary* pFontDict = pDoc->NewIndirect<CPDF_Dictionary>(); |
576 pFontDict->SetNameFor("Type", "Font"); | 573 pFontDict->SetNewFor<CPDF_Name>("Type", "Font"); |
577 pFontDict->SetNameFor("Subtype", "Type1"); | 574 pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); |
578 pFontDict->SetNameFor("BaseFont", "Helvetica"); | 575 pFontDict->SetNewFor<CPDF_Name>("BaseFont", "Helvetica"); |
579 pFontDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 576 pFontDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); |
580 | 577 |
581 auto pResourceFontDict = | 578 auto pResourceFontDict = |
582 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 579 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); |
583 pResourceFontDict->SetReferenceFor(sFontDictName, pDoc, pFontDict); | 580 pResourceFontDict->SetNewFor<CPDF_Reference>(sFontDictName, pDoc, |
| 581 pFontDict->GetObjNum()); |
584 return pResourceFontDict; | 582 return pResourceFontDict; |
585 } | 583 } |
586 | 584 |
587 std::unique_ptr<CPDF_Dictionary> GenerateResourceDict( | 585 std::unique_ptr<CPDF_Dictionary> GenerateResourceDict( |
588 CPDF_Document* pDoc, | 586 CPDF_Document* pDoc, |
589 std::unique_ptr<CPDF_Dictionary> pExtGStateDict, | 587 std::unique_ptr<CPDF_Dictionary> pExtGStateDict, |
590 std::unique_ptr<CPDF_Dictionary> pResourceFontDict) { | 588 std::unique_ptr<CPDF_Dictionary> pResourceFontDict) { |
591 auto pResourceDict = | 589 auto pResourceDict = |
592 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 590 pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); |
593 if (pExtGStateDict) | 591 if (pExtGStateDict) |
594 pResourceDict->SetFor("ExtGState", pExtGStateDict.release()); | 592 pResourceDict->SetFor("ExtGState", std::move(pExtGStateDict)); |
595 if (pResourceFontDict) | 593 if (pResourceFontDict) |
596 pResourceDict->SetFor("Font", pResourceFontDict.release()); | 594 pResourceDict->SetFor("Font", std::move(pResourceFontDict)); |
597 return pResourceDict; | 595 return pResourceDict; |
598 } | 596 } |
599 | 597 |
600 void GenerateAndSetAPDict(CPDF_Document* pDoc, | 598 void GenerateAndSetAPDict(CPDF_Document* pDoc, |
601 CPDF_Dictionary* pAnnotDict, | 599 CPDF_Dictionary* pAnnotDict, |
602 const CFX_ByteTextBuf& sAppStream, | 600 const CFX_ByteTextBuf& sAppStream, |
603 std::unique_ptr<CPDF_Dictionary> pResourceDict, | 601 std::unique_ptr<CPDF_Dictionary> pResourceDict, |
604 bool bIsTextMarkupAnnotation) { | 602 bool bIsTextMarkupAnnotation) { |
605 CPDF_Stream* pNormalStream = pDoc->NewIndirect<CPDF_Stream>(); | 603 CPDF_Stream* pNormalStream = pDoc->NewIndirect<CPDF_Stream>(); |
606 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize()); | 604 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize()); |
607 | 605 |
608 auto pAPDict = pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()); | 606 CPDF_Dictionary* pAPDict = pAnnotDict->SetNewFor<CPDF_Dictionary>("AP"); |
609 pAPDict->SetReferenceFor("N", pDoc, pNormalStream); | 607 pAPDict->SetNewFor<CPDF_Reference>("N", pDoc, pNormalStream->GetObjNum()); |
610 pAnnotDict->SetFor("AP", pAPDict.release()); | |
611 | 608 |
612 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); | 609 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); |
613 pStreamDict->SetIntegerFor("FormType", 1); | 610 pStreamDict->SetNewFor<CPDF_Number>("FormType", 1); |
614 pStreamDict->SetStringFor("Subtype", "Form"); | 611 pStreamDict->SetNewFor<CPDF_String>("Subtype", "Form", false); |
615 pStreamDict->SetMatrixFor("Matrix", CFX_Matrix()); | 612 pStreamDict->SetMatrixFor("Matrix", CFX_Matrix()); |
616 | 613 |
617 CFX_FloatRect rect = bIsTextMarkupAnnotation | 614 CFX_FloatRect rect = bIsTextMarkupAnnotation |
618 ? CPDF_Annot::RectFromQuadPoints(pAnnotDict) | 615 ? CPDF_Annot::RectFromQuadPoints(pAnnotDict) |
619 : pAnnotDict->GetRectFor("Rect"); | 616 : pAnnotDict->GetRectFor("Rect"); |
620 pStreamDict->SetRectFor("BBox", rect); | 617 pStreamDict->SetRectFor("BBox", rect); |
621 pStreamDict->SetFor("Resources", pResourceDict.release()); | 618 pStreamDict->SetFor("Resources", std::move(pResourceDict)); |
622 } | 619 } |
623 | 620 |
624 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { | 621 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { |
625 if (bIsStrokeRect) | 622 if (bIsStrokeRect) |
626 return bIsFillRect ? "b" : "s"; | 623 return bIsFillRect ? "b" : "s"; |
627 return bIsFillRect ? "f" : "n"; | 624 return bIsFillRect ? "f" : "n"; |
628 } | 625 } |
629 | 626 |
630 CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { | 627 CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { |
631 CFX_ByteTextBuf sAppStream; | 628 CFX_ByteTextBuf sAppStream; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 CPDF_Object* pFieldTypeObj = FPDF_GetFieldAttr(pAnnotDict, "FT"); | 683 CPDF_Object* pFieldTypeObj = FPDF_GetFieldAttr(pAnnotDict, "FT"); |
687 if (!pFieldTypeObj) | 684 if (!pFieldTypeObj) |
688 return false; | 685 return false; |
689 | 686 |
690 CFX_ByteString field_type = pFieldTypeObj->GetString(); | 687 CFX_ByteString field_type = pFieldTypeObj->GetString(); |
691 if (field_type == "Tx") | 688 if (field_type == "Tx") |
692 return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); | 689 return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict); |
693 | 690 |
694 CPDF_Object* pFieldFlagsObj = FPDF_GetFieldAttr(pAnnotDict, "Ff"); | 691 CPDF_Object* pFieldFlagsObj = FPDF_GetFieldAttr(pAnnotDict, "Ff"); |
695 uint32_t flags = pFieldFlagsObj ? pFieldFlagsObj->GetInteger() : 0; | 692 uint32_t flags = pFieldFlagsObj ? pFieldFlagsObj->GetInteger() : 0; |
696 | |
697 if (field_type == "Ch") { | 693 if (field_type == "Ch") { |
698 return (flags & (1 << 17)) | 694 return (flags & (1 << 17)) |
699 ? CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) | 695 ? CPVT_GenerateAP::GenerateComboBoxAP(pDoc, pAnnotDict) |
700 : CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); | 696 : CPVT_GenerateAP::GenerateListBoxAP(pDoc, pAnnotDict); |
701 } | 697 } |
702 | 698 |
703 if (field_type == "Btn") { | 699 if (field_type == "Btn") { |
704 if (!(flags & (1 << 16))) { | 700 if (!(flags & (1 << 16))) { |
705 if (!pAnnotDict->KeyExist("AS")) { | 701 if (!pAnnotDict->KeyExist("AS")) { |
706 if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent")) { | 702 if (CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent")) { |
707 if (pParentDict->KeyExist("AS")) { | 703 if (pParentDict->KeyExist("AS")) { |
708 pAnnotDict->SetStringFor("AS", pParentDict->GetStringFor("AS")); | 704 pAnnotDict->SetNewFor<CPDF_String>( |
| 705 "AS", pParentDict->GetStringFor("AS"), false); |
709 } | 706 } |
710 } | 707 } |
711 } | 708 } |
712 } | 709 } |
713 } | 710 } |
714 | 711 |
715 return false; | 712 return false; |
716 } | 713 } |
717 | 714 |
718 // Static. | 715 // Static. |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 int32_t nFontIndex, | 1358 int32_t nFontIndex, |
1362 FX_FLOAT fFontSize) { | 1359 FX_FLOAT fFontSize) { |
1363 CFX_ByteTextBuf sRet; | 1360 CFX_ByteTextBuf sRet; |
1364 if (pFontMap) { | 1361 if (pFontMap) { |
1365 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 1362 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
1366 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 1363 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
1367 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 1364 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
1368 } | 1365 } |
1369 return sRet.MakeString(); | 1366 return sRet.MakeString(); |
1370 } | 1367 } |
OLD | NEW |