sw/source/filter/ww8/wrtw8nds.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
New commits: commit 056e1fff2ed232f2a50db933fbade1c71c0c2a65 Author: Stephan Bergmann <[email protected]> AuthorDate: Tue Aug 27 21:42:46 2019 +0200 Commit: Stephan Bergmann <[email protected]> CommitDate: Wed Aug 28 14:41:00 2019 +0200 Simplify code removing the last segment from a URL This code had been introduced with 2b2f1352c72280dd25ed3bef090a3c708ee4b964 "tdf#86087 Save relative links in DOCX", but it is not clear to me what part of <https://bugs.documentfoundation.org/show_bug.cgi?id=86087> "FILESAVE FILEOPEN VIEWING: Can't open or save relative links in docx" it is meant to address. None of the tests in `make check` trigger the > else > { > // DOC > WW8Export* pWW8Export = dynamic_cast<WW8Export*>(&GetExport()); > if ( pWW8Export ) > { > SwWW8Writer& rWriter = pWW8Export->GetWriter(); > sExportedDocumentURL = rWriter.GetMedia()->GetURLObject().GetPath(); > } > } block. But what the code presumably wants to do is to create, for the DOC case, an anAbsoluteParent that is rWriter.GetMedia()->GetURLObject() with the final URL path segment removed: INetURLObject::GetPath returns the "dirname" part of a file URL's path (i.e., everything but the last path segment), and with a trailing slash removed, in the form of a filesystem pathname. That means that > INetURLObject anAbsoluteParent( sExportedDocumentURL ); creates an invalid anAbsoluteParent (because the input is not a URL), so > if ( anAbsoluteParent.GetURLPath().isEmpty() ) is true (but why not use a more obvious check of anAbsoluteParent.HasError(), or should this code also be relevant for the DOCX case?), so the following block > { > // DOC filter returns system path (without file:///) > anAbsoluteParent.setFSysPath( sExportedDocumentURL, FSysStyle::Detect ); > anAbsoluteParent.setFinalSlash(); > } recreated the URL from the filesystem pathname and added back the trailing slash. Change-Id: I9346a23680a65b6fd1ba0fa33f4565df50bd9e51 Reviewed-on: https://gerrit.libreoffice.org/78210 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 7336d8566d87..080e24bbfcdc 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -890,18 +890,14 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu if ( pWW8Export ) { SwWW8Writer& rWriter = pWW8Export->GetWriter(); - sExportedDocumentURL = rWriter.GetMedia()->GetURLObject().GetPath(); + INetURLObject parent(rWriter.GetMedia()->GetURLObject()); + parent.removeSegment(); + sExportedDocumentURL = parent.GetMainURL(INetURLObject::DecodeMechanism::NONE); } } } INetURLObject anAbsoluteParent( sExportedDocumentURL ); - if ( anAbsoluteParent.GetURLPath().isEmpty() ) - { - // DOC filter returns system path (without file:///) - anAbsoluteParent.setFSysPath( sExportedDocumentURL, FSysStyle::Detect ); - anAbsoluteParent.setFinalSlash(); - } OUString sConvertedParent = INetURLObject::GetScheme( anAbsoluteParent.GetProtocol() ) + anAbsoluteParent.GetURLPath(); OUString sParentPath = sConvertedParent.isEmpty() ? sExportedDocumentURL : sConvertedParent; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
