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 "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" | 7 #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 21 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
22 #include "xfa/fxfa/parser/xfa_script.h" | 22 #include "xfa/fxfa/parser/xfa_script.h" |
23 #include "xfa/fxfa/parser/xfa_script_imp.h" | 23 #include "xfa/fxfa/parser/xfa_script_imp.h" |
24 #include "xfa/fxfa/parser/xfa_utils.h" | 24 #include "xfa/fxfa/parser/xfa_utils.h" |
25 | 25 |
26 CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) | 26 CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) |
27 : CXFA_Object(pDocument, | 27 : CXFA_Object(pDocument, |
28 XFA_ObjectType::Object, | 28 XFA_ObjectType::Object, |
29 XFA_Element::LayoutPseudoModel) {} | 29 XFA_Element::LayoutPseudoModel) {} |
30 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} | 30 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} |
31 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Ready( | 31 void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, |
32 CFXJSE_Value* pValue, | 32 FX_BOOL bSetting, |
33 FX_BOOL bSetting, | 33 XFA_ATTRIBUTE eAttribute) { |
34 XFA_ATTRIBUTE eAttribute) { | |
35 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 34 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
36 if (!pNotify) { | 35 if (!pNotify) { |
37 return; | 36 return; |
38 } | 37 } |
39 if (bSetting) { | 38 if (bSetting) { |
40 ThrowException(XFA_IDS_UNABLE_SET_READY); | 39 ThrowException(XFA_IDS_UNABLE_SET_READY); |
41 return; | 40 return; |
42 } | 41 } |
43 int32_t iStatus = pNotify->GetLayoutStatus(); | 42 int32_t iStatus = pNotify->GetLayoutStatus(); |
44 pValue->SetBoolean(iStatus >= 2); | 43 pValue->SetBoolean(iStatus >= 2); |
45 } | 44 } |
46 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY( | 45 void CScript_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments, |
47 CFXJSE_Arguments* pArguments, | 46 XFA_LAYOUTMODEL_HWXY layoutModel) { |
48 XFA_LAYOUTMODEL_HWXY layoutModel) { | |
49 int32_t iLength = pArguments->GetLength(); | 47 int32_t iLength = pArguments->GetLength(); |
50 if (iLength < 1 || iLength > 3) { | 48 if (iLength < 1 || iLength > 3) { |
51 const FX_WCHAR* methodName = nullptr; | 49 const FX_WCHAR* methodName = nullptr; |
52 switch (layoutModel) { | 50 switch (layoutModel) { |
53 case XFA_LAYOUTMODEL_H: | 51 case XFA_LAYOUTMODEL_H: |
54 methodName = L"h"; | 52 methodName = L"h"; |
55 break; | 53 break; |
56 case XFA_LAYOUTMODEL_W: | 54 case XFA_LAYOUTMODEL_W: |
57 methodName = L"w"; | 55 methodName = L"w"; |
58 break; | 56 break; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 case XFA_LAYOUTMODEL_Y: | 115 case XFA_LAYOUTMODEL_Y: |
118 measure.Set(rtRect.top, XFA_UNIT_Pt); | 116 measure.Set(rtRect.top, XFA_UNIT_Pt); |
119 break; | 117 break; |
120 } | 118 } |
121 XFA_UNIT unit = measure.GetUnit(wsUnit.AsStringC()); | 119 XFA_UNIT unit = measure.GetUnit(wsUnit.AsStringC()); |
122 FX_FLOAT fValue = measure.ToUnit(unit); | 120 FX_FLOAT fValue = measure.ToUnit(unit); |
123 fValue = FXSYS_round(fValue * 1000) / 1000.0f; | 121 fValue = FXSYS_round(fValue * 1000) / 1000.0f; |
124 if (pValue) | 122 if (pValue) |
125 pValue->SetFloat(fValue); | 123 pValue->SetFloat(fValue); |
126 } | 124 } |
127 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_H( | 125 void CScript_LayoutPseudoModel::H(CFXJSE_Arguments* pArguments) { |
128 CFXJSE_Arguments* pArguments) { | 126 HWXY(pArguments, XFA_LAYOUTMODEL_H); |
129 Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_H); | |
130 } | 127 } |
131 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_W( | 128 void CScript_LayoutPseudoModel::W(CFXJSE_Arguments* pArguments) { |
132 CFXJSE_Arguments* pArguments) { | 129 HWXY(pArguments, XFA_LAYOUTMODEL_W); |
133 Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_W); | |
134 } | 130 } |
135 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_X( | 131 void CScript_LayoutPseudoModel::X(CFXJSE_Arguments* pArguments) { |
136 CFXJSE_Arguments* pArguments) { | 132 HWXY(pArguments, XFA_LAYOUTMODEL_X); |
137 Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_X); | |
138 } | 133 } |
139 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Y( | 134 void CScript_LayoutPseudoModel::Y(CFXJSE_Arguments* pArguments) { |
140 CFXJSE_Arguments* pArguments) { | 135 HWXY(pArguments, XFA_LAYOUTMODEL_Y); |
141 Script_LayoutPseudoModel_HWXY(pArguments, XFA_LAYOUTMODEL_Y); | |
142 } | 136 } |
143 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_NumberedPageCount( | 137 void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments, |
144 CFXJSE_Arguments* pArguments, | 138 FX_BOOL bNumbered) { |
145 FX_BOOL bNumbered) { | |
146 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 139 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
147 if (!pDocLayout) { | 140 if (!pDocLayout) { |
148 return; | 141 return; |
149 } | 142 } |
150 int32_t iPageCount = 0; | 143 int32_t iPageCount = 0; |
151 int32_t iPageNum = pDocLayout->CountPages(); | 144 int32_t iPageNum = pDocLayout->CountPages(); |
152 if (bNumbered) { | 145 if (bNumbered) { |
153 for (int32_t i = 0; i < iPageNum; i++) { | 146 for (int32_t i = 0; i < iPageNum; i++) { |
154 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i); | 147 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i); |
155 if (!pLayoutPage) { | 148 if (!pLayoutPage) { |
156 continue; | 149 continue; |
157 } | 150 } |
158 CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); | 151 CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); |
159 if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { | 152 if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { |
160 iPageCount++; | 153 iPageCount++; |
161 } | 154 } |
162 } | 155 } |
163 } else { | 156 } else { |
164 iPageCount = iPageNum; | 157 iPageCount = iPageNum; |
165 } | 158 } |
166 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 159 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
167 if (pValue) | 160 if (pValue) |
168 pValue->SetInteger(iPageCount); | 161 pValue->SetInteger(iPageCount); |
169 } | 162 } |
170 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageCount( | 163 void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) { |
171 CFXJSE_Arguments* pArguments) { | 164 NumberedPageCount(pArguments, TRUE); |
172 Script_LayoutPseudoModel_NumberedPageCount(pArguments, TRUE); | |
173 } | 165 } |
174 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( | 166 void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) { |
175 CFXJSE_Arguments* pArguments) { | |
176 int32_t iLength = pArguments->GetLength(); | 167 int32_t iLength = pArguments->GetLength(); |
177 if (iLength != 1) { | 168 if (iLength != 1) { |
178 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); | 169 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); |
179 return; | 170 return; |
180 } | 171 } |
181 CXFA_Node* pNode = nullptr; | 172 CXFA_Node* pNode = nullptr; |
182 if (iLength >= 1) { | 173 if (iLength >= 1) { |
183 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 174 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
184 } | 175 } |
185 if (!pNode) { | 176 if (!pNode) { |
186 return; | 177 return; |
187 } | 178 } |
188 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 179 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
189 if (!pDocLayout) { | 180 if (!pDocLayout) { |
190 return; | 181 return; |
191 } | 182 } |
192 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 183 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
193 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 184 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
194 if (!pLayoutItem) { | 185 if (!pLayoutItem) { |
195 pValue->SetInteger(-1); | 186 pValue->SetInteger(-1); |
196 return; | 187 return; |
197 } | 188 } |
198 int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); | 189 int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); |
199 int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 190 int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
200 int32_t iPageSpan = iLast - iFirst + 1; | 191 int32_t iPageSpan = iLast - iFirst + 1; |
201 if (pValue) | 192 if (pValue) |
202 pValue->SetInteger(iPageSpan); | 193 pValue->SetInteger(iPageSpan); |
203 } | 194 } |
204 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Page( | 195 void CScript_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) { |
205 CFXJSE_Arguments* pArguments) { | 196 PageImp(pArguments, FALSE); |
206 Script_LayoutPseudoModel_PageImp(pArguments, FALSE); | |
207 } | 197 } |
208 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( | 198 void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout, |
209 CXFA_LayoutProcessor* pDocLayout, | 199 int32_t iPageNo, |
210 int32_t iPageNo, | 200 const CFX_WideString& wsType, |
211 const CFX_WideString& wsType, | 201 FX_BOOL bOnPageArea, |
212 FX_BOOL bOnPageArea, | 202 CXFA_NodeArray& retArray) { |
213 CXFA_NodeArray& retArray) { | |
214 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo); | 203 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo); |
215 if (!pLayoutPage) { | 204 if (!pLayoutPage) { |
216 return; | 205 return; |
217 } | 206 } |
218 if (wsType == FX_WSTRC(L"pageArea")) { | 207 if (wsType == FX_WSTRC(L"pageArea")) { |
219 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { | 208 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { |
220 retArray.Add(pMasterPage); | 209 retArray.Add(pMasterPage); |
221 } | 210 } |
222 return; | 211 return; |
223 } | 212 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 continue; | 319 continue; |
331 formItems.insert(pItemChild->m_pFormNode); | 320 formItems.insert(pItemChild->m_pFormNode); |
332 retArray.Add(pItemChild->m_pFormNode); | 321 retArray.Add(pItemChild->m_pFormNode); |
333 } | 322 } |
334 } | 323 } |
335 } | 324 } |
336 } | 325 } |
337 return; | 326 return; |
338 } | 327 } |
339 } | 328 } |
340 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent( | 329 void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) { |
341 CFXJSE_Arguments* pArguments) { | |
342 int32_t iLength = pArguments->GetLength(); | 330 int32_t iLength = pArguments->GetLength(); |
343 if (iLength < 1 || iLength > 3) { | 331 if (iLength < 1 || iLength > 3) { |
344 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); | 332 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); |
345 return; | 333 return; |
346 } | 334 } |
347 int32_t iIndex = 0; | 335 int32_t iIndex = 0; |
348 CFX_WideString wsType; | 336 CFX_WideString wsType; |
349 FX_BOOL bOnPageArea = FALSE; | 337 FX_BOOL bOnPageArea = FALSE; |
350 if (iLength >= 1) { | 338 if (iLength >= 1) { |
351 iIndex = pArguments->GetInt32(0); | 339 iIndex = pArguments->GetInt32(0); |
352 } | 340 } |
353 if (iLength >= 2) { | 341 if (iLength >= 2) { |
354 CFX_ByteString bsType = pArguments->GetUTF8String(1); | 342 CFX_ByteString bsType = pArguments->GetUTF8String(1); |
355 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); | 343 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); |
356 } | 344 } |
357 if (iLength >= 3) { | 345 if (iLength >= 3) { |
358 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; | 346 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; |
359 } | 347 } |
360 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 348 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
361 if (!pNotify) { | 349 if (!pNotify) { |
362 return; | 350 return; |
363 } | 351 } |
364 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 352 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
365 if (!pDocLayout) { | 353 if (!pDocLayout) { |
366 return; | 354 return; |
367 } | 355 } |
368 CXFA_NodeArray retArray; | 356 CXFA_NodeArray retArray; |
369 Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, | 357 GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray); |
370 retArray); | |
371 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); | 358 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); |
372 pArrayNodeList->SetArrayNodeList(retArray); | 359 pArrayNodeList->SetArrayNodeList(retArray); |
373 pArguments->GetReturnValue()->SetObject( | 360 pArguments->GetReturnValue()->SetObject( |
374 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); | 361 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
375 } | 362 } |
376 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( | 363 void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) { |
377 CFXJSE_Arguments* pArguments) { | 364 NumberedPageCount(pArguments, FALSE); |
378 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); | |
379 } | 365 } |
380 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( | 366 void CScript_LayoutPseudoModel::AbsPageCountInBatch( |
381 CFXJSE_Arguments* pArguments) { | 367 CFXJSE_Arguments* pArguments) { |
382 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 368 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
383 if (!pNotify) { | 369 if (!pNotify) { |
384 return; | 370 return; |
385 } | 371 } |
386 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 372 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
387 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); | 373 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageCountInBatch(hDoc); |
388 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 374 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
389 if (pValue) | 375 if (pValue) |
390 pValue->SetInteger(iPageCount); | 376 pValue->SetInteger(iPageCount); |
391 } | 377 } |
392 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCountInBatch( | 378 void CScript_LayoutPseudoModel::SheetCountInBatch( |
393 CFXJSE_Arguments* pArguments) { | 379 CFXJSE_Arguments* pArguments) { |
394 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 380 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
395 if (!pNotify) { | 381 if (!pNotify) { |
396 return; | 382 return; |
397 } | 383 } |
398 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 384 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
399 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); | 385 int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); |
400 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 386 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
401 if (pValue) | 387 if (pValue) |
402 pValue->SetInteger(iPageCount); | 388 pValue->SetInteger(iPageCount); |
403 } | 389 } |
404 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Relayout( | 390 void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) { |
405 CFXJSE_Arguments* pArguments) { | |
406 CXFA_Node* pRootNode = m_pDocument->GetRoot(); | 391 CXFA_Node* pRootNode = m_pDocument->GetRoot(); |
407 CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form); | 392 CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form); |
408 ASSERT(pFormRoot); | 393 ASSERT(pFormRoot); |
409 CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 394 CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
410 CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); | 395 CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); |
411 if (pContentRootNode) { | 396 if (pContentRootNode) { |
412 pLayoutProcessor->AddChangedContainer(pContentRootNode); | 397 pLayoutProcessor->AddChangedContainer(pContentRootNode); |
413 } | 398 } |
414 pLayoutProcessor->SetForceReLayout(TRUE); | 399 pLayoutProcessor->SetForceReLayout(TRUE); |
415 } | 400 } |
416 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageSpan( | 401 void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) { |
417 CFXJSE_Arguments* pArguments) { | 402 PageSpan(pArguments); |
418 Script_LayoutPseudoModel_PageSpan(pArguments); | |
419 } | 403 } |
420 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageInBatch( | 404 void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) { |
421 CFXJSE_Arguments* pArguments) { | |
422 int32_t iLength = pArguments->GetLength(); | 405 int32_t iLength = pArguments->GetLength(); |
423 if (iLength != 1) { | 406 if (iLength != 1) { |
424 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); | 407 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); |
425 return; | 408 return; |
426 } | 409 } |
427 CXFA_Node* pNode = nullptr; | 410 CXFA_Node* pNode = nullptr; |
428 if (iLength >= 1) { | 411 if (iLength >= 1) { |
429 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 412 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
430 } | 413 } |
431 if (!pNode) { | 414 if (!pNode) { |
(...skipping 11 matching lines...) Expand all Loading... |
443 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); | 426 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); |
444 if (!hWidget) { | 427 if (!hWidget) { |
445 return; | 428 return; |
446 } | 429 } |
447 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 430 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
448 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget); | 431 int32_t iPageCount = pNotify->GetDocProvider()->AbsPageInBatch(hDoc, hWidget); |
449 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 432 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
450 if (pValue) | 433 if (pValue) |
451 pValue->SetInteger(iPageCount); | 434 pValue->SetInteger(iPageCount); |
452 } | 435 } |
453 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetInBatch( | 436 void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) { |
454 CFXJSE_Arguments* pArguments) { | |
455 int32_t iLength = pArguments->GetLength(); | 437 int32_t iLength = pArguments->GetLength(); |
456 if (iLength != 1) { | 438 if (iLength != 1) { |
457 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); | 439 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); |
458 return; | 440 return; |
459 } | 441 } |
460 CXFA_Node* pNode = nullptr; | 442 CXFA_Node* pNode = nullptr; |
461 if (iLength >= 1) { | 443 if (iLength >= 1) { |
462 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 444 pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
463 } | 445 } |
464 if (!pNode) { | 446 if (!pNode) { |
(...skipping 11 matching lines...) Expand all Loading... |
476 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); | 458 pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); |
477 if (!hWidget) { | 459 if (!hWidget) { |
478 return; | 460 return; |
479 } | 461 } |
480 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); | 462 CXFA_FFDoc* hDoc = pNotify->GetHDOC(); |
481 int32_t iPageCount = pNotify->GetDocProvider()->SheetInBatch(hDoc, hWidget); | 463 int32_t iPageCount = pNotify->GetDocProvider()->SheetInBatch(hDoc, hWidget); |
482 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 464 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
483 if (pValue) | 465 if (pValue) |
484 pValue->SetInteger(iPageCount); | 466 pValue->SetInteger(iPageCount); |
485 } | 467 } |
486 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Sheet( | 468 void CScript_LayoutPseudoModel::Sheet(CFXJSE_Arguments* pArguments) { |
487 CFXJSE_Arguments* pArguments) { | 469 PageImp(pArguments, TRUE); |
488 Script_LayoutPseudoModel_PageImp(pArguments, TRUE); | |
489 } | 470 } |
490 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_RelayoutPageArea( | 471 void CScript_LayoutPseudoModel::RelayoutPageArea(CFXJSE_Arguments* pArguments) { |
491 CFXJSE_Arguments* pArguments) {} | |
492 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_SheetCount( | |
493 CFXJSE_Arguments* pArguments) { | |
494 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); | |
495 } | 472 } |
496 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPage( | 473 void CScript_LayoutPseudoModel::SheetCount(CFXJSE_Arguments* pArguments) { |
497 CFXJSE_Arguments* pArguments) { | 474 NumberedPageCount(pArguments, FALSE); |
498 Script_LayoutPseudoModel_PageImp(pArguments, TRUE); | |
499 } | 475 } |
500 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageImp( | 476 void CScript_LayoutPseudoModel::AbsPage(CFXJSE_Arguments* pArguments) { |
501 CFXJSE_Arguments* pArguments, | 477 PageImp(pArguments, TRUE); |
502 FX_BOOL bAbsPage) { | 478 } |
| 479 void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments, |
| 480 FX_BOOL bAbsPage) { |
503 int32_t iLength = pArguments->GetLength(); | 481 int32_t iLength = pArguments->GetLength(); |
504 if (iLength != 1) { | 482 if (iLength != 1) { |
505 const FX_WCHAR* methodName; | 483 const FX_WCHAR* methodName; |
506 if (bAbsPage) { | 484 if (bAbsPage) { |
507 methodName = L"absPage"; | 485 methodName = L"absPage"; |
508 } else { | 486 } else { |
509 methodName = L"page"; | 487 methodName = L"page"; |
510 } | 488 } |
511 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); | 489 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); |
512 return; | 490 return; |
(...skipping 13 matching lines...) Expand all Loading... |
526 } | 504 } |
527 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 505 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
528 if (!pLayoutItem) { | 506 if (!pLayoutItem) { |
529 pValue->SetInteger(-1); | 507 pValue->SetInteger(-1); |
530 return; | 508 return; |
531 } | 509 } |
532 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 510 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
533 if (pValue) | 511 if (pValue) |
534 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); | 512 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); |
535 } | 513 } |
OLD | NEW |