listSpec.sdtList = new SdtBlock(); setTag(listSpec.sdtList, numId, ilvl); listSpec.sdtList.setSdtContent(new SdtContentBlock()); listStack.peek().sdtList.getSdtContent().getContent().add(listSpec.sdtList); listSpec.sdtList.getSdtContent().getContent().add(paragraph); } else if (numId==null) { log.error("TODO: encountered null numId!"); listSpec.sdtList = new SdtBlock(); setTag(listSpec.sdtList, numId, ilvl); listSpec.sdtList.setSdtContent(new SdtContentBlock()); listStack.peek().sdtList.getSdtContent().getContent().add(listSpec.sdtList); listSpec.sdtList.getSdtContent().getContent().add(paragraph);
private static RPr findBlockRPr(SdtBlock currentBlock) { for (Object obj:currentBlock.getSdtPr().getRPrOrAliasOrLock()) { if (obj instanceof RPr) { return (RPr)obj; } } return null; }
sdtContent.replaceElement(o, ((SdtBlock)o).getSdtContent().getContent() ); log.debug( "Paragraph object: "); org.docx4j.wml.P p = (org.docx4j.wml.P)o; flattenP(p); } else if (o instanceof javax.xml.bind.JAXBElement) {
if (sdtBlock.getParent() instanceof ArrayList) { parentList = (ArrayList)sdtBlock.getParent(); } else { log.error("Handle " + sdtBlock.getParent().getClass().getName()); parentList.addAll(index, sdtBlock.getSdtContent().getContent());
Body body = wmlDocumentEl.getBody(); SdtContentBlock sdtContent = (SdtContentBlock)sdt.getSdtContent(); if(sdtContent == null){ sdtContent = createSdtContent(); sdt.setSdtContent(sdtContent);
((Child)o).setParent( ((SdtBlock)parent).getSdtContent() ); } else if (parent instanceof List){
List<Object> cList = textElement.getSdtContent().getContent(); SdtPr pr = textElement.getSdtPr(); List<Object> al = pr.getRPrOrAliasOrLock();
|| contentContext instanceof SdtContentBlock) { sdt = new SdtBlock(); ((SdtBlock)sdt).setSdtContent(new SdtContentBlock()); sdt = new SdtBlock(); ((SdtBlock)sdt).setSdtContent(new SdtContentBlock());
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; }
/** * Create an instance of {@link SdtBlock } * */ public SdtBlock createSdtBlock() { return new SdtBlock(); }
sdtPr.setTag(tag); sdtList.setSdtPr(sdtPr);
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
sdtBorders.getSdtContent().getContent().add(sdtShading); sdtShading.getSdtContent().getContent().add(o); sdtBorders.getSdtContent().getContent().add(o);
Body body = wmlDocumentEl.getBody(); SdtContentBlock sdtContent = (SdtContentBlock)sdt.getSdtContent(); if(sdtContent == null){ sdtContent = createSdtContent(); sdt.setSdtContent(sdtContent);
String tag = block.getSdtPr().getTag().getVal(); pushTag(tag); processContent(block.getSdtContent().getContent()); popTag();
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; }
if (sdtBlock.getParent() instanceof ArrayList) { parentList = (ArrayList)sdtBlock.getParent(); } else { log.error("Handle " + sdtBlock.getParent().getClass().getName()); parentList.addAll(index, sdtBlock.getSdtContent().getContent());
/** * Create an instance of {@link SdtBlock } * */ public SdtBlock createSdtBlock() { return new SdtBlock(); }
private SdtBlock createSdt(){ org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory(); SdtBlock sdtBlock = wmlObjectFactory.createSdtBlock(); SdtPr sdtpr = wmlObjectFactory.createSdtPr(); // Create object for docPartObj (wrapped in JAXBElement) CTSdtDocPart sdtdocpart = wmlObjectFactory.createCTSdtDocPart(); JAXBElement<org.docx4j.wml.CTSdtDocPart> sdtdocpartWrapped = wmlObjectFactory.createSdtPrDocPartObj(sdtdocpart); sdtpr.getRPrOrAliasOrLock().add( sdtdocpartWrapped); // Create object for docPartGallery CTSdtDocPart.DocPartGallery sdtdocpartdocpartgallery = wmlObjectFactory.createCTSdtDocPartDocPartGallery(); sdtdocpart.setDocPartGallery(sdtdocpartdocpartgallery); sdtdocpartdocpartgallery.setVal( "Table of Contents"); // Create object for docPartUnique BooleanDefaultTrue booleandefaulttrue = wmlObjectFactory.createBooleanDefaultTrue(); sdtdocpart.setDocPartUnique(booleandefaulttrue); // Create object for id sdtpr.setId(); sdtBlock.setSdtPr(sdtpr); return sdtBlock; }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }