[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt | 45 ++ sw/qa/extras/uiwriter/uiwriter8.cxx| 27 ++ sw/source/core/doc/DocumentContentOperationsManager.cxx|9 +- 3 files changed, 79 insertions(+), 2 deletions(-) New commits: commit af64ee2f4a7120ccb8f22eab5dfcd626266fde4e Author: Mike Kaganski AuthorDate: Thu Nov 30 17:53:26 2023 +0300 Commit: Michael Stahl CommitDate: Fri Dec 1 11:06:47 2023 +0100 tdf#158459: call DeleteAndJoin in strict reverse order The crash was caused by removal of a paragraph break (pointed to by a PaM returned by pDelPam->GetNext()), that resulted in merge of the node pDelPam pointed to, with the previous node. The destructin of the node made pDelPam dangle. In debug builds, an assertion failed in destructor of SwContentIndexReg. I.e., since the code always called DeleteAndJoin on pDelPam->GetNext(), the processing went from second-to-last deletion towards the begin of the document, and the last deletion (represented by pDelPam) was handled last, when GetNext call wrapped. This change makes sure that the order is strict, from last to first. Change-Id: I5cb7fe2f06d4138d3c445eeca8220f0a87a82626 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160158 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 9c22a72a2fc92146d24c6b673d9c07b1e6ff83f2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160049 Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt b/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt new file mode 100644 index ..bdd03bc0be70 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt @@ -0,0 +1,45 @@ + + +http://purl.org/dc/elements/1.1/; xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + + + + + + + x + 2000-01-01 + + + + + + + x + 2000-01-02 + + + + + + + x + 2000-01-03 + + + + + + + x + 2000-01-04 + + + + + + a + bcdef + + + \ No newline at end of file diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 5bcc224ae24f..456852a85ecf 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -2767,6 +2767,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf73483) assertXPath(pXml, para_style_path, "master-page-name", "Right_20_Page"); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf158459) +{ +createSwDoc("tdf158459_tracked_changes_across_nodes.fodt"); +SwDoc* pDoc = getSwDoc(); + +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +CPPUNIT_ASSERT(pWrtShell); +pWrtShell->FwdPara(); // Skip first paragraph +pWrtShell->EndOfSection(true); // Select everything to the end + +SwDoc aClipboard; +pWrtShell->Copy(aClipboard); // This must not crash + +pWrtShell->SelAll(); +pWrtShell->Delete(); +pWrtShell->Paste(aClipboard); // Replace everything with the copied stuff + +SwNodes& rNodes = pDoc->GetNodes(); +SwNodeIndex aIdx(rNodes.GetEndOfExtras()); +SwContentNode* pContentNode = rNodes.GoNext(); +CPPUNIT_ASSERT(pContentNode); +SwTextNode* pTextNode = pContentNode->GetTextNode(); +CPPUNIT_ASSERT(pTextNode); +// Check that deleted parts (paragraph break, "c", "e") haven't been pasted +CPPUNIT_ASSERT_EQUAL(OUString("abdf"), pTextNode->GetText()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 81c8c14e1a4b..6b1404ecbf0b 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -440,11 +440,16 @@ namespace ::sw::UndoGuard const undoGuard(rDestDoc.GetIDocumentUndoRedo()); +// At this point, pDelPam points to the last of maybe several disjoint selections, organized +// in reverse order in document (so every GetNext() returns a PaM closer to document start, +// until wrap to pDelPam). Removal of the selections must be from last in document to first, +// to avoid situations when another PaM in chain points into the node that will be destroyed +// (joined to previous) by removal of the currently processed PaM. do { -rDestDoc.getIDocumentContentOperations().DeleteAndJoin( *pDelPam->GetNext() ); +rDestDoc.getIDocumentContentOperations().DeleteAndJoin(*pDelPam);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/split-table-merged-border.odt |binary sw/qa/core/layout/paintfrm.cxx | 49 +++ sw/source/core/layout/paintfrm.cxx | 24 + 3 files changed, 63 insertions(+), 10 deletions(-) New commits: commit 7a1b3f58080b301929269c0b4a5310851a0ee2bb Author: Miklos Vajna AuthorDate: Wed Nov 15 08:24:39 2023 +0100 Commit: Xisco Fauli CommitDate: Thu Nov 30 10:25:18 2023 +0100 tdf#157911 sw floattable: fix inconsistent inferred bottom border on split The bugdoc has a split table between page 1 and page 2. The last row of page 1 has a half bottom border: it starts on the left of the table, but finishes earlier than the right of the table. This is since commit 08aea5526c75ff4c5385e960bd940f10ffa19cd5 (tdf#156351 sw floattable: fix missing bottom border in master table, 2023-08-21). The trouble is that Writer table borders are really at a cell-level (and not at row or table level), the current partial border happens because the first row has merged cells and the last row on page 1 doesn't have merged cells, so the layout can't do a 1:1 mapping between the first row and last row cells. It's also far from clear if the fixed result should be no bottom border or a table-width bottom border: - Word documents can have cell-level borders (where no inferred border is wanted) and table-level borders (where inferred borders are wanted), see the tdf#156351 bugdoc for a case where such inferring is wanted - In case only cell-level borders are defined, then Word doesn't do such inferring Fix the problem by always inferring such borders, because: - Writer already did this in some cases for a long time, see commit a4da71fb824f2d4ecc7c01f4deb2865ba52f5f4c (INTEGRATION: CWS fmebugs04 (1.115.46); FILE MERGED 2008/05/13 13:56:19 fme 1.115.46.2: #i9860# Top border for tables - correction 2008/05/13 13:49:23 fme 1.115.46.1: #i9860# Top border for tables, 2008-06-06) - The Word UI creates table borders by default, so the majority of the DOCX documents also want this inferring An alternative could be to only do such inferring for Word documents with a compat flag, but that looks poor, given that Word doesn't always do such inferring itself, either. Change-Id: I052e4591e99d066c3109e8ab8b590e97c8aebd36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159429 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 47d824dd167eb34b08e5aec7141d2d9e6e996b34) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159588 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/layout/data/split-table-merged-border.odt b/sw/qa/core/layout/data/split-table-merged-border.odt new file mode 100644 index ..122bfd473c7c Binary files /dev/null and b/sw/qa/core/layout/data/split-table-merged-border.odt differ diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx index ad09405fe3fb..baa858020acf 100644 --- a/sw/qa/core/layout/paintfrm.cxx +++ b/sw/qa/core/layout/paintfrm.cxx @@ -109,6 +109,55 @@ CPPUNIT_TEST_FIXTURE(Test, testRTLBorderMerge) // i.e. the 2nd and 5th vertical border was missing. CPPUNIT_ASSERT_EQUAL(6, nVerticalBorders); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitTableMergedBorder) +{ +// Given a document with a split table, first row in frame 1 has merged cells: +createSwDoc("split-table-merged-border.odt"); +SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); +SwDocShell* pShell = pTextDoc->GetDocShell(); + +// When rendering that document: +std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + +// Then make sure that the master table has a bottom border with the correct widths: +MetafileXmlDump aDumper; +xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); +xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"); +xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; +std::set aHorizontalBorderStarts; +std::set aHorizontalBorderEnds; +// Collect the horizontal borders: +for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) +{ +xmlNodePtr pStart = pXmlNodes->nodeTab[i]; +xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; +xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); +xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); +sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); +sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); +if (nStartY != nEndY) +{ +// Vertical border. +continue; +} + +xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x")); +xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x")); +sal_Int32 nStartX =
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/placeholder.fodt |9 sw/qa/core/text/text.cxx | 28 + sw/source/core/text/itrform2.cxx |2 sw/source/core/text/porfld.cxx| 69 +++--- sw/source/core/text/porfld.hxx| 24 ++- sw/source/core/text/txtfld.cxx|3 - 6 files changed, 125 insertions(+), 10 deletions(-) New commits: commit 696f664b3e901077d62d0dc6fd1878d7ea29821a Author: Mike Kaganski AuthorDate: Tue Oct 24 23:20:30 2023 +0300 Commit: Michael Stahl CommitDate: Fri Oct 27 11:32:14 2023 +0200 Export text placeholder fields as PDF form fields Inspired by commit 82d90529dc2b3cb8359dec78852cbd910a66d275 (sw content controls, rich text: add initial PDF export, 2022-09-12). Change-Id: I16cc45b6f2e070ab9dc83ba15e3c66ca0caa5e53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158407 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158480 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/text/data/placeholder.fodt b/sw/qa/core/text/data/placeholder.fodt new file mode 100644 index ..01cb60437618 --- /dev/null +++ b/sw/qa/core/text/data/placeholder.fodt @@ -0,0 +1,9 @@ + + + + + + placeholder text + + + \ No newline at end of file diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 790f2f32415f..c68a0fa99cbe 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -1174,6 +1174,34 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRichContentControlPDF) CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount()); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testPlaceholderFieldPDF) +{ +std::shared_ptr pPDFium = vcl::pdf::PDFiumLibrary::get(); +if (!pPDFium) +return; + +// Given a file with a text-type placeholder field: +createSwDoc("placeholder.fodt"); + +// When exporting to PDF (default setting is "create a PDF form"): +save("writer_pdf_Export"); + +// Then make sure that a fillable form widget is emitted: +std::unique_ptr pPdfDocument = parsePDFExport(); +std::unique_ptr pPage = pPdfDocument->openPage(0); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 0 +// i.e. the placeholder field was just exported as normal text. +CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount()); +std::unique_ptr pAnnotation = pPage->getAnnotation(0); +CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType()); + +// Also verify that the widget description is correct: +CPPUNIT_ASSERT_EQUAL(OUString("reference text"), + pAnnotation->getFormFieldAlternateName(pPdfDocument.get())); +} + CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testNumberPortionFormat) { // Given a document with a single paragraph, direct formatting asks 24pt font size for the diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 51c2d7a9423f..8d52962bb7f7 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1182,7 +1182,7 @@ SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo ) const } } assert(2 <= sal_Int32(nFieldLen)); -pPor = new SwFieldPortion(aFieldName, nullptr, false, nFieldLen); +pPor = new SwFieldPortion(aFieldName, nullptr, nFieldLen); } else { diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 66f39644ffed..580b4a2635a7 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -22,10 +22,14 @@ #include #include #include + +#include #include #include #include #include +#include +#include #include #include #include "porlay.hxx" @@ -44,6 +48,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -59,7 +64,7 @@ SwFieldPortion *SwFieldPortion::Clone( const OUString ) const } // #i107143# // pass placeholder property to created instance. -SwFieldPortion* pClone = new SwFieldPortion( rExpand, std::move(pNewFnt), m_bPlaceHolder ); +SwFieldPortion* pClone = new SwFieldPortion(rExpand, std::move(pNewFnt)); pClone->SetNextOffset( m_nNextOffset ); pClone->m_bNoLength = m_bNoLength; return pClone; @@ -73,13 +78,13 @@ void SwFieldPortion::TakeNextOffset( const SwFieldPortion* pField ) m_bFollow = true; } -SwFieldPortion::SwFieldPortion(OUString aExpand, std::unique_ptr pFont, bool bPlaceHold, TextFrameIndex const nFieldLen) +SwFieldPortion::SwFieldPortion(OUString aExpand, std::unique_ptr pFont, TextFrameIndex const nFieldLen) : m_aExpand(std::move(aExpand)), m_pFont(std::move(pFont)), m_nNextOffset(0) , m_nNextScriptChg(COMPLETE_STRING), m_nFieldLen(nFieldLen),
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf157132.odt |binary sw/qa/extras/uiwriter/uiwriter8.cxx | 42 +++ sw/source/core/table/swtable.cxx |2 + 3 files changed, 44 insertions(+) New commits: commit 0bd6d55a35688d92c411d3ba647c3fcf8de263b5 Author: Xisco Fauli AuthorDate: Wed Oct 25 18:07:18 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Oct 26 15:48:59 2023 +0200 tdf#157132: restore behaviour for TBL_RELBOXNAME Regression from 8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7 "8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7" TBL_RELBOXNAME was no longer calling ToRelBoxNm Change-Id: I296d84ab955b4415bf9173ccf72b4d51e55152f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158454 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 43419accf5aa27a9bd2f2a97cbf969fb30871277) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158437 Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/uiwriter/data/tdf157132.odt b/sw/qa/extras/uiwriter/data/tdf157132.odt new file mode 100644 index ..ddb9522bf835 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf157132.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 43ef6d9ccc2d..a669192fdc25 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -1480,6 +1480,48 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573) CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132) +{ +createSwDoc("tdf157132.odt"); + +SwDoc* pDoc = getSwDoc(); +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + +// Go to cell A2 +pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1); + +// Select A2 and A3 and copy +pWrtShell->Down(/*bSelect=*/true, /*nCount=*/1); + +dispatchCommand(mxComponent, ".uno:Copy", {}); + +// Go to A4 and paste +pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1); + +dispatchCommand(mxComponent, ".uno:Paste", {}); + +uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xTables(xTextTablesSupplier->getTextTables(), +uno::UNO_QUERY); + +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + +uno::Reference xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); + +uno::Reference xCellA2(xTextTable->getCellByName("A2"), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("2"), xCellA2->getString()); +uno::Reference xCellA3(xTextTable->getCellByName("A3"), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("3"), xCellA3->getString()); +uno::Reference xCellA4(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + +// Without the fix in place, this test would have failed with +// - Expected: 6 +// - Actual : 2 +CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString()); +uno::Reference xCellA5(xTextTable->getCellByName("A5"), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf147938) { createSwDoc("tdf147938.fodt"); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index e5a2ccba936f..ff06bf510195 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1722,6 +1722,8 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags) { if(eFlags == TBL_BOXPTR) pBoxFormula->TryBoxNmToPtr(); +else if(eFlags == TBL_RELBOXNAME) +pBoxFormula->ToRelBoxNm(this); else pBoxFormula->ChangeState(); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-nested-rowspan.docx |binary sw/qa/core/layout/tabfrm.cxx | 11 + sw/source/core/layout/tabfrm.cxx | 37 ++ 3 files changed, 48 insertions(+) New commits: commit 72f035790a28ad44ce1242f87eb71eb5241cbb17 Author: Miklos Vajna AuthorDate: Fri Oct 20 08:57:08 2023 +0200 Commit: Xisco Fauli CommitDate: Fri Oct 20 21:08:08 2023 +0200 tdf#157590 sw floattable: avoid hang in the nested + row span case Regression from commit 905962db870e9d1cf1dcf3bd1be44c347cddafe1 (sw floattable: handle AllowOverlap==false in the layout, 2023-08-10), the document load resulted in a hang due to a layout loop. What happens is that SwTabFrame::MakeAll() first does a Split(), but the problematic row has cells with rowspans, and once this is combined with multi-page nested floating tables, we move all the content to the next page (we only leave a stub table frame on the old page), so the next time SwTabFrame::MakeAll() is called, we do a Join(), and this leads to a loop. The traditional Writer way here would be to add a loop control, but we can do a little bit better: nobody really asked for row span handling with nested floating tables, so just don't split rows with row span in this case, move the entire row forward instead. This is enough to avoid the layout loop, and a next iteration can still use SwFlowFrame::MoveBwd() / SwFlowFrame::MoveFwd() to split the complex row. The bug is fairly hard to hit, any naive simplification to the original bugdoc leads to a working layout. Carefully keeping the size of the document, it's possible to at least simplify the content of the table cells (while keeping their size unchanged), so we avoid half of the tables and half of the shapes for a faster test case. Change-Id: Ib14154200c45ecb7f59e85f9f4f1fe0124c4256e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158228 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 8e03dfd6a4bff4eabf779ace9b758b49cf80f8ba) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158165 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/layout/data/floattable-nested-rowspan.docx b/sw/qa/core/layout/data/floattable-nested-rowspan.docx new file mode 100644 index ..48cbdbfe59c3 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested-rowspan.docx differ diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx index a5e448081b0f..1659cf0df6fd 100644 --- a/sw/qa/core/layout/tabfrm.cxx +++ b/sw/qa/core/layout/tabfrm.cxx @@ -98,6 +98,17 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTable) CPPUNIT_ASSERT(!pTab->GetFollow()); } } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedRowSpan) +{ +// Given a document with nested floating tables and a row with rowspan cells at page boundary: +// When loading that document: +// Without the accompanying fix in place, this test would have resulted in a layout loop. +createSwDoc("floattable-nested-rowspan.docx"); + +// Then make sure the resulting page count matches Word: +CPPUNIT_ASSERT_EQUAL(6, getPages()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 51c29f899b77..079377aedb3c 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2644,6 +2644,43 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) // See if this is a split fly that can also grow. auto pUpperFly = static_cast(GetUpper()); bFlySplit = pUpperFly->IsFlySplitAllowed(); + +if (bFlySplit) +{ +// See if this is a nested split fly where the inner table also has +// rowspans. +SwTextFrame* pAnchorCharFrame = pUpperFly->FindAnchorCharFrame(); +if (pAnchorCharFrame && pAnchorCharFrame->IsInFly()) +{ +// Find the row we'll split. +SwTwips nRemaining += aRectFnSet.YDiff(nDeadLine, aRectFnSet.GetTop(getFrameArea())); +nRemaining -= aRectFnSet.GetTopMargin(*this); +const SwFrame* pRow = Lower(); +for (; pRow->GetNext(); pRow = pRow->GetNext()) +{ +if (nRemaining < aRectFnSet.GetHeight(pRow->getFrameArea())) +{ +break; +} + +nRemaining -= aRectFnSet.GetHeight(pRow->getFrameArea()); +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/txtnode/txtnode.cxx| 79 +++--- sw/source/core/txtnode/atrref.cxx | 20 ++--- 2 files changed, 55 insertions(+), 44 deletions(-) New commits: commit 01134e5742f362b0dced135fd49c2213001d15eb Author: Matti Tyrväinen AuthorDate: Mon Oct 16 09:23:15 2023 -0700 Commit: Xisco Fauli CommitDate: Fri Oct 20 21:07:52 2023 +0200 Revert change to Reference Mark behavior to avoid regression Hotfix for tdf#157287, unfixes tdf#81720. Setting the DontExpand flag would solve tdf#81720, but causes regression due to other code that depends on the old behavior. This patch restores the old behavior without reverting the UpdateFieldContent refactor included in 146941; testDontExpandRefmark is commented out for now. Change-Id: Ibaeacabec304473db63df9334e2fef46c6d9acc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158059 Reviewed-by: Matti Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit 58e5e3208a4257a8d9f2e28d8e2d304677aa6980) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158164 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index 4a4bf9901a2f..757d6c830247 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -247,44 +247,47 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testSplitNodeSuperscriptCopy) CPPUNIT_ASSERT(!aSet.HasItem(RES_CHRATR_ESCAPEMENT)); } -CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDontExpandRefmark) -{ -// Given a document with a refmark: -createSwDoc(); - -uno::Sequence aArgs = { -comphelper::makePropertyValue("TypeName", uno::Any(OUString("SetRef"))), -comphelper::makePropertyValue( -"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} RNDpyJknp173F"))), -comphelper::makePropertyValue("Content", uno::Any(OUString("foo"))), -}; -dispatchCommand(mxComponent, ".uno:InsertField", aArgs); - -SwDoc* pDoc = getSwDoc(); -SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); -SwPosition& rCursor = *pWrtShell->GetCursor()->GetPoint(); -SwTextNode* pTextNode = rCursor.GetNode().GetTextNode(); -std::vector aAttrs -= pTextNode->GetTextAttrsAt(rCursor.GetContentIndex(), RES_TXTATR_REFMARK); - -auto& rRefmark = const_cast(aAttrs[0]->GetRefMark()); -auto pTextRefMark = const_cast(rRefmark.GetTextRefMark()); - -// When typing after the refmark... -pWrtShell->SttEndDoc(/*bStt=*/true); -pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 3, /*bBasicCall=*/false); -pWrtShell->Insert(" bar"); - -// and skipping back to insert a comma after the refmark -pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 4, /*bBasicCall=*/false); -pWrtShell->Insert(","); - -// Without the accompanying fix in place, this test would have failed with: -// - Expected: 3 -// - Actual : 4 -// i.e. the reference mark expanded -CPPUNIT_ASSERT_EQUAL(3, static_cast(*pTextRefMark->End())); -} +/* FIXME: behavior change reverted due to regression; + * see sw/source/core/txtnode/atrref.cxx + *CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDontExpandRefmark) + *{ + *// Given a document with a refmark: + *createSwDoc(); + * + *uno::Sequence aArgs = { + *comphelper::makePropertyValue("TypeName", uno::Any(OUString("SetRef"))), + *comphelper::makePropertyValue( + *"Name", uno::Any(OUString("ZOTERO_ITEM CSL_CITATION {} RNDpyJknp173F"))), + *comphelper::makePropertyValue("Content", uno::Any(OUString("foo"))), + *}; + *dispatchCommand(mxComponent, ".uno:InsertField", aArgs); + * + *SwDoc* pDoc = getSwDoc(); + *SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + *SwPosition& rCursor = *pWrtShell->GetCursor()->GetPoint(); + *SwTextNode* pTextNode = rCursor.GetNode().GetTextNode(); + *std::vector aAttrs + *= pTextNode->GetTextAttrsAt(rCursor.GetContentIndex(), RES_TXTATR_REFMARK); + * + *auto& rRefmark = const_cast(aAttrs[0]->GetRefMark()); + *auto pTextRefMark = const_cast(rRefmark.GetTextRefMark()); + * + *// When typing after the refmark... + *pWrtShell->SttEndDoc(true); + *pWrtShell->Right(SwCursorSkipMode::Chars, false, 3, false); + *pWrtShell->Insert(" bar"); + * + *// and skipping back to insert a comma after the refmark + *pWrtShell->Left(SwCursorSkipMode::Chars, false, 4, false); + *pWrtShell->Insert(","); + * + *// Without the accompanying fix in place, this test would have failed with: + *// - Expected: 3 + *// - Actual : 4 + *// i.e. the reference mark expanded + *CPPUNIT_ASSERT_EQUAL(3, static_cast(*pTextRefMark->End())); + *} + */ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testInsertDropDownContentControlTwice) { diff --git a/sw/source/core/txtnode/atrref.cxx
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/content-control-header.docx |binary sw/qa/core/text/itrform2.cxx | 27 +++ sw/source/core/text/itrform2.cxx | 10 +++- 3 files changed, 36 insertions(+), 1 deletion(-) New commits: commit e1c06c2f9a7498278b8be55dc4bb79aad7b6874e Author: Miklos Vajna AuthorDate: Tue Oct 10 20:06:39 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Oct 16 11:41:00 2023 +0200 tdf#157593 sw content control, PDF export: fix headers/footers Regression from commit de90c192cb8f1f03a4028493d8bfe9a127a76b2a (sw content controls, plain text: enable DOCX filter with data binding, 2022-09-19), the PDF export of the bugdoc was broken, content was missing on page 2. Looking at the problem at a higher level, PDF form control in a header or footer makes no sense, since then you would get multiple answers for the same question. Fix the problem by disabling the mapping of Writer content controls to PDF widgets in headers and footers. Note that the original motivation is probably around providing a way to set the document header via scripting, without touching document.xml or headerN.xml. This valid use-case still works after this fix, we still update the value of the content control from data binding. (cherry picked from commit 5dff1f3a995a8e78a156214fd9c32b1005337183) Change-Id: I969682bf90026236276992dd6b6099e50dffe949 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157783 Reviewed-by: Xisco Fauli Tested-by: Xisco Fauli diff --git a/sw/qa/core/text/data/content-control-header.docx b/sw/qa/core/text/data/content-control-header.docx new file mode 100644 index ..c65ac1d41cac Binary files /dev/null and b/sw/qa/core/text/data/content-control-header.docx differ diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx index 637396a01c2e..187eb9ab678e 100644 --- a/sw/qa/core/text/itrform2.cxx +++ b/sw/qa/core/text/itrform2.cxx @@ -112,6 +112,33 @@ CPPUNIT_TEST_FIXTURE(Test, testFlyMinimalWrap) // text frames in the body frame, not 2. CPPUNIT_ASSERT(!pPage2Para2->GetNext()); } + +CPPUNIT_TEST_FIXTURE(Test, testContentControlHeaderPDFExport) +{ +// Given a document with a content control in the header: +createSwDoc("content-control-header.docx"); + +// When exporting to PDF: +save("writer_pdf_Export"); + +// Then make sure all the expected text is there on page 2: +std::unique_ptr pPdfDocument = parsePDFExport(); +std::unique_ptr pPage2 = pPdfDocument->openPage(1); +int nTextCount = 0; +for (int i = 0; i < pPage2->getObjectCount(); ++i) +{ +std::unique_ptr pObject = pPage2->getObject(i); +if (pObject->getType() == vcl::pdf::PDFPageObjectType::Text) +{ +++nTextCount; +} +} +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 3 +// - Actual : 2 +// i.e. not all of header, heading and body text was there on page 2, content was lost. +CPPUNIT_ASSERT_EQUAL(3, nTextCount); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 3aaab7a9f258..c44b831d2a63 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -974,8 +974,16 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co return false; } -// Check if this is the first content control portion of this content control. SwTextNode* pTextNode = pContentControl->GetTextNode(); +SwDoc& rDoc = pTextNode->GetDoc(); +if (rDoc.IsInHeaderFooter(*pTextNode)) +{ +// Form control in header/footer makes no sense, would allow multiple values for the same +// control. +return false; +} + +// Check if this is the first content control portion of this content control. sal_Int32 nStart = m_pTextContentControl->GetStart(); sal_Int32 nEnd = *m_pTextContentControl->GetEnd(); TextFrameIndex nViewStart = rInf.GetTextFrame()->MapModelToView(pTextNode, nStart);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx |binary sw/qa/core/layout/flycnt.cxx | 26 +++ sw/source/core/layout/flycnt.cxx | 26 --- 3 files changed, 48 insertions(+), 4 deletions(-) New commits: commit a9d17d9a7ede982c8762a0c04ff95ac4200fda89 Author: Miklos Vajna AuthorDate: Wed Oct 11 08:32:02 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 11 13:38:53 2023 +0200 sw floattable, crashtesting: fix PDF export of ooo91654-1.doc Regression from 89a75cd194371002247d0138e759835bc673f7b0 (tdf#126449 sw floattable: DOC import: handle inner floating table, 2023-10-04), the document crashed Writer layout when exporting to PDF, which triggers a layout calculation. The trouble seems to be that in case the split fly is anchored in a table which is in a section, then we assume that we can create a section on the next page and move the follow fly frame there, which will mean the follow anchor won't be in a table anymore. Fix this by not moving the follow anchor explicitly, similar to what the nested floating table (inline or floating outer table) code does. The layout will later figure out that the available space is not enough, split the outer table for us, which will lead to a correct result. Note that the original bugdoc is DOC, but just saving it as-is in Word hides the problem, so it's not easy to minimize the reproducer. Instead create a similar DOCX reproducer from scratch. Change-Id: I769615af467ccaa88057ab322da2865f11d3d2ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157803 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 6b9378154f9b504b9e924fe4565df444786e7d73) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157782 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx new file mode 100644 index ..ff329ecb5a5f Binary files /dev/null and b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 37b255945d9e..325b0078ecb0 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -1157,6 +1157,32 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDelEmpty) // Then make sure that the page count matches Word: CPPUNIT_ASSERT_EQUAL(7, getPages()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTableInSection) +{ +// Given a document where page 2 and page 3 has a floating table inside an inline table, inside +// a section: +// Without the accompanying fix in place, this test would have crashed, we created a follow +// anchor which was marked as "in table", but had no table parent. +createSwDoc("floattable-in-inltbl-in-sect.docx"); + +// Then make sure that the floating table is on page 2 and page 3: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(!pPage1->GetSortedObjs()); +auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage3); +CPPUNIT_ASSERT(pPage3->GetSortedObjs()); +SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index faf991ddd9d2..09fd24f28c4a 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1579,11 +1579,30 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) SwLayoutFrame *pLayLeaf = nullptr; // Look up the first candidate. SwSectionFrame* pFlyAnchorSection = pFlyAnchor ? pFlyAnchor->FindSctFrame() : nullptr; +bool bNesting = false; if (pFlyAnchorSection) { -// We can't just move the split anchor to the next page, that would be outside the section. -// Rather split that section as well. -pLayLeaf = pFlyAnchorSection->GetNextSctLeaf(eMakePage); +// The anchor is in a section. +if (pFlyAnchor) +{ +SwTabFrame* pFlyAnchorTab = pFlyAnchor->FindTabFrame(); +if (pFlyAnchorTab) +{ +// The anchor is in table as well. +if (pFlyAnchorTab->FindSctFrame() == pFlyAnchorSection) +{ +// We're in a table-in-section, no
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/fly-minimal-wrap.docx |binary sw/qa/core/text/itrform2.cxx | 30 + sw/qa/core/text/text.cxx |4 +-- sw/source/core/text/itrform2.cxx | 23 -- 4 files changed, 53 insertions(+), 4 deletions(-) New commits: commit f3ff9c42de8e37fef48e841eeff9732ef01bd460 Author: Miklos Vajna AuthorDate: Tue Oct 10 08:23:14 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Oct 10 11:02:01 2023 +0200 tdf#157571 sw floattable: fix incorrect blank space after table-in-shape Regression from a4af5432753408c4eea8a8d56c2f48202160c5fe (tdf#120262 sw floattable, legacy: fix text wrap around fly when no content fits, 2023-07-17), the bugdoc has a shape which contains a table, and lots of empty paragraphs next to it wrap around the shape. Writer didn't wrap these empty paragraphs, so some of the page 1 content was shifted to page 2. What happened here is that in case there is a really small space for the wrapping text around a floating object, then Word has some minimal limit. If the available horizontal space is smaller than the limit, we don't even try to wrap, even if the content (an empty paragraph) would fit. It was assumed that this limit is the shape for normal anchored objects and floating tables, but the two bugdocs show that there are two different limits here. Fix the problem by going back to MINLAY as the default limit where we start wrapping, and only increase that to TEXT_MIN_SMALL when wrapping around floating tables. That fixes the bugdoc and keeps the older floating table use-case working as well. This also allows reverting changes to testParaUpperMarginFlyIntersect, to assert the non-floating-table case again. Change-Id: I8f8a776c6ad5bdfa0ee4f197b600463fef6431f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157743 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 4a5fb05d5e2448453477ce14862a8cf9846ecb49) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157717 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/text/data/fly-minimal-wrap.docx b/sw/qa/core/text/data/fly-minimal-wrap.docx new file mode 100644 index ..f5955d29d0ed Binary files /dev/null and b/sw/qa/core/text/data/fly-minimal-wrap.docx differ diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx index e190bed46f33..637396a01c2e 100644 --- a/sw/qa/core/text/itrform2.cxx +++ b/sw/qa/core/text/itrform2.cxx @@ -82,6 +82,36 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableLegacyWrapEmptyParagraph) const SwSortedObjs& rPageObjs2 = *pPage2->GetSortedObjs(); CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs2.size()); } + +CPPUNIT_TEST_FIXTURE(Test, testFlyMinimalWrap) +{ +// Given a document with a first page that has a shape and a table in it (not floating table), +// some empty paragraphs wrapping around the shape: +createSwDoc("fly-minimal-wrap.docx"); + +// When calculating the layout: +calcLayout(); + +// Then make sure the wrap happens, so the 2nd page only has 2 paragraphs: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage); +CPPUNIT_ASSERT(pPage->GetSortedObjs()); +const SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(2), rPageObjs.size()); +auto pPage2 = dynamic_cast(pPage->GetNext()); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(!pPage2->GetSortedObjs()); +SwLayoutFrame* pBody2 = pPage2->FindBodyCont(); +SwFrame* pPage2Para1 = pBody2->GetLower(); +CPPUNIT_ASSERT(pPage2Para1); +SwFrame* pPage2Para2 = pPage2Para1->GetNext(); +CPPUNIT_ASSERT(pPage2Para2); +// Without the accompanying fix in place, this test would have failed, the second page had 19 +// text frames in the body frame, not 2. +CPPUNIT_ASSERT(!pPage2Para2->GetNext()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index eec7292b6b68..790f2f32415f 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -1286,10 +1286,10 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect) nHeight += getXPath(pXmlDoc, xPath, "height").toInt32(); } // Without the accompanying fix in place, this test would have failed with: -// - Expected: 542 (~500) +// - Expected: 521 (~500) // - Actual : 857 (~1000) // I.e. both upper and lower margin was taken into account. -CPPUNIT_ASSERT_EQUAL(542, nHeight); +CPPUNIT_ASSERT_EQUAL(521, nHeight); } CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810) diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt | 27 ++ sw/qa/extras/htmlexport/htmlexport.cxx | 11 sw/source/filter/html/htmltabw.cxx | 11 3 files changed, 38 insertions(+), 11 deletions(-) New commits: commit 11254d0af28464d04f6c980a0f8f3ce3ba0dd423 Author: Mike Kaganski AuthorDate: Fri Oct 6 20:19:28 2023 +0300 Commit: Xisco Fauli CommitDate: Mon Oct 9 16:03:34 2023 +0200 tdf#157643: Drop extra cellless rows, a "substitute" for bold borders Change-Id: Ic98bec72ed14623c880fad3b881d72ee13395a0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157670 Tested-by: Jenkins Reviewed-by: Mike Kaganski Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157698 diff --git a/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt b/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt new file mode 100644 index ..a3c53a070784 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt @@ -0,0 +1,27 @@ + + +http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:oooc="http://openoffice.org/2004/calc; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:tableooo="http://openoffice.org/2009/table; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns :css3t="http://www.w3.org/TR/css3-text/; xmlns:officeooo="http://openoffice.org/2009/office; office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + + + + + + + + + + + + A1 + + + + + A2 + + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index b6f55cebcd3f..d5b94dcc28d3 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -2746,6 +2746,17 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf156647_CellPaddingRoundtrip) } } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf157643_WideHBorder) +{ +// Given a document with a table with a wide border between its two rows: +createSwDoc("table_with_wide_horizontal_border.fodt"); +// When exporting to reqif-xhtml: +ExportToReqif(); +// Make sure that there's no extra tr's: +xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); +assertXPath(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr", 2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index d7e5e107969d..8613f37b073d 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -863,17 +863,6 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, { --nSkipRows; } -if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->m_bBottomBorder && -pRow2->m_nBottomBorder > SvxBorderLineWidth::Thin ) -{ -for( auto nCnt = (pRow2->m_nBottomBorder / SvxBorderLineWidth::Thin) - 1; nCnt; --nCnt ) -{ -
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-del-empty.docx |binary sw/qa/core/layout/flycnt.cxx | 12 sw/source/core/layout/flycnt.cxx | 11 --- 3 files changed, 12 insertions(+), 11 deletions(-) New commits: commit 840606ffb872e280228cd5144bf22541d1f94214 Author: Miklos Vajna AuthorDate: Thu Oct 5 08:14:41 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Oct 5 11:25:40 2023 +0200 sw floattable, crashtesting: fix PDF export of fdo56210-3.docx The bugdoc crashed on PDF export: heap-use-after-free on address 0x614000205148 at pc 0x7fb757347d7a bp 0x7fffeff17170 sp 0x7fffeff17168 READ of size 8 at 0x614000205148 thread T0 #2 0x7fb75785959b in SwFrame::GetDrawObjs() sw/source/core/inc/frame.hxx:569:66 #3 0x7fb75a802a60 in SwObjectFormatterTextFrame::InvalidatePrevObjs(SwAnchoredObject&) sw/source/core/layout/objectformattertxtfrm.cxx:494:50 #4 0x7fb75a7fe371 in SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool) sw/source/core/layout/objectformattertxtfrm.cxx:155:13 #5 0x7fb75a7ee2c3 in SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame*) sw/source/core/layout/objectformatter.cxx:413:19 #6 0x7fb75a807bff in SwObjectFormatterTextFrame::DoFormatObjs() sw/source/core/layout/objectformattertxtfrm.cxx:337:20 freed by thread T0 here: #1 0x7fb75b7a0b06 in SwTextFrame::~SwTextFrame() sw/source/core/text/txtfrm.cxx:988:1 #2 0x7fb75ab070e3 in SwFrame::DestroyFrame(SwFrame*) sw/source/core/layout/ssfrm.cxx:397:9 #3 0x7fb75b1925be in SwTextFrame::JoinFrame() sw/source/core/text/frmform.cxx:763:5 #4 0x7fb75a4dcd9e in SwFlyAtContentFrame::DelEmpty() sw/source/core/layout/flycnt.cxx:1748:26 #5 0x7fb75a3e3764 in SwFlowFrame::MoveSubTree(SwLayoutFrame*, SwFrame*) sw/source/core/layout/flowfrm.cxx:713:28 #6 0x7fb75a418138 in SwFlowFrame::MoveFwd(bool, bool, bool) sw/source/core/layout/flowfrm.cxx:2149:13 #7 0x7fb75ab63f19 in SwTabFrame::MakeAll(OutputDevice*) sw/source/core/layout/tabfrm.cxx:2886:23 #8 0x7fb75a2fc227 in SwFrame::PrepareMake(OutputDevice*) sw/source/core/layout/calcmove.cxx:388:5 #9 0x7fb75abf7383 in SwFrame::Calc(OutputDevice*) const sw/source/core/layout/trvlfrm.cxx:1803:37 #10 0x7fb75a7e9bd0 in SwObjectFormatter::FormatLayout_(SwLayoutFrame&) sw/source/core/layout/objectformatter.cxx:207:19 #11 0x7fb75a7e9f7d in SwObjectFormatter::FormatLayout_(SwLayoutFrame&) sw/source/core/layout/objectformatter.cxx:214:13 #12 0x7fb75a7eb550 in SwObjectFormatter::FormatObj_(SwAnchoredObject&) sw/source/core/layout/objectformatter.cxx:296:17 #13 0x7fb75a7fd88d in SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool) sw/source/core/layout/objectformattertxtfrm.cxx:133:9 #14 0x7fb75a7ee2c3 in SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame*) sw/source/core/layout/objectformatter.cxx:413:19 #15 0x7fb75a807bff in SwObjectFormatterTextFrame::DoFormatObjs() sw/source/core/layout/objectformattertxtfrm.cxx:337:20 I.e. the trouble is that SwObjectFormatter::FormatObjsAtFrame_() calls first calls DoFormatObj(), which joins a follow text frame, but then the same SwObjectFormatter::FormatObjsAtFrame_() calls DoFormatObj() again, and that still refers to the now deleted text frame. SwFlyAtContentFrame::DelEmpty() calling SwTextFrame::JoinFrame() was added recently, in commit cfe9c68a7a19dd77d1fcbde3a7dd75730634becc (tdf#157119 sw floattable: fix moving master of split fly to next page, 2023-09-21). Fix the problem by dropping the 2nd fix from the above commit (and leave the other 3 unchanged): that is no longer necessary for the old use-case, probably because in the meantime commit 695390b08799af34b393c81c834d615bea330d89 (tdf#126449 sw floattable: fix too small height of non-last anchors, 2023-10-03) started to add some real height for some of the split fly anchor frames, so less manual joins are needed. Note that the crash only happens with this bugdoc in case MALLOC_PERTURB_ is set to something non-empty or when using sanitizers. Change-Id: I4b810bd77a01a251dd1225426c50a7d7f100ece2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157577 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 2d6f48d53674ee85179ec8cee8648830207200a2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157548 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/layout/data/floattable-del-empty.docx b/sw/qa/core/layout/data/floattable-del-empty.docx new file mode 100644 index ..340d06b6222b Binary files /dev/null and
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-bad-fly-pos.docx |binary sw/qa/core/text/frmform.cxx | 30 +++ sw/source/core/text/frmform.cxx | 14 -- 3 files changed, 41 insertions(+), 3 deletions(-) New commits: commit 328c8083f2e3980252381adbec7f979982c1f8a7 Author: Miklos Vajna AuthorDate: Fri Sep 29 09:01:29 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 4 11:03:45 2023 +0200 Related: tdf#126449 sw floattable: fix bad position of in-table follow fly The reduced bugdoc is of 4 pages, an inner floating table should be on pages 2 -> 4 but was only on 2 -> 3. The reason for this seems to be that we correctly split the inner table twice, but the 3rd fly frame in the chain is positioned on page 3, and once the anchor moves to page 4, we never re-position the fly frame. The fly frame is normally only positioned once, since the position of the anchor and the fly frame depend on each other, so the loop has to be broken, and this is normally done by locking the position of the fly after one positioning. Fix the problem by extending the condition when to unlock the position of anchored fly frames in SwTextFrame::MakePos(): similar to not yet positioned fly frames, do one more cycle in case the anchor and the fly frame are not on the same page. This just fixes a simplified DOCX bugdoc, the full document still needs more fixes. Change-Id: I066c64cf4e12bf31f22218f84f0f2425256ba63e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157393 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157402 diff --git a/sw/qa/core/text/data/floattable-bad-fly-pos.docx b/sw/qa/core/text/data/floattable-bad-fly-pos.docx new file mode 100644 index ..a0a8bb4dbdb9 Binary files /dev/null and b/sw/qa/core/text/data/floattable-bad-fly-pos.docx differ diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx index f2f942bde324..ee791f325729 100644 --- a/sw/qa/core/text/frmform.cxx +++ b/sw/qa/core/text/frmform.cxx @@ -116,6 +116,36 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidLastManipOfst) CPPUNIT_ASSERT_EQUAL(static_cast(0), static_cast(pAnchorText->GetOffset())); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableBadFlyPos) +{ +// Given a document with an inner floating table on page 2 -> 4: +// When laying out that document: +createSwDoc("floattable-bad-fly-pos.docx"); + +// Then make sure that pages 2 -> 4 get the 3 fly frames: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(!pPage1->GetSortedObjs()); +auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage2->GetSortedObjs()->size()); +auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage3); +CPPUNIT_ASSERT(pPage3->GetSortedObjs()); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 2 +// i.e. the fly on page 4 was still on page 3. +CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage3->GetSortedObjs()->size()); +auto pPage4 = pPage3->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage4); +CPPUNIT_ASSERT(pPage4->GetSortedObjs()); +CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage4->GetSortedObjs()->size()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index c3c7f872b88a..495820336fb3 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -365,10 +365,18 @@ void SwTextFrame::MakePos() // Possibly this fly was positioned relative to us, invalidate its position now that our // position is changed. SwPageFrame* pPageFrame = pFly->FindPageFrame(); -if (pPageFrame && pFly->getFrameArea().Pos() == pPageFrame->getFrameArea().Pos()) +bool bFlyNeedsPositioning = false; +bool bFlyPageMismatch = false; +if (pPageFrame) { -// The position was just adjusted to be be inside the page frame, so not really -// positioned, unlock the position once to allow a recalc. +// Was the position just adjusted to be inside the page frame? +bFlyNeedsPositioning = pFly->getFrameArea().Pos() == pPageFrame->getFrameArea().Pos(); +// Is the fly on a page different than the anchor frame? +bFlyPageMismatch = pPageFrame != FindPageFrame(); +} +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uibase/fldui/fldui.cxx | 24 sw/source/uibase/fldui/fldmgr.cxx |7 +-- 2 files changed, 29 insertions(+), 2 deletions(-) New commits: commit 7bd39200c990f93b5b03b18fd863994ad8cfe4a2 Author: Miklos Vajna AuthorDate: Tue Oct 3 20:12:09 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 4 09:27:49 2023 +0200 tdf#157394 sw: fix inserting reference mark with existing selection Type "myword" in Writer, select it, Insert -> Cross-reference, set Name to "myname", click Insert. The body text now had "myword" twice, instead of creating a reference mark on the existing "myword" word. This went wrong in commit 16075474819696f920979969474aa8300f4af530 (sw, field insert: handle the Content param for refmarks and accept HTML there, 2022-12-21), because it assumed that in case the uno comand is dispatched with some reference text, then that has to be inserted at the cursor position and only then the refmark can be created on that range. It was not expected that the current Writer selection would show up as refmark text. Fix the problem by taking the refmark text from the uno command parameter only in case we don't have selection, which restores the old behavior on manual insert of a refmark and keeps the new uno command parameter working. Note that contrary to the bug title, inserting cross-references did work, but the trouble was the insert of the duplicated word. (cherry picked from commit 4c5f51a7ac4c0f7043ead2b3b48e71c33e16f992) Change-Id: I1a8b002c2a6f196975a18e01f0e8c457cfb416bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157551 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sw/qa/uibase/fldui/fldui.cxx b/sw/qa/uibase/fldui/fldui.cxx index 79a53c842a46..78b2fcedd42a 100644 --- a/sw/qa/uibase/fldui/fldui.cxx +++ b/sw/qa/uibase/fldui/fldui.cxx @@ -120,6 +120,30 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertRefmark) CPPUNIT_ASSERT_EQUAL(static_cast(1), aAttrs.size()); CPPUNIT_ASSERT_EQUAL(OUString("aaabbbccc"), pTextNode->GetText()); } + +CPPUNIT_TEST_FIXTURE(Test, testInsertRefmarkSelection) +{ +// Given a document with a single selected word: +createSwDoc(); +SwDoc* pDoc = getSwDoc(); +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->Insert2("myword"); +pWrtShell->SelAll(); + +// When inserting a refmark: +SwFieldMgr aMgr(pWrtShell); +SwInsertField_Data aData(SwFieldTypesEnum::SetRef, /*nSubType=*/0, "myname", "myword", + /*nFormatId=*/0); +aMgr.InsertField(aData); + +// Then make sure the document still just contains that word only once: +SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: myword +// - Actual : mywordmyword +// i.e. the content of the selection was duplicated. +CPPUNIT_ASSERT_EQUAL(OUString("myword"), pTextNode->GetText()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index efc5f916f178..143c981a6131 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1074,7 +1074,10 @@ bool SwFieldMgr::InsertField( const OUString& rRefmarkText = rData.m_sPar2; SwPaM* pCursorPos = pCurShell->GetCursor(); pCurShell->StartAction(); -if (!rRefmarkText.isEmpty()) +bool bHadMark = pCursorPos->HasMark(); +// If we have no selection and the refmark text is provided, then the text is +// expected to be HTML. +if (!bHadMark && !rRefmarkText.isEmpty()) { // Split node to remember where the start position is. bool bSuccess = pCurShell->GetDoc()->getIDocumentContentOperations().SplitNode( @@ -1100,7 +1103,7 @@ bool SwFieldMgr::InsertField( pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) ); -if (!rRefmarkText.isEmpty()) +if (!bHadMark && !rRefmarkText.isEmpty()) { pCursorPos->DeleteMark(); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/table-missing-join.docx |binary sw/qa/core/layout/tabfrm.cxx | 28 + sw/source/core/layout/tabfrm.cxx |9 3 files changed, 37 insertions(+) New commits: commit 1d71e51db56e9f8692dda1d66b0d2d661e0f7711 Author: Miklos Vajna AuthorDate: Mon Sep 25 08:38:28 2023 +0200 Commit: Michael Stahl CommitDate: Wed Sep 27 12:40:59 2023 +0200 tdf#157263 sw floattable: prefer join over split after moving fwd Regression from commit a4af5432753408c4eea8a8d56c2f48202160c5fe (tdf#120262 sw floattable, legacy: fix text wrap around fly when no content fits, 2023-07-17), the bugdoc was of 3 pages in both Word and Writer, but is now of 4 pages in Writer. The above commit fixed the layout, so the first row of the table around the page 1 -> page 2 boundary goes to the start of page 2 instead of to the end of page 1. This matches the Word layout, so a wanted change on its own, but it regressed the page acount. The reason for this is that the table has a single row on page 2 and its follow on page 3 is not joined, even if there would be still space on page 2. A reduced bugdoc appears to reproduce this problem even without floating tables, also with old versions, so it's not a new problem, but it's now more visible. Fix the problem by tweaking what to do in the next iteration in the loop of SwTabFrame::MakeAll() after moving forward. Moving forward is followed by a next iteration in that function, but it does both a MakePos() and a Format(), so it'll be the last iteration in the "is the postion / size of this tab frame valid" loop. We used to hit the "bSplit == true" case, there we found that there is enough remaining space, so no need to split and we quit the loop. This is now changed, so in case we moved the table forward and there is still enough space for the follow to be next to us, then the last iteration will try to join instead of trying to split. Note that probably split almost never makes sense after moving forward in the !HasNext() && HasFollow() case, but let's stay on the safe side and only do this when the follow definitely fits, which is enough for our needs here. Change-Id: I64b0a7d257b0ab01353741506969a287b361c5ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157233 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit b8521d969ab5be4fc947e467d4afe969f9d3b563) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157216 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/layout/data/table-missing-join.docx b/sw/qa/core/layout/data/table-missing-join.docx new file mode 100644 index ..1fabb9e5b27c Binary files /dev/null and b/sw/qa/core/layout/data/table-missing-join.docx differ diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx index 4b991c27dbf8..705bf47af4bc 100644 --- a/sw/qa/core/layout/tabfrm.cxx +++ b/sw/qa/core/layout/tabfrm.cxx @@ -9,6 +9,13 @@ #include +#include +#include +#include +#include + +namespace +{ /// Covers sw/source/core/layout/tabfrm.cxx fixes. class Test : public SwModelTestBase { @@ -35,4 +42,25 @@ CPPUNIT_TEST_FIXTURE(Test, testTablePrintAreaLeft) CPPUNIT_ASSERT_EQUAL(static_cast(5), nTablePrintLeft); } +CPPUNIT_TEST_FIXTURE(Test, testTableMissingJoin) +{ +// Given a document with a table on page 2: +// When laying out that document: +createSwDoc("table-missing-join.docx"); + +// Then make sure that the table fits page 2: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage2); +SwFrame* pBody = pPage2->FindBodyCont(); +auto pTab = pBody->GetLower()->DynCastTabFrame(); +// Without the accompanying fix in place, this test would have failed, the table continued on +// page 3. +CPPUNIT_ASSERT(!pTab->HasFollow()); +} +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 049893e2850d..009a05159970 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2872,6 +2872,15 @@ void SwTabFrame::MakeAll(vcl::RenderContext* pRenderContext) if ( GetFollow() ) Join(); } +else if (!GetNext() && !HasFollowFlowLine() && GetFollow() + && (getFrameArea().Bottom() + GetFollow()->getFrameArea().Height()) +< GetUpper()->getFrameArea().Bottom()) +{ +// We're the last lower of the upper, no split row and we have a follow. That follow +// fits our upper, still. Prefer
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-move-master.docx |binary sw/qa/core/layout/flycnt.cxx | 42 ++ sw/source/core/inc/rootfrm.hxx |1 sw/source/core/inc/txtfrm.hxx |2 sw/source/core/layout/calcmove.cxx | 13 +++ sw/source/core/layout/flycnt.cxx | 27 ++ sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |6 + sw/source/core/text/itratr.cxx | 10 +- 8 files changed, 95 insertions(+), 6 deletions(-) New commits: commit 93a646ddf74ada0bc96107310d50c3da3a4343bc Author: Miklos Vajna AuthorDate: Thu Sep 21 08:31:01 2023 +0200 Commit: Michael Stahl CommitDate: Tue Sep 26 17:38:01 2023 +0200 tdf#157119 sw floattable: fix moving master of split fly to next page The problem with the bugdoc is that in case you split the text frame hosting the start of the anchor text, then the fly will be split in a broken way on pages 1 -> 4 -> 2, while we want a split on just pages 2 -> 3. There were several problems here: 1) We created an unnecessary follow fly in SwFrame::GetNextFlyLeaf(): when page 1 wanted to split, we discarded the flys on page 2 and 3, because the original anchor was in the body text and the flys on page 2/3 was in a fly, so that's rejected. This resulted in a follow fly on page 4, which is not correct. Fix this by using an existing follow if possible, this is similar to what SwFrame::GetNextSctLeaf() does. 2) SwFlyAtContentFrame::DelEmpty() broke the invariant that in case the fly is split to N pieces then the anchor chain's first N frame is matching that. Fix this by joining the unwanted anchor with its follow right before unlinking the to-be-deleted fly from the fly chain. 3) SwToContentAnchoredObjectPosition::CalcOverlap() tried to shift down flys due to overlapping with the to-be-deleted frames, fix this by ignoring flys which are already in the to-delete list. 4) SwContentFrame::ShouldBwdMoved() tried to move the master fly back from page 2 to page 1, which makes no sense, since there is not enough space there to lay out the fly master correctly there. Normally we only check if the paragraph fits the remaining space on the previous page, and this is wanted: if there is a normal to-para anchored image that would not fit, we simply shift up the image. But this is not wanted to floating tables, since here the anchor's only purpose is to host the start of the fly chain at a correct position. Fix this by checking not only for the text frame height vs the available space, but also the height of our (only) anchored object. Note that 3) is not a huge problem, it just causes some extra cycles for the layout (erase the to-delete flys, then position flys once more), do it because things are complicated enough already. Change-Id: I6f2c9d479125309d16b95df0236715c9353e8ba0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157133 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit cfe9c68a7a19dd77d1fcbde3a7dd75730634becc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157215 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/layout/data/floattable-move-master.docx b/sw/qa/core/layout/data/floattable-move-master.docx new file mode 100644 index ..03087eb358a8 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-move-master.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 73a107c4bc5e..f5f5fb094a37 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -1103,6 +1103,48 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedOverlap) SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyMoveMaster) +{ +// Given a document with a multi-page floating table on pages 1 -> 2 -> 3: +createSwDoc("floattable-move-master.docx"); + +// When adding an empty para before the table, so the table gets shifted to pages 2 -> 3: +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->SttEndDoc(/*bStt=*/true); +pWrtShell->Down(/*bSelect=*/false, /*nCount=*/4); +pWrtShell->SplitNode(); + +// Then make sure page 1 has no flys, page 2 and 3 has the split fly and no flys on page 4: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +// Without the accompanying fix in place, this
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/rtl-table.docx |binary sw/qa/core/layout/paintfrm.cxx| 41 ++ sw/source/core/layout/paintfrm.cxx|4 ++- 3 files changed, 44 insertions(+), 1 deletion(-) New commits: commit 0721b09329f88c9206e02afaff832c71065618ee Author: Miklos Vajna AuthorDate: Thu Sep 21 20:21:07 2023 +0200 Commit: Caolán McNamara CommitDate: Tue Sep 26 13:39:54 2023 +0200 tdf#154198 sw: fix lost vertical table cell borders for WordTableCell + RTL This went wrong in commit 0dbecd2d2ebe18a262cfab96e105637840b5b7fe (sw: fix too long inner borders intersecting with outer borders for Word cells, 2022-01-06), the problem is that in its current form this assumes that the first cell is on the left and the last cell is on the right, which is not true for RTL, so only tweak the length of the borders in the LTR case. (cherry picked from commit 652ab50ce18d0ce7fa1209e6bcf3b10ac5c9a933) Change-Id: I513af974855496e507134cf156f9ee5a937a46db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157166 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sw/qa/core/layout/data/rtl-table.docx b/sw/qa/core/layout/data/rtl-table.docx new file mode 100644 index ..a329229699e8 Binary files /dev/null and b/sw/qa/core/layout/data/rtl-table.docx differ diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx index 2416c6b95f8c..ad09405fe3fb 100644 --- a/sw/qa/core/layout/paintfrm.cxx +++ b/sw/qa/core/layout/paintfrm.cxx @@ -68,6 +68,47 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitTableBorder) // missing. CPPUNIT_ASSERT_EQUAL(4, nHorizontalBorders); } + +CPPUNIT_TEST_FIXTURE(Test, testRTLBorderMerge) +{ +// Given a document with an RTL table: +createSwDoc("rtl-table.docx"); +SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); +SwDocShell* pShell = pTextDoc->GetDocShell(); + +// When rendering that document: +std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + +// Then make sure the 5 columns all have left and right vertical borders: +MetafileXmlDump aDumper; +xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); +xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polyline[@style='solid']/point"); +xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; +int nVerticalBorders = 0; +// Count the vertical borders: +for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2) +{ +xmlNodePtr pStart = pXmlNodes->nodeTab[i]; +xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1]; +xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y")); +xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y")); +sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY)); +sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY)); +if (nStartY == nEndY) +{ +// Horizontal border. +continue; +} + +++nVerticalBorders; +} +xmlXPathFreeObject(pXmlObj); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 6 +// - Actual : 4 +// i.e. the 2nd and 5th vertical border was missing. +CPPUNIT_ASSERT_EQUAL(6, nVerticalBorders); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 8f6347a2268e..bd07aa9e1675 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3123,11 +3123,13 @@ void SwTabFramePainter::Insert( SwLineEntry& rNew, bool bHori ) const IDocumentSettingAccess& rIDSA = pShell->GetDoc()->getIDocumentSettingAccess(); bWordTableCell = rIDSA.get(DocumentSettingId::TABLE_ROW_KEEP); } +bool bR2L = mrTabFrame.IsRightToLeft(); while ( aIter != pLineSet->end() && rNew.mnStartPos < rNew.mnEndPos ) { const SwLineEntry& rOld = *aIter; -if (rOld.mnLimitedEndPos || (bWordTableCell && (rOld.mbOuter != rNew.mbOuter))) +// The bWordTableCell code only works for LTR at the moment, avoid it for RTL. +if (rOld.mnLimitedEndPos || (bWordTableCell && (rOld.mbOuter != rNew.mbOuter) && !bR2L)) { // Don't merge with this line entry as it ends sooner than mnEndPos. ++aIter;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/layout3.cxx |2 +- sw/source/core/layout/frmtool.cxx |7 +++ 2 files changed, 8 insertions(+), 1 deletion(-) New commits: commit fbf070f38d25de29de3b8d7192e96cb957852965 Author: Michael Stahl AuthorDate: Wed Aug 23 15:49:44 2023 +0200 Commit: Caolán McNamara CommitDate: Tue Sep 26 13:37:00 2023 +0200 tdf#137523 sw: layout: fix text below tables in footer differently This fix is better than commit 027f8328eef1e149b6c99b478ed5df870291dc2d because it turns out the last text frame had a height of 219 in 6.1. One of the following commits would break this, so a different fix is needed. In SwFrameNotify::ImplDestroy(), if the frame changes its position the next frame's position is invalidated; if the next frame is undersized then also invalidate its size so that it will be formatted again, with more space. Change-Id: I8e6a3fe3127ebfa2246c440d2a3455b217476475 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155986 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 492ddef596c99a9c24d2778276025aafc612a7cb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156963 Reviewed-by: Caolán McNamara diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 8ce2ba090602..7d591e1bd3a4 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -106,7 +106,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf137523) // had wrong height and were not visible assertXPath(pXmlDoc, "/root/page/footer/txt[1]/infos/bounds", "height", "304"); assertXPath(pXmlDoc, "/root/page/footer/txt[2]/infos/bounds", "height", "191"); -assertXPath(pXmlDoc, "/root/page/footer/txt[3]/infos/bounds", "height", "153"); +assertXPath(pXmlDoc, "/root/page/footer/txt[3]/infos/bounds", "height", "219"); assertXPath(pXmlDoc, "/root/page/footer/tab/infos/bounds", "height", "1378"); } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f3de2a7e201e..7f27932434c6 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -202,7 +202,14 @@ void SwFrameNotify::ImplDestroy() } if ( pNxt ) +{ pNxt->InvalidatePos(); +if (pNxt->IsTextFrame() && static_cast(pNxt)->IsUndersized()) +{ // tdf#137523 it could have more space at new pos +pNxt->InvalidateSize(); +pNxt->Prepare(PrepareHint::AdjustSizeWithoutFormatting); +} +} else { // #104100# - correct condition for setting retouche
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/tdf155177-1-min.odt |binary sw/qa/extras/layout/layout3.cxx | 57 +++ sw/source/core/text/txtfrm.cxx | 23 -- sw/source/core/text/widorp.cxx | 44 ++-- sw/source/core/text/widorp.hxx |6 ++ 5 files changed, 94 insertions(+), 36 deletions(-) New commits: commit 6efc84525637ce4291d78033651cf21729baf86a Author: Michael Stahl AuthorDate: Fri Aug 25 14:20:34 2023 +0200 Commit: Caolán McNamara CommitDate: Tue Sep 26 13:35:10 2023 +0200 tdf#155177 sw: fix 2-line bug in WidowsAndOrphans::WouldFit() The problem is that the check if the line contains a non-fly portion was only done in the loop, but the first line is already handled before the loop, so its non-fly portions are ignored and never less than 2 lines are moved, regardless of widow/orphan settings. (regression from commit 8c32cc17ce914188ea6783b0f79e19c5ddbf0b8d) Change-Id: Ic017a17233fcd58e22d54386650328f00fb3e9f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156121 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit fe89122c15744afcaccaa6d6628fa0436adf12e1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156143 Reviewed-by: Caolán McNamara diff --git a/sw/qa/extras/layout/data/tdf155177-1-min.odt b/sw/qa/extras/layout/data/tdf155177-1-min.odt new file mode 100644 index ..68363860f05d Binary files /dev/null and b/sw/qa/extras/layout/data/tdf155177-1-min.odt differ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 1d570ca3f56f..8ce2ba090602 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -201,6 +201,63 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf120287c) assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", 3); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155177) +{ +createSwDoc("tdf155177-1-min.odt"); + +uno::Reference xStyle(getStyles("ParagraphStyles")->getByName("Body Text"), + uno::UNO_QUERY_THROW); +CPPUNIT_ASSERT_EQUAL(sal_Int32(210), getProperty(xStyle, "ParaTopMargin")); + +{ +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "/root/page[2]/body/txt", 6); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[6]/SwParaPortion/SwLineLayout", 2); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[6]/SwParaPortion/SwLineLayout[2]", "portion", +"long as two lines."); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 3); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", +"This paragraph is even longer so that "); +discardDumpedLayout(); +} + +// this should bring one line back +xStyle->setPropertyValue("ParaTopMargin", uno::Any(sal_Int32(200))); + +Scheduler::ProcessEventsToIdle(); + +{ +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "/root/page[2]/body/txt", 7); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout", 1); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[1]", "portion", +"This paragraph is even longer so that "); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 2); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", +"it is now three lines long though "); +discardDumpedLayout(); +} + +// this should bring second line back +xStyle->setPropertyValue("ParaTopMargin", uno::Any(sal_Int32(120))); + +Scheduler::ProcessEventsToIdle(); + +{ +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "/root/page[2]/body/txt", 7); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout", 2); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[1]", "portion", +"This paragraph is even longer so that "); +assertXPath(pXmlDoc, "/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[2]", "portion", +"it is now three lines long though "); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 1); +assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", +"containing a single sentence."); +discardDumpedLayout(); +} +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122878) { createSwDoc("tdf122878.docx"); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index a495e312a60b..3405fc6167bf 100644 ---
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 17 ++ sw/source/filter/ww8/docxattributeoutput.cxx | 16 + 3 files changed, 26 insertions(+), 7 deletions(-) New commits: commit 96d74b7d02aa4d7e143c67d2a55f2b5c00e56232 Author: Miklos Vajna AuthorDate: Thu Sep 14 08:29:30 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Sep 19 12:50:14 2023 +0200 Related: tdf#55160 sw floattable, nested DOCX exp: fix inner tbl at cell start A cut-down bugdoc had an inline table, and an inner floating table, anchored in the start of the C1 cell. Exporting to DOCX resulted in a layout that looks like the floating table is not anchored inside the outer table anymore. Checking the markup, the floating table was written between row 1 & row 2, which is not a valid position for a floating table. Probably the intention was to write the floating table before the first paragraph in C1. Fix the problem by still writing the floating table in DocxAttributeOutput::StartParagraph(), before opening , but do this after opening table/row/cell, which is late enough to have a correct anchor but is early enough to be still outside the paragraph. The import side of this still needs fixing. Change-Id: I1827b2def1faaf53312522f5a8415fbe697fcb8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156904 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit d50e5d6d53c94124f825758a74e186b934fc2a4e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157052 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt b/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt new file mode 100644 index ..3e2ed72eca8c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 6b9a61fe2c0d..fb01ab2b47ba 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -139,6 +139,23 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedDOCXExport) assertXPath(pXmlDoc, "//w:tblpPr", 2); } +CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedCellStartDOCXExport) +{ +// Given a document with a nested floating table at cell start: +createSwDoc("floattable-nested-cell-start.odt"); + +// When exporting to DOCX: +save("Office Open XML Text"); + +// Then make sure both floating table is exported at the right position: +xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); +// Without the accompanying fix in place, this test would have failed with +// - Expected: 1 +// - Actual : 0 +// i.e. the inner was between the two , not inside the C1 cell. +assertXPath(pXmlDoc, "//w:tc/w:tbl/w:tblPr/w:tblpPr", 1); +} + DECLARE_OOXMLEXPORT_TEST(testWpgOnly, "wpg-only.docx") { uno::Reference xShape = getShape(1); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 8b4c14c488ce..8847573ebb80 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -500,13 +500,6 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p if ( !m_aFramesOfParagraph.size() || !m_nTextFrameLevel ) m_aFramesOfParagraph.push(std::vector()); -// look ahead for floating tables that were put into a frame during import -// floating tables in shapes are not supported: exclude this case -if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen()) -{ -checkAndWriteFloatingTables(*this); -} - if ( m_nColBreakStatus == COLBRK_POSTPONE ) m_nColBreakStatus = COLBRK_WRITE; @@ -554,6 +547,15 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p } } +// look ahead for floating tables that were put into a frame during import +// floating tables in shapes are not supported: exclude this case +if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen()) +{ +// Do this after opening table/row/cell, so floating tables anchored at cell start go inside +// the cell, not outside. +checkAndWriteFloatingTables(*this); +} + // Look up the "sdt end before this paragraph" property early, when it // would normally arrive, it would be too late (would be after the // paragraph start has been written).
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/ooxmlexport12.cxx |4 sw/source/core/table/swtable.cxx |2 +- sw/source/filter/ww8/docxattributeoutput.cxx | 14 -- sw/source/filter/ww8/docxattributeoutput.hxx |4 4 files changed, 21 insertions(+), 3 deletions(-) New commits: commit a4bef51e14c7829b368bda0cf06c87c16a03b1b1 Author: László Németh AuthorDate: Wed Sep 13 10:42:45 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Sep 19 11:46:25 2023 +0200 tdf#157187 sw tracked table column: fix DOCX export DOCX export of tracked table column changes could result dummy content boxes and missing tracked table column changes in MSO, i.e. lost interoperability. As a workaround, skip exporting content boxes within tracked table cells. Note: bad 0x01 characters and incomplete w:sdt export in table cells since commit b5c616d10bff3213840d4893d13b4493de71fa56 "tdf#104823: support for sdt plain text fields". See also commit 4697d2bda1b37f9cf8b301f5bf044c2390f56333 "tdf#157011 sw tracked table column: fix DOCX import of empty cell". Change-Id: I32f77c7532a9cc6bf5d88a626ac3c62a5c02a34a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156895 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit a388a0d245314182694ea7d7f16c71290a3e4ba2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156881 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index e5a585f01d68..243bfffb23c2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1335,6 +1335,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf157011, "tdf157011_ins_del_empty_cols.docx") // This was 4 (missing tracked table cell deletions) assertXPath(pXmlDoc, "//w:del", 6); + +// tdf#157187 This was false (dummy w:tc/w:p/w:sdt/w:sdtContent content box) +assertXPath(pXmlDoc, "//w:tc/w:p/w:del", 6); +assertXPath(pXmlDoc, "//w:tc/w:p/w:ins", 3); } } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 0fbede71641f..e5a2ccba936f 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2262,7 +2262,7 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable ) const // tdf#157011 OOXML w:std cell content is imported with terminating 0x01 characters, // i.e. an empty box can contain double 0x01: handle it to avoid losing change tracking -// FIXME regression since LibreOffice 7.3? +// FIXME regression since commit b5c616d10bff3213840d4893d13b4493de71fa56 if ( pCNd && pCNd->Len() == 2 && pCNd->GetTextNode() ) { const OUString = pCNd->GetTextNode()->GetText(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index c780454e8a6e..8b4c14c488ce 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2010,7 +2010,10 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In { auto pTextContentControl = static_txtattr_cast(pAttr); m_pContentControl = pTextContentControl->GetContentControl().GetContentControl(); -WriteContentControlStart(); +if (!m_tableReference.m_bTableCellChanged) +{ +WriteContentControlStart(); +} } } @@ -2036,7 +2039,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In { sal_Int32 nEnd = nPos + nLen; SwTextAttr* pAttr = pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Default); -if (pAttr && *pAttr->GetEnd() == nEnd) +if (pAttr && *pAttr->GetEnd() == nEnd && !m_tableReference.m_bTableCellChanged) { WriteContentControlEnd(); } @@ -4722,6 +4725,12 @@ void DocxAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t InitTableHelper( pTableTextNodeInfoInner ); +// check tracked table column deletion or insertion +const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox(); +SwRedlineTable::size_type nChange = pTabBox->GetRedline(); +if (nChange != SwRedlineTable::npos) +m_tableReference.m_bTableCellChanged = true; + m_pSerializer->startElementNS(XML_w, XML_tc); // Write the cell properties here @@ -4742,6 +4751,7 @@ void DocxAttributeOutput::EndTableCell(sal_uInt32 nCell) m_tableReference.m_bTableCellOpen = false; m_tableReference.m_bTableCellParaSdtOpen = false; +m_tableReference.m_bTableCellChanged = false; } void DocxAttributeOutput::StartStyles() diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/floattable-nested.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 17 + sw/source/filter/ww8/docxattributeoutput.cxx|5 - 3 files changed, 21 insertions(+), 1 deletion(-) New commits: commit 70756773a35c0ff2d9a02a08bbca9a6c82d63315 Author: Miklos Vajna AuthorDate: Tue Sep 12 08:42:31 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Sep 18 09:08:33 2023 +0200 sw floattable, nesting: fix DOCX export There were two problems here: 1) DocxAttributeOutput::StartParagraph() didn't try to export an inner floating table as a floating table, resulting in writing a shape that can't span over multiple pages. Dropping the !pTextNodeInfo check should be OK, we'll just now clear the m_aFloatingTablesOfParagraph list at the end of the outer table. 2) Once we tried to export the inner fly, the actual table/row/cell start was missing, because m_tableReference.m_nTableDepth wasn't reset, so DocxAttributeOutput::StartParagraph() didn't know it has to emit a table definition before the first para of the table. Fix this by stashing away the table state before the inner fly's export and restoring it after the inner fly export, similar to how this is done in e.g. DocxExport::WriteHeaderFooter(). This is related to tdf#55160. Change-Id: Ib860283d32e392e2906aa12bc9eb61b5af5ca8de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156833 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 2887e6b8edbb4fdb093515a3a68269ed40e42116) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156744 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/ooxmlexport/data/floattable-nested.odt b/sw/qa/extras/ooxmlexport/data/floattable-nested.odt new file mode 100644 index ..8644412f60b6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/floattable-nested.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 5ad22de67e62..6b9a61fe2c0d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -122,6 +122,23 @@ DECLARE_OOXMLEXPORT_TEST(testWpsOnly, "wps-only.docx") CPPUNIT_ASSERT_EQUAL(false, getProperty(getShape(2), "Opaque")); } +CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedDOCXExport) +{ +// Given a document with nested floating tables: +createSwDoc("floattable-nested.odt"); + +// When exporting to DOCX: +save("Office Open XML Text"); + +// Then make sure both floating table is exported: +xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); +// Without the accompanying fix in place, this test would have failed with +// - Expected: 2 +// - Actual : 1 +// i.e. the inner floating table was lost. +assertXPath(pXmlDoc, "//w:tblpPr", 2); +} + DECLARE_OOXMLEXPORT_TEST(testWpgOnly, "wpg-only.docx") { uno::Reference xShape = getShape(1); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f543b08980d0..c780454e8a6e 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -418,6 +418,9 @@ void DocxAttributeOutput::WriteFloatingTable(ww8::Frame const* pParentFrame) //Save data here and restore when out of scope ExportDataSaveRestore aDataGuard(GetExport(), nStt, nEnd, pParentFrame); +// Stash away info about the current table, so m_tableReference is clean. +DocxTableExportContext aTableExportContext(*this); + // set a floatingTableFrame AND unset parent frame, // otherwise exporter thinks we are still in a frame m_rExport.SetFloatingTableFrame(pParentFrame); @@ -499,7 +502,7 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p // look ahead for floating tables that were put into a frame during import // floating tables in shapes are not supported: exclude this case -if (!pTextNodeInfo && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen()) +if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen()) { checkAndWriteFloatingTables(*this); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-nested-overlap.odt |binary sw/qa/core/layout/flycnt.cxx | 23 + sw/source/core/layout/tabfrm.cxx | 23 + sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx | 24 -- 4 files changed, 48 insertions(+), 22 deletions(-) New commits: commit 285c2c042fc17e7010173fcd8f8665be1e0143fa Author: Miklos Vajna AuthorDate: Mon Sep 11 08:26:43 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Sep 18 09:04:11 2023 +0200 sw floattable, nesting: fix overlap support The bugdoc had a nested, split floating table with overlap=never and that lead to a layout loop. The root of the trouble seems to be that the inner fly will obviously overlap with its outer fly but we tried to prevent that and we failed. Fix the problem by ignoring inner flys in SwToContentAnchoredObjectPosition::CalcOverlap(). This also allows removing special handling of nested split flys in lcl_ArrangeLowers() and special handling of split flys at an other place in the same function, because now the non-bDirectMove case works out of the box. Change-Id: Icf3a8f776aa758ef4ae2c2994a7216c5a6142a62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156810 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit e20bacc209a8e8483209cb4ec51c9e0b55423cdb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156739 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/layout/data/floattable-nested-overlap.odt b/sw/qa/core/layout/data/floattable-nested-overlap.odt new file mode 100644 index ..b90ae9a7b01e Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested-overlap.odt differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 1c69606c8a24..73a107c4bc5e 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -1080,6 +1080,29 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested) CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly()); CPPUNIT_ASSERT(pPage2Fly2->GetPrecede()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedOverlap) +{ +// Given a document with a nested, multi-page floating table, enabling the "don't overlap" logic: +// When calculating the layout: +createSwDoc("floattable-nested-overlap.odt"); +calcLayout(); + +// Then make sure we get 2 pages (2 flys on each page): +// Without the accompanying fix in place, this test would have failed with a layout loop. +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size()); +auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 3cfa29f92aab..c386bf2ab9de 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -5256,24 +5256,11 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, tools::Long lYStart, bool bI lcl_ArrangeLowers( static_cast(pFrame), aRectFnSet.GetTop(static_cast(pFrame)->Lower()->getFrameArea()) + lDiffX, bInva ); -SwSortedObjs* pDrawObjs = pFrame->GetDrawObjs(); -auto pTextFrame = pFrame->DynCastTextFrame(); -if (pTextFrame && pTextFrame->IsInFly()) +if ( pFrame->GetDrawObjs() ) { -// See if this is a follow anchor. If so, we want the flys anchored in the master -// which are also lowers of pFrame. -SwTextFrame* pMaster = pTextFrame; -while (pMaster->IsFollow()) +for ( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i ) { -pMaster = pMaster->FindMaster(); -} -pDrawObjs = pMaster->GetDrawObjs(); -} -if (pDrawObjs) -{ -for (size_t i = 0; i < pDrawObjs->size(); ++i) -{ -SwAnchoredObject* pAnchoredObj = (*pDrawObjs)[i]; +SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i]; // #i26945# - check, if anchored object // is lower of layout frame by checking, if the anchor
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 15 ++ sw/source/core/table/swtable.cxx| 10 ++ 3 files changed, 25 insertions(+) New commits: commit e6fc440bdb02c6a815153275ef1c7ded6f8d4a7a Author: László Németh AuthorDate: Wed Sep 6 18:01:28 2023 +0200 Commit: László Németh CommitDate: Thu Sep 7 10:40:46 2023 +0200 tdf#157011 sw tracked table column: fix DOCX import of empty cell OOXML w:std elements are imported with 0x01 characters in text content of tracked table columns (as a regression in LO 7.3?), losing change tracking data. Fix this temporarily by completing SwTableBox::IsEmpty() handling the bad 0x01 characters of the imported tracked empty cells. See also commit a483a44ca00f43a64ae51d62b8fbb4129a413f6d "tdf#143215 DOCX import: fix tracked empty row insertion/deletion". Change-Id: I4895754e540cca6ba2cb3442f24a8affcedd51fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156626 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit ec2de3e6f8e1dcca52e7e3cf36146d683afbf4f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156601 Tested-by: László Németh diff --git a/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx new file mode 100644 index ..5ebb98fda0d7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index e406d546aea6..e5a585f01d68 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1323,6 +1323,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf150824, "tdf150824.fodt") } } +DECLARE_OOXMLEXPORT_TEST(testTdf157011, "tdf157011_ins_del_empty_cols.docx") +{ +// check tracked table column insertions and deletions with empty cells +if (isExported()) +{ +xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + +// This was 1 (missing tracked table cell insertions) +assertXPath(pXmlDoc, "//w:ins", 3); + +// This was 4 (missing tracked table cell deletions) +assertXPath(pXmlDoc, "//w:del", 6); +} +} + DECLARE_OOXMLEXPORT_TEST(testTdf150824_regression, "ooo30436-1-minimized.sxw") { // There should be no crash during loading of the document diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 04d58363b97d..0fbede71641f 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2259,6 +2259,16 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable ) const const SwContentNode *pCNd = pFirstNode->GetContentNode(); if ( pCNd && !pCNd->Len() ) return true; + +// tdf#157011 OOXML w:std cell content is imported with terminating 0x01 characters, +// i.e. an empty box can contain double 0x01: handle it to avoid losing change tracking +// FIXME regression since LibreOffice 7.3? +if ( pCNd && pCNd->Len() == 2 && pCNd->GetTextNode() ) +{ +const OUString = pCNd->GetTextNode()->GetText(); +if ( rText[0] == 0x01 && rText[1] == 0x01 ) +return true; +} } else if ( bWithRemainingNestedTable ) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt |binary sw/qa/core/objectpositioning/objectpositioning.cxx | 24 ++ sw/source/core/inc/frame.hxx |2 sw/source/core/layout/findfrm.cxx | 10 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |5 +- 5 files changed, 40 insertions(+), 1 deletion(-) New commits: commit 38192482e552195a5c76a6e40fc3586cc6f0355c Author: Miklos Vajna AuthorDate: Fri Sep 1 08:51:20 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Sep 4 17:26:09 2023 +0200 Related: tdf#156318 sw floattable: fix handling of vert orient == top The bugdoc resulted in a layout loop on load. It was created by forcing pages to be in a single column + increasing the top+bottom margin of the page to 2.5cm. The problem was that the SwFormatVertOrient's m_eOrient is usually text::VertOrientation::NONE ("from top" with 0 offset), but here it's text::VertOrientation::TOP. These are meant to be more or less equivalent, but SwToContentAnchoredObjectPosition::CalcPosition() has different codepath for them. Fix the problem by making sure that TOP doesn't have a vertical offset for follow fly frame: do this by realizing that in case the "orient frame" and the "anchor" is not the same that may need no action, since the fly frame case changes the "orient" to the follow anchor and the "anchor" is the master anchor. The original scenario still needs more work, we don't hang anymore but the follow fly appears on page 3 instead of page 2. Change-Id: I1596a07b78575583070d494ddb8e1400e5653820 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156392 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 7d4213b9f0253b323750acceca8f4edb9d1a7fc5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156530 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt new file mode 100644 index ..b10f0b7188fa Binary files /dev/null and b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt differ diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx index 4958b8b6deb4..611ce1294c22 100644 --- a/sw/qa/core/objectpositioning/objectpositioning.cxx +++ b/sw/qa/core/objectpositioning/objectpositioning.cxx @@ -313,6 +313,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testFloatingTableOverlapNever) CPPUNIT_ASSERT_GREATER(pFlyFrame1->getFrameArea().Bottom(), pFlyFrame2->getFrameArea().Top()); } +CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testFloatingTableVertOrientTop) +{ +// Given a document with a vert-orient=from-top anchored floating table: +createSwDoc("floattable-vert-orient-top.odt"); + +// When laying out that document: +calcLayout(); + +// Then make sure we correctly split the table to two pages: +// Without the accompanying fix in place, this test would have produced a layout loop. +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = pLayout->Lower()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); +auto pPage2 = pPage1->GetNext()->DynCastPageFrame(); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index ec47266ec468..885a0d223f24 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -874,6 +874,8 @@ public: inline bool IsTextFrame() const; SwTextFrame* DynCastTextFrame(); const SwTextFrame* DynCastTextFrame() const; +SwPageFrame* DynCastPageFrame(); +const SwPageFrame* DynCastPageFrame() const; inline bool IsNoTextFrame() const; // Frames where its PrtArea depends on their neighbors and that are // positioned in the content flow diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index 1a98f6cf6747..5331baacd93e 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -1944,4 +1944,14 @@ const SwTextFrame* SwFrame::DynCastTextFrame() const return IsTextFrame() ? static_cast(this) : nullptr; } +SwPageFrame* SwFrame::DynCastPageFrame() +{ +return IsPageFrame() ? static_cast(this) : nullptr;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uitest/writer_tests7/tdf156784.py | 38 sw/source/core/crsr/crsrsh.cxx |9 +++ sw/source/core/frmedt/fetab.cxx |3 +- 3 files changed, 49 insertions(+), 1 deletion(-) New commits: commit 49bfb463aebcfbe3935bc9989d9a1c5689149a09 Author: László Németh AuthorDate: Thu Aug 24 16:27:16 2023 +0200 Commit: László Németh CommitDate: Tue Aug 29 15:06:04 2023 +0200 tdf#156784 sw tracked table column: fix crash at Select All Section starting table with hidden deleted first column freezed at Select All, resulting crash because of infinite recursion during waiting frame creation of a hidden cell without frame in Hide Changes mode. Regression from commit d1004cdd6a445ae73673b0ca360ae034b0ec09f2 "tdf#150673 sw offapi: add change tracking of table column deletion". Change-Id: I15d9fa0138261d7a95c6e34a8d07fb2e001d0c7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156056 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 15639650efb2fa44e96fdc2bd46a64931b9a3329) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156134 Tested-by: László Németh diff --git a/sw/qa/uitest/writer_tests7/tdf156784.py b/sw/qa/uitest/writer_tests7/tdf156784.py new file mode 100644 index ..5cac8fc628db --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf156784.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +# Bug 156784 - crash fix: Select All in section starting table with hidden first column + +class tdf156784(UITestCase): +def test_tdf156784(self): +with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + +# accept all tracked changes +self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges") + +# delete first column +self.xUITest.executeCommand(".uno:DeleteColumns") + +# hide changes +self.xUITest.executeCommand(".uno:ShowTrackedChanges") + +# select cell content +self.xUITest.executeCommand(".uno:SelectAll") + +# This resulted crashing (select section starting table with hidden first column) +self.xUITest.executeCommand(".uno:SelectAll") + +# show changes +self.xUITest.executeCommand(".uno:ShowTrackedChanges") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index f22e0bc9450a..4d69e2a6d705 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -77,6 +77,7 @@ #include #include #include +#include using namespace com::sun::star; using namespace util; @@ -2168,6 +2169,14 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd ) // created, because there used to be a Frame here! if ( !pFrame ) { +// skip, if it is a hidden deleted cell without frame +if ( GetLayout()->IsHideRedlines() ) +{ +const SwStartNode* pNd = pShellCursor->GetPointNode().FindTableBoxStartNode(); +if ( pNd && pNd->GetTableBox()->GetRedlineType() == RedlineType::Delete ) +return; +} + do { CalcLayout(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index dced56c1f2a0..59b031ce772a 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1175,7 +1175,8 @@ bool SwFEShell::CanUnProtectCells() const { SwFrame *pFrame = GetCurrFrame(); do { -pFrame = pFrame->GetUpper(); +if ( pFrame ) +pFrame = pFrame->GetUpper(); } while ( pFrame && !pFrame->IsCellFrame() ); if( pFrame ) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/tdf137523-1-min.fodt | 319 ++ sw/qa/extras/layout/layout3.cxx | 12 sw/source/core/layout/layact.cxx |6 3 files changed, 336 insertions(+), 1 deletion(-) New commits: commit b453cd8dad4580e0c2f7be358b3173ad7837fea3 Author: Michael Stahl AuthorDate: Mon Aug 21 19:21:34 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Aug 22 21:00:28 2023 +0200 tdf#137523 sw: layout: fix text below tables in footer In the footer, the text frames below a table have a very small height and are effectively invisible. This is because the JoinLock in SwLayAction::FormatLayoutTab() causes SwTabFrame::MakeAll() to return early, which is called for every cell frame in the table, and which would move the table up the page in MakePos(), by calling SwHeadFootFrame::Format(). (regression from commit cc5916cd314a27b0cc99560ab887480026630a95) Change-Id: I4add9fdd73ad3756000969af20ebf758025a0ada Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155902 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 027f8328eef1e149b6c99b478ed5df870291dc2d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155915 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/layout/data/tdf137523-1-min.fodt b/sw/qa/extras/layout/data/tdf137523-1-min.fodt new file mode 100644 index ..cbe85c9fbb82 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf137523-1-min.fodt @@ -0,0 +1,319 @@ + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2020-10-16T11:14:14.930082474LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/53ef297ff9342db2a32da0dd0e8e2f858a3624eeuser_manualP0D1Release 3.0.32020-10-181Train Backbone NodeT est Report + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/linked_frames_section_bug.odt |binary sw/qa/extras/layout/layout3.cxx| 18 + sw/source/core/layout/sectfrm.cxx |1 3 files changed, 19 insertions(+) New commits: commit 3257c0843d77e3c8f8d91702575ce1680d680c42 Author: Michael Stahl AuthorDate: Fri Aug 18 16:44:16 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Aug 21 16:43:37 2023 +0200 tdf#156419 sw: layout: don't prevent moving between linked flys ... when there is a page break on the next page. Of course you can put a section into a fly, and then link multiple flys. (regression from commit 325fe7ab507fd8f2ca17a3db32181edf30169525) Change-Id: I5cb854fc7ee5caa2af4e04f4da2d8a8083c0d007 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155842 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 987fe1175de2db53235cc6f2441335fcc3548d64) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155779 Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/layout/data/linked_frames_section_bug.odt b/sw/qa/extras/layout/data/linked_frames_section_bug.odt new file mode 100644 index ..639332ad5516 Binary files /dev/null and b/sw/qa/extras/layout/data/linked_frames_section_bug.odt differ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index c4d4678f552d..abad840647aa 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1228,6 +1228,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156725) "/root/page[2]/body/txt/anchored/fly/column[2]/body/section/column[2]/body/txt", 1); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156419) +{ +createSwDoc("linked_frames_section_bug.odt"); + +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "/root/page", 2); +// there are 2 flys on page 1, and 1 on page 2, all linked +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[1]/section/column", 2); +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[1]/section/column[1]/body/txt", 11); +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[1]/section/column[2]/body/txt", 11); +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[2]/section/column", 2); +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[2]/section/column[1]/body/txt", 12); +assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly[2]/section/column[2]/body/txt", 12); +assertXPath(pXmlDoc, "/root/page[2]/body/txt/anchored/fly[1]/section/column", 2); +assertXPath(pXmlDoc, "/root/page[2]/body/txt/anchored/fly[1]/section/column[1]/body/txt", 2); +assertXPath(pXmlDoc, "/root/page[2]/body/txt/anchored/fly[1]/section/column[2]/body/txt", 1); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf145826) { createSwDoc("tdf145826.odt"); diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 4856bdb5ba70..de4e54e27d5d 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -1758,6 +1758,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage ) // creating / moving the cell frame. // It doesn't make sense to move to a page that starts with break? if (pNxtPg != FindPageFrame() // tdf#156725 not between columns! +&& !FindFlyFrame() // tdf#156419 linked fly frames don't care! && (WrongPageDesc(pNxtPg) || HasPageBreakBefore(*pNxtPg)) && !bLayLeafTableAllowed) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/tdf156725.fodt | 163 sw/qa/extras/layout/layout3.cxx | 21 sw/source/core/layout/sectfrm.cxx |4 3 files changed, 187 insertions(+), 1 deletion(-) New commits: commit 6e0e3dbeab501f4a4bcffeac0b1520426f568e28 Author: Michael Stahl AuthorDate: Thu Aug 17 18:32:35 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Aug 21 16:20:39 2023 +0200 tdf#156725 sw: layout: don't prevent moving between columns ... ... on the same page when there is a page break on the next page. The existing, presumably pointless/always-false in case of same page, check of WrongPageDesc() let me assume that this would only be reached if the current page and the target page are different, but that was a mistake. (regression from commit 325fe7ab507fd8f2ca17a3db32181edf30169525) Change-Id: I4df53b77bed006095c34976011aa0cd5e12879e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155809 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit db83c41d460103df5d80f5bd99816575c4ead5cd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155775 Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/layout/data/tdf156725.fodt b/sw/qa/extras/layout/data/tdf156725.fodt new file mode 100644 index ..9f60e7011954 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf156725.fodt @@ -0,0 +1,163 @@ + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2023-08-17T18:14:28.1153022102023-08-17T18:20:06.109127302PT4M30S2LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/79452241ad33f9eaace2ba8bd1336be69c99ed4d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a + b + c + d + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index abe2b830e804..c4d4678f552d 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1207,6 +1207,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724) assertXPath(pXmlDoc,
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/fdo56797-2-min.odt |binary sw/qa/extras/layout/layout3.cxx | 31 sw/source/core/layout/layact.cxx|6 ++--- 3 files changed, 34 insertions(+), 3 deletions(-) New commits: commit cff929fe5c5bc24be81218ba2ce3d9304d09bf68 Author: Michael Stahl AuthorDate: Mon Aug 14 17:13:17 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Aug 21 12:05:58 2023 +0200 tdf#156724 tdf#156722 tdf#156745 sw: layout: partially remove IsPaintLocked() Having the layout algorithm dependend on IsPaintLocked() is very problematic; it is typically set when the layout is invoked from SwViewShell code, as happens several times when loading a document in response to window resize events etc., but not for idle formatting or from SwXTextDocument::getRendererCount(), hence these bugs only reproduce with soffice --convert-to pdf, not via UI. For tdf#156724 the problem is that the table is split, during formatting of the split row a new footnote is created on page 1, and this reduces the space, so splitting fails and is never attempted again. When the document is loaded from UI, when the table is split the footnote already exists and so splitting succeeds; it was created by a call from SwLayAction::FormatLayout() of the cell frame. It turns out that when the condition is removed completely, testUXTSOREL will take 5 minutes instead of 5 seconds, which seems excessive; the problem there appears to be that a text frame in a columned section moves forward and backward; plausibly columned section content should be formatted by ::CalcContent() only. (reportedly regression from commit c605283ad6785dea762feab5fdffd9d27e75c292 and commit 7e8b4756d95057f069467b34e7849f9354856578) Change-Id: I9ed73588efeec654a769eee8aa825186bd51e059 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155672 Tested-by: Michael Stahl Reviewed-by: Michael Stahl (cherry picked from commit dc5991ccc8f7d8e86c1e04be9095dda5c08b4763) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155691 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/layout/data/fdo56797-2-min.odt b/sw/qa/extras/layout/data/fdo56797-2-min.odt new file mode 100644 index ..624149ec0248 Binary files /dev/null and b/sw/qa/extras/layout/data/fdo56797-2-min.odt differ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 784a295fa2e8..abe2b830e804 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1176,6 +1176,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf128399) CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.GetNodeIndex()); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724) +{ +discardDumpedLayout(); +if (mxComponent.is()) +mxComponent->dispose(); + +OUString const url(createFileURL(u"fdo56797-2-min.odt")); + +// note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() +// does *not* forward initial VCL Window Resize and thereby triggers a +// layout which does not happen on soffice --convert-to pdf. +std::vector aFilterOptions = { +{ beans::PropertyValue("Hidden", -1, uno::Any(true), beans::PropertyState_DIRECT_VALUE) }, +}; + +// inline the loading because currently properties can't be passed... +mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument", + comphelper::containerToSequence(aFilterOptions)); +save("writer_pdf_Export"); + +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +// both pages have a tab frame and one footnote +assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); +assertXPath(pXmlDoc, "/root/page[1]/ftncont", 1); +assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 1); +assertXPath(pXmlDoc, "/root/page[2]/body/tab", 1); +assertXPath(pXmlDoc, "/root/page[2]/ftncont", 1); +assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 1); +assertXPath(pXmlDoc, "/root/page", 2); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf145826) { createSwDoc("tdf145826.odt"); diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index ecce180eb336..af93ab796ff6 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1431,10 +1431,10 @@ bool SwLayAction::FormatLayout( OutputDevice *pRenderContext, SwLayoutFrame *pLa PopFormatLayout(); } } -else if ( m_pImp->GetShell()->IsPaintLocked() ) -// Shortcut to minimize the cycles. With Lock, the -// paint is coming either way (primarily for browse) +else if (m_pImp->GetShell()->IsPaintLocked() || !pLay->IsColBodyFrame()) +{ // tdf#156724 unconditionally for frames in tables, so their footnotes exist before trying
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ww8export/ww8export4.cxx| 50 +++ sw/qa/filter/ww8/data/floattable-tbl-overlap.doc |binary sw/qa/filter/ww8/ww8.cxx | 15 ++ sw/source/filter/ww8/wrtww8.cxx |8 +++ sw/source/filter/ww8/ww8par6.cxx | 17 +++ sw/source/filter/ww8/ww8struc.hxx|1 6 files changed, 91 insertions(+) New commits: commit 35f0084bd658a6438d3c4d51824fbdb90ac85cb1 Author: Miklos Vajna AuthorDate: Mon Aug 14 08:25:41 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Aug 21 10:52:32 2023 +0200 sw floattable: handle AllowOverlap==false in the DOC filter Map sprmTFNoAllowOverlap to SwFormatWrapInfluenceOnObjPos::mbAllowOverlap on import, and do the opposite on export. Change-Id: Id61be49adb39862e30ffb2da9ff9aabae11f7d83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155650 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155714 diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index 7e3042aefab2..6e483211ba58 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -25,6 +25,11 @@ #include #include #include +#include +#include +#include +#include +#include class Test : public SwModelTestBase { @@ -142,6 +147,51 @@ CPPUNIT_TEST_FIXTURE(Test, testDontBreakWrappedTables) CPPUNIT_ASSERT(bDontBreakWrappedTables); } +CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCExport) +{ +// Given a document with a floating table, overlap is not allowed: +{ +createSwDoc(); +SwDoc* pDoc = getSwDoc(); +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->Insert2("before table"); +// Insert a table: +SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); +pWrtShell->InsertTable(aTableOptions, /*nRows=*/1, /*nCols=*/1); +pWrtShell->MoveTable(GotoPrevTable, fnTableStart); +// Select table: +pWrtShell->SelAll(); +// Wrap the table in a text frame: +SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); +pWrtShell->StartAllAction(); +aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); +pWrtShell->EndAllAction(); +// Allow the text frame to split: +pWrtShell->StartAllAction(); +sw::FrameFormats* pFlys = pDoc->GetSpzFrameFormats(); +sw::SpzFrameFormat* pFly = (*pFlys)[0]; +SwAttrSet aSet(pFly->GetAttrSet()); +aSet.Put(SwFormatFlySplit(true)); +// Don't allow overlap: +SwFormatWrapInfluenceOnObjPos aInfluence; +aInfluence.SetAllowOverlap(false); +aSet.Put(aInfluence); +pDoc->SetAttr(aSet, *pFly); +pWrtShell->EndAllAction(); +} + +// When saving to DOC: +saveAndReload("MS Word 97"); + +// Then make sure that the overlap=never markup is written: +SwDoc* pDoc = getSwDoc(); +sw::FrameFormats* pFlys = pDoc->GetSpzFrameFormats(); +sw::SpzFrameFormat* pFly = (*pFlys)[0]; +// Without the accompanying fix in place, this test would have failed, i.e. TFNoAllowOverlap was +// not written. + CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapInfluenceOnObjPos().GetAllowOverlap()); +} + DECLARE_WW8EXPORT_TEST(testTdf104704_mangledFooter, "tdf104704_mangledFooter.odt") { CPPUNIT_ASSERT_EQUAL(2, getPages()); diff --git a/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc b/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc new file mode 100644 index ..921ffe1fa667 Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc differ diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 2d12e980dbdb..db1dbcd1bf36 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -455,6 +455,21 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCXExport) // i.e. was not written. assertXPath(pXmlDoc, "//w:tblPr/w:tblOverlap", "val", "never"); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCImport) +{ +// Given a document with two floating tables, the second has sprmTFNoAllowOverlap=1 set: +// When importing that document: +createSwDoc("floattable-tbl-overlap.doc"); + +// Then make sure the second table is marked as "can't overlap": +SwDoc* pDoc = getSwDoc(); +sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); +sw::SpzFrameFormat* pFly = rFlys[1]; +// Without the accompanying fix in place, this test would have failed, the fly had the default +// "can overlap". + CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapInfluenceOnObjPos().GetAllowOverlap()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/wrtww8.cxx
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uitest/writer_tests7/tdf156783.py | 63 sw/source/core/crsr/crsrsh.cxx |2 - 2 files changed, 64 insertions(+), 1 deletion(-) New commits: commit 2748138cb5c1ad03ef794f8411e28e02de608f39 Author: László Németh AuthorDate: Wed Aug 16 21:41:26 2023 +0200 Commit: László Németh CommitDate: Fri Aug 18 11:27:39 2023 +0200 tdf#156783 sw tracked table column: fix crash setting border or border padding without correct table cursor. Table formatting is allowed on text selections starting with tables, but adding border or border padding resulted crashing. This regression became more visible with hidden deleted table columns, where SelectTable (e.g. Ctrl-A) doesn't select the whole table, but only the text content of the visible cells, and in the case of hidden right table columns, without table cursor. Manual test: insert two tables in the document, and in the first cell of the first table, select the whole document by pressing Ctrl-A 2 times or more. In table settings, enable table border or modify padding to crash LibreOffice. Regression since version 7.5. Change-Id: If8ebb52c7662ff37ac42348c8f412549b793b6d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155749 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 3a2d3926bbaf6907a50b595d867d7e36cc4ffeaa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155773 diff --git a/sw/qa/uitest/writer_tests7/tdf156783.py b/sw/qa/uitest/writer_tests7/tdf156783.py new file mode 100644 index ..2ccdb7dcf6e1 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf156783.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_url_for_data_file + +# Bug 156783 - crash fix: setting table border on a table without correct table cursor + +class tdf156783(UITestCase): +def test_tdf156783(self): +with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + +# accept all tracked changes +self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges") + +# select all tables +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:SelectAll") + +# dialog Table Properties - Borders +with self.ui_test.execute_dialog_through_command(".uno:TableDialog", close_button="ok") as xDialog: +tabcontrol = xDialog.getChild("tabcontrol") +select_pos(tabcontrol, "3") + +sync = xDialog.getChild("sync") +rightmf = xDialog.getChild("rightmf") +leftmf = xDialog.getChild("leftmf") +topmf = xDialog.getChild("topmf") +bottommf = xDialog.getChild("bottommf") +sync.executeAction("CLICK", tuple()) + +rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) +rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) +rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"})) +leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) +leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) +leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"})) +topmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) +topmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) +topmf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"})) +bottommf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) +bottommf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) +bottommf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"})) + +self.assertEqual(get_state_as_dict(rightmf)["Text"], u"72pt") +self.assertEqual(get_state_as_dict(leftmf)["Text"], u"72pt") +self.assertEqual(get_state_as_dict(topmf)["Text"], u"72pt") +self.assertEqual(get_state_as_dict(bottommf)["Text"], u"72pt") + +#
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx |binary sw/qa/core/objectpositioning/objectpositioning.cxx | 33 ++ sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx | 22 ++ 3 files changed, 55 insertions(+) New commits: commit c129a64adcd3d3be98d4eb136bceb53e72b3aff0 Author: Miklos Vajna AuthorDate: Thu Aug 10 09:05:18 2023 +0200 Commit: Michael Stahl CommitDate: Mon Aug 14 19:16:42 2023 +0200 sw floattable: handle AllowOverlap==false in the layout The bugdoc has two floating tables, and these would normally overlap, but SwFormatWrapInfluenceOnObjPos::mbAllowOverlap requests tweaking the position at a layout level to avoid that overlap. This is similar to what commit d37096f59e7e0286e55008153591a60bab92b9e8 (Related: tdf#124600 sw anchored object allow overlap: add layout, 2019-09-19) did, but that was for draw shapes and this is for split flys. Fix the problem by extending SwToContentAnchoredObjectPosition::CalcOverlap(): the overlap detection can be reused, just need to look for split flys on the entire page + need to check split flys against other split flys. The ODT filter works out of the box. Change-Id: Id31308a67ba502bcc830f15a1679996ec153f209 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155536 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 905962db870e9d1cf1dcf3bd1be44c347cddafe1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155601 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx b/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx new file mode 100644 index ..b5b23931a240 Binary files /dev/null and b/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx differ diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx index bb3a12793ae8..4958b8b6deb4 100644 --- a/sw/qa/core/objectpositioning/objectpositioning.cxx +++ b/sw/qa/core/objectpositioning/objectpositioning.cxx @@ -15,6 +15,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include /// Covers sw/source/core/objectpositioning/ fixes. class SwCoreObjectpositioningTest : public SwModelTestBase @@ -280,6 +286,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testVMLVertAlignBottomMargin) CPPUNIT_ASSERT_EQUAL(static_cast(1), nFifthVMLShapeOutside - nPageBottom); } +CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testFloatingTableOverlapNever) +{ +// Given a document with two floating tables, positioned in a way that normally these would +// overlap, but SwFormatWrapInfluenceOnObjPos::mbAllowOverlap == false explicitly asks to avoid +// overlaps: +createSwDoc("floattable-tbl-overlap.docx"); + +// When laying out that document: +calcLayout(); + +// Then make sure no overlap happens: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size()); +auto pFlyFrame1 = rPage1Objs[0]->DynCastFlyFrame(); +auto pFlyFrame2 = rPage1Objs[1]->DynCastFlyFrame(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected greater than: 2291 +// - Actual : 2175 +// i.e. the 2nd floating table overlapped with the first one. +CPPUNIT_ASSERT_GREATER(pFlyFrame1->getFrameArea().Bottom(), pFlyFrame2->getFrameArea().Top()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index 9a9abc9f4dd8..33168ceba432 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -1194,6 +1194,21 @@ void SwToContentAnchoredObjectPosition::CalcOverlap(const SwTextFrame* pAnchorFr // Get the list of objects. auto pSortedObjs = pAnchorFrameForVertPos->GetDrawObjs(); + +bool bSplitFly = false; +SwFlyFrame* pFlyFrame = GetAnchoredObj().DynCastFlyFrame(); +if (pFlyFrame && pFlyFrame->IsFlySplitAllowed()) +{ +// At least for split flys we need to consider objects on the same page, but anchored in +// different text frames. +bSplitFly = true; +const SwPageFrame* pPageFrame = pAnchorFrameForVertPos->FindPageFrame(); +if (pPageFrame) +{ +pSortedObjs = pPageFrame->GetSortedObjs(); +} +} +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/filter/ww8/ww8.cxx | 45 +++ sw/source/filter/ww8/docxtableexport.cxx |8 + 2 files changed, 53 insertions(+) New commits: commit 00203a05e84143b57170f75f5a9f57120bad24c6 Author: Miklos Vajna AuthorDate: Fri Aug 11 08:27:32 2023 +0200 Commit: Michael Stahl CommitDate: Mon Aug 14 19:14:17 2023 +0200 sw floattable: export to DOCX Once split flys containing tables have "allow overlap" disabled, this is not saved to DOCX when we map them to floating tables. The working case is the allowOverlap attribute on shapes, added in commit f8c7a2284b88c149addc8a30abb0cad8a10dad77 (Related: tdf#124600 sw anchored object allow overlap: add DOCX filter, 2019-09-20). Fix the problem by extending DocxAttributeOutput::TableDefinition(), to write in case overlap is not allowed, after . DOC and RTF filters are still missing. Change-Id: I7d0bd4a15567014d3add8cbbcd92c62c5a33b7e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155573 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 5af44a176d2a738dd7523713202aeee27c5578b6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155603 Reviewed-by: Michael Stahl diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 68bbc28fcfc3..2d12e980dbdb 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -27,6 +27,7 @@ #include #include #include +#include namespace { @@ -410,6 +411,50 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableThenFloattable) // anchor. CPPUNIT_ASSERT_EQUAL(nFly1Anchor + 1, nFly2Anchor); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCXExport) +{ +// Given a document with a floating table, overlap is not allowed: +createSwDoc(); +SwDoc* pDoc = getSwDoc(); +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->Insert2("before table"); +// Insert a table: +SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); +pWrtShell->InsertTable(aTableOptions, /*nRows=*/1, /*nCols=*/1); +pWrtShell->MoveTable(GotoPrevTable, fnTableStart); +// Select table: +pWrtShell->SelAll(); +// Wrap the table in a text frame: +SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); +pWrtShell->StartAllAction(); +aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); +pWrtShell->EndAllAction(); +// Allow the text frame to split: +pWrtShell->StartAllAction(); +auto& rFlys = *pDoc->GetSpzFrameFormats(); +auto pFly = rFlys[0]; +SwAttrSet aSet(pFly->GetAttrSet()); +aSet.Put(SwFormatFlySplit(true)); +// Don't allow overlap: +SwFormatWrapInfluenceOnObjPos aInfluence; +aInfluence.SetAllowOverlap(false); +aSet.Put(aInfluence); +pDoc->SetAttr(aSet, *pFly); +pWrtShell->EndAllAction(); + +// When saving to DOCX: +save("Office Open XML Text"); + +// Then make sure that the overlap=never markup is written: +xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 0 +// - XPath '//w:tblPr/w:tblOverlap' number of nodes is incorrect +// i.e. was not written. +assertXPath(pXmlDoc, "//w:tblPr/w:tblOverlap", "val", "never"); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx index 51fb3540c9df..b3e2d014222b 100644 --- a/sw/source/filter/ww8/docxtableexport.cxx +++ b/sw/source/filter/ww8/docxtableexport.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include "docxexportfilter.hxx" #include "docxhelper.hxx" @@ -281,6 +282,13 @@ void DocxAttributeOutput::TableDefinition( bFloatingTableWritten = true; // The outer table was floating, make sure potential inner tables are not floating. m_rExport.SetFloatingTableFrame(nullptr); + +const SwFrameFormat& rFloatingTableFormat = pFloatingTableFrame->GetFrameFormat(); +if (!rFloatingTableFormat.GetWrapInfluenceOnObjPos().GetAllowOverlap()) +{ +// Allowing overlap is the default, both in OOXML and in Writer. +m_pSerializer->singleElementNS(XML_w, XML_tblOverlap, FSNS(XML_w, XML_val), "never"); +} } // Extract properties from grab bag
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf147938.fodt | 160 ++ sw/qa/extras/uiwriter/uiwriter8.cxx | 57 ++ sw/source/core/undo/untbl.cxx |7 + 3 files changed, 223 insertions(+), 1 deletion(-) New commits: commit 7eec6b434445bac246bb75cc436fd77cad6af163 Author: Michael Stahl AuthorDate: Fri Aug 4 13:12:05 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Aug 14 11:29:41 2023 +0200 tdf#147938 sw_redlinehide: fix undo of table to text The problem is that when the text node is split in SwNodes::UndoTableToText(), the 2nd one retains the merge flag NonFirst, not the 1st one, and it ends up in the 2nd table cell, so it's skipped when creating the layout frames (and an assert in InsertCnt_() segfaults). SwContentNode::DelFrames() should probably reset the merge flags of nodes when it deletes the merged frame. (regression from commit 32902f66e7749b2d06d13f50416be5323a0c0ea9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155345 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 5b55ccfd384d3c0c11e05f22bd7e956b4bc7e43a) tdf#147938 sw_redlinehide: move fix into SwNodes::UndoTableOfText() Reproducing tdf#151866 on the .odt attachment, it becomes clear that the fix for tdf#147938 is in the wrong place. There a node has the merge flag None although it is the last node of a merge, because CheckParaRedlineMerge() first sets the node flags and then calls DelFrames(), which now resets the flags. In case there's another caller of DelFrames() that needs this, it's not obvious, can be added later. (regression from commit 5b55ccfd384d3c0c11e05f22bd7e956b4bc7e43a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155516 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit b5a41467efdce02b80ffe3824fdefe9fbc01fc95) Change-Id: I7b3b1ca873bde831481c676780200a3206ae667c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155305 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/uiwriter/data/tdf147938.fodt b/sw/qa/extras/uiwriter/data/tdf147938.fodt new file mode 100644 index ..6a95cb59c203 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf147938.fodt @@ -0,0 +1,160 @@ + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2023-08-04T13:37:50.9405330032023-08-04T13:39:42.785634897PT1M27S2LibreOfficeDev/7.5.5.0.0$Linux_X86_64 LibreOffice_project/c430b30a2ea9a678e44af112a171c86fab519a37 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt | 25 + sw/qa/core/txtnode/txtnode.cxx | 26 ++ sw/source/core/edit/edsect.cxx | 21 +++- 3 files changed, 71 insertions(+), 1 deletion(-) New commits: commit 7dbecdd63c292ba28aa5bb7143be5b0560f38c4e Author: László Németh AuthorDate: Thu Aug 10 13:37:13 2023 +0200 Commit: László Németh CommitDate: Mon Aug 14 11:13:38 2023 +0200 tdf#156492 sw: fix alt-Enter in cells merged vertically Inserting empty paragragh after the tables didn't work, if the bottom right corner of the table contains cells merged vertically. Manual test: positionate the text cursor at the end of the last paragraph of the bottom right cell of the table (which contains also cells merged vertically), and press alt-Enter to insert an empty paragraph after the table. Note: SpecialInsert, i.e. inserting empty paragraph by pressing alt-Enter is the quick and sometimes the only possible way to insert an empty paragraph before or after tables and sections. Change-Id: Ic845c3d683a561784afe69588b3b1538e82c35c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/16 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit ab60445f9250087029d5f1879668340277721efa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155487 Tested-by: László Németh diff --git a/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt b/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt new file mode 100644 index ..55ba746b669c --- /dev/null +++ b/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index 640df69ed211..4a4bf9901a2f 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -64,6 +64,32 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testBtlrCellChinese) assertXPath(pXmlDoc, "//font[1]", "vertical", "false"); } +CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testSpecialInsertAfterMergedCells) +{ +// Load a document with a table with bottom right cells merged vertically. +// SpecialInsert with alt-Enter must work here, too. +createSwDoc("special-insert-after-merged-cells.fodt"); +SwDoc* pDoc = getSwDoc(); +SwNodeOffset const nNodes(pDoc->GetNodes().Count()); +SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); +SwDocShell* pShell = pTextDoc->GetDocShell(); +SwWrtShell* pWrtShell = pShell->GetWrtShell(); +// go to the merged cell +pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + +// When pressing alt-Enter on the keyboard: +SwEditWin& rEditWin = pWrtShell->GetView().GetEditWin(); +vcl::KeyCode aKeyCode(KEY_RETURN, KEY_MOD2); +KeyEvent aKeyEvent(' ', aKeyCode); +rEditWin.KeyInput(aKeyEvent); + +// Without the accompanying fix in place, this test would have failed with: +// - Expected: nNodes + 1 +// - Actual : nNodes +// i.e. new empty paragraph wasn't inserted under the table +CPPUNIT_ASSERT_EQUAL(nNodes + 1, pDoc->GetNodes().Count()); +} + CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxCopyAnchor) { createSwDoc("textbox-copy-anchor.docx"); diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index 6116a422557f..a7e652aea9de 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -356,12 +356,31 @@ static const SwNode* lcl_SpecialInsertNode(const SwPosition* pCurrentPos) // we found an end if // - we're at or just before an end node // - there are only end nodes between the current node and -// pInnermostNode's end node +// pInnermostNode's end node or +// - there are only end nodes between the last table cell merged with +// the current cell and pInnermostNode's end node SwNodeIndex aEnd( pCurrentPos->GetNode() ); if( rCurrentNode.IsContentNode() && ( pCurrentPos->GetContentIndex() == rCurrentNode.GetContentNode()->Len() ) ) +{ ++aEnd; + +// tdf#156492 handle cells merged vertically in the bottom right corner +if ( pInnermostNode->IsTableNode() ) +{ +const SwNode* pTableBoxStartNode = pCurrentPos->GetNode().FindTableBoxStartNode(); +const SwTableBox* pTableBox = pTableBoxStartNode->GetTableBox(); +if ( pTableBox && pTableBox->getRowSpan() > 1 ) +{ +const SwTableNode* pTableNd = pInnermostNode->FindTableNode(); +pTableBox
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter5.cxx | 30 ++ sw/source/core/frmedt/fetab.cxx | 33 +++-- 2 files changed, 53 insertions(+), 10 deletions(-) New commits: commit dfa57ee45bf9aef73f8bf385b089739ee0572998 Author: László Németh AuthorDate: Tue Aug 8 19:46:15 2023 +0200 Commit: László Németh CommitDate: Mon Aug 14 11:13:14 2023 +0200 tdf#156487 sw tracked table column: fix Hide Changes In Hide Changes mode, deleting table columns with change tracking wasn't applied on the table layout immediately, only using Show Changes and Hide Changes again. Now the deleted column removed from the table instead leaving an empty table column. Also revert commit 33058b5dc47a140516669945efbdd30ea65138a6 "tdf#156544 sw tracked table column: delete empty column". See also commit a74c51025fa4519caaf461492e4ed8e68bd34885 "tdf#146962 sw: hide deleted row at deletion in Hide Changes". Change-Id: If03d2bc5996a168cb44839b0753effb9031edbc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155522 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 43b128a960d1712b984402e1b69cefecdb75462a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155478 Tested-by: László Németh diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 3e8babfff390..285a3adb7c61 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2777,6 +2777,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156544) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156487) +{ +// load a table, and delete a column in Hide Changes mode +createSwDoc("tdf118311.fodt"); +SwDoc* pDoc = getSwDoc(); + +// turn on red-lining and hide changes +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On); +CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + +CPPUNIT_ASSERT_MESSAGE("redlines shouldn't be visible", + !IDocumentRedlineAccess::IsShowChanges( + pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + +// delete table column with enabled change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + +// Dump the rendering of the first page as an XML file. +SwDocShell* pShell = pDoc->GetDocShell(); +std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); +MetafileXmlDump dumper; +xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); +CPPUNIT_ASSERT(pXmlDoc); + +// This would be 2 without hiding the first cell +assertXPath(pXmlDoc, "/metafile/push/push/push/textarray/text", 1); +} + #ifndef DBG_UTIL CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) { diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index a766596daa29..dced56c1f2a0 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -279,11 +279,14 @@ bool SwFEShell::DeleteCol() CurrShell aCurr( this ); +bool bRecordChanges = GetDoc()->GetDocShell()->IsChangeRecording(); +bool bRecordAndHideChanges = bRecordChanges && + GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines(); + // tracked deletion: remove only textbox content, // and set IsNoTracked table box property to false -if ( GetDoc()->GetDocShell()->IsChangeRecording() ) +if ( bRecordChanges ) { -bool bDeletedEmptyCell = false; StartUndo(SwUndoId::COL_DELETE); StartAllAction(); @@ -296,6 +299,10 @@ bool SwFEShell::DeleteCol() TableWait aWait( 20, pFrame, *GetDoc()->GetDocShell(), aBoxes.size() ); +SwTableNode* pTableNd = pFrame->IsTextFrame() +? static_cast(pFrame)->GetTextNodeFirst()->FindTableNode() +: static_cast(pFrame)->GetNode()->FindTableNode(); + for (size_t i = 0; i < aBoxes.size(); ++i) { SwTableBox *pBox = aBoxes[i]; @@ -318,24 +325,30 @@ bool SwFEShell::DeleteCol() aCursor.GetMark()->SetContent(0); rIDRA.SetRedlineFlags_intern( eOld ); rIDCO.DeleteAndJoin( aCursor ); -bDeletedEmptyCell = true; } } } SwEditShell* pEditShell = GetDoc()->GetEditShell(); -SwRedlineTable::size_type nPrev = pEditShell->GetRedlineCount(); pEditShell->Delete(); +// remove cell frames in Hide Changes mode (and table frames, if needed) +if ( bRecordAndHideChanges ) +{ +// remove all frames of the table, and make them again without the deleted ones +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uitest/table/tdf146145.py | 32 sw/source/core/crsr/trvltbl.cxx |2 +- sw/source/core/frmedt/fetab.cxx | 26 -- 3 files changed, 49 insertions(+), 11 deletions(-) New commits: commit 855a43795d047445ab59d6de889b858f4f8e0f79 Author: László Németh AuthorDate: Thu Aug 3 12:00:07 2023 +0200 Commit: László Németh CommitDate: Mon Aug 14 11:12:44 2023 +0200 tdf#156595 sw tracked table column: fix crash at row deletion In Hide Changes mode, deleting a row, which has a hidden column deletion before the first cell, resulted a crash because of missing cell frame/table cursor. Regression from commit aff269c18b9029fec992135a406dc5031927c401 "tdf#155345 sw tracked table column: hide them in Hide Changes mode". Note: it seems, plain uiwriter testing is not enough to catch the problem. Change-Id: I12675ecd402d6411107b90809728454f13e60580 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155287 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 1d12c5de5ab39fba33e016299cc8234475003612) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155295 Tested-by: Jenkins diff --git a/sw/qa/uitest/table/tdf146145.py b/sw/qa/uitest/table/tdf146145.py index 84cda61a6cd1..55d2092ca51e 100644 --- a/sw/qa/uitest/table/tdf146145.py +++ b/sw/qa/uitest/table/tdf146145.py @@ -250,4 +250,36 @@ class tdf146145(UITestCase): xToolkit.processEventsToIdle() self.assertEqual(len(tables[0].getColumns()), 5) + def test_crashWithHiddenFirstTableColumn(self): +with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + +# accept all tracked changes +self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges") +# delete first table column +self.xUITest.executeCommand(".uno:DeleteColumns") + +# Check enabling Accept/Reject Track Change icons +# and Accept Change/Reject Change context menu items +# on table columns with tracked deletion or insertion + +# enable Track Changes toolbar + self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes") + +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') +xToolkit.processEventsToIdle() + +# cursor at changed text: Accept Track Change is enabled +self.assertTrue(self.is_enabled_Accept_Track_Change()) + +# hide changes +self.xUITest.executeCommand(".uno:ShowTrackedChanges") +while self.is_enabled_Accept_Track_Change(): +time.sleep(0.1) +self.assertFalse(self.is_enabled_Accept_Track_Change()) + +# Without the fix in place, this test would have crashed here +self.xUITest.executeCommand(".uno:DeleteRows") + +self.xUITest.executeCommand(".uno:ShowTrackedChanges") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 0aaa899b5a46..689457d02863 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -128,7 +128,7 @@ bool SwCursorShell::SelTableRowOrCol( bool bRow, bool bRowSimple ) { // check if the current cursor's SPoint/Mark are in a table SwFrame *pFrame = GetCurrFrame(); -if( !pFrame->IsInTab() ) +if( !pFrame || !pFrame->IsInTab() ) return false; const SwTabFrame* pTabFrame = pFrame->FindTabFrame(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 8a6a664fe206..a766596daa29 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -535,18 +535,24 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) if ( SwWrtShell* pWrtShell = dynamic_cast(this) ) { pWrtShell->SelectTableRow(); -SwShellTableCursor* pTableCursor = GetTableCursor(); +SwCursor* pTableCursor = static_cast(GetTableCursor()); auto pStt = aBoxes[0]; auto pEnd = aBoxes.back(); -pTableCursor->DeleteMark(); - -// set start and end of the selection -pTableCursor->GetPoint()->Assign( *pEnd->GetSttNd()->EndOfSectionNode() ); -pTableCursor->Move( fnMoveBackward, GoInContent ); -pTableCursor->SetMark(); -pTableCursor->GetPoint()->Assign( *pStt->GetSttNd()->EndOfSectionNode() ); -pTableCursor->Move( fnMoveBackward, GoInContent ); -pWrtShell->UpdateCursor(); +if ( pTableCursor ) +pTableCursor->DeleteMark(); +else +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/htmlexport/data/table_cell_padding.fodt | 34 +++ sw/qa/extras/htmlexport/htmlexport.cxx | 32 + sw/source/filter/html/htmltab.cxx| 27 +-- 3 files changed, 91 insertions(+), 2 deletions(-) New commits: commit 7ae758b3c00e4b190290bb59da32cc31fb9feb28 Author: Mike Kaganski AuthorDate: Mon Aug 7 09:22:00 2023 +0300 Commit: Michael Stahl CommitDate: Wed Aug 9 10:56:53 2023 +0200 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 Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155414 Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/htmlexport/data/table_cell_padding.fodt b/sw/qa/extras/htmlexport/data/table_cell_padding.fodt new file mode 100644 index ..059a37b9dab7 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/table_cell_padding.fodt @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + A + + + B + + + + + C + + + D + + + + + + + diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 54df6ebf4e1e..b6f55cebcd3f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2714,6 +2715,37 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_Tdf156602) assertXPathContent(pDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p", "Following text"); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf156647_CellPaddingRoundtrip) +{ +// Given a document with a table with cell padding: +createSwDoc("table_cell_padding.fodt"); +{ +auto xTable = getParagraphOrTable(1); +auto aTableBorder = getProperty(xTable, "TableBorder2"); +CPPUNIT_ASSERT_EQUAL(sal_Int16(1270), aTableBorder.Distance); +CPPUNIT_ASSERT(aTableBorder.IsDistanceValid); +} +// When exporting to reqif-xhtml: +ExportToReqif(); +// Make sure that we export it: +xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); +assertXPath(pXmlDoc, "//reqif-xhtml:table", "cellpadding", "48"); // px +// Now import it +mxComponent->dispose(); +ImportFromReqif(maTempFile.GetURL()); +// Then make sure that padding is not lost: +{ +auto xTable = getParagraphOrTable(1); +auto aTableBorder = getProperty(xTable, "TableBorder2"); +// Without the accompanying fix in place, this test would have failed: +// - Expected: 1270 +// - Actual : 97 +// as the padding was lost, and the default 55 twip padding was used. +CPPUNIT_ASSERT_EQUAL(sal_Int16(1270), aTableBorder.Distance); +CPPUNIT_ASSERT(aTableBorder.IsDistanceValid); +} +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index a028a8fe86c4..99d412b02904 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 pOldBoxItem; +if (const SvxBoxItem* pBoxItem2 = rAttrSet.GetItemIfSet(RES_BOX)) +pOldBoxItem.reset(pBoxItem2->Clone()); pTableFormat->UpdateToSet(nPos, m_nRows==1, m_nCols==1, - const_cast(static_cast( - pFrameFormat->GetAttrSet())), + const_cast(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)); +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-then-table.doc |binary sw/qa/core/layout/flycnt.cxx | 14 ++ sw/source/core/layout/flycnt.cxx |9 + 3 files changed, 23 insertions(+) New commits: commit 8638cca898467d4644bc122ef1cbe8cc1bd443b1 Author: Miklos Vajna AuthorDate: Tue Aug 8 08:17:17 2023 +0200 Commit: Mike Kaganski CommitDate: Wed Aug 9 08:26:41 2023 +0200 tdf#156589 sw floattable: fix follow fly moving inside a table on the next page Opening the bugdoc and inserting a page break at the document start resulted in a crash. The direct problem was a nullptr deref in Notify_Background(), because pCnt reported true for IsInTab(), but then FindTabFrame() didn't find anything. The deeper problem was that SwFrame::GetNextFlyLeaf() had a case where it created a follow text frame for the anchor of a floating table, but that follow text frame went inside a table on the start of the next page, not to the start of the page. Fix the problem by continuing to use GetNextLayoutLeaf() (which knows how to traverse the layout tree from a fly frame to its anchor and then to a next page), but once we moved to a body on a next page and we would insert inside an inline table, insert before the table instead. Need to make sure the target is in a body frame, because a next layout leaf in a footer's table is not OK. Change-Id: I3ff6a0bbc2cac5f1bc2803a52a632c13053d4daa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155444 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 0d571ff8079f858a5650bf6cbb38296d22cc58e1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155406 Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/layout/data/floattable-then-table.doc b/sw/qa/core/layout/data/floattable-then-table.doc new file mode 100644 index ..8c9684e5950a Binary files /dev/null and b/sw/qa/core/layout/data/floattable-then-table.doc differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 6207a956f574..ba688728743b 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -996,6 +996,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyGrowFromBottom) // frame on page 1 even when it would fit, and this lead to a crash on export later. CPPUNIT_ASSERT(!pFly->GetFollow()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyIntoTable) +{ +// Given a document with a floating table, then an inline table on the next page: +createSwDoc("floattable-then-table.doc"); + +// When inserting a page break: +// Then make sure the layout doesn't crash: +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->InsertPageBreak(); +// Without the accompanying fix in place, this test would have crashed, we tried to insert the +// second part of a floating table into a table on the next page, not before that table. +calcLayout(); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 25e3f45c0bfa..113eaafbce9d 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1614,6 +1614,15 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) // The above conditions are not held, reject. pOldLayLeaf = pLayLeaf; pLayLeaf = pLayLeaf->GetNextLayoutLeaf(); + +if (pLayLeaf && pLayLeaf->IsInDocBody() && !bSameBody && !pLayLeaf->IsInFly() && pLayLeaf->IsInTab()) +{ +// We found a next leaf in a next body frame, which is in an inline table. Make +// sure we won't insert the follow anchor inside the table, but before it. +SwTabFrame* pTabFrame = pLayLeaf->FindTabFrame(); +pLayLeaf = pTabFrame->GetUpper(); +} + continue; } }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-from-bottom.docx |binary sw/qa/core/layout/flycnt.cxx | 21 + sw/source/core/layout/fly.cxx | 15 ++- 3 files changed, 35 insertions(+), 1 deletion(-) New commits: commit 35a8e22495a4cf756e650e8e4d840da1e8df80af Author: Miklos Vajna AuthorDate: Fri Aug 4 10:44:30 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Aug 8 10:18:15 2023 +0200 sw floattable, crashtesting: fix PDF export of tdf73201-1.docx The direct cause is that in in the SwTextFrameBreak ctor, m_pFrame has IsInSct() as true, but FindSctFrame() then doesn't find anything, which should not happen. The bigger problem is that currently the fly split code assumes that frames grow from (logical) top to bottom, so in case the vertical orientation is bottom, and we have to grow from bottom to top, that needs re-positioning the fly, but the fly split code has no support for that. Fix the crash by denying this case in SwFlyFrame::IsFlySplitAllowed() for now, the document's table is not supposed to split in the first place. In case later there is a real need to split such flys, then more research is needed how that re-positioning works in detail for non-split flys and then we have to adapt the fly split code accordingly. Change-Id: I56cf074a3d740ab716f7de232fbd131d17544d9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155339 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit c545a0729e89ee2e8f14534b77422cc9eb4eb7cf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155397 Reviewed-by: Xisco Fauli diff --git a/sw/qa/core/layout/data/floattable-from-bottom.docx b/sw/qa/core/layout/data/floattable-from-bottom.docx new file mode 100644 index ..86374a68ba27 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-from-bottom.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index a1e4c05c6c1d..6207a956f574 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -975,6 +975,27 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap) const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyGrowFromBottom) +{ +// Given a document with a floating table that grows from the bottom: +createSwDoc("floattable-from-bottom.docx"); + +// When calculating the layout: +calcLayout(); + +// Then make sure that such a floating table is not split, matching Word: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +const auto pFly = dynamic_cast(rPage1Objs[0]); +// Without the accompanying fix in place, this test would have failed, we tried to split the fly +// frame on page 1 even when it would fit, and this lead to a crash on export later. +CPPUNIT_ASSERT(!pFly->GetFollow()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index a365668c4ce2..4022e1995fe8 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -687,7 +687,20 @@ bool SwFlyFrame::IsFlySplitAllowed() const return false; } -return GetFormat()->GetFlySplit().GetValue(); +const SwFlyFrameFormat* pFormat = GetFormat(); +const SwFormatVertOrient& rVertOrient = pFormat->GetVertOrient(); +if (rVertOrient.GetVertOrient() == text::VertOrientation::BOTTOM) +{ +// We have to grow from bottom to top, and the fly split code assumes that we grow from top +// to bottom, so don't split for now. +if (rVertOrient.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA) +{ +// Growing from the bottom of the body frame. +return false; +} +} + +return pFormat->GetFlySplit().GetValue(); } SwFrame *SwFlyFrame::FindLastLower()
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/frmedt/data/floating-table-caption.docx |binary sw/qa/core/frmedt/frmedt.cxx | 28 + sw/source/core/frmedt/fews.cxx | 18 - 3 files changed, 45 insertions(+), 1 deletion(-) New commits: commit 41060a937c529247c0d4f815228bb1e21803de60 Author: Miklos Vajna AuthorDate: Thu Aug 3 08:50:39 2023 +0200 Commit: Caolán McNamara CommitDate: Fri Aug 4 10:23:56 2023 +0200 tdf#156349 sw floattable: fix caption insert for tables inside split fly frames Inserting a long enough caption below the table inside a split fly resulted in a layout loop. An additional, second problem is that in case a split fly only has a table, that can be mapped to a floating table in Word formats, but once a caption is inserted after the table (but still inside the frame), then this will be a normal shape, which can't be split. Fix the problem by disabling the "is split allowed" property on the fly in case it's on, and only then insert the caption. This not only avoids the layout loop, it also results in rendering that will match after save + load, for Word formats. Change-Id: Ie8b04e6266dd5c4068e5add86efb09cc6a6ea01f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155276 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 107de1a2c6882213cf0ef6783417302f43cdada0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155291 Reviewed-by: Caolán McNamara diff --git a/sw/qa/core/frmedt/data/floating-table-caption.docx b/sw/qa/core/frmedt/data/floating-table-caption.docx new file mode 100644 index ..18c4690322d8 Binary files /dev/null and b/sw/qa/core/frmedt/data/floating-table-caption.docx differ diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx index 26c64c0833f8..f5a12e9392f1 100644 --- a/sw/qa/core/frmedt/frmedt.cxx +++ b/sw/qa/core/frmedt/frmedt.cxx @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include /// Covers sw/source/core/frmedt/ fixes. class SwCoreFrmedtTest : public SwModelTestBase @@ -168,6 +171,31 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testTextBoxSelectCursorPos) CPPUNIT_ASSERT_EQUAL(nAnchor, nCursor); } +CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyInsertCaption) +{ +// Given a document with a full-page floating table: +createSwDoc("floating-table-caption.docx"); + +// When trying to insert a caption below that table: +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->GotoTable("Table1"); +InsCaptionOpt aOpt; +SwView& rView = pWrtShell->GetView(); +aOpt.SetCategory("Table"); +aOpt.SetCaption("Numbers English-German"); +// After, not before. +aOpt.SetPos(1); +// Without the accompanying fix in place, this call never finished, layout didn't handle content +// after the table in a floating table. +rView.InsertCaption(); + +// Then make sure the insertion finishes and now this is just a plain table-in-frame: +SwDoc* pDoc = getSwDoc(); +sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); +sw::SpzFrameFormat* pFly = rFlys[0]; +CPPUNIT_ASSERT(!pFly->GetAttrSet().GetFlySplit().GetValue()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index c89e26cf6a2c..cb26f3357225 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -50,6 +50,7 @@ #include #include #include +#include using namespace com::sun::star; @@ -452,9 +453,24 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString , con if( pCnt->IsInTab() ) { // pass down index to the TableNode for tables -const SwTable& rTable = *pCnt->FindTabFrame()->GetTable(); +SwTabFrame* pTabFrame = pCnt->FindTabFrame(); +const SwTable& rTable = *pTabFrame->GetTable(); nIdx = rTable.GetTabSortBoxes()[ 0 ] ->GetSttNd()->FindTableNode()->GetIndex(); + +SwFlyFrame* pFly = pTabFrame->FindFlyFrame(); +if (pFly && pFly->IsFlySplitAllowed()) +{ +// This table is in a split fly, but we will insert a label, which means this is not +// a floating table anymore, disable the "can split" bit, it'll be hidden on the UI +// anyway. +SwFrameFormat& rFlyFormat = pFly->GetFrameFormat(); +SfxItemSetFixed aSet(GetDoc()->GetAttrPool()); +SwFormatFlySplit aSplit(false); +aSet.Put(aSplit); +// SwUndoFormatAttr is created for us. +GetDoc()->SetFlyFrameAttr(rFlyFormat, aSet); +} } break; case SwLabelType::Draw:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/htmlexport/htmlexport.cxx | 46 ++ sw/source/core/doc/doclay.cxx | 25 ++- sw/source/filter/basflt/shellio.cxx| 14 ++-- sw/source/filter/html/htmlplug.cxx | 91 ++-- sw/source/filter/html/wrthtml.cxx | 104 ++--- sw/source/filter/html/wrthtml.hxx |2 sw/source/uibase/app/docsh.cxx | 15 +++- 7 files changed, 194 insertions(+), 103 deletions(-) New commits: commit e8ebfac4235c550daca5ca2067dbd8a69dbd09f5 Author: Mike Kaganski AuthorDate: Fri Jul 28 13:06:08 2023 +0300 Commit: Xisco Fauli CommitDate: Thu Aug 3 17:36:09 2023 +0200 ReqIF: allow to output a single selected OLE object To do that, "SelectionOnly" boolean propertyvalue is supported in the store arguments. Change-Id: I265e802256a9a678779bbd021dde9b0c87ca08b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155012 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 2f9c1990a85b0e867400f5952095704e178680ad) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155139 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 04577e8cafd0..dcfd6b9d535f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -2728,6 +2729,51 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_FrameTextAsObjectAltText) "Some text in frame & "); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testSingleOleExport) +{ +// Given a document containing an embedded OLE object: +createSwDoc("ole2.odt"); + +// Create a selection for that object: +auto xDrawPageSupplier(mxComponent.queryThrow()); +auto xDrawPage(xDrawPageSupplier->getDrawPage()); +auto xModel(mxComponent.queryThrow()); +auto xController(xModel->getCurrentController().queryThrow()); +xController->select(xDrawPage->getByIndex(0)); + +// Store only the selection +auto xStorable(mxComponent.queryThrow()); +css::uno::Sequence aStoreProperties = { +comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), +comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), +comphelper::makePropertyValue("RTFOLEMimeType", OUString("text/rtf")), +comphelper::makePropertyValue("SelectionOnly", true), +}; +xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); + +SvMemoryStream aStream; +WrapReqifFromTempFile(aStream); +xmlDocUniquePtr pXmlDoc = parseXmlStream(); + +// The root element must be reqif-xhtml:object +assertXPath(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", "type", "text/rtf"); +// It has no children +assertXPathChildren(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", 0); +// And the content is empty +assertXPathContent(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", ""); + +OUString aRtfData = getXPath(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", "data"); +INetURLObject aUrl(maTempFile.GetURL()); +aUrl.setName(aRtfData); +SvMemoryStream aRtf; + HtmlExportTest::wrapRtfFragment(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), aRtf); +tools::SvRef xReader(new TestReqIfRtfReader(aRtf)); +// The RTF OLE exports correctly +CPPUNIT_ASSERT(xReader->CallParser() != SvParserState::Error); +CPPUNIT_ASSERT_EQUAL(tools::Long(9358), xReader->GetObjw()); +CPPUNIT_ASSERT_EQUAL(tools::Long(450), xReader->GetObjh()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 02029856a09e..e71c7892398a 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -499,6 +499,13 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso, bool bAsCharAlso ) const { SwPosFlyFrames aRetval; +const SwStartNode* pDirectFly = nullptr; +if (pCmpRange && *pCmpRange->GetPoint() == *pCmpRange->GetMark() +&& (pCmpRange->GetPoint()->GetNode().IsOLENode() +|| pCmpRange->GetPoint()->GetNode().IsGrfNode())) +{ +pDirectFly = pCmpRange->GetPoint()->GetNode().FindFlyStartNode(); +} // collect all anchored somehow to paragraphs for(sw::SpzFrameFormat* pFly: *GetSpzFrameFormats()) @@ -509,11 +516,23 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso, { const SwFormatAnchor& rAnchor = pFly->GetAnchor(); SwNode const*const pAnchorNode = rAnchor.GetAnchorNode(); -if (pAnchorNode && -((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) || +if
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx |binary sw/qa/core/text/frmform.cxx| 37 + sw/source/core/text/frmform.cxx| 20 +-- 3 files changed, 54 insertions(+), 3 deletions(-) New commits: commit 262a1ae36eaf20e741759cd2c216456bbb472f7c Author: Miklos Vajna AuthorDate: Wed Aug 2 09:56:49 2023 +0200 Commit: Michael Stahl CommitDate: Thu Aug 3 11:55:19 2023 +0200 tdf#156260 sw floattable: avoid moving text from the last anchor to its precede The 5 page long bugdoc had a "dt" in the last paragraph, expanding that to an actual dummy text with F3 resulted in anchor text on both page 4 and page 5, while the expected behavior is that text only wraps on the last page, i.e. page 5. What happened is that the (text) "offset" of the text frame anchors on pages 1..5 are meant to be all 0 (so the actual anchor text is only on the last page), but in practice the anchor text frame on page 5 had an offset of 1123, which breaks the invariant that in case a fly frame is split to N pages, then only the last matching anchor text frame has text. (If it has too much text, then a next page with just anchor text is fine, but 0..N-1 pages should have no anchor text.) Fix the problem by SwTextFrame::AdjustFollow_(): in case it would reach the end for the "has follow, but no follow's follow" case, then still avoid setting the offset of the follow in case we know this is text frame has a non-last split fly anchored in it. With this, the render result matches in no overlaps and also what Word does in a similar edit session. (No F3 there, but can paste similar text at the document end.) Change-Id: I6c8d4f825d9dc356bb2a3a87a2f9c2e6529ce533 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155209 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit b6a22e2be79cd874c7526107a6793fae692620dc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155290 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx b/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx new file mode 100644 index ..017b3001b813 Binary files /dev/null and b/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx differ diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx index d23611a7eb05..f2f942bde324 100644 --- a/sw/qa/core/text/frmform.cxx +++ b/sw/qa/core/text/frmform.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include namespace { @@ -79,6 +81,41 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst) // anchors of non-last split fly frames should contain no text. CPPUNIT_ASSERT_EQUAL(static_cast(0), pAnchor->GetOffset().get()); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidLastManipOfst) +{ +// Given a document with a 5-page floating table and some anchor text: +createSwDoc("floattable-avoid-last-manip-ofst.docx"); +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->SttEndDoc(/*bStt=*/false); +pWrtShell->Insert2("dt"); + +// When expanding dummy text on the last page: +dispatchCommand(mxComponent, ".uno:ExpandGlossary", {}); + +// Then make sure the expanded text starts on page 5: +SwDoc* pDoc = getSwDocShell()->GetDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +auto pPage2 = dynamic_cast(pPage1->GetNext()); +CPPUNIT_ASSERT(pPage2); +auto pPage3 = dynamic_cast(pPage2->GetNext()); +CPPUNIT_ASSERT(pPage3); +auto pPage4 = dynamic_cast(pPage3->GetNext()); +CPPUNIT_ASSERT(pPage4); +auto pPage5 = dynamic_cast(pPage4->GetNext()); +CPPUNIT_ASSERT(pPage5); +SwContentFrame* pAnchor = pPage5->FindFirstBodyContent(); +SwTextFrame* pAnchorText = pAnchor->DynCastTextFrame(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 0 +// - Actual : 1123 +// i.e. the expand result went to page 4 and page 5 (page 5's content had no zero offset), +// instead of starting on page 5 (and creating a 6th page). +CPPUNIT_ASSERT_EQUAL(static_cast(0), + static_cast(pAnchorText->GetOffset())); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index cdf51563c0ae..c3c7f872b88a 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -602,7 +602,8 @@ void SwTextFrame::AdjustFollow_( SwTextFormatter , // We got the rest of the text mass: Delete all Follows // DummyPortions() are a special case. // Special cases are controlled by parameter . -if( HasFollow() && !(nMode &
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter5.cxx | 76 sw/source/core/frmedt/fetab.cxx |4 + 2 files changed, 79 insertions(+), 1 deletion(-) New commits: commit 72cf81802b7a9c4ce64cf853a80f2660da5ee26e Author: László Németh AuthorDate: Tue Aug 1 13:10:07 2023 +0200 Commit: Xisco Fauli CommitDate: Thu Aug 3 11:50:36 2023 +0200 tdf#156544 sw tracked table column: delete empty column Empty table columns were removed without change tracking in Record Changes mode, too. Follow-up to commit fe43f5971dfd2a121634eea9e39c7ad0cf3f962a "tdf#156475 sw tracked table column: delete empty cell". Change-Id: I8154cb1c75cf793f5a60e8259a91dd779fc766e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155153 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 33058b5dc47a140516669945efbdd30ea65138a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155187 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 07579cc6662a..3e8babfff390 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2701,6 +2701,82 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156544) +{ +// load a table, and insert a column without change tracking, +// and delete the first column with the empty cell in the second row with change tracking +createSwDoc("tdf118311.fodt"); +SwDoc* pDoc = getSwDoc(); + +// turn off red-lining and show changes +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be off", + !pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + +CPPUNIT_ASSERT_MESSAGE( +"redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + +// insert table column without change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {}); + +// check table +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1); +assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 3); + +// turn on red-lining +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + +// go to the empty column +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + +// delete table column with enabled change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + +discardDumpedLayout(); +pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1); + +// This was 2 (deleted column) +assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 3); + +// accept the deletion of the empty column +dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {}); + +discardDumpedLayout(); +pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1); +assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2); + +// test Undo/Redo +dispatchCommand(mxComponent, ".uno:Undo", {}); + +discardDumpedLayout(); +pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1); +assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 3); + +dispatchCommand(mxComponent, ".uno:Redo", {}); + +discardDumpedLayout(); +pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1); +assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2); +} + #ifndef DBG_UTIL CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) { diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index c271d975d567..8a6a664fe206 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -283,6 +283,7 @@ bool SwFEShell::DeleteCol() // and set IsNoTracked table box property to false if ( GetDoc()->GetDocShell()->IsChangeRecording() ) { +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter5.cxx | 63 sw/source/core/frmedt/fetab.cxx | 17 + 2 files changed, 80 insertions(+) New commits: commit e91faddabdf5d586c0044a3e125bdea6c2e21532 Author: László Németh AuthorDate: Thu Jul 27 15:40:52 2023 +0200 Commit: László Németh CommitDate: Wed Aug 2 12:14:41 2023 +0200 tdf#156475 sw tracked table column: delete empty cell Tracking changes, only non-empty cells of the deleted columns got coloring, and were hidden in Hide Changes mode. Add dummy text content to empty cells of the deleted columns to get visible deletion in Show Changes mode, also working context menu in that cell; to allow hiding them in Hide Changes mode, also to store the time stamp of the deletion, if all the other rows are removed during editing. Follow-up to commit 472abf99a4d90d7a53316394a2e51a26b7e62345 "tdf#155341 sw tracked table column: add insertion". Change-Id: Ieb5d237b3c82c81fded25608ef3d2906d7474003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154994 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit fe43f5971dfd2a121634eea9e39c7ad0cf3f962a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154962 diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 937567b9b2bc..07579cc6662a 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2605,6 +2605,69 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156474) CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, tdf156475) +{ +// load a table, and insert a row without change tracking, +// and delete the first column with the empty cell in the second row with change tracking +createSwDoc("tdf118311.fodt"); +SwDoc* pDoc = getSwDoc(); + +// turn off red-lining and show changes +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be off", + !pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + +CPPUNIT_ASSERT_MESSAGE( +"redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + +// insert table row +dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); + +// check table +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 2); +assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 2); +assertXPath(pXmlDoc, "//page[1]//body/tab/row[2]/cell", 2); + +// turn on red-lining +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + +// delete table column with enabled change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + +// go down to the empty cell +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->Down(/*bSelect=*/false); + +// Without the fix in place, this couldn't work +dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {}); + +discardDumpedLayout(); +pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row", 2); +assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 1); +assertXPath(pXmlDoc, "//page[1]//body/tab/row[2]/cell", 1); + +// test Undo/Redo +for (sal_Int32 i = 0; i < 4; ++i) +{ +dispatchCommand(mxComponent, ".uno:Undo", {}); +} + +for (sal_Int32 i = 0; i < 4; ++i) +{ +dispatchCommand(mxComponent, ".uno:Redo", {}); +} +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) { // load a table, and delete the first column with enabled change tracking: diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index daca7b86bc9c..c271d975d567 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -302,6 +304,21 @@ bool SwFEShell::DeleteCol() SwCursor aCursor( SwPosition(aIdx), nullptr ); SvxPrintItem aHasTextChangesOnly(RES_PRINT, false); GetDoc()->SetBoxAttr( aCursor, aHasTextChangesOnly ); + +// add dummy text content to the empty box for
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter5.cxx | 49 ++ sw/source/core/doc/DocumentRedlineManager.cxx |3 - 2 files changed, 50 insertions(+), 2 deletions(-) New commits: commit 6725d03d9a4f0562922e91c88d4494f5b74be063 Author: László Németh AuthorDate: Wed Jul 26 11:00:38 2023 +0200 Commit: László Németh CommitDate: Wed Aug 2 10:50:27 2023 +0200 tdf#156474 sw tracked table column: fix accept of insertion Accepting tracked table column insertion didn't reset HasTextChangesOnly bit of the table cells, resulting blue/pink cells (i.e. column change) after modifying only text content of the text, and later bad column deletion at accepting text-only deletion and at rejecting text-only insertion. Follow-up to commit 472abf99a4d90d7a53316394a2e51a26b7e62345 "tdf#155341 sw tracked table column: add insertion". Change-Id: I2e06e1b064d51c5e7cf8140a5fd7932e7be4f765 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154935 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 4caebc0b54461a1aadc8378a6749c0d5f05d7204) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154951 diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index dfe0cc80f7ec..937567b9b2bc 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2556,6 +2556,55 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableColumnDeletion) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156474) +{ +// load a table, and insert a column with change tracking +createSwDoc("tdf118311.fodt"); +SwDoc* pDoc = getSwDoc(); + +// turn on red-lining and show changes +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); +CPPUNIT_ASSERT_MESSAGE( +"redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + +uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xTables(xTextTablesSupplier->getTextTables(), +uno::UNO_QUERY); + +// there is a table in the text with two columns +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); +uno::Reference xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + +// insert table column with enabled change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {}); + +// 3 columns +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); + +// accept tracked changes: remove HasTextChangesOnly = false of the inserted cells +dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); + +// still 3 columns +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); + +// delete the text content (dummy character of the previous text change) of the newly +// inserted cell, and accept tracked changes +SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); +dispatchCommand(mxComponent, ".uno:SwBackspace", {}); +dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); + +// This was 2 columns (not removed HasTextChangesOnly = false resulted column deletion +// instead of deleting only content of the cell) +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) { // load a table, and delete the first column with enabled change tracking: diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index efed70b44a1a..898590d6201b 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -517,8 +517,7 @@ namespace const SvxPrintItem *pHasBoxTextChangesOnlyProp = pBox->GetFrameFormat()->GetAttrSet().GetItem(RES_PRINT); // table cell property "HasTextChangesOnly" is set and its value is false -if ( bRejectDeletion && pHasBoxTextChangesOnlyProp && -!pHasBoxTextChangesOnlyProp->GetValue() ) +if ( pHasBoxTextChangesOnlyProp && !pHasBoxTextChangesOnlyProp->GetValue() ) { SvxPrintItem aUnsetTracking(RES_PRINT, true); SwCursor aCursor( *pPos, nullptr );
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
dev/null|binary sw/qa/core/layout/data/floattable-no-footer-overlap.doc |binary sw/qa/core/layout/flycnt.cxx|9 ++ sw/source/core/layout/flowfrm.cxx | 13 sw/source/core/layout/tabfrm.cxx| 50 +++- 5 files changed, 70 insertions(+), 2 deletions(-) New commits: commit 7278c1facfd675dd1972a01370de4425704d9a16 Author: Miklos Vajna AuthorDate: Wed Jul 19 08:29:01 2023 +0200 Commit: Mike Kaganski CommitDate: Wed Aug 2 08:12:40 2023 +0200 tdf#120262 sw floattable: no split when none of first row fits the vert space The final problem with the bugdoc is that half row of the second floating table was still on page 1, while it should be fully on page 2. The reason for this was that first we thought we can't move forward, since GetIndPrev() returns nullptr for a table that's inside a fly frame. Then we thought it's a good idea to split, even if the split would move the entire first row to the next page. Fix the problem by: - In SwTabFrame::MakeAll(), handle split flys after calling GetIndPrev(), an indirect prev of the anchor has the same meaning in this context. - In SwTabFrame::Split(), fail for split flys in case only half of the first row's first line would fit, which gives an opporunity to call MoveFwd(). - In SwTabFrame::MakeAll(), call MoveFwd() in a way that it's not a problem that the GetIndPrev() call in MoveFwd() gives us a nullptr. - At this point we don't split the table, we move it forward, but an empty master remains on page 1. Fix that by improving SwFlowFrame::MoveSubTree() to mark empty flys for deletion, similar to how it does the same for sections. - Finally avoid a layout warning in SwTabFrame::MakeAll(), it's OK to try to split in case our split fly has a follow, we can move there on split failure. Also bring the test document closed to the original bugdoc, so we can assert the content on both pages. Change-Id: I2d3f88342d91b3e256bc41416a9afb274a9309d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154633 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 45574624ff05673d44f11cd49e1af599133e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155135 Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.doc b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc new file mode 100644 index ..87e301189df5 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc differ diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx deleted file mode 100644 index ca2f0d6d7244.. Binary files a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx and /dev/null differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 106be77ceac2..a1e4c05c6c1d 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -950,7 +950,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext) CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap) { // Given a document with 2 pages, a floating table on both pages: -createSwDoc("floattable-no-footer-overlap.docx"); +createSwDoc("floattable-no-footer-overlap.doc"); // When calculating the layout: calcLayout(); @@ -960,6 +960,13 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap) SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); auto pPage1 = dynamic_cast(pLayout->Lower()); CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 2 +// i.e. part of the second table was on page 1. +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); auto pPage2 = dynamic_cast(pPage1->GetNext()); // Without the accompanying fix in place, this test would have failed, there was no page 2, both // floating tables were on page 1. diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index b7356ec0a059..872e872083f8 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -693,6 +693,7 @@ void SwFlowFrame::MoveSubTree( SwLayoutFrame* pParent, SwFrame* pSibling ) // disappear automatically. SwSectionFrame *pSct; +SwFlyFrame* pFly = nullptr; if ( pOldParent && !pOldParent->Lower() && ( pOldParent->IsInSct() && !(pSct = pOldParent->FindSctFrame())->ContainsContent() && @@ -700,6 +701,18 @@ void
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/unocore/data/floattable-split.docx |binary sw/qa/core/unocore/unocore.cxx| 19 +++ sw/source/core/inc/flyfrm.hxx |3 +++ sw/source/core/layout/fly.cxx |5 + sw/source/core/unocore/unoobj2.cxx| 18 ++ 5 files changed, 45 insertions(+) New commits: commit 140ebce3b81a09d163c34ae792d090154302c8e7 Author: Miklos Vajna AuthorDate: Mon Jul 31 08:24:03 2023 +0200 Commit: Mike Kaganski CommitDate: Wed Aug 2 08:11:09 2023 +0200 tdf#156350 sw floattable: fix bad additional in ODT with layout The document has a floating table, split on two pages. Saving as ODT creates two elements, while we only expect one. The document model is correct, SwDoc::mpSpzFrameFormatTable only contains one frame, and in general the ODT export works with the SwDoc, but CollectFrameAtNode() uses the layout to help performance, and the layout is available when saving interactively (i.e. not --convert-to), which visits both layout frames of the same frame format. Fix the problem by ignoring follow fly frames in lcl_CollectFrameAtNodeWithLayout(), just working from master should ensure there is no duplication. This is similar to 4721729fba32a02683ecc930b630491599f8c6c5 (SwXParaFrameEnumeration: ignore textboxes, 2014-05-27), but that was for fly frames of draw shapes, and this is for split flys. Change-Id: I09729c0b0f9afd694e3cbf8886ccbc530bfc9674 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155081 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 2b401b7c0322d9ff972d252208ebe9a77913778d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155136 Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/unocore/data/floattable-split.docx b/sw/qa/core/unocore/data/floattable-split.docx new file mode 100644 index ..2e2c9c705df9 Binary files /dev/null and b/sw/qa/core/unocore/data/floattable-split.docx differ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 199da2e72a79..cb6f52d0fdbb 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -965,6 +965,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf155951) xText->insertString(xCursor, "test", /*bAbsorb=*/false); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testCollectFrameAtNodeWithLayout) +{ +// Given a document with a floating table on 2 pages, with a calculated layout: +createSwDoc("floattable-split.docx"); +calcLayout(); + +// When saving to ODT: +save("writer8"); + +// Then make sure the output is valid and hasa 1 : +// Without the accompanying fix in place, this test would have failed with: +// Error: uncompleted content model. +// i.e. the output was not valid, the second has an empty as a child +// element. +xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); +// Also make sure that we don't have multiple elements in the first place. +assertXPath(pXmlDoc, "//draw:frame", 1); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index d3815a82835a..4b47f0ad2b4e 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -38,6 +38,7 @@ class SwFormat; class SwViewShell; class SwFEShell; class SwWrtShell; +class SwFlyAtContentFrame; /** search an anchor for paragraph bound frames starting from pOldAnch @@ -307,6 +308,8 @@ public: virtual const SwFlyFrame* DynCastFlyFrame() const override; virtual SwFlyFrame* DynCastFlyFrame() override; +SwFlyAtContentFrame* DynCastFlyAtContentFrame(); + private: void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const; void PaintDecorators() const; diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 68184da48fd6..a365668c4ce2 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2100,6 +2100,11 @@ void SwFlyFrame::UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const rMngr.SetUnfloatTableButton(this, bShow, aTopRightPixel); } +SwFlyAtContentFrame* SwFlyFrame::DynCastFlyAtContentFrame() +{ +return IsFlyAtContentFrame() ? static_cast(this) : nullptr; +} + SwTwips SwFlyFrame::Grow_( SwTwips nDist, bool bTst ) { SwRectFnSet aRectFnSet(this); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 01682ef48587..472babcd8243 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include #include @@ -123,6 +125,22 @@ struct FrameClientSortListLess // Filter out textboxes, which are not interesting at a UNO level.
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/doc/data/floating-table-dummy-text.docx |binary sw/qa/core/doc/doc.cxx | 33 sw/source/core/doc/DocumentContentOperationsManager.cxx | 21 ++ 3 files changed, 54 insertions(+) New commits: commit 5e19348fb9507882827d29f875696ab225198be2 Author: Miklos Vajna AuthorDate: Tue Aug 1 09:06:43 2023 +0200 Commit: Mike Kaganski CommitDate: Wed Aug 2 08:06:31 2023 +0200 tdf#156260 sw floattable: avoid overlapping flys on anchor change Going to the end of the document, typing "dt" and F3 collapses the multi-page floating table into a single page, with overlapping text. In practice we insert a new paragraph before the "dt" one, insert the dummy text there and then re-anchor the floating table from the old paragraph to the new one. Such re-anchoring isn't really meant to be done with floating tables, which are always just anchored in the next paragraph in practice. An additional problem is that the amount of fly frames created depends on the position of the first fly frame, so if the anchor changes, we may need a different number of split fly frames. Fix the problem by not trying to reuse the old fly frames on anchor change: delete the old frames, change the anchor and finally create the new frames, which leads to correct layout with complicated logic trying to update the old fly chain to the new anchor. The original document still puts some dummy text on page 4 instead of starting it on page 5, that part is still unfixed. Change-Id: I74549e2ea8ca0d06a9e4814a58aaa8ca476263dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155122 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 073072f0a3abacfe4f9cc920b8138d7abc84db70) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155137 Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/doc/data/floating-table-dummy-text.docx b/sw/qa/core/doc/data/floating-table-dummy-text.docx new file mode 100644 index ..14de5a920a88 Binary files /dev/null and b/sw/qa/core/doc/data/floating-table-dummy-text.docx differ diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 5b523067523a..f8faee3a1bcd 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -34,6 +34,10 @@ #include #include #include +#include +#include +#include +#include /// Covers sw/source/core/doc/ fixes. class SwCoreDocTest : public SwModelTestBase @@ -482,6 +486,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitFlyChain) CPPUNIT_ASSERT_EQUAL(SwChainRet::IS_IN_CHAIN, eActual); } +CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitExpandGlossary) +{ +// Given a document with a split fly (2 pages) and a 'dt' at the end: +createSwDoc("floating-table-dummy-text.docx"); +SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); +pWrtShell->SttEndDoc(/*bStt=*/false); + +// When expanding 'dt' to an actual dummy text: +dispatchCommand(mxComponent, ".uno:ExpandGlossary", {}); + +// Then make sure the 2 fly frames stay on the 2 pages: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 2 +// i.e. both parts of the split fly chain were on page 1. +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); +auto pPage2 = dynamic_cast(pPage1->GetNext()); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 470a018eb0ef..f7d24dd55ea0 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -5238,7 +5239,27 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo { SwFormatAnchor anchor(*pAnchor); anchor.SetAnchor( ); + +bool bSplitFly = false; +if (pFly->GetFlySplit().GetValue()) +{ +SwIterator aIter(*pFly); +bSplitFly = aIter.First() && aIter.Next(); +} +if (bSplitFly) +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt | 13 + sw/qa/extras/ooxmlexport/ooxmlexport19.cxx | 31 sw/source/filter/ww8/docxattributeoutput.cxx| 32 ++--- sw/source/filter/ww8/docxattributeoutput.hxx|2 sw/source/filter/ww8/wrtw8nds.cxx | 42 - sw/source/filter/ww8/wrtww8.cxx | 49 sw/source/filter/ww8/wrtww8.hxx | 10 +++- sw/source/filter/ww8/ww8atr.cxx | 14 ++--- 8 files changed, 128 insertions(+), 65 deletions(-) New commits: commit b586410f13c39b1687cfe02cc48b8c14850eb055 Author: Mike Kaganski AuthorDate: Mon Jul 31 15:08:58 2023 +0300 Commit: Miklos Vajna CommitDate: Wed Aug 2 08:04:33 2023 +0200 tdf#156548: make truncated long bookmark name unique, and use it in hyperlinks Change-Id: I156359339ff8be85fe90cb6612eafdc6030c851f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155092 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit cba1b5de0bae4712024ccb0a4efd190f64c92ad8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155131 Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt b/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt new file mode 100644 index ..8b09760fcb6f --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt @@ -0,0 +1,13 @@ + + +http://www.w3.org/1999/xlink; xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + + + This is a hyperlink to the first target paragraph below + This is a hyperlink to the second target paragraph below + + The first target paragraph with a bookmark with a very long name + The second target paragraph with a bookmark with a very long name + + + diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx index 2769423eeb43..d6573d98bb21 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx @@ -1039,6 +1039,37 @@ DECLARE_OOXMLEXPORT_TEST(testTdf156372, "tdf156372.doc") CPPUNIT_ASSERT_EQUAL(1, getPages()); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156548) +{ +// Given a document using two bookmarks with similar names longer than 40 characters +loadAndReload("longBookmarkName.fodt"); + +// After the export, the names must be no longer than 40 characters; they must be unique; +// and the hyperlinks must use the same names, to still point to the correct targets: + +{ +// 1st paragraph - hyperlink to 4th paragraph +auto sURL = getProperty(getRun(getParagraph(1), 1), "HyperLinkURL"); + CPPUNIT_ASSERT_EQUAL(OUString("#A_bookmark_name_longer_than_forty_charac"), sURL); +// 4th paragraph - a bookmark +auto xBookmark = getProperty>(getRun(getParagraph(4), 1), + "Bookmark"); + CPPUNIT_ASSERT_EQUAL(OUString("A_bookmark_name_longer_than_forty_charac"), + xBookmark->getName()); +} + +{ +// 2nd paragraph - hyperlink to 5th paragraph +auto sURL = getProperty(getRun(getParagraph(2), 1), "HyperLinkURL"); + CPPUNIT_ASSERT_EQUAL(OUString("#A_bookmark_name_longer_than_forty_chara1"), sURL); +// 5th paragraph - a bookmark +auto xBookmark = getProperty>(getRun(getParagraph(5), 1), + "Bookmark"); + CPPUNIT_ASSERT_EQUAL(OUString("A_bookmark_name_longer_than_forty_chara1"), + xBookmark->getName()); +} +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 21e788665230..f543b08980d0 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2167,11 +2167,11 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In DoWriteBookmarkEndIfExist(nPos); } -void DocxAttributeOutput::DoWriteBookmarkTagStart(std::u16string_view bookmarkName) +void DocxAttributeOutput::DoWriteBookmarkTagStart(const OUString& bookmarkName) { m_pSerializer->singleElementNS(XML_w, XML_bookmarkStart, FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId), -FSNS(XML_w, XML_name), BookmarkToWord(bookmarkName)); +FSNS(XML_w, XML_name), GetExport().BookmarkToWord(bookmarkName)); } void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId) @@ -2227,7 +2227,7 @@ void DocxAttributeOutput::DoWriteBookmarkStartIfExist(sal_Int32 nRunPos) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf156372.doc |binary sw/qa/extras/ooxmlexport/ooxmlexport19.cxx | 11 +++ sw/source/core/layout/flowfrm.cxx |6 -- 3 files changed, 15 insertions(+), 2 deletions(-) New commits: commit a3d2630901608a0816bfbc490f695dde7c962952 Author: Satya AuthorDate: Mon Jul 31 14:31:10 2023 +0530 Commit: Michael Stahl CommitDate: Mon Jul 31 15:49:53 2023 +0200 tdf#156372 sw: Stop adding GetLower to every cell in header table The code was doubling the lower spacing of the last paragraph in every cell of the table. This change is to not add the space when in tables, since that was intended to only apply to the last paragraph in the header. make CppunitTest_sw_ooxmlexport19 CPPUNIT_TEST_NAME=testTdf156372 Change-Id: I4f676820634390416e6e96ea4149e48fbf0d8908 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155084 Reviewed-by: Michael Stahl Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf156372.doc b/sw/qa/extras/ooxmlexport/data/tdf156372.doc new file mode 100644 index ..3b8ade19f83d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf156372.doc differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx index a7c4b2c068d1..2769423eeb43 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx @@ -1028,6 +1028,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf133560) CPPUNIT_ASSERT_EQUAL(12.0f, getProperty(getParagraph(4), "CharHeight")); } +DECLARE_OOXMLEXPORT_TEST(testTdf156372, "tdf156372.doc") +{ +sal_Int32 nHeight = parseDump("//page[1]/header/tab/row[1]/infos/bounds", "height").toInt32(); +// Without a fix in place, this would fail with +// - Expected: 847 +// - Actual : 1327 +CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(847), nHeight, 5); + +CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 41b6b8fff953..b7356ec0a059 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1835,9 +1835,11 @@ SwTwips SwFlowFrame::CalcLowerSpace( const SwBorderAttrs* _pAttrs ) const // tdf#128195 Consider para spacing below last paragraph in header bool bHasSpacingBelowPara = m_rThis.GetUpper()->GetFormat()->getIDocumentSettingAccess().get( DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA); -if (bHasSpacingBelowPara && !m_rThis.IsInFly() && m_rThis.FindFooterOrHeader() && !GetFollow() -&& !m_rThis.GetIndNext()) +if (bHasSpacingBelowPara && !m_rThis.IsInTab() && !m_rThis.IsInFly() +&& m_rThis.FindFooterOrHeader() && !GetFollow() && !m_rThis.GetIndNext()) +{ nLowerSpace += _pAttrs->GetULSpace().GetLower() + _pAttrs->CalcLineSpacing(); +} return nLowerSpace; }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/scriptinfo-surrogate-pairs.fodt | 292 +++ sw/qa/core/text/text.cxx | 17 + sw/source/core/text/porlay.cxx | 23 - 3 files changed, 319 insertions(+), 13 deletions(-) New commits: commit 9122a0dd2a9a31431ae92bf96b3d27d4fcc88b9c Author: Khaled Hosny AuthorDate: Thu Jul 27 19:03:28 2023 +0300 Commit: Michael Stahl CommitDate: Mon Jul 31 12:28:54 2023 +0200 sw: Handle surrogate pairs when tweaking script info Change-Id: I18e8358657303571d5d90e5162dbb68cbe067980 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154995 Tested-by: Jenkins Reviewed-by: خالد حسني (cherry picked from commit 3af30bafbedb8eb481024efb35cb7876c63d26dc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154963 Reviewed-by: Michael Stahl diff --git a/sw/qa/core/text/data/scriptinfo-surrogate-pairs.fodt b/sw/qa/core/text/data/scriptinfo-surrogate-pairs.fodt new file mode 100644 index ..c14997a80741 --- /dev/null +++ b/sw/qa/core/text/data/scriptinfo-surrogate-pairs.fodt @@ -0,0 +1,292 @@ + + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="u rn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:oooc="http://openoffice.org/2004/calc; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:ooow="http://openoffice.org/2004/writer; xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http:/ /openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2023-07-27T18:43:02.5378016242023-07-27T18:43:53.298342476PT51S1LibreOfficeDev/24.2.0.0.alpha0$MacOSX_X86_64 LibreOffice_project/cf8f7b91f41821b79495c0388359c4cb1156ea67 + + + 0 + 0 + 17805 + 9950 + true + false + + + view2 + 3332 + 2501 + 0 + 0 + 17803 + 9948 + 0 + 1 + false + 200 + false + false + false + false + false + false + + + + + true + true + true + false + + false + false + true + true + true + false + false + false + false + false + false + true + false + false + 0 + 0 + false + false + false + false + false + true + false + false + true + false + false + + false + false + + true + false + false + false + false + false + false + true + true + false + false + false + false + true + true + false + + false + false + false + false + false + false + 0 + false + false + false + false + false + true + false + false + false + false + false + false + false + + true + true + true + true + false + true + true + false + 162604 + true + true + false + + false + true + false + high-resolution + 1 + 1 + true + false + false + true + true + true + true + true + false + true + + false + true + 162604 + false + + + + + http://openoffice.org/2004/office; xmlns:xlink="http://www.w3.org/1999/xlink"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/layout/data/floattable-no-footer-overlap.docx |binary sw/qa/core/layout/flycnt.cxx | 22 +++ sw/source/core/layout/fly.cxx|8 - 3 files changed, 28 insertions(+), 2 deletions(-) New commits: commit 693ad3aadbf84afa750af73c330fe7e09b38a2e7 Author: Miklos Vajna AuthorDate: Tue Jul 18 08:30:04 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Jul 31 11:49:19 2023 +0200 tdf#120262 sw floattable, legacy: go outside body only for page frame vert pos The bugdoc has to pages, the floating table from the top of page 2 is partially moved to page 1 and overlaps with the footer text. Part of the reason this happens is that in case the vertical position is relative to the page frame, then Word allows using the footer area for floating tables (see tdf#155118), but turns out that in case the position is relative to other places (e.g. paragraph), then this is not necessary. Fix the problem by making the "is legacy" condition in GetFlyAnchorBottom() more strict, which keeps tdf#155118 fixed, but improves this bugdoc. Leave the layout unchanged for cases where the floating table is not in the body text (e.g. footnotes). Now the overlap is fixed, but still a bug remains where the first row on this split table is not moved page 2. (cherry picked from commit 9a5d1c250cbaac855b3e63d8c5fa0882ba7d14a2) Change-Id: I96d6eb527d7f33dd65de8a66f815219c02625d93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154647 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx new file mode 100644 index ..ca2f0d6d7244 Binary files /dev/null and b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx differ diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 7d89a34ac914..106be77ceac2 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -946,6 +946,28 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext) const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap) +{ +// Given a document with 2 pages, a floating table on both pages: +createSwDoc("floattable-no-footer-overlap.docx"); + +// When calculating the layout: +calcLayout(); + +// Then make sure the second page has a floating table: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +auto pPage2 = dynamic_cast(pPage1->GetNext()); +// Without the accompanying fix in place, this test would have failed, there was no page 2, both +// floating tables were on page 1. +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d03e015f2c14..68184da48fd6 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -99,8 +99,12 @@ SwTwips GetFlyAnchorBottom(SwFlyFrame* pFly, const SwFrame& rAnchor) return 0; } -const IDocumentSettingAccess& rIDSA = pFly->GetFrameFormat().getIDocumentSettingAccess(); -bool bLegacy = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN); +const auto& rFrameFormat = pFly->GetFrameFormat(); +const IDocumentSettingAccess& rIDSA = rFrameFormat.getIDocumentSettingAccess(); +// Allow overlap with bottom margin / footer only in case we're relative to the page frame. +bool bVertPageFrame = rFrameFormat.GetVertOrient().GetRelationOrient() == text::RelOrientation::PAGE_FRAME; +bool bInBody = rAnchor.IsInDocBody(); +bool bLegacy = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN) && (bVertPageFrame || !bInBody); if (bLegacy) { // Word <= 2010 style: the fly can overlap with the bottom margin / footer area in case the
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-wrap-empty-para-legacy.docx |binary sw/qa/core/text/itrform2.cxx| 28 sw/qa/core/text/text.cxx|4 - sw/source/core/inc/txtfly.hxx |3 + sw/source/core/text/itrform2.cxx| 10 ++-- sw/source/core/text/txtfly.cxx |3 - 6 files changed, 38 insertions(+), 10 deletions(-) New commits: commit 2e2398ee7b9e2115f6b691f107a6223455d72ef6 Author: Miklos Vajna AuthorDate: Mon Jul 17 09:00:33 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Jul 31 11:46:36 2023 +0200 tdf#120262 sw floattable, legacy: fix text wrap around fly when no content fits The bugdoc is created from DOC (so tables are shifted to the left, slightly) and has 2 floating tables on 2 pages. Writer puts them to a single page, so they overlap, which is not wanted. The trouble is that there is some space (but not much) on the right of the floating table on page 1, and Writer wraps the empty anchor of the floating table on the right of the floating table, while Word puts it below the table, so no overlap happens. Fix the problem by extending the work from commit 8f8b31abd02876c3601e343b8b3274754f8a61b6 (compatibility setting for MS Word wrapping text in less space (bnc#822908), 2013-08-06), and work with that limit in SwTextFormatter::CalcFlyWidth(). This way Writer keeps its behavior that PARALLEL wrap text mode requires no minimal text width for existing documents, but correctly ~300 twips minimal text width (Word formats). The bugdoc still has a footer vs floating table overlap, but at least no 2 floating tables overlap now. (cherry picked from commit a4af5432753408c4eea8a8d56c2f48202160c5fe) Change-Id: Ib307ede08ead272fe16dca261db615fd8e9c547d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154646 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/text/data/floattable-wrap-empty-para-legacy.docx b/sw/qa/core/text/data/floattable-wrap-empty-para-legacy.docx new file mode 100644 index ..c62a25a193a7 Binary files /dev/null and b/sw/qa/core/text/data/floattable-wrap-empty-para-legacy.docx differ diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx index 066a8fb331a6..e190bed46f33 100644 --- a/sw/qa/core/text/itrform2.cxx +++ b/sw/qa/core/text/itrform2.cxx @@ -54,6 +54,34 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableWrapEmptyParagraph) const SwSortedObjs& rPageObjs2 = *pPage2->GetSortedObjs(); CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs2.size()); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableLegacyWrapEmptyParagraph) +{ +// Given a document with 2 pages, a floating table on both pages (from DOC, so the table is +// shifted towards the left page edge slightly): +createSwDoc("floattable-wrap-empty-para-legacy.docx"); + +// When calculating the layout: +calcLayout(); + +// Then make sure that each page has exactly 1 floating table: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage); +CPPUNIT_ASSERT(pPage->GetSortedObjs()); +const SwSortedObjs& rPageObjs = *pPage->GetSortedObjs(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 2 +// i.e. both tables were on page 1, leading to an overlap. +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size()); +auto pPage2 = dynamic_cast(pPage->GetNext()); +CPPUNIT_ASSERT(pPage2); +CPPUNIT_ASSERT(pPage2->GetSortedObjs()); +const SwSortedObjs& rPageObjs2 = *pPage2->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs2.size()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 83acef5e77d8..84cbf830db15 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -1286,10 +1286,10 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect) nHeight += getXPath(pXmlDoc, xPath, "height").toInt32(); } // Without the accompanying fix in place, this test would have failed with: -// - Expected: 521 (~500) +// - Expected: 542 (~500) // - Actual : 857 (~1000) // I.e. both upper and lower margin was taken into account. -CPPUNIT_ASSERT_EQUAL(521, nHeight); +CPPUNIT_ASSERT_EQUAL(542, nHeight); } CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810) diff --git a/sw/source/core/inc/txtfly.hxx b/sw/source/core/inc/txtfly.hxx index 95d70198f858..fe0782dcf938 100644 --- a/sw/source/core/inc/txtfly.hxx +++ b/sw/source/core/inc/txtfly.hxx @@ -86,6 +86,9 @@ public:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-avoid-manip-ofst.docx |binary sw/qa/core/text/frmform.cxx | 20 ++ sw/source/core/text/frmform.cxx |8 +++ 3 files changed, 28 insertions(+) New commits: commit 4a4ab952a76646b78dee653b625c8ee26c2ebd3a Author: Miklos Vajna AuthorDate: Wed Jul 12 14:00:20 2023 +0200 Commit: Mike Kaganski CommitDate: Wed Jul 19 11:07:04 2023 +0200 cool#6857 sw floattable: try harder to keep anchor text in the last follow The bugdoc has a single floating table, spanning over 6 pages. Loading results in a layout loop, SwFrame::GetNextFlyLeaf() never finishes as the last follow fly has no anchor, which should never happen. The root of the problem seems to be already on page 3. The 6 fly frames are meant to have 6 matching anchor frames, where the offset of these text frames is all 0, i.e. the anchor frame's text goes to the last follow, since commit 73bada774ef37efd5a4498ccc083b1358314557d (sw floattable, crashtesting: fix PDF export of fdo72790-1.docx, part 3, 2023-04-26). Fix the problem by improving SwTextFrame::FormatAdjust(), so it never sets the offset of a follow anchor frame to non-zero when the current frame has a non-last split fly. All the negative fly frame heights and the final layout loop was a result of this. Note that there are still calls to ManipOfst() on the follow frame after this, but all such calls are from SwTextFrame::RemoveFootnote(), and that always just sets a non-zero offset + restores it, so that is not a problem for us. Change-Id: If62a1e2690cffed2de0be047ffb741d524532dea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154343 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit d59704b6b8c7e5395c0606fa01f37392afc4b2cd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154423 Reviewed-by: Mike Kaganski diff --git a/sw/qa/core/text/data/floattable-avoid-manip-ofst.docx b/sw/qa/core/text/data/floattable-avoid-manip-ofst.docx new file mode 100644 index ..b4d85b5f8ac4 Binary files /dev/null and b/sw/qa/core/text/data/floattable-avoid-manip-ofst.docx differ diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx index 3c1a16a99444..d23611a7eb05 100644 --- a/sw/qa/core/text/frmform.cxx +++ b/sw/qa/core/text/frmform.cxx @@ -16,6 +16,7 @@ #include #include #include +#include namespace { @@ -59,6 +60,25 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableNegativeVertOffset) // 2nd paragraph. CPPUNIT_ASSERT_LESS(pPara2->getFrameArea().Top(), rFlyRect.Bottom()); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst) +{ +// Given a document with a 6-page floating table and some anchor text: +createSwDoc("floattable-avoid-manip-ofst.docx"); + +// When laying out that document: +calcLayout(); + +// Then make sure all anchor text is on the last page: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +SwPageFrame* pLastPage = pLayout->GetLastPage(); +SwLayoutFrame* pBodyFrame = pLastPage->FindBodyCont(); +SwTextFrame* pAnchor = pBodyFrame->GetLower()->DynCastTextFrame(); +// If this is not 0, that means some of the anchor text is shifted to a previous page, while +// anchors of non-last split fly frames should contain no text. +CPPUNIT_ASSERT_EQUAL(static_cast(0), pAnchor->GetOffset().get()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 55f259f0bc96..cdf51563c0ae 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -1192,6 +1192,14 @@ void SwTextFrame::FormatAdjust( SwTextFormatter , RemoveFootnote(nOld, nEnd - nOld); } ChangeOffset( GetFollow(), nEnd ); + +if (HasNonLastSplitFlyDrawObj()) +{ +// Make sure content from the last floating table anchor is not shifted to previous +// anchors. +nEnd = TextFrameIndex(0); +} + GetFollow()->ManipOfst( nEnd ); } else
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/filter/ww8/data/floattable-then-floattable.doc |binary sw/qa/filter/ww8/ww8.cxx | 23 +++ sw/source/filter/ww8/ww8par6.cxx | 17 ++ 3 files changed, 40 insertions(+) New commits: commit 2529a44931a2646af6f8beeecd18abb710c6d2e5 Author: Miklos Vajna AuthorDate: Tue Jul 11 08:21:20 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Jul 12 07:18:44 2023 +0200 sw floattable: make sure floattable after floattable gets own anch pos from DOC The bugdoc has 2 floating tables next to each other, which overlap in Writer, but not in Word. This looks quite similar to the DOCX case, which was solved in commit 01ad8ec4bb5425446e95dbada81de435646824b4 (sw floattable: fix lost tables around a floating table from DOCX, 2023-06-05). Fix the problem by improving SwWW8ImplReader::StartApo() so it inserts a fake paragraph when a floating table is immediately followed by a floating table. A similar case, floating table followed immediately by an inline table was already handled like this in WW8TabDesc::CreateSwTable(). Creating a reproducer document from scratch is quite tricky, as Word will also insert a fake paragraph on the first save of the DOC test file (so the doc model will be floattable-para-floattable-para) and manual edit of binary DOC files is also not easy. So the compromise is that the testcase file has 2 floating tables anchored to the same paragraph, but they don't overlap visually, while they do overlap in the original, internal bugdoc. With this, finally the bnc#816603 DOC bugdoc renders without overlaps, which was the case before my multi-page floating table changes. Change-Id: Ib1b4c7c80833db5a7bde38092c8c3ed6fd1d2462 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154290 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 663db89378aa1f0425e795ef5d471f134e658dc4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154262 Reviewed-by: Xisco Fauli diff --git a/sw/qa/filter/ww8/data/floattable-then-floattable.doc b/sw/qa/filter/ww8/data/floattable-then-floattable.doc new file mode 100644 index ..6e694140740b Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-then-floattable.doc differ diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index d7af2b675f24..68bbc28fcfc3 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -387,6 +387,29 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCVerticalFlyOffset) // Page 2 starts with an inline table: CPPUNIT_ASSERT(pTable2->IsTabFrame()); } + +CPPUNIT_TEST_FIXTURE(Test, testFloattableThenFloattable) +{ +// Given a document that contains a floating table, immediately followed by an other floating +// table: +// When importing the document & laying it out: +createSwDoc("floattable-then-floattable.doc"); +calcLayout(); + +// Then make sure that the two floating table has different anchors: +SwDoc* pDoc = getSwDoc(); +auto& rFlys = *pDoc->GetSpzFrameFormats(); +auto pFly1 = rFlys[0]; +SwNodeOffset nFly1Anchor = pFly1->GetAttrSet().GetAnchor().GetAnchorContentNode()->GetIndex(); +auto pFly2 = rFlys[1]; +SwNodeOffset nFly2Anchor = pFly2->GetAttrSet().GetAnchor().GetAnchorContentNode()->GetIndex(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 42 +// - Actual : 41 +// i.e. the two anchor positions were the same instead of first anchor followed by the second +// anchor. +CPPUNIT_ASSERT_EQUAL(nFly1Anchor + 1, nFly2Anchor); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index ca3a2ed1f101..0043678affb3 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2516,6 +2516,23 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults , const WW8_TablePos *p if (pTabPos) { +if (m_xFormatOfJustInsertedApo) +{ +// We just inserted a floating table and we'll insert a next one. +SwFrameFormat* pFormat = m_xFormatOfJustInsertedApo->GetFormat(); +if (pFormat) +{ +const SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode(); +SwPosition* pPoint = m_pPaM->GetPoint(); +if (pAnchorNode && *pAnchorNode == pPoint->GetNode()) +{ +// The two fly frames would have the same anchor position, leading to +// potentially overlapping text, prevent that. +AppendTextNode(*pPoint); +} +} +} + // Map a positioned table to a split fly.
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc |binary sw/qa/filter/ww8/ww8.cxx | 29 +++ sw/source/filter/ww8/ww8par.cxx |4 ++ 3 files changed, 33 insertions(+) New commits: commit f11e83f29852de8c2ba6fe0c9abe547c92bb1063 Author: Miklos Vajna AuthorDate: Mon Jul 10 08:23:49 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Jul 10 17:02:27 2023 +0200 sw floattable: enable AddVerticalFrameOffsets compat flag for DOC The bugdoc has a floating table, followed by an inline table. The inline table should be on the second page, but instead it's on the first page, overlapping with the floating table. It seems this works already for DOCX since commit 50223ea6e212b60b7d33839c2753c5601fb50f95 (tdf#98987 sw: add AddVerticalFrameOffsets compat mode, 2016-03-31). Fix the problem by enabling the same compat flag for DOC, since the intention was to have this on for Word formats in general. The original bnc#816603 bugdoc still needs more work, though. Change-Id: If9b4e1d3feeeaa24d6e84fea9a10ecdfd995c18f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154235 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154244 diff --git a/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc new file mode 100644 index ..d17bb5e886d3 Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-vertical-fly-offset.doc differ diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 20c1b993caa8..d7af2b675f24 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -26,6 +26,7 @@ #include #include #include +#include namespace { @@ -358,6 +359,34 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCFloatingTableHiddenAnchor) // i.e. the floating table was lost. assertXPath(pLayout, "//tab", 2); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCVerticalFlyOffset) +{ +// Given a document with 2 pages, a floating table on the first page and an inline table on the +// second page: +createSwDoc("floattable-vertical-fly-offset.doc"); + +// When laying out that document: +calcLayout(); + +// Then make sure that the tables don't overlap: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +// Page 1 has a floating table: +CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size()); +auto pPage2 = dynamic_cast(pPage1->GetNext()); +// Without the accompanying fix in place, this test would have failed, there was no second page. +CPPUNIT_ASSERT(pPage2); +SwFrame* pBody2 = pPage2->GetLower(); +SwFrame* pTable2 = pBody2->GetLower(); +CPPUNIT_ASSERT(pTable2); +// Page 2 starts with an inline table: +CPPUNIT_ASSERT(pTable2->IsTabFrame()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 1a328ebf8e54..abd7cf4c0345 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1902,6 +1902,10 @@ void SwWW8ImplReader::ImportDop() m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_VIRTUAL_DEVICE, !m_xWDop->fUsePrinterMetrics); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE, true); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_FLY_OFFSETS, true ); + +// No vertical offsets would lead to e.g. overlap of table and fly frames. + m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS, true ); + m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::ADD_EXT_LEADING, !m_xWDop->fNoLeading); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::OLD_NUMBERING, false); m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, false); // #i47448#
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/filter/ww8/data/floattable-hidden-anchor.doc |binary sw/qa/filter/ww8/ww8.cxx | 16 sw/source/filter/ww8/ww8par6.cxx | 16 3 files changed, 32 insertions(+) New commits: commit b3f13fbe2958100e7034de8ba6a8207eaa48e8db Author: Miklos Vajna AuthorDate: Wed Jul 5 08:33:06 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Jul 10 17:02:02 2023 +0200 sw floattable: fix lost floating table right before a table from DOC The bugdoc has a floating table, anchored in a paragraph that is hidden via character formatting. The bugdoc also has a normal table. This leads to 1 table in Writer, but 2 tables in Word. We already have code that tries to make sure floating tables have a suitable anchor, see the code in WW8TabDesc::CreateSwTable(), but that checks for the case when the next node after a floating table would be table (and not text), instead of the hidden character property. Fix the problem by not creating the hidden char attribute in the first place in SwWW8ImplReader::SetToggleAttr() in case the pool item would be inserted at the paragraph start and we just inserted a floating table, which makes the 2nd table visible in Writer as well. This is for DOC, interesting when Word converts this document to DOCX, then the hidden attribute is removed, so there this is not really needed. Change-Id: I3a7411e6fcc318740bcbd4b0cde9f34134f384a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154017 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154243 diff --git a/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc b/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc new file mode 100644 index ..3e8feb876964 Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-hidden-anchor.doc differ diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 253317c0deac..20c1b993caa8 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -342,6 +342,22 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCfDontBreakWrappedTables) // set. CPPUNIT_ASSERT(bDontBreakWrappedTables); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCFloatingTableHiddenAnchor) +{ +// Given a document with a normal table and a floating table with a hidden anchor: +createSwDoc("floattable-hidden-anchor.doc"); + +// When laying out that document: +xmlDocUniquePtr pLayout = parseLayoutDump(); + +// Then make sure that both tables are visible: +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 2 +// - Actual : 1 +// i.e. the floating table was lost. +assertXPath(pLayout, "//tab", 2); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 4758c4646286..ca3a2ed1f101 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -3370,6 +3370,22 @@ void SwWW8ImplReader::SetToggleAttr(sal_uInt8 nAttrId, bool bOn) : SvxCaseMap::NotMapped, RES_CHRATR_CASEMAP ) ); break; case 7: +if (m_pPaM->GetPoint()->GetContentIndex() == 0 && m_xFormatOfJustInsertedApo) +{ +// We just inserted a frame and we're at the next paragraph start. +SwFrameFormat* pFormat = m_xFormatOfJustInsertedApo->GetFormat(); +if (pFormat) +{ +SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode(); +if (pAnchorNode && *pAnchorNode == m_pPaM->GetPoint()->GetNode()) +{ +// The anchor paragraph would be hidden, leading to hiding the frame as +// well, prevent that. +break; +} +} +} + NewAttr(SvxCharHiddenItem(bOn, RES_CHRATR_HIDDEN)); break; case 8:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/data/152575.fodt | 447 + sw/qa/extras/uiwriter/uiwriter8.cxx| 28 ++ sw/source/uibase/uno/unotxdoc.cxx | 11 3 files changed, 482 insertions(+), 4 deletions(-) New commits: commit 4f942ff328463b4ecc7ed7350f7653c8d2e103c4 Author: Samuel Mehrbrodt AuthorDate: Mon Jul 3 10:40:38 2023 +0200 Commit: Caolán McNamara CommitDate: Mon Jul 3 22:37:14 2023 +0200 tdf#152575 Fix missing comment export in some cases Comments in margin were not exported to PDF when there was no comment on the first page. Change-Id: I102834d6e39b0cf471e4b28f7f6b112ad52c54a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153870 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt (cherry picked from commit c8a553388683f12e92d3c30c9d7a29a47ee12c2c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153899 Reviewed-by: Caolán McNamara diff --git a/sw/qa/extras/uiwriter/data/152575.fodt b/sw/qa/extras/uiwriter/data/152575.fodt new file mode 100644 index ..e78dac6e9f7a --- /dev/null +++ b/sw/qa/extras/uiwriter/data/152575.fodt @@ -0,0 +1,447 @@ + + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2022-12-16T12:34:49.021002022-12-18T12:40:09.26300PT14M9S3LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/f551747116ab6d1d05b46fb4b3d0d66d180a01ec + + + 0 + 0 + 38287 + 26698 + true + false + + + view2 + 8236 + 2501 + 0 + 0 + 38285 + 26696 + 0 + 1 + false + 100 + false + false + false + true + false + false + + + + + true + false + true + false + true + false + false + 0 + false + false + true + false + false + false + false + true + false + false + + false + false + true + false + false + true + true + false + false + false + false + false + false + true + false + false + false + 686405 + false + + true + false + + + fi + FI + + + + + + false + 887002 + true + false + false + false + 1 + true + true + false + false + true + false + true + true + true + true + false + true + 0 + + false + true + true + true + + 0 + true + false + false + false + high-resolution + true + true + false + false + true + false + false + false + false + true + + true + false + true + false + + false + false + false + true + false + false + false + false + false + false + false + false + false + false + 0 + true + false + + true + + + + + http://openoffice.org/2004/office; xmlns:xlink="http://www.w3.org/1999/xlink"/> + + + + + + + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/s4_min2.fodt | 360 ++ sw/qa/extras/layout/layout.cxx| 12 + sw/source/core/layout/newfrm.cxx |4 3 files changed, 376 insertions(+) New commits: commit 23eadd873de2e56d1e5f866fefae25c648f302f9 Author: Michael Stahl AuthorDate: Wed Jun 28 17:19:02 2023 +0200 Commit: Michael Stahl CommitDate: Thu Jun 29 10:40:30 2023 +0200 tdf#156077 sw: layout: call AssertFlyPages() in Init() The bugdoc has 3 pages, and there are at-page flys anchored to the 3rd page, and these are not displayed - simply missing from the layout. In LO 6.1, this worked because the layout-cache was read from the file, and 3 pages were created in SwRootFrame::Init() calling InsertCnt_(). But now this creates only 2 pages, and later SwLayAction creates the 2nd page between the existing ones on some MoveFwd(), but despite page nr 2 becoming page nr 3 nothing attaches the at-page flys to the now-page-3. If a document is loaded containing at-page flys, then all pages that have flys anchored to them should be created in SwRootFrame::Init() already. (regression from commit 7e8b4756d95057f069467b34e7849f9354856578) Change-Id: I4792c483a7620efd81211e6ad0d9220152367d68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153720 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit ff8ec4cfe5df1e15c3e9f6adc843dfe31358e097) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153698 diff --git a/sw/qa/extras/layout/data/s4_min2.fodt b/sw/qa/extras/layout/data/s4_min2.fodt new file mode 100644 index ..e1317de597d8 --- /dev/null +++ b/sw/qa/extras/layout/data/s4_min2.fodt @@ -0,0 +1,360 @@ + +http://www.w3.org/1999/xlink; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:ooow="http://openoffice.org/2004/writer; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:rpt="http://openoffice.org/2005/report; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:officeooo="http://openoffice.org/2009/office; xmlns:tableooo="http://openoffice.org/2009/table; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/; office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + CIB_OfficeDev/6.1.7.41$Linux_X86_64 LibreOffice_project/1df0ab666a1bb346850daa72aaa2e29a697a252c2023-06-26T22:28:03.054604345de-DE11PT14M3S2023-06-26T23:06:43.147312212 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uitest/writer_tests/trackedChanges.py | 65 sw/source/uibase/inc/redlndlg.hxx |3 + sw/source/uibase/misc/redlndlg.cxx | 13 + 3 files changed, 80 insertions(+), 1 deletion(-) New commits: commit 63d7157c52c945231d26192559e17e32d332 Author: László Németh AuthorDate: Thu Jun 22 17:33:16 2023 +0200 Commit: László Németh CommitDate: Tue Jun 27 10:19:23 2023 +0200 tdf#155847 sw tracked table column: fix crash in Manage Changes In Manage Changes dialog window, accept/Reject multiple tracked table columns need major tree list update because of not continuous redline ranges in the child lists of the multiple tree list parents, otherwise assert/crash could occur. Follow-up to commit 4a40a42afc3ba551e6e58947fc2e44689979b629 "tdf#155847 sw tracked table column: manage multiple changes". Change-Id: I3c7f61d35cbb433067c1f4fd28b80ad7da8ba12e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153464 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit d2b3817fd3fc44179ff0606d4234cbe0ae66e375) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153512 Tested-by: Jenkins diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index 111571881b82..14aea9bcee0d 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -597,4 +597,69 @@ class trackedchanges(UITestCase): self.assertEqual(0, len(changesList.getChildren())) +def test_tdf155847_multiple_tracked_columns_crash(self): +with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document: + +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") + +# accept all changes and insert new columns with change tracking +self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges") +tables = document.getTextTables() +self.assertEqual(2, len(tables)) +self.assertEqual(len(tables[0].getColumns()), 3) +self.xUITest.executeCommand(".uno:InsertColumnsAfter") +self.xUITest.executeCommand(".uno:DeleteColumns") +self.assertEqual(len(tables[0].getColumns()), 4) + +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') +xToolkit.processEventsToIdle() + +# check and reject changes +with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: +changesList = xTrackDlg.getChild("writerchanges") + +# six changes, but only one visible in the Manage Changes dialog window +state = get_state_as_dict(changesList) +self.assertEqual(state['Children'], '6') + +# This was 4 (missing handling of multiple different columns) +self.assertEqual(state['VisibleCount'], '2') +# Now: 2 changes (deleted and inserted columns) +self.assertEqual(2, len(changesList.getChildren())) + +# select second tracked table column in tree list +xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') +changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + +# while not empty, i.e. starts with CH_TXT_TRACKED_DUMMY_CHAR +while len(get_state_as_dict(xWriterEdit)["SelectedText"]): +xToolkit.processEventsToIdle() + +# reject column insertion + +xAccBtn = xTrackDlg.getChild("reject") +# Without the fix in place, it would have crashed here +xAccBtn.executeAction("CLICK", tuple()) + +# inserted column is removed + +self.assertEqual(len(tables[0].getColumns()), 3) + +# single parent left in the dialog window +self.assertEqual(1, len(changesList.getChildren())) + +# accept column deletion + +xAccBtn = xTrackDlg.getChild("accept") +xAccBtn.executeAction("CLICK", tuple()) + +# deleted column is removed + +self.assertEqual(len(tables[0].getColumns()), 2) + +# no changes in the dialog window + +self.assertEqual(0, len(changesList.getChildren())) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/uibase/inc/redlndlg.hxx b/sw/source/uibase/inc/redlndlg.hxx index 7337f1fadce4..c8cfd8cc8262 100644 --- a/sw/source/uibase/inc/redlndlg.hxx +++ b/sw/source/uibase/inc/redlndlg.hxx @@ -77,6 +77,9 @@ class SW_DLLPUBLIC SwRedlineAcceptDlg final // prevent update dialog data during
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/unocore/unocore.cxx| 53 ++ sw/source/core/unocore/unoobj.cxx |7 + 2 files changed, 60 insertions(+) New commits: commit 440179cfce5aafa7f480bfea48984451553f8e84 Author: László Németh AuthorDate: Tue Jun 20 19:02:20 2023 +0200 Commit: László Németh CommitDate: Wed Jun 21 10:55:19 2023 +0200 tdf#155951 sw: fix crash using XTextRange::getString() in selectionChanged() XTextRange::getString() triggered selection change event, resulting infinite recursion, when getString() used in selectionChanged() of the listener. Steps to reproduce (used by the unit test, too): Add a XSelectionChangeListener to the document with a selectionChanged() calling the getString() of the selected text range. Select a word in the document editor using the Ctrl-Shift-arrow keys. Change-Id: I87a0f60cee3663f5303d6eb6980058ccdcc373e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153356 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 0534715608aad7cc68f83ad4b72d8be0a35d0d6f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153345 diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index a1e931e75fb4..199da2e72a79 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include @@ -912,6 +914,57 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testConvertToTextFrame) CPPUNIT_ASSERT_EQUAL(aPaM.GetPoint()->nNode, aFrame3Anchor); } +namespace +{ +/// This selection listener calls XTextRange::getString() on a selection change, which triggered +/// a new selection change event by accident, resulting infinite recursion and crash +struct SelectionChangeListener : public cppu::WeakImplHelper +{ +public: +SelectionChangeListener(); +// view::XSelectionChangeListener +void SAL_CALL selectionChanged(const lang::EventObject& rEvent) override; + +// lang::XEventListener +void SAL_CALL disposing(const lang::EventObject& rSource) override; +}; +} + +SelectionChangeListener::SelectionChangeListener() {} + +void SelectionChangeListener::selectionChanged(const lang::EventObject& rEvent) +{ +uno::Reference xSelectionSupplier(rEvent.Source, uno::UNO_QUERY); +css::uno::Reference xSelection(xSelectionSupplier->getSelection(), + css::uno::UNO_QUERY_THROW); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSelection->getCount()); +css::uno::Reference xTextRange(xSelection->getByIndex(0), + css::uno::UNO_QUERY_THROW); +CPPUNIT_ASSERT(xTextRange->getString().startsWith("test")); +} + +void SelectionChangeListener::disposing(const lang::EventObject& /*rSource*/) {} + +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf155951) +{ +createSwDoc(); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); + +uno::Reference xModel(mxComponent, uno::UNO_QUERY); +uno::Reference xController(xModel->getCurrentController(), + uno::UNO_QUERY); +xController->addSelectionChangeListener(new SelectionChangeListener()); + +// This crashed here because of infinite recursion +dispatchCommand(mxComponent, ".uno:WordLeftSel", {}); + +// this needs to wait for dispatching (trigger also a second selection change) +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 2e65cf97bfcd..ccbcc536a75e 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -74,6 +74,8 @@ #include #include #include +#include +#include using namespace ::com::sun::star; @@ -158,6 +160,11 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer, const bool bOldShowProgress = xWrt->m_bShowProgress; xWrt->m_bShowProgress = false; xWrt->m_bHideDeleteRedlines = pLayout && pLayout->IsHideRedlines(); +// tdf#155951 SwWriter::Write calls EndAllAction, and that +// called SelectShell(), triggering selection change event, which +// resulted infinite recursion, if selectionChanged() calls +// XTextRange::getString() e.g. on the selected range. +::comphelper::FlagRestorationGuard g(g_bNoInterrupt, true); if( ! aWriter.Write( xWrt ).IsError() ) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-anchor-next-page.docx |binary sw/qa/core/text/text.cxx | 23 ++ sw/source/core/inc/txtfrm.hxx |4 ++ sw/source/core/text/frmform.cxx | 18 +++ sw/source/core/text/itratr.cxx| 26 sw/source/core/text/widorp.cxx| 28 ++ 6 files changed, 99 insertions(+) New commits: commit 3ba4bbcd13dda662832de8cb603b725a66cb53f0 Author: Miklos Vajna AuthorDate: Tue Jun 20 08:50:57 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Jun 21 08:25:04 2023 +0200 sw floattable: fix negative vertical offset handling on page boundary The bugdoc has 3 floating tables, the last one was on page 1 in Word, but it was on page 2 in Writer. It seems what happens is that the vertical offset of the last table is negative, so it is moved above the paragraph before the last floating table, but once the anchor frame (last paragraph) is moved to a new page (because it doesn't fit), then its fly frame is also moved to page 2, which leads to overlapping text in the original bugdoc. Interesting this works already with 0 vertical offset, and in that case we split the last paragraph, fill the page 1 part with a fly portion and fill the page 2 part with the anchor text. Fix the problem by: - triggering a split of the frame in SwTextFrameBreak::IsBreakNow(): if the anchor frame doesn't fit (has to be moved to a next page), then split it, so only the anchor text is moved, the fly is not (so its position matches Word) - preventing the manipulation of the frame offset in SwTextFrame::AdjustFollow_(), so no content is moved from the follow to the parent, because that would mean later we move the joined frame to the next page - finally minimizing the frame height at the end of SwTextFrame::Format(), so the master still fits the current page An alternative approach would be to extend SwAnchoredObject::FindAnchorCharFrame(), which already has code to handle the case when the text frame master and the anchored object is not on the same page, but that operates on existing anchor frames, and here the original problem is that the entire anchor frame is moved to page 2, so we don't have anything left on page 1. Note that this is all specific to floating tables, I could not reproduce the same behavior with an anchored shape in Word. Change-Id: I007b57b369f5c1e98ccad77111958dfd9335f079 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153309 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153366 diff --git a/sw/qa/core/text/data/floattable-anchor-next-page.docx b/sw/qa/core/text/data/floattable-anchor-next-page.docx new file mode 100644 index ..898c5514c587 Binary files /dev/null and b/sw/qa/core/text/data/floattable-anchor-next-page.docx differ diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 4a08b0683e3c..c638e0f4be0c 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -1309,6 +1309,29 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableOverlap) CPPUNIT_ASSERT(!rRect1.Overlaps(rRect2)); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableAnchorNextPage) +{ +// Given a document with 3 floating tables, the last one has a negative vertical offset, so the +// floating table is on page 1, but its anchor frame is effectively on page 2: +createSwDoc("floattable-anchor-next-page.docx"); + +// When laying out that document: +calcLayout(); + +// Then make sure all 3 floating tables are on page 1: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 3 +// - Actual : 2 +// i.e. the last floating table was on the wrong page (page 2). +CPPUNIT_ASSERT_EQUAL(static_cast(3), rPage1Objs.size()); +} + CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect) { // Given a document with 2 paragraphs, the paragraphs have both upper and lower spacing of 567 diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index 40cc0ef0bfac..512579c2d083 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -799,6 +799,10 @@ public: /// a follow, i.e. not the last in a master -> follow 1 -> ... -> last follow chain? bool HasNonLastSplitFlyDrawObj() const; +///
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/uitest/navigator/tdf154521.py | 114 sw/source/uibase/utlui/content.cxx | 42 + 2 files changed, 156 insertions(+) New commits: commit 8c234976c1d3536aab506a30487d8f5d26767c6a Author: László Németh AuthorDate: Thu Jun 15 23:36:20 2023 +0200 Commit: László Németh CommitDate: Tue Jun 20 14:54:42 2023 +0200 tdf#154521 sw navigator: allow to query selected bookmark via UNO If the hidden title of SwNavigatorPanel was emptied via UNO XPanel interface, store the name of the selected bookmark there. This allows to query the selected bookmark using UNO e.g. in add-ons, i.e. to disambiguate when multiple bookmarks are there on the selected text range. Note: this is a workaround because getDialog() of XPanel is not implemented for SwNavigatorPanel. Follow-up to commit c4a58634753a84b09f20f7271d6525a6656522d3 "tdf#154545 sw Navigator: select & track nested bookmarks" and commit 6eb1d540a1e599aa4fe0a321eddb9cc22e0546d3 "tdf#154521 sw Navigator: fix selection change event of bookmark". Change-Id: I94f79daf59516331155e0b36502821c769771207 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153162 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 8e869f2c6a2d20bb47f263a9bcf9c2486c2ac240) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153140 Tested-by: Jenkins diff --git a/sw/qa/uitest/navigator/tdf154521.py b/sw/qa/uitest/navigator/tdf154521.py index ac3c21de3c56..7b2125646ec6 100644 --- a/sw/qa/uitest/navigator/tdf154521.py +++ b/sw/qa/uitest/navigator/tdf154521.py @@ -85,4 +85,118 @@ class tdf154521(UITestCase): self.xUITest.executeCommand(".uno:Sidebar") +def getTitle(self, document): +xController = document.getCurrentController() +xSidebar = xController.getSidebar() +xDecks = xSidebar.getDecks() +xNavigator = xDecks['NavigatorDeck'] +xPanels = xNavigator.getPanels() +xPanel = xPanels['SwNavigatorPanel'] +title = xPanel.getTitle() +# empty title of SwNavigatorPanel to allow to query the name of the selected bookmark +xPanel.setTitle("") +return title + +def test_query_selected_bookmark(self): +global selectionChangedResult +with self.ui_test.create_doc_in_start_center("writer") as xDoc: + +# click on the bookmark name in the Navigator + +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") + +self.xUITest.executeCommand(".uno:Sidebar") +xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) + +xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") +xToolBar = xNavigatorPanel.getChild("content5") +xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button + +# type "foo", and create 3 bookmarks on it + +self.xUITest.executeCommand(".uno:Escape") + +xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) +self.xUITest.executeCommand(".uno:SelectAll") + +for i in range(3): +with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): +pass + +# check selected bookmarks in Navigator + +xWriterEdit.executeAction("FOCUS", tuple()) + +xContentTree = xNavigatorPanel.getChild("contenttree") + +self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +#self.xUITest.executeCommand(".uno:Escape") + +# get the title of SwNavigatorPanel with emptying it to access to the selected bookmark +self.assertEqual(self.getTitle(xDoc), "Navigator") +# title was emptied +self.assertEqual(self.getTitle(xDoc), "") + +# Select nested bookmark in Navigator + +xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + +# This jumped to Bookmark 1 after selection +self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1") + self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1") + +# This was "Navigator" +self.assertEqual(self.getTitle(xDoc), "Bookmark 1") + +# Try the same selection with Bookmark 2 +xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/para-upper-margin-fly-intersect.docx |binary sw/qa/core/text/text.cxx | 30 ++ sw/qa/extras/layout/layout3.cxx | 20 - sw/source/core/text/itrform2.cxx |6 ++ 4 files changed, 45 insertions(+), 11 deletions(-) New commits: commit b2d316f7fab79eefc2d58c8212a21ee203c6e212 Author: Miklos Vajna AuthorDate: Thu Jun 15 08:24:23 2023 +0200 Commit: Miklos Vajna CommitDate: Fri Jun 16 08:13:08 2023 +0200 sw floattable: fix handling of upper margin of anchor for fly intersect The bugdoc has 2 paragraphs and a shape between them. Word has a small amount of space between the shape and the 2nd paragraph, Writer has a large amount of space between the shape and the 2nd paragraph. It seems what happens is that Writer puts both the text node's own upper spacing and the previous text node's lower spacing into the upper spacing of the text frame, so the check added in commit d07fc485d46f431405a3f6a002f951a08c559677 (tdf#116486 Consider upper margin in paragraph positioning with flys, 2018-04-10) is not entirely correct, as it deal with both upper and lower margins, but its intention was just the upper margins. Fix the problem by (indirectly) using GetUpperSpaceAmountConsideredForPrevFrame(), which allows doing the intersection for the original text node upper spacing but not for the text node lower spacing. This keeps the original bugdoc working, but fixes the unexpected vertical space for the new bugdoc. This is part of the effort so that the original bnc#816603 bugdoc's DOCX version moves an overlapping floating table from page 4 back to page 3, like Word does. testTdf122878 is modified to just make sure no overlap happens, manual testing of the bugdoc shows that our layout still matches Word. Change-Id: I4622fb77dc8a52493766e50688ec92065eac65bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153101 Reviewed-by: Miklos Vajna Tested-by: Jenkins Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153118 diff --git a/sw/qa/core/text/data/para-upper-margin-fly-intersect.docx b/sw/qa/core/text/data/para-upper-margin-fly-intersect.docx new file mode 100644 index ..e8e767fb3897 Binary files /dev/null and b/sw/qa/core/text/data/para-upper-margin-fly-intersect.docx differ diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 30a12adc7af7..4a08b0683e3c 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -1309,6 +1309,36 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableOverlap) CPPUNIT_ASSERT(!rRect1.Overlaps(rRect2)); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect) +{ +// Given a document with 2 paragraphs, the paragraphs have both upper and lower spacing of 567 +// twips: +createSwDoc("para-upper-margin-fly-intersect.docx"); + +// When laying out that document: +calcLayout(); + +// Then make sure that we shift down the text in the second paragraph only based on the 2nd para +// upper margin, not based on the 1st para lower margin: +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +int nFlyCount += getXPathContent(pXmlDoc, + "count(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])") + .toInt32(); +int nHeight = 0; +for (int i = 1; i <= nFlyCount; ++i) +{ +OString xPath = "(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])[" ++ OString::number(i) + "]"; +nHeight += getXPath(pXmlDoc, xPath, "height").toInt32(); +} +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 521 (~500) +// - Actual : 857 (~1000) +// I.e. both upper and lower margin was taken into account. +CPPUNIT_ASSERT_EQUAL(521, nHeight); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 9d4d53be5d39..784a295fa2e8 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -193,21 +193,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122878) { createSwDoc("tdf122878.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -// FIXME: the XPath should be adjusted when the proper floating table would be imported const sal_Int32 nTblTop = getXPath(pXmlDoc, "/root/page[1]/footer/txt/anchored/fly/tab/infos/bounds", "top") .toInt32(); -const sal_Int32 nFirstPageParaCount -= getXPathContent(pXmlDoc, "count(/root/page[1]/body/txt)").toInt32(); -CPPUNIT_ASSERT_EQUAL(sal_Int32(30), nFirstPageParaCount); -for (sal_Int32 i = 1; i <=
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/layout/data/table_in_text_change.fodt | 66 + sw/qa/extras/layout/layout2.cxx| 18 + sw/source/core/table/swtable.cxx |5 + 3 files changed, 89 insertions(+) New commits: commit 49c4eec4f7974b21cd3c802892ff00b9e834cdd1 Author: László Németh AuthorDate: Tue Jun 13 13:04:28 2023 +0200 Commit: László Németh CommitDate: Wed Jun 14 14:22:36 2023 +0200 tdf#155187 sw track changes: color tables in single changes In Show Changes mode, whole tables within a single redline, i.e. in a single text change get similar coloring, as in separately tracked table rows or columns. Follow-up to commit 48898a72066ff9982feafebb26708c4e779fd460 "tdf#60382 sw xmloff: import/export tracked table/row deletion" and commit f348440e17debacbcba9153e238e010e8c020bdc "tdf#146120 sw: show tracked table changes with different color". Change-Id: I0154a20146cd6689750fa33edfe960eb22d7610a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152959 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 1f558103ce7730319a1804b9ca66132e8f48101e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152987 diff --git a/sw/qa/extras/layout/data/table_in_text_change.fodt b/sw/qa/extras/layout/data/table_in_text_change.fodt new file mode 100644 index ..6d1ccaf2c2cd --- /dev/null +++ b/sw/qa/extras/layout/data/table_in_text_change.fodt @@ -0,0 +1,66 @@ + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:tableooo="http://openoffice.org/2009/table; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:oooc="http://openoffice.org/2004/calc; xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:ooo="http://openoffice.org/2004/office; xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:open document:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + + + + + + + x + 2023-06-13T12:47:02 + + + + + + + x + 2023-06-13T12:43:39 + + + + + Whole tables in tracked text deletion + + + + + 1 + + + 2 + + + + + 3 + + + 4 + + + + Whole tables in tracked text insertion + + + + + I + + + II + + + + + III + + + IV + + + + + + + diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 9daa260c21c4..e9654dc7c9b6 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -973,6 +973,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testChangedTableRows) assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#3faf46']", 1); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf155187_TableInTextChange) +{ +createSwDoc("table_in_text_change.fodt"); +SwDoc* pDoc = getSwDoc(); +SwDocShell* pShell = pDoc->GetDocShell(); + +// Dump the rendering of the first page as an XML file. +std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); +MetafileXmlDump dumper; +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter2.cxx | 19 +++ sw/source/core/crsr/crsrsh.cxx | 10 ++ 2 files changed, 29 insertions(+) New commits: commit e2e2a9d5b1153965c93caab4b748eae5994b8a50 Author: Michael Stahl AuthorDate: Fri Jun 9 13:59:58 2023 +0200 Commit: Michael Stahl CommitDate: Wed Jun 14 10:48:00 2023 +0200 cool#6580 sw: fix infinite loop when changing document language If there's a footnote in the document, changing the document langauge goes into an infinite loop in FindParentText(), because the selection created by ExtendedSelectAll(true) is actually invalid, apparently the intention is that only very limited functions may be called while it is active. Don't handle this invalid "very" extended selection like one created by ExtendedSelectAll(false). (regression from commit d81379db730a163c5ff75d4f3a3cddbd7b5eddda) Change-Id: Icf1032715cf2e0a05bf485039c483440c08bb6bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152797 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit ca9341cf60f3f9350662d30b61f6eadefca24667) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152818 diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index a09d7b6fb780..6c9714367bf7 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -18,6 +18,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -168,6 +172,21 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) CPPUNIT_ASSERT_EQUAL(::tools::Long(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->GetTextLeft()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testExtendedSelectAllHang) +{ +createSwDoc(); +SwDoc* const pDoc = getSwDoc(); +SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + +pWrtShell->InsertFootnote(""); +pWrtShell->StartOfSection(); +SwView* pView = pDoc->GetDocShell()->GetView(); +SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Default_Spanish (Bolivia)"); +// this looped +pView->GetViewFrame().GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, + { }); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineMoveInsertInDelete) { createSwDoc(); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 325ff54d52cd..9fb43ff2d596 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -895,6 +895,16 @@ SwCursorShell::ExtendedSelectedAll() const typename SwCursorShell::StartsWith SwCursorShell::StartsWith_() { SwShellCursor const*const pShellCursor = getShellCursor(false); +// first, check if this is invalid; ExtendedSelectAll(true) may result in +// a) an ordinary selection that is valid +// b) a selection that is extended +// c) a selection that is invalid and will cause FindParentText to loop +SwNode const& rEndOfExtras(GetDoc()->GetNodes().GetEndOfExtras()); +if (pShellCursor->Start()->nNode.GetIndex() <= rEndOfExtras.GetIndex() +&& rEndOfExtras.GetIndex() < pShellCursor->End()->nNode.GetIndex()) +{ +return StartsWith::None; // *very* extended, no ExtendedSelectedAll handling! +} SwStartNode const*const pStartNode(FindParentText(*pShellCursor)); if (auto const ret = ::StartsWith(*pStartNode); ret != StartsWith::None) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source writerfilter/source
sw/qa/extras/ooxmlexport/data/para-style-char-position.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 18 ++ sw/source/filter/ww8/docxattributeoutput.cxx|8 writerfilter/source/dmapper/DomainMapper.cxx| 21 ++-- writerfilter/source/dmapper/DomainMapper.hxx|6 ++- writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 +- writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 - writerfilter/source/dmapper/StyleSheetTable.cxx |1 8 files changed, 53 insertions(+), 7 deletions(-) New commits: commit ddf8903e9b7528671e752d24717056f2db039464 Author: Miklos Vajna AuthorDate: Tue Jun 13 15:02:20 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Jun 14 08:43:45 2023 +0200 DOCX filter: improve handling of negative in paragraph styles The bugdoc has a in its Normal paragraph style, which is almost not visible in Word, but we mapped this to default subscript text in Writer, leading to very visible bad font height in practice. The root of the problem is that works with an absolute offset in half-points, while Writer works in percentages, so the import/export code can only do a correct mapping in case the font size is known. This initial mapping was added in commit e70df84352d3670508a4666c97df44f82c1ce934 (try somewhat harder to read w:position (bnc#773061), 2012-08-07), and later commit d71cf6390a89ea6a4fab724e3a7996f28ca33661 (tdf#99602 writerfilter: import subscript into character style, 2019-10-04) gave up on this for character styles. Fix the problem by working with paragraph styles similar to what the binary DOC filter already does, just assuming that the font height from the style won't be overwritten, or will be overwritten together with a matching . Do this only for negative for now, as that's good enough for our needs. Do the opposite of this at export time. It would be still possible in the future to add native handling for absolute escapements, and then this mapping would not be needed at all. Change-Id: I771c7bed27fa2596153aa77c472c91b819fa4cb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152962 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 85f0a5d7bc54dfba75e8d6dd9c905bc1ac31d927) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153011 diff --git a/sw/qa/extras/ooxmlexport/data/para-style-char-position.docx b/sw/qa/extras/ooxmlexport/data/para-style-char-position.docx new file mode 100644 index ..946ca0bf9cc2 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/para-style-char-position.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 50a058d19c9d..fbb87915369e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -615,6 +615,24 @@ CPPUNIT_TEST_FIXTURE(Test, testNumberPortionFormatFromODT) assertXPath(pXmlDoc, "//w:pPr/w:rPr/w:sz", "val", "48"); } +CPPUNIT_TEST_FIXTURE(Test, testParaStyleCharPosition) +{ +// Given a loaded document where the Normal paragraph style has : +createSwDoc("para-style-char-position.docx"); + +// When saving it back to DOCX: +save("Office Open XML Text"); + +// Then make sure that is not turned into a normal subscript text: +xmlDocUniquePtr pXmlDoc = parseExport("word/styles.xml"); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 0 +// - XPath '/w:styles/w:style[@w:styleId='Normal']/w:rPr/w:position' number of nodes is incorrect +// i.e. we wrote instead of . +assertXPath(pXmlDoc, "/w:styles/w:style[@w:styleId='Normal']/w:rPr/w:position", "val", "-1"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf150966_regularInset) { // Given a docx document with a rectangular shape with height cy="90" (EMU), tIns="18" diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a75682761d84..ba5d14bd8c90 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7791,8 +7791,14 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement ) OString sIss; short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProportionalHeight(); +bool bParaStyle = false; +if (m_rExport.m_bStyDef && m_rExport.m_pCurrentStyle) +{ +bParaStyle = m_rExport.m_pCurrentStyle->Which() == RES_TXTFMTCOLL; +} + // Simplify styles to avoid impossible complexity. Import and export as defaults only -if ( m_rExport.m_bStyDef && nEsc ) +if ( m_rExport.m_bStyDef && nEsc && !(bParaStyle && nEsc < 0)) { nProp = DFLT_ESC_PROP;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/unocore/data/floattable-outer-nonsplit-inner.docx |binary sw/qa/core/unocore/unocore.cxx | 23 +++ sw/source/core/unocore/unotext.cxx | 32 +-- 3 files changed, 52 insertions(+), 3 deletions(-) New commits: commit 0c301e505fcec37f64d3e5f7ec2445ffd9e966c4 Author: Miklos Vajna AuthorDate: Tue Jun 13 08:15:34 2023 +0200 Commit: Miklos Vajna CommitDate: Tue Jun 13 16:53:21 2023 +0200 sw floattable: fix anchor position of inner floating table The bugdoc has an outer, split floating table and an inner, non-split floating table. The anchor of the inner table was wrong: both were anchored in the only paragraph in the body text, while the inner floating table should be anchored inside the outer floating table. The reason for this is commit 9592f56323de27f9e1d890ee6259a5f4f328cbd3 (n#695479 fix anchor handling in SwXText::convertToTextFrame(), 2012-02-20), which was necessary to make sure that old-style frames after each other are all anchored to the body text, not inside each other. Fix the problem by leaving the behavior unchanged for empty paragraphs, but at least when the inner anchor is to-para, the last paragraph of a fly content is non-empty and the outer fly range contains the entire last paragraph, then consider such a fly as "inside" the outer fly content, rather than something that has to be moved so the anchor is still in the body text. CppunitTest_sw_rtfimport's testN695479, CppunitTest_sw_ooxmlexport10's testFloatingTablesAnchor and CppunitTest_sw_ooxmlexport13's testFlyInFly are all related tests and they continue to work after this change. Change-Id: I30ed1d884ec465e724b4f133640b9608845a44fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152950 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit c374628126ad222be48d5d06857b7dc6b879f783) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152976 diff --git a/sw/qa/core/unocore/data/floattable-outer-nonsplit-inner.docx b/sw/qa/core/unocore/data/floattable-outer-nonsplit-inner.docx new file mode 100644 index ..dc213b1b0d26 Binary files /dev/null and b/sw/qa/core/unocore/data/floattable-outer-nonsplit-inner.docx differ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 55b37c749436..605813a719b3 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -29,6 +29,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -930,6 +931,28 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testFlySplit) CPPUNIT_ASSERT(bIsSplitAllowed); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testConvertToTextFrame) +{ +// Given a document with 2 non-interesting frames, an inner frame and an outer frame: +createSwDoc("floattable-outer-nonsplit-inner.docx"); + +// When checking the anchor of the inner frame: +SwDoc* pDoc = getSwDoc(); +const sw::FrameFormats& rFrames = *pDoc->GetSpzFrameFormats(); +sw::SpzFrameFormat* pFrame3 = rFrames.FindFrameFormatByName("Frame3"); +SwNodeIndex aFrame3Anchor = pFrame3->GetAnchor().GetContentAnchor()->nNode; + +// Then make sure it's anchored in the outer frame's last content node: +sw::SpzFrameFormat* pFrame4 = rFrames.FindFrameFormatByName("Frame4"); +SwPaM aPaM(*pFrame4->GetContent().GetContentIdx()->GetNode().EndOfSectionNode()); +aPaM.Move(fnMoveBackward, GoInContent); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: SwNodeIndex (node 27) +// - Actual : SwNodeIndex (node 49) +// i.e. Frame3 was anchored much later, in the body text, not in Frame4. +CPPUNIT_ASSERT_EQUAL(aPaM.GetPoint()->nNode, aFrame3Anchor); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index b506b3a26183..4fede9da65b4 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1494,6 +1494,34 @@ static bool isGraphicNode(const SwFrameFormat* pFrameFormat) return index.GetNode().IsGrfNode(); } +/// Determines if the at-para rAnchor is anchored at the start or end of rAnchorCheckPam. +static bool IsAtParaMatch(const SwPaM& rAnchorCheckPam, const SwFormatAnchor& rAnchor) +{ +if (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) +{ +return false; +} + +if (rAnchorCheckPam.Start()->GetNode() == *rAnchor.GetAnchorNode()) +{ +return true; +} + +if (rAnchorCheckPam.End()->GetNode() == *rAnchor.GetAnchorNode()) +{ +SwTextNode* pEndTextNode = rAnchorCheckPam.End()->GetNode().GetTextNode(); +if (pEndTextNode && rAnchorCheckPam.End()->GetContentIndex() == pEndTextNode->Len()) +{
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/core/text/data/floattable-overlap.docx |binary sw/qa/core/text/text.cxx | 28 +++ sw/source/core/inc/txtfrm.hxx|3 ++ sw/source/core/layout/frmtool.cxx| 11 ++ sw/source/core/text/itrform2.cxx | 13 sw/source/core/text/porlay.cxx | 28 +++ sw/source/core/text/txtfly.cxx |6 + 7 files changed, 89 insertions(+) New commits: commit b25a79252ab96f1294952533b91f49b212eaf24b Author: Miklos Vajna AuthorDate: Thu Jun 8 08:09:12 2023 +0200 Commit: Miklos Vajna CommitDate: Tue Jun 13 11:20:20 2023 +0200 sw floattable, compat mode: handle lower margin of anchor for fly intersect The bugdoc has 2 floating tables and they were overlapping in Writer, but not in Word. What seems to happen is that the document has a floating table, followed by an empty paragraph, and in case that empty paragraph goes above the floating table, then we overlap, but if it goes below the floating table, then the next paragraph will start below the empty paragraph, so no overlap will happen. This is possible in Word, because in "Word 2010" compat mode it has 327 twips vertical space above the first floating table (set by its positioning attribute), and in case the empty paragraph has a font size of 11pt (220 twips) + 200 twips of lower margin (inherited from the default paragraph style), then this 420 twips of space doesn't fit. Note that for new documents Word ("Word 2013" mode) does the same as Writer and ignores the lower spacing when intersecting lines with flys. Fix the problem by introducing a new SwTextFrame::GetLowerMarginForFlyIntersect() that gives us the lower spacing if 1) this is Word 2010 compat mode 2) this text frame has no fly portions / multiple lines yet and 3) this paragraph is empty. Then use this function at 3 places where we used to intersect with the absolute print area of the frame, and extend these places with the lower spacing. This could be extended in the future for non-empty paragraphs as well, but the bugdoc works without that, and the change is invasive enough, so better to limit the scope. Change-Id: I6e9693847beaec5d9bbf9f8a5699795579c3ff71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152726 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 81a108770233825557c2dae5776d7417be017fb8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152750 diff --git a/sw/qa/core/text/data/floattable-overlap.docx b/sw/qa/core/text/data/floattable-overlap.docx new file mode 100644 index ..cc0dbd077f00 Binary files /dev/null and b/sw/qa/core/text/data/floattable-overlap.docx differ diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index f321a01c3aa5..30a12adc7af7 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -42,6 +42,7 @@ #include #include #include +#include /// Covers sw/source/core/text/ fixes. class SwCoreTextTest : public SwModelTestBase @@ -1281,6 +1282,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf41652NBSPWidth) nSectionAfterNBSPX_optionEnabled_justified); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableOverlap) +{ +// Given a document with 2 floating tables, not overlapping in Word's "Word 2010" compat mode, +// because the first empty paragraph is below the first floating table: +createSwDoc("floattable-overlap.docx"); + +// When laying out that document: +calcLayout(); + +// Then make sure they don't overlap in Writer, either: +SwDoc* pDoc = getSwDoc(); +SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); +auto pPage1 = dynamic_cast(pLayout->Lower()); +CPPUNIT_ASSERT(pPage1); +CPPUNIT_ASSERT(pPage1->GetSortedObjs()); +const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs(); +CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size()); +SwAnchoredObject* pPage1Obj1 = rPage1Objs[0]; +const SwRect& rRect1 = pPage1Obj1->GetObjRectWithSpaces(); +SwAnchoredObject* pPage1Obj2 = rPage1Objs[1]; +const SwRect& rRect2 = pPage1Obj2->GetObjRectWithSpaces(); +// Without the accompanying fix in place, this test would have failed, the empty paragraph, +// which is after the floating table in the document model went above the floating table in the +// layout, which resulted in an overlap. +CPPUNIT_ASSERT(!rRect1.Overlaps(rRect2)); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index d58b97e9d3e4..40cc0ef0bfac 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -528,6 +528,9 @@ public: // the offset
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter5.cxx | 33 ++ sw/source/core/doc/DocumentRedlineManager.cxx |3 ++ 2 files changed, 36 insertions(+) New commits: commit 59952bf9b69b856ece35d03df06991c39adca267 Author: László Németh AuthorDate: Fri Jun 9 12:22:17 2023 +0200 Commit: László Németh CommitDate: Mon Jun 12 12:19:17 2023 +0200 tdf#155747 sw tracked table column: fix crash at table selection Selecting tracked columns and accepting their deletion resulted crashing because of the outdated table cursor in IsCursorInTable() call of UpdateTableStyleFormatting(). Remove table cursor before calling DeleteCol(). Regression from commit d1004cdd6a445ae73673b0ca360ae034b0ec09f2 "tdf#150673 sw offapi: add change tracking of table column deletion". Change-Id: I47f4db11bd7ce4ad851c0658eec3e12ce4fdf4a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152792 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit fb52ae0386df9ecbfc5ddcf981fe597884d628d0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152816 diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index dc2506881c19..88868f8086c2 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2556,6 +2556,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableColumnDeletion) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) +{ +// load a table, and delete the first column with enabled change tracking: +// now the column is not deleted silently, but keeps the deleted cell content, +// and only accepting it will result the deletion of the table column. +createSwDoc("tdf118311.fodt"); +SwDoc* pDoc = getSwDoc(); + +// turn on red-lining and show changes +pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); +CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); +CPPUNIT_ASSERT_MESSAGE( +"redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + +// delete table column with enabled change tracking +// (HasTextChangesOnly property of the cell will be false) +dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + +// select table +dispatchCommand(mxComponent, ".uno:SelectTable", {}); + +// Without the fix in place, this test would have crashed here +dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {}); + +// check removed column +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +assertXPath(pXmlDoc, "//page[1]//body/tab"); +assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWithExport) { // load a table, and delete the first column with enabled change tracking: diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index ac0bfe547e90..d9148ce723f3 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -467,6 +468,8 @@ namespace SwCursor aCursor( *pPos, nullptr ); if ( pBox->IsEmpty() ) { +// tdf#155747 remove table cursor +pPos->GetDoc().GetDocShell()->GetWrtShell()->EnterStdMode(); // TODO check the other cells of the column // before removing the column pPos->GetDoc().DeleteCol( aCursor );