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

Side by Side Diff: fpdfsdk/cpdfsdk_widget.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: Remove default ctor Created 4 years, 3 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
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();
dsinclair 2016/09/19 13:24:34 Can we add the ASSERT back in here? We don't de-re
Tom Sepez 2016/09/19 18:24:59 We now de-ref it due to the has-a change. Also t
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);
1835 pStreamDict->SetFor("Resources", pStreamResList); 1833 pStreamDict->SetFor("Resources", pStreamResList);
1836 } 1834 }
1837 1835
1838 if (pStreamResList) { 1836 if (pStreamResList) {
1839 CPDF_Dictionary* pXObject = new CPDF_Dictionary; 1837 CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc);
1840 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage); 1838 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage);
1841 pStreamResList->SetFor("XObject", pXObject); 1839 pStreamResList->SetFor("XObject", pXObject);
1842 } 1840 }
1843 } 1841 }
1844 1842
1845 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { 1843 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
1846 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) 1844 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"))
1847 pAPDict->RemoveFor(sAPType); 1845 pAPDict->RemoveFor(sAPType);
1848 } 1846 }
1849 1847
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 return FALSE; 1949 return FALSE;
1952 1950
1953 if (!IsVisible()) 1951 if (!IsVisible())
1954 return FALSE; 1952 return FALSE;
1955 1953
1956 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 1954 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
1957 return FALSE; 1955 return FALSE;
1958 1956
1959 return TRUE; 1957 return TRUE;
1960 } 1958 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698