Chromium Code Reviews| 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_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 8 #include "../../../include/fxcrt/fx_string.h" | |
| 9 | |
| 8 void CPDF_Object::Release() | 10 void CPDF_Object::Release() |
| 9 { | 11 { |
| 10 if (m_ObjNum) { | 12 if (m_ObjNum) { |
| 11 return; | 13 return; |
| 12 } | 14 } |
| 13 Destroy(); | 15 Destroy(); |
| 14 } | 16 } |
| 15 void CPDF_Object::Destroy() | 17 void CPDF_Object::Destroy() |
| 16 { | 18 { |
| 17 switch (m_Type) { | 19 switch (m_Type) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 } | 326 } |
| 325 void CPDF_Object::SetUnicodeText(FX_LPCWSTR pUnicodes, int len) | 327 void CPDF_Object::SetUnicodeText(FX_LPCWSTR pUnicodes, int len) |
| 326 { | 328 { |
| 327 if (m_Type == PDFOBJ_STRING) { | 329 if (m_Type == PDFOBJ_STRING) { |
| 328 ((CPDF_String*)this)->m_String = PDF_EncodeText(pUnicodes, len); | 330 ((CPDF_String*)this)->m_String = PDF_EncodeText(pUnicodes, len); |
| 329 } else if (m_Type == PDFOBJ_STREAM) { | 331 } else if (m_Type == PDFOBJ_STREAM) { |
| 330 CFX_ByteString result = PDF_EncodeText(pUnicodes, len); | 332 CFX_ByteString result = PDF_EncodeText(pUnicodes, len); |
| 331 ((CPDF_Stream*)this)->SetData((FX_LPBYTE)result.c_str(), result.GetLengt h(), FALSE, FALSE); | 333 ((CPDF_Stream*)this)->SetData((FX_LPBYTE)result.c_str(), result.GetLengt h(), FALSE, FALSE); |
| 332 } | 334 } |
| 333 } | 335 } |
| 336 | |
| 334 CPDF_Number::CPDF_Number(int value) | 337 CPDF_Number::CPDF_Number(int value) |
| 335 { | 338 : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(value) { |
| 336 m_Type = PDFOBJ_NUMBER; | |
| 337 m_bInteger = TRUE; | |
| 338 m_Integer = value; | |
| 339 } | 339 } |
| 340 | |
| 340 CPDF_Number::CPDF_Number(FX_FLOAT value) | 341 CPDF_Number::CPDF_Number(FX_FLOAT value) |
| 341 { | 342 : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(FALSE), m_Float(value) { |
| 342 m_Type = PDFOBJ_NUMBER; | |
| 343 m_bInteger = FALSE; | |
| 344 m_Float = value; | |
| 345 } | 343 } |
| 344 | |
| 346 CPDF_Number::CPDF_Number(FX_BOOL bInteger, void* pData) | 345 CPDF_Number::CPDF_Number(FX_BOOL bInteger, void* pData) |
| 347 { | 346 : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(bInteger), m_Integer(*(int*)pData) { |
| 348 m_Type = PDFOBJ_NUMBER; | |
| 349 m_bInteger = bInteger; | |
| 350 m_Integer = *(int*)pData; | |
| 351 } | 347 } |
| 352 extern void FX_atonum(FX_BSTR, FX_BOOL&, void*); | 348 |
| 353 CPDF_Number::CPDF_Number(FX_BSTR str) | 349 CPDF_Number::CPDF_Number(FX_BSTR str) : CPDF_Object(PDFOBJ_NUMBER) { |
| 354 { | |
| 355 m_Type = PDFOBJ_NUMBER; | |
| 356 FX_atonum(str, m_bInteger, &m_Integer); | 350 FX_atonum(str, m_bInteger, &m_Integer); |
| 357 } | 351 } |
| 352 | |
| 358 void CPDF_Number::SetString(FX_BSTR str) | 353 void CPDF_Number::SetString(FX_BSTR str) |
| 359 { | 354 { |
| 360 FX_atonum(str, m_bInteger, &m_Integer); | 355 FX_atonum(str, m_bInteger, &m_Integer); |
| 361 } | 356 } |
| 362 FX_BOOL CPDF_Number::Identical(CPDF_Number* pOther) const | 357 FX_BOOL CPDF_Number::Identical(CPDF_Number* pOther) const |
| 363 { | 358 { |
| 364 return m_bInteger == pOther->m_bInteger && m_Integer == pOther->m_Integer; | 359 return m_bInteger == pOther->m_bInteger && m_Integer == pOther->m_Integer; |
| 365 } | 360 } |
| 366 CFX_ByteString CPDF_Number::GetString() const | 361 CFX_ByteString CPDF_Number::GetString() const |
| 367 { | 362 { |
| 368 return m_bInteger ? CFX_ByteString::FormatInteger(m_Integer, FXFORMAT_SIGNED ) : CFX_ByteString::FormatFloat(m_Float); | 363 return m_bInteger ? CFX_ByteString::FormatInteger(m_Integer, FXFORMAT_SIGNED ) : CFX_ByteString::FormatFloat(m_Float); |
| 369 } | 364 } |
| 370 void CPDF_Number::SetNumber(FX_FLOAT value) | 365 void CPDF_Number::SetNumber(FX_FLOAT value) |
| 371 { | 366 { |
| 372 m_bInteger = FALSE; | 367 m_bInteger = FALSE; |
| 373 m_Float = value; | 368 m_Float = value; |
| 374 } | 369 } |
| 375 CPDF_String::CPDF_String(const CFX_WideString& str) | 370 CPDF_String::CPDF_String(const CFX_WideString& str) : CPDF_Object(PDFOBJ_STRING) , m_bHex(FALSE) { |
|
Lei Zhang
2015/02/11 01:02:37
Avoid going over 80 chars?
| |
| 376 { | |
| 377 m_Type = PDFOBJ_STRING; | |
| 378 m_String = PDF_EncodeText(str, str.GetLength()); | 371 m_String = PDF_EncodeText(str, str.GetLength()); |
| 379 m_bHex = FALSE; | |
| 380 } | 372 } |
| 381 CPDF_Array::~CPDF_Array() | 373 CPDF_Array::~CPDF_Array() |
| 382 { | 374 { |
| 383 int size = m_Objects.GetSize(); | 375 int size = m_Objects.GetSize(); |
| 384 CPDF_Object** pList = (CPDF_Object**)m_Objects.GetData(); | 376 CPDF_Object** pList = (CPDF_Object**)m_Objects.GetData(); |
| 385 for (int i = 0; i < size; i ++) { | 377 for (int i = 0; i < size; i ++) { |
| 386 if (pList[i]) | 378 if (pList[i]) |
| 387 pList[i]->Release(); | 379 pList[i]->Release(); |
| 388 } | 380 } |
| 389 } | 381 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 CPDF_Array* pArray = FX_NEW CPDF_Array; | 844 CPDF_Array* pArray = FX_NEW CPDF_Array; |
| 853 pArray->AddNumber16(matrix.a); | 845 pArray->AddNumber16(matrix.a); |
| 854 pArray->AddNumber16(matrix.b); | 846 pArray->AddNumber16(matrix.b); |
| 855 pArray->AddNumber16(matrix.c); | 847 pArray->AddNumber16(matrix.c); |
| 856 pArray->AddNumber16(matrix.d); | 848 pArray->AddNumber16(matrix.d); |
| 857 pArray->AddNumber(matrix.e); | 849 pArray->AddNumber(matrix.e); |
| 858 pArray->AddNumber(matrix.f); | 850 pArray->AddNumber(matrix.f); |
| 859 SetAt(key, pArray); | 851 SetAt(key, pArray); |
| 860 } | 852 } |
| 861 CPDF_Stream::CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict) | 853 CPDF_Stream::CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict) |
| 862 { | 854 : CPDF_Object(PDFOBJ_STREAM) { |
| 863 m_Type = PDFOBJ_STREAM; | |
| 864 m_pDict = pDict; | 855 m_pDict = pDict; |
| 865 m_dwSize = size; | 856 m_dwSize = size; |
| 866 m_GenNum = (FX_DWORD) - 1; | 857 m_GenNum = (FX_DWORD) - 1; |
| 867 m_pDataBuf = pData; | 858 m_pDataBuf = pData; |
| 868 m_pCryptoHandler = NULL; | 859 m_pCryptoHandler = NULL; |
| 869 } | 860 } |
| 870 CPDF_Stream::~CPDF_Stream() | 861 CPDF_Stream::~CPDF_Stream() |
| 871 { | 862 { |
| 872 if (m_GenNum == (FX_DWORD) - 1 && m_pDataBuf != NULL) { | 863 if (m_GenNum == (FX_DWORD) - 1 && m_pDataBuf != NULL) { |
| 873 FX_Free(m_pDataBuf); | 864 FX_Free(m_pDataBuf); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 pObj->m_ObjNum = objnum; | 1277 pObj->m_ObjNum = objnum; |
| 1287 m_IndirectObjs.SetAt((FX_LPVOID)(FX_UINTPTR)objnum, pObj); | 1278 m_IndirectObjs.SetAt((FX_LPVOID)(FX_UINTPTR)objnum, pObj); |
| 1288 if (m_LastObjNum < objnum) { | 1279 if (m_LastObjNum < objnum) { |
| 1289 m_LastObjNum = objnum; | 1280 m_LastObjNum = objnum; |
| 1290 } | 1281 } |
| 1291 } | 1282 } |
| 1292 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const | 1283 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const |
| 1293 { | 1284 { |
| 1294 return m_LastObjNum; | 1285 return m_LastObjNum; |
| 1295 } | 1286 } |
| OLD | NEW |