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

Side by Side Diff: xfa/fxfa/app/xfa_fftext.cpp

Issue 2095653002: Remove NULL in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 5 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 | « xfa/fxfa/app/xfa_ffpushbutton.cpp ('k') | xfa/fxfa/app/xfa_fftextedit.h » ('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 "xfa/fxfa/app/xfa_fftext.h" 7 #include "xfa/fxfa/app/xfa_fftext.h"
8 8
9 #include "xfa/fwl/core/fwl_widgetdef.h" 9 #include "xfa/fwl/core/fwl_widgetdef.h"
10 #include "xfa/fxfa/app/xfa_ffdraw.h" 10 #include "xfa/fxfa/app/xfa_ffdraw.h"
(...skipping 20 matching lines...) Expand all
31 mtRotate.Concat(*pMatrix); 31 mtRotate.Concat(*pMatrix);
32 } 32 }
33 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); 33 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
34 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); 34 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
35 if (pTextLayout) { 35 if (pTextLayout) {
36 CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); 36 CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice();
37 CFX_RectF rtText; 37 CFX_RectF rtText;
38 GetRectWithoutRotate(rtText); 38 GetRectWithoutRotate(rtText);
39 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { 39 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
40 CXFA_LayoutItem* pItem = this; 40 CXFA_LayoutItem* pItem = this;
41 if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { 41 if (!pItem->GetPrev() && !pItem->GetNext()) {
42 XFA_RectWidthoutMargin(rtText, mgWidget); 42 XFA_RectWidthoutMargin(rtText, mgWidget);
43 } else { 43 } else {
44 FX_FLOAT fLeftInset, fRightInset, fTopInset = 0, fBottomInset = 0; 44 FX_FLOAT fLeftInset, fRightInset, fTopInset = 0, fBottomInset = 0;
45 mgWidget.GetLeftInset(fLeftInset); 45 mgWidget.GetLeftInset(fLeftInset);
46 mgWidget.GetRightInset(fRightInset); 46 mgWidget.GetRightInset(fRightInset);
47 if (pItem->GetPrev() == NULL) { 47 if (!pItem->GetPrev()) {
48 mgWidget.GetTopInset(fTopInset); 48 mgWidget.GetTopInset(fTopInset);
49 } else if (pItem->GetNext() == NULL) { 49 } else if (!pItem->GetNext()) {
50 mgWidget.GetBottomInset(fBottomInset); 50 mgWidget.GetBottomInset(fBottomInset);
51 } 51 }
52 rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); 52 rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
53 } 53 }
54 } 54 }
55 CFX_Matrix mt; 55 CFX_Matrix mt;
56 mt.Set(1, 0, 0, 1, rtText.left, rtText.top); 56 mt.Set(1, 0, 0, 1, rtText.left, rtText.top);
57 CFX_RectF rtClip = rtText; 57 CFX_RectF rtClip = rtText;
58 mtRotate.TransformRect(rtClip); 58 mtRotate.TransformRect(rtClip);
59 mt.Concat(mtRotate); 59 mt.Concat(mtRotate);
60 pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); 60 pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex());
61 } 61 }
62 } 62 }
63 } 63 }
64 FX_BOOL CXFA_FFText::IsLoaded() { 64 FX_BOOL CXFA_FFText::IsLoaded() {
65 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); 65 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
66 return pTextLayout && !pTextLayout->m_bHasBlock; 66 return pTextLayout && !pTextLayout->m_bHasBlock;
67 } 67 }
68 FX_BOOL CXFA_FFText::PerformLayout() { 68 FX_BOOL CXFA_FFText::PerformLayout() {
69 CXFA_FFDraw::PerformLayout(); 69 CXFA_FFDraw::PerformLayout();
70 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); 70 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
71 if (!pTextLayout) { 71 if (!pTextLayout) {
72 return FALSE; 72 return FALSE;
73 } 73 }
74 if (!pTextLayout->m_bHasBlock) { 74 if (!pTextLayout->m_bHasBlock) {
75 return TRUE; 75 return TRUE;
76 } 76 }
77 pTextLayout->m_Blocks.RemoveAll(); 77 pTextLayout->m_Blocks.RemoveAll();
78 CXFA_LayoutItem* pItem = this; 78 CXFA_LayoutItem* pItem = this;
79 if (pItem->GetPrev() == NULL && pItem->GetNext() == NULL) { 79 if (!pItem->GetPrev() && !pItem->GetNext()) {
80 return TRUE; 80 return TRUE;
81 } 81 }
82 pItem = pItem->GetFirst(); 82 pItem = pItem->GetFirst();
83 while (pItem) { 83 while (pItem) {
84 CFX_RectF rtText; 84 CFX_RectF rtText;
85 pItem->GetRect(rtText); 85 pItem->GetRect(rtText);
86 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { 86 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
87 if (pItem->GetPrev() == NULL) { 87 if (!pItem->GetPrev()) {
88 FX_FLOAT fTopInset; 88 FX_FLOAT fTopInset;
89 mgWidget.GetTopInset(fTopInset); 89 mgWidget.GetTopInset(fTopInset);
90 rtText.height -= fTopInset; 90 rtText.height -= fTopInset;
91 } else if (pItem->GetNext() == NULL) { 91 } else if (!pItem->GetNext()) {
92 FX_FLOAT fBottomInset; 92 FX_FLOAT fBottomInset;
93 mgWidget.GetBottomInset(fBottomInset); 93 mgWidget.GetBottomInset(fBottomInset);
94 rtText.height -= fBottomInset; 94 rtText.height -= fBottomInset;
95 } 95 }
96 } 96 }
97 pTextLayout->ItemBlocks(rtText, pItem->GetIndex()); 97 pTextLayout->ItemBlocks(rtText, pItem->GetIndex());
98 pItem = pItem->GetNext(); 98 pItem = pItem->GetNext();
99 } 99 }
100 pTextLayout->m_bHasBlock = FALSE; 100 pTextLayout->m_bHasBlock = FALSE;
101 return TRUE; 101 return TRUE;
102 } 102 }
103 FX_BOOL CXFA_FFText::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 103 FX_BOOL CXFA_FFText::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
104 CFX_RectF rtBox; 104 CFX_RectF rtBox;
105 GetRectWithoutRotate(rtBox); 105 GetRectWithoutRotate(rtBox);
106 if (!rtBox.Contains(fx, fy)) { 106 if (!rtBox.Contains(fx, fy)) {
107 return FALSE; 107 return FALSE;
108 } 108 }
109 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); 109 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy);
110 if (NULL == wsURLContent) { 110 if (!wsURLContent) {
111 return FALSE; 111 return FALSE;
112 } 112 }
113 SetButtonDown(TRUE); 113 SetButtonDown(TRUE);
114 return TRUE; 114 return TRUE;
115 } 115 }
116 FX_BOOL CXFA_FFText::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 116 FX_BOOL CXFA_FFText::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
117 CFX_RectF rtBox; 117 CFX_RectF rtBox;
118 GetRectWithoutRotate(rtBox); 118 GetRectWithoutRotate(rtBox);
119 if (!rtBox.Contains(fx, fy)) { 119 if (!rtBox.Contains(fx, fy)) {
120 return FALSE; 120 return FALSE;
121 } 121 }
122 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); 122 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy);
123 if (NULL == wsURLContent) { 123 if (!wsURLContent) {
124 return FALSE; 124 return FALSE;
125 } 125 }
126 return TRUE; 126 return TRUE;
127 } 127 }
128 FX_BOOL CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { 128 FX_BOOL CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
129 if (!IsButtonDown()) { 129 if (!IsButtonDown()) {
130 return FALSE; 130 return FALSE;
131 } 131 }
132 SetButtonDown(FALSE); 132 SetButtonDown(FALSE);
133 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); 133 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy);
134 if (NULL == wsURLContent) { 134 if (!wsURLContent) {
135 return FALSE; 135 return FALSE;
136 } 136 }
137 CXFA_FFDoc* pDoc = GetDoc(); 137 CXFA_FFDoc* pDoc = GetDoc();
138 pDoc->GetDocProvider()->GotoURL(pDoc, wsURLContent, FALSE); 138 pDoc->GetDocProvider()->GotoURL(pDoc, wsURLContent, FALSE);
139 return TRUE; 139 return TRUE;
140 } 140 }
141 FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { 141 FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
142 CFX_RectF rtBox; 142 CFX_RectF rtBox;
143 GetRectWithoutRotate(rtBox); 143 GetRectWithoutRotate(rtBox);
144 if (!rtBox.Contains(fx, fy)) 144 if (!rtBox.Contains(fx, fy))
145 return FWL_WidgetHit::Unknown; 145 return FWL_WidgetHit::Unknown;
146 if (!GetLinkURLAtPoint(fx, fy)) 146 if (!GetLinkURLAtPoint(fx, fy))
147 return FWL_WidgetHit::Unknown; 147 return FWL_WidgetHit::Unknown;
148 return FWL_WidgetHit::HyperLink; 148 return FWL_WidgetHit::HyperLink;
149 } 149 }
150 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 150 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
151 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); 151 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
152 if (NULL == pTextLayout) { 152 if (!pTextLayout) {
153 return NULL; 153 return nullptr;
154 } 154 }
155 FX_FLOAT x(fx), y(fy); 155 FX_FLOAT x(fx), y(fy);
156 FWLToClient(x, y); 156 FWLToClient(x, y);
157 const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines(); 157 const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines();
158 int32_t iCount = pPieceLines->GetSize(); 158 int32_t iCount = pPieceLines->GetSize();
159 for (int32_t i = 0; i < iCount; i++) { 159 for (int32_t i = 0; i < iCount; i++) {
160 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); 160 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i);
161 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); 161 int32_t iPieces = pPieceLine->m_textPieces.GetSize();
162 for (int32_t j = 0; j < iPieces; j++) { 162 for (int32_t j = 0; j < iPieces; j++) {
163 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); 163 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j);
164 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { 164 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) {
165 return pPiece->pLinkData->GetLinkURL(); 165 return pPiece->pLinkData->GetLinkURL();
166 } 166 }
167 } 167 }
168 } 168 }
169 return NULL; 169 return nullptr;
170 } 170 }
171 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { 171 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) {
172 CFX_RectF rtWidget; 172 CFX_RectF rtWidget;
173 GetRectWithoutRotate(rtWidget); 173 GetRectWithoutRotate(rtWidget);
174 fx -= rtWidget.left; 174 fx -= rtWidget.left;
175 fy -= rtWidget.top; 175 fy -= rtWidget.top;
176 } 176 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffpushbutton.cpp ('k') | xfa/fxfa/app/xfa_fftextedit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698