Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347428

Summary: [Webapp] Print selected topic and all subtopics doesn't work when using anchors
Product: [Eclipse Project] Platform Reporter: Lukasz H. <lukasz.hurmanski>
Component: User AssistanceAssignee: Chris Goldthorpe <cgold>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: carlos.morais, cgold, eero.helenius, natario
Version: 3.7   
Target Milestone: 3.8 M2   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 355760, 358753    
Attachments:
Description Flags
Sample document with anchor-based TOC
none
Error report
none
Infocenter's plugin list
none
Updated navActions.js
none
Patch
none
Fix version 2
none
navActions.js corresponding to Fix version 2 none

Description Lukasz H. CLA 2011-05-27 06:07:35 EDT
Build Identifier: Helios

Hi,

Print Selected Topic and All Subtopics option seems not to work properly when using anchors (example: DITA-based document with enabled chunking, produced by DITA OT).

Sample document's TOC structure:

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.toc"?>
<toc label="Test doc" topic="chunk_test.html">
<topic label="Test title 1" href="chunk_test.html#chunk_test">
<topic label="Test title 2" href="chunk_test.html#DN0948387_SNMP"/>
<topic label="Test title 3" href="chunk_test.html#chunk_test3"/>
</topic>
</toc>

More info will be provided as an attachment.


Reproducible: Always

Steps to Reproduce:
1. Open attached sample_doc.jar in Infocenter
2. Expand Test doc book
3. Click on Test title 1
4. Select Print selected topic and all subtopics
Comment 1 Lukasz H. CLA 2011-05-27 06:09:40 EDT
Created attachment 196739 [details]
Sample document with anchor-based TOC
Comment 2 Lukasz H. CLA 2011-05-27 06:11:25 EDT
Created attachment 196740 [details]
Error report
Comment 3 Lukasz H. CLA 2011-05-27 06:14:54 EDT
Created attachment 196741 [details]
Infocenter's plugin list
Comment 4 Natario Mising name CLA 2011-07-22 13:48:22 EDT
I was able to trace the problem using firebug.

Infocenter adds to the href a "path" field, like this:
 href="chunk_test.html?path=1_0_0#chunk_test"

But the printToc(errorMsg) function under navActions.js doesn't remove this and generates a print error trying to print the href with the additional field.

As it is possible to change the href directly using firebug, I removed the "?path=1_0_0" and everything started to work properly.

My guess is that the "path" field in the Contents was added as a sorting method recently and the PrintToc code stayed the same not taking this additional situation into account.
Comment 5 Lukasz H. CLA 2011-07-25 06:58:20 EDT
Changed version into 3.7 as this is also valid for Indigo.
Comment 6 Eero Helenius CLA 2011-07-25 09:26:40 EDT
Hi,

In case there's someone else looking for a solution to this problem, here's how we managed to fix it:

1. Copy plugins/org.eclipse.help.webapp_3.5.0.v20100507.jar elsewhere.

2. Unpack elsewhere/org.eclipse.help.webapp_3.5.0.v20100507.jar:

   cd elsewhere
   jar xf org.eclipse.help.webapp_3.5.0.v20100507.jar
   rm org.eclipse.help.webapp_3.5.0.v20100507.jar

3. In advanced/navActions.js, change this:

   if (indexAnchor!=-1) {
     var anchor=topic.substr(indexAnchor+1);
     topic=topic.substr(0,indexAnchor);
     parameters = "?topic="+topic+"&anchor="+anchor;
   } else {
     parameters = "?topic="+topic;
   }

   To something like this:

   if (indexAnchor != -1) {
     var anchor = topic.substr(indexAnchor+1);
     var indexPath = topic.indexOf("?path=");
     topic = topic.substr(0, indexAnchor).substr(0, indexPath);
     parameters = "?topic=" + topic + "&anchor=" + anchor;
   } else {
     parameters = "?topic=" + topic;
   }

4. Repack org.eclipse.help.webapp_3.5.0.v20100507.jar:

   jar cmf META-INF/MANIFEST.MF org.eclipse.help.webapp_3.5.0.v20100507.jar *

5. Move it back into your plugins folder:

   mv org.eclipse.help.webapp_3.5.0.v20100507.jar <plugins_dir>

6. Restart Eclipse help system.

It's a bit of a hacky solution, maybe, and we're not 100% sure whether it compromises any other functionality, but we didn't find any problems in our preliminary testing, at least.
Comment 7 Chris Goldthorpe CLA 2011-07-26 14:55:25 EDT
Thanks for filing this, targeting Eclipse 3.8.
Comment 8 Chris Goldthorpe CLA 2011-08-23 13:46:41 EDT
This problem will occur when print selected topic and all subtopics is performed on a page which is referenced more than one time from the same Toc ( and therefore gets a path parameter which in turn is required for show in contents to work correctly ).

This can be reproduced in an instance of Eclipse with the User Assistance test suite installed as follows:

Open the help system
Navigate to User Assistance Tests/manual.anchors one and two/anchor one
Select the page "anchor one" in the contents pane.
Print selected topics and all subtopics
Comment 9 Chris Goldthorpe CLA 2011-08-24 13:19:53 EDT
Created attachment 202100 [details]
Updated navActions.js

comment #6 looks to be on the right lines. I've recoded it a little differently, here is the updated version of navActions.js. I will get the fix into Eclipse 3.8, it may be too late for 3.7.1 and will have to wait for 3.7.2.
Comment 10 Chris Goldthorpe CLA 2011-08-24 13:31:12 EDT
Created attachment 202101 [details]
Patch
Comment 11 Chris Goldthorpe CLA 2011-08-24 16:31:29 EDT
The patch has been committed to the master branch. I have created Bug 355760 to track applying the fix to the 3.7 maintenance stream.
Comment 12 Chris Goldthorpe CLA 2011-08-29 14:52:28 EDT
Created attachment 202354 [details]
Fix version 2

I modified the patch so it would handle any parameters, not just ?path. The previous patch has been reverted and this patch committed.
Comment 13 Chris Goldthorpe CLA 2011-08-29 14:54:21 EDT
Created attachment 202355 [details]
navActions.js corresponding to Fix version 2
Comment 14 Chris Goldthorpe CLA 2011-09-22 14:57:31 EDT
This fix has been in the 3.8 builds for a while now and is in 3.8M2. Can someone ( Lucasz, Natario or Eero ) verify that it fixes the problem you saw.
Comment 15 Lukasz H. CLA 2011-09-23 02:33:17 EDT
Tested in RCP mode using:

Eclipse SDK

Version: 3.8.0
Build id: I20110915-1308

I can confim that it works fine.
Comment 16 Chris Goldthorpe CLA 2011-09-23 13:28:48 EDT
(In reply to comment #15)
> Tested in RCP mode using:
> 
> Eclipse SDK
> 
> Version: 3.8.0
> Build id: I20110915-1308
> 
> I can confim that it works fine.

Setting status to VERIFIED

I will open another bug to track backporting this fix to 3.7.2