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

Side by Side Diff: xfa/fxfa/parser/cscript_layoutpseudomodel.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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
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 "xfa/fxfa/parser/cscript_layoutpseudomodel.h" 7 #include "xfa/fxfa/parser/cscript_layoutpseudomodel.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 14 matching lines...) Expand all
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 CFX_WideStringC(L"layoutPseudoModel")) {} 30 CFX_WideStringC(L"layoutPseudoModel")) {}
31 31
32 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} 32 CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {}
33 33
34 void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, 34 void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
35 FX_BOOL bSetting, 35 bool bSetting,
36 XFA_ATTRIBUTE eAttribute) { 36 XFA_ATTRIBUTE eAttribute) {
37 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 37 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
38 if (!pNotify) { 38 if (!pNotify) {
39 return; 39 return;
40 } 40 }
41 if (bSetting) { 41 if (bSetting) {
42 ThrowException(XFA_IDS_UNABLE_SET_READY); 42 ThrowException(XFA_IDS_UNABLE_SET_READY);
43 return; 43 return;
44 } 44 }
45 int32_t iStatus = pNotify->GetLayoutStatus(); 45 int32_t iStatus = pNotify->GetLayoutStatus();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 while (iIndex > 0 && pLayoutItem) { 99 while (iIndex > 0 && pLayoutItem) {
100 pLayoutItem = pLayoutItem->GetNext(); 100 pLayoutItem = pLayoutItem->GetNext();
101 iIndex--; 101 iIndex--;
102 } 102 }
103 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 103 CFXJSE_Value* pValue = pArguments->GetReturnValue();
104 if (!pLayoutItem) { 104 if (!pLayoutItem) {
105 pValue->SetFloat(0); 105 pValue->SetFloat(0);
106 return; 106 return;
107 } 107 }
108 pLayoutItem->GetRect(rtRect, TRUE); 108 pLayoutItem->GetRect(rtRect, true);
109 switch (layoutModel) { 109 switch (layoutModel) {
110 case XFA_LAYOUTMODEL_H: 110 case XFA_LAYOUTMODEL_H:
111 measure.Set(rtRect.height, XFA_UNIT_Pt); 111 measure.Set(rtRect.height, XFA_UNIT_Pt);
112 break; 112 break;
113 case XFA_LAYOUTMODEL_W: 113 case XFA_LAYOUTMODEL_W:
114 measure.Set(rtRect.width, XFA_UNIT_Pt); 114 measure.Set(rtRect.width, XFA_UNIT_Pt);
115 break; 115 break;
116 case XFA_LAYOUTMODEL_X: 116 case XFA_LAYOUTMODEL_X:
117 measure.Set(rtRect.left, XFA_UNIT_Pt); 117 measure.Set(rtRect.left, XFA_UNIT_Pt);
118 break; 118 break;
(...skipping 18 matching lines...) Expand all
137 137
138 void CScript_LayoutPseudoModel::X(CFXJSE_Arguments* pArguments) { 138 void CScript_LayoutPseudoModel::X(CFXJSE_Arguments* pArguments) {
139 HWXY(pArguments, XFA_LAYOUTMODEL_X); 139 HWXY(pArguments, XFA_LAYOUTMODEL_X);
140 } 140 }
141 141
142 void CScript_LayoutPseudoModel::Y(CFXJSE_Arguments* pArguments) { 142 void CScript_LayoutPseudoModel::Y(CFXJSE_Arguments* pArguments) {
143 HWXY(pArguments, XFA_LAYOUTMODEL_Y); 143 HWXY(pArguments, XFA_LAYOUTMODEL_Y);
144 } 144 }
145 145
146 void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments, 146 void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
147 FX_BOOL bNumbered) { 147 bool bNumbered) {
148 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 148 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
149 if (!pDocLayout) { 149 if (!pDocLayout) {
150 return; 150 return;
151 } 151 }
152 int32_t iPageCount = 0; 152 int32_t iPageCount = 0;
153 int32_t iPageNum = pDocLayout->CountPages(); 153 int32_t iPageNum = pDocLayout->CountPages();
154 if (bNumbered) { 154 if (bNumbered) {
155 for (int32_t i = 0; i < iPageNum; i++) { 155 for (int32_t i = 0; i < iPageNum; i++) {
156 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i); 156 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i);
157 if (!pLayoutPage) { 157 if (!pLayoutPage) {
158 continue; 158 continue;
159 } 159 }
160 CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); 160 CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage();
161 if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { 161 if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) {
162 iPageCount++; 162 iPageCount++;
163 } 163 }
164 } 164 }
165 } else { 165 } else {
166 iPageCount = iPageNum; 166 iPageCount = iPageNum;
167 } 167 }
168 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 168 CFXJSE_Value* pValue = pArguments->GetReturnValue();
169 if (pValue) 169 if (pValue)
170 pValue->SetInteger(iPageCount); 170 pValue->SetInteger(iPageCount);
171 } 171 }
172 172
173 void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) { 173 void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) {
174 NumberedPageCount(pArguments, TRUE); 174 NumberedPageCount(pArguments, true);
175 } 175 }
176 176
177 void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) { 177 void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) {
178 int32_t iLength = pArguments->GetLength(); 178 int32_t iLength = pArguments->GetLength();
179 if (iLength != 1) { 179 if (iLength != 1) {
180 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); 180 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan");
181 return; 181 return;
182 } 182 }
183 CXFA_Node* pNode = nullptr; 183 CXFA_Node* pNode = nullptr;
184 if (iLength >= 1) { 184 if (iLength >= 1) {
(...skipping 13 matching lines...) Expand all
198 return; 198 return;
199 } 199 }
200 int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); 200 int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex();
201 int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); 201 int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
202 int32_t iPageSpan = iLast - iFirst + 1; 202 int32_t iPageSpan = iLast - iFirst + 1;
203 if (pValue) 203 if (pValue)
204 pValue->SetInteger(iPageSpan); 204 pValue->SetInteger(iPageSpan);
205 } 205 }
206 206
207 void CScript_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) { 207 void CScript_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) {
208 PageImp(pArguments, FALSE); 208 PageImp(pArguments, false);
209 } 209 }
210 210
211 void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout, 211 void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
212 int32_t iPageNo, 212 int32_t iPageNo,
213 const CFX_WideString& wsType, 213 const CFX_WideString& wsType,
214 FX_BOOL bOnPageArea, 214 bool bOnPageArea,
215 CXFA_NodeArray& retArray) { 215 CXFA_NodeArray& retArray) {
216 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo); 216 CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo);
217 if (!pLayoutPage) { 217 if (!pLayoutPage) {
218 return; 218 return;
219 } 219 }
220 if (wsType == FX_WSTRC(L"pageArea")) { 220 if (wsType == FX_WSTRC(L"pageArea")) {
221 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { 221 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) {
222 retArray.Add(pMasterPage); 222 retArray.Add(pMasterPage);
223 } 223 }
224 return; 224 return;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 342
343 void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) { 343 void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
344 int32_t iLength = pArguments->GetLength(); 344 int32_t iLength = pArguments->GetLength();
345 if (iLength < 1 || iLength > 3) { 345 if (iLength < 1 || iLength > 3) {
346 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent"); 346 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageContent");
347 return; 347 return;
348 } 348 }
349 int32_t iIndex = 0; 349 int32_t iIndex = 0;
350 CFX_WideString wsType; 350 CFX_WideString wsType;
351 FX_BOOL bOnPageArea = FALSE; 351 bool bOnPageArea = false;
352 if (iLength >= 1) { 352 if (iLength >= 1) {
353 iIndex = pArguments->GetInt32(0); 353 iIndex = pArguments->GetInt32(0);
354 } 354 }
355 if (iLength >= 2) { 355 if (iLength >= 2) {
356 CFX_ByteString bsType = pArguments->GetUTF8String(1); 356 CFX_ByteString bsType = pArguments->GetUTF8String(1);
357 wsType = CFX_WideString::FromUTF8(bsType.AsStringC()); 357 wsType = CFX_WideString::FromUTF8(bsType.AsStringC());
358 } 358 }
359 if (iLength >= 3) { 359 if (iLength >= 3) {
360 bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; 360 bOnPageArea = pArguments->GetInt32(2) == 0 ? false : true;
361 } 361 }
362 CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); 362 CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
363 if (!pNotify) { 363 if (!pNotify) {
364 return; 364 return;
365 } 365 }
366 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); 366 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
367 if (!pDocLayout) { 367 if (!pDocLayout) {
368 return; 368 return;
369 } 369 }
370 CXFA_NodeArray retArray; 370 CXFA_NodeArray retArray;
371 GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray); 371 GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray);
372 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); 372 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument);
373 pArrayNodeList->SetArrayNodeList(retArray); 373 pArrayNodeList->SetArrayNodeList(retArray);
374 pArguments->GetReturnValue()->SetObject( 374 pArguments->GetReturnValue()->SetObject(
375 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); 375 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass());
376 } 376 }
377 377
378 void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) { 378 void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) {
379 NumberedPageCount(pArguments, FALSE); 379 NumberedPageCount(pArguments, false);
380 } 380 }
381 381
382 void CScript_LayoutPseudoModel::AbsPageCountInBatch( 382 void CScript_LayoutPseudoModel::AbsPageCountInBatch(
383 CFXJSE_Arguments* pArguments) { 383 CFXJSE_Arguments* pArguments) {
384 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 384 CFXJSE_Value* pValue = pArguments->GetReturnValue();
385 if (pValue) 385 if (pValue)
386 pValue->SetInteger(0); 386 pValue->SetInteger(0);
387 } 387 }
388 388
389 void CScript_LayoutPseudoModel::SheetCountInBatch( 389 void CScript_LayoutPseudoModel::SheetCountInBatch(
390 CFXJSE_Arguments* pArguments) { 390 CFXJSE_Arguments* pArguments) {
391 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 391 CFXJSE_Value* pValue = pArguments->GetReturnValue();
392 if (pValue) 392 if (pValue)
393 pValue->SetInteger(0); 393 pValue->SetInteger(0);
394 } 394 }
395 395
396 void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) { 396 void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) {
397 CXFA_Node* pRootNode = m_pDocument->GetRoot(); 397 CXFA_Node* pRootNode = m_pDocument->GetRoot();
398 CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form); 398 CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
399 ASSERT(pFormRoot); 399 ASSERT(pFormRoot);
400 CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); 400 CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
401 CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); 401 CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor();
402 if (pContentRootNode) { 402 if (pContentRootNode) {
403 pLayoutProcessor->AddChangedContainer(pContentRootNode); 403 pLayoutProcessor->AddChangedContainer(pContentRootNode);
404 } 404 }
405 pLayoutProcessor->SetForceReLayout(TRUE); 405 pLayoutProcessor->SetForceReLayout(true);
406 } 406 }
407 407
408 void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) { 408 void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) {
409 PageSpan(pArguments); 409 PageSpan(pArguments);
410 } 410 }
411 411
412 void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) { 412 void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
413 if (pArguments->GetLength() != 1) { 413 if (pArguments->GetLength() != 1) {
414 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch"); 414 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"absPageInBatch");
415 return; 415 return;
416 } 416 }
417 417
418 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 418 CFXJSE_Value* pValue = pArguments->GetReturnValue();
419 if (pValue) 419 if (pValue)
420 pValue->SetInteger(0); 420 pValue->SetInteger(0);
421 } 421 }
422 422
423 void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) { 423 void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) {
424 if (pArguments->GetLength() != 1) { 424 if (pArguments->GetLength() != 1) {
425 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); 425 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch");
426 return; 426 return;
427 } 427 }
428 428
429 CFXJSE_Value* pValue = pArguments->GetReturnValue(); 429 CFXJSE_Value* pValue = pArguments->GetReturnValue();
430 if (pValue) 430 if (pValue)
431 pValue->SetInteger(0); 431 pValue->SetInteger(0);
432 } 432 }
433 433
434 void CScript_LayoutPseudoModel::Sheet(CFXJSE_Arguments* pArguments) { 434 void CScript_LayoutPseudoModel::Sheet(CFXJSE_Arguments* pArguments) {
435 PageImp(pArguments, TRUE); 435 PageImp(pArguments, true);
436 } 436 }
437 437
438 void CScript_LayoutPseudoModel::RelayoutPageArea(CFXJSE_Arguments* pArguments) { 438 void CScript_LayoutPseudoModel::RelayoutPageArea(CFXJSE_Arguments* pArguments) {
439 } 439 }
440 440
441 void CScript_LayoutPseudoModel::SheetCount(CFXJSE_Arguments* pArguments) { 441 void CScript_LayoutPseudoModel::SheetCount(CFXJSE_Arguments* pArguments) {
442 NumberedPageCount(pArguments, FALSE); 442 NumberedPageCount(pArguments, false);
443 } 443 }
444 444
445 void CScript_LayoutPseudoModel::AbsPage(CFXJSE_Arguments* pArguments) { 445 void CScript_LayoutPseudoModel::AbsPage(CFXJSE_Arguments* pArguments) {
446 PageImp(pArguments, TRUE); 446 PageImp(pArguments, true);
447 } 447 }
448 448
449 void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments, 449 void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments,
450 FX_BOOL bAbsPage) { 450 bool bAbsPage) {
451 int32_t iLength = pArguments->GetLength(); 451 int32_t iLength = pArguments->GetLength();
452 if (iLength != 1) { 452 if (iLength != 1) {
453 const FX_WCHAR* methodName; 453 const FX_WCHAR* methodName;
454 if (bAbsPage) { 454 if (bAbsPage) {
455 methodName = L"absPage"; 455 methodName = L"absPage";
456 } else { 456 } else {
457 methodName = L"page"; 457 methodName = L"page";
458 } 458 }
459 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); 459 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName);
460 return; 460 return;
(...skipping 13 matching lines...) Expand all
474 } 474 }
475 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); 475 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
476 if (!pLayoutItem) { 476 if (!pLayoutItem) {
477 pValue->SetInteger(-1); 477 pValue->SetInteger(-1);
478 return; 478 return;
479 } 479 }
480 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); 480 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
481 if (pValue) 481 if (pValue)
482 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); 482 pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
483 } 483 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cscript_layoutpseudomodel.h ('k') | xfa/fxfa/parser/cscript_signaturepseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698