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

Side by Side Diff: fpdfsdk/formfiller/cba_fontmap.cpp

Issue 2419173002: Update CPDF_IndirectObjectHolder APIs for unique objects (Closed)
Patch Set: Fix issues Created 4 years, 2 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 | « fpdfsdk/cpdfsdk_widget.cpp ('k') | fpdfsdk/fpdf_flatten.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 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/formfiller/cba_fontmap.h" 7 #include "fpdfsdk/formfiller/cba_fontmap.h"
8 8
9 #include "core/fpdfapi/font/cpdf_font.h" 9 #include "core/fpdfapi/font/cpdf_font.h"
10 #include "core/fpdfapi/page/cpdf_page.h" 10 #include "core/fpdfapi/page/cpdf_page.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 m_pAnnotDict->SetFor("AP", pAPDict); 159 m_pAnnotDict->SetFor("AP", pAPDict);
160 } 160 }
161 161
162 // to avoid checkbox and radiobutton 162 // to avoid checkbox and radiobutton
163 CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType); 163 CPDF_Object* pObject = pAPDict->GetObjectFor(m_sAPType);
164 if (ToDictionary(pObject)) 164 if (ToDictionary(pObject))
165 return; 165 return;
166 166
167 CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType); 167 CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType);
168 if (!pStream) { 168 if (!pStream) {
169 pStream = new CPDF_Stream; 169 pStream = m_pDocument->AddIndirectStream();
170 pAPDict->SetReferenceFor(m_sAPType, m_pDocument, 170 pAPDict->SetReferenceFor(m_sAPType, m_pDocument, pStream);
171 m_pDocument->AddIndirectObject(pStream));
172 } 171 }
173 172
174 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 173 CPDF_Dictionary* pStreamDict = pStream->GetDict();
175 if (!pStreamDict) { 174 if (!pStreamDict) {
176 pStreamDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 175 pStreamDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool());
177 pStream->InitStream(nullptr, 0, pStreamDict); 176 pStream->InitStream(nullptr, 0, pStreamDict);
178 } 177 }
179 178
180 if (pStreamDict) { 179 if (pStreamDict) {
181 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); 180 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources");
182 if (!pStreamResList) { 181 if (!pStreamResList) {
183 pStreamResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 182 pStreamResList = new CPDF_Dictionary(m_pDocument->GetByteStringPool());
184 pStreamDict->SetFor("Resources", pStreamResList); 183 pStreamDict->SetFor("Resources", pStreamResList);
185 } 184 }
186 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font"); 185 CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
187 if (!pStreamResFontList) { 186 if (!pStreamResFontList) {
188 pStreamResFontList = 187 pStreamResFontList =
189 new CPDF_Dictionary(m_pDocument->GetByteStringPool()); 188 m_pDocument->AddIndirectDictionary(m_pDocument->GetByteStringPool());
190 pStreamResList->SetReferenceFor( 189 pStreamResList->SetReferenceFor("Font", m_pDocument, pStreamResFontList);
191 "Font", m_pDocument,
192 m_pDocument->AddIndirectObject(pStreamResFontList));
193 } 190 }
194 if (!pStreamResFontList->KeyExist(sAlias)) { 191 if (!pStreamResFontList->KeyExist(sAlias)) {
195 pStreamResFontList->SetReferenceFor(sAlias, m_pDocument, 192 pStreamResFontList->SetReferenceFor(sAlias, m_pDocument,
196 pFont->GetFontDict()->GetObjNum()); 193 pFont->GetFontDict());
197 } 194 }
198 } 195 }
199 } 196 }
200 197
201 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { 198 CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
202 CPDF_Dictionary* pAcroFormDict = nullptr; 199 CPDF_Dictionary* pAcroFormDict = nullptr;
203 const bool bWidget = (m_pAnnotDict->GetStringFor("Subtype") == "Widget"); 200 const bool bWidget = (m_pAnnotDict->GetStringFor("Subtype") == "Widget");
204 if (bWidget) { 201 if (bWidget) {
205 if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot()) 202 if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
206 pAcroFormDict = pRootDict->GetDictFor("AcroForm"); 203 pAcroFormDict = pRootDict->GetDictFor("AcroForm");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 242
246 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; 243 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr;
247 } 244 }
248 245
249 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { 246 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) {
250 m_sAPType = sAPType; 247 m_sAPType = sAPType;
251 248
252 Reset(); 249 Reset();
253 Initialize(); 250 Initialize();
254 } 251 }
OLDNEW
« no previous file with comments | « fpdfsdk/cpdfsdk_widget.cpp ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698