/* -*- 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/ww8export/data/"_ustr, u"MS Word 97"_ustr) {}
};
DECLARE_WW8EXPORT_TEST(testN757910, "n757910.doc")
{ // The internal margin was larger than 0.28cm
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nValue = 0;
xPropertySet->getPropertyValue(u"LeftBorderDistance"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(280), nValue);
// The border width was zero
table::BorderLine2 aBorder;
xPropertySet->getPropertyValue(u"LeftBorder"_ustr) >>= aBorder;
CPPUNIT_ASSERT(aBorder.LineWidth > 0);
}
DECLARE_WW8EXPORT_TEST(testTdf75539_relativeWidth, "tdf75539_relativeWidth.doc")
{ //divide everything by 10 to give a margin of error for rounding etc.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 pageWidth = getXPath(pXmlDoc, "/root/page[1]/body/infos/bounds", "width").toInt32()/10;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Page width", sal_Int32(9354/10), pageWidth);
CPPUNIT_ASSERT_EQUAL_MESSAGE("100% width line", pageWidth, getXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion", "width").toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("50% width line", pageWidth/2, getXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion", "width").toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("25% width line", pageWidth/4, getXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion", "width").toInt32()/10);
CPPUNIT_ASSERT_EQUAL_MESSAGE("10% width line", pageWidth/10, getXPath(pXmlDoc ,"/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion", "width").toInt32()/10);
}
DECLARE_WW8EXPORT_TEST(testN757905, "n757905.doc")
{ // The problem was that the paragraph had only a single fly // (as-character-anchored), and the height of that was smaller than the // paragraph height. When in Word-compat mode, we should take the max of // the two, not just the height of the fly.
DECLARE_WW8EXPORT_TEST(testI120158, "i120158.doc")
{ // See https://bz.apache.org/ooo/show_bug.cgi?id=120158
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); // list of paragraphs
uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); // get contents of 1st paragraph as text
uno::Reference<uno::XInterface> paragraph0(paraEnum->nextElement(), uno::UNO_QUERY);
uno::Reference<text::XTextRange> text0(paragraph0, uno::UNO_QUERY);
OUString sFieldResult = text0->getString();
CPPUNIT_ASSERT(sFieldResult.endsWith("AM") || sFieldResult.endsWith("PM"));
}
DECLARE_WW8EXPORT_TEST(testN816603, "n816603.doc")
{ // Bugdoc was 5 pages in Word, 1 in Writer due to pointlessly wrapping the // table in a frame. Exact layout may depend on fonts available, etc. -- // but at least make sure that our table spans over multiple pages now.
CPPUNIT_ASSERT(getPages() > 1);
}
DECLARE_WW8EXPORT_TEST(testPageBorder, "page-border.doc")
{ // Page border was missing (LineWidth was 0), due to wrong interpretation of pgbApplyTo.
table::BorderLine2 aBorder = getProperty<table::BorderLine2>(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"TopBorder"_ustr);
CPPUNIT_ASSERT_EQUAL(sal_uInt32(convertTwipToMm100(6 * 20)), aBorder.LineWidth);
}
DECLARE_WW8EXPORT_TEST(testN823651, "n823651.doc")
{ // Character height was 10pt instead of 7.5pt in the header.
uno::Reference<beans::XPropertySet> xStyle(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XTextRange> >(xStyle, u"HeaderTextFirst"_ustr)->getText();
uno::Reference<text::XTextRange> xHeaderParagraph = getParagraphOfText(1, xText, "");
CPPUNIT_ASSERT_EQUAL(7.5f, getProperty<float>(xHeaderParagraph, u"CharHeight"_ustr));
// tdf#164845 - inherit the two tab stops from the "Header" paragraph style auto aTabStops
= getProperty<uno::Sequence<style::TabStop>>(xHeaderParagraph, u"ParaTabStops"_ustr);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(2), aTabStops.size());
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7620), aTabStops[0].Position); // 7.62cm
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(15240), aTabStops[1].Position); // 15.24 cm
}
DECLARE_WW8EXPORT_TEST(testFdo36868, "fdo36868.doc")
{
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aText = getXPath(pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand"); // This was 1.1.
CPPUNIT_ASSERT_EQUAL(u"2.1"_ustr, aText);
}
DECLARE_WW8EXPORT_TEST(testListNolevel, "list-nolevel.doc")
{ // Similar to fdo#36868, numbering portions had wrong values.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aText = getXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "expand"); // PortionType::Number was completely missing.
CPPUNIT_ASSERT_EQUAL(u"1."_ustr, aText);
}
DECLARE_WW8EXPORT_TEST(testHeaderApoTable, "ooo92948-1.doc")
{ // the problem was that a table anchored in the header was split across // 3 text frames and quite messed up
// uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(getStyles("PageStyles")->getByName("Standard"), "HeaderTextFirst"); // uno::Reference<text::XTextRange> xPara(getParagraphOfText(9, xHeaderText)); //TODO why does this not work // uno::Reference<beans::XPropertySet> xFrame(getParagraphAnchoredObject(1, xPara));
DECLARE_WW8EXPORT_TEST(testBnc821208, "bnc821208.doc")
{ // WW8Num1z0 earned a Symbol font, turning numbers into rectangles.
uno::Reference<beans::XPropertyState> xPropertyState(getStyles(u"CharacterStyles"_ustr)->getByName(u"WW8Num1z0"_ustr), uno::UNO_QUERY);
beans::PropertyState ePropertyState = xPropertyState->getPropertyState(u"CharFontName"_ustr); // This was beans::PropertyState_DIRECT_VALUE.
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, ePropertyState);
// Background of the numbering itself should have been the default, was yellow (0xffff00).
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPropertyState, u"CharBackColor"_ustr));
}
DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc")
{
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); // It wasn't possible to fill out this form.
CPPUNIT_ASSERT_EQUAL(false, bool(xStorable->isReadonly()));
uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, u"InteropGrabBag"_ustr);
sal_Int32 nPasswordHash = 0; for ( sal_Int32 i = 0; i < aGrabBag.getLength(); ++i )
{ if ( aGrabBag[i].Name == "FormPasswordHash" )
aGrabBag[i].Value >>= nPasswordHash;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Password Hash", sal_Int32(609995782), nPasswordHash);
}
DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
{ // The following 6 colours can only be represented with WW9 (Word 2000) // BRC (BoRder Control) structures. We can tell that they have been // exported/imported using a WW8 (Word '97) BRC if they instead come // through as one of the 16 colours listed at this link: // http://msdn.microsoft.com/en-us/library/dd773060.aspx
table::BorderLine2 expectedTop(0xFA670C, 0, 53, 0, 1, 53);
table::BorderLine2 expectedLeft(0xD99594, 0, 79, 0, 0, 79);
table::BorderLine2 expectedRight(0xB2A1C7, 53, 53, 53, 3, 159);
table::BorderLine2 expectedBottom(0xB6DDE8, 0, 106, 0, 14, 106);
table::BorderLine2 expectedDashedRed(0xFA670C, 0, 53, 0, 2, 53);
table::BorderLine2 expectedDoubleGreen(0xC2D69B, 26, 106, 26, 4, 159);
DECLARE_WW8EXPORT_TEST(testTdf95321, "tdf95321.doc")
{ // The problem was that there should be content in the second cell // but there wasn't.
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"Second Column"_ustr, uno::Reference<text::XTextRange>(xTable->getCellByName(u"B1"_ustr), uno::UNO_QUERY_THROW)->getString());
}
// get a page cursor
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(
xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
// check that the first page has no header
xCursor->jumpToFirstPage();
OUString pageStyleName = getProperty<OUString>(xCursor, u"PageStyleName"_ustr);
uno::Reference<style::XStyle> pageStyle(
pageStyles->getByName(pageStyleName), uno::UNO_QUERY); bool headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr);
CPPUNIT_ASSERT(!headerIsOn);
// check that the second page has a header
xCursor->jumpToPage(2);
pageStyleName = getProperty<OUString>(xCursor, u"PageStyleName"_ustr);
pageStyle.set(
pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr);
CPPUNIT_ASSERT(headerIsOn);
// check that the third page has a header
xCursor->jumpToPage(3);
pageStyleName = getProperty<OUString>(xCursor, u"PageStyleName"_ustr);
pageStyle.set(
pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
headerIsOn = getProperty<bool>(pageStyle, u"HeaderIsOn"_ustr);
CPPUNIT_ASSERT(headerIsOn);
// check that the fourth page has no header // (#if'd out as this is not yet imported correctly) #if 0
xCursor->jumpToPage(4);
pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
pageStyle.set(
pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
CPPUNIT_ASSERT(!headerIsOn); #endif
}
DECLARE_WW8EXPORT_TEST(testFdp80333, "fdo80333.doc")
{ // Despite there is no character border, border shadow was imported
uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, u"CharShadowFormat"_ustr);
CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
}
DECLARE_WW8EXPORT_TEST(testFdo81102, "fdo81102.doc")
{ // get page style at beginning of document
uno::Reference<text::XTextDocument> textDocument(
mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextRange> start =
textDocument->getText()->getStart();
OUString pageStyleName = getProperty<OUString>(start, u"PageStyleName"_ustr);
uno::Reference<style::XStyle> pageStyle(
getStyles(u"PageStyles"_ustr)->getByName(pageStyleName), uno::UNO_QUERY);
// check that left and right pages do not share the same header bool headerIsShared = getProperty<bool>(pageStyle, u"HeaderIsShared"_ustr);
CPPUNIT_ASSERT(!headerIsShared);
}
DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc")
{ // The frame ended up on the second page instead of first. // this is on page 1 in Word
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/body/txt[4]/anchored", u"Kralicek UsacekV lese 3Zviratkov 47025");
// The frame is at the bottom of the text area, not at the bottom of the paper.
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(text::VertOrientation::BOTTOM,
getProperty<sal_Int16>(xShape, u"VertOrient"_ustr));
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA,
getProperty<sal_Int16>(xShape, u"VertOrientRelation"_ustr));
}
DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc")
{ // This must not hang in layout
}
#if HAVE_MORE_FONTS
DECLARE_WW8EXPORT_TEST(testfdo68963, "fdo68963.doc")
{ // The problem was that the text was not displayed.
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
CPPUNIT_ASSERT ( !getXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion", "expand").isEmpty() );
assertXPath(pXmlDoc, "/root/page/body/tab/row[2]/cell[1]/txt/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u"Topic 1"); // all crossreference bookmarks should have a target. Shouldn't be any "Reference source not found" in the xml
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getXPath(pXmlDoc, "/root/page/body/txt[24]/SwParaPortion/SwLineLayout/SwFieldPortion[2]","expand").indexOf("Reference source not found"));
} #endif
DECLARE_WW8EXPORT_TEST(testTdf99100, "tdf99100.doc")
{
uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderText"_ustr); auto xField = getProperty< uno::Reference<lang::XServiceInfo> >(getRun(getParagraphOfText(1, xHeaderText), 2), u"TextField"_ustr); // This failed: the second text portion wasn't a field.
CPPUNIT_ASSERT(xField.is());
CPPUNIT_ASSERT(xField->supportsService(u"com.sun.star.text.textfield.Chapter"_ustr));
}
DECLARE_WW8EXPORT_TEST(testTdf95576, "tdf95576.doc")
{ // The first three paragraphs in this document (which are headings) // should have zero indent and first line indent for (int nPara = 1; nPara <= 3; ++nPara) {
std::cout << "nPara = " << nPara << "\n"; auto xPara = getParagraph(nPara);
// get the numbering rules effective at this paragraph
uno::Reference<container::XIndexReplace> xNumRules =
getProperty< uno::Reference<container::XIndexReplace> >(
xPara, u"NumberingRules"_ustr);
// get the numbering level of this paragraph, and the properties // associated with that numbering level int numLevel = getProperty<sal_Int32>(xPara, u"NumberingLevel"_ustr);
uno::Sequence< beans::PropertyValue > aPropertyValues;
xNumRules->getByIndex(numLevel) >>= aPropertyValues;
// Now look through these properties for the indent and // first line indent settings
sal_Int32 nIndentAt = -1;
sal_Int32 nFirstLineIndent = -1; for(int j = 0 ; j< aPropertyValues.getLength() ; ++j)
{ auto aProp = aPropertyValues[j];
std::cout << "Prop.Name: " << aProp.Name << "\n"; if (aProp.Name == "FirstLineIndent") {
nFirstLineIndent = aProp.Value.get<sal_Int32>();
} elseif (aProp.Name == "IndentAt") {
nIndentAt = aProp.Value.get<sal_Int32>();
}
}
// The indent and first line indent should be zero
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndentAt);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nFirstLineIndent);
}
}
DECLARE_WW8EXPORT_TEST(testTdf59896, "tdf59896.doc")
{ // This was awt::FontWeight::NORMAL, i.e. the first run wasn't bold, when it should be bold
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), u"CharWeight"_ustr));
}
DECLARE_WW8EXPORT_TEST(testTdf102334, "tdf102334.doc")
{ // This was false, i.e. the first run wasn't hidden, when it should have been
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(7), 1), u"CharHidden"_ustr));
}
DECLARE_WW8EXPORT_TEST(testTdf128605, "tdf128605.doc")
{
OUString aPara1PageStyleName = getProperty<OUString>(getParagraph(1), u"PageStyleName"_ustr);
OUString aPara2PageStyleName = getProperty<OUString>(getParagraph(2), u"PageStyleName"_ustr); // Without the accompanying fix in place, this test would have failed with: // - Expected: Standard // - Actual : Convert 1 // i.e. the continuous section break resulted in an unwanted page break.
CPPUNIT_ASSERT_EQUAL(aPara1PageStyleName, aPara2PageStyleName);
}
// Without the accompanying fix in place, this test would have failed: auto-contour was enabled // in Writer, but not in Word.
CPPUNIT_ASSERT(!pFormat->GetSurround().IsContour());
}
DECLARE_WW8EXPORT_TEST(testTdf106291, "tdf106291.doc")
{ // Table cell was merged vertically instead of horizontally -> had incorrect dimensions
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString cellWidth = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/infos/bounds", "width");
OUString cellHeight = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/infos/bounds", "height");
CPPUNIT_ASSERT_EQUAL(sal_Int32(8650), cellWidth.toInt32());
CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font size
}
DECLARE_WW8EXPORT_TEST(testTransparentText, "transparent-text.doc")
{
uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderText"_ustr);
uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(3, xHeaderText); // Without the accompanying fix in place, this test would have failed: transparency was set to // 100%, so the text was not readable.
sal_Int32 nExpected(COL_BLACK);
sal_Int32 nActual(getProperty<sal_Int16>(xParagraph, u"CharTransparence"_ustr));
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
}
DECLARE_WW8EXPORT_TEST( testTdf105570, "tdf105570.doc" )
{ /***** * MS-DOC specification ( https://msdn.microsoft.com/en-us/library/cc313153 ) * ch. 2.6.3, sprmTTableHeader: * A Bool8 value that specifies that the current table row is a header row. * If the value is 0x01 but sprmTTableHeader is not applied with a value of 0x01 * for a previous row in the same table, then this property MUST be ignored. * * The document have three tables with three rows. * Table 1 has { 1, 0, 0 } values of the "repeat as header row" property for each row * Table 2 has { 1, 1, 0 } * Table 3 has { 0, 1, 1 }
****/
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwShellCursor* pShellCursor = pWrtShell->getShellCursor( false );
SwNodeIndex aIdx( pShellCursor->Start()->GetNode() );
// Find first table
SwTableNode* pTableNd = aIdx.GetNode().FindTableNode();
// Go to next table
aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); while ( nullptr == (pTableNd = aIdx.GetNode().GetTableNode()) ) ++aIdx;
// As first row hasn't sprmTTableHeader set, all following must be ignored, so no rows must be repeated
CPPUNIT_ASSERT_EQUAL( sal_uInt16(0), pTableNd->GetTable().GetRowsToRepeat() );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf112346)
{ auto verify = [this]() { // Multi-page table was imported as a single page.
CPPUNIT_ASSERT_EQUAL(2, getPages());
};
createSwDoc("tdf112346.doc");
verify();
saveAndReload(u"MS Word 97"_ustr);
verify();
}
DECLARE_WW8EXPORT_TEST(testTdf79639, "tdf79639.doc")
{ // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0 // as the floating table in the header wasn't converted to a TextFrame.
CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
DECLARE_WW8EXPORT_TEST(testTdf122425_2, "tdf122425_2.doc")
{ // This is for graphic objects in headers/footers
SwDoc* pDoc = getSwDoc();
SwPosFlyFrames aPosFlyFrames = pDoc->GetAllFlyFormats(nullptr, false); // There is one fly frame in the document: the text box
CPPUNIT_ASSERT_EQUAL(size_t(1), aPosFlyFrames.size()); for (const SwPosFlyFrame& rPosFlyFrame : aPosFlyFrames)
{ const SwFrameFormat& rFormat = rPosFlyFrame.GetFormat(); const SfxPoolItem* pItem = nullptr;
// Check for correct explicitly-set values of UL spacings. Previously this was "DEFAULT", // and resulted in inherited values (114 = 2 mm) used.
CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem)); auto pUL = static_cast<const SvxULSpaceItem*>(pItem);
CPPUNIT_ASSERT(pUL);
CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetUpper());
CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pUL->GetLower());
}
}
DECLARE_WW8EXPORT_TEST(testTdf130262, "tdf130262.doc")
{ // We had an infinite layout loop
}
DECLARE_WW8EXPORT_TEST(testN325936, "n325936.doc")
{ /* * The problem was that the transparent background of the drawing in the * header was exported as non-transparent. * * xray ThisComponent.DrawPage(0).BackColorTransparency
*/
CPPUNIT_ASSERT_EQUAL(Color(0x000064), getProperty< Color >(getShape(1), u"BackColorTransparency"_ustr));
}
DECLARE_WW8EXPORT_TEST(testTscp, "tscp.doc")
{
uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, u"urn:bails"_ustr);
uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY);
uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = xDocumentMetadataAccess->getMetadataGraphsWithType(xType); // This failed, no graphs had the urn:bails type.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aGraphNames.getLength());
uno::Reference<rdf::XURI> xGraphName = aGraphNames[0];
uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName);
// No RDF statement on the first paragraph.
uno::Reference<rdf::XResource> xParagraph(getParagraph(1), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements()));
// No RDF statement on the third paragraph.
xParagraph.set(getParagraph(3), uno::UNO_QUERY);
xStatements = xGraph->getStatements(xParagraph, uno::Reference<rdf::XURI>(), uno::Reference<rdf::XURI>());
CPPUNIT_ASSERT_EQUAL(false, static_cast<bool>(xStatements->hasMoreElements()));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo45724)
{
loadAndReload("fdo45724.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The text and background color of the control shape was not correct.
uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
uno::Reference<form::validation::XValidatableFormComponent> xComponent(xControlShape->getControl(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(xComponent, u"BackgroundColor"_ustr));
CPPUNIT_ASSERT_EQUAL(u"xxx"_ustr, xComponent->getCurrentValue().get<OUString>());
}
// Without the fix in place, this test would have failed with // - Expected: 5853 // - Actual : 850
CPPUNIT_ASSERT_EQUAL(sal_Int32(5853), xShape->getSize().Width);
}
CPPUNIT_TEST_FIXTURE(Test, testFdo46020)
{
loadAndReload("fdo46020.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The footnote in that document wasn't exported, check that it is actually exported
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
}
DECLARE_WW8EXPORT_TEST(test56513, "fdo56513.doc")
{
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()", u"This is the header of the first section");
assertXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()", u"This is the first page header of the second section");
assertXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()", u"This is the non-first-page header of the second section");
}
DECLARE_WW8EXPORT_TEST(testNewPageStylesTable, "new-page-styles.doc")
{
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/header/txt/text()", u"Sigma Space Performance Goals and Results (Page 1)*");
assertXPathContent(pXmlDoc, "/root/page[2]/header/txt/text()", u"Sigma Space Performance Assessment (Page 2)****");
assertXPathContent(pXmlDoc, "/root/page[3]/header/txt/text()", u"Sigma Space Performance Goals: Next Year (Page 3)*******");
}
CPPUNIT_TEST_FIXTURE(Test, testCharacterBorder)
{
loadAndReload("charborder.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages());
uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); // WW8 has just one border attribute (sprmCBrc) for text border so all side has // the same border // Border
{ const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,u"CharTopBorder"_ustr);
CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF3333,0,318,0,0,318), aTopBorder);
CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,u"CharLeftBorder"_ustr));
CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,u"CharBottomBorder"_ustr));
CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,u"CharRightBorder"_ustr));
}
// Padding (dptSpace) it is constant 0
{
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,u"CharTopBorderDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,u"CharLeftBorderDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,u"CharBottomBorderDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun,u"CharRightBorderDistance"_ustr));
}
// Shadow (fShadow) /* WW8 use just one bool value for shadow so the next conversions are made during an export-import round color: any -> black location: any -> bottom-right
width: any -> border width */
{ const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, u"CharShadowFormat"_ustr);
CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aShadow.Color));
CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
}
}
// tdf#147819 - page background should not be forced to white color const SwFrameFormat &rFormat = getSwDoc()->GetPageDesc(0).GetMaster();
CPPUNIT_ASSERT(!rFormat.GetItemIfSet(RES_BACKGROUND));
}
// Test commented text range which spans over more text nodes // Comment starts in the second paragraph
xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
xRunEnum = xRunEnumAccess->createEnumeration();
xRunEnum->nextElement();
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"Annotation"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr)); // Comment ends in the third paragraph
xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
xRunEnum = xRunEnumAccess->createEnumeration();
xRunEnum->nextElement();
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"AnnotationEnd"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testBorderColoursExport)
{
loadAndReload("bordercolours.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages()); // This is very close to testBorderColours in ww8import.cxx, but for export
// The following 6 colours can only be represented with WW9 (Word 2000) // BRC (BoRder Control) structures. We can tell that they have been // exported/imported using a WW8 (Word '97) BRC if they instead come // through as one of the 16 colours listed at this link: // http://msdn.microsoft.com/en-us/library/dd773060.aspx
table::BorderLine2 expectedTop(0xFA670C, 0, 53, 0, 1, 53);
table::BorderLine2 expectedLeft(0xD99594, 0, 79, 0, 0, 79);
table::BorderLine2 expectedRight(0xB2A1C7, 53, 53, 53, 3, 159);
table::BorderLine2 expectedBottom(0xB6DDE8, 0, 106, 0, 14, 106);
table::BorderLine2 expectedDashedRed(0xFA670C, 0, 53, 0, 2, 53);
table::BorderLine2 expectedDoubleGreen(0xC2D69B, 26, 106, 26, 4, 159);
// Table border
uno::Reference<text::XTextTablesSupplier> tablesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> tables =
tablesSupplier->getTextTables();
uno::Reference<text::XTextTable> table(
tables->getByName(u"Table1"_ustr), uno::UNO_QUERY);
table::TableBorder2 tableBorder = getProperty<table::TableBorder2>(
table, u"TableBorder2"_ustr);
CPPUNIT_ASSERT_EQUAL(expectedTop.Color, tableBorder.TopLine.Color);
CPPUNIT_ASSERT_EQUAL(expectedLeft.Color, tableBorder.LeftLine.Color);
CPPUNIT_ASSERT_EQUAL(expectedRight.Color, tableBorder.RightLine.Color); #if 0 // #if'd out because the "fine dashed" border line style for table borders // does not seem to save or load correctly in odt format at present
CPPUNIT_ASSERT_EQUAL(expectedBottom.Color, tableBorder.BottomLine.Color); #endif
// Table cells
uno::Reference<table::XCell> cell =
table->getCellByName(u"A2"_ustr);
border = getProperty<table::BorderLine2>(cell, u"TopBorder"_ustr);
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
border = getProperty<table::BorderLine2>(cell, u"LeftBorder"_ustr);
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border); #if 0 // #if'd out because the "fine dashed" border line style for table borders // does not seem to save or load correctly in odt format at present
border = getProperty<table::BorderLine2>(cell, "BottomBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border); #endif
// Picture border // (#if'd out as they are not yet exported with correct colours) #if 0
bookmark.set(bookmarks->getByName("PictureBorder"),uno::UNO_QUERY);
anchor = bookmark->getAnchor();
border = getProperty<table::BorderLine2>(anchor, "TopBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedTop, border);
border = getProperty<table::BorderLine2>(anchor, "LeftBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedLeft, border);
border = getProperty<table::BorderLine2>(anchor, "RightBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedRight, border);
border = getProperty<table::BorderLine2>(anchor, "BottomBorder");
CPPUNIT_ASSERT_BORDER_EQUAL(expectedBottom, border); #endif
}
CPPUNIT_TEST_FIXTURE(Test, testRedlineExport1)
{
loadAndReload("redline-export-1.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages());
uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); //there must be no redline information on the first line before and after reloading while (xRunEnum->hasMoreElements())
{
uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, hasProperty(xRun, u"RedlineType"_ustr));
}
}
CPPUNIT_TEST_FIXTURE(Test, testRedlineExport2)
{
loadAndReload("redline-export-2.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); //there must be redline information on the first portion of the third paragraph before and after reloading
CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(3), 1), u"RedlineType"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testRedlineExport3)
{
loadAndReload("redline-export-3.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); //there must be redline information just on the para-break boundary between para one and two
CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(1), 1), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(1), 2), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(true, hasProperty(getRun(getParagraph(2), 1), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(2), 2), u"RedlineType"_ustr));
}
DECLARE_WW8EXPORT_TEST(testCommentedTable, "commented-table.doc")
{ // Document has a non-trivial commented text range, as the range contains a table.
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
uno::Reference<text::XTextContent> xField(xFields->nextElement(), uno::UNO_QUERY); // After first import, there was an off-by-one during import, so this was "efore.\nA1\nB1\nAfte". (Notice the additional "e" prefix.) // After export and import, things got worse, this was "\nA1\nB1\nAfte".
CPPUNIT_ASSERT_EQUAL(u"fore." SAL_NEWLINE_STRING "A1" SAL_NEWLINE_STRING "B1" SAL_NEWLINE_STRING "Afte"_ustr, xField->getAnchor()->getString());
}
DECLARE_WW8EXPORT_TEST(testTextVerticalAdjustment, "tdf36117_verticalAdjustment.doc")
{ //Preserve the page vertical alignment setting for .doc
SwDoc* pDoc = getSwDoc();
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.