Page 1 of 1

2.7.1 Questions

PostPosted: Thu Oct 27, 2011 4:53 am
by frankf
Questions on 2.7.1:

1. BindingHandler.setHyperlinkStyle(...) comments say setting the hyperlink style to null (the default) will not convert "http://" to w:hyperlink, but the default, as well as explicitly setting the style ID to null, both seem to always convert to w:hyperlink. While applyBindings does respect the null when deciding whether to "activate" the style, processString(...) seems to ignore the null style ID setting for "http://" and calls addHyperlinkToDocFrag(...), which adds the w:hyperlink. Should processString include " || hyperlinkStyleId == null" in the test of whether to call addRunToDocFrag or addHyperlinkToDocFrag?
Code: Select all
         int pos = text.indexOf("http://");

         if (pos==-1 || hyperlinkStyleId == null) {   // currently does not include " || hyperlinkStyleId == null"      
            addRunToDocFrag(sourcePart, docfrag,  text,  rPr);
            return;
         }
         // There is a hyperlink to deal with
         
         if (pos==0) {
            int spacePos = text.indexOf(" ");
            if (spacePos==-1) {
               addHyperlinkToDocFrag(sourcePart, docfrag,  text);
               return;               
            }
etc.


2. BindingHandler.applyBindings(...) accepts either WordprocessingMLPackage or JaxbXmlPart. The examples of the new recommended usage in several forum postings show passing in the main document part rather than the package. The method accepting the package seems to add a few steps before and after itself calling applyBindings with various Parts. Should the recommended call be to pass the package?

Thanks, Frank.

Re: 2.7.1 Questions

PostPosted: Thu Oct 27, 2011 9:52 am
by jason
frankf wrote:1. BindingHandler.setHyperlinkStyle(...) comments say setting the hyperlink style to null (the default) will not convert "http://" to w:hyperlink, but the default, as well as explicitly setting the style ID to null, both seem to always convert to w:hyperlink. While applyBindings does respect the null when deciding whether to "activate" the style, processString(...) seems to ignore the null style ID setting for "http://" and calls addHyperlinkToDocFrag(...), which adds the w:hyperlink. Should processString include " || hyperlinkStyleId == null" in the test of whether to call addRunToDocFrag or addHyperlinkToDocFrag?


At a quick glance, it does look like some change is required to prevent hyperlinks being added. Thanks for pointing this out.

frankf wrote:2. BindingHandler.applyBindings(...) accepts either WordprocessingMLPackage or JaxbXmlPart. The examples of the new recommended usage in several forum postings show passing in the main document part rather than the package. The method accepting the package seems to add a few steps before and after itself calling applyBindings with various Parts. Should the recommended call be to pass the package?


If you need to process headers/footers as well, pass the WordprocessingMLPackage; the method taking JaxbXmlPart processes a single part at a time. Typically you'd call this directly if you knew only your main document part needed to be processed.

cheers .. Jason

Re: 2.7.1 Questions

PostPosted: Thu Oct 27, 2011 10:33 am
by frankf
Thanks!