diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-02-11 12:51:18 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-02-12 07:27:47 +0100 |
commit | a476aa8d222a949a67676d95ec07914bbf00e23b (patch) | |
tree | 387d9f5791a17f81ff6c8ffdd207d45106c04ca6 | |
parent | d0d83b8b4a8ee5a889e1ffdf1293b858bf69caaf (diff) |
editeng: make TextPortionList iterable with ranged for
Change-Id: Ifbddd99b5877c71ebbec064672b75877fe06ccd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163226
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | editeng/inc/TextPortionList.hxx | 5 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 19 |
2 files changed, 15 insertions, 9 deletions
diff --git a/editeng/inc/TextPortionList.hxx b/editeng/inc/TextPortionList.hxx index 7c646ebbbee9..dc6b5e064bd5 100644 --- a/editeng/inc/TextPortionList.hxx +++ b/editeng/inc/TextPortionList.hxx @@ -59,6 +59,11 @@ public: sal_Int32 GetPos(const TextPortion* p) const; bool isEmpty() { return Count() == 1 && maPortions[0]->GetLen() == 0; } + + PortionsType::iterator begin() { return maPortions.begin(); } + PortionsType::iterator end() { return maPortions.end(); } + PortionsType::const_iterator cbegin() const { return maPortions.cbegin(); } + PortionsType::const_iterator cend() const { return maPortions.cend(); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 330a37cb2187..9892dfaa783f 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -724,27 +724,28 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) const sal_Int32 nInvalidEnd = nInvalidStart + std::abs( nInvalidDiff ); bool bQuickFormat = false; - if ( !bEmptyNodeWithPolygon && !HasScriptType( nPara, i18n::ScriptType::COMPLEX ) ) + + // Determine if quick formt should be used + if (!bEmptyNodeWithPolygon && !HasScriptType(nPara, i18n::ScriptType::COMPLEX)) { - if ( ( rParaPortion.IsSimpleInvalid() ) && ( nInvalidDiff > 0 ) && - ( pNode->GetString().indexOf( CH_FEATURE, nInvalidStart ) > nInvalidEnd ) ) + if (rParaPortion.IsSimpleInvalid() && + rParaPortion.GetInvalidDiff() > 0 && + pNode->GetString().indexOf(CH_FEATURE, nInvalidStart) > nInvalidEnd) { bQuickFormat = true; } - else if ( ( rParaPortion.IsSimpleInvalid() ) && ( nInvalidDiff < 0 ) ) + else if (rParaPortion.IsSimpleInvalid() && nInvalidDiff < 0) { // check if delete over the portion boundaries was done... sal_Int32 nStart = nInvalidStart; // DOUBLE !!!!!!!!!!!!!!! sal_Int32 nEnd = nStart - nInvalidDiff; // negative bQuickFormat = true; sal_Int32 nPos = 0; - sal_Int32 nPortions = rParaPortion.GetTextPortions().Count(); - for ( sal_Int32 nTP = 0; nTP < nPortions; nTP++ ) + for (auto const& pTextPortion : rParaPortion.GetTextPortions()) { // There must be no start / end in the deleted area. - const TextPortion& rTP = rParaPortion.GetTextPortions()[ nTP ]; - nPos = nPos + rTP.GetLen(); - if ( ( nPos > nStart ) && ( nPos < nEnd ) ) + nPos = nPos + pTextPortion->GetLen(); + if (nPos > nStart && nPos < nEnd) { bQuickFormat = false; break; |