svx/source/table/tablehtmlimporter.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
New commits: commit 728f5eb01de33bd1f16f25d9bd7cdef6fa0909de Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Mon Dec 16 09:06:53 2024 +0100 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Mon Dec 16 11:25:23 2024 +0100 tdf#164299 fix crash in pasting HTML table Supports <colgroup> element now. Change-Id: I4fe49f3c79c567e9364a1642e716846256c6070b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178536 Tested-by: Jenkins Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> diff --git a/svx/source/table/tablehtmlimporter.cxx b/svx/source/table/tablehtmlimporter.cxx index e9e35b93fb05..d59d956dc37e 100644 --- a/svx/source/table/tablehtmlimporter.cxx +++ b/svx/source/table/tablehtmlimporter.cxx @@ -421,6 +421,16 @@ static sal_Int32 lcl_GetWidth(const HTMLOptions& options) } return 1000; } +static sal_Int32 lcl_GetSpan(const HTMLOptions& options) +{ + for (HTMLOptions::const_iterator optionIt = options.begin(); optionIt != options.end(); + ++optionIt) + { + if (optionIt->GetToken() == HtmlOptionId::SPAN) + return optionIt->GetNumber(); + } + return 1; +} void SdrTableHTMLParser::ProcToken(HtmlImportInfo* pInfo) { HTMLParser* pHtmlParser = static_cast<HTMLParser*>(pInfo->pParser); @@ -486,6 +496,23 @@ void SdrTableHTMLParser::ProcToken(HtmlImportInfo* pInfo) break; case HtmlTokenId::COL_OFF: break; + case HtmlTokenId::COLGROUP_ON: + { + const sal_Int32 nSpan = lcl_GetSpan(options); + for (sal_Int32 nCol = 0; nCol < nSpan; ++nCol) + { + std::shared_ptr<HTMLCellDefault> pDefault(mpInsDefault.release()); + maDefaultList.push_back(pDefault); + const sal_Int32 nSize = lcl_GetWidth(options) + mnLastEdge; + if (nSize > mnLastEdge) + InsertColumnEdge(nSize); + mnLastEdge = nSize; + mpInsDefault.reset(new HTMLCellDefault()); + } + } + break; + case HtmlTokenId::COLGROUP_OFF: + break; default: break;