/* -*- 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/.
*/
/// Test to assert layout / rendering result of Writer. class SwLayoutWriter2 : public SwModelTestBase
{ public:
SwLayoutWriter2()
: SwModelTestBase(u"/sw/qa/extras/layout/data/"_ustr)
{
}
// show again - should now get the same result as on loading
dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {});
pXmlDoc = parseLayoutDump();
// check footnotes
assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 6);
assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 3); // check that first page ends with the y line and second page starts with z
assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/SwParaPortion/SwLineLayout[last()]", "portion",
u"yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy ");
assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
u"zzz. zzz zzzz zzzz* zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz ");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951)
{ // Open the bugdoc
createSwDoc("tdf138951.odt");
// Get the only shape
uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xShape);
// Gather its formats: the shape and textbox const SwFrameFormat* pTxFrm = SwTextBoxHelper::getOtherTextBoxFormat(xShape);
CPPUNIT_ASSERT(pTxFrm); const SwFrameFormat* pShFrm = SwTextBoxHelper::getOtherTextBoxFormat(pTxFrm, RES_FLYFRMFMT);
CPPUNIT_ASSERT(pShFrm);
calcLayout();
// Get the bound rectangle of the textframe
tools::Rectangle aTxtFrmRect(pTxFrm->FindRealSdrObject()->GetLogicRect());
// Get the bound rectangle of the shape
tools::Rectangle aShpRect(pShFrm->FindRealSdrObject()->GetLogicRect());
// Check the anchor the same and the textbox is inside the shape constbool bIsAnchTheSame
= *pShFrm->GetAnchor().GetAnchorNode() == *pShFrm->GetAnchor().GetAnchorNode();
CPPUNIT_ASSERT_MESSAGE("The anchor is different for the textbox and shape!", bIsAnchTheSame);
CPPUNIT_ASSERT_MESSAGE("The textbox has fallen apart!", aShpRect.Contains(aTxtFrmRect)); // Without the fix the anchor differs, and the frame outside of the shape
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150790)
{
createSwDoc("tdf150790.fodt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // point bookmark is shown as I-beam (only its text dump is |, as before on the screen)
assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwBookmarkPortion", "colors", u"#Bookmark 1 Bookmark"); // single start bookmark
assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]", "colors", u"#Bookmark 2 Bookmark Start"); // single end bookmark
assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[3]", "colors", u"#Bookmark 3 Bookmark End"); // This was |, as before the point bookmark (neighboring end and start bookmarks)
assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]", "colors", u"#Bookmark 2 Bookmark End#Bookmark 3 Bookmark Start");
}
// paragraph with 2 redlines was not marked as deleted
assertXPath(pXmlDoc, "//text[text() = 'Nunc viverra imperdiet enim. Fusce est. Vivamus a " "tellus.']/parent::textarray/preceding-sibling::font[1]", "strikeout", u"1");
// Also check if the tooltip shows the delete, not the format // Given a paragraph with both delete and format:
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwRootFrame* pLayout = pWrtShell->GetLayout();
SwFrame* pPage = pLayout->GetLower();
SwFrame* pBody = pPage->GetLower();
SwFrame* pPara = pBody->GetLower()->GetNext(); // When getting the content at a position for tooltip purposes:
Point aPoint = pPara->getFrameArea().Center();
SwContentAtPos aContentAtPos(IsAttrAtPos::Redline);
CPPUNIT_ASSERT(pWrtShell->GetContentAtPos(aPoint, aContentAtPos)); // Then make sure we find a delete redline:
CPPUNIT_ASSERT_EQUAL(IsAttrAtPos::Redline, aContentAtPos.eContentAtPos); const SwRangeRedline* pRedline = aContentAtPos.aFnd.pRedl; // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 (RedlineType::Delete) // - Actual : 5 (RedlineType::ParagraphFormat) // i.e. the delete didn't have priority over para format, leading to a misleading tooltip.
CPPUNIT_ASSERT_EQUAL(RedlineType::Delete, pRedline->GetType());
}
// Assert the tracked deletion of the number of joined list item and // the tracked insertion of the number after a split list item as not black // (and not COL_GREEN color of the tracked text movement, see testRedlineMoving) elements
assertXPath(
pXmlDoc, "/metafile/push/push/push/textcolor[not(@color='#000000') and not(@color='#008000')]", 5);
// tdf#145068 numbering shows changes in the associated list item, not the next one // This was 1 (black numbering of the first list item previously)
assertXPath(pXmlDoc, "/metafile/push/push/push/font[4][@color='#000000']", 0);
}
// Show the correct and the original line numbering instead of counting // the deleted list items in Show Changes mode, as part of the list
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); // This was "2." (deleted text node, now its text content is part of the first list item)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"[2.] "); // This was "3." (now it's the second list item)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"2.[3.] ");
}
// Show the correct and the original line numbering in Show Changes mode
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"2."); // FIXME: show as 3.[2.]
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"3."); // This was "4." (not shown the original number)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", u"4.[3.] ");
}
// Show Changes
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwRootFrame* pLayout(pWrtShell->GetLayout());
CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
// delete the paragraph mark of the first list item with change tracking
dispatchCommand(mxComponent, u".uno:GoToEndOfLine"_ustr, {});
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
dispatchCommand(mxComponent, u".uno:Delete"_ustr, {});
// Dump the rendering of the first page as an XML file.
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
// Show the correct and the original line numbering instead of counting // the deleted list items in Show Changes mode, as part of the list // This was "1."
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"[1.] "); // This was "2." (deleted text node, now its text content is part of the first list item)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"1.[2.] "); // This was "3." (now it's the second list item)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"2.[3.] ");
// remove the tracked deletion, and check the layout again
pWrtShell->Undo();
xMetaFile = pShell->GetPreviewMetaFile();
pXmlDoc = dumpAndParse(dumper, *xMetaFile);
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"2.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"3.");
}
// Show Changes
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwRootFrame* pLayout(pWrtShell->GetLayout());
CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
// insert a new list item at start of the second list item "a)"
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
pWrtShell->Down(false, 1);
pWrtShell->SplitNode(false);
// Dump the rendering of the first page as an XML file.
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
// Show the correct and the original line numbering instead of counting // the deleted list items in Show Changes mode, as part of the list
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)"); // This was "b)[2.]"
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", u"b)[a)] "); // This was "c)[3.]"
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", u"c)[b)] "); // This was "4.[2.]" (after disabling Show Changes, and enabling again)
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", u"2.");
// remove the tracked deletion, and check the layout again
pWrtShell->Undo();
xMetaFile = pShell->GetPreviewMetaFile();
pXmlDoc = dumpAndParse(dumper, *xMetaFile);
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"b)");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", u"2.");
// check Redo
pWrtShell->Redo();
xMetaFile = pShell->GetPreviewMetaFile();
pXmlDoc = dumpAndParse(dumper, *xMetaFile);
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1.");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)"); // TODO: show as b)[a)]
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", u"b)"); // FIXME: This must be "c)[b]"
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", u"c)[a)] ");
assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", u"2.");
}
assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1);
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "portion",
u"First");
assertXPath(pXmlDoc, "/root/page[2]/body/txt", 2); // this one is merged; if it were 2 0-height frames that would work too
assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "top", u"18846");
assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "height", u"0");
assertXPath(pXmlDoc, "/root/page[2]/body/tab[1]/infos/bounds", "top", u"18846");
assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/SwParaPortion/SwLineLayout", "portion", u"End");
}
// note: do not use layout dump here, because it doesn't work: // SwTextFrame::Format doesn't actually create the SwMarginPortion for // non-left-aligned frames; instead, it sets SetFormatAdj() flag and later // *SwTextPainter* checks via GetAdjusted() if the flag is set and calls // CalcAdjLine() which inserts the SwMarginPortion.
createSwDoc("tdf158885_compound-remain.fodt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // hyphenate compound word with 3- or more character distance from the stem boundary // This was "emberel=lenes" (now "ember=ellenes", i.e. hyphenating at the stem boundary)
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
u"emberellenes emberellenes emberellenes emberellenes emberellenes ember");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion",
u"ellenes emberellenes emberellenes emberellenes emberellenes emberellenes ");
}
createSwDoc("tdf158885_not_compound-remain.fodt");
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // hyphenate compound word with 2-character distance from the stem boundary, // resulting less readable hyphenation "emberel=lenes" ("emberel" and "lenes" have // different meanings, than the original word parts)
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
u"emberellenes emberellenes emberellenes emberellenes emberellenes emberel");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion",
u"lenes emberellenes emberellenes emberellenes emberellenes emberellenes ");
}
// changed color of numbers of footnote 1 (deleted footnote) and footnote 2 (inserted footnote) // decreased the black <font> elements by 2: // This was 7
assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#000000']", 5);
}
// create a 3-element list without change tracking
SwEditShell* const pEditShell(pDoc->GetEditShell());
CPPUNIT_ASSERT(pEditShell);
pEditShell->RejectRedline(0);
pEditShell->AcceptRedline(0);
// move down first list item with track changes
dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {});
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
dispatchCommand(mxComponent, u".uno:MoveDown"_ustr, {});
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// text and numbering colors show moving of the list item // tdf#157663: the moved text item "It" is detected as text moving again!
assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5);
assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11);
}
// create a 3-element list without change tracking
SwEditShell* const pEditShell(pDoc->GetEditShell());
CPPUNIT_ASSERT(pEditShell);
pEditShell->RejectRedline(0);
pEditShell->AcceptRedline(0);
// extend the first item to "An ItemIt", because detection of move needs // at least 6 characters with an inner space after stripping white spaces // of the redline
dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {});
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->Insert(u"An Item"_ustr);
// move down first list item with track changes
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
dispatchCommand(mxComponent, u".uno:MoveDown"_ustr, {});
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// text and numbering colors show moving of the list item // These were 0 (other color, not COL_GREEN, color of the tracked text movement)
assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5);
assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11);
}
SwEditShell* const pEditShell(pDoc->GetEditShell());
CPPUNIT_ASSERT(pEditShell); // This was 2 (moveFrom and moveTo joined other redlines)
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(5), pEditShell->GetRedlineCount());
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// text colors show moved text // These were 0 (other color, not COL_GREEN, color of the tracked text movement)
assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 6);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate)
{ // 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<beans::PropertyValue> aFilterOptions = {
{ beans::PropertyValue(u"Hidden"_ustr, -1, uno::Any(true),
beans::PropertyState_DIRECT_VALUE) },
};
// inline the loading because currently properties can't be passed...
OUString const url(createFileURL(u"table_cell_overlap.fodt"));
loadWithParams(url, comphelper::containerToSequence(aFilterOptions));
save(u"writer_pdf_Export"_ustr);
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// text colors show moved text // This was 0 (other color, not COL_GREEN, color of the tracked text movement)
assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 4);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// This was 0 (other color, not COL_AUTHOR_TABLE_DEL, color of the tracked row deletion)
assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#fce6f4']", 1); // This was 0 (other color, not COL_AUTHOR_TABLE_INS, color of the tracked row insertion)
assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#e1f2fa']", 1); // This was 3 (color of the cells of the last column, 2 of them disabled by change tracking )
assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#3faf46']", 1);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// This was 0 (other color, not COL_AUTHOR_TABLE_DEL, color of the tracked row deletion)
assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#fce6f4']", 2); // This was 0 (other color, not COL_AUTHOR_TABLE_INS, color of the tracked row insertion)
assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#e1f2fa']", 2);
}
// create a 3-element list without change tracking // (because the fixed problem depends on the own changes)
SwEditShell* const pEditShell(pDoc->GetEditShell());
CPPUNIT_ASSERT(pEditShell);
pEditShell->RejectRedline(0);
pEditShell->AcceptRedline(0);
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), pEditShell->GetRedlineCount());
// Show Changes
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwRootFrame* pLayout(pWrtShell->GetLayout());
CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
// insert a tracked paragraph break in middle of the second list item, i.e. split it
dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {});
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // positionate the cursor in the middle of the second list item
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 4, /*bBasicCall=*/false);
pWrtShell->SplitNode(false);
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount());
// move up the last list item over the paragraph split
dispatchCommand(mxComponent, u".uno:GoToEndOfDoc"_ustr, {});
dispatchCommand(mxComponent, u".uno:MoveUp"_ustr, {});
dispatchCommand(mxComponent, u".uno:MoveUp"_ustr, {}); // This was 2 (the tracked paragraph break joined with the moved list item, // setting the not changed text of the second list item to tracked insertion)
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount());
}
// enable Record Changes
dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {});
CPPUNIT_ASSERT_MESSAGE("redlining should be on",
pDoc->getIDocumentRedlineAccess().IsRedlineOn());
// delete and paste the deleted word again during Track Changes
dispatchCommand(mxComponent, u".uno:WordRightSel"_ustr, {});
dispatchCommand(mxComponent, u".uno:Cut"_ustr, {});
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// Assert that the yellow rectangle (cell background) is painted after the // polypolygon (background shape). // Background shape: 1.1.1.2 // Cell background: 1.1.1.3
assertXPath(
pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/fillcolor[@color='#729fcf']", 1);
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/polypolygon",
1);
// This failed: cell background was painted before the background shape.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/fillcolor[@color='#ffff00']", 1);
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPathContent(pXmlDoc, "(//textarray)[12]/text", u"Data3"); // This failed, if the legend first label is not "Data3". The legend position is right.
}
assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/infos/bounds", "top", u"2185"); // the image should be inside of the cell boundary - so the same top or higher
assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/anchored/fly/infos/bounds", "top", u"2185");
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// Bug 122225 - FILEOPEN DOCX Textbox of Column chart legend reduces and text of legend disappears const sal_Int32 nLegendLabelLines
= getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Advanced Diploma\")])")
.toInt32(); // This failed, if the legend label is not "Advanced Diploma".
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nLegendLabelLines);
// Bug 140623 - Fileopen DOCX: Text Orientation of X-Axis 0 instead of 45 degrees const sal_Int32 nThirdLabelLines
= getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Hispanic\")])").toInt32(); // This failed, if the third X axis label broke to multiple lines.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nThirdLabelLines);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPathContent(pXmlDoc, "(//textarray)[12]/text", u"Data3"); // This failed, if the legend first label is not "Data3". The legend position is bottom.
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPathContent(pXmlDoc, "(//textarray)[14]/text", u"1. adatsor"); // This failed, if the legend first label is not "1. adatsor".
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPathContent(pXmlDoc, "(//textarray)[17]/text", u"Series1");
assertXPathContent(pXmlDoc, "(//textarray)[18]/text", u"Series2");
assertXPathContent(pXmlDoc, "(//textarray)[19]/text", u"Series3"); // These failed, if the legend names are empty strings.
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// Check number of legend entries
assertXPath(pXmlDoc, "//text[contains(text(),\"Column\")]", 2);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc); // Without the accompanying fix in place, this test would have failed with: // - Expected: 14 // - Actual : 12 // i.e. the text of the chart legend lost.
assertXPath(pXmlDoc, "//textarray", 14);
}
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT(pXmlDoc); // Without the accompanying fix in place, this test would have failed with: // - Expected: >300 // - Actual : 142 // i.e. the formula squashed
CPPUNIT_ASSERT_GREATEREQUAL( double(300),
getXPath(pXmlDoc, "/root/page/body/txt[2]/anchored/fly/notxt/infos/bounds", "height")
.toDouble());
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc); // Without the accompanying fix in place, this test would have failed with: // - Expected: 53 // - Actual : 0 // i.e. the chart lost.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push",
53);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc, "//textarray[@length='22']", 8); // This failed, if the textarray length of the first axis label not 22.
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
int nCount = countXPathNodes(pXmlDoc, "//textarray[@length='17']");
CPPUNIT_ASSERT_EQUAL(4, nCount); // This failed, if the textarray length of the category axis label not 17.
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc, "//textarray[@length='22']", 9); // This failed, if the textarray length of the first axis label not 22.
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
// test the X axis label visibility
assertXPathContent(pXmlDoc, "(//textarray)[1]/text", u"Long axis label truncated 1");
// test the Y axis label visibility
assertXPathContent(pXmlDoc, "(//textarray)[3]/text", u"-5.00");
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPathContent(pXmlDoc, "(//textarray)[1]/text", u"A very long category name 1");
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc); // Test the first level of vertical category axis labels orientation. The first level orientation should be horizontal.
assertXPath(pXmlDoc, "(//font)[1]", "orientation", u"0"); // Test the second level of vertical category axis labels orientation. The second level orientation should be vertical.
sal_Int32 nRotation = getXPath(pXmlDoc, "(//font)[5]", "orientation").toInt32();
CPPUNIT_ASSERT(nRotation >= 899);
CPPUNIT_ASSERT(nRotation <= 900); // Test the third level of vertical category axis labels orientation. The third level orientation should be vertical.
nRotation = getXPath(pXmlDoc, "(//font)[7]", "orientation").toInt32();
CPPUNIT_ASSERT(nRotation >= 899);
CPPUNIT_ASSERT(nRotation <= 900);
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc); // Test the first level of horizontal category axis labels orientation. The first level orientation should be vertical.
sal_Int32 nRotation = getXPath(pXmlDoc, "(//font)[1]", "orientation").toInt32();
CPPUNIT_ASSERT(nRotation >= 899);
CPPUNIT_ASSERT(nRotation <= 900); // Test the second level of horizontal category axis labels orientation. The second level orientation should be horizontal.
assertXPath(pXmlDoc, "(//font)[5]", "orientation", u"0"); // Test the third level of horizontal category axis labels orientation. The third level orientation should be horizontal.
assertXPath(pXmlDoc, "(//font)[7]", "orientation", u"0");
}
// Dump the rendering of the first page as an XML file.
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump dumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc); // Test the Y position of horizontal category axis label.
sal_Int32 nYposition = getXPath(pXmlDoc, "(//textarray)[7]", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(11248, nYposition, 20);
}
CPPUNIT_ASSERT_MESSAGE("Textbox must be inside the shape!", aChildShape.Contains(aFrame));
}
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116256)
{ // Open bugdoc
createSwDoc("tdf116256.docx");
// Get the textbox
uno::Reference<beans::XPropertySet> xTextBox(getShape(2), uno::UNO_QUERY_THROW);
// Ensure that is a real textbox, and follows the text flow
CPPUNIT_ASSERT(xTextBox->getPropertyValue(u"TextBox"_ustr).get<bool>());
CPPUNIT_ASSERT(xTextBox->getPropertyValue(u"IsFollowingTextFlow"_ustr).get<bool>());
// Parse the layout auto pLayout = parseLayoutDump(); // Get the position of the shape constauto nCellLeft
= getXPath(pLayout, "//page/body/txt/anchored/fly/tab/row[1]/cell/infos/bounds", "left")
.toInt64(); constauto nCellTop
= getXPath(pLayout, "//page/body/txt/anchored/fly/tab/row[1]/cell/infos/bounds", "top")
.toInt64(); // Get the position of the textframe too. constauto nTextBoxFrameLeft
= getXPath(pLayout, "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", "left")
.toInt64(); constauto nTextBoxFrameTop
= getXPath(pLayout, "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", "top")
.toInt64();
// Without the fix in place these were less than they supposed to.
CPPUNIT_ASSERT_GREATEREQUAL(nCellLeft, nTextBoxFrameLeft);
CPPUNIT_ASSERT_GREATEREQUAL(nCellTop, nTextBoxFrameTop);
}
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.