| 1 | package org.docx4j.model; |
|---|
| 2 | |
|---|
| 3 | import org.docx4j.openpackaging.exceptions.Docx4JException; |
|---|
| 4 | import org.docx4j.openpackaging.packages.WordprocessingMLPackage; |
|---|
| 5 | import org.docx4j.openpackaging.parts.ThemePart; |
|---|
| 6 | import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart; |
|---|
| 7 | import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart; |
|---|
| 8 | import org.docx4j.wml.PPr; |
|---|
| 9 | import org.docx4j.wml.RPr; |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * Property resolver which assumes that style properties will not be modified |
|---|
| 13 | * (it works by actually copying the property objects, so it can be used only |
|---|
| 14 | * when they won't be modified). |
|---|
| 15 | * |
|---|
| 16 | * @author Adam Schmideg |
|---|
| 17 | * |
|---|
| 18 | */ |
|---|
| 19 | public class ImmutablePropertyResolver extends PropertyResolver { |
|---|
| 20 | |
|---|
| 21 | public ImmutablePropertyResolver(WordprocessingMLPackage wordMLPackage) |
|---|
| 22 | throws Docx4JException { |
|---|
| 23 | super(wordMLPackage); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | // public ImmutablePropertyResolver(StyleDefinitionsPart styleDefinitionsPart, |
|---|
| 27 | // ThemePart themePart, |
|---|
| 28 | // NumberingDefinitionsPart numberingDefinitionsPart) |
|---|
| 29 | // throws Docx4JException { |
|---|
| 30 | // super(styleDefinitionsPart, themePart, numberingDefinitionsPart); |
|---|
| 31 | // } |
|---|
| 32 | |
|---|
| 33 | protected void applyPPr(PPr src, PPr dest) { |
|---|
| 34 | if (src == null) { |
|---|
| 35 | return; |
|---|
| 36 | } |
|---|
| 37 | // not copying: class, parent, rpr |
|---|
| 38 | if (src.getAdjustRightInd() != null) |
|---|
| 39 | dest.setAdjustRightInd(src.getAdjustRightInd()); |
|---|
| 40 | if (src.getAutoSpaceDE() != null) |
|---|
| 41 | dest.setAutoSpaceDE(src.getAutoSpaceDE()); |
|---|
| 42 | if (src.getAutoSpaceDN() != null) |
|---|
| 43 | dest.setAutoSpaceDN(src.getAutoSpaceDN()); |
|---|
| 44 | if (src.getBidi() != null) |
|---|
| 45 | dest.setBidi(src.getBidi()); |
|---|
| 46 | if (src.getCnfStyle() != null) |
|---|
| 47 | dest.setCnfStyle(src.getCnfStyle()); |
|---|
| 48 | if (src.getContextualSpacing() != null) |
|---|
| 49 | dest.setContextualSpacing(src.getContextualSpacing()); |
|---|
| 50 | if (src.getDivId() != null) |
|---|
| 51 | dest.setDivId(src.getDivId()); |
|---|
| 52 | if (src.getFramePr() != null) |
|---|
| 53 | dest.setFramePr(src.getFramePr()); |
|---|
| 54 | if (src.getInd() != null) |
|---|
| 55 | dest.setInd(src.getInd()); |
|---|
| 56 | if (src.getJc() != null) |
|---|
| 57 | dest.setJc(src.getJc()); |
|---|
| 58 | if (src.getKeepLines() != null) |
|---|
| 59 | dest.setKeepLines(src.getKeepLines()); |
|---|
| 60 | if (src.getKeepNext() != null) |
|---|
| 61 | dest.setKeepNext(src.getKeepNext()); |
|---|
| 62 | if (src.getKinsoku() != null) |
|---|
| 63 | dest.setKinsoku(src.getKinsoku()); |
|---|
| 64 | if (src.getMirrorIndents() != null) |
|---|
| 65 | dest.setMirrorIndents(src.getMirrorIndents()); |
|---|
| 66 | if (src.getNumPr() != null) |
|---|
| 67 | dest.setNumPr(src.getNumPr()); |
|---|
| 68 | if (src.getOutlineLvl() != null) |
|---|
| 69 | dest.setOutlineLvl(src.getOutlineLvl()); |
|---|
| 70 | if (src.getOverflowPunct() != null) |
|---|
| 71 | dest.setOverflowPunct(src.getOverflowPunct()); |
|---|
| 72 | if (src.getPageBreakBefore() != null) |
|---|
| 73 | dest.setPageBreakBefore(src.getPageBreakBefore()); |
|---|
| 74 | if (src.getPBdr() != null) |
|---|
| 75 | dest.setPBdr(src.getPBdr()); |
|---|
| 76 | if (src.getPPrChange() != null) |
|---|
| 77 | dest.setPPrChange(src.getPPrChange()); |
|---|
| 78 | if (src.getPStyle() != null) |
|---|
| 79 | dest.setPStyle(src.getPStyle()); |
|---|
| 80 | if (src.getSectPr() != null) |
|---|
| 81 | dest.setSectPr(src.getSectPr()); |
|---|
| 82 | if (src.getShd() != null) |
|---|
| 83 | dest.setShd(src.getShd()); |
|---|
| 84 | if (src.getSnapToGrid() != null) |
|---|
| 85 | dest.setSnapToGrid(src.getSnapToGrid()); |
|---|
| 86 | if (src.getSpacing() != null) |
|---|
| 87 | dest.setSpacing(src.getSpacing()); |
|---|
| 88 | if (src.getSuppressAutoHyphens() != null) |
|---|
| 89 | dest.setSuppressAutoHyphens(src.getSuppressAutoHyphens()); |
|---|
| 90 | if (src.getSuppressLineNumbers() != null) |
|---|
| 91 | dest.setSuppressLineNumbers(src.getSuppressLineNumbers()); |
|---|
| 92 | if (src.getSuppressOverlap() != null) |
|---|
| 93 | dest.setSuppressOverlap(src.getSuppressOverlap()); |
|---|
| 94 | if (src.getTabs() != null) |
|---|
| 95 | dest.setTabs(src.getTabs()); |
|---|
| 96 | if (src.getTextAlignment() != null) |
|---|
| 97 | dest.setTextAlignment(src.getTextAlignment()); |
|---|
| 98 | if (src.getTextboxTightWrap() != null) |
|---|
| 99 | dest.setTextboxTightWrap(src.getTextboxTightWrap()); |
|---|
| 100 | if (src.getTextDirection() != null) |
|---|
| 101 | dest.setTextDirection(src.getTextDirection()); |
|---|
| 102 | if (src.getTopLinePunct() != null) |
|---|
| 103 | dest.setTopLinePunct(src.getTopLinePunct()); |
|---|
| 104 | if (src.getWidowControl() != null) |
|---|
| 105 | dest.setWidowControl(src.getWidowControl()); |
|---|
| 106 | if (src.getWordWrap() != null) |
|---|
| 107 | dest.setWordWrap(src.getWordWrap()); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | protected void applyRPr(RPr src, RPr dest) { |
|---|
| 111 | if (src == null) { |
|---|
| 112 | return; |
|---|
| 113 | } |
|---|
| 114 | // not copying: class, parent |
|---|
| 115 | if (src.getB() != null) |
|---|
| 116 | dest.setB(src.getB()); |
|---|
| 117 | if (src.getBCs() != null) |
|---|
| 118 | dest.setBCs(src.getBCs()); |
|---|
| 119 | if (src.getBdr() != null) |
|---|
| 120 | dest.setBdr(src.getBdr()); |
|---|
| 121 | if (src.getCaps() != null) |
|---|
| 122 | dest.setCaps(src.getCaps()); |
|---|
| 123 | if (src.getColor() != null) |
|---|
| 124 | dest.setColor(src.getColor()); |
|---|
| 125 | if (src.getCs() != null) |
|---|
| 126 | dest.setCs(src.getCs()); |
|---|
| 127 | if (src.getDstrike() != null) |
|---|
| 128 | dest.setDstrike(src.getDstrike()); |
|---|
| 129 | if (src.getEastAsianLayout() != null) |
|---|
| 130 | dest.setEastAsianLayout(src.getEastAsianLayout()); |
|---|
| 131 | if (src.getEffect() != null) |
|---|
| 132 | dest.setEffect(src.getEffect()); |
|---|
| 133 | if (src.getEm() != null) |
|---|
| 134 | dest.setEm(src.getEm()); |
|---|
| 135 | if (src.getEmboss() != null) |
|---|
| 136 | dest.setEmboss(src.getEmboss()); |
|---|
| 137 | if (src.getFitText() != null) |
|---|
| 138 | dest.setFitText(src.getFitText()); |
|---|
| 139 | if (src.getHighlight() != null) |
|---|
| 140 | dest.setHighlight(src.getHighlight()); |
|---|
| 141 | if (src.getI() != null) |
|---|
| 142 | dest.setI(src.getI()); |
|---|
| 143 | if (src.getICs() != null) |
|---|
| 144 | dest.setICs(src.getICs()); |
|---|
| 145 | if (src.getImprint() != null) |
|---|
| 146 | dest.setImprint(src.getImprint()); |
|---|
| 147 | if (src.getKern() != null) |
|---|
| 148 | dest.setKern(src.getKern()); |
|---|
| 149 | if (src.getLang() != null) |
|---|
| 150 | dest.setLang(src.getLang()); |
|---|
| 151 | if (src.getNoProof() != null) |
|---|
| 152 | dest.setNoProof(src.getNoProof()); |
|---|
| 153 | if (src.getOMath() != null) |
|---|
| 154 | dest.setOMath(src.getOMath()); |
|---|
| 155 | if (src.getOutline() != null) |
|---|
| 156 | dest.setOutline(src.getOutline()); |
|---|
| 157 | if (src.getPosition() != null) |
|---|
| 158 | dest.setPosition(src.getPosition()); |
|---|
| 159 | if (src.getRFonts() != null) |
|---|
| 160 | dest.setRFonts(src.getRFonts()); |
|---|
| 161 | if (src.getRPrChange() != null) |
|---|
| 162 | dest.setRPrChange(src.getRPrChange()); |
|---|
| 163 | if (src.getRStyle() != null) |
|---|
| 164 | dest.setRStyle(src.getRStyle()); |
|---|
| 165 | if (src.getRtl() != null) |
|---|
| 166 | dest.setRtl(src.getRtl()); |
|---|
| 167 | if (src.getShadow() != null) |
|---|
| 168 | dest.setShadow(src.getShadow()); |
|---|
| 169 | if (src.getShd() != null) |
|---|
| 170 | dest.setShd(src.getShd()); |
|---|
| 171 | if (src.getSmallCaps() != null) |
|---|
| 172 | dest.setSmallCaps(src.getSmallCaps()); |
|---|
| 173 | if (src.getSnapToGrid() != null) |
|---|
| 174 | dest.setSnapToGrid(src.getSnapToGrid()); |
|---|
| 175 | if (src.getSpacing() != null) |
|---|
| 176 | dest.setSpacing(src.getSpacing()); |
|---|
| 177 | if (src.getSpecVanish() != null) |
|---|
| 178 | dest.setSpecVanish(src.getSpecVanish()); |
|---|
| 179 | if (src.getStrike() != null) |
|---|
| 180 | dest.setStrike(src.getStrike()); |
|---|
| 181 | if (src.getSz() != null) |
|---|
| 182 | dest.setSz(src.getSz()); |
|---|
| 183 | if (src.getSzCs() != null) |
|---|
| 184 | dest.setSzCs(src.getSzCs()); |
|---|
| 185 | if (src.getU() != null) |
|---|
| 186 | dest.setU(src.getU()); |
|---|
| 187 | if (src.getVanish() != null) |
|---|
| 188 | dest.setVanish(src.getVanish()); |
|---|
| 189 | if (src.getVertAlign() != null) |
|---|
| 190 | dest.setVertAlign(src.getVertAlign()); |
|---|
| 191 | if (src.getW() != null) |
|---|
| 192 | dest.setW(src.getW()); |
|---|
| 193 | if (src.getWebHidden() != null) |
|---|
| 194 | dest.setWebHidden(src.getWebHidden()); |
|---|
| 195 | } |
|---|
| 196 | } |
|---|