1 51 52 package org.apache.fop.mif; 53 54 57 import org.apache.fop.messaging.MessageHandler; 58 59 import java.io.*; 61 import java.util.*; 62 63 71 public class MIFDocument { 72 73 76 77 78 protected static final String mifVersion = "5.5"; 79 protected BookComponent bookComponent; 80 private Flow curFlow; private ID curIDCounter = new ID(); 83 84 public static final String MIFEncode(String val) { 85 int len = val.length(); 86 StringBuffer buf = new StringBuffer (len * 2); 87 char c; 88 89 for(int i = 0; i < len; i++) { 90 c = val.charAt(i); 91 switch(c) { 92 case '\u00e0': buf.append("\\x88 "); break; 93 case '\u00e8': buf.append("\\x8f "); break; 94 case '\u00ec': buf.append("\\x93 "); break; 95 case '\u00f2': buf.append("\\x98 "); break; 96 case '\u00f9': buf.append("\\x9d "); break; 97 case '\u00c0': buf.append("\\xcb "); break; 98 case '\u00c8': buf.append("\\xe9 "); break; 99 case '\u00cc': buf.append("\\xed "); break; 100 case '\u00d2': buf.append("\\xf1 "); break; 101 case '\u00d9': buf.append("\\xf4 "); break; 102 103 case '\u00e1': buf.append("\\x87 "); break; 104 case '\u00e9': buf.append("\\x8e "); break; 105 case '\u00ed': buf.append("\\x92 "); break; 106 case '\u00f3': buf.append("\\x97 "); break; 107 case '\u00fa': buf.append("\\x9c "); break; 108 case '\u00c1': buf.append("\\xe7 "); break; 109 case '\u00c9': buf.append("\\x83 "); break; 110 case '\u00cd': buf.append("\\xea "); break; 111 case '\u00d3': buf.append("\\xee "); break; 112 case '\u00da': buf.append("\\xf2 "); break; 113 114 case '\u00f1': buf.append("\\x96 "); break; 115 case '\u00d1': buf.append("\\x84 "); break; 116 117 case '\u00e7': buf.append("\\x8d "); break; 118 case '\u00c7': buf.append("\\x82 "); break; 119 120 case '`': buf.append("\\xd4 "); break; 121 case '\'': buf.append("\\xd5 "); break; 122 case '\u00b4': buf.append("\\xab "); break; 123 case '\u00aa': buf.append("\\xbb "); break; 124 case '\u00ba': buf.append("\\xbc "); break; 125 126 case '>': buf.append("\\>"); break; 127 default: buf.append(c); 128 } 129 } 130 return buf.toString(); 131 } 132 133 class ID { 134 135 private int idCounter = 1; 136 public int getnewID() { 137 138 return idCounter++; 139 } 140 141 } 142 143 class FontFormat { 144 145 public FontFormat() {} 146 147 } 148 149 class ParagraphFormat extends FontFormat { 150 151 public ParagraphFormat() {} 152 153 int startIndent; 154 int endIndent; 155 156 157 158 } 159 160 class Document { 161 protected int height; 162 protected int width; 163 public Document() {} 164 165 public void output(OutputStream stream) throws IOException { 166 167 String mif = "\n<Document " + "\n<DPageSize " + width / 1000f 168 + " " + height / 1000f + " >\n>"; 169 byte buf[] = mif.getBytes(); 170 171 stream.write(buf); 172 173 } 174 175 } 176 177 178 class PolyLine { 179 180 public PolyLine() {} 181 182 } 183 184 class ImportObject { 185 186 private String url; 187 private int x, y, w, h; 188 189 public ImportObject(String url, int x, int y, int w, int h) { 190 191 this.url = url; 192 this.x = x; 193 this.y = y; 194 this.w = w; 195 this.h = h; 196 197 } 198 199 200 public void output(OutputStream stream) throws IOException { 201 202 203 String path = this.url; 204 205 path = path.substring(5); 207 String result = ""; 208 int i; 209 do { 211 i = path.indexOf("/"); 212 if (i != -1) { 213 result = path.substring(0, i); 214 result += "<c\\>"; 215 result += path.substring(i + 1); 216 path = result; 217 } 218 219 } while (i != -1); 220 221 String mif = "\n<ImportObject" + "\n<ImportObFixedSize Yes>"; 222 mif += "\n\t<ImportObFileDI " + "`<c\\>" + path + "'" + " >"; 223 mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f 224 + " " + this.w / 1000f + " " + this.h / 1000f + " >"; 225 226 mif += "\n> #End ImportObj"; 227 stream.write(mif.getBytes()); 228 229 } 230 231 } 232 233 234 class Frame { 235 236 private int ID; 237 private int x, y, w, h; 238 ArrayList content = new ArrayList(); 239 public Frame(int x, int y, int w, int h) { 240 241 this.ID = curIDCounter.getnewID(); 242 this.x = x; 243 this.y = y; 244 this.w = w; 245 this.h = h; 246 247 } 248 249 public void addContent(ImportObject obj) { 250 251 content.add(obj); 252 253 } 254 255 public void output(OutputStream stream) throws IOException { 256 257 String mif = "\n<Frame" + "\n\t<ID " + this.ID + " >"; 258 mif += 259 "\n\t<Pen 15>\n\t<Fill 7>\n\t<PenWidth 1.0 >\n\t<Separation 0>\n\t<ObColor `Black'>\n\t<DashedPattern \n\t <DashedStyle Solid> \n >"; 260 261 mif += 262 "\n\t<RunaroundGap 6.0 pt>\n\t<RunaroundType None>\n\t<Angle 360.0>\n\t<Float No>\n\t<NSOffset 0.0>\n\t<BLOffset 0>\n\t<Cropped No>\n\t<FrameType Below>\n\t<AnchorAlign Center>"; 263 264 mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f 265 + " " + this.w / 1000f + " " + this.h / 1000f + " >"; 266 267 268 stream.write(mif.getBytes()); 269 270 for (int i = 0; i < content.size(); i++) { 271 ((ImportObject)content.get(i)).output(stream); 272 } 273 mif = "\n> #End Frame"; 274 stream.write(mif.getBytes()); 275 276 277 278 } 279 280 public int getID() { 281 282 return this.ID; 283 } 284 285 } 286 287 class TextRect { 288 private int rx, ry, w, h; 289 private int numCols; 290 private int curCol = 0; private int colGap = 0; 292 private int textRectID; 293 public TextRect(int numCols) { 294 295 this.numCols = numCols; 296 this.curCol = 0; 297 this.textRectID = curIDCounter.getnewID(); 298 299 } 300 301 302 public int getTextRectID() { 303 304 return textRectID; 305 306 } 307 308 309 public void setTextRectProp(int left, int top, int width, 310 int height) { 311 312 if (curCol == 0) { 313 314 316 rx = left; 317 ry = top; 318 w = width; h = height; 320 curCol++; 321 322 } else if (curCol == 1) { 323 colGap = left - rx - width; 325 w = numCols * width + (numCols - 1) * colGap; 327 curCol++; 328 329 330 } 331 332 } 333 334 335 public void output(OutputStream stream) throws IOException { 336 337 String mif = "\n<TextRect" + "\n\t<ID " + textRectID + ">" 338 + "\n\t<ShapeRect " + rx / 1000f + " " + ry / 1000f 339 + " " + w / 1000f + " " + h / 1000f + ">"; 340 341 if (numCols > 1) { 342 mif += "\n<TRNumColumns " + numCols + ">"; 343 mif += "\n<TRColumnGap " + colGap / 1000f + ">"; 344 } 345 346 mif += "\n> #End TextRect"; 347 byte buf[] = mif.getBytes(); 348 stream.write(buf); 349 } 350 351 } 352 353 class Page { 354 private String pageType; 355 private String pageTag; 356 private String pageBackground; 357 private ArrayList textRects; 358 public Page(String pageType, String pageTag, String pageBackground) { 359 360 this.pageType = pageType; 361 this.pageTag = pageTag; 362 this.pageBackground = pageBackground; 363 this.textRects = new ArrayList(); 364 } 365 366 public Page() { 367 368 this.pageType = "BodyPage"; 369 this.pageBackground = "Default"; 370 this.textRects = new ArrayList(); 371 372 } 373 374 375 public void addTextRect(int numCols) { 376 377 TextRect textRect = new TextRect(numCols); 378 this.textRects.add(textRect); 379 } 380 381 public TextRect curTextRect() { 382 383 if (textRects.isEmpty()) { 385 TextRect textRect = new TextRect(1); 386 this.textRects.add(textRect); 387 } 388 return (TextRect)textRects.get(textRects.size() - 1); 389 } 390 391 392 393 public void output(OutputStream stream) throws IOException { 394 String mif = "\n<Page" + "\n\t<PageType " + pageType + ">" 395 + "\n\t<PageBackground " + "`" + pageBackground 396 + "'" + ">"; 397 byte buf[] = mif.getBytes(); 398 stream.write(buf); 399 for (int i = 0; i < textRects.size(); i++) { 400 ((TextRect)textRects.get(i)).output(stream); 401 } 402 mif = "\n> #End Page\n"; 403 stream.write(mif.getBytes()); 404 } 405 } 406 407 abstract class Flow { 408 409 public Flow() {} 410 411 public abstract Para curPara(); 412 public abstract void startPara(); 413 } 414 415 416 class TextFlow extends Flow { 417 418 ArrayList paras; 419 private int ID; 422 public TextFlow() { 423 424 425 428 this.ID = 429 ((bookComponent.curPage()).curTextRect()).getTextRectID(); 430 this.paras = new ArrayList(); 431 432 } 433 434 435 public int getTextRectID() { 436 437 return ID; 438 439 } 440 441 public Para curPara() { 442 return (Para)paras.get(paras.size() - 1); 443 } 444 445 public void startPara() { 446 this.paras.add(new Para(ID)); 447 } 448 449 public void output(OutputStream stream) throws IOException { 450 String mif = "\n<TextFlow"; 451 stream.write(mif.getBytes()); 452 for (int i = 0; i < paras.size(); i++) { 453 ((Para)paras.get(i)).output(stream); 454 } 455 mif = "\n> #End TextFlow"; 456 stream.write(mif.getBytes()); 457 } 458 } 459 460 461 class Para { 462 463 ArrayList paraLines; 464 int ID; ParagraphFormat pgf = 466 null; public Para() { 468 469 this.ID = 0; 470 this.paraLines = new ArrayList(); 471 } 472 473 474 public Para(int ID) { 475 476 this.ID = ID; 477 this.paraLines = new ArrayList(); 478 479 } 480 481 public ParaLine curParaLine() { 482 if (paraLines.isEmpty()) { 483 return null; 484 } else { 485 return (ParaLine)paraLines.get(paraLines.size() - 1); 486 } 487 } 488 489 void startParaLine() { 490 491 this.paraLines.add(new ParaLine(ID)); 492 493 } 494 495 496 public void setBlockProp(int startIndent, int endIndent) { 497 498 pgf = new ParagraphFormat(); 499 pgf.startIndent = startIndent; 500 pgf.endIndent = endIndent; 501 502 503 } 504 505 506 public void output(OutputStream stream) throws IOException { 507 508 String mif = "\n<Para"; 509 511 if (pgf != null) { 512 mif += "\n<Pgf"; 513 mif += "\n<PgfTag `Body'>"; 514 mif += "\n<PgfLIndent " + pgf.startIndent / 1000f + ">"; 515 mif += "\n<PgfRIndent " + pgf.endIndent / 1000f + ">"; 516 mif += "\n>"; 517 } 518 stream.write(mif.getBytes()); 519 for (int i = 0; i < paraLines.size(); i++) { 520 ((ParaLine)paraLines.get(i)).output(stream); 521 } 522 mif = "\n> #End ParaLine"; 523 stream.write(mif.getBytes()); 524 } 525 526 } 527 528 class ParaLine { 529 ArrayList content; 530 int textRectID; 531 String tableID; 532 String aFrameID; 533 public ParaLine(int textRectID) { 534 535 this.textRectID = textRectID; 536 this.content = new ArrayList(); 537 538 } 539 540 public ParaLine() { 541 542 this.textRectID = 0; this.content = new ArrayList(); 544 } 545 546 public void addContent(Object obj) { 547 548 this.content.add(obj); 549 550 } 551 552 public void output(OutputStream stream) throws IOException { 553 554 String mif = "\n<ParaLine"; 555 556 if (textRectID != 0) { 558 mif += "\n\t<TextRectID " + textRectID + ">"; 559 } 560 stream.write(mif.getBytes()); 561 for (int i = 0; i < content.size(); i++) { 562 Object elem = content.get(i); 563 if (elem instanceof String ) { 564 if (elem == "\n") { 566 mif = "\n<Char HardReturn>"; 567 } else { 568 mif = "\n\t<String `" + MIFEncode((String )elem) + "'>"; 569 } 570 stream.write(mif.getBytes()); 571 } else if (elem instanceof Frame) { 572 mif = "\n\t<AFrame " + ((Frame)elem).getID() + " >"; 573 stream.write(mif.getBytes()); 574 } else if (elem instanceof Tbl) { 575 mif = "\n\t<ATbl " + ((Tbl)elem).getID() + " >"; 576 stream.write(mif.getBytes()); 577 } 578 } 579 mif = "\n> #End ParaLine"; 580 stream.write(mif.getBytes()); 581 582 } 583 584 } 585 586 class PgfCatalog { 587 588 ArrayList pgfs; public PgfCatalog() {} 590 591 public void output(OutputStream stream) throws IOException { 592 String mif = "\n<PgfCatalog" + "\n<Pgf" + "\n<PgfTag `Body'>" 593 + "\n>" + "\n>"; 594 stream.write(mif.getBytes()); 595 } 596 597 } 598 599 class Color { 600 601 public Color() {} 602 603 } 604 605 class ColorCatalog { 606 607 public ColorCatalog() {} 608 609 } 610 611 class Ruling { 612 613 int penWidth; 614 int pen; 615 int lines; 616 public Ruling() { 617 penWidth = 1; 619 pen = 0; 620 lines = 1; 621 622 623 } 624 625 public void output(OutputStream stream) throws IOException { 626 627 String mif = "\n<Ruling \n<RulingTag `Default'>"; 628 mif += "\n<RulingPenWidth " + penWidth + ">"; 629 mif += "\n<RulingPen " + pen + ">"; 630 mif += "\n<RulingLines " + lines + ">"; 631 mif += "\n>"; 632 stream.write(mif.getBytes()); 633 } 634 635 } 636 637 class RulingCatalog { 638 640 ArrayList ruling = new ArrayList(); 641 public RulingCatalog() { 642 643 645 ruling.add(new Ruling()); 646 647 } 648 649 public void output(OutputStream stream) throws IOException { 650 651 String mif = "\n<RulingCatalog"; 652 stream.write(mif.getBytes()); 653 for (int i = 0; i < ruling.size(); i++) { 654 ((Ruling)ruling.get(i)).output(stream); 655 } 656 mif = "\n> #End RulingCatalog"; 657 stream.write(mif.getBytes()); 658 659 } 660 661 } 662 663 class TblFormat { 664 public TblFormat() {} 665 666 } 667 668 class TblCatalog { 669 public TblCatalog() {} 670 671 } 672 673 class Tbl extends Flow { 674 675 class TblColumn { 676 private int width; 677 public TblColumn(int width) { 678 679 this.width = width; 680 681 } 682 683 public void output(OutputStream stream) throws IOException { 684 685 String mif = "\n\t<TblColumnWidth " + width + " >"; 686 stream.write(mif.getBytes()); 687 688 } 689 690 691 } 692 693 class Row { 694 695 class Cell { 696 697 private int rowSpan, colSpan; 698 private ArrayList paras; public Cell(int rowSpan, int colSpan) { 700 701 this.rowSpan = rowSpan; 702 this.colSpan = colSpan; 703 paras = new ArrayList(); 704 } 705 706 public void startPara() { 707 this.paras.add(new Para()); 708 } 709 710 public void output(OutputStream stream) throws IOException { 711 712 String mif = "\n\t\t<Cell" + "\n\t\t<CellContent"; 713 stream.write(mif.getBytes()); 714 for (int i = 0; i < paras.size(); i++) { 715 ((Para)paras.get(i)).output(stream); 716 } 717 mif = "\n\t\t> #End CellContent"; 718 mif += "\n\t> #End Cell"; 719 stream.write(mif.getBytes()); 720 } 721 } 722 723 private ArrayList cells; 724 725 public void addCell(int rowSpan, int colSpan) { 726 cells.add(new Cell(rowSpan, colSpan)); 727 } 728 729 public Row() { 730 cells = new ArrayList(); 731 } 732 733 public Cell curCell() { 734 return (Cell)this.cells.get(cells.size() - 1); 735 } 736 737 public void output(OutputStream stream) throws IOException { 738 String mif = "\n\t<Row"; 739 stream.write(mif.getBytes()); 740 for (int i = 0; i < cells.size(); i++) { 741 ((Cell)cells.get(i)).output(stream); 742 } 743 mif = "\n\t> #End Row"; 744 stream.write(mif.getBytes()); 745 } 746 } 747 748 private int ID; 749 private ArrayList tblColumns = new ArrayList(); 750 private ArrayList tblBody, tblHead, tblFoot; 751 private ArrayList current; public void addColumn(int colWidth) { 753 754 tblColumns.add(new TblColumn(colWidth)); 755 756 } 757 758 public void setCurrent(String current) { 759 760 if (current == "fo:table-body") { 761 this.current = this.tblBody; 762 } else if (current == "tablehead") { 763 this.current = this.tblHead; 764 } else if (current == "tablefoot") { 765 this.current = this.tblFoot; 766 } 767 } 768 769 public void startRow() { 770 771 this.current.add(new Row()); 772 } 773 774 public void startCell(int rowSpan, int colSpan) { 775 776 ((Row)this.current.get(current.size() - 1)).addCell(rowSpan, colSpan); 778 779 } 780 781 public Tbl() { 782 783 this.ID = curIDCounter.getnewID(); 784 tblBody = new ArrayList(); 785 tblHead = new ArrayList(); 786 tblFoot = new ArrayList(); 787 788 } 789 790 public int getID() { 791 792 return this.ID; 793 } 794 795 public Para curPara() { 796 797 Row curRow = (Row)this.current.get(current.size() - 1); 799 ArrayList paras = curRow.curCell().paras; 800 return (Para)paras.get(paras.size() - 1); 801 } 802 803 public void startPara() { 804 805 Row curRow; 807 curRow = (Row)this.current.get(current.size() - 1); 808 curRow.curCell().startPara(); 809 810 } 811 812 public void output(OutputStream stream) throws IOException { 813 814 String mif = "\n<Tbl" + "\n\t<TblID " + ID + " >"; 815 816 mif += "\n<TblTag Body>" + "\n<TblFormat"; 818 mif += "\n<TblColumnRuling `Default'>"; 819 mif += "\n<TblBodyRowRuling `Default'>"; 820 mif += "\n<TblLRuling `Default'>"; 821 mif += "\n<TblBRuling `Default'>"; 822 mif += "\n<TblRRuling `Default'>"; 823 mif += "\n<TblTRuling `Default'>"; 824 825 mif += "\n> #End TblFormat"; 826 ; 827 mif += "\n\t<TblNumColumns " + tblColumns.size() + " >"; 828 stream.write(mif.getBytes()); 829 830 if (!tblHead.isEmpty()) { 831 for (int i = 0; i < tblHead.size(); i++) { 832 ((Row)tblHead.get(i)).output(stream); 833 } 834 } 835 if (!tblFoot.isEmpty()) { 836 for (int i = 0; i < tblFoot.size(); i++) { 837 ((Row)tblFoot.get(i)).output(stream); 838 } 839 } 840 if (!tblBody.isEmpty()) { 841 mif = "\n\t<TblBody"; 842 stream.write(mif.getBytes()); 843 for (int i = 0; i < tblBody.size(); i++) { 844 ((Row)tblBody.get(i)).output(stream); 845 } 846 mif = "\n\t> #End tblBody"; 847 } 848 mif += "\n> #End Table"; 849 stream.write(mif.getBytes()); 850 } 851 852 } 853 854 class XRefFormat { 855 856 public XRefFormat() {} 857 858 } 859 860 class CrossRefInfo { 861 862 public CrossRefInfo() {} 863 864 } 865 866 class XRef { 867 868 public XRef() {} 869 870 } 871 872 class Marker { 873 874 public Marker() {} 875 876 } 877 878 class BookComponent { 879 880 Document document; 881 ColorCatalog colorCatalog; 882 RulingCatalog rulingCatalog; 883 PgfCatalog pgfCatalog; 884 TblCatalog tblCatalog; 885 ArrayList aFrames = new ArrayList(); 886 ArrayList tables = new ArrayList(); 887 ArrayList pages = new ArrayList(); 888 ArrayList textFlows = new ArrayList(); 889 890 891 public BookComponent() { 892 893 document = null; pgfCatalog = new PgfCatalog(); 895 rulingCatalog = new RulingCatalog(); 896 } 897 898 899 public Frame createFrame(int x, int y, int w, int h) { 900 Frame frame = new Frame(x, y, w, h); 901 aFrames.add(frame); 902 return frame; 903 } 904 905 public Frame curFrame() { 906 return (Frame)aFrames.get(aFrames.size() - 1); 907 } 908 909 public TextFlow curTextFlow() { 910 return (TextFlow)textFlows.get(textFlows.size() - 1); 911 } 912 913 public Tbl createTable() { 914 915 Tbl table = new Tbl(); 916 tables.add(table); 917 return table; 918 } 919 920 public Tbl curTable() { 921 922 return (Tbl)tables.get(tables.size() - 1); 923 } 924 925 public void output(OutputStream stream) throws IOException { 926 String mif = "<MIFFile 5.00>" + "\n<Units Upt>"; 927 stream.write(mif.getBytes()); 928 pgfCatalog.output(stream); 929 rulingCatalog.output(stream); 930 document.output(stream); 931 932 if (!aFrames.isEmpty()) { 933 mif = "\n<AFrames"; 934 stream.write(mif.getBytes()); 935 for (int i = 0; i < aFrames.size(); i++) { 936 ((Frame)aFrames.get(i)).output(stream); 937 } 938 mif = "\n>"; 939 stream.write(mif.getBytes()); 940 } 941 942 if (!tables.isEmpty()) { 943 mif = "\n<Tbls"; 944 stream.write(mif.getBytes()); 945 for (int i = 0; i < tables.size(); i++) { 946 ((Tbl)tables.get(i)).output(stream); 947 } 948 mif = "\n>"; 949 stream.write(mif.getBytes()); 950 } 951 952 for (int i = 0; i < pages.size(); i++) { 953 ((Page)pages.get(i)).output(stream); 954 } 955 956 for (int i = 0; i < textFlows.size(); i++) { 957 ((TextFlow)textFlows.get(i)).output(stream); 958 } 959 } 960 961 private Page curPage() { 962 return (Page)pages.get(pages.size() - 1); 963 } 964 965 } 966 967 class ElementSet { 968 public ElementSet() {} 969 970 } 971 972 975 public MIFDocument() { 976 977 bookComponent = new BookComponent(); 978 979 } 980 981 public void createPage() { 982 983 bookComponent.pages.add(new Page()); 984 985 } 986 987 public void addToStream(String s) { 988 989 991 Para para = curFlow.curPara(); 992 ParaLine paraLine = para.curParaLine(); 993 paraLine.addContent(s); 994 995 } 996 997 public void output(OutputStream stream) throws IOException { 998 1000 this.bookComponent.output(stream); 1001 1002 } 1003 1004 public void setDocumentHeightWidth(int height, int width) { 1005 1006 if (bookComponent.document == null) { 1007 1008 bookComponent.document = new Document(); 1009 bookComponent.document.height = height; 1010 bookComponent.document.width = width; 1011 } else if (bookComponent.document.height != height 1012 || bookComponent.document.width != width) { 1013 1014 MessageHandler.logln("Warning : FrameMaker doesnt support different page-sizes in a document"); 1015 } 1016 1017 } 1018 1019 public void createTextRect(int numCols) { 1020 1021 1025 1026 (bookComponent.curPage()).addTextRect(numCols); 1027 1028 1029 1031 curFlow = new TextFlow(); 1032 bookComponent.textFlows.add(curFlow); 1033 } 1034 1035 public void setTextRectProp(int left, int top, int width, int height) { 1036 1037 (bookComponent.curPage()).curTextRect().setTextRectProp(left, top, 1038 width, height); 1039 1040 1041 } 1042 1043 public void startLine() { 1044 1045 if (curFlow.curPara().curParaLine() != null) { 1046 this.addToStream("\n"); 1047 curFlow.curPara().startParaLine(); 1048 } else 1049 curFlow.curPara().startParaLine(); 1050 1051 1052 } 1053 1054 public void setBlockProp(int startIndent, int endIndent) { 1055 1056 1057 curFlow.startPara(); curFlow.curPara().setBlockProp(startIndent, endIndent); 1059 1060 } 1061 1062 public void createFrame(int x, int y, int w, int h) { 1063 1064 1066 bookComponent.createFrame(x, y, w, h); 1067 1068 } 1069 1070 public void addImage(String url, int x, int y, int w, int h) { 1071 1072 Frame frame = bookComponent.createFrame(x, y, w, h); 1073 ImportObject imageObject = new ImportObject(url, 0, 0, w, h); 1074 frame.addContent(imageObject); 1075 if (curFlow.curPara().curParaLine() == null) { 1076 curFlow.curPara().startParaLine(); 1077 1078 } 1079 curFlow.curPara().curParaLine().addContent(frame); 1080 1081 1082 } 1083 1084 public void createTable() { 1085 1086 1088 Tbl table = bookComponent.createTable(); 1089 if (curFlow.curPara().curParaLine() == null) { 1090 curFlow.curPara().startParaLine(); 1091 1092 } 1093 curFlow.curPara().curParaLine().addContent(table); 1094 1095 1099 1100 curFlow = table; 1101 1102 } 1103 1104 public void setColumnProp(int colWidth) { 1105 1106 1107 1109 Tbl table = bookComponent.curTable(); 1110 table.addColumn(colWidth); 1111 1112 1113 } 1114 1115 public void setCurrent(String current) { 1116 1117 Tbl table = bookComponent.curTable(); 1119 table.setCurrent(current); 1120 1121 } 1122 1123 public void startRow() { 1124 1125 Tbl table = bookComponent.curTable(); 1126 table.startRow(); 1127 1128 1129 } 1130 1131 public void startCell(int rowSpan, int colSpan) { 1132 1133 Tbl table = bookComponent.curTable(); 1134 table.startCell(rowSpan, colSpan); 1135 1136 } 1137 1138 public void endTable() { 1139 1140 1142 curFlow = bookComponent.curTextFlow(); 1143 1144 } 1145 1146} 1147 | Popular Tags |