Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: fpdfsdk/cpdfsdk_baannot.cpp

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/cpdfsdk_baannot.h" 7 #include "fpdfsdk/cpdfsdk_baannot.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_array.h" 9 #include "core/fpdfapi/parser/cpdf_array.h"
10 #include "core/fpdfapi/parser/cpdf_document.h" 10 #include "core/fpdfapi/parser/cpdf_document.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 int CPDFSDK_BAAnnot::GetStructParent() const { 157 int CPDFSDK_BAAnnot::GetStructParent() const {
158 return m_pAnnot->GetAnnotDict()->GetIntegerFor("StructParent"); 158 return m_pAnnot->GetAnnotDict()->GetIntegerFor("StructParent");
159 } 159 }
160 160
161 // border 161 // border
162 void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { 162 void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) {
163 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); 163 CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border");
164 if (pBorder) { 164 if (pBorder) {
165 pBorder->SetAt(2, new CPDF_Number(nWidth)); 165 pBorder->SetNewAt<CPDF_Number>(2, nWidth);
166 } else { 166 } else {
167 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); 167 CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS");
168 if (!pBSDict) { 168 if (!pBSDict) {
169 pBSDict = 169 pBSDict =
170 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool()); 170 new CPDF_Dictionary(m_pAnnot->GetDocument()->GetByteStringPool());
171 m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict); 171 m_pAnnot->GetAnnotDict()->SetFor("BS", pBSDict);
172 } 172 }
173 pBSDict->SetIntegerFor("W", nWidth); 173 pBSDict->SetIntegerFor("W", nWidth);
174 } 174 }
175 } 175 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (pDP && pDP->GetCount() > 0) 235 if (pDP && pDP->GetCount() > 0)
236 return BorderStyle::DASH; 236 return BorderStyle::DASH;
237 } 237 }
238 } 238 }
239 239
240 return BorderStyle::SOLID; 240 return BorderStyle::SOLID;
241 } 241 }
242 242
243 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { 243 void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) {
244 CPDF_Array* pArray = new CPDF_Array; 244 CPDF_Array* pArray = new CPDF_Array;
245 pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f); 245 pArray->AddNew<CPDF_Number>((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
246 pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f); 246 pArray->AddNew<CPDF_Number>((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
247 pArray->AddNumber((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f); 247 pArray->AddNew<CPDF_Number>((FX_FLOAT)FXSYS_GetBValue(color) / 255.0f);
dsinclair 2016/11/16 14:58:32 nit: static_cast's
Tom Sepez 2016/11/16 20:08:57 Done.
248 m_pAnnot->GetAnnotDict()->SetFor("C", pArray); 248 m_pAnnot->GetAnnotDict()->SetFor("C", pArray);
249 } 249 }
250 250
251 void CPDFSDK_BAAnnot::RemoveColor() { 251 void CPDFSDK_BAAnnot::RemoveColor() {
252 m_pAnnot->GetAnnotDict()->RemoveFor("C"); 252 m_pAnnot->GetAnnotDict()->RemoveFor("C");
253 } 253 }
254 254
255 bool CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { 255 bool CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const {
256 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayFor("C")) { 256 if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayFor("C")) {
257 size_t nCount = pEntry->GetCount(); 257 size_t nCount = pEntry->GetCount();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 CPDF_RenderOptions* pOptions) { 393 CPDF_RenderOptions* pOptions) {
394 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); 394 m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
395 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, 395 m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
396 CPDF_Annot::Normal, nullptr); 396 CPDF_Annot::Normal, nullptr);
397 } 397 }
398 398
399 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) { 399 void CPDFSDK_BAAnnot::SetOpenState(bool bOpenState) {
400 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot()) 400 if (CPDF_Annot* pAnnot = m_pAnnot->GetPopupAnnot())
401 pAnnot->SetOpenState(bOpenState); 401 pAnnot->SetOpenState(bOpenState);
402 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698