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

Side by Side Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 1278053004: Add new public APIs to find the z-order for links and widgets. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 4 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 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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../../public/fpdf_doc.h" 8 #include "../../public/fpdf_doc.h"
9 9
10 static int THISMODULE = 0; 10 static int THISMODULE = 0;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 static void ReleaseLinkList(void* data) { 164 static void ReleaseLinkList(void* data) {
165 delete (CPDF_LinkList*)data; 165 delete (CPDF_LinkList*)data;
166 } 166 }
167 167
168 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, 168 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
169 double x, 169 double x,
170 double y) { 170 double y) {
171 if (!page) 171 if (!page)
172 return NULL; 172 return nullptr;
173
173 CPDF_Page* pPage = (CPDF_Page*)page; 174 CPDF_Page* pPage = (CPDF_Page*)page;
174 // Link list is stored with the document 175 // Link list is stored with the document
175 CPDF_Document* pDoc = pPage->m_pDocument; 176 CPDF_Document* pDoc = pPage->m_pDocument;
176 CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE); 177 CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
177 if (!pLinkList) { 178 if (!pLinkList) {
178 pLinkList = new CPDF_LinkList(pDoc); 179 pLinkList = new CPDF_LinkList;
179 pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList); 180 pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
180 } 181 }
181 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict(); 182 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr)
183 .GetDict();
184 }
185
186 DLLEXPORT int STDCALL FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page,
187 double x,
188 double y) {
189 if (!page)
190 return -1;
191
192 CPDF_Page* pPage = (CPDF_Page*)page;
193 // Link list is stored with the document
194 CPDF_Document* pDoc = pPage->m_pDocument;
195 CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
Tom Sepez 2015/08/07 18:14:06 nit: Is this the only place we do "get or create"?
Lei Zhang 2015/08/07 23:03:41 I consolidated.
196 if (!pLinkList) {
197 pLinkList = new CPDF_LinkList;
198 pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
199 }
200 int z_order = -1;
201 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order);
Tom Sepez 2015/08/07 18:14:06 nit: maybe (void) to indicate result not used?
Lei Zhang 2015/08/07 23:03:41 Done.
202 return z_order;
182 } 203 }
183 204
184 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, 205 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
185 FPDF_LINK pDict) { 206 FPDF_LINK pDict) {
186 if (!document) 207 if (!document)
187 return NULL; 208 return NULL;
188 if (!pDict) 209 if (!pDict)
189 return NULL; 210 return NULL;
190 CPDF_Document* pDoc = (CPDF_Document*)document; 211 CPDF_Document* pDoc = (CPDF_Document*)document;
191 CPDF_Link link((CPDF_Dictionary*)pDict); 212 CPDF_Link link((CPDF_Dictionary*)pDict);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 return 0; 311 return 0;
291 CFX_WideString text = pInfo->GetUnicodeText(tag); 312 CFX_WideString text = pInfo->GetUnicodeText(tag);
292 // Use UTF-16LE encoding 313 // Use UTF-16LE encoding
293 CFX_ByteString encodedText = text.UTF16LE_Encode(); 314 CFX_ByteString encodedText = text.UTF16LE_Encode();
294 unsigned long len = encodedText.GetLength(); 315 unsigned long len = encodedText.GetLength();
295 if (buffer && buflen >= len) { 316 if (buffer && buflen >= len) {
296 FXSYS_memcpy(buffer, encodedText.c_str(), len); 317 FXSYS_memcpy(buffer, encodedText.c_str(), len);
297 } 318 }
298 return len; 319 return len;
299 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698