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

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

Issue 1892203002: Revert of SkPDF: PDF/A runtime switch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/SkPDFMetadata.h ('k') | no next file » | 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 "SkMD5.h"
9 #include "SkMilestone.h" 8 #include "SkMilestone.h"
10 #include "SkPDFMetadata.h" 9 #include "SkPDFMetadata.h"
11 #include "SkPDFTypes.h" 10 #include "SkPDFTypes.h"
12 #include <utility> 11 #include <utility>
13 12
13 #ifdef SK_PDF_GENERATE_PDFA
14 #include "SkMD5.h"
15 #endif
16
14 static SkString pdf_date(const SkTime::DateTime& dt) { 17 static SkString pdf_date(const SkTime::DateTime& dt) {
15 int timeZoneMinutes = SkToInt(dt.fTimeZoneMinutes); 18 int timeZoneMinutes = SkToInt(dt.fTimeZoneMinutes);
16 char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-'; 19 char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-';
17 int timeZoneHours = SkTAbs(timeZoneMinutes) / 60; 20 int timeZoneHours = SkTAbs(timeZoneMinutes) / 60;
18 timeZoneMinutes = SkTAbs(timeZoneMinutes) % 60; 21 timeZoneMinutes = SkTAbs(timeZoneMinutes) % 60;
19 return SkStringPrintf( 22 return SkStringPrintf(
20 "D:%04u%02u%02u%02u%02u%02u%c%02d'%02d'", 23 "D:%04u%02u%02u%02u%02u%02u%c%02d'%02d'",
21 static_cast<unsigned>(dt.fYear), static_cast<unsigned>(dt.fMonth), 24 static_cast<unsigned>(dt.fYear), static_cast<unsigned>(dt.fMonth),
22 static_cast<unsigned>(dt.fDay), static_cast<unsigned>(dt.fHour), 25 static_cast<unsigned>(dt.fDay), static_cast<unsigned>(dt.fHour),
23 static_cast<unsigned>(dt.fMinute), 26 static_cast<unsigned>(dt.fMinute),
(...skipping 18 matching lines...) Expand all
42 dict->insertString("Producer", "Skia/PDF m" SKPDF_STRING(SK_MILESTONE)); 45 dict->insertString("Producer", "Skia/PDF m" SKPDF_STRING(SK_MILESTONE));
43 if (fCreation) { 46 if (fCreation) {
44 dict->insertString("CreationDate", pdf_date(*fCreation.get())); 47 dict->insertString("CreationDate", pdf_date(*fCreation.get()));
45 } 48 }
46 if (fModified) { 49 if (fModified) {
47 dict->insertString("ModDate", pdf_date(*fModified.get())); 50 dict->insertString("ModDate", pdf_date(*fModified.get()));
48 } 51 }
49 return dict.release(); 52 return dict.release();
50 } 53 }
51 54
55 #ifdef SK_PDF_GENERATE_PDFA
52 SkPDFMetadata::UUID SkPDFMetadata::uuid() const { 56 SkPDFMetadata::UUID SkPDFMetadata::uuid() const {
53 // The main requirement is for the UUID to be unique; the exact 57 // The main requirement is for the UUID to be unique; the exact
54 // format of the data that will be hashed is not important. 58 // format of the data that will be hashed is not important.
55 SkMD5 md5; 59 SkMD5 md5;
56 const char uuidNamespace[] = "org.skia.pdf\n"; 60 const char uuidNamespace[] = "org.skia.pdf\n";
57 md5.write(uuidNamespace, strlen(uuidNamespace)); 61 md5.write(uuidNamespace, strlen(uuidNamespace));
58 double msec = SkTime::GetMSecs(); 62 double msec = SkTime::GetMSecs();
59 md5.write(&msec, sizeof(msec)); 63 md5.write(&msec, sizeof(msec));
60 SkTime::DateTime dateTime; 64 SkTime::DateTime dateTime;
61 SkTime::GetDateTime(&dateTime); 65 SkTime::GetDateTime(&dateTime);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 SkASSERT(0 == count_xml_escape_size(documentID)); 343 SkASSERT(0 == count_xml_escape_size(documentID));
340 SkString instanceID = uuid_to_string(instance); 344 SkString instanceID = uuid_to_string(instance);
341 SkASSERT(0 == count_xml_escape_size(instanceID)); 345 SkASSERT(0 == count_xml_escape_size(instanceID));
342 return new PDFXMLObject(sk_string_printf( 346 return new PDFXMLObject(sk_string_printf(
343 templateString, modificationDate.c_str(), creationDate.c_str(), 347 templateString, modificationDate.c_str(), creationDate.c_str(),
344 creator.c_str(), title.c_str(), 348 creator.c_str(), title.c_str(),
345 subject.c_str(), author.c_str(), keywords1.c_str(), 349 subject.c_str(), author.c_str(), keywords1.c_str(),
346 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); 350 documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
347 } 351 }
348 352
353 #endif // SK_PDF_GENERATE_PDFA
354
349 #undef SKPDF_STRING 355 #undef SKPDF_STRING
350 #undef SKPDF_STRING_IMPL 356 #undef SKPDF_STRING_IMPL
351 357
OLDNEW
« no previous file with comments | « src/pdf/SkPDFMetadata.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698