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

Side by Side Diff: fpdfsdk/cpdfsdk_widget.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compilation 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();
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 if (pStreamResList) { 1836 CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc->GetByteStringPool());
1839 CPDF_Dictionary* pXObject = new CPDF_Dictionary; 1837 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage);
1840 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage); 1838 pStreamResList->SetFor("XObject", pXObject);
1841 pStreamResList->SetFor("XObject", pXObject);
1842 }
1843 } 1839 }
1844 1840
1845 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { 1841 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
1846 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) 1842 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"))
1847 pAPDict->RemoveFor(sAPType); 1843 pAPDict->RemoveFor(sAPType);
1848 } 1844 }
1849 1845
1850 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, 1846 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
1851 PDFSDK_FieldAction& data, 1847 PDFSDK_FieldAction& data,
1852 CPDFSDK_PageView* pPageView) { 1848 CPDFSDK_PageView* pPageView) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 return FALSE; 1947 return FALSE;
1952 1948
1953 if (!IsVisible()) 1949 if (!IsVisible())
1954 return FALSE; 1950 return FALSE;
1955 1951
1956 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 1952 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
1957 return FALSE; 1953 return FALSE;
1958 1954
1959 return TRUE; 1955 return TRUE;
1960 } 1956 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698