diff options
Diffstat (limited to 'editeng/qa')
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 1386 |
1 files changed, 747 insertions, 639 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index e40d5f0bf4c9..9cec620ed291 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -37,12 +37,13 @@ #include <com/sun/star/text/textfield/Type.hpp> #include <memory> +#include <vector> #include <editeng/outliner.hxx> using namespace com::sun::star; -namespace { - +namespace +{ class Test : public test::BootstrapFixture { public: @@ -86,6 +87,12 @@ public: /// Test Paste using an HTML fragment void testHTMLFragmentPaste(); + /// Test Paste using an RTF + void testRTFPaste(); + + /// Test Paste preference HTML/ + void testRTFHTMLPaste(); + /// Test Copy/Paste with selective selection over multiple paragraphs void testMultiParaSelCopyPaste(); @@ -124,7 +131,7 @@ public: void testCreateLines(); void testTdf154248MultilineFieldWrapping(); - DECL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, void ); + DECL_STATIC_LINK(Test, CalcFieldValueHdl, EditFieldInfo*, void); CPPUNIT_TEST_SUITE(Test); #if HAVE_MORE_FONTS @@ -137,6 +144,8 @@ public: CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testHTMLPaste); CPPUNIT_TEST(testHTMLFragmentPaste); + CPPUNIT_TEST(testRTFPaste); + CPPUNIT_TEST(testRTFHTMLPaste); CPPUNIT_TEST(testMultiParaSelCopyPaste); CPPUNIT_TEST(testTabsCopyPaste); CPPUNIT_TEST(testHyperlinkSearch); @@ -166,12 +175,12 @@ void Test::testLineSpacing() // Create EditEngine's instance EditEngine aEditEngine(mpItemPool.get()); - if(aEditEngine.GetRefDevice()->GetDPIY() != 96 + if (aEditEngine.GetRefDevice()->GetDPIY() != 96 || aEditEngine.GetRefDevice()->GetDPIScaleFactor() != 1.0) return; // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); @@ -190,8 +199,7 @@ void Test::testLineSpacing() // Select all paragraphs ESelection aSelection(0, 0, 0, aTextLen); - auto doTest = [&](sal_uInt16 nSpace, sal_uInt16 nExpMaxAscent, sal_uInt32 nExpLineHeight) - { + auto doTest = [&](sal_uInt16 nSpace, sal_uInt16 nExpMaxAscent, sal_uInt32 nExpLineHeight) { std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); SvxLineSpacingItem aLineSpacing(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL); aLineSpacing.SetPropLineSpace(nSpace); @@ -248,7 +256,7 @@ void Test::testConstruction() bool includes(const uno::Sequence<OUString>& rSeq, std::u16string_view rVal) { - for (OUString const & s : rSeq) + for (OUString const& s : rSeq) if (s == rVal) return true; @@ -299,7 +307,8 @@ void Test::testUnoTextFields() { // FILE - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::DOCINFO_TITLE)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::DOCINFO_TITLE)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.text.textfield.docinfo.Title"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -315,7 +324,8 @@ void Test::testUnoTextFields() { // EXTENDED TIME - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_TIME)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::EXTENDED_TIME)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.text.textfield.DateTime"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -323,7 +333,8 @@ void Test::testUnoTextFields() { // EXTENDED FILE - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_FILE)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::EXTENDED_FILE)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.text.textfield.FileName"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -347,7 +358,8 @@ void Test::testUnoTextFields() { // PRESENTATION HEADER - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_HEADER)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::PRESENTATION_HEADER)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.presentation.textfield.Header"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -355,7 +367,8 @@ void Test::testUnoTextFields() { // PRESENTATION FOOTER - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_FOOTER)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::PRESENTATION_FOOTER)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.presentation.textfield.Footer"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -363,7 +376,8 @@ void Test::testUnoTextFields() { // PRESENTATION DATE TIME - rtl::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_DATE_TIME)); + rtl::Reference<SvxUnoTextField> xField( + new SvxUnoTextField(text::textfield::Type::PRESENTATION_DATE_TIME)); uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames(); bool bGood = includes(aSvcs, u"com.sun.star.presentation.textfield.DateTime"); CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood); @@ -374,46 +388,44 @@ class TestAutoCorrDoc : public SvxAutoCorrDoc { public: /// just like the real thing, this dummy modifies the rText parameter :( - TestAutoCorrDoc(OUString &rText, LanguageType eLang) + TestAutoCorrDoc(OUString& rText, LanguageType eLang) : m_rText(rText) , m_eLang(eLang) { } - OUString const& getResult() const - { - return m_rText; - } + OUString const& getResult() const { return m_rText; } + private: - OUString & m_rText; + OUString& m_rText; LanguageType m_eLang; - virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override + virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override { //fprintf(stderr, "TestAutoCorrDoc::Delete\n"); - m_rText = m_rText.replaceAt(nStt, nEnd-nStt, u""); + m_rText = m_rText.replaceAt(nStt, nEnd - nStt, u""); return true; } - virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) override + virtual bool Insert(sal_Int32 nPos, const OUString& rTxt) override { //fprintf(stderr, "TestAutoCorrDoc::Insert\n"); m_rText = m_rText.replaceAt(nPos, 0, rTxt); return true; } - virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) override + virtual bool Replace(sal_Int32 nPos, const OUString& rTxt) override { //fprintf(stderr, "TestAutoCorrDoc::Replace\n"); - return ReplaceRange( nPos, rTxt.getLength(), rTxt ); + return ReplaceRange(nPos, rTxt.getLength(), rTxt); } - virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) override + virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt) override { //fprintf(stderr, "TestAutoCorrDoc::ReplaceRange %d %d %s\n", nPos, nLen, OUStringToOString(rTxt, RTL_TEXTENCODING_UTF8).getStr()); m_rText = m_rText.replaceAt(nPos, nLen, rTxt); return true; } - virtual void SetAttr( sal_Int32, sal_Int32, sal_uInt16, SfxPoolItem& ) override + virtual void SetAttr(sal_Int32, sal_Int32, sal_uInt16, SfxPoolItem&) override { //fprintf(stderr, "TestAutoCorrDoc::SetAttr\n"); } - virtual bool SetINetAttr( sal_Int32, sal_Int32, const OUString& ) override + virtual bool SetINetAttr(sal_Int32, sal_Int32, const OUString&) override { //fprintf(stderr, "TestAutoCorrDoc::SetINetAttr\n"); return true; @@ -423,30 +435,29 @@ private: //fprintf(stderr, "TestAutoCorrDoc::GetPrevPara\n"); return nullptr; } - virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, - sal_Int32 nEndPos, SvxAutoCorrect& rACorrect, - OUString* pPara ) override + virtual bool ChgAutoCorrWord(sal_Int32& rSttPos, sal_Int32 nEndPos, SvxAutoCorrect& rACorrect, + OUString* pPara) override { //fprintf(stderr, "TestAutoCorrDoc::ChgAutoCorrWord\n"); if (m_rText.isEmpty()) return false; - LanguageTag aLanguageTag( m_eLang); - const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( - m_rText, rSttPos, nEndPos, *this, aLanguageTag); + LanguageTag aLanguageTag(m_eLang); + const SvxAutocorrWord* pFnd + = rACorrect.SearchWordsInList(m_rText, rSttPos, nEndPos, *this, aLanguageTag); if (pFnd && pFnd->IsTextOnly()) { m_rText = m_rText.replaceAt(rSttPos, nEndPos, pFnd->GetLong()); - if( pPara ) + if (pPara) pPara->clear(); // =&pCurNode->GetString(); return true; } return false; } - virtual bool TransliterateRTLWord( sal_Int32& /*rSttPos*/, - sal_Int32 /*nEndPos*/, bool /*bApply*/ ) override + virtual bool TransliterateRTLWord(sal_Int32& /*rSttPos*/, sal_Int32 /*nEndPos*/, + bool /*bApply*/) override { return false; } @@ -530,10 +541,9 @@ void Test::testAutocorrect() CPPUNIT_ASSERT_EQUAL_MESSAGE("autocorrect", OUString(sExpected), aFoo.getResult()); } - } -IMPL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, pInfo, void ) +IMPL_STATIC_LINK(Test, CalcFieldValueHdl, EditFieldInfo*, pInfo, void) { if (!pInfo) return; @@ -544,18 +554,18 @@ IMPL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, pInfo, void ) { // URLField OUString aURL = pURLField->GetURL(); - switch ( pURLField->GetFormat() ) + switch (pURLField->GetFormat()) { case SvxURLFormat::AppDefault: case SvxURLFormat::Repr: { - pInfo->SetRepresentation( pURLField->GetRepresentation() ); + pInfo->SetRepresentation(pURLField->GetRepresentation()); } break; case SvxURLFormat::Url: { - pInfo->SetRepresentation( aURL ); + pInfo->SetRepresentation(aURL); } break; } @@ -571,17 +581,17 @@ void Test::testHyperlinkCopyPaste() { // Create Outliner instance Outliner aOutliner(mpItemPool.get(), OutlinerMode::TextObject); - aOutliner.SetCalcFieldValueHdl( LINK( nullptr, Test, CalcFieldValueHdl ) ); + aOutliner.SetCalcFieldValueHdl(LINK(nullptr, Test, CalcFieldValueHdl)); // Create EditEngine's instance - EditEngine& aEditEngine = const_cast<EditEngine&> (aOutliner.GetEditEngine()); + EditEngine& aEditEngine = const_cast<EditEngine&>(aOutliner.GetEditEngine()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // New instance must be empty - no initial text - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Get corresponding Field Item for inserting URLs in text // URL 1 @@ -599,26 +609,26 @@ void Test::testHyperlinkCopyPaste() OUString aParaText = u"sampletextfortestingfeaturefields"_ustr; // Positions Ref .............*13....*20.......... sal_Int32 aTextLen = aParaText.getLength(); - aEditEngine.SetText( aParaText ); + aEditEngine.SetText(aParaText); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aParaText, rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aParaText, rDoc.GetParaAsString(sal_Int32(0))); // Insert URL 1 - ContentNode *pNode = rDoc.GetObject(0); - EditSelection aSel1( EditPaM(pNode, 13), EditPaM(pNode, 13) ); - aEditEngine.InsertField( aSel1, aField1 ); + ContentNode* pNode = rDoc.GetObject(0); + EditSelection aSel1(EditPaM(pNode, 13), EditPaM(pNode, 13)); + aEditEngine.InsertField(aSel1, aField1); // Assert Field Count - CPPUNIT_ASSERT_EQUAL( sal_uInt16(1), aEditEngine.GetFieldCount(0) ); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aEditEngine.GetFieldCount(0)); // Insert URL 2 - EditSelection aSel2( EditPaM(pNode, 20 + 1), EditPaM(pNode, 20 + 1) ); - aEditEngine.InsertField( aSel2, aField2 ); + EditSelection aSel2(EditPaM(pNode, 20 + 1), EditPaM(pNode, 20 + 1)); + aEditEngine.InsertField(aSel2, aField2); // Assert Field Count - CPPUNIT_ASSERT_EQUAL( sal_uInt16(2), aEditEngine.GetFieldCount(0) ); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), aEditEngine.GetFieldCount(0)); // Assert URL Fields and text before copy // Check text @@ -626,36 +636,40 @@ void Test::testHyperlinkCopyPaste() CPPUNIT_ASSERT_EQUAL( u"sampletextforuser@example.comtestingexample@domain.comfeaturefields"_ustr, rDoc.GetParaAsString(sal_Int32(0)) ); // Check Field 1 - EFieldInfo aURLFieldInfo1 = aEditEngine.GetFieldInfo( sal_Int32(0), sal_uInt16(0) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(13), aURLFieldInfo1.aPosition.nIndex ); - CPPUNIT_ASSERT_EQUAL( sal_uInt16(EE_FEATURE_FIELD), aURLFieldInfo1.pFieldItem->Which() ); - SvxURLField* pURLField1 = dynamic_cast<SvxURLField*> ( const_cast<SvxFieldData*> (aURLFieldInfo1.pFieldItem->GetField()) ); + EFieldInfo aURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(0)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(13), aURLFieldInfo1.aPosition.nIndex); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(EE_FEATURE_FIELD), aURLFieldInfo1.pFieldItem->Which()); + SvxURLField* pURLField1 = dynamic_cast<SvxURLField*>( + const_cast<SvxFieldData*>(aURLFieldInfo1.pFieldItem->GetField())); CPPUNIT_ASSERT(pURLField1); - CPPUNIT_ASSERT_EQUAL( aURL1, pURLField1->GetURL() ); - CPPUNIT_ASSERT_EQUAL( aRepres1, pURLField1->GetRepresentation() ); + CPPUNIT_ASSERT_EQUAL(aURL1, pURLField1->GetURL()); + CPPUNIT_ASSERT_EQUAL(aRepres1, pURLField1->GetRepresentation()); // Check Field 2 - EFieldInfo aURLFieldInfo2 = aEditEngine.GetFieldInfo( sal_Int32(0), sal_uInt16(1) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(21), aURLFieldInfo2.aPosition.nIndex ); - CPPUNIT_ASSERT_EQUAL( sal_uInt16(EE_FEATURE_FIELD), aURLFieldInfo2.pFieldItem->Which() ); - SvxURLField* pURLField2 = dynamic_cast<SvxURLField*> ( const_cast<SvxFieldData*> (aURLFieldInfo2.pFieldItem->GetField()) ); + EFieldInfo aURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(21), aURLFieldInfo2.aPosition.nIndex); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(EE_FEATURE_FIELD), aURLFieldInfo2.pFieldItem->Which()); + SvxURLField* pURLField2 = dynamic_cast<SvxURLField*>( + const_cast<SvxFieldData*>(aURLFieldInfo2.pFieldItem->GetField())); CPPUNIT_ASSERT(pURLField2); - CPPUNIT_ASSERT_EQUAL( aURL2, pURLField2->GetURL() ); - CPPUNIT_ASSERT_EQUAL( aRepres2, pURLField2->GetRepresentation() ); + CPPUNIT_ASSERT_EQUAL(aURL2, pURLField2->GetURL()); + CPPUNIT_ASSERT_EQUAL(aRepres2, pURLField2->GetRepresentation()); // Copy text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,10,0,21) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 10, 0, 21)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert Changes ACP, ACP: after Copy/Paste // Check the fields count - CPPUNIT_ASSERT_EQUAL( sal_uInt16(3), aEditEngine.GetFieldCount(0) ); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), aEditEngine.GetFieldCount(0)); // Check the updated text length - CPPUNIT_ASSERT_EQUAL( aTextLen + 10 + aRepres1.getLength()*2 + aRepres2.getLength(), rDoc.GetTextLen() ); + CPPUNIT_ASSERT_EQUAL(aTextLen + 10 + aRepres1.getLength() * 2 + aRepres2.getLength(), + rDoc.GetTextLen()); // Check the updated text contents CPPUNIT_ASSERT_EQUAL( u"sampletextforuser@example.comtestingexample@domain.comfeaturefieldsforuser@example.comtesting"_ustr, rDoc.GetParaAsString(sal_Int32(0)) ); @@ -663,118 +677,142 @@ void Test::testHyperlinkCopyPaste() // Check the Fields and their values // Field 1 - EFieldInfo aACPURLFieldInfo1 = aEditEngine.GetFieldInfo( sal_Int32(0), sal_uInt16(0) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(13), aACPURLFieldInfo1.aPosition.nIndex ); - CPPUNIT_ASSERT_EQUAL( sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo1.pFieldItem->Which() ); - SvxURLField* pACPURLField1 = dynamic_cast<SvxURLField*> ( const_cast<SvxFieldData*> (aACPURLFieldInfo1.pFieldItem->GetField()) ); + EFieldInfo aACPURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(0)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(13), aACPURLFieldInfo1.aPosition.nIndex); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo1.pFieldItem->Which()); + SvxURLField* pACPURLField1 = dynamic_cast<SvxURLField*>( + const_cast<SvxFieldData*>(aACPURLFieldInfo1.pFieldItem->GetField())); CPPUNIT_ASSERT(pACPURLField1); - CPPUNIT_ASSERT_EQUAL( aURL1, pACPURLField1->GetURL() ); - CPPUNIT_ASSERT_EQUAL( aRepres1, pACPURLField1->GetRepresentation() ); + CPPUNIT_ASSERT_EQUAL(aURL1, pACPURLField1->GetURL()); + CPPUNIT_ASSERT_EQUAL(aRepres1, pACPURLField1->GetRepresentation()); // Field 2 - EFieldInfo aACPURLFieldInfo2 = aEditEngine.GetFieldInfo( sal_Int32(0), sal_uInt16(1) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(21), aACPURLFieldInfo2.aPosition.nIndex ); - CPPUNIT_ASSERT_EQUAL( sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo2.pFieldItem->Which() ); - SvxURLField* pACPURLField2 = dynamic_cast<SvxURLField*> ( const_cast<SvxFieldData*> (aACPURLFieldInfo2.pFieldItem->GetField()) ); + EFieldInfo aACPURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(1)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(21), aACPURLFieldInfo2.aPosition.nIndex); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo2.pFieldItem->Which()); + SvxURLField* pACPURLField2 = dynamic_cast<SvxURLField*>( + const_cast<SvxFieldData*>(aACPURLFieldInfo2.pFieldItem->GetField())); CPPUNIT_ASSERT(pACPURLField2); - CPPUNIT_ASSERT_EQUAL( aURL2, pACPURLField2->GetURL() ); - CPPUNIT_ASSERT_EQUAL( aRepres2, pACPURLField2->GetRepresentation() ) ; + CPPUNIT_ASSERT_EQUAL(aURL2, pACPURLField2->GetURL()); + CPPUNIT_ASSERT_EQUAL(aRepres2, pACPURLField2->GetRepresentation()); // Field 3 - EFieldInfo aACPURLFieldInfo3 = aEditEngine.GetFieldInfo( sal_Int32(0), sal_uInt16(2) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32(38), aACPURLFieldInfo3.aPosition.nIndex ); - CPPUNIT_ASSERT_EQUAL( sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo3.pFieldItem->Which() ); - SvxURLField* pACPURLField3 = dynamic_cast<SvxURLField*> ( const_cast<SvxFieldData*> (aACPURLFieldInfo3.pFieldItem->GetField()) ); + EFieldInfo aACPURLFieldInfo3 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(2)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(38), aACPURLFieldInfo3.aPosition.nIndex); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(EE_FEATURE_FIELD), aACPURLFieldInfo3.pFieldItem->Which()); + SvxURLField* pACPURLField3 = dynamic_cast<SvxURLField*>( + const_cast<SvxFieldData*>(aACPURLFieldInfo3.pFieldItem->GetField())); CPPUNIT_ASSERT(pACPURLField3); - CPPUNIT_ASSERT_EQUAL( aURL1, pACPURLField3->GetURL() ); - CPPUNIT_ASSERT_EQUAL( aRepres1, pACPURLField3->GetRepresentation() ); + CPPUNIT_ASSERT_EQUAL(aURL1, pACPURLField3->GetURL()); + CPPUNIT_ASSERT_EQUAL(aRepres1, pACPURLField3->GetRepresentation()); } void Test::testCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Set initial text OUString aText = u"This is custom initial text"_ustr; sal_Int32 aTextLen = aText.getLength(); - aEditEngine.SetText( aText ); + aEditEngine.SetText(aText); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aText, rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aText, rDoc.GetParaAsString(sal_Int32(0))); // Copy initial text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,0,0,aTextLen) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 0, 0, aTextLen)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen + aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen + aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0))); } /// XTransferable implementation that provides simple HTML content. -class TestHTMLTransferable : public cppu::WeakImplHelper<datatransfer::XTransferable> +class TestTransferable : public cppu::WeakImplHelper<datatransfer::XTransferable> { - OString m_aHTML; + std::vector<OString> m_aContent; + std::vector<OUString> m_aMimeType; + public: - TestHTMLTransferable(const OString& rHTML); + TestTransferable(std::vector<OString>& rContent, std::vector<OUString>& rMimeType); uno::Any SAL_CALL getTransferData(const datatransfer::DataFlavor& rFlavor) override; uno::Sequence<datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override; sal_Bool SAL_CALL isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor) override; }; -TestHTMLTransferable::TestHTMLTransferable(const OString& rHTML) - : m_aHTML(rHTML) +TestTransferable::TestTransferable(std::vector<OString>& rContent, std::vector<OUString>& rMimeType) + : m_aContent(rContent) + , m_aMimeType(rMimeType) { + CPPUNIT_ASSERT_EQUAL(m_aContent.size(), m_aMimeType.size()); } -uno::Any TestHTMLTransferable::getTransferData(const datatransfer::DataFlavor& rFlavor) +uno::Any TestTransferable::getTransferData(const datatransfer::DataFlavor& rFlavor) { - if (rFlavor.MimeType != "text/html") + for (size_t nType = 0; nType < m_aMimeType.size(); ++nType) { - return {}; + if (rFlavor.MimeType == m_aMimeType[nType]) + { + uno::Any aRet; + SvMemoryStream aStream; + aStream.WriteOString(m_aContent[nType]); + aRet <<= uno::Sequence<sal_Int8>(static_cast<const sal_Int8*>(aStream.GetData()), + aStream.GetSize()); + return aRet; + } } - - uno::Any aRet; - SvMemoryStream aStream; - aStream.WriteOString(m_aHTML); - aRet <<= uno::Sequence<sal_Int8>(static_cast<const sal_Int8*>(aStream.GetData()), aStream.GetSize()); - return aRet; + return {}; } -uno::Sequence<datatransfer::DataFlavor> TestHTMLTransferable::getTransferDataFlavors() +uno::Sequence<datatransfer::DataFlavor> TestTransferable::getTransferDataFlavors() { - datatransfer::DataFlavor aFlavor; - aFlavor.DataType = cppu::UnoType<uno::Sequence<sal_Int8>>::get(); - aFlavor.MimeType = "text/html"; - aFlavor.HumanPresentableName = aFlavor.MimeType; - return { aFlavor }; + std::vector<datatransfer::DataFlavor> aFlavourVac; + for (size_t nType = 0; nType < m_aMimeType.size(); ++nType) + { + datatransfer::DataFlavor aFlavor; + aFlavor.DataType = cppu::UnoType<uno::Sequence<sal_Int8>>::get(); + aFlavor.MimeType = m_aMimeType[nType]; + aFlavor.HumanPresentableName = aFlavor.MimeType; + aFlavourVac.push_back(aFlavor); + } + uno::Sequence<datatransfer::DataFlavor> aFlavors(aFlavourVac.data(), m_aMimeType.size()); + return aFlavors; } -sal_Bool TestHTMLTransferable::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor) +sal_Bool TestTransferable::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor) { - return rFlavor.MimeType == "text/html" - && rFlavor.DataType == cppu::UnoType<uno::Sequence<sal_Int8>>::get(); + for (size_t nType = 0; nType < m_aMimeType.size(); ++nType) + { + if (rFlavor.MimeType == m_aMimeType[nType] + && rFlavor.DataType == cppu::UnoType<uno::Sequence<sal_Int8>>::get()) + return true; + } + return false; } void Test::testHTMLPaste() { // Given an empty editeng document: EditEngine aEditEngine(mpItemPool.get()); - EditDoc &rDoc = aEditEngine.GetEditDoc(); - OString aHTML("<!DOCTYPE html>\n<html><body>test</body></html>"_ostr); - uno::Reference< datatransfer::XTransferable > xData(new TestHTMLTransferable(aHTML)); + EditDoc& rDoc = aEditEngine.GetEditDoc(); + //OString aHTML("<!DOCTYPE html>\n<html><body>test</body></html>"_ostr); + std::vector<OString> aContent({ "<!DOCTYPE html>\n<html><body>test</body></html>"_ostr }); + std::vector<OUString> aMime({ "text/html" }); + uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); // When trying to paste HTML: aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); @@ -790,9 +828,11 @@ void Test::testHTMLFragmentPaste() { // Given an empty editeng document: EditEngine aEditEngine(mpItemPool.get()); - EditDoc &rDoc = aEditEngine.GetEditDoc(); - OString aHTML("a<b>b</b>c"_ostr); - uno::Reference< datatransfer::XTransferable > xData(new TestHTMLTransferable(aHTML)); + EditDoc& rDoc = aEditEngine.GetEditDoc(); + std::vector<OString> aContent({ "a<b>b</b>c"_ostr }); + std::vector<OUString> aMime({ "text/html" }); + + uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); // When trying to paste an HTML fragment: aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); @@ -805,17 +845,71 @@ void Test::testHTMLFragmentPaste() CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, rDoc.GetParaAsString(static_cast<sal_Int32>(0))); } +void Test::testRTFPaste() +{ + // Given an empty editeng document: + EditEngine aEditEngine(mpItemPool.get()); + EditDoc& rDoc = aEditEngine.GetEditDoc(); + std::vector<OString> aContent( + { "{\\rtf1\\adeflang1025\\ansi{\\ul www.libreoffice.org}}"_ostr }); + std::vector<OUString> aMime({ "text/richtext" }); + uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); + + // When trying to paste HTML: + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); + + // Then make sure the text gets pasted: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: www.libreoffice.org + // - Actual : + // i.e. RTF and plain text paste worked, but not HTML. + CPPUNIT_ASSERT_EQUAL(OUString("www.libreoffice.org"), + rDoc.GetParaAsString(static_cast<sal_Int32>(0))); +} + +void Test::testRTFHTMLPaste() +{ + // Given an empty editeng document: + EditEngine aEditEngine(mpItemPool.get()); + EditDoc& rDoc = aEditEngine.GetEditDoc(); + std::vector<OString> aContent( + { "{\\rtf1\\adeflang1025\\ansi{\\ul www.libreoffice.org}}"_ostr, + "Version:1.0\nStartHTML:0000000121\n" + "EndHTML:0000000596\n" + "StartFragment:0000000519\n" + "EndFragment:0000000579\n" + "<!DOCTYPE html><html><head><meta http-equiv=\"content-type\" content=\"text/html; " + "charset=utf-8\"/>" + "<title></title><meta name=\"generator\" content=\"LibreOffice 7.4.5.1 (Windows)\"/>" + "<style type=\"text/css\">@page { size: 21cm 29.7cm; margin: 2cm }" + "p{ line-height: 115%; margin-bottom: 0.25cm; background: transparent }</style>" + "</head><body lang=\"de-DE\" link=\"#000080\" vlink=\"#800000\" dir=\"ltr\">" + "<p style=\"line-height: 100%; margin-bottom: 0cm\">abc</p></body></html>"_ostr }); + std::vector<OUString> aMime( + { "text/richtext", + "application/x-openoffice-html-simple;windows_formatname=\"HTML Format\"" }); + uno::Reference<datatransfer::XTransferable> xData(new TestTransferable(aContent, aMime)); + + // When trying to paste HTML: + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); + + // Then make sure the text gets pasted: + // expected "abc" + // wrong: www.libreoffice.org + // i.e. HTML is preferred over HTML. + CPPUNIT_ASSERT_EQUAL(OUString("abc"), rDoc.GetParaAsString(static_cast<sal_Int32>(0))); +} void Test::testMultiParaSelCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Insert initial text OUString aFirstPara = u"This is first paragraph"_ustr; @@ -830,16 +924,17 @@ void Test::testMultiParaSelCopyPaste() sal_Int32 aCopyTextLen = aCopyText.getLength(); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdPara, rDoc.GetParaAsString(sal_Int32(2))); // Copy initial text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,8,1,14) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 8, 1, 14)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes OUString aThirdParaAfterCopyPaste = aThirdPara + "first paragraph"; @@ -853,50 +948,51 @@ void Test::testMultiParaSelCopyPaste() void Test::testTabsCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // New instance must be empty - no initial text - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Get corresponding Item for inserting tabs in the text - SfxVoidItem aTab( EE_FEATURE_TAB ); + SfxVoidItem aTab(EE_FEATURE_TAB); // Insert initial text OUString aParaText = u"sampletextfortestingtab"_ustr; // Positions Ref ......*6...............*23 sal_Int32 aTextLen = aParaText.getLength(); - aEditEngine.SetText( aParaText ); + aEditEngine.SetText(aParaText); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aParaText, rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aParaText, rDoc.GetParaAsString(sal_Int32(0))); // Insert tab 1 at desired position - ContentNode *pNode = rDoc.GetObject(0); - EditSelection aSel1( EditPaM(pNode, 6), EditPaM(pNode, 6) ); - aEditEngine.InsertFeature( aSel1, aTab ); + ContentNode* pNode = rDoc.GetObject(0); + EditSelection aSel1(EditPaM(pNode, 6), EditPaM(pNode, 6)); + aEditEngine.InsertFeature(aSel1, aTab); // Assert changes CPPUNIT_ASSERT_EQUAL( aTextLen + 1, rDoc.GetTextLen() ); CPPUNIT_ASSERT_EQUAL( u"sample\ttextfortestingtab"_ustr, rDoc.GetParaAsString(sal_Int32(0)) ); // Insert tab 2 at desired position - EditSelection aSel2( EditPaM(pNode, 23+1), EditPaM(pNode, 23+1) ); - aEditEngine.InsertFeature( aSel2, aTab ); + EditSelection aSel2(EditPaM(pNode, 23 + 1), EditPaM(pNode, 23 + 1)); + aEditEngine.InsertFeature(aSel2, aTab); // Assert changes CPPUNIT_ASSERT_EQUAL( aTextLen + 2, rDoc.GetTextLen() ); CPPUNIT_ASSERT_EQUAL( u"sample\ttextfortestingtab\t"_ustr, rDoc.GetParaAsString(sal_Int32(0)) ); // Copy text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,6,0,aTextLen+2) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 6, 0, aTextLen + 2)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes CPPUNIT_ASSERT_EQUAL( aTextLen + aTextLen - 6 + 4, rDoc.GetTextLen() ); @@ -906,9 +1002,14 @@ void Test::testTabsCopyPaste() class UrlEditEngine : public EditEngine { public: - explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {} + explicit UrlEditEngine(SfxItemPool* pPool) + : EditEngine(pPool) + { + } - virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, std::optional<Color>&, std::optional<Color>&, std::optional<FontLineStyle>& ) override + virtual OUString CalcFieldValue(const SvxFieldItem&, sal_Int32, sal_Int32, + std::optional<Color>&, std::optional<Color>&, + std::optional<FontLineStyle>&) override { return u"jim@bob.com"_ustr; // a sophisticated view of value: } @@ -919,14 +1020,14 @@ public: void Test::testHyperlinkSearch() { UrlEditEngine aEngine(mpItemPool.get()); - EditDoc &rDoc = aEngine.GetEditDoc(); + EditDoc& rDoc = aEngine.GetEditDoc(); OUString aSampleText = u"Please write email to . if you find a fish(not a dog)."_ustr; aEngine.SetText(aSampleText); CPPUNIT_ASSERT_EQUAL_MESSAGE("set text", aSampleText, rDoc.GetParaAsString(sal_Int32(0))); - ContentNode *pNode = rDoc.GetObject(0); + ContentNode* pNode = rDoc.GetObject(0); EditSelection aSel(EditPaM(pNode, 22), EditPaM(pNode, 22)); SvxURLField aURLField(u"mailto:///jim@bob.com"_ustr, u"jim@bob.com"_ustr, SvxURLFormat::Repr); @@ -940,37 +1041,33 @@ void Test::testHyperlinkSearch() CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong length", aContent.getLength(), rDoc.GetTextLen()); // Check expansion and positioning re-work - CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong length", aContent.getLength(), - pNode->GetExpandedLen()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong length", aContent.getLength(), pNode->GetExpandedLen()); for (sal_Int32 n = 0; n < aContent.getLength(); n++) { sal_Int32 nStart = n, nEnd = n; - pNode->UnExpandPositions(nStart,nEnd); + pNode->UnExpandPositions(nStart, nEnd); CPPUNIT_ASSERT_MESSAGE("out of bound start", nStart < pNode->Len()); CPPUNIT_ASSERT_MESSAGE("out of bound end", nEnd <= pNode->Len()); } - static const struct { + static const struct + { sal_Int32 mnStart, mnEnd; sal_Int32 mnNewStart, mnNewEnd; - } aTrickyOnes[] = { - { 0, 1, /* -> */ 0, 1 }, - { 21, 25, /* -> */ 21, 23 }, // the field is really just one char - { 25, 27, /* -> */ 22, 23 }, - { 50, 56, /* -> */ 40, 46 } - }; + } aTrickyOnes[] = { { 0, 1, /* -> */ 0, 1 }, + { 21, 25, /* -> */ 21, 23 }, // the field is really just one char + { 25, 27, /* -> */ 22, 23 }, + { 50, 56, /* -> */ 40, 46 } }; for (size_t n = 0; n < SAL_N_ELEMENTS(aTrickyOnes); n++) { sal_Int32 nStart = aTrickyOnes[n].mnStart; sal_Int32 nEnd = aTrickyOnes[n].mnEnd; - pNode->UnExpandPositions(nStart,nEnd); - - CPPUNIT_ASSERT_EQUAL_MESSAGE( - OString("in row " + OString::number(n)).getStr(), - aTrickyOnes[n].mnNewStart, nStart); - CPPUNIT_ASSERT_EQUAL_MESSAGE( - OString("in row " + OString::number(n)).getStr(), - aTrickyOnes[n].mnNewEnd, nEnd); + pNode->UnExpandPositions(nStart, nEnd); + + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("in row " + OString::number(n)).getStr(), + aTrickyOnes[n].mnNewStart, nStart); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("in row " + OString::number(n)).getStr(), + aTrickyOnes[n].mnNewEnd, nEnd); } SvxSearchItem aItem(1); //SID_SEARCH_ITEM); @@ -984,38 +1081,38 @@ void Test::testHyperlinkSearch() bool hasBold(const editeng::Section& rSecAttr) { - return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), - [](const SfxPoolItem* p) { + return std::any_of( + rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), [](const SfxPoolItem* p) { return p->Which() == EE_CHAR_WEIGHT - && static_cast<const SvxWeightItem*>(p)->GetWeight() == WEIGHT_BOLD; + && static_cast<const SvxWeightItem*>(p)->GetWeight() == WEIGHT_BOLD; }); } bool hasItalic(const editeng::Section& rSecAttr) { - return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), - [](const SfxPoolItem* p) { + return std::any_of( + rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), [](const SfxPoolItem* p) { return p->Which() == EE_CHAR_ITALIC - && static_cast<const SvxPostureItem*>(p)->GetPosture() == ITALIC_NORMAL; + && static_cast<const SvxPostureItem*>(p)->GetPosture() == ITALIC_NORMAL; }); } void Test::testBoldItalicCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // New instance must be empty - no initial text - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Get corresponding ItemSet for inserting Bold/Italic text - std::unique_ptr<SfxItemSet> pSet( new SfxItemSet(aEditEngine.GetEmptyItemSet()) ); - SvxWeightItem aBold( WEIGHT_BOLD, EE_CHAR_WEIGHT ); - SvxPostureItem aItalic( ITALIC_NORMAL, EE_CHAR_ITALIC ); + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); + SvxWeightItem aBold(WEIGHT_BOLD, EE_CHAR_WEIGHT); + SvxPostureItem aItalic(ITALIC_NORMAL, EE_CHAR_ITALIC); // Insert initial text OUString aParaText = u"boldeditengineitalic"_ustr; @@ -1023,268 +1120,272 @@ void Test::testBoldItalicCopyPaste() // Bold Ref ..[ BOLD ]...... // Italic Ref ........[ ITALIC ].. sal_Int32 aTextLen = aParaText.getLength(); - aEditEngine.SetText( aParaText ); + aEditEngine.SetText(aParaText); // Assert changes - text insertion - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aParaText, rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aParaText, rDoc.GetParaAsString(sal_Int32(0))); // Apply Bold to appropriate selection pSet->Put(aBold); - CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1), pSet->Count() ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(0,2,0,14) ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 2, 0, 14)); // Assert changes - std::unique_ptr<EditTextObject> pEditText1( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText1(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs1; - pEditText1->GetAllSections( aAttrs1 ); + pEditText1->GetAllSections(aAttrs1); // There should be 3 sections - woBold - wBold - woBold (w - with, wo - without) - CPPUNIT_ASSERT_EQUAL( size_t(3), aAttrs1.size() ); + CPPUNIT_ASSERT_EQUAL(size_t(3), aAttrs1.size()); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs1[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs1[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].maAttributes.size())); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs1[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs1[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs1[1]) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs1[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs1[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs1[1])); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs1[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 20, static_cast<int>(aAttrs1[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs1[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(20, static_cast<int>(aAttrs1[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].maAttributes.size())); // Apply Italic to appropriate selection - pSet.reset( new SfxItemSet(aEditEngine.GetEmptyItemSet()) ); + pSet.reset(new SfxItemSet(aEditEngine.GetEmptyItemSet())); pSet->Put(aItalic); - CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1), pSet->Count() ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(0,8,0,18) ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 8, 0, 18)); // Assert changes - std::unique_ptr<EditTextObject> pEditText2( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText2(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs2; - pEditText2->GetAllSections( aAttrs2 ); + pEditText2->GetAllSections(aAttrs2); // There should be 5 sections - woBold&woItalic - wBold&woItalic - wBold&wItalic - woBold&wItalic - woBold&woItalic (w - with, wo - without) - CPPUNIT_ASSERT_EQUAL( size_t(5), aAttrs2.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 8, static_cast<int>(aAttrs2[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs2[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 8, static_cast<int>(aAttrs2[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs2[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[2].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs2[2]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs2[2]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs2[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[3].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs2[3]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[4].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[4].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 20, static_cast<int>(aAttrs2[4].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[4].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(size_t(5), aAttrs2.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(aAttrs2[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs2[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(aAttrs2[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs2[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[2].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs2[2])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs2[2])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs2[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[3].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs2[3])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[4].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[4].mnStart)); + CPPUNIT_ASSERT_EQUAL(20, static_cast<int>(aAttrs2[4].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[4].maAttributes.size())); // Copy text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,1,0,aTextLen-1) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 1, 0, aTextLen - 1)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen + aTextLen - 2, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(aParaText + "oldeditengineitali" ), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen + aTextLen - 2, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(aParaText + "oldeditengineitali"), + rDoc.GetParaAsString(sal_Int32(0))); // Check updated text for appropriate Bold/Italics - std::unique_ptr<EditTextObject> pEditText3( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText3(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs3; - pEditText3->GetAllSections( aAttrs3 ); + pEditText3->GetAllSections(aAttrs3); // There should be 9 sections - woBold&woItalic - wBold&woItalic - wBold&wItalic - woBold&wItalic - woBold&woItalic - wBold&woItalic // - wBold&wItalic - woBold&wItalic - woBold&woItalic(w - with, wo - without) - CPPUNIT_ASSERT_EQUAL( size_t(9), aAttrs3.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 8, static_cast<int>(aAttrs3[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 8, static_cast<int>(aAttrs3[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs3[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[2].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[2]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[2]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs3[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs3[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[3].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[3]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[4].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs3[4].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 21, static_cast<int>(aAttrs3[4].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[4].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[5].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 21, static_cast<int>(aAttrs3[5].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 27, static_cast<int>(aAttrs3[5].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[5].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[5]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[6].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 27, static_cast<int>(aAttrs3[6].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 33, static_cast<int>(aAttrs3[6].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[6].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[6]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[6]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[7].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 33, static_cast<int>(aAttrs3[7].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 37, static_cast<int>(aAttrs3[7].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[7].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[7]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[8].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 37, static_cast<int>(aAttrs3[8].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 38, static_cast<int>(aAttrs3[8].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[8].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(size_t(9), aAttrs3.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(aAttrs3[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(aAttrs3[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs3[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[2].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[2])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[2])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs3[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs3[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[3].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[3])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[4].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs3[4].mnStart)); + CPPUNIT_ASSERT_EQUAL(21, static_cast<int>(aAttrs3[4].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[4].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[5].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(21, static_cast<int>(aAttrs3[5].mnStart)); + CPPUNIT_ASSERT_EQUAL(27, static_cast<int>(aAttrs3[5].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[5].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[5])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[6].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(27, static_cast<int>(aAttrs3[6].mnStart)); + CPPUNIT_ASSERT_EQUAL(33, static_cast<int>(aAttrs3[6].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[6].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[6])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[6])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[7].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(33, static_cast<int>(aAttrs3[7].mnStart)); + CPPUNIT_ASSERT_EQUAL(37, static_cast<int>(aAttrs3[7].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[7].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[7])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[8].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(37, static_cast<int>(aAttrs3[8].mnStart)); + CPPUNIT_ASSERT_EQUAL(38, static_cast<int>(aAttrs3[8].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[8].maAttributes.size())); } // Auxiliary function to test Underline text Copy/Paste using Legacy Format bool hasUnderline(const editeng::Section& rSecAttr) { - return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), - [](const SfxPoolItem* p) { + return std::any_of( + rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), [](const SfxPoolItem* p) { return p->Which() == EE_CHAR_UNDERLINE - && static_cast<const SvxUnderlineItem*>(p)->GetLineStyle() == LINESTYLE_SINGLE; + && static_cast<const SvxUnderlineItem*>(p)->GetLineStyle() == LINESTYLE_SINGLE; }); } void Test::testUnderlineCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // New instance must be empty - no initial text - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Get corresponding ItemSet for inserting Underline text - std::unique_ptr<SfxItemSet> pSet( new SfxItemSet(aEditEngine.GetEmptyItemSet()) ); - SvxUnderlineItem aULine( LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ); + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); + SvxUnderlineItem aULine(LINESTYLE_SINGLE, EE_CHAR_UNDERLINE); // Insert initial text OUString aParaText = u"sampletextforunderline"_ustr; // Positions Ref ......*6.........*17.. // Underline Ref ......[UNDERLINE ].... sal_Int32 aTextLen = aParaText.getLength(); - aEditEngine.SetText( aParaText ); + aEditEngine.SetText(aParaText); // Apply Underline style - pSet->Put( aULine ); - CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1), pSet->Count() ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(0,6,0,18) ); + pSet->Put(aULine); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 6, 0, 18)); // Assert changes - std::unique_ptr<EditTextObject> pEditText1( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText1(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs1; - pEditText1->GetAllSections( aAttrs1 ); + pEditText1->GetAllSections(aAttrs1); // There should be 3 sections - woUnderline - wUnderline - woUnderline (w - with, wo - without) - CPPUNIT_ASSERT_EQUAL( size_t(3), aAttrs1.size() ); + CPPUNIT_ASSERT_EQUAL(size_t(3), aAttrs1.size()); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 6, static_cast<int>(aAttrs1[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(6, static_cast<int>(aAttrs1[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].maAttributes.size())); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 6, static_cast<int>(aAttrs1[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs1[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be underlined.", hasUnderline(aAttrs1[1]) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(6, static_cast<int>(aAttrs1[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs1[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be underlined.", hasUnderline(aAttrs1[1])); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs1[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 22, static_cast<int>(aAttrs1[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs1[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(22, static_cast<int>(aAttrs1[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].maAttributes.size())); // Copy text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,6,0,aTextLen-4) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 6, 0, aTextLen - 4)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes - CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(aTextLen + strlen("textforunder")), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(aParaText + "textforunder" ), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aTextLen + strlen("textforunder")), + rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(aParaText + "textforunder"), rDoc.GetParaAsString(sal_Int32(0))); // Check updated text for appropriate Underline - std::unique_ptr<EditTextObject> pEditText2( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText2(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs2; - pEditText2->GetAllSections( aAttrs2 ); + pEditText2->GetAllSections(aAttrs2); // There should be 4 sections - woUnderline - wUnderline - woUnderline - wUnderline (w - with, wo - without) - CPPUNIT_ASSERT_EQUAL( size_t(4), aAttrs2.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 6, static_cast<int>(aAttrs2[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 6, static_cast<int>(aAttrs2[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be underlined.", hasUnderline(aAttrs2[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 22, static_cast<int>(aAttrs2[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[2].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 22, static_cast<int>(aAttrs2[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 34, static_cast<int>(aAttrs2[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[3].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be underlined.", hasUnderline(aAttrs2[3]) ); + CPPUNIT_ASSERT_EQUAL(size_t(4), aAttrs2.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(6, static_cast<int>(aAttrs2[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(6, static_cast<int>(aAttrs2[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be underlined.", hasUnderline(aAttrs2[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(22, static_cast<int>(aAttrs2[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[2].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(22, static_cast<int>(aAttrs2[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(34, static_cast<int>(aAttrs2[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[3].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be underlined.", hasUnderline(aAttrs2[3])); } void Test::testMultiParaCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Insert initial text OUString aFirstPara = u"This is first paragraph"_ustr; @@ -1292,46 +1393,47 @@ void Test::testMultiParaCopyPaste() OUString aThirdPara = u"This is third paragraph"_ustr; OUString aText = aFirstPara + "\n" + aSecondPara + "\n" + aThirdPara; sal_Int32 aTextLen = aFirstPara.getLength() + aSecondPara.getLength() + aThirdPara.getLength(); - aEditEngine.SetText( aText ); + aEditEngine.SetText(aText); sal_Int32 aCopyTextLen = aFirstPara.getLength() + aSecondPara.getLength(); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdPara, rDoc.GetParaAsString(sal_Int32(2))); // Copy initial text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,0,1,aSecondPara.getLength()) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 0, 1, aSecondPara.getLength())); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes OUString aThirdParaAfterCopyPaste = aThirdPara + aFirstPara; - CPPUNIT_ASSERT_EQUAL( aTextLen + aCopyTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdParaAfterCopyPaste, rDoc.GetParaAsString(sal_Int32(2)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(3)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen + aCopyTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdParaAfterCopyPaste, rDoc.GetParaAsString(sal_Int32(2))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(3))); } void Test::testParaBoldItalicCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Get corresponding ItemSet for inserting Bold/Italic text - std::unique_ptr<SfxItemSet> pSet( new SfxItemSet(aEditEngine.GetEmptyItemSet()) ); - SvxWeightItem aBold( WEIGHT_BOLD, EE_CHAR_WEIGHT ); - SvxPostureItem aItalic( ITALIC_NORMAL, EE_CHAR_ITALIC ); + std::unique_ptr<SfxItemSet> pSet(new SfxItemSet(aEditEngine.GetEmptyItemSet())); + SvxWeightItem aBold(WEIGHT_BOLD, EE_CHAR_WEIGHT); + SvxPostureItem aItalic(ITALIC_NORMAL, EE_CHAR_ITALIC); // Insert initial text OUString aFirstPara = u"This is first paragraph"_ustr; @@ -1352,132 +1454,133 @@ void Test::testParaBoldItalicCopyPaste() sal_Int32 aCopyTextLen = aCopyText.getLength(); // Assert changes - text insertion - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdPara, rDoc.GetParaAsString(sal_Int32(2))); // Apply Bold to appropriate selections pSet->Put(aBold); - CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1), pSet->Count() ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(0,5,0,18) ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(1,5,1,19) ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 5, 0, 18)); + aEditEngine.QuickSetAttribs(*pSet, ESelection(1, 5, 1, 19)); // Assert changes - std::unique_ptr<EditTextObject> pEditText1( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText1(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs1; - pEditText1->GetAllSections( aAttrs1 ); + pEditText1->GetAllSections(aAttrs1); // There should be 7 sections - woB - wB - woB -woB -wB -woB -woB (w - with, wo - without, B - Bold, I - Italic) - CPPUNIT_ASSERT_EQUAL( size_t(7), aAttrs1.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs1[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs1[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs1[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs1[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs1[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs1[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[2].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs1[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[3].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[4].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs1[4].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs1[4].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[4].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs1[4]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs1[5].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs1[5].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 24, static_cast<int>(aAttrs1[5].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[5].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs1[6].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[6].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs1[6].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs1[6].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(size_t(7), aAttrs1.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs1[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs1[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs1[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs1[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs1[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs1[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[2].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs1[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[3].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[4].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs1[4].mnStart)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs1[4].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[4].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs1[4])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs1[5].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs1[5].mnStart)); + CPPUNIT_ASSERT_EQUAL(24, static_cast<int>(aAttrs1[5].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[5].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs1[6].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[6].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs1[6].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs1[6].maAttributes.size())); // Apply Italic to appropriate selection - pSet.reset( new SfxItemSet(aEditEngine.GetEmptyItemSet()) ); + pSet.reset(new SfxItemSet(aEditEngine.GetEmptyItemSet())); pSet->Put(aItalic); - CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1), pSet->Count() ); - aEditEngine.QuickSetAttribs( *pSet, ESelection(0,14,1,9) ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), pSet->Count()); + aEditEngine.QuickSetAttribs(*pSet, ESelection(0, 14, 1, 9)); // Assert changes - std::unique_ptr<EditTextObject> pEditText2( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText2(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs2; - pEditText2->GetAllSections( aAttrs2 ); + pEditText2->GetAllSections(aAttrs2); // There should be 9 sections - woB&woI - wB&woI - wB&wI -woB&wI - woB&wI - wB&wI - wB&woI - woB&woI - woB&woI (w - with, wo - without, B - Bold, I - Italic) - CPPUNIT_ASSERT_EQUAL( size_t(9), aAttrs2.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs2[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs2[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs2[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs2[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs2[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[2].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs2[2]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs2[2]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs2[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs2[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[3].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs2[3]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[4].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[4].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs2[4].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[4].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs2[4]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[5].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs2[5].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs2[5].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[5].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs2[5]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs2[5]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[6].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs2[6].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs2[6].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[6].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs2[6]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs2[7].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs2[7].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 24, static_cast<int>(aAttrs2[7].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[7].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs2[8].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[8].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs2[8].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs2[8].maAttributes.size()) ); + CPPUNIT_ASSERT_EQUAL(size_t(9), aAttrs2.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs2[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs2[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs2[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs2[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs2[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[2].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs2[2])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs2[2])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs2[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs2[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[3].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs2[3])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[4].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[4].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs2[4].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[4].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs2[4])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[5].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs2[5].mnStart)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs2[5].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[5].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs2[5])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs2[5])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[6].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs2[6].mnStart)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs2[6].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[6].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs2[6])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs2[7].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs2[7].mnStart)); + CPPUNIT_ASSERT_EQUAL(24, static_cast<int>(aAttrs2[7].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[7].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs2[8].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[8].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs2[8].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs2[8].maAttributes.size())); // Copy text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,8,1,14) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 8, 1, 14)); // Paste text at the end - aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetEndPaM(), true); // Assert changes OUString aThirdParaAfterCopyPaste = aThirdPara + "first paragraph"; @@ -1488,116 +1591,116 @@ void Test::testParaBoldItalicCopyPaste() CPPUNIT_ASSERT_EQUAL( u"This is second"_ustr, rDoc.GetParaAsString(sal_Int32(3)) ); // Check updated text for appropriate Bold/Italics - std::unique_ptr<EditTextObject> pEditText3( aEditEngine.CreateTextObject() ); + std::unique_ptr<EditTextObject> pEditText3(aEditEngine.CreateTextObject()); std::vector<editeng::Section> aAttrs3; - pEditText3->GetAllSections( aAttrs3 ); + pEditText3->GetAllSections(aAttrs3); // There should be 15 sections - woB&woI - wB&woI - wB&wI -woB&wI - woB&wI - wB&wI - wB&woI - woB&woI - woB&woI // - wB&woI - wB&wI - woB&wI - -woB&wI - wB&wI - wB&woI (w - with, wo - without, B - Bold, I - Italic) - CPPUNIT_ASSERT_EQUAL( size_t(15), aAttrs3.size() ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[0].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[0].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[1].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[1].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs3[1].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[1].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[1]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[2].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs3[2].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs3[2].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[2].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[2]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[2]) ); - - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[3].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 18, static_cast<int>(aAttrs3[3].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs3[3].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[3].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[3]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[4].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[4].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[4].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[4].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[4]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[5].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[5].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs3[5].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[5].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[5]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[5]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[6].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs3[6].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs3[6].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[6].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[6]) ); - - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[7].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 19, static_cast<int>(aAttrs3[7].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 24, static_cast<int>(aAttrs3[7].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[7].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[8].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[8].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs3[8].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[8].maAttributes.size()) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[9].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 23, static_cast<int>(aAttrs3[9].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 29, static_cast<int>(aAttrs3[9].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[9].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[9]) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[10].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 29, static_cast<int>(aAttrs3[10].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 33, static_cast<int>(aAttrs3[10].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[10].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[10]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[10]) ); - - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[11].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 33, static_cast<int>(aAttrs3[11].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 38, static_cast<int>(aAttrs3[11].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[11].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[11]) ); - - CPPUNIT_ASSERT_EQUAL( 3, static_cast<int>(aAttrs3[12].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 0, static_cast<int>(aAttrs3[12].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[12].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[12].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be italic.", hasItalic(aAttrs3[12]) ); - - CPPUNIT_ASSERT_EQUAL( 3, static_cast<int>(aAttrs3[13].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 5, static_cast<int>(aAttrs3[13].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs3[13].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 2, static_cast<int>(aAttrs3[13].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasBold(aAttrs3[13]) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold and italic.", hasItalic(aAttrs3[13]) ); - - CPPUNIT_ASSERT_EQUAL( 3, static_cast<int>(aAttrs3[14].mnParagraph) ); - CPPUNIT_ASSERT_EQUAL( 9, static_cast<int>(aAttrs3[14].mnStart) ); - CPPUNIT_ASSERT_EQUAL( 14, static_cast<int>(aAttrs3[14].mnEnd) ); - CPPUNIT_ASSERT_EQUAL( 1, static_cast<int>(aAttrs3[14].maAttributes.size()) ); - CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(aAttrs3[14]) ); + CPPUNIT_ASSERT_EQUAL(size_t(15), aAttrs3.size()); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[0].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[0].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[1].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[1].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs3[1].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[1].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[1])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[2].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs3[2].mnStart)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs3[2].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[2].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[2])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[2])); + + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[3].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(18, static_cast<int>(aAttrs3[3].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs3[3].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[3].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[3])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[4].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[4].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[4].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[4].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[4])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[5].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[5].mnStart)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs3[5].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[5].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[5])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[5])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[6].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs3[6].mnStart)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs3[6].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[6].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[6])); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[7].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(19, static_cast<int>(aAttrs3[7].mnStart)); + CPPUNIT_ASSERT_EQUAL(24, static_cast<int>(aAttrs3[7].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[7].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[8].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[8].mnStart)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs3[8].mnEnd)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[8].maAttributes.size())); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[9].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(23, static_cast<int>(aAttrs3[9].mnStart)); + CPPUNIT_ASSERT_EQUAL(29, static_cast<int>(aAttrs3[9].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[9].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[9])); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[10].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(29, static_cast<int>(aAttrs3[10].mnStart)); + CPPUNIT_ASSERT_EQUAL(33, static_cast<int>(aAttrs3[10].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[10].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[10])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[10])); + + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[11].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(33, static_cast<int>(aAttrs3[11].mnStart)); + CPPUNIT_ASSERT_EQUAL(38, static_cast<int>(aAttrs3[11].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[11].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[11])); + + CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(aAttrs3[12].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs3[12].mnStart)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[12].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[12].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(aAttrs3[12])); + + CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(aAttrs3[13].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(aAttrs3[13].mnStart)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs3[13].mnEnd)); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(aAttrs3[13].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(aAttrs3[13])); + CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasItalic(aAttrs3[13])); + + CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(aAttrs3[14].mnParagraph)); + CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aAttrs3[14].mnStart)); + CPPUNIT_ASSERT_EQUAL(14, static_cast<int>(aAttrs3[14].mnEnd)); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aAttrs3[14].maAttributes.size())); + CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(aAttrs3[14])); } void Test::testParaStartCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Insert initial text OUString aFirstPara = u"This is first paragraph"_ustr; @@ -1612,16 +1715,17 @@ void Test::testParaStartCopyPaste() sal_Int32 aCopyTextLen = aCopyText.getLength(); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdPara, rDoc.GetParaAsString(sal_Int32(2))); // Copy initial text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,8,1,14) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(0, 8, 1, 14)); // Paste text at the start - aEditEngine.InsertText( xData, OUString(), rDoc.GetStartPaM(), true ); + aEditEngine.InsertText(xData, OUString(), rDoc.GetStartPaM(), true); // Assert changes OUString aSecondParaAfterCopyPaste = "This is second" + aFirstPara; @@ -1643,20 +1747,24 @@ void Test::testSectionAttributes() { aEngine.SetText(u"aaabbbccc"_ustr); pSet->Put(aBold); - CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", static_cast<sal_uInt16>(1), pSet->Count()); - aEngine.QuickSetAttribs(*pSet, ESelection(0,0,0,6)); // 'aaabbb' - end point is not inclusive. + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", + static_cast<sal_uInt16>(1), pSet->Count()); + aEngine.QuickSetAttribs(*pSet, + ESelection(0, 0, 0, 6)); // 'aaabbb' - end point is not inclusive. pSet.reset(new SfxItemSet(aEngine.GetEmptyItemSet())); pSet->Put(aItalic); - CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", static_cast<sal_uInt16>(1), pSet->Count()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", + static_cast<sal_uInt16>(1), pSet->Count()); - aEngine.QuickSetAttribs(*pSet, ESelection(0,3,0,9)); // 'bbbccc' + aEngine.QuickSetAttribs(*pSet, ESelection(0, 3, 0, 9)); // 'bbbccc' std::unique_ptr<EditTextObject> pEditText(aEngine.CreateTextObject()); CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText); std::vector<editeng::Section> aAttrs; pEditText->GetAllSections(aAttrs); // Now, we should have a total of 3 sections. - CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 3 sections.", static_cast<size_t>(3), aAttrs.size()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 3 sections.", static_cast<size_t>(3), + aAttrs.size()); // First section should be 0-3 of paragraph 0, and it should only have boldness applied. CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(aAttrs[0].mnParagraph)); @@ -1692,10 +1800,11 @@ void Test::testSectionAttributes() // Apply boldness to paragraphs 1, 3, 5 only. Leave 2 and 4 unformatted. pSet.reset(new SfxItemSet(aEngine.GetEmptyItemSet())); pSet->Put(aBold); - CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", static_cast<sal_uInt16>(1), pSet->Count()); - aEngine.QuickSetAttribs(*pSet, ESelection(0,0,0,3)); - aEngine.QuickSetAttribs(*pSet, ESelection(2,0,2,3)); - aEngine.QuickSetAttribs(*pSet, ESelection(4,0,4,5)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one item.", + static_cast<sal_uInt16>(1), pSet->Count()); + aEngine.QuickSetAttribs(*pSet, ESelection(0, 0, 0, 3)); + aEngine.QuickSetAttribs(*pSet, ESelection(2, 0, 2, 3)); + aEngine.QuickSetAttribs(*pSet, ESelection(4, 0, 4, 5)); std::unique_ptr<EditTextObject> pEditText(aEngine.CreateTextObject()); CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText); @@ -1734,7 +1843,6 @@ void Test::testSectionAttributes() CPPUNIT_ASSERT_MESSAGE("Attribute array should be empty.", aAttrs[3].maAttributes.empty()); } - { aEngine.Clear(); aEngine.SetText(u"one\ntwo"_ustr); @@ -1743,14 +1851,14 @@ void Test::testSectionAttributes() // embolden 2nd paragraph pSet.reset(new SfxItemSet(aEngine.GetEmptyItemSet())); pSet->Put(aBold); - aEngine.QuickSetAttribs(*pSet, ESelection(1,0,1,3)); + aEngine.QuickSetAttribs(*pSet, ESelection(1, 0, 1, 3)); // disboldify 1st paragraph SvxWeightItem aNotSoBold(WEIGHT_NORMAL, EE_CHAR_WEIGHT); pSet->Put(aNotSoBold); - aEngine.QuickSetAttribs(*pSet, ESelection(0,0,0,3)); + aEngine.QuickSetAttribs(*pSet, ESelection(0, 0, 0, 3)); // now delete & join the paragraphs - this is fdo#85496 scenario - aEngine.QuickDelete(ESelection(0,0,1,3)); + aEngine.QuickDelete(ESelection(0, 0, 1, 3)); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aEngine.GetParagraphCount()); std::unique_ptr<EditTextObject> pEditText(aEngine.CreateTextObject()); @@ -1768,7 +1876,7 @@ void Test::testSectionAttributes() { sal_uInt16 const nWhich(aAttrs[0].maAttributes[i]->Which()); CPPUNIT_ASSERT_MESSAGE("duplicate item in text portion attributes", - whiches.insert(nWhich).second); + whiches.insert(nWhich).second); } } } @@ -1776,14 +1884,14 @@ void Test::testSectionAttributes() void Test::testLargeParaCopyPaste() { // Create EditEngine's instance - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); // Get EditDoc for current EditEngine's instance - EditDoc &rDoc = aEditEngine.GetEditDoc(); + EditDoc& rDoc = aEditEngine.GetEditDoc(); // Initially no text should be there - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) ); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0))); // Insert initial text OUString aFirstPara = u"This is first paragraph"_ustr; @@ -1809,24 +1917,25 @@ void Test::testLargeParaCopyPaste() sal_Int32 aCopyTextLen = aCopyText.getLength(); // Assert changes - CPPUNIT_ASSERT_EQUAL( aTextLen, rDoc.GetTextLen() ); - CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) ); - CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) ); - CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) ); - CPPUNIT_ASSERT_EQUAL( aFourthPara, rDoc.GetParaAsString(sal_Int32(3)) ); - CPPUNIT_ASSERT_EQUAL( aFifthPara, rDoc.GetParaAsString(sal_Int32(4)) ); - CPPUNIT_ASSERT_EQUAL( aSixthPara, rDoc.GetParaAsString(sal_Int32(5)) ); - CPPUNIT_ASSERT_EQUAL( aSeventhPara, rDoc.GetParaAsString(sal_Int32(6)) ); - CPPUNIT_ASSERT_EQUAL( aEighthPara, rDoc.GetParaAsString(sal_Int32(7)) ); - CPPUNIT_ASSERT_EQUAL( aNinthPara, rDoc.GetParaAsString(sal_Int32(8)) ); - CPPUNIT_ASSERT_EQUAL( aTenthPara, rDoc.GetParaAsString(sal_Int32(9)) ); + CPPUNIT_ASSERT_EQUAL(aTextLen, rDoc.GetTextLen()); + CPPUNIT_ASSERT_EQUAL(aFirstPara, rDoc.GetParaAsString(sal_Int32(0))); + CPPUNIT_ASSERT_EQUAL(aSecondPara, rDoc.GetParaAsString(sal_Int32(1))); + CPPUNIT_ASSERT_EQUAL(aThirdPara, rDoc.GetParaAsString(sal_Int32(2))); + CPPUNIT_ASSERT_EQUAL(aFourthPara, rDoc.GetParaAsString(sal_Int32(3))); + CPPUNIT_ASSERT_EQUAL(aFifthPara, rDoc.GetParaAsString(sal_Int32(4))); + CPPUNIT_ASSERT_EQUAL(aSixthPara, rDoc.GetParaAsString(sal_Int32(5))); + CPPUNIT_ASSERT_EQUAL(aSeventhPara, rDoc.GetParaAsString(sal_Int32(6))); + CPPUNIT_ASSERT_EQUAL(aEighthPara, rDoc.GetParaAsString(sal_Int32(7))); + CPPUNIT_ASSERT_EQUAL(aNinthPara, rDoc.GetParaAsString(sal_Int32(8))); + CPPUNIT_ASSERT_EQUAL(aTenthPara, rDoc.GetParaAsString(sal_Int32(9))); // Copy initial text using legacy format - uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(5,8,7,14) ); + uno::Reference<datatransfer::XTransferable> xData + = aEditEngine.CreateTransferable(ESelection(5, 8, 7, 14)); // Paste text at the end of 4th Para ContentNode* pLastNode = rDoc.GetObject(3); - aEditEngine.InsertText( xData, OUString(), EditPaM( pLastNode, pLastNode->Len() ), true ); + aEditEngine.InsertText(xData, OUString(), EditPaM(pLastNode, pLastNode->Len()), true); // Assert changes OUString aFourthParaAfterCopyPaste = aFourthPara + "sixth paragraph"; @@ -1845,18 +1954,18 @@ void Test::testLargeParaCopyPaste() CPPUNIT_ASSERT_EQUAL( aTenthPara, rDoc.GetParaAsString(sal_Int32(11)) ); } -OUString lcl_translitTest(EditEngine& aEditEngine, const OUString& text, const ESelection& esel, const TransliterationFlags nType) +OUString lcl_translitTest(EditEngine& aEditEngine, const OUString& text, const ESelection& esel, + const TransliterationFlags nType) { aEditEngine.SetText(text); aEditEngine.TransliterateText(esel, nType); return aEditEngine.GetText(); } - void Test::testTransliterate() { // Create EditEngine's instance - EditEngine editEng( mpItemPool.get() ); + EditEngine editEng(mpItemPool.get()); OUString sText(u"one (two) three"_ustr); editEng.SetText(sText); @@ -1935,7 +2044,6 @@ void Test::testTransliterate() CPPUNIT_ASSERT_EQUAL(u"Mary Jones MEt joe Smith. Time Passed."_ustr, lcl_translitTest(editEng, sText2, esel, TF::LOWERCASE_UPPERCASE)); CPPUNIT_ASSERT_EQUAL(u"Mary Jones met joe Smith. Time Passed."_ustr, lcl_translitTest(editEng, sText2, esel, TF::UPPERCASE_LOWERCASE)); - /* Test behavior when there is a selection that crosses a word boundary: "nes met joe Sm" */ selStart = 7; selEnd = 21; @@ -1984,7 +2092,7 @@ void Test::testTdf147196() void Test::testTdf148148() { using TF = TransliterationFlags; - EditEngine editEng( mpItemPool.get() ); + EditEngine editEng(mpItemPool.get()); /* Test what happens when node contains text but selection does not contain any text */ int selStart = 0; @@ -2066,7 +2174,7 @@ void Test::testTdf148148() void Test::testSingleLine() { - EditEngine aEditEngine( mpItemPool.get() ); + EditEngine aEditEngine(mpItemPool.get()); aEditEngine.SetSingleLine(true); aEditEngine.SetText(u"Bolivian\nSanta Cruz de la Sierra"_ustr); @@ -2145,7 +2253,8 @@ void Test::testMoveParagraph() CPPUNIT_ASSERT_EQUAL(u"Paragraph 4"_ustr, aEditEngine.GetText(3)); CPPUNIT_ASSERT_EQUAL(u"Paragraph 5"_ustr, aEditEngine.GetText(4)); - aEditEngine.MoveParagraphs(Range(0, 0), 8); // Move paragraph 1 -> to before index 8 but 8 is out of bounds + aEditEngine.MoveParagraphs(Range(0, 0), + 8); // Move paragraph 1 -> to before index 8 but 8 is out of bounds CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aEditEngine.GetParagraphCount()); CPPUNIT_ASSERT_EQUAL(u"Paragraph 2"_ustr, aEditEngine.GetText(0)); @@ -2294,7 +2403,6 @@ void Test::testTdf154248MultilineFieldWrapping() } CPPUNIT_TEST_SUITE_REGISTRATION(Test); - } CPPUNIT_PLUGIN_IMPLEMENT(); |