BoxModelContent.java 40.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.layout;

import com.adobe.xfa.AppModel;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Int;
import com.adobe.xfa.Measurement;
import com.adobe.xfa.Node;
import com.adobe.xfa.XFA;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.content.ExDataValue;
import com.adobe.xfa.font.FontService;
import com.adobe.xfa.layout.BoxModelCaptionable;
import com.adobe.xfa.layout.BoxModelLayout;
import com.adobe.xfa.layout.LayoutEnv;
import com.adobe.xfa.layout.LayoutHandler;
import com.adobe.xfa.template.TemplateResolver;
import com.adobe.xfa.template.containers.Draw;
import com.adobe.xfa.template.containers.Field;
import com.adobe.xfa.template.formatting.Picture;
import com.adobe.xfa.template.ui.UI;
import com.adobe.xfa.text.TextAttr;
import com.adobe.xfa.text.TextDisplay;
import com.adobe.xfa.text.TextMeasurement;
import com.adobe.xfa.text.TextPosn;
import com.adobe.xfa.text.TextPosnBase;
import com.adobe.xfa.text.TextRange;
import com.adobe.xfa.text.TextRegion;
import com.adobe.xfa.text.TextResolver;
import com.adobe.xfa.text.TextStream;
import com.adobe.xfa.ut.Angle;
import com.adobe.xfa.ut.CoordPair;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.IntegerHolder;
import com.adobe.xfa.ut.LcLocale;
import com.adobe.xfa.ut.LcNum;
import com.adobe.xfa.ut.Margins;
import com.adobe.xfa.ut.ObjectHolder;
import com.adobe.xfa.ut.PictureFmt;
import com.adobe.xfa.ut.Rect;
import com.adobe.xfa.ut.ResId;
import com.adobe.xfa.ut.StringUtils;
import com.adobe.xfa.ut.UnitSpan;
import java.util.List;

