Chromium Code Reviews| Index: core/fpdfdoc/cpvt_generateap.cpp |
| diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp |
| index 7eb6188c94baeba8c2e58c2f5f88abf9b953b1ff..dedd412a746e56929b7c7b101ca9ae8c462a3866 100644 |
| --- a/core/fpdfdoc/cpvt_generateap.cpp |
| +++ b/core/fpdfdoc/cpvt_generateap.cpp |
| @@ -493,6 +493,66 @@ FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, |
| return GenerateWidgetAP(pDoc, pAnnotDict, 2); |
| } |
| +FX_BOOL CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, |
| + CPDF_Dictionary* pAnnotDict) { |
| + // If AP dictionary exists, we use the appearance defined in the |
| + // existing AP dictionary. |
| + if (pAnnotDict->KeyExist("AP")) |
| + return FALSE; |
| + |
| + CFX_ByteTextBuf sAppStream; |
| + sAppStream << "/TransGs gs "; |
| + |
| + if (pAnnotDict->KeyExist("C")) { |
| + CPDF_Array* pColor = pAnnotDict->GetArrayBy("C"); |
| + CPVT_Color color = CPVT_Color::ParseColor(*pColor); |
| + sAppStream << CPVT_GenerateAP::GenerateColorAP(color, TRUE); |
| + } else { |
| + // Defaults to 0xFFFF0 color for highlight. |
|
Lei Zhang
2016/07/29 22:20:50
0xFFFF00 ?
jaepark
2016/07/29 23:32:26
Done.
|
| + sAppStream << "1 1 0 rg \n"; |
| + } |
| + |
| + CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + rect.Normalize(); |
| + |
| + sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
| + << rect.top << " l " << rect.right << " " << rect.bottom << " l " |
| + << rect.left << " " << rect.bottom << " l " |
| + << "h f\n"; |
| + |
| + CPDF_Dictionary* pAPDict = new CPDF_Dictionary; |
| + pAnnotDict->SetAt("AP", pAPDict); |
| + |
| + CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); |
| + int32_t objnum = pDoc->AddIndirectObject(pNormalStream); |
| + pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); |
| + |
| + pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetSize(), |
|
Lei Zhang
2016/07/29 22:20:50
No C-style casting. Use static_cast or reinterpret
jaepark
2016/07/29 23:32:26
Done.
|
| + FALSE, FALSE); |
| + |
| + CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); |
| + pStreamDict->SetAtInteger("FormType", 1); |
| + pStreamDict->SetAtString("Subtype", "Form"); |
| + pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); |
| + pStreamDict->SetAtRect("BBox", rect); |
| + |
| + CPDF_Dictionary* pTransGsDict = new CPDF_Dictionary; |
| + pTransGsDict->SetAtString("Type", "ExtGState"); |
| + pTransGsDict->SetAtInteger("ca", 1); |
| + pTransGsDict->SetAtString("CA", 1); |
| + pTransGsDict->SetAtBoolean("AIS", false); |
| + pTransGsDict->SetAtString("BM", "Multiply"); |
| + |
| + CPDF_Dictionary* pExtGStateDict = new CPDF_Dictionary; |
| + pExtGStateDict->SetAt("TransGs", pTransGsDict); |
|
Lei Zhang
2016/07/29 22:20:50
So if we have multiple highlight annotations, can
jaepark
2016/07/29 23:32:26
We can reuse "TransGs" because the scope of a name
Lei Zhang
2016/07/30 00:56:44
How about just "GS" then?
jaepark
2016/07/30 01:28:27
Done.
|
| + |
| + CPDF_Dictionary* pResourceDict = new CPDF_Dictionary; |
| + pResourceDict->SetAt("ExtGState", pExtGStateDict); |
| + |
| + pStreamDict->SetAt("Resources", pResourceDict); |
| + return TRUE; |
| +} |
| + |
| // Static. |
| CFX_ByteString CPVT_GenerateAP::GenerateEditAP( |
| IPVT_FontMap* pFontMap, |