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

Side by Side Diff: fpdfsdk/cpdfsdk_widget.cpp

Issue 2510223002: Make CPDF_Dictionary use unique pointers. (Closed)
Patch Set: rebase Created 4 years, 1 month 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/cpdfsdk_widget.h" 7 #include "fpdfsdk/cpdfsdk_widget.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "core/fpdfapi/parser/cpdf_array.h"
11 #include "core/fpdfapi/parser/cpdf_dictionary.h" 12 #include "core/fpdfapi/parser/cpdf_dictionary.h"
12 #include "core/fpdfapi/parser/cpdf_document.h" 13 #include "core/fpdfapi/parser/cpdf_document.h"
14 #include "core/fpdfapi/parser/cpdf_reference.h"
13 #include "core/fpdfapi/parser/cpdf_stream.h" 15 #include "core/fpdfapi/parser/cpdf_stream.h"
16 #include "core/fpdfapi/parser/cpdf_string.h"
14 #include "core/fpdfdoc/cpdf_defaultappearance.h" 17 #include "core/fpdfdoc/cpdf_defaultappearance.h"
15 #include "core/fpdfdoc/cpdf_formcontrol.h" 18 #include "core/fpdfdoc/cpdf_formcontrol.h"
16 #include "core/fpdfdoc/cpdf_formfield.h" 19 #include "core/fpdfdoc/cpdf_formfield.h"
17 #include "core/fpdfdoc/cpdf_iconfit.h" 20 #include "core/fpdfdoc/cpdf_iconfit.h"
18 #include "core/fpdfdoc/cpdf_interform.h" 21 #include "core/fpdfdoc/cpdf_interform.h"
19 #include "core/fxge/cfx_graphstatedata.h" 22 #include "core/fxge/cfx_graphstatedata.h"
20 #include "core/fxge/cfx_pathdata.h" 23 #include "core/fxge/cfx_pathdata.h"
21 #include "core/fxge/cfx_renderdevice.h" 24 #include "core/fxge/cfx_renderdevice.h"
22 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 25 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
23 #include "fpdfsdk/cpdfsdk_interform.h" 26 #include "fpdfsdk/cpdfsdk_interform.h"
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 962
960 if (pControl->HasMKEntry("RI")) 963 if (pControl->HasMKEntry("RI"))
961 pRolloverIcon = pControl->GetRolloverIcon(); 964 pRolloverIcon = pControl->GetRolloverIcon();
962 965
963 if (pControl->HasMKEntry("IX")) 966 if (pControl->HasMKEntry("IX"))
964 pDownIcon = pControl->GetDownIcon(); 967 pDownIcon = pControl->GetDownIcon();
965 968
966 if (pNormalIcon) { 969 if (pNormalIcon) {
967 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { 970 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) {
968 if (pImageDict->GetStringFor("Name").IsEmpty()) 971 if (pImageDict->GetStringFor("Name").IsEmpty())
969 pImageDict->SetStringFor("Name", "ImgA"); 972 pImageDict->SetNewFor<CPDF_String>("Name", "ImgA", false);
970 } 973 }
971 } 974 }
972 975
973 if (pRolloverIcon) { 976 if (pRolloverIcon) {
974 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { 977 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) {
975 if (pImageDict->GetStringFor("Name").IsEmpty()) 978 if (pImageDict->GetStringFor("Name").IsEmpty())
976 pImageDict->SetStringFor("Name", "ImgB"); 979 pImageDict->SetNewFor<CPDF_String>("Name", "ImgB", false);
977 } 980 }
978 } 981 }
979 982
980 if (pDownIcon) { 983 if (pDownIcon) {
981 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { 984 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) {
982 if (pImageDict->GetStringFor("Name").IsEmpty()) 985 if (pImageDict->GetStringFor("Name").IsEmpty())
983 pImageDict->SetStringFor("Name", "ImgC"); 986 pImageDict->SetNewFor<CPDF_String>("Name", "ImgC", false);
984 } 987 }
985 } 988 }
986 989
987 CPDF_IconFit iconFit = pControl->GetIconFit(); 990 CPDF_IconFit iconFit = pControl->GetIconFit();
988 991
989 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler()); 992 CBA_FontMap font_map(this, m_pInterForm->GetFormFillEnv()->GetSysHandler());
990 font_map.SetAPType("N"); 993 font_map.SetAPType("N");
991 994
992 CFX_ByteString csAP = 995 CFX_ByteString csAP =
993 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + 996 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) +
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 CFX_ByteString sImageAlias = "IMG"; 1800 CFX_ByteString sImageAlias = "IMG";
1798 1801
1799 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { 1802 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) {
1800 sImageAlias = pImageDict->GetStringFor("Name"); 1803 sImageAlias = pImageDict->GetStringFor("Name");
1801 if (sImageAlias.IsEmpty()) 1804 if (sImageAlias.IsEmpty())
1802 sImageAlias = "IMG"; 1805 sImageAlias = "IMG";
1803 } 1806 }
1804 1807
1805 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 1808 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1806 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources"); 1809 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictFor("Resources");
1807 if (!pStreamResList) { 1810 if (!pStreamResList)
1808 pStreamResList = new CPDF_Dictionary(pDoc->GetByteStringPool()); 1811 pStreamResList = pStreamDict->SetNewFor<CPDF_Dictionary>("Resources");
1809 pStreamDict->SetFor("Resources", pStreamResList);
1810 }
1811 1812
1812 CPDF_Dictionary* pXObject = new CPDF_Dictionary(pDoc->GetByteStringPool()); 1813 CPDF_Dictionary* pXObject =
1813 pXObject->SetReferenceFor(sImageAlias, pDoc, pImage->GetObjNum()); 1814 pStreamResList->SetNewFor<CPDF_Dictionary>("XObject");
1814 pStreamResList->SetFor("XObject", pXObject); 1815 pXObject->SetNewFor<CPDF_Reference>(sImageAlias, pDoc, pImage->GetObjNum());
1815 } 1816 }
1816 1817
1817 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { 1818 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
1818 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP")) 1819 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"))
1819 pAPDict->RemoveFor(sAPType); 1820 pAPDict->RemoveFor(sAPType);
1820 } 1821 }
1821 1822
1822 bool CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, 1823 bool CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
1823 PDFSDK_FieldAction& data, 1824 PDFSDK_FieldAction& data,
1824 CPDFSDK_PageView* pPageView) { 1825 CPDFSDK_PageView* pPageView) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 return false; 1923 return false;
1923 1924
1924 if (!IsVisible()) 1925 if (!IsVisible())
1925 return false; 1926 return false;
1926 1927
1927 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 1928 if ((GetFieldFlags() & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
1928 return false; 1929 return false;
1929 1930
1930 return true; 1931 return true;
1931 } 1932 }
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