| 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 "x:/pdf/fpdfapi5/include/fpdfapi.h" | 7 // #include "x:/pdf/fpdfapi5/include/fpdfapi.h" |
| 8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/fpdfedit.h" | 9 #include "../include/fpdfedit.h" |
| 10 | 10 |
| 11 | |
| 12 #if _FX_OS_ == _FX_ANDROID_ | 11 #if _FX_OS_ == _FX_ANDROID_ |
| 13 #include "time.h" | 12 #include "time.h" |
| 14 #else | 13 #else |
| 15 #include <ctime> | 14 #include <ctime> |
| 16 #endif | 15 #endif |
| 17 | 16 |
| 18 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() | 17 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { |
| 19 { | 18 CPDF_Document* pDoc = FX_NEW CPDF_Document; |
| 20 » CPDF_Document* pDoc = FX_NEW CPDF_Document; | 19 if (!pDoc) |
| 21 » if (!pDoc) | 20 return NULL; |
| 22 » » return NULL; | 21 pDoc->CreateNewDoc(); |
| 23 » pDoc->CreateNewDoc(); | 22 time_t currentTime; |
| 24 » time_t currentTime; | 23 |
| 25 | 24 CFX_ByteString DateStr; |
| 26 » CFX_ByteString DateStr; | 25 |
| 27 | 26 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) { |
| 28 » if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) | 27 if (-1 != time(¤tTime)) { |
| 29 » { | 28 tm* pTM = localtime(¤tTime); |
| 30 » » if ( -1 != time( ¤tTime ) ) | 29 if (pTM) { |
| 31 » » { | 30 DateStr.Format("D:%04d%02d%02d%02d%02d%02d", |
| 32 » » » tm * pTM = localtime( ¤tTime ); | 31 pTM->tm_year + 1900, |
| 33 » » » if ( pTM ) | 32 pTM->tm_mon + 1, |
| 34 » » » { | 33 pTM->tm_mday, |
| 35 » » » » DateStr.Format(»"D:%04d%02d%02d%02d%02d%02d", pT
M->tm_year+1900, pTM->tm_mon+1, | 34 pTM->tm_hour, |
| 36 » » » » » pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
pTM->tm_sec ); | 35 pTM->tm_min, |
| 37 » » » } | 36 pTM->tm_sec); |
| 38 » » } | 37 } |
| 39 » } | 38 } |
| 40 » | 39 } |
| 41 » CPDF_Dictionary* pInfoDict = NULL; | 40 |
| 42 » pInfoDict = pDoc->GetInfo(); | 41 CPDF_Dictionary* pInfoDict = NULL; |
| 43 » if (pInfoDict) | 42 pInfoDict = pDoc->GetInfo(); |
| 44 » { | 43 if (pInfoDict) { |
| 45 » » if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) | 44 if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) |
| 46 » » » pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr
)); | 45 pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); |
| 47 #ifdef FOXIT_CHROME_BUILD | 46 #ifdef FOXIT_CHROME_BUILD |
| 48 » » pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Google")); | 47 pInfoDict->SetAt("Creator", FX_NEW CPDF_String(L"Google")); |
| 49 #else | 48 #else |
| 50 » » pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Foxit PDF SDK DL
L 2.0 - Foxit Software")); | 49 pInfoDict->SetAt( |
| 50 "Creator", |
| 51 FX_NEW CPDF_String(L"Foxit PDF SDK DLL 2.0 - Foxit Software")); |
| 51 #endif | 52 #endif |
| 52 } | 53 } |
| 53 | 54 |
| 54 return pDoc; | 55 return pDoc; |
| 55 } | 56 } |
| 56 | 57 |
| 57 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) | 58 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { |
| 58 { | 59 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 59 CPDF_Document* pDoc = (CPDF_Document*)document; | 60 if (pDoc == NULL) |
| 60 if (pDoc == NULL) | 61 return; |
| 61 return; | 62 if (page_index < 0 || page_index >= pDoc->GetPageCount()) |
| 62 if (page_index < 0 || page_index >= pDoc->GetPageCount()) | 63 return; |
| 63 return; | 64 |
| 64 | 65 pDoc->DeletePage(page_index); |
| 65 pDoc->DeletePage(page_index); | 66 } |
| 66 } | 67 |
| 67 | 68 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, |
| 68 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index,
double width, double height) | 69 int page_index, |
| 69 { | 70 double width, |
| 70 if (!document) | 71 double height) { |
| 71 return NULL; | 72 if (!document) |
| 72 | 73 return NULL; |
| 73 // CPDF_Parser* pParser = (CPDF_Parser*)document; | 74 |
| 74 CPDF_Document* pDoc = (CPDF_Document*)document; | 75 // CPDF_Parser* pParser = (CPDF_Parser*)document; |
| 75 if(page_index < 0) | 76 CPDF_Document* pDoc = (CPDF_Document*)document; |
| 76 page_index = 0; | 77 if (page_index < 0) |
| 77 if(pDoc->GetPageCount()<page_index) | 78 page_index = 0; |
| 78 page_index = pDoc->GetPageCount(); | 79 if (pDoc->GetPageCount() < page_index) |
| 79 // if (page_index < 0 || page_index >= pDoc->GetPageCount()) | 80 page_index = pDoc->GetPageCount(); |
| 80 // return NULL; | 81 // if (page_index < 0 || page_index >= pDoc->GetPageCount()) |
| 81 | 82 // return NULL; |
| 82 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); | 83 |
| 83 if(!pPageDict) | 84 CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index); |
| 84 return NULL; | 85 if (!pPageDict) |
| 85 CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array; | 86 return NULL; |
| 86 pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); | 87 CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array; |
| 87 pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); | 88 pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); |
| 88 pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width))); | 89 pMediaBoxArray->Add(FX_NEW CPDF_Number(0)); |
| 89 pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height))); | 90 pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width))); |
| 90 | 91 pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height))); |
| 91 pPageDict->SetAt("MediaBox", pMediaBoxArray); | 92 |
| 92 pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0)); | 93 pPageDict->SetAt("MediaBox", pMediaBoxArray); |
| 93 pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary); | 94 pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0)); |
| 94 | 95 pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary); |
| 95 CPDF_Page* pPage = FX_NEW CPDF_Page; | 96 |
| 96 pPage->Load(pDoc,pPageDict); | 97 CPDF_Page* pPage = FX_NEW CPDF_Page; |
| 97 pPage->ParseContent(); | 98 pPage->Load(pDoc, pPageDict); |
| 98 | 99 pPage->ParseContent(); |
| 99 return pPage; | 100 |
| 100 } | 101 return pPage; |
| 101 | 102 } |
| 102 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) | 103 |
| 103 { | 104 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { |
| 104 CPDF_Page* pPage = (CPDF_Page*)page; | 105 CPDF_Page* pPage = (CPDF_Page*)page; |
| 105 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() | 106 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 106 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 107 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 107 { | 108 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 108 return -1; | 109 "Page")) { |
| 109 } | 110 return -1; |
| 110 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 111 } |
| 111 | 112 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 112 int rotate = 0; | 113 |
| 113 if(pDict != NULL) | 114 int rotate = 0; |
| 114 { | 115 if (pDict != NULL) { |
| 115 if (pDict->KeyExist("Rotate")) | 116 if (pDict->KeyExist("Rotate")) |
| 116 rotate = pDict->GetElement("Rotate")->GetDirect()? pDict
->GetElement("Rotate")->GetDirect()->GetInteger() / 90 : 0; | 117 rotate = pDict->GetElement("Rotate")->GetDirect() |
| 117 else | 118 ? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90 |
| 118 { | 119 : 0; |
| 119 if(pDict->KeyExist("Parent")) | 120 else { |
| 120 { | 121 if (pDict->KeyExist("Parent")) { |
| 121 CPDF_Dictionary* pPages = (CPDF_Dictionary*)pDic
t->GetElement("Parent")->GetDirect(); | 122 CPDF_Dictionary* pPages = |
| 122 while(pPages) | 123 (CPDF_Dictionary*)pDict->GetElement("Parent")->GetDirect(); |
| 123 { | 124 while (pPages) { |
| 124 if(pPages->KeyExist("Rotate")) | 125 if (pPages->KeyExist("Rotate")) { |
| 125 { | 126 rotate = |
| 126 rotate = pPages->GetElement("Rot
ate")->GetDirect()? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90
: 0; | 127 pPages->GetElement("Rotate")->GetDirect() |
| 127 break; | 128 ? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / |
| 128 } | 129 90 |
| 129 else if(pPages->KeyExist("Parent")) | 130 : 0; |
| 130 pPages = (CPDF_Dictionary*)pPage
s->GetElement("Parent")->GetDirect(); | 131 break; |
| 131 else break; | 132 } else if (pPages->KeyExist("Parent")) |
| 132 } | 133 pPages = |
| 133 } | 134 (CPDF_Dictionary*)pPages->GetElement("Parent")->GetDirect(); |
| 134 } | 135 else |
| 135 } | 136 break; |
| 136 else | 137 } |
| 137 { | 138 } |
| 138 return -1; | 139 } |
| 139 } | 140 } else { |
| 140 | 141 return -1; |
| 141 return rotate; | 142 } |
| 142 } | 143 |
| 143 | 144 return rotate; |
| 144 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT pag
e_obj) | 145 } |
| 145 { | 146 |
| 146 CPDF_Page* pPage = (CPDF_Page*)page; | 147 DLLEXPORT void STDCALL |
| 147 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() | 148 FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj) { |
| 148 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 149 CPDF_Page* pPage = (CPDF_Page*)page; |
| 149 { | 150 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 150 return; | 151 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 151 } | 152 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 152 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; | 153 "Page")) { |
| 153 if(pPageObj == NULL) | 154 return; |
| 154 return; | 155 } |
| 155 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); | 156 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; |
| 156 | 157 if (pPageObj == NULL) |
| 157 pPage->InsertObject(LastPersition, pPageObj); | 158 return; |
| 158 switch(pPageObj->m_Type) | 159 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); |
| 159 { | 160 |
| 160 case FPDF_PAGEOBJ_PATH: | 161 pPage->InsertObject(LastPersition, pPageObj); |
| 161 { | 162 switch (pPageObj->m_Type) { |
| 162 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; | 163 case FPDF_PAGEOBJ_PATH: { |
| 163 pPathObj->CalcBoundingBox(); | 164 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; |
| 164 break; | 165 pPathObj->CalcBoundingBox(); |
| 165 } | 166 break; |
| 166 case FPDF_PAGEOBJ_TEXT: | 167 } |
| 167 { | 168 case FPDF_PAGEOBJ_TEXT: { |
| 168 // CPDF_PathObject* pPathObj = (CPDF_PathObject*)pP
ageObj; | 169 // CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; |
| 169 // pPathObj->CalcBoundingBox(); | 170 // pPathObj->CalcBoundingBox(); |
| 170 break; | 171 break; |
| 171 } | 172 } |
| 172 case FPDF_PAGEOBJ_IMAGE: | 173 case FPDF_PAGEOBJ_IMAGE: { |
| 173 { | 174 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj; |
| 174 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageOb
j; | 175 pImageObj->CalcBoundingBox(); |
| 175 pImageObj->CalcBoundingBox(); | 176 break; |
| 176 break; | 177 } |
| 177 } | 178 case FPDF_PAGEOBJ_SHADING: { |
| 178 case FPDF_PAGEOBJ_SHADING: | 179 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj; |
| 179 { | 180 pShadingObj->CalcBoundingBox(); |
| 180 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)p
PageObj; | 181 break; |
| 181 pShadingObj->CalcBoundingBox(); | 182 } |
| 182 break; | 183 case FPDF_PAGEOBJ_FORM: { |
| 183 } | 184 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; |
| 184 case FPDF_PAGEOBJ_FORM: | 185 pFormObj->CalcBoundingBox(); |
| 185 { | 186 break; |
| 186 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; | 187 } |
| 187 pFormObj->CalcBoundingBox(); | 188 default: |
| 188 break; | 189 break; |
| 189 } | 190 } |
| 190 default: | 191 |
| 191 break; | 192 // pPage->ParseContent(); |
| 192 } | 193 // pPage->GenerateContent(); |
| 193 | 194 } |
| 194 // pPage->ParseContent(); | 195 |
| 195 //pPage->GenerateContent(); | 196 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) { |
| 196 | 197 CPDF_Page* pPage = (CPDF_Page*)page; |
| 197 } | 198 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 198 | 199 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 199 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) | 200 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 200 { | 201 "Page")) { |
| 201 CPDF_Page* pPage = (CPDF_Page*)page; | 202 return -1; |
| 202 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() | 203 } |
| 203 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 204 return pPage->CountObjects(); |
| 204 { | 205 // return 0; |
| 205 return -1; | 206 } |
| 206 } | 207 |
| 207 return pPage->CountObjects(); | 208 DLLEXPORT FPDF_PAGEOBJECT STDCALL |
| 208 // return 0; | 209 FPDFPage_GetObject(FPDF_PAGE page, int index) { |
| 209 } | 210 CPDF_Page* pPage = (CPDF_Page*)page; |
| 210 | 211 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 211 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index) | 212 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 212 { | 213 "Page")) { |
| 213 CPDF_Page* pPage = (CPDF_Page*)page; | 214 return NULL; |
| 214 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") | 215 } |
| 215 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 216 return pPage->GetObjectByIndex(index); |
| 216 { | 217 // return NULL; |
| 217 return NULL; | 218 } |
| 218 } | 219 |
| 219 return pPage->GetObjectByIndex(index); | 220 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) { |
| 220 // return NULL; | 221 if (!page) |
| 221 } | 222 return FALSE; |
| 222 | 223 CPDF_Page* pPage = (CPDF_Page*)page; |
| 223 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) | 224 |
| 224 { | 225 return pPage->BackgroundAlphaNeeded(); |
| 225 if(!page) return FALSE; | 226 } |
| 226 CPDF_Page* pPage = (CPDF_Page*)page; | 227 |
| 227 | 228 DLLEXPORT FPDF_BOOL STDCALL |
| 228 return pPage->BackgroundAlphaNeeded(); | 229 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { |
| 229 } | 230 if (!pageObject) |
| 230 | 231 return FALSE; |
| 231 DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObje
ct) | 232 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject; |
| 232 { | 233 |
| 233 if(!pageObject) return FALSE; | 234 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; |
| 234 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject; | 235 int blend_type = |
| 235 | 236 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL; |
| 236 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; | 237 if (blend_type != FXDIB_BLEND_NORMAL) |
| 237 int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEN
D_NORMAL; | 238 return TRUE; |
| 238 if (blend_type != FXDIB_BLEND_NORMAL) return TRUE; | 239 |
| 239 | 240 CPDF_Dictionary* pSMaskDict = |
| 240 CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneral
State->m_pSoftMask : NULL; | 241 pGeneralState ? (CPDF_Dictionary*)pGeneralState->m_pSoftMask : NULL; |
| 241 if(pSMaskDict) return TRUE; | 242 if (pSMaskDict) |
| 242 | 243 return TRUE; |
| 243 if(pGeneralState && pGeneralState->m_FillAlpha != 1.0f) | 244 |
| 244 return TRUE; | 245 if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f) |
| 245 | 246 return TRUE; |
| 246 if(pPageObj->m_Type == PDFPAGE_PATH) | 247 |
| 247 { | 248 if (pPageObj->m_Type == PDFPAGE_PATH) { |
| 248 if(pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f) | 249 if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f) |
| 249 return TRUE; | 250 return TRUE; |
| 250 } | 251 } |
| 251 | 252 |
| 252 if(pPageObj->m_Type == PDFPAGE_FORM) | 253 if (pPageObj->m_Type == PDFPAGE_FORM) { |
| 253 { | 254 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; |
| 254 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; | 255 if (pFormObj->m_pForm && |
| 255 if(pFormObj->m_pForm && (pFormObj->m_pForm->m_Transparency & PDF
TRANS_ISOLATED)) | 256 (pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED)) |
| 256 return TRUE; | 257 return TRUE; |
| 257 if(pFormObj->m_pForm && (!(pFormObj->m_pForm->m_Transparency & P
DFTRANS_ISOLATED) && (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP))) | 258 if (pFormObj->m_pForm && |
| 258 return TRUE; | 259 (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) && |
| 259 } | 260 (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP))) |
| 260 return FALSE; | 261 return TRUE; |
| 261 } | 262 } |
| 262 | 263 return FALSE; |
| 263 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) | 264 } |
| 264 { | 265 |
| 265 CPDF_Page* pPage = (CPDF_Page*)page; | 266 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) { |
| 266 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() | 267 CPDF_Page* pPage = (CPDF_Page*)page; |
| 267 || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 268 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 268 { | 269 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 269 return FALSE; | 270 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 270 } | 271 "Page")) { |
| 271 CPDF_PageContentGenerate CG(pPage); | 272 return FALSE; |
| 272 CG.GenerateContent(); | 273 } |
| 273 | 274 CPDF_PageContentGenerate CG(pPage); |
| 274 return TRUE; | 275 CG.GenerateContent(); |
| 276 |
| 277 return TRUE; |
| 275 } | 278 } |
| 276 | 279 |
| 277 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, | 280 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, |
| 278 » » » double a, double b, double c, double d, double e, doubl
e f) | 281 double a, |
| 279 { | 282 double b, |
| 280 » CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; | 283 double c, |
| 281 » if(pPageObj == NULL) | 284 double d, |
| 282 » » return; | 285 double e, |
| 283 //PDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject; | 286 double f) { |
| 284 » CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d,
(FX_FLOAT)e,(FX_FLOAT)f); | 287 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; |
| 285 » pPageObj->Transform(matrix); | 288 if (pPageObj == NULL) |
| 289 return; |
| 290 // PDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject; |
| 291 CFX_AffineMatrix matrix((FX_FLOAT)a, |
| 292 (FX_FLOAT)b, |
| 293 (FX_FLOAT)c, |
| 294 (FX_FLOAT)d, |
| 295 (FX_FLOAT)e, |
| 296 (FX_FLOAT)f); |
| 297 pPageObj->Transform(matrix); |
| 286 } | 298 } |
| 287 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, | 299 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, |
| 288 » » » » » » » » » »
» double a, double b, double c, double d, double e, double f) | 300 double a, |
| 289 { | 301 double b, |
| 290 » if(page == NULL) | 302 double c, |
| 291 » » return; | 303 double d, |
| 292 » CPDF_Page* pPage = (CPDF_Page*)page; | 304 double e, |
| 293 » CPDF_AnnotList AnnotList(pPage); | 305 double f) { |
| 294 » for (int i=0; i<AnnotList.Count();i++) | 306 if (page == NULL) |
| 295 » { | 307 return; |
| 296 » » CPDF_Annot* pAnnot = AnnotList.GetAt(i); | 308 CPDF_Page* pPage = (CPDF_Page*)page; |
| 297 » » // transformAnnots Rectangle | 309 CPDF_AnnotList AnnotList(pPage); |
| 298 » » CPDF_Rect rect; | 310 for (int i = 0; i < AnnotList.Count(); i++) { |
| 299 » » pAnnot->GetRect(rect); | 311 CPDF_Annot* pAnnot = AnnotList.GetAt(i); |
| 300 » » CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_
FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f); | 312 // transformAnnots Rectangle |
| 301 » » rect.Transform(&matrix); | 313 CPDF_Rect rect; |
| 302 » » CPDF_Array *pRectArray = NULL; | 314 pAnnot->GetRect(rect); |
| 303 » » pRectArray = pAnnot->m_pAnnotDict->GetArray("Rect"); | 315 CFX_AffineMatrix matrix((FX_FLOAT)a, |
| 304 » » if (!pRectArray) pRectArray=CPDF_Array::Create(); | 316 (FX_FLOAT)b, |
| 305 » » pRectArray->SetAt(0,FX_NEW CPDF_Number(rect.left)); | 317 (FX_FLOAT)c, |
| 306 » » pRectArray->SetAt(1,FX_NEW CPDF_Number(rect.bottom)); | 318 (FX_FLOAT)d, |
| 307 » » pRectArray->SetAt(2,FX_NEW CPDF_Number(rect.right)); | 319 (FX_FLOAT)e, |
| 308 » » pRectArray->SetAt(3,FX_NEW CPDF_Number(rect.top)); | 320 (FX_FLOAT)f); |
| 309 » » pAnnot->m_pAnnotDict->SetAt("Rect",pRectArray); | 321 rect.Transform(&matrix); |
| 310 | 322 CPDF_Array* pRectArray = NULL; |
| 311 » » //Transform AP's rectangle | 323 pRectArray = pAnnot->m_pAnnotDict->GetArray("Rect"); |
| 312 » » //To Do | 324 if (!pRectArray) |
| 313 | 325 pRectArray = CPDF_Array::Create(); |
| 314 » } | 326 pRectArray->SetAt(0, FX_NEW CPDF_Number(rect.left)); |
| 315 | 327 pRectArray->SetAt(1, FX_NEW CPDF_Number(rect.bottom)); |
| 316 } | 328 pRectArray->SetAt(2, FX_NEW CPDF_Number(rect.right)); |
| 317 | 329 pRectArray->SetAt(3, FX_NEW CPDF_Number(rect.top)); |
| 318 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) | 330 pAnnot->m_pAnnotDict->SetAt("Rect", pRectArray); |
| 319 { | 331 |
| 320 » CPDF_Page* pPage = (CPDF_Page*)page; | 332 // Transform AP's rectangle |
| 321 » if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type
") || !pPage->m_pFormDict->GetElement("Type")->GetDirect() | 333 // To Do |
| 322 » » || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetStrin
g().Compare("Page")) | 334 } |
| 323 » { | 335 } |
| 324 » » return; | 336 |
| 325 » } | 337 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { |
| 326 » CPDF_Dictionary* pDict = pPage->m_pFormDict; | 338 CPDF_Page* pPage = (CPDF_Page*)page; |
| 327 » rotate %=4; | 339 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
| 328 | 340 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
| 329 » pDict->SetAt("Rotate", FX_NEW CPDF_Number(rotate * 90)); | 341 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
| 330 } | 342 "Page")) { |
| 343 return; |
| 344 } |
| 345 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 346 rotate %= 4; |
| 347 |
| 348 pDict->SetAt("Rotate", FX_NEW CPDF_Number(rotate * 90)); |
| 349 } |
| OLD | NEW |