home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 March / PCpro_2007_03.ISO / files / browser / msie7 / IE7Setup.exe / ieframe.dll / HTML / PREVIEW.JS < prev    next >
Encoding:
Text File  |  2006-10-27  |  53.6 KB  |  2,339 lines

  1. var g_aDocTree = new Object();
  2. var g_nDispPage = -1;
  3. var g_cLeftToPrint = 0;
  4. var g_fRTL = false;
  5. var g_fPreview;
  6. var g_nScreenDPI = 96
  7. var g_nMarginTop = 0;
  8. var g_nMarginBottom = 0;
  9. var g_nMarginLeft = 0;
  10. var g_nMarginRight = 0;
  11. var g_nPageWidth = 0;
  12. var g_nPageHeight = 0;
  13. var g_strOrientation = Printer.orientation;
  14. var g_nScalePercent = 100;
  15. var g_fCheckAutoFit = false;
  16. var g_fCheckOrphan = false;
  17. var g_nUnprintTop = 0;
  18. var g_nUnprintBottom = 0;
  19. var g_strHeader = "";
  20. var g_strFooter = "";
  21. var g_fTableOfLinks = false;
  22. var g_fPrintHeaderFooter = true;
  23. var g_cPagesDisplayed = 0;
  24. var g_cxDisplaySlots = 1;
  25. var g_cyDisplaySlots = 1;
  26. var g_imgUnderMouse = null;
  27. var g_imgDown = null;
  28. var g_curMultiSelect = null;
  29. var g_curMultiPages = 1;
  30. var g_nFramesetLayout = 0;
  31. var g_strActiveFrame = null;
  32. var g_nTotalPages = 0;
  33. var g_nDocsToCalc = 0;
  34. var g_nFramesLeft = 0;
  35. var g_nZoomLevel = 100;
  36. var g_zoomLayout = -2;
  37. var g_zoomLayoutX = 1;
  38. var g_zoomLayoutY = 1;
  39. var g_zoomPageCount = 1;
  40. var g_fDelayClose = false;
  41. var g_ObsoleteBar = 0;
  42. function AttachDialogEvents()
  43. {
  44. printimg.onclick = HandlePrintClick;
  45. printimg.onmouseover = buttonOver;
  46. printimg.onmouseout = buttonOut;
  47. portrait.onmouseover = buttonOver;
  48. portrait.onmouseout = buttonOut;
  49. landscape.onmouseover = buttonOver;
  50. landscape.onmouseout = buttonOut;
  51. settings.onmouseover = buttonOver;
  52. settings.onmouseout = buttonOut;
  53. headerimg.onmouseover = buttonOver;
  54. headerimg.onmouseout = buttonOut;
  55. zoomWidth.onmouseover = buttonOver;
  56. zoomWidth.onmouseout = buttonOut;
  57. zoomPage.onmouseover = buttonOver;
  58. zoomPage.onmouseout = buttonOut;
  59. helpimg.onmouseover = buttonOver;
  60. helpimg.onmouseout = buttonOut;
  61. begin.onmouseover = buttonOver;
  62. begin.onmouseout = buttonOut;
  63. prev.onmouseover = buttonOver;
  64. prev.onmouseout = buttonOut;
  65. next.onmouseover = buttonOver;
  66. next.onmouseout = buttonOut;
  67. end.onmouseover = buttonOver;
  68. end.onmouseout = buttonOut;
  69. printimg.onmousedown = buttonDown;
  70. printimg.onmouseup = buttonUp;
  71. portrait.onmousedown = buttonDown;
  72. portrait.onmouseup = buttonUp;
  73. landscape.onmousedown = buttonDown;
  74. landscape.onmouseup = buttonUp;
  75. settings.onmousedown = buttonDown;
  76. settings.onmouseup = buttonUp;
  77. headerimg.onmousedown = buttonDown;
  78. headerimg.onmouseup = buttonUp;
  79. zoomWidth.onmousedown = buttonDown;
  80. zoomWidth.onmouseup = buttonUp;
  81. zoomPage.onmousedown = buttonDown;
  82. zoomPage.onmouseup = buttonUp;
  83. helpimg.onmousedown = buttonDown;
  84. helpimg.onmouseup = buttonUp;
  85. portrait.onclick = HandlePortrait;
  86. landscape.onclick = HandleLandscape;
  87. settings.onclick = HandlePageSetup;
  88. headerimg.onclick = HandleHeaders;
  89. zoomWidth.onclick = HandleZoomWidthButton;
  90. zoomPage.onclick = HandleZoomPageButton;
  91. begin.onclick = HandleFirstPage;
  92. prev.onclick = HandleBackPage;
  93. next.onclick = HandleForwardPage;
  94. end.onclick = HandleLastPage;
  95. helpimg.onclick = HandleHelp;
  96. document.onhelp = HandleHelp;
  97. begin.onmousedown = buttonDown;
  98. begin.onmouseup = buttonUp;
  99. prev.onmousedown = buttonDown;
  100. prev.onmouseup = buttonUp;
  101. next.onmousedown = buttonDown;
  102. next.onmouseup = buttonUp;
  103. end.onmousedown = buttonDown;
  104. end.onmouseup = buttonUp;
  105. inputCustomScale.onkeypress = HandleInputKeyPress;
  106. inputCustomScale.onchange = HandleCustomScaleSelect;
  107. inputPageNum.onkeypress = HandleInputKeyPress;
  108. inputPageNum.onchange = HandlePageSelect;
  109. selectScale.onchange = HandleScaleSelect;
  110. selectFrameset.onchange = HandleFramesetSelect;
  111. selectPages.onchange = HandleZoomMultiPageSelect;
  112. window.onresize = OnResizeBody;
  113. window.onerror = HandleError;
  114. document.body.onkeypress = OnKeyPress;
  115. document.body.onkeydown = OnKeyDown;
  116. OverflowContainer.onmousedown = HandleMarginMouseDown;
  117. OverflowContainer.onmouseup = HandleMarginMouseUp;
  118. OverflowContainer.onmousemove = HandleMarginMouseMove;
  119. window.onfocus = new Function("MasterContainer.focus()");
  120. }
  121. function GetRuleFromSelector(strSelector)
  122. {
  123. var i;
  124. var oRule;
  125. var oSS = document.styleSheets[0];
  126. for (i = 0; i < oSS.rules.length; i++)
  127. {
  128. oRule = oSS.rules[i];
  129. if (oRule == null)
  130. break;
  131. if (oRule.selectorText == strSelector)
  132. break;
  133. }
  134. return oRule;
  135. }
  136. function UnprintableURL(strLink)
  137. {
  138. var fUnprintable = false;
  139. var cIndex;
  140. cIndex = strLink.indexOf(":");
  141. switch (cIndex)
  142. {
  143. case 4:
  144. if (strLink.substr(0, cIndex) == "news")
  145. {
  146. fUnprintable = true;
  147. }
  148. break;
  149. case 5:
  150. if (strLink.substr(0, cIndex) == "snews")
  151. {
  152. fUnprintable = true;
  153. }
  154. break;
  155. case 6:
  156. if ( strLink.substr(0, cIndex) == "telnet"
  157. || strLink.substr(0, cIndex) == "mailto")
  158. {
  159. fUnprintable = true;
  160. }
  161. break;
  162. case 8:
  163. if (strLink.substr(0,cIndex) == "vbscript")
  164. {
  165. fUnprintable = true;
  166. }
  167. break;
  168. case 10:
  169. if (strLink.substr(0,cIndex) == "javascript")
  170. {
  171. fUnprintable = true;
  172. }
  173. break;
  174. }
  175. return fUnprintable;
  176. }
  177. function OnKeyPress()
  178. {
  179. if (event.keyCode == 27)
  180. {
  181. Close();
  182. }
  183. }
  184. function OnKeyDown()
  185. {
  186. if(event.keyCode==13 && event.srcElement && (event.srcElement.id=="OverflowContainer" || event.srcElement.id=="MasterContainer")) {
  187. event.cancelBubble = true;
  188. return false;
  189. }
  190. if (event.altKey)
  191. {
  192. switch (event.keyCode)
  193. {
  194. case 37:
  195. if (document.body.dir=="rtl")
  196. {
  197. ChangeDispPage(g_nDispPage+1);
  198. }
  199. else
  200. {
  201. ChangeDispPage(g_nDispPage-1);
  202. }
  203. break;
  204. case 39:
  205. if (document.body.dir=="rtl")
  206. {
  207. ChangeDispPage(g_nDispPage-1);
  208. }
  209. else
  210. {
  211. ChangeDispPage(g_nDispPage+1);
  212. }
  213. break;
  214. case 35:
  215. HandleLastPage();
  216. break;
  217. case 36:
  218. HandleFirstPage();
  219. break;
  220. case 50: '2'
  221. case 98: '2'
  222. selectPages.selectedIndex = 1;
  223. HandleZoomMultiPageClick(2);
  224. break;
  225. case 51: '3'
  226. case 99: '3'
  227. selectPages.selectedIndex = 2;
  228. HandleZoomMultiPageClick(3);
  229. break;
  230. case 54: '6'
  231. case 102: '6'
  232. selectPages.selectedIndex = 3;
  233. HandleZoomMultiPageClick(6);
  234. break;
  235. case 67: 'C'
  236. Close();
  237. break;
  238. case 48: '0'
  239. case 96: '0'
  240. selectPages.selectedIndex = 4;
  241. HandleZoomMultiPageClick(12);
  242. break;
  243. default:
  244. return;
  245. }
  246. event.cancelBubble = true;
  247. return false;
  248. }
  249. }
  250. function OnLoadBody()
  251. {
  252. try{
  253. if(dialogArguments.__IE_BrowseDocument && dialogArguments.__IE_BrowseDocument.body) {
  254. g_fRTL = (dialogArguments.__IE_BrowseDocument.body.currentStyle.direction.toLowerCase() == "rtl");
  255. }
  256. }catch(e){}
  257. g_fPreview = dialogArguments.__IE_PrintType == "Preview";
  258. if (UnprintableURL(dialogArguments.__IE_ContentDocumentUrl))
  259. {
  260. var L_Invalid_Text = "Unable to print URL. Please navigate directly to this page and select Print.";
  261. alert(L_Invalid_Text);
  262. window.close();
  263. }
  264. UpdateOrientationButtons();
  265. ChangeZoom();
  266. if (dialogArguments.__IE_HeaderString)
  267. {
  268. Printer.header = dialogArguments.__IE_HeaderString
  269. }
  270. if (dialogArguments.__IE_FooterString)
  271. {
  272. Printer.footer = dialogArguments.__IE_FooterString
  273. }
  274. EnsureDocuments(false);
  275. window.document.body.style.cursor="wait";
  276. g_fCheckAutoFit = true;
  277. g_fCheckOrphan = true;
  278. CreateDocument("document", "C", true);
  279. ChangeDispPage(1);
  280. g_nFramesLeft = 1;
  281. OnBuildAllFrames("C");
  282. if (g_fPreview)
  283. {
  284. if(dialogArguments.__IE_ContentSelectionUrl)
  285. {
  286. CreateDocument(dialogArguments.__IE_ContentSelectionUrl, "S", true);
  287. }
  288. AttachDialogEvents();
  289. OverflowContainer.style.top = idDivToolbar.offsetHeight;
  290. var h = document.body.clientHeight - idDivToolbar.offsetHeight - idDivToolbar2.offsetHeight;
  291. if(h<0) h = 0;
  292. OverflowContainer.style.height = h;
  293. idDivToolbar2.style.visibility = "visible";
  294. idDivToolbar2.style.pixelTop = idDivToolbar.offsetHeight + h;
  295. ChangeZoomSpecial(g_zoomLayout);
  296. }
  297. else
  298. {
  299. PrintNow(dialogArguments.__IE_PrintType == "Prompt");
  300. }
  301. }
  302. function BuildAllFramesComplete()
  303. {
  304. ;
  305. window.document.body.style.cursor="auto";
  306. UpdateFramesetSelect();
  307. }
  308. function CalcDocsComplete()
  309. {
  310. ;
  311. if (g_nFramesetLayout == 2)
  312. {
  313. ChangeFramesetLayout(g_nFramesetLayout, true)
  314. }
  315. if(g_fCheckAutoFit)
  316. {
  317. g_fCheckAutoFit = false;
  318. var fitScale = CalcAutoFit();
  319. if(fitScale < 30) fitScale = 30;
  320. selectScale.selectedIndex = 0;
  321. cellCustomScale.style.display = "none";
  322. g_nScalePercent = fitScale;
  323. if(fitScale!=100 )
  324. {
  325. EnsureDocuments(true);
  326. return;
  327. }
  328. }
  329. if (g_fCheckOrphan)
  330. {
  331. g_fCheckOrphan = false;
  332. if(IsOrphaned())
  333. {
  334. var orphanScale = CalcOrphanRemovalScale();
  335. g_nScalePercent = g_nScalePercent * orphanScale/100;
  336. if(g_nScalePercent < 30) g_nScalePercent = 30;
  337. EnsureDocuments(true);
  338. return;
  339. }
  340. }
  341. ChangeDispPage(g_nDispPage);
  342. ChangeZoomSpecial(g_zoomLayout);
  343. }
  344. function OnResizeBody()
  345. {
  346. OverflowContainer.style.top = idDivToolbar.offsetHeight;
  347. var h = document.body.clientHeight - idDivToolbar.offsetHeight - idDivToolbar2.offsetHeight;
  348. if(h<0) h = 0;
  349. OverflowContainer.style.height = h;
  350. idDivToolbar2.style.visibility = "visible";
  351. idDivToolbar2.style.pixelTop = idDivToolbar.offsetHeight + h;
  352. ChangeZoomSpecial(g_zoomLayout);
  353. PositionPages(g_nDispPage);
  354. }
  355. function HandleError(message, url, line)
  356. {
  357. var L_Internal_ErrorMessage = "There was an internal error, and Internet Explorer is unable to print this document.";
  358. alert(L_Internal_ErrorMessage);
  359. window.close();
  360. return true;
  361. }
  362. function OnRectComplete(strDoc, ObsoleteCookie)
  363. {
  364. if (!g_aDocTree[strDoc])
  365. {
  366. HandleError("Document " + strDoc + " does not exist.", document.URL, "OnRectComplete");
  367. return;
  368. }
  369. window.setTimeout("OnRectCompleteNext('" + strDoc + "', " + event.contentOverflow + ",'" + event.srcElement.id + "'," + ObsoleteCookie + ");", 25);
  370. }
  371. function OnRectCompleteNext( strDoc, fOverflow, strElement, ObsoleteCookie)
  372. {
  373. if (ObsoleteCookie == g_ObsoleteBar)
  374. {
  375. g_aDocTree[strDoc].RectComplete(fOverflow, strElement);
  376. }
  377. }
  378. function enableButton(img)
  379. {
  380. var imgname = img.id;
  381. if (img == begin || img == end || img == prev || img == next)
  382. {
  383. imgname = img.value;
  384. }
  385. img.disabled = false;
  386. if (g_imgUnderMouse == img)
  387. {
  388. if(g_imgDown==img)
  389. {
  390. img.src = imgname + "_down.png";
  391. }
  392. else
  393. {
  394. img.src = imgname + "_hover.png";
  395. }
  396. }
  397. else
  398. {
  399. img.src = imgname + ".png";
  400. }
  401. }
  402. function disableButton(img)
  403. {
  404. var imgname = img.id;
  405. if (img == begin || img == end || img == prev || img == next)
  406. {
  407. imgname = img.value;
  408. }
  409. img.disabled = true;
  410. img.src = imgname + "_disabled.png";
  411. }
  412. function updateNavButtons()
  413. {
  414. if (g_nDispPage == 1)
  415. {
  416. disableButton(begin);
  417. disableButton(prev);
  418. }
  419. else
  420. {
  421. enableButton(begin);
  422. enableButton(prev);
  423. }
  424. if (TotalDisplayPages() - g_nDispPage < g_cxDisplaySlots * g_cyDisplaySlots)
  425. {
  426. disableButton(next);
  427. disableButton(end);
  428. }
  429. else
  430. {
  431. enableButton(next);
  432. enableButton(end);
  433. }
  434. }
  435. function UpdateOrientationButtons()
  436. {
  437. if (g_strOrientation != Printer.orientation)
  438. {
  439. g_strOrientation = Printer.orientation;
  440. }
  441. if (g_strOrientation == "portrait")
  442. {
  443. disableButton(portrait);
  444. enableButton(landscape);
  445. }
  446. else
  447. {
  448. disableButton(landscape);
  449. enableButton(portrait);
  450. }
  451. }
  452. function buttonOver()
  453. {
  454. var imgSrc = event.srcElement;
  455. if(imgSrc.disabled) return;
  456. g_imgUnderMouse = imgSrc;
  457. if (imgSrc == begin ||
  458. imgSrc == prev ||
  459. imgSrc == next ||
  460. imgSrc == end)
  461. {
  462. updateNavButtons();
  463. }
  464. else
  465. {
  466. if(g_imgDown==imgSrc)
  467. {
  468. imgSrc.src= "" + imgSrc.id + "_down.png";
  469. }
  470. else
  471. {
  472. imgSrc.src= "" + imgSrc.id + "_hover.png";
  473. }
  474. }
  475. }
  476. function buttonOut()
  477. {
  478. var imgSrc = event.srcElement;
  479. if(imgSrc.disabled) return;
  480. g_imgUnderMouse = null;
  481. if (imgSrc == begin || imgSrc == prev ||
  482. imgSrc == next || imgSrc == end)
  483. {
  484. updateNavButtons();
  485. }
  486. else
  487. {
  488. imgSrc.src= "" + imgSrc.id + ".png";
  489. }
  490. }
  491. function buttonDown()
  492. {
  493. if(event.button!=1) return;
  494. var imgSrc = event.srcElement;
  495. if(imgSrc.disabled) return;
  496. var imgname = imgSrc.id;
  497. if (imgSrc == begin || imgSrc == end
  498. || imgSrc == next || imgSrc == prev)
  499. {
  500. imgname = imgSrc.value;
  501. }
  502. imgSrc.src= "" + imgname + "_down.png";
  503. g_imgDown = imgSrc;
  504. g_imgDown.setCapture();
  505. }
  506. function buttonUp()
  507. {
  508. if(event.button!=1) return;
  509. var imgSrc = event.srcElement;
  510. if(imgSrc.disabled) return;
  511. if(g_imgDown!=null) {
  512. var imgname = g_imgDown.id;
  513. if (g_imgDown == begin || g_imgDown == end
  514. || g_imgDown == next || g_imgDown == prev)
  515. {
  516. imgname = g_imgDown.value;
  517. }
  518. if(g_imgUnderMouse==g_imgDown)
  519. {
  520. g_imgDown.src= "" + imgname + "_hover.png";
  521. }
  522. else
  523. {
  524. g_imgDown.src= "" + imgname + ".png";
  525. }
  526. g_imgDown.releaseCapture();
  527. g_imgDown = null;
  528. }
  529. }
  530. function HandlePageSelect()
  531. {
  532. event.srcElement.value = ChangeDispPage(parseInt(inputPageNum.value));
  533. MasterContainer.focus();
  534. }
  535. function HandleCustomScaleSelect()
  536. {
  537. var scale = parseInt(inputCustomScale.value);
  538. if(isNaN(scale)) scale = 100;
  539. if (scale < 30)
  540. {
  541. scale = 30;
  542. }
  543. if (scale > 999)
  544. {
  545. scale = 999;
  546. }
  547. inputCustomScale.value = scale;
  548. if(g_nScalePercent!=scale)
  549. {
  550. g_nScalePercent = scale;
  551. EnsureDocuments(true);
  552. }
  553. MasterContainer.focus();
  554. }
  555. function HandleInputKeyPress()
  556. {
  557. var keyStroke = event.keyCode;
  558. if (keyStroke == 13)
  559. {
  560. event.srcElement.onchange();
  561. return false;
  562. }
  563. else if (keyStroke < 48 || keyStroke > 57)
  564. {
  565. event.returnValue = false;
  566. }
  567. }
  568. function HandleScaleSelect()
  569. {
  570. var oldScale = g_nScalePercent;
  571. g_nScalePercent = parseInt(selectScale.options[selectScale.selectedIndex].value);
  572. g_fCheckAutoFit = false;
  573. g_fCheckOrphan = false;
  574. if (g_nScalePercent == (-1))
  575. {
  576. g_nScalePercent = 100;
  577. g_fCheckAutoFit = true;
  578. g_fCheckOrphan = true;
  579. cellCustomScale.style.display = "none";
  580. EnsureDocuments(true);
  581. }
  582. else if(g_nScalePercent == (0))
  583. {
  584. g_nScalePercent = oldScale;
  585. cellCustomScale.style.display = "block";
  586. inputCustomScale.value = oldScale;
  587. }
  588. else
  589. {
  590. cellCustomScale.style.display = "none";
  591. EnsureDocuments(true);
  592. }
  593. printimg.scrollIntoView();
  594. }
  595. function HandlePageSetup()
  596. {
  597. if (Printer.showPageSetupDialog())
  598. {
  599. UpdateOrientationButtons();
  600. if (IsShrinkToFit())
  601. {
  602. g_nScalePercent = 100;
  603. g_fCheckAutoFit = true;
  604. g_fCheckOrphan = true;
  605. EnsureDocuments(true);
  606. }
  607. else
  608. {
  609. EnsureDocuments(false);
  610. }
  611. }
  612. }
  613. function HandleHelp()
  614. {
  615. var w = Math.floor(document.body.offsetWidth*0.75);
  616. var h = Math.floor(document.body.offsetHeight*0.75);
  617. window.open("http://go.microsoft.com/fwlink/?LinkId=56117","_blank","scrollbars=yes,width="+w+",height="+h);
  618. event.cancelBubble = true;
  619. return false;
  620. }
  621. function HandleForwardPage()
  622. {
  623. ChangeDispPage(g_nDispPage + 1);
  624. }
  625. function HandleBackPage()
  626. {
  627. ChangeDispPage(g_nDispPage - 1);
  628. }
  629. function HandleFirstPage()
  630. {
  631. ChangeDispPage(1);
  632. }
  633. function HandleLastPage()
  634. {
  635. ChangeDispPage(TotalDisplayPages());
  636. }
  637. function HandleHeaders()
  638. {
  639. g_fPrintHeaderFooter = !g_fPrintHeaderFooter;
  640. var oRule = GetRuleFromSelector(".divHead");
  641. if (oRule == null)
  642. {
  643. HandleError("'.divHead' rule does not exist!", document.URL, "HandleHeaders()");
  644. }
  645. oRule.style.display = g_fPrintHeaderFooter ? "inline" : "none";
  646. oRule = GetRuleFromSelector(".divFoot");
  647. if (oRule == null)
  648. {
  649. HandleError("'.divFoot' rule does not exist!", document.URL, "HandleHeaders()");
  650. }
  651. oRule.style.display = g_fPrintHeaderFooter ? "inline" : "none";
  652. }
  653. function HandleLandscape()
  654. {
  655. HandleOrient(false);
  656. }
  657. function HandlePortrait()
  658. {
  659. HandleOrient(true);
  660. }
  661. function HandleOrient(fPortrait)
  662. {
  663. var newOrient;
  664. if (fPortrait)
  665. {
  666. newOrient = "portrait";
  667. }
  668. else
  669. {
  670. newOrient = "landscape";
  671. }
  672. if(newOrient==g_strOrientation) return;
  673. g_strOrientation = newOrient;
  674. var ml = Printer.marginLeft;
  675. var mr = Printer.marginRight;
  676. var mt = Printer.marginTop;
  677. var mb = Printer.marginBottom;
  678. Printer.orientation = g_strOrientation;
  679. Printer.marginLeft = mt;
  680. Printer.marginRight = mb;
  681. Printer.marginTop = ml;
  682. Printer.marginBottom = mr;
  683. UpdateOrientationButtons();
  684. ReflowDocument();
  685. }
  686. function HandleFramesetSelect()
  687. {
  688. UndisplayPages();
  689. var newFramesetLayout = parseInt(selectFrameset.options[selectFrameset.selectedIndex].value);
  690. var isShrinkToFit = IsShrinkToFit();
  691. if (isShrinkToFit)
  692. {
  693. g_nScalePercent = 100;
  694. g_fCheckAutoFit = true;
  695. g_fCheckOrphan = true;
  696. }
  697. ChangeFramesetLayout(newFramesetLayout, false);
  698. if (isShrinkToFit)
  699. {
  700. EnsureDocuments(true);
  701. }
  702. printimg.scrollIntoView();
  703. }
  704. function HandleZoomWidthButton()
  705. {
  706. ChangeZoomSpecial(-1);
  707. g_zoomPageCount = 1;
  708. selectPages.selectedIndex = 0;
  709. }
  710. function HandleZoomPageButton()
  711. {
  712. ChangeZoomSpecial(-2);
  713. g_zoomPageCount = 1;
  714. selectPages.selectedIndex = 0;
  715. }
  716. function getLeft(elm) {
  717. if(elm==null) {
  718. return 0;
  719. } else {
  720. var sz = getLeft(elm.offsetParent);
  721. return sz + elm.offsetLeft;
  722. }
  723. }
  724. function getTop(elm) {
  725. if(elm==null) {
  726. return 0;
  727. } else {
  728. var sz = getTop(elm.offsetParent);
  729. return sz + elm.offsetTop;
  730. }
  731. }
  732. function HandleZoomMultiPageSelect()
  733. {
  734. g_zoomPageCount = parseInt(selectPages.options[selectPages.selectedIndex].value);
  735. UpdateZoomMultiPage();
  736. }
  737. function HandleZoomMultiPageClick(pageCount)
  738. {
  739. g_zoomPageCount = pageCount;
  740. UpdateZoomMultiPage()
  741. }
  742. function UpdateZoomMultiPage()
  743. {
  744. switch(g_zoomPageCount) {
  745. case 2:
  746. HandleZoomMultiPage(2,1);
  747. break;
  748. case 3:
  749. HandleZoomMultiPage(3,1);
  750. break;
  751. case 6:
  752. HandleZoomMultiPage(3,2);
  753. break;
  754. case 12:
  755. HandleZoomMultiPage(4,3);
  756. break;
  757. default:
  758. ChangeZoomSpecial(-2);
  759. break;
  760. }
  761. printimg.scrollIntoView();
  762. }
  763. function HandleZoomMultiPage(x,y)
  764. {
  765. g_zoomLayoutX = x;
  766. g_zoomLayoutY = y;
  767. ChangeZoomSpecial(0);
  768. }
  769. function HandlePrintClick()
  770. {
  771. PrintNow(true);
  772. }
  773. var g_sMarginItemID;
  774. var g_nMarginStartingPos;
  775. var g_nMarginImageOffset;
  776. var g_nMarginLowerLimit;
  777. var g_nMarginUpperLimit;
  778. function HandleMarginMouseDown()
  779. {
  780. if(event.button!=1) return;
  781. if(g_zoomLayout!=-2) return;
  782. var posX = event.x;
  783. var posY = event.y;
  784. if(g_nDispPage <= 0) return;
  785. var oPage = DisplayPage(g_nDispPage);
  786. if(null == oPage) return;
  787. var pageOffsetX;
  788. var pageOffsetY = oPage.style.pixelTop;
  789. if(g_fRTL)
  790. {
  791. pageOffsetX = oPage.style.pixelRight;
  792. }
  793. else
  794. {
  795. pageOffsetX = oPage.style.pixelLeft;
  796. }
  797. var xPageWidth = getPageWidth();
  798. var yPageHeight = getPageHeight();
  799. switch(event.srcElement.id)
  800. {
  801. case "maLeft":
  802. g_nMarginStartingPos = posX;
  803. g_nMarginImageOffset = maLeft.offsetLeft - posX;
  804. g_nMarginLowerLimit = (pageOffsetX * g_nZoomLevel/100) - 10;
  805. g_nMarginUpperLimit = g_nMarginLowerLimit + ((xPageWidth - ((g_nMarginRight+0.5)*g_nScreenDPI)) * g_nZoomLevel/100);
  806. break;
  807. case "maRight":
  808. g_nMarginStartingPos = posX;
  809. g_nMarginImageOffset = maRight.offsetLeft - posX;
  810. g_nMarginLowerLimit = (pageOffsetX * g_nZoomLevel/100) - 10;
  811. g_nMarginUpperLimit = g_nMarginLowerLimit + (xPageWidth * g_nZoomLevel/100);
  812. g_nMarginLowerLimit += ((g_nMarginLeft+0.5)*g_nScreenDPI) * g_nZoomLevel/100;
  813. break;
  814. case "maTop":
  815. g_nMarginStartingPos = posY;
  816. g_nMarginImageOffset = maTop.offsetTop - posY;
  817. g_nMarginLowerLimit = (pageOffsetY * g_nZoomLevel/100) - 10;
  818. g_nMarginUpperLimit = g_nMarginLowerLimit + ((yPageHeight - ((g_nMarginBottom+0.5)*g_nScreenDPI)) * g_nZoomLevel/100);
  819. break;
  820. case "maBottom":
  821. g_nMarginStartingPos = posY;
  822. g_nMarginImageOffset = maBottom.offsetTop - posY;
  823. g_nMarginLowerLimit = (pageOffsetY * g_nZoomLevel/100) - 10;
  824. g_nMarginUpperLimit = g_nMarginLowerLimit + (yPageHeight * g_nZoomLevel/100);
  825. g_nMarginLowerLimit += ((g_nMarginTop+0.5)*g_nScreenDPI) * g_nZoomLevel/100;
  826. break;
  827. default:
  828. return;
  829. }
  830. g_sMarginItemID = event.srcElement.id;
  831. UpdateMarginBox();
  832. OverflowContainer.setCapture();
  833. }
  834. function ReflowDocument()
  835. {
  836. if(IsShrinkToFit())
  837. {
  838. g_nScalePercent = 100;
  839. g_fCheckAutoFit = true;
  840. g_fCheckOrphan = true;
  841. }
  842. EnsureDocuments(true);
  843. }
  844. function IsShrinkToFit()
  845. {
  846. return parseInt(selectScale.options[selectScale.selectedIndex].value) == (-1);
  847. }
  848. function UpdateMarginBox()
  849. {
  850. MarginBox.style.pixelLeft = maLeft.style.pixelLeft + 10;
  851. MarginBox.style.pixelWidth = maRight.style.pixelLeft - maLeft.style.pixelLeft;
  852. MarginBox.style.pixelTop = maTop.style.pixelTop + 10;
  853. MarginBox.style.pixelHeight = maBottom.style.pixelTop - maTop.style.pixelTop;
  854. MarginBox.style.display = "block";
  855. }
  856. function HandleMarginMouseUp()
  857. {
  858. if(g_sMarginItemID==null) return;
  859. if(((g_sMarginItemID=="maLeft" || g_sMarginItemID=="maRight") && g_nMarginStartingPos==event.x)
  860. || ((g_sMarginItemID=="maTop" || g_sMarginItemID=="maBottom") && g_nMarginStartingPos==event.y))
  861. {
  862. g_sMarginItemID = null;
  863. MarginBox.style.display = "none";
  864. OverflowContainer.releaseCapture();
  865. return;
  866. }
  867. var posX = event.x + g_nMarginImageOffset + 10;
  868. var posY = event.y + g_nMarginImageOffset + 10;
  869. posX *= 100/g_nZoomLevel;
  870. posY *= 100/g_nZoomLevel;
  871. var oPage = DisplayPage(g_nDispPage);
  872. var pageOffsetX;
  873. var pageOffsetY = oPage.style.pixelTop;
  874. var xPageWidth = getPageWidth();
  875. var yPageHeight = getPageHeight();
  876. var fReflow = false;
  877. var limit;
  878. if(g_fRTL)
  879. {
  880. pageOffsetX = oPage.style.pixelRight;
  881. }
  882. else
  883. {
  884. pageOffsetX = oPage.style.pixelLeft;
  885. }
  886. switch(g_sMarginItemID)
  887. {
  888. case "maLeft":
  889. var newLeft = Math.floor((posX - pageOffsetX) * 100 / g_nScreenDPI);
  890. limit = Printer.pageWidth - Printer.marginRight - 50;
  891. if(newLeft > limit) newLeft = limit;
  892. if(newLeft<0) newLeft = 0;
  893. if(Printer.marginLeft!=newLeft)
  894. {
  895. Printer.marginLeft = newLeft;
  896. fReflow = true;
  897. }
  898. break;
  899. case "maRight":
  900. var newRight = Math.floor((pageOffsetX + xPageWidth - posX) * 100 / g_nScreenDPI);
  901. limit = Math.floor((g_nPageWidth-g_nMarginLeft-0.5)*100);
  902. if(newRight > limit) newRight = limit;
  903. if(newRight<0) newRight = 0;
  904. if(Printer.marginRight!=newRight)
  905. {
  906. Printer.marginRight = newRight;
  907. fReflow = true;
  908. }
  909. break;
  910. case "maTop":
  911. var newTop = Math.floor((posY - pageOffsetY) * 100 / g_nScreenDPI);
  912. limit = Math.floor((g_nPageHeight-g_nMarginBottom-0.5)*100);
  913. if(newTop > limit) newTop = limit;
  914. if(newTop<0) newTop = 0;
  915. if(Printer.marginTop != newTop)
  916. {
  917. Printer.marginTop = newTop;
  918. fReflow = true;
  919. }
  920. break;
  921. case "maBottom":
  922. var newBottom = Math.floor((pageOffsetY + yPageHeight - posY) * 100 / g_nScreenDPI);
  923. if(newBottom<0) newBottom = 0;
  924. limit = Math.floor((g_nPageHeight-g_nMarginTop-0.5)*100);
  925. if(newBottom > limit) newBottom = limit;
  926. if(Printer.marginBottom != newBottom)
  927. {
  928. Printer.marginBottom = newBottom;
  929. fReflow = true;
  930. }
  931. break;
  932. }
  933. if(fReflow)
  934. {
  935. ReflowDocument();
  936. }
  937. else
  938. {
  939. PositionPages(g_nDispPage);
  940. }
  941. g_sMarginItemID = null;
  942. MarginBox.style.display = "none";
  943. OverflowContainer.releaseCapture();
  944. }
  945. function HandleMarginMouseMove()
  946. {
  947. if(g_sMarginItemID==null) return;
  948. var posX = event.x + g_nMarginImageOffset;
  949. var posY = event.y + g_nMarginImageOffset;
  950. switch(g_sMarginItemID)
  951. {
  952. case "maLeft":
  953. if(posX < g_nMarginLowerLimit) posX = g_nMarginLowerLimit;
  954. if(posX > g_nMarginUpperLimit) posX = g_nMarginUpperLimit;
  955. maLeft.style.left = posX;
  956. break;
  957. case "maRight":
  958. if(posX < g_nMarginLowerLimit) posX = g_nMarginLowerLimit;
  959. if(posX > g_nMarginUpperLimit) posX = g_nMarginUpperLimit;
  960. maRight.style.left = posX;
  961. break;
  962. case "maTop":
  963. if(posY < g_nMarginLowerLimit) posY = g_nMarginLowerLimit;
  964. if(posY > g_nMarginUpperLimit) posY = g_nMarginUpperLimit;
  965. maTop.style.top = posY;
  966. break;
  967. case "maBottom":
  968. if(posY < g_nMarginLowerLimit) posY = g_nMarginLowerLimit;
  969. if(posY > g_nMarginUpperLimit) posY = g_nMarginUpperLimit;
  970. maBottom.style.top = posY;
  971. break;
  972. }
  973. UpdateMarginBox();
  974. }
  975. function UpdateFramesetSelect()
  976. {
  977. if(g_aDocTree["S"]==null)
  978. {
  979. selectFrameset.options.remove(3);
  980. }
  981. if ( g_aDocTree["C"]._fFrameset )
  982. {
  983. if (!g_strActiveFrame)
  984. {
  985. selectFrameset.options.remove(1);
  986. }
  987. separatorFrameset.style.display = "inline";
  988. cellFrameset.style.display = "inline";
  989. }
  990. if(g_aDocTree["S"]!=null)
  991. {
  992. if(!g_aDocTree["C"]._fFrameset)
  993. {
  994. selectFrameset.options.remove(2);
  995. selectFrameset.options.remove(1);
  996. }
  997. if(g_nFramesetLayout == 3)
  998. {
  999. idSelection.selected = true;
  1000. }
  1001. separatorFrameset.style.display = "inline";
  1002. cellFrameset.style.display = "inline";
  1003. }
  1004. }
  1005. function getPageWidth()
  1006. {
  1007. return g_aDocTree["C"].Page(1).offsetWidth;
  1008. }
  1009. function getPageHeight()
  1010. {
  1011. return g_aDocTree["C"].Page(1).offsetHeight;
  1012. }
  1013. function UndisplayPages()
  1014. {
  1015. while (g_cPagesDisplayed > 0)
  1016. {
  1017. var oPage = DisplayPage(g_nDispPage + g_cPagesDisplayed - 1);
  1018. if (oPage != null)
  1019. {
  1020. oPage.style.top = "-20000px";
  1021. if (g_fRTL)
  1022. {
  1023. oPage.style.right = "10px";
  1024. }
  1025. else
  1026. {
  1027. oPage.style.left = "10px";
  1028. }
  1029. }
  1030. g_cPagesDisplayed--;
  1031. }
  1032. var oAnchorRule = GetRuleFromSelector(".MarginAnchor");
  1033. oAnchorRule.style.display = "none";
  1034. }
  1035. function PositionPages(nDispPage)
  1036. {
  1037. var fRendering = false;
  1038. if((g_fCheckAutoFit || g_fCheckOrphan) && g_nDocsToCalc>0) {
  1039. UndisplayPages();
  1040. fRendering = true;
  1041. }
  1042. var strDispDoc = DisplayDocument(nDispPage);
  1043. if (g_aDocTree != null &&
  1044. g_aDocTree[strDispDoc] != null &&
  1045. g_aDocTree[strDispDoc].Pages() > 0)
  1046. {
  1047. UndisplayPages();
  1048. RecalculateZoom();
  1049. MasterContainer.style.zoom = g_nZoomLevel + "%";
  1050. var xPageWidth = getPageWidth();
  1051. var yPageHeight = getPageHeight();
  1052. var nMaxPage = TotalDisplayPages();
  1053. var xContainerWidth = (OverflowContainer.offsetWidth)*100/g_nZoomLevel;
  1054. var yContainerHeight = OverflowContainer.offsetHeight*100/g_nZoomLevel;
  1055. if(g_zoomLayout==0) {
  1056. g_cxDisplaySlots = g_zoomLayoutX;
  1057. g_cyDisplaySlots = g_zoomLayoutY;
  1058. } else {
  1059. g_cxDisplaySlots = 1;
  1060. g_cyDisplaySlots = 1;
  1061. }
  1062. var yOff = (yContainerHeight - (g_cyDisplaySlots * yPageHeight) - ((g_cyDisplaySlots-1)*10)) / 2;
  1063. if(yOff<0)
  1064. {
  1065. xContainerWidth -= 20*100/g_nZoomLevel;
  1066. yOff = 10;
  1067. }
  1068. var xOff = (xContainerWidth - (g_cxDisplaySlots * xPageWidth) - ((g_cxDisplaySlots-1)*10)) / 2;
  1069. if(xOff<0) xOff = 0;
  1070. if(fRendering)
  1071. {
  1072. EmptyPage.style.left = xOff;
  1073. EmptyPage.style.top = yOff;
  1074. EmptyPage.style.display = "block";
  1075. return;
  1076. } else {
  1077. EmptyPage.style.display = "none";
  1078. }
  1079. var nMaxPageRequest = Math.max(nMaxPage - g_cxDisplaySlots * g_cyDisplaySlots + 1, 1);
  1080. if (nDispPage < 1)
  1081. {
  1082. nDispPage = 1;
  1083. }
  1084. else if (nDispPage > nMaxPageRequest)
  1085. {
  1086. nDispPage = nMaxPageRequest;
  1087. }
  1088. g_nDispPage = nDispPage;
  1089. document.all.spanPageTotal.innerText = nMaxPage;
  1090. document.all.inputPageNum.value = g_nDispPage;
  1091. updateNavButtons();
  1092. var xDisplaySlot = 1;
  1093. var yDisplaySlot = 1;
  1094. var iPage = g_nDispPage;
  1095. g_cPagesDisplayed = 0;
  1096. while (iPage <= nMaxPage && yDisplaySlot <= g_cyDisplaySlots)
  1097. {
  1098. var xPos = xOff + (xDisplaySlot-1)*(xPageWidth+10);
  1099. var yPos = yOff + (yDisplaySlot-1)*(yPageHeight+10);
  1100. var oPage = DisplayPage(iPage);
  1101. if (g_fRTL)
  1102. {
  1103. oPage.style.right = xPos;
  1104. }
  1105. else
  1106. {
  1107. oPage.style.left = xPos;
  1108. }
  1109. oPage.style.top = yPos;
  1110. iPage++;
  1111. if (++xDisplaySlot > g_cxDisplaySlots)
  1112. {
  1113. xDisplaySlot = 1;
  1114. yDisplaySlot++;
  1115. }
  1116. g_cPagesDisplayed++;
  1117. }
  1118. var oAnchorRule = GetRuleFromSelector(".MarginAnchor");
  1119. if(g_zoomLayout==-2)
  1120. {
  1121. var oPage = DisplayPage(g_nDispPage);
  1122. if(g_fRTL)
  1123. {
  1124. maLeft.style.pixelLeft = (oPage.style.pixelRight * g_nZoomLevel/100) - 10;
  1125. maTop.style.left = (oPage.style.pixelRight * g_nZoomLevel/100) - 24;
  1126. maRight.style.left = ((oPage.style.pixelRight + xPageWidth) * g_nZoomLevel/100) - 10;
  1127. }
  1128. else
  1129. {
  1130. maLeft.style.pixelLeft = (oPage.style.pixelLeft * g_nZoomLevel/100) - 10;
  1131. maTop.style.left = (oPage.style.pixelLeft * g_nZoomLevel/100) - 20;
  1132. maRight.style.left = ((oPage.style.pixelLeft + xPageWidth) * g_nZoomLevel/100) - 10;
  1133. }
  1134. maLeft.style.pixelTop = (oPage.style.pixelTop * g_nZoomLevel/100) - 20;
  1135. maTop.style.top = oPage.style.pixelTop * g_nZoomLevel/100 - 10;
  1136. maRight.style.top = maLeft.style.pixelTop;
  1137. maBottom.style.left = maTop.style.pixelLeft;
  1138. maBottom.style.top = ((oPage.style.pixelTop + yPageHeight) * g_nZoomLevel/100) - 10;
  1139. maLeft.style.pixelLeft += g_nMarginLeft * g_nScreenDPI * g_nZoomLevel/100;
  1140. maTop.style.pixelTop += g_nMarginTop * g_nScreenDPI * g_nZoomLevel/100;
  1141. maRight.style.pixelLeft -= g_nMarginRight * g_nScreenDPI * g_nZoomLevel/100;
  1142. maBottom.style.pixelTop -= g_nMarginBottom * g_nScreenDPI * g_nZoomLevel/100;
  1143. oAnchorRule.style.display = "block";
  1144. }
  1145. else
  1146. {
  1147. oAnchorRule.style.display = "none";
  1148. }
  1149. }
  1150. }
  1151. function ChangeDispPage(nDispPageNew)
  1152. {
  1153. if (isNaN(nDispPageNew))
  1154. {
  1155. inputPageNum.value = g_nDispPage;
  1156. }
  1157. else
  1158. {
  1159. var totalPages = TotalDisplayPages();
  1160. if (nDispPageNew < 1)
  1161. {
  1162. nDispPageNew = 1;
  1163. }
  1164. else if (nDispPageNew > totalPages)
  1165. {
  1166. nDispPageNew = totalPages;
  1167. }
  1168. if((!g_fCheckAutoFit && !g_fCheckOrphan) || g_nDocsToCalc>0)
  1169. {
  1170. PositionPages(nDispPageNew);
  1171. }
  1172. }
  1173. return g_nDispPage;
  1174. }
  1175. function DisplayDocument(nWhichPage)
  1176. {
  1177. switch (g_nFramesetLayout)
  1178. {
  1179. case 0:
  1180. return "C";
  1181. break;
  1182. case 1:
  1183. return g_strActiveFrame;
  1184. break;
  1185. case 3:
  1186. return "S";
  1187. break;
  1188. case 2:
  1189. var i;
  1190. if (!nWhichPage)
  1191. return null;
  1192. ;
  1193. for (i in g_aDocTree)
  1194. {
  1195. if ( nWhichPage >= g_aDocTree[i]._nStartingPage
  1196. && nWhichPage < (g_aDocTree[i]._nStartingPage + g_aDocTree[i].Pages()))
  1197. return i;
  1198. }
  1199. break;
  1200. default:
  1201. HandleError("Display document cannot be found!", document.URL, "DisplayDocument");
  1202. break;
  1203. }
  1204. }
  1205. function TotalDisplayPages()
  1206. {
  1207. if (g_nFramesetLayout == 2)
  1208. {
  1209. return g_nTotalPages;
  1210. }
  1211. return g_aDocTree[DisplayDocument()].Pages();
  1212. }
  1213. function DisplayPage(nWhichPage)
  1214. {
  1215. ;
  1216. if (g_nFramesetLayout != 2)
  1217. {
  1218. return g_aDocTree[DisplayDocument(nWhichPage)].Page(nWhichPage);
  1219. }
  1220. return g_aDocTree[DisplayDocument(nWhichPage)].Page(nWhichPage - g_aDocTree[DisplayDocument(nWhichPage)]._nStartingPage + 1);
  1221. }
  1222. function DisplayPageLayoutRect(nWhichPage)
  1223. {
  1224. var oPage = DisplayPage(nWhichPage);
  1225. if(oPage==null) return null;
  1226. var oRectColl = oPage.getElementsByTagName("LAYOUTRECT");
  1227. if(oRectColl==null || oRectColl.length==0) return null;
  1228. ;
  1229. return oRectColl[0];
  1230. }
  1231. function ChangeZoom()
  1232. {
  1233. MasterContainer.style.zoom = g_nZoomLevel + "%";
  1234. PositionPages(g_nDispPage);
  1235. return g_nZoomLevel;
  1236. }
  1237. function ChangeZoomSpecial(zoomtype)
  1238. {
  1239. CalculateZoomSpecial(zoomtype);
  1240. ChangeZoom();
  1241. }
  1242. function RecalculateZoom()
  1243. {
  1244. CalculateZoomSpecial(g_zoomLayout);
  1245. }
  1246. function CalculateZoomSpecial(zoomtype)
  1247. {
  1248. var xPage = getPageWidth();
  1249. var yPage = getPageHeight();
  1250. if(xPage==0 || yPage==0) return;
  1251. var xContainer = OverflowContainer.offsetWidth;
  1252. var yContainer = OverflowContainer.offsetHeight;
  1253. if(zoomtype==0 && g_zoomLayoutX==1 && g_zoomLayoutY==1) {
  1254. zoomtype = -2;
  1255. }
  1256. var x,y;
  1257. var factor = 100;
  1258. switch(zoomtype) {
  1259. case -1:
  1260. factor = Math.floor(((xContainer - 40)*100)/xPage);
  1261. break;
  1262. case -2:
  1263. x = Math.floor(((xContainer - 40)*100)/xPage);
  1264. y = Math.floor(((yContainer - 40)*100)/yPage);
  1265. factor = Math.min(x,y);
  1266. break;
  1267. case 0:
  1268. x = Math.floor(((xContainer - 20)*100)/((xPage+10)*g_zoomLayoutX));
  1269. y = Math.floor(((yContainer - 20)*100)/((yPage+10)*g_zoomLayoutY));
  1270. factor = Math.min(x,y);
  1271. break;
  1272. default:
  1273. return;
  1274. }
  1275. if(factor<10) factor = 10;
  1276. else if(factor>1000) factor = 1000;
  1277. g_zoomLayout = zoomtype;
  1278. g_nZoomLevel = factor;
  1279. }
  1280. function BuildTableOfLinks(docSource)
  1281. {
  1282. var aLinks = docSource.links;
  1283. var nLinks = aLinks.length;
  1284. if (nLinks > 0)
  1285. {
  1286. var fDuplicate;
  1287. var i;
  1288. var j;
  1289. var newHTM;
  1290. var docLinkTable = document.createElement("BODY");
  1291. var L_LINKSHEADER1_Text = "Shortcut Text";
  1292. var L_LINKSHEADER2_Text = "Internet Address";
  1293. newHTM = "<CENTER><TABLE BORDER=1>";
  1294. newHTM += "<THEAD style=\"display:table-header-group\"><TR><TH>"
  1295. + L_LINKSHEADER1_Text
  1296. + "</TH><TH>" + L_LINKSHEADER2_Text + "</TH></TR></THEAD><TBODY>";
  1297. for (i = 0; i < nLinks; i++)
  1298. {
  1299. fDuplicate = false;
  1300. for (j = 0; (!fDuplicate) && (j < i); j++)
  1301. {
  1302. if (aLinks[i].href == aLinks[j].href)
  1303. {
  1304. fDuplicate = true;
  1305. }
  1306. }
  1307. if (!fDuplicate)
  1308. {
  1309. newHTM += ("<TR><TD>" + aLinks[i].innerText + "</TD><TD>" + aLinks[i].href + "</TD></TR>");
  1310. }
  1311. }
  1312. newHTM += "</TBODY></TABLE></CENTER>";
  1313. docLinkTable.innerHTML = newHTM;
  1314. return docLinkTable.document;
  1315. }
  1316. return null;
  1317. }
  1318. function CreateDocument(docURL, strDocID, fUseStreamHeader)
  1319. {
  1320. if (g_aDocTree[strDocID])
  1321. {
  1322. return;
  1323. }
  1324. g_aDocTree[strDocID] = new CPrintDoc(strDocID, docURL);
  1325. g_aDocTree[strDocID].InitDocument(fUseStreamHeader);
  1326. g_nDocsToCalc++;
  1327. }
  1328. function ChangeFramesetLayout(nNewLayout, fForce)
  1329. {
  1330. if (g_nFramesetLayout == nNewLayout && !fForce)
  1331. {
  1332. return;
  1333. }
  1334. UndisplayPages();
  1335. g_nFramesetLayout = nNewLayout;
  1336. switch (nNewLayout)
  1337. {
  1338. case 0:
  1339. case 1:
  1340. case 3:
  1341. break;
  1342. case 2:
  1343. g_nTotalPages = 0;
  1344. var i;
  1345. for (i in g_aDocTree)
  1346. {
  1347. if (g_aDocTree[i]._fFrameset || i == "S")
  1348. {
  1349. g_aDocTree[i]._nStartingPage = 0;
  1350. }
  1351. else
  1352. {
  1353. g_aDocTree[i]._nStartingPage = g_nTotalPages + 1;
  1354. g_nTotalPages += g_aDocTree[i].Pages();
  1355. }
  1356. }
  1357. break;
  1358. default:
  1359. HandleError("Impossible frameset layout type: " + nNewLayout, document.URL, "ChangeFramesetLayout");
  1360. break;
  1361. }
  1362. ChangeDispPage(1);
  1363. }
  1364. function EnsureDocuments(fForceRepaginate)
  1365. {
  1366. var i;
  1367. var tmp;
  1368. var top = Printer.marginTop / 100;
  1369. var bottom = Printer.marginBottom / 100;
  1370. var left = Printer.marginLeft / 100;
  1371. var right = Printer.marginRight / 100;
  1372. var pageWidth = Printer.pageWidth / 100;
  1373. var pageHeight = Printer.pageHeight / 100;
  1374. var linktable = Printer.tableOfLinks;
  1375. var upTop = Printer.unprintableTop / 100;
  1376. var upBottom = Printer.unprintableBottom / 100;
  1377. var header = Printer.header;
  1378. var footer = Printer.footer;
  1379. if (header)
  1380. {
  1381. tmp = upTop + (27 / 100);
  1382. if (tmp > top)
  1383. {
  1384. top = tmp;
  1385. }
  1386. }
  1387. if (footer)
  1388. {
  1389. tmp = upBottom + (27 / 100);
  1390. if (tmp > bottom)
  1391. {
  1392. bottom = tmp;
  1393. }
  1394. }
  1395. if (upTop != g_nUnprintTop)
  1396. {
  1397. g_nUnprintTop = upTop;
  1398. var oRule = GetRuleFromSelector(".divHead");
  1399. if (oRule == null)
  1400. {
  1401. HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1402. }
  1403. oRule.style.top = upTop + "in";
  1404. if(g_fRTL)
  1405. {
  1406. oRule.style.direction = "rtl";
  1407. }
  1408. }
  1409. if (upBottom != g_nUnprintBottom)
  1410. {
  1411. g_nUnprintBottom= upBottom;
  1412. var oRule = GetRuleFromSelector(".divFoot");
  1413. if (oRule == null)
  1414. {
  1415. HandleError("'.divFoot' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1416. }
  1417. oRule.style.bottom = upBottom + "in";
  1418. if(g_fRTL)
  1419. {
  1420. oRule.style.direction = "rtl";
  1421. }
  1422. }
  1423. if (top != g_nMarginTop ||
  1424. bottom != g_nMarginBottom ||
  1425. left != g_nMarginLeft ||
  1426. right != g_nMarginRight ||
  1427. pageWidth != g_nPageWidth ||
  1428. pageHeight != g_nPageHeight ||
  1429. header != g_strHeader ||
  1430. footer != g_strFooter ||
  1431. fForceRepaginate == true)
  1432. {
  1433. var conWidth = pageWidth - left - right;
  1434. var conHeight = pageHeight - top - bottom;
  1435. var oStyleSheet = document.styleSheets[0];
  1436. var oRule;
  1437. if (conWidth < 0)
  1438. {
  1439. conWidth = 0;
  1440. }
  1441. if (conHeight < 0)
  1442. {
  1443. conHeight = 0;
  1444. }
  1445. UndisplayPages();
  1446. g_nTotalPages = 0;
  1447. g_nDocsToCalc = 0;
  1448. for (i in g_aDocTree)
  1449. {
  1450. g_nDocsToCalc++;
  1451. g_aDocTree[i].ResetDocument();
  1452. }
  1453. g_ObsoleteBar++;
  1454. g_nMarginTop = top;
  1455. g_nMarginBottom = bottom;
  1456. g_nMarginLeft = left;
  1457. g_nMarginRight = right;
  1458. g_nPageWidth = pageWidth;
  1459. g_nPageHeight = pageHeight;
  1460. g_fTableofLinks = linktable;
  1461. g_strHeader = header;
  1462. g_strFooter = footer;
  1463. HeadFoot.textHead = g_strHeader;
  1464. HeadFoot.textFoot = g_strFooter;
  1465. oRule = GetRuleFromSelector(".page");
  1466. if (oRule == null)
  1467. {
  1468. HandleError("'.page' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1469. }
  1470. oRule.style.width = pageWidth + "in";
  1471. oRule.style.height = pageHeight + "in";
  1472. oRule = GetRuleFromSelector(".mRect");
  1473. if (oRule == null)
  1474. {
  1475. HandleError("'.mRect' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1476. }
  1477. oRule.style.marginLeft = left + "in";
  1478. oRule.style.marginRight = right + "in";
  1479. oRule.style.marginTop = top + "in";
  1480. oRule.style.marginBottom = bottom + "in";
  1481. oRule.style.width = (conWidth*100/g_nScalePercent) + "in";
  1482. oRule.style.height = (conHeight*100/g_nScalePercent) + "in";
  1483. oRule.style.zoom = g_nScalePercent + "%";
  1484. oRule = GetRuleFromSelector(".divHead");
  1485. if (oRule == null)
  1486. {
  1487. HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1488. }
  1489. oRule.style.left = left + "in";
  1490. oRule.style.width = conWidth + "in";
  1491. oRule = GetRuleFromSelector(".divFoot");
  1492. if (oRule == null)
  1493. {
  1494. HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
  1495. }
  1496. oRule.style.left = left + "in";
  1497. oRule.style.width = conWidth + "in";
  1498. for (i in g_aDocTree)
  1499. {
  1500. g_aDocTree[i].InitDocument((g_aDocTree[i]._anMerge[1] == 1));
  1501. }
  1502. if (g_nFramesetLayout == 2)
  1503. {
  1504. ChangeFramesetLayout(g_nFramesetLayout, true);
  1505. }
  1506. PositionPages(g_nDispPage);
  1507. }
  1508. else if (linktable != g_fTableOfLinks)
  1509. {
  1510. g_fTableOfLinks = linktable;
  1511. for (i in g_aDocTree)
  1512. {
  1513. g_aDocTree[i].ResetTableOfLinks();
  1514. }
  1515. }
  1516. }
  1517. function CalcAutoFit()
  1518. {
  1519. var docWidthPx = 0;
  1520. var docWidthIn = 0;
  1521. var printerWidth = Printer.pageWidth / 100;
  1522. var scale = 100;
  1523. var docClientWidthPx = 0;
  1524. if (g_nScreenDPI == 0)
  1525. {
  1526. return scale;
  1527. }
  1528. printerWidth -= g_nMarginLeft;
  1529. printerWidth -= g_nMarginRight;
  1530. var nCount = TotalDisplayPages();
  1531. var i;
  1532. for(i = 1; i<=nCount; i++)
  1533. {
  1534. var oRect = DisplayPageLayoutRect(i);
  1535. if(oRect!=null)
  1536. {
  1537. if (oRect.scrollWidth > docWidthPx)
  1538. {
  1539. docWidthPx = oRect.scrollWidth;
  1540. }
  1541. if (oRect.clientWidth > docClientWidthPx)
  1542. {
  1543. docClientWidthPx = oRect.clientWidth;
  1544. }
  1545. }
  1546. }
  1547. docWidthIn = docWidthPx * (1/g_nScreenDPI);
  1548. if (docWidthPx == 0 || docClientWidthPx >= docWidthPx)
  1549. {
  1550. return scale;
  1551. }
  1552. scale = (printerWidth / docWidthIn) * 100;
  1553. scale = Math.floor(scale+0.05);
  1554. if (scale < 30)
  1555. {
  1556. scale = 30;
  1557. }
  1558. if (scale > 100)
  1559. {
  1560. scale = 100;
  1561. }
  1562. return scale;
  1563. }
  1564. function IsOrphaned()
  1565. {
  1566. if((g_nFramesetLayout!=0 && g_nFramesetLayout!=1) || TotalDisplayPages()!=2)
  1567. {
  1568. return false;
  1569. }
  1570. var printerHeight = Printer.pageHeight / 100;
  1571. printerHeight -= g_nMarginTop;
  1572. printerHeight -= g_nMarginBottom;
  1573. if(printerHeight <= 0) return false;
  1574. var oSecondRect = DisplayPageLayoutRect(2);
  1575. if(g_nScreenDPI==0) return false;
  1576. var layoutHeight = oSecondRect.scrollHeight/g_nScreenDPI;
  1577. var pageCoverage = layoutHeight * 100 / printerHeight;
  1578. return pageCoverage < 10;
  1579. }
  1580. function CalcOrphanRemovalScale()
  1581. {
  1582. var scale = 100;
  1583. var printerHeight = Printer.pageHeight / 100;
  1584. printerHeight -= g_nMarginTop;
  1585. printerHeight -= g_nMarginBottom;
  1586. if(printerHeight <= 0) return scale;
  1587. var oSecondRect = DisplayPageLayoutRect(2);
  1588. if(oSecondRect==null) return scale;
  1589. if(g_nScreenDPI==0) return false;
  1590. var totalHeight = oSecondRect.scrollHeight;
  1591. totalHeight = totalHeight / g_nScreenDPI;
  1592. totalHeight += printerHeight;
  1593. if(totalHeight <= 0) return scale;
  1594. scale = printerHeight*100/totalHeight;
  1595. scale = Math.floor(scale+0.05);
  1596. if(scale>100) scale = 100;
  1597. return scale;
  1598. }
  1599. function Close()
  1600. {
  1601. Printer.updatePageStatus(-1);
  1602. if (g_fDelayClose)
  1603. {
  1604. g_fDelayClose = false;
  1605. window.setTimeout("Close()", 120000);
  1606. return;
  1607. }
  1608. window.close();
  1609. }
  1610. function PrintAll()
  1611. {
  1612. var i;
  1613. var nFirstDoc;
  1614. if (g_nFramesLeft > 0 && Printer.framesetDocument && !Printer.frameAsShown)
  1615. {
  1616. window.setTimeout("PrintAll()", 100);
  1617. return;
  1618. }
  1619. EnsureDocuments(false);
  1620. if (Printer.copies <= 0)
  1621. {
  1622. Close();
  1623. }
  1624. else if (Printer.selectedPages && Printer.pageFrom > Printer.pageTo )
  1625. {
  1626. var L_PAGERANGE_ErrorMessage = "The 'From' value cannot be greater than the 'To' value.";
  1627. alert(L_PAGERANGE_ErrorMessage);
  1628. ;
  1629. if (!g_fPreview)
  1630. PrintNow(true);
  1631. }
  1632. else
  1633. {
  1634. g_cLeftToPrint = 1;
  1635. Printer.updatePageStatus(1);
  1636. var strSel;
  1637. if (Printer.selection)
  1638. {
  1639. strSel = "S";
  1640. }
  1641. else if (Printer.frameActive && !!g_strActiveFrame)
  1642. {
  1643. strSel = g_strActiveFrame;
  1644. }
  1645. else
  1646. {
  1647. strSel = "C";
  1648. }
  1649. PrintSentinel(strSel, true);
  1650. }
  1651. }
  1652. function PrintSentinel(strDoc, fRecursionOK)
  1653. {
  1654. if (g_fCheckAutoFit || g_fCheckOrphan || !g_aDocTree[strDoc] || !g_aDocTree[strDoc].ReadyToPrint())
  1655. {
  1656. window.setTimeout("PrintSentinel('" + strDoc + "'," + fRecursionOK + ");", 500);
  1657. return;
  1658. }
  1659. g_aDocTree[strDoc].Print(fRecursionOK);
  1660. }
  1661. function PrintDocumentComplete()
  1662. {
  1663. g_cLeftToPrint--;
  1664. if (g_cLeftToPrint <= 0)
  1665. {
  1666. Close();
  1667. }
  1668. }
  1669. function PrintNow(fWithPrompt)
  1670. {
  1671. if (!g_aDocTree["C"] ||
  1672. !g_aDocTree["C"]._aaRect[1][0] ||
  1673. !g_aDocTree["C"]._aaRect[1][0].contentDocument.body)
  1674. {
  1675. window.setTimeout("PrintNow('" + fWithPrompt + "');", 100);
  1676. return;
  1677. }
  1678. var oDoc = g_aDocTree["C"]._aaRect[1][0].contentDocument;
  1679. var fConfirmed;
  1680. var fFramesetDocument = (oDoc.body.tagName.toUpperCase() == "FRAMESET");
  1681. var fActiveFrame = (oDoc.getElementsByTagName("HTML").item(0).__IE_ActiveFrame != null);
  1682. Printer.framesetDocument = fFramesetDocument;
  1683. Printer.frameActiveEnabled = fActiveFrame;
  1684. if (g_fPreview)
  1685. {
  1686. Printer.frameActive = (g_nFramesetLayout == 1 || g_nFramesetLayout == 3);
  1687. Printer.frameAsShown = (g_nFramesetLayout == 0);
  1688. Printer.currentPageAvail = true;
  1689. }
  1690. else
  1691. {
  1692. Printer.frameActive = fActiveFrame;
  1693. Printer.frameAsShown = false;
  1694. Printer.currentPageAvail = false;
  1695. }
  1696. Printer.selectionEnabled = !!(dialogArguments.__IE_ContentSelectionUrl);
  1697. Printer.selection = Printer.selectionEnabled && (g_nFramesetLayout == 3);
  1698. fConfirmed = (eval(fWithPrompt)) ? Printer.showPrintDialog() : Printer.ensurePrintDialogDefaults();
  1699. if (fConfirmed)
  1700. {
  1701. if (Printer.selection && dialogArguments.__IE_ContentSelectionUrl && g_aDocTree["S"]==null)
  1702. {
  1703. CreateDocument(dialogArguments.__IE_ContentSelectionUrl, "S", true);
  1704. }
  1705. Printer.usePrinterCopyCollate =(Printer.deviceSupports("copies") >= Printer.copies &&
  1706. (!Printer.collate || Printer.deviceSupports("collate")) );
  1707. PrintAll();
  1708. }
  1709. else
  1710. {
  1711. if (!g_fPreview)
  1712. {
  1713. Close();
  1714. }
  1715. else
  1716. {
  1717. Printer.tableoflinks = false;
  1718. }
  1719. }
  1720. }
  1721. function CPrintDoc_ReadyToPrint()
  1722. {
  1723. if(g_fCheckAutoFit || g_fCheckOrphan) return false;
  1724. return (this._nStatus == 4 && this._aaRect[1][0].contentDocument.readyState == "complete");
  1725. }
  1726. function CPrintDoc_Print(fRecursionOK)
  1727. {
  1728. if (!this.ReadyToPrint())
  1729. {
  1730. HandleError("Printing when not ready!", document.URL, "CPrintDoc::Print");
  1731. return;
  1732. }
  1733. var nCount = (Printer.usePrinterCopyCollate) ? 1 : Printer.copies;
  1734. var nFrom;
  1735. var nTo;
  1736. ;
  1737. if (fRecursionOK)
  1738. {
  1739. var fFrameset = (this._aaRect[1][0].contentDocument.body.tagName.toUpperCase() == "FRAMESET");
  1740. if (Printer.frameActive)
  1741. {
  1742. var n = parseInt(this._aaRect[1][0].contentDocument.getElementsByTagName("HTML").item(0).__IE_ActiveFrame);
  1743. if (n >= 0)
  1744. {
  1745. var oTargetFrame = (fFrameset)
  1746. ? this._aaRect[1][0].contentDocument.getElementsByTagName("FRAME").item(n)
  1747. : this._aaRect[1][0].contentDocument.getElementsByTagName("IFRAME").item(n);
  1748. if (IsPersistedDoc() &&
  1749. (oTargetFrame.src == "res://SHDOCVW.DLL/printnof.htm" ||
  1750. oTargetFrame.src == "about:blank"))
  1751. {
  1752. Printer.printNonNativeFrames(this._aaRect[1][0].contentDocument, true);
  1753. }
  1754. else
  1755. {
  1756. this.CreateSubDocument(oTargetFrame.src, true);
  1757. this.PrintAllSubDocuments(true);
  1758. }
  1759. PrintDocumentComplete();
  1760. return;
  1761. }
  1762. }
  1763. if (fFrameset)
  1764. {
  1765. if (!Printer.frameAsShown)
  1766. {
  1767. this.PrintAllSubDocuments(true);
  1768. if (IsPersistedDoc())
  1769. {
  1770. Printer.printNonNativeFrames(this._aaRect[1][0].contentDocument, false);
  1771. }
  1772. PrintDocumentComplete();
  1773. return;
  1774. }
  1775. else
  1776. {
  1777. Printer.printNonNativeFrames(this._aaRect[1][0].contentDocument, false);
  1778. }
  1779. }
  1780. else
  1781. {
  1782. if (Printer.allLinkedDocuments)
  1783. {
  1784. this.BuildAllLinkedDocuments();
  1785. this.PrintAllSubDocuments(false);
  1786. }
  1787. }
  1788. }
  1789. if (Printer.printNonNative(this._aaRect[1][0].contentDocument) )
  1790. {
  1791. g_fDelayClose = !g_fPreview;
  1792. PrintDocumentComplete();
  1793. return;
  1794. }
  1795. if (Printer.selectedPages)
  1796. {
  1797. nFrom = Printer.pageFrom;
  1798. nTo = Printer.pageTo;
  1799. if (nFrom < 1)
  1800. {
  1801. nFrom = 1;
  1802. }
  1803. if (nTo > this.Pages())
  1804. {
  1805. nTo = this.Pages();
  1806. }
  1807. }
  1808. else if ( Printer.currentPage
  1809. && this._strDoc == DisplayDocument())
  1810. {
  1811. nFrom = (this.Pages() >= g_nDispPage) ? g_nDispPage : this.Pages();
  1812. nTo = nFrom;
  1813. }
  1814. else
  1815. {
  1816. nFrom = 1;
  1817. nTo = this.Pages();
  1818. }
  1819. if (nTo < nFrom)
  1820. {
  1821. PrintDocumentComplete();
  1822. return;
  1823. }
  1824. ;
  1825. ;
  1826. ;
  1827. if (Printer.startDoc(this._aaRect[1][0].contentDocument.URL))
  1828. {
  1829. if (Printer.collate)
  1830. {
  1831. var fExtraPage = (Printer.duplex && ((nFrom - nTo) % 2 == 0));
  1832. var j;
  1833. for (j = 0; j < nCount; j++)
  1834. {
  1835. for (i = nFrom; i <= nTo; i++)
  1836. {
  1837. Printer.printPage(this.Page(i).children[0]);
  1838. }
  1839. if (fExtraPage)
  1840. {
  1841. Printer.printBlankPage();
  1842. }
  1843. }
  1844. }
  1845. else
  1846. {
  1847. var fDuplex = Printer.duplex;
  1848. for (i = nFrom; i <= nTo; i++)
  1849. {
  1850. for (j = 0; j < nCount; j++)
  1851. {
  1852. Printer.printPage(this.Page(i).children[0]);
  1853. if (fDuplex)
  1854. {
  1855. if (i < nTo)
  1856. {
  1857. Printer.printPage(this.Page(i+1));
  1858. }
  1859. else
  1860. {
  1861. Printer.printBlankPage();
  1862. }
  1863. }
  1864. }
  1865. if (fDuplex)
  1866. {
  1867. i++;
  1868. }
  1869. }
  1870. }
  1871. Printer.stopDoc();
  1872. }
  1873. PrintDocumentComplete();
  1874. }
  1875. function CPrintDoc_RectComplete(fOverflow, strElement)
  1876. {
  1877. var nStatus = parseInt(strElement.substr(5,1));
  1878. var nPage = parseInt(strElement.substr(strElement.lastIndexOf("p") + 1));
  1879. ;
  1880. ;
  1881. if (nStatus > this._nStatus)
  1882. {
  1883. return false;
  1884. }
  1885. if (nPage != this._acPage[nStatus] - 1 + this._anMerge[nStatus])
  1886. {
  1887. return false;
  1888. }
  1889. if (nStatus != this._nStatus)
  1890. {
  1891. if (!fOverflow)
  1892. {
  1893. return false;
  1894. }
  1895. this.StopFixupHF();
  1896. if (this._nStatus == 4)
  1897. {
  1898. g_nDocsToCalc++;
  1899. }
  1900. this._nStatus = nStatus;
  1901. }
  1902. if (fOverflow)
  1903. {
  1904. this.AddPage();
  1905. }
  1906. else
  1907. {
  1908. switch (this._nStatus)
  1909. {
  1910. case 0:
  1911. this._nStatus = 1;
  1912. this.AddFirstPage();
  1913. this._aaRect[this._nStatus][0].contentSrc = this._strDocURL;
  1914. break;
  1915. case 1:
  1916. this._nStatus = 2;
  1917. this.AddTableOfLinks();
  1918. break;
  1919. case 2:
  1920. this._nStatus = 3;
  1921. if (this._strDoc == DisplayDocument()) {
  1922. ChangeDispPage(g_nDispPage);
  1923. }
  1924. this.FixupHF();
  1925. break;
  1926. }
  1927. }
  1928. if (this._strDoc == DisplayDocument())
  1929. {
  1930. spanPageTotal.innerText = this.Pages();
  1931. updateNavButtons();
  1932. }
  1933. }
  1934. function CPrintDoc_AddPage()
  1935. {
  1936. var newHTM = "";
  1937. var aPage = this._aaPage[this._nStatus];
  1938. var aRect = this._aaRect[this._nStatus];
  1939. ;
  1940. (this._acPage[this._nStatus])++;
  1941. HeadFoot.URL = this.EnsureURL();
  1942. HeadFoot.title = this.EnsureTitle();
  1943. HeadFoot.pageTotal = this.Pages();
  1944. HeadFoot.page = HeadFoot.pageTotal;
  1945. if (this._acPage[this._nStatus] <= aPage.length)
  1946. {
  1947. var oPage = aPage[this._acPage[this._nStatus] - 1];
  1948. oPage.children("header").innerHTML = HeadFoot.HtmlHead;
  1949. oPage.children("footer").innerHTML = HeadFoot.HtmlFoot;
  1950. }
  1951. else
  1952. {
  1953. newHTM = "<DIV class=divPage><IE:DeviceRect media=\"print\" class=page id=mDiv" + this._nStatus + this._strDoc + "p" + aPage.length + ">";
  1954. newHTM += "<IE:LAYOUTRECT id=mRect" + this._nStatus + this._strDoc + "p" + aRect.length;
  1955. newHTM += " class=mRect nextRect=mRect" + this._nStatus + this._strDoc + "p" + (aRect.length + 1);
  1956. newHTM += " onlayoutcomplete=\"OnRectComplete('" + this._strDoc + "', " + g_ObsoleteBar + ")\"";
  1957. newHTM += " tabindex=-1 onbeforefocusenter='event.returnValue=false;' ";
  1958. newHTM += " />";
  1959. newHTM += "<DIV class=divHead id=header>";
  1960. newHTM += HeadFoot.HtmlHead;
  1961. newHTM += "</DIV><DIV class=divFoot id=footer>";
  1962. newHTM += HeadFoot.HtmlFoot;
  1963. newHTM += "</DIV>";
  1964. newHTM += "</IE:DeviceRect></DIV>";
  1965. MasterContainer.insertAdjacentHTML("beforeEnd", newHTM);
  1966. aPage[aPage.length] = eval("document.all.mDiv" + this._nStatus + this._strDoc + "p" + aPage.length);
  1967. aRect[aRect.length] = eval("document.all.mRect" + this._nStatus + this._strDoc + "p" + aRect.length);
  1968. }
  1969. }
  1970. function CPrintDoc_AddFirstPage()
  1971. {
  1972. this._acPage[this._nStatus] = 0;
  1973. if (this._anMerge[this._nStatus] == 0)
  1974. {
  1975. this.AddPage();
  1976. }
  1977. else
  1978. {
  1979. var aRect = this._aaRect[this._nStatus];
  1980. var oPage = this._aaPage[this._nStatus - 1][this._acPage[this._nStatus - 1] - 1];
  1981. var oTop = this._aaRect[this._nStatus - 1][this._acPage[this._nStatus - 1] + this._anMerge[this._nStatus - 1] - 1];
  1982. var nTop = oTop.offsetTop + oTop.scrollHeight;
  1983. var nHeight = oTop.clientHeight - oTop.scrollHeight;
  1984. ;
  1985. ;
  1986. if (aRect.length > 0)
  1987. {
  1988. var oNode = aRect[0];
  1989. oNode.style.marginTop = nTop + "px";
  1990. oNode.style.pixelHeight = nHeight;
  1991. if (oNode.parentElement != oPage)
  1992. {
  1993. oPage.insertBefore(oNode);
  1994. }
  1995. }
  1996. else
  1997. {
  1998. var newHTM;
  1999. var oNode;
  2000. newHTM = "<IE:LAYOUTRECT id=mRect" + this._nStatus + this._strDoc + "p0";
  2001. newHTM += " class=mRect nextRect=mRect" + this._nStatus + this._strDoc + "p1";
  2002. newHTM += " onlayoutcomplete=\"OnRectComplete('" + this._strDoc + "', " + g_ObsoleteBar + ")\"";
  2003. newHTM += " tabindex=-1 onbeforefocus='event.returnValue=false;'";
  2004. newHTM += " />";
  2005. oPage.insertAdjacentHTML("beforeEnd", newHTM);
  2006. oNode = eval("document.all.mRect" + this._nStatus + this._strDoc + "p0");
  2007. aRect[0] = oNode;
  2008. oNode.style.marginTop = nTop + "px";
  2009. oNode.style.height = nHeight + "px";
  2010. }
  2011. }
  2012. }
  2013. function CPrintDoc_InitDocument(fUseStreamHeader)
  2014. {
  2015. var fReallyUseStreamHeader = (fUseStreamHeader && (dialogArguments.__IE_OutlookHeader != null));
  2016. this._anMerge[1] = (fReallyUseStreamHeader) ? 1 : 0;
  2017. this._nStatus = ((fReallyUseStreamHeader) ? 0 : 1);
  2018. this.AddFirstPage();
  2019. this._aaRect[this._nStatus][0].contentSrc = (fReallyUseStreamHeader)
  2020. ? dialogArguments.__IE_OutlookHeader
  2021. : this._strDocURL;
  2022. }
  2023. function CPrintDoc_PrintAllSubDocuments(fRecursionOK)
  2024. {
  2025. if (this._aDoc)
  2026. {
  2027. var nDocs = this._aDoc.length;
  2028. var i;
  2029. g_cLeftToPrint += nDocs;
  2030. for (i = 0; i < nDocs; i++)
  2031. {
  2032. PrintSentinel(this._aDoc[i]._strDoc, fRecursionOK);
  2033. }
  2034. }
  2035. }
  2036. function CPrintDoc_BuildAllLinkedDocuments()
  2037. {
  2038. var strURL = this._aaRect[1][0].contentDocument.URL;
  2039. var aLinks = this._aaRect[1][0].contentDocument.links;
  2040. var nLinks = aLinks.length;
  2041. var i;
  2042. var j;
  2043. var strLink;
  2044. for (i = 0; i < nLinks; i++)
  2045. {
  2046. strLink = aLinks[i].href;
  2047. if (strURL == strLink || UnprintableURL(strLink))
  2048. {
  2049. continue;
  2050. }
  2051. for (j = 0; j < i; j++)
  2052. {
  2053. if (strLink == aLinks[j].href)
  2054. {
  2055. break;
  2056. }
  2057. }
  2058. if (j < i)
  2059. {
  2060. continue;
  2061. }
  2062. this.CreateSubDocument(strLink, false);
  2063. }
  2064. }
  2065. function OnBuildAllFrames(strDoc)
  2066. {
  2067. if (!g_aDocTree[strDoc] ||
  2068. !g_aDocTree[strDoc]._aaRect[1][0] ||
  2069. !g_aDocTree[strDoc]._aaRect[1][0].contentDocument.body)
  2070. {
  2071. window.setTimeout("OnBuildAllFrames('" + strDoc + "');", 100);
  2072. return;
  2073. }
  2074. g_aDocTree[strDoc].BuildAllFrames();
  2075. }
  2076. function IsPersistedDoc()
  2077. {
  2078. return (!!g_aDocTree["C"]._aaRect[1][0].contentDocument.getElementsByTagName("HTML")[0].__IE_DisplayURL);
  2079. }
  2080. function CPrintDoc_BuildAllFrames()
  2081. {
  2082. var aFrames = this._aaRect[1][0].contentDocument.getElementsByTagName("FRAME");
  2083. var nFrames = aFrames.length;
  2084. var nActive = parseInt(this._aaRect[1][0].contentDocument.getElementsByTagName("HTML").item(0).__IE_ActiveFrame);
  2085. var i;
  2086. var strSrc;
  2087. var strDoc;
  2088. if (nFrames > 0)
  2089. {
  2090. this._fFrameset = true;
  2091. }
  2092. for (i = 0; i < nFrames; i++)
  2093. {
  2094. strSrc = aFrames[i].src;
  2095. if (strSrc == "res://SHDOCVW.DLL/printnof.htm")
  2096. {
  2097. continue;
  2098. }
  2099. strDoc = this.CreateSubDocument(strSrc, true);
  2100. if (i == nActive)
  2101. {
  2102. g_strActiveFrame = strDoc;
  2103. }
  2104. g_nFramesLeft++;
  2105. OnBuildAllFrames(strDoc);
  2106. }
  2107. g_nFramesLeft--;
  2108. if (g_nFramesLeft <= 0)
  2109. {
  2110. BuildAllFramesComplete();
  2111. }
  2112. }
  2113. function CPrintDoc_CreateSubDocument( docURL, fUseStreamHeader )
  2114. {
  2115. if (!this._aDoc)
  2116. this._aDoc = new Array();
  2117. var nDoc = this._aDoc.length;
  2118. var strDoc = this._strDoc + "_" + nDoc;
  2119. CreateDocument(docURL, strDoc, fUseStreamHeader);
  2120. this._aDoc[nDoc] = g_aDocTree[strDoc];
  2121. return (strDoc);
  2122. }
  2123. function CPrintDoc_AddTableOfLinks()
  2124. {
  2125. ;
  2126. if (!g_fTableOfLinks)
  2127. {
  2128. this._nStatus = 3;
  2129. ChangeDispPage(g_nDispPage);
  2130. this.FixupHF();
  2131. }
  2132. else
  2133. {
  2134. var oTableOfLinks = BuildTableOfLinks(this._aaRect[1][0].contentDocument);
  2135. if (oTableOfLinks != null)
  2136. {
  2137. var oBody = oTableOfLinks.body;
  2138. this.AddFirstPage()
  2139. this._aaRect[this._nStatus][0].contentSrc = oBody.document;
  2140. }
  2141. else
  2142. {
  2143. this._nStatus = 3;
  2144. ChangeDispPage(g_nDispPage);
  2145. this.FixupHF();
  2146. }
  2147. }
  2148. }
  2149. function OnTickHF( strDoc )
  2150. {
  2151. if (!g_aDocTree[strDoc])
  2152. {
  2153. HandleError("Document " + strDoc + " does not exist.", document.URL, "OnRectComplete");
  2154. return;
  2155. }
  2156. g_aDocTree[strDoc].TickHF();
  2157. }
  2158. function CPrintDoc_TickHF()
  2159. {
  2160. var i, j;
  2161. var iTo, jTo;
  2162. var aTok;
  2163. var oTok;
  2164. var nStartPage = this._nNextHF;
  2165. var cPages = this.Pages();
  2166. iTo = nStartPage + 2;
  2167. if (iTo > cPages)
  2168. {
  2169. iTo = cPages;
  2170. }
  2171. for (i = nStartPage; i <= iTo; i++)
  2172. {
  2173. aTok = this.Page(i).children[0].getElementsByTagName("SPAN");
  2174. for (j=0, jTo = aTok.length; j < jTo; j++)
  2175. {
  2176. oTok = aTok[j];
  2177. if (oTok.className == "hfPageTotal")
  2178. {
  2179. oTok.innerText = cPages;
  2180. }
  2181. else if (oTok.className == "hfUrl" && oTok.innerText == "")
  2182. {
  2183. oTok.innerText = this.EnsureURL();
  2184. }
  2185. else if (oTok.className == "hfTitle" && oTok.innerText == "")
  2186. {
  2187. oTok.innerText = this.EnsureTitle();
  2188. }
  2189. }
  2190. }
  2191. this._nNextHF = i;
  2192. if (iTo == cPages)
  2193. {
  2194. this._nStatus = 4;
  2195. if (--g_nDocsToCalc == 0)
  2196. {
  2197. window.setTimeout("CalcDocsComplete()", 1);
  2198. }
  2199. }
  2200. else
  2201. {
  2202. this._nTimerHF = window.setTimeout("OnTickHF('" + this._strDoc + "');", 250);
  2203. }
  2204. }
  2205. function CPrintDoc_FixupHF()
  2206. {
  2207. ;
  2208. this.TickHF();
  2209. }
  2210. function CPrintDoc_Pages()
  2211. {
  2212. var i;
  2213. var c;
  2214. for (i = 0, c = 0; i < 3; i++)
  2215. {
  2216. c += this._acPage[i];
  2217. }
  2218. return c;
  2219. }
  2220. function CPrintDoc_Page(nPage)
  2221. {
  2222. var i;
  2223. var n = nPage;
  2224. if (n <= 0)
  2225. return null;
  2226. for (i = 0; i < 3; i++)
  2227. {
  2228. if (n <= this._acPage[i])
  2229. {
  2230. return this._aaPage[i][n - 1].parentElement;
  2231. }
  2232. n -= this._acPage[i];
  2233. }
  2234. return null;
  2235. }
  2236. function CPrintDoc_EnsureURL()
  2237. {
  2238. if (this._strURL == null)
  2239. {
  2240. if (this._aaRect[1][0] && this._aaRect[1][0].contentDocument)
  2241. {
  2242. this._strURL = this._aaRect[1][0].contentDocument.URL;
  2243. }
  2244. if (this._strURL == null)
  2245. {
  2246. return "";
  2247. }
  2248. }
  2249. return this._strURL;
  2250. }
  2251. function CPrintDoc_EnsureTitle()
  2252. {
  2253. if (this._strTitle == null)
  2254. {
  2255. if (this._aaRect[1][0] && this._aaRect[1][0].contentDocument)
  2256. {
  2257. this._strTitle = this._aaRect[1][0].contentDocument.title;
  2258. }
  2259. if (this._strTitle == null)
  2260. {
  2261. return "";
  2262. }
  2263. }
  2264. return this._strTitle;
  2265. }
  2266. function CPrintDoc_ResetDocument()
  2267. {
  2268. var i;
  2269. for (i=0; i<3; i++)
  2270. {
  2271. this._aaRect[i] = new Array();
  2272. this._aaPage[i] = new Array();
  2273. this._acPage[i] = 0;
  2274. this._anMerge[i] = 0;
  2275. }
  2276. MasterContainer.innerHTML = "<div id=\"EmptyPage\" class=\"divPage\" style=\"position:absolute; left:0px; top:0px; display:none;\"><div class=\"page\"> </div></div>";
  2277. this.StopFixupHF();
  2278. }
  2279. function CPrintDoc_ResetTableOfLinks()
  2280. {
  2281. if (this._nStatus <= 2)
  2282. return;
  2283. this.StopFixupHF();
  2284. this._nStatus = 2;
  2285. this.AddTableOfLinks();
  2286. }
  2287. function CPrintDoc_StopFixupHF()
  2288. {
  2289. if (this._nTimerHF != -1)
  2290. window.clearTimeout(this._nTimerHF);
  2291. this._nTimerHF = -1;
  2292. this._nNextHF = 1;
  2293. }
  2294. function CPrintDoc(nDocNum, strDocURL)
  2295. {
  2296. var i;
  2297. this._aDoc = null;
  2298. this._strDoc = nDocNum;
  2299. this._strDocURL = strDocURL;
  2300. this._nStatus = 0;
  2301. this._aaPage = new Array(3);
  2302. this._aaRect = new Array(3);
  2303. this._acPage = new Array(3);
  2304. this._anMerge = new Array(3);
  2305. for (i=0; i<3; i++)
  2306. {
  2307. this._aaPage[i] = new Array();
  2308. this._aaRect[i] = new Array();
  2309. this._acPage[i] = 0;
  2310. this._anMerge[i]= 0;
  2311. }
  2312. this._nNextHF = 1;
  2313. this._nTimerHF = -1;
  2314. this._strURL = null;
  2315. this._strTitle = null;
  2316. this._fFrameset = false;
  2317. this._nStartingPage = 0;
  2318. }
  2319. CPrintDoc.prototype.RectComplete = CPrintDoc_RectComplete;
  2320. CPrintDoc.prototype.AddPage = CPrintDoc_AddPage;
  2321. CPrintDoc.prototype.AddFirstPage = CPrintDoc_AddFirstPage;
  2322. CPrintDoc.prototype.AddTableOfLinks = CPrintDoc_AddTableOfLinks;
  2323. CPrintDoc.prototype.FixupHF = CPrintDoc_FixupHF;
  2324. CPrintDoc.prototype.StopFixupHF = CPrintDoc_StopFixupHF;
  2325. CPrintDoc.prototype.TickHF = CPrintDoc_TickHF;
  2326. CPrintDoc.prototype.InitDocument = CPrintDoc_InitDocument;
  2327. CPrintDoc.prototype.ResetDocument = CPrintDoc_ResetDocument;
  2328. CPrintDoc.prototype.ResetTableOfLinks = CPrintDoc_ResetTableOfLinks;
  2329. CPrintDoc.prototype.BuildAllLinkedDocuments = CPrintDoc_BuildAllLinkedDocuments;
  2330. CPrintDoc.prototype.BuildAllFrames = CPrintDoc_BuildAllFrames;
  2331. CPrintDoc.prototype.CreateSubDocument = CPrintDoc_CreateSubDocument;
  2332. CPrintDoc.prototype.Print = CPrintDoc_Print;
  2333. CPrintDoc.prototype.PrintAllSubDocuments = CPrintDoc_PrintAllSubDocuments;
  2334. CPrintDoc.prototype.ReadyToPrint = CPrintDoc_ReadyToPrint;
  2335. CPrintDoc.prototype.Page = CPrintDoc_Page;
  2336. CPrintDoc.prototype.Pages = CPrintDoc_Pages;
  2337. CPrintDoc.prototype.EnsureURL = CPrintDoc_EnsureURL;
  2338. CPrintDoc.prototype.EnsureTitle = CPrintDoc_EnsureTitle;
  2339.