diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-07 09:22:00 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-07 09:50:04 +0200 |
commit | 97a6e3f22185b26745dbe27949a9b283937f98da (patch) | |
tree | 90eb361a8b5a56a03e67d0b0dabeb86830329201 /sw/source/filter | |
parent | aff642067712df55c0b5212b4c496e9391777733 (diff) |
tdf#156647: restore the explicitly set properties after applying defaults
Since commit 63c91b9cb3f73b66a915875721b0efd65b8aebac (sw HTML import: apply
default table autoformat on cells in reqif mode, 2018-08-08), defaults are
applied to imported-from-ReqIF tables. This resets the padding correctly
imported from the markup.
This change saves the previous box item, and restores the non-default line
and distance settings from it after the defaults application.
Change-Id: Ibcd8868875905fa93ab2e0443b2a8900ce1441a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155410
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 861152083455..e1e50865f624 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -1486,11 +1486,34 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, if (pTableFormat) { sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, nRow, m_nRows); + const SfxItemSet& rAttrSet = pFrameFormat->GetAttrSet(); + std::unique_ptr<SvxBoxItem> pOldBoxItem; + if (const SvxBoxItem* pBoxItem2 = rAttrSet.GetItemIfSet(RES_BOX)) + pOldBoxItem.reset(pBoxItem2->Clone()); pTableFormat->UpdateToSet(nPos, m_nRows==1, m_nCols==1, - const_cast<SfxItemSet&>(static_cast<SfxItemSet const&>( - pFrameFormat->GetAttrSet())), + const_cast<SfxItemSet&>(rAttrSet), SwTableAutoFormatUpdateFlags::Box, pFrameFormat->GetDoc()->GetNumberFormatter()); + if (pOldBoxItem) + { + // There was an old item, so it's guaranteed that there's a new item + const SvxBoxItem* pBoxItem2(rAttrSet.GetItem(RES_BOX)); + if (*pBoxItem2 != *pOldBoxItem) + { + std::unique_ptr<SvxBoxItem> pNewBoxItem(pBoxItem2->Clone()); + // Restore the box elements that could have been already set + for (auto eLine : { SvxBoxItemLine::TOP, SvxBoxItemLine::BOTTOM, + SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT }) + { + if (auto pLine = pOldBoxItem->GetLine(eLine)) + pNewBoxItem->SetLine(pLine, eLine); + if (auto nDistance = pOldBoxItem->GetDistance(eLine, true)) + pNewBoxItem->SetDistance(nDistance, eLine); + } + + pFrameFormat->SetFormatAttr(*pNewBoxItem); + } + } } } } |