| 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 "../../public/fpdf_doc.h" | 7 #include "../../public/fpdf_doc.h" |
| 8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_page.h" | 10 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 11 | 11 |
| 12 static int THISMODULE = 0; | 12 static int THISMODULE = 0; |
| 13 | 13 |
| 14 static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark b
ookmark, const CFX_WideString& title) | 14 static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark b
ookmark, const CFX_WideString& title) |
| 15 { | 15 { |
| 16 » if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { | 16 if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) { |
| 17 » » // First check this item | 17 // First check this item |
| 18 » » return bookmark; | 18 return bookmark; |
| 19 » } | 19 } |
| 20 » // go into children items | 20 // go into children items |
| 21 » CPDF_Bookmark child = tree.GetFirstChild(bookmark); | 21 CPDF_Bookmark child = tree.GetFirstChild(bookmark); |
| 22 » while (child) { | 22 while (child) { |
| 23 » » // check if this item | 23 // check if this item |
| 24 » » CPDF_Bookmark found = FindBookmark(tree, child, title); | 24 CPDF_Bookmark found = FindBookmark(tree, child, title); |
| 25 » » if (found) | 25 if (found) |
| 26 » » » return found; | 26 return found; |
| 27 » » child = tree.GetNextSibling(child); | 27 child = tree.GetNextSibling(child); |
| 28 » } | 28 } |
| 29 » return CPDF_Bookmark(); | 29 return CPDF_Bookmark(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT documen
t, FPDF_BOOKMARK pDict) | 32 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetFirstChild(FPDF_DOCUMENT documen
t, FPDF_BOOKMARK pDict) |
| 33 { | 33 { |
| 34 if (!document || !pDict) | 34 if (!document || !pDict) |
| 35 return NULL; | 35 return NULL; |
| 36 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 36 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 37 CPDF_BookmarkTree tree(pDoc); | 37 CPDF_BookmarkTree tree(pDoc); |
| 38 CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); | 38 CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); |
| 39 return tree.GetFirstChild(bookmark).GetDict(); | 39 return tree.GetFirstChild(bookmark).GetDict(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetNextSibling(FPDF_DOCUMENT docume
nt, FPDF_BOOKMARK pDict) | 42 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_GetNextSibling(FPDF_DOCUMENT docume
nt, FPDF_BOOKMARK pDict) |
| 43 { | 43 { |
| 44 if (!document || !pDict) | 44 if (!document || !pDict) |
| 45 return NULL; | 45 return NULL; |
| 46 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 46 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 47 CPDF_BookmarkTree tree(pDoc); | 47 CPDF_BookmarkTree tree(pDoc); |
| 48 CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); | 48 CPDF_Bookmark bookmark = CPDF_Bookmark((CPDF_Dictionary*)pDict); |
| 49 return tree.GetNextSibling(bookmark).GetDict(); | 49 return tree.GetNextSibling(bookmark).GetDict(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void*
buffer, unsigned long buflen) | 52 DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void*
buffer, unsigned long buflen) |
| 53 { | 53 { |
| 54 if (!pDict) | 54 if (!pDict) |
| 55 return 0; | 55 return 0; |
| 56 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); | 56 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); |
| 57 CFX_WideString title = bookmark.GetTitle(); | 57 CFX_WideString title = bookmark.GetTitle(); |
| 58 CFX_ByteString encodedTitle = title.UTF16LE_Encode(); | 58 CFX_ByteString encodedTitle = title.UTF16LE_Encode(); |
| 59 unsigned long len = encodedTitle.GetLength(); | 59 unsigned long len = encodedTitle.GetLength(); |
| 60 if (buffer && buflen >= len) { | 60 if (buffer && buflen >= len) { |
| 61 FXSYS_memcpy(buffer, encodedTitle.c_str(), len); | 61 FXSYS_memcpy(buffer, encodedTitle.c_str(), len); |
| 62 } | 62 } |
| 63 return len; | 63 return len; |
| 64 } | 64 } |
| 65 | 65 |
| 66 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_W
IDESTRING title) | 66 DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_W
IDESTRING title) |
| 67 { | 67 { |
| 68 » if (!document) | 68 if (!document) |
| 69 » » return NULL; | 69 return NULL; |
| 70 » if (!title || title[0] == 0) | 70 if (!title || title[0] == 0) |
| 71 » » return NULL; | 71 return NULL; |
| 72 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 72 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 73 » CPDF_BookmarkTree tree(pDoc); | 73 CPDF_BookmarkTree tree(pDoc); |
| 74 » FX_STRSIZE len = CFX_WideString::WStringLength(title); | 74 FX_STRSIZE len = CFX_WideString::WStringLength(title); |
| 75 » CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len); | 75 CFX_WideString encodedTitle = CFX_WideString::FromUTF16LE(title, len); |
| 76 » return FindBookmark(tree, CPDF_Bookmark(), encodedTitle).GetDict(); | 76 return FindBookmark(tree, CPDF_Bookmark(), encodedTitle).GetDict(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BO
OKMARK pDict) | 79 DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BO
OKMARK pDict) |
| 80 { | 80 { |
| 81 » if (!document) | 81 if (!document) |
| 82 » » return NULL; | 82 return NULL; |
| 83 » if (!pDict) | 83 if (!pDict) |
| 84 » » return NULL; | 84 return NULL; |
| 85 » CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); | 85 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); |
| 86 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 86 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 87 » CPDF_Dest dest = bookmark.GetDest(pDoc); | 87 CPDF_Dest dest = bookmark.GetDest(pDoc); |
| 88 » if (dest) | 88 if (dest) |
| 89 » » return dest.GetObject(); | 89 return dest.GetObject(); |
| 90 » // If this bookmark is not directly associated with a dest, we try to ge
t action | 90 // If this bookmark is not directly associated with a dest, we try to get ac
tion |
| 91 » CPDF_Action action = bookmark.GetAction(); | 91 CPDF_Action action = bookmark.GetAction(); |
| 92 » if (!action) | 92 if (!action) |
| 93 » » return NULL; | 93 return NULL; |
| 94 » return action.GetDest(pDoc).GetObject(); | 94 return action.GetDest(pDoc).GetObject(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) | 97 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) |
| 98 { | 98 { |
| 99 » if (!pDict) | 99 if (!pDict) |
| 100 » » return NULL; | 100 return NULL; |
| 101 » CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); | 101 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); |
| 102 » return bookmark.GetAction().GetDict(); | 102 return bookmark.GetAction().GetDict(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) | 105 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) |
| 106 { | 106 { |
| 107 » if (!pDict) | 107 if (!pDict) |
| 108 » » return 0; | 108 return 0; |
| 109 » CPDF_Action action((CPDF_Dictionary*)pDict); | 109 CPDF_Action action((CPDF_Dictionary*)pDict); |
| 110 » CPDF_Action::ActionType type = action.GetType(); | 110 CPDF_Action::ActionType type = action.GetType(); |
| 111 » switch (type) { | 111 switch (type) { |
| 112 » » case CPDF_Action::GoTo: | 112 case CPDF_Action::GoTo: |
| 113 » » » return PDFACTION_GOTO; | 113 return PDFACTION_GOTO; |
| 114 » » case CPDF_Action::GoToR: | 114 case CPDF_Action::GoToR: |
| 115 » » » return PDFACTION_REMOTEGOTO; | 115 return PDFACTION_REMOTEGOTO; |
| 116 » » case CPDF_Action::URI: | 116 case CPDF_Action::URI: |
| 117 » » » return PDFACTION_URI; | 117 return PDFACTION_URI; |
| 118 » » case CPDF_Action::Launch: | 118 case CPDF_Action::Launch: |
| 119 » » » return PDFACTION_LAUNCH; | 119 return PDFACTION_LAUNCH; |
| 120 » » default: | 120 default: |
| 121 » » » return PDFACTION_UNSUPPORTED; | 121 return PDFACTION_UNSUPPORTED; |
| 122 » } | 122 } |
| 123 » return PDFACTION_UNSUPPORTED; | 123 return PDFACTION_UNSUPPORTED; |
| 124 } | 124 } |
| 125 | 125 |
| 126 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI
ON pDict) | 126 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI
ON pDict) |
| 127 { | 127 { |
| 128 » if (!document) | 128 if (!document) |
| 129 » » return NULL; | 129 return NULL; |
| 130 » if (!pDict) | 130 if (!pDict) |
| 131 » » return NULL; | 131 return NULL; |
| 132 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 132 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 133 » CPDF_Action action((CPDF_Dictionary*)pDict); | 133 CPDF_Action action((CPDF_Dictionary*)pDict); |
| 134 » return action.GetDest(pDoc).GetObject(); | 134 return action.GetDest(pDoc).GetObject(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP
DF_ACTION pDict, | 137 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP
DF_ACTION pDict, |
| 138 » » » » » » » » » »
» void* buffer, unsigned long buflen) | 138 void* buffer, unsigned long buflen
) |
| 139 { | 139 { |
| 140 » if (!document) | 140 if (!document) |
| 141 » » return 0; | 141 return 0; |
| 142 » if (!pDict) | 142 if (!pDict) |
| 143 » » return 0; | 143 return 0; |
| 144 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 144 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 145 » CPDF_Action action((CPDF_Dictionary*)pDict); | 145 CPDF_Action action((CPDF_Dictionary*)pDict); |
| 146 » CFX_ByteString path = action.GetURI(pDoc); | 146 CFX_ByteString path = action.GetURI(pDoc); |
| 147 » unsigned long len = path.GetLength() + 1; | 147 unsigned long len = path.GetLength() + 1; |
| 148 » if (buffer != NULL && buflen >= len) | 148 if (buffer != NULL && buflen >= len) |
| 149 » » FXSYS_memcpy(buffer, path.c_str(), len); | 149 FXSYS_memcpy(buffer, path.c_str(), len); |
| 150 » return len; | 150 return len; |
| 151 } | 151 } |
| 152 | 152 |
| 153 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP
DF_DEST pDict) | 153 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP
DF_DEST pDict) |
| 154 { | 154 { |
| 155 » if (!document) | 155 if (!document) |
| 156 » » return 0; | 156 return 0; |
| 157 » if (!pDict) | 157 if (!pDict) |
| 158 » » return 0; | 158 return 0; |
| 159 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 159 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 160 » CPDF_Dest dest((CPDF_Array*)pDict); | 160 CPDF_Dest dest((CPDF_Array*)pDict); |
| 161 » return dest.GetPageIndex(pDoc); | 161 return dest.GetPageIndex(pDoc); |
| 162 } | 162 } |
| 163 | 163 |
| 164 static void ReleaseLinkList(void* data) | 164 static void ReleaseLinkList(void* data) |
| 165 { | 165 { |
| 166 » delete (CPDF_LinkList*)data; | 166 delete (CPDF_LinkList*)data; |
| 167 } | 167 } |
| 168 | 168 |
| 169 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, do
uble y) | 169 DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, do
uble y) |
| 170 { | 170 { |
| 171 » if (!page) | 171 if (!page) |
| 172 » » return NULL; | 172 return NULL; |
| 173 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | 173 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); |
| 174 » if (!pPage) | 174 if (!pPage) |
| 175 » » return NULL; | 175 return NULL; |
| 176 » // Link list is stored with the document | 176 // Link list is stored with the document |
| 177 » CPDF_Document* pDoc = pPage->m_pDocument; | 177 CPDF_Document* pDoc = pPage->m_pDocument; |
| 178 » CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMOD
ULE); | 178 CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE)
; |
| 179 » if (!pLinkList) { | 179 if (!pLinkList) { |
| 180 » » pLinkList = FX_NEW CPDF_LinkList(pDoc); | 180 pLinkList = FX_NEW CPDF_LinkList(pDoc); |
| 181 » » pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList); | 181 pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList); |
| 182 » } | 182 } |
| 183 » return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDic
t(); | 183 return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK p
Dict) | 186 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK p
Dict) |
| 187 { | 187 { |
| 188 » if (!document) | 188 if (!document) |
| 189 » » return NULL; | 189 return NULL; |
| 190 » if (!pDict) | 190 if (!pDict) |
| 191 » » return NULL; | 191 return NULL; |
| 192 » CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 192 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
| 193 » CPDF_Link link((CPDF_Dictionary*)pDict); | 193 CPDF_Link link((CPDF_Dictionary*)pDict); |
| 194 » FPDF_DEST dest = link.GetDest(pDoc).GetObject(); | 194 FPDF_DEST dest = link.GetDest(pDoc).GetObject(); |
| 195 » if (dest) | 195 if (dest) |
| 196 » » return dest; | 196 return dest; |
| 197 » // If this link is not directly associated with a dest, we try to get ac
tion | 197 // If this link is not directly associated with a dest, we try to get action |
| 198 » CPDF_Action action = link.GetAction(); | 198 CPDF_Action action = link.GetAction(); |
| 199 » if (!action) | 199 if (!action) |
| 200 » » return NULL; | 200 return NULL; |
| 201 » return action.GetDest(pDoc).GetObject(); | 201 return action.GetDest(pDoc).GetObject(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) | 204 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) |
| 205 { | 205 { |
| 206 » if (!pDict) | 206 if (!pDict) |
| 207 » » return NULL; | 207 return NULL; |
| 208 » CPDF_Link link((CPDF_Dictionary*)pDict); | 208 CPDF_Link link((CPDF_Dictionary*)pDict); |
| 209 » return link.GetAction().GetDict(); | 209 return link.GetAction().GetDict(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP
DF_LINK* linkAnnot) | 212 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP
DF_LINK* linkAnnot) |
| 213 { | 213 { |
| 214 » if(!page || !startPos || !linkAnnot) | 214 if(!page || !startPos || !linkAnnot) |
| 215 » » return FALSE; | 215 return FALSE; |
| 216 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | 216 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); |
| 217 » if(!pPage->m_pFormDict) | 217 if(!pPage->m_pFormDict) |
| 218 » » return FALSE; | 218 return FALSE; |
| 219 » CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); | 219 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); |
| 220 » if(!pAnnots) | 220 if(!pAnnots) |
| 221 » » return FALSE; | 221 return FALSE; |
| 222 » for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { | 222 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { |
| 223 » » CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementVa
lue(i); | 223 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); |
| 224 » » if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) | 224 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) |
| 225 » » » continue; | 225 continue; |
| 226 » » if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))
) { | 226 if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))) { |
| 227 » » » *startPos = i + 1; | 227 *startPos = i + 1; |
| 228 » » » *linkAnnot = (FPDF_LINK)pDict; | 228 *linkAnnot = (FPDF_LINK)pDict; |
| 229 » » » return TRUE; | 229 return TRUE; |
| 230 » » } | 230 } |
| 231 » } | 231 } |
| 232 » return FALSE; | 232 return FALSE; |
| 233 } | 233 } |
| 234 | 234 |
| 235 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF*
rect) | 235 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF*
rect) |
| 236 { | 236 { |
| 237 » if(!linkAnnot || !rect) | 237 if(!linkAnnot || !rect) |
| 238 » » return FALSE; | 238 return FALSE; |
| 239 » CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 239 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
| 240 » CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect")); | 240 CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect")); |
| 241 » rect->left = rt.left; | 241 rect->left = rt.left; |
| 242 » rect->bottom = rt.bottom; | 242 rect->bottom = rt.bottom; |
| 243 » rect->right = rt.right; | 243 rect->right = rt.right; |
| 244 » rect->top = rt.top; | 244 rect->top = rt.top; |
| 245 » return TRUE; | 245 return TRUE; |
| 246 } | 246 } |
| 247 | 247 |
| 248 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) | 248 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) |
| 249 { | 249 { |
| 250 » if(!linkAnnot) | 250 if(!linkAnnot) |
| 251 » » return 0; | 251 return 0; |
| 252 » CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 252 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
| 253 » CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); | 253 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); |
| 254 » if (!pArray) | 254 if (!pArray) |
| 255 » » return 0; | 255 return 0; |
| 256 » else | 256 return pArray->GetCount() / 8; |
| 257 » » return pArray->GetCount() / 8; | |
| 258 } | 257 } |
| 259 | 258 |
| 260 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad
Index, FS_QUADPOINTSF* quadPoints) | 259 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad
Index, FS_QUADPOINTSF* quadPoints) |
| 261 { | 260 { |
| 262 » if(!linkAnnot || !quadPoints) | 261 if(!linkAnnot || !quadPoints) |
| 263 » » return FALSE; | 262 return FALSE; |
| 264 » CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 263 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
| 265 » CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); | 264 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); |
| 266 » if (pArray) { | 265 if (pArray) { |
| 267 » » if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || (
(quadIndex*8+7) >= (int)pArray->GetCount())) | 266 if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || ((quadInd
ex*8+7) >= (int)pArray->GetCount())) |
| 268 » » » return FALSE; | 267 return FALSE; |
| 269 » » quadPoints->x1 = pArray->GetNumber(quadIndex*8); | 268 quadPoints->x1 = pArray->GetNumber(quadIndex*8); |
| 270 » » quadPoints->y1 = pArray->GetNumber(quadIndex*8+1); | 269 quadPoints->y1 = pArray->GetNumber(quadIndex*8+1); |
| 271 » » quadPoints->x2 = pArray->GetNumber(quadIndex*8+2); | 270 quadPoints->x2 = pArray->GetNumber(quadIndex*8+2); |
| 272 » » quadPoints->y2 = pArray->GetNumber(quadIndex*8+3); | 271 quadPoints->y2 = pArray->GetNumber(quadIndex*8+3); |
| 273 » » quadPoints->x3 = pArray->GetNumber(quadIndex*8+4); | 272 quadPoints->x3 = pArray->GetNumber(quadIndex*8+4); |
| 274 » » quadPoints->y3 = pArray->GetNumber(quadIndex*8+5); | 273 quadPoints->y3 = pArray->GetNumber(quadIndex*8+5); |
| 275 » » quadPoints->x4 = pArray->GetNumber(quadIndex*8+6); | 274 quadPoints->x4 = pArray->GetNumber(quadIndex*8+6); |
| 276 » » quadPoints->y4 = pArray->GetNumber(quadIndex*8+7); | 275 quadPoints->y4 = pArray->GetNumber(quadIndex*8+7); |
| 277 » » return TRUE; | 276 return TRUE; |
| 278 » } | 277 } |
| 279 » return FALSE; | 278 return FALSE; |
| 280 } | 279 } |
| 281 | 280 |
| 282 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
ING tag, | 281 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
ING tag, |
| 283 » » » » » » » » » »
» » void* buffer, unsigned long buflen) | 282 void* buffer, unsigned long buf
len) |
| 284 { | 283 { |
| 285 » if (!doc || !tag) | 284 if (!doc || !tag) |
| 286 » » return 0; | 285 return 0; |
| 287 CPDF_Document* pDoc = ((CPDFXFA_Document*)doc)->GetPDFDoc(); | 286 CPDF_Document* pDoc = ((CPDFXFA_Document*)doc)->GetPDFDoc(); |
| 288 » // Get info dictionary | 287 // Get info dictionary |
| 289 » CPDF_Dictionary* pInfo = pDoc->GetInfo(); | 288 CPDF_Dictionary* pInfo = pDoc->GetInfo(); |
| 290 » if (!pInfo) | 289 if (!pInfo) |
| 291 » » return 0; | 290 return 0; |
| 292 » CFX_WideString text = pInfo->GetUnicodeText(tag); | 291 CFX_WideString text = pInfo->GetUnicodeText(tag); |
| 293 » // Use UTF-16LE encoding | 292 // Use UTF-16LE encoding |
| 294 » CFX_ByteString encodedText = text.UTF16LE_Encode(); | 293 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
| 295 » unsigned long len = encodedText.GetLength(); | 294 unsigned long len = encodedText.GetLength(); |
| 296 » if (buffer && buflen >= len) { | 295 if (buffer && buflen >= len) { |
| 297 » » FXSYS_memcpy(buffer, encodedText.c_str(), len); | 296 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
| 298 » } | 297 } |
| 299 » return len; | 298 return len; |
| 300 } | 299 } |
| OLD | NEW |