Changeset 1601 for trunk/docx4j/src/main


Ignore:
Timestamp:
07/09/11 04:22:08 (11 months ago)
Author:
jharrop
Message:

Handle case where pgMar header|footer null

Location:
trunk/docx4j/src/main/java/org/docx4j/model/structure
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/model/structure/HeaderFooterPolicy.java

    r1353 r1601  
    9999                // Grab what headers and footers have been defined               
    100100                if (sectPr == null) { 
     101                        log.debug("No headers/footers in this sectPr"); 
    101102                        return; 
    102103                } 
  • trunk/docx4j/src/main/java/org/docx4j/model/structure/PageDimensions.java

    r1580 r1601  
    2323import java.math.BigInteger; 
    2424 
     25import org.apache.log4j.Logger; 
    2526import org.docx4j.jaxb.Context; 
    2627import org.docx4j.wml.STPageOrientation; 
     
    4445public class PageDimensions { 
    4546         
     47        protected static Logger log = Logger.getLogger(PageDimensions.class); 
     48         
    4649        // TODO - defaults page size and margins in a .properties file?  
    4750         
     
    7578                 
    7679                if (pgSz == null) { 
     80                        log.warn("No pgSz in this section; defaulting."); 
    7781                        pgSz = Context.getWmlObjectFactory().createSectPrPgSz();                         
     82                        setPgSize(PageSizePaper.A4, false ); 
    7883                } else { 
    7984                        this.pgSz = pgSz;                        
     
    8186                 
    8287                if (pgMar ==null) { 
     88                        log.warn("No pgMar in this section; defaulting."); 
    8389                        pgMar = Context.getWmlObjectFactory().createSectPrPgMar();                       
     90                        setMargins(MarginsWellKnown.NORMAL); 
    8491                } else { 
    8592                        this.pgMar = pgMar;                              
     
    261268         * space occupied), it may be possible to do this automatically.    
    262269         *  
    263          */ 
    264          
    265         public int getHeaderExtent() { 
     270         * ------------------ 
     271         *  
     272         * pgMar.header  is the distance from the top edge of the paper to the top edge of the header 
     273         *  
     274         * in XSL FO, extent is  the inline-progression-dimension of the region-start or region-end  
     275         * or the block-progression-dimension of the region-before or region-after. 
     276         */ 
     277         
     278        /** 
     279         * Get the distance from the top edge of the paper to the top edge of the header 
     280         */ 
     281        public int getHeaderMargin() { 
    266282                if (pgMar.getHeader()==null  
    267283                                || pgMar.getHeader().intValue() ==0 ) { 
     
    272288        } 
    273289 
    274         public int getFooterExtent() { 
     290        /** 
     291         * Get the distance from the bottom edge of the paper to the bottom edge of the footer 
     292         */ 
     293        public int getFooterMargin() { 
    275294                if (pgMar.getFooter()==null  
    276295                                || pgMar.getFooter().intValue() ==0 ) { 
     
    281300        } 
    282301         
     302        int headerExtent = 708; 
     303        /** 
     304         * Get the height of the header. In Word, the size of header and footer areas can change dynamically; 
     305         * for PDF output, you need to set this appropriately.  It defaults to 708 TWIPs  
     306         */ 
     307        public int getHeaderExtent() { 
     308                return headerExtent; 
     309        } 
     310        public void setHeaderExtent(int headerExtent) { 
     311                this.headerExtent = headerExtent; 
     312        } 
     313 
     314        int footerExtent = 708; 
     315        /** 
     316         * Get the height of the footer. In Word, the size of header and footer areas can change dynamically; 
     317         * for PDF output, you need to set this appropriately.  It defaults to 708 TWIPs  
     318         */ 
     319        public int getFooterExtent() { 
     320                return footerExtent; 
     321        } 
     322        public void setFooterExtent(int footerExtent) { 
     323                this.footerExtent = footerExtent; 
     324        } 
     325         
    283326} 
  • trunk/docx4j/src/main/java/org/docx4j/model/structure/SectionWrapper.java

    r1567 r1601  
    2121 
    2222 
     23import org.apache.log4j.Logger; 
    2324import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    2425import org.docx4j.wml.SectPr; 
     
    2627public class SectionWrapper { 
    2728         
     29        protected static Logger log = Logger.getLogger(SectionWrapper.class);            
     30         
    2831        protected SectionWrapper(SectPr sectPr, HeaderFooterPolicy previousHF, RelationshipsPart rels) { 
    2932                // This should work even if sectPr is null 
    3033                this.sectPr = sectPr; 
     34                if (sectPr==null) { 
     35                        log.warn("No (document level?) sectPr!"); 
     36                } 
    3137                this.headerFooterPolicy = new HeaderFooterPolicy(sectPr, previousHF, rels);  
    3238                 
Note: See TracChangeset for help on using the changeset viewer.