| 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/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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 SetButtonDown(FALSE); | 133 SetButtonDown(FALSE); |
| 134 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); | 134 const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); |
| 135 if (NULL == wsURLContent) { | 135 if (NULL == wsURLContent) { |
| 136 return FALSE; | 136 return FALSE; |
| 137 } | 137 } |
| 138 CXFA_FFDoc* pDoc = GetDoc(); | 138 CXFA_FFDoc* pDoc = GetDoc(); |
| 139 pDoc->GetDocProvider()->GotoURL(pDoc, CFX_WideStringC(wsURLContent), FALSE); | 139 pDoc->GetDocProvider()->GotoURL(pDoc, CFX_WideStringC(wsURLContent), FALSE); |
| 140 return TRUE; | 140 return TRUE; |
| 141 } | 141 } |
| 142 uint32_t CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { | 142 FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 143 CFX_RectF rtBox; | 143 CFX_RectF rtBox; |
| 144 GetRectWithoutRotate(rtBox); | 144 GetRectWithoutRotate(rtBox); |
| 145 if (!rtBox.Contains(fx, fy)) { | 145 if (!rtBox.Contains(fx, fy)) |
| 146 return FWL_WGTHITTEST_Unknown; | 146 return FWL_WidgetHit::Unknown; |
| 147 } | 147 if (!GetLinkURLAtPoint(fx, fy)) |
| 148 if (!GetLinkURLAtPoint(fx, fy)) { | 148 return FWL_WidgetHit::Unknown; |
| 149 return FWL_WGTHITTEST_Unknown; | 149 return FWL_WidgetHit::HyperLink; |
| 150 } | |
| 151 return FWL_WGTHITTEST_HyperLink; | |
| 152 } | 150 } |
| 153 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 151 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| 154 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); | 152 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); |
| 155 if (NULL == pTextLayout) { | 153 if (NULL == pTextLayout) { |
| 156 return NULL; | 154 return NULL; |
| 157 } | 155 } |
| 158 FX_FLOAT x(fx), y(fy); | 156 FX_FLOAT x(fx), y(fy); |
| 159 FWLToClient(x, y); | 157 FWLToClient(x, y); |
| 160 const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines(); | 158 const CXFA_PieceLineArray* pPieceLines = pTextLayout->GetPieceLines(); |
| 161 int32_t iCount = pPieceLines->GetSize(); | 159 int32_t iCount = pPieceLines->GetSize(); |
| 162 for (int32_t i = 0; i < iCount; i++) { | 160 for (int32_t i = 0; i < iCount; i++) { |
| 163 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); | 161 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i); |
| 164 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 162 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
| 165 for (int32_t j = 0; j < iPieces; j++) { | 163 for (int32_t j = 0; j < iPieces; j++) { |
| 166 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); | 164 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); |
| 167 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { | 165 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) { |
| 168 return pPiece->pLinkData->GetLinkURL(); | 166 return pPiece->pLinkData->GetLinkURL(); |
| 169 } | 167 } |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 return NULL; | 170 return NULL; |
| 173 } | 171 } |
| 174 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { | 172 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { |
| 175 CFX_RectF rtWidget; | 173 CFX_RectF rtWidget; |
| 176 GetRectWithoutRotate(rtWidget); | 174 GetRectWithoutRotate(rtWidget); |
| 177 fx -= rtWidget.left; | 175 fx -= rtWidget.left; |
| 178 fy -= rtWidget.top; | 176 fy -= rtWidget.top; |
| 179 } | 177 } |
| OLD | NEW |