OLD | NEW |
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/fwl_widgetdef.h" | 9 #include "xfa/fwl/fwl_widgetdef.h" |
10 #include "xfa/fwl/fwl_widgethit.h" | 10 #include "xfa/fwl/fwl_widgethit.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 CFX_RectF rtBox; | 146 CFX_RectF rtBox; |
147 GetRectWithoutRotate(rtBox); | 147 GetRectWithoutRotate(rtBox); |
148 if (!rtBox.Contains(fx, fy)) | 148 if (!rtBox.Contains(fx, fy)) |
149 return FWL_WidgetHit::Unknown; | 149 return FWL_WidgetHit::Unknown; |
150 if (!GetLinkURLAtPoint(fx, fy)) | 150 if (!GetLinkURLAtPoint(fx, fy)) |
151 return FWL_WidgetHit::Unknown; | 151 return FWL_WidgetHit::Unknown; |
152 return FWL_WidgetHit::HyperLink; | 152 return FWL_WidgetHit::HyperLink; |
153 } | 153 } |
154 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 154 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
155 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); | 155 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); |
156 if (!pTextLayout) { | 156 if (!pTextLayout) |
157 return nullptr; | 157 return nullptr; |
158 } | 158 |
159 FX_FLOAT x(fx), y(fy); | 159 FX_FLOAT x(fx); |
| 160 FX_FLOAT y(fy); |
160 FWLToClient(x, y); | 161 FWLToClient(x, y); |
161 const CFX_ArrayTemplate<CXFA_PieceLine*>* pPieceLines = | 162 |
162 pTextLayout->GetPieceLines(); | 163 for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) { |
163 int32_t iCount = pPieceLines->GetSize(); | 164 for (const auto& pPiece : pPieceLine->m_textPieces) { |
164 for (int32_t i = 0; i < iCount; i++) { | 165 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) |
165 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); | |
166 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | |
167 for (int32_t j = 0; j < iPieces; j++) { | |
168 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); | |
169 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { | |
170 return pPiece->pLinkData->GetLinkURL(); | 166 return pPiece->pLinkData->GetLinkURL(); |
171 } | |
172 } | 167 } |
173 } | 168 } |
174 return nullptr; | 169 return nullptr; |
175 } | 170 } |
176 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { | 171 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { |
177 CFX_RectF rtWidget; | 172 CFX_RectF rtWidget; |
178 GetRectWithoutRotate(rtWidget); | 173 GetRectWithoutRotate(rtWidget); |
179 fx -= rtWidget.left; | 174 fx -= rtWidget.left; |
180 fy -= rtWidget.top; | 175 fy -= rtWidget.top; |
181 } | 176 } |
OLD | NEW |