class BoxModelContent
extends BoxModelCaptionable {
    protected Rect m_oContentDisplayExtent = Rect.ZERO;
    protected boolean m_bSplitContent = false;
    protected TextPosn m_oStartContentPosn = new TextPosn();
    protected TextPosn m_oEndContentPosn = new TextPosn();
    protected TextAttr m_oAmbientTextAttr = new TextAttr();
    protected boolean m_bEmbeddedContent = false;
    protected boolean m_bKeepContentTextStream = false;
    protected boolean m_bForcedGrowableW = false;
    protected boolean m_bForcedGrowableH = false;

    public BoxModelContent(LayoutEnv oEnv, boolean bAllowRenderProxy) {
        super(oEnv, bAllowRenderProxy);
    }

    @Override
    public void clear() {
        this.m_bKeepContentTextStream = false;
        this.m_bSplitContent = false;
        super.clear();
    }

    @Override
    public void initialize(Element oNode) {
        assert (oNode != null);
        assert (oNode instanceof Field || oNode instanceof Draw);
        if (!this.isBoxModelCompatible(oNode)) {
            return;
        }
        this.checkProxyStatus(oNode);
        if (!this.isProxy()) {
            this.initWidthHeight(oNode, true);
        }
        this.initAnchorPoint(oNode);
        this.initMargins(oNode);
        this.initBorder(oNode);
        if (!this.isProxy()) {
            this.initCaption(oNode);
            this.initContent(oNode);
            this.format(oNode);
        } else {
            this.initContent(oNode);
            if (oNode instanceof Field) {
                this.createDisplay(this.m_oContentExtent.width(), this.m_oContentExtent.width(), this.m_oContentExtent.height(), this.m_oContentExtent.height());
            }
        }
        this.initRotatedContentTopLeft();
        this.respectRotation(oNode);
        this.initVisualExtent(oNode);
    }

    @Override
    public void reinitialize(Element oNode) {
        if (!this.m_bKeepContentTextStream && !this.m_bKeepCaptionTextStream) {
            super.reinitialize(oNode);
            return;
        }
        assert (oNode != null);
        this.initialize(oNode);
    }

    @Override
    public boolean hasContent() {
        return true;
    }

    @Override
    public String getContentByType(String sType, List<TemplateResolver.RGB> colorTable, List<String> fontTable) {
        assert (null != this.getContent());
        if (null != this.getContent()) {
            return this.getStringByType(this.getContent(), this.m_oAmbientTextAttr, sType, this.m_oStartContentPosn, this.m_oEndContentPosn, colorTable, fontTable);
        }
        return "";
    }

    @Override
    public boolean enumerateContent(LayoutHandler pHandler, CoordPair oLocalOrigin, boolean bWrap, boolean bTruncate, Rect oInvalidatedRect) {
        CoordPair oNewOrigin = oLocalOrigin;
        Rect oInvalid = oInvalidatedRect;
        if (oInvalid.width().equals(UnitSpan.ZERO) && oInvalid.height().equals(UnitSpan.ZERO)) {
            oInvalid = Rect.ZERO;
        }
        if (this.m_bSplitContent) {
            oInvalid = this.m_oContentDisplayExtent;
            oNewOrigin = new CoordPair(oNewOrigin.x(), oNewOrigin.y().subtract(this.m_oContentDisplayExtent.top()));
        }
        boolean bSplitContentFits = true;
        if (this.m_oContentDisplayExtent.width().gt(this.getContentExtent().width())) {
            oInvalid = oInvalid.width(this.getContentExtent().width(), false);
            bSplitContentFits = false;
        }
        if (this.m_oContentDisplayExtent.height().gt(this.getContentExtent().height())) {
            oInvalid = oInvalid.height(this.getContentExtent().height(), false);
            bSplitContentFits = false;
        }
        boolean bFits = this.m_oGfxLayoutEnv.renderText(pHandler, this.getContentDisplay(), oNewOrigin, bWrap, bTruncate, this.m_oRotationAngle, oInvalid);
        if (this.m_bSplitContent) {
            return bSplitContentFits;
        }
        return bFits;
    }

    @Override
    public void resizeToNominal(UnitSpan oW, UnitSpan oH, Element oNode) {
        if (this.m_bWasRotated && (this.m_oRotationAngle.degrees() == 90 || this.m_oRotationAngle.degrees() == 270)) {
            this.setGrowableH(oW, oW);
            this.setGrowableW(oH, oH);
        } else {
            this.setGrowableW(oW, oW);
            this.setGrowableH(oH, oH);
        }
        this.format(oNode);
        this.initRotatedContentTopLeft();
        this.respectRotation(oNode);
        this.initVisualExtent(oNode);
    }

    @Override
    public void resizeToNominalWidth(UnitSpan oW, Element oNode) {
        assert (UnitSpan.ZERO.lte(oW));
        if (this.m_bWasRotated) {
            if (this.m_oRotationAngle.degrees() == 90 || this.m_oRotationAngle.degrees() == 270) {
                this.setGrowableH(oW, oW);
            } else {
                this.setGrowableW(oW, oW);
            }
        } else {
            this.setGrowableW(oW, oW);
        }
        this.format(oNode);
        this.initRotatedContentTopLeft();
        this.respectRotation(oNode);
        this.initVisualExtent(oNode);
    }

    @Override
    public void resizeToContent(UnitSpan oW, UnitSpan oH, Element oNode) {
        assert (false);
    }

    @Override
    public boolean splitImpl(UnitSpan oVSplit, BoxModelLayout pNewBM, Element oNode) {
        if (this.m_bWasRotated) {
            return false;
        }
        boolean bSplit = false;
        if (oVSplit.gt(UnitSpan.ZERO) && oVSplit.lt(this.getHeight()) && oVSplit.gte(this.m_oContentExtent.top()) && oVSplit.lte(this.m_oContentExtent.bottom())) {
            if (!this.m_bSplitContent) {
                this.m_oContentDisplayExtent = this.m_oContentDisplayExtent.width(this.getContentExtent().width(), false);
                this.m_oContentDisplayExtent = this.m_oContentDisplayExtent.height(this.getContentExtent().height(), false);
                if (this.m_bHasCaption) {
                    this.m_oCaptionDisplayExtent = this.m_oCaptionDisplayExtent.width(this.getCaptionExtent().width(), false);
                    this.m_oCaptionDisplayExtent = this.m_oCaptionDisplayExtent.height(this.getCaptionExtent().height(), false);
                }
            }
            assert (null != this.getContentDisplay());
            assert (null != this.getCaptionDisplay() || !this.m_bHasCaption);
            UnitSpan oContentDisplayOffset = this.m_oContentDisplayExtent.top();
            assert (UnitSpan.ZERO.lte(oVSplit.subtract(this.m_oContentExtent.top()).add(oContentDisplayOffset)));
            TextPosn oPrevEndContentPosn = this.m_oEndContentPosn;
            boolean bEndsInNewLine = false;
            UnitSpan oContentSplit = UnitSpan.ZERO;
            UnitSpan oContentDisplayBottom = this.m_oContentDisplayExtent.bottom();
            Rect oLineRect = Rect.ZERO;
            if (oLineRect.height().gt(oContentDisplayBottom.subtract(oContentSplit)) && !$assertionsDisabled && !oContentSplit.lt(oContentDisplayBottom)) {
                throw new AssertionError();
            }
            if (oLineRect.height().gt(oContentSplit.subtract(this.m_oContentDisplayExtent.top()))) {
                if (!this.m_bSplitContent) {
                    this.m_oContentDisplayExtent = Rect.ZERO;
                    if (this.m_bHasCaption) {
                        this.m_oCaptionDisplayExtent = Rect.ZERO;
                    }
                }
                this.m_oEndContentPosn = oPrevEndContentPosn;
                return false;
            }
            Rect oOldNE = this.getNominalExtent();
            if (oContentSplit.gte(oContentDisplayOffset) && oContentSplit.lte(oContentDisplayBottom)) {
                Rect oNewContentDisplayExtent = this.m_oContentDisplayExtent;
                oNewContentDisplayExtent = oNewContentDisplayExtent.topBottom(oContentSplit, oContentDisplayBottom);
                this.m_oContentDisplayExtent = this.m_oContentDisplayExtent.topBottom(oContentDisplayOffset, oContentSplit);
                pNewBM = new BoxModelContent(this.m_oGfxLayoutEnv, false);
                BoxModelContent pBMContent = (BoxModelContent)pNewBM;
                pBMContent.m_bSplitContent = true;
                pBMContent.m_oStartContentPosn = this.m_oEndContentPosn;
                pBMContent.m_oEndContentPosn = oPrevEndContentPosn;
                if (bEndsInNewLine) {
                    this.m_oEndContentPosn.prevUserPosn();
                }
                this.m_bSplitContent = true;
                Rect oNewCaptionDisplayExtent = this.m_oCaptionDisplayExtent;
                if (this.m_bHasCaption) {
                    assert (this.m_eCaptionPlacement != 4194308);
                    if (this.m_eCaptionPlacement == 4194307 || this.m_eCaptionPlacement == 4194305 || this.m_eCaptionPlacement == 4194306) {
                        pBMContent.m_bHasCaption = true;
                        pBMContent.m_bReserveCaptionSpace = this.m_bReserveCaptionSpace;
                        pBMContent.m_eCaptionPresence = this.m_eCaptionPresence;
                        pBMContent.m_eCaptionPlacement = this.m_eCaptionPlacement;
                        pBMContent.m_oReserveCaptionSpace = this.m_oReserveCaptionSpace;
                        if (this.m_eCaptionPlacement == 4194306) {
                            this.m_bHasCaption = false;
                        } else {
                            UnitSpan oCaptionDisplayOffset = this.m_oCaptionDisplayExtent.top();
                            assert (UnitSpan.ZERO.lte(oVSplit.subtract(this.m_oCaptionExtent.top()).add(oCaptionDisplayOffset)));
                            TextPosn oPrevEndCaptionPosn = new TextPosn(this.m_oEndCaptionPosn);
                            bEndsInNewLine = false;
                            UnitSpan oCaptionSplit = UnitSpan.ZERO;
                            UnitSpan oCaptionDisplayBottom = this.m_oCaptionDisplayExtent.bottom();
                            oNewCaptionDisplayExtent = oNewCaptionDisplayExtent.topBottom(oCaptionSplit, oCaptionDisplayBottom);
                            this.m_oCaptionDisplayExtent = this.m_oCaptionDisplayExtent.topBottom(oCaptionDisplayOffset, oCaptionSplit);
                            pBMContent.m_bSplitCaption = true;
                            pBMContent.m_oStartCaptionPosn = this.m_oEndCaptionPosn;
                            pBMContent.m_oEndCaptionPosn = oPrevEndCaptionPosn;
                            if (bEndsInNewLine) {
                                this.m_oEndCaptionPosn.prevUserPosn();
                            }
                            this.m_bSplitCaption = true;
                        }
                    }
                }
                pBMContent.initializeSplit(oNode, oNewContentDisplayExtent, oNewCaptionDisplayExtent);
                pBMContent.disableTopMargin();
                pBMContent.disableContentTopMargin();
                if (this.m_bSplitCaption) {
                    pBMContent.disableCaptionTopMargin();
                    this.disableCaptionBottomMargin();
                }
                this.disableBottomMargin();
                this.disableContentBottomMargin();
                boolean bWasHGrowable = this.hasGrowableH();
                this.setGrowableH(UnitSpan.ZERO, new UnitSpan(3, -1));
                this.format(oNode);
                UnitSpan oNewNEHeight = this.getHeight();
                if (!bWasHGrowable) {
                    this.setGrowableH(oNewNEHeight, oNewNEHeight);
                }
                UnitSpan oNEDelta = oOldNE.height().subtract(oNewNEHeight);
                pNewBM.resizeToNominal(oOldNE.width(), oNEDelta, oNode);
                if (bWasHGrowable) {
                    pBMContent.setGrowableH(UnitSpan.ZERO, new UnitSpan(3, -1));
                }
                pBMContent.setForcedGrowableH(this.hasForcedGrowableH());
                pBMContent.setForcedGrowableW(this.hasForcedGrowableW());
                bSplit = true;
            }
        }
        return bSplit;
    }

    @Override
    public boolean hasSplit() {
        return this.m_bSplitContent || this.m_bSplitCaption;
    }

    @Override
    public boolean isFontSubstituted() {
        boolean bIsFontSubstituted = false;
        TextDisplay pDisp = this.getCaptionDisplay();
        if (pDisp != null) {
            bIsFontSubstituted = pDisp.hasFontSubstitution();
        }
        if (!bIsFontSubstituted && (pDisp = this.getContentDisplay()) != null) {
            bIsFontSubstituted = pDisp.hasFontSubstitution();
        }
        return bIsFontSubstituted;
    }

    @Override
    public boolean hasGrowableW() {
        return super.hasGrowableW() || this.m_bForcedGrowableW;
    }

    @Override
    public boolean hasGrowableH() {
        return super.hasGrowableH() || this.m_bForcedGrowableH;
    }

    public void setForcedGrowableW(boolean bForcedGrowableW) {
        this.m_bForcedGrowableW = bForcedGrowableW;
    }

    public void setForcedGrowableH(boolean bForcedGrowableH) {
        this.m_bForcedGrowableH = bForcedGrowableH;
    }

    public boolean hasForcedGrowableW() {
        return this.m_bForcedGrowableW;
    }

    public boolean hasForcedGrowableH() {
        return this.m_bForcedGrowableH;
    }

    public boolean getContentRange(ObjectHolder<TextPosn> oStartPosn, ObjectHolder<TextPosn> oEndPosn) {
        oStartPosn.value = this.m_oStartContentPosn;
        oEndPosn.value = this.m_oEndContentPosn;
        return this.hasSplit();
    }

    public boolean getComb(Element oNode, Element oCurrentUI, IntegerHolder nNumCells) {
        if (oNode == null) {
            return false;
        }
        boolean bIsComb = false;
        nNumCells.value = 0;
        Element oCombNode = oCurrentUI.peekElement(XFA.COMBTAG, false, 0);
        if (oCombNode != null) {
            bIsComb = true;
            Int oCells = (Int)oCombNode.getAttribute(XFA.NUMBEROFCELLSTAG);
            nNumCells.value = oCells.getValue();
            if (nNumCells.value < 1) {
                Element oTextNode;
                Int oMaxChars;
                nNumCells.value = 1;
                Element oValueNode = oNode.peekElement(XFA.VALUETAG, false, 0);
                if (oValueNode != null && (oTextNode = oValueNode.peekElement(XFA.TEXTTAG, false, 0)) != null && (oMaxChars = (Int)oTextNode.getAttribute(XFA.MAXCHARSTAG)) != null) {
                    nNumCells.value = oMaxChars.getValue();
                    if (nNumCells.value < 1) {
                        nNumCells.value = 1;
                    }
                }
            }
        }
        return bIsComb;
    }

    public boolean getKeepContentTextStreamFlag() {
        return this.m_bKeepContentTextStream;
    }

    public void setKeepContentTextStreamFlag(boolean bKeepTextStream) {
        this.m_bKeepContentTextStream = bKeepTextStream;
    }

    @Override
    public void update(Element oNode) {
        assert (!this.m_bWasRotated);
        if (!(this.m_bGrowableW || this.m_bGrowableH || this.m_bForcedGrowableW || this.m_bForcedGrowableH)) {
            return;
        }
        if (this.m_bWasRotated) {
            return;
        }
        this.format(oNode);
        this.initVisualExtent(oNode);
    }

    public TextDisplay getContentDisplay() {
        throw new ExFull(ResId.UNSUPPORTED_OPERATION, "BoxModelContent#getContentDisplay");
    }

    public TextRegion getContent() {
        return null;
    }

    public TextRange getContentRangeAttrs() {
        return null;
    }

    public UnitSpan calculateSplitPoint(UnitSpan oSuggestedVSplit) {
        if (oSuggestedVSplit.gt(UnitSpan.ZERO) && oSuggestedVSplit.lte(this.getHeight())) {
            if (oSuggestedVSplit.lt(this.m_oContentExtent.top())) {
                return UnitSpan.ZERO;
            }
            if (oSuggestedVSplit.gt(this.m_oContentExtent.bottom())) {
                return this.m_oContentExtent.bottom();
            }
            if (null != this.getContentDisplay()) {
                Rect oLineRect;
                UnitSpan oTextContentSplitPt = UnitSpan.ZERO;
                if (!this.m_bSplitContent) {
                    this.m_oContentDisplayExtent = this.m_oContentDisplayExtent.width(this.getContentExtent().width(), false);
                    this.m_oContentDisplayExtent = this.m_oContentDisplayExtent.height(this.getContentExtent().height(), false);
                }
                if ((oLineRect = Rect.ZERO).height().gt(this.m_oContentDisplayExtent.bottom().subtract(oTextContentSplitPt))) {
                    throw new ExFull(ResId.UNSUPPORTED_OPERATION, "BoxModelContent#calculateSplitPoint");
                }
                if (oLineRect.bottom().gt(this.m_oContentDisplayExtent.top().add(oTextContentSplitPt))) {
                    return UnitSpan.ZERO;
                }
                if (UnitSpan.ZERO.gt(oTextContentSplitPt)) {
                    return UnitSpan.ZERO;
                }
                return oTextContentSplitPt.add(this.m_oContentExtent.top()).subtract(this.m_oContentDisplayExtent.top());
            }
        }
        return UnitSpan.ZERO;
    }

    protected void format(Element oNode) {
        Rect oRuntimeExtent;
        UnitSpan oCapSpaceW = UnitSpan.ZERO;
        UnitSpan oCapSpaceH = UnitSpan.ZERO;
        UnitSpan oCapStreamMinH = UnitSpan.ZERO;
        UnitSpan oCapStreamMaxH = UnitSpan.ZERO;
        UnitSpan oCapStreamMinW = UnitSpan.ZERO;
        UnitSpan oCapStreamMaxW = UnitSpan.ZERO;
        UnitSpan oConStreamMinH = UnitSpan.ZERO;
        UnitSpan oConStreamMaxH = UnitSpan.ZERO;
        UnitSpan oConStreamMinW = UnitSpan.ZERO;
        UnitSpan oConStreamMaxW = UnitSpan.ZERO;
        UnitSpan oCaptionExtentW = UnitSpan.ZERO;
        UnitSpan oCaptionExtentH = UnitSpan.ZERO;
        UnitSpan oContentExtentW = UnitSpan.ZERO;
        UnitSpan oContentExtentH = UnitSpan.ZERO;
        Margins oCapMargins = this.getCaptionExtentMargins();
        Margins oConMargins = this.getContentExtentMargins();
        Margins oNEMargins = this.getNominalExtentMargins();
        UnitSpan oCapLeftRightMargins = oCapMargins.marginLeft().add(oCapMargins.marginRight());
        UnitSpan oCapTopBottomMargins = oCapMargins.marginTop().add(oCapMargins.marginBottom());
        UnitSpan oConLeftRightMargins = oConMargins.marginLeft().add(oConMargins.marginRight());
        UnitSpan oConTopBottomMargins = oConMargins.marginTop().add(oConMargins.marginBottom());
        UnitSpan oNELeftRightMargins = oNEMargins.marginLeft().add(oNEMargins.marginRight());
        UnitSpan oNETopBottomMargins = oNEMargins.marginTop().add(oNEMargins.marginBottom());
        if (this.m_bHasCaption) {
            assert (4194308 != this.m_eCaptionPlacement);
            if (4194307 == this.m_eCaptionPlacement || 4194305 == this.m_eCaptionPlacement) {
                oCapStreamMinH = this.m_oMinH.subtract(oNETopBottomMargins).subtract(oCapTopBottomMargins);
                oCapStreamMaxH = this.m_bGrowableH && this.m_bInfiniteMaxH ? new UnitSpan(3, -1) : this.m_oMaxH.subtract(oNETopBottomMargins).subtract(oCapTopBottomMargins);
                if (this.m_bReserveCaptionSpace) {
                    oCapStreamMaxW = oCapStreamMinW = this.m_oReserveCaptionSpace.subtract(oCapLeftRightMargins);
                } else {
                    oCapStreamMinW = this.m_oMinW.subtract(oNELeftRightMargins).subtract(oCapLeftRightMargins);
                    oCapStreamMaxW = this.m_bGrowableW && this.m_bInfiniteMaxW ? new UnitSpan(3, -1) : this.m_oMaxW.subtract(oNELeftRightMargins).subtract(oCapLeftRightMargins);
                }
            } else if (4194304 == this.m_eCaptionPlacement || 4194306 == this.m_eCaptionPlacement) {
                oCapStreamMinW = this.m_oMinW.subtract(oNELeftRightMargins).subtract(oCapLeftRightMargins);
                oCapStreamMaxW = this.m_bGrowableW && this.m_bInfiniteMaxW ? new UnitSpan(3, -1) : this.m_oMaxW.subtract(oNELeftRightMargins).subtract(oCapLeftRightMargins);
                if (this.m_bReserveCaptionSpace) {
                    oCapStreamMaxH = oCapStreamMinH = this.m_oReserveCaptionSpace.subtract(oCapTopBottomMargins);
                } else {
                    oCapStreamMinH = this.m_oMinH.subtract(oNETopBottomMargins.subtract(oCapTopBottomMargins));
                    oCapStreamMaxH = this.m_bGrowableH && this.m_bInfiniteMaxH ? new UnitSpan(3, -1) : this.m_oMaxH.subtract(oNETopBottomMargins).subtract(oCapTopBottomMargins);
                }
            }
            if (oCapStreamMinW.lt(UnitSpan.ZERO)) {
                oCapStreamMinW = UnitSpan.ZERO;
            }
            if (oCapStreamMinH.lt(UnitSpan.ZERO)) {
                oCapStreamMinH = UnitSpan.ZERO;
            }
            if (!this.m_bSplitCaption) {
                // empty if block
            }
            if (4194307 == this.m_eCaptionPlacement || 4194305 == this.m_eCaptionPlacement) {
                if (this.m_bReserveCaptionSpace) {
                    assert (oCapStreamMinW.equals(oCapStreamMaxW));
                    oCaptionExtentW = oCapStreamMaxW;
                }
                if (!this.m_bGrowableH) {
                    oCaptionExtentH = oCapStreamMaxH;
                }
                oCapSpaceW = oCaptionExtentW.add(oCapLeftRightMargins);
                oCapSpaceH = UnitSpan.ZERO;
            } else if (4194304 == this.m_eCaptionPlacement || 4194306 == this.m_eCaptionPlacement) {
                if (this.m_bReserveCaptionSpace) {
                    assert (oCapStreamMinH.equals(oCapStreamMaxH));
                } else {
                    throw new ExFull(ResId.UNSUPPORTED_OPERATION, "BoxModelContent#format");
                }
                oCaptionExtentH = oCapStreamMaxH;
                if (!this.m_bGrowableW) {
                    oCaptionExtentW = oCapStreamMaxW;
                }
                oCapSpaceH = oCaptionExtentH.add(oCapTopBottomMargins);
                oCapSpaceW = UnitSpan.ZERO;
            }
        }
        oConStreamMinW = this.m_oMinW.subtract(oNELeftRightMargins).subtract(oConLeftRightMargins).subtract(oCapSpaceW);
        oConStreamMaxW = this.m_oMaxW.subtract(oNELeftRightMargins).subtract(oConLeftRightMargins).subtract(oCapSpaceW);
        oConStreamMinH = this.m_oMinH.subtract(oNETopBottomMargins).subtract(oConTopBottomMargins).subtract(oCapSpaceH);
        oConStreamMaxH = this.m_oMaxH.subtract(oNETopBottomMargins).subtract(oConTopBottomMargins).subtract(oCapSpaceH);
        if (oConStreamMinW.lt(UnitSpan.ZERO)) {
            oConStreamMinW = UnitSpan.ZERO;
        }
        if (oConStreamMinH.lt(UnitSpan.ZERO)) {
            oConStreamMinH = UnitSpan.ZERO;
        }
        if (this.m_bGrowableW && this.m_bInfiniteMaxW || this.m_bForcedGrowableW) {
            oConStreamMaxW = new UnitSpan(3, -1);
        } else if (oConStreamMaxW.lt(UnitSpan.ZERO)) {
            oConStreamMaxW = UnitSpan.ZERO;
        }
        if (this.m_bGrowableH && this.m_bInfiniteMaxH || this.m_bForcedGrowableH) {
            oConStreamMaxH = new UnitSpan(3, -1);
        } else if (oConStreamMaxH.lt(UnitSpan.ZERO)) {
            oConStreamMaxH = UnitSpan.ZERO;
        }
        this.createDisplay(oConStreamMinW, oConStreamMaxW, oConStreamMinH, oConStreamMaxH);
        if (this.m_bGrowableW || this.m_bForcedGrowableW) {
            oRuntimeExtent = this.m_bSplitContent ? this.m_oContentDisplayExtent : this.getContentDisplay().runtimeExtent();
            oContentExtentW = oRuntimeExtent.right();
            if (oContentExtentW.lt(oConStreamMinW)) {
                oContentExtentW = oConStreamMinW;
            } else if (!this.m_bForcedGrowableW && oContentExtentW.gt(oConStreamMaxW) && !this.m_bInfiniteMaxW) {
                oContentExtentW = oConStreamMaxW;
            }
            assert (!oContentExtentW.gt(oConStreamMaxW) || this.m_bInfiniteMaxW || this.m_bForcedGrowableW);
        } else {
            assert (oConStreamMinW.equals(oConStreamMaxW));
            oContentExtentW = oConStreamMaxW;
        }
        if (this.m_bGrowableH || this.m_bForcedGrowableH) {
            oRuntimeExtent = this.m_bSplitContent ? this.m_oContentDisplayExtent : this.getContentDisplay().runtimeExtent();
            oContentExtentH = oRuntimeExtent.height();
            if (oContentExtentH.lt(oConStreamMinH)) {
                oContentExtentH = oConStreamMinH;
            } else if (!this.m_bForcedGrowableH && oContentExtentH.gt(oConStreamMaxH) && !this.m_bInfiniteMaxH) {
                oContentExtentH = oConStreamMaxH;
            }
            assert (!oContentExtentH.gt(oConStreamMaxH) || this.m_bInfiniteMaxH || this.m_bForcedGrowableH);
        } else {
            assert (oConStreamMinH.equals(oConStreamMaxH));
            oContentExtentH = oConStreamMaxH;
        }
        if (this.m_bHasCaption) {
            if (4194307 == this.m_eCaptionPlacement) {
                this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oCapLeftRightMargins).add(oCaptionExtentW).add(oConLeftRightMargins).add(oContentExtentW), false);
                if (oContentExtentH.add(oConTopBottomMargins).gt(oCaptionExtentH.add(oCapTopBottomMargins))) {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oContentExtentH).add(oConTopBottomMargins), false);
                    oCaptionExtentH = oContentExtentH.add(oConTopBottomMargins).subtract(oCapTopBottomMargins);
                } else if (this.m_bSplitCaption) {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oContentExtentH).add(oConTopBottomMargins), false);
                    oCaptionExtentH = this.m_oNE.height().subtract(oCapTopBottomMargins).add(oNETopBottomMargins);
                    this.m_oCaptionDisplayExtent = this.m_oCaptionDisplayExtent.height(oCaptionExtentH, false);
                } else {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oCaptionExtentH).add(oCapTopBottomMargins), false);
                    oContentExtentH = oCaptionExtentH.add(oCapTopBottomMargins).subtract(oConTopBottomMargins);
                }
                this.m_oCaptionExtent = this.m_oCaptionExtent.leftWidth(oNEMargins.marginLeft().add(oCapMargins.marginLeft()), oCaptionExtentW);
                this.m_oCaptionExtent = this.m_oCaptionExtent.topHeight(oNEMargins.marginTop().add(oCapMargins.marginTop()), oCaptionExtentH);
                this.m_oContentExtent = this.m_oContentExtent.leftWidth(oNEMargins.marginLeft().add(oCapLeftRightMargins).add(oCaptionExtentW).add(oConMargins.marginLeft()), oContentExtentW);
                this.m_oContentExtent = this.m_oContentExtent.topHeight(oNEMargins.marginTop().add(oConMargins.marginTop()), oContentExtentH);
            } else if (4194305 == this.m_eCaptionPlacement) {
                this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oCapLeftRightMargins).add(oCaptionExtentW).add(oConLeftRightMargins).add(oContentExtentW), false);
                if (oContentExtentH.add(oConTopBottomMargins).gt(oCaptionExtentH.add(oCapTopBottomMargins))) {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oContentExtentH).add(oConTopBottomMargins), false);
                    oCaptionExtentH = oContentExtentH.add(oConTopBottomMargins).subtract(oCapTopBottomMargins);
                } else if (this.m_bSplitCaption) {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oContentExtentH).add(oConTopBottomMargins), false);
                    oCaptionExtentH = this.m_oNE.height().subtract(oCapTopBottomMargins.add(oNETopBottomMargins));
                    this.m_oCaptionDisplayExtent = this.m_oCaptionDisplayExtent.height(oCaptionExtentH, false);
                } else {
                    this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oCaptionExtentH).add(oCapTopBottomMargins), false);
                    oContentExtentH = oCaptionExtentH.add(oCapTopBottomMargins).subtract(oConTopBottomMargins);
                }
                this.m_oCaptionExtent = this.m_oCaptionExtent.leftWidth(oNEMargins.marginLeft().add(oConLeftRightMargins).add(oContentExtentW).add(oCapMargins.marginLeft()), oCaptionExtentW);
                this.m_oCaptionExtent = this.m_oCaptionExtent.topHeight(oNEMargins.marginTop().add(oCapMargins.marginTop()), oCaptionExtentH);
                this.m_oContentExtent = this.m_oContentExtent.leftWidth(oNEMargins.marginLeft().add(oConMargins.marginLeft()), oContentExtentW);
                this.m_oContentExtent = this.m_oContentExtent.topHeight(oNEMargins.marginTop().add(oConMargins.marginTop()), oContentExtentH);
            } else if (4194304 == this.m_eCaptionPlacement) {
                this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oCapTopBottomMargins).add(oCaptionExtentH).add(oConTopBottomMargins).add(oContentExtentH), false);
                if (oContentExtentW.add(oConLeftRightMargins).gt(oCaptionExtentW.add(oCapLeftRightMargins))) {
                    this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oContentExtentW).add(oConLeftRightMargins), false);
                    oCaptionExtentW = oContentExtentW.add(oConLeftRightMargins).subtract(oCapLeftRightMargins);
                } else {
                    this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oCaptionExtentW).add(oCapLeftRightMargins), false);
                    oContentExtentW = oCaptionExtentW.add(oCapLeftRightMargins).subtract(oConLeftRightMargins);
                }
                this.m_oCaptionExtent = this.m_oCaptionExtent.leftWidth(oNEMargins.marginLeft().add(oCapMargins.marginLeft()), oCaptionExtentW);
                this.m_oCaptionExtent = this.m_oCaptionExtent.topHeight(oNEMargins.marginTop().add(oCapMargins.marginTop()), oCaptionExtentH);
                this.m_oContentExtent = this.m_oContentExtent.leftWidth(oNEMargins.marginLeft().add(oConMargins.marginLeft()), oContentExtentW);
                this.m_oContentExtent = this.m_oContentExtent.topHeight(oNEMargins.marginTop().add(oCapTopBottomMargins).add(oCaptionExtentH).add(oConMargins.marginTop()), oContentExtentH);
            } else if (4194306 == this.m_eCaptionPlacement) {
                this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oCapTopBottomMargins).add(oCaptionExtentH).add(oConTopBottomMargins).add(oContentExtentH), false);
                if (oContentExtentW.add(oConLeftRightMargins).gt(oCaptionExtentW.add(oCapLeftRightMargins))) {
                    this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oContentExtentW).add(oConLeftRightMargins), false);
                    oCaptionExtentW = oContentExtentW.add(oConLeftRightMargins).subtract(oCapLeftRightMargins);
                } else {
                    this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oCaptionExtentW).add(oCapLeftRightMargins), false);
                    oContentExtentW = oCaptionExtentW.add(oCapLeftRightMargins).subtract(oConLeftRightMargins);
                }
                this.m_oCaptionExtent = this.m_oCaptionExtent.leftWidth(oNEMargins.marginLeft().add(oCapMargins.marginLeft()), oCaptionExtentW);
                this.m_oCaptionExtent = this.m_oCaptionExtent.topHeight(oNEMargins.marginTop().add(oConTopBottomMargins).add(oContentExtentH).add(oCapMargins.marginTop()), oCaptionExtentH);
                this.m_oContentExtent = this.m_oContentExtent.leftWidth(oNEMargins.marginLeft().add(oConMargins.marginLeft()), oContentExtentW);
                this.m_oContentExtent = this.m_oContentExtent.topHeight(oNEMargins.marginTop().add(oConMargins.marginTop()), oContentExtentH);
            } else assert (false);
            if (!this.m_bSplitCaption) {
                // empty if block
            }
            if (!this.m_bSplitContent) {
                // empty if block
            }
        } else {
            this.m_oCaptionExtent = Rect.ZERO;
            this.m_oContentExtent = this.m_oContentExtent.leftWidth(oNEMargins.marginLeft().add(oConMargins.marginLeft()), oContentExtentW);
            this.m_oContentExtent = this.m_oContentExtent.topHeight(oNEMargins.marginTop().add(oConMargins.marginTop()), oContentExtentH);
            if (!this.m_bSplitContent) {
                // empty if block
            }
            this.m_oNE = this.m_oNE.height(oNETopBottomMargins.add(oConTopBottomMargins).add(oContentExtentH), false);
            this.m_oNE = this.m_oNE.width(oNELeftRightMargins.add(oContentExtentW).add(oConLeftRightMargins), false);
        }
        if (!this.m_bGrowableW && !this.m_bForcedGrowableW) {
            assert (this.m_oMaxW.equals(this.m_oMinW));
            this.m_oNE = this.m_oNE.width(this.m_oMaxW, false);
        }
        if (!this.m_bGrowableH && !this.m_bForcedGrowableH) {
            assert (this.m_oMaxH.equals(this.m_oMinH));
            this.m_oNE = this.m_oNE.height(this.m_oMaxH, false);
        }
    }

    protected void initContent(Element oNode) {
        assert (oNode instanceof Draw || oNode instanceof Field);
        if (this.isProxy() && oNode instanceof Draw) {
            return;
        }
        Element oValue = oNode.peekElement(XFA.VALUETAG, true, 0);
        Content oContent = (Content)oValue.getOneOfChild(true, true);
        UI oUI = (UI)oNode.peekElement(XFA.UITAG, true, 0);
        Element oCurrentUI = oUI.getUIElement(false);
        boolean bRichContent = false;
        boolean bIsField = oNode instanceof Field;
        boolean bPasswordEdit = false;
        char uPasswordChar = '\u0000';
        String sLang = oNode.getInstalledLocale();
        boolean bIsLocaleSpecified = !StringUtils.isEmpty(sLang);
        int oCurrentUITag = oCurrentUI.getClassTag();
        if (oCurrentUITag == XFA.PASSWORDEDITTAG && bIsField) {
            String sPasswordChar;
            bPasswordEdit = true;
            String oPasswordChar = oCurrentUI.peekAttribute(XFA.PASSWORDCHARTAG).toString();
            if (oPasswordChar != null && !StringUtils.isEmpty(sPasswordChar = oPasswordChar)) {
                uPasswordChar = sPasswordChar.charAt(0);
            }
            if (uPasswordChar == '\u0000') {
                uPasswordChar = '*';
            }
        }
        if (oContent instanceof ExDataValue) {
            String sContentType = oContent.getAttribute(XFA.CONTENTTYPETAG).toString();
            bRichContent = "text/html".equals(sContentType);
        }
        if (!this.m_bKeepContentTextStream) {
            AppModel appModel;
            boolean bLegacy;
            String sRichText;
            TextPosnBase oPosn;
            this.m_oAmbientTextAttr.transparent(true);
            this.m_oAmbientTextAttr.fontService(this.m_oGfxLayoutEnv.fontService());
            Element oPara = oNode.peekElement(XFA.PARATAG, true, 0);
            int eVAlign = oPara.getEnum(XFA.VALIGNTAG);
            this.setVertAlign(eVAlign, this.m_oAmbientTextAttr);
            int eHAlign = oPara.getEnum(XFA.HALIGNTAG);
            if (1441796 == eHAlign && this.hasGrowableW()) {
                eHAlign = 1441795;
            }
            this.setHorizAlign(eHAlign, this.m_oAmbientTextAttr);
            if (1441797 == eHAlign) {
                UnitSpan oRO = new Measurement(oPara.getAttribute(XFA.RADIXOFFSETTAG)).getUnitSpan();
                this.m_oAmbientTextAttr.radixOffset(new TextMeasurement(oRO));
            }
            if (bIsLocaleSpecified) {
                this.m_oAmbientTextAttr.locale(sLang);
            }
            this.setFont(oNode.peekElement(XFA.FONTTAG, true, 0), oPara, true, this.m_oAmbientTextAttr, sLang);
            if (bIsField) {
                StringBuilder sCat;
                StringBuilder sSub;
                StringBuilder sLoc;
                Element oFormat = oNode.peekElement(XFA.FORMATTAG, false, 0);
                Picture oPicture = null;
                if (oFormat != null) {
                    oPicture = (Picture)oFormat.peekElement(XFA.PICTURETAG, false, 0);
                }
                String sPicture = "";
                if (oPicture != null) {
                    sPicture = oPicture.getValue();
                }
                if (!StringUtils.isEmpty(sPicture) && (PictureFmt.isSubPicture(sPicture, 0, sCat = new StringBuilder(), sLoc = new StringBuilder(), sSub = new StringBuilder()) && sCat.toString().equals("num") || PictureFmt.isNumericPicture(sPicture))) {
                    if (StringUtils.isEmpty(sSub)) {
                        sSub.append(sPicture);
                    }
                    if (StringUtils.isEmpty(sLoc)) {
                        sLoc.append(sLang);
                    }
                    LcLocale oLocale = new LcLocale(sLoc.toString());
                    this.m_oAmbientTextAttr.locale(oLocale.getIsoName());
                    String sRawTextContent = ((Field)oNode).getRawValue();
                    LcNum oNum = new LcNum(sRawTextContent, sLoc.toString());
                    IntegerHolder oRadixPos = new IntegerHolder();
                    String sRes = oNum.format(sSub.toString(), oRadixPos);
                    if (!StringUtils.isEmpty(sRes)) {
                        this.m_oAmbientTextAttr.radixPos(oRadixPos.value);
                    }
                }
                this.setTabs(oPara.getAttribute(XFA.TABSDEFAULTTAG), oPara.getAttribute(XFA.TABSTOPSTAG), this.m_oAmbientTextAttr);
            }
            if (bPasswordEdit) {
                this.m_oAmbientTextAttr.invisible(true);
                this.m_oAmbientTextAttr.invisChar(uPasswordChar);
            }
            if (!bRichContent || StringUtils.isEmpty(sRichText = ((ExDataValue)oContent).getValue(true, false, bLegacy = (appModel = oContent.getAppModel()).getLegacySetting(AppModel.XFA_LEGACY_V27_XHTMLVERSIONPROCESSING))) || null != this.m_oGfxLayoutEnv.getTextResolver()) {
                // empty if block
            }
            if (this.hasInlineCaption() && null != this.getCaption()) {
                oPosn = new TextPosnBase(this.getContent());
                oPosn.first();
            }
            oPosn = new TextPosnBase(this.getContent());
            this.m_oStartContentPosn = new TextPosn(oPosn);
            this.m_oEndContentPosn = new TextPosn(oPosn);
            this.m_oStartContentPosn.first();
            this.m_oEndContentPosn.last();
        }
    }

    @Override
    public boolean hasEmbeddedContent() {
        return this.m_bEmbeddedContent;
    }

    protected void createDisplay(UnitSpan minW, UnitSpan maxW, UnitSpan minH, UnitSpan maxH) {
        if (!this.m_bSplitContent) {
            // empty if block
        }
    }

    private void initializeSplit(Element oNode, Rect oContentRect, Rect oCaptionRect) {
        assert (oNode != null);
        assert (this.isBoxModelCompatible(oNode));
        if (!this.isBoxModelCompatible(oNode)) {
            return;
        }
        this.initWidthHeight(oNode, true);
        this.initAnchorPoint(oNode);
        this.initMargins(oNode);
        this.initBorder(oNode);
        this.initSplitCaption(oNode, oCaptionRect);
        this.initSplitContent(oNode, oContentRect);
        this.format(oNode);
        this.initVisualExtent(oNode);
    }

    private void initSplitContent(Element oNode, Rect oRect) {
        if (!this.m_bHasCaption) {
            return;
        }
        this.m_oCaptionDisplayExtent = oRect;
        assert (null != this.getCaption());
        assert (null != this.getCaptionDisplay());
    }

    private void initSplitCaption(Element oNode, Rect oRect) {
        this.m_oContentDisplayExtent = oRect;
        assert (null != this.getContent());
        assert (null != this.getContentDisplay());
    }

    @Override
    public boolean hasOverflowingContentText() {
        return false;
    }
}