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 "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 FX_Free(widths); | 249 FX_Free(widths); |
250 } | 250 } |
251 | 251 |
252 int InsertDeletePDFPage(CPDF_Document* pDoc, | 252 int InsertDeletePDFPage(CPDF_Document* pDoc, |
253 CPDF_Dictionary* pPages, | 253 CPDF_Dictionary* pPages, |
254 int nPagesToGo, | 254 int nPagesToGo, |
255 CPDF_Dictionary* pPage, | 255 CPDF_Dictionary* pPage, |
256 FX_BOOL bInsert, | 256 FX_BOOL bInsert, |
257 std::set<CPDF_Dictionary*>* pVisited) { | 257 std::set<CPDF_Dictionary*>* pVisited) { |
258 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); | 258 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
259 if (!pKidList) | 259 if (!pKidList) |
260 return -1; | 260 return -1; |
261 | 261 |
262 for (size_t i = 0; i < pKidList->GetCount(); i++) { | 262 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
263 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 263 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
264 if (pKid->GetStringBy("Type") == "Page") { | 264 if (pKid->GetStringFor("Type") == "Page") { |
265 if (nPagesToGo == 0) { | 265 if (nPagesToGo == 0) { |
266 if (bInsert) { | 266 if (bInsert) { |
267 pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum())); | 267 pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum())); |
268 pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum()); | 268 pPage->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); |
269 } else { | 269 } else { |
270 pKidList->RemoveAt(i); | 270 pKidList->RemoveAt(i); |
271 } | 271 } |
272 pPages->SetAtInteger( | 272 pPages->SetIntegerFor( |
273 "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1)); | 273 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); |
274 return 1; | 274 return 1; |
275 } | 275 } |
276 nPagesToGo--; | 276 nPagesToGo--; |
277 } else { | 277 } else { |
278 int nPages = pKid->GetIntegerBy("Count"); | 278 int nPages = pKid->GetIntegerFor("Count"); |
279 if (nPagesToGo < nPages) { | 279 if (nPagesToGo < nPages) { |
280 if (pdfium::ContainsKey(*pVisited, pKid)) | 280 if (pdfium::ContainsKey(*pVisited, pKid)) |
281 return -1; | 281 return -1; |
282 | 282 |
283 pdfium::ScopedSetInsertion<CPDF_Dictionary*> insertion(pVisited, pKid); | 283 pdfium::ScopedSetInsertion<CPDF_Dictionary*> insertion(pVisited, pKid); |
284 if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert, | 284 if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert, |
285 pVisited) < 0) { | 285 pVisited) < 0) { |
286 return -1; | 286 return -1; |
287 } | 287 } |
288 pPages->SetAtInteger( | 288 pPages->SetIntegerFor( |
289 "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1)); | 289 "Count", pPages->GetIntegerFor("Count") + (bInsert ? 1 : -1)); |
290 return 1; | 290 return 1; |
291 } | 291 } |
292 nPagesToGo -= nPages; | 292 nPagesToGo -= nPages; |
293 } | 293 } |
294 } | 294 } |
295 return 0; | 295 return 0; |
296 } | 296 } |
297 | 297 |
298 int InsertNewPage(CPDF_Document* pDoc, | 298 int InsertNewPage(CPDF_Document* pDoc, |
299 int iPage, | 299 int iPage, |
300 CPDF_Dictionary* pPageDict, | 300 CPDF_Dictionary* pPageDict, |
301 CFX_ArrayTemplate<uint32_t>& pageList) { | 301 CFX_ArrayTemplate<uint32_t>& pageList) { |
302 CPDF_Dictionary* pRoot = pDoc->GetRoot(); | 302 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
303 CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictBy("Pages") : nullptr; | 303 CPDF_Dictionary* pPages = pRoot ? pRoot->GetDictFor("Pages") : nullptr; |
304 if (!pPages) | 304 if (!pPages) |
305 return -1; | 305 return -1; |
306 | 306 |
307 int nPages = pDoc->GetPageCount(); | 307 int nPages = pDoc->GetPageCount(); |
308 if (iPage < 0 || iPage > nPages) | 308 if (iPage < 0 || iPage > nPages) |
309 return -1; | 309 return -1; |
310 | 310 |
311 if (iPage == nPages) { | 311 if (iPage == nPages) { |
312 CPDF_Array* pPagesList = pPages->GetArrayBy("Kids"); | 312 CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); |
313 if (!pPagesList) { | 313 if (!pPagesList) { |
314 pPagesList = new CPDF_Array; | 314 pPagesList = new CPDF_Array; |
315 pPages->SetAt("Kids", pPagesList); | 315 pPages->SetFor("Kids", pPagesList); |
316 } | 316 } |
317 pPagesList->Add(pPageDict, pDoc); | 317 pPagesList->Add(pPageDict, pDoc); |
318 pPages->SetAtInteger("Count", nPages + 1); | 318 pPages->SetIntegerFor("Count", nPages + 1); |
319 pPageDict->SetAtReference("Parent", pDoc, pPages->GetObjNum()); | 319 pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); |
320 } else { | 320 } else { |
321 std::set<CPDF_Dictionary*> stack = {pPages}; | 321 std::set<CPDF_Dictionary*> stack = {pPages}; |
322 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0) | 322 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0) |
323 return -1; | 323 return -1; |
324 } | 324 } |
325 pageList.InsertAt(iPage, pPageDict->GetObjNum()); | 325 pageList.InsertAt(iPage, pPageDict->GetObjNum()); |
326 return iPage; | 326 return iPage; |
327 } | 327 } |
328 | 328 |
329 int CountPages(CPDF_Dictionary* pPages, | 329 int CountPages(CPDF_Dictionary* pPages, |
330 std::set<CPDF_Dictionary*>* visited_pages) { | 330 std::set<CPDF_Dictionary*>* visited_pages) { |
331 int count = pPages->GetIntegerBy("Count"); | 331 int count = pPages->GetIntegerFor("Count"); |
332 if (count > 0 && count < FPDF_PAGE_MAX_NUM) | 332 if (count > 0 && count < FPDF_PAGE_MAX_NUM) |
333 return count; | 333 return count; |
334 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); | 334 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
335 if (!pKidList) | 335 if (!pKidList) |
336 return 0; | 336 return 0; |
337 count = 0; | 337 count = 0; |
338 for (size_t i = 0; i < pKidList->GetCount(); i++) { | 338 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
339 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 339 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
340 if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) | 340 if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) |
341 continue; | 341 continue; |
342 if (pKid->KeyExist("Kids")) { | 342 if (pKid->KeyExist("Kids")) { |
343 // Use |visited_pages| to help detect circular references of pages. | 343 // Use |visited_pages| to help detect circular references of pages. |
344 pdfium::ScopedSetInsertion<CPDF_Dictionary*> local_add(visited_pages, | 344 pdfium::ScopedSetInsertion<CPDF_Dictionary*> local_add(visited_pages, |
345 pKid); | 345 pKid); |
346 count += CountPages(pKid, visited_pages); | 346 count += CountPages(pKid, visited_pages); |
347 } else { | 347 } else { |
348 // This page is a leaf node. | 348 // This page is a leaf node. |
349 count++; | 349 count++; |
350 } | 350 } |
351 } | 351 } |
352 pPages->SetAtInteger("Count", count); | 352 pPages->SetIntegerFor("Count", count); |
353 return count; | 353 return count; |
354 } | 354 } |
355 | 355 |
356 int CalculateFlags(bool bold, | 356 int CalculateFlags(bool bold, |
357 bool italic, | 357 bool italic, |
358 bool fixedPitch, | 358 bool fixedPitch, |
359 bool serif, | 359 bool serif, |
360 bool script, | 360 bool script, |
361 bool symbolic) { | 361 bool symbolic) { |
362 int flags = 0; | 362 int flags = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
381 bool bold, | 381 bool bold, |
382 bool italic, | 382 bool italic, |
383 CFX_ByteString basefont, | 383 CFX_ByteString basefont, |
384 CPDF_Array* pWidths) { | 384 CPDF_Array* pWidths) { |
385 if (bold && italic) | 385 if (bold && italic) |
386 basefont += ",BoldItalic"; | 386 basefont += ",BoldItalic"; |
387 else if (bold) | 387 else if (bold) |
388 basefont += ",Bold"; | 388 basefont += ",Bold"; |
389 else if (italic) | 389 else if (italic) |
390 basefont += ",Italic"; | 390 basefont += ",Italic"; |
391 pBaseDict->SetAtName("Subtype", "TrueType"); | 391 pBaseDict->SetNameFor("Subtype", "TrueType"); |
392 pBaseDict->SetAtName("BaseFont", basefont); | 392 pBaseDict->SetNameFor("BaseFont", basefont); |
393 pBaseDict->SetAtNumber("FirstChar", 32); | 393 pBaseDict->SetNumberFor("FirstChar", 32); |
394 pBaseDict->SetAtNumber("LastChar", 255); | 394 pBaseDict->SetNumberFor("LastChar", 255); |
395 pBaseDict->SetAt("Widths", pWidths); | 395 pBaseDict->SetFor("Widths", pWidths); |
396 } | 396 } |
397 | 397 |
398 } // namespace | 398 } // namespace |
399 | 399 |
400 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) | 400 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) |
401 : CPDF_IndirectObjectHolder(), | 401 : CPDF_IndirectObjectHolder(), |
402 m_pParser(std::move(pParser)), | 402 m_pParser(std::move(pParser)), |
403 m_pRootDict(nullptr), | 403 m_pRootDict(nullptr), |
404 m_pInfoDict(nullptr), | 404 m_pInfoDict(nullptr), |
405 m_bLinearized(false), | 405 m_bLinearized(false), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 void CPDF_Document::LoadDoc() { | 439 void CPDF_Document::LoadDoc() { |
440 LoadDocInternal(); | 440 LoadDocInternal(); |
441 m_PageList.SetSize(RetrievePageCount()); | 441 m_PageList.SetSize(RetrievePageCount()); |
442 } | 442 } |
443 | 443 |
444 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { | 444 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { |
445 m_bLinearized = true; | 445 m_bLinearized = true; |
446 LoadDocInternal(); | 446 LoadDocInternal(); |
447 | 447 |
448 uint32_t dwPageCount = 0; | 448 uint32_t dwPageCount = 0; |
449 CPDF_Object* pCount = pLinearizationParams->GetObjectBy("N"); | 449 CPDF_Object* pCount = pLinearizationParams->GetObjectFor("N"); |
450 if (ToNumber(pCount)) | 450 if (ToNumber(pCount)) |
451 dwPageCount = pCount->GetInteger(); | 451 dwPageCount = pCount->GetInteger(); |
452 m_PageList.SetSize(dwPageCount); | 452 m_PageList.SetSize(dwPageCount); |
453 | 453 |
454 CPDF_Object* pNo = pLinearizationParams->GetObjectBy("P"); | 454 CPDF_Object* pNo = pLinearizationParams->GetObjectFor("P"); |
455 if (ToNumber(pNo)) | 455 if (ToNumber(pNo)) |
456 m_iFirstPageNo = pNo->GetInteger(); | 456 m_iFirstPageNo = pNo->GetInteger(); |
457 | 457 |
458 CPDF_Object* pObjNum = pLinearizationParams->GetObjectBy("O"); | 458 CPDF_Object* pObjNum = pLinearizationParams->GetObjectFor("O"); |
459 if (ToNumber(pObjNum)) | 459 if (ToNumber(pObjNum)) |
460 m_dwFirstPageObjNum = pObjNum->GetInteger(); | 460 m_dwFirstPageObjNum = pObjNum->GetInteger(); |
461 } | 461 } |
462 | 462 |
463 void CPDF_Document::LoadPages() { | 463 void CPDF_Document::LoadPages() { |
464 m_PageList.SetSize(RetrievePageCount()); | 464 m_PageList.SetSize(RetrievePageCount()); |
465 } | 465 } |
466 | 466 |
467 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, | 467 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, |
468 int iPage, | 468 int iPage, |
469 int nPagesToGo, | 469 int nPagesToGo, |
470 int level) { | 470 int level) { |
471 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); | 471 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); |
472 if (!pKidList) | 472 if (!pKidList) |
473 return nPagesToGo == 0 ? pPages : nullptr; | 473 return nPagesToGo == 0 ? pPages : nullptr; |
474 | 474 |
475 if (level >= FX_MAX_PAGE_LEVEL) | 475 if (level >= FX_MAX_PAGE_LEVEL) |
476 return nullptr; | 476 return nullptr; |
477 | 477 |
478 for (size_t i = 0; i < pKidList->GetCount(); i++) { | 478 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
479 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 479 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
480 if (!pKid) { | 480 if (!pKid) { |
481 nPagesToGo--; | 481 nPagesToGo--; |
482 continue; | 482 continue; |
483 } | 483 } |
484 if (pKid == pPages) | 484 if (pKid == pPages) |
485 continue; | 485 continue; |
486 if (!pKid->KeyExist("Kids")) { | 486 if (!pKid->KeyExist("Kids")) { |
487 if (nPagesToGo == 0) | 487 if (nPagesToGo == 0) |
488 return pKid; | 488 return pKid; |
489 | 489 |
490 m_PageList.SetAt(iPage - nPagesToGo, pKid->GetObjNum()); | 490 m_PageList.SetAt(iPage - nPagesToGo, pKid->GetObjNum()); |
491 nPagesToGo--; | 491 nPagesToGo--; |
492 } else { | 492 } else { |
493 int nPages = pKid->GetIntegerBy("Count"); | 493 int nPages = pKid->GetIntegerFor("Count"); |
494 if (nPagesToGo < nPages) | 494 if (nPagesToGo < nPages) |
495 return FindPDFPage(pKid, iPage, nPagesToGo, level + 1); | 495 return FindPDFPage(pKid, iPage, nPagesToGo, level + 1); |
496 | 496 |
497 nPagesToGo -= nPages; | 497 nPagesToGo -= nPages; |
498 } | 498 } |
499 } | 499 } |
500 return nullptr; | 500 return nullptr; |
501 } | 501 } |
502 | 502 |
503 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { | 503 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { |
504 CPDF_Dictionary* pRoot = GetRoot(); | 504 CPDF_Dictionary* pRoot = GetRoot(); |
505 return pRoot ? pRoot->GetDictBy("Pages") : nullptr; | 505 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; |
506 } | 506 } |
507 | 507 |
508 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { | 508 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { |
509 if (iPage < 0 || iPage >= m_PageList.GetSize()) | 509 if (iPage < 0 || iPage >= m_PageList.GetSize()) |
510 return nullptr; | 510 return nullptr; |
511 | 511 |
512 if (m_bLinearized && (iPage == m_iFirstPageNo)) { | 512 if (m_bLinearized && (iPage == m_iFirstPageNo)) { |
513 if (CPDF_Dictionary* pDict = | 513 if (CPDF_Dictionary* pDict = |
514 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { | 514 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { |
515 return pDict; | 515 return pDict; |
(...skipping 27 matching lines...) Expand all Loading... |
543 if (objnum == pNode->GetObjNum()) | 543 if (objnum == pNode->GetObjNum()) |
544 return index; | 544 return index; |
545 | 545 |
546 if (skip_count) | 546 if (skip_count) |
547 skip_count--; | 547 skip_count--; |
548 | 548 |
549 index++; | 549 index++; |
550 return -1; | 550 return -1; |
551 } | 551 } |
552 | 552 |
553 CPDF_Array* pKidList = pNode->GetArrayBy("Kids"); | 553 CPDF_Array* pKidList = pNode->GetArrayFor("Kids"); |
554 if (!pKidList) | 554 if (!pKidList) |
555 return -1; | 555 return -1; |
556 | 556 |
557 if (level >= FX_MAX_PAGE_LEVEL) | 557 if (level >= FX_MAX_PAGE_LEVEL) |
558 return -1; | 558 return -1; |
559 | 559 |
560 size_t count = pNode->GetIntegerBy("Count"); | 560 size_t count = pNode->GetIntegerFor("Count"); |
561 if (count <= skip_count) { | 561 if (count <= skip_count) { |
562 skip_count -= count; | 562 skip_count -= count; |
563 index += count; | 563 index += count; |
564 return -1; | 564 return -1; |
565 } | 565 } |
566 | 566 |
567 if (count && count == pKidList->GetCount()) { | 567 if (count && count == pKidList->GetCount()) { |
568 for (size_t i = 0; i < count; i++) { | 568 for (size_t i = 0; i < count; i++) { |
569 if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) { | 569 if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) { |
570 if (pKid->GetRefObjNum() == objnum) { | 570 if (pKid->GetRefObjNum() == objnum) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 if (!pObj) | 666 if (!pObj) |
667 return nullptr; | 667 return nullptr; |
668 | 668 |
669 ASSERT(pObj->GetObjNum()); | 669 ASSERT(pObj->GetObjNum()); |
670 return m_pDocPage->GetImage(pObj); | 670 return m_pDocPage->GetImage(pObj); |
671 } | 671 } |
672 | 672 |
673 void CPDF_Document::CreateNewDoc() { | 673 void CPDF_Document::CreateNewDoc() { |
674 ASSERT(!m_pRootDict && !m_pInfoDict); | 674 ASSERT(!m_pRootDict && !m_pInfoDict); |
675 m_pRootDict = new CPDF_Dictionary; | 675 m_pRootDict = new CPDF_Dictionary; |
676 m_pRootDict->SetAtName("Type", "Catalog"); | 676 m_pRootDict->SetNameFor("Type", "Catalog"); |
677 int objnum = AddIndirectObject(m_pRootDict); | 677 int objnum = AddIndirectObject(m_pRootDict); |
678 CPDF_Dictionary* pPages = new CPDF_Dictionary; | 678 CPDF_Dictionary* pPages = new CPDF_Dictionary; |
679 pPages->SetAtName("Type", "Pages"); | 679 pPages->SetNameFor("Type", "Pages"); |
680 pPages->SetAtNumber("Count", 0); | 680 pPages->SetNumberFor("Count", 0); |
681 pPages->SetAt("Kids", new CPDF_Array); | 681 pPages->SetFor("Kids", new CPDF_Array); |
682 objnum = AddIndirectObject(pPages); | 682 objnum = AddIndirectObject(pPages); |
683 m_pRootDict->SetAtReference("Pages", this, objnum); | 683 m_pRootDict->SetReferenceFor("Pages", this, objnum); |
684 m_pInfoDict = new CPDF_Dictionary; | 684 m_pInfoDict = new CPDF_Dictionary; |
685 AddIndirectObject(m_pInfoDict); | 685 AddIndirectObject(m_pInfoDict); |
686 } | 686 } |
687 | 687 |
688 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { | 688 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { |
689 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 689 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
690 pDict->SetAtName("Type", "Page"); | 690 pDict->SetNameFor("Type", "Page"); |
691 uint32_t dwObjNum = AddIndirectObject(pDict); | 691 uint32_t dwObjNum = AddIndirectObject(pDict); |
692 if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) { | 692 if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) { |
693 ReleaseIndirectObject(dwObjNum); | 693 ReleaseIndirectObject(dwObjNum); |
694 return nullptr; | 694 return nullptr; |
695 } | 695 } |
696 return pDict; | 696 return pDict; |
697 } | 697 } |
698 | 698 |
699 void CPDF_Document::DeletePage(int iPage) { | 699 void CPDF_Document::DeletePage(int iPage) { |
700 CPDF_Dictionary* pPages = GetPagesDict(); | 700 CPDF_Dictionary* pPages = GetPagesDict(); |
701 if (!pPages) | 701 if (!pPages) |
702 return; | 702 return; |
703 | 703 |
704 int nPages = pPages->GetIntegerBy("Count"); | 704 int nPages = pPages->GetIntegerFor("Count"); |
705 if (iPage < 0 || iPage >= nPages) | 705 if (iPage < 0 || iPage >= nPages) |
706 return; | 706 return; |
707 | 707 |
708 std::set<CPDF_Dictionary*> stack = {pPages}; | 708 std::set<CPDF_Dictionary*> stack = {pPages}; |
709 if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0) | 709 if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0) |
710 return; | 710 return; |
711 | 711 |
712 m_PageList.RemoveAt(iPage); | 712 m_PageList.RemoveAt(iPage); |
713 } | 713 } |
714 | 714 |
715 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, | 715 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, |
716 CPDF_FontEncoding* pEncoding) { | 716 CPDF_FontEncoding* pEncoding) { |
717 CFX_ByteString name(font); | 717 CFX_ByteString name(font); |
718 if (PDF_GetStandardFontName(&name) < 0) | 718 if (PDF_GetStandardFontName(&name) < 0) |
719 return nullptr; | 719 return nullptr; |
720 return GetPageData()->GetStandardFont(name, pEncoding); | 720 return GetPageData()->GetStandardFont(name, pEncoding); |
721 } | 721 } |
722 | 722 |
723 size_t CPDF_Document::CalculateEncodingDict(int charset, | 723 size_t CPDF_Document::CalculateEncodingDict(int charset, |
724 CPDF_Dictionary* pBaseDict) { | 724 CPDF_Dictionary* pBaseDict) { |
725 size_t i; | 725 size_t i; |
726 for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) { | 726 for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) { |
727 if (g_FX_CharsetUnicodes[i].m_Charset == charset) | 727 if (g_FX_CharsetUnicodes[i].m_Charset == charset) |
728 break; | 728 break; |
729 } | 729 } |
730 if (i == FX_ArraySize(g_FX_CharsetUnicodes)) | 730 if (i == FX_ArraySize(g_FX_CharsetUnicodes)) |
731 return i; | 731 return i; |
732 CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary; | 732 CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary; |
733 pEncodingDict->SetAtName("BaseEncoding", "WinAnsiEncoding"); | 733 pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); |
734 CPDF_Array* pArray = new CPDF_Array; | 734 CPDF_Array* pArray = new CPDF_Array; |
735 pArray->AddInteger(128); | 735 pArray->AddInteger(128); |
736 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; | 736 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; |
737 for (int j = 0; j < 128; j++) { | 737 for (int j = 0; j < 128; j++) { |
738 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); | 738 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); |
739 pArray->AddName(name.IsEmpty() ? ".notdef" : name); | 739 pArray->AddName(name.IsEmpty() ? ".notdef" : name); |
740 } | 740 } |
741 pEncodingDict->SetAt("Differences", pArray); | 741 pEncodingDict->SetFor("Differences", pArray); |
742 AddIndirectObject(pEncodingDict); | 742 AddIndirectObject(pEncodingDict); |
743 pBaseDict->SetAtReference("Encoding", this, pEncodingDict); | 743 pBaseDict->SetReferenceFor("Encoding", this, pEncodingDict); |
744 return i; | 744 return i; |
745 } | 745 } |
746 | 746 |
747 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { | 747 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { |
748 if (!pFont) | 748 if (!pFont) |
749 return nullptr; | 749 return nullptr; |
750 | 750 |
751 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || | 751 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || |
752 charset == FXFONT_GB2312_CHARSET || | 752 charset == FXFONT_GB2312_CHARSET || |
753 charset == FXFONT_HANGEUL_CHARSET || | 753 charset == FXFONT_HANGEUL_CHARSET || |
754 charset == FXFONT_SHIFTJIS_CHARSET; | 754 charset == FXFONT_SHIFTJIS_CHARSET; |
755 CFX_ByteString basefont = pFont->GetFamilyName(); | 755 CFX_ByteString basefont = pFont->GetFamilyName(); |
756 basefont.Replace(" ", ""); | 756 basefont.Replace(" ", ""); |
757 int flags = | 757 int flags = |
758 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), | 758 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), |
759 false, false, charset == FXFONT_SYMBOL_CHARSET); | 759 false, false, charset == FXFONT_SYMBOL_CHARSET); |
760 | 760 |
761 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; | 761 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; |
762 pBaseDict->SetAtName("Type", "Font"); | 762 pBaseDict->SetNameFor("Type", "Font"); |
763 std::unique_ptr<CFX_UnicodeEncoding> pEncoding( | 763 std::unique_ptr<CFX_UnicodeEncoding> pEncoding( |
764 new CFX_UnicodeEncoding(pFont)); | 764 new CFX_UnicodeEncoding(pFont)); |
765 CPDF_Dictionary* pFontDict = pBaseDict; | 765 CPDF_Dictionary* pFontDict = pBaseDict; |
766 if (!bCJK) { | 766 if (!bCJK) { |
767 CPDF_Array* pWidths = new CPDF_Array; | 767 CPDF_Array* pWidths = new CPDF_Array; |
768 for (int charcode = 32; charcode < 128; charcode++) { | 768 for (int charcode = 32; charcode < 128; charcode++) { |
769 int glyph_index = pEncoding->GlyphFromCharCode(charcode); | 769 int glyph_index = pEncoding->GlyphFromCharCode(charcode); |
770 int char_width = pFont->GetGlyphWidth(glyph_index); | 770 int char_width = pFont->GetGlyphWidth(glyph_index); |
771 pWidths->AddInteger(char_width); | 771 pWidths->AddInteger(char_width); |
772 } | 772 } |
773 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET || | 773 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET || |
774 charset == FXFONT_SYMBOL_CHARSET) { | 774 charset == FXFONT_SYMBOL_CHARSET) { |
775 pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); | 775 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
776 for (int charcode = 128; charcode <= 255; charcode++) { | 776 for (int charcode = 128; charcode <= 255; charcode++) { |
777 int glyph_index = pEncoding->GlyphFromCharCode(charcode); | 777 int glyph_index = pEncoding->GlyphFromCharCode(charcode); |
778 int char_width = pFont->GetGlyphWidth(glyph_index); | 778 int char_width = pFont->GetGlyphWidth(glyph_index); |
779 pWidths->AddInteger(char_width); | 779 pWidths->AddInteger(char_width); |
780 } | 780 } |
781 } else { | 781 } else { |
782 size_t i = CalculateEncodingDict(charset, pBaseDict); | 782 size_t i = CalculateEncodingDict(charset, pBaseDict); |
783 if (i < FX_ArraySize(g_FX_CharsetUnicodes)) { | 783 if (i < FX_ArraySize(g_FX_CharsetUnicodes)) { |
784 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; | 784 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; |
785 for (int j = 0; j < 128; j++) { | 785 for (int j = 0; j < 128; j++) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 pWidthArray->AddInteger(231); | 829 pWidthArray->AddInteger(231); |
830 InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7d, pWidthArray); | 830 InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7d, pWidthArray); |
831 pWidthArray->AddInteger(326); | 831 pWidthArray->AddInteger(326); |
832 InsertWidthArray1(pFont, pEncoding.get(), 0xa0, 0xa0, pWidthArray); | 832 InsertWidthArray1(pFont, pEncoding.get(), 0xa0, 0xa0, pWidthArray); |
833 pWidthArray->AddInteger(327); | 833 pWidthArray->AddInteger(327); |
834 InsertWidthArray1(pFont, pEncoding.get(), 0xa1, 0xdf, pWidthArray); | 834 InsertWidthArray1(pFont, pEncoding.get(), 0xa1, 0xdf, pWidthArray); |
835 pWidthArray->AddInteger(631); | 835 pWidthArray->AddInteger(631); |
836 InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray); | 836 InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray); |
837 break; | 837 break; |
838 } | 838 } |
839 pBaseDict->SetAtName("Subtype", "Type0"); | 839 pBaseDict->SetNameFor("Subtype", "Type0"); |
840 pBaseDict->SetAtName("BaseFont", basefont); | 840 pBaseDict->SetNameFor("BaseFont", basefont); |
841 pBaseDict->SetAtName("Encoding", cmap); | 841 pBaseDict->SetNameFor("Encoding", cmap); |
842 pFontDict->SetAt("W", pWidthArray); | 842 pFontDict->SetFor("W", pWidthArray); |
843 pFontDict->SetAtName("Type", "Font"); | 843 pFontDict->SetNameFor("Type", "Font"); |
844 pFontDict->SetAtName("Subtype", "CIDFontType2"); | 844 pFontDict->SetNameFor("Subtype", "CIDFontType2"); |
845 pFontDict->SetAtName("BaseFont", basefont); | 845 pFontDict->SetNameFor("BaseFont", basefont); |
846 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; | 846 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; |
847 pCIDSysInfo->SetAtString("Registry", "Adobe"); | 847 pCIDSysInfo->SetStringFor("Registry", "Adobe"); |
848 pCIDSysInfo->SetAtString("Ordering", ordering); | 848 pCIDSysInfo->SetStringFor("Ordering", ordering); |
849 pCIDSysInfo->SetAtInteger("Supplement", supplement); | 849 pCIDSysInfo->SetIntegerFor("Supplement", supplement); |
850 pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo); | 850 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); |
851 CPDF_Array* pArray = new CPDF_Array; | 851 CPDF_Array* pArray = new CPDF_Array; |
852 pBaseDict->SetAt("DescendantFonts", pArray); | 852 pBaseDict->SetFor("DescendantFonts", pArray); |
853 AddIndirectObject(pFontDict); | 853 AddIndirectObject(pFontDict); |
854 pArray->AddReference(this, pFontDict); | 854 pArray->AddReference(this, pFontDict); |
855 } | 855 } |
856 AddIndirectObject(pBaseDict); | 856 AddIndirectObject(pBaseDict); |
857 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; | 857 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; |
858 pFontDesc->SetAtName("Type", "FontDescriptor"); | 858 pFontDesc->SetNameFor("Type", "FontDescriptor"); |
859 pFontDesc->SetAtName("FontName", basefont); | 859 pFontDesc->SetNameFor("FontName", basefont); |
860 pFontDesc->SetAtInteger("Flags", flags); | 860 pFontDesc->SetIntegerFor("Flags", flags); |
861 pFontDesc->SetAtInteger( | 861 pFontDesc->SetIntegerFor( |
862 "ItalicAngle", | 862 "ItalicAngle", |
863 pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0); | 863 pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0); |
864 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); | 864 pFontDesc->SetIntegerFor("Ascent", pFont->GetAscent()); |
865 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); | 865 pFontDesc->SetIntegerFor("Descent", pFont->GetDescent()); |
866 FX_RECT bbox; | 866 FX_RECT bbox; |
867 pFont->GetBBox(bbox); | 867 pFont->GetBBox(bbox); |
868 CPDF_Array* pBBox = new CPDF_Array; | 868 CPDF_Array* pBBox = new CPDF_Array; |
869 pBBox->AddInteger(bbox.left); | 869 pBBox->AddInteger(bbox.left); |
870 pBBox->AddInteger(bbox.bottom); | 870 pBBox->AddInteger(bbox.bottom); |
871 pBBox->AddInteger(bbox.right); | 871 pBBox->AddInteger(bbox.right); |
872 pBBox->AddInteger(bbox.top); | 872 pBBox->AddInteger(bbox.top); |
873 pFontDesc->SetAt("FontBBox", pBBox); | 873 pFontDesc->SetFor("FontBBox", pBBox); |
874 int32_t nStemV = 0; | 874 int32_t nStemV = 0; |
875 if (pFont->GetSubstFont()) { | 875 if (pFont->GetSubstFont()) { |
876 nStemV = pFont->GetSubstFont()->m_Weight / 5; | 876 nStemV = pFont->GetSubstFont()->m_Weight / 5; |
877 } else { | 877 } else { |
878 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; | 878 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; |
879 const size_t count = FX_ArraySize(stem_chars); | 879 const size_t count = FX_ArraySize(stem_chars); |
880 uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); | 880 uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); |
881 nStemV = pFont->GetGlyphWidth(glyph); | 881 nStemV = pFont->GetGlyphWidth(glyph); |
882 for (size_t i = 1; i < count; i++) { | 882 for (size_t i = 1; i < count; i++) { |
883 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); | 883 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); |
884 int width = pFont->GetGlyphWidth(glyph); | 884 int width = pFont->GetGlyphWidth(glyph); |
885 if (width > 0 && width < nStemV) | 885 if (width > 0 && width < nStemV) |
886 nStemV = width; | 886 nStemV = width; |
887 } | 887 } |
888 } | 888 } |
889 pFontDesc->SetAtInteger("StemV", nStemV); | 889 pFontDesc->SetIntegerFor("StemV", nStemV); |
890 AddIndirectObject(pFontDesc); | 890 AddIndirectObject(pFontDesc); |
891 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 891 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); |
892 return LoadFont(pBaseDict); | 892 return LoadFont(pBaseDict); |
893 } | 893 } |
894 | 894 |
895 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 895 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
896 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, | 896 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, |
897 FX_BOOL bVert, | 897 FX_BOOL bVert, |
898 FX_BOOL bTranslateName) { | 898 FX_BOOL bTranslateName) { |
899 LOGFONTA lfa; | 899 LOGFONTA lfa; |
900 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); | 900 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); |
901 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); | 901 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 944 |
945 int italicangle = ptm->otmItalicAngle / 10; | 945 int italicangle = ptm->otmItalicAngle / 10; |
946 int ascend = ptm->otmrcFontBox.top; | 946 int ascend = ptm->otmrcFontBox.top; |
947 int descend = ptm->otmrcFontBox.bottom; | 947 int descend = ptm->otmrcFontBox.bottom; |
948 int capheight = ptm->otmsCapEmHeight; | 948 int capheight = ptm->otmsCapEmHeight; |
949 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom, | 949 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom, |
950 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top}; | 950 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top}; |
951 FX_Free(tm_buf); | 951 FX_Free(tm_buf); |
952 basefont.Replace(" ", ""); | 952 basefont.Replace(" ", ""); |
953 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; | 953 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; |
954 pBaseDict->SetAtName("Type", "Font"); | 954 pBaseDict->SetNameFor("Type", "Font"); |
955 CPDF_Dictionary* pFontDict = pBaseDict; | 955 CPDF_Dictionary* pFontDict = pBaseDict; |
956 if (!bCJK) { | 956 if (!bCJK) { |
957 if (pLogFont->lfCharSet == ANSI_CHARSET || | 957 if (pLogFont->lfCharSet == ANSI_CHARSET || |
958 pLogFont->lfCharSet == DEFAULT_CHARSET || | 958 pLogFont->lfCharSet == DEFAULT_CHARSET || |
959 pLogFont->lfCharSet == SYMBOL_CHARSET) { | 959 pLogFont->lfCharSet == SYMBOL_CHARSET) { |
960 pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); | 960 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
961 } else { | 961 } else { |
962 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); | 962 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); |
963 } | 963 } |
964 int char_widths[224]; | 964 int char_widths[224]; |
965 GetCharWidth(hDC, 32, 255, char_widths); | 965 GetCharWidth(hDC, 32, 255, char_widths); |
966 CPDF_Array* pWidths = new CPDF_Array; | 966 CPDF_Array* pWidths = new CPDF_Array; |
967 for (size_t i = 0; i < 224; i++) | 967 for (size_t i = 0; i < 224; i++) |
968 pWidths->AddInteger(char_widths[i]); | 968 pWidths->AddInteger(char_widths[i]); |
969 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM, | 969 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM, |
970 pLogFont->lfItalic != 0, basefont, pWidths); | 970 pLogFont->lfItalic != 0, basefont, pWidths); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 pWidthArray->AddInteger(231); | 1004 pWidthArray->AddInteger(231); |
1005 InsertWidthArray(hDC, 0x20, 0x7d, pWidthArray); | 1005 InsertWidthArray(hDC, 0x20, 0x7d, pWidthArray); |
1006 pWidthArray->AddInteger(326); | 1006 pWidthArray->AddInteger(326); |
1007 InsertWidthArray(hDC, 0xa0, 0xa0, pWidthArray); | 1007 InsertWidthArray(hDC, 0xa0, 0xa0, pWidthArray); |
1008 pWidthArray->AddInteger(327); | 1008 pWidthArray->AddInteger(327); |
1009 InsertWidthArray(hDC, 0xa1, 0xdf, pWidthArray); | 1009 InsertWidthArray(hDC, 0xa1, 0xdf, pWidthArray); |
1010 pWidthArray->AddInteger(631); | 1010 pWidthArray->AddInteger(631); |
1011 InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray); | 1011 InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray); |
1012 break; | 1012 break; |
1013 } | 1013 } |
1014 pBaseDict->SetAtName("Subtype", "Type0"); | 1014 pBaseDict->SetNameFor("Subtype", "Type0"); |
1015 pBaseDict->SetAtName("BaseFont", basefont); | 1015 pBaseDict->SetNameFor("BaseFont", basefont); |
1016 pBaseDict->SetAtName("Encoding", cmap); | 1016 pBaseDict->SetNameFor("Encoding", cmap); |
1017 pFontDict->SetAt("W", pWidthArray); | 1017 pFontDict->SetFor("W", pWidthArray); |
1018 pFontDict->SetAtName("Type", "Font"); | 1018 pFontDict->SetNameFor("Type", "Font"); |
1019 pFontDict->SetAtName("Subtype", "CIDFontType2"); | 1019 pFontDict->SetNameFor("Subtype", "CIDFontType2"); |
1020 pFontDict->SetAtName("BaseFont", basefont); | 1020 pFontDict->SetNameFor("BaseFont", basefont); |
1021 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; | 1021 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; |
1022 pCIDSysInfo->SetAtString("Registry", "Adobe"); | 1022 pCIDSysInfo->SetStringFor("Registry", "Adobe"); |
1023 pCIDSysInfo->SetAtString("Ordering", ordering); | 1023 pCIDSysInfo->SetStringFor("Ordering", ordering); |
1024 pCIDSysInfo->SetAtInteger("Supplement", supplement); | 1024 pCIDSysInfo->SetIntegerFor("Supplement", supplement); |
1025 pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo); | 1025 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); |
1026 CPDF_Array* pArray = new CPDF_Array; | 1026 CPDF_Array* pArray = new CPDF_Array; |
1027 pBaseDict->SetAt("DescendantFonts", pArray); | 1027 pBaseDict->SetFor("DescendantFonts", pArray); |
1028 AddIndirectObject(pFontDict); | 1028 AddIndirectObject(pFontDict); |
1029 pArray->AddReference(this, pFontDict); | 1029 pArray->AddReference(this, pFontDict); |
1030 } | 1030 } |
1031 AddIndirectObject(pBaseDict); | 1031 AddIndirectObject(pBaseDict); |
1032 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; | 1032 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; |
1033 pFontDesc->SetAtName("Type", "FontDescriptor"); | 1033 pFontDesc->SetNameFor("Type", "FontDescriptor"); |
1034 pFontDesc->SetAtName("FontName", basefont); | 1034 pFontDesc->SetNameFor("FontName", basefont); |
1035 pFontDesc->SetAtInteger("Flags", flags); | 1035 pFontDesc->SetIntegerFor("Flags", flags); |
1036 CPDF_Array* pBBox = new CPDF_Array; | 1036 CPDF_Array* pBBox = new CPDF_Array; |
1037 for (int i = 0; i < 4; i++) | 1037 for (int i = 0; i < 4; i++) |
1038 pBBox->AddInteger(bbox[i]); | 1038 pBBox->AddInteger(bbox[i]); |
1039 pFontDesc->SetAt("FontBBox", pBBox); | 1039 pFontDesc->SetFor("FontBBox", pBBox); |
1040 pFontDesc->SetAtInteger("ItalicAngle", italicangle); | 1040 pFontDesc->SetIntegerFor("ItalicAngle", italicangle); |
1041 pFontDesc->SetAtInteger("Ascent", ascend); | 1041 pFontDesc->SetIntegerFor("Ascent", ascend); |
1042 pFontDesc->SetAtInteger("Descent", descend); | 1042 pFontDesc->SetIntegerFor("Descent", descend); |
1043 pFontDesc->SetAtInteger("CapHeight", capheight); | 1043 pFontDesc->SetIntegerFor("CapHeight", capheight); |
1044 pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5); | 1044 pFontDesc->SetIntegerFor("StemV", pLogFont->lfWeight / 5); |
1045 AddIndirectObject(pFontDesc); | 1045 AddIndirectObject(pFontDesc); |
1046 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 1046 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); |
1047 hFont = SelectObject(hDC, hFont); | 1047 hFont = SelectObject(hDC, hFont); |
1048 DeleteObject(hFont); | 1048 DeleteObject(hFont); |
1049 DeleteDC(hDC); | 1049 DeleteDC(hDC); |
1050 return LoadFont(pBaseDict); | 1050 return LoadFont(pBaseDict); |
1051 } | 1051 } |
1052 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1052 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
OLD | NEW |