Created attachment 138904 [details]
tdf104707_urlComment.odt: ODT master for creating .doc and .docx copies.
URLs in comments in .docx format are imported as plain text, losing the URL formatting/clickability.
See attachment 138876 [details] from related bug 104707
URLinComment2003.docx: MS Word 2003 created test with URL in comment
.odt and .doc files don't have this problem. Look at ww8par5.cxx:Read_F_Hyperlink for the function that creates the SwFormatINetFormat attribute.
The problem code for docx is in DomainMapper_Impl:PopFieldContext() which throws an exception when setting the "HyperLinkURL" property in the annotation. The same code is used for setting the URL property in regular text and works fine there. I'm stumped, but it should be an easy bug to solve for someone with good understanding of how .docx importing works.
I can confirm with Version: 18.104.22.168.alpha0+
Build ID: 88f6ffeb9e0c0b942c2b0bc9d60af7bb7a6caaf8
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk3;
Repro 6.3+ with ODT attachment 138904 [details]. MSO 2016 opens DOCX fine.
(In reply to Justin L from comment #0)
> The same code is used for setting the URL property in regular
> text and works fine there.
Normal text uses SwTextCursor, while the draw-based cursor uses SvxUnoTextRangeBase.
Since .doc format worked, I found that it uses Draw to ImportAsOutliner
m_pDrawEditEngine->QuickInsertField(SvxFieldItem(aURL, EE_FEATURE_FIELD), aSel);
That suggests doing something like this
SvxUnoTextRangeBase* pDrawText = dynamic_cast<SvxUnoTextRangeBase*>(xCrsr.get());
if ( pDrawText )
pDrawText->attachField( std::make_unique<SvxURLField>(pContext->GetHyperlinkURL(), "the displayed text", SvxURLFormat::AppDefault) );
proposed fix at https://gerrit.libreoffice.org/77108
Justin Luth committed a patch related to this issue.
It has been pushed to "master":
tdf#114854 writerfilter: EditEng URLs import different from SW URLs
It will be available in 6.4.0.
The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.