/* -*- 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/.
*/
class Test : public SwModelTestBase
{ public:
Test() : SwModelTestBase(u"/sw/qa/extras/odfimport/data/"_ustr, u"writer8"_ustr) {}
};
CPPUNIT_TEST_FIXTURE(Test, testEmptySvgFamilyName)
{
createSwDoc("empty-svg-family-name.odt"); // .odt import did crash on the empty font list (which I think is valid according SVG spec)
}
CPPUNIT_TEST_FIXTURE(Test, testHideAllSections)
{
createSwDoc("fdo53210.odt"); // This document has a section that is conditionally hidden, but has no empty paragraph after it.
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xMasters = xTextFieldsSupplier->getTextFieldMasters(); // Set _CS_Allgemein to 0
uno::Reference<beans::XPropertySet> xMaster(xMasters->getByName(u"com.sun.star.text.fieldmaster.User._CS_Allgemein"_ustr), uno::UNO_QUERY);
xMaster->setPropertyValue(u"Content"_ustr, uno::Any(u"0"_ustr)); // This used to crash
uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh();
}
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(textDocument->getText(), uno::UNO_QUERY); // list of paragraphs
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); do
{
uno::Reference<lang::XServiceInfo> xServiceInfo; if (xParaEnum->nextElement() >>= xServiceInfo)
{ if (xServiceInfo->supportsService(u"com.sun.star.text.TextTable"_ustr))
{
uno::Reference<text::XTextTable> const xTextTable(xServiceInfo, uno::UNO_QUERY_THROW);
uno::Sequence<OUString> const cells = xTextTable->getCellNames();
sal_Int32 nLength = cells.getLength();
AllBordersMap::iterator it = map.begin();
for (sal_Int32 i = 0; i < nLength; ++i)
{ if(i%10==6 || (i%10==8 && i<60)) // only B and D cells have borders, every 2 rows
{
uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]);
uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
it = map.find(cells[i]);
CPPUNIT_TEST_FIXTURE(Test, testTdf41542_borderlessPadding)
{
createSwDoc("tdf41542_borderlessPadding.odt"); // the page style's borderless padding should force this to 3 pages, not 1
CPPUNIT_ASSERT_EQUAL( 3, getPages() );
}
CPPUNIT_TEST_FIXTURE(Test, testPageStyleLayoutDefault)
{
createSwDoc("hello.odt");
uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); // This was style::PageStyleLayout_MIRRORED.
CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, u"PageStyleLayout"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTimeFormFormats)
{
createSwDoc("timeFormFormats.odt"); //FIXME: make it an ODFEXPORT_TEST. Validator fails with //attribute "form:current-value" has a bad value: "PT12H12M" does not satisfy the "time" type //See tdf#131127
CPPUNIT_TEST_FIXTURE(Test, testDateFormFormats)
{
createSwDoc("dateFormFormats.odt"); //FIXME: make it an ODFEXPORT_TEST. Validator fails with //unexpected attribute "form:input-required" //See tdf#131148
CPPUNIT_TEST_FIXTURE(Test, testTdf149978)
{
createSwDoc("tdf149978.fodt"); // on Linux the bug only reproduces if a document has been loaded previously
createSwDoc("tdf149978.fodt"); // this was nondeterministic so try 10 times for (int i = 1; i <= 10; ++i)
{
CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(getRun(getParagraph(i), 2, u"bar"_ustr), u"CharBackColor"_ustr));
}
}
// The problem was that the first-footer was shared.
uno::Reference<beans::XPropertySet> xPropSet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, u"FirstIsShared"_ustr));
CPPUNIT_TEST_FIXTURE(Test, testFdo56272)
{
createSwDoc("fdo56272.odt");
uno::Reference<drawing::XShape> xShape = getShape(1); // Vertical position was incorrect.
CPPUNIT_ASSERT_EQUAL(sal_Int32(422), xShape->getPosition().Y); // Was -2371
}
CPPUNIT_TEST_FIXTURE(Test, testIncorrectSum)
{
createSwDoc("incorrectsum.odt");
Scheduler::ProcessEventsToIdle();
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xCell(xTextTable->getCellByName(u"C3"_ustr), uno::UNO_QUERY); // Use indexOf instead of exact match since the result contains an Euro sign which OUString doesn't like
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xCell->getString().indexOf("1,278"));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf128737)
{
createSwDoc("tdf128737.odt"); // Without the fix in place, this test would have crashed
CPPUNIT_ASSERT_EQUAL(4, getPages());
CPPUNIT_ASSERT_EQUAL(8, getShapes());
}
CPPUNIT_TEST_FIXTURE(Test, tdf167455)
{ // crashes at import time on macOS
createSwDoc("tdf167455.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_TEST_FIXTURE(Test, testCalcFootnoteContent)
{
createSwDoc("ooo32780-1.odt"); //this was a CalcFootnoteContent crash
}
CPPUNIT_TEST_FIXTURE(Test, testMoveSubTree)
{
createSwDoc("ooo77837-1.odt"); //this was a MoveSubTree crash
}
CPPUNIT_TEST_FIXTURE(Test, testFdo75872_ooo33)
{
createSwDoc("fdo75872_ooo33.odt"); // graphics default style: line color and fill color changed
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(COL_BLACK,
getProperty<Color>(xShape, u"LineColor"_ustr));
CPPUNIT_ASSERT_EQUAL(Color(0x99ccff),
getProperty<Color>(xShape, u"FillColor"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo75872_aoo40)
{
createSwDoc("fdo75872_aoo40.odt"); // graphics default style: line color and fill color changed
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(COL_GRAY,
getProperty<Color>(xShape, u"LineColor"_ustr));
CPPUNIT_ASSERT_EQUAL(Color(0xcfe7f5),
getProperty<Color>(xShape, u"FillColor"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo82165)
{
createSwDoc("fdo82165.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes()); // there was a duplicate shape in the left header
lcl_CheckShape(getShape(1), u"Picture 9"_ustr);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf89802)
{
createSwDoc("tdf89802.fodt"); // the text frame was dropped during import
uno::Reference<text::XTextFramesSupplier> const xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> const xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
uno::Reference<beans::XPropertySet> const xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x3f004586), getProperty<Color>(xFrame, u"BackColor"_ustr));
{
pWrtShell->SelAll(); // Selects A1.
SwTextNode& rCellEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode()); // fdo#72486 This was "Hello.", i.e. a single select-all selected the whole document, not just the cell only.
CPPUNIT_ASSERT_EQUAL(u"A1"_ustr, rCellEnd.GetText());
pWrtShell->SelAll(); // Selects the whole table.
pWrtShell->SelAll(); // Selects the whole document.
pShellCursor = pWrtShell->getShellCursor(false);
SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode()); // This was "A1", i.e. Ctrl-A only selected the A1 cell of the table, not the whole document.
CPPUNIT_ASSERT_EQUAL(u"Hello."_ustr, rEnd.GetText());
}
{
pWrtShell->SttEndDoc(false); // Go to the end of the doc.
pWrtShell->SelAll(); // And now that we're outside of the table, try Ctrl-A again.
SwTextNode& rStart = dynamic_cast<SwTextNode&>(pShellCursor->Start()->GetNode()); // This was "Hello", i.e. Ctrl-A did not select the starting table.
CPPUNIT_ASSERT_EQUAL(u"A1"_ustr, rStart.GetText());
SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode());
CPPUNIT_ASSERT_EQUAL(u"Hello."_ustr, rEnd.GetText());
}
{
pWrtShell->Delete(); // Delete the selection // And make sure the table got deleted as well.
SwNodes& rNodes = pWrtShell->GetDoc()->GetNodes();
SwNodeIndex nNode(rNodes.GetEndOfExtras());
SwContentNode* pContentNode = SwNodes::GoNext(&nNode); // First content node was in a table -> table wasn't deleted.
CPPUNIT_ASSERT(!pContentNode->FindTableNode());
}
}
// Previously copy&paste failed to copy the table in case it was the document-starting one.
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
} #endif
CPPUNIT_TEST_FIXTURE(Test, testFdo69862)
{
createSwDoc("fdo69862.odt"); // The test doc is special in that it starts with a table and it also has a footnote.
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SelAll(); // Selects A1.
pWrtShell->SelAll(); // Selects the whole table.
pWrtShell->SelAll(); // Selects the whole document.
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
SwTextNode& rStart = dynamic_cast<SwTextNode&>(pShellCursor->Start()->GetNode()); // This was "Footnote.", as Ctrl-A also selected footnotes, but it should not.
CPPUNIT_ASSERT_EQUAL(u"A1"_ustr, rStart.GetText());
SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode());
CPPUNIT_ASSERT_EQUAL(u"H""\x01""ello."_ustr, rEnd.GetText());
}
CPPUNIT_TEST_FIXTURE(Test, testFdo69979)
{
createSwDoc("fdo69979.odt"); // The test doc is special in that it starts with a table and it also has a header.
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
pWrtShell->SelAll(); // Selects A1.
pWrtShell->SelAll(); // Selects the whole table.
pWrtShell->SelAll(); // Selects the whole document.
SwTextNode& rStart = dynamic_cast<SwTextNode&>(pShellCursor->Start()->GetNode()); // This was "", as Ctrl-A also selected headers, but it should not.
CPPUNIT_ASSERT_EQUAL(u"A1"_ustr, rStart.GetText());
SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode());
CPPUNIT_ASSERT_EQUAL(u"Hello."_ustr, rEnd.GetText());
}
CPPUNIT_TEST_FIXTURE(Test, testSpellmenuRedline)
{
createSwDoc("spellmenu-redline.odt");
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
uno::Reference<linguistic2::XSpellAlternatives> xAlt;
SwSpellPopup aPopup(pWrtShell, xAlt, OUString());
Menu& rMenu = aPopup.GetMenu(); // Make sure that if we show the spellcheck popup menu (for the current // document, which contains redlines), then the last two entries will be // always 'go to next/previous change'.
CPPUNIT_ASSERT_EQUAL(u"next"_ustr, rMenu.GetItemIdent(rMenu.GetItemId(rMenu.GetItemCount() - 2)));
CPPUNIT_ASSERT_EQUAL(u"prev"_ustr, rMenu.GetItemIdent(rMenu.GetItemId(rMenu.GetItemCount() - 1)));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf107776)
{
createSwDoc("tdf107776.fodt"); // Shape with a Graphics parent style name was imported as textbox.
CPPUNIT_ASSERT(!getProperty<bool>(getShape(1), u"TextBox"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testAnnotationFormatting)
{
createSwDoc("annotation-formatting.odt");
uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 1), u"TextField"_ustr);
uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XText> >(xTextField, u"TextRange"_ustr); // Make sure we test the right annotation.
uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, u"Looses: bold"_ustr); // Formatting was lost: the second text portion was NORMAL, not BOLD.
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xParagraph, 2), u"CharWeight"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testBnc800714)
{
createSwDoc("bnc800714.fodt"); // Document's second paragraph wants to be together with the third one, but: // - it's in a section with multiple columns // - contains a single as-char anchored frame // This was a layout loop.
CPPUNIT_ASSERT(getProperty< uno::Reference<text::XTextSection> >(getParagraph(2), u"TextSection"_ustr).is());
CPPUNIT_ASSERT(getProperty<bool>(getParagraph(2), u"ParaKeepTogether"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf92586)
{
createSwDoc("tdf92586.odt");
uno::Any aPageStyle = getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr); // This was BitmapMode_NO_REPEAT.
CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, getProperty<drawing::BitmapMode>(aPageStyle, u"FillBitmapMode"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf76322_columnBreakInHeader)
{
createSwDoc("tdf76322_columnBreakInHeader.docx"); // column breaks were ignored. First line should start in column 2
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/header/section/column[2]/body/txt/text()", u"Test1");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf76349_1columnBreak)
{
createSwDoc("tdf76349_1columnBreak.odt"); //single-column breaks should only be treated as page breaks for MS formats - should be only one page here.
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf96113)
{
createSwDoc("tdf96113.odt"); // Background of the formula frame was white (0xffffff), not green.
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty<Color>(getShape(1), u"BackColor"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo47267)
{
createSwDoc("fdo47267-3.odt"); // This was a Style Families getByName() crash
}
CPPUNIT_TEST_FIXTURE(Test, testTdf75221)
{
createSwDoc("tdf75221.odt"); // When "Don't add space between paragraphs of the same style" setting set, // spacing between same-style paragraphs must be equal to their line spacing. // It used to be 0.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString top = getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/prtBounds", "top");
CPPUNIT_ASSERT(top.toInt32() > 0);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf101729)
{
createSwDoc("tdf101729.odt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 l = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "left").toInt32();
sal_Int32 w = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32();
sal_Int32 x = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt/infos/bounds", "left").toInt32(); // Make sure the text does not go outside and verify it is centered roughly
CPPUNIT_ASSERT( l + w / 4 < x );
CPPUNIT_ASSERT( x < l + 3 * w / 4);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf107392)
{
createSwDoc("tdf107392.odt"); // Shapes from bottom to top were Frame, SVG, Bitmap, i.e. in the order as // they appeared in the document, not according to their requested z-index, // as sorting failed. // So instead of 0, 1, 2 these were 2, 0, 1.
CPPUNIT_TEST_FIXTURE(Test, testTdf100033_1)
{
createSwDoc("tdf100033_1.odt"); // Test document have three duplicated frames with the same name and position/size -> import one frame
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(Test, testWordAsCharShape)
{
createSwDoc("Word2010AsCharShape.odt"); // As-char shape had VertOrient "from-top"/NONE default from GetVOrient()
uno::Reference<drawing::XShape> const xShape(getShape(1));
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(xShape, u"AnchorType"_ustr));
CPPUNIT_ASSERT_EQUAL(text::VertOrientation::TOP, getProperty<sal_Int16>(xShape, u"VertOrient"_ustr)); // also, the paragraph default fo:bottom-margin was wrongly applied to // the shape
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, u"BottomMargin"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf100033_2)
{
createSwDoc("tdf100033_2.odt"); // Test document have three different frames anchored to different paragraphs -> import all frames
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
}
CPPUNIT_TEST_FIXTURE(Test, testI61225)
{
createSwDoc("i61225.sxw"); // Part of ooo61225-1.sxw from crashtesting.
// This never returned.
calcLayout();
}
CPPUNIT_TEST_FIXTURE(Test, testTdf109080_loext_ns)
{
createSwDoc("tdf109080_loext_ns.odt"); // Test we can import <loext:header-first> and <loext:footer-first>
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()", u"This is the first page header");
assertXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()", u"This is the non-first-page header");
assertXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()", u"This is the first page footer");
assertXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()", u"This is the non-first-page footer");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf109080_style_ns)
{
createSwDoc("tdf109080_style_ns.odt"); // Test we can import <style:header-first> and <style:footer-first> // (produced by LibreOffice 4.0 - 5.x)
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()", u"This is the first page header");
assertXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()", u"This is the non-first-page header");
assertXPathContent(pXmlDoc, "/root/page[1]/footer/txt/text()", u"This is the first page footer");
assertXPathContent(pXmlDoc, "/root/page[2]/footer/txt/text()", u"This is the non-first-page footer");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf109228)
{
createSwDoc("tdf109228.odt"); // Embedded object with no frame name was imported incorrectly, it was anchored 'to character' instead of 'as character'
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), u"AnchorType"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf94882)
{
createSwDoc("tdf94882.odt"); // Get the header of the page containing our content // (done this way to skip past any blank page inserted before it // due to the page number being even)
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString headertext = getXPathContent(pXmlDoc, "/root/page[starts-with(body/txt/text(),'The paragraph style on this')]" "/header/txt/text()"
); // This header should be the first page header
CPPUNIT_ASSERT_EQUAL(u"This is the first page header"_ustr, headertext);
}
CPPUNIT_TEST_FIXTURE(Test, testBlankBeforeFirstPage)
{
createSwDoc("tdf94882.odt"); // This document starts on page 50, which is even, but it should not have a // blank page inserted before it to make it a left page
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 1 pages output",
u"1"_ustr, getXPathContent(pXmlDoc, "count(/root/page)")
);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf115079)
{
createSwDoc("tdf115079.odt"); // This document caused segfault when layouting
}
CPPUNIT_TEST_FIXTURE(Test, testTdf108482)
{
createSwDoc("tdf108482.odt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL_MESSAGE("The table on second page must have two rows",
u"2"_ustr, getXPathContent(pXmlDoc, "count(/root/page[2]/body/tab/row)")
);
CPPUNIT_ASSERT_EQUAL_MESSAGE("The second page table's first row must be the repeated headline",
u"Header"_ustr, getXPathContent(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell/txt")
); // The first (repeated headline) row with vertical text orientation must have non-zero height // (in my tests, it was 1135)
CPPUNIT_ASSERT_GREATER(
sal_Int32(1000), getXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/infos/bounds", "height").toInt32()
);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf116195)
{
createSwDoc("tdf116195.odt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // The image was set to zero height due to a regression
CPPUNIT_ASSERT_EQUAL(
sal_Int32(12960), getXPath(pXmlDoc, "/root/page/anchored/fly/notxt/infos/bounds", "height").toInt32()
);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf120677)
{
createSwDoc("tdf120677.fodt"); // The document used to hang the layout, consuming memory until OOM
}
CPPUNIT_TEST_FIXTURE(Test, testTdf152015)
{ // it hangs at import time
createSwDoc("tdf152015.odt");
CPPUNIT_ASSERT_EQUAL( 1, getPages() );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf123829)
{
createSwDoc("tdf123829.odt");
SwDoc* pDoc = getSwDoc();
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Compatibility: collapse cell paras should not be set", false,
pDoc->getIDocumentSettingAccess().get(DocumentSettingId::COLLAPSE_EMPTY_CELL_PARA));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf123968)
{
createSwDoc("tdf123968.odt"); // The test doc is special in that it starts with a table and it also has a header.
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
// The field is now editable like any text, thus the field content "New value" shows up for the cursor. // This field's variable is declared as string and used as string - typical.
CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART)
+ "New value" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)),
rStart.GetText());
// This field's variable is declared as float and used as string - not // typical; this can easily happen if the input field is in a header/footer, // because only content.xml contains the variable-decls, styles.xml is // imported before content.xml, and apparently the default variable type is // numeric.
SwTextNode& rEnd = dynamic_cast<SwTextNode&>(pShellCursor->End()->GetNode());
CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART)
+ "String input for num variable" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)),
rEnd.GetText());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf133459)
{
createSwDoc("tdf133459.odt"); // Test that the number format was correctly imported, and used by both fields.
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xFields(xTextFieldsSupplier->getTextFields()->createEnumeration());
// First Field
uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY); const OUString sPresentation(xField->getPresentation(false)); const sal_Int32 nFormat(getProperty<sal_Int32>(xField, u"NumberFormat"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xField, u"IsFixedLanguage"_ustr));
// Second field
xField.set(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sPresentation, xField->getPresentation(false));
CPPUNIT_ASSERT_EQUAL(nFormat, getProperty<sal_Int32>(xField, u"NumberFormat"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xField, u"IsFixedLanguage"_ustr));
// Test the number format itself
uno::Reference<util::XNumberFormatsSupplier> xNumberFormatsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xFormat(xNumberFormatsSupplier->getNumberFormats()->getByKey(nFormat));
lang::Locale aLocale(getProperty<lang::Locale>(xFormat, u"Locale"_ustr));
CPPUNIT_ASSERT_EQUAL(u"ru"_ustr, aLocale.Language);
CPPUNIT_ASSERT_EQUAL(u"RU"_ustr, aLocale.Country);
CPPUNIT_ASSERT_EQUAL(u"QQ YYYY"_ustr, getProperty<OUString>(xFormat, u"FormatString"_ustr));
}
// Without the fix in place, this test would have failed with // - Expected: Heading 1 // - Actual : Standard
CPPUNIT_ASSERT_EQUAL(u"Heading 1"_ustr,
getProperty<OUString>(getParagraph(1), u"ParaStyleName"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testPasteFirstParaDirectFormat)
{
createSwDoc();
{ // Set some direct formatting on the first paragraph, but leave paragraph adjust at its // default (left).
uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
xParagraph->setPropertyValue(u"PageNumberOffset"_ustr, uno::Any(static_cast<sal_Int16>(0)));
}
// Without the accompanying fix in place, this test would have failed with: // - Expected: 3 (center) // - Actual : 0 (left) // i.e. the inserted document's first paragraph's paragraph formatting was lost.
uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(style::ParagraphAdjust_CENTER),
getProperty<sal_Int16>(xParagraph, u"ParaAdjust"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testVerticallyMergedCellBorder)
{ // Given a document with two cells, vertically merged, when loading the document:
createSwDoc("vmerge-cell-border.odt");
// Then make sure that the first cell has a right border while the second has no right border:
SwDocShell* pDocShell = getSwDocShell();
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(/*bBlock=*/false);
SwStartNode* pA1 = pShellCursor->Start()->GetNode().StartOfSectionNode(); const SwAttrSet& rA1Set = pA1->GetTableBox()->GetFrameFormat()->GetAttrSet();
CPPUNIT_ASSERT(rA1Set.GetBox().GetRight());
SwNodeIndex aA2(*pA1->EndOfSectionNode(), 1); const SwAttrSet& rA2Set = aA2.GetNode().GetTableBox()->GetFrameFormat()->GetAttrSet();
// Without the accompanying fix in place, this test would have failed, as the A2 cell also had a // right border, even if <table:covered-table-cell table:style-name="..."> explicitly disabled // it.
CPPUNIT_ASSERT(!rA2Set.GetBox().GetRight());
// Given this document model, when exporting to ODT:
save(u"writer8"_ustr);
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.