1 /* 2 Source File : InfoDictionary.cpp 3 4 5 Copyright 2011 Gal Kahana PDFWriter 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 20 */ 21 #include "InfoDictionary.h" 22 InfoDictionary(void)23InfoDictionary::InfoDictionary(void) 24 { 25 Trapped = EInfoTrappedUnknown; 26 } 27 ~InfoDictionary(void)28InfoDictionary::~InfoDictionary(void) 29 { 30 } 31 IsEmpty()32bool InfoDictionary::IsEmpty() 33 { 34 return 35 Title.IsEmpty() && 36 Author.IsEmpty() && 37 Subject.IsEmpty() && 38 Keywords.IsEmpty() && 39 Creator.IsEmpty() && 40 Producer.IsEmpty() && 41 CreationDate.IsNull() && 42 ModDate.IsNull() && 43 EInfoTrappedUnknown == Trapped && 44 mAdditionalInfoEntries.empty(); 45 46 } 47 Reset()48void InfoDictionary::Reset() 49 { 50 mAdditionalInfoEntries.clear(); 51 Trapped = EInfoTrappedUnknown; 52 Title = PDFTextString::Empty; 53 Author = PDFTextString::Empty; 54 Subject = PDFTextString::Empty; 55 Keywords = PDFTextString::Empty; 56 Creator = PDFTextString::Empty; 57 Producer = PDFTextString::Empty; 58 CreationDate.SetTime(-1); 59 ModDate.SetTime(-1); 60 } 61 AddAdditionalInfoEntry(const std::string & inKey,const PDFTextString & inValue)62void InfoDictionary::AddAdditionalInfoEntry(const std::string& inKey, 63 const PDFTextString& inValue) 64 { 65 if(mAdditionalInfoEntries.find(inKey) != mAdditionalInfoEntries.end()) 66 mAdditionalInfoEntries[inKey] = inValue; 67 else 68 mAdditionalInfoEntries.insert(StringToPDFTextString::value_type(inKey,inValue)); 69 } 70 RemoveAdditionalInfoEntry(const std::string & inKey)71void InfoDictionary::RemoveAdditionalInfoEntry(const std::string& inKey) 72 { 73 StringToPDFTextString::iterator it = mAdditionalInfoEntries.find(inKey); 74 if(it != mAdditionalInfoEntries.end()) 75 mAdditionalInfoEntries.erase(it); 76 } 77 ClearAdditionalInfoEntries()78void InfoDictionary::ClearAdditionalInfoEntries() 79 { 80 mAdditionalInfoEntries.clear(); 81 } 82 GetAdditionalInfoEntry(const std::string & inKey)83PDFTextString InfoDictionary::GetAdditionalInfoEntry(const std::string& inKey) 84 { 85 StringToPDFTextString::iterator it = mAdditionalInfoEntries.find(inKey); 86 87 if(it == mAdditionalInfoEntries.end()) 88 return PDFTextString::Empty; 89 else 90 return it->second; 91 } 92 GetAdditionaEntriesIterator()93MapIterator<StringToPDFTextString> InfoDictionary::GetAdditionaEntriesIterator() 94 { 95 return MapIterator<StringToPDFTextString>(mAdditionalInfoEntries); 96 } 97