From 1001dbaef4dec2b51c25ed8343bab6910f1219e1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 19 Mar 2021 08:42:35 +0100 Subject: ODT import: handle style name of covered cells Similar to commit 66ac8e60896f6306bed8fbb34606fd14474f19ce (sw: fix unwanted long vertical border around vertically merged Word cell, 2021-03-04), but that one was for the DOCX import / rendering. Change-Id: I394a4f062544a9774b9b40ec757cb37e72220561 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112696 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/qa/extras/odfimport/data/vmerge-cell-border.odt | Bin 0 -> 8996 bytes sw/qa/extras/odfimport/odfimport.cxx | 24 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 sw/qa/extras/odfimport/data/vmerge-cell-border.odt (limited to 'sw/qa') diff --git a/sw/qa/extras/odfimport/data/vmerge-cell-border.odt b/sw/qa/extras/odfimport/data/vmerge-cell-border.odt new file mode 100644 index 000000000000..bf387bcb183e Binary files /dev/null and b/sw/qa/extras/odfimport/data/vmerge-cell-border.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 6ab87d07a3de..ac7e34a9ebdd 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -54,6 +55,7 @@ #include #include #include +#include typedef std::map > AllBordersMap; typedef std::pair > StringSequencePair; @@ -1158,5 +1160,27 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteFirstParaDirectFormat) getProperty(xParagraph, "ParaAdjust")); } +CPPUNIT_TEST_FIXTURE(Test, testVerticallyMergedCellBorder) +{ + // Given a document with two cells, vertically merged, when loading the document: + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "vmerge-cell-border.odt"); + + // Then make sure that the first cell has a right border while the second has no right border: + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1); + SwShellCursor* pShellCursor = pWrtShell->getShellCursor(/*bBlock=*/false); + SwStartNode* pA1 = pShellCursor->Start()->nNode.GetNode().StartOfSectionNode(); + const SwAttrSet& rA1Set = pA1->GetTableBox()->GetFrameFormat()->GetAttrSet(); + CPPUNIT_ASSERT(rA1Set.GetBox().GetRight()); + SwNodeIndex aA2(*pA1->EndOfSectionNode(), 1); + const SwAttrSet& rA2Set = aA2.GetNode().GetTableBox()->GetFrameFormat()->GetAttrSet(); + + // Without the accompanying fix in place, this test would have failed, as the A2 cell also had a + // right border, even if explicitly disabled + // it. + CPPUNIT_ASSERT(!rA2Set.GetBox().GetRight()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit