OLD | NEW |
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 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 } | 39 } |
40 } | 40 } |
41 dict->insertString("Producer", "Skia/PDF"); | 41 dict->insertString("Producer", "Skia/PDF"); |
42 if (fCreation) { | 42 if (fCreation) { |
43 dict->insertString("CreationDate", pdf_date(*fCreation.get())); | 43 dict->insertString("CreationDate", pdf_date(*fCreation.get())); |
44 } | 44 } |
45 if (fModified) { | 45 if (fModified) { |
46 dict->insertString("ModDate", pdf_date(*fModified.get())); | 46 dict->insertString("ModDate", pdf_date(*fModified.get())); |
47 } | 47 } |
48 return dict.detach(); | 48 return dict.release(); |
49 } | 49 } |
50 | 50 |
51 #ifdef SK_PDF_GENERATE_PDFA | 51 #ifdef SK_PDF_GENERATE_PDFA |
52 SkPDFMetadata::UUID SkPDFMetadata::uuid() const { | 52 SkPDFMetadata::UUID SkPDFMetadata::uuid() const { |
53 // The main requirement is for the UUID to be unique; the exact | 53 // The main requirement is for the UUID to be unique; the exact |
54 // format of the data that will be hashed is not important. | 54 // format of the data that will be hashed is not important. |
55 SkMD5 md5; | 55 SkMD5 md5; |
56 const char uuidNamespace[] = "org.skia.pdf\n"; | 56 const char uuidNamespace[] = "org.skia.pdf\n"; |
57 md5.write(uuidNamespace, strlen(uuidNamespace)); | 57 md5.write(uuidNamespace, strlen(uuidNamespace)); |
58 SkMSec msec = SkTime::GetMSecs(); | 58 SkMSec msec = SkTime::GetMSecs(); |
(...skipping 26 matching lines...) Expand all Loading... |
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 SkAutoTUnref<SkPDFArray> array(new SkPDFArray); | 89 SkAutoTUnref<SkPDFArray> array(new 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.detach(); | 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. |
100 static SkString sk_string_printf(const char* format, ...) { | 100 static SkString sk_string_printf(const char* format, ...) { |
101 #ifdef SK_BUILD_FOR_WIN | 101 #ifdef SK_BUILD_FOR_WIN |
102 va_list args; | 102 va_list args; |
103 va_start(args, format); | 103 va_start(args, format); |
104 char buffer[1024]; | 104 char buffer[1024]; |
105 int length = _vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, format, args); | 105 int length = _vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, format, args); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |