Add APIs for getting bookmarks and named destinations.
[pdfium.git] / fpdfsdk / src / fpdfeditpage.cpp
index 4c9fd35..831a85a 100644 (file)
@@ -4,7 +4,6 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-// #include "x:/pdf/fpdfapi5/include/fpdfapi.h"
 #include "../include/fsdk_define.h"
 #include "../include/fpdfedit.h"
 
@@ -44,11 +43,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()
        {
                if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
                        pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));
-#ifdef FOXIT_CHROME_BUILD
-               pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Google"));
-#else
-               pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Foxit PDF SDK DLL 2.0 - Foxit Software"));
-#endif
+               pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"PDFium"));
        }
 
        return pDoc;
@@ -102,7 +97,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
 {
        CPDF_Page* pPage = (CPDF_Page*)page;
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
                || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
        {
                return -1;
@@ -112,8 +107,8 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
        int rotate = 0;
        if(pDict != NULL)
        {
-               if(pDict->KeyExist("Rotate"))
-                       rotate = pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90;
+               if (pDict->KeyExist("Rotate"))
+                       rotate = pDict->GetElement("Rotate")->GetDirect()? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0;
                else
                {
                        if(pDict->KeyExist("Parent"))
@@ -123,7 +118,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
                                {
                                        if(pPages->KeyExist("Rotate"))
                                        {
-                                               rotate = pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90;
+                                               rotate = pPages->GetElement("Rotate")->GetDirect()? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0;
                                                break;
                                        }
                                        else if(pPages->KeyExist("Parent"))
@@ -144,7 +139,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)
 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)
 {
        CPDF_Page* pPage = (CPDF_Page*)page;
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
                || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
        {
                return;
@@ -199,7 +194,7 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag
 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page)
 {
        CPDF_Page* pPage = (CPDF_Page*)page;
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
                || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
        {
                return -1;
@@ -263,7 +258,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObje
 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page)
 {
        CPDF_Page* pPage = (CPDF_Page*)page;
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
                || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
        {
                return FALSE;
@@ -318,7 +313,7 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate)
 {
        CPDF_Page* pPage = (CPDF_Page*)page;
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")
+       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || !pPage->m_pFormDict->GetElement("Type")->GetDirect()
                || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))
        {
                return;
@@ -327,4 +322,4 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate)
        rotate %=4;
 
        pDict->SetAt("Rotate", FX_NEW CPDF_Number(rotate * 90));
-}
\ No newline at end of file
+}