OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 m_pTypeList = FX_Alloc(uint8_t, alloc_size); | 90 m_pTypeList = FX_Alloc(uint8_t, alloc_size); |
91 } | 91 } |
92 if (text_count) { | 92 if (text_count) { |
93 m_TextCount = text_count; | 93 m_TextCount = text_count; |
94 m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); | 94 m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); |
95 } | 95 } |
96 } | 96 } |
97 CPDF_Rect CPDF_ClipPath::GetClipBox() const | 97 CPDF_Rect CPDF_ClipPath::GetClipBox() const |
98 { | 98 { |
99 CPDF_Rect rect; | 99 CPDF_Rect rect; |
100 FX_BOOL bStarted = FALSE; | 100 bool bStarted = false; |
101 int count = GetPathCount(); | 101 int count = GetPathCount(); |
102 if (count) { | 102 if (count) { |
103 rect = GetPath(0).GetBoundingBox(); | 103 rect = GetPath(0).GetBoundingBox(); |
104 for (int i = 1; i < count; i ++) { | 104 for (int i = 1; i < count; i ++) { |
105 CPDF_Rect path_rect = GetPath(i).GetBoundingBox(); | 105 CPDF_Rect path_rect = GetPath(i).GetBoundingBox(); |
106 rect.Intersect(path_rect); | 106 rect.Intersect(path_rect); |
107 } | 107 } |
108 bStarted = TRUE; | 108 bStarted = true; |
109 } | 109 } |
110 count = GetTextCount(); | 110 count = GetTextCount(); |
111 if (count) { | 111 if (count) { |
112 CPDF_Rect layer_rect; | 112 CPDF_Rect layer_rect; |
113 FX_BOOL bLayerStarted = FALSE; | 113 bool bLayerStarted = false; |
114 for (int i = 0; i < count; i ++) { | 114 for (int i = 0; i < count; i ++) { |
115 CPDF_TextObject* pTextObj = GetText(i); | 115 CPDF_TextObject* pTextObj = GetText(i); |
116 if (pTextObj == NULL) { | 116 if (pTextObj == NULL) { |
117 if (!bStarted) { | 117 if (!bStarted) { |
118 rect = layer_rect; | 118 rect = layer_rect; |
119 bStarted = TRUE; | 119 bStarted = true; |
120 } else { | 120 } else { |
121 rect.Intersect(layer_rect); | 121 rect.Intersect(layer_rect); |
122 } | 122 } |
123 bLayerStarted = FALSE; | 123 bLayerStarted = false; |
124 } else { | 124 } else { |
125 if (!bLayerStarted) { | 125 if (!bLayerStarted) { |
126 layer_rect = pTextObj->GetBBox(NULL); | 126 layer_rect = pTextObj->GetBBox(NULL); |
127 bLayerStarted = TRUE; | 127 bLayerStarted = true; |
128 } else { | 128 } else { |
129 layer_rect.Union(pTextObj->GetBBox(NULL)); | 129 layer_rect.Union(pTextObj->GetBBox(NULL)); |
130 } | 130 } |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 return rect; | 134 return rect; |
135 } | 135 } |
136 void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge) | 136 void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, bool bAutoMerge) |
137 { | 137 { |
138 CPDF_ClipPathData* pData = GetModify(); | 138 CPDF_ClipPathData* pData = GetModify(); |
139 if (pData->m_PathCount && bAutoMerge) { | 139 if (pData->m_PathCount && bAutoMerge) { |
140 CPDF_Path old_path = pData->m_pPathList[pData->m_PathCount - 1]; | 140 CPDF_Path old_path = pData->m_pPathList[pData->m_PathCount - 1]; |
141 if (old_path.IsRect()) { | 141 if (old_path.IsRect()) { |
142 CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), | 142 CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), |
143 old_path.GetPointX(2), old_path.GetPointY(2)); | 143 old_path.GetPointX(2), old_path.GetPointY(2)); |
144 CPDF_Rect new_rect = path.GetBoundingBox(); | 144 CPDF_Rect new_rect = path.GetBoundingBox(); |
145 if (old_rect.Contains(new_rect)) { | 145 if (old_rect.Contains(new_rect)) { |
146 pData->m_PathCount --; | 146 pData->m_PathCount --; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 color.SetValue(pValue); | 250 color.SetValue(pValue); |
251 int R, G, B; | 251 int R, G, B; |
252 rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1; | 252 rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1; |
253 } | 253 } |
254 void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue, i
nt nValues) | 254 void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue, i
nt nValues) |
255 { | 255 { |
256 CPDF_ColorStateData* pData = GetModify(); | 256 CPDF_ColorStateData* pData = GetModify(); |
257 pData->m_FillColor.SetValue(pPattern, pValue, nValues); | 257 pData->m_FillColor.SetValue(pPattern, pValue, nValues); |
258 int R, G, B; | 258 int R, G, B; |
259 FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B); | 259 bool ret = pData->m_FillColor.GetRGB(R, G, B); |
260 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo
red && !ret) { | 260 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo
red && !ret) { |
261 pData->m_FillRGB = 0x00BFBFBF; | 261 pData->m_FillRGB = 0x00BFBFBF; |
262 return; | 262 return; |
263 } | 263 } |
264 pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1; | 264 pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (FX_DWORD) - 1; |
265 } | 265 } |
266 void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue,
int nValues) | 266 void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue,
int nValues) |
267 { | 267 { |
268 CPDF_ColorStateData* pData = GetModify(); | 268 CPDF_ColorStateData* pData = GetModify(); |
269 pData->m_StrokeColor.SetValue(pPattern, pValue, nValues); | 269 pData->m_StrokeColor.SetValue(pPattern, pValue, nValues); |
270 int R, G, B; | 270 int R, G, B; |
271 FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B); | 271 bool ret = pData->m_StrokeColor.GetRGB(R, G, B); |
272 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo
red && !ret) { | 272 if (pPattern->m_PatternType == 1 && ((CPDF_TilingPattern*)pPattern)->m_bColo
red && !ret) { |
273 pData->m_StrokeRGB = 0x00BFBFBF; | 273 pData->m_StrokeRGB = 0x00BFBFBF; |
274 return; | 274 return; |
275 } | 275 } |
276 pData->m_StrokeRGB = pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G,
B) : (FX_DWORD) - 1; | 276 pData->m_StrokeRGB = pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G,
B) : (FX_DWORD) - 1; |
277 } | 277 } |
278 CPDF_TextStateData::CPDF_TextStateData() | 278 CPDF_TextStateData::CPDF_TextStateData() |
279 { | 279 { |
280 m_pFont = NULL; | 280 m_pFont = NULL; |
281 m_pDocument = NULL; | 281 m_pDocument = NULL; |
282 m_FontSize = 1.0f; | 282 m_FontSize = 1.0f; |
283 m_WordSpace = 0; | 283 m_WordSpace = 0; |
284 m_CharSpace = 0; | 284 m_CharSpace = 0; |
285 m_TextMode = 0; | 285 m_TextMode = 0; |
286 m_Matrix[0] = m_Matrix[3] = 1.0f; | 286 m_Matrix[0] = m_Matrix[3] = 1.0f; |
287 m_Matrix[1] = m_Matrix[2] = 0; | 287 m_Matrix[1] = m_Matrix[2] = 0; |
288 m_CTM[0] = m_CTM[3] = 1.0f; | 288 m_CTM[0] = m_CTM[3] = 1.0f; |
289 m_CTM[1] = m_CTM[2] = 0; | 289 m_CTM[1] = m_CTM[2] = 0; |
290 } | 290 } |
291 CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src) | 291 CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src) |
292 { | 292 { |
293 if (this == &src) { | 293 if (this == &src) { |
294 return; | 294 return; |
295 } | 295 } |
296 FXSYS_memcpy(this, &src, sizeof(CPDF_TextStateData)); | 296 FXSYS_memcpy(this, &src, sizeof(CPDF_TextStateData)); |
297 if (m_pDocument && m_pFont) { | 297 if (m_pDocument && m_pFont) { |
298 m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FA
LSE); | 298 m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), fa
lse); |
299 } | 299 } |
300 } | 300 } |
301 CPDF_TextStateData::~CPDF_TextStateData() | 301 CPDF_TextStateData::~CPDF_TextStateData() |
302 { | 302 { |
303 if (m_pDocument && m_pFont) { | 303 if (m_pDocument && m_pFont) { |
304 CPDF_DocPageData *pPageData = m_pDocument->GetPageData(); | 304 CPDF_DocPageData *pPageData = m_pDocument->GetPageData(); |
305 if (pPageData && !pPageData->IsForceClear()) { | 305 if (pPageData && !pPageData->IsForceClear()) { |
306 pPageData->ReleaseFont(m_pFont->GetFontDict()); | 306 pPageData->ReleaseFont(m_pFont->GetFontDict()); |
307 } | 307 } |
308 } | 308 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 break; | 538 break; |
539 case FXBSTR_ID('B', 'M', 0, 0): { | 539 case FXBSTR_ID('B', 'M', 0, 0): { |
540 CFX_ByteString mode; | 540 CFX_ByteString mode; |
541 if (pObject->GetType() == PDFOBJ_ARRAY) { | 541 if (pObject->GetType() == PDFOBJ_ARRAY) { |
542 mode = ((CPDF_Array*)pObject)->GetString(0); | 542 mode = ((CPDF_Array*)pObject)->GetString(0); |
543 } else { | 543 } else { |
544 mode = pObject->GetString(); | 544 mode = pObject->GetString(); |
545 } | 545 } |
546 pGeneralState->SetBlendMode(mode); | 546 pGeneralState->SetBlendMode(mode); |
547 if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { | 547 if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { |
548 pParser->GetObjectList()->m_bBackgroundAlphaNeeded = TRU
E; | 548 pParser->GetObjectList()->m_bBackgroundAlphaNeeded = tru
e; |
549 } | 549 } |
550 break; | 550 break; |
551 } | 551 } |
552 case FXBSTR_ID('S', 'M', 'a', 's'): | 552 case FXBSTR_ID('S', 'M', 'a', 's'): |
553 if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) { | 553 if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY) { |
554 pGeneralState->m_pSoftMask = pObject; | 554 pGeneralState->m_pSoftMask = pObject; |
555 FXSYS_memcpy(pGeneralState->m_SMaskMatrix, &pParser->GetCurS
tates()->m_CTM, sizeof(CPDF_Matrix)); | 555 FXSYS_memcpy(pGeneralState->m_SMaskMatrix, &pParser->GetCurS
tates()->m_CTM, sizeof(CPDF_Matrix)); |
556 } else { | 556 } else { |
557 pGeneralState->m_pSoftMask = NULL; | 557 pGeneralState->m_pSoftMask = NULL; |
558 } | 558 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } else { | 624 } else { |
625 m_pParam = src.m_pParam; | 625 m_pParam = src.m_pParam; |
626 } | 626 } |
627 } | 627 } |
628 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() | 628 CPDF_ContentMarkItem::~CPDF_ContentMarkItem() |
629 { | 629 { |
630 if (m_ParamType == DirectDict && m_pParam) { | 630 if (m_ParamType == DirectDict && m_pParam) { |
631 ((CPDF_Dictionary*)m_pParam)->Release(); | 631 ((CPDF_Dictionary*)m_pParam)->Release(); |
632 } | 632 } |
633 } | 633 } |
634 FX_BOOL»CPDF_ContentMarkItem::HasMCID() const | 634 bool» CPDF_ContentMarkItem::HasMCID() const |
635 { | 635 { |
636 if (m_pParam && (m_ParamType == DirectDict || m_ParamType == PropertiesDict)
) { | 636 if (m_pParam && (m_ParamType == DirectDict || m_ParamType == PropertiesDict)
) { |
637 return ((CPDF_Dictionary *)m_pParam)->KeyExist(FX_BSTRC("MCID")); | 637 return ((CPDF_Dictionary *)m_pParam)->KeyExist(FX_BSTRC("MCID")); |
638 } | 638 } |
639 return FALSE; | 639 return false; |
640 } | 640 } |
641 CPDF_ContentMarkData::CPDF_ContentMarkData(const CPDF_ContentMarkData& src) | 641 CPDF_ContentMarkData::CPDF_ContentMarkData(const CPDF_ContentMarkData& src) |
642 { | 642 { |
643 for (int i = 0; i < src.m_Marks.GetSize(); i ++) { | 643 for (int i = 0; i < src.m_Marks.GetSize(); i ++) { |
644 m_Marks.Add(src.m_Marks[i]); | 644 m_Marks.Add(src.m_Marks[i]); |
645 } | 645 } |
646 } | 646 } |
647 int CPDF_ContentMarkData::GetMCID() const | 647 int CPDF_ContentMarkData::GetMCID() const |
648 { | 648 { |
649 CPDF_ContentMarkItem::ParamType type = CPDF_ContentMarkItem::None; | 649 CPDF_ContentMarkItem::ParamType type = CPDF_ContentMarkItem::None; |
650 for (int i = 0; i < m_Marks.GetSize(); i ++) { | 650 for (int i = 0; i < m_Marks.GetSize(); i ++) { |
651 type = m_Marks[i].GetParamType(); | 651 type = m_Marks[i].GetParamType(); |
652 if (type == CPDF_ContentMarkItem::PropertiesDict || type == CPDF_Content
MarkItem::DirectDict) { | 652 if (type == CPDF_ContentMarkItem::PropertiesDict || type == CPDF_Content
MarkItem::DirectDict) { |
653 CPDF_Dictionary *pDict = (CPDF_Dictionary *)m_Marks[i].GetParam(); | 653 CPDF_Dictionary *pDict = (CPDF_Dictionary *)m_Marks[i].GetParam(); |
654 if (pDict->KeyExist(FX_BSTRC("MCID"))) { | 654 if (pDict->KeyExist(FX_BSTRC("MCID"))) { |
655 return pDict->GetInteger(FX_BSTRC("MCID")); | 655 return pDict->GetInteger(FX_BSTRC("MCID")); |
656 } | 656 } |
657 } | 657 } |
658 } | 658 } |
659 return -1; | 659 return -1; |
660 } | 660 } |
661 void CPDF_ContentMarkData::AddMark(const CFX_ByteString& name, CPDF_Dictionary*
pDict, FX_BOOL bDirect) | 661 void CPDF_ContentMarkData::AddMark(const CFX_ByteString& name, CPDF_Dictionary*
pDict, bool bDirect) |
662 { | 662 { |
663 CPDF_ContentMarkItem& item = m_Marks.Add(); | 663 CPDF_ContentMarkItem& item = m_Marks.Add(); |
664 item.SetName(name); | 664 item.SetName(name); |
665 if (pDict == NULL) { | 665 if (pDict == NULL) { |
666 return; | 666 return; |
667 } | 667 } |
668 item.SetParam(bDirect ? CPDF_ContentMarkItem::DirectDict : CPDF_ContentMarkI
tem::PropertiesDict, | 668 item.SetParam(bDirect ? CPDF_ContentMarkItem::DirectDict : CPDF_ContentMarkI
tem::PropertiesDict, |
669 bDirect ? pDict->Clone() : pDict); | 669 bDirect ? pDict->Clone() : pDict); |
670 } | 670 } |
671 void CPDF_ContentMarkData::DeleteLastMark() | 671 void CPDF_ContentMarkData::DeleteLastMark() |
672 { | 672 { |
673 int size = m_Marks.GetSize(); | 673 int size = m_Marks.GetSize(); |
674 if (size == 0) { | 674 if (size == 0) { |
675 return; | 675 return; |
676 } | 676 } |
677 m_Marks.RemoveAt(size - 1); | 677 m_Marks.RemoveAt(size - 1); |
678 } | 678 } |
679 FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const | 679 bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const |
680 { | 680 { |
681 if (m_pObject == NULL) { | 681 if (m_pObject == NULL) { |
682 return FALSE; | 682 return false; |
683 } | 683 } |
684 for (int i = 0; i < m_pObject->CountItems(); i ++) { | 684 for (int i = 0; i < m_pObject->CountItems(); i ++) { |
685 CPDF_ContentMarkItem& item = m_pObject->GetItem(i); | 685 CPDF_ContentMarkItem& item = m_pObject->GetItem(i); |
686 if (item.GetName() == mark) { | 686 if (item.GetName() == mark) { |
687 return TRUE; | 687 return true; |
688 } | 688 } |
689 } | 689 } |
690 return FALSE; | 690 return false; |
691 } | 691 } |
692 FX_BOOL CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionar
y*& pDict) const | 692 bool CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*&
pDict) const |
693 { | 693 { |
694 if (m_pObject == NULL) { | 694 if (m_pObject == NULL) { |
695 return FALSE; | 695 return false; |
696 } | 696 } |
697 for (int i = 0; i < m_pObject->CountItems(); i ++) { | 697 for (int i = 0; i < m_pObject->CountItems(); i ++) { |
698 CPDF_ContentMarkItem& item = m_pObject->GetItem(i); | 698 CPDF_ContentMarkItem& item = m_pObject->GetItem(i); |
699 if (item.GetName() == mark) { | 699 if (item.GetName() == mark) { |
700 pDict = NULL; | 700 pDict = NULL; |
701 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || | 701 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || |
702 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { | 702 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { |
703 pDict = (CPDF_Dictionary*)item.GetParam(); | 703 pDict = (CPDF_Dictionary*)item.GetParam(); |
704 } | 704 } |
705 return TRUE; | 705 return true; |
706 } | 706 } |
707 } | 707 } |
708 return FALSE; | 708 return false; |
709 } | 709 } |
OLD | NEW |