editeng/source/editeng/editdbg.cxx | 26 ++++----- editeng/source/editeng/editdoc.cxx | 101 ++++++++++++++++++++++++++---------- editeng/source/editeng/editdoc.hxx | 12 ++-- editeng/source/editeng/impedit2.cxx | 4 - editeng/source/editeng/impedit3.cxx | 8 +- editeng/source/editeng/impedit4.cxx | 4 + editeng/source/editeng/impedit5.cxx | 4 + 7 files changed, 104 insertions(+), 55 deletions(-)
New commits: commit 6dd2a085a04fc1df355a78ab0731728a87eeb446 Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 3 00:45:39 2014 +0100 editeng: let's assert attribute consistency in some more places Change-Id: Idf3a1eb821b3b938f1bdd04bf449ade190703ab3 diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 13889f4..9e2e29f 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1287,6 +1287,10 @@ void ContentNode::ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNew, SfxItemPool& if ( !nNew ) return; +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); +#endif + // Since features are treated differently than normal character attributes, // can also the order of the start list be change! // In every if ..., in the next (n) opportunities due to bFeature or @@ -1423,6 +1427,10 @@ void ContentNode::CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDeleted, SfxItemP if ( !nDeleted ) return; +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); +#endif + // Since features are treated differently than normal character attributes, // can also the order of the start list be change! bool bResort = false; @@ -1510,6 +1518,11 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, { DBG_ASSERT( pPrevNode, "Copy of attributes to a null pointer?" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); + CharAttribList::DbgCheckAttribs(pPrevNode->aCharAttribList); +#endif + sal_Int32 nCut = pPrevNode->Len(); sal_Int32 nAttr = 0; @@ -1552,6 +1565,11 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, nAttr++; pAttrib = GetAttrib(rPrevAttribs, nAttr); } + +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); + CharAttribList::DbgCheckAttribs(pPrevNode->aCharAttribList); +#endif } void ContentNode::AppendAttribs( ContentNode* pNextNode ) @@ -1562,6 +1580,7 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode ) #if OSL_DEBUG_LEVEL > 0 CharAttribList::DbgCheckAttribs(aCharAttribList); + CharAttribList::DbgCheckAttribs(pNextNode->aCharAttribList); #endif sal_Int32 nAttr = 0; @@ -1618,6 +1637,7 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode ) #if OSL_DEBUG_LEVEL > 0 CharAttribList::DbgCheckAttribs(aCharAttribList); + CharAttribList::DbgCheckAttribs(pNextNode->aCharAttribList); #endif } @@ -2449,6 +2469,10 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn DBG_ASSERT( nStart <= nEnd, "Small miscalculations in InsertAttribInSelection" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(pNode->GetCharAttribs()); +#endif + // iterate over the attributes ... sal_Int32 nAttr = 0; CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs(); @@ -2540,6 +2564,10 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn SetModified(true); } +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(pNode->GetCharAttribs()); +#endif + return bChanged; } @@ -2739,29 +2767,46 @@ void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib ) const sal_Int32 nStart = pAttrib->GetStart(); // may be better for Comp.Opt. +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(*this); +#endif + if ( pAttrib->IsEmpty() ) bHasEmptyAttribs = true; + bool bInsert(true); for (sal_Int32 i = 0, n = aAttribs.size(); i < n; ++i) { const EditCharAttrib& rCurAttrib = aAttribs[i]; if (rCurAttrib.GetStart() > nStart) { aAttribs.insert(aAttribs.begin()+i, pAttrib); - return; + bInsert = false; + break; } } - aAttribs.push_back(pAttrib); + if (bInsert) aAttribs.push_back(pAttrib); + +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(*this); +#endif } void CharAttribList::ResortAttribs() { aAttribs.sort(LessByStart()); + +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(*this); +#endif } void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool ) { +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(*this); +#endif for (sal_Int32 i = 0; i < (sal_Int32)aAttribs.size(); ++i) { EditCharAttrib& rAttr = aAttribs[i]; @@ -2784,6 +2829,9 @@ void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool ) } } } +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(*this); +#endif } sal_Int32 CharAttribList::Count() const diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 62ded41..df59f11 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -664,6 +664,10 @@ void ImpEditEngine::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich, bool pAttr = GetAttrib(rAttrs, nAttr); } +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(pNode->GetCharAttribs()); +#endif + pPortion->MarkSelectionInvalid( 0, pNode->Len() ); } commit 2b846d7e847441a1da7f63fe1e8139e743f143be Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 3 00:18:00 2014 +0100 editeng: it's like there's a nest of these things Change-Id: Iceef908e8cc1e7a2849398bd2d9e6e7cb1a9e9c9 diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index c78a1b6..4a8c6e5 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -485,21 +485,20 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox ) if ( bInfoBox ) InfoBox(0, OUString( "D:\\DEBUG.LOG !" ) ).Execute(); } +#endif -#if OSL_DEBUG_LEVEL > 2 -sal_Bool ParaPortion::DbgCheckTextPortions() +#if OSL_DEBUG_LEVEL > 0 +bool ParaPortion::DbgCheckTextPortions(ParaPortion const& rPara) { // check, if Portion length ok: sal_uInt16 nXLen = 0; - for ( sal_uInt16 nPortion = 0; nPortion < aTextPortionList.Count(); nPortion++ ) - nXLen = nXLen + aTextPortionList[nPortion]->GetLen(); - return nXLen == pNode->Len() ? sal_True : sal_False; + for (sal_uInt16 nPortion = 0; nPortion < rPara.aTextPortionList.Count(); nPortion++) + { + nXLen = nXLen + rPara.aTextPortionList[nPortion]->GetLen(); + } + return nXLen == rPara.pNode->Len(); } -#endif - -#endif -#if OSL_DEBUG_LEVEL > 0 void CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart) { sal_Int32 nPrev = 0; diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 0740757..5e4559c 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -647,8 +647,8 @@ public: short GetInvalidDiff() const { return nInvalidDiff; } void CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine ); -#if OSL_DEBUG_LEVEL > 2 - sal_Bool DbgCheckTextPortions(); +#if OSL_DEBUG_LEVEL > 0 + static bool DbgCheckTextPortions(ParaPortion const&); #endif }; diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index bcbe8dc..e4af131 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2386,8 +2386,8 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS } DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No Portions?!" ); -#if OSL_DEBUG_LEVEL > 2 - OSL_ENSURE( pParaPortion->DbgCheckTextPortions(), "Portion is broken?" ); +#if OSL_DEBUG_LEVEL > 0 + OSL_ENSURE( ParaPortion::DbgCheckTextPortions(*pParaPortion), "Portion is broken?" ); #endif } @@ -2502,8 +2502,8 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta } } } -#if OSL_DEBUG_LEVEL > 2 - OSL_ENSURE( pParaPortion->DbgCheckTextPortions(), "Portions are broken?" ); +#if OSL_DEBUG_LEVEL > 0 + OSL_ENSURE( ParaPortion::DbgCheckTextPortions(*pParaPortion), "Portions are broken?" ); #endif } commit 7ae2a4d68a79408c0be7d5b6cb349d0aaac38a01 Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 3 00:05:14 2014 +0100 editeng: there's yet another checking function hidden at dbglevel=3 Change-Id: Idd54bd4fd87cd138a2daf363bd692440a01e2624 diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 3db1715..c78a1b6 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -497,21 +497,20 @@ sal_Bool ParaPortion::DbgCheckTextPortions() } #endif -bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart) +#endif + +#if OSL_DEBUG_LEVEL > 0 +void CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart) { - sal_uInt16 nPrev = 0; + sal_Int32 nPrev = 0; for (size_t nAttr = 0; nAttr < rAttribs.size(); ++nAttr) { const EditCharAttrib& rAttr = rAttribs[nAttr]; - sal_uInt16 nCur = bStart ? rAttr.GetStart() : rAttr.GetEnd(); - if ( nCur < nPrev ) - return false; - + sal_Int32 const nCur = bStart ? rAttr.GetStart() : rAttr.GetEnd(); + assert(nCur >= nPrev); nPrev = nCur; } - return true; } - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 9eb25bb..13889f4 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1413,8 +1413,8 @@ void ContentNode::ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNew, SfxItemPool& mpWrongList->TextInserted( nIndex, nNew, bSep ); } -#if OSL_DEBUG_LEVEL > 2 - OSL_ENSURE( CheckOrderedList( aCharAttribList.GetAttribs(), sal_True ), "Expand: Start List distorted" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); #endif } @@ -1501,8 +1501,8 @@ void ContentNode::CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDeleted, SfxItemP if (mpWrongList) mpWrongList->TextDeleted(nIndex, nDeleted); -#if OSL_DEBUG_LEVEL > 2 - OSL_ENSURE( CheckOrderedList( aCharAttribList.GetAttribs(), sal_True ), "Collaps: Start list distorted" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); #endif } @@ -3005,6 +3005,8 @@ void CharAttribList::DbgCheckAttribs(CharAttribList const& rAttribs) assert(zero_set.insert(std::make_pair(rAttr.GetStart(), rAttr.Which())).second && "duplicate 0-length attribute detected"); } } + CheckOrderedList(rAttribs.GetAttribs(), true); +// CheckOrderedList(rAttribs.GetAttribs(), false); // this does not work - need 2nd array to sort by ends? } #endif diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 5a1d2e3..0740757 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -835,7 +835,7 @@ inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, sal_Int3 return (nAttr < (sal_Int32)rAttribs.size()) ? &rAttribs[nAttr] : NULL; } -bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart); +void CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart); // class EditEngineItemPool diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 6af9a8f..5d17194 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1297,7 +1297,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject pPortion->MarkSelectionInvalid( nStartPos, pC->GetText().getLength() ); } - DBG_ASSERT( CheckOrderedList( aPaM.GetNode()->GetCharAttribs().GetAttribs(), true ), "InsertBinTextObject: Start-Liste distorted" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aPaM.GetNode()->GetCharAttribs()); +#endif bool bParaAttribs = false; if ( bNewContent || ( ( n > 0 ) && ( n < (nContents-1) ) ) ) commit 4c21d3ac912bdb7eb013d3ee440464489a3838b7 Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 2 22:48:01 2014 +0100 editeng: convert that to assert Change-Id: I03e43d35efb813f985b93bc05c3b50c4462f9111 diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index e763cc6..9eb25bb 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -847,12 +847,12 @@ ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) void ParaPortionList::DbgCheck(ParaPortionList const& rParas, EditDoc const& rDoc) { - DBG_ASSERT( rParas.Count() == rDoc.Count(), "ParaPortionList::DbgCheck() - Count() unequal!" ); + assert(rParas.Count() == rDoc.Count()); for (sal_Int32 i = 0; i < rParas.Count(); ++i) { - DBG_ASSERT( rParas.SafeGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" ); - DBG_ASSERT( rParas.SafeGetObject(i)->GetNode(), "ParaPortionList::DbgCheck() - Null-Pointer in List(2)!" ); - DBG_ASSERT( rParas.SafeGetObject(i)->GetNode() == rDoc.GetObject(i), "ParaPortionList::DbgCheck() - Entries intersect!" ); + assert(rParas.SafeGetObject(i) != nullptr); + assert(rParas.SafeGetObject(i)->GetNode() != nullptr); + assert(rParas.SafeGetObject(i)->GetNode() == rDoc.GetObject(i)); } } #endif @@ -1560,7 +1560,9 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode ) sal_Int32 nNewStart = maString.getLength(); - OSL_ENSURE( CharAttribList::DbgCheckAttribs(aCharAttribList), "Attribute before AppendAttribs broken" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); +#endif sal_Int32 nAttr = 0; CharAttribList::AttribsType& rNextAttribs = pNextNode->GetCharAttribs().GetAttribs(); @@ -1614,7 +1616,9 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode ) // For the Attributes that just moved over: rNextAttribs.clear(); - OSL_ENSURE( CharAttribList::DbgCheckAttribs(aCharAttribList), "Attribute after AppendAttribs broken" ); +#if OSL_DEBUG_LEVEL > 0 + CharAttribList::DbgCheckAttribs(aCharAttribList); +#endif } void ContentNode::CreateDefFont() @@ -2985,32 +2989,22 @@ void CharAttribList::DeleteEmptyAttribs( SfxItemPool& rItemPool ) } #if OSL_DEBUG_LEVEL > 0 -bool CharAttribList::DbgCheckAttribs(CharAttribList const& rAttribs) +void CharAttribList::DbgCheckAttribs(CharAttribList const& rAttribs) { - bool bOK = true; AttribsType::const_iterator it = rAttribs.aAttribs.begin(); AttribsType::const_iterator itEnd = rAttribs.aAttribs.end(); std::set<std::pair<sal_Int32, sal_uInt16>> zero_set; for (; it != itEnd; ++it) { const EditCharAttrib& rAttr = *it; - if (rAttr.GetStart() > rAttr.GetEnd()) - { - bOK = false; - OSL_FAIL( "Attribute is distorted" ); - } - if (rAttr.IsFeature() && rAttr.GetLen() != 1) - { - bOK = false; - OSL_FAIL( "Feature, Len != 1" ); - } + assert(rAttr.GetStart() <= rAttr.GetEnd()); + assert(!rAttr.IsFeature() || rAttr.GetLen() == 1); if (0 == rAttr.GetLen()) { // not sure if 0-length attributes allowed at all in non-empty para? assert(zero_set.insert(std::make_pair(rAttr.GetStart(), rAttr.Which())).second && "duplicate 0-length attribute detected"); } } - return bOK; } #endif diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 1c5703b..5a1d2e3 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -230,7 +230,7 @@ public: void Release(const EditCharAttrib* p); #if OSL_DEBUG_LEVEL > 0 - static bool DbgCheckAttribs(CharAttribList const& rAttribs); + static void DbgCheckAttribs(CharAttribList const& rAttribs); #endif }; commit 54988348f847f4712d8a168a3baf2a1fc2f3d5ac Author: Michael Stahl <mst...@redhat.com> Date: Tue Dec 2 22:11:29 2014 +0100 editeng: activate some more assertions hidden behind dbglevel=3 Change-Id: I46c168946c51f1c8064f5902aa97fb0c5b7a3934 diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 15be683..e763cc6 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -843,15 +843,16 @@ ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) return 0 <= nPos && nPos < (sal_Int32)maPortions.size() ? &maPortions[nPos] : NULL; } -#if OSL_DEBUG_LEVEL > 2 -void ParaPortionList::DbgCheck( EditDoc& rDoc) +#if OSL_DEBUG_LEVEL > 0 +void +ParaPortionList::DbgCheck(ParaPortionList const& rParas, EditDoc const& rDoc) { - DBG_ASSERT( Count() == rDoc.Count(), "ParaPortionList::DbgCheck() - Count() unequal!" ); - for ( sal_Int32 i = 0; i < Count(); i++ ) + DBG_ASSERT( rParas.Count() == rDoc.Count(), "ParaPortionList::DbgCheck() - Count() unequal!" ); + for (sal_Int32 i = 0; i < rParas.Count(); ++i) { - DBG_ASSERT( SafeGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" ); - DBG_ASSERT( GetObject(i)->GetNode(), "ParaPortionList::DbgCheck() - Null-Pointer in List(2)!" ); - DBG_ASSERT( GetObject(i)->GetNode() == rDoc.GetObject(i), "ParaPortionList::DbgCheck() - Entries intersect!" ); + DBG_ASSERT( rParas.SafeGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" ); + DBG_ASSERT( rParas.SafeGetObject(i)->GetNode(), "ParaPortionList::DbgCheck() - Null-Pointer in List(2)!" ); + DBG_ASSERT( rParas.SafeGetObject(i)->GetNode() == rDoc.GetObject(i), "ParaPortionList::DbgCheck() - Entries intersect!" ); } } #endif diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 7cbbd43..1c5703b 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -680,9 +680,9 @@ public: void Append(ParaPortion* p); sal_Int32 Count() const; -#if OSL_DEBUG_LEVEL > 2 +#if OSL_DEBUG_LEVEL > 0 // temporary: - void DbgCheck( EditDoc& rDoc ); + static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc); #endif }; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 3f030d1..cf226c1 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2176,8 +2176,8 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n while( aTmpPortionList.Count() > 0 ) aTmpPortionList.Release( aTmpPortionList.Count() - 1 ); -#if OSL_DEBUG_LEVEL > 2 - GetParaPortions().DbgCheck(aEditDoc); +#if OSL_DEBUG_LEVEL > 0 + ParaPortionList::DbgCheck(GetParaPortions(), aEditDoc); #endif return aSelection; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits