Index: core/fpdfdoc/cpvt_generateap.cpp |
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp |
index be96d2d1d3bf46bf306f60b0f9d5aa12e81127f1..a2d3b366bc2c56e96f650ef943af6ed265f8b153 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) { |
jaepark
2016/09/07 17:30:09
bIsTextMarkupAnnotation.
In PDF annotation, there
tonikitoo
2016/09/08 04:10:35
Done.
|
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"); |
jaepark
2016/09/07 17:30:09
It seems like this and RectForDrawing is basically
tonikitoo
2016/09/08 04:10:35
Good point. Ideally yes, we could use RectForDrawi
|
pStreamDict->SetAtRect("BBox", rect); |
pStreamDict->SetAt("Resources", pResourceDict); |
@@ -793,7 +795,8 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, |
GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
CPDF_Dictionary* pResourceDict = |
GenerateResourceDict(pExtGStateDict, nullptr); |
- GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
+ false /*IsTextMarkupAnnotation*/); |
return true; |
} |
@@ -807,7 +810,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 +822,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; |
} |
@@ -873,7 +877,8 @@ bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, |
GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
CPDF_Dictionary* pResourceDict = |
GenerateResourceDict(pExtGStateDict, nullptr); |
- GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
+ false /*IsTextMarkupAnnotation*/); |
return true; |
} |
@@ -895,7 +900,8 @@ bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, |
GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
CPDF_Dictionary* pResourceDict = |
GenerateResourceDict(pExtGStateDict, nullptr); |
- GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
+ false /*IsTextMarkupAnnotation*/); |
return true; |
} |
@@ -909,7 +915,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 +927,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; |
} |
@@ -959,7 +966,8 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, |
return false; |
sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName); |
- GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
+ false /*IsTextMarkupAnnotation*/); |
return true; |
} |
@@ -1006,7 +1014,8 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, |
GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
CPDF_Dictionary* pResourceDict = |
GenerateResourceDict(pExtGStateDict, nullptr); |
- GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict); |
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict, |
+ false /*IsTextMarkupAnnotation*/); |
return true; |
} |
@@ -1020,7 +1029,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 +1063,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 +1078,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 +1090,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; |
} |