Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWPFParagraph: easier way to create a link. #153

Closed

Conversation

@asfgit

This comment has been minimized.

Copy link

commented Jun 4, 2019

Can one of the admins verify this patch?

@dourouc05

This comment has been minimized.

Copy link
Author

commented Jun 24, 2019

I've just added a test; is this OK to merge?

@pjfanning
Copy link
Contributor

left a comment

Test fails for me.

Testcase: testAddHyperlink took 0.007 sec
	Caused an ERROR
null
java.lang.NullPointerException
	at org.apache.poi.xwpf.usermodel.TestXWPFDocument.testAddHyperlink(TestXWPFDocument.java:194)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@dourouc05

This comment has been minimized.

Copy link
Author

commented Jul 19, 2019

The DOCX always got generated as it should have, but retrieving a newly added link could not work. What I did is call initHyperlinks in XWPFDocument each time a link is requested by ID, in case a new link was added (first emptying the hyperlinks field).

Is this approach correct? From my understanding, I think so… Performancewise, it seems problematic, as the list is rebuilt each time a request for a link is made, this is why I made a second commit to rebuild this list only when the link is not found (which is already better).

@asfgit asfgit closed this in e14c9f2 Jul 19, 2019

@pjfanning

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.