/* -*- 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
{ class Test : public SwModelTestBase
{ public:
Test() : SwModelTestBase(u"/sw/qa/extras/ooxmlimport/data/"_ustr, u"Office Open XML Text"_ustr)
{
}
};
CPPUNIT_TEST_FIXTURE(Test, testTdf103931)
{
createSwDoc("tdf103931.docx");
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // This was 2, the last (empty) section of the document was lost on import. // (import test only: Columns/Sections do not round-trip well)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTextSections->getCount());
}
CPPUNIT_TEST_FIXTURE(Test, testN751017)
{
createSwDoc("n751017.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters()); // Make sure we have a variable named foo.
CPPUNIT_ASSERT(xMasters->hasByName(u"com.sun.star.text.FieldMaster.SetExpression.foo"_ustr));
CPPUNIT_TEST_FIXTURE(Test, testN751077)
{
createSwDoc("n751077.docx"); /* xray ThisComponent.DrawPage(1).getByIndex(0).String
*/
uno::Reference<drawing::XShapes> xShapes(getShape(2), uno::UNO_QUERY); // The groupshape should be in the foreground, not the background.
CPPUNIT_ASSERT(getProperty<bool>(xShapes, u"Opaque"_ustr));
// test the textbox is on the first page (it was put onto another page without the fix) const xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "//page[1]//OutlinerParaObject[1]//text", u"TEXT1");
}
uno::Reference<text::XTextField> xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"DocInformation:Title (fixed)"_ustr, xEnumerationAccess3->getPresentation(true).trim());
CPPUNIT_ASSERT_EQUAL(u"MY PATNA IS BEST IN THE WORLD"_ustr, xEnumerationAccess3->getPresentation(false).trim());
// Without the fix in place, this test would have failed with // - Expected: RK - Risk / EH&S // - Actual : [Responsible Office]
uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"RK - Risk / EH&S"_ustr, xEnumerationAccess1->getPresentation(false).trim());
// Access the second run, which is a textfield
xRunEnum->nextElement();
uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); float fValue;
xRun->getPropertyValue(u"CharHeight"_ustr) >>= fValue; // This used to be 11, as character properties were ignored.
CPPUNIT_ASSERT_EQUAL(8.f, fValue);
}
CPPUNIT_TEST_FIXTURE(Test, testN764745)
{
createSwDoc("n764745-alignment.docx"); /* shape = ThisComponent.DrawPage.getByIndex(0) xray shape.AnchorType xray shape.AnchorPosition.X xray ThisComponent.StyleFamilies.PageStyles.Default.Width
*/
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); // The paragraph is right-aligned and the picture does not explicitly specify position, // so check it's anchored as character and in the right side of the document.
text::TextContentAnchorType anchorType;
xPropertySet->getPropertyValue(u"AnchorType"_ustr) >>= anchorType;
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, anchorType);
awt::Point pos;
xPropertySet->getPropertyValue(u"AnchorPosition"_ustr) >>= pos;
uno::Reference<style::XStyleFamiliesSupplier> styleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> styleFamilies = styleFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> pageStyles;
styleFamilies->getByName(u"PageStyles"_ustr) >>= pageStyles;
uno::Reference<uno::XInterface> defaultStyle;
pageStyles->getByName(u"Standard"_ustr) >>= defaultStyle;
uno::Reference<beans::XPropertySet> styleProperties( defaultStyle, uno::UNO_QUERY );
sal_Int32 width = 0;
styleProperties->getPropertyValue( u"Width"_ustr ) >>= width;
CPPUNIT_ASSERT( pos.X > width / 2 );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf115719b)
{
createSwDoc("tdf115719b.docx"); // This was 0, 4th (last) paragraph had no increased spacing.
CPPUNIT_ASSERT(getProperty<sal_Int32>(getParagraph(4), u"ParaTopMargin"_ustr) > 0);
}
CPPUNIT_TEST_FIXTURE(Test, testN766477)
{
createSwDoc("n766477.docx"); /* * The problem was that the checkbox was not checked. * * oParas = ThisComponent.Text.createEnumeration * oPara = oParas.nextElement * oRuns = oPara.createEnumeration * oRun = oRuns.nextElement * xray oRun.Bookmark.Parameters.ElementNames(0) 'Checkbox_Checked
*/
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xRunEnum(xRunEnumAccess->createEnumeration());
uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
uno::Reference<text::XFormField> xFormField(xRun->getPropertyValue(u"Bookmark"_ustr), uno::UNO_QUERY);
uno::Reference<container::XNameContainer> xParameters(xFormField->getParameters());
uno::Sequence<OUString> aElementNames(xParameters->getElementNames());
CPPUNIT_ASSERT_EQUAL(u"Checkbox_Checked"_ustr, aElementNames[0]);
}
//Without the fix in place, txtHeight would have been flyHeight + 55
CPPUNIT_ASSERT_EQUAL(flyHeight, txtHeight);
// Also check the bookmark portion is ignored in the next paragraph
OUString aTop = getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/prtBounds", "top");
CPPUNIT_ASSERT_EQUAL(u"240"_ustr, aTop);
}
CPPUNIT_TEST_FIXTURE(Test, testN758883)
{
createSwDoc("n758883.docx"); /* * The problem was that direct formatting of the paragraph was not applied * to the numbering. This is easier to test using a layout dump.
*/
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwFieldPortion[1]/SwFont", "height", u"220");
// hidden _Toc and _Ref bookmarks are not visible in Visible bookmarks mode // This was PortionType::Bookmark
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", u"PortionType::Text");
// insert a not hidden bookmark
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextRange> xTextRange = xTextDocument->getText();
uno::Reference<text::XText> xText = xTextRange->getText();
uno::Reference<text::XParagraphCursor> xCursor(xText->createTextCursor(), uno::UNO_QUERY);
uno::Reference<lang::XMultiServiceFactory> xFact(mxComponent, uno::UNO_QUERY); // creating bookmark "BookmarkTest"
uno::Reference<text::XTextContent> xBookmark(
xFact->createInstance(u"com.sun.star.text.Bookmark"_ustr), uno::UNO_QUERY);
uno::Reference<container::XNamed> xBookmarkName(xBookmark, uno::UNO_QUERY);
xBookmarkName->setName(u"BookmarkTest"_ustr); // moving cursor to the end of paragraph
xCursor->gotoEndOfParagraph(true); // inserting the bookmark in paragraph
xText->insertTextContent(xCursor, xBookmark, true);
pXmlDoc = parseLayoutDump();
// check the bookmark portions are of the expected height
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]", "type", u"PortionType::Bookmark");
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]", "height", u"253");
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]", "type", u"PortionType::Bookmark");
assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]", "height", u"253");
/* * Next problem was that the page margin contained the width of the page border as well. * * xray ThisComponent.StyleFamilies.PageStyles.Default.LeftMargin
*/
uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
sal_Int32 nValue = 0;
xPropertySet->getPropertyValue(u"LeftMargin"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(847), nValue);
// No assert for the 3rd problem: see the comment in the test doc.
/* * 4th problem: Wrap type of the textwrape was not 'through'. * * xray ThisComponent.DrawPage(0).Surround ' was 2, should be 1
*/
xPropertySet.set(getShape(1), uno::UNO_QUERY);
text::WrapTextMode eValue;
xPropertySet->getPropertyValue(u"Surround"_ustr) >>= eValue;
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, eValue);
/* * 5th problem: anchor type of the second textbox was wrong. * * xray ThisComponent.DrawPage(1).AnchorType ' was 1, should be 4
*/
xPropertySet.set(getShape(2), uno::UNO_QUERY);
text::TextContentAnchorType eAnchorType;
xPropertySet->getPropertyValue(u"AnchorType"_ustr) >>= eAnchorType;
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
// 6th problem: xray ThisComponent.DrawPage(2).AnchorType ' was 2, should be 4
xPropertySet.set(getShape(3), uno::UNO_QUERY);
xPropertySet->getPropertyValue(u"AnchorType"_ustr) >>= eAnchorType;
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf74367_MarginsZeroed)
{
createSwDoc("tdf74367_MarginsZeroed.docx"); // Do not import page borders with 'None' style, or else it will change the page margins.
uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
sal_Int32 nValue = 0;
xPropertySet->getPropertyValue(u"TopMargin"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
xPropertySet->getPropertyValue(u"RightMargin"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
xPropertySet->getPropertyValue(u"BottomMargin"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
xPropertySet->getPropertyValue(u"LeftMargin"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2501), nValue);
}
CPPUNIT_TEST_FIXTURE(Test, testN778140)
{
createSwDoc("n778140.docx"); /* * The problem was that the paragraph top/bottom margins were incorrect due * to unhandled w:doNotUseHTMLParagraphAutoSpacing.
*/
CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(1), u"ParaTopMargin"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(176), getProperty<sal_Int32>(getParagraph(1), u"ParaBottomMargin"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testInk)
{
createSwDoc("ink.docx"); /* * The problem was that ~nothing was imported, except an empty CustomShape. * * xray ThisComponent.DrawPage(0).supportsService("com.sun.star.drawing.OpenBezierShape")
*/
uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.drawing.OpenBezierShape"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testN779627)
{
createSwDoc("n779627.docx"); /* * The problem was that the table left position was based on the tableCellMar left value * even for nested tables, while it shouldn't.
*/
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Any aValue = xTableProperties->getPropertyValue(u"LeftMargin"_ustr);
sal_Int32 nLeftMargin;
aValue >>= nLeftMargin; // only border width considered.
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables",
sal_Int32(9), nLeftMargin);
/* * Another problem tested with this document is the loading of the shapes * anchored to a hidden header or footer
*/
CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
CPPUNIT_TEST_FIXTURE(Test, testN779627b)
{
createSwDoc("n779627b.docx"); /* * Another problem tested with the original n779627.docx document (before removing its unnecessary * shape loading) is that the roundrect is centered vertically and horizontally.
*/
uno::Reference<beans::XPropertySet> xShapeProperties( getShape(1), uno::UNO_QUERY );
uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xShapeProperties, uno::UNO_QUERY); // If this goes wrong, probably the index of the shape is changed and the test should be adjusted.
CPPUNIT_ASSERT_EQUAL(u"com.sun.star.drawing.RectangleShape"_ustr, xShapeDescriptor->getShapeType());
sal_Int16 nValue;
xShapeProperties->getPropertyValue(u"HoriOrient"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue);
xShapeProperties->getPropertyValue(u"HoriOrientRelation"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
xShapeProperties->getPropertyValue(u"VertOrient"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically", text::VertOrientation::CENTER, nValue);
xShapeProperties->getPropertyValue(u"VertOrientRelation"_ustr) >>= nValue;
CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically relatively to page", text::RelOrientation::PAGE_FRAME, nValue);
}
CPPUNIT_TEST_FIXTURE(Test, testN782061)
{
createSwDoc("n782061.docx"); /* * The problem was that the character escapement in the second run was -58.
*/
CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), u"CharEscapement"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testN780645)
{
createSwDoc("n780645.docx"); // The problem was that when the number of cells didn't match the grid, we // didn't take care of direct cell widths.
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<table::XTableRows> xTableRows = xTextTable->getRows();
CPPUNIT_ASSERT_EQUAL(sal_Int16(2135), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(1), u"TableColumnSeparators"_ustr)[0].Position); // was 1999
}
CPPUNIT_TEST_FIXTURE(Test, testWordArtResizing)
{
createSwDoc("WordArt.docx"); /* The Word-Arts and watermarks were getting resized automatically, It was as if they were getting glued to the fallback geometry(the sdrObj) and were getting bound to the font size.
The test-case ensures the original height and width of the word-art is not changed while importing*/
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_TEST_FIXTURE(Test, testGroupshapeChildRotation)
{
createSwDoc("groupshape-child-rotation.docx"); // The problem was that (due to incorrect handling of rotation inside // groupshapes), the first child wasn't in the top left corner of an inline // groupshape.
uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-5741), xShape->getPosition().Y);
#if HAVE_MORE_FONTS
xShape.set(xGroupShape->getByIndex(4), uno::UNO_QUERY); // This was true, a VML textbox without <v:textbox style="mso-fit-shape-to-text:t"> had // auto-grow on.
CPPUNIT_ASSERT(!getProperty<bool>(xShape, u"TextAutoGrowHeight"_ustr)); // Paragraph Style Normal should provide the font name - which slightly affects the shape's height (was 686)
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Font", u"Times New Roman"_ustr, getProperty<OUString>(getRun(xText, 1), u"CharFontName"_ustr)); #endif
uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroupShape->getByIndex(5), uno::UNO_QUERY); // This was com.sun.star.drawing.RectangleShape, all shape text in a single line.
CPPUNIT_ASSERT_EQUAL(u"com.sun.star.drawing.TextShape"_ustr, xShapeDescriptor->getShapeType());
}
CPPUNIT_TEST_FIXTURE(Test, testN820788)
{
createSwDoc("n820788.docx"); // The problem was that AutoSize was not enabled for the text frame.
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); // This was text::SizeType::FIX.
CPPUNIT_ASSERT_EQUAL(text::SizeType::MIN, getProperty<sal_Int16>(xFrame, u"SizeType"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testN820504)
{
createSwDoc("n820504.docx");
uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xFamiliesAccess = xFamiliesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xStylesAccess(xFamiliesAccess->getByName(u"ParagraphStyles"_ustr), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xStyle(xStylesAccess->getByName(u"Standard"_ustr), uno::UNO_QUERY); // The problem was that the CharColor was set to AUTO (-1) even if we have some default char color set
CPPUNIT_ASSERT_EQUAL(Color(0x3da7bb), getProperty<Color>(xStyle, u"CharColor"_ustr));
// Also, the groupshape was anchored at-page instead of at-character // (that's incorrect as Word only supports at-character and as-character).
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), u"AnchorType"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo43641)
{
createSwDoc("fdo43641.docx");
uno::Reference<container::XIndexAccess> xGroupLockedCanvas(getShape(1), uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xGroupShape(xGroupLockedCanvas->getByIndex(0), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xLine(xGroupShape->getByIndex(1), uno::UNO_QUERY); // This was 2200, not 2579 in mm100, i.e. the size of the line shape was incorrect. // File cx=928694EMU = 2579.7Hmm, round up 2580Hmm. Currently off by 1.
CPPUNIT_ASSERT_EQUAL(sal_Int32(2581), xLine->getSize().Width);
}
CPPUNIT_TEST_FIXTURE(Test, testGroupshapeSdt)
{
createSwDoc("groupshape-sdt.docx"); // All problems here are due to the groupshape: we have a drawinglayer rectangle, not a writer textframe.
uno::Reference<drawing::XShapes> xOuterGroupShape(getShape(1), uno::UNO_QUERY);
uno::Reference<drawing::XShapes> xInnerGroupShape(xOuterGroupShape->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xShape(xInnerGroupShape->getByIndex(0), uno::UNO_QUERY); // Border distances were not implemented, this was 0.
CPPUNIT_ASSERT_EQUAL(sal_Int32(1905), getProperty<sal_Int32>(xShape, u"TextUpperDistance"_ustr)); // Sdt field result wasn't imported, this was "".
CPPUNIT_ASSERT_EQUAL(u"placeholder text"_ustr, xShape->getString()); // w:spacing was ignored in oox, this was 0.
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xShape->getText()), 1), u"CharKerning"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testBnc779620)
{
createSwDoc("bnc779620.docx"); // The problem was that the floating table was imported as a non-floating one.
lcl_countTextFrames( mxComponent, 1 );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf105127)
{
createSwDoc("tdf105127.docx"); auto aPolyPolygon = getProperty<drawing::PolyPolygonBezierCoords>(getShape(1), u"PolyPolygonBezier"_ustr); // tdf#106792 These values were wrong all the time due to a missing // conversion in SvxShapePolyPolygon::getPropertyValueImpl. There was no // ForceMetricTo100th_mm -> the old results were in twips due to the // object residing in Writer. The UNO API by definition is in 100thmm, // thus I will correct the value here.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5719), aPolyPolygon.Coordinates[0][0].Y); // was: 3257
}
CPPUNIT_TEST_FIXTURE(Test, testTdf105143)
{
createSwDoc("tdf105143.docx");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString aTop = getXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top"); // This was 6272, i.e. the shape was moved up (incorrect position) to be // inside the page rectangle.
CPPUNIT_ASSERT_EQUAL(u"6731"_ustr, aTop);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf105975)
{
createSwDoc("105975.docx");
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters()); // Make sure we have a variable named TEST_VAR.
CPPUNIT_ASSERT(xMasters->hasByName(u"com.sun.star.text.FieldMaster.SetExpression.TEST_VAR"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testfdo76583)
{
createSwDoc("fdo76583.docx"); // The problem was that the floating table was imported as a non-floating one. // floating tables are imported as text frames, therefore the document should // exactly 1 text frame.
lcl_countTextFrames( mxComponent, 1 );
}
CPPUNIT_TEST_FIXTURE(Test, testTdf105975formula)
{
createSwDoc("tdf105975.docx"); // Make sure the field contains a formula with 10 + 15
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_TEST_FIXTURE(Test, testTdf133647)
{
createSwDoc("tdf133647.docx"); /* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_TEST_FIXTURE(Test, testTdf123386)
{
createSwDoc("tdf123386.docx"); /* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
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::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u" L 2"_ustr, xEnumerationAccess1->getPresentation(true).trim());
CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xEnumerationAccess1->getPresentation(false).trim());
/* Ensures non-cell references passed to DEFINED() are preserved.
* Doesn't test the display string because LO doesn't support DEFINED(). */
uno::Reference<text::XTextField> xEnumerationAccess10(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"((1) AND (DEFINED(ABC1)))"_ustr, xEnumerationAccess10->getPresentation(true).trim());
uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u" G 1"_ustr, xEnumerationAccess2->getPresentation(true).trim());
CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xEnumerationAccess2->getPresentation(false).trim());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf133647_unicode)
{
createSwDoc("tdf133647_unicode.docx"); /* Tests that non-ASCII characters in formulas are preserved when importing from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_TEST_FIXTURE(Test, testTdf123389)
{
createSwDoc("tdf123389.docx"); /* Tests that argument lists, cell references, and cell ranges are translated correctly
* when importing table formulae from MS Word */
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_TEST_FIXTURE(Test, testTdf107784)
{
createSwDoc("tdf107784.docx"); // Make sure the field displays the citation's title and not the identifier
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_TEST_FIXTURE(Test, testTdf115883)
{
createSwDoc("tdf115883.docx"); // Import failed due to an unhandled exception when getting the Surround // property of a not yet inserted frame.
}
CPPUNIT_TEST_FIXTURE(Test, testTdf75573)
{
createSwDoc("tdf75573_page1frame.docx"); // the problem was that the frame was discarded // when an unrelated, unused, odd-header was flagged as discardable
lcl_countTextFrames( mxComponent, 1 );
// the frame should be on page 1
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPathContent(pXmlDoc, "/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()", u"lorem ipsum");
// the "Proprietary" style should set the vertical and horizontal anchors to the page
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xPropertySet, u"VertOrientRelation"_ustr));
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xPropertySet, u"HoriOrientRelation"_ustr));
// the frame should be located near the bottom[23186]/center[2955] of the page
CPPUNIT_ASSERT(sal_Int32(20000) < getProperty<sal_Int32>(xPropertySet, u"VertOrientPosition"_ustr));
CPPUNIT_ASSERT(sal_Int32(2500) < getProperty<sal_Int32>(xPropertySet, u"HoriOrientPosition"_ustr));
CPPUNIT_TEST_FIXTURE(Test, lineWpsOnly)
{
createSwDoc("line-wps-only.docx");
uno::Reference<drawing::XShape> xShape = getShape(1); // Check position, it was -7223 as it was set after the CustomShapeGeometry property.
CPPUNIT_ASSERT_EQUAL(sal_Int32(210), xShape->getPosition().X);
}
CPPUNIT_TEST_FIXTURE(Test, lineRotation)
{
createSwDoc("line-rotation.docx");
uno::Reference<drawing::XShape> xShape = getShape(3); // This was 5096: the line was shifted towards the bottom, so the end of // the 3 different lines wasn't at the same point.
CPPUNIT_ASSERT_EQUAL(sal_Int32(4808), xShape->getPosition().Y);
}
// Position was the default (hori center, vert top) for the textbox.
xFrame.set(getShape(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2173), getProperty<sal_Int32>(xFrame, u"HoriOrientPosition"_ustr)); #ifdef MACOSX // FIXME: The assert below fails wildly on a Retina display
NSScreen* nsScreen = [ NSScreen mainScreen ];
CGFloat scaleFactor = [ nsScreen backingScaleFactor ]; // for instance on the 5K Retina iMac, // [NSScreen mainScreen].frame.size is 2560x1440, // while real display size is 5120x2880 if ( nsScreen.frame.size.width * scaleFactor > 4000 ) return; #endif
CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty<sal_Int32>(xFrame, u"VertOrientPosition"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testGroupshapeRelsize)
{
createSwDoc("groupshape-relsize.docx"); // This was 43760, i.e. the height of the groupshape was larger than the page height, which is obviously incorrect.
CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(9142730), getShape(1)->getSize().Height);
}
CPPUNIT_TEST_FIXTURE(Test, testOleAnchor)
{
createSwDoc("ole-anchor.docx"); // This was AS_CHARACTER, even if the VML style explicitly contains "position:absolute".
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), u"AnchorType"_ustr)); // This was DYNAMIC, even if the default is THROUGH and there is no w10:wrap element in the bugdoc.
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGH, getProperty<text::WrapTextMode>(getShape(1), u"Surround"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf48658_transparentOLEheader)
{
createSwDoc("tdf48658_transparentOLEheader.docx"); // The problem was that the shape in the header was hidden in the background. // The round-tripped document was always fine (even before the fix) but the shape numbers change, so import-only test.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), u"Opaque"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testDMLGroupShapeParaAdjust)
{
createSwDoc("dml-groupshape-paraadjust.docx"); // Paragraph adjustment inside a group shape was not imported
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); // 2nd line is adjusted to the right
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), u"ParaAdjust"_ustr)); // 3rd line has no adjustment
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), u"ParaAdjust"_ustr)); // 4th line is adjusted to center
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getRun(getParagraphOfText(4, xText), 1), u"ParaAdjust"_ustr)); // 5th line has no adjustment
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), u"ParaAdjust"_ustr)); // 6th line is justified
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_BLOCK), getProperty<sal_Int16>(getRun(getParagraphOfText(6, xText), 1), u"ParaAdjust"_ustr)); // 7th line has no adjustment
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), u"ParaAdjust"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf99135)
{
createSwDoc("tdf99135.docx"); // This was 0, crop was ignored on VML import.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1825), getProperty<text::GraphicCrop>(getShape(1), u"GraphicCrop"_ustr).Bottom);
}
CPPUNIT_TEST_FIXTURE(Test, testTdf85523)
{
createSwDoc("tdf85523.docx"); auto xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 7), u"TextField"_ustr); auto xText = getProperty< uno::Reference<text::XText> >(xTextField, u"TextRange"_ustr); // This was "commentX": an unexpected extra char was added at the comment end.
getParagraphOfText(1, xText, u"comment"_ustr);
}
// a slight difference regarding vml file is tolerated due to rounding errors
CPPUNIT_ASSERT_EQUAL(sal_Int32(3720), aPos.X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-397), aPos.Y);
CPPUNIT_ASSERT_EQUAL(sal_Int32(5457), aSize.Width);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3447), aSize.Height);
CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot);
}
CPPUNIT_TEST_FIXTURE(Test, testUnbalancedColumnsCompat)
{
createSwDoc("unbalanced-columns-compat.docx");
uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), u"DontBalanceTextColumns"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testFloatingTableSectionColumns)
{
createSwDoc("floating-table-section-columns.docx");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
OUString tableWidth = getXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width"); // table width was restricted by a column
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
}
CPPUNIT_TEST_FIXTURE(Test, testBnc821804)
{
createSwDoc("bnc821804.docx");
CPPUNIT_ASSERT_EQUAL( u"TITLE"_ustr, getRun( getParagraph( 1 ), 1 )->getString());
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(1), 1), u"RedlineType"_ustr)); // Redline information (SwXRedlinePortion) are separate "runs" apparently.
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 2), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(u"Insert"_ustr,getProperty<OUString>(getRun(getParagraph(1), 2), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(1), 2), u"IsStart"_ustr));
CPPUNIT_ASSERT_EQUAL(u"unknown1"_ustr,getProperty<OUString>(getRun(getParagraph(1), 2), u"RedlineAuthor"_ustr));
CPPUNIT_ASSERT_EQUAL("2006-08-29T09:46:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 2), u"RedlineDateTime"_ustr))); // So only the 3rd run is actual text (and the two runs have been merged into one, not sure why, but that shouldn't be a problem).
CPPUNIT_ASSERT_EQUAL(u" (1st run of an insert) (2nd run of an insert)"_ustr, getRun(getParagraph(1),3)->getString());
CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(1), 3), u"RedlineType"_ustr)); // And the end SwXRedlinePortion of the redline.
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(u"Insert"_ustr,getProperty<OUString>(getRun(getParagraph(1), 4), u"RedlineType"_ustr));
CPPUNIT_ASSERT_EQUAL(u"unknown1"_ustr,getProperty<OUString>(getRun(getParagraph(1), 4), u"RedlineAuthor"_ustr));
CPPUNIT_ASSERT_EQUAL("2006-08-29T09:46:00Z"_ostr,dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 4), u"RedlineDateTime"_ustr)));
CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(1), 4), u"IsStart"_ustr));
// This is both inserted and formatted, so there are two SwXRedlinePortion "runs". Given that the redlines overlap and Writer core
--> --------------------
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.