1 19 20 package jxl; 21 22 import common.Assert; 23 24 import jxl.format.PageOrientation; 25 import jxl.format.PaperSize; 26 27 32 public final class SheetSettings 33 { 34 37 private PageOrientation orientation; 38 39 42 private PaperSize paperSize; 43 44 47 private boolean sheetProtected; 48 49 52 private boolean hidden; 53 54 57 private boolean selected; 58 59 62 private HeaderFooter header; 63 64 67 private double headerMargin; 68 69 72 private HeaderFooter footer; 73 74 77 private double footerMargin; 78 79 82 private int scaleFactor; 83 84 88 private int zoomFactor; 89 90 93 private int pageStart; 94 95 98 private int fitWidth; 99 100 103 private int fitHeight; 104 105 108 private int horizontalPrintResolution; 109 110 113 private int verticalPrintResolution; 114 115 118 private double leftMargin; 119 120 123 private double rightMargin; 124 125 128 private double topMargin; 129 130 133 private double bottomMargin; 134 135 140 private boolean fitToPages; 141 142 145 private boolean showGridLines; 146 147 150 private boolean printGridLines; 151 152 155 private boolean printHeaders; 156 157 160 private boolean displayZeroValues; 161 162 165 private String password; 166 167 170 private int passwordHash; 171 172 175 private int defaultColumnWidth; 176 177 180 private int defaultRowHeight; 181 182 185 private int horizontalFreeze; 186 187 190 private int verticalFreeze; 191 192 195 private int copies; 196 197 private static final PageOrientation defaultOrientation = 201 PageOrientation.PORTRAIT; 202 private static final PaperSize defaultPaperSize = PaperSize.A4; 203 private static final double defaultHeaderMargin = 0.5; 204 private static final double defaultFooterMargin = 0.5; 205 private static final int defaultPrintResolution = 0x12c; 206 private static final double defaultWidthMargin = 0.75; 207 private static final double defaultHeightMargin = 1; 208 209 private static final int defaultDefaultColumnWidth = 8; 210 private static final int defaultZoomFactor = 100; 211 212 216 public static final int DEFAULT_DEFAULT_ROW_HEIGHT = 0xff; 217 218 221 public SheetSettings() 222 { 223 orientation = defaultOrientation; 224 paperSize = defaultPaperSize; 225 sheetProtected = false; 226 hidden = false; 227 selected = false; 228 headerMargin = defaultHeaderMargin; 229 footerMargin = defaultFooterMargin; 230 horizontalPrintResolution = defaultPrintResolution; 231 verticalPrintResolution = defaultPrintResolution; 232 leftMargin = defaultWidthMargin; 233 rightMargin = defaultWidthMargin; 234 topMargin = defaultHeightMargin; 235 bottomMargin = defaultHeightMargin; 236 fitToPages = false; 237 showGridLines = true; 238 printGridLines = false; 239 printHeaders = false; 240 displayZeroValues = true; 241 defaultColumnWidth = defaultDefaultColumnWidth; 242 defaultRowHeight = DEFAULT_DEFAULT_ROW_HEIGHT; 243 zoomFactor = defaultZoomFactor; 244 horizontalFreeze = 0; 245 verticalFreeze = 0; 246 copies = 1; 247 header = new HeaderFooter(); 248 footer = new HeaderFooter(); 249 } 250 251 255 public SheetSettings(SheetSettings copy) 256 { 257 Assert.verify(copy != null); 258 259 orientation = copy.orientation; 260 paperSize = copy.paperSize; 261 sheetProtected = copy.sheetProtected; 262 hidden = copy.hidden; 263 selected = false; headerMargin = copy.headerMargin; 265 footerMargin = copy.footerMargin; 266 scaleFactor = copy.scaleFactor; 267 pageStart = copy.pageStart; 268 fitWidth = copy.fitWidth; 269 fitHeight = copy.fitHeight; 270 horizontalPrintResolution = copy.horizontalPrintResolution; 271 verticalPrintResolution = copy.verticalPrintResolution; 272 leftMargin = copy.leftMargin; 273 rightMargin = copy.rightMargin; 274 topMargin = copy.topMargin; 275 bottomMargin = copy.bottomMargin; 276 fitToPages = copy.fitToPages; 277 password = copy.password; 278 passwordHash = copy.passwordHash; 279 defaultColumnWidth = copy.defaultColumnWidth; 280 defaultRowHeight = copy.defaultRowHeight; 281 zoomFactor = copy.zoomFactor; 282 showGridLines = copy.showGridLines; 283 displayZeroValues = copy.displayZeroValues; 284 horizontalFreeze = copy.horizontalFreeze; 285 verticalFreeze = copy.verticalFreeze; 286 copies = copy.copies; 287 header = new HeaderFooter(copy.header); 288 footer = new HeaderFooter(copy.footer); 289 } 290 291 296 public void setOrientation(PageOrientation po) 297 { 298 orientation = po; 299 } 300 301 306 public PageOrientation getOrientation() 307 { 308 return orientation; 309 } 310 311 316 public void setPaperSize(PaperSize ps) 317 { 318 paperSize = ps; 319 } 320 321 326 public PaperSize getPaperSize() 327 { 328 return paperSize; 329 } 330 331 336 public boolean isProtected() 337 { 338 return sheetProtected; 339 } 340 341 346 public void setProtected(boolean p) 347 { 348 sheetProtected = p; 349 } 350 351 356 public void setHeaderMargin(double d) 357 { 358 headerMargin = d; 359 } 360 361 366 public double getHeaderMargin() 367 { 368 return headerMargin; 369 } 370 371 376 public void setFooterMargin(double d) 377 { 378 footerMargin = d; 379 } 380 381 386 public double getFooterMargin() 387 { 388 return footerMargin; 389 } 390 391 396 public void setHidden(boolean h) 397 { 398 hidden = h; 399 } 400 401 406 public boolean isHidden() 407 { 408 return hidden; 409 } 410 411 416 public void setSelected() 417 { 418 setSelected(true); 419 } 420 421 426 public void setSelected(boolean s) 427 { 428 selected = s; 429 } 430 431 436 public boolean isSelected() 437 { 438 return selected; 439 } 440 441 448 public void setScaleFactor(int sf) 449 { 450 scaleFactor = sf; 451 fitToPages = false; 452 } 453 454 459 public int getScaleFactor() 460 { 461 return scaleFactor; 462 } 463 464 469 public void setPageStart(int ps) 470 { 471 pageStart = ps; 472 } 473 474 479 public int getPageStart() 480 { 481 return pageStart; 482 } 483 484 490 public void setFitWidth(int fw) 491 { 492 fitWidth = fw; 493 fitToPages = true; 494 } 495 496 501 public int getFitWidth() 502 { 503 return fitWidth; 504 } 505 506 511 public void setFitHeight(int fh) 512 { 513 fitHeight = fh; 514 fitToPages = true; 515 } 516 517 522 public int getFitHeight() 523 { 524 return fitHeight; 525 } 526 527 532 public void setHorizontalPrintResolution(int hpw) 533 { 534 horizontalPrintResolution = hpw; 535 } 536 537 542 public int getHorizontalPrintResolution() 543 { 544 return horizontalPrintResolution; 545 } 546 547 552 public void setVerticalPrintResolution(int vpw) 553 { 554 verticalPrintResolution = vpw; 555 } 556 557 562 public int getVerticalPrintResolution() 563 { 564 return verticalPrintResolution; 565 } 566 567 572 public void setRightMargin(double m) 573 { 574 rightMargin = m; 575 } 576 577 582 public double getRightMargin() 583 { 584 return rightMargin; 585 } 586 587 592 public void setLeftMargin(double m) 593 { 594 leftMargin = m; 595 } 596 597 602 public double getLeftMargin() 603 { 604 return leftMargin; 605 } 606 607 612 public void setTopMargin(double m) 613 { 614 topMargin = m; 615 } 616 617 622 public double getTopMargin() 623 { 624 return topMargin; 625 } 626 627 632 public void setBottomMargin(double m) 633 { 634 bottomMargin = m; 635 } 636 637 642 public double getBottomMargin() 643 { 644 return bottomMargin; 645 } 646 647 652 public double getDefaultWidthMargin() 653 { 654 return defaultWidthMargin; 655 } 656 657 662 public double getDefaultHeightMargin() 663 { 664 return defaultHeightMargin; 665 } 666 667 671 public boolean getFitToPages() 672 { 673 return fitToPages; 674 } 675 676 680 public void setFitToPages(boolean b) 681 { 682 fitToPages = b; 683 } 684 685 690 public String getPassword() 691 { 692 return password; 693 } 694 695 700 public void setPassword(String s) 701 { 702 password = s; 703 } 704 705 710 public int getPasswordHash() 711 { 712 return passwordHash; 713 } 714 715 720 public void setPasswordHash(int ph) 721 { 722 passwordHash = ph; 723 } 724 725 730 public int getDefaultColumnWidth() 731 { 732 return defaultColumnWidth; 733 } 734 735 740 public void setDefaultColumnWidth(int w) 741 { 742 defaultColumnWidth = w; 743 } 744 745 750 public int getDefaultRowHeight() 751 { 752 return defaultRowHeight; 753 } 754 755 760 public void setDefaultRowHeight(int h) 761 { 762 defaultRowHeight = h; 763 } 764 765 772 public int getZoomFactor() 773 { 774 return zoomFactor; 775 } 776 777 784 public void setZoomFactor(int zf) 785 { 786 zoomFactor = zf; 787 } 788 789 794 public boolean getDisplayZeroValues() 795 { 796 return displayZeroValues; 797 } 798 799 804 public void setDisplayZeroValues(boolean b) 805 { 806 displayZeroValues = b; 807 } 808 809 814 public boolean getShowGridLines() 815 { 816 return showGridLines; 817 } 818 819 824 public void setShowGridLines(boolean b) 825 { 826 showGridLines = b; 827 } 828 829 834 public boolean getPrintGridLines() 835 { 836 return printGridLines; 837 } 838 839 844 public void setPrintGridLines(boolean b) 845 { 846 printGridLines = b; 847 } 848 849 854 public boolean getPrintHeaders() 855 { 856 return printHeaders; 857 } 858 859 864 public void setPrintHeaders(boolean b) 865 { 866 printHeaders = b; 867 } 868 869 875 public int getHorizontalFreeze() 876 { 877 return horizontalFreeze; 878 } 879 880 885 public void setHorizontalFreeze(int row) 886 { 887 horizontalFreeze = Math.max(row, 0); 888 } 889 890 896 public int getVerticalFreeze() 897 { 898 return verticalFreeze; 899 } 900 901 906 public void setVerticalFreeze(int col) 907 { 908 verticalFreeze = Math.max(col, 0); 909 } 910 911 916 public void setCopies(int c) 917 { 918 copies = c; 919 } 920 921 926 public int getCopies() 927 { 928 return copies; 929 } 930 931 936 public HeaderFooter getHeader() 937 { 938 return header; 939 } 940 941 946 public void setHeader(HeaderFooter h) 947 { 948 header = h; 949 } 950 951 956 public void setFooter(HeaderFooter f) 957 { 958 footer = f; 959 } 960 961 966 public HeaderFooter getFooter() 967 { 968 return footer; 969 } 970 } 971 | Popular Tags |