Page 1 of 1

getHeaderFooterPolicy deprecated?

PostPosted: Thu Oct 29, 2009 5:14 am
by jbeltran
Hi,

I just updated my code with the latest code in the repository and I saw that the getHeaderFooterPolicy method was deprecated in WordprocessingMLPackage. Since it's deprecated what's the best way to get a header or footer in a document?

Is it best to find the sectPr in the document and find out what headers/footers are tied to that sectPr, get the relationship ID from those header/footer references, and then get the part using that ID (i.e. via getMainDocumentPart().getRelationshipsPart().getPart(oldRelId))?

Thanks!

Justin

Re: getHeaderFooterPolicy deprecated?

PostPosted: Thu Oct 29, 2009 6:07 am
by jason
Its accessed via DocumentModel, which models the document as a series of sections (ie one for each sectPr). Via that you get the HeaderFooterPolicy for the section of interest. Well, that's the idea. Right now the constructor only adds the last sectPr.

You'll see that the deprecated method now returns getDocumentModel().getSections().get(0).getHeaderFooterPolicy() - the '0' because only the last sectPr is currently present.

On your WordML package, you can getDocumentModel().

cheers .. Jason

Re: getHeaderFooterPolicy deprecated?

PostPosted: Thu Oct 29, 2009 10:43 am
by dqkit
Right now the constructor only adds the last sectPr.

does it mean other sectPrs would not be loaded ?
or should I use another way to access sectPrs except the last sectPr?

Re: getHeaderFooterPolicy deprecated?

PostPosted: Thu Oct 29, 2009 1:25 pm
by jason
Other sectPr will be present and accessible in the body in the usual way, but if you want to access them in the DocumentModel, they need to be added first. Its requires a modest change to the constructor (go through the document, find them, and add them), but I haven't done it. Perhaps you could? cheers .. Jason