editeng/qa/unit/core-test.cxx | 18 ++-- editeng/source/accessibility/AccessibleEditableTextPara.cxx | 44 +++++------- editeng/source/editeng/editeng.cxx | 35 +-------- editeng/source/editeng/editview.cxx | 10 +- editeng/source/editeng/impedit.cxx | 2 editeng/source/editeng/impedit4.cxx | 2 editeng/source/uno/unoedprx.cxx | 41 ++++------- editeng/source/uno/unofored.cxx | 9 -- editeng/source/uno/unoforou.cxx | 9 -- editeng/source/uno/unotext.cxx | 9 -- include/editeng/editeng.hxx | 3 include/editeng/unoedprx.hxx | 3 include/editeng/unoedsrc.hxx | 14 --- include/editeng/unofored.hxx | 3 include/editeng/unoforou.hxx | 3 include/editeng/unotext.hxx | 3 sc/source/ui/view/gridwin.cxx | 6 - sd/source/ui/dlg/headerfooterdlg.cxx | 10 +- svx/source/accessibility/AccessibleEmptyEditSource.cxx | 3 svx/source/dialog/ClassificationDialog.cxx | 8 -- svx/source/dialog/weldeditview.cxx | 15 +--- 21 files changed, 84 insertions(+), 166 deletions(-)
New commits: commit 40e08851304e5c179842dcf2e1e3b352f1baee21 Author: Noel Grandin <[email protected]> AuthorDate: Fri Jun 21 19:42:48 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Jun 22 14:00:49 2024 +0200 fix O(n^2) behaviour when fetching field info from EditEngine Change-Id: I324a1814fc1b3321eed5b29922790600e7092c17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169344 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index f4032b09e120..599496d18919 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -638,14 +638,14 @@ void Test::testHyperlinkCopyPaste() aEditEngine.InsertField(aSel1, aField1); // Assert Field Count - CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aEditEngine.GetFieldCount(0)); + CPPUNIT_ASSERT_EQUAL(size_t(1), aEditEngine.GetFieldInfo(0).size()); // Insert URL 2 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(size_t(2), aEditEngine.GetFieldInfo(0).size()); // Assert URL Fields and text before copy // Check text @@ -653,7 +653,7 @@ void Test::testHyperlinkCopyPaste() CPPUNIT_ASSERT_EQUAL( u"[email protected]@domain.comfeaturefields"_ustr, rDoc.GetParaAsString(sal_Int32(0)) ); // Check Field 1 - EFieldInfo aURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(0)); + EFieldInfo aURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0))[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*>( @@ -663,7 +663,7 @@ void Test::testHyperlinkCopyPaste() CPPUNIT_ASSERT_EQUAL(aRepres1, pURLField1->GetRepresentation()); // Check Field 2 - EFieldInfo aURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(1)); + EFieldInfo aURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0))[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*>( @@ -682,7 +682,7 @@ void Test::testHyperlinkCopyPaste() // Assert Changes ACP, ACP: after Copy/Paste // Check the fields count - CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), aEditEngine.GetFieldCount(0)); + CPPUNIT_ASSERT_EQUAL(size_t(3), aEditEngine.GetFieldInfo(0).size()); // Check the updated text length CPPUNIT_ASSERT_EQUAL(aTextLen + 10 + aRepres1.getLength() * 2 + aRepres2.getLength(), @@ -694,7 +694,7 @@ void Test::testHyperlinkCopyPaste() // Check the Fields and their values // Field 1 - EFieldInfo aACPURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(0)); + EFieldInfo aACPURLFieldInfo1 = aEditEngine.GetFieldInfo(sal_Int32(0))[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*>( @@ -704,7 +704,7 @@ void Test::testHyperlinkCopyPaste() CPPUNIT_ASSERT_EQUAL(aRepres1, pACPURLField1->GetRepresentation()); // Field 2 - EFieldInfo aACPURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(1)); + EFieldInfo aACPURLFieldInfo2 = aEditEngine.GetFieldInfo(sal_Int32(0))[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*>( @@ -714,7 +714,7 @@ void Test::testHyperlinkCopyPaste() CPPUNIT_ASSERT_EQUAL(aRepres2, pACPURLField2->GetRepresentation()); // Field 3 - EFieldInfo aACPURLFieldInfo3 = aEditEngine.GetFieldInfo(sal_Int32(0), sal_uInt16(2)); + EFieldInfo aACPURLFieldInfo3 = aEditEngine.GetFieldInfo(sal_Int32(0))[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*>( @@ -2388,7 +2388,7 @@ void Test::testTdf154248MultilineFieldWrapping() aEditEngine.InsertField(aSel, aField); // Assert Field Count - CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), aEditEngine.GetFieldCount(0)); + CPPUNIT_ASSERT_EQUAL(size_t(1), aEditEngine.GetFieldInfo(0).size()); aEditEngine.QuickFormatDoc(false); CPPUNIT_ASSERT_EQUAL(true, aEditEngine.IsFormatted()); diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index da13332d9ad4..e8543bda4e80 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -886,10 +886,9 @@ namespace accessibility //For field object info sal_Int32 nParaIndex = GetParagraphIndex(); sal_Int32 nAllFieldLen = 0; - sal_Int32 nField = rCacheTF.GetFieldCount(nParaIndex); - for (sal_Int32 j = 0; j < nField; ++j) + std::vector<EFieldInfo> aFieldInfos = rCacheTF.GetFieldInfo(nParaIndex); + for (const EFieldInfo& ree : aFieldInfos) { - EFieldInfo ree = rCacheTF.GetFieldInfo(nParaIndex, j); sal_Int32 reeBegin = ree.aPosition.nIndex + nAllFieldLen; sal_Int32 reeEnd = reeBegin + ree.aCurrentText.getLength(); nAllFieldLen += (ree.aCurrentText.getLength() - 1); @@ -1529,11 +1528,12 @@ namespace accessibility sal_Int32 nParaIndex = GetParagraphIndex(); SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); sal_Int32 nAllFieldLen = 0; - sal_Int32 nField = rCacheTF.GetFieldCount(nParaIndex), nFoundFieldIndex = -1; + sal_Int32 nFoundFieldIndex = -1; + std::vector<EFieldInfo> aFieldInfos = rCacheTF.GetFieldInfo(nParaIndex); sal_Int32 reeBegin=0, reeEnd=0; - for (sal_Int32 j = 0; j < nField; ++j) + sal_Int32 j = 0; + for (const EFieldInfo& ree : aFieldInfos) { - EFieldInfo ree = rCacheTF.GetFieldInfo(nParaIndex, j); reeBegin = ree.aPosition.nIndex + nAllFieldLen; reeEnd = reeBegin + ree.aCurrentText.getLength(); nAllFieldLen += (ree.aCurrentText.getLength() - 1); @@ -1549,6 +1549,7 @@ namespace accessibility break; } } + j++; } if( nFoundFieldIndex >= 0 ) { @@ -1563,12 +1564,13 @@ namespace accessibility { sal_Int32 nParaIndex = GetParagraphIndex(); SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); + std::vector<EFieldInfo> aFieldInfos = rCacheTF.GetFieldInfo(nParaIndex); sal_Int32 nAllFieldLen = 0; - sal_Int32 nField = rCacheTF.GetFieldCount(nParaIndex), nFoundFieldIndex = -1; + sal_Int32 nField = aFieldInfos.size(), nFoundFieldIndex = -1; sal_Int32 reeBegin=0, reeEnd=0; for (sal_Int32 j = 0; j < nField; ++j) { - EFieldInfo ree = rCacheTF.GetFieldInfo(nParaIndex, j); + const EFieldInfo& ree = aFieldInfos[j]; reeBegin = ree.aPosition.nIndex + nAllFieldLen; reeEnd = reeBegin + ree.aCurrentText.getLength(); nAllFieldLen += (ree.aCurrentText.getLength() - 1); @@ -2493,12 +2495,12 @@ namespace accessibility SvxAccessibleTextAdapter& rT = GetTextForwarder(); const sal_Int32 nPara = GetParagraphIndex(); + std::vector<EFieldInfo> aFieldInfos = rT.GetFieldInfo( nPara ); sal_Int32 nHyperLinks = 0; - sal_Int32 nFields = rT.GetFieldCount( nPara ); + sal_Int32 nFields = aFieldInfos.size(); for (sal_Int32 n = 0; n < nFields; ++n) { - EFieldInfo aField = rT.GetFieldInfo( nPara, n ); - if ( dynamic_cast<const SvxURLField* >(aField.pFieldItem->GetField() ) != nullptr) + if ( dynamic_cast<const SvxURLField* >(aFieldInfos[n].pFieldItem->GetField() ) != nullptr) nHyperLinks++; } return nHyperLinks; @@ -2512,20 +2514,18 @@ namespace accessibility const sal_Int32 nPara = GetParagraphIndex(); sal_Int32 nHyperLink = 0; - sal_Int32 nFields = rT.GetFieldCount( nPara ); - for (sal_Int32 n = 0; n < nFields; ++n) + for (const EFieldInfo& rField : rT.GetFieldInfo( nPara )) { - EFieldInfo aField = rT.GetFieldInfo( nPara, n ); - if ( dynamic_cast<const SvxURLField* >(aField.pFieldItem->GetField()) != nullptr ) + if ( dynamic_cast<const SvxURLField* >(rField.pFieldItem->GetField()) != nullptr ) { if ( nHyperLink == nLinkIndex ) { - sal_Int32 nEEStart = aField.aPosition.nIndex; + sal_Int32 nEEStart = rField.aPosition.nIndex; // Translate EE Index to accessible index sal_Int32 nStart = rT.CalcEditEngineIndex( nPara, nEEStart ); - sal_Int32 nEnd = nStart + aField.aCurrentText.getLength(); - xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nStart, nEnd, aField.aCurrentText ); + sal_Int32 nEnd = nStart + rField.aCurrentText.getLength(); + xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *rField.pFieldItem ), nStart, nEnd, rField.aCurrentText ); break; } nHyperLink++; @@ -2543,13 +2543,11 @@ namespace accessibility const sal_Int32 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex ); sal_Int32 nHLIndex = -1; //i123620 sal_Int32 nHyperLink = 0; - sal_Int32 nFields = rT.GetFieldCount( nPara ); - for (sal_Int32 n = 0; n < nFields; ++n) + for (const EFieldInfo & rField : rT.GetFieldInfo( nPara )) { - EFieldInfo aField = rT.GetFieldInfo( nPara, n ); - if ( dynamic_cast<const SvxURLField* >( aField.pFieldItem->GetField() ) != nullptr) + if ( dynamic_cast<const SvxURLField* >( rField.pFieldItem->GetField() ) != nullptr) { - if ( aField.aPosition.nIndex == nEEIndex ) + if ( rField.aPosition.nIndex == nEEIndex ) { nHLIndex = nHyperLink; break; diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 7707ce81ce42..1bc8ae77a564 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1429,46 +1429,25 @@ bool EditEngine::ShouldCreateBigTextObject() const return nTextPortions >= getImpl().GetBigTextObjectStart(); } -sal_uInt16 EditEngine::GetFieldCount( sal_Int32 nPara ) const +std::vector<EFieldInfo> EditEngine::GetFieldInfo( sal_Int32 nPara ) const { - sal_uInt16 nFields = 0; + std::vector<EFieldInfo> aFieldInfos; ContentNode* pNode = getImpl().GetEditDoc().GetObject(nPara); if ( pNode ) { - for (auto const& attrib : pNode->GetCharAttribs().GetAttribs()) - { - if (attrib->Which() == EE_FEATURE_FIELD) - ++nFields; - } - } - - return nFields; -} - -EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const -{ - ContentNode* pNode = getImpl().GetEditDoc().GetObject(nPara); - if ( pNode ) - { - sal_uInt16 nCurrentField = 0; for (auto const& attrib : pNode->GetCharAttribs().GetAttribs()) { const EditCharAttrib& rAttr = *attrib; if (rAttr.Which() == EE_FEATURE_FIELD) { - if ( nCurrentField == nField ) - { - const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem()); - EFieldInfo aInfo(*p, nPara, rAttr.GetStart()); - aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue(); - return aInfo; - } - - ++nCurrentField; + const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem()); + EFieldInfo aInfo(*p, nPara, rAttr.GetStart()); + aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue(); + aFieldInfos.push_back(aInfo); } } } - return EFieldInfo(); + return aFieldInfos; } diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 88de93b10060..a8dda101c606 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1450,18 +1450,16 @@ sal_Int32 EditView::countFieldsOffsetSum(sal_Int32 nPara, sal_Int32 nPos, bool b for (int nCurrentPara = 0; nCurrentPara <= nPara; nCurrentPara++) { - int nFields = getEditEngine().GetFieldCount( nCurrentPara ); - for (int nField = 0; nField < nFields; nField++) + std::vector<EFieldInfo> aFieldInfos = getEditEngine().GetFieldInfo( nCurrentPara ); + for (const EFieldInfo& rFieldInfo : aFieldInfos) { - EFieldInfo aFieldInfo = getEditEngine().GetFieldInfo( nCurrentPara, nField ); - bool bLastPara = nCurrentPara == nPara; - sal_Int32 nFieldPos = aFieldInfo.aPosition.nIndex; + sal_Int32 nFieldPos = rFieldInfo.aPosition.nIndex; if (bLastPara && nFieldPos >= nPos) break; - sal_Int32 nFieldLen = aFieldInfo.aCurrentText.getLength(); + sal_Int32 nFieldLen = rFieldInfo.aCurrentText.getLength(); // position in the middle of a field if (!bCanOverflow && bLastPara && nFieldPos + nFieldLen > nPos) diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx index 1877d068e0e0..15342e874753 100644 --- a/editeng/source/uno/unoedprx.cxx +++ b/editeng/source/uno/unoedprx.cxx @@ -180,7 +180,6 @@ void SvxAccessibleTextIndex::SetEEIndex( sal_Int32 nEEIndex, const SvxTextForwar mnEEIndex = nEEIndex; // calculate unknowns - sal_Int32 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() ); mnIndex = nEEIndex; @@ -194,20 +193,19 @@ void SvxAccessibleTextIndex::SetEEIndex( sal_Int32 nEEIndex, const SvxTextForwar mnIndex += aBulletInfo.aText.getLength(); } - for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField ) + std::vector<EFieldInfo> aFieldInfos = rTF.GetFieldInfo( GetParagraph() ); + for( const EFieldInfo& rFieldInfo : aFieldInfos ) { - EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) ); - - if( aFieldInfo.aPosition.nIndex > nEEIndex ) + if( rFieldInfo.aPosition.nIndex > nEEIndex ) break; - if( aFieldInfo.aPosition.nIndex == nEEIndex ) + if( rFieldInfo.aPosition.nIndex == nEEIndex ) { AreInField(); break; } - mnIndex += std::max(aFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)); + mnIndex += std::max(rFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)); } } @@ -225,7 +223,6 @@ void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder& mnIndex = nIndex; // calculate unknowns - sal_Int32 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() ); DBG_ASSERT(nIndex >= 0, "SvxAccessibleTextIndex::SetIndex: index value overflow"); @@ -252,23 +249,22 @@ void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder& mnEEIndex = mnEEIndex - nBulletLen; } - for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField ) + std::vector<EFieldInfo> aFieldInfos = rTF.GetFieldInfo( GetParagraph() ); + for( const EFieldInfo& rFieldInfo : aFieldInfos ) { - EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) ); - // we're before a field - if( aFieldInfo.aPosition.nIndex > mnEEIndex ) + if( rFieldInfo.aPosition.nIndex > mnEEIndex ) break; - mnEEIndex -= std::max(aFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)); + mnEEIndex -= std::max(rFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)); // we're within a field - if( aFieldInfo.aPosition.nIndex >= mnEEIndex ) + if( rFieldInfo.aPosition.nIndex >= mnEEIndex ) { AreInField(); - SetFieldOffset( std::max(aFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)) - (aFieldInfo.aPosition.nIndex - mnEEIndex), - aFieldInfo.aCurrentText.getLength() ); - mnEEIndex = aFieldInfo.aPosition.nIndex ; + SetFieldOffset( std::max(rFieldInfo.aCurrentText.getLength()-1, sal_Int32(0)) - (rFieldInfo.aPosition.nIndex - mnEEIndex), + rFieldInfo.aCurrentText.getLength() ); + mnEEIndex = rFieldInfo.aPosition.nIndex ; break; } } @@ -671,18 +667,11 @@ LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_Int32 nPara, sal_Int32 n return mpTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() ); } -sal_Int32 SvxAccessibleTextAdapter::GetFieldCount( sal_Int32 nPara ) const -{ - assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); - - return mpTextForwarder->GetFieldCount( nPara ); -} - -EFieldInfo SvxAccessibleTextAdapter::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const +std::vector<EFieldInfo> SvxAccessibleTextAdapter::GetFieldInfo( sal_Int32 nPara ) const { assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); - return mpTextForwarder->GetFieldInfo( nPara, nField ); + return mpTextForwarder->GetFieldInfo( nPara ); } EBulletInfo SvxAccessibleTextAdapter::GetBulletInfo( sal_Int32 nPara ) const diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx index 6d088245f142..c24f9ff965b1 100644 --- a/editeng/source/uno/unofored.cxx +++ b/editeng/source/uno/unofored.cxx @@ -284,14 +284,9 @@ LanguageType SvxEditEngineForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIn return rEditEngine.GetLanguage(nPara, nIndex).nLang; } -sal_Int32 SvxEditEngineForwarder::GetFieldCount( sal_Int32 nPara ) const +std::vector<EFieldInfo> SvxEditEngineForwarder::GetFieldInfo( sal_Int32 nPara ) const { - return rEditEngine.GetFieldCount(nPara); -} - -EFieldInfo SvxEditEngineForwarder::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const -{ - return rEditEngine.GetFieldInfo( nPara, nField ); + return rEditEngine.GetFieldInfo( nPara ); } EBulletInfo SvxEditEngineForwarder::GetBulletInfo( sal_Int32 ) const diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx index 8772ff9a77fa..a04885190050 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -270,14 +270,9 @@ LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nInde return rOutliner.GetLanguage(nPara, nIndex); } -sal_Int32 SvxOutlinerForwarder::GetFieldCount( sal_Int32 nPara ) const +std::vector<EFieldInfo> SvxOutlinerForwarder::GetFieldInfo( sal_Int32 nPara ) const { - return rOutliner.GetEditEngine().GetFieldCount(nPara); -} - -EFieldInfo SvxOutlinerForwarder::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const -{ - return rOutliner.GetEditEngine().GetFieldInfo( nPara, nField ); + return rOutliner.GetEditEngine().GetFieldInfo( nPara ); } EBulletInfo SvxOutlinerForwarder::GetBulletInfo( sal_Int32 nPara ) const diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 5ee01340f880..7c4c3fbfbc26 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -2446,14 +2446,9 @@ LanguageType SvxDummyTextSource::GetLanguage( sal_Int32, sal_Int32 ) const return LANGUAGE_DONTKNOW; } -sal_Int32 SvxDummyTextSource::GetFieldCount( sal_Int32 ) const +std::vector<EFieldInfo> SvxDummyTextSource::GetFieldInfo( sal_Int32 ) const { - return 0; -} - -EFieldInfo SvxDummyTextSource::GetFieldInfo( sal_Int32, sal_uInt16 ) const -{ - return EFieldInfo(); + return {}; } EBulletInfo SvxDummyTextSource::GetBulletInfo( sal_Int32 ) const diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index e2b40613b0f2..af62e525e98a 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -476,8 +476,7 @@ public: SAL_DLLPRIVATE bool UpdateFieldsOnly(); void RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} ); - sal_uInt16 GetFieldCount( sal_Int32 nPara ) const; - EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const; + std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const; bool IsRightToLeft( sal_Int32 nPara ) const; diff --git a/include/editeng/unoedprx.hxx b/include/editeng/unoedprx.hxx index 22b6be0c91e3..b3cf3f89309c 100644 --- a/include/editeng/unoedprx.hxx +++ b/include/editeng/unoedprx.hxx @@ -65,8 +65,7 @@ public: virtual bool IsValid() const override; virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override; - virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override; - virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override; + virtual std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const override; virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override; virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override; virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override; diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx index 1537f00a743c..45824a4e390e 100644 --- a/include/editeng/unoedsrc.hxx +++ b/include/editeng/unoedsrc.hxx @@ -193,22 +193,12 @@ public: */ virtual LanguageType GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const = 0; - /** Query number of fields in the underlying edit engine - - @param nPara[0 .. n-1] - Index of paragraph to query field number in - */ - virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const = 0; - - /** Query information for given field number in the underlying edit engine + /** Query information for fields in the underlying edit engine @param nPara[0 .. n-1] Index of paragraph to query field info in - - @param nField[0 .. m-1] - Index of field to query information of */ - virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const = 0; + virtual std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const = 0; /** Query information regarding bullets for given paragraph on the underlying edit engine diff --git a/include/editeng/unofored.hxx b/include/editeng/unofored.hxx index 323095f85f0b..ca64ca8c891a 100644 --- a/include/editeng/unofored.hxx +++ b/include/editeng/unofored.hxx @@ -62,8 +62,7 @@ public: virtual bool IsValid() const override; virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override; - virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override; - virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override; + virtual std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const override; virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override; virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override; virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override; diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx index 0abb982cf62d..1909eb3f2f85 100644 --- a/include/editeng/unoforou.hxx +++ b/include/editeng/unoforou.hxx @@ -82,8 +82,7 @@ public: virtual bool IsValid() const override final; virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override final; - virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override final; - virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override final; + virtual std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const override final; virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override final; virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override final; virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override final; diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index bb3d8c708606..38efd32e0aaf 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -208,8 +208,7 @@ public: virtual bool IsValid() const override; virtual LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override; - virtual sal_Int32 GetFieldCount( sal_Int32 nPara ) const override; - virtual EFieldInfo GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const override; + virtual std::vector<EFieldInfo> GetFieldInfo( sal_Int32 nPara ) const override; virtual EBulletInfo GetBulletInfo( sal_Int32 nPara ) const override; virtual tools::Rectangle GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const override; virtual tools::Rectangle GetParaBounds( sal_Int32 nPara ) const override; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 5d298458cb75..ee06a5aa4835 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5839,11 +5839,9 @@ static std::vector<std::unique_ptr<SvxFieldItem>> lcl_GetEditEngineFields(std::s sal_Int32 nPara = pEditEngine->GetParagraphCount(); for (sal_Int32 nCurrPara = 0; nCurrPara < nPara; ++nCurrPara) { - sal_Int16 nField = pEditEngine->GetFieldCount(nCurrPara); - for (sal_Int16 nCurrField = 0; nCurrField < nField; ++nCurrField) + for (EFieldInfo& rFieldInfo : pEditEngine->GetFieldInfo(nCurrPara)) { - EFieldInfo aFieldInfo = pEditEngine->GetFieldInfo(nCurrPara, nCurrField); - vFieldVect.push_back(std::move(aFieldInfo.pFieldItem)); + vFieldVect.push_back(std::move(rFieldInfo.pFieldItem)); } } return vFieldVect; diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx index a69e61f647dd..d02634e811f3 100644 --- a/sd/source/ui/dlg/headerfooterdlg.cxx +++ b/sd/source/ui/dlg/headerfooterdlg.cxx @@ -576,18 +576,16 @@ bool HeaderFooterTabPage::GetOrSetDateTimeLanguage(LanguageType& rLanguage, bool sal_Int32 nParaCount = pEdit->GetParagraphCount(); for (sal_Int32 nPara = 0; (nPara < nParaCount) && !bHasDateFieldItem; ++nPara) { - sal_uInt16 nFieldCount = pEdit->GetFieldCount(nPara); - for (sal_uInt16 nField = 0; (nField < nFieldCount); ++nField) + for (const EFieldInfo& rFieldInfo : pEdit->GetFieldInfo(nPara)) { - EFieldInfo aFieldInfo = pEdit->GetFieldInfo(nPara, nField); - if (aFieldInfo.pFieldItem) + if (rFieldInfo.pFieldItem) { - const SvxFieldData* pFieldData = aFieldInfo.pFieldItem->GetField(); + const SvxFieldData* pFieldData = rFieldInfo.pFieldItem->GetField(); if (dynamic_cast<const SvxDateTimeField*>(pFieldData) != nullptr || dynamic_cast<const SvxDateField*>(pFieldData) != nullptr) { bHasDateFieldItem = true; - aDateFieldPosition = aFieldInfo.aPosition; + aDateFieldPosition = rFieldInfo.aPosition; break; } } diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx index 7ff9ec6610f7..619c3443a42a 100644 --- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx +++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx @@ -133,8 +133,7 @@ namespace accessibility bool IsValid() const override { return true; } LanguageType GetLanguage( sal_Int32, sal_Int32 ) const override { return LANGUAGE_DONTKNOW; } - sal_Int32 GetFieldCount( sal_Int32 ) const override { return 0; } - EFieldInfo GetFieldInfo( sal_Int32, sal_uInt16 ) const override { return EFieldInfo(); } + std::vector<EFieldInfo> GetFieldInfo( sal_Int32 ) const override { return {}; } EBulletInfo GetBulletInfo( sal_Int32 ) const override { return EBulletInfo(); } tools::Rectangle GetCharBounds( sal_Int32, sal_Int32 ) const override { return tools::Rectangle(); } tools::Rectangle GetParaBounds( sal_Int32 ) const override { return tools::Rectangle(); } diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx index e3d06b1bdbc1..757eba262807 100644 --- a/svx/source/dialog/ClassificationDialog.cxx +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -486,13 +486,11 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory() for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph) { - sal_uInt16 nFieldCount = rEditEngine.GetFieldCount(nParagraph); - for (sal_uInt16 nField = 0; nField < nFieldCount; ++nField) + for (const EFieldInfo& rFieldInfo : rEditEngine.GetFieldInfo(nParagraph)) { - EFieldInfo aFieldInfo = rEditEngine.GetFieldInfo(nParagraph, nField); - if (aFieldInfo.pFieldItem) + if (rFieldInfo.pFieldItem) { - const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(aFieldInfo.pFieldItem->GetField()); + const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rFieldInfo.pFieldItem->GetField()); if (pClassificationField && pClassificationField->meType == ClassificationType::CATEGORY) { m_xOkButton->set_sensitive(true); diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index 0df0ffdc2549..b24b00717cb8 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -392,8 +392,7 @@ public: virtual bool IsValid() const override; virtual LanguageType GetLanguage(sal_Int32, sal_Int32) const override; - virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const override; - virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const override; + virtual std::vector<EFieldInfo> GetFieldInfo(sal_Int32 nPara) const override; virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const override; virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const override; virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const override; @@ -1213,16 +1212,12 @@ LanguageType WeldTextForwarder::GetLanguage(sal_Int32 nPara, sal_Int32 nIndex) c return pEditEngine ? pEditEngine->GetLanguage(nPara, nIndex).nLang : LANGUAGE_NONE; } -sal_Int32 WeldTextForwarder::GetFieldCount(sal_Int32 nPara) const +std::vector<EFieldInfo> WeldTextForwarder::GetFieldInfo(sal_Int32 nPara) const { EditEngine* pEditEngine = m_rEditAcc.GetEditEngine(); - return pEditEngine ? pEditEngine->GetFieldCount(nPara) : 0; -} - -EFieldInfo WeldTextForwarder::GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const -{ - EditEngine* pEditEngine = m_rEditAcc.GetEditEngine(); - return pEditEngine ? pEditEngine->GetFieldInfo(nPara, nField) : EFieldInfo(); + if (!pEditEngine) + return {}; + return pEditEngine->GetFieldInfo(nPara); } EBulletInfo WeldTextForwarder::GetBulletInfo(sal_Int32 /*nPara*/) const { return EBulletInfo(); } commit 858bc4d76bb49ff1766e5d4bd404b04d61201c37 Author: Noel Grandin <[email protected]> AuthorDate: Fri Jun 21 18:59:27 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Jun 22 14:00:41 2024 +0200 no need to call FormatDoc() after calling CheckIdleFormatter() CheckIdleFormatter() already does that Change-Id: Ie6b9e3285303899e3f67cccb0fc5f5625c8db684 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169343 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 27ff1831fb62..411b96b8dfe8 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -1175,8 +1175,6 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) return; getEditEngine().CheckIdleFormatter(); - if (!getEditEngine().IsFormatted()) - getImpEditEngine().FormatDoc(); // For some reasons I end up here during the formatting, if the Outliner // is initialized in Paint, because no SetPool(); diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 13f13b6fe491..35070a4dd740 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -296,8 +296,6 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel, bool bCl { assert( IsUpdateLayout() && "WriteRTF for UpdateMode = sal_False!" ); CheckIdleFormatter(); - if ( !IsFormatted() ) - FormatDoc(); sal_Int32 nStartNode, nEndNode; aSel.Adjust( maEditDoc );
