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

Side by Side Diff: fpdfsdk/cpdfsdk_widget.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile 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_baannot.cpp ('k') | fpdfsdk/formfiller/cba_fontmap.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/include/cpdfsdk_widget.h" 7 #include "fpdfsdk/include/cpdfsdk_widget.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 FX_FLOAT fc[4]; 1808 FX_FLOAT fc[4];
1809 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); 1809 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc);
1810 if (iColorType > 0) 1810 if (iColorType > 0)
1811 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); 1811 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
1812 1812
1813 return crFill; 1813 return crFill;
1814 } 1814 }
1815 1815
1816 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, 1816 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType,
1817 CPDF_Stream* pImage) { 1817 CPDF_Stream* pImage) {
1818 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1819 ASSERT(pDoc);
1820
1821 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); 1818 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP");
1822 CPDF_Stream* pStream = pAPDict->GetStreamFor(sAPType); 1819 CPDF_Stream* pStream = pAPDict->GetStreamFor(sAPType);
1823 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 1820 CPDF_Dictionary* pStreamDict = pStream->GetDict();
1824 CFX_ByteString sImageAlias = "IMG"; 1821 CFX_ByteString sImageAlias = "IMG";
1825 1822
1826 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { 1823 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) {
1827 sImageAlias = pImageDict->GetStringFor("Name"); 1824 sImageAlias = pImageDict->GetStringFor("Name");
1828 if (sImageAlias.IsEmpty()) 1825 if (sImageAlias.IsEmpty())
1829 sImageAlias = "IMG"; 1826 sImageAlias = "IMG";
1830 } 1827 }
1831 1828
1829 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1832 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); 1830 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources");
1833 if (!pStreamResList) { 1831 if (!pStreamResList) {
1834 pStreamResList = new CPDF_Dictionary(); 1832 pStreamResList = new CPDF_Dictionary(pDoc->GetByteStringPool());
1835 pStreamDict->SetFor("Resources", pStreamResList); 1833 pStreamDict->SetFor("Resources", pStreamResList);
1836 } 1834 }
1837 1835
1838 CPDF_Dictionary* pXObject = new CPDF_Dictionary; 1836 CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc->GetByteStringPool());
1839 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage->GetObjNum()); 1837 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage->GetObjNum());
1840 pStreamResList->SetFor("XObject", pXObject); 1838 pStreamResList->SetFor("XObject", pXObject);
1841 } 1839 }
1842 1840
1843 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { 1841 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
1844 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) 1842 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"))
1845 pAPDict->RemoveFor(sAPType); 1843 pAPDict->RemoveFor(sAPType);
1846 } 1844 }
1847 1845
1848 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, 1846 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 return FALSE; 1947 return FALSE;
1950 1948
1951 if (!IsVisible()) 1949 if (!IsVisible())
1952 return FALSE; 1950 return FALSE;
1953 1951
1954 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 1952 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
1955 return FALSE; 1953 return FALSE;
1956 1954
1957 return TRUE; 1955 return TRUE;
1958 } 1956 }
OLDNEW
« no previous file with comments | « fpdfsdk/cpdfsdk_baannot.cpp ('k') | fpdfsdk/formfiller/cba_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698