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

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

Issue 834703002: Add APIs for getting bookmarks and named destinations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 11 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
« fpdfsdk/src/fpdfdoc.cpp ('K') | « fpdfsdk/src/fpdfdoc.cpp ('k') | no next file » | 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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fpdfview.h" 9 #include "../include/fpdfview.h"
10 #include "../include/fsdk_rendercontext.h" 10 #include "../include/fsdk_rendercontext.h"
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 CFX_ByteString duplex = viewRef.Duplex(); 781 CFX_ByteString duplex = viewRef.Duplex();
782 if (FX_BSTRC("Simplex") == duplex) 782 if (FX_BSTRC("Simplex") == duplex)
783 return Simplex; 783 return Simplex;
784 if (FX_BSTRC("DuplexFlipShortEdge") == duplex) 784 if (FX_BSTRC("DuplexFlipShortEdge") == duplex)
785 return DuplexFlipShortEdge; 785 return DuplexFlipShortEdge;
786 if (FX_BSTRC("DuplexFlipLongEdge") == duplex) 786 if (FX_BSTRC("DuplexFlipLongEdge") == duplex)
787 return DuplexFlipLongEdge; 787 return DuplexFlipLongEdge;
788 return DuplexUndefined; 788 return DuplexUndefined;
789 } 789 }
790 790
791 DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document)
792 {
793 if (!document) return 0;
794 CPDF_Document* pDoc = (CPDF_Document*)document;
Tom Sepez 2015/01/01 01:10:08 nit: blank line here if you want to use one-line i
Bo Xu 2015/01/05 22:46:52 Done.
795 CPDF_Dictionary* pRoot = pDoc->GetRoot();
796 if (!pRoot) return 0;
797
798 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests"));
799 int count = nameTree.GetCount();
800 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests"));
801 if (pDest)
802 count += pDest->GetCount();
803 return count;
804 }
805
791 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_ BYTESTRING name) 806 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_ BYTESTRING name)
792 { 807 {
793 if (document == NULL) 808 if (document == NULL)
794 return NULL; 809 return NULL;
795 if (name == NULL || name[0] == 0) 810 if (name == NULL || name[0] == 0)
796 return NULL; 811 return NULL;
797 812
798 CPDF_Document* pDoc = (CPDF_Document*)document; 813 CPDF_Document* pDoc = (CPDF_Document*)document;
799 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests")); 814 CPDF_NameTree name_tree(pDoc, FX_BSTRC("Dests"));
800 return name_tree.LookupNamedDest(pDoc, name); 815 return name_tree.LookupNamedDest(pDoc, name);
801 } 816 }
817
818 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, std::string& name)
819 {
820 if (!document || index < 0) return NULL;
821 CPDF_Document* pDoc = (CPDF_Document*)document;
Tom Sepez 2015/01/01 01:10:08 nit: blank line.
Bo Xu 2015/01/05 22:46:52 Done.
822 CPDF_Dictionary* pRoot = pDoc->GetRoot();
823 if (!pRoot) return NULL;
824
825 CPDF_Object* pDestObj = NULL;
826 CFX_ByteString bsName;
827
Tom Sepez 2015/01/01 01:10:08 nit: no blank line
Bo Xu 2015/01/05 22:46:52 Done.
828 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests"));
829 int count = nameTree.GetCount();
830 if (index >= count) {
831 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests"));
832 if (!pDest) return NULL;
833 if (index >= count + pDest->GetCount())
834 return NULL;
835 index -= count;
836 FX_POSITION pos = pDest->GetStartPos();
837 int i = 0;
838 while (pos) {
839 pDestObj = pDest->GetNextElement(pos, bsName);
840 if (!pDestObj) continue;
841 if (i == index) break;
842 i++;
843 }
844 } else {
845 pDestObj = nameTree.LookupValue(index, bsName);
846 }
847 if (!pDestObj) return NULL;
848 if (pDestObj->GetType() == PDFOBJ_DICTIONARY)
849 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D"));
850 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL;
851 CFX_WideString wsName = PDF_DecodeText(bsName);
852 CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
853 name = utf16Name.c_str();
854 return (FPDF_DEST)pDestObj;
855 }
OLDNEW
« fpdfsdk/src/fpdfdoc.cpp ('K') | « fpdfsdk/src/fpdfdoc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698