/* * 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/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class Test : public SwModelTestBase { public: Test() : SwModelTestBase("/sw/qa/extras/rtfimport/data/", "Rich Text Format") { } virtual void preTest(const char* filename) SAL_OVERRIDE { m_aSavedSettings = Application::GetSettings(); if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf") { AllSettings aSettings(m_aSavedSettings); aSettings.SetLanguageTag(LanguageTag("ru")); Application::SetSettings(aSettings); } else if (OString(filename) == "fdo44211.rtf") { AllSettings aSettings(m_aSavedSettings); aSettings.SetLanguageTag(LanguageTag("lt")); Application::SetSettings(aSettings); } } virtual void postTest(const char* filename) SAL_OVERRIDE { if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf" || OString(filename) == "fdo44211.rtf") Application::SetSettings(m_aSavedSettings); } protected: /// Copy&paste helper. #if !defined MACOSX && !defined WNT void paste(const OUString& aFilename, uno::Reference xTextRange = uno::Reference()) { uno::Reference xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW); uno::Reference xImporter(xFilter, uno::UNO_QUERY_THROW); xImporter->setTargetDocument(mxComponent); uno::Sequence aDescriptor(xTextRange.is() ? 3 : 2); aDescriptor[0].Name = "InputStream"; SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename, STREAM_WRITE); uno::Reference xStream(new utl::OStreamWrapper(*pStream)); aDescriptor[0].Value <<= xStream; aDescriptor[1].Name = "InsertMode"; aDescriptor[1].Value <<= sal_True; if (xTextRange.is()) { aDescriptor[2].Name = "TextInsertModeRange"; aDescriptor[2].Value <<= xTextRange; } xFilter->filter(aDescriptor); } #endif AllSettings m_aSavedSettings; }; #define DECLARE_RTFIMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, Test) #if !defined(MACOSX) && !defined(WNT) DECLARE_RTFIMPORT_TEST(testFdo45553, "fdo45553.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); while (xParaEnum->hasMoreElements()) { uno::Reference xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference xRangeEnum = xRangeEnumAccess->createEnumeration(); while (xRangeEnum->hasMoreElements()) { uno::Reference xRange(xRangeEnum->nextElement(), uno::UNO_QUERY); OUString aStr = xRange->getString(); if (aStr == "space-before") CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(120)), getProperty(xRange, "ParaTopMargin")); else if (aStr == "space-after") CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(240)), getProperty(xRange, "ParaBottomMargin")); } } } DECLARE_RTFIMPORT_TEST(testN192129, "n192129.rtf") { // We expect that the result will be 16x16px. Size aExpectedSize(16, 16); MapMode aMap(MAP_100TH_MM); aExpectedSize = Application::GetDefaultDevice()->PixelToLogic(aExpectedSize, aMap); uno::Reference xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY); uno::Reference xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY); awt::Size aActualSize(xShape->getSize()); CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width); CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Height()), aActualSize.Height); } DECLARE_RTFIMPORT_TEST(testFdo45543, "fdo45543.rtf") { CPPUNIT_ASSERT_EQUAL(5, getLength()); } DECLARE_RTFIMPORT_TEST(testN695479, "n695479.rtf") { uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); uno::Reference xPropertySet(xIndexAccess->getByIndex(0), uno::UNO_QUERY); // Negative ABSH should mean fixed size. CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty(xPropertySet, "SizeType")); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(300)), getProperty(xPropertySet, "Height")); uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); bool bFrameFound = false, bDrawFound = false; for (int i = 0; i < xDraws->getCount(); ++i) { uno::Reference xServiceInfo(xDraws->getByIndex(i), uno::UNO_QUERY); if (xServiceInfo->supportsService("com.sun.star.text.TextFrame")) { // Both frames should be anchored to the first paragraph. bFrameFound = true; uno::Reference xTextContent(xServiceInfo, uno::UNO_QUERY); uno::Reference xRange(xTextContent->getAnchor(), uno::UNO_QUERY); uno::Reference xText(xRange->getText(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("plain"), xText->getString()); if (i == 0) // Additionally, the frist frame should have double border at the bottom. CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::DOUBLE, getProperty(xPropertySet, "BottomBorder").LineStyle); } else if (xServiceInfo->supportsService("com.sun.star.drawing.LineShape")) { // The older "drawing objects" syntax should be recognized. bDrawFound = true; xPropertySet.set(xServiceInfo, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty(xPropertySet, "HoriOrientRelation")); CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(xPropertySet, "VertOrientRelation")); } } CPPUNIT_ASSERT(bFrameFound); CPPUNIT_ASSERT(bDrawFound); } DECLARE_RTFIMPORT_TEST(testFdo42465, "fdo42465.rtf") { CPPUNIT_ASSERT_EQUAL(3, getLength()); } DECLARE_RTFIMPORT_TEST(testFdo45187, "fdo45187.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // There should be two shapes. CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); // They should be anchored to different paragraphs. uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xTextRangeCompare(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xAnchor0 = uno::Reference(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor(); uno::Reference xAnchor1 = uno::Reference(xDraws->getByIndex(1), uno::UNO_QUERY)->getAnchor(); // Was 0 ("starts at the same position"), should be 1 ("starts before") CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1)); } DECLARE_RTFIMPORT_TEST(testFdo46662, "fdo46662.rtf") { uno::Reference xPropertySet(getStyles("NumberingStyles")->getByName("WWNum3"), uno::UNO_QUERY); uno::Reference xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence aProps; xLevels->getByIndex(1) >>= aProps; // 2nd level for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "ParentNumbering") CPPUNIT_ASSERT_EQUAL(sal_Int16(2), rProp.Value.get()); else if (rProp.Name == "Suffix") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get().getLength()); } } DECLARE_RTFIMPORT_TEST(testN750757, "n750757.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty(xParaEnum->nextElement(), "ParaContextMargin")); CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty(xParaEnum->nextElement(), "ParaContextMargin")); } DECLARE_RTFIMPORT_TEST(testFdo45563, "fdo45563.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); int i = 0; while (xParaEnum->hasMoreElements()) { xParaEnum->nextElement(); i++; } CPPUNIT_ASSERT_EQUAL(4, i); } DECLARE_RTFIMPORT_TEST(testFdo43965, "fdo43965.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); // First paragraph: the parameter of \up was ignored uno::Reference xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference xRangeEnum = xRangeEnumAccess->createEnumeration(); uno::Reference xPropertySet(xRangeEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(36), getProperty(xPropertySet, "CharEscapement")); CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty(xPropertySet, "CharEscapementHeight")); // Second paragraph: Word vs Writer border default problem CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty(xParaEnum->nextElement(), "TopBorder").LineWidth); // Finally, make sure that we have two pages CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testN751020, "n751020.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(200)), getProperty(xParaEnum->nextElement(), "ParaBottomMargin")); } DECLARE_RTFIMPORT_TEST(testFdo79384, "fdo79384.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); CPPUNIT_ASSERT_EQUAL(OUString("Маркеры спискамЫ", 31, RTL_TEXTENCODING_UTF8), xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo47326, "fdo47326.rtf") { // This was 15 only, as \super buffered text, then the contents of it got lost. CPPUNIT_ASSERT_EQUAL(19, getLength()); } DECLARE_RTFIMPORT_TEST(testFdo47036, "fdo47036.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); int nAtCharacter = 0; for (int i = 0; i < xDraws->getCount(); ++i) { if (getProperty(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AT_CHARACTER) nAtCharacter++; } // The image at the document start was ignored. CPPUNIT_ASSERT_EQUAL(1, nAtCharacter); // There should be 2 textboxes, not 4 uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo46955, "fdo46955.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); while (xParaEnum->hasMoreElements()) { uno::Reference xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); uno::Reference xRangeEnum = xRangeEnumAccess->createEnumeration(); while (xRangeEnum->hasMoreElements()) CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty(xRangeEnum->nextElement(), "CharCaseMap")); } } DECLARE_RTFIMPORT_TEST(testFdo81892, "fdo81892.rtf") { // table was not centered uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty(xTable, "HoriOrient")); // fdo#81893: paragraph with \page was not centered uno::Reference xPara(getParagraph(2, "Performance")); CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast(getProperty(xPara, "ParaAdjust"))); } DECLARE_RTFIMPORT_TEST(testFdo45394, "fdo45394.rtf") { uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); OUString aActual = xHeaderText->getString(); // Encoding in the header was wrong. OUString aExpected("\xd0\x9f\xd0\x9a \xd0\xa0\xd0\x98\xd0\x9a", 11, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo48104, "fdo48104.rtf") { CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo47107, "fdo47107.rtf") { uno::Reference xNumberingStyles(getStyles("NumberingStyles")); // Make sure numbered and bullet legacy syntax is recognized, this used to throw a NoSuchElementException xNumberingStyles->getByName("WWNum1"); xNumberingStyles->getByName("WWNum2"); } DECLARE_RTFIMPORT_TEST(testFdo45182, "fdo45182.rtf") { uno::Reference xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); uno::Reference xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY); // Encoding in the footnote was wrong. OUString aExpected("\xc5\xbeivnost\xc3\xad\n", 11, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo44176, "fdo44176.rtf") { uno::Reference xPageStyles(getStyles("PageStyles")); uno::Reference xFirstPage(xPageStyles->getByName("First Page"), uno::UNO_QUERY); uno::Reference xDefault(xPageStyles->getByName(DEFAULT_STYLE), uno::UNO_QUERY); sal_Int32 nFirstTop = 0, nDefaultTop = 0, nDefaultHeader = 0; xFirstPage->getPropertyValue("TopMargin") >>= nFirstTop; xDefault->getPropertyValue("TopMargin") >>= nDefaultTop; xDefault->getPropertyValue("HeaderHeight") >>= nDefaultHeader; CPPUNIT_ASSERT_EQUAL(nFirstTop, nDefaultTop + nDefaultHeader); } DECLARE_RTFIMPORT_TEST(testFdo39053, "fdo39053.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); int nAsCharacter = 0; for (int i = 0; i < xDraws->getCount(); ++i) if (getProperty(xDraws->getByIndex(i), "AnchorType") == text::TextContentAnchorType_AS_CHARACTER) nAsCharacter++; // The image in binary format was ignored. CPPUNIT_ASSERT_EQUAL(1, nAsCharacter); } DECLARE_RTFIMPORT_TEST(testFdo48356, "fdo48356.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); int i = 0; while (xParaEnum->hasMoreElements()) { xParaEnum->nextElement(); i++; } // The document used to be imported as two paragraphs. CPPUNIT_ASSERT_EQUAL(1, i); } DECLARE_RTFIMPORT_TEST(testFdo48023, "fdo48023.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); // Implicit encoding detection based on locale was missing OUString aExpected("\xd0\x9f\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x81\xd1\x82", 22, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo48876, "fdo48876.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, getProperty(xParaEnum->nextElement(), "ParaLineSpacing").Mode); } DECLARE_RTFIMPORT_TEST(testFdo48193, "fdo48193.rtf") { CPPUNIT_ASSERT_EQUAL(7, getLength()); } DECLARE_RTFIMPORT_TEST(testFdo44211, "fdo44211.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); OUString aExpected("\xc4\x85\xc4\x8d\xc4\x99", 6, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo48037, "fdo48037.rtf") { uno::Reference xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW); lang::Locale aUSLocale, aFRLocale; aUSLocale.Language = "en"; aFRLocale.Language = "fr"; sal_Int32 nExpected = xNumberSupplier->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale, aFRLocale); uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference xFields(xFieldsAccess->createEnumeration()); uno::Reference xPropertySet(xFields->nextElement(), uno::UNO_QUERY); sal_Int32 nActual = 0; xPropertySet->getPropertyValue("NumberFormat") >>= nActual; CPPUNIT_ASSERT_EQUAL(nExpected, nActual); } DECLARE_RTFIMPORT_TEST(testFdo85812, "fdo85812.rtf") { lang::Locale locale(getProperty( getRun(getParagraph(1), 1, "This "), "CharLocale")); // the \lang inside the group was applied to CJK not Western CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); // further testing indicates that Word is doing really weird stuff // \loch \hich \dbch is reset by opening a group locale = getProperty( getRun(getParagraph(2), 1, "CharGroup"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale.Country); locale = getProperty( getRun(getParagraph(2), 2, "AfterChar"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(3), 2, "AfterBookmark"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(4), 1, "CharGroup"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("ru"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("RU"), locale.Country); locale = getProperty( getRun(getParagraph(4), 1, "CharGroup"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country); locale = getProperty( getRun(getParagraph(4), 2, "AfterChar"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(4), 2, "AfterChar"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country); locale = getProperty( getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(5), 2, "AfterBookmark"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country); // \ltrch \rtlch works differently - it is sticky across groups locale = getProperty( getRun(getParagraph(6), 1, "CharGroup"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(6), 1, "CharGroup"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("DZ"), locale.Country); locale = getProperty( getRun(getParagraph(6), 2, "AfterChar"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(6), 2, "AfterChar"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale.Country); locale = getProperty( getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocale"); CPPUNIT_ASSERT_EQUAL(OUString("en"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("US"), locale.Country); locale = getProperty( getRun(getParagraph(7), 2, "AfterBookmark"), "CharLocaleComplex"); CPPUNIT_ASSERT_EQUAL(OUString("ar"), locale.Language); CPPUNIT_ASSERT_EQUAL(OUString("EG"), locale.Country); } DECLARE_RTFIMPORT_TEST(testFdo47764, "fdo47764.rtf") { // \cbpat with zero argument should mean the auto (-1) color, not a default color (black) CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(getParagraph(1), "ParaBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo38786, "fdo38786.rtf") { uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference xFields(xFieldsAccess->createEnumeration()); // \chpgn was ignored, so exception was thrown xFields->nextElement(); } DECLARE_RTFIMPORT_TEST(testN757651, "n757651.rtf") { // The bug was that due to buggy layout the text expanded to two pages. if (Application::GetDefaultDevice()->IsFontAvailable(OUString("Times New Roman"))) CPPUNIT_ASSERT_EQUAL(1, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo49501, "fdo49501.rtf") { uno::Reference xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_True, getProperty(xStyle, "IsLandscape")); sal_Int32 nExpected(convertTwipToMm100(567)); CPPUNIT_ASSERT_EQUAL(nExpected, getProperty(xStyle, "LeftMargin")); CPPUNIT_ASSERT_EQUAL(nExpected, getProperty(xStyle, "RightMargin")); CPPUNIT_ASSERT_EQUAL(nExpected, getProperty(xStyle, "TopMargin")); CPPUNIT_ASSERT_EQUAL(nExpected, getProperty(xStyle, "BottomMargin")); } DECLARE_RTFIMPORT_TEST(testFdo49271, "fdo49271.rtf") { CPPUNIT_ASSERT_EQUAL(25.f, getProperty(getParagraph(2), "CharHeight")); } DECLARE_RTFIMPORT_TEST(testFdo49692, "fdo49692.rtf") { uno::Reference xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); uno::Reference xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence aProps; xLevels->getByIndex(0) >>= aProps; // 1st level for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "Suffix") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get().getLength()); } } DECLARE_RTFIMPORT_TEST(testFdo45190, "fdo45190.rtf") { // inherited \fi should be reset CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(getParagraph(1), "ParaFirstLineIndent")); // but direct one not CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-100)), getProperty(getParagraph(2), "ParaFirstLineIndent")); } DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf") { // \chcbpat with zero argument should mean the auto (-1) color, not a default color (black) CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(getRun(getParagraph(1), 1), "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo79599, "fdo79599.rtf") { // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) // ignore \highlight0 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(getRun(getParagraph(1), 1), "CharBackColor")); // test \highlight2 = yellow CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty(getRun(getParagraph(2), 1), "CharBackColor")); // test \highlight3 = green CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty(getRun(getParagraph(3), 1), "CharBackColor")); // test \highlight4 = cyan CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty(getRun(getParagraph(4), 1), "CharBackColor")); // test \highlight5 = magenta CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty(getRun(getParagraph(5), 1), "CharBackColor")); // test \highlight6 = blue CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty(getRun(getParagraph(6), 1), "CharBackColor")); // test \highlight7 = red CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty(getRun(getParagraph(7), 1), "CharBackColor")); // test \highlight8 = dark blue CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty(getRun(getParagraph(8), 1), "CharBackColor")); // test \highlight9 = dark cyan CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty(getRun(getParagraph(9), 1), "CharBackColor")); // test \highlight10 = dark green CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty(getRun(getParagraph(10), 1), "CharBackColor")); // test \highlight11 = dark magenta CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty(getRun(getParagraph(11), 1), "CharBackColor")); // test \highlight12 = dark red CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty(getRun(getParagraph(12), 1), "CharBackColor")); // test \highlight13 = dark yellow CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty(getRun(getParagraph(13), 1), "CharBackColor")); // test \highlight14 = dark gray CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty(getRun(getParagraph(14), 1), "CharBackColor")); // test \highlight15 = light gray CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty(getRun(getParagraph(15), 1), "CharBackColor")); // test \highlight1 = black CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty(getRun(getParagraph(16), 1), "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf") { // Access the second run, which is a textfield uno::Reference xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY); // This used to be the default, as character properties were ignored. CPPUNIT_ASSERT_EQUAL(OUString("Book Antiqua"), getProperty(xRun, "CharFontName")); } DECLARE_RTFIMPORT_TEST(testFdo49659, "fdo49659.rtf") { // Both tables were ignored: 1) was in the header, 2) was ignored due to missing empty par at the end of the doc uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); // The graphic was also empty uno::Reference xGraphic(getProperty< uno::Reference >(getShape(1), "Graphic"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(graphic::GraphicType::PIXEL, getProperty(xGraphic, "GraphicType")); } DECLARE_RTFIMPORT_TEST(testFdo46966, "fdo46966.rtf") { /* * The problem was the top margin was 1440 (1 inch), but it should be 720 (0.5 inch). * * xray ThisComponent.StyleFamilies.PageStyles.Default.TopMargin */ uno::Reference xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(720)), getProperty(xPropertySet, "TopMargin")); } DECLARE_RTFIMPORT_TEST(testFdo52066, "fdo52066.rtf") { /* * The problem was that the height of the shape was too big. * * xray ThisComponent.DrawPage(0).Size.Height */ uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(19)), xShape->getSize().Height); } DECLARE_RTFIMPORT_TEST(testFdo76633, "fdo76633.rtf") { // check that there is only a graphic object, not an additional rectangle uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT(xShape.is()); CPPUNIT_ASSERT(xShape->supportsService("com.sun.star.text.TextGraphicObject")); try { uno::Reference xShape2(getShape(2), uno::UNO_QUERY); CPPUNIT_FAIL("exception expected"); } catch (lang::IndexOutOfBoundsException const&) { /* expected */ } } DECLARE_RTFIMPORT_TEST(testFdo48033, "fdo48033.rtf") { /* * The problem was that the picture (48033) or OLE object (53594) was in the first cell, * instead of the second one. * * oTable = ThisComponent.TextTables(0) * oParas = oTable.getCellByName("B1").Text.createEnumeration * oPara = oParas.nextElement * oRuns = oPara.createEnumeration * oRun = oRuns.nextElement * xray oRun.TextPortionType ' Frame, was Text */ uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); uno::Reference xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty(getRun(xPara, 1), "TextPortionType")); } DECLARE_RTFIMPORT_TEST(testFdo53594, "fdo53594.rtf") { /* * The problem was that the picture (48033) or OLE object (53594) was in the first cell, * instead of the second one. * * oTable = ThisComponent.TextTables(0) * oParas = oTable.getCellByName("B1").Text.createEnumeration * oPara = oParas.nextElement * oRuns = oPara.createEnumeration * oRun = oRuns.nextElement * xray oRun.TextPortionType ' Frame, was Text */ uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); uno::Reference xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty(getRun(xPara, 1), "TextPortionType")); } DECLARE_RTFIMPORT_TEST(testFdo36089, "fdo36089.rtf") { CPPUNIT_ASSERT_EQUAL(sal_Int16(-50), getProperty(getRun(getParagraph(1), 2), "CharEscapement")); } DECLARE_RTFIMPORT_TEST(testFdo49892, "fdo49892.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); for (int i = 0; i < xDraws->getCount(); ++i) { OUString aDescription = getProperty(xDraws->getByIndex(i), "Description"); if (aDescription == "red") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xDraws->getByIndex(i), "ZOrder")); else if (aDescription == "green") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty(xDraws->getByIndex(i), "ZOrder")); else if (aDescription == "blue") CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty(xDraws->getByIndex(i), "ZOrder")); else if (aDescription == "rect") { CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(xDraws->getByIndex(i), "HoriOrientRelation")); CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(xDraws->getByIndex(i), "VertOrientRelation")); } } } DECLARE_RTFIMPORT_TEST(testFdo48446, "fdo48446.rtf") { OUString aExpected("\xd0\x98\xd0\xbc\xd1\x8f", 6, RTL_TEXTENCODING_UTF8); getParagraph(1, aExpected); } DECLARE_RTFIMPORT_TEST(testFdo47495, "fdo47495.rtf") { // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1. CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); } DECLARE_RTFIMPORT_TEST(testAllGapsWord, "all_gaps_word.rtf") { BorderTest borderTest; borderTest.testTheBorders(mxComponent, false); } DECLARE_RTFIMPORT_TEST(testFdo52052, "fdo52052.rtf") { // Make sure the textframe containing the text "third" appears on the 3rd page. CPPUNIT_ASSERT_EQUAL(OUString("third"), parseDump("/root/page[3]/body/txt/anchored/fly/txt/text()")); } DECLARE_RTFIMPORT_TEST(testInk, "ink.rtf") { /* * The problem was that the second segment had wrong command count and wrap type. * * oShape = ThisComponent.DrawPage(0) * oPathPropVec = oShape.CustomShapeGeometry(1).Value * oSegments = oPathPropVec(1).Value * msgbox oSegments(1).Count ' was 0x2000 | 10, should be 10 * msgbox oShape.Surround ' was 2, should be 1 */ uno::Sequence aProps = getProperty< uno::Sequence >(getShape(1), "CustomShapeGeometry"); uno::Sequence aPathProps; for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "Path") rProp.Value >>= aPathProps; } uno::Sequence aSegments; for (int i = 0; i < aPathProps.getLength(); ++i) { const beans::PropertyValue& rProp = aPathProps[i]; if (rProp.Name == "Segments") rProp.Value >>= aSegments; } CPPUNIT_ASSERT_EQUAL(sal_Int16(10), aSegments[1].Count); CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty(getShape(1), "Surround")); } DECLARE_RTFIMPORT_TEST(testFdo52389, "fdo52389.rtf") { // The last '!' character at the end of the document was lost CPPUNIT_ASSERT_EQUAL(6, getLength()); } DECLARE_RTFIMPORT_TEST(testFdo49655, "fdo49655.rtf") { /* * 49655 : * The problem was that the table was not imported due to the ' ' string in the middle of the table definition. * * xray ThisComponent.TextTables.Count 'was 0 */ uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo62805, "fdo62805.rtf") { /* * 62805 : * The problem was that the table was not imported due to the absence of \pard after \row. * The table was instead in a group (the '}' replace the \pard). */ uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo52475, "fdo52475.rtf") { // The problem was that \chcbpat0 resulted in no color, instead of COL_AUTO. CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty(getRun(getParagraph(1), 3), "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo55493, "fdo55493.rtf") { // The problem was that the width of the PNG was detected as 15,24cm, instead of 3.97cm uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape->getSize().Width); } DECLARE_RTFIMPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.rtf") { // The problem was that RTF import during copy&paste did not ignore page styles. // Once we have more copy&paste tests, makes sense to refactor this to some helper method. paste("copypaste-pagestyle-paste.rtf"); uno::Reference xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty(xPropertySet, "Width")); // Was letter, i.e. 21590 } DECLARE_RTFIMPORT_TEST(testCopyPasteFootnote, "copypaste-footnote.rtf") { // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote. uno::Reference xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); uno::Reference xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY); paste("copypaste-footnote-paste.rtf", xTextRange); CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo61193, "hello.rtf") { // Pasting content that contained a footnote caused a crash. uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xEnd = xText->getEnd(); paste("fdo61193.rtf", xEnd); } DECLARE_RTFIMPORT_TEST(testShptxtPard, "shptxt-pard.rtf") { // The problem was that \pard inside \shptxt caused loss of shape text uno::Reference xText(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("shape text"), xText->getString()); } DECLARE_RTFIMPORT_TEST(testDoDhgt, "do-dhgt.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); for (int i = 0; i < xDraws->getCount(); ++i) { sal_Int32 nFillColor = getProperty(xDraws->getByIndex(i), "FillColor"); if (nFillColor == 0xc0504d) // red CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xDraws->getByIndex(i), "ZOrder")); else if (nFillColor == 0x9bbb59) // green CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty(xDraws->getByIndex(i), "ZOrder")); else if (nFillColor == 0x4f81bd) // blue CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty(xDraws->getByIndex(i), "ZOrder")); } } DECLARE_RTFIMPORT_TEST(testDplinehollow, "dplinehollow.rtf") { uno::Reference xPropertySet(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty(xPropertySet, "LineStyle")); } DECLARE_RTFIMPORT_TEST(testLeftmarginDefault, "leftmargin-default.rtf") { // The default left/right margin was incorrect when the top margin was set to zero. CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin")); } DECLARE_RTFIMPORT_TEST(testDppolyline, "dppolyline.rtf") { // This was completely ignored, for now, just make sure we have all 4 lines. uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo79319, "fdo79319.rtf") { // the thin horizontal rule was imported as a big fat rectangle uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(xShape, "RelativeWidth")); // FIXME the width/height numbers here are bogus; they should be 15238 / 53 // (as they are when opening the file in a full soffice) #if 0 CPPUNIT_ASSERT_EQUAL(sal_Int32(15238), xShape->getSize().Width); CPPUNIT_ASSERT_EQUAL(sal_Int32(53), xShape->getSize().Height); CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty(xShape, "VertOrient")); CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty(xShape, "HoriOrient")); #endif } DECLARE_RTFIMPORT_TEST(testFdo56512, "fdo56512.rtf") { uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); uno::Reference xTextRange(xIndexAccess->getByIndex(0), uno::UNO_QUERY); OUString aExpected("\xd7\xa2\xd7\x95\xd7\xa1\xd7\xa7 \xd7\x9e\xd7\x95\xd7\xa8\xd7\xa9\xd7\x94 ", 20, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo52989, "fdo52989.rtf") { // Same as n#192129, but for JPEG files. uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape->getSize().Width); } DECLARE_RTFIMPORT_TEST(testFdo48442, "fdo48442.rtf") { // The problem was that \pvmrg is the default in RTF, but not in Writer. uno::Reference xShape = getShape(1); CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty(xShape, "VertOrientRelation")); // was FRAME } DECLARE_RTFIMPORT_TEST(testFdo55525, "fdo55525.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); // Negative left margin was ~missing, -191 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty(xTable, "LeftMargin")); // Cell width of A1 was 3332 (e.g. not set, 30% percent of total width) uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(896), getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position); } DECLARE_RTFIMPORT_TEST(testFdo57708, "fdo57708.rtf") { // There were two issues: the doc was of 2 pages and the picture was missing. CPPUNIT_ASSERT_EQUAL(1, getPages()); uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // Two objects: a picture and a textframe. CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo54473, "fdo54473.rtf") { // The problem was that character styles were not imported due to a typo. CPPUNIT_ASSERT_EQUAL(OUString("Anot"), getProperty(getRun(getParagraph(1), 1, "Text "), "CharStyleName")); CPPUNIT_ASSERT_EQUAL(OUString("ForeignTxt"), getProperty(getRun(getParagraph(1), 3, "character "), "CharStyleName")); } DECLARE_RTFIMPORT_TEST(testFdo49934, "fdo49934.rtf") { // Column break without columns defined should be a page break, but it was just ignored. CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo57886, "fdo57886.rtf") { // Was 'int from to '. CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1))); } DECLARE_RTFIMPORT_TEST(testFdo58076, "fdo58076.rtf") { // An additional section was created, so the default page style didn't have the custom margins. uno::Reference xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty(xStyle, "LeftMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty(xStyle, "RightMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty(xStyle, "TopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty(xStyle, "BottomMargin")); } DECLARE_RTFIMPORT_TEST(testFdo57678, "fdo57678.rtf") { // Paragraphs of the two tables were not converted to tables. uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo45183, "fdo45183.rtf") { // Was text::WrapTextMode_PARALLEL, i.e. shpfblwtxt didn't send the shape below text. CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty(getShape(1), "Surround")); uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); // Was 247, resulting in a table having width almost zero and height of 10+ pages. CPPUNIT_ASSERT_EQUAL(sal_Int32(16237), getProperty(xTables->getByIndex(0), "Width")); } DECLARE_RTFIMPORT_TEST(testFdo54612, "fdo54612.rtf") { // \dpptx without a \dppolycount caused a crash. uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo58933, "fdo58933.rtf") { // The problem was that the table had an additional cell in its first line. uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); // This was 4. CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getCellNames().getLength()); } DECLARE_RTFIMPORT_TEST(testFdo44053, "fdo44053.rtf") { uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xTableRows(xTextTable->getRows(), uno::UNO_QUERY); // The with of the table's A1 and A2 cell should equal. CPPUNIT_ASSERT_EQUAL(getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position, getProperty< uno::Sequence >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); } DECLARE_RTFIMPORT_TEST(testFdo48440, "fdo48440.rtf") { // Page break was ignored. CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo58646line, "fdo58646line.rtf") { // \line symbol was ignored getParagraph(1, "foo\nbar"); } DECLARE_RTFIMPORT_TEST(testFdo78502, "fdo78502.rtf") { // ";" separators were inserted as text getParagraph(1, "foo"); } DECLARE_RTFIMPORT_TEST(testFdo58646, "fdo58646.rtf") { // Page break was ignored inside a continuous section, on title page. CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo59419, "fdo59419.rtf") { // Junk to be ignored broke import of the table. uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo58076_2, "fdo58076-2.rtf") { // Position of the picture wasn't correct. CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(8345)), getProperty(getShape(1), "HoriOrientPosition")); } DECLARE_RTFIMPORT_TEST(testFdo59953, "fdo59953.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); // Cell width of A1 was 4998 (e.g. not set / not wide enough, ~50% of total width) uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(7649), getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position); } DECLARE_RTFIMPORT_TEST(testFdo59638, "fdo59638.rtf") { // The problem was that w:lvlOverride inside w:num was ignores by dmapper. uno::Reference xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); uno::Reference xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence aProps; xLevels->getByIndex(0) >>= aProps; // 1st level for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "BulletChar") { // Was '*', should be 'o'. CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get()); return; } } CPPUNIT_FAIL("no BulletChar property"); } DECLARE_RTFIMPORT_TEST(testFdo60722, "fdo60722.rtf") { // The problem was that the larger shape was over the smaller one, and not the other way around. uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xShape, "ZOrder")); CPPUNIT_ASSERT_EQUAL(OUString("larger"), getProperty(xShape, "Description")); xShape.set(getShape(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty(xShape, "ZOrder")); CPPUNIT_ASSERT_EQUAL(OUString("smaller"), getProperty(xShape, "Description")); // Color of the line was blue, and it had zero width. xShape.set(getShape(3), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty(xShape, "LineWidth")); CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty(xShape, "LineColor")); } DECLARE_RTFIMPORT_TEST(testDoDhgtOld, "do-dhgt-old.rtf") { // The file contains 3 shapes which have the same dhgt (z-order). // Test that the order is 1) a 2) black rectangle 3) b, and not something else uno::Reference xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xShape, "ZOrder")); CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString()); xShape.set(getShape(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty(xShape, "ZOrder")); CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty(xShape, "FillColor")); xShape.set(getShape(3), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty(xShape, "ZOrder")); CPPUNIT_ASSERT_EQUAL(OUString("b"), xShape->getString()); } DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); // Was the Writer default font. CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty(xTextRange, "CharFontName")); // It is white (0xFFFFFF) in document CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty(xTextRange, "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); uno::Reference xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); // Margins were inherited from the previous cell, even there was a \pard there. CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, "ParaLeftMargin")); } DECLARE_RTFIMPORT_TEST(testFdo37716, "fdo37716.rtf") { uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFrames(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); // \nowrap got ignored, so Surround was text::WrapTextMode_PARALLEL CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_NONE, getProperty(xFrames->getByIndex(0), "Surround")); } DECLARE_RTFIMPORT_TEST(testFdo51916, "fdo51916.rtf") { // Complex nested table caused a crash. } DECLARE_RTFIMPORT_TEST(testFdo63023, "fdo63023.rtf") { uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); // Back color was black (0) in the header, due to missing color table in the substream. CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo42109, "fdo42109.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); // Make sure the page number is imported as a field in the B1 cell. CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType")); } DECLARE_RTFIMPORT_TEST(testFdo62977, "fdo62977.rtf") { // The middle character was imported as '?' instead of the proper unicode value. getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8)); } DECLARE_RTFIMPORT_TEST(testN818997, "n818997.rtf") { // \page was ignored between two \shp tokens. CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo64671, "fdo64671.rtf") { // Additional '}' was inserted before the special character. getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8)); } DECLARE_RTFIMPORT_TEST(testPageBackground, "page-background.rtf") { // The problem was that \background was ignored. uno::Reference xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty(xPageStyle, "BackColor")); } DECLARE_RTFIMPORT_TEST(testFdo81944, "fdo81944.rtf") { // font properties in style were not imported uno::Reference xPropertySet( getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY); uno::Reference xStyle(xPropertySet, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Segoe UI"), getProperty(xStyle, "CharFontName")); CPPUNIT_ASSERT_EQUAL(9.0f, getProperty(xStyle, "CharHeight")); // not sure if this should be set on Asian or Complex or both? CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty(xStyle, "CharFontNameComplex")); CPPUNIT_ASSERT_EQUAL(11.0f, getProperty(xStyle, "CharHeightComplex")); } DECLARE_RTFIMPORT_TEST(testFdo62044, "fdo62044.rtf") { // The problem was that RTF import during copy&paste did not ignore existing paragraph styles. uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xEnd = xText->getEnd(); paste("fdo62044-paste.rtf", xEnd); uno::Reference xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(10.f, getProperty(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value. } DECLARE_RTFIMPORT_TEST(testFdo70578, "fdo70578.rtf") { // Style without explicit \s0 was not imported as the default style uno::Reference xPropertySet( getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY); uno::Reference xStyle(xPropertySet, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle->getParentStyle()); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPropertySet, "ParaTopMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPropertySet, "ParaBottomMargin")); } DECLARE_RTFIMPORT_TEST(testPoshPosv, "posh-posv.rtf") { CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty(getShape(1), "HoriOrient")); CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty(getShape(1), "VertOrient")); CPPUNIT_ASSERT_EQUAL(true, getProperty(getShape(1), "FrameIsAutomaticHeight")); } DECLARE_RTFIMPORT_TEST(testN825305, "n825305.rtf") { // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0. uno::Reference xPropertyState(getShape(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty(getShape(2), "BackColorTransparency")); beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency"); // Was beans::PropertyState_DEFAULT_VALUE. CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); } DECLARE_RTFIMPORT_TEST(testParaBottomMargin, "para-bottom-margin.rtf") { uno::Reference xPropertySet( getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty(xPropertySet, "ParaBottomMargin")); // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0. // The reason why this is 0 despite the default style containing \sa200 // is that Word will actually interpret \sN (or \pard which apparently // implies \s0) as "set style N and for every attribute of that style, // set an attribute with default value on the paragraph" CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(getParagraph(1), "ParaBottomMargin")); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty(getParagraph(1), "ParaTopMargin")); } DECLARE_RTFIMPORT_TEST(testN823655, "n823655.rtf") { uno::Sequence aProps = getProperty< uno::Sequence >(getShape(1), "CustomShapeGeometry"); uno::Sequence aPathProps; for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "Path") aPathProps = rProp.Value.get< uno::Sequence >(); } uno::Sequence aCoordinates; for (int i = 0; i < aPathProps.getLength(); ++i) { const beans::PropertyValue& rProp = aPathProps[i]; if (rProp.Name == "Coordinates") aCoordinates = rProp.Value.get< uno::Sequence >(); } // The first coordinate pair of this freeform shape was 286,0 instead of 0,286. CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get()); } DECLARE_RTFIMPORT_TEST(testFdo66040, "fdo66040.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // This was 0 (no shapes were imported), we want two textframes. CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell. uno::Reference xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY); uno::Reference xText = xTextRange->getText(); uno::Reference xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString()); // Make sure the second shape has the correct position and size. uno::Reference xShape(xDraws->getByIndex(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty(xShape, "HoriOrientPosition")); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty(xShape, "VertOrientPosition")); CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width); CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height); } DECLARE_RTFIMPORT_TEST(testN823675, "n823675.rtf") { uno::Reference xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); uno::Reference xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); uno::Sequence aProps; xLevels->getByIndex(0) >>= aProps; // 1st level awt::FontDescriptor aFont; for (int i = 0; i < aProps.getLength(); ++i) { const beans::PropertyValue& rProp = aProps[i]; if (rProp.Name == "BulletFont") aFont = rProp.Value.get(); } // This was empty, i.e. no font name was set for the bullet numbering. CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name); } DECLARE_RTFIMPORT_TEST(testFdo77996, "fdo77996.rtf") { // all styles were imported as name "0" uno::Reference xChars(getStyles("CharacterStyles")); CPPUNIT_ASSERT(!xChars->hasByName("0")); CPPUNIT_ASSERT(xChars->hasByName("strong")); CPPUNIT_ASSERT(xChars->hasByName("author")); uno::Reference xParas(getStyles("ParagraphStyles")); CPPUNIT_ASSERT(!xParas->hasByName("0")); CPPUNIT_ASSERT(xParas->hasByName("extract2")); // some document properties were lost uno::Reference xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xProps(xDocumentPropertiesSupplier->getDocumentProperties()); CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps->getAuthor()); OUString aTitle("\xe5\x8e\xa6\xe9\x97\xa8\xe9\x92\xa8\xe4\xb8\x9a\xe8\x82\xa1\xe4\xbb\xbd\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8", 30, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aTitle, xProps->getTitle()); uno::Reference xUDProps(xProps->getUserDefinedProperties(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty(xUDProps, "Operator")); // fdo#80486 also check that the ftnsep doesn't insert paragraph breaks getParagraph(1, aTitle); } DECLARE_RTFIMPORT_TEST(testFdo47802, "fdo47802.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // Shape inside table was ignored. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo39001, "fdo39001.rtf") { // Document was of 4 pages, \sect at the end of the doc wasn't ignored. CPPUNIT_ASSERT_EQUAL(3, getPages()); } DECLARE_RTFIMPORT_TEST(testGroupshape, "groupshape.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // There should be a single groupshape with 2 children. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); uno::Reference xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount()); } DECLARE_RTFIMPORT_TEST(testGroupshape_notext, "groupshape-notext.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // There should be a single groupshape with 2 children. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); uno::Reference xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount()); } DECLARE_RTFIMPORT_TEST(testFdo81033, "fdo81033.rtf") { // Number of tabstops in the paragraph should be 2, was 3. uno::Sequence tabs( getProperty< uno::Sequence >(getParagraph(1), "ParaTabStops")); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabs.getLength()); CPPUNIT_ASSERT_EQUAL(sal_Int32(5808), tabs[0].Position); CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT, tabs[0].Alignment); CPPUNIT_ASSERT_EQUAL(sal_Unicode(' '), tabs[0].FillChar); CPPUNIT_ASSERT_EQUAL(sal_Int32(16002), tabs[1].Position); CPPUNIT_ASSERT_EQUAL(style::TabAlign_LEFT, tabs[1].Alignment); CPPUNIT_ASSERT_EQUAL(sal_Unicode('_'), tabs[1].FillChar); } DECLARE_RTFIMPORT_TEST(testFdo66565, "fdo66565.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); // Cell width of A2 was 554, should be 453/14846*10000 uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(304), getProperty< uno::Sequence >(xTableRows->getByIndex(1), "TableColumnSeparators")[0].Position); } DECLARE_RTFIMPORT_TEST(testFdo54900, "fdo54900.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); // Paragraph was aligned to left, should be center. CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast(getProperty(getParagraphOfText(1, xCell->getText()), "ParaAdjust"))); } DECLARE_RTFIMPORT_TEST(testFdo64637, "fdo64637.rtf") { // The problem was that the custom "Company" property was added twice, the second invocation resulted in an exception. uno::Reference xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xPropertySet(xDocumentPropertiesSupplier->getDocumentProperties()->getUserDefinedProperties(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("bbb"), getProperty(xPropertySet, "Company")); } DECLARE_RTFIMPORT_TEST(testN820504, "n820504.rtf") { // The shape 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(getShape(1), "AnchorType")); } DECLARE_RTFIMPORT_TEST(testFdo67365, "fdo67365.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xRows = xTable->getRows(); // The table only had 3 rows. CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xRows->getCount()); // This was 4999, i.e. the two cells of the row had equal widths instead of a larger and a smaller cell. CPPUNIT_ASSERT_EQUAL(sal_Int16(5290), getProperty< uno::Sequence >(xRows->getByIndex(2), "TableColumnSeparators")[0].Position); uno::Reference xCell(xTable->getCellByName("A2"), uno::UNO_QUERY); // Paragraph was aligned to center, should be left. CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, static_cast(getProperty(getParagraphOfText(1, xCell->getText()), "ParaAdjust"))); } DECLARE_RTFIMPORT_TEST(testFdo67498, "fdo67498.rtf") { // Left margin of the default page style wasn't set (was 2000). CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(5954)), getProperty(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin")); } DECLARE_RTFIMPORT_TEST(testFdo47440, "fdo47440.rtf") { // Vertical and horizontal orientation of the picture wasn't imported (was text::RelOrientation::FRAME). CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(getShape(1), "HoriOrientRelation")); CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(getShape(1), "VertOrientRelation")); } DECLARE_RTFIMPORT_TEST(testFdo53556, "fdo53556.rtf") { // This was drawing::FillStyle_SOLID, which resulted in being non-transparent, hiding text which would be visible. CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty(getShape(3), "FillStyle")); // This was a com.sun.star.drawing.CustomShape, which resulted in lack of word wrapping in the bugdoc. uno::Reference xShapeProperties(getShape(1), uno::UNO_QUERY); uno::Reference xShapeDescriptor(xShapeProperties, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), xShapeDescriptor->getShapeType()); } DECLARE_RTFIMPORT_TEST(testFdo63428, "hello.rtf") { // Pasting content that contained an annotation caused a crash. uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xEnd = xText->getEnd(); paste("fdo63428.rtf", xEnd); // Additionally, commented range was imported as a normal comment. CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty(getRun(getParagraph(1), 2), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty(getRun(getParagraph(1), 4), "TextPortionType")); } DECLARE_RTFIMPORT_TEST(testGroupshapeRotation, "groupshape-rotation.rtf") { // Rotation on groupshapes wasn't handled correctly, RotateAngle was 4500. CPPUNIT_ASSERT_EQUAL(sal_Int32(315 * 100), getProperty(getShape(1), "RotateAngle")); } DECLARE_RTFIMPORT_TEST(testFdo44715, "fdo44715.rtf") { uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); // Style information wasn't reset, which caused character height to be 16. CPPUNIT_ASSERT_EQUAL(12.f, getProperty(getParagraphOfText(2, xCell->getText()), "CharHeight")); } DECLARE_RTFIMPORT_TEST(testFdo68076, "fdo68076.rtf") { // Encoding of the last char was wrong (more 'o' than 'y'). OUString aExpected("\xD0\x9E\xD0\xB1\xD1\x8A\xD0\xB5\xD0\xBA\xD1\x82 \xE2\x80\x93 \xD1\x83", 19, RTL_TEXTENCODING_UTF8); getParagraph(1, aExpected); } DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xEnd = xText->getEnd(); paste("fdo68291-paste.rtf", xEnd); // This was "Standard", causing an unwanted page break on next paste. CPPUNIT_ASSERT_EQUAL(OUString(), getProperty(getParagraph(1), "PageDescName")); } DECLARE_RTFIMPORT_TEST(testFdo69384, "hello.rtf") { uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference xEnd = xText->getEnd(); paste("fdo69384-paste.rtf", xEnd); // Import got interrupted in the middle of style sheet table import, // resuling in missing styles and text. getStyles("ParagraphStyles")->getByName("Text body justified"); } DECLARE_RTFIMPORT_TEST(testFdo70221, "fdo70221.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // The picture was imported twice. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); } DECLARE_RTFIMPORT_TEST(testCp1000018, "cp1000018.rtf") { // The problem was that the empty paragraph at the end of the footnote got // lost during import. uno::Reference xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); uno::Reference xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY); OUString aExpected("Footnote first line.\n"); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } #endif DECLARE_RTFIMPORT_TEST(testNestedTable, "rhbz1065629.rtf") { // nested table in second cell was missing uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(1), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); uno::Reference xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); uno::Reference xParaEnum = xParaEnumAccess->createEnumeration(); uno::Reference xPara(xParaEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Responsable Commercial:"), xPara->getString()); xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); xParaEnum = xParaEnumAccess->createEnumeration(); xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Nom: John Doe"), xPara->getString()); // outer table: background color, borders for B1/B2 cell xTable.set(xTables->getByIndex(2), uno::UNO_QUERY); xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 fullPtSolid(1, 0, 35, 0, table::BorderLineStyle::SOLID, 35); CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty(xCell, "TopBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(fullPtSolid, getProperty(xCell, "BottomBorder")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty(xCell, "BackColor")); xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 halfPtSolid(/*0*/1, 0, 18, 0, table::BorderLineStyle::SOLID, 18); CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_EQUAL(static_cast(0xffffffff), getProperty(xCell, "BackColor")); xCell.set(xTable->getCellByName("B2"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(halfPtSolid, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_EQUAL(static_cast(0xffffffff), getProperty(xCell, "BackColor")); // \sect at the end resulted in spurious page break CPPUNIT_ASSERT_EQUAL(1, getPages()); } DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf") { uno::Reference xParaSecond = getParagraph(2); CPPUNIT_ASSERT_EQUAL(OUString("SECOND"), xParaSecond->getString()); CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty(xParaSecond, "BreakType")); CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xParaSecond, "PageDescName")); // actually not sure how many paragraph there should be between // SECOND and THIRD - important is that the page break is on there uno::Reference xParaNext = getParagraph(3); CPPUNIT_ASSERT_EQUAL(OUString(""), xParaNext->getString()); CPPUNIT_ASSERT_EQUAL(OUString("Converted1"), getProperty(xParaNext, "PageDescName")); uno::Reference xParaThird = getParagraph(4); CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird->getString()); CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty(xParaThird, "BreakType")); CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xParaThird, "PageDescName")); CPPUNIT_ASSERT_EQUAL(2, getPages()); } DECLARE_RTFIMPORT_TEST(testFooterPara, "footer-para.rtf") { // check that paragraph properties in footer are imported uno::Reference xFooterText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName("First Page"), "FooterText"); uno::Reference xParagraph = getParagraphOrTable(1, xFooterText); CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."), uno::Reference(xParagraph, uno::UNO_QUERY)->getString()); CPPUNIT_ASSERT_EQUAL((sal_Int16)style::ParagraphAdjust_CENTER, getProperty(xParagraph, "ParaAdjust")); } DECLARE_RTFIMPORT_TEST(testCp1000016, "hello.rtf") { // The single-line document had a second fake empty para on Windows. bool bFound = true; try { getParagraph(2); } catch (const container::NoSuchElementException&) { bFound = false; } CPPUNIT_ASSERT_EQUAL(false, bFound); } DECLARE_RTFIMPORT_TEST(testFdo65090, "fdo65090.rtf") { uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xTableRows(xTextTable->getRows(), uno::UNO_QUERY); // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator). CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); } DECLARE_RTFIMPORT_TEST(testTableBorderDefaults, "fdo68779.rtf") { // table borders without \brdrw were not imported uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 solid(1, 0, 26, 0, table::BorderLineStyle::SOLID, 26); CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty(xCell, "TopBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(solid, getProperty(xCell, "BottomBorder")); xTable.set(xTables->getByIndex(1), uno::UNO_QUERY); xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 dotted(1, 0, 26, 0, table::BorderLineStyle::DOTTED, 26); CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty(xCell, "TopBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(dotted, getProperty(xCell, "BottomBorder")); xTable.set(xTables->getByIndex(2), uno::UNO_QUERY); xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 doubled(1, 26, 26, 26, table::BorderLineStyle::DOUBLE, 79); CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty(xCell, "TopBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(doubled, getProperty(xCell, "BottomBorder")); xTable.set(xTables->getByIndex(3), uno::UNO_QUERY); xCell.set(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT(xCell.is()); table::BorderLine2 thinThickMG(1, 14, 26, 14, table::BorderLineStyle::THINTHICK_MEDIUMGAP, 53); CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty(xCell, "LeftBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty(xCell, "RightBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty(xCell, "TopBorder")); CPPUNIT_ASSERT_BORDER_EQUAL(thinThickMG, getProperty(xCell, "BottomBorder")); } DECLARE_RTFIMPORT_TEST(testShpzDhgt, "shpz-dhgt.rtf") { // Test that shpz has priority over dhght and not the other way around. // Drawpage is sorted by ZOrder, so first should be red (back). CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty(getShape(1), "FillColor")); // Second (front) should be green. CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty(getShape(2), "FillColor")); } DECLARE_RTFIMPORT_TEST(testBackground, "background.rtf") { // The first shape wasn't in the foreground. CPPUNIT_ASSERT_EQUAL(true, bool(getProperty(getShape(1), "Opaque"))); CPPUNIT_ASSERT_EQUAL(false, bool(getProperty(getShape(2), "Opaque"))); } DECLARE_RTFIMPORT_TEST(testLevelfollow, "levelfollow.rtf") { uno::Reference xNum1Levels = getProperty< uno::Reference >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules"); CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::LISTTAB), comphelper::SequenceAsHashMap(xNum1Levels->getByIndex(0))["LabelFollowedBy"].get()); // first level, tab uno::Reference xNum2Levels = getProperty< uno::Reference >(getStyles("NumberingStyles")->getByName("WWNum2"), "NumberingRules"); CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::SPACE), comphelper::SequenceAsHashMap(xNum2Levels->getByIndex(0))["LabelFollowedBy"].get()); // first level, space uno::Reference xNum3Levels = getProperty< uno::Reference >(getStyles("NumberingStyles")->getByName("WWNum3"), "NumberingRules"); CPPUNIT_ASSERT_EQUAL(sal_Int16(SvxNumberFormat::NOTHING), comphelper::SequenceAsHashMap(xNum3Levels->getByIndex(0))["LabelFollowedBy"].get()); // first level, nothing } DECLARE_RTFIMPORT_TEST(testCharColor, "char-color.rtf") { // This was -1: character color wasn't set. CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty(getParagraph(1), "CharColor")); } DECLARE_RTFIMPORT_TEST(testFdo69289, "fdo69289.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); // There were only 2 cells (1 separators) in the table, should be 3 (2 separators). CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty< uno::Sequence >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); } DECLARE_RTFIMPORT_TEST(testDptxbxRelation, "dptxbx-relation.rtf") { // This was FRAME, not PAGE_FRAME, even if dobxpage is in the document. CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty(getShape(1), "HoriOrientRelation")); } DECLARE_RTFIMPORT_TEST(testDprectAnchor, "dprect-anchor.rtf") { // This was at-page, which is not something Word supports, so clearly an import error. CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty(getShape(1), "AnchorType")); } DECLARE_RTFIMPORT_TEST(testFdo76628, "fdo76628.rtf") { OUString aExpected("\xd0\x9e\xd0\x91\xd0\xa0\xd0\x90\xd0\x97\xd0\x95\xd0\xa6", 14, RTL_TEXTENCODING_UTF8); // Should be 'SAMPLE' in Russian, was garbage. getParagraph(1, aExpected); uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); OUString aExpectedHeader("\xd0\x9f\xd0\xbe\xd0\xb4\xd0\xb3\xd0\xbe\xd1\x82\xd0\xbe\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xbe", 24, RTL_TEXTENCODING_UTF8); // Should be 'prepared' in Russian, was garbage. getParagraphOfText(1, xHeaderText, aExpectedHeader); } DECLARE_RTFIMPORT_TEST(testFdo74823, "fdo74823.rtf") { uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); // Cell width of C2 was too large / column separator being 3749 too small (e.g. not set, around 3/7 of total width) uno::Reference xTableRows(xTable->getRows(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int16(5391), getProperty< uno::Sequence >(xTableRows->getByIndex(1), "TableColumnSeparators")[2].Position); } DECLARE_RTFIMPORT_TEST(testFdo74599, "fdo74599.rtf") { uno::Reference xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 3"), uno::UNO_QUERY); // Writer default styles weren't disabled, so the color was gray, not default (black). CPPUNIT_ASSERT_EQUAL(static_cast(-1), getProperty(xPropertySet, "CharColor")); } DECLARE_RTFIMPORT_TEST(testFdo77267, "fdo77267.rtf") { // Paragraph was aligned to left, should be center. CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast(getProperty(getParagraph(1), "ParaAdjust"))); } DECLARE_RTFIMPORT_TEST(testFdo75735, "fdo75735.rtf") { // Number of tabstops in the second paragraph should be 3, was 6. CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty< uno::Sequence >(getParagraph(2), "ParaTabStops").getLength()); } DECLARE_RTFIMPORT_TEST(testFontOverride, "font-override.rtf") { // This was "Times New Roman". CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(getRun(getParagraph(1), 1), "CharFontName")); } DECLARE_RTFIMPORT_TEST(testFdo73241, "fdo73241.rtf") { // This was 2, page break in table wasn't ignored. CPPUNIT_ASSERT_EQUAL(1, getPages()); } DECLARE_RTFIMPORT_TEST(testFdo80905, "fdo80905.rtf") { uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference xFields(xFieldsAccess->createEnumeration()); xFields->nextElement(); // The problem was that there was only one field in the document, but there should be true. CPPUNIT_ASSERT_EQUAL(true, static_cast(xFields->hasMoreElements())); } DECLARE_RTFIMPORT_TEST(testOleInline, "ole-inline.rtf") { // Problem was that inline shape had at-page anchor. CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty(getShape(1), "AnchorType")); } DECLARE_RTFIMPORT_TEST(testFdo80742, "fdo80742.rtf") { uno::Reference xPropertySet(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY); // This was 0, outline level was body text. CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty(xPropertySet, "OutlineLevel")); } DECLARE_RTFIMPORT_TEST(testFdo82106, "fdo82106.rtf") { // Tab was missing after footnote not containing a tab. getParagraph(2, "before\tafter"); } DECLARE_RTFIMPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf") { // The shape also didn't have negative top / left coordinates. CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty(getShape(1), "HoriOrientPosition")); CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty(getShape(1), "VertOrientPosition")); } DECLARE_RTFIMPORT_TEST(testFdo84679, "fdo84679.rtf") { // The problem was that the paragraph in A1 had some bottom margin, but it should not. uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); // This was 282. CPPUNIT_ASSERT_EQUAL(static_cast(0), getProperty(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin")); } DECLARE_RTFIMPORT_TEST(testFdo83464, "fdo83464.rtf") { // Problem was that the text in the textfrme had wrong font. uno::Reference xFrameText(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xFrameText->getString()); // This was Times New Roman. CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty(getRun(getParagraphOfText(1, xFrameText->getText()), 1), "CharFontName")); } DECLARE_RTFIMPORT_TEST(testFdo85179, "fdo85179.rtf") { // This was 0, border around the picture was ignored on import. // 360: EMU -> MM100 CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800/360), getProperty(getShape(1), "TopBorder").LineWidth); } DECLARE_RTFIMPORT_TEST(testFdo86761, "fdo86761.rtf") { // This was 26, even if the picture should have no border, due to fLine=0. CPPUNIT_ASSERT_EQUAL(static_cast(0), getProperty(getShape(1), "TopBorder").LineWidth); } DECLARE_RTFIMPORT_TEST(testFdo82859, "fdo82859.rtf") { // This was 0: "0xffffff" was converted to 0, i.e. the background was black instead of the default. CPPUNIT_ASSERT_EQUAL(static_cast(-1), getProperty(getShape(1), "BackColor")); } DECLARE_RTFIMPORT_TEST(testFdo82076, "fdo82076.rtf") { // Footnote position was wrong: should be at the end of the B1 cell. uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference xCell(xTable->getCellByName("B1"), uno::UNO_QUERY); // This resulted in container::NoSuchElementException: the footnote was at the start of the A1 cell. CPPUNIT_ASSERT_EQUAL(OUString("Footnote"), getProperty(getRun(getParagraphOfText(1, xCell->getText()), 2), "TextPortionType")); } DECLARE_RTFIMPORT_TEST(testFdo82512, "fdo82512.rtf") { // This was style::BreakType_NONE, column break was before the 3rd paragraph, not before the 2nd one. CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); } DECLARE_RTFIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.rtf") { uno::Reference xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // This was false, last section was balanced, but it's unbalanced in Word. CPPUNIT_ASSERT_EQUAL(true, getProperty(xTextSections->getByIndex(0), "DontBalanceTextColumns")); } DECLARE_RTFIMPORT_TEST(testFdo84685, "fdo84685.rtf") { // index mark was not imported uno::Reference xMark( getProperty >( getRun(getParagraph(1), 1), "DocumentIndexMark")); CPPUNIT_ASSERT(xMark.is()); CPPUNIT_ASSERT_EQUAL(OUString("Key the 1st"), getProperty(xMark, "PrimaryKey")); // let's test toc entry too uno::Reference xTOCMark( getProperty >( getRun(getParagraph(2), 1), "DocumentIndexMark")); CPPUNIT_ASSERT(xTOCMark.is()); uno::Reference xTOCSI(xTOCMark, uno::UNO_QUERY); CPPUNIT_ASSERT(xTOCSI->supportsService("com.sun.star.text.ContentIndexMark")); } DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf") { // This was Standard, \sN was ignored after \bkmkstart and \pard. CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty(getParagraph(1), "ParaStyleName")); } DECLARE_RTFIMPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); OUString aExpected("\xc2\xb1\xe2\x89\xa5\xe2\x89\xa4", 8, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); OUString aExpected("\xc2\xb1\xe2\x80\x97\xc2\xbe", 7, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf") { uno::Reference xTextRange = getRun(getParagraph(1), 1); OUString aExpected("\xc3\x92\xc3\x9a\xc3\x9b", 6, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } DECLARE_RTFIMPORT_TEST(testFdo72031, "fdo72031.rtf") { OUString aExpected("\xc3\x85", 2, RTL_TEXTENCODING_UTF8); CPPUNIT_ASSERT_EQUAL(aExpected, getRun(getParagraph(1), 1)->getString()); } DECLARE_RTFIMPORT_TEST(testFdo86750, "fdo86750.rtf") { // This was 'HYPERLINK#anchor', the URL of the hyperlink had the field type as a prefix, leading to broken links. CPPUNIT_ASSERT_EQUAL(OUString("#anchor"), getProperty(getRun(getParagraph(1), 1), "HyperLinkURL")); } DECLARE_RTFIMPORT_TEST(testFdo82114, "fdo82114.rtf") { uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName("Converted1"), "HeaderText"); OUString aActual = xHeaderText->getString(); OUString aExpected("First page header, section 2"); // This was 'Right page header, section 1'. CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */