Chromium Code Reviews| Index: core/fpdfdoc/cpvt_generateap.cpp |
| diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp |
| index be96d2d1d3bf46bf306f60b0f9d5aa12e81127f1..908b839f6a2513892cee3db0cb5f086dc8ca0f05 100644 |
| --- a/core/fpdfdoc/cpvt_generateap.cpp |
| +++ b/core/fpdfdoc/cpvt_generateap.cpp |
| @@ -596,7 +596,8 @@ CPDF_Dictionary* GenerateResourceDict(CPDF_Dictionary* pExtGStateDict, |
| void GenerateAndSetAPDict(CPDF_Document* pDoc, |
| CPDF_Dictionary* pAnnotDict, |
| const CFX_ByteTextBuf& sAppStream, |
| - CPDF_Dictionary* pResourceDict) { |
| + CPDF_Dictionary* pResourceDict, |
| + bool bIsTextAnnotation = false) { |
|
Lei Zhang
2016/09/06 21:27:03
I would highly prefer we don't have default argume
|
| CPDF_Dictionary* pAPDict = new CPDF_Dictionary; |
| pAnnotDict->SetAt("AP", pAPDict); |
| @@ -612,7 +613,8 @@ void GenerateAndSetAPDict(CPDF_Document* pDoc, |
| pStreamDict->SetAtString("Subtype", "Form"); |
| pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); |
| - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + CFX_FloatRect rect = bIsTextAnnotation ? CPDF_Annot::RectFromQuads(pAnnotDict) |
| + : pAnnotDict->GetRectBy("Rect"); |
| pStreamDict->SetAtRect("BBox", rect); |
| pStreamDict->SetAt("Resources", pResourceDict); |
| @@ -807,7 +809,7 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, |
| CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), |
| PaintOperation::FILL); |
| - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
| rect.Normalize(); |
| sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
| @@ -819,7 +821,8 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, |
| GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply"); |
| CPDF_Dictionary* pResourceDict = |
| GenerateResourceDict(pExtGStateDict, nullptr); |
| - GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
| + GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
| + true /*IsTextMarkupAnnotation*/); |
| return true; |
| } |
| @@ -909,7 +912,7 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, |
| CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
| PaintOperation::STROKE); |
| - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
| rect.Normalize(); |
| FX_FLOAT fLineWidth = 1.0; |
| @@ -921,7 +924,8 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, |
| GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
| CPDF_Dictionary* pResourceDict = |
| GenerateResourceDict(pExtGStateDict, nullptr); |
| - GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
| + GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
| + true /*IsTextMarkupAnnotation*/); |
| return true; |
| } |
| @@ -1020,7 +1024,7 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, |
| CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
| PaintOperation::STROKE); |
| - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
| rect.Normalize(); |
| FX_FLOAT fLineWidth = 1.0; |
| @@ -1054,7 +1058,8 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, |
| GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
| CPDF_Dictionary* pResourceDict = |
| GenerateResourceDict(pExtGStateDict, nullptr); |
| - GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
| + GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
| + true /*IsTextMarkupAnnotation*/); |
| return true; |
| } |
| @@ -1068,7 +1073,7 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, |
| CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
| PaintOperation::STROKE); |
| - CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| + CFX_FloatRect rect = CPDF_Annot::RectFromQuads(pAnnotDict); |
| rect.Normalize(); |
| FX_FLOAT fLineWidth = 1.0; |
| @@ -1080,7 +1085,8 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, |
| GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
| CPDF_Dictionary* pResourceDict = |
| GenerateResourceDict(pExtGStateDict, nullptr); |
| - GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
| + GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
| + true /*IsTextMarkupAnnotation*/); |
| return true; |
| } |