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

Side by Side Diff: src/pdf/SkPDFMetadata.cpp

Issue 1773033002: SkPDF: use sk_make_sp<T> when it makes sense. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-08 (Tuesday) 06:54:33 EST Created 4 years, 9 months 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
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFResourceDict.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPDFMetadata.h" 8 #include "SkPDFMetadata.h"
9 #include "SkPDFTypes.h" 9 #include "SkPDFTypes.h"
10 #include <utility> 10 #include <utility>
(...skipping 10 matching lines...) Expand all
21 return SkStringPrintf( 21 return SkStringPrintf(
22 "D:%04u%02u%02u%02u%02u%02u%c%02d'%02d'", 22 "D:%04u%02u%02u%02u%02u%02u%c%02d'%02d'",
23 static_cast<unsigned>(dt.fYear), static_cast<unsigned>(dt.fMonth), 23 static_cast<unsigned>(dt.fYear), static_cast<unsigned>(dt.fMonth),
24 static_cast<unsigned>(dt.fDay), static_cast<unsigned>(dt.fHour), 24 static_cast<unsigned>(dt.fDay), static_cast<unsigned>(dt.fHour),
25 static_cast<unsigned>(dt.fMinute), 25 static_cast<unsigned>(dt.fMinute),
26 static_cast<unsigned>(dt.fSecond), timezoneSign, timeZoneHours, 26 static_cast<unsigned>(dt.fSecond), timezoneSign, timeZoneHours,
27 timeZoneMinutes); 27 timeZoneMinutes);
28 } 28 }
29 29
30 SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const { 30 SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const {
31 sk_sp<SkPDFDict> dict(new SkPDFDict); 31 auto dict = sk_make_sp<SkPDFDict>();
32 static const char* keys[] = { 32 static const char* keys[] = {
33 "Title", "Author", "Subject", "Keywords", "Creator"}; 33 "Title", "Author", "Subject", "Keywords", "Creator"};
34 for (const char* key : keys) { 34 for (const char* key : keys) {
35 for (const SkDocument::Attribute& keyValue : fInfo) { 35 for (const SkDocument::Attribute& keyValue : fInfo) {
36 if (keyValue.fKey.equals(key)) { 36 if (keyValue.fKey.equals(key)) {
37 dict->insertString(key, keyValue.fValue); 37 dict->insertString(key, keyValue.fValue);
38 } 38 }
39 } 39 }
40 } 40 }
41 dict->insertString("Producer", "Skia/PDF"); 41 dict->insertString("Producer", "Skia/PDF");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 digest.data[8] = (digest.data[6] & 0x3F) | 0x80; 79 digest.data[8] = (digest.data[6] & 0x3F) | 0x80;
80 static_assert(sizeof(digest) == sizeof(UUID), "uuid_size"); 80 static_assert(sizeof(digest) == sizeof(UUID), "uuid_size");
81 SkPDFMetadata::UUID uuid; 81 SkPDFMetadata::UUID uuid;
82 memcpy(&uuid, &digest, sizeof(digest)); 82 memcpy(&uuid, &digest, sizeof(digest));
83 return uuid; 83 return uuid;
84 } 84 }
85 85
86 SkPDFObject* SkPDFMetadata::CreatePdfId(const UUID& doc, const UUID& instance) { 86 SkPDFObject* SkPDFMetadata::CreatePdfId(const UUID& doc, const UUID& instance) {
87 // /ID [ <81b14aafa313db63dbd6f981e49f94f4> 87 // /ID [ <81b14aafa313db63dbd6f981e49f94f4>
88 // <81b14aafa313db63dbd6f981e49f94f4> ] 88 // <81b14aafa313db63dbd6f981e49f94f4> ]
89 sk_sp<SkPDFArray> array(new SkPDFArray); 89 auto array = sk_make_sp<SkPDFArray>();
90 static_assert(sizeof(UUID) == 16, "uuid_size"); 90 static_assert(sizeof(UUID) == 16, "uuid_size");
91 array->appendString( 91 array->appendString(
92 SkString(reinterpret_cast<const char*>(&doc), sizeof(UUID))); 92 SkString(reinterpret_cast<const char*>(&doc), sizeof(UUID)));
93 array->appendString( 93 array->appendString(
94 SkString(reinterpret_cast<const char*>(&instance), sizeof(UUID))); 94 SkString(reinterpret_cast<const char*>(&instance), sizeof(UUID)));
95 return array.release(); 95 return array.release();
96 } 96 }
97 97
98 // Improvement on SkStringPrintf to allow for arbitrarily long output. 98 // Improvement on SkStringPrintf to allow for arbitrarily long output.
99 // TODO: replace SkStringPrintf. 99 // TODO: replace SkStringPrintf.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 SkString instanceID = uuid_to_string(instance); 342 SkString instanceID = uuid_to_string(instance);
343 SkASSERT(0 == count_xml_escape_size(instanceID)); 343 SkASSERT(0 == count_xml_escape_size(instanceID));
344 return new PDFXMLObject(sk_string_printf( 344 return new PDFXMLObject(sk_string_printf(
345 templateString, modificationDate.c_str(), creationDate.c_str(), 345 templateString, modificationDate.c_str(), creationDate.c_str(),
346 metadataDate.c_str(), creator.c_str(), title.c_str(), 346 metadataDate.c_str(), creator.c_str(), title.c_str(),
347 subject.c_str(), author.c_str(), keywords1.c_str(), 347 subject.c_str(), author.c_str(), keywords1.c_str(),
348 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); 348 documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
349 } 349 }
350 350
351 #endif // SK_PDF_GENERATE_PDFA 351 #endif // SK_PDF_GENERATE_PDFA
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFResourceDict.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698