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

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

Issue 1781673002: Skia minor version tracks milestone release branch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-09 (Wednesday) 11:54:09 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 | « include/core/SkTypes.h ('k') | tests/PDFMetadataAttributeTest.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>
11 11
12 #ifdef SK_PDF_GENERATE_PDFA 12 #ifdef SK_PDF_GENERATE_PDFA
13 #include "SkMD5.h" 13 #include "SkMD5.h"
14 #endif 14 #endif
15 15
16 static SkString pdf_date(const SkTime::DateTime& dt) { 16 static SkString pdf_date(const SkTime::DateTime& dt) {
17 int timeZoneMinutes = SkToInt(dt.fTimeZoneMinutes); 17 int timeZoneMinutes = SkToInt(dt.fTimeZoneMinutes);
18 char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-'; 18 char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-';
19 int timeZoneHours = SkTAbs(timeZoneMinutes) / 60; 19 int timeZoneHours = SkTAbs(timeZoneMinutes) / 60;
20 timeZoneMinutes = SkTAbs(timeZoneMinutes) % 60; 20 timeZoneMinutes = SkTAbs(timeZoneMinutes) % 60;
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 #define SKPDF_STRING(X) SKPDF_STRING_IMPL(X)
30 #define SKPDF_STRING_IMPL(X) #X
29 31
30 SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const { 32 SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const {
31 auto dict = sk_make_sp<SkPDFDict>(); 33 auto dict = sk_make_sp<SkPDFDict>();
32 static const char* keys[] = { 34 static const char* keys[] = {
33 "Title", "Author", "Subject", "Keywords", "Creator"}; 35 "Title", "Author", "Subject", "Keywords", "Creator"};
34 for (const char* key : keys) { 36 for (const char* key : keys) {
35 for (const SkDocument::Attribute& keyValue : fInfo) { 37 for (const SkDocument::Attribute& keyValue : fInfo) {
36 if (keyValue.fKey.equals(key)) { 38 if (keyValue.fKey.equals(key)) {
37 dict->insertString(key, keyValue.fValue); 39 dict->insertString(key, keyValue.fValue);
38 } 40 }
39 } 41 }
40 } 42 }
41 dict->insertString("Producer", "Skia/PDF"); 43 dict->insertString("Producer", "Skia/PDF m" SKPDF_STRING(SKIA_MILESTONE));
42 if (fCreation) { 44 if (fCreation) {
43 dict->insertString("CreationDate", pdf_date(*fCreation.get())); 45 dict->insertString("CreationDate", pdf_date(*fCreation.get()));
44 } 46 }
45 if (fModified) { 47 if (fModified) {
46 dict->insertString("ModDate", pdf_date(*fModified.get())); 48 dict->insertString("ModDate", pdf_date(*fModified.get()));
47 } 49 }
48 return dict.release(); 50 return dict.release();
49 } 51 }
50 52
51 #ifdef SK_PDF_GENERATE_PDFA 53 #ifdef SK_PDF_GENERATE_PDFA
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 SkString instanceID = uuid_to_string(instance); 344 SkString instanceID = uuid_to_string(instance);
343 SkASSERT(0 == count_xml_escape_size(instanceID)); 345 SkASSERT(0 == count_xml_escape_size(instanceID));
344 return new PDFXMLObject(sk_string_printf( 346 return new PDFXMLObject(sk_string_printf(
345 templateString, modificationDate.c_str(), creationDate.c_str(), 347 templateString, modificationDate.c_str(), creationDate.c_str(),
346 metadataDate.c_str(), creator.c_str(), title.c_str(), 348 metadataDate.c_str(), creator.c_str(), title.c_str(),
347 subject.c_str(), author.c_str(), keywords1.c_str(), 349 subject.c_str(), author.c_str(), keywords1.c_str(),
348 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); 350 documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
349 } 351 }
350 352
351 #endif // SK_PDF_GENERATE_PDFA 353 #endif // SK_PDF_GENERATE_PDFA
OLDNEW
« no previous file with comments | « include/core/SkTypes.h ('k') | tests/PDFMetadataAttributeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698