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 "SkMD5.h" | 8 #include "SkMD5.h" |
9 #include "SkMilestone.h" | 9 #include "SkMilestone.h" |
10 #include "SkPDFMetadata.h" | 10 #include "SkPDFMetadata.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 SkString SkDocument::PDFMetadata::*const valuePtr; | 36 SkString SkDocument::PDFMetadata::*const valuePtr; |
37 } gMetadataKeys[] = { | 37 } gMetadataKeys[] = { |
38 {"Title", &SkDocument::PDFMetadata::fTitle}, | 38 {"Title", &SkDocument::PDFMetadata::fTitle}, |
39 {"Author", &SkDocument::PDFMetadata::fAuthor}, | 39 {"Author", &SkDocument::PDFMetadata::fAuthor}, |
40 {"Subject", &SkDocument::PDFMetadata::fSubject}, | 40 {"Subject", &SkDocument::PDFMetadata::fSubject}, |
41 {"Keywords", &SkDocument::PDFMetadata::fKeywords}, | 41 {"Keywords", &SkDocument::PDFMetadata::fKeywords}, |
42 {"Creator", &SkDocument::PDFMetadata::fCreator}, | 42 {"Creator", &SkDocument::PDFMetadata::fCreator}, |
43 }; | 43 }; |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 #ifdef SK_SUPPORT_LEGACY_DOCUMENT_API | |
47 void SkPDFMetadata::SetMetadataByKey(const SkString& key, | |
48 const SkString& value, | |
49 SkDocument::PDFMetadata* metadata) { | |
50 for (const auto keyValuePtr : gMetadataKeys) { | |
51 if (key.equals(keyValuePtr.key)) { | |
52 metadata->*(keyValuePtr.valuePtr) = value; | |
53 } | |
54 } | |
55 } | |
56 | |
57 #endif | |
58 | |
59 sk_sp<SkPDFObject> SkPDFMetadata::MakeDocumentInformationDict( | 46 sk_sp<SkPDFObject> SkPDFMetadata::MakeDocumentInformationDict( |
60 const SkDocument::PDFMetadata& metadata) { | 47 const SkDocument::PDFMetadata& metadata) { |
61 auto dict = sk_make_sp<SkPDFDict>(); | 48 auto dict = sk_make_sp<SkPDFDict>(); |
62 for (const auto keyValuePtr : gMetadataKeys) { | 49 for (const auto keyValuePtr : gMetadataKeys) { |
63 const SkString& value = metadata.*(keyValuePtr.valuePtr); | 50 const SkString& value = metadata.*(keyValuePtr.valuePtr); |
64 if (value.size() > 0) { | 51 if (value.size() > 0) { |
65 dict->insertString(keyValuePtr.key, value); | 52 dict->insertString(keyValuePtr.key, value); |
66 } | 53 } |
67 } | 54 } |
68 if (metadata.fProducer.isEmpty()) { | 55 if (metadata.fProducer.isEmpty()) { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 templateString, modificationDate.c_str(), creationDate.c_str(), | 320 templateString, modificationDate.c_str(), creationDate.c_str(), |
334 creator.c_str(), title.c_str(), subject.c_str(), author.c_str(), | 321 creator.c_str(), title.c_str(), subject.c_str(), author.c_str(), |
335 keywords1.c_str(), documentID.c_str(), instanceID.c_str(), | 322 keywords1.c_str(), documentID.c_str(), instanceID.c_str(), |
336 producer.c_str(), keywords2.c_str())); | 323 producer.c_str(), keywords2.c_str())); |
337 } | 324 } |
338 | 325 |
339 #undef SKPDF_CUSTOM_PRODUCER_KEY | 326 #undef SKPDF_CUSTOM_PRODUCER_KEY |
340 #undef SKPDF_PRODUCER | 327 #undef SKPDF_PRODUCER |
341 #undef SKPDF_STRING | 328 #undef SKPDF_STRING |
342 #undef SKPDF_STRING_IMPL | 329 #undef SKPDF_STRING_IMPL |
OLD | NEW |