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 "fpdfsdk/include/cpdfsdk_baannot.h" | 7 #include "fpdfsdk/include/cpdfsdk_baannot.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const { | 32 CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const { |
33 return m_pAnnot->GetAnnotDict(); | 33 return m_pAnnot->GetAnnotDict(); |
34 } | 34 } |
35 | 35 |
36 void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) { | 36 void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) { |
37 ASSERT(rect.right - rect.left >= GetMinWidth()); | 37 ASSERT(rect.right - rect.left >= GetMinWidth()); |
38 ASSERT(rect.top - rect.bottom >= GetMinHeight()); | 38 ASSERT(rect.top - rect.bottom >= GetMinHeight()); |
39 | 39 |
40 m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect); | 40 m_pAnnot->GetAnnotDict()->SetRectFor("Rect", rect); |
41 } | 41 } |
42 | 42 |
43 CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { | 43 CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { |
44 return m_pAnnot->GetRect(); | 44 return m_pAnnot->GetRect(); |
45 } | 45 } |
46 | 46 |
47 CPDF_Annot::Subtype CPDFSDK_BAAnnot::GetAnnotSubtype() const { | 47 CPDF_Annot::Subtype CPDFSDK_BAAnnot::GetAnnotSubtype() const { |
48 return m_pAnnot->GetSubtype(); | 48 return m_pAnnot->GetSubtype(); |
49 } | 49 } |
50 | 50 |
51 void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, | 51 void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, |
52 const CFX_Matrix* pUser2Device, | 52 const CFX_Matrix* pUser2Device, |
53 CPDF_Annot::AppearanceMode mode, | 53 CPDF_Annot::AppearanceMode mode, |
54 const CPDF_RenderOptions* pOptions) { | 54 const CPDF_RenderOptions* pOptions) { |
55 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, | 55 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
56 mode, pOptions); | 56 mode, pOptions); |
57 } | 57 } |
58 | 58 |
59 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() { | 59 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() { |
60 return !!m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 60 return !!m_pAnnot->GetAnnotDict()->GetDictFor("AP"); |
61 } | 61 } |
62 | 62 |
63 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { | 63 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { |
64 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 64 CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); |
65 if (!pAP) | 65 if (!pAP) |
66 return FALSE; | 66 return FALSE; |
67 | 67 |
68 // Choose the right sub-ap | 68 // Choose the right sub-ap |
69 const FX_CHAR* ap_entry = "N"; | 69 const FX_CHAR* ap_entry = "N"; |
70 if (mode == CPDF_Annot::Down) | 70 if (mode == CPDF_Annot::Down) |
71 ap_entry = "D"; | 71 ap_entry = "D"; |
72 else if (mode == CPDF_Annot::Rollover) | 72 else if (mode == CPDF_Annot::Rollover) |
73 ap_entry = "R"; | 73 ap_entry = "R"; |
74 if (!pAP->KeyExist(ap_entry)) | 74 if (!pAP->KeyExist(ap_entry)) |
75 ap_entry = "N"; | 75 ap_entry = "N"; |
76 | 76 |
77 // Get the AP stream or subdirectory | 77 // Get the AP stream or subdirectory |
78 CPDF_Object* psub = pAP->GetDirectObjectBy(ap_entry); | 78 CPDF_Object* psub = pAP->GetDirectObjectFor(ap_entry); |
79 return !!psub; | 79 return !!psub; |
80 } | 80 } |
81 | 81 |
82 void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice, | 82 void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice, |
83 const CFX_Matrix* pUser2Device, | 83 const CFX_Matrix* pUser2Device, |
84 const CPDF_RenderOptions* pOptions) { | 84 const CPDF_RenderOptions* pOptions) { |
85 m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions); | 85 m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions); |
86 } | 86 } |
87 | 87 |
88 void CPDFSDK_BAAnnot::ClearCachedAP() { | 88 void CPDFSDK_BAAnnot::ClearCachedAP() { |
89 m_pAnnot->ClearCachedAP(); | 89 m_pAnnot->ClearCachedAP(); |
90 } | 90 } |
91 | 91 |
92 void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { | 92 void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) { |
93 if (sContents.IsEmpty()) | 93 if (sContents.IsEmpty()) |
94 m_pAnnot->GetAnnotDict()->RemoveAt("Contents"); | 94 m_pAnnot->GetAnnotDict()->RemoveFor("Contents"); |
95 else | 95 else |
96 m_pAnnot->GetAnnotDict()->SetAtString("Contents", | 96 m_pAnnot->GetAnnotDict()->SetStringFor("Contents", |
97 PDF_EncodeText(sContents)); | 97 PDF_EncodeText(sContents)); |
98 } | 98 } |
99 | 99 |
100 CFX_WideString CPDFSDK_BAAnnot::GetContents() const { | 100 CFX_WideString CPDFSDK_BAAnnot::GetContents() const { |
101 return m_pAnnot->GetAnnotDict()->GetUnicodeTextBy("Contents"); | 101 return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("Contents"); |
102 } | 102 } |
103 | 103 |
104 void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName) { | 104 void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName) { |
105 if (sName.IsEmpty()) | 105 if (sName.IsEmpty()) |
106 m_pAnnot->GetAnnotDict()->RemoveAt("NM"); | 106 m_pAnnot->GetAnnotDict()->RemoveFor("NM"); |
107 else | 107 else |
108 m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName)); | 108 m_pAnnot->GetAnnotDict()->SetStringFor("NM", PDF_EncodeText(sName)); |
109 } | 109 } |
110 | 110 |
111 CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const { | 111 CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const { |
112 return m_pAnnot->GetAnnotDict()->GetUnicodeTextBy("NM"); | 112 return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("NM"); |
113 } | 113 } |
114 | 114 |
115 void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) { | 115 void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) { |
116 CPDFSDK_DateTime dt(st); | 116 CPDFSDK_DateTime dt(st); |
117 CFX_ByteString str = dt.ToPDFDateTimeString(); | 117 CFX_ByteString str = dt.ToPDFDateTimeString(); |
118 | 118 |
119 if (str.IsEmpty()) | 119 if (str.IsEmpty()) |
120 m_pAnnot->GetAnnotDict()->RemoveAt("M"); | 120 m_pAnnot->GetAnnotDict()->RemoveFor("M"); |
121 else | 121 else |
122 m_pAnnot->GetAnnotDict()->SetAtString("M", str); | 122 m_pAnnot->GetAnnotDict()->SetStringFor("M", str); |
123 } | 123 } |
124 | 124 |
125 FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { | 125 FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { |
126 FX_SYSTEMTIME systime; | 126 FX_SYSTEMTIME systime; |
127 CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetStringBy("M"); | 127 CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetStringFor("M"); |
128 | 128 |
129 CPDFSDK_DateTime dt(str); | 129 CPDFSDK_DateTime dt(str); |
130 dt.ToSystemTime(systime); | 130 dt.ToSystemTime(systime); |
131 | 131 |
132 return systime; | 132 return systime; |
133 } | 133 } |
134 | 134 |
135 void CPDFSDK_BAAnnot::SetFlags(uint32_t nFlags) { | 135 void CPDFSDK_BAAnnot::SetFlags(uint32_t nFlags) { |
136 m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags); | 136 m_pAnnot->GetAnnotDict()->SetIntegerFor("F", nFlags); |
137 } | 137 } |
138 | 138 |
139 uint32_t CPDFSDK_BAAnnot::GetFlags() const { | 139 uint32_t CPDFSDK_BAAnnot::GetFlags() const { |
140 return m_pAnnot->GetAnnotDict()->GetIntegerBy("F"); | 140 return m_pAnnot->GetAnnotDict()->GetIntegerFor("F"); |
141 } | 141 } |
142 | 142 |
143 void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str) { | 143 void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str) { |
144 if (str.IsEmpty()) | 144 if (str.IsEmpty()) |
145 m_pAnnot->GetAnnotDict()->RemoveAt("AS"); | 145 m_pAnnot->GetAnnotDict()->RemoveFor("AS"); |
146 else | 146 else |
147 m_pAnnot->GetAnnotDict()->SetAtString("AS", str); | 147 m_pAnnot->GetAnnotDict()->SetStringFor("AS", str); |
148 } | 148 } |
149 | 149 |
150 CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const { | 150 CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const { |
151 return m_pAnnot->GetAnnotDict()->GetStringBy("AS"); | 151 return m_pAnnot->GetAnnotDict()->GetStringFor("AS"); |
152 } | 152 } |
153 | 153 |
154 void CPDFSDK_BAAnnot::SetStructParent(int key) { | 154 void CPDFSDK_BAAnnot::SetStructParent(int key) { |
155 m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key); | 155 m_pAnnot->GetAnnotDict()->SetIntegerFor("StructParent", key); |
156 } | 156 } |
157 | 157 |
158 int CPDFSDK_BAAnnot::GetStructParent() const { | 158 int CPDFSDK_BAAnnot::GetStructParent() const { |
159 return m_pAnnot->GetAnnotDict()->GetIntegerBy("StructParent"); | 159 return m_pAnnot->GetAnnotDict()->GetIntegerFor("StructParent"); |
160 } | 160 } |
161 | 161 |
162 // border | 162 // border |
163 void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { | 163 void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { |
164 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); | 164 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); |
165 | 165 |
166 if (pBorder) { | 166 if (pBorder) { |
167 pBorder->SetAt(2, new CPDF_Number(nWidth)); | 167 pBorder->SetAt(2, new CPDF_Number(nWidth)); |
168 } else { | 168 } else { |
169 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); | 169 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); |
170 | 170 |
171 if (!pBSDict) { | 171 if (!pBSDict) { |
172 pBSDict = new CPDF_Dictionary; | 172 pBSDict = new CPDF_Dictionary; |
173 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); | 173 m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict); |
174 } | 174 } |
175 | 175 |
176 pBSDict->SetAtInteger("W", nWidth); | 176 pBSDict->SetIntegerFor("W", nWidth); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 int CPDFSDK_BAAnnot::GetBorderWidth() const { | 180 int CPDFSDK_BAAnnot::GetBorderWidth() const { |
181 if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border")) { | 181 if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border")) { |
182 return pBorder->GetIntegerAt(2); | 182 return pBorder->GetIntegerAt(2); |
183 } | 183 } |
184 if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS")) { | 184 if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS")) { |
185 return pBSDict->GetIntegerBy("W", 1); | 185 return pBSDict->GetIntegerFor("W", 1); |
186 } | 186 } |
187 return 1; | 187 return 1; |
188 } | 188 } |
189 | 189 |
190 void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { | 190 void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { |
191 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); | 191 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); |
192 if (!pBSDict) { | 192 if (!pBSDict) { |
193 pBSDict = new CPDF_Dictionary; | 193 pBSDict = new CPDF_Dictionary; |
194 m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict); | 194 m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict); |
195 } | 195 } |
196 | 196 |
197 switch (nStyle) { | 197 switch (nStyle) { |
198 case BorderStyle::SOLID: | 198 case BorderStyle::SOLID: |
199 pBSDict->SetAtName("S", "S"); | 199 pBSDict->SetNameFor("S", "S"); |
200 break; | 200 break; |
201 case BorderStyle::DASH: | 201 case BorderStyle::DASH: |
202 pBSDict->SetAtName("S", "D"); | 202 pBSDict->SetNameFor("S", "D"); |
203 break; | 203 break; |
204 case BorderStyle::BEVELED: | 204 case BorderStyle::BEVELED: |
205 pBSDict->SetAtName("S", "B"); | 205 pBSDict->SetNameFor("S", "B"); |
206 break; | 206 break; |
207 case BorderStyle::INSET: | 207 case BorderStyle::INSET: |
208 pBSDict->SetAtName("S", "I"); | 208 pBSDict->SetNameFor("S", "I"); |
209 break; | 209 break; |
210 case BorderStyle::UNDERLINE: | 210 case BorderStyle::UNDERLINE: |
211 pBSDict->SetAtName("S", "U"); | 211 pBSDict->SetNameFor("S", "U"); |
212 break; | 212 break; |
213 default: | 213 default: |
214 break; | 214 break; |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { | 218 BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { |
219 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); | 219 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); |
220 if (pBSDict) { | 220 if (pBSDict) { |
221 CFX_ByteString sBorderStyle = pBSDict->GetStringBy("S", "S"); | 221 CFX_ByteString sBorderStyle = pBSDict->GetStringFor("S", "S"); |
222 if (sBorderStyle == "S") | 222 if (sBorderStyle == "S") |
223 return BorderStyle::SOLID; | 223 return BorderStyle::SOLID; |
224 if (sBorderStyle == "D") | 224 if (sBorderStyle == "D") |
225 return BorderStyle::DASH; | 225 return BorderStyle::DASH; |
226 if (sBorderStyle == "B") | 226 if (sBorderStyle == "B") |
227 return BorderStyle::BEVELED; | 227 return BorderStyle::BEVELED; |
228 if (sBorderStyle == "I") | 228 if (sBorderStyle == "I") |
229 return BorderStyle::INSET; | 229 return BorderStyle::INSET; |
230 if (sBorderStyle == "U") | 230 if (sBorderStyle == "U") |
231 return BorderStyle::UNDERLINE; | 231 return BorderStyle::UNDERLINE; |
232 } | 232 } |
233 | 233 |
234 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); | 234 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); |
235 if (pBorder) { | 235 if (pBorder) { |
236 if (pBorder->GetCount() >= 4) { | 236 if (pBorder->GetCount() >= 4) { |
237 CPDF_Array* pDP = pBorder->GetArrayAt(3); | 237 CPDF_Array* pDP = pBorder->GetArrayAt(3); |
238 if (pDP && pDP->GetCount() > 0) | 238 if (pDP && pDP->GetCount() > 0) |
239 return BorderStyle::DASH; | 239 return BorderStyle::DASH; |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 return BorderStyle::SOLID; | 243 return BorderStyle::SOLID; |
244 } | 244 } |
245 | 245 |
246 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { | 246 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { |
247 CPDF_Array* pArray = new CPDF_Array; | 247 CPDF_Array* pArray = new CPDF_Array; |
248 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); | 248 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); |
249 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); | 249 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); |
250 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); | 250 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); |
251 m_pAnnot->GetAnnotDict()->SetAt("C", pArray); | 251 m_pAnnot->GetAnnotDict()->SetFor("C", pArray); |
252 } | 252 } |
253 | 253 |
254 void CPDFSDK_BAAnnot::RemoveColor() { | 254 void CPDFSDK_BAAnnot::RemoveColor() { |
255 m_pAnnot->GetAnnotDict()->RemoveAt("C"); | 255 m_pAnnot->GetAnnotDict()->RemoveFor("C"); |
256 } | 256 } |
257 | 257 |
258 FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { | 258 FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { |
259 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayBy("C")) { | 259 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayFor("C")) { |
260 size_t nCount = pEntry->GetCount(); | 260 size_t nCount = pEntry->GetCount(); |
261 if (nCount == 1) { | 261 if (nCount == 1) { |
262 FX_FLOAT g = pEntry->GetNumberAt(0) * 255; | 262 FX_FLOAT g = pEntry->GetNumberAt(0) * 255; |
263 | 263 |
264 color = FXSYS_RGB((int)g, (int)g, (int)g); | 264 color = FXSYS_RGB((int)g, (int)g, (int)g); |
265 | 265 |
266 return TRUE; | 266 return TRUE; |
267 } else if (nCount == 3) { | 267 } else if (nCount == 3) { |
268 FX_FLOAT r = pEntry->GetNumberAt(0) * 255; | 268 FX_FLOAT r = pEntry->GetNumberAt(0) * 255; |
269 FX_FLOAT g = pEntry->GetNumberAt(1) * 255; | 269 FX_FLOAT g = pEntry->GetNumberAt(1) * 255; |
(...skipping 19 matching lines...) Expand all Loading... |
289 } | 289 } |
290 | 290 |
291 return FALSE; | 291 return FALSE; |
292 } | 292 } |
293 | 293 |
294 void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, | 294 void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, |
295 const CFX_FloatRect& rcBBox, | 295 const CFX_FloatRect& rcBBox, |
296 const CFX_Matrix& matrix, | 296 const CFX_Matrix& matrix, |
297 const CFX_ByteString& sContents, | 297 const CFX_ByteString& sContents, |
298 const CFX_ByteString& sAPState) { | 298 const CFX_ByteString& sAPState) { |
299 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); | 299 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); |
300 | 300 |
301 if (!pAPDict) { | 301 if (!pAPDict) { |
302 pAPDict = new CPDF_Dictionary; | 302 pAPDict = new CPDF_Dictionary; |
303 m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict); | 303 m_pAnnot->GetAnnotDict()->SetFor("AP", pAPDict); |
304 } | 304 } |
305 | 305 |
306 CPDF_Stream* pStream = nullptr; | 306 CPDF_Stream* pStream = nullptr; |
307 CPDF_Dictionary* pParentDict = nullptr; | 307 CPDF_Dictionary* pParentDict = nullptr; |
308 | 308 |
309 if (sAPState.IsEmpty()) { | 309 if (sAPState.IsEmpty()) { |
310 pParentDict = pAPDict; | 310 pParentDict = pAPDict; |
311 pStream = pAPDict->GetStreamBy(sAPType); | 311 pStream = pAPDict->GetStreamFor(sAPType); |
312 } else { | 312 } else { |
313 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType); | 313 CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictFor(sAPType); |
314 if (!pAPTypeDict) { | 314 if (!pAPTypeDict) { |
315 pAPTypeDict = new CPDF_Dictionary; | 315 pAPTypeDict = new CPDF_Dictionary; |
316 pAPDict->SetAt(sAPType, pAPTypeDict); | 316 pAPDict->SetFor(sAPType, pAPTypeDict); |
317 } | 317 } |
318 pParentDict = pAPTypeDict; | 318 pParentDict = pAPTypeDict; |
319 pStream = pAPTypeDict->GetStreamBy(sAPState); | 319 pStream = pAPTypeDict->GetStreamFor(sAPState); |
320 } | 320 } |
321 | 321 |
322 if (!pStream) { | 322 if (!pStream) { |
323 pStream = new CPDF_Stream(nullptr, 0, nullptr); | 323 pStream = new CPDF_Stream(nullptr, 0, nullptr); |
324 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 324 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
325 int32_t objnum = pDoc->AddIndirectObject(pStream); | 325 int32_t objnum = pDoc->AddIndirectObject(pStream); |
326 pParentDict->SetAtReference(sAPType, pDoc, objnum); | 326 pParentDict->SetReferenceFor(sAPType, pDoc, objnum); |
327 } | 327 } |
328 | 328 |
329 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 329 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
330 if (!pStreamDict) { | 330 if (!pStreamDict) { |
331 pStreamDict = new CPDF_Dictionary; | 331 pStreamDict = new CPDF_Dictionary; |
332 pStreamDict->SetAtName("Type", "XObject"); | 332 pStreamDict->SetNameFor("Type", "XObject"); |
333 pStreamDict->SetAtName("Subtype", "Form"); | 333 pStreamDict->SetNameFor("Subtype", "Form"); |
334 pStreamDict->SetAtInteger("FormType", 1); | 334 pStreamDict->SetIntegerFor("FormType", 1); |
335 pStream->InitStream(nullptr, 0, pStreamDict); | 335 pStream->InitStream(nullptr, 0, pStreamDict); |
336 } | 336 } |
337 | 337 |
338 if (pStreamDict) { | 338 if (pStreamDict) { |
339 pStreamDict->SetAtMatrix("Matrix", matrix); | 339 pStreamDict->SetMatrixFor("Matrix", matrix); |
340 pStreamDict->SetAtRect("BBox", rcBBox); | 340 pStreamDict->SetRectFor("BBox", rcBBox); |
341 } | 341 } |
342 | 342 |
343 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, | 343 pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE, |
344 FALSE); | 344 FALSE); |
345 } | 345 } |
346 | 346 |
347 FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { | 347 FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { |
348 uint32_t nFlags = GetFlags(); | 348 uint32_t nFlags = GetFlags(); |
349 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || | 349 return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || |
350 (nFlags & ANNOTFLAG_NOVIEW)); | 350 (nFlags & ANNOTFLAG_NOVIEW)); |
351 } | 351 } |
352 | 352 |
353 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { | 353 CPDF_Action CPDFSDK_BAAnnot::GetAction() const { |
354 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictBy("A")); | 354 return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); |
355 } | 355 } |
356 | 356 |
357 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { | 357 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) { |
358 ASSERT(action.GetDict()); | 358 ASSERT(action.GetDict()); |
359 if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("A")) { | 359 if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("A")) { |
360 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); | 360 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); |
361 CPDF_Dictionary* pDict = action.GetDict(); | 361 CPDF_Dictionary* pDict = action.GetDict(); |
362 if (pDict && pDict->GetObjNum() == 0) { | 362 if (pDict && pDict->GetObjNum() == 0) { |
363 pDoc->AddIndirectObject(pDict); | 363 pDoc->AddIndirectObject(pDict); |
364 } | 364 } |
365 m_pAnnot->GetAnnotDict()->SetAtReference("A", pDoc, pDict->GetObjNum()); | 365 m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc, pDict->GetObjNum()); |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 void CPDFSDK_BAAnnot::RemoveAction() { | 369 void CPDFSDK_BAAnnot::RemoveAction() { |
370 m_pAnnot->GetAnnotDict()->RemoveAt("A"); | 370 m_pAnnot->GetAnnotDict()->RemoveFor("A"); |
371 } | 371 } |
372 | 372 |
373 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { | 373 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { |
374 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictBy("AA")); | 374 return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); |
375 } | 375 } |
376 | 376 |
377 void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) { | 377 void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) { |
378 if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("AA")) | 378 if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictFor("AA")) |
379 m_pAnnot->GetAnnotDict()->SetAt("AA", aa.GetDict()); | 379 m_pAnnot->GetAnnotDict()->SetFor("AA", aa.GetDict()); |
380 } | 380 } |
381 | 381 |
382 void CPDFSDK_BAAnnot::RemoveAAction() { | 382 void CPDFSDK_BAAnnot::RemoveAAction() { |
383 m_pAnnot->GetAnnotDict()->RemoveAt("AA"); | 383 m_pAnnot->GetAnnotDict()->RemoveFor("AA"); |
384 } | 384 } |
385 | 385 |
386 CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { | 386 CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { |
387 CPDF_AAction AAction = GetAAction(); | 387 CPDF_AAction AAction = GetAAction(); |
388 | 388 |
389 if (AAction.ActionExist(eAAT)) | 389 if (AAction.ActionExist(eAAT)) |
390 return AAction.GetAction(eAAT); | 390 return AAction.GetAction(eAAT); |
391 | 391 |
392 if (eAAT == CPDF_AAction::ButtonUp) | 392 if (eAAT == CPDF_AAction::ButtonUp) |
393 return GetAction(); | 393 return GetAction(); |
394 | 394 |
395 return CPDF_Action(); | 395 return CPDF_Action(); |
396 } | 396 } |
397 | 397 |
398 void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, | 398 void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, |
399 CFX_Matrix* pUser2Device, | 399 CFX_Matrix* pUser2Device, |
400 CPDF_RenderOptions* pOptions) { | 400 CPDF_RenderOptions* pOptions) { |
401 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); | 401 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); |
402 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, | 402 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, |
403 CPDF_Annot::Normal, nullptr); | 403 CPDF_Annot::Normal, nullptr); |
404 } | 404 } |
405 | 405 |
406 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { | 406 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { |
407 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) | 407 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) |
408 pAnnot->SetOpenState(bOpenState); | 408 pAnnot->SetOpenState(bOpenState); |
409 } | 409 } |
OLD | NEW |