private void emptyRepeatTagValue(final Tag tag) { if (tag==null) { // TODO: this is ok for a w15 repeat log.warn("No tag"); return; } final String tagVal = tag.getVal(); final Pattern stripRepeatArgPattern = Pattern .compile("(.*od:repeat=)([^&]*)(.*)"); final Matcher stripPatternMatcher = stripRepeatArgPattern .matcher(tagVal); if (!stripPatternMatcher.matches()) { log.error("Cannot find repeat tag in sdtPr/tag while processing repeat; something is wrong with " + tagVal); return; } // final String emptyRepeatValue = stripPatternMatcher.group(1) // + stripPatternMatcher.group(3); final String emptyRepeatValue = BINDING_RESULT_RPTD + "=" + stripPatternMatcher.group(2) + stripPatternMatcher.group(3); tag.setVal(emptyRepeatValue); }
private void processDescendantCondition(Object sdt, String xpathBase, int index, Tag tag ) { Condition c = null; HashMap<String, String> map = QueryString.parseQueryString( tag.getVal(), true); String conditionId = map.get(BINDING_ROLE_CONDITIONAL); if (conditionId != null) { //c = ConditionsPart.getConditionById(conditions, conditionId); c = conditionsMap.get(conditionId); if (c == null) { log.error("Missing condition " + conditionId); throw new InputIntegrityException("Required condition '" + conditionId + "' is missing"); } // TODO: this code assumes the condition contains // a simple xpath if(log.isDebugEnabled()) { log.debug("Using condition" + XmlUtils.marshaltoString(c, true, true)); } Condition newCondition = c.repeat(xpathBase, index, conditionsMap, xpathsMap); // set sdt to use it map.put(BINDING_ROLE_CONDITIONAL, newCondition.getId() ); tag.setVal(QueryString.create(map)); } }
tag.setVal(emptyRepeatValue);
tag.setVal(BINDING_RESULT_RPTD_ZERO_W15 + "=true"); sdtPr.setTag(tag);
tag.setVal(emptyConditionValue);
private static SdtBlock createSdt(String tagVal, RPr rPr) { // .. so create content control! SdtBlock sdtBlock = Context.getWmlObjectFactory().createSdtBlock(); SdtPr sdtPr = Context.getWmlObjectFactory().createSdtPr(); sdtBlock.setSdtPr(sdtPr); SdtContentBlock sdtContent = Context.getWmlObjectFactory().createSdtContentBlock(); sdtBlock.setSdtContent(sdtContent); // For borders/shading, we'll use the values in this first paragraph. // We'll use a tag, so the XSLT can detect that its supposed to do something special. Tag tag = Context.getWmlObjectFactory().createTag(); tag.setVal(tagVal); sdtPr.setTag(tag); if (rPr != null) { sdtPr.getRPrOrAliasOrLock().add((RPr)XmlUtils.deepCopy(rPr)); /* * ECMA-376 says "specifies the set of run properties which shall be applied to * the text entered into the parent structured document tag in replacement of * placeholder text. When placeholder text is present in a structured document * tag, its formatting is often different than the desired underlying formatting, * and this element specifies the formatting which shall be used for non-placeholder * text contents when they are initially added to the control. " * * Note that docx2fo.xslt is co-opting this to do something else. */ } return sdtBlock; }
private void emptyRepeatTagValue(final Tag tag) { if (tag==null) { // TODO: this is ok for a w15 repeat log.warn("No tag"); return; } final String tagVal = tag.getVal(); final Pattern stripRepeatArgPattern = Pattern .compile("(.*od:repeat=)([^&]*)(.*)"); final Matcher stripPatternMatcher = stripRepeatArgPattern .matcher(tagVal); if (!stripPatternMatcher.matches()) { log.error("Cannot find repeat tag in sdtPr/tag while processing repeat; something is wrong with " + tagVal); return; } // final String emptyRepeatValue = stripPatternMatcher.group(1) // + stripPatternMatcher.group(3); final String emptyRepeatValue = BINDING_RESULT_RPTD + "=" + stripPatternMatcher.group(2) + stripPatternMatcher.group(3); tag.setVal(emptyRepeatValue); }
private void processDescendantCondition(Object sdt, String xpathBase, int index, Tag tag ) { Condition c = null; HashMap<String, String> map = QueryString.parseQueryString( tag.getVal(), true); String conditionId = map.get(BINDING_ROLE_CONDITIONAL); if (conditionId != null) { //c = ConditionsPart.getConditionById(conditions, conditionId); c = conditionsMap.get(conditionId); if (c == null) { log.error("Missing condition " + conditionId); throw new InputIntegrityException("Required condition '" + conditionId + "' is missing"); } // TODO: this code assumes the condition contains // a simple xpath if(log.isDebugEnabled()) { log.debug("Using condition" + XmlUtils.marshaltoString(c, true, true)); } Condition newCondition = c.repeat(xpathBase, index, conditionsMap, xpathsMap); // set sdt to use it map.put(BINDING_ROLE_CONDITIONAL, newCondition.getId() ); tag.setVal(QueryString.create(map)); } }
tag.setVal(QueryString.create(attrs));
tag.setVal(emptyConditionValue);
tag.setVal(emptyRepeatValue);
tag.setVal(BINDING_RESULT_RPTD_ZERO_W15 + "=true"); sdtPr.setTag(tag);
private static SdtBlock createSdt(String tagVal, RPr rPr) { // .. so create content control! SdtBlock sdtBlock = Context.getWmlObjectFactory().createSdtBlock(); SdtPr sdtPr = Context.getWmlObjectFactory().createSdtPr(); sdtBlock.setSdtPr(sdtPr); SdtContentBlock sdtContent = Context.getWmlObjectFactory().createSdtContentBlock(); sdtBlock.setSdtContent(sdtContent); // For borders/shading, we'll use the values in this first paragraph. // We'll use a tag, so the XSLT can detect that its supposed to do something special. Tag tag = Context.getWmlObjectFactory().createTag(); tag.setVal(tagVal); sdtPr.setTag(tag); if (rPr != null) { sdtPr.getRPrOrAliasOrLock().add((RPr)XmlUtils.deepCopy(rPr)); /* * ECMA-376 says "specifies the set of run properties which shall be applied to * the text entered into the parent structured document tag in replacement of * placeholder text. When placeholder text is present in a structured document * tag, its formatting is often different than the desired underlying formatting, * and this element specifies the formatting which shall be used for non-placeholder * text contents when they are initially added to the control. " * * Note that docx2fo.xslt is co-opting this to do something else. */ } return sdtBlock; }