/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
*/
namespace
{ /// 8th set of tests asserting the behavior of Writer user interface shells. class SwUiWriterTest8 : public SwModelTestBase
{ public:
SwUiWriterTest8()
: SwModelTestBase(u"/sw/qa/extras/uiwriter/data/"_ustr)
{
}
};
dispatchCommand(mxComponent, u".uno:DeleteRows"_ustr, {}); // This was 2 (deleting the already deleted table with change tracking)
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTables->getCount());
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
// check that the first table was deleted with change tracking
dispatchCommand(mxComponent, u".uno:AcceptAllTrackedChanges"_ustr, {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
// now only the second table deleted by AcceptAllTrackedChanges
dispatchCommand(mxComponent, u".uno:AcceptAllTrackedChanges"_ustr, {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146962)
{ // load a 2-row table, set Hide Changes mode and delete the first row with change tracking
createSwDoc("tdf116789.fodt");
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtShell);
// enable redlining
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
CPPUNIT_ASSERT_MESSAGE("redlining should be on",
pDoc->getIDocumentRedlineAccess().IsRedlineOn()); // hide changes
dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {});
CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
// Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
// FIXME: Show Changes, otherwise ~SwTableNode() would have crashed
dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {});
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148345)
{ // load a 2-row table, set Hide Changes mode and delete the first row with change tracking
createSwDoc("tdf116789.fodt");
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtShell);
// enable redlining
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
CPPUNIT_ASSERT_MESSAGE("redlining should be on",
pDoc->getIDocumentRedlineAccess().IsRedlineOn()); // hide changes
dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {});
CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
pXmlDoc = parseLayoutDump(); // only a single row is visible again
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1);
// tdf#148227 check Reject All of tracked table row deletion
dispatchCommand(mxComponent, u".uno:RejectAllTrackedChanges"_ustr, {});
pXmlDoc = parseLayoutDump(); // This was 1
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf141391)
{ // table insertion in the first paragraph of the cell // overwrites the row content, instead of inserting a nested table
// select the table, and copy it into at paragraph start of cell "A2"
dispatchCommand(mxComponent, u".uno:SelectTable"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); // remove the selection and positionate the cursor at beginning of A2
pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // 3-row, overwriting cells of the second row and inserting a new row // with the 2-row clipboard table content
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 3);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
// Undo
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {});
pXmlDoc = parseLayoutDump(); // 2 rows again, no copied text content
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/SwParaPortion", 0);
// insert the 2-row table into the second paragraph of cell "A2" as a nested table // For this it's enough to positionate the text cursor not in the first paragraph
// insert some text and an empty paragraph
pWrtShell->Insert(u"Some text..."_ustr);
pWrtShell->SplitNode();
Scheduler::ProcessEventsToIdle();
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/txt", 2);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/txt[1]/SwParaPortion/SwLineLayout", "portion", u"Some text..."); // the empty paragraph in A2
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/txt[2]/SwParaPortion", 0);
// insert the table, as a nested one in cell "A2"
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/tab", 1);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/tab/row", 2);
// copy the 2-row table into the first paragraph of cell "A2", // but not at paragraph start (changed behaviour)
pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
pWrtShell->Insert(u"and some text again in the first paragraph to be sure..."_ustr);
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
pXmlDoc = parseLayoutDump();
// 3-row, overwriting cells of the second row and inserting a new row // with the 2-row clipboard table content
// This was 2 (nested table)
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 3); // This was "Some text..." with a nested table
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf148791)
{ // test Paste as Rows Above with centered table alignment
// set table alignment to center, select and copy the table again
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(),
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
dispatchCommand(mxComponent, u".uno:SelectTable"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); // remove the selection and positionate the cursor at beginning of A2
pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
pWrtShell->Up(/*bSelect=*/false);
pWrtShell->Up(/*bSelect=*/false);
pWrtShell->Up(/*bSelect=*/false);
dispatchCommand(mxComponent, u".uno:PasteRowsBefore"_ustr, {});
pXmlDoc = parseLayoutDump(); // This was 5 (inserting only a single row for the 4-row clipboard content, and // overwriting 3 existing rows)
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 8);
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[1]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[3]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[5]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row[7]/cell[1]/txt/SwParaPortion/SwLineLayout", "portion", u"hello");
// tdf#64902 add a test case for nested tables
// insert a nested table, and copy as paste as rows above the whole table with it
dispatchCommand(mxComponent, u".uno:PasteNestedTable"_ustr, {});
dispatchCommand(mxComponent, u".uno:SelectTable"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); // remove the selection and positionate the cursor at beginning of A2
pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); // skip 7 table rows plus 4 rows of the nested table for (int i = 0; i < 7 + 4; ++i)
pWrtShell->Up(/*bSelect=*/false);
dispatchCommand(mxComponent, u".uno:PasteRowsBefore"_ustr, {});
pXmlDoc = parseLayoutDump(); // rows of the nested table doesn't effect row number of the main table
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 16); // there are two nested tables after the paste
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell/tab", 2);
// tdf#64902 add a test case for repeated table headings
dispatchCommand(mxComponent, u".uno:SelectTable"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {}); // remove the selection and positionate the cursor at beginning of A2
pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); // skip 15 table rows plus 4 * 2 rows of the nested tables for (int i = 0; i < 15 + 4 * 2; ++i)
pWrtShell->Up(/*bSelect=*/false);
dispatchCommand(mxComponent, u".uno:PasteRowsBefore"_ustr, {});
pXmlDoc = parseLayoutDump(); // repeating table header (and its thead/tbody indentation) doesn't effect row number
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 32); // there are two nested tables after the paste
assertXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell/tab", 4);
}
// Shape toolbar is active, use ESC before inserting a new shape
SwXTextDocument* pTextDoc = getSwTextDoc();
pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE);
Scheduler::ProcessEventsToIdle();
// Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, u".uno:BasicShapes.diamond"_ustr, aArgs);
// Without the fix in place, this test would have bad order // (starting with the outlines of text frames)
CPPUNIT_ASSERT_EQUAL(u"Article 1. Definitions\n" " Apple\n" " Bread\n" " Cable\n" " Cable\n"// ??? "Article 2. Three style separators in one line!\n" " Heading 2\n" " Heading 2 Again\n"_ustr,
pPdfDocument->getBookmarks());
}
// Without the fix in place, this test would have bad order // (starting with the outlines of text frames)
CPPUNIT_ASSERT_EQUAL(u"H1\n" " H2\n" " H3\n" " Lorem\n" " Vestibulum\n" " Integer\n" " Aliquam\n" " Donec\n" " Praesent\n" " H3\n" " Lorem\n" " Vestibulum\n" " Integer\n" " Aliquam\n" " Donec\n" " Praesent\n" "H1\n" " H2\n" " H3\n" " Lorem\n" " Vestibulum\n" " Integer\n" " Aliquam\n" " Donec\n" " Praesent\n"_ustr,
pPdfDocument->getBookmarks());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf152575)
{ // FIXME: the DPI check should be removed when either (1) the test is fixed to work with // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. if (!IsDefaultDPI()) return;
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
createSwDoc("152575.fodt");
// Save as PDF.
uno::Sequence<beans::PropertyValue> aFilterData(
comphelper::InitPropertySequence({ { "ExportNotesInMargin", uno::Any(true) } }));
// Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, u".uno:ExportToPDF"_ustr, aDescriptor);
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
CPPUNIT_ASSERT_EQUAL(3, pPdfDocument->getPageCount());
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/1);
CPPUNIT_ASSERT(pPdfPage); // Without the fix for tdf#152575 this would be only 42 objects
CPPUNIT_ASSERT_EQUAL(50, pPdfPage->getObjectCount());
}
// generating a big text with ~60k words and several paragraphs for (sal_Int32 i = 0; i < 8; ++i)
{
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
// Format->Text operations on small selections (which would generate <~500 redlines) // changetracking still working
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
// Without the fix in place, on big selections writer would freeze. Now it ignores change tracking.
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), pEditShell->GetRedlineCount());
// The patch has no effects on the Format->Text operations
CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Lorem Ipsum Dolor Sit Amet"));
{
SwTextNode& rNode{ *pWrtShell->GetCursor()->GetPoint()->GetNode().GetTextNode() }; // numrule from paragraph style, but not from direct formatting auto pSet{ rNode.GetpSwAttrSet() };
CPPUNIT_ASSERT(pSet); // list id was set
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_LIST_ID, false)); // the numrule is set on the paragraph style, not on the paragraph
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_PARATR_NUMRULE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_NUMRULE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT,
pSet->GetItemState(RES_MARGIN_FIRSTLINE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_FIRSTLINE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_MARGIN_TEXTLEFT, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_TEXTLEFT, true));
CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, rNode.GetTextColl()->GetName().toString());
CPPUNIT_ASSERT_EQUAL(u"Item We confirm receipt of your application material."_ustr,
rNode.GetText());
pNumRule = rNode.GetNumRule();
pTextLeftMargin = &rNode.GetAttr(RES_MARGIN_TEXTLEFT);
pFirstLineIndent = &rNode.GetAttr(RES_MARGIN_FIRSTLINE);
}
pWrtShell->FwdPara();
{
SwTextNode& rNode{ *pWrtShell->GetCursor()->GetPoint()->GetNode().GetTextNode() }; auto pSet{ rNode.GetpSwAttrSet() };
CPPUNIT_ASSERT(pSet); // list id was set
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_LIST_ID, false)); // middle paragraph was pasted - has numrule and indents applied directly
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_NUMRULE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_FIRSTLINE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_TEXTLEFT, false));
CPPUNIT_ASSERT_EQUAL(u"Default Paragraph Style"_ustr,
rNode.GetTextColl()->GetName().toString());
CPPUNIT_ASSERT(rNode.GetText().startsWith("As more applicants applied"));
CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule());
CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}),
rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}));
CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}),
rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({}));
}
pWrtShell->FwdPara();
{
SwTextNode& rNode{ *pWrtShell->GetCursor()->GetPoint()->GetNode().GetTextNode() }; // numrule from paragraph style, but not from direct formatting auto pSet{ rNode.GetpSwAttrSet() };
CPPUNIT_ASSERT(pSet); // list id was set
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_LIST_ID, false)); // the numrule is set on the paragraph style, not on the paragraph
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_PARATR_NUMRULE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_NUMRULE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT,
pSet->GetItemState(RES_MARGIN_FIRSTLINE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_FIRSTLINE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_MARGIN_TEXTLEFT, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_TEXTLEFT, true));
CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, rNode.GetTextColl()->GetName().toString());
CPPUNIT_ASSERT(rNode.GetText().endsWith("as soon as we have come to a decision."));
CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule());
CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}),
rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}));
CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}),
rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({}));
}
pWrtShell->FwdPara();
{
SwTextNode& rNode{ *pWrtShell->GetCursor()->GetPoint()->GetNode().GetTextNode() }; // numrule from paragraph style, but not from direct formatting auto pSet{ rNode.GetpSwAttrSet() };
CPPUNIT_ASSERT(pSet); // list id was set
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_LIST_ID, false)); // the numrule is set on the paragraph style, not on the paragraph
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_PARATR_NUMRULE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_PARATR_NUMRULE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT,
pSet->GetItemState(RES_MARGIN_FIRSTLINE, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_FIRSTLINE, true));
CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, pSet->GetItemState(RES_MARGIN_TEXTLEFT, false));
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, pSet->GetItemState(RES_MARGIN_TEXTLEFT, true));
CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, rNode.GetTextColl()->GetName().toString());
CPPUNIT_ASSERT_EQUAL(u"more"_ustr, rNode.GetText()); // pre-existing list item
CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule());
CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}),
rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}));
CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}),
rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({}));
}
}
// was ...'letter of <placeholder:"November 21, 2004":"Click placeholder and overwrite">'
CPPUNIT_ASSERT_EQUAL(
u"We hereby acknowledge the receipt of your letter of ."_ustr,
getParagraph(1)->getString());
}
// create an additional non-header undo point
pWrtShell->Insert(u"crash_test"_ustr); // three undo points
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rUndoManager.GetUndoActionCount());
// undo all the changes in one pass
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
{ "Undo", uno::Any(sal_Int32(4)) },
}));
dispatchCommand(mxComponent, u".uno:Undo"_ustr, aPropertyValues); // undo all 4 actions
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPageStyle, u"HeaderIsOn"_ustr));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount());
// Crash avoided by clearing the entire redo stack. This redo request will do nothing. // Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, u".uno:Redo"_ustr, {}); // redo first (Header) change // Since Redo is "cleared", the redo did nothing, thus the Header remains off
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPageStyle, u"HeaderIsOn"_ustr));
}
// Without the fix in place, this test would have crashed here
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {});
CPPUNIT_ASSERT_EQUAL(u""_ustr, getParagraph(1)->getString());
}
// Without the fix in place, this test would have failed with // - Expected: Default Style // - Actual :
CPPUNIT_ASSERT_EQUAL(u"Default Style"_ustr,
getProperty<OUString>(xTextTable2, u"TableTemplateName"_ustr));
}
// check that table was created and inserted into the document
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
// create another document
createSwDoc();
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
// without the test, writer freezes on redo table paste into new doc
dispatchCommand(mxComponent, u".uno:Redo"_ustr, {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables2->getCount());
}
//Get the format of the shape constauto& rFrmFormats = *pDoc->GetSpzFrameFormats();
CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front();
CPPUNIT_ASSERT(pShape);
//Add a textbox
SwTextBoxHelper::create(pShape, pShape->FindRealSdrObject());
SwFrameFormat* pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
CPPUNIT_ASSERT(pTxBxFrm);
//Remove the textbox using Undo
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {});
//Add again
SwTextBoxHelper::create(pShape, pShape->FindRealSdrObject());
pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
//This was nullptr because of unsuccessful re-adding
CPPUNIT_ASSERT_MESSAGE("Textbox cannot be readd after Undo!", pTxBxFrm);
}
// Without the fix in place, the table would be hidden
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, TestTextBoxCrashAfterLineDel)
{ // Open the desired file
createSwDoc("txbx_crash.odt");
SwDoc* pDoc = getSwDoc();
// Get the format of the shape constauto& rFrmFormats = *pDoc->GetSpzFrameFormats();
CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front();
CPPUNIT_ASSERT(pShape);
// Without the fix in place, this test would have failed with // - Expected: Some Text // - Actual : Table of Contents
CPPUNIT_ASSERT_EQUAL(u"Some Text"_ustr, getParagraph(1)->getString());
// tdf#160095: Without the fix in place, this test would have crashed here
pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD2 | awt::Key::RETURN);
Scheduler::ProcessEventsToIdle();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.